wj-elements 0.7.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/animations.js +28 -51
  2. package/dist/animations.js.map +1 -1
  3. package/dist/base-path.js +19 -31
  4. package/dist/base-path.js.map +1 -1
  5. package/dist/custom-elements.json +11504 -11499
  6. package/dist/dark.css +1 -302
  7. package/dist/date.js +16 -36
  8. package/dist/date.js.map +1 -1
  9. package/dist/element-utils.js +20 -81
  10. package/dist/element-utils.js.map +1 -1
  11. package/dist/event.js +49 -165
  12. package/dist/event.js.map +1 -1
  13. package/dist/form-associated-element-BjeJn7j8.js +101 -0
  14. package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
  15. package/dist/icon-DmsqtDpL.js +102 -0
  16. package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
  17. package/dist/light.css +1 -731
  18. package/dist/localize.js +36 -111
  19. package/dist/localize.js.map +1 -1
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
  21. package/dist/permissions.js +14 -41
  22. package/dist/permissions.js.map +1 -1
  23. package/dist/popup.element-CbkhthPP.js +806 -0
  24. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  25. package/dist/router-links-CNsJ-elb.js +105 -0
  26. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  27. package/dist/skeleton.css +1 -197
  28. package/dist/styles.css +1 -866
  29. package/dist/universal-service.js +48 -109
  30. package/dist/universal-service.js.map +1 -1
  31. package/dist/utils.js +11 -18
  32. package/dist/utils.js.map +1 -1
  33. package/dist/web-types.json +760 -760
  34. package/dist/wje-accordion-item.js +33 -106
  35. package/dist/wje-accordion-item.js.map +1 -1
  36. package/dist/wje-accordion.js +19 -84
  37. package/dist/wje-accordion.js.map +1 -1
  38. package/dist/wje-animation.js +37 -4258
  39. package/dist/wje-animation.js.map +1 -1
  40. package/dist/wje-aside.js +9 -34
  41. package/dist/wje-aside.js.map +1 -1
  42. package/dist/wje-avatar.js +36 -126
  43. package/dist/wje-avatar.js.map +1 -1
  44. package/dist/wje-badge.js +10 -52
  45. package/dist/wje-badge.js.map +1 -1
  46. package/dist/wje-breadcrumb.js +205 -672
  47. package/dist/wje-breadcrumb.js.map +1 -1
  48. package/dist/wje-breadcrumbs.js +177 -633
  49. package/dist/wje-breadcrumbs.js.map +1 -1
  50. package/dist/wje-button-group.js +48 -153
  51. package/dist/wje-button-group.js.map +1 -1
  52. package/dist/wje-button.js +92 -413
  53. package/dist/wje-button.js.map +1 -1
  54. package/dist/wje-card-content.js +7 -30
  55. package/dist/wje-card-content.js.map +1 -1
  56. package/dist/wje-card-controls.js +7 -30
  57. package/dist/wje-card-controls.js.map +1 -1
  58. package/dist/wje-card-header.js +7 -30
  59. package/dist/wje-card-header.js.map +1 -1
  60. package/dist/wje-card-subtitle.js +7 -34
  61. package/dist/wje-card-subtitle.js.map +1 -1
  62. package/dist/wje-card-title.js +7 -34
  63. package/dist/wje-card-title.js.map +1 -1
  64. package/dist/wje-card.js +15 -71
  65. package/dist/wje-card.js.map +1 -1
  66. package/dist/wje-carousel-item.js +12 -56
  67. package/dist/wje-carousel-item.js.map +1 -1
  68. package/dist/wje-carousel.js +154 -509
  69. package/dist/wje-carousel.js.map +1 -1
  70. package/dist/wje-checkbox.js +50 -227
  71. package/dist/wje-checkbox.js.map +1 -1
  72. package/dist/wje-chip.js +43 -160
  73. package/dist/wje-chip.js.map +1 -1
  74. package/dist/wje-col.js +7 -20
  75. package/dist/wje-col.js.map +1 -1
  76. package/dist/wje-color-picker.js +445 -1464
  77. package/dist/wje-color-picker.js.map +1 -1
  78. package/dist/wje-container.js +9 -35
  79. package/dist/wje-container.js.map +1 -1
  80. package/dist/wje-copy-button.js +64 -204
  81. package/dist/wje-copy-button.js.map +1 -1
  82. package/dist/wje-dialog.js +85 -553
  83. package/dist/wje-dialog.js.map +1 -1
  84. package/dist/wje-divider.js +7 -34
  85. package/dist/wje-divider.js.map +1 -1
  86. package/dist/wje-dropdown.js +78 -305
  87. package/dist/wje-dropdown.js.map +1 -1
  88. package/dist/wje-element.js +191 -700
  89. package/dist/wje-element.js.map +1 -1
  90. package/dist/wje-file-upload-item.js +51 -156
  91. package/dist/wje-file-upload-item.js.map +1 -1
  92. package/dist/wje-file-upload.js +181 -619
  93. package/dist/wje-file-upload.js.map +1 -1
  94. package/dist/wje-footer.js +7 -31
  95. package/dist/wje-footer.js.map +1 -1
  96. package/dist/wje-form.js +7 -32
  97. package/dist/wje-form.js.map +1 -1
  98. package/dist/wje-format-digital.js +26 -118
  99. package/dist/wje-format-digital.js.map +1 -1
  100. package/dist/wje-grid.js +7 -33
  101. package/dist/wje-grid.js.map +1 -1
  102. package/dist/wje-header.js +9 -35
  103. package/dist/wje-header.js.map +1 -1
  104. package/dist/wje-icon-library.js +12 -18
  105. package/dist/wje-icon-library.js.map +1 -1
  106. package/dist/wje-icon-picker.js +65 -320
  107. package/dist/wje-icon-picker.js.map +1 -1
  108. package/dist/wje-icon.js +1 -1
  109. package/dist/wje-img-comparer.js +37 -114
  110. package/dist/wje-img-comparer.js.map +1 -1
  111. package/dist/wje-img.js +50 -198
  112. package/dist/wje-img.js.map +1 -1
  113. package/dist/wje-infinite-scroll.js +94 -346
  114. package/dist/wje-infinite-scroll.js.map +1 -1
  115. package/dist/wje-input-file.js +23 -84
  116. package/dist/wje-input-file.js.map +1 -1
  117. package/dist/wje-input.js +78 -392
  118. package/dist/wje-input.js.map +1 -1
  119. package/dist/wje-item.js +11 -64
  120. package/dist/wje-item.js.map +1 -1
  121. package/dist/wje-kanban.js +124 -401
  122. package/dist/wje-kanban.js.map +1 -1
  123. package/dist/wje-label.js +9 -32
  124. package/dist/wje-label.js.map +1 -1
  125. package/dist/wje-level-indicator.js +38 -157
  126. package/dist/wje-level-indicator.js.map +1 -1
  127. package/dist/wje-list.js +10 -40
  128. package/dist/wje-list.js.map +1 -1
  129. package/dist/wje-main.js +7 -31
  130. package/dist/wje-main.js.map +1 -1
  131. package/dist/wje-masonry.js +66 -211
  132. package/dist/wje-masonry.js.map +1 -1
  133. package/dist/wje-master.js +45 -161
  134. package/dist/wje-master.js.map +1 -1
  135. package/dist/wje-menu-button.js +10 -38
  136. package/dist/wje-menu-button.js.map +1 -1
  137. package/dist/wje-menu-item.js +127 -577
  138. package/dist/wje-menu-item.js.map +1 -1
  139. package/dist/wje-menu-label.js +9 -35
  140. package/dist/wje-menu-label.js.map +1 -1
  141. package/dist/wje-menu.js +14 -49
  142. package/dist/wje-menu.js.map +1 -1
  143. package/dist/wje-option.js +48 -279
  144. package/dist/wje-option.js.map +1 -1
  145. package/dist/wje-options.js +130 -384
  146. package/dist/wje-options.js.map +1 -1
  147. package/dist/wje-orgchart-group.js +16 -52
  148. package/dist/wje-orgchart-group.js.map +1 -1
  149. package/dist/wje-orgchart-item.js +24 -93
  150. package/dist/wje-orgchart-item.js.map +1 -1
  151. package/dist/wje-orgchart.js +18 -68
  152. package/dist/wje-orgchart.js.map +1 -1
  153. package/dist/wje-pagination.js +113 -397
  154. package/dist/wje-pagination.js.map +1 -1
  155. package/dist/wje-popup.js +3 -3
  156. package/dist/wje-popup.js.map +1 -1
  157. package/dist/wje-progress-bar.js +53 -205
  158. package/dist/wje-progress-bar.js.map +1 -1
  159. package/dist/wje-qr-code.js +398 -2980
  160. package/dist/wje-qr-code.js.map +1 -1
  161. package/dist/wje-radio-group.js +52 -190
  162. package/dist/wje-radio-group.js.map +1 -1
  163. package/dist/wje-radio.js +24 -118
  164. package/dist/wje-radio.js.map +1 -1
  165. package/dist/wje-rate.js +62 -266
  166. package/dist/wje-rate.js.map +1 -1
  167. package/dist/wje-relative-time.js +24 -99
  168. package/dist/wje-relative-time.js.map +1 -1
  169. package/dist/wje-reorder-dropzone.js +9 -31
  170. package/dist/wje-reorder-dropzone.js.map +1 -1
  171. package/dist/wje-reorder-handle.js +67 -204
  172. package/dist/wje-reorder-handle.js.map +1 -1
  173. package/dist/wje-reorder-item.js +14 -44
  174. package/dist/wje-reorder-item.js.map +1 -1
  175. package/dist/wje-reorder.js +61 -246
  176. package/dist/wje-reorder.js.map +1 -1
  177. package/dist/wje-route.js +6 -24
  178. package/dist/wje-route.js.map +1 -1
  179. package/dist/wje-router-link.js +11 -39
  180. package/dist/wje-router-link.js.map +1 -1
  181. package/dist/wje-router-outlet.js +76 -172
  182. package/dist/wje-router-outlet.js.map +1 -1
  183. package/dist/wje-routerx.js +537 -1331
  184. package/dist/wje-routerx.js.map +1 -1
  185. package/dist/wje-row.js +9 -31
  186. package/dist/wje-row.js.map +1 -1
  187. package/dist/wje-select.js +326 -1152
  188. package/dist/wje-select.js.map +1 -1
  189. package/dist/wje-slider.js +44 -225
  190. package/dist/wje-slider.js.map +1 -1
  191. package/dist/wje-sliding-container.js +295 -1319
  192. package/dist/wje-sliding-container.js.map +1 -1
  193. package/dist/wje-split-view.js +35 -121
  194. package/dist/wje-split-view.js.map +1 -1
  195. package/dist/wje-status.js +14 -45
  196. package/dist/wje-status.js.map +1 -1
  197. package/dist/wje-step.js +9 -32
  198. package/dist/wje-step.js.map +1 -1
  199. package/dist/wje-stepper.js +109 -357
  200. package/dist/wje-stepper.js.map +1 -1
  201. package/dist/wje-store.js +67 -360
  202. package/dist/wje-store.js.map +1 -1
  203. package/dist/wje-tab-group.js +85 -314
  204. package/dist/wje-tab-group.js.map +1 -1
  205. package/dist/wje-tab-panel.js +7 -28
  206. package/dist/wje-tab-panel.js.map +1 -1
  207. package/dist/wje-tab.js +21 -198
  208. package/dist/wje-tab.js.map +1 -1
  209. package/dist/wje-textarea.js +64 -264
  210. package/dist/wje-textarea.js.map +1 -1
  211. package/dist/wje-thumbnail.js +10 -51
  212. package/dist/wje-thumbnail.js.map +1 -1
  213. package/dist/wje-toast.js +127 -632
  214. package/dist/wje-toast.js.map +1 -1
  215. package/dist/wje-toggle.js +52 -177
  216. package/dist/wje-toggle.js.map +1 -1
  217. package/dist/wje-toolbar-action.js +128 -456
  218. package/dist/wje-toolbar-action.js.map +1 -1
  219. package/dist/wje-toolbar.js +75 -270
  220. package/dist/wje-toolbar.js.map +1 -1
  221. package/dist/wje-tooltip.js +50 -161
  222. package/dist/wje-tooltip.js.map +1 -1
  223. package/dist/wje-tree-item.js +70 -301
  224. package/dist/wje-tree-item.js.map +1 -1
  225. package/dist/wje-tree.js +145 -489
  226. package/dist/wje-tree.js.map +1 -1
  227. package/dist/wje-visually-hidden.js +7 -34
  228. package/dist/wje-visually-hidden.js.map +1 -1
  229. package/package.json +3 -2
  230. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  231. package/dist/icon-CReYMzAK.js +0 -245
  232. package/dist/popup.element-CwXvVFK7.js +0 -2133
  233. package/dist/router-links-wjqCnncc.js +0 -156
