wj-elements 0.2.0-alpha.9 → 0.3.0-alpha.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.
- package/dist/animations.js.map +1 -1
- package/dist/base-path.js.map +1 -1
- package/dist/dark.css +15 -1
- package/dist/date.js.map +1 -1
- package/dist/element-utils.js.map +1 -1
- package/dist/event.js.map +1 -1
- package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
- package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
- package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
- package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
- package/dist/light.css +7 -2
- package/dist/localize.js +8 -5
- package/dist/localize.js.map +1 -1
- package/dist/packages/internals/form-associated-element.d.ts +0 -1
- package/dist/packages/utils/utils.d.ts +16 -0
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -0
- package/dist/packages/wje-avatar/avatar.element.d.ts +5 -0
- package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +1 -0
- package/dist/packages/wje-button/button.element.d.ts +5 -1
- package/dist/packages/wje-button-group/button-group.element.d.ts +4 -0
- package/dist/packages/wje-card/card.element.d.ts +15 -6
- package/dist/packages/wje-carousel/carousel.element.d.ts +4 -0
- package/dist/packages/wje-checkbox/checkbox.element.d.ts +14 -0
- package/dist/packages/wje-chip/chip.element.d.ts +6 -0
- package/dist/packages/wje-color-picker/color-picker.element.d.ts +43 -1
- package/dist/packages/wje-copy-button/copy-button.element.d.ts +4 -0
- package/dist/packages/wje-dialog/dialog.element.d.ts +2 -0
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +7 -0
- package/dist/packages/wje-element/element.d.ts +55 -24
- package/dist/packages/wje-file-upload/file-upload.element.d.ts +17 -6
- package/dist/packages/wje-file-upload/service/service.d.ts +0 -23
- package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +5 -0
- package/dist/packages/wje-format-digital/format-digital.element.d.ts +2 -0
- package/dist/packages/wje-icon/icon.element.d.ts +11 -0
- package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +4 -0
- package/dist/packages/wje-img/img.element.d.ts +1 -0
- package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +4 -0
- package/dist/packages/wje-input/input.element.d.ts +9 -1
- package/dist/packages/wje-item/item.element.d.ts +8 -0
- package/dist/packages/wje-kanban/kanban.element.d.ts +4 -0
- package/dist/packages/wje-level-indicator/level-indicator.element.d.ts +17 -0
- package/dist/packages/wje-list/list.element.d.ts +4 -0
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +4 -0
- package/dist/packages/wje-option/option.element.d.ts +4 -0
- package/dist/packages/wje-options/options.element.d.ts +4 -0
- package/dist/packages/wje-orgchart/orgchart.element.d.ts +4 -0
- package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +11 -0
- package/dist/packages/wje-qr-code/qr-code.element.d.ts +63 -0
- package/dist/packages/wje-radio/radio.element.d.ts +5 -0
- package/dist/packages/wje-radio-group/radio-group.element.d.ts +16 -1
- package/dist/packages/wje-rate/rate.element.d.ts +4 -0
- package/dist/packages/wje-relative-time/relative-time.element.d.ts +2 -0
- package/dist/packages/wje-reorder/reorder.element.d.ts +4 -0
- package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +4 -0
- package/dist/packages/wje-select/select.element.d.ts +7 -0
- package/dist/packages/wje-slider/slider.element.d.ts +5 -0
- package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +4 -0
- package/dist/packages/wje-split-view/split-view.element.d.ts +1 -0
- package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
- package/dist/packages/wje-tab/tab.element.d.ts +10 -0
- package/dist/packages/wje-tab-group/tab-group.element.d.ts +11 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +20 -1
- package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +4 -0
- package/dist/packages/wje-timeline/timeline.element.d.ts +4 -0
- package/dist/packages/wje-toggle/toggle.element.d.ts +4 -0
- package/dist/packages/wje-toolbar/toolbar.element.d.ts +4 -0
- package/dist/packages/wje-tooltip/tooltip.element.d.ts +3 -0
- package/dist/packages/wje-tree/tree.element.d.ts +4 -0
- package/dist/packages/wje-tree-item/tree-item.element.d.ts +5 -0
- package/dist/permissions.js.map +1 -1
- package/dist/{popup.element-DeajFyOQ.js → popup.element-DklicGea.js} +130 -97
- package/dist/popup.element-DklicGea.js.map +1 -0
- package/dist/{router-links-CJnOdbas.js → router-links-wjqCnncc.js} +9 -3
- package/dist/router-links-wjqCnncc.js.map +1 -0
- package/dist/skeleton.css +197 -0
- package/dist/universal-service.js.map +1 -1
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/dist/wje-accordion-item.js +26 -4
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +1 -0
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +1 -0
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js +18 -0
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +1 -0
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +13 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +1 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +10 -0
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +30 -6
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card-content.js.map +1 -1
- package/dist/wje-card-controls.js.map +1 -1
- package/dist/wje-card-header.js.map +1 -1
- package/dist/wje-card-subtitle.js.map +1 -1
- package/dist/wje-card-title.js.map +1 -1
- package/dist/wje-card.js +37 -0
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +38 -4
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +48 -3
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +22 -0
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-col.js.map +1 -1
- package/dist/wje-color-picker.js +145 -31
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-container.js.map +1 -1
- package/dist/wje-copy-button.js +21 -0
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +35 -2
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-divider.js.map +1 -1
- package/dist/wje-dropdown.js +27 -3
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +87 -242
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +23 -1
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +100 -77
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-footer.js.map +1 -1
- package/dist/wje-form.js.map +1 -1
- package/dist/wje-format-digital.js +9 -0
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-grid.js.map +1 -1
- package/dist/wje-header.js.map +1 -1
- package/dist/wje-icon-library.js.map +1 -1
- package/dist/wje-icon-picker.js +15 -0
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +5 -1
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +16 -1
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +10 -0
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +2 -0
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +59 -4
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +14 -0
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +14 -0
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-label.js.map +1 -1
- package/dist/wje-level-indicator.js +36 -0
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -0
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-main.js.map +1 -1
- package/dist/wje-masonry.js.map +1 -1
- package/dist/wje-master.js +12 -3
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +1 -0
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +25 -1
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu-label.js.map +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +14 -1
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +13 -0
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart-group.js.map +1 -1
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +9 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +18 -9
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +26 -0
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +162 -20
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +49 -2
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +27 -1
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +23 -1
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +14 -1
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-dropzone.js.map +1 -1
- package/dist/wje-reorder-handle.js +21 -0
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder-item.js.map +1 -1
- package/dist/wje-reorder.js +10 -0
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-route.js.map +1 -1
- package/dist/wje-router-link.js +1 -1
- package/dist/wje-router-link.js.map +1 -1
- package/dist/wje-router-outlet.js +15 -5
- package/dist/wje-router-outlet.js.map +1 -1
- package/dist/wje-routerx.js +64 -66
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-row.js.map +1 -1
- package/dist/wje-select.js +35 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +51 -1
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +18 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +9 -0
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +1 -0
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-step.js.map +1 -1
- package/dist/wje-stepper.js +24 -1
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +59 -2
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js.map +1 -1
- package/dist/wje-tab.js +31 -1
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +96 -14
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +19 -0
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +4 -0
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +17 -1
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +14 -0
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +31 -7
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +41 -5
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +12 -1
- package/dist/wje-tree.js.map +1 -1
- package/dist/wje-visually-hidden.js.map +1 -1
- package/package.json +22 -3
- package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-animation/animation.test.d.ts +0 -1
- package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
- package/dist/packages/wje-badge/badge.test.d.ts +0 -1
- package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
- package/dist/packages/wje-button/button.test.d.ts +0 -1
- package/dist/packages/wje-chip/chip.test.d.ts +0 -1
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
- package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
- package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
- package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
- package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
- package/dist/packages/wje-select/select.test.d.ts +0 -1
- package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
- package/dist/packages/wje-toast/toast.test.d.ts +0 -1
- package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
- package/dist/packages/wje-tree/tree.test.d.ts +0 -1
- package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
- package/dist/popup.element-DeajFyOQ.js.map +0 -1
- package/dist/router-links-CJnOdbas.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-copy-button.js","sources":["../packages/wje-copy-button/service/service.js","../packages/wje-copy-button/copy-button.element.js","../packages/wje-copy-button/copy-button.js"],"sourcesContent":["/**\n * Create a node with the text content.\n * @param text\n * @returns {Element}\n */\nfunction createNode(text) {\n const node = document.createElement('pre');\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.position = 'fixed';\n node.style.top = '5px';\n node.textContent = text;\n return node;\n}\n\n/**\n * Copy the node to the clipboard.\n * @param node\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyNode(node) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(node.textContent || '');\n }\n\n const selection = getSelection(); // Firefox return null\n if (selection === null) {\n return Promise.reject(new Error());\n }\n\n selection.removeAllRanges();\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.addRange(range);\n\n // document.execCommand(\"copy\")\n selection.removeAllRanges();\n return Promise.resolve();\n}\n\n/**\n * Copy the text to the clipboard.\n * @param text\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyText(text) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(text);\n }\n\n const body = document.body;\n if (!body) {\n return Promise.reject(new Error());\n }\n\n const node = createNode(text);\n body.appendChild(node);\n copyNode(node);\n body.removeChild(node);\n return Promise.resolve();\n}\n","import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Input from '../wje-input/input.js';\nimport { copyNode, copyText } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary CopyButton is a custom web component that extends WJElement.\n * It provides a button that, when clicked, copies a specified text to the clipboard.\n * The text to be copied can be specified through the `value` attribute.\n * The CopyButton also supports keyboard interaction, copying the text when the space or enter key is pressed.\n * @documentation https://elements.webjet.sk/components/copy-button\n * @status stable\n * @augments WJElement\n * @attribute {string} for - The id of the element to copy content from.\n * @attribute {string} value - The text to be copied.\n * @slot - This is a default/unnamed slot.\n * @csspart button - Styles the button element.\n * @cssproperty --text-color - Controls the color of the text.\n * @cssproperty --background-color - Controls the background color of the button.\n * //@fires wje:copy-button - Dispatched when the button is clicked and the text is copied.\n * @tag wje-copy-button\n */\nexport default class CopyButton extends WJElement {\n /**\n * Constructor for the CopyButton class.\n * Initializes the timeout property.\n */\n constructor() {\n super();\n\n this.timeout = 1000;\n }\n\n /**\n * Setter for the value property.\n * @param {string} value The value to be set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string} The value of the value property.\n */\n get value() {\n return this.getAttribute('value') || '';\n }\n\n className = 'CopyButton';\n\n /**\n * Getter for the cssStyleSheet property.\n * @returns {string} The CSS styles.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes property.\n * @returns {Array} An empty array.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the CopyButton.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the ColorPicker element.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('offset', '5');\n tooltip.setAttribute('content', this.label || 'Copy');\n\n if (WjElementUtils.hasSlot(this)) {\n let slot = document.createElement('slot');\n tooltip.appendChild(slot);\n } else {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'clipboard');\n\n tooltip.appendChild(icon);\n this.icon = icon;\n }\n\n fragment.appendChild(tooltip);\n\n this.tooltip = tooltip;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the click, focus, and blur events.\n */\n afterDraw() {\n event.addListener(this, 'click', null, this.clicked);\n event.addListener(this, 'focus', null, this.focused);\n event.addListener(this, 'blur', null, this.blurred);\n\n event.addListener(this, 'wje-copy-button:click', null, this.copied);\n }\n\n /**\n * Handles the click event.\n * @param {Event} e The event object.\n */\n clicked = (e) => {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n };\n\n /**\n * Handles the keydown event.\n * @param {Event} e The event object.\n */\n keydown = (e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n }\n };\n\n /**\n * Handles the focus event.\n * @param {Event} e The event object.\n */\n focused = (e) => {\n e.currentTarget.addEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the blur event.\n * @param {Event} e The event object.\n */\n blurred = (e) => {\n e.currentTarget.removeEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the copied event.\n * You can override this method to customize the behavior when the text is copied.\n * @param {Event} e The event object.\n */\n copied = (e) => {\n if (this.hasOwnProperty('icon')) {\n this.icon.setAttribute('color', 'success');\n this.icon.setAttribute('name', 'check');\n }\n this.tooltip.setAttribute('content', this.labelSuccess || 'Copied');\n\n setTimeout(() => {\n if (this.hasOwnProperty('icon')) {\n this.icon.removeAttribute('color');\n this.icon.setAttribute('name', 'clipboard');\n }\n this.tooltip.setAttribute('content', this.label || 'Copy');\n }, this.timeout);\n };\n\n /**\n * Copies the specified text or node.\n * @param {HTMLElement} button The button element.\n */\n async copy(button) {\n const id = this.getAttribute('for');\n const text = this.getAttribute('value');\n\n if (button.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n if (text) {\n await copyText(text);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n } else if (id) {\n const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument;\n if (!(root instanceof Document || ('ShadowRoot' in window && root instanceof ShadowRoot))) return;\n\n const node = root.getElementById(id);\n if (node) {\n await this.copyTarget(node);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n }\n }\n }\n\n /**\n * Copies the target content.\n * @param {HTMLElement} content The content to be copied.\n * @returns {Promise} A promise that resolves when the content is copied.\n */\n copyTarget(content) {\n if (content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement || content instanceof Input) {\n return copyText(content.value);\n } else if (content instanceof HTMLAnchorElement && content.hasAttribute('href')) {\n return copyText(content.href);\n } else {\n return copyNode(content);\n }\n }\n}\n","import CopyButton from './copy-button.element.js';\n\nexport default CopyButton;\n\nCopyButton.define('wje-copy-button', CopyButton);\n"],"names":[],"mappings":";;;;;;;AAKA,SAAS,WAAW,MAAM;AACtB,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,SAAS;AACpB,OAAK,MAAM,WAAW;AACtB,OAAK,MAAM,MAAM;AACjB,OAAK,cAAc;AACnB,SAAO;AACX;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,KAAK,eAAe,EAAE;AAAA,EACnE;AAEI,QAAM,YAAY;AAClB,MAAI,cAAc,MAAM;AACpB,WAAO,QAAQ,OAAO,IAAI,OAAO;AAAA,EACzC;AAEI,YAAU,gBAAiB;AAE3B,QAAM,QAAQ,SAAS,YAAa;AACpC,QAAM,mBAAmB,IAA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.js","../packages/wje-copy-button/copy-button.element.js","../packages/wje-copy-button/copy-button.js"],"sourcesContent":["/**\n * Create a node with the text content.\n * @param text\n * @returns {Element}\n */\nfunction createNode(text) {\n const node = document.createElement('pre');\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.position = 'fixed';\n node.style.top = '5px';\n node.textContent = text;\n return node;\n}\n\n/**\n * Copy the node to the clipboard.\n * @param node\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyNode(node) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(node.textContent || '');\n }\n\n const selection = getSelection(); // Firefox return null\n if (selection === null) {\n return Promise.reject(new Error());\n }\n\n selection.removeAllRanges();\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.addRange(range);\n\n // document.execCommand(\"copy\")\n selection.removeAllRanges();\n return Promise.resolve();\n}\n\n/**\n * Copy the text to the clipboard.\n * @param text\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyText(text) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(text);\n }\n\n const body = document.body;\n if (!body) {\n return Promise.reject(new Error());\n }\n\n const node = createNode(text);\n body.appendChild(node);\n copyNode(node);\n body.removeChild(node);\n return Promise.resolve();\n}\n","import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Input from '../wje-input/input.js';\nimport { copyNode, copyText } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary CopyButton is a custom web component that extends WJElement.\n * It provides a button that, when clicked, copies a specified text to the clipboard.\n * The text to be copied can be specified through the `value` attribute.\n * The CopyButton also supports keyboard interaction, copying the text when the space or enter key is pressed.\n * @documentation https://elements.webjet.sk/components/copy-button\n * @status stable\n * @augments WJElement\n * @attribute {string} for - The id of the element to copy content from.\n * @attribute {string} value - The text to be copied.\n * @slot - This is a default/unnamed slot.\n * @csspart button - Styles the button element.\n * @cssproperty --text-color - Controls the color of the text.\n * @cssproperty --background-color - Controls the background color of the button.\n * //@fires wje:copy-button - Dispatched when the button is clicked and the text is copied.\n * @tag wje-copy-button\n */\nexport default class CopyButton extends WJElement {\n /**\n * Constructor for the CopyButton class.\n * Initializes the timeout property.\n */\n constructor() {\n super();\n\n this.timeout = 1000;\n }\n\n /**\n * Setter for the value property.\n * @param {string} value The value to be set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string} The value of the value property.\n */\n get value() {\n return this.getAttribute('value') || '';\n }\n\n className = 'CopyButton';\n\n /**\n * Getter for the cssStyleSheet property.\n * @returns {string} The CSS styles.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes property.\n * @returns {Array} An empty array.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the CopyButton.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the ColorPicker element.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('offset', '5');\n tooltip.setAttribute('content', this.label || 'Copy');\n\n if (WjElementUtils.hasSlot(this)) {\n let slot = document.createElement('slot');\n tooltip.appendChild(slot);\n } else {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'clipboard');\n\n tooltip.appendChild(icon);\n this.icon = icon;\n }\n\n fragment.appendChild(tooltip);\n\n this.tooltip = tooltip;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the click, focus, and blur events.\n */\n afterDraw() {\n this.syncAria();\n event.addListener(this, 'click', null, this.clicked);\n event.addListener(this, 'focus', null, this.focused);\n event.addListener(this, 'blur', null, this.blurred);\n\n event.addListener(this, 'wje-copy-button:click', null, this.copied);\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'button' });\n }\n\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label') || this.label || 'Copy';\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n\n if (this.hasAttribute('disabled')) {\n this.setAriaState({ disabled: true });\n }\n }\n\n /**\n * Handles the click event.\n * @param {Event} e The event object.\n */\n clicked = (e) => {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n };\n\n /**\n * Handles the keydown event.\n * @param {Event} e The event object.\n */\n keydown = (e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n }\n };\n\n /**\n * Handles the focus event.\n * @param {Event} e The event object.\n */\n focused = (e) => {\n e.currentTarget.addEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the blur event.\n * @param {Event} e The event object.\n */\n blurred = (e) => {\n e.currentTarget.removeEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the copied event.\n * You can override this method to customize the behavior when the text is copied.\n * @param {Event} e The event object.\n */\n copied = (e) => {\n if (this.hasOwnProperty('icon')) {\n this.icon.setAttribute('color', 'success');\n this.icon.setAttribute('name', 'check');\n }\n this.tooltip.setAttribute('content', this.labelSuccess || 'Copied');\n\n setTimeout(() => {\n if (this.hasOwnProperty('icon')) {\n this.icon.removeAttribute('color');\n this.icon.setAttribute('name', 'clipboard');\n }\n this.tooltip.setAttribute('content', this.label || 'Copy');\n }, this.timeout);\n };\n\n /**\n * Copies the specified text or node.\n * @param {HTMLElement} button The button element.\n */\n async copy(button) {\n const id = this.getAttribute('for');\n const text = this.getAttribute('value');\n\n if (button.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n if (text) {\n await copyText(text);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n } else if (id) {\n const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument;\n if (!(root instanceof Document || ('ShadowRoot' in window && root instanceof ShadowRoot))) return;\n\n const node = root.getElementById(id);\n if (node) {\n await this.copyTarget(node);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n }\n }\n }\n\n /**\n * Copies the target content.\n * @param {HTMLElement} content The content to be copied.\n * @returns {Promise} A promise that resolves when the content is copied.\n */\n copyTarget(content) {\n if (content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement || content instanceof Input) {\n return copyText(content.value);\n } else if (content instanceof HTMLAnchorElement && content.hasAttribute('href')) {\n return copyText(content.href);\n } else {\n return copyNode(content);\n }\n }\n}\n","import CopyButton from './copy-button.element.js';\n\nexport default CopyButton;\n\nCopyButton.define('wje-copy-button', CopyButton);\n"],"names":[],"mappings":";;;;;;;AAKA,SAAS,WAAW,MAAM;AACtB,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,SAAS;AACpB,OAAK,MAAM,WAAW;AACtB,OAAK,MAAM,MAAM;AACjB,OAAK,cAAc;AACnB,SAAO;AACX;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,KAAK,eAAe,EAAE;AAAA,EAC/D;AAEA,QAAM,YAAY;AAClB,MAAI,cAAc,MAAM;AACpB,WAAO,QAAQ,OAAO,IAAI,OAAO;AAAA,EACrC;AAEA,YAAU,gBAAe;AAEzB,QAAM,QAAQ,SAAS,YAAW;AAClC,QAAM,mBAAmB,IAAI;AAC7B,YAAU,SAAS,KAAK;AAGxB,YAAU,gBAAe;AACzB,SAAO,QAAQ,QAAO;AAC1B;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,IAAI;AAAA,EAC7C;AAEA,QAAM,OAAO,SAAS;AACtB,MAAI,CAAC,MAAM;AACP,WAAO,QAAQ,OAAO,IAAI,OAAO;AAAA,EACrC;AAEA,QAAM,OAAO,WAAW,IAAI;AAC5B,OAAK,YAAY,IAAI;AACrB,WAAS,IAAI;AACb,OAAK,YAAY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AChC,OAAO;AACH,aAAO,SAAS,OAAO;AAAA,IAC3B;AAAA,EACJ;AACJ;AC7OA,WAAW,OAAO,mBAAmB,UAAU;"}
|
package/dist/wje-dialog.js
CHANGED
|
@@ -140,6 +140,7 @@ dialog:focus-visible {
|
|
|
140
140
|
|
|
141
141
|
:host {
|
|
142
142
|
dialog {
|
|
143
|
+
background: var(--wje-dialog-background);
|
|
143
144
|
box-sizing: border-box;
|
|
144
145
|
transition: all 0.2s !important;
|
|
145
146
|
width: var(--wje-dialog-width);
|
|
@@ -279,7 +280,7 @@ dialog[open] {
|
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
`;
|
|
282
|
-
class
|
|
283
|
+
const _Dialog = class _Dialog extends WJElement {
|
|
283
284
|
/**
|
|
284
285
|
* @class
|
|
285
286
|
*/
|
|
@@ -320,6 +321,7 @@ class Dialog extends WJElement {
|
|
|
320
321
|
}
|
|
321
322
|
});
|
|
322
323
|
});
|
|
324
|
+
this._instanceId = ++_Dialog._instanceId;
|
|
323
325
|
}
|
|
324
326
|
/**
|
|
325
327
|
* Sets the value of the 'headline' attribute.
|
|
@@ -443,6 +445,7 @@ class Dialog extends WJElement {
|
|
|
443
445
|
* @param dialog
|
|
444
446
|
*/
|
|
445
447
|
htmlDialogBody(dialog) {
|
|
448
|
+
const dialogId = this.id || `wje-dialog-${this._instanceId}`;
|
|
446
449
|
let icon = document.createElement("wje-icon");
|
|
447
450
|
icon.setAttribute("name", "x");
|
|
448
451
|
icon.setAttribute("slot", "icon-only");
|
|
@@ -450,12 +453,14 @@ class Dialog extends WJElement {
|
|
|
450
453
|
close.setAttribute("fill", "link");
|
|
451
454
|
close.setAttribute("size", "small");
|
|
452
455
|
close.setAttribute("part", "close");
|
|
456
|
+
close.setAttribute("aria-label", "Close dialog");
|
|
453
457
|
close.addEventListener("click", (e) => {
|
|
454
458
|
this.close(e);
|
|
455
459
|
});
|
|
456
460
|
let header = document.createElement("div");
|
|
457
461
|
header.setAttribute("part", "header");
|
|
458
462
|
header.classList.add("dialog-header");
|
|
463
|
+
header.id = `${dialogId}-header`;
|
|
459
464
|
if (this.hasAttribute("headline"))
|
|
460
465
|
header.innerHTML = `<span part="headline">${this.headline}</span>`;
|
|
461
466
|
let slotHeader = document.createElement("slot");
|
|
@@ -468,6 +473,7 @@ class Dialog extends WJElement {
|
|
|
468
473
|
let body = document.createElement("div");
|
|
469
474
|
body.setAttribute("part", "body");
|
|
470
475
|
body.classList.add("dialog-content");
|
|
476
|
+
body.id = `${dialogId}-body`;
|
|
471
477
|
let footer = document.createElement("div");
|
|
472
478
|
footer.setAttribute("part", "footer");
|
|
473
479
|
footer.classList.add("dialog-footer");
|
|
@@ -484,6 +490,31 @@ class Dialog extends WJElement {
|
|
|
484
490
|
if (!this.hiddenHeader) dialog.appendChild(header);
|
|
485
491
|
dialog.appendChild(body);
|
|
486
492
|
if (!this.hiddenFooter) dialog.appendChild(footer);
|
|
493
|
+
dialog.setAttribute("role", "dialog");
|
|
494
|
+
dialog.setAttribute("aria-modal", "true");
|
|
495
|
+
dialog.setAttribute("aria-describedby", body.id);
|
|
496
|
+
if (!this.hiddenHeader) {
|
|
497
|
+
dialog.setAttribute("aria-labelledby", header.id);
|
|
498
|
+
} else {
|
|
499
|
+
dialog.removeAttribute("aria-labelledby");
|
|
500
|
+
}
|
|
501
|
+
const ariaState = {
|
|
502
|
+
role: "dialog",
|
|
503
|
+
modal: true,
|
|
504
|
+
describedBy: body.id
|
|
505
|
+
};
|
|
506
|
+
if (!this.hiddenHeader) {
|
|
507
|
+
ariaState.labelledBy = header.id;
|
|
508
|
+
this.removeAttribute("aria-label");
|
|
509
|
+
} else {
|
|
510
|
+
this.removeAttribute("aria-labelledby");
|
|
511
|
+
if (this.headline) {
|
|
512
|
+
ariaState.label = this.headline;
|
|
513
|
+
} else {
|
|
514
|
+
this.removeAttribute("aria-label");
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
this.setAriaState(ariaState);
|
|
487
518
|
Promise.resolve().then(() => this.updateHasFooter());
|
|
488
519
|
}
|
|
489
520
|
/**
|
|
@@ -572,7 +603,9 @@ class Dialog extends WJElement {
|
|
|
572
603
|
if (footerEl) footerEl.toggleAttribute("hidden", !hasContent);
|
|
573
604
|
this.toggleAttribute("has-footer", hasContent);
|
|
574
605
|
}
|
|
575
|
-
}
|
|
606
|
+
};
|
|
607
|
+
__publicField(_Dialog, "_instanceId", 0);
|
|
608
|
+
let Dialog = _Dialog;
|
|
576
609
|
Dialog.define("wje-dialog", Dialog);
|
|
577
610
|
export {
|
|
578
611
|
Dialog as default
|
package/dist/wje-dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-dialog.js","sources":["../packages/wje-dialog/dialog.element.js","../packages/wje-dialog/dialog.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n /**\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'headline' attribute.\n * @param {string} value The new value for the 'headline' attribute.\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Retrieves the value of the \"headline\" attribute from the element.\n * If the \"headline\" attribute is not present, returns an empty string.\n * @returns {string} The headline attribute value or an empty string if not set.\n */\n get headline() {\n return this.getAttribute('headline') || '';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n set hiddenHeader(value) {\n if (value) this.setAttribute('hidden-header', '');\n }\n\n get hiddenHeader() {\n return !!this.hasAttribute('hidden-header');\n }\n\n set hiddenFooter(value) {\n if (value) this.setAttribute('hidden-footer', '');\n }\n\n get hiddenFooter() {\n return !!this.hasAttribute('hidden-footer');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.setAttribute('part', 'dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n\n return fragment;\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.headline}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n slotFooter.id = 'footerSlot';\n slotFooter.addEventListener('slotchange', () => this.updateHasFooter());\n\n close.appendChild(icon);\n\n if (!this.closeHidden) header.appendChild(close);\n\n header.appendChild(headerActions);\n body.appendChild(contentSlot);\n footer.appendChild(slotFooter);\n\n if (!this.hiddenHeader) dialog.appendChild(header);\n dialog.appendChild(body);\n if (!this.hiddenFooter) dialog.appendChild(footer);\n\n // Slot assignment may not be reflected synchronously on first render.\n // Run in a microtask to ensure assignedNodes() sees slotted content.\n Promise.resolve().then(() => this.updateHasFooter());\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen(dialog, trigger) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen(dialog, trigger) {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose(dialog, trigger) {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose(dialog, trigger) {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n if (this.dialog) {\n this.dialog.innerHTML = '';\n }\n\n setTimeout(() => {\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n }, 0);\n }\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n\n updateHasFooter() {\n // If footer is intentionally hidden, ensure it doesn't reserve space\n if (this.hiddenFooter) {\n const footerEl = this.shadowRoot?.querySelector('.dialog-footer');\n if (footerEl) footerEl.setAttribute('hidden', '');\n this.removeAttribute('has-footer');\n return;\n }\n const slot = this.shadowRoot?.getElementById('footerSlot');\n if (!slot) {\n this.removeAttribute('has-footer');\n return;\n }\n\n const assigned = slot.assignedNodes({ flatten: true });\n const hasContent = assigned.some((n) => {\n if (n.nodeType === Node.ELEMENT_NODE) return true;\n if (n.nodeType === Node.TEXT_NODE) return n.textContent.trim().length > 0;\n return false;\n });\n\n // Prefer toggling the actual footer element so CSS/spacing is always correct\n const footerEl = this.shadowRoot?.querySelector('.dialog-footer');\n if (footerEl) footerEl.toggleAttribute('hidden', !hasContent);\n\n // Keep host attribute too (harmless, may be used elsewhere)\n this.toggleAttribute('has-footer', hasContent);\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport default Dialog;\n\nDialog.define('wje-dialog', Dialog);\n"],"names":["footerEl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n static _instanceId = 0;\n /**\n * @class\n */\n constructor() {\n super();\n this._instanceId = ++Dialog._instanceId;\n }\n\n /**\n * Sets the value of the 'headline' attribute.\n * @param {string} value The new value for the 'headline' attribute.\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Retrieves the value of the \"headline\" attribute from the element.\n * If the \"headline\" attribute is not present, returns an empty string.\n * @returns {string} The headline attribute value or an empty string if not set.\n */\n get headline() {\n return this.getAttribute('headline') || '';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n set hiddenHeader(value) {\n if (value) this.setAttribute('hidden-header', '');\n }\n\n get hiddenHeader() {\n return !!this.hasAttribute('hidden-header');\n }\n\n set hiddenFooter(value) {\n if (value) this.setAttribute('hidden-footer', '');\n }\n\n get hiddenFooter() {\n return !!this.hasAttribute('hidden-footer');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.setAttribute('part', 'dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n\n return fragment;\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n const dialogId = this.id || `wje-dialog-${this._instanceId}`;\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.setAttribute('aria-label', 'Close dialog');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n header.id = `${dialogId}-header`;\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.headline}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n body.id = `${dialogId}-body`;\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n slotFooter.id = 'footerSlot';\n slotFooter.addEventListener('slotchange', () => this.updateHasFooter());\n\n close.appendChild(icon);\n\n if (!this.closeHidden) header.appendChild(close);\n\n header.appendChild(headerActions);\n body.appendChild(contentSlot);\n footer.appendChild(slotFooter);\n\n if (!this.hiddenHeader) dialog.appendChild(header);\n dialog.appendChild(body);\n if (!this.hiddenFooter) dialog.appendChild(footer);\n\n dialog.setAttribute('role', 'dialog');\n dialog.setAttribute('aria-modal', 'true');\n dialog.setAttribute('aria-describedby', body.id);\n if (!this.hiddenHeader) {\n dialog.setAttribute('aria-labelledby', header.id);\n } else {\n dialog.removeAttribute('aria-labelledby');\n }\n\n const ariaState = {\n role: 'dialog',\n modal: true,\n describedBy: body.id,\n };\n\n if (!this.hiddenHeader) {\n ariaState.labelledBy = header.id;\n this.removeAttribute('aria-label');\n } else {\n this.removeAttribute('aria-labelledby');\n if (this.headline) {\n ariaState.label = this.headline;\n } else {\n this.removeAttribute('aria-label');\n }\n }\n\n this.setAriaState(ariaState);\n\n Promise.resolve().then(() => this.updateHasFooter());\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen(dialog, trigger) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen(dialog, trigger) {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose(dialog, trigger) {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose(dialog, trigger) {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n if (this.dialog) {\n this.dialog.innerHTML = '';\n }\n\n setTimeout(() => {\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n }, 0);\n }\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n\n updateHasFooter() {\n // If footer is intentionally hidden, ensure it doesn't reserve space\n if (this.hiddenFooter) {\n const footerEl = this.shadowRoot?.querySelector('.dialog-footer');\n if (footerEl) footerEl.setAttribute('hidden', '');\n this.removeAttribute('has-footer');\n return;\n }\n const slot = this.shadowRoot?.getElementById('footerSlot');\n if (!slot) {\n this.removeAttribute('has-footer');\n return;\n }\n\n const assigned = slot.assignedNodes({ flatten: true });\n const hasContent = assigned.some((n) => {\n if (n.nodeType === Node.ELEMENT_NODE) return true;\n if (n.nodeType === Node.TEXT_NODE) return n.textContent.trim().length > 0;\n return false;\n });\n\n // Prefer toggling the actual footer element so CSS/spacing is always correct\n const footerEl = this.shadowRoot?.querySelector('.dialog-footer');\n if (footerEl) footerEl.toggleAttribute('hidden', !hasContent);\n\n // Keep host attribute too (harmless, may be used elsewhere)\n this.toggleAttribute('has-footer', hasContent);\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport default Dialog;\n\nDialog.define('wje-dialog', Dialog);\n"],"names":["footerEl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAc;AACnB,YAAMA,aAAW,UAAK,eAAL,mBAAiB,cAAc;AAChD,UAAIA,UAAU,CAAAA,UAAS,aAAa,UAAU,EAAE;AAChD,WAAK,gBAAgB,YAAY;AACjC;AAAA,IACJ;AACA,UAAM,QAAO,UAAK,eAAL,mBAAiB,eAAe;AAC7C,QAAI,CAAC,MAAM;AACP,WAAK,gBAAgB,YAAY;AACjC;AAAA,IACJ;AAEA,UAAM,WAAW,KAAK,cAAc,EAAE,SAAS,KAAI,CAAE;AACrD,UAAM,aAAa,SAAS,KAAK,CAAC,MAAM;AACpC,UAAI,EAAE,aAAa,KAAK,aAAc,QAAO;AAC7C,UAAI,EAAE,aAAa,KAAK,UAAW,QAAO,EAAE,YAAY,OAAO,SAAS;AACxE,aAAO;AAAA,IACX,CAAC;AAGD,UAAM,YAAW,UAAK,eAAL,mBAAiB,cAAc;AAChD,QAAI,SAAU,UAAS,gBAAgB,UAAU,CAAC,UAAU;AAG5D,SAAK,gBAAgB,cAAc,UAAU;AAAA,EACjD;AACJ;AA5YI,cADiB,SACV,eAAc;AADV,IAAM,SAAN;ACvBf,OAAO,OAAO,cAAc,MAAM;"}
|
package/dist/wje-divider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-divider.js","sources":["../packages/wje-divider/divider.element.js","../packages/wje-divider/divider.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Divider is a custom web component that extends WJElement.\n * It provides a simple divider line that can be used to separate content.\n * @documentation https://elements.webjet.sk/components/divider\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @cssproperty [--wje-border-width=1px] - The size of the border.\n * @cssproperty [--wje-divider-border-color=var(--wje-border-color)] - The color of the divider borderline.\n * @cssproperty [--wje-divider-border-width=var(--wje-border-width, 1px)] - The width of the divider borderline.\n * @cssproperty [--wje-divider-spacing=0] - The spacing for the divider.\n * @tag wje-divider\n * @tag wje-divider\n */\nexport default class Divider extends WJElement {\n /**\n * Constructor for the Divider class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Divider class.\n * @type {string}\n */\n className = 'Divider';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An empty array as there are no observed attributes.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the Divider.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Divider.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Divider from './divider.element.js';\n\nexport default Divider;\n\nDivider.define('wje-divider', Divider);\n"],"names":[],"mappings":";;;;;AAiBe,MAAM,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI3C,cAAc;AACV,
|
|
1
|
+
{"version":3,"file":"wje-divider.js","sources":["../packages/wje-divider/divider.element.js","../packages/wje-divider/divider.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Divider is a custom web component that extends WJElement.\n * It provides a simple divider line that can be used to separate content.\n * @documentation https://elements.webjet.sk/components/divider\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @cssproperty [--wje-border-width=1px] - The size of the border.\n * @cssproperty [--wje-divider-border-color=var(--wje-border-color)] - The color of the divider borderline.\n * @cssproperty [--wje-divider-border-width=var(--wje-border-width, 1px)] - The width of the divider borderline.\n * @cssproperty [--wje-divider-spacing=0] - The spacing for the divider.\n * @tag wje-divider\n * @tag wje-divider\n */\nexport default class Divider extends WJElement {\n /**\n * Constructor for the Divider class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Divider class.\n * @type {string}\n */\n className = 'Divider';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An empty array as there are no observed attributes.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the Divider.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Divider.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Divider from './divider.element.js';\n\nexport default Divider;\n\nDivider.define('wje-divider', Divider);\n"],"names":[],"mappings":";;;;;AAiBe,MAAM,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI3C,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,qBAAqB;AAC5B,WAAO,CAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AACd,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,WAAO,YAAY,IAAI;AACvB,aAAS,YAAY,MAAM;AAE3B,WAAO;AAAA,EACX;AACJ;ACjEA,QAAQ,OAAO,eAAe,OAAO;"}
|
package/dist/wje-dropdown.js
CHANGED
|
@@ -9,9 +9,9 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var _onMenuItemCustom;
|
|
11
11
|
import WJElement from "./wje-element.js";
|
|
12
|
-
import { P as Popup } from "./popup.element-
|
|
12
|
+
import { P as Popup } from "./popup.element-DklicGea.js";
|
|
13
13
|
import { event } from "./event.js";
|
|
14
|
-
class
|
|
14
|
+
const _Dropdown = class _Dropdown extends WJElement {
|
|
15
15
|
/**
|
|
16
16
|
* Creates an instance of Dropdown.
|
|
17
17
|
* @class
|
|
@@ -78,6 +78,7 @@ class Dropdown extends WJElement {
|
|
|
78
78
|
*/
|
|
79
79
|
__publicField(this, "onOpen", (e) => {
|
|
80
80
|
this.classList.add("active");
|
|
81
|
+
this.syncAria();
|
|
81
82
|
Promise.resolve(this.beforeShow(this)).then((res) => {
|
|
82
83
|
if (!this.classList.contains("active")) {
|
|
83
84
|
throw new Error("beforeShow method returned false or not string");
|
|
@@ -100,6 +101,7 @@ class Dropdown extends WJElement {
|
|
|
100
101
|
});
|
|
101
102
|
__publicField(this, "onClose", () => {
|
|
102
103
|
this.classList.remove("active");
|
|
104
|
+
this.syncAria();
|
|
103
105
|
Promise.resolve(this.beforeClose(this)).then((res) => {
|
|
104
106
|
if (this.classList.contains("active")) {
|
|
105
107
|
throw new Error("beforeShow method returned false or not string");
|
|
@@ -126,6 +128,7 @@ class Dropdown extends WJElement {
|
|
|
126
128
|
this.classList.remove("active");
|
|
127
129
|
this.popup.hide(true);
|
|
128
130
|
});
|
|
131
|
+
this._instanceId = ++_Dropdown._instanceId;
|
|
129
132
|
}
|
|
130
133
|
/**
|
|
131
134
|
* Sets or removes the 'portaled' attribute on the element.
|
|
@@ -240,17 +243,22 @@ class Dropdown extends WJElement {
|
|
|
240
243
|
this.onClose
|
|
241
244
|
);
|
|
242
245
|
}
|
|
246
|
+
this.onSlotChange = () => this.syncAria();
|
|
247
|
+
this.anchorSlot.addEventListener("slotchange", this.onSlotChange);
|
|
248
|
+
this.syncAria();
|
|
243
249
|
}
|
|
244
250
|
/**
|
|
245
251
|
* Adds event listeners for the mouseenter and mouseleave events.
|
|
246
252
|
*/
|
|
247
253
|
afterDisconnect() {
|
|
254
|
+
var _a;
|
|
248
255
|
event.removeListener(this, "mouseenter", null, this.onOpen);
|
|
249
256
|
event.removeListener(this, "mouseleave", null, this.onClose);
|
|
250
257
|
event.removeListener(this.anchorSlot, "click", null, this.toggleCallback, { capture: true });
|
|
251
258
|
event.removeListener(this, "wje-popup:hide", null, this.popupHideCallback);
|
|
252
259
|
event.removeListener(this.popup, "click", null, this.onMenuItemClick, { capture: true });
|
|
253
260
|
event.removeListener(document, "wje-menu-item:click", null, __privateGet(this, _onMenuItemCustom), false);
|
|
261
|
+
(_a = this.anchorSlot) == null ? void 0 : _a.removeEventListener("slotchange", this.onSlotChange);
|
|
254
262
|
}
|
|
255
263
|
/**
|
|
256
264
|
* @summary Returns the content to be displayed before showing the dropdown.
|
|
@@ -264,8 +272,24 @@ class Dropdown extends WJElement {
|
|
|
264
272
|
*/
|
|
265
273
|
afterShow() {
|
|
266
274
|
}
|
|
267
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Syncs ARIA attributes for the trigger element.
|
|
277
|
+
*/
|
|
278
|
+
syncAria() {
|
|
279
|
+
var _a, _b, _c, _d;
|
|
280
|
+
const triggerEl = (_c = (_b = (_a = this.anchorSlot) == null ? void 0 : _a.assignedElements) == null ? void 0 : _b.call(_a, { flatten: true })) == null ? void 0 : _c[0];
|
|
281
|
+
if (!triggerEl) return;
|
|
282
|
+
const popupId = ((_d = this.popup) == null ? void 0 : _d.id) || `wje-dropdown-popup-${this._instanceId}`;
|
|
283
|
+
if (this.popup && !this.popup.id) this.popup.id = popupId;
|
|
284
|
+
const hasMenu = !!this.querySelector("wje-menu");
|
|
285
|
+
triggerEl.setAttribute("aria-haspopup", hasMenu ? "menu" : "dialog");
|
|
286
|
+
triggerEl.setAttribute("aria-expanded", this.classList.contains("active") ? "true" : "false");
|
|
287
|
+
triggerEl.setAttribute("aria-controls", popupId);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
268
290
|
_onMenuItemCustom = new WeakMap();
|
|
291
|
+
__publicField(_Dropdown, "_instanceId", 0);
|
|
292
|
+
let Dropdown = _Dropdown;
|
|
269
293
|
Dropdown.define("wje-dropdown", Dropdown);
|
|
270
294
|
export {
|
|
271
295
|
Dropdown as default
|
package/dist/wje-dropdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-dropdown.js","sources":["../packages/wje-dropdown/dropdown.element.js","../packages/wje-dropdown/dropdown.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Popup from '../wje-popup/popup.element.js';\n\n/**\n * `Dropdown` is a custom element that displays a dropdown menu.\n * @summary This element represents a dropdown menu.\n * @documentation https://elements.webjet.sk/components/dropdown\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the dropdown.\n * @slot trigger - The slot for the trigger of the dropdown.\n * @slot - The default slot for the dropdown.\n * // @fires wje-dropdown:open - Event fired when the dropdown is opened.\n * // @fires wje-dropdown:close - Event fired when the dropdown is closed.\n * @tag wje-dropdown\n */\nexport default class Dropdown extends WJElement {\n /**\n * Creates an instance of Dropdown.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * The placement of the dropdown.\n * @type {{\"wje-popup\": Popup}}\n */\n dependencies = {\n 'wje-popup': Popup,\n };\n\n /**\n * Sets or removes the 'portaled' attribute on the element.\n * When the value is truthy, the attribute 'portaled' is added to the element.\n * When the value is falsy, the attribute 'portaled' is removed from the element.\n * @param {boolean} value Determines whether to add or remove the 'portaled' attribute.\n */\n set portaled(value) {\n if (value) {\n this.setAttribute('portaled', value);\n } else {\n this.removeAttribute('portaled');\n }\n }\n\n /**\n * Getter method for the `portaled` property.\n * Checks if the `portaled` attribute is present on the element.\n * @returns {boolean} Returns `true` if the `portaled` attribute exists, otherwise `false`.\n */\n get portaled() {\n return this.getAttribute('portaled') || '';\n }\n\n /**\n * Checks whether the element has the 'portaled' attribute.\n * @returns {boolean} True if the element has the 'portaled' attribute, otherwise false.\n */\n get isPortaled() {\n return this.hasAttribute('portaled');\n }\n\n /**\n * Sets the placement of the dropdown.\n * @param value\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Gets the placement of the dropdown.\n * @returns {string|string}\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n /**\n * Sets the placement of the dropdown.\n * @type {string}\n */\n className = 'Dropdown';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string[]}\n */\n static get observedAttributes() {\n return ['active'];\n }\n\n /**\n * Callback function to handle other dropdowns being opened. Close the dropdown if it is not the target and collapse is enabled.\n * @param {Event} e The event object.\n */\n otherDropdownOpennedCallback = (e) => {\n if (e.detail.detail.target !== this) {\n this.classList.remove('active');\n this.popup.hide();\n }\n };\n\n /**\n * Sets up the attributes for the dropdown.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Removes the popup element.\n */\n beforeDraw() {\n this.popup?.remove();\n this.popup = null;\n }\n\n /**\n * Draws the dropdown element and returns the created document fragment.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', 'wje-' + this.placement || 'wje-start');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-dropdown');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.tooltip);\n\n let anchorSlot = document.createElement('slot');\n anchorSlot.setAttribute('name', 'trigger');\n anchorSlot.setAttribute('slot', 'anchor');\n\n let slot = document.createElement('slot');\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n popup.setAttribute('part', 'popup');\n\n if(this.isPortaled)\n popup.setAttribute('portal', this.portaled);\n\n popup.append(anchorSlot, slot);\n\n // if(this.trigger === \"click\")\n popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.anchorSlot = anchorSlot;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDraw() {\n event.addListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n\n // Close when any actionable wje-menu-item inside the popup is clicked (works across Shadow DOM via composed path)\n event.addListener(this.popup, 'click', null, this.onMenuItemClick, { capture: true });\n\n if (this.trigger !== 'click') {\n event.addListener(this, 'mouseenter', null, this.onOpen);\n event.addListener(this, 'mouseleave', null, this.onClose);\n } else {\n event.addListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n }\n\n if (this.hasAttribute('collapsible')) {\n event.addListener(\n Array.from(this.querySelectorAll('wje-menu-item')),\n 'click',\n 'wje-menu-item:click',\n this.onClose\n );\n }\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDisconnect() {\n event.removeListener(this, 'mouseenter', null, this.onOpen);\n event.removeListener(this, 'mouseleave', null, this.onClose);\n event.removeListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n event.removeListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n event.removeListener(this.popup, 'click', null, this.onMenuItemClick, { capture: true });\n event.removeListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n }\n\n popupHideCallback = (e) => {\n if (this.classList.contains('active') && e.target.tagName === \"WJE-DROPDOWN\") {\n this.toggleCallback(e);\n }\n };\n\n /**\n * Handles delegated clicks from inside the popup and closes the dropdown when a leaf menu item is selected.\n * This works even when the menu is portaled, because we rely on the composed path.\n */\n onMenuItemClick = (e) => {\n // Find nearest wje-menu-item in the composed path\n const path = typeof e.composedPath === 'function' ? e.composedPath() : [];\n const item = path.find((n) => n && n.tagName === 'WJE-MENU-ITEM');\n if (!item) return;\n\n // Ignore disabled items\n if (item.hasAttribute('disabled') || item.getAttribute('aria-disabled') === 'true') return;\n\n // If this item contains a nested submenu (wje-menu), it's not a leaf -> don't close yet\n if (typeof item.querySelector === 'function' && item.querySelector('wje-menu')) return;\n\n // Leaf item selected -> close dropdown (which calls popup.hide(true) inside onClose)\n this.onClose();\n }\n\n /**\n * @summary Toggles the dropdown element between active and inactive states.\n * Calls the `onOpen` method if the element is currently inactive,\n * and calls the `onClose` method if the element is currently active.\n * @param {Event} e The event object.\n */\n toggleCallback = (e) => {\n if (this.classList.contains('active')) {\n e.stopPropagation();\n this.onClose();\n } else {\n e.stopPropagation();\n this.onOpen(e);\n }\n };\n\n /**\n * @summary Returns the content to be displayed before showing the dropdown.\n * @returns {any} The content to be displayed.\n */\n beforeShow() {\n return this.content;\n }\n\n /**\n * This method is called after the dropdown is shown.\n */\n afterShow() {\n // Do nothing\n }\n\n /**\n * Open the popup element.\n * @param {object} e\n */\n onOpen = (e) => {\n this.classList.add('active');\n Promise.resolve(this.beforeShow(this))\n .then((res) => {\n if (!this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.show(true); // Show tooltip\n\n event.addListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n\n event.dispatchCustomEvent(this, 'wje-dropdown:open', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterShow(this));\n })\n .catch((error) => {\n // ak je nejaka chyba tak to len zatvorime\n this.classList.remove('active');\n this.popup.hide(true);\n });\n };\n\n beforeClose = () => {\n // Do nothing\n };\n\n afterClose = () => {\n // Do nothing\n };\n\n onClose = () => {\n this.classList.remove('active');\n Promise.resolve(this.beforeClose(this))\n .then((res) => {\n if (this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.hide(true); // Show tooltip\n\n event.removeListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterClose(this));\n })\n .catch((error) => {\n this.classList.add('active');\n this.popup.show(true);\n });\n }\n\n #onMenuItemCustom = (e) => {\n const path = typeof e.composedPath === 'function' ? e.composedPath() : [];\n if (!this.popup || !this.popup.floatingEl || !path.includes(this.popup.floatingEl)) return;\n\n const item = path.find(n => n && n.tagName === 'WJE-MENU-ITEM');\n if (!item) return;\n if (item.hasAttribute('disabled') || item.getAttribute('aria-disabled') === 'true') return;\n if (item.hasAttribute('has-submenu')) return; // parent; nezatváraj\n\n // Zavri len tento dropdown. NEvolaj stopPropagation na custom evente,\n // aby fungovali aj tvoje app-level listenery (riadok 480).\n this.classList.remove('active');\n this.popup.hide(true);\n }\n}\n","import Dropdown from './dropdown.element.js';\n\nexport default Dropdown;\n\nDropdown.define('wje-dropdown', Dropdown);\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,IAChB;AAqDD;AAAA;AAAA;AAAA;AAAA,qCAAY;AAcZ;AAAA;AAAA;AAAA;AAAA,wDAA+B,CAAC,MAAM;AAClC,UAAI,EAAE,OAAO,OAAO,WAAW,MAAM;AACjC,aAAK,UAAU,OAAO,QAAQ;AAC9B,aAAK,MAAM,KAAM;AAAA,MAC7B;AAAA,IACK;AAoGD,6CAAoB,CAAC,MAAM;AACvB,UAAI,KAAK,UAAU,SAAS,QAAQ,KAAK,EAAE,OAAO,YAAY,gBAAgB;AAC1E,aAAK,eAAe,CAAC;AAAA,MACjC;AAAA,IACK;AAMD;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,MAAM;AAErB,YAAM,OAAO,OAAO,EAAE,iBAAiB,aAAa,EAAE,aAAY,IAAK,CAAE;AACzE,YAAM,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,EAAE,YAAY,eAAe;AAChE,UAAI,CAAC,KAAM;AAGX,UAAI,KAAK,aAAa,UAAU,KAAK,KAAK,a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,"file":"wje-dropdown.js","sources":["../packages/wje-dropdown/dropdown.element.js","../packages/wje-dropdown/dropdown.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Popup from '../wje-popup/popup.element.js';\n\n/**\n * `Dropdown` is a custom element that displays a dropdown menu.\n * @summary This element represents a dropdown menu.\n * @documentation https://elements.webjet.sk/components/dropdown\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the dropdown.\n * @slot trigger - The slot for the trigger of the dropdown.\n * @slot - The default slot for the dropdown.\n * // @fires wje-dropdown:open - Event fired when the dropdown is opened.\n * // @fires wje-dropdown:close - Event fired when the dropdown is closed.\n * @tag wje-dropdown\n */\nexport default class Dropdown extends WJElement {\n static _instanceId = 0;\n /**\n * Creates an instance of Dropdown.\n * @class\n */\n constructor() {\n super();\n this._instanceId = ++Dropdown._instanceId;\n }\n\n /**\n * The placement of the dropdown.\n * @type {{\"wje-popup\": Popup}}\n */\n dependencies = {\n 'wje-popup': Popup,\n };\n\n /**\n * Sets or removes the 'portaled' attribute on the element.\n * When the value is truthy, the attribute 'portaled' is added to the element.\n * When the value is falsy, the attribute 'portaled' is removed from the element.\n * @param {boolean} value Determines whether to add or remove the 'portaled' attribute.\n */\n set portaled(value) {\n if (value) {\n this.setAttribute('portaled', value);\n } else {\n this.removeAttribute('portaled');\n }\n }\n\n /**\n * Getter method for the `portaled` property.\n * Checks if the `portaled` attribute is present on the element.\n * @returns {boolean} Returns `true` if the `portaled` attribute exists, otherwise `false`.\n */\n get portaled() {\n return this.getAttribute('portaled') || '';\n }\n\n /**\n * Checks whether the element has the 'portaled' attribute.\n * @returns {boolean} True if the element has the 'portaled' attribute, otherwise false.\n */\n get isPortaled() {\n return this.hasAttribute('portaled');\n }\n\n /**\n * Sets the placement of the dropdown.\n * @param value\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Gets the placement of the dropdown.\n * @returns {string|string}\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n /**\n * Sets the placement of the dropdown.\n * @type {string}\n */\n className = 'Dropdown';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string[]}\n */\n static get observedAttributes() {\n return ['active'];\n }\n\n /**\n * Callback function to handle other dropdowns being opened. Close the dropdown if it is not the target and collapse is enabled.\n * @param {Event} e The event object.\n */\n otherDropdownOpennedCallback = (e) => {\n if (e.detail.detail.target !== this) {\n this.classList.remove('active');\n this.popup.hide();\n }\n };\n\n /**\n * Sets up the attributes for the dropdown.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Removes the popup element.\n */\n beforeDraw() {\n this.popup?.remove();\n this.popup = null;\n }\n\n /**\n * Draws the dropdown element and returns the created document fragment.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', 'wje-' + this.placement || 'wje-start');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-dropdown');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.tooltip);\n\n let anchorSlot = document.createElement('slot');\n anchorSlot.setAttribute('name', 'trigger');\n anchorSlot.setAttribute('slot', 'anchor');\n\n let slot = document.createElement('slot');\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n popup.setAttribute('part', 'popup');\n\n if(this.isPortaled)\n popup.setAttribute('portal', this.portaled);\n\n popup.append(anchorSlot, slot);\n\n // if(this.trigger === \"click\")\n popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.anchorSlot = anchorSlot;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDraw() {\n event.addListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n\n // Close when any actionable wje-menu-item inside the popup is clicked (works across Shadow DOM via composed path)\n event.addListener(this.popup, 'click', null, this.onMenuItemClick, { capture: true });\n\n if (this.trigger !== 'click') {\n event.addListener(this, 'mouseenter', null, this.onOpen);\n event.addListener(this, 'mouseleave', null, this.onClose);\n } else {\n event.addListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n }\n\n if (this.hasAttribute('collapsible')) {\n event.addListener(\n Array.from(this.querySelectorAll('wje-menu-item')),\n 'click',\n 'wje-menu-item:click',\n this.onClose\n );\n }\n\n this.onSlotChange = () => this.syncAria();\n this.anchorSlot.addEventListener('slotchange', this.onSlotChange);\n\n this.syncAria();\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDisconnect() {\n event.removeListener(this, 'mouseenter', null, this.onOpen);\n event.removeListener(this, 'mouseleave', null, this.onClose);\n event.removeListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n event.removeListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n event.removeListener(this.popup, 'click', null, this.onMenuItemClick, { capture: true });\n event.removeListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n this.anchorSlot?.removeEventListener('slotchange', this.onSlotChange);\n }\n\n popupHideCallback = (e) => {\n if (this.classList.contains('active') && e.target.tagName === \"WJE-DROPDOWN\") {\n this.toggleCallback(e);\n }\n };\n\n /**\n * Handles delegated clicks from inside the popup and closes the dropdown when a leaf menu item is selected.\n * This works even when the menu is portaled, because we rely on the composed path.\n */\n onMenuItemClick = (e) => {\n // Find nearest wje-menu-item in the composed path\n const path = typeof e.composedPath === 'function' ? e.composedPath() : [];\n const item = path.find((n) => n && n.tagName === 'WJE-MENU-ITEM');\n if (!item) return;\n\n // Ignore disabled items\n if (item.hasAttribute('disabled') || item.getAttribute('aria-disabled') === 'true') return;\n\n // If this item contains a nested submenu (wje-menu), it's not a leaf -> don't close yet\n if (typeof item.querySelector === 'function' && item.querySelector('wje-menu')) return;\n\n // Leaf item selected -> close dropdown (which calls popup.hide(true) inside onClose)\n this.onClose();\n }\n\n /**\n * @summary Toggles the dropdown element between active and inactive states.\n * Calls the `onOpen` method if the element is currently inactive,\n * and calls the `onClose` method if the element is currently active.\n * @param {Event} e The event object.\n */\n toggleCallback = (e) => {\n if (this.classList.contains('active')) {\n e.stopPropagation();\n this.onClose();\n } else {\n e.stopPropagation();\n this.onOpen(e);\n }\n };\n\n /**\n * @summary Returns the content to be displayed before showing the dropdown.\n * @returns {any} The content to be displayed.\n */\n beforeShow() {\n return this.content;\n }\n\n /**\n * This method is called after the dropdown is shown.\n */\n afterShow() {\n // Do nothing\n }\n\n /**\n * Open the popup element.\n * @param {object} e\n */\n onOpen = (e) => {\n this.classList.add('active');\n this.syncAria();\n Promise.resolve(this.beforeShow(this))\n .then((res) => {\n if (!this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.show(true); // Show tooltip\n\n event.addListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n\n event.dispatchCustomEvent(this, 'wje-dropdown:open', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterShow(this));\n })\n .catch((error) => {\n // ak je nejaka chyba tak to len zatvorime\n this.classList.remove('active');\n this.popup.hide(true);\n });\n };\n\n beforeClose = () => {\n // Do nothing\n };\n\n afterClose = () => {\n // Do nothing\n };\n\n onClose = () => {\n this.classList.remove('active');\n this.syncAria();\n Promise.resolve(this.beforeClose(this))\n .then((res) => {\n if (this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.hide(true); // Show tooltip\n\n event.removeListener(document, 'wje-menu-item:click', null, this.#onMenuItemCustom, false);\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterClose(this));\n })\n .catch((error) => {\n this.classList.add('active');\n this.popup.show(true);\n });\n }\n\n /**\n * Syncs ARIA attributes for the trigger element.\n */\n syncAria() {\n const triggerEl = this.anchorSlot?.assignedElements?.({ flatten: true })?.[0];\n if (!triggerEl) return;\n\n const popupId = this.popup?.id || `wje-dropdown-popup-${this._instanceId}`;\n if (this.popup && !this.popup.id) this.popup.id = popupId;\n\n const hasMenu = !!this.querySelector('wje-menu');\n triggerEl.setAttribute('aria-haspopup', hasMenu ? 'menu' : 'dialog');\n triggerEl.setAttribute('aria-expanded', this.classList.contains('active') ? 'true' : 'false');\n triggerEl.setAttribute('aria-controls', popupId);\n }\n\n #onMenuItemCustom = (e) => {\n const path = typeof e.composedPath === 'function' ? e.composedPath() : [];\n if (!this.popup || !this.popup.floatingEl || !path.includes(this.popup.floatingEl)) return;\n\n const item = path.find(n => n && n.tagName === 'WJE-MENU-ITEM');\n if (!item) return;\n if (item.hasAttribute('disabled') || item.getAttribute('aria-disabled') === 'true') return;\n if (item.hasAttribute('has-submenu')) return; // parent; nezatváraj\n\n // Zavri len tento dropdown. NEvolaj stopPropagation na custom evente,\n // aby fungovali aj tvoje app-level listenery (riadok 480).\n this.classList.remove('active');\n this.popup.hide(true);\n }\n}\n","import Dropdown from './dropdown.element.js';\n\nexport default Dropdown;\n\nDropdown.define('wje-dropdown', Dropdown);\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBe,MAAM,YAAN,MAAM,kBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,cAAc;AACV,UAAK;AAQT;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,IACrB;AAqDI;AAAA;AAAA;AAAA;AAAA,qCAAY;AAcZ;AAAA;AAAA;AAAA;AAAA,wDAA+B,CAAC,MAAM;AAClC,UAAI,EAAE,OAAO,OAAO,WAAW,MAAM;AACjC,aAAK,UAAU,OAAO,QAAQ;AAC9B,aAAK,MAAM,KAAI;AAAA,MACnB;AAAA,IACJ;AA0GA,6CAAoB,CAAC,MAAM;AACvB,UAAI,KAAK,UAAU,SAAS,QAAQ,KAAK,EAAE,OAAO,YAAY,gBAAgB;AAC1E,aAAK,eAAe,CAAC;AAAA,MACzB;AAAA,IACJ;AAMA;AAAA;AAAA;AAAA;AAAA,2CA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