wj-elements 0.7.6 → 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 (234) 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 +9053 -9048
  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/packages/wje-img/img.element.d.ts +4 -4
  22. package/dist/permissions.js +14 -41
  23. package/dist/permissions.js.map +1 -1
  24. package/dist/popup.element-CbkhthPP.js +806 -0
  25. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  26. package/dist/router-links-CNsJ-elb.js +105 -0
  27. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  28. package/dist/skeleton.css +1 -197
  29. package/dist/styles.css +1 -866
  30. package/dist/universal-service.js +48 -109
  31. package/dist/universal-service.js.map +1 -1
  32. package/dist/utils.js +11 -18
  33. package/dist/utils.js.map +1 -1
  34. package/dist/web-types.json +698 -698
  35. package/dist/wje-accordion-item.js +33 -106
  36. package/dist/wje-accordion-item.js.map +1 -1
  37. package/dist/wje-accordion.js +19 -84
  38. package/dist/wje-accordion.js.map +1 -1
  39. package/dist/wje-animation.js +37 -4258
  40. package/dist/wje-animation.js.map +1 -1
  41. package/dist/wje-aside.js +9 -34
  42. package/dist/wje-aside.js.map +1 -1
  43. package/dist/wje-avatar.js +36 -126
  44. package/dist/wje-avatar.js.map +1 -1
  45. package/dist/wje-badge.js +10 -52
  46. package/dist/wje-badge.js.map +1 -1
  47. package/dist/wje-breadcrumb.js +205 -668
  48. package/dist/wje-breadcrumb.js.map +1 -1
  49. package/dist/wje-breadcrumbs.js +177 -633
  50. package/dist/wje-breadcrumbs.js.map +1 -1
  51. package/dist/wje-button-group.js +48 -153
  52. package/dist/wje-button-group.js.map +1 -1
  53. package/dist/wje-button.js +92 -413
  54. package/dist/wje-button.js.map +1 -1
  55. package/dist/wje-card-content.js +7 -30
  56. package/dist/wje-card-content.js.map +1 -1
  57. package/dist/wje-card-controls.js +7 -30
  58. package/dist/wje-card-controls.js.map +1 -1
  59. package/dist/wje-card-header.js +7 -30
  60. package/dist/wje-card-header.js.map +1 -1
  61. package/dist/wje-card-subtitle.js +7 -34
  62. package/dist/wje-card-subtitle.js.map +1 -1
  63. package/dist/wje-card-title.js +7 -34
  64. package/dist/wje-card-title.js.map +1 -1
  65. package/dist/wje-card.js +15 -71
  66. package/dist/wje-card.js.map +1 -1
  67. package/dist/wje-carousel-item.js +12 -56
  68. package/dist/wje-carousel-item.js.map +1 -1
  69. package/dist/wje-carousel.js +154 -509
  70. package/dist/wje-carousel.js.map +1 -1
  71. package/dist/wje-checkbox.js +50 -227
  72. package/dist/wje-checkbox.js.map +1 -1
  73. package/dist/wje-chip.js +43 -160
  74. package/dist/wje-chip.js.map +1 -1
  75. package/dist/wje-col.js +7 -20
  76. package/dist/wje-col.js.map +1 -1
  77. package/dist/wje-color-picker.js +445 -1464
  78. package/dist/wje-color-picker.js.map +1 -1
  79. package/dist/wje-container.js +9 -35
  80. package/dist/wje-container.js.map +1 -1
  81. package/dist/wje-copy-button.js +64 -204
  82. package/dist/wje-copy-button.js.map +1 -1
  83. package/dist/wje-dialog.js +85 -553
  84. package/dist/wje-dialog.js.map +1 -1
  85. package/dist/wje-divider.js +7 -34
  86. package/dist/wje-divider.js.map +1 -1
  87. package/dist/wje-dropdown.js +78 -305
  88. package/dist/wje-dropdown.js.map +1 -1
  89. package/dist/wje-element.js +191 -700
  90. package/dist/wje-element.js.map +1 -1
  91. package/dist/wje-file-upload-item.js +51 -156
  92. package/dist/wje-file-upload-item.js.map +1 -1
  93. package/dist/wje-file-upload.js +181 -619
  94. package/dist/wje-file-upload.js.map +1 -1
  95. package/dist/wje-footer.js +7 -31
  96. package/dist/wje-footer.js.map +1 -1
  97. package/dist/wje-form.js +7 -32
  98. package/dist/wje-form.js.map +1 -1
  99. package/dist/wje-format-digital.js +26 -118
  100. package/dist/wje-format-digital.js.map +1 -1
  101. package/dist/wje-grid.js +7 -33
  102. package/dist/wje-grid.js.map +1 -1
  103. package/dist/wje-header.js +9 -35
  104. package/dist/wje-header.js.map +1 -1
  105. package/dist/wje-icon-library.js +12 -18
  106. package/dist/wje-icon-library.js.map +1 -1
  107. package/dist/wje-icon-picker.js +65 -320
  108. package/dist/wje-icon-picker.js.map +1 -1
  109. package/dist/wje-icon.js +1 -1
  110. package/dist/wje-img-comparer.js +37 -114
  111. package/dist/wje-img-comparer.js.map +1 -1
  112. package/dist/wje-img.js +50 -197
  113. package/dist/wje-img.js.map +1 -1
  114. package/dist/wje-infinite-scroll.js +94 -346
  115. package/dist/wje-infinite-scroll.js.map +1 -1
  116. package/dist/wje-input-file.js +23 -84
  117. package/dist/wje-input-file.js.map +1 -1
  118. package/dist/wje-input.js +78 -392
  119. package/dist/wje-input.js.map +1 -1
  120. package/dist/wje-item.js +11 -64
  121. package/dist/wje-item.js.map +1 -1
  122. package/dist/wje-kanban.js +124 -401
  123. package/dist/wje-kanban.js.map +1 -1
  124. package/dist/wje-label.js +9 -32
  125. package/dist/wje-label.js.map +1 -1
  126. package/dist/wje-level-indicator.js +38 -157
  127. package/dist/wje-level-indicator.js.map +1 -1
  128. package/dist/wje-list.js +10 -40
  129. package/dist/wje-list.js.map +1 -1
  130. package/dist/wje-main.js +7 -31
  131. package/dist/wje-main.js.map +1 -1
  132. package/dist/wje-masonry.js +66 -211
  133. package/dist/wje-masonry.js.map +1 -1
  134. package/dist/wje-master.js +45 -161
  135. package/dist/wje-master.js.map +1 -1
  136. package/dist/wje-menu-button.js +10 -38
  137. package/dist/wje-menu-button.js.map +1 -1
  138. package/dist/wje-menu-item.js +127 -577
  139. package/dist/wje-menu-item.js.map +1 -1
  140. package/dist/wje-menu-label.js +9 -35
  141. package/dist/wje-menu-label.js.map +1 -1
  142. package/dist/wje-menu.js +14 -49
  143. package/dist/wje-menu.js.map +1 -1
  144. package/dist/wje-option.js +48 -279
  145. package/dist/wje-option.js.map +1 -1
  146. package/dist/wje-options.js +130 -384
  147. package/dist/wje-options.js.map +1 -1
  148. package/dist/wje-orgchart-group.js +16 -52
  149. package/dist/wje-orgchart-group.js.map +1 -1
  150. package/dist/wje-orgchart-item.js +24 -93
  151. package/dist/wje-orgchart-item.js.map +1 -1
  152. package/dist/wje-orgchart.js +18 -68
  153. package/dist/wje-orgchart.js.map +1 -1
  154. package/dist/wje-pagination.js +113 -397
  155. package/dist/wje-pagination.js.map +1 -1
  156. package/dist/wje-popup.js +3 -3
  157. package/dist/wje-popup.js.map +1 -1
  158. package/dist/wje-progress-bar.js +53 -205
  159. package/dist/wje-progress-bar.js.map +1 -1
  160. package/dist/wje-qr-code.js +398 -2980
  161. package/dist/wje-qr-code.js.map +1 -1
  162. package/dist/wje-radio-group.js +52 -190
  163. package/dist/wje-radio-group.js.map +1 -1
  164. package/dist/wje-radio.js +24 -118
  165. package/dist/wje-radio.js.map +1 -1
  166. package/dist/wje-rate.js +62 -266
  167. package/dist/wje-rate.js.map +1 -1
  168. package/dist/wje-relative-time.js +24 -99
  169. package/dist/wje-relative-time.js.map +1 -1
  170. package/dist/wje-reorder-dropzone.js +9 -31
  171. package/dist/wje-reorder-dropzone.js.map +1 -1
  172. package/dist/wje-reorder-handle.js +67 -204
  173. package/dist/wje-reorder-handle.js.map +1 -1
  174. package/dist/wje-reorder-item.js +14 -44
  175. package/dist/wje-reorder-item.js.map +1 -1
  176. package/dist/wje-reorder.js +61 -246
  177. package/dist/wje-reorder.js.map +1 -1
  178. package/dist/wje-route.js +6 -24
  179. package/dist/wje-route.js.map +1 -1
  180. package/dist/wje-router-link.js +11 -39
  181. package/dist/wje-router-link.js.map +1 -1
  182. package/dist/wje-router-outlet.js +76 -172
  183. package/dist/wje-router-outlet.js.map +1 -1
  184. package/dist/wje-routerx.js +537 -1331
  185. package/dist/wje-routerx.js.map +1 -1
  186. package/dist/wje-row.js +9 -31
  187. package/dist/wje-row.js.map +1 -1
  188. package/dist/wje-select.js +326 -1152
  189. package/dist/wje-select.js.map +1 -1
  190. package/dist/wje-slider.js +44 -225
  191. package/dist/wje-slider.js.map +1 -1
  192. package/dist/wje-sliding-container.js +295 -1319
  193. package/dist/wje-sliding-container.js.map +1 -1
  194. package/dist/wje-split-view.js +35 -121
  195. package/dist/wje-split-view.js.map +1 -1
  196. package/dist/wje-status.js +14 -45
  197. package/dist/wje-status.js.map +1 -1
  198. package/dist/wje-step.js +9 -32
  199. package/dist/wje-step.js.map +1 -1
  200. package/dist/wje-stepper.js +109 -357
  201. package/dist/wje-stepper.js.map +1 -1
  202. package/dist/wje-store.js +67 -360
  203. package/dist/wje-store.js.map +1 -1
  204. package/dist/wje-tab-group.js +85 -314
  205. package/dist/wje-tab-group.js.map +1 -1
  206. package/dist/wje-tab-panel.js +7 -28
  207. package/dist/wje-tab-panel.js.map +1 -1
  208. package/dist/wje-tab.js +21 -198
  209. package/dist/wje-tab.js.map +1 -1
  210. package/dist/wje-textarea.js +64 -264
  211. package/dist/wje-textarea.js.map +1 -1
  212. package/dist/wje-thumbnail.js +10 -51
  213. package/dist/wje-thumbnail.js.map +1 -1
  214. package/dist/wje-toast.js +127 -632
  215. package/dist/wje-toast.js.map +1 -1
  216. package/dist/wje-toggle.js +52 -177
  217. package/dist/wje-toggle.js.map +1 -1
  218. package/dist/wje-toolbar-action.js +128 -456
  219. package/dist/wje-toolbar-action.js.map +1 -1
  220. package/dist/wje-toolbar.js +75 -270
  221. package/dist/wje-toolbar.js.map +1 -1
  222. package/dist/wje-tooltip.js +50 -161
  223. package/dist/wje-tooltip.js.map +1 -1
  224. package/dist/wje-tree-item.js +70 -301
  225. package/dist/wje-tree-item.js.map +1 -1
  226. package/dist/wje-tree.js +145 -489
  227. package/dist/wje-tree.js.map +1 -1
  228. package/dist/wje-visually-hidden.js +7 -34
  229. package/dist/wje-visually-hidden.js.map +1 -1
  230. package/package.json +4 -2
  231. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  232. package/dist/icon-CReYMzAK.js +0 -245
  233. package/dist/popup.element-CwXvVFK7.js +0 -2133
  234. package/dist/router-links-wjqCnncc.js +0 -156
