@duetds/components 5.1.4 → 5.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/hydrate/index.js +132 -27
  2. package/lib/cjs/duet-action-button.cjs.entry.js +16 -5
  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 +2 -2
  8. package/lib/cjs/duet-caption_4.cjs.entry.js +2 -2
  9. package/lib/cjs/duet-card.cjs.entry.js +2 -2
  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 +104 -26
  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 +2 -2
  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-9ac6d246.js → focus-utils-a84555de.js} +1 -1
  46. package/lib/cjs/{index-c417c983.js → index-d5c2b63c.js} +1 -1
  47. package/lib/cjs/loader.cjs.js +2 -2
  48. package/lib/cjs/{token-utils-d1f8069b.js → token-utils-50a1f7e2.js} +15 -0
  49. package/lib/collection/components/duet-action-button/duet-action-button.css +2 -2
  50. package/lib/collection/components/duet-action-button/duet-action-button.js +14 -2
  51. package/lib/collection/components/duet-table/duet-table.js +1 -1
  52. package/lib/collection/components/duet-upload/duet-upload.js +136 -27
  53. package/lib/collection/components/duet-upload/upload-editable-item-pending.js +7 -0
  54. package/lib/collection/utils/token-utils.js +14 -0
  55. package/lib/custom-elements-bundle/index.js +133 -30
  56. package/lib/duet/duet.esm.js +1 -1
  57. package/lib/duet/duet.js +1 -1
  58. package/lib/duet/{p-f650fa99.entry.js → p-032948e5.entry.js} +1 -1
  59. package/lib/duet/{p-b1375931.entry.js → p-04ac5c4e.entry.js} +1 -1
  60. package/lib/duet/{p-24c8d0df.entry.js → p-05092d95.entry.js} +1 -1
  61. package/lib/duet/{p-18d04f2e.system.entry.js → p-05ab59af.system.entry.js} +1 -1
  62. package/lib/duet/{p-4dace9be.system.entry.js → p-0dbd1f32.system.entry.js} +1 -1
  63. package/lib/duet/{p-24f41cb3.system.entry.js → p-0f1327c5.system.entry.js} +1 -1
  64. package/lib/duet/{p-4ae75bd5.entry.js → p-0f428b46.entry.js} +1 -1
  65. package/lib/duet/{p-f4943cc5.system.entry.js → p-111e56ea.system.entry.js} +1 -1
  66. package/lib/duet/{p-8a684ac7.system.entry.js → p-1271800f.system.entry.js} +1 -1
  67. package/lib/duet/{p-20c86cc5.system.entry.js → p-18137a51.system.entry.js} +1 -1
  68. package/lib/duet/{p-4a1a4d2d.system.entry.js → p-199b8120.system.entry.js} +1 -1
  69. package/lib/duet/{p-29b73b1b.system.entry.js → p-1eb573fd.system.entry.js} +1 -1
  70. package/lib/duet/{p-30371492.entry.js → p-1ef3c483.entry.js} +1 -1
  71. package/lib/duet/{p-e2074848.system.js → p-2271f8d5.system.js} +1 -1
  72. package/lib/duet/{p-8fa8bdab.system.entry.js → p-258f3ccc.system.entry.js} +1 -1
  73. package/lib/duet/{p-47053a5e.entry.js → p-26294067.entry.js} +1 -1
  74. package/lib/duet/p-2879eb73.entry.js +4 -0
  75. package/lib/duet/{p-b49f89cf.system.entry.js → p-28ee491f.system.entry.js} +1 -1
  76. package/lib/duet/{p-5ff75ab0.entry.js → p-33e5acf3.entry.js} +1 -1
  77. package/lib/duet/{p-f597ccbb.system.entry.js → p-3b316fee.system.entry.js} +1 -1
  78. package/lib/duet/{p-2aeb9bd2.system.entry.js → p-3e654074.system.entry.js} +1 -1
  79. package/lib/duet/{p-e8340671.entry.js → p-3f0c0460.entry.js} +1 -1
  80. package/lib/duet/{p-078fcf7c.system.entry.js → p-4017ddb2.system.entry.js} +1 -1
  81. package/lib/duet/{p-ecf2860f.entry.js → p-41582a97.entry.js} +1 -1
  82. package/lib/duet/{p-bf95adc2.entry.js → p-45753e58.entry.js} +1 -1
  83. package/lib/duet/{p-e6aa9737.entry.js → p-45805cfc.entry.js} +1 -1
  84. package/lib/duet/{p-3956c0b8.system.entry.js → p-45aef220.system.entry.js} +1 -1
  85. package/lib/duet/{p-3f4ea241.entry.js → p-45e5f4f4.entry.js} +1 -1
  86. package/lib/duet/{p-be6e164e.system.entry.js → p-46917bfa.system.entry.js} +1 -1
  87. package/lib/duet/{p-b1039960.system.entry.js → p-4c080f56.system.entry.js} +1 -1
  88. package/lib/duet/{p-37a36786.entry.js → p-4d4ad632.entry.js} +1 -1
  89. package/lib/duet/{p-0e2e056f.system.entry.js → p-5265e0d0.system.entry.js} +1 -1
  90. package/lib/duet/{p-1e5f2840.entry.js → p-5742b705.entry.js} +1 -1
  91. package/lib/duet/{p-89042509.system.entry.js → p-5ce17df4.system.entry.js} +1 -1
  92. package/lib/duet/{p-ab84084f.entry.js → p-5ecfc1ad.entry.js} +1 -1
  93. package/lib/duet/p-6190e2d6.system.js +4 -0
  94. package/lib/duet/{p-e6eb55cf.system.entry.js → p-62e99b72.system.entry.js} +1 -1
  95. package/lib/duet/{p-e15afaf5.system.entry.js → p-67c75f37.system.entry.js} +1 -1
  96. package/lib/duet/{p-0356ed8e.entry.js → p-696fb340.entry.js} +1 -1
  97. package/lib/duet/{p-78d2dfc8.system.entry.js → p-6d480ff6.system.entry.js} +1 -1
  98. package/lib/duet/{p-6440fa65.entry.js → p-740f3d97.entry.js} +1 -1
  99. package/lib/duet/p-746c8ba5.js +4 -0
  100. package/lib/duet/{p-9ce054f9.system.entry.js → p-75d1f821.system.entry.js} +1 -1
  101. package/lib/duet/{p-f8b1afeb.system.entry.js → p-76733981.system.entry.js} +1 -1
  102. package/lib/duet/p-7c1b3583.entry.js +4 -0
  103. package/lib/duet/{p-212f7cf5.entry.js → p-7dfb2869.entry.js} +1 -1
  104. package/lib/duet/{p-d4d7c619.entry.js → p-817aaa83.entry.js} +1 -1
  105. package/lib/duet/{p-445d538d.entry.js → p-820f1caa.entry.js} +1 -1
  106. package/lib/duet/p-83e6a536.system.entry.js +4 -0
  107. package/lib/duet/{p-b6e0ea1d.entry.js → p-84603769.entry.js} +1 -1
  108. package/lib/duet/{p-ec1797d8.entry.js → p-85a02775.entry.js} +1 -1
  109. package/lib/duet/{p-b78ab2f5.system.js → p-88ad1951.system.js} +1 -1
  110. package/lib/duet/{p-ec06dc8c.system.entry.js → p-9601701a.system.entry.js} +1 -1
  111. package/lib/duet/{p-460e6137.system.entry.js → p-96bd1cbc.system.entry.js} +1 -1
  112. package/lib/duet/{p-bd8c5946.entry.js → p-987b7532.entry.js} +1 -1
  113. package/lib/duet/{p-4cab1ba4.system.entry.js → p-9af6ba66.system.entry.js} +1 -1
  114. package/lib/duet/{p-b2dfc5bd.system.entry.js → p-9bfffd81.system.entry.js} +1 -1
  115. package/lib/duet/p-9cca0bb4.js +4 -0
  116. package/lib/duet/{p-e7f60c95.system.entry.js → p-9ecaa83e.system.entry.js} +1 -1
  117. package/lib/duet/{p-f2f17151.system.entry.js → p-a08af4d9.system.entry.js} +1 -1
  118. package/lib/duet/{p-e0e35d41.js → p-a31268d6.js} +1 -1
  119. package/lib/duet/{p-efeac1a1.entry.js → p-a712a800.entry.js} +1 -1
  120. package/lib/duet/{p-37217e63.entry.js → p-aea39e5a.entry.js} +1 -1
  121. package/lib/duet/p-b5a180e9.system.entry.js +4 -0
  122. package/lib/duet/{p-472da63a.system.entry.js → p-bddd664d.system.entry.js} +1 -1
  123. package/lib/duet/{p-87900286.entry.js → p-c0086352.entry.js} +1 -1
  124. package/lib/duet/{p-9d681426.system.entry.js → p-c2ac1fab.system.entry.js} +1 -1
  125. package/lib/duet/{p-4c74be13.system.entry.js → p-c8ad170c.system.entry.js} +1 -1
  126. package/lib/duet/{p-9f3c3af5.system.entry.js → p-ca57d285.system.entry.js} +1 -1
  127. package/lib/duet/{p-7af28ef6.entry.js → p-cc2204e6.entry.js} +1 -1
  128. package/lib/duet/{p-4d95a973.entry.js → p-cc37da81.entry.js} +1 -1
  129. package/lib/duet/{p-1862208a.system.entry.js → p-d41db290.system.entry.js} +1 -1
  130. package/lib/duet/{p-4bbd7a9c.entry.js → p-dab4fba0.entry.js} +1 -1
  131. package/lib/duet/{p-78ccd8fa.entry.js → p-db79c34d.entry.js} +1 -1
  132. package/lib/duet/{p-85e8d34e.system.entry.js → p-dbb107d3.system.entry.js} +1 -1
  133. package/lib/duet/{p-99187a3a.system.js → p-e133d744.system.js} +1 -1
  134. package/lib/duet/{p-2e959285.system.entry.js → p-e1a86fe6.system.entry.js} +1 -1
  135. package/lib/duet/{p-553366aa.entry.js → p-e3882375.entry.js} +1 -1
  136. package/lib/duet/{p-9bf95a5d.entry.js → p-ea9ebc20.entry.js} +1 -1
  137. package/lib/duet/{p-b7e592bf.entry.js → p-eb779add.entry.js} +1 -1
  138. package/lib/duet/{p-71d151e6.entry.js → p-ebf20912.entry.js} +1 -1
  139. package/lib/duet/{p-a980e270.system.entry.js → p-ec0d8fa3.system.entry.js} +1 -1
  140. package/lib/duet/{p-9903055f.system.entry.js → p-ed747a10.system.entry.js} +1 -1
  141. package/lib/duet/{p-9c9947a8.entry.js → p-ef5be208.entry.js} +1 -1
  142. package/lib/duet/{p-2000ef23.entry.js → p-f3f0db95.entry.js} +1 -1
  143. package/lib/duet/{p-4df9144d.system.entry.js → p-f3f1d874.system.entry.js} +1 -1
  144. package/lib/duet/{p-64611b86.entry.js → p-f4f18841.entry.js} +1 -1
  145. package/lib/duet/{p-3474c348.entry.js → p-fc0e878a.entry.js} +1 -1
  146. package/lib/duet/{p-2fd66459.entry.js → p-fc29251a.entry.js} +1 -1
  147. package/lib/duet/{p-b8e8a024.entry.js → p-fdb59ab3.entry.js} +1 -1
  148. package/lib/duet/{p-6144a827.system.entry.js → p-ff56790f.system.entry.js} +1 -1
  149. package/lib/esm/duet-action-button.entry.js +16 -5
  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 +2 -2
  155. package/lib/esm/duet-caption_4.entry.js +2 -2
  156. package/lib/esm/duet-card.entry.js +2 -2
  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 +104 -26
  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 +2 -2
  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-bcb5b759.js → focus-utils-b869910b.js} +1 -1
  193. package/lib/esm/{index-7dc1fa94.js → index-1e15387b.js} +1 -1
  194. package/lib/esm/loader.js +2 -2
  195. package/lib/esm/{token-utils-f3b5f7a8.js → token-utils-1f9435bc.js} +15 -1
  196. package/lib/esm-es5/duet-action-button.entry.js +1 -1
  197. package/lib/esm-es5/duet-alert.entry.js +1 -1
  198. package/lib/esm-es5/duet-badge.entry.js +1 -1
  199. package/lib/esm-es5/duet-breadcrumb.entry.js +1 -1
  200. package/lib/esm-es5/duet-breadcrumbs.entry.js +1 -1
  201. package/lib/esm-es5/duet-button_2.entry.js +1 -1
  202. package/lib/esm-es5/duet-caption_4.entry.js +1 -1
  203. package/lib/esm-es5/duet-card.entry.js +1 -1
  204. package/lib/esm-es5/duet-checkbox.entry.js +1 -1
  205. package/lib/esm-es5/duet-choice_2.entry.js +1 -1
  206. package/lib/esm-es5/duet-collapsible.entry.js +1 -1
  207. package/lib/esm-es5/duet-combobox.entry.js +1 -1
  208. package/lib/esm-es5/duet-cookie-consent.entry.js +1 -1
  209. package/lib/esm-es5/duet-date-picker.entry.js +1 -1
  210. package/lib/esm-es5/duet-divider_2.entry.js +1 -1
  211. package/lib/esm-es5/duet-editable-table_3.entry.js +1 -1
  212. package/lib/esm-es5/duet-empty-state.entry.js +1 -1
  213. package/lib/esm-es5/duet-fieldset.entry.js +1 -1
  214. package/lib/esm-es5/duet-footer.entry.js +1 -1
  215. package/lib/esm-es5/duet-grid_2.entry.js +1 -1
  216. package/lib/esm-es5/duet-header_2.entry.js +1 -1
  217. package/lib/esm-es5/duet-hero.entry.js +1 -1
  218. package/lib/esm-es5/duet-icon.entry.js +1 -1
  219. package/lib/esm-es5/duet-input_2.entry.js +1 -1
  220. package/lib/esm-es5/duet-layout.entry.js +1 -1
  221. package/lib/esm-es5/duet-list_2.entry.js +1 -1
  222. package/lib/esm-es5/duet-modal.entry.js +1 -1
  223. package/lib/esm-es5/duet-notification_2.entry.js +1 -1
  224. package/lib/esm-es5/duet-number-input.entry.js +1 -1
  225. package/lib/esm-es5/duet-pagination_2.entry.js +1 -1
  226. package/lib/esm-es5/duet-progress.entry.js +1 -1
  227. package/lib/esm-es5/duet-radio_2.entry.js +1 -1
  228. package/lib/esm-es5/duet-range-slider.entry.js +1 -1
  229. package/lib/esm-es5/duet-scrollable_3.entry.js +1 -1
  230. package/lib/esm-es5/duet-select.entry.js +1 -1
  231. package/lib/esm-es5/duet-step_2.entry.js +1 -1
  232. package/lib/esm-es5/duet-textarea.entry.js +1 -1
  233. package/lib/esm-es5/duet-toggle.entry.js +1 -1
  234. package/lib/esm-es5/duet-tooltip.entry.js +1 -1
  235. package/lib/esm-es5/duet-tray.entry.js +1 -1
  236. package/lib/esm-es5/duet-upload-aria-status.entry.js +1 -1
  237. package/lib/esm-es5/duet-visually-hidden.entry.js +1 -1
  238. package/lib/esm-es5/duet.js +1 -1
  239. package/lib/esm-es5/focus-utils-b869910b.js +4 -0
  240. package/lib/esm-es5/{index-7dc1fa94.js → index-1e15387b.js} +1 -1
  241. package/lib/esm-es5/loader.js +1 -1
  242. package/lib/esm-es5/token-utils-1f9435bc.js +4 -0
  243. package/lib/html.html-data.json +7 -3
  244. package/lib/types/components/duet-upload/duet-upload.d.ts +18 -1
  245. package/lib/types/components/duet-upload/upload-editable-item-pending.d.ts +6 -0
  246. package/lib/types/components.d.ts +14 -2
  247. package/lib/types/utils/token-utils.d.ts +1 -0
  248. package/package.json +5 -5
  249. package/lib/duet/p-32774c23.system.entry.js +0 -4
  250. package/lib/duet/p-41e4f10e.entry.js +0 -4
  251. package/lib/duet/p-50363944.js +0 -4
  252. package/lib/duet/p-7212c87c.entry.js +0 -4
  253. package/lib/duet/p-81ccf6d6.system.entry.js +0 -4
  254. package/lib/duet/p-9eaccbf3.system.js +0 -4
  255. package/lib/duet/p-e918a990.js +0 -4
  256. package/lib/esm-es5/focus-utils-bcb5b759.js +0 -4
  257. package/lib/esm-es5/token-utils-f3b5f7a8.js +0 -4
