wj-elements 0.2.0-alpha.4 → 0.2.0-alpha.5

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 (243) hide show
  1. package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +2 -2
  2. package/dist/wje-file-upload.js +1 -0
  3. package/dist/wje-file-upload.js.map +1 -1
  4. package/package.json +1 -1
  5. package/dist/index.d.ts +0 -107
  6. package/dist/internals/form-associated-element.d.ts +0 -143
  7. package/dist/localize/localize.d.ts +0 -48
  8. package/dist/translations/en-gb.d.ts +0 -18
  9. package/dist/translations/sk-sk.d.ts +0 -13
  10. package/dist/utils/animations.d.ts +0 -2
  11. package/dist/utils/base-path.d.ts +0 -14
  12. package/dist/utils/date.d.ts +0 -2
  13. package/dist/utils/element-utils.d.ts +0 -46
  14. package/dist/utils/event.d.ts +0 -67
  15. package/dist/utils/icon-library.d.ts +0 -3
  16. package/dist/utils/localize.d.ts +0 -4
  17. package/dist/utils/permissions.d.ts +0 -40
  18. package/dist/utils/universal-service.d.ts +0 -18
  19. package/dist/utils/utils.d.ts +0 -1
  20. package/dist/wje-accordion/accordion.d.ts +0 -2
  21. package/dist/wje-accordion/accordion.element.d.ts +0 -72
  22. package/dist/wje-accordion/accordion.test.d.ts +0 -0
  23. package/dist/wje-accordion-item/accordion-item.d.ts +0 -2
  24. package/dist/wje-accordion-item/accordion-item.element.d.ts +0 -40
  25. package/dist/wje-animation/animation.d.ts +0 -2
  26. package/dist/wje-animation/animation.element.d.ts +0 -158
  27. package/dist/wje-aside/aside.d.ts +0 -2
  28. package/dist/wje-aside/aside.element.d.ts +0 -31
  29. package/dist/wje-avatar/avatar.d.ts +0 -2
  30. package/dist/wje-avatar/avatar.element.d.ts +0 -76
  31. package/dist/wje-avatar/avatar.test.d.ts +0 -1
  32. package/dist/wje-avatar/service/service.d.ts +0 -52
  33. package/dist/wje-badge/badge.d.ts +0 -2
  34. package/dist/wje-badge/badge.element.d.ts +0 -35
  35. package/dist/wje-badge/badge.test.d.ts +0 -1
  36. package/dist/wje-breadcrumb/breadcrumb.d.ts +0 -2
  37. package/dist/wje-breadcrumb/breadcrumb.element.d.ts +0 -98
  38. package/dist/wje-breadcrumbs/breadcrumbs.d.ts +0 -2
  39. package/dist/wje-breadcrumbs/breadcrumbs.element.d.ts +0 -105
  40. package/dist/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
  41. package/dist/wje-button/button.d.ts +0 -2
  42. package/dist/wje-button/button.element.d.ts +0 -204
  43. package/dist/wje-button/button.test.d.ts +0 -1
  44. package/dist/wje-button-group/button-group.d.ts +0 -2
  45. package/dist/wje-button-group/button-group.element.d.ts +0 -96
  46. package/dist/wje-card/card.d.ts +0 -2
  47. package/dist/wje-card/card.element.d.ts +0 -31
  48. package/dist/wje-card-content/card-content.d.ts +0 -2
  49. package/dist/wje-card-content/card-content.element.d.ts +0 -22
  50. package/dist/wje-card-controls/card-controls.d.ts +0 -2
  51. package/dist/wje-card-controls/card-controls.element.d.ts +0 -23
  52. package/dist/wje-card-header/card-header.d.ts +0 -2
  53. package/dist/wje-card-header/card-header.element.d.ts +0 -22
  54. package/dist/wje-card-subtitle/card-subtitle.d.ts +0 -2
  55. package/dist/wje-card-subtitle/card-subtitle.element.d.ts +0 -30
  56. package/dist/wje-card-title/card-title.d.ts +0 -2
  57. package/dist/wje-card-title/card-title.element.d.ts +0 -32
  58. package/dist/wje-carousel/carousel.d.ts +0 -2
  59. package/dist/wje-carousel/carousel.element.d.ts +0 -154
  60. package/dist/wje-carousel-item/carousel-item.d.ts +0 -2
  61. package/dist/wje-carousel-item/carousel-item.element.d.ts +0 -38
  62. package/dist/wje-checkbox/checkbox.d.ts +0 -2
  63. package/dist/wje-checkbox/checkbox.element.d.ts +0 -100
  64. package/dist/wje-chip/chip.d.ts +0 -2
  65. package/dist/wje-chip/chip.element.d.ts +0 -76
  66. package/dist/wje-chip/chip.test.d.ts +0 -1
  67. package/dist/wje-col/col.d.ts +0 -2
  68. package/dist/wje-col/col.element.d.ts +0 -16
  69. package/dist/wje-color-picker/color-picker.d.ts +0 -2
  70. package/dist/wje-color-picker/color-picker.element.d.ts +0 -230
  71. package/dist/wje-color-picker/color-picker.test.d.ts +0 -1
  72. package/dist/wje-container/container.d.ts +0 -2
  73. package/dist/wje-container/container.element.d.ts +0 -31
  74. package/dist/wje-copy-button/copy-button.d.ts +0 -2
  75. package/dist/wje-copy-button/copy-button.element.d.ts +0 -89
  76. package/dist/wje-copy-button/service/service.d.ts +0 -12
  77. package/dist/wje-dialog/dialog.d.ts +0 -2
  78. package/dist/wje-dialog/dialog.element.d.ts +0 -132
  79. package/dist/wje-divider/divider.d.ts +0 -2
  80. package/dist/wje-divider/divider.element.d.ts +0 -32
  81. package/dist/wje-dropdown/dropdown.d.ts +0 -2
  82. package/dist/wje-dropdown/dropdown.element.d.ts +0 -108
  83. package/dist/wje-element/element.d.ts +0 -341
  84. package/dist/wje-file-upload/file-upload.d.ts +0 -2
  85. package/dist/wje-file-upload/file-upload.element.d.ts +0 -191
  86. package/dist/wje-file-upload/service/service.d.ts +0 -70
  87. package/dist/wje-file-upload-item/file-upload-item.d.ts +0 -2
  88. package/dist/wje-file-upload-item/file-upload-item.element.d.ts +0 -68
  89. package/dist/wje-footer/footer.d.ts +0 -2
  90. package/dist/wje-footer/footer.element.d.ts +0 -28
  91. package/dist/wje-form/form.d.ts +0 -2
  92. package/dist/wje-form/form.element.d.ts +0 -28
  93. package/dist/wje-format-digital/format-digital.d.ts +0 -2
  94. package/dist/wje-format-digital/format-digital.element.d.ts +0 -83
  95. package/dist/wje-format-digital/format-digital.test.d.ts +0 -1
  96. package/dist/wje-grid/grid.d.ts +0 -2
  97. package/dist/wje-grid/grid.element.d.ts +0 -26
  98. package/dist/wje-header/header.d.ts +0 -2
  99. package/dist/wje-header/header.element.d.ts +0 -35
  100. package/dist/wje-icon/icon.d.ts +0 -2
  101. package/dist/wje-icon/icon.element.d.ts +0 -40
  102. package/dist/wje-icon/service/library.d.ts +0 -3
  103. package/dist/wje-icon/service/service.d.ts +0 -11
  104. package/dist/wje-icon-picker/icon-picker.d.ts +0 -2
  105. package/dist/wje-icon-picker/icon-picker.element.d.ts +0 -210
  106. package/dist/wje-img/img.d.ts +0 -2
  107. package/dist/wje-img/img.element.d.ts +0 -118
  108. package/dist/wje-img-comparer/img-comparer.d.ts +0 -2
  109. package/dist/wje-img-comparer/img-comparer.element.d.ts +0 -60
  110. package/dist/wje-img-comparer/service/service.d.ts +0 -1
  111. package/dist/wje-infinite-scroll/infinite-scroll.d.ts +0 -2
  112. package/dist/wje-infinite-scroll/infinite-scroll.element.d.ts +0 -173
  113. package/dist/wje-input/input.d.ts +0 -2
  114. package/dist/wje-input/input.element.d.ts +0 -159
  115. package/dist/wje-input-file/input-file.d.ts +0 -2
  116. package/dist/wje-input-file/input-file.element.d.ts +0 -50
  117. package/dist/wje-item/item.d.ts +0 -2
  118. package/dist/wje-item/item.element.d.ts +0 -68
  119. package/dist/wje-kanban/kanban.d.ts +0 -2
  120. package/dist/wje-kanban/kanban.element.d.ts +0 -182
  121. package/dist/wje-label/label.d.ts +0 -2
  122. package/dist/wje-label/label.element.d.ts +0 -34
  123. package/dist/wje-level-indicator/level-indicator.d.ts +0 -2
  124. package/dist/wje-level-indicator/level-indicator.element.d.ts +0 -91
  125. package/dist/wje-list/list.d.ts +0 -2
  126. package/dist/wje-list/list.element.d.ts +0 -31
  127. package/dist/wje-main/main.d.ts +0 -2
  128. package/dist/wje-main/main.element.d.ts +0 -30
  129. package/dist/wje-masonry/masonry.d.ts +0 -2
  130. package/dist/wje-masonry/masonry.element.d.ts +0 -114
  131. package/dist/wje-masonry/service/service.d.ts +0 -32
  132. package/dist/wje-menu/menu.d.ts +0 -2
  133. package/dist/wje-menu/menu.element.d.ts +0 -47
  134. package/dist/wje-menu-button/menu-button.d.ts +0 -2
  135. package/dist/wje-menu-button/menu-button.element.d.ts +0 -34
  136. package/dist/wje-menu-item/menu-item.d.ts +0 -2
  137. package/dist/wje-menu-item/menu-item.element.d.ts +0 -161
  138. package/dist/wje-menu-label/menu-label.d.ts +0 -2
  139. package/dist/wje-menu-label/menu-label.element.d.ts +0 -39
  140. package/dist/wje-option/option.d.ts +0 -2
  141. package/dist/wje-option/option.element.d.ts +0 -95
  142. package/dist/wje-options/options.d.ts +0 -2
  143. package/dist/wje-options/options.element.d.ts +0 -232
  144. package/dist/wje-orgchart/orgchart.d.ts +0 -2
  145. package/dist/wje-orgchart/orgchart.element.d.ts +0 -24
  146. package/dist/wje-orgchart-group/orgchart-group.d.ts +0 -2
  147. package/dist/wje-orgchart-group/orgchart-group.element.d.ts +0 -28
  148. package/dist/wje-orgchart-item/orgchart-item.d.ts +0 -2
  149. package/dist/wje-orgchart-item/orgchart-item.element.d.ts +0 -49
  150. package/dist/wje-pagination/pagination.d.ts +0 -2
  151. package/dist/wje-pagination/pagination.element.d.ts +0 -178
  152. package/dist/wje-pagination/pagination.test.d.ts +0 -1
  153. package/dist/wje-pagination/service/service.d.ts +0 -9
  154. package/dist/wje-panel/panel.d.ts +0 -2
  155. package/dist/wje-panel/panel.element.d.ts +0 -34
  156. package/dist/wje-popup/popup.d.ts +0 -2
  157. package/dist/wje-popup/popup.element.d.ts +0 -145
  158. package/dist/wje-progress-bar/progress-bar.d.ts +0 -2
  159. package/dist/wje-progress-bar/progress-bar.element.d.ts +0 -96
  160. package/dist/wje-qr-code/qr-code.d.ts +0 -2
  161. package/dist/wje-qr-code/qr-code.element.d.ts +0 -33
  162. package/dist/wje-radio/radio.d.ts +0 -2
  163. package/dist/wje-radio/radio.element.d.ts +0 -64
  164. package/dist/wje-radio-group/radio-group.d.ts +0 -2
  165. package/dist/wje-radio-group/radio-group.element.d.ts +0 -61
  166. package/dist/wje-rate/rate.d.ts +0 -2
  167. package/dist/wje-rate/rate.element.d.ts +0 -156
  168. package/dist/wje-relative-time/relative-time.d.ts +0 -2
  169. package/dist/wje-relative-time/relative-time.element.d.ts +0 -55
  170. package/dist/wje-relative-time/relative-time.test.d.ts +0 -1
  171. package/dist/wje-reorder/reorder.d.ts +0 -2
  172. package/dist/wje-reorder/reorder.element.d.ts +0 -119
  173. package/dist/wje-reorder-dropzone/reorder-dropzone.d.ts +0 -2
  174. package/dist/wje-reorder-dropzone/reorder-dropzone.element.d.ts +0 -23
  175. package/dist/wje-reorder-handle/reorder-handle.d.ts +0 -2
  176. package/dist/wje-reorder-handle/reorder-handle.element.d.ts +0 -84
  177. package/dist/wje-reorder-item/reorder-item.d.ts +0 -2
  178. package/dist/wje-reorder-item/reorder-item.element.d.ts +0 -24
  179. package/dist/wje-route/route.d.ts +0 -2
  180. package/dist/wje-route/route.element.d.ts +0 -22
  181. package/dist/wje-router/router.d.ts +0 -2
  182. package/dist/wje-router/router.element.d.ts +0 -43
  183. package/dist/wje-router-link/router-link.d.ts +0 -2
  184. package/dist/wje-router-link/router-link.element.d.ts +0 -31
  185. package/dist/wje-router-outlet/router-outlet.d.ts +0 -2
  186. package/dist/wje-router-outlet/router-outlet.element.d.ts +0 -16
  187. package/dist/wje-row/row.d.ts +0 -2
  188. package/dist/wje-row/row.element.d.ts +0 -23
  189. package/dist/wje-select/select.d.ts +0 -2
  190. package/dist/wje-select/select.element.d.ts +0 -386
  191. package/dist/wje-select/select.test.d.ts +0 -1
  192. package/dist/wje-slider/slider.d.ts +0 -2
  193. package/dist/wje-slider/slider.element.d.ts +0 -103
  194. package/dist/wje-sliding-container/sliding-container.d.ts +0 -2
  195. package/dist/wje-sliding-container/sliding-container.element.d.ts +0 -265
  196. package/dist/wje-split-view/service/service.d.ts +0 -1
  197. package/dist/wje-split-view/split-view.d.ts +0 -2
  198. package/dist/wje-split-view/split-view.element.d.ts +0 -65
  199. package/dist/wje-status/status.d.ts +0 -2
  200. package/dist/wje-status/status.element.d.ts +0 -26
  201. package/dist/wje-step/step.d.ts +0 -2
  202. package/dist/wje-step/step.element.d.ts +0 -23
  203. package/dist/wje-stepper/stepper.d.ts +0 -2
  204. package/dist/wje-stepper/stepper.element.d.ts +0 -125
  205. package/dist/wje-store/default-store-actions.d.ts +0 -25
  206. package/dist/wje-store/pubsub.d.ts +0 -22
  207. package/dist/wje-store/store.d.ts +0 -153
  208. package/dist/wje-tab/tab.d.ts +0 -2
  209. package/dist/wje-tab/tab.element.d.ts +0 -66
  210. package/dist/wje-tab-group/tab-group.d.ts +0 -2
  211. package/dist/wje-tab-group/tab-group.element.d.ts +0 -131
  212. package/dist/wje-tab-group/tab-group.test.d.ts +0 -1
  213. package/dist/wje-tab-panel/tab-panel.d.ts +0 -2
  214. package/dist/wje-tab-panel/tab-panel.element.d.ts +0 -23
  215. package/dist/wje-textarea/textarea.d.ts +0 -2
  216. package/dist/wje-textarea/textarea.element.d.ts +0 -89
  217. package/dist/wje-thumbnail/thumbnail.d.ts +0 -2
  218. package/dist/wje-thumbnail/thumbnail.element.d.ts +0 -31
  219. package/dist/wje-timeline/timeline.d.ts +0 -2
  220. package/dist/wje-timeline/timeline.element.d.ts +0 -25
  221. package/dist/wje-timeline-item/timeline-item.d.ts +0 -2
  222. package/dist/wje-timeline-item/timeline-item.element.d.ts +0 -27
  223. package/dist/wje-toast/toast.d.ts +0 -2
  224. package/dist/wje-toast/toast.element.d.ts +0 -173
  225. package/dist/wje-toast/toast.test.d.ts +0 -1
  226. package/dist/wje-toggle/toggle.d.ts +0 -2
  227. package/dist/wje-toggle/toggle.element.d.ts +0 -81
  228. package/dist/wje-toggle/toggle.test.d.ts +0 -1
  229. package/dist/wje-toolbar/toolbar.d.ts +0 -2
  230. package/dist/wje-toolbar/toolbar.element.d.ts +0 -39
  231. package/dist/wje-toolbar-action/toolbar-action.d.ts +0 -2
  232. package/dist/wje-toolbar-action/toolbar-action.element.d.ts +0 -35
  233. package/dist/wje-tooltip/tooltip.d.ts +0 -2
  234. package/dist/wje-tooltip/tooltip.element.d.ts +0 -77
  235. package/dist/wje-tree/tree.d.ts +0 -2
  236. package/dist/wje-tree/tree.element.d.ts +0 -105
  237. package/dist/wje-tree/tree.test.d.ts +0 -1
  238. package/dist/wje-tree-item/tree-item.d.ts +0 -2
  239. package/dist/wje-tree-item/tree-item.element.d.ts +0 -155
  240. package/dist/wje-tree-item/tree-item.test.d.ts +0 -1
  241. package/dist/wje-visually-hidden/visually-hidden.d.ts +0 -2
  242. package/dist/wje-visually-hidden/visually-hidden.element.d.ts +0 -29
  243. /package/dist/{wje-animation/animation.test.d.ts → packages/wje-file-upload/file-upload.test.d.ts} +0 -0
