wj-elements 0.7.7 → 0.8.0

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 (233) hide show
  1. package/dist/animations.js +28 -51
  2. package/dist/animations.js.map +1 -1
  3. package/dist/base-path.js +19 -31
  4. package/dist/base-path.js.map +1 -1
  5. package/dist/custom-elements.json +11504 -11499
  6. package/dist/dark.css +1 -302
  7. package/dist/date.js +16 -36
  8. package/dist/date.js.map +1 -1
  9. package/dist/element-utils.js +20 -81
  10. package/dist/element-utils.js.map +1 -1
  11. package/dist/event.js +49 -165
  12. package/dist/event.js.map +1 -1
  13. package/dist/form-associated-element-BjeJn7j8.js +101 -0
  14. package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
  15. package/dist/icon-DmsqtDpL.js +102 -0
  16. package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
  17. package/dist/light.css +1 -731
  18. package/dist/localize.js +36 -111
  19. package/dist/localize.js.map +1 -1
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
  21. package/dist/permissions.js +14 -41
  22. package/dist/permissions.js.map +1 -1
  23. package/dist/popup.element-CbkhthPP.js +806 -0
  24. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  25. package/dist/router-links-CNsJ-elb.js +105 -0
  26. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  27. package/dist/skeleton.css +1 -197
  28. package/dist/styles.css +1 -866
  29. package/dist/universal-service.js +48 -109
  30. package/dist/universal-service.js.map +1 -1
  31. package/dist/utils.js +11 -18
  32. package/dist/utils.js.map +1 -1
  33. package/dist/web-types.json +760 -760
  34. package/dist/wje-accordion-item.js +33 -106
  35. package/dist/wje-accordion-item.js.map +1 -1
  36. package/dist/wje-accordion.js +19 -84
  37. package/dist/wje-accordion.js.map +1 -1
  38. package/dist/wje-animation.js +37 -4258
  39. package/dist/wje-animation.js.map +1 -1
  40. package/dist/wje-aside.js +9 -34
  41. package/dist/wje-aside.js.map +1 -1
  42. package/dist/wje-avatar.js +36 -126
  43. package/dist/wje-avatar.js.map +1 -1
  44. package/dist/wje-badge.js +10 -52
  45. package/dist/wje-badge.js.map +1 -1
  46. package/dist/wje-breadcrumb.js +205 -672
  47. package/dist/wje-breadcrumb.js.map +1 -1
  48. package/dist/wje-breadcrumbs.js +177 -633
  49. package/dist/wje-breadcrumbs.js.map +1 -1
  50. package/dist/wje-button-group.js +48 -153
  51. package/dist/wje-button-group.js.map +1 -1
  52. package/dist/wje-button.js +92 -413
  53. package/dist/wje-button.js.map +1 -1
  54. package/dist/wje-card-content.js +7 -30
  55. package/dist/wje-card-content.js.map +1 -1
  56. package/dist/wje-card-controls.js +7 -30
  57. package/dist/wje-card-controls.js.map +1 -1
  58. package/dist/wje-card-header.js +7 -30
  59. package/dist/wje-card-header.js.map +1 -1
  60. package/dist/wje-card-subtitle.js +7 -34
  61. package/dist/wje-card-subtitle.js.map +1 -1
  62. package/dist/wje-card-title.js +7 -34
  63. package/dist/wje-card-title.js.map +1 -1
  64. package/dist/wje-card.js +15 -71
  65. package/dist/wje-card.js.map +1 -1
  66. package/dist/wje-carousel-item.js +12 -56
  67. package/dist/wje-carousel-item.js.map +1 -1
  68. package/dist/wje-carousel.js +154 -509
  69. package/dist/wje-carousel.js.map +1 -1
  70. package/dist/wje-checkbox.js +50 -227
  71. package/dist/wje-checkbox.js.map +1 -1
  72. package/dist/wje-chip.js +43 -160
  73. package/dist/wje-chip.js.map +1 -1
  74. package/dist/wje-col.js +7 -20
  75. package/dist/wje-col.js.map +1 -1
  76. package/dist/wje-color-picker.js +445 -1464
  77. package/dist/wje-color-picker.js.map +1 -1
  78. package/dist/wje-container.js +9 -35
  79. package/dist/wje-container.js.map +1 -1
  80. package/dist/wje-copy-button.js +64 -204
  81. package/dist/wje-copy-button.js.map +1 -1
  82. package/dist/wje-dialog.js +85 -553
  83. package/dist/wje-dialog.js.map +1 -1
  84. package/dist/wje-divider.js +7 -34
  85. package/dist/wje-divider.js.map +1 -1
  86. package/dist/wje-dropdown.js +78 -305
  87. package/dist/wje-dropdown.js.map +1 -1
  88. package/dist/wje-element.js +191 -700
  89. package/dist/wje-element.js.map +1 -1
  90. package/dist/wje-file-upload-item.js +51 -156
  91. package/dist/wje-file-upload-item.js.map +1 -1
  92. package/dist/wje-file-upload.js +181 -619
  93. package/dist/wje-file-upload.js.map +1 -1
  94. package/dist/wje-footer.js +7 -31
  95. package/dist/wje-footer.js.map +1 -1
  96. package/dist/wje-form.js +7 -32
  97. package/dist/wje-form.js.map +1 -1
  98. package/dist/wje-format-digital.js +26 -118
  99. package/dist/wje-format-digital.js.map +1 -1
  100. package/dist/wje-grid.js +7 -33
  101. package/dist/wje-grid.js.map +1 -1
  102. package/dist/wje-header.js +9 -35
  103. package/dist/wje-header.js.map +1 -1
  104. package/dist/wje-icon-library.js +12 -18
  105. package/dist/wje-icon-library.js.map +1 -1
  106. package/dist/wje-icon-picker.js +65 -320
  107. package/dist/wje-icon-picker.js.map +1 -1
  108. package/dist/wje-icon.js +1 -1
  109. package/dist/wje-img-comparer.js +37 -114
  110. package/dist/wje-img-comparer.js.map +1 -1
  111. package/dist/wje-img.js +50 -198
  112. package/dist/wje-img.js.map +1 -1
  113. package/dist/wje-infinite-scroll.js +94 -346
  114. package/dist/wje-infinite-scroll.js.map +1 -1
  115. package/dist/wje-input-file.js +23 -84
  116. package/dist/wje-input-file.js.map +1 -1
  117. package/dist/wje-input.js +78 -392
  118. package/dist/wje-input.js.map +1 -1
  119. package/dist/wje-item.js +11 -64
  120. package/dist/wje-item.js.map +1 -1
  121. package/dist/wje-kanban.js +124 -401
  122. package/dist/wje-kanban.js.map +1 -1
  123. package/dist/wje-label.js +9 -32
  124. package/dist/wje-label.js.map +1 -1
  125. package/dist/wje-level-indicator.js +38 -157
  126. package/dist/wje-level-indicator.js.map +1 -1
  127. package/dist/wje-list.js +10 -40
  128. package/dist/wje-list.js.map +1 -1
  129. package/dist/wje-main.js +7 -31
  130. package/dist/wje-main.js.map +1 -1
  131. package/dist/wje-masonry.js +66 -211
  132. package/dist/wje-masonry.js.map +1 -1
  133. package/dist/wje-master.js +45 -161
  134. package/dist/wje-master.js.map +1 -1
  135. package/dist/wje-menu-button.js +10 -38
  136. package/dist/wje-menu-button.js.map +1 -1
  137. package/dist/wje-menu-item.js +127 -577
  138. package/dist/wje-menu-item.js.map +1 -1
  139. package/dist/wje-menu-label.js +9 -35
  140. package/dist/wje-menu-label.js.map +1 -1
  141. package/dist/wje-menu.js +14 -49
  142. package/dist/wje-menu.js.map +1 -1
  143. package/dist/wje-option.js +48 -279
  144. package/dist/wje-option.js.map +1 -1
  145. package/dist/wje-options.js +130 -384
  146. package/dist/wje-options.js.map +1 -1
  147. package/dist/wje-orgchart-group.js +16 -52
  148. package/dist/wje-orgchart-group.js.map +1 -1
  149. package/dist/wje-orgchart-item.js +24 -93
  150. package/dist/wje-orgchart-item.js.map +1 -1
  151. package/dist/wje-orgchart.js +18 -68
  152. package/dist/wje-orgchart.js.map +1 -1
  153. package/dist/wje-pagination.js +113 -397
  154. package/dist/wje-pagination.js.map +1 -1
  155. package/dist/wje-popup.js +3 -3
  156. package/dist/wje-popup.js.map +1 -1
  157. package/dist/wje-progress-bar.js +53 -205
  158. package/dist/wje-progress-bar.js.map +1 -1
  159. package/dist/wje-qr-code.js +398 -2980
  160. package/dist/wje-qr-code.js.map +1 -1
  161. package/dist/wje-radio-group.js +52 -190
  162. package/dist/wje-radio-group.js.map +1 -1
  163. package/dist/wje-radio.js +24 -118
  164. package/dist/wje-radio.js.map +1 -1
  165. package/dist/wje-rate.js +62 -266
  166. package/dist/wje-rate.js.map +1 -1
  167. package/dist/wje-relative-time.js +24 -99
  168. package/dist/wje-relative-time.js.map +1 -1
  169. package/dist/wje-reorder-dropzone.js +9 -31
  170. package/dist/wje-reorder-dropzone.js.map +1 -1
  171. package/dist/wje-reorder-handle.js +67 -204
  172. package/dist/wje-reorder-handle.js.map +1 -1
  173. package/dist/wje-reorder-item.js +14 -44
  174. package/dist/wje-reorder-item.js.map +1 -1
  175. package/dist/wje-reorder.js +61 -246
  176. package/dist/wje-reorder.js.map +1 -1
  177. package/dist/wje-route.js +6 -24
  178. package/dist/wje-route.js.map +1 -1
  179. package/dist/wje-router-link.js +11 -39
  180. package/dist/wje-router-link.js.map +1 -1
  181. package/dist/wje-router-outlet.js +76 -172
  182. package/dist/wje-router-outlet.js.map +1 -1
  183. package/dist/wje-routerx.js +537 -1331
  184. package/dist/wje-routerx.js.map +1 -1
  185. package/dist/wje-row.js +9 -31
  186. package/dist/wje-row.js.map +1 -1
  187. package/dist/wje-select.js +326 -1152
  188. package/dist/wje-select.js.map +1 -1
  189. package/dist/wje-slider.js +44 -225
  190. package/dist/wje-slider.js.map +1 -1
  191. package/dist/wje-sliding-container.js +295 -1319
  192. package/dist/wje-sliding-container.js.map +1 -1
  193. package/dist/wje-split-view.js +35 -121
  194. package/dist/wje-split-view.js.map +1 -1
  195. package/dist/wje-status.js +14 -45
  196. package/dist/wje-status.js.map +1 -1
  197. package/dist/wje-step.js +9 -32
  198. package/dist/wje-step.js.map +1 -1
  199. package/dist/wje-stepper.js +109 -357
  200. package/dist/wje-stepper.js.map +1 -1
  201. package/dist/wje-store.js +67 -360
  202. package/dist/wje-store.js.map +1 -1
  203. package/dist/wje-tab-group.js +85 -314
  204. package/dist/wje-tab-group.js.map +1 -1
  205. package/dist/wje-tab-panel.js +7 -28
  206. package/dist/wje-tab-panel.js.map +1 -1
  207. package/dist/wje-tab.js +21 -198
  208. package/dist/wje-tab.js.map +1 -1
  209. package/dist/wje-textarea.js +64 -264
  210. package/dist/wje-textarea.js.map +1 -1
  211. package/dist/wje-thumbnail.js +10 -51
  212. package/dist/wje-thumbnail.js.map +1 -1
  213. package/dist/wje-toast.js +127 -632
  214. package/dist/wje-toast.js.map +1 -1
  215. package/dist/wje-toggle.js +52 -177
  216. package/dist/wje-toggle.js.map +1 -1
  217. package/dist/wje-toolbar-action.js +128 -456
  218. package/dist/wje-toolbar-action.js.map +1 -1
  219. package/dist/wje-toolbar.js +75 -270
  220. package/dist/wje-toolbar.js.map +1 -1
  221. package/dist/wje-tooltip.js +50 -161
  222. package/dist/wje-tooltip.js.map +1 -1
  223. package/dist/wje-tree-item.js +70 -301
  224. package/dist/wje-tree-item.js.map +1 -1
  225. package/dist/wje-tree.js +145 -489
  226. package/dist/wje-tree.js.map +1 -1
  227. package/dist/wje-visually-hidden.js +7 -34
  228. package/dist/wje-visually-hidden.js.map +1 -1
  229. package/package.json +3 -2
  230. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  231. package/dist/icon-CReYMzAK.js +0 -245
  232. package/dist/popup.element-CwXvVFK7.js +0 -2133
  233. package/dist/router-links-wjqCnncc.js +0 -156
