wj-elements 0.1.199 → 0.1.201

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 (238) hide show
  1. package/dist/packages/index.d.ts +107 -0
  2. package/dist/packages/internals/form-associated-element.d.ts +143 -0
  3. package/dist/packages/localize/localize.d.ts +47 -0
  4. package/dist/packages/translations/en-gb.d.ts +18 -0
  5. package/dist/packages/translations/sk-sk.d.ts +13 -0
  6. package/dist/packages/utils/animations.d.ts +2 -0
  7. package/dist/packages/utils/base-path.d.ts +14 -0
  8. package/dist/packages/utils/date.d.ts +2 -0
  9. package/dist/packages/utils/element-utils.d.ts +46 -0
  10. package/dist/packages/utils/event.d.ts +67 -0
  11. package/dist/packages/utils/icon-library.d.ts +3 -0
  12. package/dist/packages/utils/localize.d.ts +4 -0
  13. package/dist/packages/utils/permissions.d.ts +40 -0
  14. package/dist/packages/utils/universal-service.d.ts +18 -0
  15. package/dist/packages/utils/utils.d.ts +1 -0
  16. package/dist/packages/wje-accordion/accordion.d.ts +2 -0
  17. package/dist/packages/wje-accordion/accordion.element.d.ts +72 -0
  18. package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
  19. package/dist/packages/wje-accordion-item/accordion-item.d.ts +2 -0
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +40 -0
  21. package/dist/packages/wje-animation/animation.d.ts +2 -0
  22. package/dist/packages/wje-animation/animation.element.d.ts +158 -0
  23. package/dist/packages/wje-animation/animation.test.d.ts +1 -0
  24. package/dist/packages/wje-aside/aside.d.ts +2 -0
  25. package/dist/packages/wje-aside/aside.element.d.ts +31 -0
  26. package/dist/packages/wje-avatar/avatar.d.ts +2 -0
  27. package/dist/packages/wje-avatar/avatar.element.d.ts +76 -0
  28. package/dist/packages/wje-avatar/avatar.test.d.ts +1 -0
  29. package/dist/packages/wje-avatar/service/service.d.ts +40 -0
  30. package/dist/packages/wje-badge/badge.d.ts +2 -0
  31. package/dist/packages/wje-badge/badge.element.d.ts +35 -0
  32. package/dist/packages/wje-badge/badge.test.d.ts +1 -0
  33. package/dist/packages/wje-breadcrumb/breadcrumb.d.ts +2 -0
  34. package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +80 -0
  35. package/dist/packages/wje-breadcrumbs/breadcrumbs.d.ts +2 -0
  36. package/dist/packages/wje-breadcrumbs/breadcrumbs.element.d.ts +97 -0
  37. package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +1 -0
  38. package/dist/packages/wje-button/button.d.ts +2 -0
  39. package/dist/packages/wje-button/button.element.d.ts +204 -0
  40. package/dist/packages/wje-button/button.test.d.ts +1 -0
  41. package/dist/packages/wje-button-group/button-group.d.ts +2 -0
  42. package/dist/packages/wje-button-group/button-group.element.d.ts +96 -0
  43. package/dist/packages/wje-card/card.d.ts +2 -0
  44. package/dist/packages/wje-card/card.element.d.ts +29 -0
  45. package/dist/packages/wje-card-content/card-content.d.ts +2 -0
  46. package/dist/packages/wje-card-content/card-content.element.d.ts +22 -0
  47. package/dist/packages/wje-card-controls/card-controls.d.ts +2 -0
  48. package/dist/packages/wje-card-controls/card-controls.element.d.ts +23 -0
  49. package/dist/packages/wje-card-header/card-header.d.ts +2 -0
  50. package/dist/packages/wje-card-header/card-header.element.d.ts +22 -0
  51. package/dist/packages/wje-card-subtitle/card-subtitle.d.ts +2 -0
  52. package/dist/packages/wje-card-subtitle/card-subtitle.element.d.ts +30 -0
  53. package/dist/packages/wje-card-title/card-title.d.ts +2 -0
  54. package/dist/packages/wje-card-title/card-title.element.d.ts +32 -0
  55. package/dist/packages/wje-carousel/carousel.d.ts +2 -0
  56. package/dist/packages/wje-carousel/carousel.element.d.ts +146 -0
  57. package/dist/packages/wje-carousel-item/carousel-item.d.ts +2 -0
  58. package/dist/packages/wje-carousel-item/carousel-item.element.d.ts +38 -0
  59. package/dist/packages/wje-checkbox/checkbox.d.ts +2 -0
  60. package/dist/packages/wje-checkbox/checkbox.element.d.ts +99 -0
  61. package/dist/packages/wje-chip/chip.d.ts +2 -0
  62. package/dist/packages/wje-chip/chip.element.d.ts +64 -0
  63. package/dist/packages/wje-col/col.d.ts +2 -0
  64. package/dist/packages/wje-col/col.element.d.ts +16 -0
  65. package/dist/packages/wje-color-picker/color-picker.d.ts +2 -0
  66. package/dist/packages/wje-color-picker/color-picker.element.d.ts +187 -0
  67. package/dist/packages/wje-color-picker/color-picker.test.d.ts +1 -0
  68. package/dist/packages/wje-container/container.d.ts +2 -0
  69. package/dist/packages/wje-container/container.element.d.ts +31 -0
  70. package/dist/packages/wje-copy-button/copy-button.d.ts +2 -0
  71. package/dist/packages/wje-copy-button/copy-button.element.d.ts +89 -0
  72. package/dist/packages/wje-copy-button/service/service.d.ts +12 -0
  73. package/dist/packages/wje-dialog/dialog.d.ts +2 -0
  74. package/dist/packages/wje-dialog/dialog.element.d.ts +127 -0
  75. package/dist/packages/wje-divider/divider.d.ts +2 -0
  76. package/dist/packages/wje-divider/divider.element.d.ts +32 -0
  77. package/dist/packages/wje-dropdown/dropdown.d.ts +2 -0
  78. package/dist/packages/wje-dropdown/dropdown.element.d.ts +84 -0
  79. package/dist/packages/wje-element/element.d.ts +306 -0
  80. package/dist/packages/wje-file-upload/file-upload.d.ts +2 -0
  81. package/dist/packages/wje-file-upload/file-upload.element.d.ts +191 -0
  82. package/dist/packages/wje-file-upload/service/service.d.ts +70 -0
  83. package/dist/packages/wje-file-upload-item/file-upload-item.d.ts +2 -0
  84. package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +68 -0
  85. package/dist/packages/wje-footer/footer.d.ts +2 -0
  86. package/dist/packages/wje-footer/footer.element.d.ts +28 -0
  87. package/dist/packages/wje-form/form.d.ts +2 -0
  88. package/dist/packages/wje-form/form.element.d.ts +28 -0
  89. package/dist/packages/wje-format-digital/format-digital.d.ts +2 -0
  90. package/dist/packages/wje-format-digital/format-digital.element.d.ts +83 -0
  91. package/dist/packages/wje-format-digital/format-digital.test.d.ts +1 -0
  92. package/dist/packages/wje-grid/grid.d.ts +2 -0
  93. package/dist/packages/wje-grid/grid.element.d.ts +26 -0
  94. package/dist/packages/wje-header/header.d.ts +2 -0
  95. package/dist/packages/wje-header/header.element.d.ts +35 -0
  96. package/dist/packages/wje-icon/icon.d.ts +2 -0
  97. package/dist/packages/wje-icon/icon.element.d.ts +40 -0
  98. package/dist/packages/wje-icon/service/library.d.ts +3 -0
  99. package/dist/packages/wje-icon/service/service.d.ts +11 -0
  100. package/dist/packages/wje-icon-picker/icon-picker.d.ts +2 -0
  101. package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +187 -0
  102. package/dist/packages/wje-img/img.d.ts +2 -0
  103. package/dist/packages/wje-img/img.element.d.ts +118 -0
  104. package/dist/packages/wje-img-comparer/img-comparer.d.ts +2 -0
  105. package/dist/packages/wje-img-comparer/img-comparer.element.d.ts +60 -0
  106. package/dist/packages/wje-img-comparer/service/service.d.ts +1 -0
  107. package/dist/packages/wje-infinite-scroll/infinite-scroll.d.ts +2 -0
  108. package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +172 -0
  109. package/dist/packages/wje-input/input.d.ts +2 -0
  110. package/dist/packages/wje-input/input.element.d.ts +159 -0
  111. package/dist/packages/wje-input-file/input-file.d.ts +2 -0
  112. package/dist/packages/wje-input-file/input-file.element.d.ts +50 -0
  113. package/dist/packages/wje-item/item.d.ts +2 -0
  114. package/dist/packages/wje-item/item.element.d.ts +68 -0
  115. package/dist/packages/wje-kanban/kanban.d.ts +2 -0
  116. package/dist/packages/wje-kanban/kanban.element.d.ts +182 -0
  117. package/dist/packages/wje-label/label.d.ts +2 -0
  118. package/dist/packages/wje-label/label.element.d.ts +34 -0
  119. package/dist/packages/wje-level-indicator/level-indicator.d.ts +2 -0
  120. package/dist/packages/wje-level-indicator/level-indicator.element.d.ts +91 -0
  121. package/dist/packages/wje-list/list.d.ts +2 -0
  122. package/dist/packages/wje-list/list.element.d.ts +31 -0
  123. package/dist/packages/wje-main/main.d.ts +2 -0
  124. package/dist/packages/wje-main/main.element.d.ts +30 -0
  125. package/dist/packages/wje-masonry/masonry.d.ts +2 -0
  126. package/dist/packages/wje-masonry/masonry.element.d.ts +114 -0
  127. package/dist/packages/wje-masonry/service/service.d.ts +32 -0
  128. package/dist/packages/wje-menu/menu.d.ts +2 -0
  129. package/dist/packages/wje-menu/menu.element.d.ts +47 -0
  130. package/dist/packages/wje-menu-button/menu-button.d.ts +2 -0
  131. package/dist/packages/wje-menu-button/menu-button.element.d.ts +34 -0
  132. package/dist/packages/wje-menu-item/menu-item.d.ts +2 -0
  133. package/dist/packages/wje-menu-item/menu-item.element.d.ts +158 -0
  134. package/dist/packages/wje-menu-label/menu-label.d.ts +2 -0
  135. package/dist/packages/wje-menu-label/menu-label.element.d.ts +39 -0
  136. package/dist/packages/wje-option/option.d.ts +2 -0
  137. package/dist/packages/wje-option/option.element.d.ts +95 -0
  138. package/dist/packages/wje-options/options.d.ts +2 -0
  139. package/dist/packages/wje-options/options.element.d.ts +232 -0
  140. package/dist/packages/wje-orgchart/orgchart.d.ts +2 -0
  141. package/dist/packages/wje-orgchart/orgchart.element.d.ts +24 -0
  142. package/dist/packages/wje-orgchart-group/orgchart-group.d.ts +2 -0
  143. package/dist/packages/wje-orgchart-group/orgchart-group.element.d.ts +28 -0
  144. package/dist/packages/wje-orgchart-item/orgchart-item.d.ts +2 -0
  145. package/dist/packages/wje-orgchart-item/orgchart-item.element.d.ts +49 -0
  146. package/dist/packages/wje-pagination/pagination.d.ts +2 -0
  147. package/dist/packages/wje-pagination/pagination.element.d.ts +166 -0
  148. package/dist/packages/wje-pagination/pagination.test.d.ts +1 -0
  149. package/dist/packages/wje-pagination/service/service.d.ts +9 -0
  150. package/dist/packages/wje-panel/panel.d.ts +2 -0
  151. package/dist/packages/wje-panel/panel.element.d.ts +34 -0
  152. package/dist/packages/wje-popup/popup.d.ts +2 -0
  153. package/dist/packages/wje-popup/popup.element.d.ts +94 -0
  154. package/dist/packages/wje-progress-bar/progress-bar.d.ts +2 -0
  155. package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +96 -0
  156. package/dist/packages/wje-qr-code/qr-code.d.ts +2 -0
  157. package/dist/packages/wje-qr-code/qr-code.element.d.ts +33 -0
  158. package/dist/packages/wje-radio/radio.d.ts +2 -0
  159. package/dist/packages/wje-radio/radio.element.d.ts +64 -0
  160. package/dist/packages/wje-radio-group/radio-group.d.ts +2 -0
  161. package/dist/packages/wje-radio-group/radio-group.element.d.ts +61 -0
  162. package/dist/packages/wje-rate/rate.d.ts +2 -0
  163. package/dist/packages/wje-rate/rate.element.d.ts +156 -0
  164. package/dist/packages/wje-relative-time/relative-time.d.ts +2 -0
  165. package/dist/packages/wje-relative-time/relative-time.element.d.ts +55 -0
  166. package/dist/packages/wje-relative-time/relative-time.test.d.ts +1 -0
  167. package/dist/packages/wje-reorder/reorder.d.ts +2 -0
  168. package/dist/packages/wje-reorder/reorder.element.d.ts +119 -0
  169. package/dist/packages/wje-reorder-dropzone/reorder-dropzone.d.ts +2 -0
  170. package/dist/packages/wje-reorder-dropzone/reorder-dropzone.element.d.ts +23 -0
  171. package/dist/packages/wje-reorder-handle/reorder-handle.d.ts +2 -0
  172. package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +84 -0
  173. package/dist/packages/wje-reorder-item/reorder-item.d.ts +2 -0
  174. package/dist/packages/wje-reorder-item/reorder-item.element.d.ts +24 -0
  175. package/dist/packages/wje-route/route.d.ts +2 -0
  176. package/dist/packages/wje-route/route.element.d.ts +22 -0
  177. package/dist/packages/wje-router/router.d.ts +2 -0
  178. package/dist/packages/wje-router/router.element.d.ts +39 -0
  179. package/dist/packages/wje-router-link/router-link.d.ts +2 -0
  180. package/dist/packages/wje-router-link/router-link.element.d.ts +31 -0
  181. package/dist/packages/wje-router-outlet/router-outlet.d.ts +2 -0
  182. package/dist/packages/wje-router-outlet/router-outlet.element.d.ts +16 -0
  183. package/dist/packages/wje-row/row.d.ts +2 -0
  184. package/dist/packages/wje-row/row.element.d.ts +23 -0
  185. package/dist/packages/wje-select/select.d.ts +2 -0
  186. package/dist/packages/wje-select/select.element.d.ts +358 -0
  187. package/dist/packages/wje-slider/slider.d.ts +2 -0
  188. package/dist/packages/wje-slider/slider.element.d.ts +103 -0
  189. package/dist/packages/wje-sliding-container/sliding-container.d.ts +2 -0
  190. package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +265 -0
  191. package/dist/packages/wje-split-view/service/service.d.ts +1 -0
  192. package/dist/packages/wje-split-view/split-view.d.ts +2 -0
  193. package/dist/packages/wje-split-view/split-view.element.d.ts +65 -0
  194. package/dist/packages/wje-status/status.d.ts +2 -0
  195. package/dist/packages/wje-status/status.element.d.ts +26 -0
  196. package/dist/packages/wje-step/step.d.ts +2 -0
  197. package/dist/packages/wje-step/step.element.d.ts +23 -0
  198. package/dist/packages/wje-stepper/stepper.d.ts +2 -0
  199. package/dist/packages/wje-stepper/stepper.element.d.ts +80 -0
  200. package/dist/packages/wje-store/default-store-actions.d.ts +25 -0
  201. package/dist/packages/wje-store/pubsub.d.ts +22 -0
  202. package/dist/packages/wje-store/store.d.ts +153 -0
  203. package/dist/packages/wje-tab/tab.d.ts +2 -0
  204. package/dist/packages/wje-tab/tab.element.d.ts +66 -0
  205. package/dist/packages/wje-tab-group/tab-group.d.ts +2 -0
  206. package/dist/packages/wje-tab-group/tab-group.element.d.ts +107 -0
  207. package/dist/packages/wje-tab-panel/tab-panel.d.ts +2 -0
  208. package/dist/packages/wje-tab-panel/tab-panel.element.d.ts +23 -0
  209. package/dist/packages/wje-textarea/textarea.d.ts +2 -0
  210. package/dist/packages/wje-textarea/textarea.element.d.ts +89 -0
  211. package/dist/packages/wje-thumbnail/thumbnail.d.ts +2 -0
  212. package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +31 -0
  213. package/dist/packages/wje-timeline/timeline.d.ts +2 -0
  214. package/dist/packages/wje-timeline/timeline.element.d.ts +25 -0
  215. package/dist/packages/wje-timeline-item/timeline-item.d.ts +2 -0
  216. package/dist/packages/wje-timeline-item/timeline-item.element.d.ts +27 -0
  217. package/dist/packages/wje-toast/toast.d.ts +2 -0
  218. package/dist/packages/wje-toast/toast.element.d.ts +173 -0
  219. package/dist/packages/wje-toast/toast.test.d.ts +1 -0
  220. package/dist/packages/wje-toggle/toggle.d.ts +2 -0
  221. package/dist/packages/wje-toggle/toggle.element.d.ts +65 -0
  222. package/dist/packages/wje-toolbar/toolbar.d.ts +2 -0
  223. package/dist/packages/wje-toolbar/toolbar.element.d.ts +39 -0
  224. package/dist/packages/wje-toolbar-action/toolbar-action.d.ts +2 -0
  225. package/dist/packages/wje-toolbar-action/toolbar-action.element.d.ts +35 -0
  226. package/dist/packages/wje-tooltip/tooltip.d.ts +2 -0
  227. package/dist/packages/wje-tooltip/tooltip.element.d.ts +77 -0
  228. package/dist/packages/wje-tree/tree.d.ts +2 -0
  229. package/dist/packages/wje-tree/tree.element.d.ts +105 -0
  230. package/dist/packages/wje-tree/tree.test.d.ts +1 -0
  231. package/dist/packages/wje-tree-item/tree-item.d.ts +2 -0
  232. package/dist/packages/wje-tree-item/tree-item.element.d.ts +155 -0
  233. package/dist/packages/wje-tree-item/tree-item.test.d.ts +1 -0
  234. package/dist/packages/wje-visually-hidden/visually-hidden.d.ts +2 -0
  235. package/dist/packages/wje-visually-hidden/visually-hidden.element.d.ts +29 -0
  236. package/dist/wje-reorder-handle.js +38 -26
  237. package/dist/wje-reorder-handle.js.map +1 -1
  238. package/package.json +1 -1