@@ -1 +1 @@
1
- {"version":3,"file":"wje-relative-time.js","sources":["../packages/wje-relative-time/relative-time.element.js","../packages/wje-relative-time/relative-time.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement } from '../wje-element/element.js';\n\n/**\n * `RelativeTime` is a custom web component that represents a relative time component.\n * @summary This element represents a relative time component.\n * @documentation https://elements.webjet.sk/components/relative-time\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the relative time component.\n * @tag wje-relative-time\n */\n\nexport default class RelativeTime extends WJElement {\n /**\n * Creates an instance of RelativeTime.\n * @class\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n /**\n * Sets the date of the relative time component.\n * @param value\n */\n set date(value) {\n this.setAttribute('date', value);\n }\n\n /**\n * Gets the date of the relative time component.\n * @returns {string}\n */\n get date() {\n return this.getAttribute('date');\n }\n\n /**\n * Sets the object date of the relative time component.\n * @param value\n */\n set objectDate(value) {\n this.setAttribute('object-date', value);\n }\n\n /**\n * Gets the object date of the relative time component.\n * @returns {Date}\n */\n get objectDate() {\n let date = new Date();\n let inputDate = this.date;\n\n if (!!inputDate && inputDate !== '') {\n inputDate = this.isISODate(inputDate) ? inputDate : +inputDate * 1000;\n\n date = new Date(inputDate);\n }\n\n return date;\n }\n\n /**\n * Sets the lang of the relative time component.\n * @type {string}\n */\n className = 'RelativeTime';\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['date', 'lang'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (oldValue === newValue) return;\n if (this.native) {\n this.native.innerText = this.getRelativeTimeString();\n if (this.date) this.native.setAttribute('datetime', this.date);\n else this.native.removeAttribute('datetime');\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'status' });\n }\n\n /**\n * Draws the component for the relative time.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-relative-time');\n element.innerText = this.getRelativeTimeString();\n if (this.date) element.setAttribute('datetime', this.date);\n\n fragment.appendChild(element);\n this.native = element;\n\n return fragment;\n }\n\n /**\n * Returns the relative time string for the given date.\n */\n getRelativeTimeString(lang = navigator.language) {\n if (this.objectDate.toString() === 'Invalid Date' || this.objectDate.toString() === 'NaN') {\n return '';\n }\n\n const timeMs = this.objectDate.getTime();\n\n const deltaSeconds = Math.round((timeMs - Date.now()) / 1000);\n\n const cutoffs = [60, 3600, 86400, 86400 * 7, 86400 * 30, 86400 * 365, Infinity];\n\n const units = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'];\n const unitIndex = cutoffs.findIndex((cutoff) => cutoff > Math.abs(deltaSeconds));\n const divisor = unitIndex ? cutoffs[unitIndex - 1] : 1;\n\n return this.localizer.relativeTime(\n this.getAttribute('lang'),\n Math.trunc(deltaSeconds / divisor),\n units[unitIndex],\n { numeric: 'auto' }\n );\n }\n\n /**\n * Checks if the given string is an ISO date.\n * @param {string} str The string to check.\n * @returns {boolean} True if the string is an ISO date, false otherwise.\n */\n isISODate(str) {\n const date = new Date(str);\n return !isNaN(date.getTime());\n }\n}\n","import RelativeTime from './relative-time.element.js';\n\nexport default RelativeTime;\n\nRelativeTime.define('wje-relative-time', RelativeTime);\n"],"names":[],"mappings":";;;;;AAae,MAAM,qBAAqB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhD,cAAc;AACV,UAAK;AAiDT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAhDR,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,KAAK,OAAO;AACZ,SAAK,aAAa,QAAQ,KAAK;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,OAAO;AACP,WAAO,KAAK,aAAa,MAAM;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,WAAW,OAAO;AAClB,SAAK,aAAa,eAAe,KAAK;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAa;AACb,QAAI,OAAO,oBAAI,KAAI;AACnB,QAAI,YAAY,KAAK;AAErB,QAAI,CAAC,CAAC,aAAa,cAAc,IAAI;AACjC,kBAAY,KAAK,UAAU,SAAS,IAAI,YAAY,CAAC,YAAY;AAEjE,aAAO,IAAI,KAAK,SAAS;AAAA,IAC7B;AAEA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,WAAW,qBAAqB;AAC5B,WAAO,CAAC,QAAQ,MAAM;AAAA,EAC1B;AAAA,EAEA,yBAAyB,MAAM,UAAU,UAAU;;AAC/C,gBAAM,6BAAN,8BAAiC,MAAM,UAAU;AACjD,QAAI,aAAa,SAAU;AAC3B,QAAI,KAAK,QAAQ;AACb,WAAK,OAAO,YAAY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AS;AAAA,MACf,EAAE,SAAS,OAAM;AAAA,IAC7B;AAAA,EACI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,UAAU,KAAK;AACX,UAAM,OAAO,IAAI,KAAK,GAAG;AACzB,WAAO,CAAC,MAAM,KAAK,SAAS;AAAA,EAChC;AACJ;ACnJA,aAAa,OAAO,qBAAqB,YAAY;"}
1
+ {"version":3,"file":"wje-relative-time.js","sources":["../packages/wje-relative-time/relative-time.element.js","../packages/wje-relative-time/relative-time.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement } from '../wje-element/element.js';\n\n/**\n * `RelativeTime` is a custom web component that represents a relative time component.\n * @summary This element represents a relative time component.\n * @documentation https://elements.webjet.sk/components/relative-time\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the relative time component.\n * @tag wje-relative-time\n */\n\nexport default class RelativeTime extends WJElement {\n /**\n * Creates an instance of RelativeTime.\n * @class\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n /**\n * Sets the date of the relative time component.\n * @param value\n */\n set date(value) {\n this.setAttribute('date', value);\n }\n\n /**\n * Gets the date of the relative time component.\n * @returns {string}\n */\n get date() {\n return this.getAttribute('date');\n }\n\n /**\n * Sets the object date of the relative time component.\n * @param value\n */\n set objectDate(value) {\n this.setAttribute('object-date', value);\n }\n\n /**\n * Gets the object date of the relative time component.\n * @returns {Date}\n */\n get objectDate() {\n let date = new Date();\n let inputDate = this.date;\n\n if (!!inputDate && inputDate !== '') {\n inputDate = this.isISODate(inputDate) ? inputDate : +inputDate * 1000;\n\n date = new Date(inputDate);\n }\n\n return date;\n }\n\n /**\n * Sets the lang of the relative time component.\n * @type {string}\n */\n className = 'RelativeTime';\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['date', 'lang'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (oldValue === newValue) return;\n if (this.native) {\n this.native.innerText = this.getRelativeTimeString();\n if (this.date) this.native.setAttribute('datetime', this.date);\n else this.native.removeAttribute('datetime');\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'status' });\n }\n\n /**\n * Draws the component for the relative time.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-relative-time');\n element.innerText = this.getRelativeTimeString();\n if (this.date) element.setAttribute('datetime', this.date);\n\n fragment.appendChild(element);\n this.native = element;\n\n return fragment;\n }\n\n /**\n * Returns the relative time string for the given date.\n */\n getRelativeTimeString(lang = navigator.language) {\n if (this.objectDate.toString() === 'Invalid Date' || this.objectDate.toString() === 'NaN') {\n return '';\n }\n\n const timeMs = this.objectDate.getTime();\n\n const deltaSeconds = Math.round((timeMs - Date.now()) / 1000);\n\n const cutoffs = [60, 3600, 86400, 86400 * 7, 86400 * 30, 86400 * 365, Infinity];\n\n const units = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'];\n const unitIndex = cutoffs.findIndex((cutoff) => cutoff > Math.abs(deltaSeconds));\n const divisor = unitIndex ? cutoffs[unitIndex - 1] : 1;\n\n return this.localizer.relativeTime(\n this.getAttribute('lang'),\n Math.trunc(deltaSeconds / divisor),\n units[unitIndex],\n { numeric: 'auto' }\n );\n }\n\n /**\n * Checks if the given string is an ISO date.\n * @param {string} str The string to check.\n * @returns {boolean} True if the string is an ISO date, false otherwise.\n */\n isISODate(str) {\n const date = new Date(str);\n return !isNaN(date.getTime());\n }\n}\n","import RelativeTime from './relative-time.element.js';\n\nexport default RelativeTime;\n\nRelativeTime.define('wje-relative-time', RelativeTime);\n"],"names":["RelativeTime","WJElement","constructor","super","className","this","localizer","Localizer","value","setAttribute","date","getAttribute","objectDate","Date","inputDate","isISODate","observedAttributes","name","oldValue","newValue","attributeChangedCallback","native","innerText","getRelativeTimeString","removeAttribute","setupAttributes","isShadowRoot","setAriaState","role","draw","fragment","document","createDocumentFragment","element","createElement","classList","add","appendChild","lang","navigator","language","toString","timeMs","getTime","deltaSeconds","Math","round","now","cutoffs","Infinity","unitIndex","findIndex","cutoff","abs","divisor","relativeTime","trunc","numeric","str","isNaN","define"],"mappings":";;;;;AAae,MAAMA,UAAqBC,EAAAA;AAAAA,EAKtC,cAAAC;AACIC,UAAAA;AAiDJC,qCAAY;AAhDRC,SAAKC,YAAY,IAAIC,EAAUF,IAAAA;AAAAA,EACnC;AAAA,EAMA,IAAA,KAASG,IAAAA;AACLH,SAAKI,aAAa,QAAQD,EAAAA;AAAAA,EAC9B;AAAA,EAMA,IAAA,OAAIE;AACA,WAAOL,KAAKM,aAAa,MAAA;AAAA,EAC7B;AAAA,EAMA,IAAA,WAAeH,IAAAA;AACXH,SAAKI,aAAa,eAAeD,EAAAA;AAAAA,EACrC;AAAA,EAMA,IAAA,aAAII;AACA,QAAIF,KAAO,oBAAIG,QACXC,KAAYT,KAAKK;AAQrB,WANMI,MAA2B,OAAdA,OACfA,KAAYT,KAAKU,UAAUD,EAAAA,IAAaA,KAAyB,MAAA,CAAZA,IAErDJ,KAAO,IAAIG,KAAKC,EAAAA,IAGbJ;AAAAA,EACX;AAAA,EAaA,WAAA,qBAAWM;AACP,WAAO,CAAC,QAAQ,MAAA;AAAA,EACpB;AAAA,EAEA,yBAAyBC,IAAMC,IAAUC,IAAAA;;AACrChB,gBAAMiB,6BAANjB,8BAAiCc,IAAMC,IAAUC,KAC7CD,OAAaC,MACbd,KAAKgB,WACLhB,KAAKgB,OAAOC,YAAYjB,KAAKkB,yBACzBlB,KAAKK,OAAML,KAAKgB,OAAOZ,aAAa,YAAYJ,KAAKK,IAAAA,IACpDL,KAAKgB,OAAOG,gBAAgB,UAAA;AAAA,EAEzC;AAAA,EAKA,kBAAAC;AACIpB,SAAKqB,eAAe,QACpBrB,KAAKsB,aAAa,EAAEC,MAAM,S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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 = ".dropzone {\n border: 1px dashed lightgrey;\n border-radius: var(--wje-border-radius-small);\n margin: 0.5rem;\n display: flex;\n flex-direction: column;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n min-height: 250px;\n width: 200px;\n}\n";
6
- class ReorderDropzone extends WJElement {
7
- /**
8
- * Creates an instance of ReorderDropzone.
9
- */
4
+ import e from "./wje-element.js";
5
+ class t extends e {
10
6
  constructor() {
11
7
  super();
12
- /**
13
- * The class name for the component.
14
- * @type {string}
15
- */
16
8
  __publicField(this, "className", "ReorderDropzone");
17
9
  }
18
- /**
19
- * Returns the CSS stylesheet for the component.
20
- * @returns {CSSStyleSheet} The CSS stylesheet.
21
- */
22
10
  static get cssStyleSheet() {
23
- return styles;
11
+ return ".dropzone{border:1px dashed lightgrey;border-radius:var(--wje-border-radius-small);margin:.5rem;display:flex;flex-direction:column;align-items:center;overflow:hidden;justify-content:center;min-height:250px;width:200px}";
24
12
  }
25
- /**
26
- * Sets up the attributes for the component.
27
- */
28
13
  setupAttributes() {
29
14
  this.isShadowRoot = "open";
30
15
  }
31
- /**
32
- * Returns the list of observed attributes.
33
- * @returns {DocumentFragment}
34
- */
35
16
  draw() {
36
- let fragment = document.createDocumentFragment();
37
- let dropzone = document.createElement("div");
38
- dropzone.classList.add("dropzone");
39
- let slot = document.createElement("slot");
40
- dropzone.appendChild(slot);
41
- fragment.appendChild(dropzone);
42
- return fragment;
17
+ let e2 = document.createDocumentFragment(), t2 = document.createElement("div");
18
+ t2.classList.add("dropzone");
19
+ let r = document.createElement("slot");
20
+ return t2.appendChild(r), e2.appendChild(t2), e2;
43
21
  }
44
22
  }
45
- ReorderDropzone.define("wje-reorder-dropzone", ReorderDropzone);
23
+ t.define("wje-reorder-dropzone", t);
46
24
  export {
47
- ReorderDropzone as default
25
+ t as default
48
26
  };
49
27
  //# sourceMappingURL=wje-reorder-dropzone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-reorder-dropzone.js","sources":["../packages/wje-reorder-dropzone/reorder-dropzone.element.js","../packages/wje-reorder-dropzone/reorder-dropzone.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ReorderDropzone` is a custom web component that represents a reorder dropzone.\n * @summary This element represents a reorder dropzone.\n * @documentation https://elements.webjet.sk/components/reorder-dropzone\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the reorder dropzone.\n * @slot - The default slot for the reorder dropzone.\n * @tag wje-reorder-dropzone\n */\nexport default class ReorderDropzone extends WJElement {\n /**\n * Creates an instance of ReorderDropzone.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'ReorderDropzone';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @returns {CSSStyleSheet} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Returns the list of observed attributes.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let dropzone = document.createElement('div');\n dropzone.classList.add('dropzone');\n\n let slot = document.createElement('slot');\n\n dropzone.appendChild(slot);\n\n fragment.appendChild(dropzone);\n\n return fragment;\n }\n}\n","import ReorderDropzone from './reorder-dropzone.element';\n\nexport default ReorderDropzone;\n\nReorderDropzone.define('wje-reorder-dropzone', ReorderDropzone);\n"],"names":[],"mappings":";;;;;AAae,MAAM,wBAAwB,UAAU;AAAA;AAAA;AAAA;AAAA,EAInD,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AACd,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,WAAW,SAAS,cAAc,KAAK;AAC3C,aAAS,UAAU,IAAI,UAAU;AAEjC,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,aAAS,YAAY,IAAI;AAEzB,aAAS,YAAY,QAAQ;AAE7B,WAAO;AAAA,EACX;AACJ;ACxDA,gBAAgB,OAAO,wBAAwB,eAAe;"}
1
+ {"version":3,"file":"wje-reorder-dropzone.js","sources":["../packages/wje-reorder-dropzone/reorder-dropzone.element.js","../packages/wje-reorder-dropzone/reorder-dropzone.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ReorderDropzone` is a custom web component that represents a reorder dropzone.\n * @summary This element represents a reorder dropzone.\n * @documentation https://elements.webjet.sk/components/reorder-dropzone\n * @status stable\n * @augments WJElement\n * @csspart native - The native part of the reorder dropzone.\n * @slot - The default slot for the reorder dropzone.\n * @tag wje-reorder-dropzone\n */\nexport default class ReorderDropzone extends WJElement {\n /**\n * Creates an instance of ReorderDropzone.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'ReorderDropzone';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @returns {CSSStyleSheet} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Returns the list of observed attributes.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let dropzone = document.createElement('div');\n dropzone.classList.add('dropzone');\n\n let slot = document.createElement('slot');\n\n dropzone.appendChild(slot);\n\n fragment.appendChild(dropzone);\n\n return fragment;\n }\n}\n","import ReorderDropzone from './reorder-dropzone.element';\n\nexport default ReorderDropzone;\n\nReorderDropzone.define('wje-reorder-dropzone', ReorderDropzone);\n"],"names":["ReorderDropzone","WJElement","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","draw","fragment","document","createDocumentFragment","dropzone","createElement","classList","add","slot","appendChild","define"],"mappings":";;;;AAae,MAAMA,UAAwBC,EAAAA;AAAAA,EAIzC;AACIC,UAAAA;AAOJC,qCAAY;AAAA,EANZ;AAAA,EAYA,WAAA,gBAAWC;AACP;EACJ;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,0BAEpBC,KAAWF,SAASG,cAAc,KAAA;AACtCD,IAAAA,GAASE,UAAUC,IAAI,UAAA;AAEvB,QAAIC,IAAON,SAASG,cAAc,MAAA;AAMlC,WAJAD,GAASK,YAAYD,CAAAA,GAErBP,GAASQ,YAAYL,EAAAA,GAEdH;AAAAA,EACX;AAAA;ACvDJT,EAAgBkB,OAAO,wBAAwBlB,CAAAA;"}
@@ -1,251 +1,114 @@
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
- import { event } from "./event.js";
6
- const styles = ".disabled {\n opacity: 0.3;\n}\n";
7
- class ReorderHandle extends WJElement {
8
- /**
9
- * Creates an instance of ReorderHandle.
10
- */
4
+ import t from "./wje-element.js";
5
+ import { event as e } from "./event.js";
6
+ class s extends t {
11
7
  constructor() {
12
8
  super();
13
- /**
14
- * The class name for the component.
15
- * @type {string}
16
- */
17
9
  __publicField(this, "className", "ReorderHandle");
18
- this.addEventListener("mousedown", this.startDrag.bind(this));
19
- this.addEventListener("touchstart", this.startTouchDrag.bind(this));
10
+ this.addEventListener("mousedown", this.startDrag.bind(this)), this.addEventListener("touchstart", this.startTouchDrag.bind(this));
20
11
  }
21
- /**
22
- * Returns the CSS styles for the component.
23
- * @returns {*}
24
- */
25
12
  static get cssStyleSheet() {
26
- return styles;
13
+ return ".disabled{opacity:.3}";
27
14
  }
28
- /**
29
- * Returns the list of attributes to observe for changes.
30
- * @returns {string[]}
31
- */
32
15
  static get observedAttributes() {
33
16
  return ["dropzone", "parent"];
34
17
  }
35
18
  setupAttributes() {
36
- this.isShadowRoot = "open";
37
- this.syncAria();
19
+ this.isShadowRoot = "open", this.syncAria();
38
20
  }
39
- /**
40
- * Draws the component.
41
- * @returns {DocumentFragment}
42
- */
43
21
  draw() {
44
- const fragment = document.createDocumentFragment();
45
- const container = document.createElement("div");
46
- container.classList.add("container");
47
- container.setAttribute("part", "native");
48
- const slot = document.createElement("slot");
49
- container.appendChild(slot);
50
- fragment.appendChild(container);
51
- return fragment;
22
+ const t2 = document.createDocumentFragment(), e2 = document.createElement("div");
23
+ e2.classList.add("container"), e2.setAttribute("part", "native");
24
+ const s2 = document.createElement("slot");
25
+ return e2.appendChild(s2), t2.appendChild(e2), t2;
52
26
  }
53
- /**
54
- * Draws the component after it is connected to the DOM.
55
- */
56
27
  afterDraw() {
57
- this.syncAria();
58
- if (this.hasAttribute("disabled")) {
59
- this.style.opacity = ".3";
60
- }
28
+ this.syncAria(), this.hasAttribute("disabled") && (this.style.opacity = ".3");
61
29
  }
62
- /**
63
- * Sync ARIA attributes on host.
64
- */
65
30
  syncAria() {
66
- if (!this.hasAttribute("role")) {
67
- this.setAriaState({ role: "button" });
68
- }
69
- if (!this.hasAttribute("tabindex")) {
70
- this.setAttribute("tabindex", "0");
71
- }
72
- if (this.hasAttribute("disabled")) {
73
- this.setAriaState({ disabled: true });
74
- }
75
- const ariaLabel = this.getAttribute("aria-label");
76
- const label = this.getAttribute("label") || "Reorder item";
77
- if (!ariaLabel && label) {
78
- this.setAriaState({ label });
79
- }
31
+ this.hasAttribute("role") || this.setAriaState({ role: "button" }), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.hasAttribute("disabled") && this.setAriaState({ disabled: true });
32
+ const t2 = this.getAttribute("aria-label"), e2 = this.getAttribute("label") || "Reorder item";
33
+ !t2 && e2 && this.setAriaState({ label: e2 });
80
34
  }
81
- /**
82
- * Handles the attribute changes.
83
- * @param {DragEvent} e
84
- */
85
- startDrag(e) {
86
- if (this.hasAttribute("disabled") || this.hasAttribute("locked")) return;
87
- this.startDragAction(e.clientX, e.clientY);
88
- event.dispatchCustomEvent(this, "wje-reorder-handle:start", { draggable: this.getDraggable() });
35
+ startDrag(t2) {
36
+ this.hasAttribute("disabled") || this.hasAttribute("locked") || (this.startDragAction(t2.clientX, t2.clientY), e.dispatchCustomEvent(this, "wje-reorder-handle:start", { draggable: this.getDraggable() }));
89
37
  }
90
- /**
91
- * Handles the touch start event.
92
- * @param {TouchEvent} e
93
- */
94
- startTouchDrag(e) {
38
+ startTouchDrag(t2) {
95
39
  if (this.hasAttribute("disabled") || this.hasAttribute("locked")) return;
96
- const touch = e.touches[0];
97
- this.startDragAction(touch.clientX, touch.clientY);
40
+ const e2 = t2.touches[0];
41
+ this.startDragAction(e2.clientX, e2.clientY);
98
42
  }
99
- /**
100
- * Initiates the drag-and-drop action for a sortable element.
101
- * @param {number} clientX The x-coordinate of the mouse pointer at the start of the drag action.
102
- * @param {number} clientY The y-coordinate of the mouse pointer at the start of the drag action.
103
- */
104
- startDragAction(clientX, clientY) {
105
- let draggable = this.getDraggable();
106
- const initialContainer = this.getDropzone(draggable);
107
- if (!this.getAttribute("dropzone")) {
108
- this.setAttribute("dropzone", initialContainer.localName);
109
- }
110
- const rect = draggable.getBoundingClientRect();
111
- const offsetX = clientX - rect.left;
112
- const offsetY = clientY - rect.top;
113
- let placeholder = document.createElement("div");
114
- placeholder.classList.add("sortable-item");
115
- placeholder.style.visibility = "hidden";
116
- placeholder.style.height = `${rect.height}px`;
117
- draggable.classList.add("dragging");
118
- draggable.style.position = "fixed";
119
- draggable.style.zIndex = "1000";
120
- draggable.style.width = `${rect.width}px`;
121
- const moveAt = (pageX, pageY) => {
122
- draggable.style.left = `${pageX - offsetX - document.documentElement.scrollLeft}px`;
123
- draggable.style.top = `${pageY - offsetY - document.documentElement.scrollTop}px`;
43
+ startDragAction(t2, s2) {
44
+ let i = this.getDraggable();
45
+ const r = this.getDropzone(i);
46
+ this.getAttribute("dropzone") || this.setAttribute("dropzone", r.localName);
47
+ const n = i.getBoundingClientRect(), o = t2 - n.left, a = s2 - n.top;
48
+ let l = document.createElement("div");
49
+ l.classList.add("sortable-item"), l.style.visibility = "hidden", l.style.height = `${n.height}px`, i.classList.add("dragging"), i.style.position = "fixed", i.style.zIndex = "1000", i.style.width = `${n.width}px`;
50
+ const d = (t3, e2) => {
51
+ i.style.left = t3 - o - document.documentElement.scrollLeft + "px", i.style.top = e2 - a - document.documentElement.scrollTop + "px";
124
52
  };
125
- moveAt(clientX, clientY);
126
- const onMouseMove = (e) => {
53
+ d(t2, s2);
54
+ const h = (t3) => {
127
55
  var _a;
128
- moveAt(e.pageX, e.pageY);
129
- const dropzone = this.getClosestDropzone(e.clientX, e.clientY);
130
- if (!dropzone) return;
131
- const siblings = Array.from(dropzone.children).filter(
132
- (child) => child !== draggable && child !== placeholder
133
- );
134
- for (const sibling of siblings) {
135
- const siblingRect = sibling.getBoundingClientRect();
136
- if ((_a = sibling.children[0]) == null ? void 0 : _a.hasAttribute("locked")) continue;
137
- if (e.clientY > siblingRect.top && e.clientY < siblingRect.bottom) {
138
- if (e.clientY < siblingRect.top + siblingRect.height / 2) {
139
- dropzone.insertBefore(placeholder, sibling);
140
- } else {
141
- dropzone.insertBefore(placeholder, sibling.nextSibling);
142
- }
56
+ d(t3.pageX, t3.pageY);
57
+ const e2 = this.getClosestDropzone(t3.clientX, t3.clientY);
58
+ if (!e2) return;
59
+ const s3 = Array.from(e2.children).filter((t4) => t4 !== i && t4 !== l);
60
+ for (const i2 of s3) {
61
+ const s4 = i2.getBoundingClientRect();
62
+ if (!((_a = i2.children[0]) == null ? void 0 : _a.hasAttribute("locked")) && (t3.clientY > s4.top && t3.clientY < s4.bottom)) {
63
+ t3.clientY < s4.top + s4.height / 2 ? e2.insertBefore(l, i2) : e2.insertBefore(l, i2.nextSibling);
143
64
  break;
144
65
  }
145
66
  }
67
+ }, c = () => {
68
+ document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c), i.classList.remove("dragging"), i.style.position = "", i.style.zIndex = "", i.style.left = "", i.style.top = "", i.style.width = "";
69
+ const t3 = l.parentElement;
70
+ t3.insertBefore(i, l), t3.removeChild(l), this.reIndexItems(t3), e.dispatchCustomEvent(this, "wje-reorder-handle:change", { finalContainer: t3, draggable: i });
146
71
  };
147
- const onMouseUp = () => {
148
- document.removeEventListener("mousemove", onMouseMove);
149
- document.removeEventListener("mouseup", onMouseUp);
150
- draggable.classList.remove("dragging");
151
- draggable.style.position = "";
152
- draggable.style.zIndex = "";
153
- draggable.style.left = "";
154
- draggable.style.top = "";
155
- draggable.style.width = "";
156
- const finalContainer = placeholder.parentElement;
157
- finalContainer.insertBefore(draggable, placeholder);
158
- finalContainer.removeChild(placeholder);
159
- this.reIndexItems(finalContainer);
160
- event.dispatchCustomEvent(this, "wje-reorder-handle:change", { finalContainer, draggable });
161
- };
162
- document.addEventListener("mousemove", onMouseMove);
163
- document.addEventListener("mouseup", onMouseUp);
164
- initialContainer.insertBefore(placeholder, draggable);
72
+ document.addEventListener("mousemove", h), document.addEventListener("mouseup", c), r.insertBefore(l, i);
165
73
  }
166
- /**
167
- * Retrieves the closest draggable element based on attribute conditions.
168
- * If the element has a "parent" attribute, the method attempts to find the closest ancestor
169
- * matching the CSS selector specified in the attribute. If no such ancestor exists,
170
- * the method defaults to returning the immediate parent element.
171
- * @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.
172
- */
173
74
  getDraggable() {
174
75
  if (this.hasAttribute("parent")) {
175
- let parent = this.closest(this.getAttribute("parent"));
176
- if (parent) return parent;
76
+ let t2 = this.closest(this.getAttribute("parent"));
77
+ if (t2) return t2;
177
78
  }
178
79
  return this.parentElement;
179
80
  }
180
- /**
181
- * Retrieves the nearest dropzone element based on the element's attributes or its parent element.
182
- * @param {HTMLElement} element The HTML element for which the dropzone is being determined.
183
- * @returns {HTMLElement|null} The nearest dropzone element if found; otherwise, the parent element or null.
184
- */
185
- getDropzone(element) {
186
- this.getAttribute("dropzone");
187
- if (this.hasAttribute("dropzone")) {
188
- let dropzone = element.closest(this.getAttribute("dropzone"));
189
- if (dropzone) return dropzone;
81
+ getDropzone(t2) {
82
+ if (this.getAttribute("dropzone"), this.hasAttribute("dropzone")) {
83
+ let e2 = t2.closest(this.getAttribute("dropzone"));
84
+ if (e2) return e2;
190
85
  }
191
- return element.parentElement;
86
+ return t2.parentElement;
192
87
  }
193
- /**
194
- * Retrieves the closest dropzone element at the specified coordinates.
195
- * @param {number} clientX The x-coordinate relative to the viewport.
196
- * @param {number} clientY The y-coordinate relative to the viewport.
197
- * @returns {HTMLElement|null} - The closest dropzone element matching the `dropzone` attribute, or `null` if none is found.
198
- */
199
- getClosestDropzone(clientX, clientY) {
200
- const elements = this.getElementsFromPointAll(clientX, clientY);
201
- for (const element of elements) {
202
- if (element.matches(this.getAttribute("dropzone"))) {
203
- return element;
204
- }
205
- }
88
+ getClosestDropzone(t2, e2) {
89
+ const s2 = this.getElementsFromPointAll(t2, e2);
90
+ for (const t3 of s2) if (t3.matches(this.getAttribute("dropzone"))) return t3;
206
91
  return null;
207
92
  }
208
- /**
209
- * Retrieves all elements at the specified coordinates, including those within shadow DOMs.
210
- * @param {number} x The x-coordinate relative to the viewport.
211
- * @param {number} y The y-coordinate relative to the viewport.
212
- * @param {Document|ShadowRoot} [root] The root context in which to search. Defaults to the main document.
213
- * @param {Set<Node>} [visited] A set of already visited nodes to avoid infinite recursion in nested shadow DOMs.
214
- * @returns {HTMLElement[]} An array of all elements found at the specified coordinates, including shadow DOM elements.
215
- */
216
- getElementsFromPointAll(x, y, root = document, visited = /* @__PURE__ */ new Set()) {
217
- if (visited.has(root)) return [];
218
- visited.add(root);
219
- const elements = root.elementsFromPoint(x, y);
220
- let allElements = [...elements];
221
- for (const element of elements) {
222
- if (element.shadowRoot && !visited.has(element.shadowRoot)) {
223
- allElements = allElements.concat(this.getElementsFromPointAll(x, y, element.shadowRoot, visited));
224
- }
225
- }
226
- return allElements;
93
+ getElementsFromPointAll(t2, e2, s2 = document, i = /* @__PURE__ */ new Set()) {
94
+ if (i.has(s2)) return [];
95
+ i.add(s2);
96
+ const r = s2.elementsFromPoint(t2, e2);
97
+ let n = [...r];
98
+ for (const s3 of r) s3.shadowRoot && !i.has(s3.shadowRoot) && (n = n.concat(this.getElementsFromPointAll(t2, e2, s3.shadowRoot, i)));
99
+ return n;
227
100
  }
228
- /**
229
- * Re-indexes child elements of the given container by setting their dataset index.
230
- * @param {HTMLElement} container The container element whose children are to be re-indexed.
231
- * @returns {void}
232
- */
233
- reIndexItems(container) {
234
- const items = Array.from(container.children);
235
- let index = 0;
236
- items.forEach((child) => {
101
+ reIndexItems(t2) {
102
+ const e2 = Array.from(t2.children);
103
+ let s2 = 0;
104
+ e2.forEach((t3) => {
237
105
  var _a;
238
- if ((_a = child.children[0]) == null ? void 0 : _a.hasAttribute("locked")) {
239
- child.dataset.index = index;
240
- } else {
241
- child.dataset.index = index;
242
- }
243
- index++;
106
+ (_a = t3.children[0]) == null ? void 0 : _a.hasAttribute("locked"), t3.dataset.index = s2, s2++;
244
107
  });
245
108
  }
246
109
  }
247
- ReorderHandle.define("wje-reorder-handle", ReorderHandle);
110
+ s.define("wje-reorder-handle", s);
248
111
  export {
249
- ReorderHandle as default
112
+ s as default
250
113
  };
251
114
  //# sourceMappingURL=wje-reorder-handle.js.map
@@ -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, 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 this.syncAria();\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 this.syncAria();\n if (this.hasAttribute('disabled')) {\n this.style.opacity = '.3';\n }\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'button' });\n }\n\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n\n if (this.hasAttribute('disabled')) {\n this.setAriaState({ disabled: true });\n }\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label') || 'Reorder item';\n if (!ariaLabel && label) {\n this.setAriaState({ label });\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,UAAK;AAST;AAAA;AAAA;AAAA;AAAA,qCAAY;AARR,SAAK,iBAAiB,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC;AAC5D,SAAK,iBAAiB,cAAc,KAAK,eAAe,K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AACrB,WAAI,WAAM,SAAS,CAAC,MAAhB,mBAAmB,aAAa,WAAW;AAC3C,cAAM,QAAQ,QAAQ;AAAA,MAC1B,OAAO;AACH,cAAM,QAAQ,QAAQ;AAAA,MAC1B;AACA;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;ACvSA,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 this.syncAria();\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 this.syncAria();\n if (this.hasAttribute('disabled')) {\n this.style.opacity = '.3';\n }\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'button' });\n }\n\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n\n if (this.hasAttribute('disabled')) {\n this.setAriaState({ disabled: true });\n }\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label') || 'Reorder item';\n if (!ariaLabel && label) {\n this.setAriaState({ label });\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":["ReorderHandle","WJElement","constructor","super","className","this","addEventListener","startDrag","bind","startTouchDrag","cssStyleSheet","observedAttributes","setupAttributes","isShadowRoot","syncAria","draw","fragment","document","createDocumentFragment","container","createElement","classList","add","setAttribute","slot","appendChild","afterDraw","hasAttribute","style","opacity","setAriaState","role","disabled","ariaLabel","getAttribute","label","e","startDragAction","clientX","clientY","event","dispatchCustomEvent","draggable","getDraggable","touch","touches","initialContainer","getDropzone","localName","rect","getBoundingClientRect","offsetX","left","offsetY","top","placeholder","visibility","height","position","zIndex","width","moveAt","pageX","pageY","documentElement","scrollLeft","scrollTop","onMouseMove","dropzone","getClosestDropzone","siblings","Array","from","children","filter","child","sibling","siblingRect","bottom","insertBefore","nextSibling","onMouseUp","removeEventListener","remove","finalContainer","parentElement","removeChild","reIndexItems","parent","closest","element","elements","getElementsFromPointAll","matches","x","y","root","visited","Set","has","elementsFromPoint","allElements","shadowRoot","concat","items","index","forEach","dataset","define"],"mappings":";;;;;AAae,MAAMA,UAAsBC,EAAAA;AAAAA,EAIvC,cAAAC;AACIC,UAAAA;AASJC,qCAAY;AARRC,SAAKC,iBAAiB,aAAaD,KAAKE,UAAUC,KAAKH,IAAAA,CAAAA,GACvDA,KAAKC,iBAAiB,cAAcD,KAAKI,eAAeD,KAAKH;EACjE;AAAA,EAYA,WAAA,gBAAWK;AACP;EACJ;AAAA,EAMA,gCAAWC;AACP,WAAO,CAAC,YAAY,QAAA;AAAA,EACxB;AAAA,EAEA,kBAAAC;AACIP,SAAKQ,eAAe,QACpBR,KAAKS,SAAAA;AAAAA,EACT;AAAA,EAMA,OAAAC;AACI,UAAMC,KAAWC,SAASC,uBAAAA,GAEpBC,KAAYF,SAASG,cAAc,KAAA;AACzCD,IAAAA,GAAUE,UAAUC,IAAI,WAAA,GACxBH,GAAUI,aAAa,QAAQ,QAAA;AAE/B,UAAMC,KAAOP,SAASG,cAAc,MAAA;AAMpC,WAJAD,GAAUM,YA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mD,MAAWC,GAClB,KAAID,GAAQG,QAAQxF,KAAK6B,aAAa,UAAA,CAAA,EAClC,QAAOwD;AAGf,WAAO;AAAA,EACX;AAAA,EAUA,wBAAwBI,IAAGC,IAAGC,KAAO/E,UAAUgF,IAAU,oBAAIC,OAAAA;AACzD,QAAID,EAAQE,IAAIH,EAAAA,EAAO,QAAO,CAAA;AAC9BC,MAAQ3E,IAAI0E,EAAAA;AAEZ,UAAML,IAAWK,GAAKI,kBAAkBN,IAAGC,EAAAA;AAC3C,QAAIM,IAAc,CAAA,GAAIV,CAAAA;AAEtB,eAAWD,MAAWC,EACdD,CAAAA,GAAQY,eAAeL,EAAQE,IAAIT,GAAQY,UAAAA,MAC3CD,IAAcA,EAAYE,OAAOlG,KAAKuF,wBAAwBE,IAAGC,IAAGL,GAAQY,YAAYL,CAAAA,CAAAA;AAIhG,WAAOI;AAAAA,EACX;AAAA,EAOA,aAAalF,IAAAA;AACT,UAAMqF,KAAQjC,MAAMC,KAAKrD,GAAUsD,QAAAA;AACnC,QAAIgC,KAAQ;AAEZD,IAAAA,GAAME,QAAS/B,CAAAA,OAAAA;;AACPA,YAAAA,GAAMF,SAAS,CAAA,MAAfE,mBAAmBhD,aAAa,WAChCgD,GAAMgC,QAAQF,QAAQA,IAI1BA;AAAAA,IAAAA,CAAAA;AAAAA,EAER;AAAA;ACtSJzG,EAAc4G,OAAO,sBAAsB5G,CAAAA;"}
@@ -1,62 +1,32 @@
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
- import { WjElementUtils } from "./element-utils.js";
6
- const styles = ":host {\n /*--reorder-background-color: var(--wje-color-contrast-0);*/\n --reorder-item-spacing: 0.5rem;\n}\n\n.item {\n width: 134px;\n height: 19px;\n display: flex;\n align-items: center;\n justify-content: left;\n position: relative;\n gap: var(--reorder-item-spacing);\n padding: var(--reorder-item-spacing);\n border-radius: var(--wje-border-radius-small);\n background-color: var(--reorder-background-color);\n cursor: grab;\n transition:\n top 0.3s ease,\n left 0.3s ease;\n}\n\n.item-w-handle {\n cursor: default;\n}\n\n.item-w-handle:active {\n opacity: 0.3;\n}\n\n.item:active:not(.item-w-handle):not(.moving) {\n background-color: var(--reorder-background-color);\n cursor: grabbing;\n}\n\n.moving {\n background-color: lightgrey;\n}\n\n.handle {\n cursor: grab;\n gap: 10px;\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.name {\n width: 108px;\n height: 19px;\n text-align: center;\n font-size: var(--wje-font-size);\n font-weight: 400;\n line-height: 19.36px;\n gap: 10px;\n}\n\n/* .drag--down {\n --item-transform: translateY(-5px);\n}\n\n.drag--up {\n --item-transform: translateY(5px);\n} */\n\n.item {\n transform: var(--item-transform);\n}\n";
7
- class ReorderItem extends WJElement {
8
- /**
9
- * Creates an instance of ReorderItem.
10
- */
4
+ import e from "./wje-element.js";
5
+ import { WjElementUtils as t } from "./element-utils.js";
6
+ class r extends e {
11
7
  constructor() {
12
8
  super();
13
- /**
14
- * The class name for the component.
15
- * @type {string}
16
- */
17
9
  __publicField(this, "className", "ReorderItem");
18
10
  }
19
- /**
20
- * Returns the CSS stylesheet for the component.
21
- * @returns {CSSStyleSheet} The CSS stylesheet.
22
- */
23
11
  static get cssStyleSheet() {
24
- return styles;
12
+ return ":host{--reorder-item-spacing: .5rem}.item{width:134px;height:19px;display:flex;align-items:center;justify-content:left;position:relative;gap:var(--reorder-item-spacing);padding:var(--reorder-item-spacing);border-radius:var(--wje-border-radius-small);background-color:var(--reorder-background-color);cursor:grab;transition:top .3s ease,left .3s ease}.item-w-handle{cursor:default}.item-w-handle:active{opacity:.3}.item:active:not(.item-w-handle):not(.moving){background-color:var(--reorder-background-color);cursor:grabbing}.moving{background-color:#d3d3d3}.handle{cursor:grab;gap:10px}.handle:active{cursor:grabbing}.name{width:108px;height:19px;text-align:center;font-size:var(--wje-font-size);font-weight:400;line-height:19.36px;gap:10px}.item{transform:var(--item-transform)}";
25
13
  }
26
- /**
27
- * Sets up the attributes for the component.
28
- */
29
14
  setupAttributes() {
30
15
  this.isShadowRoot = "open";
31
16
  }
32
- /**
33
- * Returns the list of observed attributes.
34
- * @returns {DocumentFragment}
35
- */
36
17
  draw() {
37
- let fragment = document.createDocumentFragment();
38
- let wrapper = document.createElement("div");
39
- wrapper.classList.add("item");
40
- wrapper.setAttribute("part", "native-reorder-item");
41
- let element = document.createElement("slot");
42
- element.classList.add("name");
43
- if (WjElementUtils.hasSlot(this, "handle")) {
44
- const handle = document.createElement("slot");
45
- handle.classList.add("handle");
46
- handle.setAttribute("name", "handle");
47
- handle.setAttribute("part", "handle-part");
48
- wrapper.classList.add("item-w-handle");
49
- wrapper.appendChild(handle);
50
- } else {
51
- element.setAttribute("draggable", "true");
52
- }
53
- wrapper.appendChild(element);
54
- fragment.appendChild(wrapper);
55
- return fragment;
18
+ let e2 = document.createDocumentFragment(), r2 = document.createElement("div");
19
+ r2.classList.add("item"), r2.setAttribute("part", "native-reorder-item");
20
+ let a = document.createElement("slot");
21
+ if (a.classList.add("name"), t.hasSlot(this, "handle")) {
22
+ const e3 = document.createElement("slot");
23
+ e3.classList.add("handle"), e3.setAttribute("name", "handle"), e3.setAttribute("part", "handle-part"), r2.classList.add("item-w-handle"), r2.appendChild(e3);
24
+ } else a.setAttribute("draggable", "true");
25
+ return r2.appendChild(a), e2.appendChild(r2), e2;
56
26
  }
57
27
  }
58
- ReorderItem.define("wje-reorder-item", ReorderItem);
28
+ r.define("wje-reorder-item", r);
59
29
  export {
60
- ReorderItem as default
30
+ r as default
61
31
  };
62
32
  //# sourceMappingURL=wje-reorder-item.js.map