calcite-list_3.entry.js 19 KB

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