wj-elements 0.1.200 → 0.1.202

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.
@@ -31,14 +31,14 @@ export default class ReorderHandle extends WJElement {
31
31
  afterDraw(): void;
32
32
  /**
33
33
  * Handles the attribute changes.
34
- * @param {DragEvent} event
34
+ * @param {DragEvent} e
35
35
  */
36
- startDrag(event: DragEvent): void;
36
+ startDrag(e: DragEvent): void;
37
37
  /**
38
38
  * Handles the touch start event.
39
- * @param {TouchEvent} event
39
+ * @param {TouchEvent} e
40
40
  */
41
- startTouchDrag(event: TouchEvent): void;
41
+ startTouchDrag(e: TouchEvent): void;
42
42
  /**
43
43
  * Initiates the drag-and-drop action for a sortable element.
44
44
  * @param {number} clientX The x-coordinate of the mouse pointer at the start of the drag action.
@@ -46,9 +46,17 @@ export default class ReorderHandle extends WJElement {
46
46
  */
47
47
  startDragAction(clientX: number, clientY: number): void;
48
48
  /**
49
- * Retrieves the dropzone associated with the given element.
50
- * @param {HTMLElement} element The element from which to search for the closest dropzone.
51
- * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or the parent element if no dropzone is found.
49
+ * Retrieves the closest draggable element based on attribute conditions.
50
+ * If the element has a "parent" attribute, the method attempts to find the closest ancestor
51
+ * matching the CSS selector specified in the attribute. If no such ancestor exists,
52
+ * the method defaults to returning the immediate parent element.
53
+ * @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.
54
+ */
55
+ getDraggable(): Element | null;
56
+ /**
57
+ * Retrieves the nearest dropzone element based on the element's attributes or its parent element.
58
+ * @param {HTMLElement} element The HTML element for which the dropzone is being determined.
59
+ * @returns {HTMLElement|null} The nearest dropzone element if found; otherwise, the parent element or null.
52
60
  */
53
61
  getDropzone(element: HTMLElement): HTMLElement | null;
54
62
  /**
@@ -68,8 +76,9 @@ export default class ReorderHandle extends WJElement {
68
76
  */
69
77
  getElementsFromPointAll(x: number, y: number, root?: Document | ShadowRoot, visited?: Set<Node>): HTMLElement[];
70
78
  /**
71
- * Re-indexes the items in the container.
72
- * @param container
79
+ * Re-indexes child elements of the given container by setting their dataset index.
80
+ * @param {HTMLElement} container The container element whose children are to be re-indexed.
81
+ * @returns {void}
73
82
  */
74
- reIndexItems(container: any): void;
83
+ reIndexItems(container: HTMLElement): void;
75
84
  }
