calcite-block_2.entry.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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, c as createEvent, h, H as Host, g as getElement } from './index-8ece2564.js';
  7. import { g as getSlotted, t as toAriaBoolean, a as getElementDir } from './dom-da697a3f.js';
  8. import { H as Heading } from './Heading-8d613e81.js';
  9. import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-203be745.js';
  10. import { u as updateHostInteraction } from './interactive-cb5bf285.js';
  11. import { g as guid } from './guid-b4461004.js';
  12. import './observers-b198f831.js';
  13. const CSS$1 = {
  14. article: "article",
  15. content: "content",
  16. headerContainer: "header-container",
  17. icon: "icon",
  18. statusIcon: "status-icon",
  19. toggle: "toggle",
  20. toggleIcon: "toggle-icon",
  21. title: "title",
  22. heading: "heading",
  23. header: "header",
  24. button: "button",
  25. summary: "summary",
  26. controlContainer: "control-container",
  27. valid: "valid",
  28. invalid: "invalid",
  29. loading: "loading"
  30. };
  31. const TEXT$1 = {
  32. collapse: "Collapse",
  33. expand: "Expand",
  34. loading: "Loading",
  35. options: "Options"
  36. };
  37. const SLOTS = {
  38. icon: "icon",
  39. control: "control",
  40. headerMenuActions: "header-menu-actions"
  41. };
  42. const ICONS$1 = {
  43. opened: "chevron-up",
  44. closed: "chevron-down",
  45. valid: "check-circle",
  46. invalid: "exclamation-mark-triangle",
  47. refresh: "refresh"
  48. };
  49. const HEADING_LEVEL = 4;
  50. const blockCss = "@-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}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host{--calcite-icon-size:1rem;--calcite-spacing-eighth:0.125rem;--calcite-spacing-quarter:0.25rem;--calcite-spacing-half:0.5rem;--calcite-spacing-three-quarters:0.75rem;--calcite-spacing:1rem;--calcite-spacing-plus-quarter:1.25rem;--calcite-spacing-plus-half:1.5rem;--calcite-spacing-double:2rem;--calcite-menu-min-width:10rem;--calcite-header-min-height:3rem;--calcite-footer-min-height:3rem}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-negative:0;flex-shrink:0;-ms-flex-positive:0;flex-grow:0;-ms-flex-direction:column;flex-direction:column;border-width:0px;border-bottom-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding:0px;-webkit-transition-property:margin;transition-property:margin;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.215, 0.440, 0.420, 0.880);transition-timing-function:cubic-bezier(0.215, 0.440, 0.420, 0.880);-ms-flex-preferred-size:auto;flex-basis:auto}: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}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.header{-ms-flex-pack:start;justify-content:flex-start;padding:0px}.header,.toggle{grid-area:header}.header-container{display:grid;-ms-flex-align:stretch;align-items:stretch;grid-template:auto/auto 1fr auto auto;grid-template-areas:\"handle header control menu\";grid-column:header-start/menu-end;grid-row:1/2}.toggle{margin:0px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;border-style:none;padding:0px;font-family:inherit;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;background-color:transparent}.toggle:hover{background-color:var(--calcite-ui-foreground-2)}.toggle:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}calcite-loader[inline]{grid-area:control;align-self:center}calcite-handle{grid-area:handle}.title{margin:0px;padding:0.75rem}.header .title .heading{padding:0px;font-size:var(--calcite-font-size--1);font-weight:var(--calcite-font-weight-medium);line-height:1.25;color:var(--calcite-ui-text-2);-webkit-transition-property:color;transition-property:color;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);word-wrap:break-word;word-break:break-word}.summary{margin-top:0.125rem;padding:0px;font-size:var(--calcite-font-size--2);color:var(--calcite-ui-text-3);word-wrap:break-word;word-break:break-word}.icon{-webkit-margin-start:0.75rem;margin-inline-start:0.75rem;-webkit-margin-end:0px;margin-inline-end:0px;margin-block:0.75rem}.status-icon.valid{color:var(--calcite-ui-success)}.status-icon.invalid{color:var(--calcite-ui-danger)}.status-icon.loading{-webkit-animation:spin 2s linear infinite;animation:spin 2s linear infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.toggle-icon{margin-top:0.75rem;margin-bottom:0.75rem;-ms-flex-item-align:center;align-self:center;justify-self:end;color:var(--calcite-ui-text-3);-webkit-transition-property:color;transition-property:color;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:1rem;margin-inline-end:1rem;-webkit-margin-start:auto;margin-inline-start:auto}.toggle:hover .toggle-icon{color:var(--calcite-ui-text-1)}.content{position:relative}@keyframes in{0%{opacity:0}100%{opacity:1}}.content{-webkit-animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.5rem;padding-bottom:0.5rem}.control-container{margin:0px;display:-ms-flexbox;display:flex;grid-area:control}calcite-action-menu{grid-area:menu}:host([open]){margin-top:0.5rem;margin-bottom:0.5rem}:host([open]) .header .title .heading{color:var(--calcite-ui-text-1)}";
  51. const Block = class {
  52. constructor(hostRef) {
  53. registerInstance(this, hostRef);
  54. this.calciteBlockToggle = createEvent(this, "calciteBlockToggle", 7);
  55. // --------------------------------------------------------------------------
  56. //
  57. // Properties
  58. //
  59. // --------------------------------------------------------------------------
  60. /**
  61. * When true, this block will be collapsible.
  62. */
  63. this.collapsible = false;
  64. /**
  65. * When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
  66. */
  67. this.disabled = false;
  68. /**
  69. * When true, displays a drag handle in the header.
  70. */
  71. this.dragHandle = false;
  72. /**
  73. * Aria-label for collapsing the toggle and tooltip used for the toggle when expanded.
  74. */
  75. this.intlCollapse = TEXT$1.collapse;
  76. /**
  77. * Aria-label for expanding the toggle and tooltip used for the toggle when collapsed.
  78. */
  79. this.intlExpand = TEXT$1.expand;
  80. /** string to override English loading text
  81. * @default "Loading"
  82. */
  83. this.intlLoading = TEXT$1.loading;
  84. /** Text string used for the actions menu
  85. * @default "Options"
  86. */
  87. this.intlOptions = TEXT$1.options;
  88. /**
  89. * When true, content is waiting to be loaded. This state shows a busy indicator.
  90. */
  91. this.loading = false;
  92. /**
  93. * When true, the block's content will be displayed.
  94. */
  95. this.open = false;
  96. this.guid = guid();
  97. // --------------------------------------------------------------------------
  98. //
  99. // Private Methods
  100. //
  101. // --------------------------------------------------------------------------
  102. this.onHeaderClick = () => {
  103. this.open = !this.open;
  104. this.calciteBlockToggle.emit();
  105. };
  106. }
  107. //--------------------------------------------------------------------------
  108. //
  109. // Lifecycle
  110. //
  111. //--------------------------------------------------------------------------
  112. componentDidRender() {
  113. updateHostInteraction(this);
  114. }
  115. // --------------------------------------------------------------------------
  116. //
  117. // Lifecycle
  118. //
  119. // --------------------------------------------------------------------------
  120. connectedCallback() {
  121. connectConditionalSlotComponent(this);
  122. }
  123. disconnectedCallback() {
  124. disconnectConditionalSlotComponent(this);
  125. }
  126. // --------------------------------------------------------------------------
  127. //
  128. // Render Methods
  129. //
  130. // --------------------------------------------------------------------------
  131. renderScrim() {
  132. const { loading } = this;
  133. const defaultSlot = h("slot", null);
  134. return [loading ? h("calcite-scrim", { loading: loading }) : null, defaultSlot];
  135. }
  136. renderIcon() {
  137. const { el, status } = this;
  138. const showingLoadingStatus = this.loading && !this.open;
  139. const statusIcon = showingLoadingStatus ? ICONS$1.refresh : ICONS$1[status];
  140. const hasIcon = getSlotted(el, SLOTS.icon) || statusIcon;
  141. const iconEl = !statusIcon ? (h("slot", { key: "icon-slot", name: SLOTS.icon })) : (h("calcite-icon", { class: {
  142. [CSS$1.statusIcon]: true,
  143. [CSS$1.valid]: status == "valid",
  144. [CSS$1.invalid]: status == "invalid",
  145. [CSS$1.loading]: showingLoadingStatus
  146. }, icon: statusIcon, scale: "m" }));
  147. return hasIcon ? h("div", { class: CSS$1.icon }, iconEl) : null;
  148. }
  149. renderTitle() {
  150. const { heading, headingLevel, summary } = this;
  151. return heading || summary ? (h("div", { class: CSS$1.title }, h(Heading, { class: CSS$1.heading, level: headingLevel || HEADING_LEVEL }, heading), summary ? h("div", { class: CSS$1.summary }, summary) : null)) : null;
  152. }
  153. render() {
  154. const { collapsible, el, intlCollapse, intlExpand, loading, open, intlLoading } = this;
  155. const toggleLabel = open ? intlCollapse || TEXT$1.collapse : intlExpand || TEXT$1.expand;
  156. const headerContent = (h("header", { class: CSS$1.header }, this.renderIcon(), this.renderTitle()));
  157. const hasControl = !!getSlotted(el, SLOTS.control);
  158. const hasMenuActions = !!getSlotted(el, SLOTS.headerMenuActions);
  159. const collapseIcon = open ? ICONS$1.opened : ICONS$1.closed;
  160. const { guid } = this;
  161. const regionId = `${guid}-region`;
  162. const buttonId = `${guid}-button`;
  163. const headerNode = (h("div", { class: CSS$1.headerContainer }, this.dragHandle ? h("calcite-handle", null) : null, collapsible ? (h("button", { "aria-controls": regionId, "aria-expanded": collapsible ? toAriaBoolean(open) : null, "aria-label": toggleLabel, class: CSS$1.toggle, id: buttonId, onClick: this.onHeaderClick, title: toggleLabel }, headerContent, !hasControl && !hasMenuActions ? (h("calcite-icon", { "aria-hidden": "true", class: CSS$1.toggleIcon, icon: collapseIcon, scale: "s" })) : null)) : (headerContent), loading ? (h("calcite-loader", { inline: true, "is-active": true, label: intlLoading })) : hasControl ? (h("div", { class: CSS$1.controlContainer }, h("slot", { name: SLOTS.control }))) : null, hasMenuActions ? (h("calcite-action-menu", { label: this.intlOptions || TEXT$1.options }, h("slot", { name: SLOTS.headerMenuActions }))) : null));
  164. return (h(Host, null, h("article", { "aria-busy": toAriaBoolean(loading), class: {
  165. [CSS$1.article]: true
  166. } }, headerNode, h("section", { "aria-expanded": toAriaBoolean(open), "aria-labelledby": buttonId, class: CSS$1.content, hidden: !open, id: regionId }, this.renderScrim()))));
  167. }
  168. get el() { return getElement(this); }
  169. };
  170. Block.style = blockCss;
  171. const CSS = {
  172. content: "content",
  173. invalid: "invalid",
  174. toggle: "toggle",
  175. toggleSwitch: "toggle--switch",
  176. toggleSwitchContent: "toggle--switch__content",
  177. toggleSwitchText: "toggle--switch__text",
  178. sectionHeader: "section-header",
  179. sectionHeaderText: "section-header__text",
  180. statusIcon: "status-icon",
  181. valid: "valid"
  182. };
  183. const TEXT = {
  184. collapse: "Collapse",
  185. expand: "Expand"
  186. };
  187. const ICONS = {
  188. menuOpen: "chevron-down",
  189. menuClosedLeft: "chevron-left",
  190. menuClosedRight: "chevron-right",
  191. valid: "check-circle",
  192. invalid: "exclamation-mark-triangle"
  193. };
  194. const blockSectionCss = "@-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{-webkit-box-sizing:border-box;box-sizing:border-box;display:block;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}:host([open]){border-width:0px;border-bottom-width:1px;border-style:solid;border-bottom-color:var(--calcite-ui-border-3)}:host(:last-child){border-bottom-width:0px}.toggle{width:100%;border-width:0px;background-color:transparent;font-family:var(--calcite-sans-family);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}.toggle--switch,.section-header{margin-left:0px;margin-right:0px;margin-top:0.25rem;margin-bottom:0.25rem;display:-ms-flexbox;display:flex;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-align:center;align-items:center;padding-left:0px;padding-right:0px;padding-top:0.5rem;padding-bottom:0.5rem;font-size:var(--calcite-font-size--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}.toggle--switch:focus,.section-header:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.toggle--switch:hover,.section-header:hover{color:var(--calcite-ui-text-1)}.section-header .status-icon{-ms-flex-item-align:end;align-self:flex-end}.section-header__text{margin-left:0.75rem;margin-right:0.75rem;margin-top:0px;margin-bottom:0px;-ms-flex:1 1 auto;flex:1 1 auto;text-align:initial;word-wrap:anywhere}.toggle--switch calcite-switch{pointer-events:none;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.toggle--switch .status-icon{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}.toggle--switch__content{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-align:center;align-items:center}.status-icon.valid{color:var(--calcite-ui-success)}.status-icon.invalid{color:var(--calcite-ui-danger)}";
  195. const BlockSection = class {
  196. constructor(hostRef) {
  197. registerInstance(this, hostRef);
  198. this.calciteBlockSectionToggle = createEvent(this, "calciteBlockSectionToggle", 7);
  199. /**
  200. * When true, the block's section content will be displayed.
  201. */
  202. this.open = false;
  203. /**
  204. * This property determines the look of the section toggle.
  205. * If the value is "switch", a toggle-switch will be displayed.
  206. * If the value is "button", a clickable header is displayed.
  207. */
  208. this.toggleDisplay = "button";
  209. this.guid = guid();
  210. // --------------------------------------------------------------------------
  211. //
  212. // Private Methods
  213. //
  214. // --------------------------------------------------------------------------
  215. this.handleHeaderKeyDown = (event) => {
  216. if (event.key === " " || event.key === "Enter") {
  217. this.toggleSection();
  218. event.preventDefault();
  219. event.stopPropagation();
  220. }
  221. };
  222. this.toggleSection = () => {
  223. this.open = !this.open;
  224. this.calciteBlockSectionToggle.emit();
  225. };
  226. }
  227. // --------------------------------------------------------------------------
  228. //
  229. // Render Methods
  230. //
  231. // --------------------------------------------------------------------------
  232. renderStatusIcon() {
  233. var _a;
  234. const { status } = this;
  235. const statusIcon = (_a = ICONS[status]) !== null && _a !== void 0 ? _a : false;
  236. const statusIconClasses = {
  237. [CSS.statusIcon]: true,
  238. [CSS.valid]: status == "valid",
  239. [CSS.invalid]: status == "invalid"
  240. };
  241. return !!statusIcon ? (h("calcite-icon", { class: statusIconClasses, icon: statusIcon, scale: "s" })) : null;
  242. }
  243. render() {
  244. const { el, intlCollapse, intlExpand, open, text, toggleDisplay } = this;
  245. const dir = getElementDir(el);
  246. const arrowIcon = open
  247. ? ICONS.menuOpen
  248. : dir === "rtl"
  249. ? ICONS.menuClosedLeft
  250. : ICONS.menuClosedRight;
  251. const toggleLabel = open ? intlCollapse || TEXT.collapse : intlExpand || TEXT.expand;
  252. const { guid } = this;
  253. const regionId = `${guid}-region`;
  254. const buttonId = `${guid}-button`;
  255. const headerNode = toggleDisplay === "switch" ? (h("div", { "aria-controls": regionId, "aria-label": toggleLabel, class: {
  256. [CSS.toggle]: true,
  257. [CSS.toggleSwitch]: true
  258. }, id: buttonId, onClick: this.toggleSection, onKeyDown: this.handleHeaderKeyDown, tabIndex: 0, title: toggleLabel }, h("div", { class: CSS.toggleSwitchContent }, h("span", { class: CSS.toggleSwitchText }, text)), h("calcite-switch", { checked: open, label: toggleLabel, scale: "s", tabIndex: -1 }), this.renderStatusIcon())) : (h("button", { "aria-controls": regionId, "aria-label": toggleLabel, class: {
  259. [CSS.sectionHeader]: true,
  260. [CSS.toggle]: true
  261. }, id: buttonId, name: toggleLabel, onClick: this.toggleSection }, h("calcite-icon", { icon: arrowIcon, scale: "s" }), h("span", { class: CSS.sectionHeaderText }, text), this.renderStatusIcon()));
  262. return (h(Host, null, headerNode, h("section", { "aria-expanded": toAriaBoolean(open), "aria-labelledby": buttonId, class: CSS.content, hidden: !open, id: regionId }, h("slot", null))));
  263. }
  264. get el() { return getElement(this); }
  265. };
  266. BlockSection.style = blockSectionCss;
  267. export { Block as calcite_block, BlockSection as calcite_block_section };