wj-elements 0.2.0-alpha.8 → 0.3.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 (385) hide show
  1. package/dist/dark.css +15 -1
  2. package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
  3. package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
  4. package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
  5. package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
  6. package/dist/{packages/internals → internals}/form-associated-element.d.ts +0 -1
  7. package/dist/light.css +7 -2
  8. package/dist/localize.js +8 -5
  9. package/dist/localize.js.map +1 -1
  10. package/dist/{popup.element-DeajFyOQ.js → popup.element-Cl6QeG8M.js} +2 -2
  11. package/dist/{popup.element-DeajFyOQ.js.map → popup.element-Cl6QeG8M.js.map} +1 -1
  12. package/dist/skeleton.css +197 -0
  13. package/dist/utils/utils.d.ts +17 -0
  14. package/dist/utils.js +18 -1
  15. package/dist/utils.js.map +1 -1
  16. package/dist/{packages/wje-accordion-item → wje-accordion-item}/accordion-item.element.d.ts +3 -0
  17. package/dist/wje-accordion-item.js +26 -4
  18. package/dist/wje-accordion-item.js.map +1 -1
  19. package/dist/wje-accordion.js +1 -0
  20. package/dist/wje-accordion.js.map +1 -1
  21. package/dist/wje-animation.js +1 -0
  22. package/dist/wje-animation.js.map +1 -1
  23. package/dist/{packages/wje-avatar → wje-avatar}/avatar.element.d.ts +5 -0
  24. package/dist/wje-avatar.js +18 -0
  25. package/dist/wje-avatar.js.map +1 -1
  26. package/dist/wje-badge.js +1 -0
  27. package/dist/wje-badge.js.map +1 -1
  28. package/dist/{packages/wje-breadcrumb → wje-breadcrumb}/breadcrumb.element.d.ts +1 -0
  29. package/dist/wje-breadcrumb.js +13 -1
  30. package/dist/wje-breadcrumb.js.map +1 -1
  31. package/dist/wje-breadcrumbs.js +1 -0
  32. package/dist/wje-breadcrumbs.js.map +1 -1
  33. package/dist/{packages/wje-button → wje-button}/button.element.d.ts +5 -1
  34. package/dist/{packages/wje-button-group → wje-button-group}/button-group.element.d.ts +4 -0
  35. package/dist/wje-button-group.js +10 -0
  36. package/dist/wje-button-group.js.map +1 -1
  37. package/dist/wje-button.js +29 -5
  38. package/dist/wje-button.js.map +1 -1
  39. package/dist/{packages/wje-card → wje-card}/card.element.d.ts +15 -6
  40. package/dist/wje-card.js +37 -0
  41. package/dist/wje-card.js.map +1 -1
  42. package/dist/{packages/wje-carousel → wje-carousel}/carousel.element.d.ts +4 -0
  43. package/dist/wje-carousel.js +38 -4
  44. package/dist/wje-carousel.js.map +1 -1
  45. package/dist/{packages/wje-checkbox → wje-checkbox}/checkbox.element.d.ts +14 -0
  46. package/dist/wje-checkbox.js +48 -3
  47. package/dist/wje-checkbox.js.map +1 -1
  48. package/dist/{packages/wje-chip → wje-chip}/chip.element.d.ts +6 -0
  49. package/dist/wje-chip.js +22 -0
  50. package/dist/wje-chip.js.map +1 -1
  51. package/dist/{packages/wje-color-picker → wje-color-picker}/color-picker.element.d.ts +43 -1
  52. package/dist/wje-color-picker.js +143 -29
  53. package/dist/wje-color-picker.js.map +1 -1
  54. package/dist/{packages/wje-copy-button → wje-copy-button}/copy-button.element.d.ts +4 -0
  55. package/dist/wje-copy-button.js +21 -0
  56. package/dist/wje-copy-button.js.map +1 -1
  57. package/dist/{packages/wje-dialog → wje-dialog}/dialog.element.d.ts +2 -0
  58. package/dist/wje-dialog.js +35 -2
  59. package/dist/wje-dialog.js.map +1 -1
  60. package/dist/{packages/wje-dropdown → wje-dropdown}/dropdown.element.d.ts +7 -0
  61. package/dist/wje-dropdown.js +27 -3
  62. package/dist/wje-dropdown.js.map +1 -1
  63. package/dist/{packages/wje-element → wje-element}/element.d.ts +55 -24
  64. package/dist/wje-element.js +87 -242
  65. package/dist/wje-element.js.map +1 -1
  66. package/dist/{packages/wje-file-upload → wje-file-upload}/file-upload.element.d.ts +17 -6
  67. package/dist/{packages/wje-file-upload → wje-file-upload}/service/service.d.ts +0 -23
  68. package/dist/{packages/wje-file-upload-item → wje-file-upload-item}/file-upload-item.element.d.ts +6 -0
  69. package/dist/wje-file-upload-item.js +24 -2
  70. package/dist/wje-file-upload-item.js.map +1 -1
  71. package/dist/wje-file-upload.js +100 -77
  72. package/dist/wje-file-upload.js.map +1 -1
  73. package/dist/{packages/wje-format-digital → wje-format-digital}/format-digital.element.d.ts +2 -0
  74. package/dist/wje-format-digital.js +9 -0
  75. package/dist/wje-format-digital.js.map +1 -1
  76. package/dist/{packages/wje-icon → wje-icon}/icon.element.d.ts +11 -0
  77. package/dist/{packages/wje-icon-picker → wje-icon-picker}/icon-picker.element.d.ts +4 -0
  78. package/dist/wje-icon-picker.js +15 -0
  79. package/dist/wje-icon-picker.js.map +1 -1
  80. package/dist/wje-icon.js +1 -1
  81. package/dist/{packages/wje-img → wje-img}/img.element.d.ts +1 -0
  82. package/dist/wje-img-comparer.js +5 -1
  83. package/dist/wje-img-comparer.js.map +1 -1
  84. package/dist/wje-img.js +16 -1
  85. package/dist/wje-img.js.map +1 -1
  86. package/dist/{packages/wje-infinite-scroll → wje-infinite-scroll}/infinite-scroll.element.d.ts +4 -0
  87. package/dist/wje-infinite-scroll.js +10 -0
  88. package/dist/wje-infinite-scroll.js.map +1 -1
  89. package/dist/{packages/wje-input → wje-input}/input.element.d.ts +9 -1
  90. package/dist/wje-input-file.js +2 -0
  91. package/dist/wje-input-file.js.map +1 -1
  92. package/dist/wje-input.js +59 -4
  93. package/dist/wje-input.js.map +1 -1
  94. package/dist/{packages/wje-item → wje-item}/item.element.d.ts +8 -0
  95. package/dist/wje-item.js +14 -0
  96. package/dist/wje-item.js.map +1 -1
  97. package/dist/{packages/wje-kanban → wje-kanban}/kanban.element.d.ts +4 -0
  98. package/dist/wje-kanban.js +14 -0
  99. package/dist/wje-kanban.js.map +1 -1
  100. package/dist/{packages/wje-level-indicator → wje-level-indicator}/level-indicator.element.d.ts +17 -0
  101. package/dist/wje-level-indicator.js +36 -0
  102. package/dist/wje-level-indicator.js.map +1 -1
  103. package/dist/{packages/wje-list → wje-list}/list.element.d.ts +4 -0
  104. package/dist/wje-list.js +10 -0
  105. package/dist/wje-list.js.map +1 -1
  106. package/dist/wje-master.js +11 -2
  107. package/dist/wje-master.js.map +1 -1
  108. package/dist/wje-menu-button.js +1 -0
  109. package/dist/wje-menu-button.js.map +1 -1
  110. package/dist/{packages/wje-menu-item → wje-menu-item}/menu-item.element.d.ts +4 -0
  111. package/dist/wje-menu-item.js +24 -0
  112. package/dist/wje-menu-item.js.map +1 -1
  113. package/dist/wje-menu.js +4 -1
  114. package/dist/wje-menu.js.map +1 -1
  115. package/dist/{packages/wje-option → wje-option}/option.element.d.ts +4 -0
  116. package/dist/wje-option.js +14 -1
  117. package/dist/wje-option.js.map +1 -1
  118. package/dist/{packages/wje-options → wje-options}/options.element.d.ts +4 -0
  119. package/dist/wje-options.js +13 -0
  120. package/dist/wje-options.js.map +1 -1
  121. package/dist/{packages/wje-orgchart → wje-orgchart}/orgchart.element.d.ts +4 -0
  122. package/dist/wje-orgchart.js +9 -0
  123. package/dist/wje-orgchart.js.map +1 -1
  124. package/dist/wje-pagination.js +18 -9
  125. package/dist/wje-pagination.js.map +1 -1
  126. package/dist/wje-popup.js +1 -1
  127. package/dist/{packages/wje-progress-bar → wje-progress-bar}/progress-bar.element.d.ts +11 -0
  128. package/dist/wje-progress-bar.js +26 -0
  129. package/dist/wje-progress-bar.js.map +1 -1
  130. package/dist/wje-qr-code/qr-code.element.d.ts +96 -0
  131. package/dist/wje-qr-code.js +159 -17
  132. package/dist/wje-qr-code.js.map +1 -1
  133. package/dist/{packages/wje-radio → wje-radio}/radio.element.d.ts +5 -0
  134. package/dist/{packages/wje-radio-group → wje-radio-group}/radio-group.element.d.ts +16 -1
  135. package/dist/wje-radio-group.js +49 -2
  136. package/dist/wje-radio-group.js.map +1 -1
  137. package/dist/wje-radio.js +27 -1
  138. package/dist/wje-radio.js.map +1 -1
  139. package/dist/{packages/wje-rate → wje-rate}/rate.element.d.ts +4 -0
  140. package/dist/wje-rate.js +23 -1
  141. package/dist/wje-rate.js.map +1 -1
  142. package/dist/{packages/wje-relative-time → wje-relative-time}/relative-time.element.d.ts +2 -0
  143. package/dist/wje-relative-time.js +14 -1
  144. package/dist/wje-relative-time.js.map +1 -1
  145. package/dist/{packages/wje-reorder → wje-reorder}/reorder.element.d.ts +4 -0
  146. package/dist/{packages/wje-reorder-handle → wje-reorder-handle}/reorder-handle.element.d.ts +4 -0
  147. package/dist/wje-reorder-handle.js +21 -0
  148. package/dist/wje-reorder-handle.js.map +1 -1
  149. package/dist/wje-reorder.js +10 -0
  150. package/dist/wje-reorder.js.map +1 -1
  151. package/dist/{packages/wje-select → wje-select}/select.element.d.ts +7 -0
  152. package/dist/wje-select.js +35 -5
  153. package/dist/wje-select.js.map +1 -1
  154. package/dist/{packages/wje-slider → wje-slider}/slider.element.d.ts +5 -0
  155. package/dist/wje-slider.js +51 -1
  156. package/dist/wje-slider.js.map +1 -1
  157. package/dist/{packages/wje-sliding-container → wje-sliding-container}/sliding-container.element.d.ts +4 -0
  158. package/dist/wje-sliding-container.js +18 -0
  159. package/dist/wje-sliding-container.js.map +1 -1
  160. package/dist/{packages/wje-split-view → wje-split-view}/split-view.element.d.ts +1 -0
  161. package/dist/wje-split-view.js +9 -0
  162. package/dist/wje-split-view.js.map +1 -1
  163. package/dist/wje-status.js +1 -0
  164. package/dist/wje-status.js.map +1 -1
  165. package/dist/{packages/wje-stepper → wje-stepper}/stepper.element.d.ts +1 -0
  166. package/dist/wje-stepper.js +24 -1
  167. package/dist/wje-stepper.js.map +1 -1
  168. package/dist/{packages/wje-tab → wje-tab}/tab.element.d.ts +10 -0
  169. package/dist/{packages/wje-tab-group → wje-tab-group}/tab-group.element.d.ts +11 -0
  170. package/dist/wje-tab-group.js +59 -2
  171. package/dist/wje-tab-group.js.map +1 -1
  172. package/dist/wje-tab.js +30 -0
  173. package/dist/wje-tab.js.map +1 -1
  174. package/dist/{packages/wje-textarea → wje-textarea}/textarea.element.d.ts +20 -1
  175. package/dist/wje-textarea.js +96 -14
  176. package/dist/wje-textarea.js.map +1 -1
  177. package/dist/{packages/wje-thumbnail → wje-thumbnail}/thumbnail.element.d.ts +4 -0
  178. package/dist/wje-thumbnail.js +19 -0
  179. package/dist/wje-thumbnail.js.map +1 -1
  180. package/dist/{packages/wje-timeline → wje-timeline}/timeline.element.d.ts +4 -0
  181. package/dist/wje-toast.js +4 -0
  182. package/dist/wje-toast.js.map +1 -1
  183. package/dist/{packages/wje-toggle → wje-toggle}/toggle.element.d.ts +4 -0
  184. package/dist/wje-toggle.js +17 -1
  185. package/dist/wje-toggle.js.map +1 -1
  186. package/dist/{packages/wje-toolbar → wje-toolbar}/toolbar.element.d.ts +4 -0
  187. package/dist/wje-toolbar.js +14 -0
  188. package/dist/wje-toolbar.js.map +1 -1
  189. package/dist/{packages/wje-tooltip → wje-tooltip}/tooltip.element.d.ts +3 -0
  190. package/dist/wje-tooltip.js +31 -7
  191. package/dist/wje-tooltip.js.map +1 -1
  192. package/dist/{packages/wje-tree → wje-tree}/tree.element.d.ts +4 -0
  193. package/dist/{packages/wje-tree-item → wje-tree-item}/tree-item.element.d.ts +5 -0
  194. package/dist/wje-tree-item.js +41 -5
  195. package/dist/wje-tree-item.js.map +1 -1
  196. package/dist/wje-tree.js +12 -1
  197. package/dist/wje-tree.js.map +1 -1
  198. package/package.json +21 -2
  199. package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
  200. package/dist/packages/utils/utils.d.ts +0 -1
  201. package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
  202. package/dist/packages/wje-animation/animation.test.d.ts +0 -1
  203. package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
  204. package/dist/packages/wje-badge/badge.test.d.ts +0 -1
  205. package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
  206. package/dist/packages/wje-button/button.test.d.ts +0 -1
  207. package/dist/packages/wje-chip/chip.test.d.ts +0 -1
  208. package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
  209. package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
  210. package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
  211. package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
  212. package/dist/packages/wje-qr-code/qr-code.element.d.ts +0 -33
  213. package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
  214. package/dist/packages/wje-select/select.test.d.ts +0 -1
  215. package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
  216. package/dist/packages/wje-toast/toast.test.d.ts +0 -1
  217. package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
  218. package/dist/packages/wje-tree/tree.test.d.ts +0 -1
  219. package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
  220. /package/dist/{packages/index.d.ts → index.d.ts} +0 -0
  221. /package/dist/{packages/localize → localize}/localize.d.ts +0 -0
  222. /package/dist/{packages/translations → translations}/en-gb.d.ts +0 -0
  223. /package/dist/{packages/translations → translations}/sk-sk.d.ts +0 -0
  224. /package/dist/{packages/utils → utils}/animations.d.ts +0 -0
  225. /package/dist/{packages/utils → utils}/base-path.d.ts +0 -0
  226. /package/dist/{packages/utils → utils}/date.d.ts +0 -0
  227. /package/dist/{packages/utils → utils}/element-utils.d.ts +0 -0
  228. /package/dist/{packages/utils → utils}/event.d.ts +0 -0
  229. /package/dist/{packages/utils → utils}/icon-library.d.ts +0 -0
  230. /package/dist/{packages/utils → utils}/localize.d.ts +0 -0
  231. /package/dist/{packages/utils → utils}/permissions.d.ts +0 -0
  232. /package/dist/{packages/utils → utils}/universal-service.d.ts +0 -0
  233. /package/dist/{packages/wje-accordion → wje-accordion}/accordion.d.ts +0 -0
  234. /package/dist/{packages/wje-accordion → wje-accordion}/accordion.element.d.ts +0 -0
  235. /package/dist/{packages/wje-accordion-item → wje-accordion-item}/accordion-item.d.ts +0 -0
  236. /package/dist/{packages/wje-animation → wje-animation}/animation.d.ts +0 -0
  237. /package/dist/{packages/wje-animation → wje-animation}/animation.element.d.ts +0 -0
  238. /package/dist/{packages/wje-aside → wje-aside}/aside.d.ts +0 -0
  239. /package/dist/{packages/wje-aside → wje-aside}/aside.element.d.ts +0 -0
  240. /package/dist/{packages/wje-avatar → wje-avatar}/avatar.d.ts +0 -0
  241. /package/dist/{packages/wje-avatar → wje-avatar}/service/service.d.ts +0 -0
  242. /package/dist/{packages/wje-badge → wje-badge}/badge.d.ts +0 -0
  243. /package/dist/{packages/wje-badge → wje-badge}/badge.element.d.ts +0 -0
  244. /package/dist/{packages/wje-breadcrumb → wje-breadcrumb}/breadcrumb.d.ts +0 -0
  245. /package/dist/{packages/wje-breadcrumbs → wje-breadcrumbs}/breadcrumbs.d.ts +0 -0
  246. /package/dist/{packages/wje-breadcrumbs → wje-breadcrumbs}/breadcrumbs.element.d.ts +0 -0
  247. /package/dist/{packages/wje-button → wje-button}/button.d.ts +0 -0
  248. /package/dist/{packages/wje-button-group → wje-button-group}/button-group.d.ts +0 -0
  249. /package/dist/{packages/wje-card → wje-card}/card.d.ts +0 -0
  250. /package/dist/{packages/wje-card-content → wje-card-content}/card-content.d.ts +0 -0
  251. /package/dist/{packages/wje-card-content → wje-card-content}/card-content.element.d.ts +0 -0
  252. /package/dist/{packages/wje-card-controls → wje-card-controls}/card-controls.d.ts +0 -0
  253. /package/dist/{packages/wje-card-controls → wje-card-controls}/card-controls.element.d.ts +0 -0
  254. /package/dist/{packages/wje-card-header → wje-card-header}/card-header.d.ts +0 -0
  255. /package/dist/{packages/wje-card-header → wje-card-header}/card-header.element.d.ts +0 -0
  256. /package/dist/{packages/wje-card-subtitle → wje-card-subtitle}/card-subtitle.d.ts +0 -0
  257. /package/dist/{packages/wje-card-subtitle → wje-card-subtitle}/card-subtitle.element.d.ts +0 -0
  258. /package/dist/{packages/wje-card-title → wje-card-title}/card-title.d.ts +0 -0
  259. /package/dist/{packages/wje-card-title → wje-card-title}/card-title.element.d.ts +0 -0
  260. /package/dist/{packages/wje-carousel → wje-carousel}/carousel.d.ts +0 -0
  261. /package/dist/{packages/wje-carousel-item → wje-carousel-item}/carousel-item.d.ts +0 -0
  262. /package/dist/{packages/wje-carousel-item → wje-carousel-item}/carousel-item.element.d.ts +0 -0
  263. /package/dist/{packages/wje-checkbox → wje-checkbox}/checkbox.d.ts +0 -0
  264. /package/dist/{packages/wje-chip → wje-chip}/chip.d.ts +0 -0
  265. /package/dist/{packages/wje-col → wje-col}/col.d.ts +0 -0
  266. /package/dist/{packages/wje-col → wje-col}/col.element.d.ts +0 -0
  267. /package/dist/{packages/wje-color-picker → wje-color-picker}/color-picker.d.ts +0 -0
  268. /package/dist/{packages/wje-container → wje-container}/container.d.ts +0 -0
  269. /package/dist/{packages/wje-container → wje-container}/container.element.d.ts +0 -0
  270. /package/dist/{packages/wje-copy-button → wje-copy-button}/copy-button.d.ts +0 -0
  271. /package/dist/{packages/wje-copy-button → wje-copy-button}/service/service.d.ts +0 -0
  272. /package/dist/{packages/wje-dialog → wje-dialog}/dialog.d.ts +0 -0
  273. /package/dist/{packages/wje-divider → wje-divider}/divider.d.ts +0 -0
  274. /package/dist/{packages/wje-divider → wje-divider}/divider.element.d.ts +0 -0
  275. /package/dist/{packages/wje-dropdown → wje-dropdown}/dropdown.d.ts +0 -0
  276. /package/dist/{packages/wje-file-upload → wje-file-upload}/file-upload.d.ts +0 -0
  277. /package/dist/{packages/wje-file-upload-item → wje-file-upload-item}/file-upload-item.d.ts +0 -0
  278. /package/dist/{packages/wje-footer → wje-footer}/footer.d.ts +0 -0
  279. /package/dist/{packages/wje-footer → wje-footer}/footer.element.d.ts +0 -0
  280. /package/dist/{packages/wje-form → wje-form}/form.d.ts +0 -0
  281. /package/dist/{packages/wje-form → wje-form}/form.element.d.ts +0 -0
  282. /package/dist/{packages/wje-format-digital → wje-format-digital}/format-digital.d.ts +0 -0
  283. /package/dist/{packages/wje-grid → wje-grid}/grid.d.ts +0 -0
  284. /package/dist/{packages/wje-grid → wje-grid}/grid.element.d.ts +0 -0
  285. /package/dist/{packages/wje-header → wje-header}/header.d.ts +0 -0
  286. /package/dist/{packages/wje-header → wje-header}/header.element.d.ts +0 -0
  287. /package/dist/{packages/wje-icon → wje-icon}/icon.d.ts +0 -0
  288. /package/dist/{packages/wje-icon → wje-icon}/service/library.d.ts +0 -0
  289. /package/dist/{packages/wje-icon → wje-icon}/service/service.d.ts +0 -0
  290. /package/dist/{packages/wje-icon-picker → wje-icon-picker}/icon-picker.d.ts +0 -0
  291. /package/dist/{packages/wje-img → wje-img}/img.d.ts +0 -0
  292. /package/dist/{packages/wje-img-comparer → wje-img-comparer}/img-comparer.d.ts +0 -0
  293. /package/dist/{packages/wje-img-comparer → wje-img-comparer}/img-comparer.element.d.ts +0 -0
  294. /package/dist/{packages/wje-img-comparer → wje-img-comparer}/service/service.d.ts +0 -0
  295. /package/dist/{packages/wje-infinite-scroll → wje-infinite-scroll}/infinite-scroll.d.ts +0 -0
  296. /package/dist/{packages/wje-input → wje-input}/input.d.ts +0 -0
  297. /package/dist/{packages/wje-input-file → wje-input-file}/input-file.d.ts +0 -0
  298. /package/dist/{packages/wje-input-file → wje-input-file}/input-file.element.d.ts +0 -0
  299. /package/dist/{packages/wje-item → wje-item}/item.d.ts +0 -0
  300. /package/dist/{packages/wje-kanban → wje-kanban}/kanban.d.ts +0 -0
  301. /package/dist/{packages/wje-label → wje-label}/label.d.ts +0 -0
  302. /package/dist/{packages/wje-label → wje-label}/label.element.d.ts +0 -0
  303. /package/dist/{packages/wje-level-indicator → wje-level-indicator}/level-indicator.d.ts +0 -0
  304. /package/dist/{packages/wje-list → wje-list}/list.d.ts +0 -0
  305. /package/dist/{packages/wje-main → wje-main}/main.d.ts +0 -0
  306. /package/dist/{packages/wje-main → wje-main}/main.element.d.ts +0 -0
  307. /package/dist/{packages/wje-masonry → wje-masonry}/masonry.d.ts +0 -0
  308. /package/dist/{packages/wje-masonry → wje-masonry}/masonry.element.d.ts +0 -0
  309. /package/dist/{packages/wje-masonry → wje-masonry}/service/service.d.ts +0 -0
  310. /package/dist/{packages/wje-menu → wje-menu}/menu.d.ts +0 -0
  311. /package/dist/{packages/wje-menu → wje-menu}/menu.element.d.ts +0 -0
  312. /package/dist/{packages/wje-menu-button → wje-menu-button}/menu-button.d.ts +0 -0
  313. /package/dist/{packages/wje-menu-button → wje-menu-button}/menu-button.element.d.ts +0 -0
  314. /package/dist/{packages/wje-menu-item → wje-menu-item}/menu-item.d.ts +0 -0
  315. /package/dist/{packages/wje-menu-label → wje-menu-label}/menu-label.d.ts +0 -0
  316. /package/dist/{packages/wje-menu-label → wje-menu-label}/menu-label.element.d.ts +0 -0
  317. /package/dist/{packages/wje-option → wje-option}/option.d.ts +0 -0
  318. /package/dist/{packages/wje-options → wje-options}/options.d.ts +0 -0
  319. /package/dist/{packages/wje-orgchart → wje-orgchart}/orgchart.d.ts +0 -0
  320. /package/dist/{packages/wje-orgchart-group → wje-orgchart-group}/orgchart-group.d.ts +0 -0
  321. /package/dist/{packages/wje-orgchart-group → wje-orgchart-group}/orgchart-group.element.d.ts +0 -0
  322. /package/dist/{packages/wje-orgchart-item → wje-orgchart-item}/orgchart-item.d.ts +0 -0
  323. /package/dist/{packages/wje-orgchart-item → wje-orgchart-item}/orgchart-item.element.d.ts +0 -0
  324. /package/dist/{packages/wje-pagination → wje-pagination}/pagination.d.ts +0 -0
  325. /package/dist/{packages/wje-pagination → wje-pagination}/pagination.element.d.ts +0 -0
  326. /package/dist/{packages/wje-pagination → wje-pagination}/service/service.d.ts +0 -0
  327. /package/dist/{packages/wje-panel → wje-panel}/panel.d.ts +0 -0
  328. /package/dist/{packages/wje-panel → wje-panel}/panel.element.d.ts +0 -0
  329. /package/dist/{packages/wje-popup → wje-popup}/popup.d.ts +0 -0
  330. /package/dist/{packages/wje-popup → wje-popup}/popup.element.d.ts +0 -0
  331. /package/dist/{packages/wje-progress-bar → wje-progress-bar}/progress-bar.d.ts +0 -0
  332. /package/dist/{packages/wje-qr-code → wje-qr-code}/qr-code.d.ts +0 -0
  333. /package/dist/{packages/wje-radio → wje-radio}/radio.d.ts +0 -0
  334. /package/dist/{packages/wje-radio-group → wje-radio-group}/radio-group.d.ts +0 -0
  335. /package/dist/{packages/wje-rate → wje-rate}/rate.d.ts +0 -0
  336. /package/dist/{packages/wje-relative-time → wje-relative-time}/relative-time.d.ts +0 -0
  337. /package/dist/{packages/wje-reorder → wje-reorder}/reorder.d.ts +0 -0
  338. /package/dist/{packages/wje-reorder-dropzone → wje-reorder-dropzone}/reorder-dropzone.d.ts +0 -0
  339. /package/dist/{packages/wje-reorder-dropzone → wje-reorder-dropzone}/reorder-dropzone.element.d.ts +0 -0
  340. /package/dist/{packages/wje-reorder-handle → wje-reorder-handle}/reorder-handle.d.ts +0 -0
  341. /package/dist/{packages/wje-reorder-item → wje-reorder-item}/reorder-item.d.ts +0 -0
  342. /package/dist/{packages/wje-reorder-item → wje-reorder-item}/reorder-item.element.d.ts +0 -0
  343. /package/dist/{packages/wje-route → wje-route}/route.d.ts +0 -0
  344. /package/dist/{packages/wje-route → wje-route}/route.element.d.ts +0 -0
  345. /package/dist/{packages/wje-router → wje-router}/router.d.ts +0 -0
  346. /package/dist/{packages/wje-router → wje-router}/router.element.d.ts +0 -0
  347. /package/dist/{packages/wje-router-link → wje-router-link}/router-link.d.ts +0 -0
  348. /package/dist/{packages/wje-router-link → wje-router-link}/router-link.element.d.ts +0 -0
  349. /package/dist/{packages/wje-router-outlet → wje-router-outlet}/router-outlet.d.ts +0 -0
  350. /package/dist/{packages/wje-router-outlet → wje-router-outlet}/router-outlet.element.d.ts +0 -0
  351. /package/dist/{packages/wje-row → wje-row}/row.d.ts +0 -0
  352. /package/dist/{packages/wje-row → wje-row}/row.element.d.ts +0 -0
  353. /package/dist/{packages/wje-select → wje-select}/select.d.ts +0 -0
  354. /package/dist/{packages/wje-slider → wje-slider}/slider.d.ts +0 -0
  355. /package/dist/{packages/wje-sliding-container → wje-sliding-container}/sliding-container.d.ts +0 -0
  356. /package/dist/{packages/wje-split-view → wje-split-view}/service/service.d.ts +0 -0
  357. /package/dist/{packages/wje-split-view → wje-split-view}/split-view.d.ts +0 -0
  358. /package/dist/{packages/wje-status → wje-status}/status.d.ts +0 -0
  359. /package/dist/{packages/wje-status → wje-status}/status.element.d.ts +0 -0
  360. /package/dist/{packages/wje-step → wje-step}/step.d.ts +0 -0
  361. /package/dist/{packages/wje-step → wje-step}/step.element.d.ts +0 -0
  362. /package/dist/{packages/wje-stepper → wje-stepper}/stepper.d.ts +0 -0
  363. /package/dist/{packages/wje-store → wje-store}/default-store-actions.d.ts +0 -0
  364. /package/dist/{packages/wje-store → wje-store}/pubsub.d.ts +0 -0
  365. /package/dist/{packages/wje-store → wje-store}/store.d.ts +0 -0
  366. /package/dist/{packages/wje-tab → wje-tab}/tab.d.ts +0 -0
  367. /package/dist/{packages/wje-tab-group → wje-tab-group}/tab-group.d.ts +0 -0
  368. /package/dist/{packages/wje-tab-panel → wje-tab-panel}/tab-panel.d.ts +0 -0
  369. /package/dist/{packages/wje-tab-panel → wje-tab-panel}/tab-panel.element.d.ts +0 -0
  370. /package/dist/{packages/wje-textarea → wje-textarea}/textarea.d.ts +0 -0
  371. /package/dist/{packages/wje-thumbnail → wje-thumbnail}/thumbnail.d.ts +0 -0
  372. /package/dist/{packages/wje-timeline → wje-timeline}/timeline.d.ts +0 -0
  373. /package/dist/{packages/wje-timeline-item → wje-timeline-item}/timeline-item.d.ts +0 -0
  374. /package/dist/{packages/wje-timeline-item → wje-timeline-item}/timeline-item.element.d.ts +0 -0
  375. /package/dist/{packages/wje-toast → wje-toast}/toast.d.ts +0 -0
  376. /package/dist/{packages/wje-toast → wje-toast}/toast.element.d.ts +0 -0
  377. /package/dist/{packages/wje-toggle → wje-toggle}/toggle.d.ts +0 -0
  378. /package/dist/{packages/wje-toolbar → wje-toolbar}/toolbar.d.ts +0 -0
  379. /package/dist/{packages/wje-toolbar-action → wje-toolbar-action}/toolbar-action.d.ts +0 -0
  380. /package/dist/{packages/wje-toolbar-action → wje-toolbar-action}/toolbar-action.element.d.ts +0 -0
  381. /package/dist/{packages/wje-tooltip → wje-tooltip}/tooltip.d.ts +0 -0
  382. /package/dist/{packages/wje-tree → wje-tree}/tree.d.ts +0 -0
  383. /package/dist/{packages/wje-tree-item → wje-tree-item}/tree-item.d.ts +0 -0
  384. /package/dist/{packages/wje-visually-hidden → wje-visually-hidden}/visually-hidden.d.ts +0 -0
  385. /package/dist/{packages/wje-visually-hidden → wje-visually-hidden}/visually-hidden.element.d.ts +0 -0
