calcite-list_3.entry.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { r as registerInstance, h, H as Host, g as getElement } from './index-1f9b54dc.js';
  7. import { u as updateHostInteraction } from './interactive-5db230e8.js';
  8. import { g as getSlotted } from './dom-8f0a9ff2.js';
  9. import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-a3e8c63a.js';
  10. import { H as Heading, c as constrainHeadingLevel } from './Heading-e0abf8a2.js';
  11. import './resources-9c476cb6.js';
  12. import './guid-9f15e57a.js';
  13. import './observers-9f44e9b3.js';
  14. const CSS$2 = {
  15. container: "container"
  16. };
  17. const listCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:block}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{box-sizing:border-box;display:flex;inline-size:100%;flex-direction:column;background-color:transparent}.container *{box-sizing:border-box}::slotted(calcite-list-item){margin-block-end:1px;--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}::slotted(calcite-list-item:last-child){--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}";
  18. const List = class {
  19. constructor(hostRef) {
  20. registerInstance(this, hostRef);
  21. // --------------------------------------------------------------------------
  22. //
  23. // Properties
  24. //
  25. // --------------------------------------------------------------------------
  26. /**
  27. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  28. */
  29. this.disabled = false;
  30. }
  31. //--------------------------------------------------------------------------
  32. //
  33. // Lifecycle
  34. //
  35. //--------------------------------------------------------------------------
  36. componentDidRender() {
  37. updateHostInteraction(this);
  38. }
  39. // --------------------------------------------------------------------------
  40. //
  41. // Public Methods
  42. //
  43. // --------------------------------------------------------------------------
  44. /** Sets focus on the component. */
  45. async setFocus() {
  46. const firstListItem = this.el.querySelector(`calcite-list-item:not([non-interactive])`);
  47. firstListItem === null || firstListItem === void 0 ? void 0 : firstListItem.setFocus();
  48. }
  49. // --------------------------------------------------------------------------
  50. //
  51. // Render Methods
  52. //
  53. // --------------------------------------------------------------------------
  54. render() {
  55. return (h(Host, { role: "list" }, h("div", { class: CSS$2.container }, h("slot", null))));
  56. }
  57. get el() { return getElement(this); }
  58. };
  59. List.style = listCss;
  60. const CSS$1 = {
  61. container: "container",
  62. contentContainer: "content-container",
  63. nestedContainer: "nested-container",
  64. contentContainerButton: "content-container--button",
  65. content: "content",
  66. actionsStart: "actions-start",
  67. contentStart: "content-start",
  68. label: "label",
  69. description: "description",
  70. contentEnd: "content-end",
  71. actionsEnd: "actions-end",
  72. hasCenterContent: "has-center-content"
  73. };
  74. const SLOTS = {
  75. actionsStart: "actions-start",
  76. contentStart: "content-start",
  77. contentEnd: "content-end",
  78. actionsEnd: "actions-end"
  79. };
  80. const listItemCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:flex;flex-direction:column}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.container{box-sizing:border-box;display:flex;flex:1 1 0%;background-color:var(--calcite-ui-foreground-1);font-family:var(--calcite-sans-family)}.container *{box-sizing:border-box}.nested-container{display:flex;flex-direction:column;background-color:var(--calcite-ui-foreground-1)}.content-container{display:flex;flex:1 1 auto;align-items:stretch;padding:0px;font-family:var(--calcite-sans-family);font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2);outline-color:transparent}.content-container--button{cursor:pointer;border-style:none;background-color:var(--calcite-ui-foreground-1);outline-color:transparent;text-align:initial}.content-container--button:hover{background-color:var(--calcite-ui-foreground-2)}.content-container--button:hover .label,.content-container--button:hover .description{color:var(--calcite-ui-text-1)}.content-container--button:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.content-container--button .content-start,.content-container--button .content-end{pointer-events:none}.content{display:flex;flex:1 1 auto;flex-direction:column;justify-content:center;padding-inline:0.75rem;padding-block:0.5rem;font-size:var(--calcite-font-size--2);line-height:1.375}.label,.description{font-family:var(--calcite-sans-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal);word-wrap:break-word;word-break:break-word}.label:only-child,.description:only-child{margin:0px;padding-block:0.25rem}.label{color:var(--calcite-ui-text-1)}.description{margin-block-start:0.125rem;color:var(--calcite-ui-text-3)}.content-start{justify-content:flex-start}.content-end{justify-content:flex-end}.content-start,.content-end{flex:1 1 auto}.has-center-content .content-start,.has-center-content .content-end{flex:0 1 auto}.actions-start,.actions-end,.content-start,.content-end{display:flex;align-items:center}.content-start ::slotted(calcite-icon),.content-end ::slotted(calcite-icon){margin-inline:0.75rem;align-self:center}.actions-start ::slotted(calcite-action),.actions-end ::slotted(calcite-action){align-self:stretch;color:inherit}::slotted(calcite-list-item-group),::slotted(calcite-list-item){padding-inline-start:0.5rem}";
  81. const ListItem = class {
  82. constructor(hostRef) {
  83. registerInstance(this, hostRef);
  84. // --------------------------------------------------------------------------
  85. //
  86. // Properties
  87. //
  88. // --------------------------------------------------------------------------
  89. /**
  90. * When `true`, prevents the content of the component from user interaction.
  91. */
  92. this.nonInteractive = false;
  93. /**
  94. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  95. */
  96. this.disabled = false;
  97. }
  98. //--------------------------------------------------------------------------
  99. //
  100. // Lifecycle
  101. //
  102. //--------------------------------------------------------------------------
  103. componentDidRender() {
  104. updateHostInteraction(this);
  105. }
  106. // --------------------------------------------------------------------------
  107. //
  108. // Lifecycle
  109. //
  110. // --------------------------------------------------------------------------
  111. connectedCallback() {
  112. connectConditionalSlotComponent(this);
  113. }
  114. disconnectedCallback() {
  115. disconnectConditionalSlotComponent(this);
  116. }
  117. // --------------------------------------------------------------------------
  118. //
  119. // Public Methods
  120. //
  121. // --------------------------------------------------------------------------
  122. /** Sets focus on the component. */
  123. async setFocus() {
  124. var _a;
  125. (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
  126. }
  127. // --------------------------------------------------------------------------
  128. //
  129. // Render Methods
  130. //
  131. // --------------------------------------------------------------------------
  132. renderActionsStart() {
  133. const { el } = this;
  134. return getSlotted(el, SLOTS.actionsStart) ? (h("div", { class: CSS$1.actionsStart }, h("slot", { name: SLOTS.actionsStart }))) : null;
  135. }
  136. renderActionsEnd() {
  137. const { el } = this;
  138. return getSlotted(el, SLOTS.actionsEnd) ? (h("div", { class: CSS$1.actionsEnd }, h("slot", { name: SLOTS.actionsEnd }))) : null;
  139. }
  140. renderContentStart() {
  141. const { el } = this;
  142. return getSlotted(el, SLOTS.contentStart) ? (h("div", { class: CSS$1.contentStart }, h("slot", { name: SLOTS.contentStart }))) : null;
  143. }
  144. renderContentEnd() {
  145. const { el } = this;
  146. return getSlotted(el, SLOTS.contentEnd) ? (h("div", { class: CSS$1.contentEnd }, h("slot", { name: SLOTS.contentEnd }))) : null;
  147. }
  148. renderContent() {
  149. const { label, description } = this;
  150. return !!label || !!description ? (h("div", { class: CSS$1.content }, label ? h("div", { class: CSS$1.label }, label) : null, description ? h("div", { class: CSS$1.description }, description) : null)) : null;
  151. }
  152. renderContentContainer() {
  153. const { description, disabled, label, nonInteractive } = this;
  154. const hasCenterContent = !!label || !!description;
  155. const content = [this.renderContentStart(), this.renderContent(), this.renderContentEnd()];
  156. return !nonInteractive ? (h("button", { class: {
  157. [CSS$1.contentContainer]: true,
  158. [CSS$1.contentContainerButton]: true,
  159. [CSS$1.hasCenterContent]: hasCenterContent
  160. }, disabled: disabled, ref: (focusEl) => (this.focusEl = focusEl) }, content)) : (h("div", { class: { [CSS$1.contentContainer]: true, [CSS$1.hasCenterContent]: hasCenterContent }, ref: () => (this.focusEl = null) }, content));
  161. }
  162. render() {
  163. return (h(Host, { role: "listitem" }, h("div", { class: CSS$1.container }, this.renderActionsStart(), this.renderContentContainer(), this.renderActionsEnd()), h("div", { class: CSS$1.nestedContainer }, h("slot", null))));
  164. }
  165. get el() { return getElement(this); }
  166. };
  167. ListItem.style = listItemCss;
  168. const CSS = {
  169. heading: "heading",
  170. container: "container"
  171. };
  172. const HEADING_LEVEL = 3;
  173. const listItemGroupCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:flex;flex-direction:column}.heading{margin:0px;display:flex;flex:1 1 0%;background-color:var(--calcite-ui-foreground-2);padding:0.75rem;font-family:var(--calcite-sans-family);font-size:var(--calcite-font-size--1);font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-2)}.container{display:flex;inline-size:100%;flex-direction:column;background-color:var(--calcite-ui-foreground-1)}::slotted(calcite-list-item-group){padding-inline-start:0.5rem}";
  174. const ListItemGroup = class {
  175. constructor(hostRef) {
  176. registerInstance(this, hostRef);
  177. }
  178. // --------------------------------------------------------------------------
  179. //
  180. // Render Methods
  181. //
  182. // --------------------------------------------------------------------------
  183. render() {
  184. var _a;
  185. const { el, heading, headingLevel } = this;
  186. const parentLevel = (_a = el.closest("calcite-list, calcite-list-item-group")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  187. const relativeLevel = parentLevel ? constrainHeadingLevel(parentLevel + 1) : null;
  188. const level = headingLevel || relativeLevel || HEADING_LEVEL;
  189. return (h(Host, null, heading ? (h(Heading, { class: CSS.heading, level: level }, heading)) : null, h("div", { class: CSS.container, role: "group" }, h("slot", null))));
  190. }
  191. get el() { return getElement(this); }
  192. };
  193. ListItemGroup.style = listItemGroupCss;
  194. export { List as calcite_list, ListItem as calcite_list_item, ListItemGroup as calcite_list_item_group };