@zanichelli/albe-web-components 18.0.1 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/z-app-header_12.cjs.entry.js +1 -1
  3. package/dist/cjs/z-app-header_12.cjs.entry.js.map +1 -1
  4. package/dist/cjs/z-menu-section.cjs.entry.js +2 -2
  5. package/dist/cjs/z-menu-section.cjs.entry.js.map +1 -1
  6. package/dist/cjs/z-menu.cjs.entry.js +1 -1
  7. package/dist/cjs/z-menu.cjs.entry.js.map +1 -1
  8. package/dist/cjs/z-toast-notification.cjs.entry.js +3 -3
  9. package/dist/cjs/z-toast-notification.cjs.entry.js.map +1 -1
  10. package/dist/collection/components/z-button/styles.css +4 -4
  11. package/dist/collection/components/z-menu/index.js +1 -1
  12. package/dist/collection/components/z-menu/index.js.map +1 -1
  13. package/dist/collection/components/z-menu/styles.css +3 -1
  14. package/dist/collection/components/z-menu-section/index.js +2 -2
  15. package/dist/collection/components/z-menu-section/index.js.map +1 -1
  16. package/dist/collection/components/z-menu-section/styles.css +3 -1
  17. package/dist/collection/components/z-toast-notification/index.js +2 -2
  18. package/dist/collection/components/z-toast-notification/index.js.map +1 -1
  19. package/dist/collection/components/z-toast-notification/styles.css +5 -3
  20. package/dist/components/index4.js +1 -1
  21. package/dist/components/index4.js.map +1 -1
  22. package/dist/components/z-menu-section.js +2 -2
  23. package/dist/components/z-menu-section.js.map +1 -1
  24. package/dist/components/z-menu.js +1 -1
  25. package/dist/components/z-menu.js.map +1 -1
  26. package/dist/components/z-toast-notification.js +3 -3
  27. package/dist/components/z-toast-notification.js.map +1 -1
  28. package/dist/esm/z-app-header_12.entry.js +1 -1
  29. package/dist/esm/z-app-header_12.entry.js.map +1 -1
  30. package/dist/esm/z-menu-section.entry.js +2 -2
  31. package/dist/esm/z-menu-section.entry.js.map +1 -1
  32. package/dist/esm/z-menu.entry.js +1 -1
  33. package/dist/esm/z-menu.entry.js.map +1 -1
  34. package/dist/esm/z-toast-notification.entry.js +3 -3
  35. package/dist/esm/z-toast-notification.entry.js.map +1 -1
  36. package/dist/types/components/z-menu/index.d.ts +1 -1
  37. package/dist/types/components/z-menu-section/index.d.ts +1 -1
  38. package/dist/web-components-library/{p-8d043fc0.entry.js → p-1c017b32.entry.js} +2 -2
  39. package/dist/web-components-library/{p-8d043fc0.entry.js.map → p-1c017b32.entry.js.map} +1 -1
  40. package/dist/web-components-library/p-4b8a0caf.entry.js +2 -0
  41. package/dist/web-components-library/p-4b8a0caf.entry.js.map +1 -0
  42. package/dist/web-components-library/p-611e6579.entry.js +2 -0
  43. package/dist/web-components-library/p-611e6579.entry.js.map +1 -0
  44. package/dist/web-components-library/p-7f707293.entry.js +2 -0
  45. package/dist/web-components-library/p-7f707293.entry.js.map +1 -0
  46. package/dist/web-components-library/web-components-library.css +2 -0
  47. package/dist/web-components-library/web-components-library.esm.js +1 -1
  48. package/package.json +1 -1
  49. package/www/build/{p-8d043fc0.entry.js → p-1c017b32.entry.js} +2 -2
  50. package/www/build/{p-8d043fc0.entry.js.map → p-1c017b32.entry.js.map} +1 -1
  51. package/www/build/{p-3595114a.js → p-2c0166dc.js} +1 -1
  52. package/www/build/p-4b8a0caf.entry.js +2 -0
  53. package/www/build/p-4b8a0caf.entry.js.map +1 -0
  54. package/www/build/p-611e6579.entry.js +2 -0
  55. package/www/build/p-611e6579.entry.js.map +1 -0
  56. package/www/build/p-7f707293.entry.js +2 -0
  57. package/www/build/p-7f707293.entry.js.map +1 -0
  58. package/www/build/{p-a69c66e4.css → p-f4f746f6.css} +2 -0
  59. package/www/build/web-components-library.css +2 -0
  60. package/www/build/web-components-library.esm.js +1 -1
  61. package/www/index.html +1 -1
  62. package/dist/web-components-library/p-29414fa3.entry.js +0 -2
  63. package/dist/web-components-library/p-29414fa3.entry.js.map +0 -1
  64. package/dist/web-components-library/p-32c1e2fa.entry.js +0 -2
  65. package/dist/web-components-library/p-32c1e2fa.entry.js.map +0 -1
  66. package/dist/web-components-library/p-b4018dab.entry.js +0 -2
  67. package/dist/web-components-library/p-b4018dab.entry.js.map +0 -1
  68. package/www/build/p-29414fa3.entry.js +0 -2
  69. package/www/build/p-29414fa3.entry.js.map +0 -1
  70. package/www/build/p-32c1e2fa.entry.js +0 -2
  71. package/www/build/p-32c1e2fa.entry.js.map +0 -1
  72. package/www/build/p-b4018dab.entry.js +0 -2
  73. package/www/build/p-b4018dab.entry.js.map +0 -1
@@ -90,28 +90,28 @@
90
90
 
91
91
  :host([variant="secondary"]) .z-button--container {
92
92
  border-color: var(--color-primary01);
93
- background-color: var(--color-surface01);
93
+ background-color: var(--color-button-secondary);
94
94
  color: var(--color-primary01);
95
95
  }
96
96
 
97
97
  @media (hover: hover) {
98
98
  :host([variant="secondary"]) .z-button--container:hover {
99
99
  border-color: var(--color-hover-primary);
100
- background-color: var(--color-surface01);
100
+ background-color: var(--color-button-secondary);
101
101
  color: var(--color-hover-primary);
102
102
  }
103
103
  }
104
104
 
105
105
  :host([variant="secondary"]) .z-button--container:active {
106
106
  border-color: var(--color-pressed-primary);
107
- background-color: var(--color-surface01);
107
+ background-color: var(--color-button-secondary);
108
108
  box-shadow: var(--shadow-2);
109
109
  color: var(--color-pressed-primary);
110
110
  }
111
111
 
112
112
  :host([variant="secondary"][disabled]:not([disabled="false"])) .z-button--container {
113
113
  border-color: var(--color-disabled01);
114
- background-color: var(--color-surface01);
114
+ background-color: var(--color-button-secondary);
115
115
  color: var(--color-disabled03);
116
116
  }
117
117
 
