calcite-list_3.cjs.entry.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. const index = require('./index-a0010f96.js');
  9. const interactive = require('./interactive-32293bca.js');
  10. const dom = require('./dom-2ec8c9ed.js');
  11. const conditionalSlot = require('./conditionalSlot-ef852d9d.js');
  12. const Heading = require('./Heading-1e87a15f.js');
  13. require('./resources-b5a5f8a7.js');
  14. require('./guid-f4f03a7a.js');
  15. require('./observers-5706326b.js');
  16. const CSS$2 = {
  17. container: "container"
  18. };
  19. 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)}";
  20. const List = class {
  21. constructor(hostRef) {
  22. index.registerInstance(this, hostRef);
  23. // --------------------------------------------------------------------------
  24. //
  25. // Properties
  26. //
  27. // --------------------------------------------------------------------------
  28. /**
  29. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  30. */
  31. this.disabled = false;
  32. }
  33. //--------------------------------------------------------------------------
  34. //
  35. // Lifecycle
  36. //
  37. //--------------------------------------------------------------------------
  38. componentDidRender() {
  39. interactive.updateHostInteraction(this);
  40. }
  41. // --------------------------------------------------------------------------
  42. //
  43. // Public Methods
  44. //
  45. // --------------------------------------------------------------------------
  46. /** Sets focus on the component. */
  47. async setFocus() {
  48. const firstListItem = this.el.querySelector(`calcite-list-item:not([non-interactive])`);
  49. firstListItem === null || firstListItem === void 0 ? void 0 : firstListItem.setFocus();
  50. }
  51. // --------------------------------------------------------------------------
  52. //
  53. // Render Methods
  54. //
  55. // --------------------------------------------------------------------------
  56. render() {
  57. return (index.h(index.Host, { role: "list" }, index.h("div", { class: CSS$2.container }, index.h("slot", null))));
  58. }
  59. get el() { return index.getElement(this); }
  60. };
  61. List.style = listCss;
  62. const CSS$1 = {
  63. container: "container",
  64. contentContainer: "content-container",
  65. nestedContainer: "nested-container",
  66. contentContainerButton: "content-container--button",
  67. content: "content",
  68. actionsStart: "actions-start",
  69. contentStart: "content-start",
  70. label: "label",
  71. description: "description",
  72. contentEnd: "content-end",
  73. actionsEnd: "actions-end",
  74. hasCenterContent: "has-center-content"
  75. };
  76. const SLOTS = {
  77. actionsStart: "actions-start",
  78. contentStart: "content-start",
  79. contentEnd: "content-end",
  80. actionsEnd: "actions-end"
  81. };
  82. 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}";
  83. const ListItem = class {
  84. constructor(hostRef) {
  85. index.registerInstance(this, hostRef);
  86. // --------------------------------------------------------------------------
  87. //
  88. // Properties
  89. //
  90. // --------------------------------------------------------------------------
  91. /**
  92. * When `true`, prevents the content of the component from user interaction.
  93. */
  94. this.nonInteractive = false;
  95. /**
  96. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  97. */
  98. this.disabled = false;
  99. }
  100. //--------------------------------------------------------------------------
  101. //
  102. // Lifecycle
  103. //
  104. //--------------------------------------------------------------------------
  105. componentDidRender() {
  106. interactive.updateHostInteraction(this);
  107. }
  108. // --------------------------------------------------------------------------
  109. //
  110. // Lifecycle
  111. //
  112. // --------------------------------------------------------------------------
  113. connectedCallback() {
  114. conditionalSlot.connectConditionalSlotComponent(this);
  115. }
  116. disconnectedCallback() {
  117. conditionalSlot.disconnectConditionalSlotComponent(this);
  118. }
  119. // --------------------------------------------------------------------------
  120. //
  121. // Public Methods
  122. //
  123. // --------------------------------------------------------------------------
  124. /** Sets focus on the component. */
  125. async setFocus() {
  126. var _a;
  127. (_a = this.focusEl) === null || _a === void 0 ? void 0 : _a.focus();
  128. }
  129. // --------------------------------------------------------------------------
  130. //
  131. // Render Methods
  132. //
  133. // --------------------------------------------------------------------------
  134. renderActionsStart() {
  135. const { el } = this;
  136. return dom.getSlotted(el, SLOTS.actionsStart) ? (index.h("div", { class: CSS$1.actionsStart }, index.h("slot", { name: SLOTS.actionsStart }))) : null;
  137. }
  138. renderActionsEnd() {
  139. const { el } = this;
  140. return dom.getSlotted(el, SLOTS.actionsEnd) ? (index.h("div", { class: CSS$1.actionsEnd }, index.h("slot", { name: SLOTS.actionsEnd }))) : null;
  141. }
  142. renderContentStart() {
  143. const { el } = this;
  144. return dom.getSlotted(el, SLOTS.contentStart) ? (index.h("div", { class: CSS$1.contentStart }, index.h("slot", { name: SLOTS.contentStart }))) : null;
  145. }
  146. renderContentEnd() {
  147. const { el } = this;
  148. return dom.getSlotted(el, SLOTS.contentEnd) ? (index.h("div", { class: CSS$1.contentEnd }, index.h("slot", { name: SLOTS.contentEnd }))) : null;
  149. }
  150. renderContent() {
  151. const { label, description } = this;
  152. return !!label || !!description ? (index.h("div", { class: CSS$1.content }, label ? index.h("div", { class: CSS$1.label }, label) : null, description ? index.h("div", { class: CSS$1.description }, description) : null)) : null;
  153. }
  154. renderContentContainer() {
  155. const { description, disabled, label, nonInteractive } = this;
  156. const hasCenterContent = !!label || !!description;
  157. const content = [this.renderContentStart(), this.renderContent(), this.renderContentEnd()];
  158. return !nonInteractive ? (index.h("button", { class: {
  159. [CSS$1.contentContainer]: true,
  160. [CSS$1.contentContainerButton]: true,
  161. [CSS$1.hasCenterContent]: hasCenterContent
  162. }, disabled: disabled, ref: (focusEl) => (this.focusEl = focusEl) }, content)) : (index.h("div", { class: { [CSS$1.contentContainer]: true, [CSS$1.hasCenterContent]: hasCenterContent }, ref: () => (this.focusEl = null) }, content));
  163. }
  164. render() {
  165. return (index.h(index.Host, { role: "listitem" }, index.h("div", { class: CSS$1.container }, this.renderActionsStart(), this.renderContentContainer(), this.renderActionsEnd()), index.h("div", { class: CSS$1.nestedContainer }, index.h("slot", null))));
  166. }
  167. get el() { return index.getElement(this); }
  168. };
  169. ListItem.style = listItemCss;
  170. const CSS = {
  171. heading: "heading",
  172. container: "container"
  173. };
  174. const HEADING_LEVEL = 3;
  175. 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}";
  176. const ListItemGroup = class {
  177. constructor(hostRef) {
  178. index.registerInstance(this, hostRef);
  179. }
  180. // --------------------------------------------------------------------------
  181. //
  182. // Render Methods
  183. //
  184. // --------------------------------------------------------------------------
  185. render() {
  186. var _a;
  187. const { el, heading, headingLevel } = this;
  188. const parentLevel = (_a = el.closest("calcite-list, calcite-list-item-group")) === null || _a === void 0 ? void 0 : _a.headingLevel;
  189. const relativeLevel = parentLevel ? Heading.constrainHeadingLevel(parentLevel + 1) : null;
  190. const level = headingLevel || relativeLevel || HEADING_LEVEL;
  191. return (index.h(index.Host, null, heading ? (index.h(Heading.Heading, { class: CSS.heading, level: level }, heading)) : null, index.h("div", { class: CSS.container, role: "group" }, index.h("slot", null))));
  192. }
  193. get el() { return index.getElement(this); }
  194. };
  195. ListItemGroup.style = listItemGroupCss;
  196. exports.calcite_list = List;
  197. exports.calcite_list_item = ListItem;
  198. exports.calcite_list_item_group = ListItemGroup;