@@ -0,0 +1,155 @@
1
+ /**
2
+ * `wje-tree-item` is a custom web component used as a child of the `wje-tree`.
3
+ * It represents a node within a tree structure, capable of nesting other items.
4
+ * @summary Represents a single item in a tree structure.
5
+ * @documentation https://elements.webjet.sk/components/tree-item
6
+ * @status stable
7
+ * @augments {HTMLElement}
8
+ * @slot - Default slot for rendering the tree item's content (e.g., text or custom elements).
9
+ * @csspart native - The native container of the tree item.
10
+ * @cssproperty [--wje-tree-item-indent=var(--wje-spacing-large)] - Defines the indentation for nested tree items.
11
+ * @cssproperty [--wje-tree-item-indent-guid-width=0px] - Specifies the width of the guide element shown next to a tree item.
12
+ * @cssproperty [--wje-tree-item-border-radius=var(--wje-border-radius-medium)] - Sets the border radius of the tree item’s container.
13
+ * @tag wje-tree-item
14
+ */
15
+ export default class TreeItem extends HTMLElement {
16
+ /**
17
+ * Returns the CSS stylesheet for the component.
18
+ * @static
19
+ * @returns {CSSStyleSheet} The CSS stylesheet
20
+ */
21
+ static get cssStyleSheet(): CSSStyleSheet;
22
+ /**
23
+ * Returns the list of attributes to observe for changes.
24
+ * @static
25
+ * @returns {Array<string>}
26
+ */
27
+ static get observedAttributes(): Array<string>;
28
+ _selection: string;
29
+ /**
30
+ * Sets the expanded state of the element. When set to a truthy value,
31
+ * the 'expanded' attribute will be added to the element. When set to a falsy
32
+ * value, the 'expanded' attribute will be removed.
33
+ * @param {boolean} value A boolean value indicating whether the
34
+ * element should be expanded (true) or collapsed (false).
35
+ */
36
+ set expanded(value: boolean);
37
+ /**
38
+ * Retrieves the value of the 'expanded' state for the current element.
39
+ * This getter checks whether the 'expanded' attribute is present on the element.
40
+ * If the attribute exists, it returns true, representing that the element is expanded.
41
+ * Otherwise, it returns false, indicating that the element is not expanded.
42
+ * @returns {boolean} True if the 'expanded' attribute is present, false otherwise.
43
+ */
44
+ get expanded(): boolean;
45
+ /**
46
+ * Sets the 'selected' attribute of the element. Removes the attribute if the provided value is falsy; otherwise, sets it.
47
+ * @param {boolean} value The value indicating whether the element should have the 'selected' attribute.
48
+ */
49
+ set selected(value: boolean);
50
+ /**
51
+ * Getter method for determining if the 'selected' attribute is present on the element.
52
+ * @returns {boolean} Returns true if the 'selected' attribute is present, otherwise false.
53
+ */
54
+ get selected(): boolean;
55
+ /**
56
+ * Sets the selection mode for the component.
57
+ * @param {string} value The selection mode to apply. Defaults to 'single'
58
+ * if no value is provided. Possible options may be
59
+ * specific to the implementation of the component
60
+ * (e.g., 'single', 'multiple').
61
+ */
62
+ set selection(value: string);
63
+ /**
64
+ * Retrieves the current selection.
65
+ * @returns {*} The value of the current selection.
66
+ */
67
+ get selection(): any;
68
+ /**
69
+ * Sets or removes the 'indeterminate' attribute based on the provided value.
70
+ * This can be used to visually indicate an indeterminate state for elements like checkboxes.
71
+ * @param {boolean} value A boolean indicating whether to set the element to an indeterminate state.
72
+ * If true, the 'indeterminate' attribute is added to the element; if false, the attribute is removed.
73
+ */
74
+ set indeterminate(value: boolean);
75
+ /**
76
+ * Retrieves the state of the indeterminate attribute.
77
+ * @returns {boolean} True if the indeterminate attribute is present, otherwise false.
78
+ */
79
+ get indeterminate(): boolean;
80
+ /**
81
+ * Setup attributes for the Button element.
82
+ */
83
+ setupAttributes(): void;
84
+ isShadowRoot: string;
85
+ /**
86
+ * Handles updates when observed attributes of the element are changed.
87
+ * Updates the checkbox state based on changes to the "selected" or "indeterminate" attributes.
88
+ * @param {string} name The name of the attribute that was changed.
89
+ * @param {string|null} oldValue The previous value of the attribute before the change.
90
+ * @param {string|null} newValue The new value of the attribute after the change.
91
+ * @returns {void}
92
+ */
93
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
94
+ /**
95
+ * Custom logic executed before the draw process begins.
96
+ * Determines and sets the appropriate slot if the current item is nested.
97
+ * @returns {void} No return value.
98
+ */
99
+ beforeDraw(): void;
100
+ /**
101
+ * Creates and returns a document fragment representing the structure of a tree item component.
102
+ * The method constructs the DOM elements including the native container, indentation, toggle button,
103
+ * selection checkbox, label, and children container, along with their respective slots and attributes.
104
+ * It dynamically handles the creation of expand and collapse icons, as well as appending slots for
105
+ * child components.
106
+ * @returns {DocumentFragment} A fragment containing the complete tree item structure to be rendered.
107
+ */
108
+ draw(): DocumentFragment;
109
+ checkbox: HTMLElement;
110
+ native: HTMLDivElement;
111
+ button: HTMLDivElement;
112
+ childrenElement: HTMLDivElement;
113
+ childrenSlot: HTMLSlotElement;
114
+ /**
115
+ * Executes operations to be performed after the draw action is completed.
116
+ * If the state indicates it is expanded, toggles its children.
117
+ * Additionally, sets up an event listener on the button element to handle toggling children upon click.
118
+ * @returns {void} Does not return a value.
119
+ */
120
+ afterDraw(): void;
121
+ /**
122
+ * Determines if the current item is a nested item within a tree structure.
123
+ * Checks if the item's parent element exists and is also a tree item.
124
+ * @returns {boolean} Returns true if the current item is a nested tree item; otherwise, false.
125
+ */
126
+ isNestedItem(): boolean;
127
+ /**
128
+ * Checks whether the given node is a tree item.
129
+ * @param {object} node The node to check.
130
+ * @returns {boolean} Returns true if the node is an Element and has a class name of 'TreeItem', otherwise false.
131
+ */
132
+ isTreeItem(node: object): boolean;
133
+ /**
134
+ * Toggles the visibility state of the children element and updates the class of the parent element.
135
+ * The method toggles the 'open' class on the children elements and the 'expanded' class on the parent element,
136
+ * effectively showing or hiding the children and indicating the expanded state.
137
+ * @returns {void} Does not return a value.
138
+ */
139
+ toggleChildren(): void;
140
+ /**
141
+ * Retrieves the child items from the `childrenSlot` that match specific criteria.
142
+ * @param {object} [options] Configuration options.
143
+ * @param {boolean} [options.includeDisabled] Determines whether disabled items should be included in the result. Defaults to true.
144
+ * @returns {Array} An array of child items that are valid tree items and meet the criteria specified in the options.
145
+ */
146
+ getChildrenItems(options?: {
147
+ includeDisabled?: boolean;
148
+ }): any[];
149
+ /**
150
+ * Retrieves all descendant children of the current object in a flattened array structure.
151
+ * @param {object} [options] An optional object specifying filters or configurations for retrieving children.
152
+ * @returns {Array} An array containing all children and their descendants in a flat structure.
153
+ */
154
+ getAllChildrenFlat(options?: object): any[];
155
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { default as VisuallyHidden } from './visually-hidden.element.js';
2
+ export default VisuallyHidden;
@@ -0,0 +1,29 @@
1
+ import { default as WJElement } from '../wje-element/element.js';
2
+ /**
3
+ * `VisuallyHidden` is a custom web component that represents a visually hidden element.
4
+ * @summary This element represents a visually hidden element.
5
+ * @documentation https://elements.webjet.sk/components/visually-hidden
6
+ * @status stable
7
+ * @augments {WJElement}
8
+ * @slot - The default slot for the visually hidden element.
9
+ * @tag wje-visually-hidden
10
+ */
11
+ export default class VisuallyHidden extends WJElement {
12
+ /**
13
+ * Returns the CSS stylesheet for the component.
14
+ * @static
15
+ * @returns {CSSStyleSheet} The CSS stylesheet
16
+ */
17
+ static get cssStyleSheet(): CSSStyleSheet;
18
+ /**
19
+ * Returns the list of observed attributes.
20
+ * @static
21
+ * @returns {Array} An empty array
22
+ */
23
+ static get observedAttributes(): any[];
24
+ /**
25
+ * Draws the component for the visually hidden element.
26
+ * @returns {object} Document fragment
27
+ */
28
+ draw(): object;
29
+ }
@@ -2,6 +2,7 @@ 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
4
  import WJElement from "./wje-element.js";
5
+ import { event } from "./event.js";
5
6
  const styles = ".disabled {\n opacity: 0.3;\n}\n";
6
7
  class ReorderHandle extends WJElement {
7
8
  /**
@@ -58,19 +59,20 @@ class ReorderHandle extends WJElement {
58
59
  }
59
60
  /**
60
61
  * Handles the attribute changes.
61
- * @param {DragEvent} event
62
+ * @param {DragEvent} e
62
63
  */
63
- startDrag(event) {
64
+ startDrag(e) {
64
65
  if (this.hasAttribute("disabled") || this.hasAttribute("locked")) return;
65
- this.startDragAction(event.clientX, event.clientY);
66
+ this.startDragAction(e.clientX, e.clientY);
67
+ event.dispatchCustomEvent(this, "wje-reorder-handle:start", { draggable: this.getDraggable() });
66
68
  }
67
69
  /**
68
70
  * Handles the touch start event.
69
- * @param {TouchEvent} event
71
+ * @param {TouchEvent} e
70
72
  */
71
- startTouchDrag(event) {
73
+ startTouchDrag(e) {
72
74
  if (this.hasAttribute("disabled") || this.hasAttribute("locked")) return;
73
- const touch = event.touches[0];
75
+ const touch = e.touches[0];
74
76
  this.startDragAction(touch.clientX, touch.clientY);
75
77
  }
76
78
  /**
@@ -79,13 +81,7 @@ class ReorderHandle extends WJElement {
79
81
  * @param {number} clientY The y-coordinate of the mouse pointer at the start of the drag action.
80
82
  */
81
83
  startDragAction(clientX, clientY) {
82
- let draggable;
83
- if (this.hasAttribute("parent")) {
84
- const parentSelector = this.getAttribute("parent");
85
- draggable = this.closest(parentSelector);
86
- } else {
87
- draggable = this.parentElement;
88
- }
84
+ let draggable = this.getDraggable();
89
85
  const initialContainer = this.getDropzone(draggable);
90
86
  if (!this.getAttribute("dropzone")) {
91
87
  this.setAttribute("dropzone", initialContainer.localName);
@@ -106,10 +102,10 @@ class ReorderHandle extends WJElement {
106
102
  draggable.style.top = `${pageY - offsetY - document.documentElement.scrollTop}px`;
107
103
  };
108
104
  moveAt(clientX, clientY);
109
- const onMouseMove = (event) => {
105
+ const onMouseMove = (e) => {
110
106
  var _a;
111
- moveAt(event.pageX, event.pageY);
112
- const dropzone = this.getClosestDropzone(event.clientX, event.clientY);
107
+ moveAt(e.pageX, e.pageY);
108
+ const dropzone = this.getClosestDropzone(e.clientX, e.clientY);
113
109
  if (!dropzone) return;
114
110
  const siblings = Array.from(dropzone.children).filter(
115
111
  (child) => child !== draggable && child !== placeholder
@@ -117,8 +113,8 @@ class ReorderHandle extends WJElement {
117
113
  for (const sibling of siblings) {
118
114
  const siblingRect = sibling.getBoundingClientRect();
119
115
  if ((_a = sibling.children[0]) == null ? void 0 : _a.hasAttribute("locked")) continue;
120
- if (event.clientY > siblingRect.top && event.clientY < siblingRect.bottom) {
121
- if (event.clientY < siblingRect.top + siblingRect.height / 2) {
116
+ if (e.clientY > siblingRect.top && e.clientY < siblingRect.bottom) {
117
+ if (e.clientY < siblingRect.top + siblingRect.height / 2) {
122
118
  dropzone.insertBefore(placeholder, sibling);
123
119
  } else {
124
120
  dropzone.insertBefore(placeholder, sibling.nextSibling);
@@ -140,20 +136,35 @@ class ReorderHandle extends WJElement {
140
136
  finalContainer.insertBefore(draggable, placeholder);
141
137
  finalContainer.removeChild(placeholder);
142
138
  this.reIndexItems(finalContainer);
139
+ event.dispatchCustomEvent(this, "wje-reorder-handle:change", { finalContainer, draggable });
143
140
  };
144
141
  document.addEventListener("mousemove", onMouseMove);
145
142
  document.addEventListener("mouseup", onMouseUp);
146
143
  initialContainer.insertBefore(placeholder, draggable);
147
144
  }
148
145
  /**
149
- * Retrieves the dropzone associated with the given element.
150
- * @param {HTMLElement} element The element from which to search for the closest dropzone.
151
- * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or the parent element if no dropzone is found.
146
+ * Retrieves the closest draggable element based on attribute conditions.
147
+ * If the element has a "parent" attribute, the method attempts to find the closest ancestor
148
+ * matching the CSS selector specified in the attribute. If no such ancestor exists,
149
+ * the method defaults to returning the immediate parent element.
150
+ * @returns {Element|null} The closest matching ancestor or the immediate parent element if no match is found, or null if the element has no parent.
151
+ */
152
+ getDraggable() {
153
+ if (this.hasAttribute("parent")) {
154
+ let parent = this.closest(this.getAttribute("parent"));
155
+ if (parent) return parent;
156
+ }
157
+ return this.parentElement;
158
+ }
159
+ /**
160
+ * Retrieves the nearest dropzone element based on the element's attributes or its parent element.
161
+ * @param {HTMLElement} element The HTML element for which the dropzone is being determined.
162
+ * @returns {HTMLElement|null} The nearest dropzone element if found; otherwise, the parent element or null.
152
163
  */
153
164
  getDropzone(element) {
154
- const dropzoneAttr = this.getAttribute("dropzone");
155
- if (dropzoneAttr) {
156
- let dropzone = element.closest(dropzoneAttr);
165
+ this.getAttribute("dropzone");
166
+ if (this.hasAttribute("dropzone")) {
167
+ let dropzone = element.closest(this.getAttribute("dropzone"));
157
168
  if (dropzone) return dropzone;
158
169
  }
159
170
  return element.parentElement;
@@ -194,8 +205,9 @@ class ReorderHandle extends WJElement {
194
205
  return allElements;
195
206
  }
196
207
  /**
197
- * Re-indexes the items in the container.
198
- * @param container
208
+ * Re-indexes child elements of the given container by setting their dataset index.
209
+ * @param {HTMLElement} container The container element whose children are to be re-indexed.
210
+ * @returns {void}
199
211
  */
200
212
  reIndexItems(container) {
201
213
  const items = Array.from(container.children);
@@ -1 +1 @@
1
- {"version":3,"file":"wje-reorder-handle.js","sources":["../packages/wje-reorder-handle/reorder-handle.element.js","../packages/wje-reorder-handle/reorder-handle.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ReorderHandle` is a custom web component that represents a reorder handle.\n * @summary This element represents a reorder handle.\n * @documentation https://elements.webjet.sk/components/reorder-handle\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the reorder handle.\n * @slot - The default slot for the reorder handle.\n * @tag wje-reorder-handle\n */\nexport default class ReorderHandle extends WJElement {\n /**\n * Creates an instance of ReorderHandle.\n */\n constructor() {\n super();\n this.addEventListener('mousedown', this.startDrag.bind(this));\n this.addEventListener('touchstart', this.startTouchDrag.bind(this));\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'ReorderHandle';\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 {string[]}\n */\n static get observedAttributes() {\n return ['dropzone', 'parent'];\n }\n\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n const fragment = document.createDocumentFragment();\n\n const container = document.createElement('div');\n container.classList.add('container');\n container.setAttribute('part', 'native');\n\n const slot = document.createElement('slot');\n\n container.appendChild(slot);\n\n fragment.appendChild(container);\n\n return fragment;\n }\n\n /**\n * Draws the component after it is connected to the DOM.\n */\n afterDraw() {\n if (this.hasAttribute('disabled')) {\n this.style.opacity = '.3';\n }\n }\n\n /**\n * Handles the attribute changes.\n * @param {DragEvent} event\n */\n startDrag(event) {\n if (this.hasAttribute('disabled') || this.hasAttribute('locked')) return;\n this.startDragAction(event.clientX, event.clientY);\n }\n\n /**\n * Handles the touch start event.\n * @param {TouchEvent} event\n */\n startTouchDrag(event) {\n if (this.hasAttribute('disabled') || this.hasAttribute('locked')) return;\n const touch = event.touches[0];\n this.startDragAction(touch.clientX, touch.clientY);\n }\n\n /**\n * Initiates the drag-and-drop action for a sortable element.\n * @param {number} clientX The x-coordinate of the mouse pointer at the start of the drag action.\n * @param {number} clientY The y-coordinate of the mouse pointer at the start of the drag action.\n */\n startDragAction(clientX, clientY) {\n let draggable;\n if (this.hasAttribute('parent')) {\n const parentSelector = this.getAttribute('parent');\n draggable = this.closest(parentSelector);\n } else {\n draggable = this.parentElement;\n }\n\n const initialContainer = this.getDropzone(draggable);\n\n if (!this.getAttribute('dropzone')) {\n this.setAttribute('dropzone', initialContainer.localName);\n }\n\n const rect = draggable.getBoundingClientRect();\n const offsetX = clientX - rect.left;\n const offsetY = clientY - rect.top;\n\n let placeholder = document.createElement('div');\n placeholder.classList.add('sortable-item');\n placeholder.style.visibility = 'hidden';\n placeholder.style.height = `${rect.height}px`;\n\n draggable.classList.add('dragging');\n\n draggable.style.position = 'fixed';\n draggable.style.zIndex = '1000';\n draggable.style.width = `${rect.width}px`;\n\n const moveAt = (pageX, pageY) => {\n draggable.style.left = `${pageX - offsetX - document.documentElement.scrollLeft}px`;\n draggable.style.top = `${pageY - offsetY - document.documentElement.scrollTop}px`;\n };\n\n moveAt(clientX, clientY);\n\n const onMouseMove = (event) => {\n moveAt(event.pageX, event.pageY);\n\n const dropzone = this.getClosestDropzone(event.clientX, event.clientY);\n if (!dropzone) return;\n\n const siblings = Array.from(dropzone.children).filter(\n (child) => child !== draggable && child !== placeholder\n );\n\n for (const sibling of siblings) {\n const siblingRect = sibling.getBoundingClientRect();\n\n if (sibling.children[0]?.hasAttribute('locked')) continue;\n\n if (event.clientY > siblingRect.top && event.clientY < siblingRect.bottom) {\n if (event.clientY < siblingRect.top + siblingRect.height / 2) {\n dropzone.insertBefore(placeholder, sibling);\n } else {\n dropzone.insertBefore(placeholder, sibling.nextSibling);\n }\n break;\n }\n }\n };\n\n const onMouseUp = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n\n draggable.classList.remove('dragging');\n\n draggable.style.position = '';\n draggable.style.zIndex = '';\n draggable.style.left = '';\n draggable.style.top = '';\n draggable.style.width = '';\n\n const finalContainer = placeholder.parentElement;\n finalContainer.insertBefore(draggable, placeholder);\n finalContainer.removeChild(placeholder);\n\n this.reIndexItems(finalContainer);\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n\n initialContainer.insertBefore(placeholder, draggable);\n }\n\n /**\n * Retrieves the dropzone associated with the given element.\n * @param {HTMLElement} element The element from which to search for the closest dropzone.\n * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or the parent element if no dropzone is found.\n */\n getDropzone(element) {\n const dropzoneAttr = this.getAttribute('dropzone');\n if (dropzoneAttr) {\n let dropzone = element.closest(dropzoneAttr);\n if (dropzone) return dropzone;\n }\n return element.parentElement;\n }\n\n /**\n * Retrieves the closest dropzone element at the specified coordinates.\n * @param {number} clientX The x-coordinate relative to the viewport.\n * @param {number} clientY The y-coordinate relative to the viewport.\n * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or `null` if none is found.\n */\n getClosestDropzone(clientX, clientY) {\n const elements = this.getElementsFromPointAll(clientX, clientY);\n for (const element of elements) {\n if (element.matches(this.getAttribute('dropzone'))) {\n return element;\n }\n }\n return null;\n }\n\n /**\n * Retrieves all elements at the specified coordinates, including those within shadow DOMs.\n * @param {number} x The x-coordinate relative to the viewport.\n * @param {number} y The y-coordinate relative to the viewport.\n * @param {Document|ShadowRoot} [root] The root context in which to search. Defaults to the main document.\n * @param {Set<Node>} [visited] A set of already visited nodes to avoid infinite recursion in nested shadow DOMs.\n * @returns {HTMLElement[]} An array of all elements found at the specified coordinates, including shadow DOM elements.\n */\n getElementsFromPointAll(x, y, root = document, visited = new Set()) {\n if (visited.has(root)) return [];\n visited.add(root);\n\n const elements = root.elementsFromPoint(x, y);\n let allElements = [...elements];\n\n for (const element of elements) {\n if (element.shadowRoot && !visited.has(element.shadowRoot)) {\n allElements = allElements.concat(this.getElementsFromPointAll(x, y, element.shadowRoot, visited));\n }\n }\n\n return allElements;\n }\n\n /**\n * Re-indexes the items in the container.\n * @param container\n */\n reIndexItems(container) {\n const items = Array.from(container.children);\n let index = 0;\n\n items.forEach((child) => {\n if (child.children[0]?.hasAttribute('locked')) {\n child.dataset.index = index;\n } else {\n child.dataset.index = index;\n }\n index++;\n });\n }\n}\n","import ReorderHandle from './reorder-handle.element.js';\n\nexport default ReorderHandle;\n\nReorderHandle.define('wje-reorder-handle', ReorderHandle);\n"],"names":[],"mappings":";;;;;AAae,MAAM,sBAAsB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIjD,cAAc;AACV,UAAO;AASX;AAAA;AAAA;AAAA;AAAA,qCAAY;AARR,SAAK,iBAAiB,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC;AAC5D,SAAK,iBAAiB,cAAc,KAAK,eAAe,KAAK,IAAI,CAAC;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,WAAW,qBAAqB;AAC5B,WAAO,CAAC,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,UAAM,WAAW,SAAS,uBAAwB;AAElD,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,UAAU,IAAI,WAAW;AACnC,cAAU,aAAa,QAAQ,QAAQ;AAEvC,UAAM,OAAO,SAAS,cAAc,MAAM;AAE1C,cAAU,YAAY,IAAI;AAE1B,aAAS,YAAY,SAAS;AAE9B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,QAAI,KAAK,aAAa,UAAU,GAAG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;AAAA,MACtC;AACY;AAAA,IACZ,CAAS;AAAA,EACT;AACA;ACjQA,cAAc,OAAO,sBAAsB,aAAa;"}
1
+ {"version":3,"file":"wje-reorder-handle.js","sources":["../packages/wje-reorder-handle/reorder-handle.element.js","../packages/wje-reorder-handle/reorder-handle.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ReorderHandle` is a custom web component that represents a reorder handle.\n * @summary This element represents a reorder handle.\n * @documentation https://elements.webjet.sk/components/reorder-handle\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the reorder handle.\n * @slot - The default slot for the reorder handle.\n * @tag wje-reorder-handle\n */\nexport default class ReorderHandle extends WJElement {\n /**\n * Creates an instance of ReorderHandle.\n */\n constructor() {\n super();\n this.addEventListener('mousedown', this.startDrag.bind(this));\n this.addEventListener('touchstart', this.startTouchDrag.bind(this));\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'ReorderHandle';\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 {string[]}\n */\n static get observedAttributes() {\n return ['dropzone', 'parent'];\n }\n\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n const fragment = document.createDocumentFragment();\n\n const container = document.createElement('div');\n container.classList.add('container');\n container.setAttribute('part', 'native');\n\n const slot = document.createElement('slot');\n\n container.appendChild(slot);\n\n fragment.appendChild(container);\n\n return fragment;\n }\n\n /**\n * Draws the component after it is connected to the DOM.\n */\n afterDraw() {\n if (this.hasAttribute('disabled')) {\n this.style.opacity = '.3';\n }\n }\n\n /**\n * Handles the attribute changes.\n * @param {DragEvent} e\n */\n startDrag(e) {\n if (this.hasAttribute('disabled') || this.hasAttribute('locked')) return;\n this.startDragAction(e.clientX, e.clientY);\n event.dispatchCustomEvent(this, 'wje-reorder-handle:start', {draggable: this.getDraggable()});\n }\n\n /**\n * Handles the touch start event.\n * @param {TouchEvent} e\n */\n startTouchDrag(e) {\n if (this.hasAttribute('disabled') || this.hasAttribute('locked')) return;\n const touch = e.touches[0];\n this.startDragAction(touch.clientX, touch.clientY);\n }\n\n /**\n * Initiates the drag-and-drop action for a sortable element.\n * @param {number} clientX The x-coordinate of the mouse pointer at the start of the drag action.\n * @param {number} clientY The y-coordinate of the mouse pointer at the start of the drag action.\n */\n startDragAction(clientX, clientY) {\n let draggable = this.getDraggable();\n\n const initialContainer = this.getDropzone(draggable);\n\n if (!this.getAttribute('dropzone')) {\n this.setAttribute('dropzone', initialContainer.localName);\n }\n\n const rect = draggable.getBoundingClientRect();\n const offsetX = clientX - rect.left;\n const offsetY = clientY - rect.top;\n\n let placeholder = document.createElement('div');\n placeholder.classList.add('sortable-item');\n placeholder.style.visibility = 'hidden';\n placeholder.style.height = `${rect.height}px`;\n\n draggable.classList.add('dragging');\n\n draggable.style.position = 'fixed';\n draggable.style.zIndex = '1000';\n draggable.style.width = `${rect.width}px`;\n\n const moveAt = (pageX, pageY) => {\n draggable.style.left = `${pageX - offsetX - document.documentElement.scrollLeft}px`;\n draggable.style.top = `${pageY - offsetY - document.documentElement.scrollTop}px`;\n };\n\n moveAt(clientX, clientY);\n\n const onMouseMove = (e) => {\n moveAt(e.pageX, e.pageY);\n\n const dropzone = this.getClosestDropzone(e.clientX, e.clientY);\n if (!dropzone) return;\n\n const siblings = Array.from(dropzone.children).filter(\n (child) => child !== draggable && child !== placeholder\n );\n\n for (const sibling of siblings) {\n const siblingRect = sibling.getBoundingClientRect();\n\n if (sibling.children[0]?.hasAttribute('locked')) continue;\n\n if (e.clientY > siblingRect.top && e.clientY < siblingRect.bottom) {\n if (e.clientY < siblingRect.top + siblingRect.height / 2) {\n dropzone.insertBefore(placeholder, sibling);\n } else {\n dropzone.insertBefore(placeholder, sibling.nextSibling);\n }\n break;\n }\n }\n }\n\n const onMouseUp = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n\n draggable.classList.remove('dragging');\n\n draggable.style.position = '';\n draggable.style.zIndex = '';\n draggable.style.left = '';\n draggable.style.top = '';\n draggable.style.width = '';\n\n const finalContainer = placeholder.parentElement;\n finalContainer.insertBefore(draggable, placeholder);\n finalContainer.removeChild(placeholder);\n\n this.reIndexItems(finalContainer);\n\n event.dispatchCustomEvent(this, 'wje-reorder-handle:change', {finalContainer: finalContainer, draggable: draggable});\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n\n initialContainer.insertBefore(placeholder, draggable);\n }\n\n /**\n * Retrieves the closest draggable element based on attribute conditions.\n * If the element has a \"parent\" attribute, the method attempts to find the closest ancestor\n * matching the CSS selector specified in the attribute. If no such ancestor exists,\n * the method defaults to returning the immediate parent element.\n * @returns {Element|null} The closest matching ancestor or the immediate parent element if no match is found, or null if the element has no parent.\n */\n getDraggable() {\n if (this.hasAttribute('parent')) {\n let parent = this.closest(this.getAttribute('parent'));\n if(parent) return parent;\n }\n return this.parentElement;\n }\n\n /**\n * Retrieves the nearest dropzone element based on the element's attributes or its parent element.\n * @param {HTMLElement} element The HTML element for which the dropzone is being determined.\n * @returns {HTMLElement|null} The nearest dropzone element if found; otherwise, the parent element or null.\n */\n getDropzone(element) {\n const dropzoneAttr = this.getAttribute('dropzone');\n if (this.hasAttribute('dropzone')) {\n let dropzone = element.closest(this.getAttribute('dropzone'));\n if (dropzone) return dropzone;\n }\n return element.parentElement;\n }\n\n /**\n * Retrieves the closest dropzone element at the specified coordinates.\n * @param {number} clientX The x-coordinate relative to the viewport.\n * @param {number} clientY The y-coordinate relative to the viewport.\n * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or `null` if none is found.\n */\n getClosestDropzone(clientX, clientY) {\n const elements = this.getElementsFromPointAll(clientX, clientY);\n for (const element of elements) {\n if (element.matches(this.getAttribute('dropzone'))) {\n return element;\n }\n }\n return null;\n }\n\n /**\n * Retrieves all elements at the specified coordinates, including those within shadow DOMs.\n * @param {number} x The x-coordinate relative to the viewport.\n * @param {number} y The y-coordinate relative to the viewport.\n * @param {Document|ShadowRoot} [root] The root context in which to search. Defaults to the main document.\n * @param {Set<Node>} [visited] A set of already visited nodes to avoid infinite recursion in nested shadow DOMs.\n * @returns {HTMLElement[]} An array of all elements found at the specified coordinates, including shadow DOM elements.\n */\n getElementsFromPointAll(x, y, root = document, visited = new Set()) {\n if (visited.has(root)) return [];\n visited.add(root);\n\n const elements = root.elementsFromPoint(x, y);\n let allElements = [...elements];\n\n for (const element of elements) {\n if (element.shadowRoot && !visited.has(element.shadowRoot)) {\n allElements = allElements.concat(this.getElementsFromPointAll(x, y, element.shadowRoot, visited));\n }\n }\n\n return allElements;\n }\n\n /**\n * Re-indexes child elements of the given container by setting their dataset index.\n * @param {HTMLElement} container The container element whose children are to be re-indexed.\n * @returns {void}\n */\n reIndexItems(container) {\n const items = Array.from(container.children);\n let index = 0;\n\n items.forEach((child) => {\n if (child.children[0]?.hasAttribute('locked')) {\n child.dataset.index = index;\n } else {\n child.dataset.index = index;\n }\n index++;\n });\n }\n}\n","import ReorderHandle from './reorder-handle.element.js';\n\nexport default ReorderHandle;\n\nReorderHandle.define('wje-reorder-handle', ReorderHandle);\n"],"names":[],"mappings":";;;;;;AAae,MAAM,sBAAsB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIjD,cAAc;AACV,UAAO;AASX;AAAA;AAAA;AAAA;AAAA,qCAAY;AARR,SAAK,iBAAiB,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC;AAC5D,SAAK,iBAAiB,cAAc,KAAK,eAAe,KAAK,IAAI,CAAC;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,WAAW,qBAAqB;AAC5B,WAAO,CAAC,YAAY,QAAQ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AI,OAAO;AAChE,QAAI,QAAQ,IAAI,IAAI,EAAG,QAAO,CAAE;AAChC,YAAQ,IAAI,IAAI;AAEhB,UAAM,WAAW,KAAK,kBAAkB,GAAG,CAAC;AAC5C,QAAI,cAAc,CAAC,GAAG,QAAQ;AAE9B,eAAW,WAAW,UAAU;AAC5B,UAAI,QAAQ,cAAc,CAAC,QAAQ,IAAI,QAAQ,UAAU,GAAG;AACxD,sBAAc,YAAY,OAAO,KAAK,wBAAwB,GAAG,GAAG,QAAQ,YAAY,OAAO,CAAC;AAAA,MAChH;AAAA,IACA;AAEQ,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,aAAa,WAAW;AACpB,UAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ;AAC3C,QAAI,QAAQ;AAEZ,UAAM,QAAQ,CAAC,UAAU;;AACrB,WAAI,WAAM,SAAS,CAAC,MAAhB,mBAAmB,aAAa,WAAW;AAC3C,cAAM,QAAQ,QAAQ;AAAA,MACtC,OAAmB;AACH,cAAM,QAAQ,QAAQ;AAAA,MACtC;AACY;AAAA,IACZ,CAAS;AAAA,EACT;AACA;AC9QA,cAAc,OAAO,sBAAsB,aAAa;"}
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.1.199",
4
+ "version": "0.1.201",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",