@@ -1 +1 @@
1
- {"version":3,"file":"wje-tree.js","sources":["../packages/wje-tree/tree.element.js","../packages/wje-tree/tree.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n// @fires wje-tree:move - Dispatched when a tree item is moved.\n/**\n * `Tree` is a custom web component that represents a hierarchical tree structure.\n * It extends from `WJElement`.\n * @summary This element visually represents a tree structure, supporting single or multiple selection modes and hierarchy management.\n * @documentation https://elements.webjet.sk/components/tree\n * @status stable\n * @augments {WJElement}\n * @attribute {boolean} reorder - Enables moving tree items by dragging direct start slot content.\n * @csspart native - The native container part of the tree.\n * @slot - The default slot to place `wje-tree-item` child components.\n * @tag wje-tree\n */\n\nexport default class Tree extends WJElement {\n /**\n * Creates an instance of Tree.\n */\n constructor() {\n super();\n\n this.draggedItem = null;\n this.dropTarget = null;\n this.dropPosition = null;\n }\n\n /**\n * Sets the selection attribute for the element.\n * @param {string} value The value to set as the selection attribute.\n */\n set selection(value) {\n this.setAttribute('selection', value);\n }\n\n /**\n * Gets the current selection mode for the element.\n * If no selection is explicitly set, it defaults to 'single'.\n * @returns {string} The current selection mode, either set by the element's attribute or the default value 'single'.\n */\n get selection() {\n return this.getAttribute('selection') || 'single';\n }\n\n /**\n * Enables reordering tree items by dragging an element assigned to the start slot.\n * @param {boolean} value Whether reordering is enabled.\n */\n set reorder(value) {\n if (value) this.setAttribute('reorder', '');\n else this.removeAttribute('reorder');\n }\n\n /**\n * Indicates whether tree items can be reordered with the start slot handle.\n * @returns {boolean}\n */\n get reorder() {\n return this.hasAttribute('reorder');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Tree';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * A method called before the drawing or rendering process of tree items.\n * It iterates through all `wje-tree-item` elements, updating their selection state\n * and managing their expand/collapse icons accordingly.\n * @returns {void} This method does not return a value.\n */\n beforeDraw() {\n const template = this.querySelector('template');\n const items = this.querySelectorAll('wje-tree-item');\n items?.forEach((item) => {\n item.selection = this.selection;\n item.syncNestingState?.();\n\n this.appendTemplateSlot(item, template, 'expand');\n this.appendTemplateSlot(item, template, 'collapse');\n this.appendTemplateSlot(item, template, 'start');\n this.appendTemplateSlot(item, template, 'end');\n\n if (this.reorder) this.setupReorderHandle(item);\n });\n }\n\n /**\n * Draw method for the tree.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-tree');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Called after the draw process of the component is completed.\n * Typically used to add event listeners or perform operations\n * that are dependent on the component's drawn state.\n * @returns {void} This method does not return a value.\n */\n afterDraw() {\n this.addEventListener('click', this.handleClick);\n this.addEventListener('dragstart', this.handleDragStart);\n this.addEventListener('dragover', this.handleDragOver);\n this.addEventListener('drop', this.handleDrop);\n this.addEventListener('dragend', this.handleDragEnd);\n this.syncAria();\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n this.setAriaState({\n role: 'tree',\n multiselectable: this.selection === 'multiple' ? 'true' : undefined,\n });\n }\n\n beforeDisconnect() {\n this.removeEventListener('click', this.handleClick);\n this.removeEventListener('dragstart', this.handleDragStart);\n this.removeEventListener('dragover', this.handleDragOver);\n this.removeEventListener('drop', this.handleDrop);\n this.removeEventListener('dragend', this.handleDragEnd);\n }\n\n /**\n * Handles the click event triggered by the user interaction.\n * Identifies the closest tree item element to the event target and sets it\n * as the selected item. Ensures that only one item is selected at a time, resetting\n * the selection state for all other items.\n * @param {Event} e The click event object.\n */\n handleClick = (e) => {\n if (e?.preventDefault) e.preventDefault();\n if (this.reorder && this.isReorderHandleEvent(e)) return;\n\n const selectedItem = this.getTreeItemFromEvent(e);\n if (!selectedItem) return;\n\n const isClickButton = (e.composedPath?.() || []).some((el) => el?.classList?.contains('toggle'));\n if (isClickButton) return;\n\n if (this.selection === 'single') {\n for (let item of this.getAllItems()) {\n item.selected = item === selectedItem;\n }\n } else if (this.selection === 'multiple') {\n // let children = selectedItem.getAllChildrenFlat();\n selectedItem.selected = !selectedItem.selected;\n\n this.updateCheckboxState(selectedItem);\n }\n };\n\n /**\n * Starts dragging a tree item when the drag begins from the configured start slot handle.\n * @param {DragEvent} e The drag event.\n * @returns {void}\n */\n handleDragStart = (e) => {\n if (!this.reorder || !this.isReorderHandleEvent(e)) return;\n\n const item = this.getTreeItemFromEvent(e);\n if (!item) return;\n\n this.draggedItem = item;\n item.classList.add('wje-tree-dragging');\n\n if (e.dataTransfer) {\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/plain', item.textContent?.trim() || '');\n }\n };\n\n /**\n * Updates the current drop target and exposes a visual drop position.\n * @param {DragEvent} e The drag event.\n * @returns {void}\n */\n handleDragOver = (e) => {\n if (!this.reorder || !this.draggedItem) return;\n\n const target = this.getTreeItemFromEvent(e);\n\n if (!this.canDrop(this.draggedItem, target)) {\n this.clearDropState();\n return;\n }\n\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';\n\n const position = this.getDropPosition(e, target);\n this.setDropState(target, position);\n };\n\n /**\n * Completes a tree item move.\n * @param {DragEvent} e The drop event.\n * @returns {void}\n */\n handleDrop = (e) => {\n if (!this.reorder || !this.draggedItem) return;\n\n e.preventDefault();\n\n const target = this.dropTarget || this.getTreeItemFromEvent(e);\n const position = this.dropPosition || this.getDropPosition(e, target);\n const detail = this.moveItem(this.draggedItem, target, position);\n\n if (detail) {\n this.dispatchEvent(new CustomEvent('wje-tree:move', {\n detail,\n bubbles: true,\n composed: true,\n }));\n }\n\n this.clearDragState();\n };\n\n /**\n * Clears drag state after the browser drag operation ends.\n * @returns {void}\n */\n handleDragEnd = () => {\n this.clearDragState();\n };\n\n /**\n * Retrieves all items that match the selector 'wje-tree-item' within the current context.\n * @returns {Array<Element>} An array of all matching DOM elements.\n */\n getAllItems() {\n return [...this.querySelectorAll('wje-tree-item')];\n }\n\n /**\n * Retrieves and appends a template slot to a tree item.\n * @param {HTMLElement} item The DOM element to which the slot content will be appended.\n * @param {HTMLTemplateElement|null} template Template that may provide reusable slot content.\n * @param {string} slotName Name of the projected slot content to clone.\n * @returns {void}\n */\n appendTemplateSlot(item, template, slotName) {\n const slot = template?.content.querySelector(`[slot=\"${slotName}\"]`);\n if (!slot) return;\n\n const templateSlotClass = this.getTemplateSlotClass(slotName);\n const existing = item.querySelector(`:scope > [slot=\"${slotName}\"].${templateSlotClass}`);\n if (existing) return;\n\n const slotClone = slot.cloneNode(true);\n slotClone.classList.add('wje-tree-template-slot', templateSlotClass);\n item.append(slotClone);\n }\n\n /**\n * Returns the internal class used to identify cloned template slot content.\n * @param {string} slotName Name of the projected slot.\n * @returns {string}\n */\n getTemplateSlotClass(slotName) {\n return `wje-tree-template-slot-${slotName}`;\n }\n\n /**\n * Marks direct start slot content as the drag handle for reorderable trees.\n * @param {HTMLElement} item Host item that receives draggable start content.\n * @returns {void}\n */\n setupReorderHandle(item) {\n const handles = item.querySelectorAll(':scope > [slot=\"start\"]');\n\n handles.forEach((handle) => {\n handle.setAttribute('draggable', 'true');\n handle.classList.add('wje-tree-drag-handle');\n\n if (!handle.hasAttribute('aria-label')) {\n handle.setAttribute('aria-label', 'Move tree item');\n }\n });\n }\n\n /**\n * Finds a tree item from a composed event path.\n * @param {Event} e User interaction that may originate inside shadow DOM.\n * @returns {HTMLElement|null}\n */\n getTreeItemFromEvent(e) {\n const path = e.composedPath?.() || [];\n const pathItem = path.find((el) => this.isTreeItem(el) && this.contains(el));\n if (pathItem) return pathItem;\n\n const targetItem = e.target?.closest?.('wje-tree-item');\n return targetItem && this.contains(targetItem) ? targetItem : null;\n }\n\n /**\n * Checks whether the event started from a reorder handle.\n * @param {Event} e User interaction to inspect.\n * @returns {boolean}\n */\n isReorderHandleEvent(e) {\n return (e.composedPath?.() || []).some((el) => el?.classList?.contains('wje-tree-drag-handle'));\n }\n\n /**\n * Checks whether a node is a tree item element.\n * @param {object} node The node to inspect.\n * @returns {boolean}\n */\n isTreeItem(node) {\n return node instanceof Element && node.localName === 'wje-tree-item';\n }\n\n /**\n * Returns direct tree item children for a tree or tree item parent.\n * @param {HTMLElement} parent The parent element.\n * @returns {HTMLElement[]}\n */\n getDirectTreeItems(parent) {\n return Array.from(parent?.children || []).filter((child) => this.isTreeItem(child));\n }\n\n /**\n * Gets the index of a tree item among direct tree item siblings.\n * @param {HTMLElement} item Element whose sibling position should be resolved.\n * @returns {number}\n */\n getTreeItemIndex(item) {\n return this.getDirectTreeItems(item.parentElement).indexOf(item);\n }\n\n /**\n * Determines whether the dragged item can be dropped on the target.\n * @param {HTMLElement} draggedItem Item currently being moved.\n * @param {HTMLElement} targetItem Candidate item under the pointer.\n * @returns {boolean}\n */\n canDrop(draggedItem, targetItem) {\n return !!draggedItem && !!targetItem && draggedItem !== targetItem && !draggedItem.contains(targetItem);\n }\n\n /**\n * Resolves the drop position against the visible tree item row.\n * @param {DragEvent} e Browser drag event carrying pointer coordinates.\n * @param {HTMLElement|null} target Item used to calculate row boundaries.\n * @returns {'before'|'inside'|'after'}\n */\n getDropPosition(e, target) {\n const row = target?.shadowRoot?.querySelector('.item');\n const rect = row?.getBoundingClientRect?.() || target?.getBoundingClientRect?.();\n\n if (!rect) return 'after';\n\n const topBoundary = rect.top + rect.height * 0.25;\n const bottomBoundary = rect.bottom - rect.height * 0.25;\n\n if (e.clientY < topBoundary) return 'before';\n if (e.clientY > bottomBoundary) return 'after';\n\n return 'inside';\n }\n\n /**\n * Applies the visual drop position to the current target item.\n * @param {HTMLElement} target Item currently showing insertion feedback.\n * @param {string} position Resolved insertion area for the target row.\n * @returns {void}\n */\n setDropState(target, position) {\n if (this.dropTarget !== target || this.dropPosition !== position) {\n this.clearDropState();\n this.dropTarget = target;\n this.dropPosition = position;\n target.classList.add(this.getDropPositionClass(position));\n }\n }\n\n /**\n * Clears visual drop target state.\n * @returns {void}\n */\n clearDropState() {\n this.dropTarget?.classList.remove(\n this.getDropPositionClass('before'),\n this.getDropPositionClass('inside'),\n this.getDropPositionClass('after')\n );\n this.dropTarget = null;\n this.dropPosition = null;\n }\n\n /**\n * Clears the active drag state.\n * @returns {void}\n */\n clearDragState() {\n this.draggedItem?.classList.remove('wje-tree-dragging');\n this.clearDropState();\n this.draggedItem = null;\n }\n\n /**\n * Returns the internal class used to render a drop marker.\n * @param {'before'|'inside'|'after'} position Drop marker position.\n * @returns {string}\n */\n getDropPositionClass(position) {\n return `wje-tree-drop-${position}`;\n }\n\n /**\n * Moves a tree item relative to another tree item and syncs nesting metadata.\n * @param {HTMLElement} draggedItem The item being moved.\n * @param {HTMLElement} targetItem Item that receives or anchors the moved item.\n * @param {'before'|'inside'|'after'} position The target position.\n * @returns {object|null} Move detail, or null when the move is invalid.\n */\n moveItem(draggedItem, targetItem, position = 'after') {\n if (!this.canDrop(draggedItem, targetItem)) return null;\n\n const fromParent = draggedItem.parentElement;\n const fromParentItem = fromParent?.closest?.('wje-tree-item');\n const fromIndex = this.getTreeItemIndex(draggedItem);\n\n if (position === 'inside') {\n targetItem.appendChild(draggedItem);\n targetItem.setChildrenExpanded?.(true);\n } else {\n const parent = targetItem.parentElement;\n const reference = position === 'before' ? targetItem : targetItem.nextSibling;\n parent.insertBefore(draggedItem, reference);\n }\n\n this.syncTreeItems();\n\n const toParent = draggedItem.parentElement;\n const toParentItem = toParent?.closest?.('wje-tree-item');\n const toIndex = this.getTreeItemIndex(draggedItem);\n const orderElements = this.getOrderElements(toParent);\n const order = orderElements.map((item) => item.innerText.trim());\n\n this.refreshMovedItems([fromParentItem, toParentItem, targetItem]);\n\n return {\n item: draggedItem,\n target: targetItem,\n position,\n from: fromIndex,\n to: toIndex,\n order,\n orderElements,\n orderIds: this.getOrderIds(toParent),\n itemId: this.getItemId(draggedItem),\n targetId: this.getItemId(targetItem),\n fromParentItem,\n toParentItem,\n fromParentId: this.getItemId(fromParentItem),\n toParentId: this.getItemId(toParentItem),\n fromParent,\n toParent,\n fromIndex,\n toIndex,\n };\n }\n\n /**\n * Returns cloned direct tree item children for an event detail.\n * @param {HTMLElement} parent Parent whose direct tree item children should be serialized.\n * @returns {HTMLElement[]}\n */\n getOrderElements(parent) {\n return this.getDirectTreeItems(parent).map((item) => {\n const clone = item.cloneNode(true);\n clone.querySelectorAll('.wje-tree-template-slot').forEach((slot) => slot.remove());\n return clone;\n });\n }\n\n /**\n * Returns stable ids for direct tree item children when they are available.\n * @param {HTMLElement} parent Parent whose direct tree item children should be serialized.\n * @returns {Array<string|null>}\n */\n getOrderIds(parent) {\n return this.getDirectTreeItems(parent).map((item) => this.getItemId(item));\n }\n\n /**\n * Gets an application-facing id from a tree item.\n * @param {HTMLElement|null} item Tree item to read.\n * @returns {string|null}\n */\n getItemId(item) {\n if (!this.isTreeItem(item)) return null;\n return item.getAttribute('value') || item.id || null;\n }\n\n /**\n * Syncs item selection mode and nesting metadata after a DOM move.\n * @returns {void}\n */\n syncTreeItems() {\n this.getAllItems().forEach((item) => {\n item.selection = this.selection;\n item.syncNestingState?.();\n item.syncAria?.();\n });\n }\n\n /**\n * Redraws affected parent items so expand/collapse affordances match current children.\n * @param {HTMLElement[]} items Items that may need refresh.\n * @returns {void}\n */\n refreshMovedItems(items) {\n [...new Set(items)].forEach((item) => {\n if (this.isTreeItem(item)) item.refresh?.();\n });\n }\n\n /**\n * Updates the state of a checkbox, syncing the state both upwards to parent elements\n * and downwards to child elements as necessary.\n * @param {object} changedItem The specific item whose checkbox state has changed.\n * @param {boolean} [isInitialSync] Indicates whether the state update is part of the initial synchronization process.\n * @returns {void} This method does not return a value.\n */\n updateCheckboxState(changedItem, isInitialSync = false) {\n this.isInitialSync = isInitialSync;\n this.propagateStateDownwards(changedItem);\n this.propagateStateUpwards(changedItem);\n }\n\n /**\n * Updates the state of the parent item based on the state of its child items.\n * Recursively propagates changes up to all parent items to reflect the selection\n * or indeterminate state accurately.\n * @param {object} item The current tree item whose parent state needs to be updated.\n * It is expected to have properties `selected`, `indeterminate`,\n * and a method `getChildrenItems({ includeDisabled: boolean })`.\n * @returns {void} This method does not return a value.\n */\n updateParentState(item) {\n const children = item.getChildrenItems({ includeDisabled: false });\n\n if (children.length) {\n const areAllChildrenChecked = children.every((child) => child.selected);\n const areSomeChildrenChecked = children.some((child) => child.selected);\n const areSomeChildrenIndeterminate = children.some((child) => child.indeterminate);\n\n item.selected = areAllChildrenChecked;\n item.indeterminate = areSomeChildrenIndeterminate || (areSomeChildrenChecked && !areAllChildrenChecked);\n } else {\n item.indeterminate = false;\n }\n\n const parent = item.parentElement?.closest('wje-tree-item');\n if (parent) {\n this.updateParentState(parent);\n }\n }\n\n /**\n * Propagates the state changes of an item upwards through its ancestors in the hierarchy.\n * Calls the `updateParentState` method for each parent element until no parent exists.\n * @param {HTMLElement} item The current item whose state to propagate to its parent.\n * @returns {void} This method does not return a value.\n */\n propagateStateUpwards(item) {\n const parent = item.parentElement?.closest('wje-tree-item');\n\n if (parent) {\n this.updateParentState(parent);\n this.propagateStateUpwards(parent);\n }\n }\n\n /**\n * Propagates the selected state of an item to its children recursively. Depending on the `isInitialSync` flag,\n * it also determines how the state should be applied to the child items and updates the parent state if needed.\n * @param {object} item The item whose state is being propagated to its child items. The item must have properties\n * such as `selected` and methods like `getChildrenItems` to retrieve its child elements.\n * @returns {void} This method does not return a value.\n */\n propagateStateDownwards(item) {\n const isChecked = item.selected;\n\n item.getChildrenItems().forEach((child) => {\n child.selected = this.isInitialSync ? isChecked || child.selected : !child.disabled && isChecked;\n this.propagateStateDownwards(child);\n });\n\n if (this.isInitialSync) {\n this.updateParentState(item);\n }\n }\n}\n","import Tree from './tree.element.js';\n\nexport default Tree;\n\nTree.define('wje-tree', Tree);\n"],"names":["_a"],"mappings":";;;;;AAiBe,MAAM,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC,cAAc;AACV,UAAK;AA6CT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAqGZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,CAAC,MAAM;;AACjB,UAAI,uBAAG,eAAgB,GAAE,eAAc;AACvC,UAAI,KAAK,WAAW,KAAK,qBAAqB,CAAC,EAAG;AAElD,YAAM,eAAe,KAAK,qBAAqB,CAAC;AAChD,UAAI,CAAC,aAAc;AAEnB,YAAM,mBAAiB,OAAE,iBAAF,+BAAsB,CAAA,GAAI,KAAK,CAAC,OAAE;;AAAK,gBAAAA,MAAA,yBAAI,cAAJ,gBAAAA,IAAe,SAAS;AAAA,OAAS;AAC/F,UAAI,cAAe;AAEnB,UAAI,KAAK,cAAc,UAAU;AAC7B,iBAAS,QAAQ,KAAK,eAAe;AACjC,eAAK,WAAW,SAAS;AAAA,QAC7B;AAAA,MACJ,WAAW,KAAK,cAAc,YAAY;AAEtC,qBAAa,WAAW,CAAC,aAAa;AAE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A,KAAK,OAAO,YAAY,IAAI;"}
1
+ {"version":3,"file":"wje-tree.js","sources":["../packages/wje-tree/tree.element.js","../packages/wje-tree/tree.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n// @fires wje-tree:move - Dispatched when a tree item is moved.\n/**\n * `Tree` is a custom web component that represents a hierarchical tree structure.\n * It extends from `WJElement`.\n * @summary This element visually represents a tree structure, supporting single or multiple selection modes and hierarchy management.\n * @documentation https://elements.webjet.sk/components/tree\n * @status stable\n * @augments {WJElement}\n * @attribute {boolean} reorder - Enables moving tree items by dragging direct start slot content.\n * @csspart native - The native container part of the tree.\n * @slot - The default slot to place `wje-tree-item` child components.\n * @tag wje-tree\n */\n\nexport default class Tree extends WJElement {\n /**\n * Creates an instance of Tree.\n */\n constructor() {\n super();\n\n this.draggedItem = null;\n this.dropTarget = null;\n this.dropPosition = null;\n }\n\n /**\n * Sets the selection attribute for the element.\n * @param {string} value The value to set as the selection attribute.\n */\n set selection(value) {\n this.setAttribute('selection', value);\n }\n\n /**\n * Gets the current selection mode for the element.\n * If no selection is explicitly set, it defaults to 'single'.\n * @returns {string} The current selection mode, either set by the element's attribute or the default value 'single'.\n */\n get selection() {\n return this.getAttribute('selection') || 'single';\n }\n\n /**\n * Enables reordering tree items by dragging an element assigned to the start slot.\n * @param {boolean} value Whether reordering is enabled.\n */\n set reorder(value) {\n if (value) this.setAttribute('reorder', '');\n else this.removeAttribute('reorder');\n }\n\n /**\n * Indicates whether tree items can be reordered with the start slot handle.\n * @returns {boolean}\n */\n get reorder() {\n return this.hasAttribute('reorder');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Tree';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * A method called before the drawing or rendering process of tree items.\n * It iterates through all `wje-tree-item` elements, updating their selection state\n * and managing their expand/collapse icons accordingly.\n * @returns {void} This method does not return a value.\n */\n beforeDraw() {\n const template = this.querySelector('template');\n const items = this.querySelectorAll('wje-tree-item');\n items?.forEach((item) => {\n item.selection = this.selection;\n item.syncNestingState?.();\n\n this.appendTemplateSlot(item, template, 'expand');\n this.appendTemplateSlot(item, template, 'collapse');\n this.appendTemplateSlot(item, template, 'start');\n this.appendTemplateSlot(item, template, 'end');\n\n if (this.reorder) this.setupReorderHandle(item);\n });\n }\n\n /**\n * Draw method for the tree.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-tree');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Called after the draw process of the component is completed.\n * Typically used to add event listeners or perform operations\n * that are dependent on the component's drawn state.\n * @returns {void} This method does not return a value.\n */\n afterDraw() {\n this.addEventListener('click', this.handleClick);\n this.addEventListener('dragstart', this.handleDragStart);\n this.addEventListener('dragover', this.handleDragOver);\n this.addEventListener('drop', this.handleDrop);\n this.addEventListener('dragend', this.handleDragEnd);\n this.syncAria();\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n this.setAriaState({\n role: 'tree',\n multiselectable: this.selection === 'multiple' ? 'true' : undefined,\n });\n }\n\n beforeDisconnect() {\n this.removeEventListener('click', this.handleClick);\n this.removeEventListener('dragstart', this.handleDragStart);\n this.removeEventListener('dragover', this.handleDragOver);\n this.removeEventListener('drop', this.handleDrop);\n this.removeEventListener('dragend', this.handleDragEnd);\n }\n\n /**\n * Handles the click event triggered by the user interaction.\n * Identifies the closest tree item element to the event target and sets it\n * as the selected item. Ensures that only one item is selected at a time, resetting\n * the selection state for all other items.\n * @param {Event} e The click event object.\n */\n handleClick = (e) => {\n if (e?.preventDefault) e.preventDefault();\n if (this.reorder && this.isReorderHandleEvent(e)) return;\n\n const selectedItem = this.getTreeItemFromEvent(e);\n if (!selectedItem) return;\n\n const isClickButton = (e.composedPath?.() || []).some((el) => el?.classList?.contains('toggle'));\n if (isClickButton) return;\n\n if (this.selection === 'single') {\n for (let item of this.getAllItems()) {\n item.selected = item === selectedItem;\n }\n } else if (this.selection === 'multiple') {\n // let children = selectedItem.getAllChildrenFlat();\n selectedItem.selected = !selectedItem.selected;\n\n this.updateCheckboxState(selectedItem);\n }\n };\n\n /**\n * Starts dragging a tree item when the drag begins from the configured start slot handle.\n * @param {DragEvent} e The drag event.\n * @returns {void}\n */\n handleDragStart = (e) => {\n if (!this.reorder || !this.isReorderHandleEvent(e)) return;\n\n const item = this.getTreeItemFromEvent(e);\n if (!item) return;\n\n this.draggedItem = item;\n item.classList.add('wje-tree-dragging');\n\n if (e.dataTransfer) {\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/plain', item.textContent?.trim() || '');\n }\n };\n\n /**\n * Updates the current drop target and exposes a visual drop position.\n * @param {DragEvent} e The drag event.\n * @returns {void}\n */\n handleDragOver = (e) => {\n if (!this.reorder || !this.draggedItem) return;\n\n const target = this.getTreeItemFromEvent(e);\n\n if (!this.canDrop(this.draggedItem, target)) {\n this.clearDropState();\n return;\n }\n\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';\n\n const position = this.getDropPosition(e, target);\n this.setDropState(target, position);\n };\n\n /**\n * Completes a tree item move.\n * @param {DragEvent} e The drop event.\n * @returns {void}\n */\n handleDrop = (e) => {\n if (!this.reorder || !this.draggedItem) return;\n\n e.preventDefault();\n\n const target = this.dropTarget || this.getTreeItemFromEvent(e);\n const position = this.dropPosition || this.getDropPosition(e, target);\n const detail = this.moveItem(this.draggedItem, target, position);\n\n if (detail) {\n this.dispatchEvent(new CustomEvent('wje-tree:move', {\n detail,\n bubbles: true,\n composed: true,\n }));\n }\n\n this.clearDragState();\n };\n\n /**\n * Clears drag state after the browser drag operation ends.\n * @returns {void}\n */\n handleDragEnd = () => {\n this.clearDragState();\n };\n\n /**\n * Retrieves all items that match the selector 'wje-tree-item' within the current context.\n * @returns {Array<Element>} An array of all matching DOM elements.\n */\n getAllItems() {\n return [...this.querySelectorAll('wje-tree-item')];\n }\n\n /**\n * Retrieves and appends a template slot to a tree item.\n * @param {HTMLElement} item The DOM element to which the slot content will be appended.\n * @param {HTMLTemplateElement|null} template Template that may provide reusable slot content.\n * @param {string} slotName Name of the projected slot content to clone.\n * @returns {void}\n */\n appendTemplateSlot(item, template, slotName) {\n const slot = template?.content.querySelector(`[slot=\"${slotName}\"]`);\n if (!slot) return;\n\n const templateSlotClass = this.getTemplateSlotClass(slotName);\n const existing = item.querySelector(`:scope > [slot=\"${slotName}\"].${templateSlotClass}`);\n if (existing) return;\n\n const slotClone = slot.cloneNode(true);\n slotClone.classList.add('wje-tree-template-slot', templateSlotClass);\n item.append(slotClone);\n }\n\n /**\n * Returns the internal class used to identify cloned template slot content.\n * @param {string} slotName Name of the projected slot.\n * @returns {string}\n */\n getTemplateSlotClass(slotName) {\n return `wje-tree-template-slot-${slotName}`;\n }\n\n /**\n * Marks direct start slot content as the drag handle for reorderable trees.\n * @param {HTMLElement} item Host item that receives draggable start content.\n * @returns {void}\n */\n setupReorderHandle(item) {\n const handles = item.querySelectorAll(':scope > [slot=\"start\"]');\n\n handles.forEach((handle) => {\n handle.setAttribute('draggable', 'true');\n handle.classList.add('wje-tree-drag-handle');\n\n if (!handle.hasAttribute('aria-label')) {\n handle.setAttribute('aria-label', 'Move tree item');\n }\n });\n }\n\n /**\n * Finds a tree item from a composed event path.\n * @param {Event} e User interaction that may originate inside shadow DOM.\n * @returns {HTMLElement|null}\n */\n getTreeItemFromEvent(e) {\n const path = e.composedPath?.() || [];\n const pathItem = path.find((el) => this.isTreeItem(el) && this.contains(el));\n if (pathItem) return pathItem;\n\n const targetItem = e.target?.closest?.('wje-tree-item');\n return targetItem && this.contains(targetItem) ? targetItem : null;\n }\n\n /**\n * Checks whether the event started from a reorder handle.\n * @param {Event} e User interaction to inspect.\n * @returns {boolean}\n */\n isReorderHandleEvent(e) {\n return (e.composedPath?.() || []).some((el) => el?.classList?.contains('wje-tree-drag-handle'));\n }\n\n /**\n * Checks whether a node is a tree item element.\n * @param {object} node The node to inspect.\n * @returns {boolean}\n */\n isTreeItem(node) {\n return node instanceof Element && node.localName === 'wje-tree-item';\n }\n\n /**\n * Returns direct tree item children for a tree or tree item parent.\n * @param {HTMLElement} parent The parent element.\n * @returns {HTMLElement[]}\n */\n getDirectTreeItems(parent) {\n return Array.from(parent?.children || []).filter((child) => this.isTreeItem(child));\n }\n\n /**\n * Gets the index of a tree item among direct tree item siblings.\n * @param {HTMLElement} item Element whose sibling position should be resolved.\n * @returns {number}\n */\n getTreeItemIndex(item) {\n return this.getDirectTreeItems(item.parentElement).indexOf(item);\n }\n\n /**\n * Determines whether the dragged item can be dropped on the target.\n * @param {HTMLElement} draggedItem Item currently being moved.\n * @param {HTMLElement} targetItem Candidate item under the pointer.\n * @returns {boolean}\n */\n canDrop(draggedItem, targetItem) {\n return !!draggedItem && !!targetItem && draggedItem !== targetItem && !draggedItem.contains(targetItem);\n }\n\n /**\n * Resolves the drop position against the visible tree item row.\n * @param {DragEvent} e Browser drag event carrying pointer coordinates.\n * @param {HTMLElement|null} target Item used to calculate row boundaries.\n * @returns {'before'|'inside'|'after'}\n */\n getDropPosition(e, target) {\n const row = target?.shadowRoot?.querySelector('.item');\n const rect = row?.getBoundingClientRect?.() || target?.getBoundingClientRect?.();\n\n if (!rect) return 'after';\n\n const topBoundary = rect.top + rect.height * 0.25;\n const bottomBoundary = rect.bottom - rect.height * 0.25;\n\n if (e.clientY < topBoundary) return 'before';\n if (e.clientY > bottomBoundary) return 'after';\n\n return 'inside';\n }\n\n /**\n * Applies the visual drop position to the current target item.\n * @param {HTMLElement} target Item currently showing insertion feedback.\n * @param {string} position Resolved insertion area for the target row.\n * @returns {void}\n */\n setDropState(target, position) {\n if (this.dropTarget !== target || this.dropPosition !== position) {\n this.clearDropState();\n this.dropTarget = target;\n this.dropPosition = position;\n target.classList.add(this.getDropPositionClass(position));\n }\n }\n\n /**\n * Clears visual drop target state.\n * @returns {void}\n */\n clearDropState() {\n this.dropTarget?.classList.remove(\n this.getDropPositionClass('before'),\n this.getDropPositionClass('inside'),\n this.getDropPositionClass('after')\n );\n this.dropTarget = null;\n this.dropPosition = null;\n }\n\n /**\n * Clears the active drag state.\n * @returns {void}\n */\n clearDragState() {\n this.draggedItem?.classList.remove('wje-tree-dragging');\n this.clearDropState();\n this.draggedItem = null;\n }\n\n /**\n * Returns the internal class used to render a drop marker.\n * @param {'before'|'inside'|'after'} position Drop marker position.\n * @returns {string}\n */\n getDropPositionClass(position) {\n return `wje-tree-drop-${position}`;\n }\n\n /**\n * Moves a tree item relative to another tree item and syncs nesting metadata.\n * @param {HTMLElement} draggedItem The item being moved.\n * @param {HTMLElement} targetItem Item that receives or anchors the moved item.\n * @param {'before'|'inside'|'after'} position The target position.\n * @returns {object|null} Move detail, or null when the move is invalid.\n */\n moveItem(draggedItem, targetItem, position = 'after') {\n if (!this.canDrop(draggedItem, targetItem)) return null;\n\n const fromParent = draggedItem.parentElement;\n const fromParentItem = fromParent?.closest?.('wje-tree-item');\n const fromIndex = this.getTreeItemIndex(draggedItem);\n\n if (position === 'inside') {\n targetItem.appendChild(draggedItem);\n targetItem.setChildrenExpanded?.(true);\n } else {\n const parent = targetItem.parentElement;\n const reference = position === 'before' ? targetItem : targetItem.nextSibling;\n parent.insertBefore(draggedItem, reference);\n }\n\n this.syncTreeItems();\n\n const toParent = draggedItem.parentElement;\n const toParentItem = toParent?.closest?.('wje-tree-item');\n const toIndex = this.getTreeItemIndex(draggedItem);\n const orderElements = this.getOrderElements(toParent);\n const order = orderElements.map((item) => item.innerText.trim());\n\n this.refreshMovedItems([fromParentItem, toParentItem, targetItem]);\n\n return {\n item: draggedItem,\n target: targetItem,\n position,\n from: fromIndex,\n to: toIndex,\n order,\n orderElements,\n orderIds: this.getOrderIds(toParent),\n itemId: this.getItemId(draggedItem),\n targetId: this.getItemId(targetItem),\n fromParentItem,\n toParentItem,\n fromParentId: this.getItemId(fromParentItem),\n toParentId: this.getItemId(toParentItem),\n fromParent,\n toParent,\n fromIndex,\n toIndex,\n };\n }\n\n /**\n * Returns cloned direct tree item children for an event detail.\n * @param {HTMLElement} parent Parent whose direct tree item children should be serialized.\n * @returns {HTMLElement[]}\n */\n getOrderElements(parent) {\n return this.getDirectTreeItems(parent).map((item) => {\n const clone = item.cloneNode(true);\n clone.querySelectorAll('.wje-tree-template-slot').forEach((slot) => slot.remove());\n return clone;\n });\n }\n\n /**\n * Returns stable ids for direct tree item children when they are available.\n * @param {HTMLElement} parent Parent whose direct tree item children should be serialized.\n * @returns {Array<string|null>}\n */\n getOrderIds(parent) {\n return this.getDirectTreeItems(parent).map((item) => this.getItemId(item));\n }\n\n /**\n * Gets an application-facing id from a tree item.\n * @param {HTMLElement|null} item Tree item to read.\n * @returns {string|null}\n */\n getItemId(item) {\n if (!this.isTreeItem(item)) return null;\n return item.getAttribute('value') || item.id || null;\n }\n\n /**\n * Syncs item selection mode and nesting metadata after a DOM move.\n * @returns {void}\n */\n syncTreeItems() {\n this.getAllItems().forEach((item) => {\n item.selection = this.selection;\n item.syncNestingState?.();\n item.syncAria?.();\n });\n }\n\n /**\n * Redraws affected parent items so expand/collapse affordances match current children.\n * @param {HTMLElement[]} items Items that may need refresh.\n * @returns {void}\n */\n refreshMovedItems(items) {\n [...new Set(items)].forEach((item) => {\n if (this.isTreeItem(item)) item.refresh?.();\n });\n }\n\n /**\n * Updates the state of a checkbox, syncing the state both upwards to parent elements\n * and downwards to child elements as necessary.\n * @param {object} changedItem The specific item whose checkbox state has changed.\n * @param {boolean} [isInitialSync] Indicates whether the state update is part of the initial synchronization process.\n * @returns {void} This method does not return a value.\n */\n updateCheckboxState(changedItem, isInitialSync = false) {\n this.isInitialSync = isInitialSync;\n this.propagateStateDownwards(changedItem);\n this.propagateStateUpwards(changedItem);\n }\n\n /**\n * Updates the state of the parent item based on the state of its child items.\n * Recursively propagates changes up to all parent items to reflect the selection\n * or indeterminate state accurately.\n * @param {object} item The current tree item whose parent state needs to be updated.\n * It is expected to have properties `selected`, `indeterminate`,\n * and a method `getChildrenItems({ includeDisabled: boolean })`.\n * @returns {void} This method does not return a value.\n */\n updateParentState(item) {\n const children = item.getChildrenItems({ includeDisabled: false });\n\n if (children.length) {\n const areAllChildrenChecked = children.every((child) => child.selected);\n const areSomeChildrenChecked = children.some((child) => child.selected);\n const areSomeChildrenIndeterminate = children.some((child) => child.indeterminate);\n\n item.selected = areAllChildrenChecked;\n item.indeterminate = areSomeChildrenIndeterminate || (areSomeChildrenChecked && !areAllChildrenChecked);\n } else {\n item.indeterminate = false;\n }\n\n const parent = item.parentElement?.closest('wje-tree-item');\n if (parent) {\n this.updateParentState(parent);\n }\n }\n\n /**\n * Propagates the state changes of an item upwards through its ancestors in the hierarchy.\n * Calls the `updateParentState` method for each parent element until no parent exists.\n * @param {HTMLElement} item The current item whose state to propagate to its parent.\n * @returns {void} This method does not return a value.\n */\n propagateStateUpwards(item) {\n const parent = item.parentElement?.closest('wje-tree-item');\n\n if (parent) {\n this.updateParentState(parent);\n this.propagateStateUpwards(parent);\n }\n }\n\n /**\n * Propagates the selected state of an item to its children recursively. Depending on the `isInitialSync` flag,\n * it also determines how the state should be applied to the child items and updates the parent state if needed.\n * @param {object} item The item whose state is being propagated to its child items. The item must have properties\n * such as `selected` and methods like `getChildrenItems` to retrieve its child elements.\n * @returns {void} This method does not return a value.\n */\n propagateStateDownwards(item) {\n const isChecked = item.selected;\n\n item.getChildrenItems().forEach((child) => {\n child.selected = this.isInitialSync ? isChecked || child.selected : !child.disabled && isChecked;\n this.propagateStateDownwards(child);\n });\n\n if (this.isInitialSync) {\n this.updateParentState(item);\n }\n }\n}\n","import Tree from './tree.element.js';\n\nexport default Tree;\n\nTree.define('wje-tree', Tree);\n"],"names":["Tree","WJElement","constructor","super","className","handleClick","e","preventDefault","this","reorder","isReorderHandleEvent","selectedItem","getTreeItemFromEvent","composedPath","some","el","classList","contains","selection","item","getAllItems","selected","updateCheckboxState","handleDragStart","draggedItem","add","dataTransfer","effectAllowed","setData","textContent","trim","handleDragOver","target","canDrop","clearDropState","dropEffect","position","getDropPosition","setDropState","handleDrop","dropTarget","dropPosition","detail","moveItem","dispatchEvent","CustomEvent","bubbles","composed","clearDragState","handleDragEnd","value","setAttribute","getAttribute","removeAttribute","hasAttribute","cssStyleSheet","setupAttributes","isShadowRoot","syncAria","beforeDraw","template","querySelector","items","querySelectorAll","forEach","syncNestingState","appendTemplateSlot","setupReorderHandle","draw","fragment","document","createDocumentFragment","native","createElement","slot","appendChild","afterDraw","addEventListener","setAriaState","role","multiselectable","beforeDisconnect","removeEventListener","slotName","content","templateSlotClass","getTemplateSlotClass","slotClone","cloneNode","append","handle","pathItem","find","isTreeItem","targetItem","closest","node","Element","localName","parent","Array","from","children","filter","child","getDirectTreeItems","parentElement","indexOf","row","shadowRoot","rect","getBoundingClientRect","topBoundary","top","height","bottomBoundary","bottom","clientY","getDropPositionClass","remove","fromParent","fromParentItem","fromIndex","getTreeItemIndex","setChildrenExpanded","reference","nextSibling","insertBefore","syncTreeItems","toParent","toParentItem","toIndex","orderElements","getOrderElements","order","map","innerText","refreshMovedItems","to","orderIds","getOrderIds","itemId","getItemId","targetId","fromParentId","toParentId","clone","id","Set","refresh","changedItem","isInitialSync","propagateStateDownwards","propagateStateUpwards","getChildrenItems","includeDisabled","length","areAllChildrenChecked","every","areSomeChildrenChecked","areSomeChildrenIndeterminate","indeterminate","updateParentState","isChecked","disabled","define"],"mappings":";;;;AAiBe,MAAMA,UAAaC,EAAAA;AAAAA,EAI9B,cAAAC;AACIC,UAAAA;AA6CJC,qCAAY;AAqGZC,uCAAeC,CAAAA,OAAAA;;AAEX,WADIA,MAAAA,gBAAAA,GAAGC,mBAAgBD,GAAEC,e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AAKuF,kBAALvF,mBAAoB4E,QAAQ;AAEvCI,IAAAA,OACA3F,KAAK0J,kBAAkB/D,EAAAA,GACvB3F,KAAKiJ,sBAAsBtD,EAAAA;AAAAA,EAEnC;AAAA,EASA,wBAAwBhF,IAAAA;AACpB,UAAMgJ,KAAYhJ,GAAKE;AAEvBF,IAAAA,GAAKuI,iBAAAA,EAAmB1F,QAASwC,CAAAA,OAAAA;AAC7BA,MAAAA,GAAMnF,WAAWb,KAAK+I,gBAAgBY,MAAa3D,GAAMnF,WAAAA,CAAYmF,GAAM4D,YAAYD,IACvF3J,KAAKgJ,wBAAwBhD,EAAAA;AAAAA,IAAAA,CAAAA,GAG7BhG,KAAK+I,iBACL/I,KAAK0J,kBAAkB/I,EAAAA;AAAAA,EAE/B;AAAA;ACtnBJnB,EAAKqK,OAAO,YAAYrK,CAAAA;"}
@@ -1,55 +1,28 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ WJ Visually Hidden ]\n*/\n\n:host(:not(:focus-within)) {\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n clip: rect(0 0 0 0) !important;\n clip-path: inset(50%) !important;\n border: none !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n padding: 0 !important;\n}\n";
6
- class VisuallyHidden extends WJElement {
7
- /**
8
- * Creates an instance of VisuallyHidden.
9
- */
4
+ import t from "./wje-element.js";
5
+ class e extends t {
10
6
  constructor() {
11
7
  super();
12
- /**
13
- * The class name for the component.
14
- * @type {string}
15
- */
16
8
  __publicField(this, "className", "VisuallyHidden");
17
9
  }
18
- /**
19
- * Returns the CSS stylesheet for the component.
20
- * @static
21
- * @returns {CSSStyleSheet} The CSS stylesheet
22
- */
23
10
  static get cssStyleSheet() {
24
- return styles;
11
+ return ":host(:not(:focus-within)){position:absolute!important;width:1px!important;height:1px!important;clip:rect(0 0 0 0)!important;clip-path:inset(50%)!important;border:none!important;overflow:hidden!important;white-space:nowrap!important;padding:0!important}";
25
12
  }
26
- /**
27
- * Returns the list of observed attributes.
28
- * @static
29
- * @returns {Array} An empty array
30
- */
31
13
  static get observedAttributes() {
32
14
  return [];
33
15
  }
34
- /**
35
- * Sets up the attributes for the component.
36
- */
37
16
  setupAttributes() {
38
17
  this.isShadowRoot = "open";
39
18
  }
40
- /**
41
- * Draws the component for the visually hidden element.
42
- * @returns {object} Document fragment
43
- */
44
19
  draw() {
45
- let fragment = document.createDocumentFragment();
46
- let slot = document.createElement("slot");
47
- fragment.appendChild(slot);
48
- return fragment;
20
+ let t2 = document.createDocumentFragment(), e2 = document.createElement("slot");
21
+ return t2.appendChild(e2), t2;
49
22
  }
50
23
  }
51
- VisuallyHidden.define("wje-visually-hidden", VisuallyHidden);
24
+ e.define("wje-visually-hidden", e);
52
25
  export {
53
- VisuallyHidden as default
26
+ e as default
54
27
  };
55
28
  //# sourceMappingURL=wje-visually-hidden.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-visually-hidden.js","sources":["../packages/wje-visually-hidden/visually-hidden.element.js","../packages/wje-visually-hidden/visually-hidden.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `VisuallyHidden` is a custom web component that represents a visually hidden element.\n * @summary This element represents a visually hidden element.\n * @documentation https://elements.webjet.sk/components/visually-hidden\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the visually hidden element.\n * @tag wje-visually-hidden\n */\nexport default class VisuallyHidden extends WJElement {\n /**\n * Creates an instance of VisuallyHidden.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'VisuallyHidden';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 for the visually hidden element.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let slot = document.createElement('slot');\n\n fragment.appendChild(slot);\n\n return fragment;\n }\n}\n","import VisuallyHidden from './visually-hidden.element.js';\n\nexport default VisuallyHidden;\n\nVisuallyHidden.define('wje-visually-hidden', VisuallyHidden);\n"],"names":[],"mappings":";;;;;AAYe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIlD,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,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,OAAO,SAAS,cAAc,MAAM;AAExC,aAAS,YAAY,IAAI;AAEzB,WAAO;AAAA,EACX;AACJ;AC5DA,eAAe,OAAO,uBAAuB,cAAc;"}
1
+ {"version":3,"file":"wje-visually-hidden.js","sources":["../packages/wje-visually-hidden/visually-hidden.element.js","../packages/wje-visually-hidden/visually-hidden.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `VisuallyHidden` is a custom web component that represents a visually hidden element.\n * @summary This element represents a visually hidden element.\n * @documentation https://elements.webjet.sk/components/visually-hidden\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the visually hidden element.\n * @tag wje-visually-hidden\n */\nexport default class VisuallyHidden extends WJElement {\n /**\n * Creates an instance of VisuallyHidden.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'VisuallyHidden';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 for the visually hidden element.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let slot = document.createElement('slot');\n\n fragment.appendChild(slot);\n\n return fragment;\n }\n}\n","import VisuallyHidden from './visually-hidden.element.js';\n\nexport default VisuallyHidden;\n\nVisuallyHidden.define('wje-visually-hidden', VisuallyHidden);\n"],"names":["VisuallyHidden","WJElement","constructor","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","draw","fragment","document","createDocumentFragment","slot","createElement","appendChild","define"],"mappings":";;;;AAYe,MAAMA,UAAuBC,EAAAA;AAAAA,EAIxC,cAAAC;AACIC,UAAAA;AAOJC,qCAAY;AAAA,EANZ;AAAA,EAaA,2BAAWC;AACP;EACJ;AAAA,EAOA,WAAA;AACI,WAAO,CAAA;AAAA,EACX;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,0BAEpBC,KAAOF,SAASG,cAAc,MAAA;AAIlC,WAFAJ,GAASK,YAAYF,EAAAA,GAEdH;AAAAA,EACX;AAAA;AC3DJV,EAAegB,OAAO,uBAAuBhB,CAAAA;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.7.7",
4
+ "version": "0.8.0",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",
@@ -119,6 +119,7 @@
119
119
  "@faker-js/faker": "^8.0.0",
120
120
  "@open-wc/semantic-dom-diff": "^0.20.1",
121
121
  "@open-wc/testing": "^3.2.0",
122
+ "@rollup/plugin-terser": "^1.0.0",
122
123
  "@web/test-runner": "^0.19.0",
123
124
  "@web/test-runner-commands": "^0.9.0",
124
125
  "@web/test-runner-playwright": "^0.11.0",
@@ -140,7 +141,7 @@
140
141
  "sass": "^1.83.0",
141
142
  "sinon": "^21.0.2",
142
143
  "typescript": "^5.8.2",
143
- "vite": "^6.4.1",
144
+ "vite": "^7.3.6",
144
145
  "vite-plugin-dts": "^4.5.0",
145
146
  "vite-plugin-javascript-obfuscator": "^3.1.0"
146
147
  }
@@ -1,245 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import WJElement from "./wje-element.js";
5
- import { event } from "./event.js";
6
- class FormAssociatedElement extends WJElement {
7
- constructor() {
8
- super();
9
- }
10
- /**
11
- * Sets the 'name' attribute to the given value.
12
- * @param {string} value The new value for the 'name' attribute.
13
- */
14
- set name(value) {
15
- this.setAttribute("name", value);
16
- }
17
- /**
18
- * Getter for the name attribute.
19
- * @returns {string} The name of the input.
20
- */
21
- get name() {
22
- return this.getAttribute("name");
23
- }
24
- /**
25
- * Getter for the type attribute.
26
- * @returns {string} The type of the input.
27
- */
28
- get type() {
29
- return this.getAttribute("type");
30
- }
31
- /**
32
- * Sets or removes the 'required' attribute on the element.
33
- * @param {boolean} value If true, adds the 'required' attribute. If false, removes the 'required' attribute.
34
- */
35
- set required(value) {
36
- if (value) {
37
- this.setAttribute("required", "");
38
- } else {
39
- this.removeAttribute("required");
40
- }
41
- }
42
- /**
43
- * Checks if the 'required' attribute is present on the element.
44
- * @returns {boolean} `true` if the 'required' attribute is set, otherwise `false`.
45
- */
46
- get required() {
47
- return this.hasAttribute("required");
48
- }
49
- /**
50
- * Setter for the invalid attribute.
51
- * @param {boolean} isInvalid Whether the input is invalid.
52
- */
53
- set invalid(isInvalid) {
54
- if (isInvalid) this.setAttribute("invalid", "");
55
- else this.removeAttribute("invalid");
56
- }
57
- /**
58
- * Getter for the invalid attribute.
59
- * @returns {boolean} Whether the attribute is present.
60
- */
61
- get invalid() {
62
- return this.hasAttribute("invalid");
63
- }
64
- /**
65
- * Set checked attribute.
66
- * @param {boolean} value true if the toggle is checked, false otherwise
67
- */
68
- set disabled(value) {
69
- if (value) {
70
- this.setAttribute("disabled", "");
71
- } else {
72
- this.removeAttribute("disabled");
73
- }
74
- }
75
- /**
76
- * Get disabled attribute value.
77
- * @returns {boolean} true if the toggle is disabled, false otherwise
78
- */
79
- get disabled() {
80
- return this.hasAttribute("disabled");
81
- }
82
- /**
83
- * Retrieves the form element associated with this object.
84
- * @returns {HTMLFormElement|null} The associated form element, or null if there isn't one.
85
- */
86
- get form() {
87
- return this.internals.form;
88
- }
89
- /**
90
- * Retrieves the validity state of the element by returning the validity object from the internal element.
91
- * The validity object provides information on whether the element satisfies its validation constraints.
92
- * @returns {ValidityState} The validity state object representing the element's validation constraints.
93
- */
94
- get validity() {
95
- return this.internals.validity;
96
- }
97
- /**
98
- * Retrieves the current validation message associated with the element.
99
- * @returns {string} The validation message that describes why the element's value fails validity checks.
100
- */
101
- get validationMessage() {
102
- return this.internals.validationMessage;
103
- }
104
- /**
105
- * Indicates whether the element is a candidate for constraint validation.
106
- * @returns {boolean} Returns true if the element will be validated during constraint validation, false otherwise.
107
- */
108
- get willValidate() {
109
- return this.internals.willValidate;
110
- }
111
- /**
112
- * Validates the input element associated with the component and updates its validity state
113
- * and error messages based on the user's input and the current validation rules.
114
- * @returns {void} This method does not return a value. It modifies the validity state
115
- * internally and sets appropriate validation messages.
116
- */
117
- validate() {
118
- const validState = this.input.validity;
119
- if (!validState.valid) {
120
- for (let state in validState) {
121
- const attr = `message-${state.toString()}`;
122
- if (validState[state]) {
123
- this.validationError = state.toString();
124
- let errorMessage = this.message;
125
- if (!this.hasAttribute("message"))
126
- errorMessage = this.hasAttribute(attr) ? this.getAttribute(attr) : this.input.validationMessage;
127
- this.internals.setValidity({ [this.validationError]: true }, errorMessage, this.input);
128
- }
129
- }
130
- } else {
131
- this.internals.setValidity({});
132
- }
133
- }
134
- /**
135
- * Propagates a validation event based on the validity state of the component.
136
- *
137
- * This method checks the validity status of the component and emits a custom
138
- * event if the component is invalid. The event's name and additional details
139
- * can be specified.
140
- * @param {string} [eventName] The name of the event to dispatch when the component is invalid.
141
- * @param {object} [detail] Additional detail to include in the dispatched event.
142
- * @returns {void} This method does not return a value.
143
- */
144
- propagateValidation(eventName = "invalid", detail = {}) {
145
- const internals = this.internals;
146
- this.invalid = !this.pristine && !internals.validity.valid;
147
- if (this.invalid) {
148
- event.dispatchCustomEvent(this, this.tagName.toLocaleLowerCase() + ":" + eventName, detail);
149
- }
150
- }
151
- /**
152
- * Displays an invalid message for the current element.
153
- * If an error message element does not exist within the designated slot,
154
- * it creates one and appends it to the slot. Updates the text content
155
- * of the error message element with the validation message from the
156
- * element's internals.
157
- * @returns {void} This method does not return any value.
158
- */
159
- showInvalidMessage() {
160
- const internals = this.internals;
161
- const slot = this.querySelector("[slot='error']");
162
- let errorMessageEl = slot == null ? void 0 : slot.querySelector("[error-message]");
163
- if (!errorMessageEl) {
164
- const error = document.createElement("div");
165
- error.setAttribute("error-message", "");
166
- slot == null ? void 0 : slot.append(error);
167
- errorMessageEl = error;
168
- }
169
- errorMessageEl.textContent = internals.validationMessage;
170
- }
171
- /**
172
- * Checks the validity of the input by invoking custom validation logic
173
- * and then verifying against internal validation rules.
174
- * @returns {boolean} Returns true if the input is valid according to both custom validation and internal validation rules, otherwise false.
175
- */
176
- checkValidity() {
177
- this.validate();
178
- return this.internals.checkValidity();
179
- }
180
- /**
181
- * Callback to handle the reset action for a form.
182
- * Resets the value of the form control to its default value, updates the form value, and clears any validity states.
183
- * @returns {void} Does not return a value.
184
- */
185
- formResetCallback() {
186
- this.value = this.defaultValue;
187
- this.internals.setFormValue(this.defaultValue);
188
- this.internals.setValidity({});
189
- }
190
- /**
191
- * Restores the form state by assigning the provided state value
192
- * and updating the internal form value and validity.
193
- * @param {object} state The state object containing the value to restore the form.
194
- * @param {*} state.value The value to set for the form element.
195
- * @returns {void} This method does not return any value.
196
- */
197
- formStateRestoreCallback(state) {
198
- this.value = state.value;
199
- this.internals.setFormValue(state.value);
200
- this.internals.setValidity({});
201
- }
202
- /**
203
- * Callback method to save the current state of a form.
204
- * This method captures and returns the form's value property.
205
- * @returns {object} An object containing the `value` property of the current form state.
206
- */
207
- formStateSaveCallback() {
208
- return {
209
- value: this.value
210
- };
211
- }
212
- /**
213
- * Toggles the disabled state of the component and updates corresponding attributes.
214
- * @param {boolean} disabled Indicates whether the form should be marked as disabled.
215
- * If true, the 'disabled' class is added, and the 'disabled' attribute is set.
216
- * If false, both the class and attribute are removed.
217
- * @returns {void}
218
- */
219
- formDisabledCallback(disabled) {
220
- var _a;
221
- (_a = this.native) == null ? void 0 : _a.classList.toggle("disabled", disabled);
222
- this.toggleAttribute("disabled", disabled);
223
- }
224
- /**
225
- * A lifecycle callback that is executed when the element is associated with a form.
226
- * It updates the form's value field with the element's value and sets up an event
227
- * listener to perform validation and propagate it whenever the form is submitted.
228
- * @returns {void} Does not return any value.
229
- */
230
- formAssociatedCallback() {
231
- var _a;
232
- if (this.form) {
233
- this.internals.setFormValue(this.value);
234
- (_a = this.form) == null ? void 0 : _a.addEventListener("submit", () => {
235
- this.validate();
236
- this.propagateValidation();
237
- });
238
- }
239
- }
240
- }
241
- __publicField(FormAssociatedElement, "formAssociated", true);
242
- export {
243
- FormAssociatedElement as F
244
- };
245
- //# sourceMappingURL=form-associated-element-DEQ4y-jn.js.map