@@ -242,8 +242,8 @@ export default class SlidingContainer extends WJElement {
242
242
  * @returns {Promise<void>} A promise that resolves when the transition animation is completed.
243
243
  */
244
244
  doAnimateTransition(): Promise<void>;
245
- animation: Animation;
246
- nativeAnimation: Animation;
245
+ animation: any;
246
+ nativeAnimation: any;
247
247
  /**
248
248
  * Opens the sliding container by performing necessary preparatory and transitional operations.
249
249
  * @param {Event} e The event that triggered the open operation.
@@ -208,6 +208,7 @@ class FileUpload extends WJElement {
208
208
  this.appendChild(preview);
209
209
  this.uploadFunction(file, preview).then((res) => {
210
210
  var _a2;
211
+ res.item = preview;
211
212
  this.dispatchEvent(
212
213
  new CustomEvent("file-upload:upladed-file-complete", {
213
214
  detail: res,
@@ -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 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,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,IACD;AAAA,MACI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a,QAAQ,KAAK,IAAI;AACtC,YAAQ,aAAa,YAAY,GAAG;AACpC,YAAQ,aAAa,YAAY,GAAG;AACpC,YAAQ,YAAY,8BAA8B,gBAAgB,KAAK,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAE1F,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,gBAAgB,MAAM,QAAQ;AAC1B,QAAI,MAAM,SAAS,cAAc,KAAK;AACtC,QAAI,aAAa,OAAO,OAAO,MAAM;AAErC,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,iBAAiB,MAAM;AACnB,UAAM,EAAE,MAAM,UAAU,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;ACjgBA,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 * 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 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,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,MAC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QAAQ;AACxB,QAAI,UAAU,SAAS,cAAc,sBAAsB;AAC3D,YAAQ,aAAa,QAAQ,MAAM;AACnC,YAAQ,aAAa,QAAQ,KAAK,IAAI;AACtC,YAAQ,aAAa,QAAQ,KAAK,IAAI;AACtC,YAAQ,aAAa,YAAY,GAAG;AACpC,YAAQ,aAAa,YAAY,GAAG;AACpC,YAAQ,YAAY,8BAA8B,gBAAgB,KAAK,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAE1F,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,gBAAgB,MAAM,QAAQ;AAC1B,QAAI,MAAM,SAAS,cAAc,KAAK;AACtC,QAAI,aAAa,OAAO,OAAO,MAAM;AAErC,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,iBAAiB,MAAM;AACnB,UAAM,EAAE,MAAM,UAAU,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;ACngBA,WAAW,OAAO,mBAAmB,UAAU;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.2.0-alpha.4",
4
+ "version": "0.2.0-alpha.5",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",
package/dist/index.d.ts DELETED
@@ -1,107 +0,0 @@
1
- export { Localizer } from './utils/localize.js';
2
- export { Permissions } from './utils/permissions.js';
3
- export { UniversalService } from './utils/universal-service.js';
4
- export { fetchAndParseCSS } from './utils/animations.js';
5
- export { event } from './utils/event.js';
6
- export { skSk } from './translations/sk-sk.js';
7
- export { enGb } from './translations/en-gb.js';
8
- export { default as Accordion } from './wje-accordion/accordion.js';
9
- export { default as AccordionItem } from './wje-accordion-item/accordion-item.js';
10
- export { default as Animation } from './wje-animation/animation.js';
11
- export { default as Aside } from './wje-aside/aside.js';
12
- export { default as Avatar } from './wje-avatar/avatar.js';
13
- export { default as Badge } from './wje-badge/badge.js';
14
- export { default as Breadcrumb } from './wje-breadcrumb/breadcrumb.js';
15
- export { default as Breadcrumbs } from './wje-breadcrumbs/breadcrumbs.js';
16
- export { default as Button } from './wje-button/button.js';
17
- export { default as ButtonGroup } from './wje-button-group/button-group.js';
18
- export { default as Card } from './wje-card/card.js';
19
- export { default as CardContent } from './wje-card-content/card-content.js';
20
- export { default as CardControls } from './wje-card-controls/card-controls.js';
21
- export { default as CardHeader } from './wje-card-header/card-header.js';
22
- export { default as CardSubtitle } from './wje-card-subtitle/card-subtitle.js';
23
- export { default as CardTitle } from './wje-card-title/card-title.js';
24
- export { default as Carousel } from './wje-carousel/carousel.js';
25
- export { default as CarouselItem } from './wje-carousel-item/carousel-item.js';
26
- export { default as Checkbox } from './wje-checkbox/checkbox.js';
27
- export { default as Chip } from './wje-chip/chip.js';
28
- export { default as Col } from './wje-col/col.js';
29
- export { default as ColorPicker } from './wje-color-picker/color-picker.js';
30
- export { default as Container } from './wje-container/container.js';
31
- export { default as CopyButton } from './wje-copy-button/copy-button.js';
32
- export { default as Dialog } from './wje-dialog/dialog.js';
33
- export { default as Divider } from './wje-divider/divider.js';
34
- export { default as Dropdown } from './wje-dropdown/dropdown.js';
35
- export { default as WJElement } from './wje-element/element.js';
36
- export { default as FileUpload } from './wje-file-upload/file-upload.js';
37
- export { default as FileUploadItem } from './wje-file-upload-item/file-upload-item.js';
38
- export { default as Footer } from './wje-footer/footer.js';
39
- export { default as FormatDigital } from './wje-format-digital/format-digital.js';
40
- export { default as Grid } from './wje-grid/grid.js';
41
- export { default as Header } from './wje-header/header.js';
42
- export { default as Icon } from './wje-icon/icon.js';
43
- export { default as IconPicker } from './wje-icon-picker/icon-picker.js';
44
- export { default as Img } from './wje-img/img.js';
45
- export { default as ImgComparer } from './wje-img-comparer/img-comparer.js';
46
- export { default as InfiniteScroll } from './wje-infinite-scroll/infinite-scroll.js';
47
- export { default as Input } from './wje-input/input.js';
48
- export { default as InputFile } from './wje-input-file/input-file.js';
49
- export { default as Item } from './wje-item/item.js';
50
- export { default as Kanban } from './wje-kanban/kanban.js';
51
- export { default as Label } from './wje-label/label.js';
52
- export { default as LevelIndicator } from './wje-level-indicator/level-indicator.js';
53
- export { default as List } from './wje-list/list.js';
54
- export { default as Main } from './wje-main/main.js';
55
- export { default as Masonry } from './wje-masonry/masonry.js';
56
- export { default as Menu } from './wje-menu/menu.js';
57
- export { default as MenuButton } from './wje-menu-button/menu-button.js';
58
- export { default as MenuItem } from './wje-menu-item/menu-item.js';
59
- export { default as MenuLabel } from './wje-menu-label/menu-label.js';
60
- export { default as Option } from './wje-option/option.js';
61
- export { default as Options } from './wje-options/options.js';
62
- export { default as Orgchart } from './wje-orgchart/orgchart.js';
63
- export { default as OrgchartGroup } from './wje-orgchart-group/orgchart-group.js';
64
- export { default as OrgchartItem } from './wje-orgchart-item/orgchart-item.js';
65
- export { default as Pagination } from './wje-pagination/pagination.js';
66
- export { default as Popup } from './wje-popup/popup.js';
67
- export { default as ProgressBar } from './wje-progress-bar/progress-bar.js';
68
- export { default as QrCode } from './wje-qr-code/qr-code.js';
69
- export { default as Radio } from './wje-radio/radio.js';
70
- export { default as RadioGroup } from './wje-radio-group/radio-group.js';
71
- export { default as Rate } from './wje-rate/rate.js';
72
- export { default as RelativeTime } from './wje-relative-time/relative-time.js';
73
- export { default as Reorder } from './wje-reorder/reorder.js';
74
- export { default as ReorderDropzone } from './wje-reorder-dropzone/reorder-dropzone.js';
75
- export { default as ReorderHandle } from './wje-reorder-handle/reorder-handle.js';
76
- export { default as ReorderItem } from './wje-reorder-item/reorder-item.js';
77
- export { default as Route } from './wje-route/route.js';
78
- export { default as Routerx } from './wje-router/router.js';
79
- export { default as RouterLink } from './wje-router-link/router-link.js';
80
- export { default as RouterOutlet } from './wje-router-outlet/router-outlet.js';
81
- export { default as Row } from './wje-row/row.js';
82
- export { default as Select } from './wje-select/select.js';
83
- export { default as Slider } from './wje-slider/slider.js';
84
- export { default as SlidingContainer } from './wje-sliding-container/sliding-container.js';
85
- export { default as SplitView } from './wje-split-view/split-view.js';
86
- export { default as Status } from './wje-status/status.js';
87
- export { default as Step } from './wje-step/step.js';
88
- export { default as Stepper } from './wje-stepper/stepper.js';
89
- export { default as Tab } from './wje-tab/tab.js';
90
- export { default as TabGroup } from './wje-tab-group/tab-group.js';
91
- export { default as TabPanel } from './wje-tab-panel/tab-panel.js';
92
- export { default as Textarea } from './wje-textarea/textarea.js';
93
- export { default as Thumbnail } from './wje-thumbnail/thumbnail.js';
94
- export { default as Timeline } from './wje-timeline/timeline.js';
95
- export { default as TimelineItem } from './wje-timeline-item/timeline-item.js';
96
- export { default as Toast } from './wje-toast/toast.js';
97
- export { default as Toggle } from './wje-toggle/toggle.js';
98
- export { default as Toolbar } from './wje-toolbar/toolbar.js';
99
- export { default as ToolbarAction } from './wje-toolbar-action/toolbar-action.js';
100
- export { default as Tooltip } from './wje-tooltip/tooltip.js';
101
- export { default as Tree } from './wje-tree/tree.js';
102
- export { default as TreeItem } from './wje-tree-item/tree-item.js';
103
- export { default as VisuallyHidden } from './wje-visually-hidden/visually-hidden.js';
104
- export { setBasePath, getBasePath } from './utils/base-path.js';
105
- export { formatDate, toSafeDate } from './utils/date.js';
106
- export { registerIconLibrary, unregisterIconLibrary } from './utils/icon-library.js';
107
- export { defaultStoreActions, store } from './wje-store/store.js';
@@ -1,143 +0,0 @@
1
- import { default as WJElement } from '../wje-element/element.js';
2
- export class FormAssociatedElement extends WJElement {
3
- static formAssociated: boolean;
4
- internals: ElementInternals;
5
- /**
6
- * Sets the 'name' attribute to the given value.
7
- * @param {string} value The new value for the 'name' attribute.
8
- */
9
- set name(value: string);
10
- /**
11
- * Getter for the name attribute.
12
- * @returns {string} The name of the input.
13
- */
14
- get name(): string;
15
- /**
16
- * Getter for the type attribute.
17
- * @returns {string} The type of the input.
18
- */
19
- get type(): string;
20
- /**
21
- * Sets or removes the 'required' attribute on the element.
22
- * @param {boolean} value If true, adds the 'required' attribute. If false, removes the 'required' attribute.
23
- */
24
- set required(value: boolean);
25
- /**
26
- * Checks if the 'required' attribute is present on the element.
27
- * @returns {boolean} `true` if the 'required' attribute is set, otherwise `false`.
28
- */
29
- get required(): boolean;
30
- /**
31
- * Setter for the invalid attribute.
32
- * @param {boolean} isInvalid Whether the input is invalid.
33
- */
34
- set invalid(isInvalid: boolean);
35
- /**
36
- * Getter for the invalid attribute.
37
- * @returns {boolean} Whether the attribute is present.
38
- */
39
- get invalid(): boolean;
40
- /**
41
- * Set checked attribute.
42
- * @param {boolean} value true if the toggle is checked, false otherwise
43
- */
44
- set disabled(value: boolean);
45
- /**
46
- * Get disabled attribute value.
47
- * @returns {boolean} true if the toggle is disabled, false otherwise
48
- */
49
- get disabled(): boolean;
50
- /**
51
- * Retrieves the form element associated with this object.
52
- * @returns {HTMLFormElement|null} The associated form element, or null if there isn't one.
53
- */
54
- get form(): HTMLFormElement | null;
55
- /**
56
- * Retrieves the validity state of the element by returning the validity object from the internal element.
57
- * The validity object provides information on whether the element satisfies its validation constraints.
58
- * @returns {ValidityState} The validity state object representing the element's validation constraints.
59
- */
60
- get validity(): ValidityState;
61
- /**
62
- * Retrieves the current validation message associated with the element.
63
- * @returns {string} The validation message that describes why the element's value fails validity checks.
64
- */
65
- get validationMessage(): string;
66
- /**
67
- * Indicates whether the element is a candidate for constraint validation.
68
- * @returns {boolean} Returns true if the element will be validated during constraint validation, false otherwise.
69
- */
70
- get willValidate(): boolean;
71
- /**
72
- * Validates the input element associated with the component and updates its validity state
73
- * and error messages based on the user's input and the current validation rules.
74
- * @returns {void} This method does not return a value. It modifies the validity state
75
- * internally and sets appropriate validation messages.
76
- */
77
- validate(): void;
78
- validationError: string;
79
- /**
80
- * Propagates a validation event based on the validity state of the component.
81
- *
82
- * This method checks the validity status of the component and emits a custom
83
- * event if the component is invalid. The event's name and additional details
84
- * can be specified.
85
- * @param {string} [eventName] The name of the event to dispatch when the component is invalid.
86
- * @param {object} [detail] Additional detail to include in the dispatched event.
87
- * @returns {void} This method does not return a value.
88
- */
89
- propagateValidation(eventName?: string, detail?: object): void;
90
- /**
91
- * Displays an invalid message for the current element.
92
- * If an error message element does not exist within the designated slot,
93
- * it creates one and appends it to the slot. Updates the text content
94
- * of the error message element with the validation message from the
95
- * element's internals.
96
- * @returns {void} This method does not return any value.
97
- */
98
- showInvalidMessage(): void;
99
- /**
100
- * Checks the validity of the input by invoking custom validation logic
101
- * and then verifying against internal validation rules.
102
- * @returns {boolean} Returns true if the input is valid according to both custom validation and internal validation rules, otherwise false.
103
- */
104
- checkValidity(): boolean;
105
- /**
106
- * Callback to handle the reset action for a form.
107
- * Resets the value of the form control to its default value, updates the form value, and clears any validity states.
108
- * @returns {void} Does not return a value.
109
- */
110
- formResetCallback(): void;
111
- value: any;
112
- /**
113
- * Restores the form state by assigning the provided state value
114
- * and updating the internal form value and validity.
115
- * @param {object} state The state object containing the value to restore the form.
116
- * @param {*} state.value The value to set for the form element.
117
- * @returns {void} This method does not return any value.
118
- */
119
- formStateRestoreCallback(state: {
120
- value: any;
121
- }): void;
122
- /**
123
- * Callback method to save the current state of a form.
124
- * This method captures and returns the form's value property.
125
- * @returns {object} An object containing the `value` property of the current form state.
126
- */
127
- formStateSaveCallback(): object;
128
- /**
129
- * Toggles the disabled state of the component and updates corresponding attributes.
130
- * @param {boolean} disabled Indicates whether the form should be marked as disabled.
131
- * If true, the 'disabled' class is added, and the 'disabled' attribute is set.
132
- * If false, both the class and attribute are removed.
133
- * @returns {void}
134
- */
135
- formDisabledCallback(disabled: boolean): void;
136
- /**
137
- * A lifecycle callback that is executed when the element is associated with a form.
138
- * It updates the form's value field with the element's value and sets up an event
139
- * listener to perform validation and propagate it whenever the form is submitted.
140
- * @returns {void} Does not return any value.
141
- */
142
- formAssociatedCallback(): void;
143
- }
@@ -1,48 +0,0 @@
1
- export function registerTranslation(...translation: any[]): void;
2
- export class LocalizerDefault {
3
- constructor(element: any);
4
- element: any;
5
- lang: any;
6
- dir: any;
7
- currentLang: string;
8
- get languages(): any;
9
- setLanguage(): void;
10
- convertLangCode: (lang: any) => any;
11
- /**
12
- * Translates a given translation key based on the currently selected language.
13
- * @param {string} key The key representing the text to be translated.
14
- * @returns {string} The translated text if available; otherwise, returns the original key.
15
- */
16
- translate(key: string): string;
17
- /**
18
- * Translates a key into a localized string based on the provided count and pluralization type.
19
- * @param {string} key The base translation key to be used for fetching the localized string.
20
- * @param {number} [count=0] The count value used to determine the pluralization form.
21
- * @param {string} [type='cardinal'] The type of pluralization to use, such as 'cardinal' or 'ordinal'.
22
- * @returns {string} The translated string, adapted to the pluralization rules and count.
23
- */
24
- translatePlural(key: string, count?: number, type?: string): string;
25
- /**
26
- * Formats a number according to the specified locale and formatting options.
27
- * @param {number} number The numeric value to format.
28
- * @param {object} options An object containing formatting options for the number.
29
- * @returns {string} The formatted number as a string.
30
- */
31
- formatNumber(number: number, options: object): string;
32
- /**
33
- * Formats a given date based on the specified options and the current language setting.
34
- * @param {string|Date|number} date The date to format. Can be a Date object, a timestamp, or a date string.
35
- * @param {object} options The formatting options to customize the output, as supported by Intl.DateTimeFormat.
36
- * @returns {string} The formatted date string based on the specified options and current language.
37
- */
38
- formatDate(date: string | Date | number, options: object): string;
39
- /**
40
- * Formats a relative time string based on a given language, value, unit, and formatting options.
41
- * @param {string} lang The language to use for formatting. Defaults to `this.currentLang` if not provided.
42
- * @param {number} value The numerical value to format, representing the time difference.
43
- * @param {string} [unit] The unit of time to use (e.g., "second", "minute", "hour", "day", "week", "month", "year").
44
- * @param {object} [options] An object containing formatting options, such as the style for the numeric representation.
45
- * @returns {string} The formatted relative time string in the specified language.
46
- */
47
- relativeTime(lang: string, value?: number, unit?: string, options?: object): string;
48
- }
@@ -1,18 +0,0 @@
1
- export const enGb: {
2
- code: string;
3
- name: string;
4
- dir: string;
5
- welcome: string;
6
- 'wj.file.upload.button': string;
7
- 'wj.file.upload.uploaded': string;
8
- 'wj.file.upload.from': string;
9
- 'wj.stepper.button.next': string;
10
- 'wj.stepper.button.finish': string;
11
- 'wj.stepper.button.previous': string;
12
- 'wj.stepper.step': string;
13
- 'wj.pagination.of': string;
14
- 'wj.pagination.first': string;
15
- 'wj.pagination.prev': string;
16
- 'wj.pagination.next': string;
17
- 'wj.pagination.last': string;
18
- };
@@ -1,13 +0,0 @@
1
- export const skSk: {
2
- code: string;
3
- name: string;
4
- dir: string;
5
- welcome: string;
6
- 'wj.file.upload.button': string;
7
- 'wj.file.upload.uploaded': string;
8
- 'wj.file.upload.from': string;
9
- 'wj.stepper.button.next': string;
10
- 'wj.stepper.button.finish': string;
11
- 'wj.stepper.button.previous': string;
12
- 'wj.stepper.step': string;
13
- };
@@ -1,2 +0,0 @@
1
- export function fetchAndParseCSS(css: any): Promise<any[]>;
2
- export let animations: any[];
@@ -1,14 +0,0 @@
1
- /**
2
- * Sets the base path for the application.
3
- * @param {string} path The base path to be set.
4
- * @returns {void} This function does not return anything.
5
- */
6
- export function setBasePath(path: string): void;
7
- /**
8
- * Returns the base path of the application, optionally appending a specified relative path.
9
- * If the base path has not been set, it determines the base path from the first script element
10
- * with a `base-path` attribute or generates it based on the current script location.
11
- * @param {string} [appendedPath] The relative path to append to the base path. Defaults to an empty string.
12
- * @returns {string} The complete base path, with the appended relative path if specified.
13
- */
14
- export function getBasePath(appendedPath?: string): string;
@@ -1,2 +0,0 @@
1
- export function formatDate(input: any, format: any): any;
2
- export function toSafeDate(iso: any): any;
@@ -1,46 +0,0 @@
1
- export class WjElementUtils {
2
- /**
3
- * This function creates an element.
4
- * @param element : HTMLElement - The element value.
5
- * @param object : Object - The object value.
6
- */
7
- static setAttributesToElement(element: any, object: any): void;
8
- /**
9
- * This function gets the attributes from an element.
10
- * @param {string|HTMLElement} el The element or selector to retrieve attributes from.
11
- * @returns {object} - An object containing the element's attributes as key-value pairs.
12
- */
13
- static getAttributes(el: string | HTMLElement): object;
14
- /**
15
- * This function gets the events from an element.
16
- * @param {string|HTMLElement} el The element or selector to retrieve events from.
17
- * @returns {Map<any, any>} - The map value.
18
- */
19
- static getEvents(el: string | HTMLElement): Map<any, any>;
20
- /**
21
- * This function converts an object to a string.
22
- * @param {object} object The object to convert.
23
- * @returns {string} - The string value.
24
- */
25
- static attributesToString(object: object): string;
26
- /**
27
- * This function checks if the slot exists.
28
- * @param {string|HTMLElement} el The element or selector to check for slots.
29
- * @param slotName The slot name to check for.
30
- * @returns {boolean} - The boolean value.
31
- */
32
- static hasSlot(el: string | HTMLElement, slotName?: any): boolean;
33
- /**
34
- * This function checks if the slot has content.
35
- * @param {string|HTMLElement} el The element or selector to check for slot content
36
- * @param slotName The slot name to check for.
37
- * @returns {boolean} - The boolean value.
38
- */
39
- static hasSlotContent(el: string | HTMLElement, slotName?: any): boolean;
40
- /**
41
- * This function converts a string to a boolean.
42
- * @param {string | object} value The value to convert to a boolean. If the value is a boolean, it will be returned as is.
43
- * @returns {boolean} - The boolean value.
44
- */
45
- static stringToBoolean(value: string | object): boolean;
46
- }