@@ -5,7 +5,7 @@ const isZMenuSection = (el) => (el === null || el === void 0 ? void 0 : el.tagNa
5
5
  /**
6
6
  * @slot - Menu label
7
7
  * @slot header - Header to display as the first entry of the open menu.
8
- * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `active` HTML attribute on the element to highlight it. Use `z-menu-section` for submenus.
8
+ * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `data-active` HTML attribute on the element to highlight it (`active` also works but `data-active` is preferable). Use `z-menu-section` for submenus.
9
9
  * @cssprop --z-menu-label-color - Color of the label's text.
10
10
  */
11
11
  export class ZMenu {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-menu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,EAAyC,EAAiC,EAAE,CAClG,CAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,OAAO,MAAK,gBAAgB,CAAC;AAEnC;;;;;GAKG;AAMH,MAAM,OAAO,KAAK;IAwDhB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3G,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAC,EAAS;QACjC,MAAM,YAAY,GAAI,EAAE,CAAC,MAA0B,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAgB,CAAC;QACzF,YAAY,CAAC,OAAO,CAAC,IAAI,GAAG,YAAY,aAAZ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b,IAAI,EAAC,MAAM;oBAEX,YACE,IAAI,EAAC,MAAM,EACX,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\nimport {containsElement} from \"../../utils/utils\";\n\nconst isZMenuSection = (el: HTMLElement | HTMLZMenuSectionElement): el is HTMLZMenuSectionElement =>\n el?.tagName === \"Z-MENU-SECTION\";\n\n/**\n * @slot - Menu label\n * @slot header - Header to display as the first entry of the open menu.\n * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `active` HTML attribute on the element to highlight it. Use `z-menu-section` for submenus.\n * @cssprop --z-menu-label-color - Color of the label's text.\n */\n@Component({\n tag: \"z-menu\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenu {\n @Element() host: HTMLZMenuElement;\n\n /** Flag to set the active status of the menu. */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Flag to set the display mode of the list.\n * If true, the list will be absolutely positioned under the menu label,\n * stacked beneath it otherwise.\n */\n @Prop({reflect: true})\n floating? = true;\n\n /** The opening state of the menu. */\n @Prop({mutable: true, reflect: true})\n open = false;\n\n /**\n * Tells the component that it's placed in a vertical context with other `ZMenu`s (usually in the ZAppHeader's offcanvas).\n * A small border is placed under it as a separator from other elements.\n */\n @Prop({reflect: true})\n verticalContext = false;\n\n /**\n * Tabindex value to set on the menu label.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZAppHeader).\n */\n @Prop()\n htmlTabindex = -1;\n\n @State()\n hasHeader: boolean;\n\n @State()\n hasContent: boolean;\n\n /** The menu has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The menu has been closed. */\n @Event()\n closed: EventEmitter;\n\n private labelButton: HTMLButtonElement;\n\n private content: HTMLElement;\n\n private items: (HTMLElement | HTMLZMenuSectionElement)[] = [];\n\n /** Animation frame request id. */\n private raf: number;\n\n private get focusableItem(): HTMLZMenuSectionElement | HTMLElement | null {\n return this.items.find((item) => (isZMenuSection(item) ? item.htmlTabindex === 0 : item.tabIndex === 0));\n }\n\n private toggle(): void {\n if (!this.hasContent) {\n return;\n }\n\n this.open = !this.open;\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n this.setLabelA11yAttrs();\n }\n\n /**\n * Correctly set position of the floating menu in order to prevent overflow.\n * @param live Should run the method on every refresh frame.\n */\n private reflow(live = false): void {\n if (!this.floating) {\n return;\n }\n\n if (this.content && this.hasContent) {\n const {style} = this.content;\n const {left} = this.host.getBoundingClientRect();\n const widthPx = getComputedStyle(this.content).width;\n const width = widthPx ? parseFloat(widthPx.replace(\"px\", \"\")) : 375;\n const safeScrollbarSpace = 30;\n style.left = `${Math.min(window.innerWidth - left - width - safeScrollbarSpace, 0)}px`;\n }\n if (live) {\n this.raf = requestAnimationFrame(this.reflow.bind(this, live));\n }\n }\n\n /**\n * Check if some content slot is set.\n */\n private checkContent(): void {\n this.hasHeader = !!this.host.querySelectorAll(\"[slot=header]\").length;\n this.hasContent = !!this.host.querySelectorAll(\"[slot=item]\").length || this.hasHeader;\n }\n\n private setItemTabindex(item: HTMLElement | HTMLZMenuSectionElement, tabIndex: number): void {\n if (isZMenuSection(item)) {\n item.htmlTabindex = tabIndex;\n } else {\n item.tabIndex = tabIndex;\n }\n }\n\n /**\n * Set `menuitem` role to all menu items (ZMenuSection items already have it).\n * Set -1 to the tabindex of the items and 0 to the first one.\n */\n private setItemsA11yAttrs(): void {\n this.items.forEach((item, index) => {\n const tabindex = index === 0 ? 0 : -1;\n this.setItemTabindex(item, tabindex);\n if (!isZMenuSection(item)) {\n item.setAttribute(\"role\", \"menuitem\");\n }\n });\n }\n\n private onItemsChange(): void {\n this.checkContent();\n this.items = Array.from(this.host.children).filter(({slot}) => slot === \"item\") as HTMLElement[];\n this.setItemsA11yAttrs();\n this.items.forEach((item) => {\n if (!isZMenuSection(item)) {\n item.dataset.text = item.textContent;\n }\n });\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n * If the receiver is a ZMenuSection and it's open, focus its first focusable item.\n */\n private moveFocus(\n receiver: HTMLElement | HTMLZMenuSectionElement,\n current?: HTMLElement | HTMLZMenuSectionElement\n ): void {\n if (isZMenuSection(receiver)) {\n receiver.setFocus();\n } else {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n }\n if (!current) {\n return;\n }\n\n this.setItemTabindex(current, -1);\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.moveFocus(this.items[0]);\n }\n\n return;\n }\n\n if (!this.verticalContext) {\n return;\n }\n\n if (ev.key === KeyboardCode.ARROW_RIGHT && !this.open) {\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.moveFocus(this.items[0]);\n }\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n const label = this.hasContent ? this.labelButton : (this.host.firstElementChild as HTMLElement);\n label.focus();\n }\n\n /**\n * Focus the last item.\n */\n @Method()\n async focusLastItem(): Promise<void> {\n const lastItem = this.items[this.items.length - 1];\n if (isZMenuSection(lastItem) && lastItem.open) {\n lastItem.focusLastItem();\n\n return;\n }\n\n this.moveFocus(lastItem);\n }\n\n @Watch(\"open\")\n onOpenChanged(): void {\n if (!this.open) {\n cancelAnimationFrame(this.raf);\n this.closed.emit();\n this.items.forEach((item) => {\n if (isZMenuSection(item) && item.open) {\n item.open = false;\n }\n });\n\n return;\n }\n\n this.setItemsA11yAttrs();\n this.opened.emit();\n if (this.floating) {\n this.reflow(true);\n }\n }\n\n @Watch(\"htmlTabindex\")\n setLabelA11yAttrs(): void {\n if (this.hasContent && this.labelButton) {\n this.labelButton.tabIndex = this.htmlTabindex;\n\n return;\n }\n\n const slottedLabel = this.host.firstElementChild as HTMLElement;\n slottedLabel.role = \"menuitem\";\n slottedLabel.tabIndex = this.htmlTabindex;\n }\n\n /**\n * Set tabindex to -1 to all siblings of the clicked item.\n */\n @Listen(\"click\", {target: \"document\"})\n onItemClick(ev: MouseEvent): void {\n const clickedItem = this.items.find((item) => containsElement(item, ev.target as HTMLElement));\n if (clickedItem) {\n this.items.forEach((item) => {\n if (item === clickedItem) {\n return;\n }\n\n if (isZMenuSection(item)) {\n item.htmlTabindex = -1;\n } else {\n item.tabIndex = -1;\n }\n });\n }\n }\n\n @Listen(\"keydown\")\n onKeyDown(ev: KeyboardEvent): void {\n if (!this.hasContent) {\n return;\n }\n\n switch (ev.key) {\n case KeyboardCode.ESC:\n if (!this.open) {\n break;\n }\n ev.stopPropagation();\n ev.preventDefault();\n this.open = false;\n this.setFocus();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (document.activeElement === this.host) {\n if (this.verticalContext && !this.open) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[0]);\n break;\n }\n\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (this.verticalContext && currentIndex === this.items.length - 1) {\n // navigation is going to leave this menu. restore tabindex to the label and let the parent handle it\n this.setItemTabindex(this.items[currentIndex], -1);\n this.htmlTabindex = 0;\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const receiver = this.items[currentIndex + 1];\n // if the last item is already focused, navigate to the first one\n this.moveFocus(receiver ?? this.items[0], this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (document.activeElement === this.host) {\n if (this.verticalContext) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n // open the menu and focus the last item\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[this.items.length - 1], this.focusableItem);\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (currentIndex === 0 && this.verticalContext) {\n this.setItemTabindex(this.focusableItem, -1);\n this.setFocus();\n break;\n }\n\n const receiver = this.items[currentIndex - 1] ?? this.items[this.items.length - 1];\n // if the receiver is a ZMenuSection and it's open, focus its last item\n if (isZMenuSection(receiver) && receiver.open) {\n this.setItemTabindex(this.focusableItem, -1);\n receiver.focusLastItem();\n break;\n }\n\n this.moveFocus(receiver, this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_LEFT:\n if (!this.open || !this.verticalContext) {\n break;\n }\n\n // close the menu and focus the label\n ev.preventDefault();\n ev.stopPropagation();\n this.open = false;\n this.setFocus();\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.checkContent = this.checkContent.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n }\n\n componentWillLoad(): void {\n this.setLabelA11yAttrs();\n this.onItemsChange();\n }\n\n render(): HTMLDivElement | HTMLZMenuElement {\n if (!this.hasContent) {\n return (\n <div class=\"menu-label\">\n <slot onSlotchange={this.onLabelSlotChange} />\n </div>\n );\n }\n\n return (\n <Host>\n <button\n ref={(el) => (this.labelButton = el)}\n class=\"menu-label\"\n aria-expanded={`${!!this.open}`}\n aria-haspopup={`${this.hasContent}`}\n aria-label={this.open ? \"Chiudi menù\" : \"Apri menù\"}\n role=\"menuitem\"\n tabIndex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />\n </button>\n\n <div\n class=\"content\"\n ref={(el) => (this.content = el)}\n >\n {this.hasHeader && (\n <header class=\"header\">\n <slot\n name=\"header\"\n onSlotchange={this.checkContent}\n />\n </header>\n )}\n\n <div\n class=\"items\"\n role=\"menu\"\n >\n <slot\n name=\"item\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-menu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,EAAyC,EAAiC,EAAE,CAClG,CAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,OAAO,MAAK,gBAAgB,CAAC;AAEnC;;;;;GAKG;AAMH,MAAM,OAAO,KAAK;IAwDhB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,K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AAI,CAAC,iBAAiB,GAAI;gBAC9C,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,GAAI,CACpD;YAET,WACE,KAAK,EAAC,SAAS,EACf,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;gBAE/B,IAAI,CAAC,SAAS,IAAI,CACjB,cAAQ,KAAK,EAAC,QAAQ;oBACpB,YACE,IAAI,EAAC,QAAQ,EACb,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACK,CACV;gBAED,WACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM;oBAEX,YACE,IAAI,EAAC,MAAM,EACX,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\nimport {containsElement} from \"../../utils/utils\";\n\nconst isZMenuSection = (el: HTMLElement | HTMLZMenuSectionElement): el is HTMLZMenuSectionElement =>\n el?.tagName === \"Z-MENU-SECTION\";\n\n/**\n * @slot - Menu label\n * @slot header - Header to display as the first entry of the open menu.\n * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `data-active` HTML attribute on the element to highlight it (`active` also works but `data-active` is preferable). Use `z-menu-section` for submenus.\n * @cssprop --z-menu-label-color - Color of the label's text.\n */\n@Component({\n tag: \"z-menu\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenu {\n @Element() host: HTMLZMenuElement;\n\n /** Flag to set the active status of the menu. */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Flag to set the display mode of the list.\n * If true, the list will be absolutely positioned under the menu label,\n * stacked beneath it otherwise.\n */\n @Prop({reflect: true})\n floating? = true;\n\n /** The opening state of the menu. */\n @Prop({mutable: true, reflect: true})\n open = false;\n\n /**\n * Tells the component that it's placed in a vertical context with other `ZMenu`s (usually in the ZAppHeader's offcanvas).\n * A small border is placed under it as a separator from other elements.\n */\n @Prop({reflect: true})\n verticalContext = false;\n\n /**\n * Tabindex value to set on the menu label.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZAppHeader).\n */\n @Prop()\n htmlTabindex = -1;\n\n @State()\n hasHeader: boolean;\n\n @State()\n hasContent: boolean;\n\n /** The menu has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The menu has been closed. */\n @Event()\n closed: EventEmitter;\n\n private labelButton: HTMLButtonElement;\n\n private content: HTMLElement;\n\n private items: (HTMLElement | HTMLZMenuSectionElement)[] = [];\n\n /** Animation frame request id. */\n private raf: number;\n\n private get focusableItem(): HTMLZMenuSectionElement | HTMLElement | null {\n return this.items.find((item) => (isZMenuSection(item) ? item.htmlTabindex === 0 : item.tabIndex === 0));\n }\n\n private toggle(): void {\n if (!this.hasContent) {\n return;\n }\n\n this.open = !this.open;\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n this.setLabelA11yAttrs();\n }\n\n /**\n * Correctly set position of the floating menu in order to prevent overflow.\n * @param live Should run the method on every refresh frame.\n */\n private reflow(live = false): void {\n if (!this.floating) {\n return;\n }\n\n if (this.content && this.hasContent) {\n const {style} = this.content;\n const {left} = this.host.getBoundingClientRect();\n const widthPx = getComputedStyle(this.content).width;\n const width = widthPx ? parseFloat(widthPx.replace(\"px\", \"\")) : 375;\n const safeScrollbarSpace = 30;\n style.left = `${Math.min(window.innerWidth - left - width - safeScrollbarSpace, 0)}px`;\n }\n if (live) {\n this.raf = requestAnimationFrame(this.reflow.bind(this, live));\n }\n }\n\n /**\n * Check if some content slot is set.\n */\n private checkContent(): void {\n this.hasHeader = !!this.host.querySelectorAll(\"[slot=header]\").length;\n this.hasContent = !!this.host.querySelectorAll(\"[slot=item]\").length || this.hasHeader;\n }\n\n private setItemTabindex(item: HTMLElement | HTMLZMenuSectionElement, tabIndex: number): void {\n if (isZMenuSection(item)) {\n item.htmlTabindex = tabIndex;\n } else {\n item.tabIndex = tabIndex;\n }\n }\n\n /**\n * Set `menuitem` role to all menu items (ZMenuSection items already have it).\n * Set -1 to the tabindex of the items and 0 to the first one.\n */\n private setItemsA11yAttrs(): void {\n this.items.forEach((item, index) => {\n const tabindex = index === 0 ? 0 : -1;\n this.setItemTabindex(item, tabindex);\n if (!isZMenuSection(item)) {\n item.setAttribute(\"role\", \"menuitem\");\n }\n });\n }\n\n private onItemsChange(): void {\n this.checkContent();\n this.items = Array.from(this.host.children).filter(({slot}) => slot === \"item\") as HTMLElement[];\n this.setItemsA11yAttrs();\n this.items.forEach((item) => {\n if (!isZMenuSection(item)) {\n item.dataset.text = item.textContent;\n }\n });\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n * If the receiver is a ZMenuSection and it's open, focus its first focusable item.\n */\n private moveFocus(\n receiver: HTMLElement | HTMLZMenuSectionElement,\n current?: HTMLElement | HTMLZMenuSectionElement\n ): void {\n if (isZMenuSection(receiver)) {\n receiver.setFocus();\n } else {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n }\n if (!current) {\n return;\n }\n\n this.setItemTabindex(current, -1);\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.moveFocus(this.items[0]);\n }\n\n return;\n }\n\n if (!this.verticalContext) {\n return;\n }\n\n if (ev.key === KeyboardCode.ARROW_RIGHT && !this.open) {\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.moveFocus(this.items[0]);\n }\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n const label = this.hasContent ? this.labelButton : (this.host.firstElementChild as HTMLElement);\n label.focus();\n }\n\n /**\n * Focus the last item.\n */\n @Method()\n async focusLastItem(): Promise<void> {\n const lastItem = this.items[this.items.length - 1];\n if (isZMenuSection(lastItem) && lastItem.open) {\n lastItem.focusLastItem();\n\n return;\n }\n\n this.moveFocus(lastItem);\n }\n\n @Watch(\"open\")\n onOpenChanged(): void {\n if (!this.open) {\n cancelAnimationFrame(this.raf);\n this.closed.emit();\n this.items.forEach((item) => {\n if (isZMenuSection(item) && item.open) {\n item.open = false;\n }\n });\n\n return;\n }\n\n this.setItemsA11yAttrs();\n this.opened.emit();\n if (this.floating) {\n this.reflow(true);\n }\n }\n\n @Watch(\"htmlTabindex\")\n setLabelA11yAttrs(): void {\n if (this.hasContent && this.labelButton) {\n this.labelButton.tabIndex = this.htmlTabindex;\n\n return;\n }\n\n const slottedLabel = this.host.firstElementChild as HTMLElement;\n slottedLabel.role = \"menuitem\";\n slottedLabel.tabIndex = this.htmlTabindex;\n }\n\n /**\n * Set tabindex to -1 to all siblings of the clicked item.\n */\n @Listen(\"click\", {target: \"document\"})\n onItemClick(ev: MouseEvent): void {\n const clickedItem = this.items.find((item) => containsElement(item, ev.target as HTMLElement));\n if (clickedItem) {\n this.items.forEach((item) => {\n if (item === clickedItem) {\n return;\n }\n\n if (isZMenuSection(item)) {\n item.htmlTabindex = -1;\n } else {\n item.tabIndex = -1;\n }\n });\n }\n }\n\n @Listen(\"keydown\")\n onKeyDown(ev: KeyboardEvent): void {\n if (!this.hasContent) {\n return;\n }\n\n switch (ev.key) {\n case KeyboardCode.ESC:\n if (!this.open) {\n break;\n }\n ev.stopPropagation();\n ev.preventDefault();\n this.open = false;\n this.setFocus();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (document.activeElement === this.host) {\n if (this.verticalContext && !this.open) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[0]);\n break;\n }\n\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (this.verticalContext && currentIndex === this.items.length - 1) {\n // navigation is going to leave this menu. restore tabindex to the label and let the parent handle it\n this.setItemTabindex(this.items[currentIndex], -1);\n this.htmlTabindex = 0;\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const receiver = this.items[currentIndex + 1];\n // if the last item is already focused, navigate to the first one\n this.moveFocus(receiver ?? this.items[0], this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (document.activeElement === this.host) {\n if (this.verticalContext) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n // open the menu and focus the last item\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[this.items.length - 1], this.focusableItem);\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (currentIndex === 0 && this.verticalContext) {\n this.setItemTabindex(this.focusableItem, -1);\n this.setFocus();\n break;\n }\n\n const receiver = this.items[currentIndex - 1] ?? this.items[this.items.length - 1];\n // if the receiver is a ZMenuSection and it's open, focus its last item\n if (isZMenuSection(receiver) && receiver.open) {\n this.setItemTabindex(this.focusableItem, -1);\n receiver.focusLastItem();\n break;\n }\n\n this.moveFocus(receiver, this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_LEFT:\n if (!this.open || !this.verticalContext) {\n break;\n }\n\n // close the menu and focus the label\n ev.preventDefault();\n ev.stopPropagation();\n this.open = false;\n this.setFocus();\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.checkContent = this.checkContent.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n }\n\n componentWillLoad(): void {\n this.setLabelA11yAttrs();\n this.onItemsChange();\n }\n\n render(): HTMLDivElement | HTMLZMenuElement {\n if (!this.hasContent) {\n return (\n <div class=\"menu-label\">\n <slot onSlotchange={this.onLabelSlotChange} />\n </div>\n );\n }\n\n return (\n <Host>\n <button\n ref={(el) => (this.labelButton = el)}\n class=\"menu-label\"\n aria-expanded={`${!!this.open}`}\n aria-haspopup={`${this.hasContent}`}\n aria-label={this.open ? \"Chiudi menù\" : \"Apri menù\"}\n role=\"menuitem\"\n tabIndex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />\n </button>\n\n <div\n class=\"content\"\n ref={(el) => (this.content = el)}\n >\n {this.hasHeader && (\n <header class=\"header\">\n <slot\n name=\"header\"\n onSlotchange={this.checkContent}\n />\n </header>\n )}\n\n <div\n class=\"items\"\n role=\"menu\"\n >\n <slot\n name=\"item\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -205,7 +205,9 @@ when placed below the real text using `flex-direction: column`. */
205
205
 
206
206
  .items > ::slotted([slot="item"]:hover),
207
207
  .items > ::slotted([slot="item"]:focus:focus-visible),
208
- .items > ::slotted([slot="item"]:active) {
208
+ .items > ::slotted([slot="item"]:active),
209
+ .items > ::slotted([slot="item"][active]),
210
+ .items > ::slotted([slot="item"][data-active]) {
209
211
  border-color: var(--color-primary01);
210
212
  font-weight: var(--font-bd);
211
213
  }
@@ -3,7 +3,7 @@ import { KeyboardCode } from "../../beans";
3
3
  /**
4
4
  * A component to create submenus inside the ZMenu.
5
5
  * @slot - Label of the menu section.
6
- * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `active` attribute to a slotted element to highlight it.
6
+ * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `data-active` attribute to a slotted element to highlight it (`active` also works but `data-active` is preferable).
7
7
  */
8
8
  export class ZMenuSection {
9
9
  get focusableItem() {
@@ -174,7 +174,7 @@ export class ZMenuSection {
174
174
  this.onItemsChange();
175
175
  }
176
176
  render() {
177
- return (h(Host, { key: '7096b13684165ea59a80c5aa679f9ab63c47c0c0', open: this.open }, h("button", { key: '9f170b0588f348f8b17ae9d7809c9fcbf52d9e53', ref: (el) => (this.label = el), class: "label", "aria-haspopup": `${!!this.hasItems}`, "aria-expanded": `${!!this.open}`, role: "menuitem", tabindex: this.htmlTabindex, onClick: this.onLabelClick, onKeyDown: this.onLabelKeydown }, h("slot", { key: 'bf8676afd6af9f622fed46baee5c3f2ef349e083', onSlotchange: this.onLabelSlotChange }), this.hasItems && h("z-icon", { key: '53ac6446d771a867af3474619809ffc110e4baa1', name: this.open ? "chevron-up" : "chevron-down" })), h("div", { key: '632ee96a07716da82d70b8fc8170014846f8fca4', class: "items", role: "menu", hidden: !this.open }, h("slot", { key: 'f5c81d4bf7073341a0d46a0638c8d08172c2afb9', name: "section", onSlotchange: this.onItemsChange }))));
177
+ return (h(Host, { key: '9eef5a05b215717aad80be2ec3fe859d23d52ad3', open: this.open }, h("button", { key: '7410d9fa50eeb8fdfd90fd04b32f9a14875aa606', ref: (el) => (this.label = el), class: "label", "aria-haspopup": `${!!this.hasItems}`, "aria-expanded": `${!!this.open}`, role: "menuitem", tabindex: this.htmlTabindex, onClick: this.onLabelClick, onKeyDown: this.onLabelKeydown }, h("slot", { key: 'd346a0c2fdbf294c8c663b50e75ed04057f3d4b8', onSlotchange: this.onLabelSlotChange }), this.hasItems && h("z-icon", { key: '1236be381bc589b8deb3c84bb9d7df4f3cbd7f4b', name: this.open ? "chevron-up" : "chevron-down" })), h("div", { key: '4c2fb773306316acb9926fd2cefe8d4ba5c1dad3', class: "items", role: "menu", hidden: !this.open }, h("slot", { key: 'b9f2d723eeaacfba9eabececaaa7139ff654a9c1', name: "section", onSlotchange: this.onItemsChange }))));
178
178
  }
179
179
  static get is() { return "z-menu-section"; }
180
180
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-menu-section/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AAMH,MAAM,OAAO,YAAY;IAkCvB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;IACzB,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACtC,IAAI,C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AI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IAED,iBAAiB;QACf,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,qDAAC,IAAI,EAAE,IAAI,CAAC,IAAI;YACnB,+DACE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,KAAK,EAAC,OAAO,mBACE,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,mBACpB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAC/B,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,SAAS,EAAE,IAAI,CAAC,cAAc;gBAE9B,6DAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI;gBAC7C,IAAI,CAAC,QAAQ,IAAI,+DAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,GAAI,CACtE;YACT,4DACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI;gBAElB,6DACE,IAAI,EAAC,SAAS,EACd,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\n\n/**\n * A component to create submenus inside the ZMenu.\n * @slot - Label of the menu section.\n * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `active` attribute to a slotted element to highlight it.\n */\n@Component({\n tag: \"z-menu-section\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenuSection {\n @Element() host: HTMLZMenuSectionElement;\n\n /** Active state */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Tabindex value to set on the label button.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZMenu).\n */\n @Prop()\n htmlTabindex = -1;\n\n /** The opening state of the section. */\n @Prop({mutable: true})\n open: boolean;\n\n @State()\n hasItems: boolean;\n\n @State()\n items: HTMLElement[];\n\n /** The section has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The section has been closed. */\n @Event()\n closed: EventEmitter;\n\n private label: HTMLButtonElement;\n\n private get focusableItem(): HTMLElement {\n return this.items.find(({tabIndex}) => tabIndex === 0);\n }\n\n private toggle(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.open = !this.open;\n }\n\n private setItemsA11yAttrs(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.items.forEach((item) => {\n item.setAttribute(\"role\", \"menuitem\");\n item.tabIndex = -1;\n });\n }\n\n private onItemsChange(): void {\n this.items = Array.from(this.host.querySelectorAll('[slot=\"section\"]')) as HTMLElement[];\n this.hasItems = this.items.length > 0;\n this.setItemsA11yAttrs();\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.focustFirstItem();\n }\n }\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n */\n private moveFocus(receiver: HTMLElement, current?: HTMLElement): void {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n if (current) {\n current.tabIndex = -1;\n }\n }\n\n private focustFirstItem(): void {\n this.moveFocus(this.items[0]);\n }\n\n /** Focus the last item. */\n @Method()\n async focusLastItem(): Promise<void> {\n this.moveFocus(this.items[this.items.length - 1]);\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n setTimeout(() => {\n this.label.focus();\n }, 100);\n }\n\n @Watch(\"open\")\n onOpenChange(): void {\n if (!this.open) {\n this.setItemsA11yAttrs();\n this.closed.emit();\n } else {\n this.opened.emit();\n }\n }\n\n @Watch(\"htmlTabindex\")\n onTabindexChange(): void {\n if (!this.label) {\n return;\n }\n\n this.label.tabIndex = this.htmlTabindex;\n }\n\n @Listen(\"keydown\")\n private onItemsKeydown(ev: KeyboardEvent): void {\n switch (ev.key) {\n case KeyboardCode.ESC:\n case KeyboardCode.ARROW_LEFT:\n if (!this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(this.label, this.focusableItem);\n this.open = false;\n break;\n case KeyboardCode.ARROW_RIGHT:\n if (this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.focustFirstItem();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (!this.open) {\n break;\n }\n if (document.activeElement === this.host) {\n ev.preventDefault();\n ev.stopPropagation();\n this.focustFirstItem();\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex + 1];\n if (receiver) {\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(receiver, this.focusableItem);\n } else {\n this.htmlTabindex = 0;\n this.focusableItem.tabIndex = -1;\n }\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (!this.open || document.activeElement === this.host) {\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex - 1];\n ev.preventDefault();\n ev.stopPropagation();\n if (receiver) {\n this.moveFocus(receiver, this.focusableItem);\n } else {\n // since there isn't a previous item to focus, give the focus to the label element\n this.focusableItem.tabIndex = -1;\n this.setFocus();\n }\n break;\n }\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n this.onItemsKeydown = this.onItemsKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n }\n\n render(): HTMLZMenuSectionElement {\n return (\n <Host open={this.open}>\n <button\n ref={(el) => (this.label = el)}\n class=\"label\"\n aria-haspopup={`${!!this.hasItems}`}\n aria-expanded={`${!!this.open}`}\n role=\"menuitem\"\n tabindex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n {this.hasItems && <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />}\n </button>\n <div\n class=\"items\"\n role=\"menu\"\n hidden={!this.open}\n >\n <slot\n name=\"section\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-menu-section/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC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C,IAAI,CAAC,QAAQ,IAAI,+DAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,GAAI,CACtE;YACT,4DACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI;gBAElB,6DACE,IAAI,EAAC,SAAS,EACd,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\n\n/**\n * A component to create submenus inside the ZMenu.\n * @slot - Label of the menu section.\n * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `data-active` attribute to a slotted element to highlight it (`active` also works but `data-active` is preferable).\n */\n@Component({\n tag: \"z-menu-section\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenuSection {\n @Element() host: HTMLZMenuSectionElement;\n\n /** Active state */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Tabindex value to set on the label button.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZMenu).\n */\n @Prop()\n htmlTabindex = -1;\n\n /** The opening state of the section. */\n @Prop({mutable: true})\n open: boolean;\n\n @State()\n hasItems: boolean;\n\n @State()\n items: HTMLElement[];\n\n /** The section has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The section has been closed. */\n @Event()\n closed: EventEmitter;\n\n private label: HTMLButtonElement;\n\n private get focusableItem(): HTMLElement {\n return this.items.find(({tabIndex}) => tabIndex === 0);\n }\n\n private toggle(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.open = !this.open;\n }\n\n private setItemsA11yAttrs(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.items.forEach((item) => {\n item.setAttribute(\"role\", \"menuitem\");\n item.tabIndex = -1;\n });\n }\n\n private onItemsChange(): void {\n this.items = Array.from(this.host.querySelectorAll('[slot=\"section\"]')) as HTMLElement[];\n this.hasItems = this.items.length > 0;\n this.setItemsA11yAttrs();\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.focustFirstItem();\n }\n }\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n */\n private moveFocus(receiver: HTMLElement, current?: HTMLElement): void {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n if (current) {\n current.tabIndex = -1;\n }\n }\n\n private focustFirstItem(): void {\n this.moveFocus(this.items[0]);\n }\n\n /** Focus the last item. */\n @Method()\n async focusLastItem(): Promise<void> {\n this.moveFocus(this.items[this.items.length - 1]);\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n setTimeout(() => {\n this.label.focus();\n }, 100);\n }\n\n @Watch(\"open\")\n onOpenChange(): void {\n if (!this.open) {\n this.setItemsA11yAttrs();\n this.closed.emit();\n } else {\n this.opened.emit();\n }\n }\n\n @Watch(\"htmlTabindex\")\n onTabindexChange(): void {\n if (!this.label) {\n return;\n }\n\n this.label.tabIndex = this.htmlTabindex;\n }\n\n @Listen(\"keydown\")\n private onItemsKeydown(ev: KeyboardEvent): void {\n switch (ev.key) {\n case KeyboardCode.ESC:\n case KeyboardCode.ARROW_LEFT:\n if (!this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(this.label, this.focusableItem);\n this.open = false;\n break;\n case KeyboardCode.ARROW_RIGHT:\n if (this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.focustFirstItem();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (!this.open) {\n break;\n }\n if (document.activeElement === this.host) {\n ev.preventDefault();\n ev.stopPropagation();\n this.focustFirstItem();\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex + 1];\n if (receiver) {\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(receiver, this.focusableItem);\n } else {\n this.htmlTabindex = 0;\n this.focusableItem.tabIndex = -1;\n }\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (!this.open || document.activeElement === this.host) {\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex - 1];\n ev.preventDefault();\n ev.stopPropagation();\n if (receiver) {\n this.moveFocus(receiver, this.focusableItem);\n } else {\n // since there isn't a previous item to focus, give the focus to the label element\n this.focusableItem.tabIndex = -1;\n this.setFocus();\n }\n break;\n }\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n this.onItemsKeydown = this.onItemsKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n }\n\n render(): HTMLZMenuSectionElement {\n return (\n <Host open={this.open}>\n <button\n ref={(el) => (this.label = el)}\n class=\"label\"\n aria-haspopup={`${!!this.hasItems}`}\n aria-expanded={`${!!this.open}`}\n role=\"menuitem\"\n tabindex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n {this.hasItems && <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />}\n </button>\n <div\n class=\"items\"\n role=\"menu\"\n hidden={!this.open}\n >\n <slot\n name=\"section\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -130,7 +130,9 @@ when placed below the real text using `flex-direction: column`. */
130
130
 
131
131
  ::slotted([slot="section"]:hover),
132
132
  ::slotted([slot="section"]:focus:focus-visible),
133
- ::slotted([slot="section"][active]) {
133
+ ::slotted([slot="section"]:active),
134
+ ::slotted([slot="section"][active]),
135
+ ::slotted([slot="section"][data-active]) {
134
136
  color: var(--color-primary01);
135
137
  font-weight: var(--font-bd);
136
138
  }
@@ -141,7 +141,7 @@ export class ZToastNotification {
141
141
  return totalWidth > parentWidth;
142
142
  }
143
143
  renderText() {
144
- return (h("div", { id: "text", ref: (el) => (this.toastText = el) }, h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)));
144
+ return (h("div", { id: "text", ref: (el) => (this.toastText = el) }, this.heading && h("span", { class: "title" }, this.heading), h("span", { class: "message" }, this.message)));
145
145
  }
146
146
  renderButton() {
147
147
  return (h("div", { id: "button" }, h("slot", { name: "button" })));
@@ -171,7 +171,7 @@ export class ZToastNotification {
171
171
  } }, h("div", { id: "flex-container", ref: (el) => (this.container = el) }, this.renderText(), this.renderButton()), this.renderCloseIcon()));
172
172
  }
173
173
  render() {
174
- return (h(Host, { key: 'beb43ce29f5a836f01238134129ee0eef78d3f7b', style: {
174
+ return (h(Host, { key: 'f890b7ca4232d9ac0b181c6eb35ebb7b19a853fb', style: {
175
175
  "--percentuale": `${this.percentage}%`,
176
176
  }, class: this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN, onAnimationEnd: (e) => {
177
177
  if (this.autoclose && e.animationName.includes("slidein")) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnG,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAExD,OAAO,MAAM,MAAM,UAAU,CAAC;AAO9B,MAAM,OAAO,kBAAkB;;QA0DrB,uBAAkB,GAAG,KAAK,CAAC;;;;;gCArCN,IAAI;;2BAQT,IAAI;mCAIG,EAAE;;;;IA4BjC,oBAAoB,CAAC,QAAiB;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAGD,kBAAkB,CAAC,QAAgB;QACjC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAGD,yBAAyB,CAAC,QAAiB;QACzC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;YACnF,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AE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CACjE,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Prop, State, Watch, h} from \"@stencil/core\";\nimport {ToastNotification, ToastNotificationTransition} from \"../../beans\";\nimport {Breakpoints} from \"../../constants/breakpoints\";\n\nimport Hammer from \"hammerjs\";\n\n@Component({\n tag: \"z-toast-notification\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZToastNotification {\n @Element() hostElement: HTMLZToastNotificationElement;\n\n /** toast notification's title */\n @Prop()\n heading?: string;\n\n /** toast notification's message */\n @Prop()\n message: string;\n\n /** toggles closing button rendering */\n @Prop()\n closebutton: boolean;\n\n /** toast notification closing timeout (ms) */\n @Prop()\n autoclose?: number;\n\n /** toast notification autoclose can be paused */\n @Prop()\n pauseonfocusloss?: boolean = true;\n\n /** toast notification type: dark, light, accent, error, success, warning */\n @Prop()\n type?: ToastNotification;\n\n /** toast notification can be draggable*/\n @Prop()\n isdraggable?: boolean = true;\n\n /** toast notification draggable percentage*/\n @Prop()\n draggablepercentage?: number = 80;\n\n /** toast notification animation type: slide-in-left, slide-in-right, slide-in-down, slide-in-up*/\n @Prop()\n transition?: ToastNotificationTransition;\n\n @State()\n percentage: number;\n\n private isTextLong: boolean;\n\n private container!: HTMLElement;\n\n private toastText!: HTMLElement;\n\n private sliderManager: HammerManager;\n\n private elapsedTime: number;\n\n private timeoutHandle: number;\n\n private startTime: number;\n\n private isMobile: boolean;\n\n private isCloseEventCalled = false;\n\n @Watch(\"isdraggable\")\n watchPropIsdraggable(newValue: boolean): void {\n if (newValue) {\n this.sliderManager.get(\"pan\").set({enable: true});\n } else {\n this.sliderManager.get(\"pan\").set({enable: false});\n }\n }\n\n @Watch(\"autoclose\")\n watchPropAutoclose(newValue: number): void {\n clearTimeout(this.timeoutHandle);\n this.startClosingTimeout(newValue);\n }\n\n @Watch(\"pauseonfocusloss\")\n watchPropPauseonfocusloss(newValue: boolean): void {\n if (this.autoclose) {\n if (newValue) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n } else {\n document.removeEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n }\n }\n\n /** notification close event */\n @Event()\n toastClose: EventEmitter;\n\n private emitToastClose(cssClass: string): void {\n this.timeoutHandle = null;\n this.elapsedTime = null;\n this.hostElement.classList.add(cssClass);\n this.toastClose.emit();\n }\n\n componentWillLoad(): void {\n this.isMobile = window.innerWidth <= Breakpoints.MOBILE;\n this.validateAutoclose();\n this.percentage = 0;\n }\n\n componentDidLoad(): void {\n this.isTextLong = this.detectWrap() || this.toastText.offsetHeight > 20;\n this.startTime = Date.now();\n if (this.autoclose && this.pauseonfocusloss) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n\n this.isdraggable && this.handleSlideOutDragAnimation();\n }\n\n private visibilityChangeEventHandler(): void {\n if (document.visibilityState === \"hidden\") {\n this.timeoutHandle && this.onBlur();\n } else {\n this.elapsedTime && this.onFocus();\n }\n }\n\n private validateAutoclose(): void {\n if (!this.autoclose && !this.closebutton) {\n console.error(\"At least one between autoclose and closebutton must be present\");\n }\n }\n\n private mapSlideOutClass(): ToastNotificationTransition {\n switch (this.transition) {\n case ToastNotificationTransition.SLIDE_IN_DOWN:\n return ToastNotificationTransition.SLIDE_OUT_UP;\n case ToastNotificationTransition.SLIDE_IN_UP:\n return ToastNotificationTransition.SLIDE_OUT_DOWN;\n case ToastNotificationTransition.SLIDE_IN_LEFT:\n return ToastNotificationTransition.SLIDE_OUT_RIGHT;\n case ToastNotificationTransition.SLIDE_IN_RIGHT:\n return ToastNotificationTransition.SLIDE_OUT_LEFT;\n }\n }\n\n private calculateDraggedPercentage(e): number {\n const bounding = this.hostElement.getBoundingClientRect();\n\n return Math.round((100 * e.deltaX) / bounding.width);\n }\n\n private handleSlideOutDragAnimation(): void {\n this.sliderManager = new Hammer(this.hostElement);\n this.sliderManager.get(\"pan\").set({\n direction: Hammer.DIRECTION_HORIZONTAL,\n });\n\n this.sliderManager.on(\"pan\", (e) => {\n this.percentage = this.calculateDraggedPercentage(e);\n this.hostElement.style.transition = \"none\";\n this.hostElement.classList.remove(this.transition);\n const translateObj = {\n translate: `translateX(${this.percentage}%)`,\n translateBack: \"translateX(0)\",\n };\n\n this.hostElement.style.opacity = `${100 - Math.abs(this.percentage)}%`;\n if (e.eventType === Hammer.DIRECTION_LEFT || e.eventType === Hammer.DIRECTION_RIGHT) {\n this.hostElement.style.transform = translateObj.translate;\n if (Math.abs(this.percentage) > this.draggablepercentage && !this.isCloseEventCalled) {\n this.isCloseEventCalled = true;\n this.emitToastClose(e.direction === Hammer.DIRECTION_LEFT ? \"slide-out-left\" : \"slide-out-right\");\n }\n }\n\n if (e.isFinal && Math.abs(this.percentage) < this.draggablepercentage) {\n this.hostElement.style.transform = translateObj.translateBack;\n this.hostElement.style.transition = \"all 1s\";\n this.hostElement.style.opacity = \"100%\";\n this.percentage = 0;\n }\n });\n }\n\n private onFocus(): void {\n let time = this.autoclose;\n if (this.elapsedTime) {\n time = this.autoclose - this.elapsedTime;\n }\n if (time > 0) {\n this.startClosingTimeout(time);\n }\n }\n\n private onBlur(): void {\n this.elapsedTime = Date.now() - this.startTime;\n clearTimeout(this.timeoutHandle);\n }\n\n private startClosingTimeout(time: number): void {\n this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);\n }\n\n private detectWrap(): boolean {\n const parentWidth = this.container.offsetWidth;\n const children = this.container.children;\n let totalWidth = 0;\n\n for (let i = 0; i < children.length; i++) {\n totalWidth += (children[i] as HTMLElement).offsetWidth;\n }\n\n return totalWidth > parentWidth;\n }\n\n private renderText(): HTMLDivElement {\n return (\n <div\n id=\"text\"\n ref={(el) => (this.toastText = el as HTMLElement)}\n >\n <span class=\"title\">{this.heading}</span>\n <span class=\"message\">{this.message}</span>\n </div>\n );\n }\n\n private renderButton(): HTMLDivElement {\n return (\n <div id=\"button\">\n <slot name=\"button\" />\n </div>\n );\n }\n\n private renderCloseIcon(): HTMLDivElement {\n if (!this.closebutton) {\n return;\n }\n\n return (\n <div id=\"icon\">\n <z-icon\n tabIndex={0}\n name=\"multiply-circled\"\n width={15}\n height={15}\n onClick={() => this.emitToastClose(this.mapSlideOutClass())}\n onKeyPress={(e) => {\n if (e.keyCode == 32 || e.keyCode == 13) {\n e.preventDefault();\n this.emitToastClose(this.mapSlideOutClass());\n }\n }}\n />\n </div>\n );\n }\n\n private renderContainer(): HTMLDivElement {\n return (\n <div\n tabIndex={0}\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n }}\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n private renderMobileContainer(): HTMLDivElement {\n return (\n <div\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n \"mobile-wrapped\": this.isTextLong,\n }}\n >\n <div\n id=\"flex-container\"\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n </div>\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n render(): HTMLZToastNotificationElement {\n return (\n <Host\n style={{\n \"--percentuale\": `${this.percentage}%`,\n }}\n class={this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN}\n onAnimationEnd={(e: AnimationEvent) => {\n if (this.autoclose && e.animationName.includes(\"slidein\")) {\n this.startClosingTimeout(this.autoclose);\n }\n if (e.animationName.includes(\"slideout\")) {\n this.hostElement.parentNode.removeChild(this.hostElement);\n }\n }}\n >\n {this.isMobile ? this.renderMobileContainer() : this.renderContainer()}\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-toast-notification/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnG,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAExD,OAAO,MAAM,MAAM,UAAU,CAAC;AAO9B,MAAM,OAAO,kBAAkB;;QA0DrB,uBAAkB,GAAG,KAAK,CAAC;;;;;gCArCN,IAAI;;2BAQT,IAAI;mCAIG,EAAE;;;;IA4BjC,oBAAoB,CAAC,QAAiB;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAGD,kBAAkB,CAAC,QAAgB;QACjC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAGD,yBAAyB,CAAC,QAAiB;QACzC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC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AAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CACjE,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Prop, State, Watch, h} from \"@stencil/core\";\nimport {ToastNotification, ToastNotificationTransition} from \"../../beans\";\nimport {Breakpoints} from \"../../constants/breakpoints\";\n\nimport Hammer from \"hammerjs\";\n\n@Component({\n tag: \"z-toast-notification\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZToastNotification {\n @Element() hostElement: HTMLZToastNotificationElement;\n\n /** toast notification's title */\n @Prop()\n heading?: string;\n\n /** toast notification's message */\n @Prop()\n message: string;\n\n /** toggles closing button rendering */\n @Prop()\n closebutton: boolean;\n\n /** toast notification closing timeout (ms) */\n @Prop()\n autoclose?: number;\n\n /** toast notification autoclose can be paused */\n @Prop()\n pauseonfocusloss?: boolean = true;\n\n /** toast notification type: dark, light, accent, error, success, warning */\n @Prop()\n type?: ToastNotification;\n\n /** toast notification can be draggable*/\n @Prop()\n isdraggable?: boolean = true;\n\n /** toast notification draggable percentage*/\n @Prop()\n draggablepercentage?: number = 80;\n\n /** toast notification animation type: slide-in-left, slide-in-right, slide-in-down, slide-in-up*/\n @Prop()\n transition?: ToastNotificationTransition;\n\n @State()\n percentage: number;\n\n private isTextLong: boolean;\n\n private container!: HTMLElement;\n\n private toastText!: HTMLElement;\n\n private sliderManager: HammerManager;\n\n private elapsedTime: number;\n\n private timeoutHandle: number;\n\n private startTime: number;\n\n private isMobile: boolean;\n\n private isCloseEventCalled = false;\n\n @Watch(\"isdraggable\")\n watchPropIsdraggable(newValue: boolean): void {\n if (newValue) {\n this.sliderManager.get(\"pan\").set({enable: true});\n } else {\n this.sliderManager.get(\"pan\").set({enable: false});\n }\n }\n\n @Watch(\"autoclose\")\n watchPropAutoclose(newValue: number): void {\n clearTimeout(this.timeoutHandle);\n this.startClosingTimeout(newValue);\n }\n\n @Watch(\"pauseonfocusloss\")\n watchPropPauseonfocusloss(newValue: boolean): void {\n if (this.autoclose) {\n if (newValue) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n } else {\n document.removeEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n }\n }\n\n /** notification close event */\n @Event()\n toastClose: EventEmitter;\n\n private emitToastClose(cssClass: string): void {\n this.timeoutHandle = null;\n this.elapsedTime = null;\n this.hostElement.classList.add(cssClass);\n this.toastClose.emit();\n }\n\n componentWillLoad(): void {\n this.isMobile = window.innerWidth <= Breakpoints.MOBILE;\n this.validateAutoclose();\n this.percentage = 0;\n }\n\n componentDidLoad(): void {\n this.isTextLong = this.detectWrap() || this.toastText.offsetHeight > 20;\n this.startTime = Date.now();\n if (this.autoclose && this.pauseonfocusloss) {\n document.addEventListener(\"visibilitychange\", this.visibilityChangeEventHandler);\n }\n\n this.isdraggable && this.handleSlideOutDragAnimation();\n }\n\n private visibilityChangeEventHandler(): void {\n if (document.visibilityState === \"hidden\") {\n this.timeoutHandle && this.onBlur();\n } else {\n this.elapsedTime && this.onFocus();\n }\n }\n\n private validateAutoclose(): void {\n if (!this.autoclose && !this.closebutton) {\n console.error(\"At least one between autoclose and closebutton must be present\");\n }\n }\n\n private mapSlideOutClass(): ToastNotificationTransition {\n switch (this.transition) {\n case ToastNotificationTransition.SLIDE_IN_DOWN:\n return ToastNotificationTransition.SLIDE_OUT_UP;\n case ToastNotificationTransition.SLIDE_IN_UP:\n return ToastNotificationTransition.SLIDE_OUT_DOWN;\n case ToastNotificationTransition.SLIDE_IN_LEFT:\n return ToastNotificationTransition.SLIDE_OUT_RIGHT;\n case ToastNotificationTransition.SLIDE_IN_RIGHT:\n return ToastNotificationTransition.SLIDE_OUT_LEFT;\n }\n }\n\n private calculateDraggedPercentage(e): number {\n const bounding = this.hostElement.getBoundingClientRect();\n\n return Math.round((100 * e.deltaX) / bounding.width);\n }\n\n private handleSlideOutDragAnimation(): void {\n this.sliderManager = new Hammer(this.hostElement);\n this.sliderManager.get(\"pan\").set({\n direction: Hammer.DIRECTION_HORIZONTAL,\n });\n\n this.sliderManager.on(\"pan\", (e) => {\n this.percentage = this.calculateDraggedPercentage(e);\n this.hostElement.style.transition = \"none\";\n this.hostElement.classList.remove(this.transition);\n const translateObj = {\n translate: `translateX(${this.percentage}%)`,\n translateBack: \"translateX(0)\",\n };\n\n this.hostElement.style.opacity = `${100 - Math.abs(this.percentage)}%`;\n if (e.eventType === Hammer.DIRECTION_LEFT || e.eventType === Hammer.DIRECTION_RIGHT) {\n this.hostElement.style.transform = translateObj.translate;\n if (Math.abs(this.percentage) > this.draggablepercentage && !this.isCloseEventCalled) {\n this.isCloseEventCalled = true;\n this.emitToastClose(e.direction === Hammer.DIRECTION_LEFT ? \"slide-out-left\" : \"slide-out-right\");\n }\n }\n\n if (e.isFinal && Math.abs(this.percentage) < this.draggablepercentage) {\n this.hostElement.style.transform = translateObj.translateBack;\n this.hostElement.style.transition = \"all 1s\";\n this.hostElement.style.opacity = \"100%\";\n this.percentage = 0;\n }\n });\n }\n\n private onFocus(): void {\n let time = this.autoclose;\n if (this.elapsedTime) {\n time = this.autoclose - this.elapsedTime;\n }\n if (time > 0) {\n this.startClosingTimeout(time);\n }\n }\n\n private onBlur(): void {\n this.elapsedTime = Date.now() - this.startTime;\n clearTimeout(this.timeoutHandle);\n }\n\n private startClosingTimeout(time: number): void {\n this.timeoutHandle = window.setTimeout(() => this.emitToastClose(this.mapSlideOutClass()), time);\n }\n\n private detectWrap(): boolean {\n const parentWidth = this.container.offsetWidth;\n const children = this.container.children;\n let totalWidth = 0;\n\n for (let i = 0; i < children.length; i++) {\n totalWidth += (children[i] as HTMLElement).offsetWidth;\n }\n\n return totalWidth > parentWidth;\n }\n\n private renderText(): HTMLDivElement {\n return (\n <div\n id=\"text\"\n ref={(el) => (this.toastText = el as HTMLElement)}\n >\n {this.heading && <span class=\"title\">{this.heading}</span>}\n <span class=\"message\">{this.message}</span>\n </div>\n );\n }\n\n private renderButton(): HTMLDivElement {\n return (\n <div id=\"button\">\n <slot name=\"button\" />\n </div>\n );\n }\n\n private renderCloseIcon(): HTMLDivElement {\n if (!this.closebutton) {\n return;\n }\n\n return (\n <div id=\"icon\">\n <z-icon\n tabIndex={0}\n name=\"multiply-circled\"\n width={15}\n height={15}\n onClick={() => this.emitToastClose(this.mapSlideOutClass())}\n onKeyPress={(e) => {\n if (e.keyCode == 32 || e.keyCode == 13) {\n e.preventDefault();\n this.emitToastClose(this.mapSlideOutClass());\n }\n }}\n />\n </div>\n );\n }\n\n private renderContainer(): HTMLDivElement {\n return (\n <div\n tabIndex={0}\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n }}\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n private renderMobileContainer(): HTMLDivElement {\n return (\n <div\n id=\"external-container\"\n class={{\n [this.type]: !!this.type,\n \"several-lines-padding\": this.isTextLong,\n \"mobile-wrapped\": this.isTextLong,\n }}\n >\n <div\n id=\"flex-container\"\n ref={(el) => (this.container = el as HTMLElement)}\n >\n {this.renderText()}\n {this.renderButton()}\n </div>\n {this.renderCloseIcon()}\n </div>\n );\n }\n\n render(): HTMLZToastNotificationElement {\n return (\n <Host\n style={{\n \"--percentuale\": `${this.percentage}%`,\n }}\n class={this.transition ? this.transition : ToastNotificationTransition.SLIDE_IN_DOWN}\n onAnimationEnd={(e: AnimationEvent) => {\n if (this.autoclose && e.animationName.includes(\"slidein\")) {\n this.startClosingTimeout(this.autoclose);\n }\n if (e.animationName.includes(\"slideout\")) {\n this.hostElement.parentNode.removeChild(this.hostElement);\n }\n }}\n >\n {this.isMobile ? this.renderMobileContainer() : this.renderContainer()}\n </Host>\n );\n }\n}\n"]}
@@ -142,11 +142,10 @@
142
142
 
143
143
  :host > #external-container {
144
144
  display: flex;
145
- min-height: 52px;
146
145
  box-sizing: border-box;
147
- align-items: center;
146
+ align-items: flex-start;
148
147
  justify-content: space-between;
149
- padding: calc(var(--space-unit) * 1) calc(var(--space-unit) * 2);
148
+ padding: calc(var(--space-unit) * 2);
150
149
  border-radius: var(--border-size-large);
151
150
  box-shadow: var(--shadow-3);
152
151
  font-family: var(--font-family-sans);
@@ -189,6 +188,9 @@
189
188
  }
190
189
 
191
190
  :host > #external-container #icon {
191
+ display: flex;
192
+ height: 20px;
193
+ align-items: center;
192
194
  margin-left: calc(var(--space-unit) * 2);
193
195
  cursor: pointer;
194
196
  fill: var(--color-inverse-icon);
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/clien
2
2
  import { c as ButtonType, B as ButtonVariant, e as ControlSize } from './index2.js';
3
3
  import { d as defineCustomElement$1 } from './index9.js';
4
4
 
5
- const stylesCss = ".sc-z-button-h{display:inline-block;--z-icon-width:16px;--z-icon-height:16px;--z-icon-right-margin:0}[disabled].sc-z-button-h:not([disabled=\"false\"]){pointer-events:none}.sc-z-button-h .z-button--container.sc-z-button{display:inline-flex;width:100%;box-sizing:border-box;align-items:center;justify-content:center;padding:0;border-width:var(--border-size-medium);border-style:solid;border-radius:var(--border-radius);cursor:pointer;fill:currentcolor;font-family:var(--font-family-sans);font-size:14px;font-weight:var(--font-sb);letter-spacing:0.3px;line-height:1;outline:none;text-decoration:none;text-transform:uppercase;white-space:nowrap}.sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{box-shadow:var(--shadow-focus-primary)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button{min-width:calc(var(--space-unit) * 8);padding:0 calc(var(--space-unit) * 2)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button z-icon.sc-z-button{--z-icon-right-margin:var(--space-unit)}[size=\"big\"].sc-z-button-h .z-button--container.sc-z-button{min-width:44px;height:44px}[size=\"small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:36px;height:36px}[size=\"x-small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:32px;height:32px}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-primary01);color:var(--color-text-inverse)}@media (hover: hover){[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-hover-primary);color:var(--color-text-inverse)}}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-pressed-primary);box-shadow:var(--shadow-2);color:var(--color-text-inverse)}[variant=\"primary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled03)}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-surface01);color:var(--color-primary01)}@media (hover: hover){[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-surface01);color:var(--color-hover-primary)}}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-surface01);box-shadow:var(--shadow-2);color:var(--color-pressed-primary)}[variant=\"secondary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-surface01);color:var(--color-disabled03)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary02);background-color:var(--color-primary02);color:var(--color-primary01)}@media (hover: hover){[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-primary03);background-color:var(--color-primary03);color:var(--color-hover-primary)}}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{border-color:var(--color-primary02);background-color:var(--color-primary02);color:var(--color-primary01)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-primary02);background-color:var(--color-primary02);box-shadow:var(--shadow-2);color:var(--color-primary01)}[variant=\"tertiary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled03)}";
5
+ const stylesCss = ".sc-z-button-h{display:inline-block;--z-icon-width:16px;--z-icon-height:16px;--z-icon-right-margin:0}[disabled].sc-z-button-h:not([disabled=\"false\"]){pointer-events:none}.sc-z-button-h .z-button--container.sc-z-button{display:inline-flex;width:100%;box-sizing:border-box;align-items:center;justify-content:center;padding:0;border-width:var(--border-size-medium);border-style:solid;border-radius:var(--border-radius);cursor:pointer;fill:currentcolor;font-family:var(--font-family-sans);font-size:14px;font-weight:var(--font-sb);letter-spacing:0.3px;line-height:1;outline:none;text-decoration:none;text-transform:uppercase;white-space:nowrap}.sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{box-shadow:var(--shadow-focus-primary)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button{min-width:calc(var(--space-unit) * 8);padding:0 calc(var(--space-unit) * 2)}.sc-z-button-h .z-button--container.z-button--has-text.sc-z-button z-icon.sc-z-button{--z-icon-right-margin:var(--space-unit)}[size=\"big\"].sc-z-button-h .z-button--container.sc-z-button{min-width:44px;height:44px}[size=\"small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:36px;height:36px}[size=\"x-small\"].sc-z-button-h .z-button--container.sc-z-button{min-width:32px;height:32px}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-primary01);color:var(--color-text-inverse)}@media (hover: hover){[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-hover-primary);color:var(--color-text-inverse)}}[variant=\"primary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-pressed-primary);box-shadow:var(--shadow-2);color:var(--color-text-inverse)}[variant=\"primary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled03)}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary01);background-color:var(--color-button-secondary);color:var(--color-primary01)}@media (hover: hover){[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-hover-primary);background-color:var(--color-button-secondary);color:var(--color-hover-primary)}}[variant=\"secondary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-pressed-primary);background-color:var(--color-button-secondary);box-shadow:var(--shadow-2);color:var(--color-pressed-primary)}[variant=\"secondary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-button-secondary);color:var(--color-disabled03)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button{border-color:var(--color-primary02);background-color:var(--color-primary02);color:var(--color-primary01)}@media (hover: hover){[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:hover{border-color:var(--color-primary03);background-color:var(--color-primary03);color:var(--color-hover-primary)}}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:focus:focus-visible{border-color:var(--color-primary02);background-color:var(--color-primary02);color:var(--color-primary01)}[variant=\"tertiary\"].sc-z-button-h .z-button--container.sc-z-button:active{border-color:var(--color-primary02);background-color:var(--color-primary02);box-shadow:var(--shadow-2);color:var(--color-primary01)}[variant=\"tertiary\"][disabled].sc-z-button-h:not([disabled=\"false\"]) .z-button--container.sc-z-button{border-color:var(--color-disabled01);background-color:var(--color-disabled01);color:var(--color-disabled03)}";
6
6
  const ZButtonStyle0 = stylesCss;
7
7
 
8
8
  const ZButton = /*@__PURE__*/ proxyCustomElement(class ZButton extends HTMLElement {
@@ -1 +1 @@
1
- {"file":"index4.js","mappings":";;;;AAAA,MAAM,SAAS,GAAG,02HAA02H,CAAC;AAC73H,sBAAe,SAAS;;MCYX,OAAO;;;;yBAKN,EAAE;oBAIP,EAAE;;;;;wBAoBY,KAAK;oBAIN,UAAU,CAAC,MAAM;uBAIX,aAAa,CAAC,OAAO;;oBAQb,WAAW,CAAC,GAAG;;IAEzC,aAAa;QACnB,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,MAAM;YACf,KAAK,EAAE;gBACL,qBAAqB,EAAE,IAAI;gBAC3B,oBAAoB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE;aAC5D;SACF,CAAC;KACH;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,QACE,yBACM,IAAI,CAAC,aAAa,EAAE,kBACZ,IAAI,CAAC,SAAS,EAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,MAAM,KAElB,IAAI,CAAC,IAAI,IAAI,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,EACzC,eAAQ,CACN,EACJ;SACH;QAED,QACE,8BACM,IAAI,CAAC,aAAa,EAAE,kBACZ,IAAI,CAAC,SAAS,EAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAEtB,IAAI,CAAC,IAAI,IAAI,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,EACzC,eAAQ,CACD,EACT;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/z-button/styles.css?tag=z-button&encapsulation=scoped","src/components/z-button/index.tsx"],"sourcesContent":[":host {\n display: inline-block;\n\n --z-icon-width: 16px;\n --z-icon-height: 16px;\n --z-icon-right-margin: 0;\n}\n\n:host([disabled]:not([disabled=\"false\"])) {\n pointer-events: none;\n}\n\n:host .z-button--container {\n display: inline-flex;\n width: 100%;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n padding: 0;\n border-width: var(--border-size-medium);\n border-style: solid;\n border-radius: var(--border-radius);\n cursor: pointer;\n fill: currentcolor;\n font-family: var(--font-family-sans);\n font-size: 14px;\n font-weight: var(--font-sb);\n letter-spacing: 0.3px;\n line-height: 1;\n outline: none;\n text-decoration: none;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n:host .z-button--container:focus:focus-visible {\n box-shadow: var(--shadow-focus-primary);\n}\n\n:host .z-button--container.z-button--has-text {\n min-width: calc(var(--space-unit) * 8);\n padding: 0 calc(var(--space-unit) * 2);\n}\n\n:host .z-button--container.z-button--has-text z-icon {\n --z-icon-right-margin: var(--space-unit);\n}\n\n:host([size=\"big\"]) .z-button--container {\n min-width: 44px;\n height: 44px;\n}\n\n:host([size=\"small\"]) .z-button--container {\n min-width: 36px;\n height: 36px;\n}\n\n:host([size=\"x-small\"]) .z-button--container {\n min-width: 32px;\n height: 32px;\n}\n\n:host([variant=\"primary\"]) .z-button--container {\n border-color: var(--color-primary01);\n background-color: var(--color-primary01);\n color: var(--color-text-inverse);\n}\n\n@media (hover: hover) {\n :host([variant=\"primary\"]) .z-button--container:hover {\n border-color: var(--color-hover-primary);\n background-color: var(--color-hover-primary);\n color: var(--color-text-inverse);\n }\n}\n\n:host([variant=\"primary\"]) .z-button--container:active {\n border-color: var(--color-pressed-primary);\n background-color: var(--color-pressed-primary);\n box-shadow: var(--shadow-2);\n color: var(--color-text-inverse);\n}\n\n:host([variant=\"primary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-disabled01);\n color: var(--color-disabled03);\n}\n\n:host([variant=\"secondary\"]) .z-button--container {\n border-color: var(--color-primary01);\n background-color: var(--color-surface01);\n color: var(--color-primary01);\n}\n\n@media (hover: hover) {\n :host([variant=\"secondary\"]) .z-button--container:hover {\n border-color: var(--color-hover-primary);\n background-color: var(--color-surface01);\n color: var(--color-hover-primary);\n }\n}\n\n:host([variant=\"secondary\"]) .z-button--container:active {\n border-color: var(--color-pressed-primary);\n background-color: var(--color-surface01);\n box-shadow: var(--shadow-2);\n color: var(--color-pressed-primary);\n}\n\n:host([variant=\"secondary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-surface01);\n color: var(--color-disabled03);\n}\n\n:host([variant=\"tertiary\"]) .z-button--container {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n color: var(--color-primary01);\n}\n\n@media (hover: hover) {\n :host([variant=\"tertiary\"]) .z-button--container:hover {\n border-color: var(--color-primary03);\n background-color: var(--color-primary03);\n color: var(--color-hover-primary);\n }\n}\n\n:host([variant=\"tertiary\"]) .z-button--container:focus:focus-visible {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n color: var(--color-primary01);\n}\n\n:host([variant=\"tertiary\"]) .z-button--container:active {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n box-shadow: var(--shadow-2);\n color: var(--color-primary01);\n}\n\n:host([variant=\"tertiary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-disabled01);\n color: var(--color-disabled03);\n}\n","import {Component, Element, Prop, h} from \"@stencil/core\";\nimport {JSXBase} from \"@stencil/core/internal\";\nimport {ButtonSize, ButtonType, ButtonVariant, ControlSize} from \"../../beans\";\n\n/**\n * @slot - button label\n */\n@Component({\n tag: \"z-button\",\n styleUrl: \"styles.css\",\n shadow: false,\n scoped: true,\n})\nexport class ZButton {\n @Element() hostElement: HTMLZButtonElement;\n\n /** defines a string value that labels an interactive element, used for accessibility. */\n @Prop({reflect: true})\n ariaLabel = \"\";\n\n /** defines role attribute, used for accessibility. */\n @Prop()\n role = \"\";\n\n /** HTML <a> href attribute. If it is set, it renders an HTML <a> tag. */\n @Prop()\n href?: string;\n\n /** HTML a target attribute. */\n @Prop()\n target?: string;\n\n /** Identifier, should be unique. */\n @Prop()\n htmlid?: string;\n\n /** HTML button name attribute. */\n @Prop()\n name?: string;\n\n /** HTML button disabled attribute. */\n @Prop({reflect: true})\n disabled?: boolean = false;\n\n /** HTML button type attribute. */\n @Prop()\n type?: ButtonType = ButtonType.BUTTON;\n\n /** Graphical variant: `primary`, `secondary`, `tertiary`. Defaults to `primary`. */\n @Prop({reflect: true})\n variant?: ButtonVariant = ButtonVariant.PRIMARY;\n\n /** `z-icon` name to use (optional). */\n @Prop()\n icon?: string;\n\n /** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */\n @Prop({reflect: true})\n size?: ButtonSize | ControlSize = ControlSize.BIG;\n\n private getAttributes(): JSXBase.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement> {\n return {\n id: this.htmlid,\n class: {\n \"z-button--container\": true,\n \"z-button--has-text\": !!this.hostElement.textContent.trim(),\n },\n };\n }\n\n render(): HTMLAnchorElement | HTMLButtonElement {\n if (this.href) {\n return (\n <a\n {...this.getAttributes()}\n aria-label={this.ariaLabel}\n href={this.href}\n target={this.target}\n >\n {this.icon && <z-icon name={this.icon} />}\n <slot />\n </a>\n );\n }\n\n return (\n <button\n {...this.getAttributes()}\n aria-label={this.ariaLabel}\n name={this.name}\n type={this.type}\n role={this.role}\n disabled={this.disabled}\n >\n {this.icon && <z-icon name={this.icon} />}\n <slot />\n </button>\n );\n }\n}\n"],"version":3}
1
+ {"file":"index4.js","mappings":";;;;AAAA,MAAM,SAAS,GAAG,s4HAAs4H,CAAC;AACz5H,sBAAe,SAAS;;MCYX,OAAO;;;;yBAKN,EAAE;oBAIP,EAAE;;;;;wBAoBY,KAAK;oBAIN,UAAU,CAAC,MAAM;uBAIX,aAAa,CAAC,OAAO;;oBAQb,WAAW,CAAC,GAAG;;IAEzC,aAAa;QACnB,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,MAAM;YACf,KAAK,EAAE;gBACL,qBAAqB,EAAE,IAAI;gBAC3B,oBAAoB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE;aAC5D;SACF,CAAC;KACH;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,QACE,yBACM,IAAI,CAAC,aAAa,EAAE,kBACZ,IAAI,CAAC,SAAS,EAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,MAAM,KAElB,IAAI,CAAC,IAAI,IAAI,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,EACzC,eAAQ,CACN,EACJ;SACH;QAED,QACE,8BACM,IAAI,CAAC,aAAa,EAAE,kBACZ,IAAI,CAAC,SAAS,EAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAEtB,IAAI,CAAC,IAAI,IAAI,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,EACzC,eAAQ,CACD,EACT;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/z-button/styles.css?tag=z-button&encapsulation=scoped","src/components/z-button/index.tsx"],"sourcesContent":[":host {\n display: inline-block;\n\n --z-icon-width: 16px;\n --z-icon-height: 16px;\n --z-icon-right-margin: 0;\n}\n\n:host([disabled]:not([disabled=\"false\"])) {\n pointer-events: none;\n}\n\n:host .z-button--container {\n display: inline-flex;\n width: 100%;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n padding: 0;\n border-width: var(--border-size-medium);\n border-style: solid;\n border-radius: var(--border-radius);\n cursor: pointer;\n fill: currentcolor;\n font-family: var(--font-family-sans);\n font-size: 14px;\n font-weight: var(--font-sb);\n letter-spacing: 0.3px;\n line-height: 1;\n outline: none;\n text-decoration: none;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n:host .z-button--container:focus:focus-visible {\n box-shadow: var(--shadow-focus-primary);\n}\n\n:host .z-button--container.z-button--has-text {\n min-width: calc(var(--space-unit) * 8);\n padding: 0 calc(var(--space-unit) * 2);\n}\n\n:host .z-button--container.z-button--has-text z-icon {\n --z-icon-right-margin: var(--space-unit);\n}\n\n:host([size=\"big\"]) .z-button--container {\n min-width: 44px;\n height: 44px;\n}\n\n:host([size=\"small\"]) .z-button--container {\n min-width: 36px;\n height: 36px;\n}\n\n:host([size=\"x-small\"]) .z-button--container {\n min-width: 32px;\n height: 32px;\n}\n\n:host([variant=\"primary\"]) .z-button--container {\n border-color: var(--color-primary01);\n background-color: var(--color-primary01);\n color: var(--color-text-inverse);\n}\n\n@media (hover: hover) {\n :host([variant=\"primary\"]) .z-button--container:hover {\n border-color: var(--color-hover-primary);\n background-color: var(--color-hover-primary);\n color: var(--color-text-inverse);\n }\n}\n\n:host([variant=\"primary\"]) .z-button--container:active {\n border-color: var(--color-pressed-primary);\n background-color: var(--color-pressed-primary);\n box-shadow: var(--shadow-2);\n color: var(--color-text-inverse);\n}\n\n:host([variant=\"primary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-disabled01);\n color: var(--color-disabled03);\n}\n\n:host([variant=\"secondary\"]) .z-button--container {\n border-color: var(--color-primary01);\n background-color: var(--color-button-secondary);\n color: var(--color-primary01);\n}\n\n@media (hover: hover) {\n :host([variant=\"secondary\"]) .z-button--container:hover {\n border-color: var(--color-hover-primary);\n background-color: var(--color-button-secondary);\n color: var(--color-hover-primary);\n }\n}\n\n:host([variant=\"secondary\"]) .z-button--container:active {\n border-color: var(--color-pressed-primary);\n background-color: var(--color-button-secondary);\n box-shadow: var(--shadow-2);\n color: var(--color-pressed-primary);\n}\n\n:host([variant=\"secondary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-button-secondary);\n color: var(--color-disabled03);\n}\n\n:host([variant=\"tertiary\"]) .z-button--container {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n color: var(--color-primary01);\n}\n\n@media (hover: hover) {\n :host([variant=\"tertiary\"]) .z-button--container:hover {\n border-color: var(--color-primary03);\n background-color: var(--color-primary03);\n color: var(--color-hover-primary);\n }\n}\n\n:host([variant=\"tertiary\"]) .z-button--container:focus:focus-visible {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n color: var(--color-primary01);\n}\n\n:host([variant=\"tertiary\"]) .z-button--container:active {\n border-color: var(--color-primary02);\n background-color: var(--color-primary02);\n box-shadow: var(--shadow-2);\n color: var(--color-primary01);\n}\n\n:host([variant=\"tertiary\"][disabled]:not([disabled=\"false\"])) .z-button--container {\n border-color: var(--color-disabled01);\n background-color: var(--color-disabled01);\n color: var(--color-disabled03);\n}\n","import {Component, Element, Prop, h} from \"@stencil/core\";\nimport {JSXBase} from \"@stencil/core/internal\";\nimport {ButtonSize, ButtonType, ButtonVariant, ControlSize} from \"../../beans\";\n\n/**\n * @slot - button label\n */\n@Component({\n tag: \"z-button\",\n styleUrl: \"styles.css\",\n shadow: false,\n scoped: true,\n})\nexport class ZButton {\n @Element() hostElement: HTMLZButtonElement;\n\n /** defines a string value that labels an interactive element, used for accessibility. */\n @Prop({reflect: true})\n ariaLabel = \"\";\n\n /** defines role attribute, used for accessibility. */\n @Prop()\n role = \"\";\n\n /** HTML <a> href attribute. If it is set, it renders an HTML <a> tag. */\n @Prop()\n href?: string;\n\n /** HTML a target attribute. */\n @Prop()\n target?: string;\n\n /** Identifier, should be unique. */\n @Prop()\n htmlid?: string;\n\n /** HTML button name attribute. */\n @Prop()\n name?: string;\n\n /** HTML button disabled attribute. */\n @Prop({reflect: true})\n disabled?: boolean = false;\n\n /** HTML button type attribute. */\n @Prop()\n type?: ButtonType = ButtonType.BUTTON;\n\n /** Graphical variant: `primary`, `secondary`, `tertiary`. Defaults to `primary`. */\n @Prop({reflect: true})\n variant?: ButtonVariant = ButtonVariant.PRIMARY;\n\n /** `z-icon` name to use (optional). */\n @Prop()\n icon?: string;\n\n /** Available sizes: `big`, `small` and `x-small`. Defaults to `big`. */\n @Prop({reflect: true})\n size?: ButtonSize | ControlSize = ControlSize.BIG;\n\n private getAttributes(): JSXBase.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement> {\n return {\n id: this.htmlid,\n class: {\n \"z-button--container\": true,\n \"z-button--has-text\": !!this.hostElement.textContent.trim(),\n },\n };\n }\n\n render(): HTMLAnchorElement | HTMLButtonElement {\n if (this.href) {\n return (\n <a\n {...this.getAttributes()}\n aria-label={this.ariaLabel}\n href={this.href}\n target={this.target}\n >\n {this.icon && <z-icon name={this.icon} />}\n <slot />\n </a>\n );\n }\n\n return (\n <button\n {...this.getAttributes()}\n aria-label={this.ariaLabel}\n name={this.name}\n type={this.type}\n role={this.role}\n disabled={this.disabled}\n >\n {this.icon && <z-icon name={this.icon} />}\n <slot />\n </button>\n );\n }\n}\n"],"version":3}
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
2
2
  import { g as KeyboardCode } from './index2.js';
3
3
  import { d as defineCustomElement$2 } from './index9.js';
4
4
 
5
- const stylesCss = ":host{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:0;font-family:var(--font-family-sans)}:host,::slotted(*),*{box-sizing:border-box}::slotted(a){text-decoration:none}::slotted(*){color:var(--color-default-text);font-family:var(--font-family-sans);font-weight:var(--font-rg)}.label{display:flex;width:100%;align-items:center;padding:var(--space-unit) 0;border:0;border-bottom:var(--border-size-small) solid var(--color-surface03);margin:0;background:transparent;border-radius:0;cursor:pointer;text-align:left}:host(:last-child:not([open])) .label{border-bottom:none}:host(:is([active],[open])) .label,.label:focus:focus-visible,.label:hover{border-color:var(--color-primary01)}.label:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}:host(:is([active],[open])) .label ::slotted(*),.label:focus:focus-visible ::slotted(*),.label:hover ::slotted(*){font-weight:var(--font-bd)}::slotted([data-text]){display:inline-flex;flex-direction:column}::slotted([data-text])::after{overflow:hidden;height:0;content:attr(data-text);content:attr(data-text) / \"\";font-weight:var(--font-bd);pointer-events:none;user-select:none;visibility:hidden}@media speech{::slotted([data-text])::after{display:none}}.label ::slotted(*){width:100%;margin:0;font-size:var(--font-size-3);line-height:1.5}.label z-icon{margin-left:calc(var(--space-unit) * 4);fill:var(--color-default-icon)}.items{display:flex;width:100%;flex-direction:column;padding:calc(var(--space-unit) / 2);padding-bottom:calc(var(--space-unit) * 1.5)}.items[hidden]{display:none}::slotted([slot=\"section\"]){display:inline-flex;padding:calc(var(--space-unit) / 2);margin:0;font-size:var(--font-size-1);line-height:1.333;outline:none}::slotted([slot=\"section\"]:last-of-type){border:none}::slotted([slot=\"section\"]:focus:focus-visible){box-shadow:var(--shadow-focus-primary);color:var(--color-primary01)}::slotted([slot=\"section\"]:hover),::slotted([slot=\"section\"]:focus:focus-visible),::slotted([slot=\"section\"][active]){color:var(--color-primary01);font-weight:var(--font-bd)}";
5
+ const stylesCss = ":host{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:0;font-family:var(--font-family-sans)}:host,::slotted(*),*{box-sizing:border-box}::slotted(a){text-decoration:none}::slotted(*){color:var(--color-default-text);font-family:var(--font-family-sans);font-weight:var(--font-rg)}.label{display:flex;width:100%;align-items:center;padding:var(--space-unit) 0;border:0;border-bottom:var(--border-size-small) solid var(--color-surface03);margin:0;background:transparent;border-radius:0;cursor:pointer;text-align:left}:host(:last-child:not([open])) .label{border-bottom:none}:host(:is([active],[open])) .label,.label:focus:focus-visible,.label:hover{border-color:var(--color-primary01)}.label:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}:host(:is([active],[open])) .label ::slotted(*),.label:focus:focus-visible ::slotted(*),.label:hover ::slotted(*){font-weight:var(--font-bd)}::slotted([data-text]){display:inline-flex;flex-direction:column}::slotted([data-text])::after{overflow:hidden;height:0;content:attr(data-text);content:attr(data-text) / \"\";font-weight:var(--font-bd);pointer-events:none;user-select:none;visibility:hidden}@media speech{::slotted([data-text])::after{display:none}}.label ::slotted(*){width:100%;margin:0;font-size:var(--font-size-3);line-height:1.5}.label z-icon{margin-left:calc(var(--space-unit) * 4);fill:var(--color-default-icon)}.items{display:flex;width:100%;flex-direction:column;padding:calc(var(--space-unit) / 2);padding-bottom:calc(var(--space-unit) * 1.5)}.items[hidden]{display:none}::slotted([slot=\"section\"]){display:inline-flex;padding:calc(var(--space-unit) / 2);margin:0;font-size:var(--font-size-1);line-height:1.333;outline:none}::slotted([slot=\"section\"]:last-of-type){border:none}::slotted([slot=\"section\"]:focus:focus-visible){box-shadow:var(--shadow-focus-primary);color:var(--color-primary01)}::slotted([slot=\"section\"]:hover),::slotted([slot=\"section\"]:focus:focus-visible),::slotted([slot=\"section\"]:active),::slotted([slot=\"section\"][active]),::slotted([slot=\"section\"][data-active]){color:var(--color-primary01);font-weight:var(--font-bd)}";
6
6
  const ZMenuSectionStyle0 = stylesCss;
7
7
 
8
8
  const ZMenuSection$1 = /*@__PURE__*/ proxyCustomElement(class ZMenuSection extends HTMLElement {
@@ -179,7 +179,7 @@ const ZMenuSection$1 = /*@__PURE__*/ proxyCustomElement(class ZMenuSection exten
179
179
  this.onItemsChange();
180
180
  }
181
181
  render() {
182
- return (h(Host, { key: '7096b13684165ea59a80c5aa679f9ab63c47c0c0', open: this.open }, h("button", { key: '9f170b0588f348f8b17ae9d7809c9fcbf52d9e53', ref: (el) => (this.label = el), class: "label", "aria-haspopup": `${!!this.hasItems}`, "aria-expanded": `${!!this.open}`, role: "menuitem", tabindex: this.htmlTabindex, onClick: this.onLabelClick, onKeyDown: this.onLabelKeydown }, h("slot", { key: 'bf8676afd6af9f622fed46baee5c3f2ef349e083', onSlotchange: this.onLabelSlotChange }), this.hasItems && h("z-icon", { key: '53ac6446d771a867af3474619809ffc110e4baa1', name: this.open ? "chevron-up" : "chevron-down" })), h("div", { key: '632ee96a07716da82d70b8fc8170014846f8fca4', class: "items", role: "menu", hidden: !this.open }, h("slot", { key: 'f5c81d4bf7073341a0d46a0638c8d08172c2afb9', name: "section", onSlotchange: this.onItemsChange }))));
182
+ return (h(Host, { key: '9eef5a05b215717aad80be2ec3fe859d23d52ad3', open: this.open }, h("button", { key: '7410d9fa50eeb8fdfd90fd04b32f9a14875aa606', ref: (el) => (this.label = el), class: "label", "aria-haspopup": `${!!this.hasItems}`, "aria-expanded": `${!!this.open}`, role: "menuitem", tabindex: this.htmlTabindex, onClick: this.onLabelClick, onKeyDown: this.onLabelKeydown }, h("slot", { key: 'd346a0c2fdbf294c8c663b50e75ed04057f3d4b8', onSlotchange: this.onLabelSlotChange }), this.hasItems && h("z-icon", { key: '1236be381bc589b8deb3c84bb9d7df4f3cbd7f4b', name: this.open ? "chevron-up" : "chevron-down" })), h("div", { key: '4c2fb773306316acb9926fd2cefe8d4ba5c1dad3', class: "items", role: "menu", hidden: !this.open }, h("slot", { key: 'b9f2d723eeaacfba9eabececaaa7139ff654a9c1', name: "section", onSlotchange: this.onItemsChange }))));
183
183
  }
184
184
  get host() { return this; }
185
185
  static get watchers() { return {
@@ -1 +1 @@
1
- {"file":"z-menu-section.js","mappings":";;;;AAAA,MAAM,SAAS,GAAG,ijEAAijE,CAAC;AACpkE,2BAAe,SAAS;;MCYXA,cAAY;IAkCvB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAC,QAAQ,EAAC,KAAK,QAAQ,KAAK,CAAC,CAAC,CAAC;KACxD;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACR;QAED,IAAI,CAAC,IAAI,GAAG,CAAC,I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AAI,EAAE,IAAI,CAAC,IAAI,IACnB,+DACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,KAAK,EAAC,OAAO,mBACE,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,mBACpB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAC/B,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,SAAS,EAAE,IAAI,CAAC,cAAc,IAE9B,6DAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI,EAC7C,IAAI,CAAC,QAAQ,IAAI,+DAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,YAAY,GAAG,cAAc,GAAI,CACtE,EACT,4DACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,IAElB,6DACE,IAAI,EAAC,SAAS,EACd,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ZMenuSection"],"sources":["src/components/z-menu-section/styles.css?tag=z-menu-section&encapsulation=shadow","src/components/z-menu-section/index.tsx"],"sourcesContent":[":host {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n padding: 0;\n font-family: var(--font-family-sans);\n}\n\n:host,\n::slotted(*),\n* {\n box-sizing: border-box;\n}\n\n::slotted(a) {\n text-decoration: none;\n}\n\n::slotted(*) {\n color: var(--color-default-text);\n font-family: var(--font-family-sans);\n font-weight: var(--font-rg);\n}\n\n.label {\n display: flex;\n width: 100%;\n align-items: center;\n padding: var(--space-unit) 0;\n border: 0;\n border-bottom: var(--border-size-small) solid var(--color-surface03);\n margin: 0;\n background: transparent;\n border-radius: 0;\n cursor: pointer;\n text-align: left;\n}\n\n:host(:last-child:not([open])) .label {\n border-bottom: none;\n}\n\n:host(:is([active], [open])) .label,\n.label:focus:focus-visible,\n.label:hover {\n border-color: var(--color-primary01);\n}\n\n.label:focus:focus-visible {\n box-shadow: var(--shadow-focus-primary);\n outline: none;\n}\n\n:host(:is([active], [open])) .label ::slotted(*),\n.label:focus:focus-visible ::slotted(*),\n.label:hover ::slotted(*) {\n font-weight: var(--font-bd);\n}\n\n::slotted([data-text]) {\n display: inline-flex;\n flex-direction: column;\n}\n\n/* Trick to prevent layout shifts on font-weight changes.\nThe trick is to put an hidden copy of the text already set to bold,\nso the needed space is correctly calculated before any hover/active state changes the\nfont-weight of the real text.\nThe hidden text has an height of 0px so it can expand the width without changing the height\nwhen placed below the real text using `flex-direction: column`. */\n::slotted([data-text])::after {\n overflow: hidden;\n height: 0;\n content: attr(data-text);\n content: attr(data-text) / \"\";\n font-weight: var(--font-bd);\n pointer-events: none;\n user-select: none;\n visibility: hidden;\n}\n\n@media speech {\n ::slotted([data-text])::after {\n display: none;\n }\n}\n\n.label ::slotted(*) {\n width: 100%;\n margin: 0;\n font-size: var(--font-size-3);\n line-height: 1.5;\n}\n\n.label z-icon {\n margin-left: calc(var(--space-unit) * 4);\n fill: var(--color-default-icon);\n}\n\n.items {\n display: flex;\n width: 100%;\n flex-direction: column;\n padding: calc(var(--space-unit) / 2);\n padding-bottom: calc(var(--space-unit) * 1.5);\n}\n\n.items[hidden] {\n display: none;\n}\n\n::slotted([slot=\"section\"]) {\n display: inline-flex;\n padding: calc(var(--space-unit) / 2);\n margin: 0;\n font-size: var(--font-size-1);\n line-height: 1.333;\n outline: none;\n}\n\n::slotted([slot=\"section\"]:last-of-type) {\n border: none;\n}\n\n::slotted([slot=\"section\"]:focus:focus-visible) {\n box-shadow: var(--shadow-focus-primary);\n color: var(--color-primary01);\n}\n\n::slotted([slot=\"section\"]:hover),\n::slotted([slot=\"section\"]:focus:focus-visible),\n::slotted([slot=\"section\"][active]) {\n color: var(--color-primary01);\n font-weight: var(--font-bd);\n}\n","import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\n\n/**\n * A component to create submenus inside the ZMenu.\n * @slot - Label of the menu section.\n * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `active` attribute to a slotted element to highlight it.\n */\n@Component({\n tag: \"z-menu-section\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenuSection {\n @Element() host: HTMLZMenuSectionElement;\n\n /** Active state */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Tabindex value to set on the label button.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZMenu).\n */\n @Prop()\n htmlTabindex = -1;\n\n /** The opening state of the section. */\n @Prop({mutable: true})\n open: boolean;\n\n @State()\n hasItems: boolean;\n\n @State()\n items: HTMLElement[];\n\n /** The section has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The section has been closed. */\n @Event()\n closed: EventEmitter;\n\n private label: HTMLButtonElement;\n\n private get focusableItem(): HTMLElement {\n return this.items.find(({tabIndex}) => tabIndex === 0);\n }\n\n private toggle(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.open = !this.open;\n }\n\n private setItemsA11yAttrs(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.items.forEach((item) => {\n item.setAttribute(\"role\", \"menuitem\");\n item.tabIndex = -1;\n });\n }\n\n private onItemsChange(): void {\n this.items = Array.from(this.host.querySelectorAll('[slot=\"section\"]')) as HTMLElement[];\n this.hasItems = this.items.length > 0;\n this.setItemsA11yAttrs();\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.focustFirstItem();\n }\n }\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n */\n private moveFocus(receiver: HTMLElement, current?: HTMLElement): void {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n if (current) {\n current.tabIndex = -1;\n }\n }\n\n private focustFirstItem(): void {\n this.moveFocus(this.items[0]);\n }\n\n /** Focus the last item. */\n @Method()\n async focusLastItem(): Promise<void> {\n this.moveFocus(this.items[this.items.length - 1]);\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n setTimeout(() => {\n this.label.focus();\n }, 100);\n }\n\n @Watch(\"open\")\n onOpenChange(): void {\n if (!this.open) {\n this.setItemsA11yAttrs();\n this.closed.emit();\n } else {\n this.opened.emit();\n }\n }\n\n @Watch(\"htmlTabindex\")\n onTabindexChange(): void {\n if (!this.label) {\n return;\n }\n\n this.label.tabIndex = this.htmlTabindex;\n }\n\n @Listen(\"keydown\")\n private onItemsKeydown(ev: KeyboardEvent): void {\n switch (ev.key) {\n case KeyboardCode.ESC:\n case KeyboardCode.ARROW_LEFT:\n if (!this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(this.label, this.focusableItem);\n this.open = false;\n break;\n case KeyboardCode.ARROW_RIGHT:\n if (this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.focustFirstItem();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (!this.open) {\n break;\n }\n if (document.activeElement === this.host) {\n ev.preventDefault();\n ev.stopPropagation();\n this.focustFirstItem();\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex + 1];\n if (receiver) {\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(receiver, this.focusableItem);\n } else {\n this.htmlTabindex = 0;\n this.focusableItem.tabIndex = -1;\n }\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (!this.open || document.activeElement === this.host) {\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex - 1];\n ev.preventDefault();\n ev.stopPropagation();\n if (receiver) {\n this.moveFocus(receiver, this.focusableItem);\n } else {\n // since there isn't a previous item to focus, give the focus to the label element\n this.focusableItem.tabIndex = -1;\n this.setFocus();\n }\n break;\n }\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n this.onItemsKeydown = this.onItemsKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n }\n\n render(): HTMLZMenuSectionElement {\n return (\n <Host open={this.open}>\n <button\n ref={(el) => (this.label = el)}\n class=\"label\"\n aria-haspopup={`${!!this.hasItems}`}\n aria-expanded={`${!!this.open}`}\n role=\"menuitem\"\n tabindex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n {this.hasItems && <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />}\n </button>\n <div\n class=\"items\"\n role=\"menu\"\n hidden={!this.open}\n >\n <slot\n name=\"section\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"z-menu-section.js","mappings":";;;;AAAA,MAAM,SAAS,GAAG,ioEAAioE,CAAC;AACppE,2BAAe,SAAS;;MCYXA,cAAY;IAkCvB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,K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,CAAC,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IAED,iBAAiB;QACf,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,MAAM;QACJ,QACE,EAAC,IAAI,qDAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IACnB,+DACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,KAAK,EAAC,OAAO,mBACE,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,mBACpB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAC/B,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,SAAS,EAAE,IAAI,CAAC,cAAc,IAE9B,6DAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI,EAC7C,IAAI,CAAC,QAAQ,IAAI,+DAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,YAAY,GAAG,cAAc,GAAI,CACtE,EACT,4DACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,IAElB,6DACE,IAAI,EAAC,SAAS,EACd,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ZMenuSection"],"sources":["src/components/z-menu-section/styles.css?tag=z-menu-section&encapsulation=shadow","src/components/z-menu-section/index.tsx"],"sourcesContent":[":host {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n padding: 0;\n font-family: var(--font-family-sans);\n}\n\n:host,\n::slotted(*),\n* {\n box-sizing: border-box;\n}\n\n::slotted(a) {\n text-decoration: none;\n}\n\n::slotted(*) {\n color: var(--color-default-text);\n font-family: var(--font-family-sans);\n font-weight: var(--font-rg);\n}\n\n.label {\n display: flex;\n width: 100%;\n align-items: center;\n padding: var(--space-unit) 0;\n border: 0;\n border-bottom: var(--border-size-small) solid var(--color-surface03);\n margin: 0;\n background: transparent;\n border-radius: 0;\n cursor: pointer;\n text-align: left;\n}\n\n:host(:last-child:not([open])) .label {\n border-bottom: none;\n}\n\n:host(:is([active], [open])) .label,\n.label:focus:focus-visible,\n.label:hover {\n border-color: var(--color-primary01);\n}\n\n.label:focus:focus-visible {\n box-shadow: var(--shadow-focus-primary);\n outline: none;\n}\n\n:host(:is([active], [open])) .label ::slotted(*),\n.label:focus:focus-visible ::slotted(*),\n.label:hover ::slotted(*) {\n font-weight: var(--font-bd);\n}\n\n::slotted([data-text]) {\n display: inline-flex;\n flex-direction: column;\n}\n\n/* Trick to prevent layout shifts on font-weight changes.\nThe trick is to put an hidden copy of the text already set to bold,\nso the needed space is correctly calculated before any hover/active state changes the\nfont-weight of the real text.\nThe hidden text has an height of 0px so it can expand the width without changing the height\nwhen placed below the real text using `flex-direction: column`. */\n::slotted([data-text])::after {\n overflow: hidden;\n height: 0;\n content: attr(data-text);\n content: attr(data-text) / \"\";\n font-weight: var(--font-bd);\n pointer-events: none;\n user-select: none;\n visibility: hidden;\n}\n\n@media speech {\n ::slotted([data-text])::after {\n display: none;\n }\n}\n\n.label ::slotted(*) {\n width: 100%;\n margin: 0;\n font-size: var(--font-size-3);\n line-height: 1.5;\n}\n\n.label z-icon {\n margin-left: calc(var(--space-unit) * 4);\n fill: var(--color-default-icon);\n}\n\n.items {\n display: flex;\n width: 100%;\n flex-direction: column;\n padding: calc(var(--space-unit) / 2);\n padding-bottom: calc(var(--space-unit) * 1.5);\n}\n\n.items[hidden] {\n display: none;\n}\n\n::slotted([slot=\"section\"]) {\n display: inline-flex;\n padding: calc(var(--space-unit) / 2);\n margin: 0;\n font-size: var(--font-size-1);\n line-height: 1.333;\n outline: none;\n}\n\n::slotted([slot=\"section\"]:last-of-type) {\n border: none;\n}\n\n::slotted([slot=\"section\"]:focus:focus-visible) {\n box-shadow: var(--shadow-focus-primary);\n color: var(--color-primary01);\n}\n\n::slotted([slot=\"section\"]:hover),\n::slotted([slot=\"section\"]:focus:focus-visible),\n::slotted([slot=\"section\"]:active),\n::slotted([slot=\"section\"][active]),\n::slotted([slot=\"section\"][data-active]) {\n color: var(--color-primary01);\n font-weight: var(--font-bd);\n}\n","import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\n\n/**\n * A component to create submenus inside the ZMenu.\n * @slot - Label of the menu section.\n * @slot section - Single entry of the menu section. Set the same slot name to different elements to put many of them. Add the `data-active` attribute to a slotted element to highlight it (`active` also works but `data-active` is preferable).\n */\n@Component({\n tag: \"z-menu-section\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenuSection {\n @Element() host: HTMLZMenuSectionElement;\n\n /** Active state */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Tabindex value to set on the label button.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZMenu).\n */\n @Prop()\n htmlTabindex = -1;\n\n /** The opening state of the section. */\n @Prop({mutable: true})\n open: boolean;\n\n @State()\n hasItems: boolean;\n\n @State()\n items: HTMLElement[];\n\n /** The section has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The section has been closed. */\n @Event()\n closed: EventEmitter;\n\n private label: HTMLButtonElement;\n\n private get focusableItem(): HTMLElement {\n return this.items.find(({tabIndex}) => tabIndex === 0);\n }\n\n private toggle(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.open = !this.open;\n }\n\n private setItemsA11yAttrs(): void {\n if (!this.hasItems) {\n return;\n }\n\n this.items.forEach((item) => {\n item.setAttribute(\"role\", \"menuitem\");\n item.tabIndex = -1;\n });\n }\n\n private onItemsChange(): void {\n this.items = Array.from(this.host.querySelectorAll('[slot=\"section\"]')) as HTMLElement[];\n this.hasItems = this.items.length > 0;\n this.setItemsA11yAttrs();\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.focustFirstItem();\n }\n }\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n */\n private moveFocus(receiver: HTMLElement, current?: HTMLElement): void {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n if (current) {\n current.tabIndex = -1;\n }\n }\n\n private focustFirstItem(): void {\n this.moveFocus(this.items[0]);\n }\n\n /** Focus the last item. */\n @Method()\n async focusLastItem(): Promise<void> {\n this.moveFocus(this.items[this.items.length - 1]);\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n setTimeout(() => {\n this.label.focus();\n }, 100);\n }\n\n @Watch(\"open\")\n onOpenChange(): void {\n if (!this.open) {\n this.setItemsA11yAttrs();\n this.closed.emit();\n } else {\n this.opened.emit();\n }\n }\n\n @Watch(\"htmlTabindex\")\n onTabindexChange(): void {\n if (!this.label) {\n return;\n }\n\n this.label.tabIndex = this.htmlTabindex;\n }\n\n @Listen(\"keydown\")\n private onItemsKeydown(ev: KeyboardEvent): void {\n switch (ev.key) {\n case KeyboardCode.ESC:\n case KeyboardCode.ARROW_LEFT:\n if (!this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(this.label, this.focusableItem);\n this.open = false;\n break;\n case KeyboardCode.ARROW_RIGHT:\n if (this.open) {\n break;\n }\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.focustFirstItem();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (!this.open) {\n break;\n }\n if (document.activeElement === this.host) {\n ev.preventDefault();\n ev.stopPropagation();\n this.focustFirstItem();\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex + 1];\n if (receiver) {\n ev.preventDefault();\n ev.stopPropagation();\n this.moveFocus(receiver, this.focusableItem);\n } else {\n this.htmlTabindex = 0;\n this.focusableItem.tabIndex = -1;\n }\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (!this.open || document.activeElement === this.host) {\n break;\n }\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex - 1];\n ev.preventDefault();\n ev.stopPropagation();\n if (receiver) {\n this.moveFocus(receiver, this.focusableItem);\n } else {\n // since there isn't a previous item to focus, give the focus to the label element\n this.focusableItem.tabIndex = -1;\n this.setFocus();\n }\n break;\n }\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n this.onItemsKeydown = this.onItemsKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n }\n\n render(): HTMLZMenuSectionElement {\n return (\n <Host open={this.open}>\n <button\n ref={(el) => (this.label = el)}\n class=\"label\"\n aria-haspopup={`${!!this.hasItems}`}\n aria-expanded={`${!!this.open}`}\n role=\"menuitem\"\n tabindex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n {this.hasItems && <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />}\n </button>\n <div\n class=\"items\"\n role=\"menu\"\n hidden={!this.open}\n >\n <slot\n name=\"section\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </Host>\n );\n }\n}\n"],"version":3}