@duetds/components 5.3.2 → 5.3.3

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 (249) hide show
  1. package/hydrate/index.js +72 -38
  2. package/lib/cjs/duet-action-button.cjs.entry.js +1 -1
  3. package/lib/cjs/duet-alert.cjs.entry.js +1 -1
  4. package/lib/cjs/duet-badge.cjs.entry.js +1 -1
  5. package/lib/cjs/duet-breadcrumb.cjs.entry.js +1 -1
  6. package/lib/cjs/duet-breadcrumbs.cjs.entry.js +1 -1
  7. package/lib/cjs/duet-button_2.cjs.entry.js +1 -1
  8. package/lib/cjs/duet-caption_4.cjs.entry.js +1 -1
  9. package/lib/cjs/duet-card.cjs.entry.js +1 -1
  10. package/lib/cjs/duet-checkbox.cjs.entry.js +1 -1
  11. package/lib/cjs/duet-choice_2.cjs.entry.js +2 -2
  12. package/lib/cjs/duet-collapsible.cjs.entry.js +1 -1
  13. package/lib/cjs/duet-combobox.cjs.entry.js +1 -1
  14. package/lib/cjs/duet-cookie-consent.cjs.entry.js +1 -1
  15. package/lib/cjs/duet-date-picker.cjs.entry.js +2 -2
  16. package/lib/cjs/duet-divider_2.cjs.entry.js +1 -1
  17. package/lib/cjs/duet-editable-table_3.cjs.entry.js +72 -40
  18. package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
  19. package/lib/cjs/duet-fieldset.cjs.entry.js +1 -1
  20. package/lib/cjs/duet-footer.cjs.entry.js +1 -1
  21. package/lib/cjs/duet-grid_2.cjs.entry.js +1 -1
  22. package/lib/cjs/duet-header_2.cjs.entry.js +1 -1
  23. package/lib/cjs/duet-hero.cjs.entry.js +1 -1
  24. package/lib/cjs/duet-icon.cjs.entry.js +1 -1
  25. package/lib/cjs/duet-input_2.cjs.entry.js +1 -1
  26. package/lib/cjs/duet-layout.cjs.entry.js +1 -1
  27. package/lib/cjs/duet-list_2.cjs.entry.js +1 -1
  28. package/lib/cjs/duet-modal.cjs.entry.js +2 -2
  29. package/lib/cjs/duet-notification_2.cjs.entry.js +1 -1
  30. package/lib/cjs/duet-number-input.cjs.entry.js +1 -1
  31. package/lib/cjs/duet-pagination_2.cjs.entry.js +1 -1
  32. package/lib/cjs/duet-progress.cjs.entry.js +1 -1
  33. package/lib/cjs/duet-radio_2.cjs.entry.js +1 -1
  34. package/lib/cjs/duet-range-slider.cjs.entry.js +1 -1
  35. package/lib/cjs/duet-scrollable_3.cjs.entry.js +1 -1
  36. package/lib/cjs/duet-select.cjs.entry.js +1 -1
  37. package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
  38. package/lib/cjs/duet-textarea.cjs.entry.js +1 -1
  39. package/lib/cjs/duet-toggle.cjs.entry.js +1 -1
  40. package/lib/cjs/duet-tooltip.cjs.entry.js +1 -1
  41. package/lib/cjs/duet-tray.cjs.entry.js +1 -1
  42. package/lib/cjs/duet-upload-aria-status.cjs.entry.js +1 -1
  43. package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
  44. package/lib/cjs/duet.cjs.js +2 -2
  45. package/lib/cjs/{focus-utils-1de1fb9e.js → focus-utils-54bf88c4.js} +1 -1
  46. package/lib/cjs/{index-e25673c3.js → index-d74701f0.js} +1 -1
  47. package/lib/cjs/loader.cjs.js +2 -2
  48. package/lib/collection/components/duet-upload/duet-upload.css +3 -3
  49. package/lib/collection/components/duet-upload/duet-upload.js +110 -24
  50. package/lib/collection/components/duet-upload/errorcodes.utils.js +5 -4
  51. package/lib/collection/components/duet-upload/mock.helpers.js +16 -5
  52. package/lib/collection/components/duet-upload/upload-editable-item-error.js +4 -4
  53. package/lib/collection/components/duet-upload/upload-editable-item-inprogres.js +5 -2
  54. package/lib/collection/components/duet-upload/upload-editable-item-pending.js +4 -3
  55. package/lib/collection/components/duet-upload/upload-validators.js +5 -5
  56. package/lib/collection/components/duet-upload/xhr.helpers.js +1 -0
  57. package/lib/custom-elements-bundle/index.js +72 -40
  58. package/lib/duet/duet.esm.js +1 -1
  59. package/lib/duet/duet.js +1 -1
  60. package/lib/duet/{p-76502a6e.system.entry.js → p-017c8f85.system.entry.js} +1 -1
  61. package/lib/duet/{p-06d6fcbb.entry.js → p-05093845.entry.js} +1 -1
  62. package/lib/duet/{p-606f0e3e.system.entry.js → p-09f8d68b.system.entry.js} +1 -1
  63. package/lib/duet/{p-a00567c5.entry.js → p-0c2a368b.entry.js} +1 -1
  64. package/lib/duet/{p-096d3138.system.entry.js → p-0ed8f525.system.entry.js} +1 -1
  65. package/lib/duet/{p-a79524ea.system.entry.js → p-0fe15b1c.system.entry.js} +1 -1
  66. package/lib/duet/{p-44430576.entry.js → p-10dd6a3a.entry.js} +1 -1
  67. package/lib/duet/{p-e1dc474f.entry.js → p-1463ec25.entry.js} +1 -1
  68. package/lib/duet/{p-96bd5181.entry.js → p-187dac44.entry.js} +1 -1
  69. package/lib/duet/{p-3b90bf38.system.entry.js → p-1b971cb4.system.entry.js} +1 -1
  70. package/lib/duet/{p-e60b6064.system.entry.js → p-263d5c73.system.entry.js} +1 -1
  71. package/lib/duet/{p-83ccb4d1.system.entry.js → p-29b78a88.system.entry.js} +1 -1
  72. package/lib/duet/{p-9518a50d.entry.js → p-2ae81abd.entry.js} +1 -1
  73. package/lib/duet/{p-195cbb65.system.js → p-310cc65a.system.js} +1 -1
  74. package/lib/duet/{p-eed733d0.entry.js → p-31ee57ef.entry.js} +1 -1
  75. package/lib/duet/{p-7f720f3d.system.entry.js → p-323af601.system.entry.js} +1 -1
  76. package/lib/duet/{p-27e1329c.system.entry.js → p-334e765b.system.entry.js} +1 -1
  77. package/lib/duet/{p-eda03e7a.system.entry.js → p-3357023c.system.entry.js} +1 -1
  78. package/lib/duet/{p-bd361dca.entry.js → p-351c4ca8.entry.js} +1 -1
  79. package/lib/duet/{p-e8a19b86.system.entry.js → p-3d4098a1.system.entry.js} +1 -1
  80. package/lib/duet/{p-3a196674.entry.js → p-4390278a.entry.js} +1 -1
  81. package/lib/duet/{p-58f4df49.entry.js → p-4407c77f.entry.js} +1 -1
  82. package/lib/duet/{p-a2f33ea2.entry.js → p-4be003ee.entry.js} +1 -1
  83. package/lib/duet/{p-18f1a32e.js → p-4bfb3001.js} +1 -1
  84. package/lib/duet/{p-7acbb1cf.entry.js → p-4f4e6e7a.entry.js} +1 -1
  85. package/lib/duet/{p-ed86e7b8.system.entry.js → p-5231f09f.system.entry.js} +1 -1
  86. package/lib/duet/{p-27df7993.entry.js → p-52cd446d.entry.js} +1 -1
  87. package/lib/duet/{p-4eca850e.system.entry.js → p-53feaad0.system.entry.js} +1 -1
  88. package/lib/duet/{p-de007928.system.entry.js → p-54adb28a.system.entry.js} +1 -1
  89. package/lib/duet/{p-cd55d122.entry.js → p-5a134750.entry.js} +1 -1
  90. package/lib/duet/{p-6c4bb84d.system.entry.js → p-60903f76.system.entry.js} +1 -1
  91. package/lib/duet/{p-e5541622.entry.js → p-707e6bde.entry.js} +1 -1
  92. package/lib/duet/{p-f62c6c1a.entry.js → p-711c5825.entry.js} +1 -1
  93. package/lib/duet/{p-324c6a7f.system.entry.js → p-7a803a0f.system.entry.js} +1 -1
  94. package/lib/duet/{p-e53b41b1.js → p-7b37a578.js} +1 -1
  95. package/lib/duet/{p-b2351491.entry.js → p-7b776a5f.entry.js} +1 -1
  96. package/lib/duet/{p-60bc3fd1.entry.js → p-7ce0b78c.entry.js} +1 -1
  97. package/lib/duet/{p-94a68b9a.entry.js → p-7ee40ef2.entry.js} +1 -1
  98. package/lib/duet/{p-0a399341.system.entry.js → p-80db2a1e.system.entry.js} +1 -1
  99. package/lib/duet/{p-943a6f4f.entry.js → p-8ea1558f.entry.js} +1 -1
  100. package/lib/duet/{p-bc4dbe8f.system.entry.js → p-9195e263.system.entry.js} +1 -1
  101. package/lib/duet/{p-dfec73ab.system.entry.js → p-933b5471.system.entry.js} +1 -1
  102. package/lib/duet/{p-f68f4f90.entry.js → p-97395d40.entry.js} +1 -1
  103. package/lib/duet/{p-9b762624.entry.js → p-98aa8c7e.entry.js} +1 -1
  104. package/lib/duet/{p-c33d40b4.entry.js → p-997ef66e.entry.js} +1 -1
  105. package/lib/duet/{p-195f6e6b.system.entry.js → p-9db6c3ef.system.entry.js} +1 -1
  106. package/lib/duet/{p-40ba3e58.entry.js → p-9e8acf0a.entry.js} +1 -1
  107. package/lib/duet/{p-1147c2f3.system.entry.js → p-9e979cae.system.entry.js} +1 -1
  108. package/lib/duet/{p-b046cc6d.entry.js → p-a07b994c.entry.js} +1 -1
  109. package/lib/duet/{p-9e9a00fa.entry.js → p-a21321dc.entry.js} +1 -1
  110. package/lib/duet/{p-05503430.system.entry.js → p-a77df5a4.system.entry.js} +1 -1
  111. package/lib/duet/{p-14532cbb.system.entry.js → p-ac356267.system.entry.js} +1 -1
  112. package/lib/duet/{p-eab71bc1.entry.js → p-aea395e2.entry.js} +1 -1
  113. package/lib/duet/{p-47a3d44a.entry.js → p-aebf923d.entry.js} +1 -1
  114. package/lib/duet/p-b0053a35.entry.js +4 -0
  115. package/lib/duet/{p-a164b64d.entry.js → p-b112ecc7.entry.js} +1 -1
  116. package/lib/duet/{p-8e84cb24.system.entry.js → p-b52d2351.system.entry.js} +1 -1
  117. package/lib/duet/{p-efd2027f.system.entry.js → p-b717297c.system.entry.js} +1 -1
  118. package/lib/duet/{p-2980439e.system.entry.js → p-b786f4a1.system.entry.js} +1 -1
  119. package/lib/duet/{p-f36d233f.entry.js → p-b9f2984d.entry.js} +1 -1
  120. package/lib/duet/{p-13b08905.system.entry.js → p-badcd20b.system.entry.js} +1 -1
  121. package/lib/duet/{p-a541f140.entry.js → p-bd697adb.entry.js} +1 -1
  122. package/lib/duet/{p-07a4933d.system.entry.js → p-bd97848c.system.entry.js} +1 -1
  123. package/lib/duet/{p-6d6af360.entry.js → p-c0dea844.entry.js} +1 -1
  124. package/lib/duet/{p-7f501fed.system.entry.js → p-c2a4820d.system.entry.js} +1 -1
  125. package/lib/duet/p-cd0b0258.system.entry.js +4 -0
  126. package/lib/duet/{p-dd1cebc6.system.entry.js → p-cfc5df00.system.entry.js} +1 -1
  127. package/lib/duet/{p-781803f9.system.entry.js → p-d03be8d0.system.entry.js} +1 -1
  128. package/lib/duet/{p-c5353e57.system.entry.js → p-d06ccc00.system.entry.js} +1 -1
  129. package/lib/duet/{p-62f76416.entry.js → p-d0eceac9.entry.js} +1 -1
  130. package/lib/duet/{p-3e8e00aa.system.entry.js → p-d11db0d5.system.entry.js} +1 -1
  131. package/lib/duet/{p-f1ac8970.entry.js → p-d28243a8.entry.js} +1 -1
  132. package/lib/duet/{p-7065da4f.entry.js → p-d3d3538f.entry.js} +1 -1
  133. package/lib/duet/{p-b7a56046.entry.js → p-d749146f.entry.js} +1 -1
  134. package/lib/duet/{p-d2eec878.entry.js → p-d77dcab2.entry.js} +1 -1
  135. package/lib/duet/{p-cd6016c3.system.entry.js → p-daa9880c.system.entry.js} +1 -1
  136. package/lib/duet/{p-b15a7acd.entry.js → p-dadfe56f.entry.js} +1 -1
  137. package/lib/duet/{p-3a587bea.system.entry.js → p-dcfa2ae4.system.entry.js} +1 -1
  138. package/lib/duet/{p-29f6749b.system.js → p-e56acd55.system.js} +1 -1
  139. package/lib/duet/{p-abb3619b.entry.js → p-e58d06d9.entry.js} +1 -1
  140. package/lib/duet/{p-5f751350.entry.js → p-e6b88a4b.entry.js} +1 -1
  141. package/lib/duet/{p-fc847cc0.system.js → p-e97c0bf3.system.js} +1 -1
  142. package/lib/duet/{p-be2cc769.system.entry.js → p-efa06b0e.system.entry.js} +1 -1
  143. package/lib/duet/{p-dfa83a7b.entry.js → p-f23108a0.entry.js} +1 -1
  144. package/lib/duet/{p-8544ac3e.system.entry.js → p-f640e49b.system.entry.js} +1 -1
  145. package/lib/duet/{p-99fc1806.system.entry.js → p-f67a994f.system.entry.js} +1 -1
  146. package/lib/duet/{p-fdfa9d96.system.entry.js → p-f94cb455.system.entry.js} +1 -1
  147. package/lib/duet/{p-b2d8afd1.system.entry.js → p-f9787dbb.system.entry.js} +1 -1
  148. package/lib/duet/{p-fe7a158d.system.entry.js → p-fb761b8d.system.entry.js} +1 -1
  149. package/lib/esm/duet-action-button.entry.js +1 -1
  150. package/lib/esm/duet-alert.entry.js +1 -1
  151. package/lib/esm/duet-badge.entry.js +1 -1
  152. package/lib/esm/duet-breadcrumb.entry.js +1 -1
  153. package/lib/esm/duet-breadcrumbs.entry.js +1 -1
  154. package/lib/esm/duet-button_2.entry.js +1 -1
  155. package/lib/esm/duet-caption_4.entry.js +1 -1
  156. package/lib/esm/duet-card.entry.js +1 -1
  157. package/lib/esm/duet-checkbox.entry.js +1 -1
  158. package/lib/esm/duet-choice_2.entry.js +2 -2
  159. package/lib/esm/duet-collapsible.entry.js +1 -1
  160. package/lib/esm/duet-combobox.entry.js +1 -1
  161. package/lib/esm/duet-cookie-consent.entry.js +1 -1
  162. package/lib/esm/duet-date-picker.entry.js +2 -2
  163. package/lib/esm/duet-divider_2.entry.js +1 -1
  164. package/lib/esm/duet-editable-table_3.entry.js +72 -40
  165. package/lib/esm/duet-empty-state.entry.js +1 -1
  166. package/lib/esm/duet-fieldset.entry.js +1 -1
  167. package/lib/esm/duet-footer.entry.js +1 -1
  168. package/lib/esm/duet-grid_2.entry.js +1 -1
  169. package/lib/esm/duet-header_2.entry.js +1 -1
  170. package/lib/esm/duet-hero.entry.js +1 -1
  171. package/lib/esm/duet-icon.entry.js +1 -1
  172. package/lib/esm/duet-input_2.entry.js +1 -1
  173. package/lib/esm/duet-layout.entry.js +1 -1
  174. package/lib/esm/duet-list_2.entry.js +1 -1
  175. package/lib/esm/duet-modal.entry.js +2 -2
  176. package/lib/esm/duet-notification_2.entry.js +1 -1
  177. package/lib/esm/duet-number-input.entry.js +1 -1
  178. package/lib/esm/duet-pagination_2.entry.js +1 -1
  179. package/lib/esm/duet-progress.entry.js +1 -1
  180. package/lib/esm/duet-radio_2.entry.js +1 -1
  181. package/lib/esm/duet-range-slider.entry.js +1 -1
  182. package/lib/esm/duet-scrollable_3.entry.js +1 -1
  183. package/lib/esm/duet-select.entry.js +1 -1
  184. package/lib/esm/duet-step_2.entry.js +1 -1
  185. package/lib/esm/duet-textarea.entry.js +1 -1
  186. package/lib/esm/duet-toggle.entry.js +1 -1
  187. package/lib/esm/duet-tooltip.entry.js +1 -1
  188. package/lib/esm/duet-tray.entry.js +1 -1
  189. package/lib/esm/duet-upload-aria-status.entry.js +1 -1
  190. package/lib/esm/duet-visually-hidden.entry.js +1 -1
  191. package/lib/esm/duet.js +2 -2
  192. package/lib/esm/{focus-utils-634e7bc9.js → focus-utils-2632e19f.js} +1 -1
  193. package/lib/esm/{index-59261780.js → index-ab50bfb2.js} +1 -1
  194. package/lib/esm/loader.js +2 -2
  195. package/lib/esm-es5/duet-action-button.entry.js +1 -1
  196. package/lib/esm-es5/duet-alert.entry.js +1 -1
  197. package/lib/esm-es5/duet-badge.entry.js +1 -1
  198. package/lib/esm-es5/duet-breadcrumb.entry.js +1 -1
  199. package/lib/esm-es5/duet-breadcrumbs.entry.js +1 -1
  200. package/lib/esm-es5/duet-button_2.entry.js +1 -1
  201. package/lib/esm-es5/duet-caption_4.entry.js +1 -1
  202. package/lib/esm-es5/duet-card.entry.js +1 -1
  203. package/lib/esm-es5/duet-checkbox.entry.js +1 -1
  204. package/lib/esm-es5/duet-choice_2.entry.js +1 -1
  205. package/lib/esm-es5/duet-collapsible.entry.js +1 -1
  206. package/lib/esm-es5/duet-combobox.entry.js +1 -1
  207. package/lib/esm-es5/duet-cookie-consent.entry.js +1 -1
  208. package/lib/esm-es5/duet-date-picker.entry.js +1 -1
  209. package/lib/esm-es5/duet-divider_2.entry.js +1 -1
  210. package/lib/esm-es5/duet-editable-table_3.entry.js +1 -1
  211. package/lib/esm-es5/duet-empty-state.entry.js +1 -1
  212. package/lib/esm-es5/duet-fieldset.entry.js +1 -1
  213. package/lib/esm-es5/duet-footer.entry.js +1 -1
  214. package/lib/esm-es5/duet-grid_2.entry.js +1 -1
  215. package/lib/esm-es5/duet-header_2.entry.js +1 -1
  216. package/lib/esm-es5/duet-hero.entry.js +1 -1
  217. package/lib/esm-es5/duet-icon.entry.js +1 -1
  218. package/lib/esm-es5/duet-input_2.entry.js +1 -1
  219. package/lib/esm-es5/duet-layout.entry.js +1 -1
  220. package/lib/esm-es5/duet-list_2.entry.js +1 -1
  221. package/lib/esm-es5/duet-modal.entry.js +1 -1
  222. package/lib/esm-es5/duet-notification_2.entry.js +1 -1
  223. package/lib/esm-es5/duet-number-input.entry.js +1 -1
  224. package/lib/esm-es5/duet-pagination_2.entry.js +1 -1
  225. package/lib/esm-es5/duet-progress.entry.js +1 -1
  226. package/lib/esm-es5/duet-radio_2.entry.js +1 -1
  227. package/lib/esm-es5/duet-range-slider.entry.js +1 -1
  228. package/lib/esm-es5/duet-scrollable_3.entry.js +1 -1
  229. package/lib/esm-es5/duet-select.entry.js +1 -1
  230. package/lib/esm-es5/duet-step_2.entry.js +1 -1
  231. package/lib/esm-es5/duet-textarea.entry.js +1 -1
  232. package/lib/esm-es5/duet-toggle.entry.js +1 -1
  233. package/lib/esm-es5/duet-tooltip.entry.js +1 -1
  234. package/lib/esm-es5/duet-tray.entry.js +1 -1
  235. package/lib/esm-es5/duet-upload-aria-status.entry.js +1 -1
  236. package/lib/esm-es5/duet-visually-hidden.entry.js +1 -1
  237. package/lib/esm-es5/duet.js +1 -1
  238. package/lib/esm-es5/{focus-utils-634e7bc9.js → focus-utils-2632e19f.js} +1 -1
  239. package/lib/esm-es5/{index-59261780.js → index-ab50bfb2.js} +1 -1
  240. package/lib/esm-es5/loader.js +1 -1
  241. package/lib/types/components/duet-upload/duet-upload.d.ts +22 -1
  242. package/lib/types/components/duet-upload/errorcodes.utils.d.ts +3 -2
  243. package/lib/types/components/duet-upload/mock.helpers.d.ts +0 -1
  244. package/lib/types/components/duet-upload/upload-editable-item-error.d.ts +2 -0
  245. package/lib/types/components/duet-upload/upload-validators.d.ts +2 -1
  246. package/lib/types/components.d.ts +22 -1
  247. package/package.json +5 -5
  248. package/lib/duet/p-2bc92bf3.entry.js +0 -4
  249. package/lib/duet/p-8342d3f7.system.entry.js +0 -4