@@ -9,6 +9,7 @@ import { inheritGlobalTheme } from "../../utils/themeable-component";
9
9
  import { getError, getI18nError } from "./errorcodes.utils";
10
10
  import { ErrorItem } from "./upload-editable-item-error";
11
11
  import { ProgressItem } from "./upload-editable-item-inprogres";
12
+ import { PendingItem } from "./upload-editable-item-pending";
12
13
  import { SuccessItem } from "./upload-editable-item-success";
13
14
  import { validateFile, validateTotalAmountIsAboveMax, validateTotalSizeIsAboveMax } from "./upload-validators";
14
15
  import { makeXhrRequest } from "./xhr.helpers";
@@ -31,9 +32,13 @@ export class DuetUpload {
31
32
  * it will be up to you to handle the upload and return progress information to the upload-component
32
33
  */
33
34
  this.external = false;
35
+ /**
36
+ * If defer-upload is true, duet-upload will not (as recommended) instantly upload files but await a call to uploadPending()
37
+ */
38
+ this.deferUpload = false;
34
39
  /**
35
40
  * If set the upload component will not display an upload button, you will have to create one yourself
36
- * and call the exposed method startUpload
41
+ * and call the exposed method startUpload to open the upload dialog
37
42
  */
38
43
  this.hideButton = false;
39
44
  /**
@@ -46,7 +51,7 @@ export class DuetUpload {
46
51
  size: "x-small",
47
52
  background: "gray-lightest",
48
53
  name: "delete",
49
- map: ["success", "failure"],
54
+ map: ["success", "failure", "pending"],
50
55
  label: {
51
56
  fi: "Poista tiedosto",
52
57
  en: "Poista tiedosto",
@@ -300,6 +305,7 @@ export class DuetUpload {
300
305
  this.DefaultGroups = {
301
306
  inprogress: "inprogress",
302
307
  success: "success",
308
+ pending: "pending",
303
309
  failure: "failure",
304
310
  };
305
311
  /**
@@ -316,6 +322,14 @@ export class DuetUpload {
316
322
  en: "Files inprogress",
317
323
  },
318
324
  },
325
+ {
326
+ id: this.DefaultGroups.pending,
327
+ label: {
328
+ en: "Files to upload",
329
+ sv: "Filer att ladda",
330
+ fi: "Tiedostot ladattavat",
331
+ },
332
+ },
319
333
  {
320
334
  id: this.DefaultGroups.success,
321
335
  label: {
@@ -343,7 +357,6 @@ export class DuetUpload {
343
357
  this.element.addEventListener("duetActionEvent", (e) => {
344
358
  const detail = e.detail;
345
359
  const { action, id, originalEvent } = detail;
346
- console.log(e);
347
360
  switch (action) {
348
361
  case "delete":
349
362
  this.onDelete(id, originalEvent);
@@ -372,9 +385,6 @@ export class DuetUpload {
372
385
  if (item.valid && item.progress === 100) {
373
386
  // if the item has a group, move the file to that group instead
374
387
  // of into the standard success group
375
- if (item.group) {
376
- return item.group;
377
- }
378
388
  return this.DefaultGroups.success;
379
389
  }
380
390
  else if (item.progress > 0 && item.progress !== 100) {
@@ -383,6 +393,9 @@ export class DuetUpload {
383
393
  else if (!item.valid) {
384
394
  return this.DefaultGroups.failure;
385
395
  }
396
+ else if (item.pending) {
397
+ return this.DefaultGroups.pending;
398
+ }
386
399
  else if (item.group) {
387
400
  return item.group;
388
401
  }
@@ -397,6 +410,9 @@ export class DuetUpload {
397
410
  else if (group === this.DefaultGroups.inprogress) {
398
411
  return h(ProgressItem, { progress: data.progress, name: data.item.name });
399
412
  }
413
+ else if (group === this.DefaultGroups.pending) {
414
+ return h(PendingItem, { name: data.item.name });
415
+ }
400
416
  else if (group === this.DefaultGroups.failure) {
401
417
  return h(ErrorItem, { data: data });
402
418
  }
@@ -409,9 +425,16 @@ export class DuetUpload {
409
425
  };
410
426
  this.genHashName = () => Date.now().toString(36) + Math.random();
411
427
  this.updateValueInMap = (item, key, value, kick = true) => {
412
- const fileItem = this.files.get(item);
413
- fileItem[key] = value;
414
- this.files.set(item, fileItem);
428
+ try {
429
+ const fileItem = this.files.get(item);
430
+ fileItem[key] = value;
431
+ this.files.set(item, fileItem);
432
+ }
433
+ catch (e) {
434
+ // if a users tries to update entries on a file that doesn't exist,
435
+ // this will blow up - so we're swallowing the errors here on purpose
436
+ // console.warn("operation on missing items")
437
+ }
415
438
  if (kick) {
416
439
  this.kick();
417
440
  }
@@ -529,6 +552,46 @@ export class DuetUpload {
529
552
  fileMaxReached: isTotalFileAmountAboveMax,
530
553
  };
531
554
  };
555
+ this.uploadFile = async (fileListItem, force = false, key) => {
556
+ if (!force && this.deferUpload) {
557
+ this.updateValueInMap(fileListItem.item.name, "pending", true, false);
558
+ this.updateValueInMap(fileListItem.item.name, "group", "pending", true);
559
+ }
560
+ else if (force) {
561
+ this.updateValueInMap(fileListItem.item.name, "pending", false, false);
562
+ this.updateValueInMap(fileListItem.item.name, "group", undefined, true);
563
+ }
564
+ try {
565
+ if (!this.deferUpload || force) {
566
+ // if all is well AND external file upload handling has not been set, start upload
567
+ const data = new FormData();
568
+ data.append("file", fileListItem.item);
569
+ if (key) {
570
+ data.append("key", key);
571
+ }
572
+ data.append("uid", fileListItem.uid);
573
+ data.append("name", fileListItem.item.name);
574
+ data.append("metadata", JSON.stringify({
575
+ uid: fileListItem.uid,
576
+ url: this.uri,
577
+ size: fileListItem.item.size,
578
+ meta: fileListItem.meta,
579
+ }));
580
+ fileListItem.xhr = await this.makeXHRPostRequest(data);
581
+ }
582
+ }
583
+ catch (e) {
584
+ // in case one of the global maxes have been reached, invalidate the file
585
+ this.updateValueInMap(fileListItem.item.name, "valid", false, false);
586
+ }
587
+ };
588
+ this.uploadPendingFiles = () => {
589
+ for (const [key, value] of this.files.entries()) {
590
+ if (value.group === "pending" && value.pending === true) {
591
+ this.uploadFile(value, true, key);
592
+ }
593
+ }
594
+ };
532
595
  this.getItemFromUID = (uid) => {
533
596
  for (const [key, value] of this.files.entries()) {
534
597
  if (value.uid === uid) {
@@ -538,7 +601,8 @@ export class DuetUpload {
538
601
  return null;
539
602
  };
540
603
  this.onDelete = (key, ev) => {
541
- const retrievedKey = this.getItemFromUID(key).key;
604
+ const item = this.getItemFromUID(key);
605
+ const retrievedKey = item.key;
542
606
  const deletedItem = this.files.get(retrievedKey);
543
607
  this.files.delete(retrievedKey);
544
608
  this.validateTotals();
@@ -548,7 +612,8 @@ export class DuetUpload {
548
612
  data: { deletion: deletedItem },
549
613
  component: "duet-upload",
550
614
  });
551
- if (!this.external) {
615
+ // don't send a xhr request if the item was pending, just remove it from the list
616
+ if (!this.external && !deletedItem.pending) {
552
617
  this.makeXHRDeleteRequest(deletedItem);
553
618
  }
554
619
  this.resetFormFields();
@@ -613,6 +678,7 @@ export class DuetUpload {
613
678
  const all = [...this.files.values()];
614
679
  const inprogress = [];
615
680
  const failure = [];
681
+ const pending = [];
616
682
  const success = [];
617
683
  all.forEach(data => {
618
684
  const group = this.getGroupFromItemData(data);
@@ -631,6 +697,13 @@ export class DuetUpload {
631
697
  group,
632
698
  });
633
699
  }
700
+ else if (group === this.DefaultGroups.pending) {
701
+ pending.push({
702
+ uid: data.uid,
703
+ item,
704
+ group,
705
+ });
706
+ }
634
707
  else if (group === this.DefaultGroups.failure) {
635
708
  failure.push({
636
709
  uid: data.uid,
@@ -648,6 +721,7 @@ export class DuetUpload {
648
721
  });
649
722
  return {
650
723
  inprogress,
724
+ pending,
651
725
  failure,
652
726
  success,
653
727
  };
@@ -729,6 +803,12 @@ export class DuetUpload {
729
803
  this.nativeInput.click();
730
804
  return;
731
805
  }
806
+ /**
807
+ * Method for uploading pending files
808
+ */
809
+ async uploadPending() {
810
+ this.uploadPendingFiles();
811
+ }
732
812
  /**
733
813
  * Method for forcing a render of the upload list, element.files can be changed externally
734
814
  * But it will only rerender on a new Map or a top Level change - this can be used to update
@@ -884,19 +964,14 @@ export class DuetUpload {
884
964
  this.updateValueInMap(item.name, "valid", false, false);
885
965
  }
886
966
  else if (valid && !this.external) {
887
- // if all is well AND external file upload handling has not been set, start upload
888
- const data = new FormData();
889
- data.append("file", item);
890
- data.append("uid", uid);
891
- data.append("name", item.name);
892
- data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size, meta: fileListItem.meta }));
893
- try {
894
- fileListItem.xhr = await this.makeXHRPostRequest(data);
895
- }
896
- catch (e) {
897
- // in case one of the global maxes have been reached, invalidate the file
898
- this.updateValueInMap(item.name, "valid", false, false);
899
- }
967
+ await this.uploadFile(fileListItem);
968
+ }
969
+ else if (valid && this.external) {
970
+ this.updateValueInMap(fileListItem.item.name, "pending", true, false);
971
+ this.updateValueInMap(fileListItem.item.name, "group", "pending", true);
972
+ }
973
+ else if (!valid) {
974
+ this.updateValueInMap(item.name, "valid", false, true);
900
975
  }
901
976
  // kick the stat to force update
902
977
  this.kick();
@@ -1007,6 +1082,24 @@ export class DuetUpload {
1007
1082
  "reflect": false,
1008
1083
  "defaultValue": "false"
1009
1084
  },
1085
+ "deferUpload": {
1086
+ "type": "boolean",
1087
+ "mutable": false,
1088
+ "complexType": {
1089
+ "original": "boolean",
1090
+ "resolved": "boolean",
1091
+ "references": {}
1092
+ },
1093
+ "required": false,
1094
+ "optional": false,
1095
+ "docs": {
1096
+ "tags": [],
1097
+ "text": "If defer-upload is true, duet-upload will not (as recommended) instantly upload files but await a call to uploadPending()"
1098
+ },
1099
+ "attribute": "defer-upload",
1100
+ "reflect": false,
1101
+ "defaultValue": "false"
1102
+ },
1010
1103
  "hideButton": {
1011
1104
  "type": "boolean",
1012
1105
  "mutable": false,
@@ -1019,7 +1112,7 @@ export class DuetUpload {
1019
1112
  "optional": false,
1020
1113
  "docs": {
1021
1114
  "tags": [],
1022
- "text": "If set the upload component will not display an upload button, you will have to create one yourself\nand call the exposed method startUpload"
1115
+ "text": "If set the upload component will not display an upload button, you will have to create one yourself\nand call the exposed method startUpload to open the upload dialog"
1023
1116
  },
1024
1117
  "attribute": "hide-upload-button",
1025
1118
  "reflect": false,
@@ -1044,7 +1137,7 @@ export class DuetUpload {
1044
1137
  "tags": [],
1045
1138
  "text": "Default actions added to the internally used duet-editable-table"
1046
1139
  },
1047
- "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\"],\n label: {\n fi: \"Keskeyt\u00E4 l\u00E4hetys\",\n en: \"Cancel the upload\",\n sv: \"Stop \u00F6verf\u00F6ringen\",\n },\n },\n ]"
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 ]"
1048
1141
  },
1049
1142
  "uri": {
1050
1143
  "type": "string",
@@ -1734,7 +1827,7 @@ export class DuetUpload {
1734
1827
  }],
1735
1828
  "text": "Array of group names that you want the editable table to use to display files"
1736
1829
  },
1737
- "defaultValue": "[\n {\n id: this.DefaultGroups.inprogress,\n label: {\n fi: \"Kesken olevat tiedostot\",\n sv: \"Filer inprogress\",\n en: \"Files inprogress\",\n },\n },\n {\n id: this.DefaultGroups.success,\n label: {\n fi: \"Valmiit tiedostot\",\n sv: \"Files success\",\n en: \"Files success\",\n },\n },\n {\n id: this.DefaultGroups.failure,\n label: {\n fi: \"Tiedostot, joissa on virheit\u00E4\",\n sv: \"Filer med fel\",\n en: \"Files with errors\",\n },\n },\n ]"
1830
+ "defaultValue": "[\n {\n id: this.DefaultGroups.inprogress,\n label: {\n fi: \"Kesken olevat tiedostot\",\n sv: \"Filer inprogress\",\n en: \"Files inprogress\",\n },\n },\n {\n id: this.DefaultGroups.pending,\n label: {\n en: \"Files to upload\",\n sv: \"Filer att ladda\",\n fi: \"Tiedostot ladattavat\",\n },\n },\n {\n id: this.DefaultGroups.success,\n label: {\n fi: \"Valmiit tiedostot\",\n sv: \"Files success\",\n en: \"Files success\",\n },\n },\n {\n id: this.DefaultGroups.failure,\n label: {\n fi: \"Tiedostot, joissa on virheit\u00E4\",\n sv: \"Filer med fel\",\n en: \"Files with errors\",\n },\n },\n ]"
1738
1831
  }
1739
1832
  }; }
1740
1833
  static get states() { return {
@@ -1954,6 +2047,22 @@ export class DuetUpload {
1954
2047
  "tags": []
1955
2048
  }
1956
2049
  },
2050
+ "uploadPending": {
2051
+ "complexType": {
2052
+ "signature": "() => Promise<void>",
2053
+ "parameters": [],
2054
+ "references": {
2055
+ "Promise": {
2056
+ "location": "global"
2057
+ }
2058
+ },
2059
+ "return": "Promise<void>"
2060
+ },
2061
+ "docs": {
2062
+ "text": "Method for uploading pending files",
2063
+ "tags": []
2064
+ }
2065
+ },
1957
2066
  "refresh": {
1958
2067
  "complexType": {
1959
2068
  "signature": "() => Promise<void>",
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Built with Duet Design System
3
+ */
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" })));
@@ -103,3 +103,17 @@ export function getFontSizeByName(name) {
103
103
  export function getFontWeightByName(name) {
104
104
  return getTokenByName("fontWeight", name);
105
105
  }
106
+ export function shadeRGBColor(color, percent) {
107
+ const f = color.split(","), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent;
108
+ let R = parseInt(f[0].slice(4)), G = parseInt(f[1]), B = parseInt(f[2]);
109
+ R = Math.round((t - R) * p) + R;
110
+ G = Math.round((t - G) * p) + G;
111
+ B = Math.round((t - B) * p) + B;
112
+ R = R < 0 ? 0 : R;
113
+ R = R > 255 ? 255 : R;
114
+ G = G < 0 ? 0 : G;
115
+ G = G > 255 ? 255 : G;
116
+ B = B < 0 ? 0 : B;
117
+ B = B > 255 ? 255 : B;
118
+ return `rgb(${R},${G},${B})`;
119
+ }