@duetds/components 4.30.0 → 4.33.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 (424) hide show
  1. package/hydrate/index.js +1481 -434
  2. package/lib/cjs/{dom-e89ebf90.js → dom-c850c8d7.js} +1 -1
  3. package/lib/cjs/duet-alert.cjs.entry.js +4 -2
  4. package/lib/cjs/duet-badge.cjs.entry.js +2 -2
  5. package/lib/cjs/duet-button_2.cjs.entry.js +6 -5
  6. package/lib/cjs/duet-caption_4.cjs.entry.js +21 -15
  7. package/lib/cjs/duet-card.cjs.entry.js +6 -6
  8. package/lib/cjs/duet-checkbox.cjs.entry.js +2 -2
  9. package/lib/cjs/duet-choice_2.cjs.entry.js +56 -25
  10. package/lib/cjs/duet-collapsible.cjs.entry.js +5 -2
  11. package/lib/cjs/duet-cookie-consent.cjs.entry.js +1 -1
  12. package/lib/cjs/duet-date-picker.cjs.entry.js +23 -13
  13. package/lib/cjs/duet-divider_2.cjs.entry.js +1 -1
  14. package/lib/cjs/duet-editable-table-button_3.cjs.entry.js +232 -0
  15. package/lib/cjs/{duet-table.cjs.entry.js → duet-editable-table_3.cjs.entry.js} +206 -2
  16. package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
  17. package/lib/cjs/duet-footer.cjs.entry.js +4 -4
  18. package/lib/cjs/duet-grid_2.cjs.entry.js +52 -4
  19. package/lib/cjs/duet-header_2.cjs.entry.js +26 -10
  20. package/lib/cjs/duet-hero.cjs.entry.js +6 -6
  21. package/lib/cjs/duet-icon.cjs.entry.js +6 -14
  22. package/lib/cjs/duet-input_2.cjs.entry.js +7 -7
  23. package/lib/cjs/duet-layout.cjs.entry.js +1 -1
  24. package/lib/cjs/duet-list_2.cjs.entry.js +2 -2
  25. package/lib/cjs/duet-modal.cjs.entry.js +8 -7
  26. package/lib/cjs/duet-notification_2.cjs.entry.js +6 -5
  27. package/lib/cjs/duet-number-input.cjs.entry.js +36 -15
  28. package/lib/cjs/duet-progress.cjs.entry.js +75 -0
  29. package/lib/cjs/duet-radio_2.cjs.entry.js +2 -2
  30. package/lib/cjs/duet-range-slider.cjs.entry.js +2 -2
  31. package/lib/cjs/duet-select.cjs.entry.js +6 -6
  32. package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
  33. package/lib/cjs/duet-tab_2.cjs.entry.js +12 -6
  34. package/lib/cjs/duet-textarea.cjs.entry.js +5 -5
  35. package/lib/cjs/duet-toggle.cjs.entry.js +1 -1
  36. package/lib/cjs/duet-tooltip.cjs.entry.js +21 -10
  37. package/lib/cjs/duet-tray.cjs.entry.js +21 -10
  38. package/lib/cjs/duet-upload.cjs.entry.js +403 -180
  39. package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
  40. package/lib/cjs/duet.cjs.js +4 -4
  41. package/lib/cjs/{focus-utils-7605778f.js → focus-utils-a7a1fb8b.js} +1 -1
  42. package/lib/cjs/{index-0c949193.js → index-b724d698.js} +88 -77
  43. package/lib/cjs/js-utils-33a9dbe3.js +16 -0
  44. package/lib/cjs/{language-utils-70d6a9a4.js → language-utils-aa282901.js} +28 -9
  45. package/lib/cjs/loader.cjs.js +3 -3
  46. package/lib/cjs/{shadow-css-0c8c175b.js → shadow-css-e3edeed1.js} +9 -10
  47. package/lib/cjs/{string-utils-a6de43d8.js → string-utils-267e3dbb.js} +7 -0
  48. package/lib/cjs/{token-utils-13e5d13e.js → token-utils-63a9c8dc.js} +1 -1
  49. package/lib/cjs/{tokens.module-53b3bd92.js → tokens.module-6b2df1c2.js} +2 -0
  50. package/lib/cjs/{watch-options-3877c082.js → watch-options-d88afac0.js} +29 -6
  51. package/lib/collection/collection-manifest.json +15 -8
  52. package/lib/collection/components/duet-alert/duet-alert.js +12 -6
  53. package/lib/collection/components/duet-badge/duet-badge.css +1 -0
  54. package/lib/collection/components/duet-button/duet-button.js +17 -15
  55. package/lib/collection/components/duet-card/duet-card.css +30 -7
  56. package/lib/collection/components/duet-card/duet-card.js +4 -3
  57. package/lib/collection/components/duet-checkbox/duet-checkbox.css +1 -1
  58. package/lib/collection/components/duet-choice/duet-choice.css +16 -3
  59. package/lib/collection/components/duet-choice/duet-choice.js +123 -36
  60. package/lib/collection/components/duet-choice-group/duet-choice-group.css +1 -0
  61. package/lib/collection/components/duet-choice-group/duet-choice-group.js +4 -4
  62. package/lib/collection/components/duet-date-picker/duet-date-picker.css +1 -1
  63. package/lib/collection/components/duet-date-picker/duet-date-picker.js +78 -43
  64. package/lib/collection/components/duet-editable-table/duet-editable-table-button.css +32 -0
  65. package/lib/collection/components/duet-editable-table/duet-editable-table-button.js +218 -0
  66. package/lib/collection/components/duet-editable-table/duet-editable-table-item.css +36 -0
  67. package/lib/collection/components/duet-editable-table/duet-editable-table-item.js +203 -0
  68. package/lib/collection/components/duet-editable-table/duet-editable-table-tabledata.js +13 -0
  69. package/lib/collection/components/duet-editable-table/duet-editable-table.css +16 -0
  70. package/lib/collection/components/duet-editable-table/duet-editable-table.js +348 -0
  71. package/lib/collection/components/duet-footer/duet-footer.js +17 -15
  72. package/lib/collection/components/duet-grid/duet-grid.js +57 -6
  73. package/lib/collection/components/duet-grid-item/duet-grid-item.js +4 -4
  74. package/lib/collection/components/duet-header/duet-header.js +60 -35
  75. package/lib/collection/components/duet-heading/duet-heading.css +4 -0
  76. package/lib/collection/components/duet-heading/duet-heading.js +7 -6
  77. package/lib/collection/components/duet-hero/duet-hero.js +20 -15
  78. package/lib/collection/components/duet-icon/duet-icon.js +2 -6
  79. package/lib/collection/components/duet-icon/icon-utils.js +5 -8
  80. package/lib/collection/components/duet-input/duet-input.css +15 -0
  81. package/lib/collection/components/duet-input/duet-input.js +4 -4
  82. package/lib/collection/components/duet-label/duet-label.css +2 -0
  83. package/lib/collection/components/duet-link/duet-link.js +18 -19
  84. package/lib/collection/components/duet-logo/duet-logo.js +4 -4
  85. package/lib/collection/components/duet-modal/duet-modal.js +22 -17
  86. package/lib/collection/components/duet-notification/duet-notification.js +8 -8
  87. package/lib/collection/components/duet-notification-drawer/duet-notification-drawer.js +20 -15
  88. package/lib/collection/components/duet-number-input/duet-number-input.js +153 -29
  89. package/lib/collection/components/duet-paragraph/duet-paragraph.css +6 -0
  90. package/lib/collection/components/duet-paragraph/duet-paragraph.js +34 -3
  91. package/lib/collection/components/duet-progress/duet-progress.css +103 -0
  92. package/lib/collection/components/duet-progress/duet-progress.js +240 -0
  93. package/lib/collection/components/duet-radio/duet-radio.js +6 -6
  94. package/lib/collection/components/duet-select/duet-select.css +15 -0
  95. package/lib/collection/components/duet-select/duet-select.js +3 -3
  96. package/lib/collection/components/duet-step/duet-step.js +8 -8
  97. package/lib/collection/components/duet-tab-group/duet-tab-group.css +2 -2
  98. package/lib/collection/components/duet-tab-group/duet-tab-group.js +43 -12
  99. package/lib/collection/components/duet-textarea/duet-textarea.css +19 -0
  100. package/lib/collection/components/duet-textarea/duet-textarea.js +5 -4
  101. package/lib/collection/components/duet-tooltip/duet-tooltip.js +82 -20
  102. package/lib/collection/components/duet-tray/duet-tray.js +79 -17
  103. package/lib/collection/components/duet-upload/duet-upload-aria-status.js +217 -0
  104. package/lib/collection/components/duet-upload/duet-upload-editable-item-error.js +16 -0
  105. package/lib/collection/components/duet-upload/duet-upload-editable-item-inprogres.js +8 -0
  106. package/lib/collection/components/duet-upload/duet-upload-editable-item-success.js +30 -0
  107. package/lib/collection/components/duet-upload/duet-upload.css +17 -86
  108. package/lib/collection/components/duet-upload/duet-upload.js +551 -153
  109. package/lib/collection/components/duet-upload/errorcodes.utils.js +16 -4
  110. package/lib/collection/components/duet-upload/xhr.helpers.js +2 -6
  111. package/lib/collection/utils/fixture-utils.js +7 -5
  112. package/lib/collection/utils/js-utils.js +12 -0
  113. package/lib/collection/utils/language-utils.js +26 -9
  114. package/lib/collection/utils/string-utils.js +6 -0
  115. package/lib/collection/utils/watch-options.js +35 -6
  116. package/lib/custom-elements-bundle/index.d.ts +30 -0
  117. package/lib/custom-elements-bundle/index.js +1603 -721
  118. package/lib/duet/duet.esm.js +1 -1
  119. package/lib/duet/duet.js +1 -1
  120. package/lib/duet/{p-4a7911fd.entry.js → p-00735436.entry.js} +1 -1
  121. package/lib/duet/p-060d79be.entry.js +4 -0
  122. package/lib/duet/p-0d22396e.system.js +16 -0
  123. package/lib/duet/p-10deead0.system.js +4 -0
  124. package/lib/duet/p-1208c84f.entry.js +4 -0
  125. package/lib/duet/p-12721178.js +4 -0
  126. package/lib/duet/p-155ef581.system.entry.js +4 -0
  127. package/lib/duet/p-16c48c5d.entry.js +4 -0
  128. package/lib/duet/p-1797df7b.system.entry.js +4 -0
  129. package/lib/duet/p-1a08fc22.system.entry.js +4 -0
  130. package/lib/duet/{p-d1817efe.system.entry.js → p-237e47b4.system.entry.js} +1 -1
  131. package/lib/duet/p-2443bdca.system.entry.js +4 -0
  132. package/lib/duet/p-263bc9cd.system.entry.js +4 -0
  133. package/lib/duet/p-2764f081.js +4 -0
  134. package/lib/duet/p-27d80cef.system.entry.js +4 -0
  135. package/lib/duet/p-28e02c08.entry.js +4 -0
  136. package/lib/duet/{p-f81d8534.entry.js → p-2bb1460c.entry.js} +1 -1
  137. package/lib/duet/p-33c58756.entry.js +4 -0
  138. package/lib/duet/{p-bd9a7d8f.js → p-35a3794e.js} +0 -0
  139. package/lib/duet/{p-bbc229d8.system.entry.js → p-374fb7e6.system.entry.js} +1 -1
  140. package/lib/duet/p-387823af.system.entry.js +4 -0
  141. package/lib/duet/p-3af5d66f.entry.js +4 -0
  142. package/lib/duet/{p-322d1c38.js → p-3c1971d8.js} +1 -1
  143. package/lib/duet/{p-7e108b7e.entry.js → p-4607af59.entry.js} +1 -1
  144. package/lib/duet/p-48d1eb1f.system.entry.js +4 -0
  145. package/lib/duet/p-4a87e9ab.system.entry.js +4 -0
  146. package/lib/duet/{p-031c2cd8.system.entry.js → p-4b6ebe40.system.entry.js} +1 -1
  147. package/lib/duet/p-4e28da18.system.entry.js +4 -0
  148. package/lib/duet/p-548d484e.js +4 -0
  149. package/lib/duet/p-5826523b.entry.js +4 -0
  150. package/lib/duet/{p-ce1374a4.system.entry.js → p-58750bae.system.entry.js} +1 -1
  151. package/lib/duet/p-597d99c7.entry.js +4 -0
  152. package/lib/duet/p-5ea0cd19.entry.js +4 -0
  153. package/lib/duet/p-63d5bf73.system.entry.js +4 -0
  154. package/lib/duet/p-67d9a9a9.system.entry.js +4 -0
  155. package/lib/duet/p-6a19b5ec.entry.js +4 -0
  156. package/lib/duet/p-6cc3be76.system.entry.js +4 -0
  157. package/lib/duet/p-6e363557.system.js +4 -0
  158. package/lib/duet/p-6e6e76db.system.entry.js +4 -0
  159. package/lib/duet/p-70fafc98.system.js +4 -0
  160. package/lib/duet/p-7368b14e.system.entry.js +4 -0
  161. package/lib/duet/p-751542a0.system.entry.js +4 -0
  162. package/lib/duet/p-794659ac.entry.js +4 -0
  163. package/lib/duet/p-7e8d5bb9.system.entry.js +4 -0
  164. package/lib/duet/p-7fee0d23.system.entry.js +4 -0
  165. package/lib/duet/p-81867417.system.js +4 -0
  166. package/lib/duet/p-86daec1c.entry.js +4 -0
  167. package/lib/duet/{p-4265de16.system.entry.js → p-8b5ca0e7.system.entry.js} +1 -1
  168. package/lib/duet/{p-66dde4d2.entry.js → p-8cb7416d.entry.js} +1 -1
  169. package/lib/duet/p-8f826843.system.entry.js +4 -0
  170. package/lib/duet/p-94169303.entry.js +4 -0
  171. package/lib/duet/{p-36007600.entry.js → p-9481e312.entry.js} +1 -1
  172. package/lib/duet/{p-f82709ba.entry.js → p-984576c9.entry.js} +1 -1
  173. package/lib/duet/p-986779fb.js +4 -0
  174. package/lib/duet/p-987edcd0.js +15 -0
  175. package/lib/duet/{p-35e45c19.system.js → p-9a945278.system.js} +1 -1
  176. package/lib/duet/p-9d73343a.entry.js +4 -0
  177. package/lib/duet/{p-e26116e0.system.entry.js → p-9dca5c22.system.entry.js} +1 -1
  178. package/lib/duet/p-a207b008.entry.js +4 -0
  179. package/lib/duet/p-a5b9c192.system.entry.js +4 -0
  180. package/lib/duet/p-a6a84ec6.entry.js +4 -0
  181. package/lib/duet/{p-2d2c45f9.entry.js → p-a890da72.entry.js} +1 -1
  182. package/lib/duet/p-a9859a82.entry.js +4 -0
  183. package/lib/duet/p-aba68b7b.entry.js +4 -0
  184. package/lib/duet/p-acc57c77.entry.js +4 -0
  185. package/lib/duet/{p-2826f987.js → p-ad07f399.js} +1 -1
  186. package/lib/duet/p-aee24388.system.entry.js +4 -0
  187. package/lib/duet/p-aef1b720.system.entry.js +4 -0
  188. package/lib/duet/{p-62806bb6.system.entry.js → p-af41d894.system.entry.js} +1 -1
  189. package/lib/duet/p-b25d3769.js +4 -0
  190. package/lib/duet/{p-dee41056.system.entry.js → p-b32224fe.system.entry.js} +1 -1
  191. package/lib/duet/p-b3744481.entry.js +4 -0
  192. package/lib/duet/{p-de2be65b.system.js → p-b42d81c3.system.js} +1 -1
  193. package/lib/duet/{p-27d538f7.system.entry.js → p-b4e87f02.system.entry.js} +1 -1
  194. package/lib/duet/{p-f71f12ed.entry.js → p-bf93a991.entry.js} +1 -1
  195. package/lib/duet/{p-fd98468a.system.js → p-c18a599e.system.js} +0 -0
  196. package/lib/duet/p-c2e77278.entry.js +4 -0
  197. package/lib/duet/p-c34329f3.entry.js +4 -0
  198. package/lib/duet/{p-59a07cf9.entry.js → p-c36b4da0.entry.js} +1 -1
  199. package/lib/duet/{p-a321a98c.entry.js → p-cdd70b93.entry.js} +1 -1
  200. package/lib/duet/p-d1c19f04.system.entry.js +4 -0
  201. package/lib/duet/{p-f71e337e.system.entry.js → p-d3a3c3c7.system.entry.js} +1 -1
  202. package/lib/duet/{p-345ea4f2.system.entry.js → p-d4118b6e.system.entry.js} +1 -1
  203. package/lib/duet/{p-3dc9d15d.system.entry.js → p-d744d188.system.entry.js} +1 -1
  204. package/lib/duet/p-ddb6344c.system.js +4 -0
  205. package/lib/duet/p-de07c7d7.entry.js +4 -0
  206. package/lib/duet/p-dfe79666.system.entry.js +4 -0
  207. package/lib/duet/p-e12f2b8b.system.js +4 -0
  208. package/lib/duet/p-e2a44156.js +4 -0
  209. package/lib/duet/p-e76b722f.entry.js +4 -0
  210. package/lib/duet/p-e964d062.entry.js +4 -0
  211. package/lib/duet/p-eb55ccd2.system.js +4 -0
  212. package/lib/duet/p-f0a4b68d.system.entry.js +4 -0
  213. package/lib/duet/p-f364eb96.entry.js +4 -0
  214. package/lib/duet/{p-a88df408.entry.js → p-f8ce39fb.entry.js} +1 -1
  215. package/lib/esm/{dom-21034390.js → dom-58cd15f6.js} +1 -1
  216. package/lib/esm/duet-alert.entry.js +4 -2
  217. package/lib/esm/duet-badge.entry.js +2 -2
  218. package/lib/esm/duet-button_2.entry.js +6 -5
  219. package/lib/esm/duet-caption_4.entry.js +21 -15
  220. package/lib/esm/duet-card.entry.js +6 -6
  221. package/lib/esm/duet-checkbox.entry.js +2 -2
  222. package/lib/esm/duet-choice_2.entry.js +57 -26
  223. package/lib/esm/duet-collapsible.entry.js +5 -2
  224. package/lib/esm/duet-cookie-consent.entry.js +1 -1
  225. package/lib/esm/duet-date-picker.entry.js +23 -13
  226. package/lib/esm/duet-divider_2.entry.js +1 -1
  227. package/lib/esm/duet-editable-table-button_3.entry.js +226 -0
  228. package/lib/esm/{duet-table.entry.js → duet-editable-table_3.entry.js} +205 -3
  229. package/lib/esm/duet-empty-state.entry.js +1 -1
  230. package/lib/esm/duet-footer.entry.js +4 -4
  231. package/lib/esm/duet-grid_2.entry.js +52 -4
  232. package/lib/esm/duet-header_2.entry.js +26 -10
  233. package/lib/esm/duet-hero.entry.js +6 -6
  234. package/lib/esm/duet-icon.entry.js +6 -14
  235. package/lib/esm/duet-input_2.entry.js +7 -7
  236. package/lib/esm/duet-layout.entry.js +1 -1
  237. package/lib/esm/duet-list_2.entry.js +2 -2
  238. package/lib/esm/duet-modal.entry.js +8 -7
  239. package/lib/esm/duet-notification_2.entry.js +6 -5
  240. package/lib/esm/duet-number-input.entry.js +36 -15
  241. package/lib/esm/duet-progress.entry.js +71 -0
  242. package/lib/esm/duet-radio_2.entry.js +2 -2
  243. package/lib/esm/duet-range-slider.entry.js +2 -2
  244. package/lib/esm/duet-select.entry.js +6 -6
  245. package/lib/esm/duet-step_2.entry.js +1 -1
  246. package/lib/esm/duet-tab_2.entry.js +12 -6
  247. package/lib/esm/duet-textarea.entry.js +5 -5
  248. package/lib/esm/duet-toggle.entry.js +1 -1
  249. package/lib/esm/duet-tooltip.entry.js +21 -10
  250. package/lib/esm/duet-tray.entry.js +21 -10
  251. package/lib/esm/duet-upload.entry.js +403 -180
  252. package/lib/esm/duet-visually-hidden.entry.js +1 -1
  253. package/lib/esm/duet.js +4 -4
  254. package/lib/esm/{focus-utils-0b12f0df.js → focus-utils-1fe0dcd0.js} +1 -1
  255. package/lib/esm/{index-f70ddc7f.js → index-84d97bd1.js} +88 -78
  256. package/lib/esm/js-utils-b69f17df.js +14 -0
  257. package/lib/esm/{language-utils-ab9c3afc.js → language-utils-344d894c.js} +28 -10
  258. package/lib/esm/loader.js +3 -3
  259. package/lib/esm/{shadow-css-31e2d504.js → shadow-css-7c726abb.js} +9 -10
  260. package/lib/esm/{string-utils-69cf0d09.js → string-utils-2f1793b8.js} +7 -1
  261. package/lib/esm/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
  262. package/lib/esm/{tokens.module-edb66c04.js → tokens.module-49cbf963.js} +3 -1
  263. package/lib/esm/watch-options-dd55bce8.js +57 -0
  264. package/lib/esm-es5/{dom-21034390.js → dom-58cd15f6.js} +0 -0
  265. package/lib/esm-es5/duet-alert.entry.js +1 -1
  266. package/lib/esm-es5/duet-badge.entry.js +1 -1
  267. package/lib/esm-es5/duet-button_2.entry.js +1 -1
  268. package/lib/esm-es5/duet-caption_4.entry.js +2 -2
  269. package/lib/esm-es5/duet-card.entry.js +1 -1
  270. package/lib/esm-es5/duet-checkbox.entry.js +1 -1
  271. package/lib/esm-es5/duet-choice_2.entry.js +2 -2
  272. package/lib/esm-es5/duet-collapsible.entry.js +1 -1
  273. package/lib/esm-es5/duet-cookie-consent.entry.js +1 -1
  274. package/lib/esm-es5/duet-date-picker.entry.js +1 -1
  275. package/lib/esm-es5/duet-divider_2.entry.js +1 -1
  276. package/lib/esm-es5/duet-editable-table-button_3.entry.js +4 -0
  277. package/lib/esm-es5/duet-editable-table_3.entry.js +4 -0
  278. package/lib/esm-es5/duet-empty-state.entry.js +1 -1
  279. package/lib/esm-es5/duet-footer.entry.js +1 -1
  280. package/lib/esm-es5/duet-grid_2.entry.js +2 -2
  281. package/lib/esm-es5/duet-header_2.entry.js +1 -1
  282. package/lib/esm-es5/duet-hero.entry.js +1 -1
  283. package/lib/esm-es5/duet-icon.entry.js +2 -2
  284. package/lib/esm-es5/duet-input_2.entry.js +1 -1
  285. package/lib/esm-es5/duet-layout.entry.js +1 -1
  286. package/lib/esm-es5/duet-list_2.entry.js +1 -1
  287. package/lib/esm-es5/duet-modal.entry.js +1 -1
  288. package/lib/esm-es5/duet-notification_2.entry.js +1 -1
  289. package/lib/esm-es5/duet-number-input.entry.js +2 -2
  290. package/lib/esm-es5/duet-progress.entry.js +4 -0
  291. package/lib/esm-es5/duet-radio_2.entry.js +1 -1
  292. package/lib/esm-es5/duet-range-slider.entry.js +1 -1
  293. package/lib/esm-es5/duet-select.entry.js +1 -1
  294. package/lib/esm-es5/duet-step_2.entry.js +1 -1
  295. package/lib/esm-es5/duet-tab_2.entry.js +2 -2
  296. package/lib/esm-es5/duet-textarea.entry.js +1 -1
  297. package/lib/esm-es5/duet-toggle.entry.js +1 -1
  298. package/lib/esm-es5/duet-tooltip.entry.js +1 -1
  299. package/lib/esm-es5/duet-tray.entry.js +1 -1
  300. package/lib/esm-es5/duet-upload.entry.js +2 -2
  301. package/lib/esm-es5/duet-visually-hidden.entry.js +1 -1
  302. package/lib/esm-es5/duet.js +1 -1
  303. package/lib/esm-es5/{focus-utils-0b12f0df.js → focus-utils-1fe0dcd0.js} +1 -1
  304. package/lib/esm-es5/index-84d97bd1.js +4 -0
  305. package/lib/esm-es5/js-utils-b69f17df.js +4 -0
  306. package/lib/esm-es5/language-utils-344d894c.js +4 -0
  307. package/lib/esm-es5/loader.js +1 -1
  308. package/lib/esm-es5/shadow-css-7c726abb.js +15 -0
  309. package/lib/esm-es5/{string-utils-69cf0d09.js → string-utils-2f1793b8.js} +1 -1
  310. package/lib/esm-es5/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
  311. package/lib/esm-es5/tokens.module-49cbf963.js +4 -0
  312. package/lib/esm-es5/watch-options-dd55bce8.js +4 -0
  313. package/lib/types/components/duet-alert/duet-alert.d.ts +2 -1
  314. package/lib/types/components/duet-button/duet-button.d.ts +1 -1
  315. package/lib/types/components/duet-choice/duet-choice.d.ts +24 -5
  316. package/lib/types/components/duet-date-picker/duet-date-picker.d.ts +15 -9
  317. package/lib/types/components/duet-editable-table/duet-editable-table-button.d.ts +72 -0
  318. package/lib/types/components/duet-editable-table/duet-editable-table-item.d.ts +72 -0
  319. package/lib/types/components/duet-editable-table/duet-editable-table-tabledata.d.ts +7 -0
  320. package/lib/types/components/duet-editable-table/duet-editable-table.d.ts +84 -0
  321. package/lib/types/components/duet-footer/duet-footer.d.ts +1 -1
  322. package/lib/types/components/duet-grid/duet-grid.d.ts +16 -2
  323. package/lib/types/components/duet-header/duet-header.d.ts +21 -5
  324. package/lib/types/components/duet-heading/duet-heading.d.ts +2 -2
  325. package/lib/types/components/duet-hero/duet-hero.d.ts +3 -3
  326. package/lib/types/components/duet-icon/duet-icon.d.ts +1 -1
  327. package/lib/types/components/duet-link/duet-link.d.ts +2 -3
  328. package/lib/types/components/duet-modal/duet-modal.d.ts +3 -3
  329. package/lib/types/components/duet-notification-drawer/duet-notification-drawer.d.ts +3 -3
  330. package/lib/types/components/duet-number-input/duet-number-input.d.ts +21 -0
  331. package/lib/types/components/duet-paragraph/duet-paragraph.d.ts +9 -1
  332. package/lib/types/components/duet-progress/duet-progress.d.ts +64 -0
  333. package/lib/types/components/duet-tab-group/duet-tab-group.d.ts +6 -0
  334. package/lib/types/components/duet-tooltip/duet-tooltip.d.ts +11 -0
  335. package/lib/types/components/duet-tray/duet-tray.d.ts +11 -0
  336. package/lib/types/components/duet-upload/duet-upload-aria-status.d.ts +49 -0
  337. package/lib/types/components/duet-upload/duet-upload-editable-item-error.d.ts +7 -0
  338. package/lib/types/components/duet-upload/duet-upload-editable-item-inprogres.d.ts +7 -0
  339. package/lib/types/components/duet-upload/duet-upload-editable-item-success.d.ts +8 -0
  340. package/lib/types/components/duet-upload/duet-upload.d.ts +94 -25
  341. package/lib/types/components/duet-upload/errorcodes.utils.d.ts +1 -0
  342. package/lib/types/components/duet-upload/xhr.helpers.d.ts +7 -1
  343. package/lib/types/components.d.ts +611 -79
  344. package/lib/types/utils/js-utils.d.ts +1 -0
  345. package/lib/types/utils/language-utils.d.ts +8 -3
  346. package/lib/types/utils/string-utils.d.ts +1 -0
  347. package/lib/types/utils/watch-options.d.ts +2 -0
  348. package/package.json +19 -15
  349. package/hydrate/package.json +0 -6
  350. package/lib/cjs/duet-fieldset.cjs.entry.js +0 -62
  351. package/lib/collection/components/duet-upload/duet-upload-file-list.js +0 -49
  352. package/lib/duet/p-0733c303.system.entry.js +0 -4
  353. package/lib/duet/p-095060cc.js +0 -4
  354. package/lib/duet/p-156864a1.system.entry.js +0 -4
  355. package/lib/duet/p-15c15c6a.js +0 -15
  356. package/lib/duet/p-1911dfe7.system.entry.js +0 -4
  357. package/lib/duet/p-1c41525a.entry.js +0 -4
  358. package/lib/duet/p-1cfe38b1.system.entry.js +0 -4
  359. package/lib/duet/p-2834a302.entry.js +0 -4
  360. package/lib/duet/p-28a3d38f.system.entry.js +0 -4
  361. package/lib/duet/p-2a1a9f9f.entry.js +0 -4
  362. package/lib/duet/p-2a4d7c5b.system.entry.js +0 -4
  363. package/lib/duet/p-3eb36e3d.entry.js +0 -4
  364. package/lib/duet/p-4095dba5.entry.js +0 -4
  365. package/lib/duet/p-418b2ce7.system.js +0 -4
  366. package/lib/duet/p-4289b543.entry.js +0 -4
  367. package/lib/duet/p-43e39d98.system.js +0 -4
  368. package/lib/duet/p-46a3ae43.system.js +0 -4
  369. package/lib/duet/p-4a38cf9d.entry.js +0 -4
  370. package/lib/duet/p-4be8e814.entry.js +0 -4
  371. package/lib/duet/p-4dcea8fb.system.entry.js +0 -4
  372. package/lib/duet/p-591b2137.entry.js +0 -4
  373. package/lib/duet/p-5c5bdb06.system.entry.js +0 -4
  374. package/lib/duet/p-5f70e318.entry.js +0 -4
  375. package/lib/duet/p-62c294d6.system.entry.js +0 -4
  376. package/lib/duet/p-6a356ab1.system.js +0 -4
  377. package/lib/duet/p-6c2729da.js +0 -4
  378. package/lib/duet/p-6f107847.system.entry.js +0 -4
  379. package/lib/duet/p-77a5fe4c.system.js +0 -4
  380. package/lib/duet/p-7809e78b.system.entry.js +0 -4
  381. package/lib/duet/p-7a36d76f.system.entry.js +0 -4
  382. package/lib/duet/p-7ee52f58.entry.js +0 -4
  383. package/lib/duet/p-884693f1.entry.js +0 -4
  384. package/lib/duet/p-89db3b94.entry.js +0 -4
  385. package/lib/duet/p-8cfce39e.system.entry.js +0 -4
  386. package/lib/duet/p-8ffe1461.system.entry.js +0 -4
  387. package/lib/duet/p-9381c2d4.entry.js +0 -4
  388. package/lib/duet/p-9a450c9a.entry.js +0 -4
  389. package/lib/duet/p-9a89ec39.js +0 -4
  390. package/lib/duet/p-9bbfe606.system.entry.js +0 -4
  391. package/lib/duet/p-a6096b05.system.entry.js +0 -4
  392. package/lib/duet/p-a89d5d7c.entry.js +0 -4
  393. package/lib/duet/p-b07055fd.system.entry.js +0 -4
  394. package/lib/duet/p-b4374f0e.entry.js +0 -4
  395. package/lib/duet/p-b456d684.system.entry.js +0 -4
  396. package/lib/duet/p-bd18c93f.js +0 -4
  397. package/lib/duet/p-bddb1c15.system.entry.js +0 -4
  398. package/lib/duet/p-c0b95b58.entry.js +0 -4
  399. package/lib/duet/p-c3688975.entry.js +0 -4
  400. package/lib/duet/p-c4d183e6.entry.js +0 -4
  401. package/lib/duet/p-c9303f9a.entry.js +0 -4
  402. package/lib/duet/p-cd4e8ccf.js +0 -4
  403. package/lib/duet/p-ceb75b35.system.entry.js +0 -4
  404. package/lib/duet/p-cf243bcb.system.entry.js +0 -4
  405. package/lib/duet/p-d37c8a05.system.js +0 -4
  406. package/lib/duet/p-d989af11.entry.js +0 -4
  407. package/lib/duet/p-e58ca7af.system.js +0 -16
  408. package/lib/duet/p-e6128d82.system.entry.js +0 -4
  409. package/lib/duet/p-e86cdc17.entry.js +0 -4
  410. package/lib/duet/p-eadb29c7.entry.js +0 -4
  411. package/lib/duet/p-f30b14d6.system.entry.js +0 -4
  412. package/lib/duet/p-f79f8da1.entry.js +0 -4
  413. package/lib/duet/p-fc397e03.system.entry.js +0 -4
  414. package/lib/esm/duet-fieldset.entry.js +0 -58
  415. package/lib/esm/watch-options-de55ea78.js +0 -35
  416. package/lib/esm-es5/duet-fieldset.entry.js +0 -4
  417. package/lib/esm-es5/duet-table.entry.js +0 -4
  418. package/lib/esm-es5/index-f70ddc7f.js +0 -4
  419. package/lib/esm-es5/language-utils-ab9c3afc.js +0 -4
  420. package/lib/esm-es5/shadow-css-31e2d504.js +0 -15
  421. package/lib/esm-es5/tokens.module-edb66c04.js +0 -4
  422. package/lib/esm-es5/watch-options-de55ea78.js +0 -4
  423. package/lib/html.html-data.json +0 -4556
  424. package/lib/types/components/duet-upload/duet-upload-file-list.d.ts +0 -9