@@ -6,13 +6,14 @@ import { inheritGlobalTheme } from "../../common/themeable-component";
6
6
  import { createID } from "../../utils/create-id";
7
7
  import { debounce } from "../../utils/js-utils";
8
8
  import { getLocaleString, sanitizeString } from "../../utils/language-utils";
9
- import { getError, getI18nError } from "./errorcodes.utils";
9
+ import errorCodes from "./errorcodes.json";
10
+ import { getI18nError } from "./errorcodes.utils";
10
11
  import { ErrorItem } from "./upload-editable-item-error";
11
12
  import { ProgressItem } from "./upload-editable-item-inprogres";
12
13
  import { PendingItem } from "./upload-editable-item-pending";
13
14
  import { SuccessItem } from "./upload-editable-item-success";
14
15
  import { validateFile, validateTotalAmountIsAboveMax, validateTotalSizeIsAboveMax } from "./upload-validators";
15
- import { makeXhrRequest } from "./xhr.helpers";
16
+ import { makeXhrRequest, } from "./xhr.helpers";
16
17
  /**
17
18
  * @slot header - named slot - to place content after description / caption
18
19
  * @slot fileheader - named slot - to place content above "filelist" (only displayed when "filelist" contains items)
@@ -32,6 +33,10 @@ export class DuetUpload {
32
33
  * it will be up to you to handle the upload and return progress information to the upload-component
33
34
  */