@@ -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 and MIME subtypes 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: [\n 'doc',\n 'docx',\n 'msword',\n 'vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'vnd.ms-word.document.macroenabled.12',\n 'vnd.openxmlformats-officedocument.wordprocessingml.template',\n 'vnd.ms-word.template.macroenabled.12',\n 'vnd.oasis.opendocument.text',\n ],\n name: 'file-type-doc',\n },\n {\n type: [\n 'xls',\n 'xlsx',\n 'vnd.ms-excel',\n 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'vnd.ms-excel.sheet.macroenabled.12',\n 'vnd.openxmlformats-officedocument.spreadsheetml.template',\n 'vnd.ms-excel.template.macroenabled.12',\n 'vnd.ms-excel.addin.macroenabled.12',\n 'vnd.ms-excel.sheet.binary.macroenabled.12',\n 'vnd.oasis.opendocument.spreadsheet',\n ],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: [\n 'ppt',\n 'pptx',\n 'odp',\n 'vnd.ms-powerpoint',\n 'vnd.openxmlformats-officedocument.presentationml.presentation',\n 'vnd.ms-powerpoint.presentation.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.slideshow',\n 'vnd.ms-powerpoint.slideshow.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.template',\n 'vnd.ms-powerpoint.template.macroenabled.12',\n 'vnd.oasis.opendocument.presentation',\n ],\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 extension, MIME subtype or category (e.g., \"pdf\", \"vnd.ms-excel\", \"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) {\n return searchType;\n }\n\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 * @cssproperty [--wje-file-upload-padding=0] - Controls the padding around the native file upload area.\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('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 errorMessage = document.createElement('div');\n errorMessage.setAttribute('part', 'error-message');\n errorMessage.setAttribute('role', 'alert');\n errorMessage.setAttribute('aria-live', 'polite');\n errorMessage.classList.add('file-error');\n errorMessage.hidden = true;\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('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(errorMessage);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n this.errorMessage = errorMessage;\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) => {\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 e.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 e.preventDefault();\n\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 this.showError(detail);\n\n return;\n }\n\n this._queuedFiles = [...(this._queuedFiles || []), ...files];\n this.clearError();\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 this.showError(err);\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 let fileType = file.type ? file.type.split('/')[1] : file.name.split('.').pop();\n let icon = getFileTypeIcon(fileType) || 'file';\n\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=\"${icon}\" 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 /**\n * Shows a user-facing validation error inside the dropzone.\n * @param {object|Error} error Error payload to display inside the dropzone.\n */\n showError(error) {\n if (!this.errorMessage) return;\n\n this.errorMessage.textContent = this.getErrorMessage(error);\n this.errorMessage.hidden = false;\n }\n\n /**\n * Clears the currently displayed validation error.\n */\n clearError() {\n if (!this.errorMessage) return;\n\n this.errorMessage.textContent = '';\n this.errorMessage.hidden = true;\n }\n\n /**\n * Resolves a readable upload error message.\n * @param {object|Error} error Error payload used to resolve the translated message.\n * @returns {string}\n */\n getErrorMessage(error = {}) {\n const code = error.code || error.detail?.code;\n\n const messages = {\n 'INVALID-FILE-TYPE': {\n key: 'wj.file.upload.error.invalid.type',\n fallback: `This file type is not supported. Allowed formats: ${error.acceptedTypes || this.acceptedTypes}.`,\n params: { acceptedTypes: error.acceptedTypes || this.acceptedTypes },\n },\n 'FILE-TOO-LARGE': {\n key: 'wj.file.upload.error.file.too.large',\n fallback: `The file is too large. Maximum size is ${this.localizer.formatNumber(this.maxFileSize / 1024 / 1024)} MB.`,\n params: { maxFileSize: this.localizer.formatNumber(this.maxFileSize / 1024 / 1024) },\n },\n 'MAX-FILES-EXCEEDED': {\n key: 'wj.file.upload.error.max.files',\n fallback: `You can upload up to ${error.maxFiles || this.maxFiles} files.`,\n params: { maxFiles: error.maxFiles || this.maxFiles },\n },\n };\n\n const message = messages[code] || {\n key: 'wj.file.upload.error.generic',\n fallback: 'The file could not be uploaded.',\n params: {},\n };\n const translated = this.localizer.translateWithParams(message.key, message.params);\n\n return translated === message.key ? message.fallback : translated;\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","fileType"],"mappings":";;;;;;;;AAeA,SAAS,WAAW;AAChB,SAAO;AAAA,IACH;AAAA,MACI,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ,KAAK;AAAA,MACxD,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,KAAK;AAAA,MAC9E,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,KAAK;AAAA,MACjC,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,KAAK;AAAA,MAC1B,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM;AAAA,QACF;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAChB;AAAA,MACY,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM;AAAA,QACF;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAChB;AAAA,MACY,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM;A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AAE,eAAe,MAAM,iBAAiB,KAAK,cAAa;AAAA,MAClF;AAAA,MACY,kBAAkB;AAAA,QACd,KAAK;AAAA,QACL,UAAU,0CAA0C,KAAK,UAAU,aAAa,KAAK,cAAc,OAAO,IAAI,CAAC;AAAA,QAC/G,QAAQ,EAAE,aAAa,KAAK,UAAU,aAAa,KAAK,cAAc,OAAO,IAAI,EAAC;AAAA,MAClG;AAAA,MACY,sBAAsB;AAAA,QAClB,KAAK;AAAA,QACL,UAAU,wBAAwB,MAAM,YAAY,KAAK,QAAQ;AAAA,QACjE,QAAQ,EAAE,UAAU,MAAM,YAAY,KAAK,SAAQ;AAAA,MACnE;AAAA,IACA;AAEQ,UAAM,UAAU,SAAS,IAAI,KAAK;AAAA,MAC9B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,QAAQ,CAAA;AAAA,IACpB;AACQ,UAAM,aAAa,KAAK,UAAU,oBAAoB,QAAQ,KAAK,QAAQ,MAAM;AAEjF,WAAO,eAAe,QAAQ,MAAM,QAAQ,WAAW;AAAA,EAC3D;AACJ;ACxoBA,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 and MIME subtypes 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: [\n 'doc',\n 'docx',\n 'msword',\n 'vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'vnd.ms-word.document.macroenabled.12',\n 'vnd.openxmlformats-officedocument.wordprocessingml.template',\n 'vnd.ms-word.template.macroenabled.12',\n 'vnd.oasis.opendocument.text',\n ],\n name: 'file-type-doc',\n },\n {\n type: [\n 'xls',\n 'xlsx',\n 'vnd.ms-excel',\n 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'vnd.ms-excel.sheet.macroenabled.12',\n 'vnd.openxmlformats-officedocument.spreadsheetml.template',\n 'vnd.ms-excel.template.macroenabled.12',\n 'vnd.ms-excel.addin.macroenabled.12',\n 'vnd.ms-excel.sheet.binary.macroenabled.12',\n 'vnd.oasis.opendocument.spreadsheet',\n ],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: [\n 'ppt',\n 'pptx',\n 'odp',\n 'vnd.ms-powerpoint',\n 'vnd.openxmlformats-officedocument.presentationml.presentation',\n 'vnd.ms-powerpoint.presentation.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.slideshow',\n 'vnd.ms-powerpoint.slideshow.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.template',\n 'vnd.ms-powerpoint.template.macroenabled.12',\n 'vnd.oasis.opendocument.presentation',\n ],\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 extension, MIME subtype or category (e.g., \"pdf\", \"vnd.ms-excel\", \"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) {\n return searchType;\n }\n\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 * @cssproperty [--wje-file-upload-padding=0] - Controls the padding around the native file upload area.\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('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 errorMessage = document.createElement('div');\n errorMessage.setAttribute('part', 'error-message');\n errorMessage.setAttribute('role', 'alert');\n errorMessage.setAttribute('aria-live', 'polite');\n errorMessage.classList.add('file-error');\n errorMessage.hidden = true;\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('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(errorMessage);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n this.errorMessage = errorMessage;\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) => {\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 e.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 e.preventDefault();\n\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 this.showError(detail);\n\n return;\n }\n\n this._queuedFiles = [...(this._queuedFiles || []), ...files];\n this.clearError();\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 this.showError(err);\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 let fileType = file.type ? file.type.split('/')[1] : file.name.split('.').pop();\n let icon = getFileTypeIcon(fileType) || 'file';\n\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=\"${icon}\" 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 /**\n * Shows a user-facing validation error inside the dropzone.\n * @param {object|Error} error Error payload to display inside the dropzone.\n */\n showError(error) {\n if (!this.errorMessage) return;\n\n this.errorMessage.textContent = this.getErrorMessage(error);\n this.errorMessage.hidden = false;\n }\n\n /**\n * Clears the currently displayed validation error.\n */\n clearError() {\n if (!this.errorMessage) return;\n\n this.errorMessage.textContent = '';\n this.errorMessage.hidden = true;\n }\n\n /**\n * Resolves a readable upload error message.\n * @param {object|Error} error Error payload used to resolve the translated message.\n * @returns {string}\n */\n getErrorMessage(error = {}) {\n const code = error.code || error.detail?.code;\n\n const messages = {\n 'INVALID-FILE-TYPE': {\n key: 'wj.file.upload.error.invalid.type',\n fallback: `This file type is not supported. Allowed formats: ${error.acceptedTypes || this.acceptedTypes}.`,\n params: { acceptedTypes: error.acceptedTypes || this.acceptedTypes },\n },\n 'FILE-TOO-LARGE': {\n key: 'wj.file.upload.error.file.too.large',\n fallback: `The file is too large. Maximum size is ${this.localizer.formatNumber(this.maxFileSize / 1024 / 1024)} MB.`,\n params: { maxFileSize: this.localizer.formatNumber(this.maxFileSize / 1024 / 1024) },\n },\n 'MAX-FILES-EXCEEDED': {\n key: 'wj.file.upload.error.max.files',\n fallback: `You can upload up to ${error.maxFiles || this.maxFiles} files.`,\n params: { maxFiles: error.maxFiles || this.maxFiles },\n },\n };\n\n const message = messages[code] || {\n key: 'wj.file.upload.error.generic',\n fallback: 'The file could not be uploaded.',\n params: {},\n };\n const translated = this.localizer.translateWithParams(message.key, message.params);\n\n return translated === message.key ? message.fallback : translated;\n }\n}\n","import FileUpload from './file-upload.element.js';\n\nexport default FileUpload;\n\nFileUpload.define('wje-file-upload', FileUpload);\n"],"names":["getFileTypeIcon","type","searchType","toLowerCase","name","forEach","i","includes","upload","url","chunkSize","wholeFile","file","preview","formData","FormData","append","fetch","method","body","then","response","json","data","setAttribute","size","catch","error","console","async","offset","totalChunks","Math","ceil","partResponses","chunk","slice","stream","ReadableStream","controller","reader","getReader","uploadedBytes","read","process","done","value","close","Promise","resolve","byteLength","enqueue","Blob","floor","ok","Error","statusText","push","at","FileUpload","WJElement","constructor","super","dependencies","Button","className","handleDrop","e","preventDefault","fileList","dataTransfer","files","this","resetFormState","addFilesToQueue","handleInputChange","Array","from","target","event","dispatchCustomEvent","handleSubmit","err","createUploadPromise","reject","assertFilesValid","FileReader","onload","onUploadStarted","createPreview","appendChild","uploadFunction","res","item","onUploadedFileComplete","uploadedFiles","readAsDataURL","localizer","Localizer","_uploadedFiles","_queuedFiles","accepted","getAttribute","hasAttribute","maxFileSize","fileSize","uploadUrl","JSON","parse","noUploadButton","label","parseInt","observedAttributes","oldValue","newValue","attributeChangedCallback","button","nextLabel","translate","innerText","setupAttributes","isShadowRoot","setAriaState","role","toChunk","draw","fragment","document","createDocumentFragment","native","createElement","classList","add","slot","errorMessage","hidden","fileInput","afterDraw","addEventListener","click","dragEventCounter","remove","detail","File","count","length","filter","entry","lastModified","currentCount","isArray","newTotal","maxFiles","code","attemptedToAdd","allowedRemaining","max","showError","clearError","onAddedFiles","autoProcessFiles","uploadFiles","map","reduce","prev","curr","onAllFilesUploaded","icon","split","pop","innerHTML","img","result","fileName","isValidFileType","acceptedTypes","textContent","getErrorMessage","message","key","fallback","params","formatNumber","translated","translateWithParams","define"],"mappings":";;;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uG,kBAC3FM,QAAQ,EAAEN,eAAepJ,GAAMoJ,iBAAiBvG,KAAKuG,cAAAA,EAAAA,GAEzD,kBAAkB,EACdI,KAAK,uCACLC,UAAU,0CAA0C5G,KAAKyB,UAAUqF,aAAa9G,KAAKgC,cAAc,OAAO,aAC1G6E,QAAQ,EAAE7E,aAAahC,KAAKyB,UAAUqF,aAAa9G,KAAKgC,cAAc,OAAO,IAAA,EAAA,EAAA,GAEjF,sBAAsB,EAClB2E,KAAK,kCACLC,UAAU,wBAAwBzJ,GAAM6H,YAAYhF,KAAKgF,mBACzD6B,QAAQ,EAAE7B,UAAU7H,GAAM6H,YAAYhF,KAAKgF,SAAAA,EAAAA,EAAAA,EAI1BC,EAAAA,KAAS,EAC9B0B,KAAK,gCACLC,UAAU,mCACVC,QAAQ,CAAA,EAAA,GAENE,KAAa/G,KAAKyB,UAAUuF,oBAAoBN,GAAQC,KAAKD,GAAQG,MAAAA;AAE3E,WAAOE,OAAeL,GAAQC,MAAMD,GAAQE,WAAWG;AAAAA,EAC3D;;ACvoBJ5H,EAAW8H,OAAO,mBAAmB9H,CAAAA;"}
@@ -1,52 +1,28 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ Wj Footer ]\n*/\n\n:host {\n --wje-footer-height: 60px;\n padding: 0 20px;\n flex-shrink: 0;\n height: var(--wje-footer-height);\n display: block;\n}\n";
6
- class Footer extends WJElement {
7
- /**
8
- * Creates an instance of Footer.
9
- * @class
10
- */
4
+ import e from "./wje-element.js";
5
+ class t extends e {
11
6
  constructor() {
12
7
  super();
13
8
  __publicField(this, "className", "Footer");
14
9
  }
15
- /**
16
- * Returns the CSS styles for the component.
17
- * @static
18
- * @returns {CSSStyleSheet}
19
- */
20
10
  static get cssStyleSheet() {
21
- return styles;
11
+ return ":host{--wje-footer-height: 60px;padding:0 20px;flex-shrink:0;height:var(--wje-footer-height);display:block}";
22
12
  }
23
- /**
24
- * Returns the list of attributes to observe for changes.
25
- * @static
26
- * @returns {Array<string>}
27
- */
28
13
  static get observedAttributes() {
29
14
  return [];
30
15
  }
31
- /**
32
- * Sets up the attributes for the component.
33
- */
34
16
  setupAttributes() {
35
17
  this.isShadowRoot = "open";
36
18
  }
37
- /**
38
- * Draws the component.
39
- * @returns {DocumentFragment}
40
- */
41
19
  draw() {
42
- let fragment = document.createDocumentFragment();
43
- let element = document.createElement("slot");
44
- fragment.appendChild(element);
45
- return fragment;
20
+ let e2 = document.createDocumentFragment(), t2 = document.createElement("slot");
21
+ return e2.appendChild(t2), e2;
46
22
  }
47
23
  }
48
- Footer.define("wje-footer", Footer);
24
+ t.define("wje-footer", t);
49
25
  export {
50
- Footer as default
26
+ t as default
51
27
  };
52
28
  //# sourceMappingURL=wje-footer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-footer.js","sources":["../packages/wje-footer/footer.element.js","../packages/wje-footer/footer.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents a footer. `Footer` is a custom web component that represents a footer.\n * @documentation https://elements.webjet.sk/components/footer\n * @status stable\n * @augments WJElement\n * @slot default - Default slot for the footer content\n * @cssproperty --primary-color - The primary color of the footer\n */\n\nexport default class Footer extends WJElement {\n /**\n * Creates an instance of Footer.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Footer';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Footer from './footer.element.js';\n\nexport default Footer;\n\nFooter.define('wje-footer', Footer);\n"],"names":[],"mappings":";;;;;AAYe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAK;AAGT,qCAAY;AAAA,EAFZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAW,qBAAqB;AAC5B,WAAO,CAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AACd,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,UAAU,SAAS,cAAc,MAAM;AAE3C,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACX;AACJ;ACzDA,OAAO,OAAO,cAAc,MAAM;"}
1
+ {"version":3,"file":"wje-footer.js","sources":["../packages/wje-footer/footer.element.js","../packages/wje-footer/footer.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents a footer. `Footer` is a custom web component that represents a footer.\n * @documentation https://elements.webjet.sk/components/footer\n * @status stable\n * @augments WJElement\n * @slot default - Default slot for the footer content\n * @cssproperty --primary-color - The primary color of the footer\n */\n\nexport default class Footer extends WJElement {\n /**\n * Creates an instance of Footer.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Footer';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Footer from './footer.element.js';\n\nexport default Footer;\n\nFooter.define('wje-footer', Footer);\n"],"names":["Footer","WJElement","constructor","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","draw","fragment","document","createDocumentFragment","element","createElement","appendChild","define"],"mappings":";;;;AAYe,MAAMA,UAAeC,EAAAA;AAAAA,EAKhC,cAAAC;AACIC,UAAAA;AAGJC,qCAAY;AAAA,EAFZ;AAAA,EASA,2BAAWC;AACP;EACJ;AAAA,EAOA,WAAA;AACI,WAAO,CAAA;AAAA,EACX;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,0BAEpBC,KAAUF,SAASG,cAAc,MAAA;AAIrC,WAFAJ,GAASK,YAAYF,EAAAA,GAEdH;AAAAA,EACX;AAAA;ACxDJV,EAAOgB,OAAO,cAAchB,CAAAA;"}
package/dist/wje-form.js CHANGED
@@ -1,53 +1,28 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ Wj Form ]\n*/\n:host {\n width: 100%;\n}";
6
- class Form extends WJElement {
7
- /**
8
- * Constructor for the Form class.
9
- */
4
+ import e from "./wje-element.js";
5
+ class t extends e {
10
6
  constructor() {
11
7
  super();
12
- /**
13
- * The class name for the Form class.
14
- * @type {string}
15
- */
16
8
  __publicField(this, "className", "Form");
17
9
  }
18
- /**
19
- * Getter for the CSS stylesheet.
20
- * @returns {*}
21
- */
22
10
  static get cssStyleSheet() {
23
- return styles;
11
+ return ":host{width:100%}";
24
12
  }
25
- /**
26
- * Getter for the observed attributes.
27
- * @returns {*[]}
28
- */
29
13
  static get observedAttributes() {
30
14
  return [];
31
15
  }
32
- /**
33
- * Sets up the attributes for the Form.
34
- */
35
16
  setupAttributes() {
36
17
  this.isShadowRoot = "open";
37
18
  }
38
- /**
39
- * Draws the Form.
40
- * @returns {DocumentFragment}
41
- */
42
19
  draw() {
43
- let fragment = document.createDocumentFragment();
44
- let element = document.createElement("slot");
45
- fragment.appendChild(element);
46
- return fragment;
20
+ let e2 = document.createDocumentFragment(), t2 = document.createElement("slot");
21
+ return e2.appendChild(t2), e2;
47
22
  }
48
23
  }
49
- Form.define("wje-form", Form);
24
+ t.define("wje-form", t);
50
25
  export {
51
- Form as default
26
+ t as default
52
27
  };
53
28
  //# sourceMappingURL=wje-form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-form.js","sources":["../packages/wje-form/form.element.js","../packages/wje-form/form.js"],"sourcesContent":["import { default as WJElement, WjElementUtils } from '../wje-element/element.js';\n\nimport styles from './scss/styles.scss?inline';\n\n/**\n * @summary The Form class is a custom\n * web component that extends WJElement. It is a simple form that can hold other elements or components.\n * It provides a slot for adding child elements or components.\n * @documentation https://elements.webjet.sk/components/form\n * @status stable\n * @augments WJElement\n * @slot - The slot for adding child elements or components.\n * @tag wje-form\n */\nexport default class Form extends WJElement {\n /**\n * Constructor for the Form class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Form class.\n * @type {string}\n */\n className = 'Form';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the Form.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Form.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Form from './form.element.js';\n\nexport default Form;\n\nForm.define('wje-form', Form);\n"],"names":[],"mappings":";;;;;AAce,MAAM,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,qBAAqB;AAC5B,WAAO,CAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AACd,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,UAAU,SAAS,cAAc,MAAM;AAE3C,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACX;AACJ;AC5DA,KAAK,OAAO,YAAY,IAAI;"}
1
+ {"version":3,"file":"wje-form.js","sources":["../packages/wje-form/form.element.js","../packages/wje-form/form.js"],"sourcesContent":["import { default as WJElement, WjElementUtils } from '../wje-element/element.js';\n\nimport styles from './scss/styles.scss?inline';\n\n/**\n * @summary The Form class is a custom\n * web component that extends WJElement. It is a simple form that can hold other elements or components.\n * It provides a slot for adding child elements or components.\n * @documentation https://elements.webjet.sk/components/form\n * @status stable\n * @augments WJElement\n * @slot - The slot for adding child elements or components.\n * @tag wje-form\n */\nexport default class Form extends WJElement {\n /**\n * Constructor for the Form class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Form class.\n * @type {string}\n */\n className = 'Form';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the Form.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Form.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Form from './form.element.js';\n\nexport default Form;\n\nForm.define('wje-form', Form);\n"],"names":["Form","WJElement","constructor","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","draw","fragment","document","createDocumentFragment","element","createElement","appendChild","define"],"mappings":";;;;AAce,MAAMA,UAAaC,EAAAA;AAAAA,EAI9B,cAAAC;AACIC,UAAAA;AAOJC,qCAAY;AAAA,EANZ;AAAA,EAYA,2BAAWC;AACP;EACJ;AAAA,EAMA,WAAA;AACI,WAAO,CAAA;AAAA,EACX;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,0BAEpBC,KAAUF,SAASG,cAAc,MAAA;AAIrC,WAFAJ,GAASK,YAAYF,EAAAA,GAEdH;AAAAA,EACX;AAAA;AC3DJV,EAAKgB,OAAO,YAAYhB,CAAAA;"}
@@ -1,155 +1,63 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { Localizer } from "./localize.js";
5
- import WJElement from "./wje-element.js";
6
- const styles = "/*\n[ WJ Format Digital ]\n*/\n\n.native-format-digital {\n white-space: nowrap;\n}\n";
7
- class FormatDigital extends WJElement {
8
- /**
9
- * Creates an instance of FormatDigital.
10
- * Initializes the `Localizer` for locale-specific formatting.
11
- */
4
+ import { Localizer as t } from "./localize.js";
5
+ import e from "./wje-element.js";
6
+ class i extends e {
12
7
  constructor() {
13
8
  super();
14
- /**
15
- * The class name identifier for this component.
16
- * @type {string}
17
- */
18
9
  __publicField(this, "className", "FormatDigital");
19
- this.localizer = new Localizer(this);
10
+ this.localizer = new t(this);
20
11
  }
21
- /**
22
- * Sets the value of the digital format.
23
- * This value determines the size in bytes or bits to be displayed.
24
- * @param {number} value The value to set.
25
- */
26
- set value(value) {
27
- this.setAttribute("value", value);
12
+ set value(t2) {
13
+ this.setAttribute("value", t2);
28
14
  }
29
- /**
30
- * Returns the value of the digital format.
31
- * @returns {number} The current value of the component.
32
- */
33
15
  get value() {
34
16
  return +this.getAttribute("value");
35
17
  }
36
- /**
37
- * Sets the unit of the digital format.
38
- * Valid values are `bit` or `byte`.
39
- * @param {string} value The unit to set.
40
- */
41
- set unit(value) {
42
- this.removeAttribute("unit");
43
- if (value) {
44
- this.setAttribute("unit", value);
45
- }
18
+ set unit(t2) {
19
+ this.removeAttribute("unit"), t2 && this.setAttribute("unit", t2);
46
20
  }
47
- /**
48
- * Returns the unit of the digital format.
49
- * Defaults to `byte` if no unit is set.
50
- * @returns {string} The current unit (`bit` or `byte`).
51
- */
52
21
  get unit() {
53
22
  return this.hasAttribute("unit") ? this.getAttribute("unit") : "byte";
54
23
  }
55
- /**
56
- * Sets the unit display style for the digital format.
57
- * Valid values are `short`, `long`, or `narrow`.
58
- * @param {string} value The unit display style to set.
59
- */
60
- set unitDisplay(value) {
61
- this.removeAttribute("unit-display");
62
- if (value) {
63
- this.setAttribute("unit-display", value);
64
- }
24
+ set unitDisplay(t2) {
25
+ this.removeAttribute("unit-display"), t2 && this.setAttribute("unit-display", t2);
65
26
  }
66
- /**
67
- * Returns the unit display style for the digital format.
68
- * Defaults to `short` if not set.
69
- * @returns {string} - The current unit display style.
70
- */
71
27
  get unitDisplay() {
72
28
  return this.hasAttribute("unit-display") ? this.getAttribute("unit-display") : "short";
73
29
  }
74
- /**
75
- * Returns the CSS styles for the component.
76
- * Encapsulated using shadow DOM.
77
- * @static
78
- * @returns {CSSStyleSheet} - The CSS styles for the component.
79
- */
80
30
  static get cssStyleSheet() {
81
- return styles;
31
+ return ".native-format-digital{white-space:nowrap}";
82
32
  }
83
- /**
84
- * Returns the list of attributes to observe for changes.
85
- * Observes `value` and `unit-display` for re-rendering.
86
- * @static
87
- * @returns {Array<string>} - The attributes to observe.
88
- */
89
33
  static get observedAttributes() {
90
34
  return ["value", "unit-display"];
91
35
  }
92
- attributeChangedCallback(name, oldValue, newValue) {
36
+ attributeChangedCallback(t2, e2, i2) {
93
37
  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;
38
+ (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, t2, e2, i2), e2 !== i2 && (this.beforeDraw(), this.formatted && (this.formatted.innerText = this.formattedValue));
98
39
  }
99
- /**
100
- * Sets up the attributes for the component.
101
- * Initializes the shadow DOM.
102
- */
103
40
  setupAttributes() {
104
- this.isShadowRoot = "open";
105
- this.setAriaState({ role: "status" });
41
+ this.isShadowRoot = "open", this.setAriaState({ role: "status" });
106
42
  }
107
- /**
108
- * Prepares the component before rendering.
109
- * Computes the formatted value based on the input value and unit.
110
- */
111
43
  beforeDraw() {
112
44
  if (this.value < 0) return;
113
- const bitPrefixes = ["", "kilo", "mega", "giga", "tera"];
114
- const bytePrefixes = ["", "kilo", "mega", "giga", "tera", "peta"];
115
- const prefix = this.unit === "bit" ? bitPrefixes : bytePrefixes;
116
- const index = Math.max(0, Math.min(Math.floor(Math.log10(this.value) / 3), prefix.length - 1)) || 0;
117
- const unit = prefix[index] + this.unit;
118
- const value = parseFloat((this.value / Math.pow(1e3, index)).toPrecision(3));
119
- this.formattedValue = this.localizer.formatNumber(value, {
120
- style: "unit",
121
- unit,
122
- unitDisplay: this.unitDisplay || "short"
123
- });
45
+ const t2 = "bit" === this.unit ? ["", "kilo", "mega", "giga", "tera"] : ["", "kilo", "mega", "giga", "tera", "peta"], e2 = Math.max(0, Math.min(Math.floor(Math.log10(this.value) / 3), t2.length - 1)) || 0, i2 = t2[e2] + this.unit, a = parseFloat((this.value / Math.pow(1e3, e2)).toPrecision(3));
46
+ this.formattedValue = this.localizer.formatNumber(a, { style: "unit", unit: i2, unitDisplay: this.unitDisplay || "short" });
124
47
  }
125
- /**
126
- * Renders the component and returns a document fragment.
127
- * The rendered structure includes a formatted value wrapped in a container
128
- * with slots for additional customization.
129
- * @returns {DocumentFragment} - The DOM structure for the component.
130
- */
131
48
  draw() {
132
- let fragment = document.createDocumentFragment();
133
- let element = document.createElement("div");
134
- element.setAttribute("part", "native");
135
- element.classList.add("native-format-digital");
136
- let formatted = document.createElement("span");
137
- formatted.setAttribute("part", "formatted");
138
- formatted.innerText = this.formattedValue;
139
- let start = document.createElement("slot");
140
- start.setAttribute("name", "start");
141
- let end = document.createElement("slot");
142
- end.setAttribute("name", "end");
143
- element.appendChild(start);
144
- element.appendChild(formatted);
145
- element.appendChild(end);
146
- fragment.appendChild(element);
147
- this.formatted = formatted;
148
- return fragment;
49
+ let t2 = document.createDocumentFragment(), e2 = document.createElement("div");
50
+ e2.setAttribute("part", "native"), e2.classList.add("native-format-digital");
51
+ let i2 = document.createElement("span");
52
+ i2.setAttribute("part", "formatted"), i2.innerText = this.formattedValue;
53
+ let a = document.createElement("slot");
54
+ a.setAttribute("name", "start");
55
+ let s = document.createElement("slot");
56
+ return s.setAttribute("name", "end"), e2.appendChild(a), e2.appendChild(i2), e2.appendChild(s), t2.appendChild(e2), this.formatted = i2, t2;
149
57
  }
150
58
  }
151
- FormatDigital.define("wje-format-digital", FormatDigital);
59
+ i.define("wje-format-digital", i);
152
60
  export {
153
- FormatDigital as default
61
+ i as default
154
62
  };
155
63
  //# sourceMappingURL=wje-format-digital.js.map
@@ -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 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,UAAK;AAmET;AAAA;AAAA;AAAA;AAAA,qCAAY;AAlER,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAQ;AACR,WAAO,CAAC,KAAK,aAAa,OAAO;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,KAAK,OAAO;AACZ,SAAK,gBAAgB,MAAM;AAC3B,QAAI,OAAO;AACP,WAAK,aAAa,QAAQ,KAAK;AAAA,IACnC;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,OAAO;AACP,WAAO,KAAK,aAAa,MAAM,IAAI,KAAK,aAAa,MAAM,IAAI;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,YAAY,OAAO;AACnB,SAAK,gBAAgB,cAAc;AACnC,QAAI,OAAO;AACP,WAAK,aAAa,gBA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A,MACA,aAAa,KAAK,eAAe;AAAA,IAC7C,CAAS;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,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,EACX;AACJ;ACpLA,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":["FormatDigital","WJElement","constructor","super","className","this","localizer","Localizer","value","setAttribute","getAttribute","removeAttribute","unit","hasAttribute","unitDisplay","observedAttributes","name","oldValue","newValue","attributeChangedCallback","beforeDraw","formatted","innerText","formattedValue","isShadowRoot","setAriaState","role","prefix","index","Math","max","min","floor","log10","length","parseFloat","pow","toPrecision","formatNumber","style","fragment","document","createDocumentFragment","element","createElement","classList","add","start","end","appendChild","define"],"mappings":";;;;;AAqBe,MAAMA,UAAsBC,EAAAA;AAAAA,EAKvC,cAAAC;AACIC,UAAAA;AAmEJC,qCAAY;AAlERC,SAAKC,YAAY,IAAIC,EAAUF,IAAAA;AAAAA,EACnC;AAAA,EAOA,IAAA,MAAUG,IAAAA;AACNH,SAAKI,aAAa,SAASD,EAAAA;AAAAA,EAC/B;AAAA,EAMA,IAAA,QAAIA;AACA,WAAA,CAAQH,KAAKK,aAAa;EAC9B;AAAA,EAOA,IAAA,KAASF,IAAAA;AACLH,SAAKM,gBAAgB,MAAA,GACjBH,MACAH,KAAKI,aAAa,QAAQD,EAAAA;AAAAA,EAElC;AAAA,EAOA,IAAA,OAAII;AACA,WAAOP,KAAKQ,aAAa,MAAA,IAAUR,KAAKK,aAAa,MAAA,IAAU;AAAA,EACnE;AAAA,EAOA,IAAA,YAAgBF,IAAAA;AACZH,SAAKM,gBAAgB,cAAA,GACjBH,MACAH,KAAKI,aAAa,gBAAgBD,EAAAA;AAAAA,EAE1C;AAAA,EAOA,IAAA,cAAIM;AACA,WAAOT,KAAKQ,aAAa,cAAA,IAAkBR,KAAKK,aAAa,cAAA,IAAkB;AAAA,EACnF;AAAA,EAcA,WAAA;AACI;EACJ;AAAA,EAQA,WAAA,qBAAWK;AACP,WAAO,CAAC,SAAS,cAAA;AAAA,EACrB;AAAA,EAEA,yBAAyBC,IAAMC,IAAUC,IAAAA;;AACrCf,gBAAMgB,6BAANhB,8BAAiCa,IAAMC,IAAUC,KAC7CD,OAAaC,OACjBb,KAAKe,WAAAA,GACDf,KAAKgB,cAAWhB,KAAKgB,UAAUC,YAAYjB,KAAKkB;AAAAA,EACxD;AAAA,EAMA;AACIlB,SAAKmB,eAAe,QACpBnB,KA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