@@ -1,183 +1,129 @@
1
1
  /*!
2
2
  * Built with Duet Design System
3
3
  */
4
- import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-f70ddc7f.js';
4
+ import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-84d97bd1.js';
5
5
  import { c as createID } from './create-id-981107da.js';
6
- import { g as getLocaleString } from './language-utils-ab9c3afc.js';
6
+ import { d as debounce } from './js-utils-b69f17df.js';
7
+ import { g as getLocaleString } from './language-utils-344d894c.js';
7
8
  import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
9
+ import './string-utils-2f1793b8.js';
8
10
 
9
- const formatBytes = (bytes, decimals = 2) => {
10
- if (bytes === 0) {
11
- return "0 Bytes";
12
- }
13
- const k = 1024;
14
- const dm = decimals < 0 ? 0 : decimals;
15
- const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
16
- const i = Math.floor(Math.log(bytes) / Math.log(k));
17
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
18
- };
19
-
20
- const DuetUploadFileList = ({ data, onDelete, onCancel, getError }) => {
21
- if (data.invalid.length === 0 && data.valid.length === 0) {
22
- return;
23
- }
24
- return (h("ol", { class: "duet-upload-filelist" },
25
- data.valid.length !== 0 && (h("li", null,
26
- h("duet-visually-hidden", null, "Files"),
27
- h("ul", null, data.valid.length !== 0 &&
28
- data.valid.map(e => (h("li", { class: "duet-upload-file" },
29
- h("div", { class: "duet-upload-file-container" },
30
- h("div", { class: "duet-upload-file-link" }, e.url ? (h("duet-button", { variation: "plain", icon: "messaging-attachment", url: e.url },
31
- e.item.name,
32
- " (",
33
- formatBytes(e.item.size),
34
- ")")) : (`${e.item.name} (${formatBytes(e.item.size)})`)),
35
- h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
36
- e.progress < 100 && (h("li", { role: "none" },
37
- h("duet-button", { role: "menuitem", variation: "plain", icon: "messaging-declined", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onCancel(e.item.name, ev) }))),
38
- e.progress === 100 && (h("li", { role: "none" },
39
- h("duet-button", { role: "menuitem", variation: "destructive", icon: "action-delete", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onDelete(e.item.name, ev) }))))),
40
- e.progress < 100 && (h("div", { class: "duet-upload-file-progress" },
41
- h("progress", { value: e.progress, max: "100" },
42
- h("div", { class: "progress-bar" },
43
- h("span", { style: { width: `${e.progress}%;` } },
44
- "Progress: ",
45
- e.progress,
46
- "%"))))))))))),
47
- data.invalid.length !== 0 && (h("li", null,
48
- h("duet-visually-hidden", null, "Files with Errors"),
49
- h("ul", null, data.invalid.map(e => {
50
- return (h("li", { class: "duet-upload-file duet-upload-file-errors" },
51
- h("div", { class: "duet-upload-file-container" },
52
- h("div", { class: "duet-upload-file-link duet-upload-file-link-error" },
53
- h("div", null,
54
- e.item.name,
55
- " (",
56
- formatBytes(e.item.size),
57
- ")"),
58
- h("div", { "data-error-type": e.error.type, "data-error-message": e.error.system_message }, getError(e.error.type))),
59
- h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
60
- h("li", { role: "none" },
61
- h("duet-button", { role: "menuitem", variation: "destructive", icon: "action-delete", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onDelete(e.item.name, ev) }))))));
62
- }))))));
63
- };
64
-
65
- const errorcodes = [
11
+ const errorCodes = [
66
12
  {
67
13
  type: "default",
68
14
  system_message: "unknown error",
69
15
  message: {
70
- fi: "",
71
- sv: "",
72
- en: "An unknown error occured, please try again"
16
+ fi: "Tapahtui tuntematon virhe, ole hyvä ja yritä uudelleen.",
17
+ sv: "Ett okänt fel uppstod, försök igen.",
18
+ en: "An unknown error occured, please try again."
73
19
  }
74
20
  },
75
21
  {
76
22
  type: "400",
77
23
  system_message: "Bad Request: The server could not understand the request due to invalid syntax.",
78
24
  message: {
79
- fi: "",
80
- sv: "",
81
- en: "The server rejected your file"
25
+ fi: "Tiedostoa ei hyväksytty.",
26
+ sv: "Servern avvisade din fil.",
27
+ en: "The server rejected your file."
82
28
  }
83
29
  },
84
30
  {
85
31
  type: "401",
86
- system_message: "Not Authenticated: The client must authenticate itself to get the requested response..",
32
+ system_message: "Not Authenticated: The client must authenticate itself to get the requested response...",
87
33
  message: {
88
- fi: "",
89
- sv: "",
90
- en: "You need to be logged in to upload files"
34
+ fi: "Vain kirjautunut käyttäjä voi lähettää tiedostoja.",
35
+ sv: "Du måste vara inloggad för att ladda upp filer.",
36
+ en: "You need to be logged in to upload files."
91
37
  }
92
38
  },
93
39
  {
94
40
  type: "403",
95
- system_message: "No Access: The client does not have access rights to the content;",
41
+ system_message: "No Access: The client does not have access rights to the content.",
96
42
  message: {
97
- fi: "",
98
- sv: "",
99
- en: "You do not have the correct access rights to upload files"
43
+ fi: "Ei oikeuksia lähettää tiedostoja.",
44
+ sv: "Du har inte rätt åtkomsträttigheter för att ladda upp filer.",
45
+ en: "You do not have the correct access rights to upload files."
100
46
  }
101
47
  },
102
48
  {
103
49
  type: "413",
104
50
  system_message: "Payload too large",
105
51
  message: {
106
- fi: "",
107
- sv: "",
108
- en: "The file was to large for the server to handle"
52
+ fi: "Tiedosto oli liian vastaanotettavaksi.",
53
+ sv: "Filen var för stor för servern att hantera.",
54
+ en: "The file was to large for the server to handle."
109
55
  }
110
56
  },
111
57
  {
112
58
  type: "415",
113
59
  system_message: "Unsupported media type",
114
60
  message: {
115
- fi: "",
116
- sv: "",
117
- en: "The server rejected the file because it had the wrong type"
61
+ fi: "Tiedoston tyyppi oli väärä.",
62
+ sv: "Servern avvisade filen eftersom den hade fel typ.",
63
+ en: "The server rejected the file because it had the wrong type."
118
64
  }
119
65
  },
120
66
  {
121
67
  type: "429",
122
68
  system_message: "Too many request from same address",
123
69
  message: {
124
- fi: "",
125
- sv: "",
126
- en: "The server has received to many request from you, please try again later"
70
+ fi: "Liian monta yritystä, ole hyvä ja yritä myöhemmin uudelleen.",
71
+ sv: "Servern har fått många förfrågningar från dig, försök igen senare.",
72
+ en: "The server has received to many request from you, please try again later."
127
73
  }
128
74
  },
129
75
  {
130
76
  type: "500",
131
77
  system_message: "Internal Server Error",
132
78
  message: {
133
- fi: "",
134
- sv: "",
135
- en: "The server reported an unknown error and the upload failed"
79
+ fi: "Palvelin ilmoitti tuntemattomasta virheestä ja lataus epäonnistui.",
80
+ sv: "Servern rapporterade ett okänt fel och uppladdningen misslyckades.",
81
+ en: "The server reported an unknown error and the upload failed."
136
82
  }
137
83
  },
138
84
  {
139
85
  type: "duet-upload-100",
140
86
  system_message: "File extension not allowed",
141
87
  message: {
142
- fi: "",
143
- sv: "",
144
- en: "You cannot upload files with that extension"
88
+ fi: "Tiedoston tyyppi ei ole sallittu.",
89
+ sv: "Du kan inte ladda upp filer av den type.",
90
+ en: "You cannot upload files with that extension."
145
91
  }
146
92
  },
147
93
  {
148
94
  type: "duet-upload-001",
149
95
  system_message: "File transfer failed",
150
96
  message: {
151
- fi: "",
152
- sv: "",
153
- en: "Your connection to the server was interrupted, try again"
97
+ fi: "Tiedoston lähetys keskeytyi, ole hyvä ja yritä uudelleen.",
98
+ sv: "Din anslutning till servern avbröts, försök igen.",
99
+ en: "Your connection to the server was interrupted, try again."
154
100
  }
155
101
  },
156
102
  {
157
103
  type: "duet-upload-101",
158
104
  system_message: "File mimetype not allowed",
159
105
  message: {
160
- fi: "",
161
- sv: "",
162
- en: "You cannot upload files of that type"
106
+ fi: "Tiedoston tyyppi ei ole sallittu.",
107
+ sv: "Du kan inte ladda upp filer av den typ.",
108
+ en: "You cannot upload files of that type."
163
109
  }
164
110
  },
165
111
  {
166
112
  type: "duet-upload-201",
167
113
  system_message: "File is too large",
168
114
  message: {
169
- fi: "",
170
- sv: "",
171
- en: "The file is larger than permitted"
115
+ fi: "Tiedosto on liian iso.",
116
+ sv: "Filen är större än tillåtet.",
117
+ en: "The file is larger than permitted."
172
118
  }
173
119
  },
174
120
  {
175
121
  type: "duet-upload-202",
176
122
  system_message: "The combined size of all files is too large",
177
123
  message: {
178
- fi: "",
179
- sv: "",
180
- en: "You have reached the maximum combined filesize"
124
+ fi: "Tiedostojen yhteenlaskettu koko on liian iso.",
125
+ sv: "Du har nått den maximala kombinerade filstorleken.",
126
+ en: "You have reached the maximum combined filesize."
181
127
  }
182
128
  },
183
129
  {
@@ -185,7 +131,7 @@ const errorcodes = [
185
131
  system_message: "The maximum file limit has been reached",
186
132
  message: {
187
133
  fi: "Liitteiden maksimimäärä saavutettu.",
188
- sv: "",
134
+ sv: "Maximalt antal bilagor har uppnåtts.",
189
135
  en: "Maximum number of attachments reached."
190
136
  }
191
137
  }
@@ -197,16 +143,81 @@ const getError = (code) => {
197
143
  system_message: undefined,
198
144
  message: undefined,
199
145
  };
200
- error = errorcodes.filter(errorItem => {
201
- return errorItem.type === code;
146
+ error = errorCodes.filter(errorItem => {
147
+ // the == is intentional we may be comparing numbers to strings - and that is ok here
148
+ return errorItem.type == code;
202
149
  })[0];
203
150
  if (!error) {
204
- error = errorcodes.filter(errorItem => {
151
+ error = errorCodes.filter(errorItem => {
205
152
  return errorItem.type === "default";
206
153
  })[0];
207
154
  }
208
155
  return error;
209
156
  };
157
+ const getI18nError = (errorCode) => {
158
+ const errorFromJson = getError(errorCode);
159
+ const i18String = getLocaleString(errorFromJson.message);
160
+ if (i18String === "" || !i18String) {
161
+ return errorFromJson.system_message;
162
+ }
163
+ else {
164
+ return i18String;
165
+ }
166
+ };
167
+
168
+ const ErrorItem = ({ data }) => {
169
+ const { item, error } = data;
170
+ const { name } = item;
171
+ const { type } = error;
172
+ return (h("span", { class: "duet-upload-item-error", role: "status" },
173
+ h("duet-paragraph", { class: "duet-upload-item-name", color: "danger", margin: "none", weight: "semi-bold" },
174
+ h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
175
+ " ",
176
+ name),
177
+ h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type))));
178
+ };
179
+
180
+ const ProgressItem = ({ progress, name }) => (h("span", null,
181
+ h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
182
+ h("duet-spacer", { size: "xx-small" }),
183
+ h("duet-progress", { progress: Math.ceil(progress), "aria-hidden": true })));
184
+
185
+ const formatBytes = (bytes, decimals = 2) => {
186
+ if (bytes === 0) {
187
+ return "0 Bytes";
188
+ }
189
+ const k = 1024;
190
+ const dm = decimals < 0 ? 0 : decimals;
191
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
192
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
193
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
194
+ };
195
+
196
+ const SuccessItem = ({ data, showLinks }) => {
197
+ const { item, size, uploaded, url, meta } = data;
198
+ const { name } = item;
199
+ const ContentName = (h("span", { class: "duet-upload-item-name" },
200
+ h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
201
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
202
+ name));
203
+ const SizeText = (h("span", { class: "duet-upload-item-size", style: { fontSize: "14px", fontWeight: "400" } },
204
+ "(",
205
+ formatBytes(size),
206
+ ")"));
207
+ const FilenameLine = uploaded && url && showLinks ? (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
208
+ h("duet-link", { url: url, external: true }, ContentName),
209
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
210
+ SizeText)) : (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
211
+ ContentName,
212
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
213
+ SizeText));
214
+ const Badges = meta && meta.badges ? (h("span", null,
215
+ h("duet-spacer", { size: "xx-small" }),
216
+ meta.badges.map(badgeText => (h("duet-badge", { color: "primary" }, badgeText))))) : undefined;
217
+ return (h("span", { class: "duet-upload-item-success" },
218
+ h("div", null, FilenameLine),
219
+ Badges));
220
+ };
210
221
 
211
222
  const validateFileExtension = (name, allowedExtensions) => {
212
223
  if (!allowedExtensions) {
@@ -297,12 +308,8 @@ const validateTotalAmountIsAboveMax = (filelist, maxFiles) => {
297
308
  return false;
298
309
  };
299
310
 
300
- const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
301
- const { type, xhr, uri, argument, headers } = Object.assign({
302
- type: "POST",
303
- argument: null,
304
- headers: null,
305
- }, options);
311
+ const makeXhrRequest = ({ payload, options, onFailure, onSuccess, onProgress }) => {
312
+ const { type = "POST", xhr, uri, argument = null, headers = null } = options;
306
313
  xhr.open(type, `${uri}${argument || ""}`, true);
307
314
  const { data, name } = payload;
308
315
  // headers must be added after open
@@ -329,7 +336,7 @@ const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
329
336
  return xhr;
330
337
  };
331
338
 
332
- const duetUploadCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host li{list-style:none}.duet-upload{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}.duet-upload li{list-style:none}.duet-upload-file-errors{padding:20px 0;color:#de2362}.duet-upload-filelist{margin-bottom:25px}.duet-upload-filelist-empty{display:flex;align-items:center;justify-content:center;width:100%;height:75px;margin:0 auto;background-color:#f3f9fc}.duet-upload-file{display:flex;flex-flow:column;justify-content:center;min-height:50px;border-bottom:1px solid #e1e3e6}.duet-upload-file:first-of-type:not(.duet-upload-file-errors){border-top:1px solid #e1e3e6}.duet-upload-file-container{display:flex;place-items:center;width:100%}.duet-upload-file-link{display:flex;flex-grow:2;place-items:center}.duet-upload-file-link-error{flex-direction:column;place-items:flex-start}.duet-upload-file-link duet-button{position:relative;top:6px}.duet-upload-file-actions{display:flex;transform:scale(0.8)}.duet-upload-file-progress{}.duet-upload-file-progress .progress-bar{position:relative;display:block;width:100%;height:15px;background-color:#f3f9fc;border-radius:0;box-shadow:none}.duet-upload-file-progress .progress-bar>span{display:block;text-indent:-9999px;background-color:#0077b3;border-radius:0}.duet-upload-file-progress progress[value]{display:flex;width:100%;height:15px;color:#0077b3;border:0 none;-webkit-appearance:none;-moz-appearance:none;appearance:none}.duet-upload-file-progress progress[value]::-webkit-progress-bar{background-color:#f3f9fc;border-radius:0}.duet-upload-file-progress progress[value]::-webkit-progress-value{background-color:#0077b3;background-size:35px 20px, 100% 100%, 100% 100%;border-radius:0;-webkit-animation:animate-stripes 5s linear infinite;animation:animate-stripes 5s linear infinite}.duet-upload-file-progress progress[value] ::-moz-progress-bar{background-color:#f3f9fc}";
339
+ const duetUploadCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}::slotted([slot=header]){margin-bottom:16px}::slotted([slot=fileheader]){margin:16px 0 0 0}::slotted([slot=filefooter]){margin-top:16px}.duet-upload{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}.duet-upload-item-size{font-size:0.75rem;font-weight:400}.duet-upload-filelist{margin-bottom:25px}.duet-upload-filelist-empty{display:flex;align-items:center;justify-content:center;width:100%;height:75px;margin:0 auto;font-size:1rem;font-weight:400;background-color:#f5f8fa}";
333
340
 
334
341
  let DuetUpload = class {
335
342
  constructor(hostRef) {
@@ -349,9 +356,19 @@ let DuetUpload = class {
349
356
  this.buttonId = createID("DuetButton");
350
357
  this.labelId = createID("DuetLabel");
351
358
  this.uploadId = createID("DuetUpload");
359
+ this.editableTableId = createID("DuetEditableTable");
352
360
  this.filesInProgress = new Map();
353
361
  this.fileMaxReached = false;
354
362
  this.bytesMaxReached = false;
363
+ //region Internally exposed properties
364
+ /**
365
+ * Properties
366
+ */
367
+ this.DefaultGroups = {
368
+ inprogress: "inprogress",
369
+ success: "success",
370
+ failure: "failure",
371
+ };
355
372
  /**
356
373
  * State() variables
357
374
  */
@@ -361,9 +378,91 @@ let DuetUpload = class {
361
378
  * it will be up to you to handle the upload and return progress information to the upload-component
362
379
  */
363
380
  this.external = false;
381
+ /**
382
+ * If set the upload component will not display an upload button, you will have to create on yourself
383
+ * and call the exposed methods startUpload
384
+ */
385
+ this.hideButton = false;
386
+ /**
387
+ * Default actions added to all files
388
+ */
389
+ this.actions = [
390
+ {
391
+ icon: "action-delete",
392
+ color: "color-danger",
393
+ color_hover: "category-home",
394
+ id: "delete",
395
+ map: ["success", "failure"],
396
+ label: {
397
+ fi: "Poista tiedosto",
398
+ en: "Poista tiedosto",
399
+ sv: "Ta bort filen",
400
+ },
401
+ },
402
+ {
403
+ icon: "navigation-close",
404
+ color: "primary",
405
+ color_hover: "category-home",
406
+ id: "cancel",
407
+ map: ["inprogress"],
408
+ label: {
409
+ fi: "Keskeytä lähetys",
410
+ en: "Cancel the upload",
411
+ sv: "Stop överföringen",
412
+ },
413
+ },
414
+ ];
415
+ /**
416
+ * If enabled the filelist will create links on successfully uploaded items,
417
+ * this requires the server can respond with link URIs in the correct format
418
+ */
419
+ this.showLinks = false;
420
+ /**
421
+ * Property to change the aria upload progress text read aloud by screenreaders
422
+ * @default {
423
+ fi: "Lisää liite",
424
+ sv: "Lägg till en bilaga",
425
+ en: "Choose files",
426
+ }
427
+ */
428
+ this.statusLabelDefaults = {
429
+ fi: {
430
+ inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
431
+ inProgressWithErrors: "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
432
+ done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
433
+ doneWithErrors: "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
434
+ files: "tiedostot",
435
+ file: "tiedosto",
436
+ },
437
+ sv: {
438
+ inProgress: "Adding {filesUploaded} of {filesTotal}",
439
+ inProgressWithErrors: "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
440
+ done: "Alla {filesTotal} har lagts till",
441
+ doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
442
+ files: "filer",
443
+ file: "fil",
444
+ },
445
+ en: {
446
+ inProgress: "Adding {filesUploaded} of {filesTotal}",
447
+ inProgressWithErrors: "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
448
+ done: "All {filesTotal} added successfully",
449
+ doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
450
+ files: "tiedostoa",
451
+ file: "tiedosto",
452
+ },
453
+ };
454
+ /**
455
+ * Strings used for the status aria-label
456
+ */
457
+ this.statusMessageLabel = getLocaleString(this.statusLabelDefaults);
364
458
  /**
365
459
  * Property to change descriptionDefaults defaults on the component.
366
460
  * normally you would handle these strings on an application level and override @label when needed
461
+ * @default {
462
+ fi: "Lisää liite",
463
+ sv: "Lägg till en bilaga",
464
+ en: "Add an attachment",
465
+ }
367
466
  */
368
467
  this.buttonLabelDefaults = {
369
468
  fi: "Lisää liite",
@@ -399,6 +498,10 @@ let DuetUpload = class {
399
498
  * browser from displaying its own validation errors.
400
499
  */
401
500
  this.required = false;
501
+ /**
502
+ * Visually hides the groups labels in the editable table list used to display the list of files
503
+ */
504
+ this.hideGroups = false;
402
505
  /**
403
506
  * Map of string that contain list of uploaded files.
404
507
  */
@@ -410,6 +513,7 @@ let DuetUpload = class {
410
513
  /**
411
514
  * Property to change labelDefaults defaults on the component.
412
515
  * normally you would handle these strings on an application level and override @label when needed
516
+ * @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
413
517
  */
414
518
  this.labelDefaults = {
415
519
  fi: "Lisää liite",
@@ -424,6 +528,11 @@ let DuetUpload = class {
424
528
  /**
425
529
  * Property to change descriptionDefaults defaults on the component.
426
530
  * normally you would handle these strings on an application level and override @label when needed
531
+ * @default {
532
+ fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
533
+ sv: "Du kan bifoga filer i flg. formater {filetypes} samt de vanligaste videofilerna. Du kan ladda upp {maxbytes} filer åt gången och lägga till upp till {maxfiles} bilagor åt gången.",
534
+ en: "You may attach the following filetypes: {filetypes} - as well as the most common video files. You can upload {maxbytes} of files at a time, and add up to {maxfiles} attachments at a time.",
535
+ }
427
536
  */
428
537
  this.descriptionDefaults = {
429
538
  fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
@@ -432,12 +541,20 @@ let DuetUpload = class {
432
541
  };
433
542
  /**
434
543
  * Description for the upload component.
435
- * @default ...
544
+ * @default {
545
+ fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
546
+ sv: "Du kan bifoga filer i flg. formater {filetypes} samt de vanligaste videofilerna. Du kan ladda upp {maxbytes} filer åt gången och lägga till upp till {maxfiles} bilagor åt gången.",
547
+ en: "You may attach the following filetypes: {filetypes} - as well as the most common video files. You can upload {maxbytes} of files at a time, and add up to {maxfiles} attachments at a time.",
548
+ }
436
549
  */
437
550
  this.description = getLocaleString(this.descriptionDefaults);
438
551
  /**
439
552
  * Defaults for the filelist's empty state.
440
- * @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
553
+ * @default {
554
+ fi: "Ei vielä lisättyjä tiedostoja.",
555
+ sv: "Inga filer har lagts till ännu.",
556
+ en: "No files added yet.",
557
+ }
441
558
  */
442
559
  this.fileListEmptyDefaults = {
443
560
  fi: "Ei vielä lisättyjä tiedostoja.",
@@ -453,21 +570,6 @@ let DuetUpload = class {
453
570
  * Display the input in error state along with an error message.
454
571
  */
455
572
  this.error = "";
456
- /**
457
- * Visually hide the label, but still show it to screen readers.
458
- */
459
- this.labelHidden = false;
460
- /**
461
- * if set, allows capture of media from user camera / microphone
462
- * The capture attribute value is a string that specifies which camera to use for capture
463
- * of image or video data, if the accept attribute indicates that the input should be of
464
- * one of those types. A value of user indicates that the user-facing camera and/or
465
- * microphone should be used. A value of environment specifies that the outward-facing
466
- * camera and/or microphone should be used. If this attribute is missing, the user agent
467
- * is free to decide on its own what to do. If the requested facing mode isn't available,
468
- * the user agent may fall back to its preferred default mode.
469
- */
470
- this.capture = undefined;
471
573
  /**
472
574
  * Use maxBytes to specify the maximum size in Bytes of a file that can be uploaded.
473
575
  */
@@ -499,10 +601,94 @@ let DuetUpload = class {
499
601
  * by default this is off, setting this to true will limit the users choices to what has been explicitly set
500
602
  */
501
603
  this.limitSelection = false;
604
+ //region Private functions
502
605
  /**
503
606
  * Private functions
504
607
  */
505
- this.kick = () => (this.tick = Date.now()); // will trigger re-render
608
+ this.listenForActionEvents = () => {
609
+ this.element.addEventListener("duetEditableItemAction", (e) => {
610
+ const detail = e.detail;
611
+ const { action, keyName, originalEvent } = detail;
612
+ switch (action) {
613
+ case "delete":
614
+ this.onDelete(keyName, originalEvent);
615
+ break;
616
+ case "cancel":
617
+ this.onCancel(keyName, originalEvent);
618
+ break;
619
+ // code block
620
+ }
621
+ });
622
+ };
623
+ this.verifyValidity = () => {
624
+ const { invalid, valid } = this.getFilesAsArray();
625
+ const oldValid = this.valid;
626
+ this.valid = invalid.length === 0 && valid.length !== 0;
627
+ if (this.valid !== oldValid) {
628
+ this.duetState.emit({
629
+ originalEvent: undefined,
630
+ data: { valid: this.valid, from: "componentWillRender" },
631
+ component: "duet-upload",
632
+ });
633
+ }
634
+ };
635
+ this.getGroupFromItemData = (item) => {
636
+ if (item.valid && item.progress === 100) {
637
+ // if the item has a group, move the file to that group instead
638
+ // of into the standard success group
639
+ if (item.group) {
640
+ return item.group;
641
+ }
642
+ return this.DefaultGroups.success;
643
+ }
644
+ else if (item.progress > 0 && item.progress !== 100) {
645
+ return this.DefaultGroups.inprogress;
646
+ }
647
+ else if (!item.valid) {
648
+ return this.DefaultGroups.failure;
649
+ }
650
+ else if (item.group) {
651
+ return item.group;
652
+ }
653
+ else {
654
+ return "none";
655
+ }
656
+ };
657
+ this.getItemHTMLFromItemData = (data, group) => {
658
+ if (group === this.DefaultGroups.success) {
659
+ return h(SuccessItem, { data: data, showLinks: this.showLinks });
660
+ }
661
+ else if (group === this.DefaultGroups.inprogress) {
662
+ return h(ProgressItem, { progress: data.progress, name: data.item.name });
663
+ }
664
+ else if (group === this.DefaultGroups.failure) {
665
+ return h(ErrorItem, { data: data });
666
+ }
667
+ else if (data.group) {
668
+ return data.html;
669
+ }
670
+ else {
671
+ return "none";
672
+ }
673
+ };
674
+ this.convertToDuetEditableTableItems = () => {
675
+ // we're always recreating the map - in order to force an update down stream.
676
+ const itemData = new Map();
677
+ //walk the files Map and convert to DuetEditableTableItemData
678
+ this.files.forEach((data, key, _originalMap) => {
679
+ const group = this.getGroupFromItemData(data);
680
+ const item = this.getItemHTMLFromItemData(data, group);
681
+ itemData.set(key, {
682
+ uid: data.uid,
683
+ item,
684
+ group,
685
+ });
686
+ });
687
+ return itemData;
688
+ };
689
+ this.kick = debounce(() => {
690
+ this.tick = Date.now();
691
+ }, 30); // will trigger re-render
506
692
  this.genHashName = () => Date.now().toString(36) + Math.random();
507
693
  this.updateValueInMap = (item, key, value, kick = true) => {
508
694
  const fileItem = this.files.get(item);
@@ -513,10 +699,14 @@ let DuetUpload = class {
513
699
  }
514
700
  };
515
701
  this.updateProgress = (ev, name) => {
516
- if (ev.lengthComputable) {
517
- const percentComplete = (ev.loaded / ev.total) * 100;
702
+ console.log(this.filesInProgress.size);
703
+ const updateProgressHelper = percentComplete => {
518
704
  this.updateValueInMap(name, "progress", percentComplete);
519
705
  this.onProgress(name, percentComplete, ev);
706
+ };
707
+ if (ev.lengthComputable) {
708
+ const percentComplete = (ev.loaded / ev.total) * 100;
709
+ updateProgressHelper(percentComplete);
520
710
  }
521
711
  else {
522
712
  console.log("cant read progress");
@@ -555,16 +745,17 @@ let DuetUpload = class {
555
745
  */
556
746
  this.nativeInput.value = "";
557
747
  };
558
- this.getI18nError = (errorCode) => {
559
- const errorFromJson = getError(errorCode);
560
- const i18String = getLocaleString(errorFromJson.message);
561
- if (i18String === "" || !i18String) {
562
- return errorFromJson.system_message;
563
- }
564
- else {
565
- return i18String;
566
- }
748
+ this.startUpload = async (ev, metaData = undefined) => {
749
+ await this.setFocus();
750
+ this.metaData = metaData;
751
+ this.nativeInput.click();
752
+ this.onUpload(ev, metaData);
753
+ ev.stopPropagation();
754
+ ev.preventDefault();
755
+ return;
567
756
  };
757
+ //endregion
758
+ //region Eventlisteners for the XHR requests
568
759
  /**
569
760
  * Eventlisteners for the XHR requests
570
761
  */
@@ -574,6 +765,7 @@ let DuetUpload = class {
574
765
  };
575
766
  this.transferDone = (xhr, name, status) => {
576
767
  this.updateValueInMap(name, "status", status, false);
768
+ this.updateValueInMap(name, "uploaded", true, false);
577
769
  try {
578
770
  const response = JSON.parse(xhr.response);
579
771
  this.updateValueInMap(name, "url", response.url);
@@ -587,12 +779,13 @@ let DuetUpload = class {
587
779
  this.transferDoneWithFailure = (xhr, name, status) => {
588
780
  try {
589
781
  const { error } = JSON.parse(xhr.response);
590
- this.updateValueInMap(name, "error", { message: error.message, type: error.type });
782
+ this.updateValueInMap(name, "error", { message: error.message, type: error.type }, false);
591
783
  }
592
784
  catch (e) {
593
785
  console.error("Server did not respond with expected response error:{message: string, type: int}");
594
- this.updateValueInMap(name, "error", { type: status });
786
+ this.updateValueInMap(name, "error", { type: status }, false);
595
787
  }
788
+ this.updateValueInMap(name, "valid", false, true);
596
789
  };
597
790
  this.transferFailed = name => {
598
791
  this.updateValueInMap(name, "error", getError("duet-upload-001"));
@@ -623,15 +816,15 @@ let DuetUpload = class {
623
816
  this.files.delete(key);
624
817
  this.validateTotals();
625
818
  this.kick();
626
- if (!this.external) {
627
- this.makeXHRDeleteRequest(deletedItem);
628
- }
629
- this.resetFormFields();
630
819
  this.duetDelete.emit({
631
820
  originalEvent: ev,
632
821
  data: { deletion: deletedItem },
633
822
  component: "duet-upload",
634
823
  });
824
+ if (!this.external) {
825
+ this.makeXHRDeleteRequest(deletedItem);
826
+ }
827
+ this.resetFormFields();
635
828
  };
636
829
  this.onCancel = (key, ev) => {
637
830
  const cancelledItem = this.files.get(key);
@@ -650,9 +843,10 @@ let DuetUpload = class {
650
843
  component: "duet-upload",
651
844
  });
652
845
  };
653
- this.onUpload = (ev) => {
846
+ this.onUpload = (ev, metaData) => {
654
847
  this.duetUpload.emit({
655
848
  originalEvent: ev,
849
+ metaData,
656
850
  component: "duet-upload",
657
851
  });
658
852
  };
@@ -684,37 +878,26 @@ let DuetUpload = class {
684
878
  data: { files: this.files },
685
879
  });
686
880
  };
687
- this.startUpload = async (ev) => {
688
- await this.setFocus();
689
- this.nativeInput.click();
690
- this.onUpload(ev);
691
- ev.stopPropagation();
692
- ev.preventDefault();
693
- };
694
881
  }
695
882
  watchValidHandler(newValue, oldValue) {
696
883
  if (newValue !== oldValue) {
697
884
  this.kick();
698
885
  }
699
886
  }
887
+ //endregion
700
888
  /**
701
889
  * Component lifecycle events.
702
890
  */
703
891
  componentWillLoad() {
704
892
  inheritGlobalTheme(this);
893
+ this.listenForActionEvents();
705
894
  }
706
895
  componentWillRender() {
707
- const { invalid, valid } = this.getFilesAsArray();
708
- const oldValid = this.valid;
709
- this.valid = invalid.length === 0 && valid.length !== 0;
710
- if (this.valid !== oldValid) {
711
- this.duetState.emit({
712
- originalEvent: undefined,
713
- data: { valid: this.valid, from: "componentWillRender" },
714
- component: "duet-upload",
715
- });
716
- }
896
+ // listen to the events from the component
897
+ this.verifyValidity();
717
898
  }
899
+ //endregion
900
+ //region XHR requests
718
901
  /**
719
902
  * XHR request utilities
720
903
  */
@@ -733,23 +916,37 @@ let DuetUpload = class {
733
916
  xhr.upload.addEventListener("abort", () => {
734
917
  this.transferCanceled(name);
735
918
  });
736
- return makeXhrRequest({ data, name }, { type: "POST", uri: this.uri, xhr, argument: null, headers: null }, this.transferDoneWithFailure, this.transferDone, this.trackProgress);
919
+ return makeXhrRequest({
920
+ payload: { data, name },
921
+ options: { type: "POST", uri: this.uri, xhr, argument: null, headers: null },
922
+ onFailure: this.transferDoneWithFailure,
923
+ onSuccess: this.transferDone,
924
+ onProgress: this.trackProgress,
925
+ });
737
926
  }
738
927
  makeXHRDeleteRequest(data) {
739
928
  const { uid, item } = data;
740
929
  const xhr = new XMLHttpRequest();
741
930
  // don't present server issues to user on deletes, just remove them from the visible list
742
- return makeXhrRequest({ data: null, name }, {
743
- type: "DELETE",
744
- xhr,
745
- uri: this.uri,
746
- arguments: `?key=${uid}&name=${item.name}`,
747
- headers: {
748
- "x-fileuid": uid,
749
- "x-filename": item.name,
931
+ return makeXhrRequest({
932
+ payload: { data: null, name },
933
+ options: {
934
+ type: "DELETE",
935
+ xhr,
936
+ uri: this.uri,
937
+ arguments: `?key=${uid}&name=${item.name}`,
938
+ headers: {
939
+ "x-fileuid": uid,
940
+ "x-filename": item.name,
941
+ },
750
942
  },
751
- }, this.transferDoneWithFailure, this.transferDone, this.trackProgress);
943
+ onFailure: this.transferDoneWithFailure,
944
+ onSuccess: this.transferDone,
945
+ onProgress: this.trackProgress,
946
+ });
752
947
  }
948
+ //endregion
949
+ //region EventHandlers
753
950
  /**
754
951
  * Component event handling.
755
952
  */
@@ -758,7 +955,7 @@ let DuetUpload = class {
758
955
  const selectedFiles = Array.from((_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.files);
759
956
  // FileList is a nice array like structure but
760
957
  // to ensure uniqueness of files we use a mapping structure and
761
- // key to the name (makes it easier to delete)
958
+ // key to the name (makes it easier to delete as well)
762
959
  if (selectedFiles) {
763
960
  for (const item of selectedFiles) {
764
961
  const { valid, errorMessage, errorType, errorSystem } = validateFile(item, {
@@ -771,6 +968,8 @@ let DuetUpload = class {
771
968
  uid,
772
969
  item: item,
773
970
  size: item.size,
971
+ meta: this.metaData,
972
+ uploaded: false,
774
973
  valid,
775
974
  error: {
776
975
  type: valid ? undefined : errorType,
@@ -799,8 +998,14 @@ let DuetUpload = class {
799
998
  data.append("file", item);
800
999
  data.append("uid", uid);
801
1000
  data.append("name", item.name);
802
- data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size }));
803
- fileListItem.xhr = await this.makeXHRPostRequest(data);
1001
+ data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size, meta: fileListItem.meta }));
1002
+ try {
1003
+ fileListItem.xhr = await this.makeXHRPostRequest(data);
1004
+ }
1005
+ catch (e) {
1006
+ // in case one of the global maxes have been reached, invalidate the file
1007
+ this.updateValueInMap(item.name, "valid", false, false);
1008
+ }
804
1009
  }
805
1010
  // kick the stat to force update
806
1011
  this.kick();
@@ -808,12 +1013,15 @@ let DuetUpload = class {
808
1013
  }
809
1014
  // reset the form, so that a user may upload a file again (with the same name)
810
1015
  this.resetFormFields();
1016
+ // reset the internal metaData state
1017
+ this.metaData = undefined;
811
1018
  this.duetChange.emit({
812
1019
  originalEvent: ev,
813
1020
  data: { files: this.files },
814
1021
  component: "duet-upload",
815
1022
  });
816
1023
  }
1024
+ //endregion
817
1025
  /**
818
1026
  * Sets focus on the specified `duet-input`. Use this method instead of the global
819
1027
  * `input.focus()`.
@@ -824,6 +1032,15 @@ let DuetUpload = class {
824
1032
  }
825
1033
  return;
826
1034
  }
1035
+ /**
1036
+ * Method for invoking the upload sequence
1037
+ */
1038
+ async upload(metaData = undefined) {
1039
+ await this.setFocus();
1040
+ this.metaData = metaData;
1041
+ this.nativeInput.click();
1042
+ return;
1043
+ }
827
1044
  /**
828
1045
  * Get list of files, divided in errors and valid sections
829
1046
  */
@@ -833,6 +1050,12 @@ let DuetUpload = class {
833
1050
  }
834
1051
  return this.getFilesAsArray();
835
1052
  }
1053
+ /**
1054
+ * Convenience method for updating a of an item in the files attribute
1055
+ */
1056
+ async updateValue(item, key, value) {
1057
+ this.updateValueInMap(item, key, value);
1058
+ }
836
1059
  /**
837
1060
  * render() function
838
1061
  * Always the last one in the class.
@@ -842,13 +1065,13 @@ let DuetUpload = class {
842
1065
  let caption = this.description.replace(/{maxfiles}/g, this.maxFiles.toString());
843
1066
  caption = caption.replace(/{maxbytes}/g, `${Math.floor(this.maxBytes / 1024 / 1024)} MB`);
844
1067
  caption = caption.replace(/{filetypes}/g, this.allowedExtensions.split(",").join(", "));
845
- return (h(Host, { class: { "duet-m-0": this.margin === "none" } }, h("duet-fieldset", { label: this.label, caption: caption }, h("slot", { name: "header" }), h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
1068
+ return (h(Host, { class: { "duet-m-0": this.margin === "none" } }, h("duet-fieldset", { label: this.label, caption: caption }, h("slot", { name: "header" }), !this.files.size && (h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
846
1069
  "duet-upload-filelist-empty": !this.files.size,
847
1070
  "duet-upload-filelist": true,
848
1071
  "duet-upload-filelist-filled": this.files.size,
849
- }, id: this.labelId, for: identifier }, !this.files.size && this.fileListEmpty), !!this.files.size && h("slot", { name: "fileheader" }), h(DuetUploadFileList, { data: this.getFilesAsArray(), onDelete: this.onDelete, onCancel: this.onCancel, getError: this.getI18nError }, h("li", null, "testing something")), !!this.files.size && h("slot", { name: "filefooter" }), h("duet-spacer", { size: "large" }), h("duet-button", { id: this.buttonId, onClick: this.startUpload, "accessible-controls": identifier, disabled: this.fileMaxReached, "accessible-label": this.accessibleButtonLabel, "accessible-owns": identifier, size: "small", variation: "secondary", fixed: true, icon: "action-add-circle" }, this.buttonLabel), h("duet-spacer", { size: "medium" }), (this.fileMaxReached || this.bytesMaxReached) && (h("duet-alert", null, this.fileMaxReached && this.getI18nError("duet-upload-301"), this.bytesMaxReached && this.getI18nError("duet-upload-202"))), h("duet-spacer", { size: "medium" }), h("duet-visually-hidden", null, h("input", { ref: input => {
1072
+ }, id: this.labelId, for: identifier }, this.fileListEmpty)), !!this.files.size && h("slot", { name: "fileheader" }), !!this.files.size && (h("duet-upload-aria-status", { invalid: this.getFilesAsArray().invalid.length, valid: this.getFilesAsArray().valid.length, inprogress: this.filesInProgress.size, total: this.files.size, statusMessageLabel: this.statusMessageLabel })), !!this.files.size && (h("duet-editable-table", { "aria-live": "polite", "aria-relevant": "removals", accessibleRole: "log", id: this.editableTableId, groups: this.groups, actions: this.actions, hideGroups: this.hideGroups, items: this.convertToDuetEditableTableItems() })), !!this.files.size && h("slot", { name: "filefooter" }), h("duet-spacer", { size: "large" }), !this.hideButton && (h("duet-button", { id: this.buttonId, onClick: this.startUpload, "accessible-controls": identifier, disabled: this.fileMaxReached, "accessible-label": this.accessibleButtonLabel, "accessible-owns": identifier, size: "small", variation: "secondary", fixed: true, icon: "action-add-circle" }, this.buttonLabel)), h("duet-spacer", { size: "medium" }), (this.fileMaxReached || this.bytesMaxReached) && (h("duet-alert", null, this.fileMaxReached && getI18nError("duet-upload-301"), this.bytesMaxReached && getI18nError("duet-upload-202"))), h("duet-spacer", { size: "medium" }), h("duet-visually-hidden", null, h("input", { ref: input => {
850
1073
  this.nativeInput = input;
851
- }, accept: this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
1074
+ }, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
852
1075
  "duet-upload": true,
853
1076
  }, disabled: this.disabled, "aria-hidden": "true", required: this.required, name: this.name, id: this.identifier, multiple: this.multiple, capture: "user" })))));
854
1077
  }