34
35
  this.external = false;
36
+ /**
37
+ * If internal upload method is used, and this has been set to a function - it will be called with the XHR options before the reqeust is sent, return an updated XHR options object in order to manipulate the request
38
+ */
39
+ this.middleware = null;
35
40
  /**
36
41
  * If defer-upload is true, duet-upload will not (as recommended) instantly upload files but await a call to uploadPending()
37
42
  */
@@ -51,7 +56,7 @@ export class DuetUpload {
51
56
  size: "x-small",
52
57
  background: "gray-lightest",
53
58
  name: "delete",
54
- map: ["success", "failure", "pending"],
59
+ map: ["success", "failure"],
55
60
  label: {
56
61
  fi: "Poista tiedosto",
57
62
  en: "Poista tiedosto",
@@ -64,7 +69,7 @@ export class DuetUpload {
64
69
  size: "x-small",
65
70
  background: "gray-lightest",
66
71
  name: "cancel",
67
- map: ["inprogress"],
72
+ map: ["inprogress", "pending"],
68
73
  label: {
69
74
  fi: "Keskeytä lähetys",
70
75
  en: "Cancel the upload",
@@ -258,6 +263,10 @@ export class DuetUpload {
258
263
  * Display the input in error state along with an error message.
259
264
  */
260
265
  this.error = "";
266
+ /**
267
+ * Default errorcodes used by the component, modifiable via javascript
268
+ */
269
+ this.errorCodes = errorCodes;
261
270
  /**
262
271
  * Use maxBytes to specify the maximum size in Bytes of a file that can be uploaded.
263
272
  */
@@ -414,7 +423,7 @@ export class DuetUpload {
414
423
  return h(PendingItem, { name: data.item.name });
415
424
  }
416
425
  else if (group === this.DefaultGroups.failure) {
417
- return h(ErrorItem, { data: data });
426
+ return h(ErrorItem, { data: data, errorCodes: this.errorCodes });
418
427
  }
419
428
  else if (data.group) {
420
429
  return data.html;
@@ -529,7 +538,7 @@ export class DuetUpload {
529
538
  this.updateValueInMap(name, "valid", false, true);
530
539
  };
531
540
  this.transferFailed = name => {
532
- this.updateValueInMap(name, "error", getError("duet-upload-001"));
541
+ this.updateValueInMap(name, "error", getI18nError("duet-upload-001", this.errorCodes));
533
542
  };
534
543
  this.transferCanceled = name => {
535
544
  this.files.delete(name);
@@ -540,10 +549,10 @@ export class DuetUpload {
540
549
  const isTotalSizeOverMaxSize = validateTotalSizeIsAboveMax(this.files, this.maxBytesTotal);
541
550
  const isTotalFileAmountAboveMax = validateTotalAmountIsAboveMax(this.files, this.maxFiles);
542
551
  if (isTotalSizeOverMaxSize && name) {
543
- this.updateValueInMap(name, "error", getError("duet-upload-202"), false);
552
+ this.updateValueInMap(name, "error", getI18nError("duet-upload-202", this.errorCodes), false);
544
553
  }
545
554
  if (isTotalFileAmountAboveMax && name) {
546
- this.updateValueInMap(name, "error", getError("duet-upload-301"), false);
555
+ this.updateValueInMap(name, "error", getI18nError("duet-upload-301", this.errorCodes), false);
547
556
  }
548
557
  this.bytesMaxReached = isTotalSizeOverMaxSize;
549
558
  this.fileMaxReached = isTotalFileAmountAboveMax;
@@ -624,7 +633,9 @@ export class DuetUpload {
624
633
  this.files.delete(retrievedKey);
625
634
  if (!this.external) {
626
635
  const { xhr } = cancelledItem;
627
- xhr.abort();
636
+ if (xhr) {
637
+ xhr.abort();
638
+ }
628
639
  }
629
640
  else {
630
641
  this.kick();
@@ -665,6 +676,11 @@ export class DuetUpload {
665
676
  component: "duet-upload",
666
677
  });
667
678
  };
679
+ this.onReady = () => {
680
+ this.duetReady.emit({
681
+ component: "duet-upload",
682
+ });
683
+ };
668
684
  this.onDone = () => {
669
685
  this.duetDone.emit({
670
686
  component: "duet-upload",
@@ -779,6 +795,7 @@ export class DuetUpload {
779
795
  }
780
796
  inheritGlobalTheme(this);
781
797
  this.listenForActionEvents();
798
+ this.onReady();
782
799
  }
783
800
  componentWillRender() {
784
801
  // listen to the events from the component
@@ -861,8 +878,8 @@ export class DuetUpload {
861
878
  !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", part: this.identifier ? `${this.identifier}-button-upload` : "duet-upload-button-upload" }, this.buttonLabel)),
862
879
  h("duet-spacer", { size: "medium" }),
863
880
  (this.fileMaxReached || this.bytesMaxReached) && (h("duet-alert", { part: this.identifier ? `${this.identifier}-error-notification` : "duet-upload-error-notification" },
864
- this.fileMaxReached && getI18nError("duet-upload-301"),
865
- this.bytesMaxReached && getI18nError("duet-upload-202"))),
881
+ this.fileMaxReached && getI18nError("duet-upload-301", this.errorCodes),
882
+ this.bytesMaxReached && getI18nError("duet-upload-202", this.errorCodes))),
866
883
  h("duet-spacer", { size: "medium" }),
867
884
  h("duet-visually-hidden", null,
868
885
  h("input", { ref: input => {
@@ -889,34 +906,43 @@ export class DuetUpload {
889
906
  xhr.upload.addEventListener("abort", () => {
890
907
  this.transferCanceled(name);
891
908
  });
892
- return makeXhrRequest({
909
+ let options = {
893
910
  payload: { data, name },
894
- options: { type: "POST", uri: this.uri, xhr, argument: null, headers: null },
911
+ options: { type: "POST", uri: this.uri, xhr, argument: null, headers: undefined },
895
912
  onFailure: this.transferDoneWithFailure,
896
913
  onSuccess: this.transferDone,
897
914
  onProgress: this.trackProgress,
898
- });
915
+ };
916
+ if (this.middleware) {
917
+ options = this.middleware(options);
918
+ }
919
+ return makeXhrRequest(options);
899
920
  }
900
921
  makeXHRDeleteRequest(data) {
901
922
  const { uid, item } = data;
902
923
  const xhr = new XMLHttpRequest();
903
- // don't present server issues to user on deletes, just remove them from the visible list
904
- return makeXhrRequest({
924
+ const headers = {
925
+ "x-fileuid": uid,
926
+ "x-filename": item.name,
927
+ };
928
+ let options = {
905
929
  payload: { data: null, name },
906
930
  options: {
907
931
  type: "DELETE",
908
932
  xhr,
909
933
  uri: this.uri,
910
- arguments: `?key=${uid}&name=${item.name}`,
911
- headers: {
912
- "x-fileuid": uid,
913
- "x-filename": item.name,
914
- },
934
+ argument: `?key=${uid}&name=${item.name}`,
935
+ headers,
915
936
  },
916
937
  onFailure: this.transferDoneWithFailure,
917
938
  onSuccess: this.transferDone,
918
939
  onProgress: this.trackProgress,
919
- });
940
+ };
941
+ if (this.middleware) {
942
+ options = this.middleware(options);
943
+ }
944
+ // don't present server issues to user on deletes, just remove them from the visible list
945
+ return makeXhrRequest(options);
920
946
  }
921
947
  /**
922
948
  * Component event handling.
@@ -933,7 +959,7 @@ export class DuetUpload {
933
959
  maxBytes: this.maxBytes,
934
960
  allowedExtensions: this.allowedExtensions,
935
961
  allowedMimetypes: this.allowedMimetypes,
936
- });
962
+ }, this.errorCodes);
937
963
  const uid = this.genHashName();
938
964
  const fileListItem = {
939
965
  uid,
@@ -1082,6 +1108,26 @@ export class DuetUpload {
1082
1108
  "reflect": false,
1083
1109
  "defaultValue": "false"
1084
1110
  },
1111
+ "middleware": {
1112
+ "type": "unknown",
1113
+ "mutable": false,
1114
+ "complexType": {
1115
+ "original": "XHRInternalMiddleWare",
1116
+ "resolved": "(XHRMiddlewareOptions: any) => XHRMiddlewareOptions",
1117
+ "references": {
1118
+ "XHRInternalMiddleWare": {
1119
+ "location": "local"
1120
+ }
1121
+ }
1122
+ },
1123
+ "required": false,
1124
+ "optional": false,
1125
+ "docs": {
1126
+ "tags": [],
1127
+ "text": "If internal upload method is used, and this has been set to a function - it will be called with the XHR options before the reqeust is sent, return an updated XHR options object in order to manipulate the request"
1128
+ },
1129
+ "defaultValue": "null"
1130
+ },
1085
1131
  "deferUpload": {
1086
1132
  "type": "boolean",
1087
1133
  "mutable": false,
@@ -1137,7 +1183,7 @@ export class DuetUpload {
1137
1183
  "tags": [],
1138
1184
  "text": "Default actions added to the internally used duet-editable-table"
1139
1185
  },
1140
- "defaultValue": "[\n {\n icon: \"action-delete\",\n color: \"color-danger\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"delete\",\n map: [\"success\", \"failure\", \"pending\"],\n label: {\n fi: \"Poista tiedosto\",\n en: \"Poista tiedosto\",\n sv: \"Ta bort filen\",\n },\n },\n {\n icon: \"navigation-close\",\n color: \"primary\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"cancel\",\n map: [\"inprogress\"],\n label: {\n fi: \"Keskeyt\u00E4 l\u00E4hetys\",\n en: \"Cancel the upload\",\n sv: \"Stop \u00F6verf\u00F6ringen\",\n },\n },\n ]"
1186
+ "defaultValue": "[\n {\n icon: \"action-delete\",\n color: \"color-danger\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"delete\",\n map: [\"success\", \"failure\"],\n label: {\n fi: \"Poista tiedosto\",\n en: \"Poista tiedosto\",\n sv: \"Ta bort filen\",\n },\n },\n {\n icon: \"navigation-close\",\n color: \"primary\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"cancel\",\n map: [\"inprogress\", \"pending\"],\n label: {\n fi: \"Keskeyt\u00E4 l\u00E4hetys\",\n en: \"Cancel the upload\",\n sv: \"Stop \u00F6verf\u00F6ringen\",\n },\n },\n ]"
1141
1187
  },
1142
1188
  "uri": {
1143
1189
  "type": "string",
@@ -1637,6 +1683,27 @@ export class DuetUpload {
1637
1683
  "reflect": false,
1638
1684
  "defaultValue": "\"\""
1639
1685
  },
1686
+ "errorCodes": {
1687
+ "type": "unknown",
1688
+ "mutable": false,
1689
+ "complexType": {
1690
+ "original": "DuetUploadErrorCode[]",
1691
+ "resolved": "DuetUploadErrorCode[]",
1692
+ "references": {
1693
+ "DuetUploadErrorCode": {
1694
+ "location": "import",
1695
+ "path": "./errorcodes.utils"
1696
+ }
1697
+ }
1698
+ },
1699
+ "required": false,
1700
+ "optional": false,
1701
+ "docs": {
1702
+ "tags": [],
1703
+ "text": "Default errorcodes used by the component, modifiable via javascript"
1704
+ },
1705
+ "defaultValue": "errorCodes"
1706
+ },
1640
1707
  "name": {
1641
1708
  "type": "string",
1642
1709
  "mutable": false,
@@ -1890,6 +1957,25 @@ export class DuetUpload {
1890
1957
  }
1891
1958
  }
1892
1959
  }
1960
+ }, {
1961
+ "method": "duetReady",
1962
+ "name": "duetReady",
1963
+ "bubbles": true,
1964
+ "cancelable": true,
1965
+ "composed": true,
1966
+ "docs": {
1967
+ "tags": [],
1968
+ "text": "Emitted when the component is finished initializing"
1969
+ },
1970
+ "complexType": {
1971
+ "original": "DuetUploadEvent",
1972
+ "resolved": "{ originalEvent?: Event; data?: Record<string, any>; metaData?: Record<string, any>; component: \"duet-upload\"; }",
1973
+ "references": {
1974
+ "DuetUploadEvent": {
1975
+ "location": "local"
1976
+ }
1977
+ }
1978
+ }
1893
1979
  }, {
1894
1980
  "method": "duetDone",
1895
1981
  "name": "duetDone",
@@ -2,13 +2,14 @@
2
2
  * Built with Duet Design System
3
3
  */
4
4
  import { getLocaleString } from "../../utils/language-utils";
5
- import errorCodes from "./errorcodes.json";
6
- export const getError = (code) => {
5
+ import { parsePossibleJSON } from "../../utils/string-utils";
6
+ export const getError = (code, errorCodes) => {
7
7
  let error = {
8
8
  type: undefined,
9
9
  system_message: undefined,
10
10
  message: undefined,
11
11
  };
12
+ errorCodes = parsePossibleJSON(errorCodes);
12
13
  error = errorCodes.filter(errorItem => {
13
14
  // the == is intentional we may be comparing numbers to strings - and that is ok here
14
15
  return errorItem.type == code;
@@ -20,8 +21,8 @@ export const getError = (code) => {
20
21
  }
21
22
  return error;
22
23
  };
23
- export const getI18nError = (errorCode) => {
24
- const errorFromJson = getError(errorCode);
24
+ export const getI18nError = (errorCode, errorCodes) => {
25
+ const errorFromJson = getError(errorCode, errorCodes);
25
26
  const i18String = getLocaleString(errorFromJson.message);
26
27
  if (i18String === "" || !i18String) {
27
28
  return errorFromJson.system_message;
@@ -1,10 +1,19 @@
1
1
  /*!
2
2
  * Built with Duet Design System
3
3
  */
4
+ import errorCodes from "./errorcodes.json";
4
5
  /** list of mock File elements to pass the duet-upload component */
6
+ import { getI18nError } from "./errorcodes.utils";
5
7
  //mock functions to show uploaded file state
6
8
  export function getBrowsedFiles() {
7
9
  return fileListFromArray([
10
+ mockFileCreator({
11
+ name: "action-buy-insurance-default-error.svg",
12
+ type: "image/svg",
13
+ size: 11 * 10000,
14
+ lastModified: new Date(),
15
+ error: "default",
16
+ }),
8
17
  mockFileCreator({
9
18
  name: "action-add-circle.svg",
10
19
  type: "image/svg",
@@ -75,11 +84,13 @@ function fileListFromArray(files) {
75
84
  item: obj.file,
76
85
  size: obj.file.size,
77
86
  valid: isValid,
78
- error: {
79
- type: isValid ? undefined : obj.error,
80
- message: isValid ? undefined : "Random error message",
81
- system_message: isValid ? undefined : "Random system error message",
82
- },
87
+ error: isValid
88
+ ? undefined
89
+ : {
90
+ type: obj.error,
91
+ message: isValid ? undefined : getI18nError(obj.error, errorCodes),
92
+ system_message: isValid ? undefined : getI18nError(obj.error, errorCodes),
93
+ },
83
94
  progress: 100,
84
95
  deleted: false,
85
96
  xhr: false,
@@ -3,14 +3,14 @@
3
3
  */
4
4
  import { h } from "@stencil/core";
5
5
  import { getI18nError } from "./errorcodes.utils";
6
- export const ErrorItem = ({ data }) => {
6
+ export const ErrorItem = ({ data, errorCodes }) => {
7
7
  const { item, error } = data;
8
8
  const { name } = item;
9
9
  const { type } = error;
10
10
  return (h("span", { class: "duet-upload-item-error", role: "status" },
11
11
  h("duet-paragraph", { class: "duet-upload-item-name", color: "danger", margin: "none", weight: "semi-bold" },
12
- h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
13
- " ",
12
+ h("duet-icon", { margin: "none", size: "x-small", name: "messaging-attachment" }),
13
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
14
14
  name),
15
- h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type))));
15
+ h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type, errorCodes))));
16
16
  };
@@ -2,6 +2,9 @@
2
2
  * Built with Duet Design System
3
3
  */
4
4
  import { h } from "@stencil/core";
5
- export const ProgressItem = ({ progress, name }) => (h("span", null,
6
- h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
5
+ export const ProgressItem = ({ progress, name }) => (h("span", { class: "duet-upload-item-name" },
6
+ h("duet-icon", { margin: "none", size: "x-small", name: "messaging-attachment" }),
7
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
8
+ name,
9
+ h("br", null),
7
10
  h("duet-progress", { progress: Math.ceil(progress), "aria-hidden": true })));
@@ -2,6 +2,7 @@
2
2
  * Built with Duet Design System
3
3
  */
4
4
  import { h } from "@stencil/core";
5
- export const PendingItem = ({ name }) => (h("span", null,
6
- h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
7
- h("duet-spacer", { size: "xx-small" })));
5
+ export const PendingItem = ({ name }) => (h("span", { class: "duet-upload-item-name" },
6
+ h("duet-icon", { margin: "none", size: "x-small", name: "messaging-attachment" }),
7
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
8
+ name));
@@ -33,23 +33,23 @@ export const validateFileSize = (size, maxBytes) => {
33
33
  }
34
34
  return maxBytes >= size;
35
35
  };
36
- export const validateFile = (item, validators) => {
36
+ export const validateFile = (item, validators, errorCodes) => {
37
37
  const { allowedMimetypes, allowedExtensions, maxBytes } = validators;
38
38
  let valid = false;
39
- let errorMessage = getError("default");
39
+ let errorMessage = getError("default", errorCodes);
40
40
  if (item) {
41
41
  const { name, type, size } = item;
42
42
  const mime = validateFileMime(type, allowedMimetypes);
43
43
  const ext = validateFileExtension(name.toLowerCase(), allowedExtensions);
44
44
  const bytes = validateFileSize(size, maxBytes);
45
45
  if (!mime) {
46
- errorMessage = getError("duet-upload-101");
46
+ errorMessage = getError("duet-upload-101", errorCodes);
47
47
  }
48
48
  if (!ext) {
49
- errorMessage = getError("duet-upload-100");
49
+ errorMessage = getError("duet-upload-100", errorCodes);
50
50
  }
51
51
  if (!bytes) {
52
- errorMessage = getError("duet-upload-201");
52
+ errorMessage = getError("duet-upload-201", errorCodes);
53
53
  }
54
54
  valid = mime && ext && bytes;
55
55
  }
@@ -2,6 +2,7 @@
2
2
  * Built with Duet Design System
3
3
  */
4
4
  export const makeXhrRequest = ({ payload, options, onFailure, onSuccess, onProgress }) => {
5
+ // @ts-ignore
5
6
  const { type = "POST", xhr, uri, argument = null, headers = null } = options;
6
7
  xhr.open(type, `${uri}${argument || ""}`, true);
7
8
  const { data, name } = payload;