@@ -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;AAC/B,WAAK,MAAM,UAAU;AAAA,IACjC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,UAAU,OAAO;AACb,QAAI,KAAK,aAAa,UAAU,KAAK,KAAK,a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le/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;AAAA,EACpC;AAAA,EAEI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,UAAM,WAAW,SAAS,uBAAwB;AA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AI,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;"}
@@ -2,7 +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
- const styles = "/*\n[ WJ Tree Item ]\n*/\n\n:host {\n .native-tree-item {\n position: relative;\n display: flex;\n align-items: stretch;\n flex-direction: column;\n &.multiple {\n .item {\n border-radius: 0 !important;\n }\n }\n .item {\n display: flex;\n align-items: center;\n padding-inline: var(--wje-tree-item-padding-inline);\n padding-block: var(--wje-tree-item-padding-block);\n border-radius: var(--wje-tree-item-border-radius);\n background-color: var(--wje-tree-item-background);\n color: var(--wje-tree-item-color);\n &:hover {\n background-color: var(--wje-tree-item-background-hover);\n color: var(--wje-tree-item-color-hover);\n }\n .indent {\n display: block;\n width: 1em;\n }\n .toggle {\n font-size: var(--wje-font-size-medium);\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: content-box;\n width: var(--wje-tree-item-indent);\n height: var(--wje-tree-item-indent);\n flex-shrink: 0;\n }\n wje-checkbox {\n font-size: var(--wje-font-size-medium);\n margin: 0;\n }\n .content {\n font-size: var(--wje-font-size-medium);\n }\n slot {\n display: flex;\n align-items: center;\n }\n slot:not([name])::slotted(wje-icon) {\n margin-right: var(--wje-spacing-2x-small);\n }\n slot[name='end'] {\n margin-inline-start: auto;\n }\n }\n .children {\n font-size: calc(1em + var(--wje-tree-item-indent, var(--wje-spacing-medium)));\n display: none;\n &.open {\n display: block;\n\n ::before {\n content: '';\n position: absolute;\n top: var(--wje-tree-item-indent);\n bottom: 5px;\n left: calc(1em - (var(--wje-spacing-3x-small) * 2) - (var(--wje-tree-item-indent-guid-width) / 2));\n border-inline-end: var(--wje-tree-item-indent-guid-width) solid var(--wje-border-color);\n z-index: 1;\n }\n }\n }\n }\n\n .native-tree-item.expanded .item slot[name='expand'],\n .native-tree-item:not(.expanded) slot[name='collapse'] {\n display: none;\n }\n}\n\n:host([selected]) {\n .item {\n background-color: var(--wje-tree-item-background-selected);\n color: var(--wje-tree-item-color-selected);\n }\n}\n:host([slot-hover-visible]) {\n .item {\n &:hover {\n slot[name='start'], slot[name='end'] {\n visibility: visible;\n }\n }\n slot[name='start'], slot[name='end'] {\n visibility: hidden;\n }\n }\n}\n";
5
+ const styles = "/*\n[ WJ Tree Item ]\n*/\n\n:host {\n .native-tree-item {\n position: relative;\n display: flex;\n align-items: stretch;\n flex-direction: column;\n &.multiple {\n .item {\n border-radius: 0 !important;\n }\n }\n .item {\n display: flex;\n align-items: center;\n padding-inline: var(--wje-tree-item-padding-inline);\n padding-block: var(--wje-tree-item-padding-block);\n border-radius: var(--wje-tree-item-border-radius);\n background-color: var(--wje-tree-item-background);\n color: var(--wje-tree-item-color);\n &:hover {\n background-color: var(--wje-tree-item-background-hover);\n color: var(--wje-tree-item-color-hover);\n }\n .indent {\n display: block;\n width: 1em;\n }\n .toggle {\n font-size: var(--wje-font-size-medium);\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: content-box;\n width: var(--wje-tree-item-indent);\n height: var(--wje-tree-item-indent);\n flex-shrink: 0;\n }\n wje-checkbox {\n font-size: var(--wje-font-size-medium);\n margin: 0;\n }\n .content {\n font-size: var(--wje-font-size-medium);\n }\n slot {\n display: flex;\n align-items: center;\n }\n slot:not([name])::slotted(wje-icon) {\n margin-right: var(--wje-spacing-2x-small);\n }\n slot[name='end'] {\n margin-inline-start: auto;\n }\n }\n .children {\n font-size: calc(1rem + var(--wje-tree-item-indent, var(--wje-spacing-medium)));\n display: none;\n &.open {\n font-size: var(--wje-font-size-medium);\n display: block;\n\n ::before {\n content: '';\n position: absolute;\n top: var(--wje-tree-item-indent);\n bottom: 5px;\n left: calc(1em - (var(--wje-spacing-3x-small) * 2) - (var(--wje-tree-item-indent-guid-width) / 2));\n border-inline-end: var(--wje-tree-item-indent-guid-width) solid var(--wje-border-color);\n z-index: 1;\n }\n }\n }\n }\n\n .native-tree-item.expanded .item slot[name='expand'],\n .native-tree-item:not(.expanded) slot[name='collapse'] {\n display: none;\n }\n}\n\n:host([selected]) {\n .item {\n background-color: var(--wje-tree-item-background-selected);\n color: var(--wje-tree-item-color-selected);\n }\n}\n:host([slot-hover-visible]) {\n .item {\n &:hover {\n slot[name='start'], slot[name='end'] {\n visibility: visible;\n }\n }\n slot[name='start'], slot[name='end'] {\n visibility: hidden;\n }\n }\n}\n";
6
6
  class TreeItem extends WJElement {
7
7
  /**
8
8
  * Creates an instance of Toast.
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.200",
4
+ "version": "0.1.202",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",