@@ -2,8 +2,10 @@ 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 { Localizer } from "./localize.js";
5
- import Button from "./wje-button.js";
6
5
  import WJElement from "./wje-element.js";
6
+ import Button from "./wje-button.js";
7
+ import { isValidFileType } from "./utils.js";
8
+ import { event } from "./event.js";
7
9
  function fileType() {
8
10
  return [
9
11
  {
@@ -65,22 +67,6 @@ function getFileTypeIcon(type) {
65
67
  }
66
68
  return searchType;
67
69
  }
68
- function isValidFileType(file, acceptedFileTypes) {
69
- const mime = file.type.toLowerCase();
70
- const base = mime.split("/")[0];
71
- const ext = file.name.split(".").pop().toLowerCase();
72
- let accepted = Array.isArray(acceptedFileTypes) ? acceptedFileTypes : acceptedFileTypes.split(",").map((t) => t.trim().toLowerCase());
73
- if (accepted.length === 0) {
74
- throw new Error("acceptedFileTypes is empty");
75
- }
76
- for (let type of accepted) {
77
- type = type.toLowerCase();
78
- if (type === base + "/*") return true;
79
- if (type === mime) return true;
80
- if (type === ext) return true;
81
- }
82
- return false;
83
- }
84
70
  function upload(url, chunkSize = 1024 * 1024, wholeFile = false) {
85
71
  if (wholeFile) {
86
72
  return (file, preview) => uploadWholeFile(url, file, preview);
@@ -170,22 +156,25 @@ class FileUpload extends WJElement {
170
156
  __publicField(this, "className", "FileUpload");
171
157
  /**
172
158
  * Method to handle file drop event.
173
- * @param {Event} event The file drop event object.
159
+ * @param {Event} e The file drop event object.
174
160
  */
175
- __publicField(this, "handleDrop", (event) => {
176
- const fileList = event.dataTransfer.files;
161
+ __publicField(this, "handleDrop", (e) => {
162
+ const fileList = e.dataTransfer.files;
177
163
  this.resetFormState();
178
164
  this.addFilesToQueue(fileList);
179
165
  });
180
166
  /**
181
167
  * Method to handle file input change event.
182
- * @param {Event} event The file input change event object.
168
+ * @param {Event} e The file input change event object.
183
169
  */
184
- __publicField(this, "handleInputChange", (event) => {
170
+ __publicField(this, "handleInputChange", (e) => {
171
+ const files = Array.from(e.target.files);
172
+ event.dispatchCustomEvent(this, "wje-file-upload:files-selected", files);
185
173
  this.resetFormState();
186
174
  try {
187
- this.handleSubmit(event);
175
+ this.handleSubmit(e);
188
176
  } catch (err) {
177
+ console.error(err);
189
178
  }
190
179
  });
191
180
  /**
@@ -198,27 +187,18 @@ class FileUpload extends WJElement {
198
187
  this.assertFilesValid(file);
199
188
  let preview;
200
189
  let reader = new FileReader();
201
- reader.onload = (e) => {
190
+ reader.onload = () => {
202
191
  var _a;
203
- this.dispatchEvent(
204
- new CustomEvent("file-upload:upload-started", { detail: file, bubbles: true, composed: true })
205
- );
192
+ event.dispatchCustomEvent(this, "wje-file-upload:started", file);
206
193
  (_a = this.onUploadStarted) == null ? void 0 : _a.call(this, file);
207
194
  preview = this.createPreview(file, reader);
208
195
  this.appendChild(preview);
209
196
  this.uploadFunction(file, preview).then((res) => {
210
197
  var _a2;
211
198
  res.item = preview;
212
- console.log(res);
213
- this.dispatchEvent(
214
- new CustomEvent("file-upload:upladed-file-complete", {
215
- detail: res,
216
- bubbles: true,
217
- composed: true
218
- })
219
- );
199
+ event.dispatchCustomEvent(this, "wje-file-upload:file-uploaded", res);
220
200
  (_a2 = this.onUploadedFileComplete) == null ? void 0 : _a2.call(this, res);
221
- this.uploadedFiles.push(res.data);
201
+ this.uploadedFiles.push(res);
222
202
  resolve(res);
223
203
  });
224
204
  };
@@ -242,7 +222,7 @@ class FileUpload extends WJElement {
242
222
  */
243
223
  get acceptedTypes() {
244
224
  const accepted = this.getAttribute("accepted-types");
245
- return this.hasAttribute("accepted-types") ? accepted : "";
225
+ return this.hasAttribute("accepted-types") ? accepted : "image/*";
246
226
  }
247
227
  /**
248
228
  * Setter for chunkSize attribute.
@@ -352,13 +332,27 @@ class FileUpload extends WJElement {
352
332
  set maxFiles(value) {
353
333
  this.setAttribute("max-files", value);
354
334
  }
335
+ /**
336
+ * Sets the label attribute for the upload button.
337
+ * @param {string} value
338
+ */
339
+ set label(value) {
340
+ this.setAttribute("label", value);
341
+ }
342
+ /**
343
+ * Gets the label attribute for the upload button.
344
+ * @returns {string}
345
+ */
346
+ get label() {
347
+ return this.getAttribute("label") || "";
348
+ }
355
349
  /**
356
350
  * Retrieves the maximum number of files allowed from the `max-files` attribute.
357
351
  * If the attribute is not set or is invalid, defaults to 0.
358
352
  * @returns {number} The maximum number of files allowed.
359
353
  */
360
354
  get maxFiles() {
361
- return parseInt(this.getAttribute("max-files")) || 1;
355
+ return parseInt(this.getAttribute("max-files")) || 10;
362
356
  }
363
357
  /**
364
358
  * Getter for cssStyleSheet.
@@ -372,13 +366,25 @@ class FileUpload extends WJElement {
372
366
  * @returns {Array} An empty array as no attributes are observed.
373
367
  */
374
368
  static get observedAttributes() {
375
- return [];
369
+ return ["label"];
370
+ }
371
+ attributeChangedCallback(name, oldValue, newValue) {
372
+ var _a;
373
+ (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, name, oldValue, newValue);
374
+ if (name === "label" && this.button) {
375
+ const nextLabel = this.label || this.localizer.translate("wj.file.upload.button");
376
+ this.button.innerText = nextLabel;
377
+ this.button.setAttribute("aria-label", nextLabel);
378
+ }
376
379
  }
377
380
  /**
378
381
  * Method to setup attributes for the component.
379
382
  */
380
383
  setupAttributes() {
381
384
  this.isShadowRoot = "open";
385
+ this.setAriaState({
386
+ role: "group"
387
+ });
382
388
  }
383
389
  beforeDraw() {
384
390
  this.uploadFunction = upload(this.uploadUrl, this.chunkSize, !this.toChunk);
@@ -405,10 +411,12 @@ class FileUpload extends WJElement {
405
411
  fileInput.setAttribute("type", "file");
406
412
  fileInput.setAttribute("multiple", "");
407
413
  fileInput.setAttribute("style", "display:none;");
414
+ fileInput.setAttribute("aria-hidden", "true");
408
415
  if (!this.noUploadButton) {
409
416
  let button = document.createElement("wje-button");
410
417
  button.innerText = this.label || this.localizer.translate("wj.file.upload.button");
411
418
  button.setAttribute("part", "upload-button");
419
+ button.setAttribute("aria-label", button.innerText);
412
420
  label.appendChild(button);
413
421
  this.button = button;
414
422
  }
@@ -432,39 +440,53 @@ class FileUpload extends WJElement {
432
440
  this.fileInput.addEventListener("change", this.handleInputChange);
433
441
  this.native.addEventListener("drop", this.handleDrop);
434
442
  let dragEventCounter = 0;
435
- this.native.addEventListener("dragenter", (event) => {
436
- event.preventDefault();
443
+ this.native.addEventListener("dragenter", (e) => {
444
+ handleInputChange;
445
+ e.preventDefault();
437
446
  if (dragEventCounter === 0) {
438
447
  this.native.classList.add("highlight");
439
448
  }
440
449
  dragEventCounter += 1;
441
450
  });
442
- this.native.addEventListener("dragover", (event) => {
443
- event.preventDefault();
451
+ this.native.addEventListener("dragover", (e) => {
452
+ e.preventDefault();
444
453
  if (dragEventCounter === 0) {
445
454
  dragEventCounter = 1;
446
455
  }
447
456
  });
448
- this.native.addEventListener("dragleave", (event) => {
449
- event.preventDefault();
457
+ this.native.addEventListener("dragleave", (e) => {
458
+ e.preventDefault();
450
459
  dragEventCounter -= 1;
451
460
  if (dragEventCounter <= 0) {
452
461
  dragEventCounter = 0;
453
462
  this.native.classList.remove("highlight");
454
463
  }
455
464
  });
456
- this.native.addEventListener("drop", (event) => {
465
+ this.native.addEventListener("drop", (e) => {
457
466
  event.preventDefault();
458
467
  dragEventCounter = 0;
459
468
  this.native.classList.remove("highlight");
460
469
  });
470
+ this.addEventListener("wje-file-upload-item:remove", (e) => {
471
+ const file = e.detail;
472
+ if (!(file instanceof File)) {
473
+ return;
474
+ }
475
+ let count = this.uploadedFiles.length;
476
+ this.uploadedFiles = this.uploadedFiles.filter((entry) => {
477
+ var _a2;
478
+ return ((_a2 = entry == null ? void 0 : entry.file) == null ? void 0 : _a2.lastModified) !== file.lastModified;
479
+ });
480
+ if (count !== this.uploadedFiles.length)
481
+ event.dispatchCustomEvent(this, "wje-file-upload:file-removed", file);
482
+ });
461
483
  }
462
484
  /**
463
485
  * Method to handle form submission.
464
- * @param {Event} event The form submission event.
486
+ * @param {Event} e The form submission event.
465
487
  */
466
- handleSubmit(event) {
467
- event.preventDefault();
488
+ handleSubmit(e) {
489
+ e.preventDefault();
468
490
  this.addFilesToQueue(this.fileInput.files);
469
491
  }
470
492
  /**
@@ -473,24 +495,22 @@ class FileUpload extends WJElement {
473
495
  */
474
496
  addFilesToQueue(files) {
475
497
  var _a;
476
- if (this.maxFiles && files.length > this.maxFiles) {
477
- this.dispatchEvent(
478
- new CustomEvent("file-upload:error", {
479
- detail: {
480
- type: "max-files-exceeded",
481
- max: this.maxFiles,
482
- received: files.length
483
- },
484
- bubbles: true,
485
- composed: true
486
- })
487
- );
498
+ const currentCount = (Array.isArray(this.uploadedFiles) ? this.uploadedFiles.length : 0) + (Array.isArray(this._queuedFiles) ? this._queuedFiles.length : 0);
499
+ const newTotal = currentCount + files.length;
500
+ if (this.maxFiles && newTotal > this.maxFiles) {
501
+ const detail = {
502
+ code: "MAX-FILES-EXCEEDED",
503
+ files,
504
+ maxFiles: this.maxFiles,
505
+ currentCount,
506
+ attemptedToAdd: files.length,
507
+ allowedRemaining: Math.max(this.maxFiles - currentCount, 0)
508
+ };
509
+ event.dispatchCustomEvent(this, "wje-file-upload:error", detail);
488
510
  return;
489
511
  }
490
- this._queuedFiles = [...files];
491
- this.dispatchEvent(
492
- new CustomEvent("file-upload:files-added", { detail: files, bubbles: true, composed: true })
493
- );
512
+ this._queuedFiles = [...this._queuedFiles || [], ...files];
513
+ event.dispatchCustomEvent(this, "wje-file-upload:files-added", files);
494
514
  (_a = this.onAddedFiles) == null ? void 0 : _a.call(this);
495
515
  if (this.autoProcessFiles) {
496
516
  this.uploadFiles();
@@ -511,15 +531,12 @@ class FileUpload extends WJElement {
511
531
  });
512
532
  }, Promise.resolve()).then(() => {
513
533
  var _a;
514
- this.dispatchEvent(
515
- new CustomEvent("file-upload:all-files-uploaded", {
516
- detail: this.uploadedFiles,
517
- bubbles: true,
518
- composed: true
519
- })
520
- );
534
+ event.dispatchCustomEvent(this, "wje-file-upload:files-uploaded", this.uploadedFiles);
521
535
  (_a = this.onAllFilesUploaded) == null ? void 0 : _a.call(this);
522
536
  this._queuedFiles = [];
537
+ }).catch((err) => {
538
+ this._queuedFiles = this._queuedFiles.filter((file) => file !== err.file);
539
+ event.dispatchCustomEvent(this, "wje-file-upload:error", err);
523
540
  });
524
541
  }
525
542
  /**
@@ -534,8 +551,8 @@ class FileUpload extends WJElement {
534
551
  preview.setAttribute("name", file.name);
535
552
  preview.setAttribute("size", file.size);
536
553
  preview.setAttribute("uploaded", "0");
537
- preview.setAttribute("progress", "0");
538
554
  preview.innerHTML = `<wje-icon slot="img" name="${getFileTypeIcon(file.type.split("/")[1])}" size="large"></wje-icon>`;
555
+ preview.data = file;
539
556
  return preview;
540
557
  }
541
558
  /**
@@ -557,12 +574,18 @@ class FileUpload extends WJElement {
557
574
  assertFilesValid(file) {
558
575
  const { name: fileName, size: fileSize } = file;
559
576
  if (!isValidFileType(file, this.acceptedTypes)) {
560
- throw new Error(`❌ FILE: "${fileName}" Valid file types are: "${this.acceptedTypes}"`);
577
+ const err = new Error("");
578
+ err.code = "INVALID-FILE-TYPE";
579
+ err.file = file;
580
+ err.acceptedTypes = this.acceptedTypes;
581
+ throw err;
561
582
  }
562
583
  if (fileSize > this.maxFileSize) {
563
- throw new Error(
564
- `❌ File "${fileName}" could not be uploaded. Only images up to ${this.maxFileSize} MB are allowed. Nie je to ${fileSize}`
565
- );
584
+ const err = new Error("");
585
+ err.code = "FILE-TOO-LARGE";
586
+ err.file = file;
587
+ err.maxFileSize = this.maxFileSize;
588
+ throw err;
566
589
  }
567
590
  }
568
591
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wje-file-upload.js","sources":["../packages/wje-file-upload/service/service.js","../packages/wje-file-upload/file-upload.element.js","../packages/wje-file-upload/file-upload.js"],"sourcesContent":["/**\n * Returns a list of file type categories and their corresponding icon names.\n * @returns {Array<object>} An array of objects representing file type categories.\n * Each object contains the following properties:\n * - `type` {Array&lt;string>} A list of file extensions associated with the category.\n * - `name` {string} The name of the icon representing the category.\n * @example\n * const types = fileType();\n * console.log(types);\n * // [\n * // { type: [\"jpg\", \"jpeg\", \"png\", \"gif\", \"bpm\", \"tiff\", \"svg\"], name: \"photo\" },\n * // { type: [\"zip\", \"rar\", \"cab\", \"jar\", \"tar\", \"gzip\", \"uue\", \"bz2\", \"scorm\", \"war\"], name: \"file-type-zip\" },\n * // ...\n * // ]\n */\nfunction fileType() {\n return [\n {\n type: ['jpg', 'jpeg', 'png', 'gif', 'bpm', 'tiff', 'svg'],\n name: 'photo',\n },\n {\n type: ['zip', 'rar', 'cab', 'jar', 'tar', 'gzip', 'uue', 'bz2', 'scorm', 'war'],\n name: 'file-type-zip',\n },\n {\n type: ['mov', 'mp4', 'avi', 'flv'],\n name: 'video',\n },\n {\n type: ['m4a', 'mp3', 'wav'],\n name: 'audio',\n },\n {\n type: ['html', 'html'],\n name: 'file-type-html',\n },\n {\n type: ['css'],\n name: 'code',\n },\n {\n type: ['txt'],\n name: 'file-type-txt',\n },\n {\n type: ['doc', 'docx'],\n name: 'file-type-doc',\n },\n {\n type: ['xls', 'xlsx'],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: ['ppt', 'pptx', 'odp'],\n name: 'file-type-ppt',\n },\n ];\n}\n\n/**\n * Retrieves the icon name for a given file type.\n * @param {string} type The file type or category (e.g., \"pdf\", \"image\", \"folder\").\n * @returns {string} The name of the icon associated with the file type.\n * @example\n * getFileTypeIcon('pdf'); // Returns the icon name for PDF files.\n * getFileTypeIcon('folder'); // Returns 'folder'.\n */\nexport function getFileTypeIcon(type) {\n let searchType;\n if (type.toLowerCase() !== 'folder') {\n fileType().forEach((i) => {\n if (i.type.includes(type.toLowerCase())) {\n searchType = i.name;\n }\n });\n } else {\n searchType = 'folder';\n }\n\n return searchType;\n}\n\n/**\n * Checks if a given file matches any of the accepted file types.\n * @param {File} file The file to validate.\n * @param {string|string[]} acceptedFileTypes A comma-separated string or an array of accepted MIME types or file extensions.\n * @returns {boolean} Returns `true` if the file type is valid, otherwise `false`.\n * @throws {Error} Throws an error if `acceptedFileTypes` is empty.\n * @example\n * const file = new File([\"\"], \"example.png\", { type: \"image/png\" });\n * const isValid = isValidFileType(file, \"image/*,application/pdf\");\n * console.log(isValid); // true\n * @example\n * const file = new File([\"\"], \"example.txt\", { type: \"text/plain\" });\n * const isValid = isValidFileType(file, [\"text/plain\", \"application/json\"]);\n * console.log(isValid); // true\n */\nexport function isValidFileType(file, acceptedFileTypes) {\n const mime = file.type.toLowerCase(); // full mime\n const base = mime.split('/')[0]; // e.g. \"application\"\n const ext = file.name.split('.').pop().toLowerCase(); // e.g. \"xlsx\"\n\n let accepted = Array.isArray(acceptedFileTypes)\n ? acceptedFileTypes\n : acceptedFileTypes.split(',').map(t => t.trim().toLowerCase());\n\n if (accepted.length === 0) {\n throw new Error('acceptedFileTypes is empty');\n }\n\n for (let type of accepted) {\n type = type.toLowerCase();\n\n // image/* alebo application/*\n if (type === base + '/*') return true;\n\n // presný MIME typ\n if (type === mime) return true;\n\n // extension (xlsx, png, pdf…)\n if (type === ext) return true;\n }\n\n return false;\n}\n\n/**\n * Uploads a file in chunks using `XMLHttpRequest`, allowing for progress tracking.\n * @param {File} file The file to be uploaded.\n * @param {number} chunkSize The size of each chunk in bytes.\n * @param {HTMLElement} preview The element used to display upload progress.\n */\nexport function uploadFile(file, chunkSize, preview) {\n let offset = 0;\n const progressArray = new Array(Math.ceil(file.size / chunkSize)).fill(0);\n\n const readAndUploadChunk = (start, end) => {\n const reader = new FileReader();\n const chunkIndex = start / chunkSize;\n const chunk = file.slice(start, end);\n\n reader.onload = (e) => {\n const xhr = new XMLHttpRequest();\n xhr.open('POST', '/upload', true);\n xhr.setRequestHeader('Content-Range', `${start}-${end}/${file.size}`);\n\n xhr.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n const progress = (event.loaded / event.total) * 100;\n progressArray[chunkIndex] = progress;\n const totalProgress = progressArray.reduce((a, b) => a + b, 0) / progressArray.length;\n // this.updateOverallProgress(progressArray, file.lastModified);\n // preview.setAttribute(\"progress\", totalProgress);\n }\n };\n\n xhr.onload = () => {\n if (xhr.status === 200 || xhr.status === 201) {\n progressArray[chunkIndex] = 100; // Táto časť je kompletná\n\n // Odoslanie ďalšej časti\n start += chunkSize;\n if (start < file.size) {\n preview.setAttribute('uploaded', start);\n readAndUploadChunk(start, Math.min(start + chunkSize, file.size));\n } else {\n preview.setAttribute('uploaded', start);\n }\n } else {\n console.error('Error during upload: ', xhr.statusText);\n }\n };\n xhr.send(e.target.result);\n };\n reader.readAsArrayBuffer(chunk);\n };\n\n readAndUploadChunk(offset, Math.min(offset + chunkSize, file.size));\n}\n\n/**\n * Returns a function for uploading files either in chunks or as a whole file, based on the provided options.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {number} [chunkSize] The size of each chunk in bytes when uploading in chunks (default is 1MB).\n * @param {boolean} [wholeFile] Whether to upload the file as a whole. If `true`, the entire file is uploaded at once.\n * @returns {Function} A function that takes a file and a preview element as arguments and uploads the file.\n * @example\n * // Upload a file in chunks\n * const uploadInChunks = upload('/upload', 1024 * 512); // 512KB chunks\n * uploadInChunks(file, previewElement);\n * @example\n * // Upload a whole file\n * const uploadWhole = upload('/upload', undefined, true);\n * uploadWhole(file, previewElement);\n */\nexport function upload(url, chunkSize = 1024 * 1024, wholeFile = false) {\n if (wholeFile) {\n return (file, preview) => uploadWholeFile(url, file, preview);\n }\n return (file, preview) => uploadFileInChunks(url, file, preview, chunkSize);\n}\n\n/**\n * Uploads a file in chunks to a specified URL, allowing for progress tracking and resuming in case of errors.\n * @param {string} url The URL to which the file chunks will be uploaded.\n * @param {File} file The file to be uploaded in chunks.\n * @param {HTMLElement} preview The element used to display upload progress.\n * @param {number} [chunkSize] The size of each chunk in bytes (default is 1MB).\n * @returns {Promise<object>} Resolves with the response of the last chunk uploaded, parsed as JSON.\n * @throws {Error} - Throws an error if a chunk fails to upload.\n */\nexport async function uploadFileInChunks(url, file, preview, chunkSize = 1024 * 1024) {\n let offset = 0;\n const totalChunks = Math.ceil(file.size / chunkSize);\n const partResponses = [];\n\n while (offset < file.size) {\n const chunk = file.slice(offset, offset + chunkSize);\n\n // Creating a custom ReadableStream to track progress of the current chunk\n const stream = new ReadableStream({\n start(controller) {\n const reader = chunk.stream().getReader();\n let uploadedBytes = 0;\n\n reader.read().then(function process({ done, value }) {\n if (done) {\n controller.close();\n return Promise.resolve();\n }\n\n // Track progress\n uploadedBytes += value.byteLength;\n const percentComplete = ((offset + uploadedBytes) / file.size) * 100;\n preview.setAttribute('uploaded', offset + uploadedBytes);\n\n // Enqueue chunk data into the stream\n controller.enqueue(value);\n\n // Read the next chunk\n return reader.read().then(process);\n });\n },\n });\n\n const formData = new FormData();\n formData.append('file', new Blob([stream])); // Send the current stream (chunk)\n formData.append('chunkIndex', Math.floor(offset / chunkSize)); // Send chunk index\n formData.append('totalChunks', totalChunks); // Send total chunks\n formData.append('fileName', file.name); // Send file name\n\n try {\n // Send the current chunk via Fetch\n const response = await fetch(url, {\n method: 'POST',\n body: formData,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to upload chunk ${Math.floor(offset / chunkSize) + 1}: ${response.statusText}`);\n }\n\n partResponses.push(response);\n } catch (error) {\n console.error('Error uploading chunk:', error);\n break;\n }\n\n // Move to the next chunk\n offset += chunkSize;\n }\n\n const response = await partResponses.at(-1).json();\n\n return {\n data: response,\n file,\n };\n}\n\n/**\n * Uploads a file to a specified URL using a `POST` request and updates the preview element with the uploaded file size.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {File} file The file to be uploaded.\n * @param {HTMLElement} preview The element that displays the upload preview. It will be updated with the file size.\n * @returns {Promise<{data: object, file: File}>} - A promise that resolves with the server response and the uploaded file.\n * @throws {Error} - Logs an error to the console if the request fails.\n */\nexport function uploadWholeFile(url, file, preview) {\n const formData = new FormData();\n formData.append('file', file);\n\n //use fetch\n return fetch(url, {\n method: 'POST',\n body: formData,\n })\n .then((response) => response.json())\n .then((data) => {\n preview.setAttribute('uploaded', file.size);\n return {\n data,\n file,\n };\n })\n .catch((error) => {\n console.error('Error:', error);\n });\n}\n","import { Localizer } from '../utils/localize.js';\nimport Button from '../wje-button/button.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport { getFileTypeIcon, isValidFileType, upload } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary FileUpload is a custom web component for uploading files.\n * It extends from WJElement and provides functionalities for file upload.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @csspart native - The native file upload part.\n * @csspart file-list - The file list part.\n * @csspart upload-button - The label part.\n * @event change - Fires when the file input changes.\n * @event drop - Fires when a file is dropped into the component.\n * @attribute {string} accepted-types - The accepted file types for upload.\n * @attribute {number} chunk-size - The chunk size for file upload.\n * @attribute {number} max-file-size - The maximum file size for upload.\n * @attribute {string} upload-url - The URL to set as the upload URL.\n * @attribute {boolean} auto-process-files - The auto process files attribute.\n * @attribute {boolean} no-upload-button - The no upload button attribute.\n * @tag wje-file-upload\n */\nexport default class FileUpload extends WJElement {\n /**\n * Constructor for FileUpload.\n * Initializes a new instance of the Localizer.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n this._uploadedFiles = [];\n this._queuedFiles = [];\n }\n\n /**\n * Dependencies for the FileUpload component.\n * @type {object}\n */\n dependencies = {\n 'wje-button': Button,\n };\n\n /**\n * Setter for acceptedTypes attribute.\n * @param {string} value The accepted file types for upload.\n */\n set acceptedTypes(value) {\n this.setAttribute('accepted-types', value);\n }\n\n /**\n * Getter for acceptedTypes attribute.\n * @returns {string} The accepted file types for upload.\n */\n get acceptedTypes() {\n const accepted = this.getAttribute('accepted-types');\n return this.hasAttribute('accepted-types') ? accepted : '';\n }\n\n /**\n * Setter for chunkSize attribute.\n * @param {number} value The chunk size for file upload.\n */\n set chunkSize(value) {\n this.setAttribute('chunk-size', value);\n }\n\n /**\n * Getter for chunkSize attribute.\n * @returns {number} The chunk size for file upload.\n */\n get chunkSize() {\n const chunk = this.getAttribute('chunk-size');\n return this.hasAttribute('chunk-size') ? chunk : 1024 * 1024;\n }\n\n /**\n * Setter for maxFileSize attribute.\n * @param {number} value The maximum file size for upload.\n */\n set maxFileSize(value) {\n this.setAttribute('max-file-size', value);\n }\n\n /**\n * Getter for maxFileSize attribute.\n * @returns {number} The maximum file size for upload.\n */\n get maxFileSize() {\n const fileSize = this.getAttribute('max-file-size');\n return this.hasAttribute('max-file-size') ? fileSize * 1024 * 1024 : 1024 * 1024;\n }\n\n /**\n * Setter for label attribute.\n * @param {string} value The URL to set as the upload URL.\n */\n set uploadUrl(value) {\n this.setAttribute('upload-url', value);\n }\n\n /**\n * Gets the upload URL for the file upload element.\n * @returns {string} The upload URL for the file upload element.\n */\n get uploadUrl() {\n return this.getAttribute('upload-url') ?? '/upload';\n }\n\n /**\n * Sets the autoProcessFiles attribute.\n * @param value\n */\n set autoProcessFiles(value) {\n this.setAttribute('auto-process-files', value);\n }\n\n /**\n * Gets the autoProcessFiles attribute.\n * @returns {any|boolean}\n */\n get autoProcessFiles() {\n return JSON.parse(this.getAttribute('auto-process-files')) ?? true;\n }\n\n /**\n * Sets the noUploadButton attribute.\n * @param value\n */\n set noUploadButton(value) {\n this.setAttribute('no-upload-button', value);\n }\n\n /**\n * Gets the noUploadButton attribute.\n * @returns {boolean}\n */\n get noUploadButton() {\n return this.hasAttribute('no-upload-button');\n }\n\n /**\n * Sets the uploaded files.\n * @param value\n */\n set uploadedFiles(value) {\n this._uploadedFiles = value;\n }\n\n /**\n * Return the uploaded files.\n * @returns {[]}\n */\n get uploadedFiles() {\n return this._uploadedFiles;\n }\n\n /**\n * Sets the to-chunk attribute.\n * @param value\n */\n set toChunk(value) {\n this.setAttribute('to-chunk', value);\n }\n\n /**\n * Gets the to-chunk attribute.\n * @returns {boolean}\n */\n get toChunk() {\n return this.hasAttribute('to-chunk');\n }\n\n /**\n * Sets the maximum number of files that can be uploaded or managed.\n * Assigns the specified value to the 'max-files' attribute.\n * @param {number} value The maximum allowable number of files.\n */\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n /**\n * Retrieves the maximum number of files allowed from the `max-files` attribute.\n * If the attribute is not set or is invalid, defaults to 0.\n * @returns {number} The maximum number of files allowed.\n */\n get maxFiles() {\n return parseInt(this.getAttribute('max-files')) || 1;\n }\n\n className = 'FileUpload';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are observed.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Method to setup attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n beforeDraw() {\n this.uploadFunction = upload(this.uploadUrl, this.chunkSize, !this.toChunk);\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload');\n native.setAttribute('part', 'native');\n\n let label = document.createElement('div');\n label.setAttribute('part', 'file-label');\n label.classList.add('file-label');\n\n let fileList = document.createElement('slot');\n fileList.setAttribute('name', 'item');\n fileList.setAttribute('part', 'items');\n fileList.classList.add('file-list');\n\n let slot = document.createElement('slot');\n label.appendChild(slot);\n\n let fileInput = document.createElement('input');\n fileInput.setAttribute('type', 'file');\n fileInput.setAttribute('multiple', '');\n fileInput.setAttribute('style', 'display:none;');\n\n if (!this.noUploadButton) {\n let button = document.createElement('wje-button');\n button.innerText = this.label || this.localizer.translate('wj.file.upload.button');\n button.setAttribute('part', 'upload-button');\n\n label.appendChild(button);\n\n this.button = button;\n }\n\n native.appendChild(fileInput);\n native.appendChild(label);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the component is drawn.\n */\n afterDraw() {\n this.button?.addEventListener('click', () => {\n this.fileInput.click();\n });\n\n this.fileInput.addEventListener('change', this.handleInputChange);\n this.native.addEventListener('drop', this.handleDrop);\n\n let dragEventCounter = 0;\n\n this.native.addEventListener('dragenter', (event) => {\n event.preventDefault();\n\n if (dragEventCounter === 0) {\n this.native.classList.add('highlight');\n }\n\n dragEventCounter += 1;\n });\n\n this.native.addEventListener('dragover', (event) => {\n event.preventDefault();\n\n if (dragEventCounter === 0) {\n dragEventCounter = 1;\n }\n });\n\n this.native.addEventListener('dragleave', (event) => {\n event.preventDefault();\n\n dragEventCounter -= 1;\n\n if (dragEventCounter <= 0) {\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n }\n });\n\n this.native.addEventListener('drop', (event) => {\n event.preventDefault();\n\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n });\n }\n\n /**\n * Method to handle form submission.\n * @param {Event} event The form submission event.\n */\n handleSubmit(event) {\n event.preventDefault();\n\n // TODO: TU TREBA PRIDAT ZOBRAZENIE SUBORU A JEHO PROCESSU\n\n this.addFilesToQueue(this.fileInput.files);\n }\n\n /**\n * Method to handle file drop event.\n * @param {Event} event The file drop event object.\n */\n handleDrop = (event) => {\n const fileList = event.dataTransfer.files;\n\n this.resetFormState();\n\n this.addFilesToQueue(fileList);\n };\n\n /**\n * Method to handle file input change event.\n * @param {Event} event The file input change event object.\n */\n handleInputChange = (event) => {\n this.resetFormState();\n\n try {\n this.handleSubmit(event);\n } catch (err) {}\n };\n\n /**\n * Method to add files to the queue.\n * @param files\n */\n addFilesToQueue(files) {\n if (this.maxFiles && files.length > this.maxFiles) {\n this.dispatchEvent(\n new CustomEvent('file-upload:error', {\n detail: {\n type: 'max-files-exceeded',\n max: this.maxFiles,\n received: files.length,\n },\n bubbles: true,\n composed: true,\n })\n );\n return; // stop processing\n }\n\n this._queuedFiles = [...files];\n\n this.dispatchEvent(\n new CustomEvent('file-upload:files-added', { detail: files, bubbles: true, composed: true })\n );\n this.onAddedFiles?.();\n\n if (this.autoProcessFiles) {\n this.uploadFiles();\n }\n\n this.fileInput.value = '';\n }\n\n /**\n * Method to upload files.\n */\n uploadFiles() {\n if (this._queuedFiles.length === 0) {\n return;\n }\n\n const uploadPromises = this._queuedFiles.map((file) => this.createUploadPromise(file));\n uploadPromises\n .reduce((prev, curr) => {\n return prev.then(() => {\n return curr;\n });\n }, Promise.resolve())\n .then(() => {\n this.dispatchEvent(\n new CustomEvent('file-upload:all-files-uploaded', {\n detail: this.uploadedFiles,\n bubbles: true,\n composed: true,\n })\n );\n this.onAllFilesUploaded?.();\n this._queuedFiles = [];\n });\n }\n\n /**\n * Method to create an upload promise.\n * @param file\n * @returns {Promise<unknown>}\n */\n createUploadPromise = (file) => {\n return new Promise((resolve, reject) => {\n this.assertFilesValid(file);\n let preview;\n\n let reader = new FileReader();\n reader.onload = (e) => {\n this.dispatchEvent(\n new CustomEvent('file-upload:upload-started', { detail: file, bubbles: true, composed: true })\n );\n this.onUploadStarted?.(file);\n\n preview = this.createPreview(file, reader);\n this.appendChild(preview);\n\n this.uploadFunction(file, preview).then((res) => {\n res.item = preview;\n\n console.log(res);\n\n this.dispatchEvent(\n new CustomEvent('file-upload:upladed-file-complete', {\n detail: res,\n bubbles: true,\n composed: true,\n })\n );\n this.onUploadedFileComplete?.(res);\n this.uploadedFiles.push(res.data);\n\n resolve(res);\n });\n };\n\n reader.readAsDataURL(file);\n });\n };\n\n /**\n * Method to create a preview for the file.\n * @param {File} file The file for which the preview is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created preview.\n */\n createPreview(file, reader) {\n let preview = document.createElement('wje-file-upload-item');\n preview.setAttribute('slot', 'item');\n preview.setAttribute('name', file.name);\n preview.setAttribute('size', file.size);\n preview.setAttribute('uploaded', '0');\n preview.setAttribute('progress', '0');\n preview.innerHTML = `<wje-icon slot=\"img\" name=\"${getFileTypeIcon(file.type.split('/')[1])}\" size=\"large\"></wje-icon>`;\n\n return preview;\n }\n\n /**\n * Method to create a thumbnail for the file.\n * @param {File} file The file for which the thumbnail is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created thumbnail.\n */\n createThumbnail(file, reader) {\n let img = document.createElement('img');\n img.setAttribute('src', reader.result);\n\n return img;\n }\n\n /**\n * Method to validate the files.\n * @param {File} file The file to be validated.\n * TODO: alowed types a size limit by malo byt cez attributy\n */\n assertFilesValid(file) {\n const { name: fileName, size: fileSize } = file;\n if (!isValidFileType(file, this.acceptedTypes)) {\n throw new Error(`❌ FILE: \"${fileName}\" Valid file types are: \"${this.acceptedTypes}\"`);\n }\n\n if (fileSize > this.maxFileSize) {\n throw new Error(\n `❌ File \"${fileName}\" could not be uploaded. Only images up to ${this.maxFileSize} MB are allowed. Nie je to ${fileSize}`\n );\n }\n }\n\n /**\n * Method to reset the form state.\n */\n resetFormState() {\n this.fileList.textContent = '';\n }\n}\n","import FileUpload from './file-upload.element.js';\n\nexport default FileUpload;\n\nFileUpload.define('wje-file-upload', FileUpload);\n"],"names":["response","_a"],"mappings":";;;;;;AAeA,SAAS,WAAW;AAChB,SAAO;AAAA,IACH;AAAA,MACI,MAAM,CAAC,OAAO,Q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,MAAM,SAAU,IAAG;AAC3C,QAAI,CAAC,gBAAgB,MAAM,KAAK,aAAa,GAAG;AAC5C,YAAM,IAAI,MAAM,YAAY,QAAQ,4BAA4B,KAAK,aAAa,GAAG;AAAA,IACjG;AAEQ,QAAI,WAAW,KAAK,aAAa;AAC7B,YAAM,IAAI;AAAA,QACN,WAAW,QAAQ,8CAA8C,KAAK,WAAW,8BAA8B,QAAQ;AAAA,MAC1H;AAAA,IACb;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,iBAAiB;AACb,SAAK,SAAS,cAAc;AAAA,EACpC;AACA;ACrgBA,WAAW,OAAO,mBAAmB,UAAU;"}
1
+ {"version":3,"file":"wje-file-upload.js","sources":["../packages/wje-file-upload/service/service.js","../packages/wje-file-upload/file-upload.element.js","../packages/wje-file-upload/file-upload.js"],"sourcesContent":["/**\n * Returns a list of file type categories and their corresponding icon names.\n * @returns {Array<object>} An array of objects representing file type categories.\n * Each object contains the following properties:\n * - `type` {Array&lt;string>} A list of file extensions associated with the category.\n * - `name` {string} The name of the icon representing the category.\n * @example\n * const types = fileType();\n * console.log(types);\n * // [\n * // { type: [\"jpg\", \"jpeg\", \"png\", \"gif\", \"bpm\", \"tiff\", \"svg\"], name: \"photo\" },\n * // { type: [\"zip\", \"rar\", \"cab\", \"jar\", \"tar\", \"gzip\", \"uue\", \"bz2\", \"scorm\", \"war\"], name: \"file-type-zip\" },\n * // ...\n * // ]\n */\nfunction fileType() {\n return [\n {\n type: ['jpg', 'jpeg', 'png', 'gif', 'bpm', 'tiff', 'svg'],\n name: 'photo',\n },\n {\n type: ['zip', 'rar', 'cab', 'jar', 'tar', 'gzip', 'uue', 'bz2', 'scorm', 'war'],\n name: 'file-type-zip',\n },\n {\n type: ['mov', 'mp4', 'avi', 'flv'],\n name: 'video',\n },\n {\n type: ['m4a', 'mp3', 'wav'],\n name: 'audio',\n },\n {\n type: ['html', 'html'],\n name: 'file-type-html',\n },\n {\n type: ['css'],\n name: 'code',\n },\n {\n type: ['txt'],\n name: 'file-type-txt',\n },\n {\n type: ['doc', 'docx'],\n name: 'file-type-doc',\n },\n {\n type: ['xls', 'xlsx'],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: ['ppt', 'pptx', 'odp'],\n name: 'file-type-ppt',\n },\n ];\n}\n\n/**\n * Retrieves the icon name for a given file type.\n * @param {string} type The file type or category (e.g., \"pdf\", \"image\", \"folder\").\n * @returns {string} The name of the icon associated with the file type.\n * @example\n * getFileTypeIcon('pdf'); // Returns the icon name for PDF files.\n * getFileTypeIcon('folder'); // Returns 'folder'.\n */\nexport function getFileTypeIcon(type) {\n let searchType;\n if (type.toLowerCase() !== 'folder') {\n fileType().forEach((i) => {\n if (i.type.includes(type.toLowerCase())) {\n searchType = i.name;\n }\n });\n } else {\n searchType = 'folder';\n }\n\n return searchType;\n}\n\n/**\n * Returns a function for uploading files either in chunks or as a whole file, based on the provided options.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {number} [chunkSize] The size of each chunk in bytes when uploading in chunks (default is 1MB).\n * @param {boolean} [wholeFile] Whether to upload the file as a whole. If `true`, the entire file is uploaded at once.\n * @returns {Function} A function that takes a file and a preview element as arguments and uploads the file.\n * @example\n * // Upload a file in chunks\n * const uploadInChunks = upload('/upload', 1024 * 512); // 512KB chunks\n * uploadInChunks(file, previewElement);\n * @example\n * // Upload a whole file\n * const uploadWhole = upload('/upload', undefined, true);\n * uploadWhole(file, previewElement);\n */\nexport function upload(url, chunkSize = 1024 * 1024, wholeFile = false) {\n if (wholeFile) {\n return (file, preview) => uploadWholeFile(url, file, preview);\n }\n return (file, preview) => uploadFileInChunks(url, file, preview, chunkSize);\n}\n\n/**\n * Uploads a file in chunks to a specified URL, allowing for progress tracking and resuming in case of errors.\n * @param {string} url The URL to which the file chunks will be uploaded.\n * @param {File} file The file to be uploaded in chunks.\n * @param {HTMLElement} preview The element used to display upload progress.\n * @param {number} [chunkSize] The size of each chunk in bytes (default is 1MB).\n * @returns {Promise<object>} Resolves with the response of the last chunk uploaded, parsed as JSON.\n * @throws {Error} - Throws an error if a chunk fails to upload.\n */\nexport async function uploadFileInChunks(url, file, preview, chunkSize = 1024 * 1024) {\n let offset = 0;\n const totalChunks = Math.ceil(file.size / chunkSize);\n const partResponses = [];\n\n while (offset < file.size) {\n const chunk = file.slice(offset, offset + chunkSize);\n\n // Creating a custom ReadableStream to track progress of the current chunk\n const stream = new ReadableStream({\n start(controller) {\n const reader = chunk.stream().getReader();\n let uploadedBytes = 0;\n\n reader.read().then(function process({ done, value }) {\n if (done) {\n controller.close();\n return Promise.resolve();\n }\n\n // Track progress\n uploadedBytes += value.byteLength;\n const percentComplete = ((offset + uploadedBytes) / file.size) * 100;\n preview.setAttribute('uploaded', offset + uploadedBytes);\n\n // Enqueue chunk data into the stream\n controller.enqueue(value);\n\n // Read the next chunk\n return reader.read().then(process);\n });\n },\n });\n\n const formData = new FormData();\n formData.append('file', new Blob([stream])); // Send the current stream (chunk)\n formData.append('chunkIndex', Math.floor(offset / chunkSize)); // Send chunk index\n formData.append('totalChunks', totalChunks); // Send total chunks\n formData.append('fileName', file.name); // Send file name\n\n try {\n // Send the current chunk via Fetch\n const response = await fetch(url, {\n method: 'POST',\n body: formData,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to upload chunk ${Math.floor(offset / chunkSize) + 1}: ${response.statusText}`);\n }\n\n partResponses.push(response);\n } catch (error) {\n console.error('Error uploading chunk:', error);\n break;\n }\n\n // Move to the next chunk\n offset += chunkSize;\n }\n\n const response = await partResponses.at(-1).json();\n\n return {\n data: response,\n file,\n };\n}\n\n/**\n * Uploads a file to a specified URL using a `POST` request and updates the preview element with the uploaded file size.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {File} file The file to be uploaded.\n * @param {HTMLElement} preview The element that displays the upload preview. It will be updated with the file size.\n * @returns {Promise<{data: object, file: File}>} - A promise that resolves with the server response and the uploaded file.\n * @throws {Error} - Logs an error to the console if the request fails.\n */\nexport function uploadWholeFile(url, file, preview) {\n const formData = new FormData();\n formData.append('file', file);\n\n //use fetch\n return fetch(url, {\n method: 'POST',\n body: formData,\n })\n .then((response) => response.json())\n .then((data) => {\n preview.setAttribute('uploaded', file.size);\n return {\n data,\n file,\n };\n })\n .catch((error) => {\n console.error('Error:', error);\n });\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport Button from '../wje-button/button.js';\nimport { isValidFileType } from '../utils/utils.js';\nimport { getFileTypeIcon, upload } from './service/service.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary FileUpload is a custom web component for uploading files.\n * It extends from WJElement and provides functionalities for file upload.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @csspart native - The native file upload part.\n * @csspart file-list - The file list part.\n * @csspart upload-button - The label part.\n * @event change - Fires when the file input changes.\n * @event drop - Fires when a file is dropped into the component.\n * @attribute {string} accepted-types - The accepted file types for upload.\n * @attribute {number} chunk-size - The chunk size for file upload.\n * @attribute {number} max-file-size - The maximum file size for upload.\n * @attribute {string} upload-url - The URL to set as the upload URL.\n * @attribute {boolean} auto-process-files - The auto process files attribute.\n * @attribute {boolean} no-upload-button - The no upload button attribute.\n * @tag wje-file-upload\n */\nexport default class FileUpload extends WJElement {\n /**\n * Constructor for FileUpload.\n * Initializes a new instance of the Localizer.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n this._uploadedFiles = [];\n this._queuedFiles = [];\n }\n\n /**\n * Dependencies for the FileUpload component.\n * @type {object}\n */\n dependencies = {\n 'wje-button': Button,\n };\n\n /**\n * Setter for acceptedTypes attribute.\n * @param {string} value The accepted file types for upload.\n */\n set acceptedTypes(value) {\n this.setAttribute('accepted-types', value);\n }\n\n /**\n * Getter for acceptedTypes attribute.\n * @returns {string} The accepted file types for upload.\n */\n get acceptedTypes() {\n const accepted = this.getAttribute('accepted-types');\n return this.hasAttribute('accepted-types') ? accepted : 'image/*';\n }\n\n /**\n * Setter for chunkSize attribute.\n * @param {number} value The chunk size for file upload.\n */\n set chunkSize(value) {\n this.setAttribute('chunk-size', value);\n }\n\n /**\n * Getter for chunkSize attribute.\n * @returns {number} The chunk size for file upload.\n */\n get chunkSize() {\n const chunk = this.getAttribute('chunk-size');\n return this.hasAttribute('chunk-size') ? chunk : 1024 * 1024;\n }\n\n /**\n * Setter for maxFileSize attribute.\n * @param {number} value The maximum file size for upload.\n */\n set maxFileSize(value) {\n this.setAttribute('max-file-size', value);\n }\n\n /**\n * Getter for maxFileSize attribute.\n * @returns {number} The maximum file size for upload.\n */\n get maxFileSize() {\n const fileSize = this.getAttribute('max-file-size');\n return this.hasAttribute('max-file-size') ? fileSize * 1024 * 1024 : 1024 * 1024;\n }\n\n /**\n * Setter for label attribute.\n * @param {string} value The URL to set as the upload URL.\n */\n set uploadUrl(value) {\n this.setAttribute('upload-url', value);\n }\n\n /**\n * Gets the upload URL for the file upload element.\n * @returns {string} The upload URL for the file upload element.\n */\n get uploadUrl() {\n return this.getAttribute('upload-url') ?? '/upload';\n }\n\n /**\n * Sets the autoProcessFiles attribute.\n * @param value\n */\n set autoProcessFiles(value) {\n this.setAttribute('auto-process-files', value);\n }\n\n /**\n * Gets the autoProcessFiles attribute.\n * @returns {any|boolean}\n */\n get autoProcessFiles() {\n return JSON.parse(this.getAttribute('auto-process-files')) ?? true;\n }\n\n /**\n * Sets the noUploadButton attribute.\n * @param value\n */\n set noUploadButton(value) {\n this.setAttribute('no-upload-button', value);\n }\n\n /**\n * Gets the noUploadButton attribute.\n * @returns {boolean}\n */\n get noUploadButton() {\n return this.hasAttribute('no-upload-button');\n }\n\n /**\n * Sets the uploaded files.\n * @param value\n */\n set uploadedFiles(value) {\n this._uploadedFiles = value;\n }\n\n /**\n * Return the uploaded files.\n * @returns {[]}\n */\n get uploadedFiles() {\n return this._uploadedFiles;\n }\n\n /**\n * Sets the to-chunk attribute.\n * @param value\n */\n set toChunk(value) {\n this.setAttribute('to-chunk', value);\n }\n\n /**\n * Gets the to-chunk attribute.\n * @returns {boolean}\n */\n get toChunk() {\n return this.hasAttribute('to-chunk');\n }\n\n /**\n * Sets the maximum number of files that can be uploaded or managed.\n * Assigns the specified value to the 'max-files' attribute.\n * @param {number} value The maximum allowable number of files.\n */\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n /**\n * Sets the label attribute for the upload button.\n * @param {string} value\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Gets the label attribute for the upload button.\n * @returns {string}\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Retrieves the maximum number of files allowed from the `max-files` attribute.\n * If the attribute is not set or is invalid, defaults to 0.\n * @returns {number} The maximum number of files allowed.\n */\n get maxFiles() {\n return parseInt(this.getAttribute('max-files')) || 10;\n }\n\n className = 'FileUpload';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are observed.\n */\n static get observedAttributes() {\n return ['label'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'label' && this.button) {\n const nextLabel = this.label || this.localizer.translate('wj.file.upload.button');\n this.button.innerText = nextLabel;\n this.button.setAttribute('aria-label', nextLabel);\n }\n }\n\n /**\n * Method to setup attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'group',\n });\n }\n\n beforeDraw() {\n this.uploadFunction = upload(this.uploadUrl, this.chunkSize, !this.toChunk);\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload');\n native.setAttribute('part', 'native');\n\n let label = document.createElement('div');\n label.setAttribute('part', 'file-label');\n label.classList.add('file-label');\n\n let fileList = document.createElement('slot');\n fileList.setAttribute('name', 'item');\n fileList.setAttribute('part', 'items');\n fileList.classList.add('file-list');\n\n let slot = document.createElement('slot');\n label.appendChild(slot);\n\n let fileInput = document.createElement('input');\n fileInput.setAttribute('type', 'file');\n fileInput.setAttribute('multiple', '');\n fileInput.setAttribute('style', 'display:none;');\n fileInput.setAttribute('aria-hidden', 'true');\n\n if (!this.noUploadButton) {\n let button = document.createElement('wje-button');\n button.innerText = this.label || this.localizer.translate('wj.file.upload.button');\n button.setAttribute('part', 'upload-button');\n button.setAttribute('aria-label', button.innerText);\n\n label.appendChild(button);\n\n this.button = button;\n }\n\n native.appendChild(fileInput);\n native.appendChild(label);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the component is drawn.\n */\n afterDraw() {\n this.button?.addEventListener('click', () => {\n this.fileInput.click();\n });\n\n this.fileInput.addEventListener('change', this.handleInputChange);\n this.native.addEventListener('drop', this.handleDrop);\n\n let dragEventCounter = 0;\n\n this.native.addEventListener('dragenter', (e) => {handleInputChange\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n this.native.classList.add('highlight');\n }\n\n dragEventCounter += 1;\n });\n\n this.native.addEventListener('dragover', (e) => {\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n dragEventCounter = 1;\n }\n });\n\n this.native.addEventListener('dragleave', (e) => {\n e.preventDefault();\n\n dragEventCounter -= 1;\n\n if (dragEventCounter <= 0) {\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n }\n });\n\n this.native.addEventListener('drop', (e) => {\n event.preventDefault();\n\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n });\n\n this.addEventListener('wje-file-upload-item:remove', (e) => {\n const file = e.detail;\n\n if (!(file instanceof File)) {\n return;\n }\n\n let count = this.uploadedFiles.length;\n\n this.uploadedFiles = this.uploadedFiles.filter((entry) => {\n return entry?.file?.lastModified !== file.lastModified;\n });\n\n if(count !== this.uploadedFiles.length)\n event.dispatchCustomEvent(this, 'wje-file-upload:file-removed', file);\n });\n }\n\n /**\n * Method to handle form submission.\n * @param {Event} e The form submission event.\n */\n handleSubmit(e) {\n e.preventDefault();\n\n this.addFilesToQueue(this.fileInput.files);\n }\n\n /**\n * Method to handle file drop event.\n * @param {Event} e The file drop event object.\n */\n handleDrop = (e) => {\n const fileList = e.dataTransfer.files;\n\n this.resetFormState();\n\n this.addFilesToQueue(fileList);\n };\n\n /**\n * Method to handle file input change event.\n * @param {Event} e The file input change event object.\n */\n handleInputChange = (e) => {\n const files = Array.from(e.target.files);\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-selected', files);\n\n this.resetFormState();\n\n try {\n this.handleSubmit(e);\n } catch (err) {\n console.error(err);\n }\n };\n\n /**\n * Method to add files to the queue.\n * @param files\n */\n addFilesToQueue(files) {\n const currentCount = (Array.isArray(this.uploadedFiles) ? this.uploadedFiles.length : 0) + (Array.isArray(this._queuedFiles) ? this._queuedFiles.length : 0);\n const newTotal = currentCount + files.length;\n\n if (this.maxFiles && newTotal > this.maxFiles) {\n const detail = {\n code: 'MAX-FILES-EXCEEDED',\n files,\n maxFiles: this.maxFiles,\n currentCount,\n attemptedToAdd: files.length,\n allowedRemaining: Math.max(this.maxFiles - currentCount, 0),\n };\n\n event.dispatchCustomEvent(this, 'wje-file-upload:error', detail);\n\n return;\n }\n\n this._queuedFiles = [...(this._queuedFiles || []), ...files];\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-added', files);\n\n this.onAddedFiles?.();\n\n if (this.autoProcessFiles) {\n this.uploadFiles();\n }\n\n this.fileInput.value = '';\n }\n\n /**\n * Method to upload files.\n */\n uploadFiles() {\n if (this._queuedFiles.length === 0) {\n return;\n }\n\n const uploadPromises = this._queuedFiles.map((file) => this.createUploadPromise(file));\n uploadPromises\n .reduce((prev, curr) => {\n return prev.then(() => {\n return curr;\n });\n }, Promise.resolve())\n .then(() => {\n event.dispatchCustomEvent(this, 'wje-file-upload:files-uploaded', this.uploadedFiles);\n\n this.onAllFilesUploaded?.();\n this._queuedFiles = [];\n }).catch((err) => {\n this._queuedFiles = this._queuedFiles.filter((file) => file !== err.file);\n\n event.dispatchCustomEvent(this,'wje-file-upload:error', err);\n });\n }\n\n /**\n * Method to create an upload promise.\n * @param file\n * @returns {Promise<unknown>}\n */\n createUploadPromise = (file) => {\n return new Promise((resolve, reject) => {\n this.assertFilesValid(file);\n let preview;\n\n let reader = new FileReader();\n reader.onload = () => {\n event.dispatchCustomEvent(this, 'wje-file-upload:started', file);\n\n this.onUploadStarted?.(file);\n\n preview = this.createPreview(file, reader);\n this.appendChild(preview);\n\n this.uploadFunction(file, preview).then((res) => {\n res.item = preview;\n\n event.dispatchCustomEvent(this, 'wje-file-upload:file-uploaded', res);\n\n this.onUploadedFileComplete?.(res);\n\n this.uploadedFiles.push(res);\n\n resolve(res);\n });\n };\n\n reader.readAsDataURL(file);\n });\n };\n\n /**\n * Method to create a preview for the file.\n * @param {File} file The file for which the preview is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created preview.\n */\n createPreview(file, reader) {\n let preview = document.createElement('wje-file-upload-item');\n preview.setAttribute('slot', 'item');\n preview.setAttribute('name', file.name);\n preview.setAttribute('size', file.size);\n preview.setAttribute('uploaded', '0');\n preview.innerHTML = `<wje-icon slot=\"img\" name=\"${getFileTypeIcon(file.type.split('/')[1])}\" size=\"large\"></wje-icon>`;\n preview.data = file;\n\n return preview;\n }\n\n /**\n * Method to create a thumbnail for the file.\n * @param {File} file The file for which the thumbnail is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created thumbnail.\n */\n createThumbnail(file, reader) {\n let img = document.createElement('img');\n img.setAttribute('src', reader.result);\n\n return img;\n }\n\n /**\n * Method to validate the files.\n * @param {File} file The file to be validated.\n * TODO: alowed types a size limit by malo byt cez attributy\n */\n assertFilesValid(file) {\n const { name: fileName, size: fileSize } = file;\n\n if (!isValidFileType(file, this.acceptedTypes)) {\n const err = new Error('');\n err.code = 'INVALID-FILE-TYPE';\n err.file = file;\n err.acceptedTypes = this.acceptedTypes;\n\n throw err;\n }\n\n if (fileSize > this.maxFileSize) {\n const err = new Error('');\n err.code = 'FILE-TOO-LARGE';\n err.file = file;\n err.maxFileSize = this.maxFileSize;\n\n throw err;\n }\n }\n\n /**\n * Method to reset the form state.\n */\n resetFormState() {\n this.fileList.textContent = '';\n }\n}\n","import FileUpload from './file-upload.element.js';\n\nexport default FileUpload;\n\nFileUpload.define('wje-file-upload', FileUpload);\n"],"names":["response","_a"],"mappings":";;;;;;;;AAeA,SAAS,WAAW;AAChB,SAAO;AAAA,IACH;AAAA,MACI,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ,KAAK;AAAA,MACxD,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,KAAK;AAAA,MAC9E,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,KAAK;AAAA,MACjC,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,KAAK;AAAA,MAC1B,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,OAAO,MAAM;AAAA,MACpB,MAAM;AAAA,IACT;AAAA,IACD;AAAA,MACI,MAAM,CAAC,OAAO,MAAM;AAAA,MACpB,MAAM;AAAA,IACT;AAAA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B;AAEQ,QAAI,WAAW,KAAK,aAAa;AAC7B,YAAM,MAAM,IAAI,MAAM,EAAE;AACxB,UAAI,OAAO;AACX,UAAI,OAAO;AACX,UAAI,cAAc,KAAK;AAEvB,YAAM;AAAA,IAClB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,iBAAiB;AACb,SAAK,SAAS,cAAc;AAAA,EACpC;AACA;AC7jBA,WAAW,OAAO,mBAAmB,UAAU;"}
@@ -67,6 +67,7 @@ export default class FormatDigital extends WJElement {
67
67
  * @returns {string} - The current unit display style.
68
68
  */
69
69
  get unitDisplay(): string;
70
+ attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
70
71
  /**
71
72
  * Prepares the component before rendering.
72
73
  * Computes the formatted value based on the input value and unit.
@@ -80,4 +81,5 @@ export default class FormatDigital extends WJElement {
80
81
  * @returns {DocumentFragment} - The DOM structure for the component.
81
82
  */
82
83
  draw(): DocumentFragment;
84
+ formatted: HTMLSpanElement;
83
85
  }
@@ -89,12 +89,20 @@ class FormatDigital extends WJElement {
89
89
  static get observedAttributes() {
90
90
  return ["value", "unit-display"];
91
91
  }
92
+ attributeChangedCallback(name, oldValue, newValue) {
93
+ var _a;
94
+ (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, name, oldValue, newValue);
95
+ if (oldValue === newValue) return;
96
+ this.beforeDraw();
97
+ if (this.formatted) this.formatted.innerText = this.formattedValue;
98
+ }
92
99
  /**
93
100
  * Sets up the attributes for the component.
94
101
  * Initializes the shadow DOM.
95
102
  */
96
103
  setupAttributes() {
97
104
  this.isShadowRoot = "open";
105
+ this.setAriaState({ role: "status" });
98
106
  }
99
107
  /**
100
108
  * Prepares the component before rendering.
@@ -136,6 +144,7 @@ class FormatDigital extends WJElement {
136
144
  element.appendChild(formatted);
137
145
  element.appendChild(end);
138
146
  fragment.appendChild(element);
147
+ this.formatted = formatted;
139
148
  return fragment;
140
149
  }
141
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wje-format-digital.js","sources":["../packages/wje-format-digital/format-digital.element.js","../packages/wje-format-digital/format-digital.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element formats and displays digital values such as file sizes or data transfer rates.\n * `FormatDigital` is a custom web component that represents a formatted digital value with units like\n * bytes or bits. It extends from `WJElement` and utilizes the `Localizer` class for locale-aware formatting.\n * @documentation https://elements.webjet.sk/components/format-digital\n * @status stable\n * @augments {WJElement}\n * @attribute {number} value - The numeric value to format (e.g., 1024 for 1 KB).\n * @attribute {string} unit - The unit of the value (`byte` or `bit`). Defaults to `byte`.\n * @attribute {string} unitDisplay - The display style of the unit (`short`, `long`, or `narrow`). Defaults to `short`.\n * @csspart native - The native part of the component.\n * @csspart formatted - The part representing the formatted value.\n * @csspart start - Slot for content before the formatted value.\n * @csspart end - Slot for content after the formatted value.\n * @tag wje-format-digital\n */\n\nexport default class FormatDigital extends WJElement {\n /**\n * Creates an instance of FormatDigital.\n * Initializes the `Localizer` for locale-specific formatting.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n /**\n * Sets the value of the digital format.\n * This value determines the size in bytes or bits to be displayed.\n * @param {number} value The value to set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Returns the value of the digital format.\n * @returns {number} The current value of the component.\n */\n get value() {\n return +this.getAttribute('value');\n }\n\n /**\n * Sets the unit of the digital format.\n * Valid values are `bit` or `byte`.\n * @param {string} value The unit to set.\n */\n set unit(value) {\n this.removeAttribute('unit');\n if (value) {\n this.setAttribute('unit', value);\n }\n }\n\n /**\n * Returns the unit of the digital format.\n * Defaults to `byte` if no unit is set.\n * @returns {string} The current unit (`bit` or `byte`).\n */\n get unit() {\n return this.hasAttribute('unit') ? this.getAttribute('unit') : 'byte';\n }\n\n /**\n * Sets the unit display style for the digital format.\n * Valid values are `short`, `long`, or `narrow`.\n * @param {string} value The unit display style to set.\n */\n set unitDisplay(value) {\n this.removeAttribute('unit-display');\n if (value) {\n this.setAttribute('unit-display', value);\n }\n }\n\n /**\n * Returns the unit display style for the digital format.\n * Defaults to `short` if not set.\n * @returns {string} - The current unit display style.\n */\n get unitDisplay() {\n return this.hasAttribute('unit-display') ? this.getAttribute('unit-display') : 'short';\n }\n\n /**\n * The class name identifier for this component.\n * @type {string}\n */\n className = 'FormatDigital';\n\n /**\n * Returns the CSS styles for the component.\n * Encapsulated using shadow DOM.\n * @static\n * @returns {CSSStyleSheet} - The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * Observes `value` and `unit-display` for re-rendering.\n * @static\n * @returns {Array<string>} - The attributes to observe.\n */\n static get observedAttributes() {\n return ['value', 'unit-display'];\n }\n\n /**\n * Sets up the attributes for the component.\n * Initializes the shadow DOM.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component before rendering.\n * Computes the formatted value based on the input value and unit.\n */\n beforeDraw() {\n if (this.value < 0) return;\n const bitPrefixes = ['', 'kilo', 'mega', 'giga', 'tera'];\n const bytePrefixes = ['', 'kilo', 'mega', 'giga', 'tera', 'peta'];\n const prefix = this.unit === 'bit' ? bitPrefixes : bytePrefixes;\n const index = Math.max(0, Math.min(Math.floor(Math.log10(this.value) / 3), prefix.length - 1)) || 0;\n const unit = prefix[index] + this.unit;\n const value = parseFloat((this.value / Math.pow(1000, index)).toPrecision(3));\n\n this.formattedValue = this.localizer.formatNumber(value, {\n style: 'unit',\n unit: unit,\n unitDisplay: this.unitDisplay || 'short',\n });\n }\n\n /**\n * Renders the component and returns a document fragment.\n * The rendered structure includes a formatted value wrapped in a container\n * with slots for additional customization.\n * @returns {DocumentFragment} - The DOM structure for the component.\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-format-digital');\n\n let formatted = document.createElement('span');\n formatted.setAttribute('part', 'formatted');\n formatted.innerText = this.formattedValue;\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n element.appendChild(start);\n element.appendChild(formatted);\n element.appendChild(end);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import FormatDigital from './format-digital.element.js';\n\nexport default FormatDigital;\n\nFormatDigital.define('wje-format-digital', FormatDigital);\n"],"names":[],"mappings":";;;;;;AAqBe,MAAM,sBAAsB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjD,cAAc;AACV,UAAO;AAmEX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAlER,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,CAAC,KAAK,aAAa,OAAO;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,KAAK,OAAO;AACZ,SAAK,gBAAgB,MAAM;AAC3B,QAAI,OAAO;AACP,WAAK,aAAa,QAAQ,KAAK;AAAA,IAC3C;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,OAAO;AACP,WAAO,KAAK,aAAa,MAAM,IAAI,KAAK,aAAa,MAAM,IAAI;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,YAAY,OAAO;AACnB,SAAK,gBAAgB,cAAc;AACnC,QAAI,OAAO;AACP,WAAK,aAAa,gBAAgB,KAAK;AAAA,IACnD;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,cAAc;AACd,WAAO,KAAK,aAAa,cAAc,IAAI,KAAK,aAAa,cAAc,IAAI;AAAA,EACvF;AAAA;A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Aa,QAAQ,OAAO;AAElC,QAAI,MAAM,SAAS,cAAc,MAAM;AACvC,QAAI,aAAa,QAAQ,KAAK;AAE9B,YAAQ,YAAY,KAAK;AACzB,YAAQ,YAAY,SAAS;AAC7B,YAAQ,YAAY,GAAG;AAEvB,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACf;AACA;AC3KA,cAAc,OAAO,sBAAsB,aAAa;"}
1
+ {"version":3,"file":"wje-format-digital.js","sources":["../packages/wje-format-digital/format-digital.element.js","../packages/wje-format-digital/format-digital.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element formats and displays digital values such as file sizes or data transfer rates.\n * `FormatDigital` is a custom web component that represents a formatted digital value with units like\n * bytes or bits. It extends from `WJElement` and utilizes the `Localizer` class for locale-aware formatting.\n * @documentation https://elements.webjet.sk/components/format-digital\n * @status stable\n * @augments {WJElement}\n * @attribute {number} value - The numeric value to format (e.g., 1024 for 1 KB).\n * @attribute {string} unit - The unit of the value (`byte` or `bit`). Defaults to `byte`.\n * @attribute {string} unitDisplay - The display style of the unit (`short`, `long`, or `narrow`). Defaults to `short`.\n * @csspart native - The native part of the component.\n * @csspart formatted - The part representing the formatted value.\n * @csspart start - Slot for content before the formatted value.\n * @csspart end - Slot for content after the formatted value.\n * @tag wje-format-digital\n */\n\nexport default class FormatDigital extends WJElement {\n /**\n * Creates an instance of FormatDigital.\n * Initializes the `Localizer` for locale-specific formatting.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n /**\n * Sets the value of the digital format.\n * This value determines the size in bytes or bits to be displayed.\n * @param {number} value The value to set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Returns the value of the digital format.\n * @returns {number} The current value of the component.\n */\n get value() {\n return +this.getAttribute('value');\n }\n\n /**\n * Sets the unit of the digital format.\n * Valid values are `bit` or `byte`.\n * @param {string} value The unit to set.\n */\n set unit(value) {\n this.removeAttribute('unit');\n if (value) {\n this.setAttribute('unit', value);\n }\n }\n\n /**\n * Returns the unit of the digital format.\n * Defaults to `byte` if no unit is set.\n * @returns {string} The current unit (`bit` or `byte`).\n */\n get unit() {\n return this.hasAttribute('unit') ? this.getAttribute('unit') : 'byte';\n }\n\n /**\n * Sets the unit display style for the digital format.\n * Valid values are `short`, `long`, or `narrow`.\n * @param {string} value The unit display style to set.\n */\n set unitDisplay(value) {\n this.removeAttribute('unit-display');\n if (value) {\n this.setAttribute('unit-display', value);\n }\n }\n\n /**\n * Returns the unit display style for the digital format.\n * Defaults to `short` if not set.\n * @returns {string} - The current unit display style.\n */\n get unitDisplay() {\n return this.hasAttribute('unit-display') ? this.getAttribute('unit-display') : 'short';\n }\n\n /**\n * The class name identifier for this component.\n * @type {string}\n */\n className = 'FormatDigital';\n\n /**\n * Returns the CSS styles for the component.\n * Encapsulated using shadow DOM.\n * @static\n * @returns {CSSStyleSheet} - The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * Observes `value` and `unit-display` for re-rendering.\n * @static\n * @returns {Array<string>} - The attributes to observe.\n */\n static get observedAttributes() {\n return ['value', 'unit-display'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (oldValue === newValue) return;\n this.beforeDraw();\n if (this.formatted) this.formatted.innerText = this.formattedValue;\n }\n\n /**\n * Sets up the attributes for the component.\n * Initializes the shadow DOM.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'status' });\n }\n\n /**\n * Prepares the component before rendering.\n * Computes the formatted value based on the input value and unit.\n */\n beforeDraw() {\n if (this.value < 0) return;\n const bitPrefixes = ['', 'kilo', 'mega', 'giga', 'tera'];\n const bytePrefixes = ['', 'kilo', 'mega', 'giga', 'tera', 'peta'];\n const prefix = this.unit === 'bit' ? bitPrefixes : bytePrefixes;\n const index = Math.max(0, Math.min(Math.floor(Math.log10(this.value) / 3), prefix.length - 1)) || 0;\n const unit = prefix[index] + this.unit;\n const value = parseFloat((this.value / Math.pow(1000, index)).toPrecision(3));\n\n this.formattedValue = this.localizer.formatNumber(value, {\n style: 'unit',\n unit: unit,\n unitDisplay: this.unitDisplay || 'short',\n });\n }\n\n /**\n * Renders the component and returns a document fragment.\n * The rendered structure includes a formatted value wrapped in a container\n * with slots for additional customization.\n * @returns {DocumentFragment} - The DOM structure for the component.\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-format-digital');\n\n let formatted = document.createElement('span');\n formatted.setAttribute('part', 'formatted');\n formatted.innerText = this.formattedValue;\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n element.appendChild(start);\n element.appendChild(formatted);\n element.appendChild(end);\n\n fragment.appendChild(element);\n this.formatted = formatted;\n\n return fragment;\n }\n}\n","import FormatDigital from './format-digital.element.js';\n\nexport default FormatDigital;\n\nFormatDigital.define('wje-format-digital', FormatDigital);\n"],"names":[],"mappings":";;;;;;AAqBe,MAAM,sBAAsB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjD,cAAc;AACV,UAAO;AAmEX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAlER,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,CAAC,KAAK,aAAa,OAAO;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,KAAK,OAAO;AACZ,SAAK,gBAAgB,MAAM;AAC3B,QAAI,OAAO;AACP,WAAK,aAAa,QAAQ,K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,KAAK,MAAM,KAAK,KAAK,IAAI,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC,KAAK;AAClG,UAAM,OAAO,OAAO,KAAK,IAAI,KAAK;AAClC,UAAM,QAAQ,YAAY,KAAK,QAAQ,KAAK,IAAI,KAAM,KAAK,GAAG,YAAY,CAAC,CAAC;AAE5E,SAAK,iBAAiB,KAAK,UAAU,aAAa,OAAO;AAAA,MACrD,OAAO;AAAA,MACP;AAAA,MACA,aAAa,KAAK,eAAe;AAAA,IAC7C,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,UAAU,SAAS,cAAc,KAAK;AAC1C,YAAQ,aAAa,QAAQ,QAAQ;AACrC,YAAQ,UAAU,IAAI,uBAAuB;AAE7C,QAAI,YAAY,SAAS,cAAc,MAAM;AAC7C,cAAU,aAAa,QAAQ,WAAW;AAC1C,cAAU,YAAY,KAAK;AAE3B,QAAI,QAAQ,SAAS,cAAc,MAAM;AACzC,UAAM,aAAa,QAAQ,OAAO;AAElC,QAAI,MAAM,SAAS,cAAc,MAAM;AACvC,QAAI,aAAa,QAAQ,KAAK;AAE9B,YAAQ,YAAY,KAAK;AACzB,YAAQ,YAAY,SAAS;AAC7B,YAAQ,YAAY,GAAG;AAEvB,aAAS,YAAY,OAAO;AAC5B,SAAK,YAAY;AAEjB,WAAO;AAAA,EACf;AACA;ACpLA,cAAc,OAAO,sBAAsB,aAAa;"}
@@ -37,4 +37,15 @@ export default class Icon extends WJElement {
37
37
  * Called after the component has been drawn.
38
38
  */
39
39
  afterDraw(): void;
40
+ /**
41
+ * Sync ARIA attributes on host.
42
+ */
43
+ syncAria(): void;
44
+ /**
45
+ * Handles attribute changes for ARIA sync.
46
+ * @param {string} name
47
+ * @param {string|null} oldValue
48
+ * @param {string|null} newValue
49
+ */
50
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
40
51
  }
@@ -101,6 +101,10 @@ export default class IconPicker extends WJElement {
101
101
  */
102
102
  afterDraw(): void;
103
103
  init: boolean;
104
+ /**
105
+ * Sync ARIA attributes on host.
106
+ */
107
+ syncAria(): void;
104
108
  /**
105
109
  * Handles the selection of an icon from a given input element and updates the relevant properties and events.
106
110
  * @function selectIcon