@duetds/components 4.31.0 → 4.33.2

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 (375) hide show
  1. package/hydrate/index.js +1895 -77
  2. package/lib/cjs/{dom-e89ebf90.js → dom-c850c8d7.js} +1 -1
  3. package/lib/cjs/duet-alert.cjs.entry.js +2 -2
  4. package/lib/cjs/duet-badge.cjs.entry.js +1 -1
  5. package/lib/cjs/duet-button_2.cjs.entry.js +4 -4
  6. package/lib/cjs/duet-caption_4.cjs.entry.js +17 -10
  7. package/lib/cjs/duet-card.cjs.entry.js +5 -5
  8. package/lib/cjs/duet-checkbox.cjs.entry.js +2 -2
  9. package/lib/cjs/duet-choice_2.cjs.entry.js +53 -24
  10. package/lib/cjs/duet-collapsible.cjs.entry.js +4 -449
  11. package/lib/cjs/duet-cookie-consent.cjs.entry.js +1 -1
  12. package/lib/cjs/duet-date-picker.cjs.entry.js +7 -7
  13. package/lib/cjs/duet-divider_2.cjs.entry.js +1 -1
  14. package/lib/cjs/duet-editable-table-button.cjs.entry.js +89 -0
  15. package/lib/cjs/duet-editable-table_4.cjs.entry.js +1445 -0
  16. package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
  17. package/lib/cjs/duet-fieldset.cjs.entry.js +1 -1
  18. package/lib/cjs/duet-footer.cjs.entry.js +2 -2
  19. package/lib/cjs/duet-grid_2.cjs.entry.js +69 -4
  20. package/lib/cjs/duet-header_2.cjs.entry.js +3 -3
  21. package/lib/cjs/duet-hero.cjs.entry.js +2 -2
  22. package/lib/cjs/duet-icon.cjs.entry.js +5 -13
  23. package/lib/cjs/duet-input_2.cjs.entry.js +6 -6
  24. package/lib/cjs/duet-layout.cjs.entry.js +1 -1
  25. package/lib/cjs/duet-list_2.cjs.entry.js +2 -2
  26. package/lib/cjs/duet-modal.cjs.entry.js +3 -3
  27. package/lib/cjs/duet-notification_2.cjs.entry.js +2 -2
  28. package/lib/cjs/duet-number-input.cjs.entry.js +2 -2
  29. package/lib/cjs/duet-progress.cjs.entry.js +75 -0
  30. package/lib/cjs/duet-radio_2.cjs.entry.js +2 -2
  31. package/lib/cjs/duet-range-slider.cjs.entry.js +2 -2
  32. package/lib/cjs/duet-select.cjs.entry.js +5 -5
  33. package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
  34. package/lib/cjs/duet-tab_2.cjs.entry.js +3 -3
  35. package/lib/cjs/duet-textarea.cjs.entry.js +5 -5
  36. package/lib/cjs/duet-toggle.cjs.entry.js +1 -1
  37. package/lib/cjs/duet-tooltip.cjs.entry.js +2 -2
  38. package/lib/cjs/duet-tray.cjs.entry.js +3 -3
  39. package/lib/cjs/duet-upload-aria-status.cjs.entry.js +100 -0
  40. package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
  41. package/lib/cjs/duet.cjs.js +4 -4
  42. package/lib/cjs/{focus-utils-bd331feb.js → focus-utils-27c696bb.js} +1 -1
  43. package/lib/cjs/{index-113c2add.js → index-18b0f43a.js} +91 -77
  44. package/lib/cjs/{language-utils-48b8860b.js → language-utils-aa282901.js} +6 -2
  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/{token-utils-13e5d13e.js → token-utils-63a9c8dc.js} +1 -1
  48. package/lib/cjs/tokens-8596cece.js +459 -0
  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 +17 -3
  52. package/lib/collection/components/duet-alert/duet-alert.js +4 -4
  53. package/lib/collection/components/duet-button/duet-button.js +10 -10
  54. package/lib/collection/components/duet-card/duet-card.css +20 -0
  55. package/lib/collection/components/duet-card/duet-card.js +4 -1
  56. package/lib/collection/components/duet-checkbox/duet-checkbox.css +1 -1
  57. package/lib/collection/components/duet-choice/duet-choice.css +16 -3
  58. package/lib/collection/components/duet-choice/duet-choice.js +117 -33
  59. package/lib/collection/components/duet-choice-group/duet-choice-group.js +4 -4
  60. package/lib/collection/components/duet-date-picker/duet-date-picker.js +16 -16
  61. package/lib/collection/components/duet-editable-table/duet-editable-table-button.css +32 -0
  62. package/lib/collection/components/duet-editable-table/duet-editable-table-button.js +218 -0
  63. package/lib/collection/components/duet-editable-table/duet-editable-table-item.css +36 -0
  64. package/lib/collection/components/duet-editable-table/duet-editable-table-item.js +203 -0
  65. package/lib/collection/components/duet-editable-table/duet-editable-table-tabledata.js +13 -0
  66. package/lib/collection/components/duet-editable-table/duet-editable-table.css +16 -0
  67. package/lib/collection/components/duet-editable-table/duet-editable-table.js +348 -0
  68. package/lib/collection/components/duet-footer/duet-footer.js +10 -10
  69. package/lib/collection/components/duet-grid/duet-grid.js +74 -6
  70. package/lib/collection/components/duet-grid-item/duet-grid-item.js +4 -4
  71. package/lib/collection/components/duet-header/duet-header.js +16 -16
  72. package/lib/collection/components/duet-heading/duet-heading.css +3 -0
  73. package/lib/collection/components/duet-heading/duet-heading.js +7 -6
  74. package/lib/collection/components/duet-hero/duet-hero.js +8 -8
  75. package/lib/collection/components/duet-icon/icon-utils.js +5 -8
  76. package/lib/collection/components/duet-input/duet-input.css +15 -0
  77. package/lib/collection/components/duet-input/duet-input.js +4 -4
  78. package/lib/collection/components/duet-link/duet-link.js +8 -8
  79. package/lib/collection/components/duet-logo/duet-logo.js +4 -4
  80. package/lib/collection/components/duet-modal/duet-modal.js +8 -8
  81. package/lib/collection/components/duet-notification/duet-notification.js +8 -8
  82. package/lib/collection/components/duet-notification-drawer/duet-notification-drawer.js +8 -8
  83. package/lib/collection/components/duet-number-input/duet-number-input.js +20 -20
  84. package/lib/collection/components/duet-paragraph/duet-paragraph.css +6 -0
  85. package/lib/collection/components/duet-paragraph/duet-paragraph.js +34 -3
  86. package/lib/collection/components/duet-progress/duet-progress.css +103 -0
  87. package/lib/collection/components/duet-progress/duet-progress.js +240 -0
  88. package/lib/collection/components/duet-radio/duet-radio.js +6 -6
  89. package/lib/collection/components/duet-select/duet-select.css +15 -0
  90. package/lib/collection/components/duet-select/duet-select.js +3 -3
  91. package/lib/collection/components/duet-step/duet-step.js +8 -8
  92. package/lib/collection/components/duet-tab-group/duet-tab-group.css +2 -2
  93. package/lib/collection/components/duet-tab-group/duet-tab-group.js +10 -10
  94. package/lib/collection/components/duet-textarea/duet-textarea.css +19 -0
  95. package/lib/collection/components/duet-textarea/duet-textarea.js +5 -4
  96. package/lib/collection/components/duet-tooltip/duet-tooltip.js +14 -14
  97. package/lib/collection/components/duet-tray/duet-tray.js +12 -12
  98. package/lib/collection/components/duet-upload/duet-upload.css +64 -0
  99. package/lib/collection/components/duet-upload/duet-upload.js +1863 -0
  100. package/lib/collection/components/duet-upload/errorcodes.utils.js +32 -0
  101. package/lib/collection/components/duet-upload/mock.helpers.js +91 -0
  102. package/lib/collection/components/duet-upload/upload-editable-item-error.js +16 -0
  103. package/lib/collection/components/duet-upload/upload-editable-item-inprogres.js +8 -0
  104. package/lib/collection/components/duet-upload/upload-editable-item-success.js +30 -0
  105. package/lib/collection/components/duet-upload/upload-validators.js +93 -0
  106. package/lib/collection/components/duet-upload/upload.helpers.js +13 -0
  107. package/lib/collection/components/duet-upload/xhr.helpers.js +30 -0
  108. package/lib/collection/components/duet-upload-aria-status/duet-upload-aria-status.js +217 -0
  109. package/lib/collection/utils/js-utils.js +12 -0
  110. package/lib/collection/utils/language-utils.js +6 -3
  111. package/lib/collection/utils/watch-options.js +35 -6
  112. package/lib/custom-elements-bundle/index.d.ts +36 -0
  113. package/lib/custom-elements-bundle/index.js +2014 -322
  114. package/lib/duet/duet.esm.js +1 -1
  115. package/lib/duet/duet.js +1 -1
  116. package/lib/duet/{p-60ab57d4.entry.js → p-042ec8b1.entry.js} +1 -1
  117. package/lib/duet/{p-bcae23fc.system.entry.js → p-0435b54a.system.entry.js} +1 -1
  118. package/lib/duet/{p-dc85d2a4.entry.js → p-04b3e682.entry.js} +1 -1
  119. package/lib/duet/p-0ac2e60d.system.entry.js +4 -0
  120. package/lib/duet/p-0d22396e.system.js +16 -0
  121. package/lib/duet/p-1082d9f2.system.entry.js +4 -0
  122. package/lib/duet/p-12721178.js +4 -0
  123. package/lib/duet/{p-7d080785.system.entry.js → p-12fc4849.system.entry.js} +1 -1
  124. package/lib/duet/{p-c4737f88.entry.js → p-15fae689.entry.js} +1 -1
  125. package/lib/duet/p-1ad58142.entry.js +4 -0
  126. package/lib/duet/{p-c5f10483.system.entry.js → p-1c7d7cdd.system.entry.js} +1 -1
  127. package/lib/duet/p-1cf8dbc7.system.js +4 -0
  128. package/lib/duet/p-1dcbd837.system.entry.js +4 -0
  129. package/lib/duet/{p-fdecaf46.entry.js → p-1ecddc1d.entry.js} +1 -1
  130. package/lib/duet/p-2764f081.js +4 -0
  131. package/lib/duet/p-2b4bd1b2.system.entry.js +4 -0
  132. package/lib/duet/p-2d8e0faa.system.entry.js +4 -0
  133. package/lib/duet/{p-453955cc.system.entry.js → p-33538e90.system.entry.js} +1 -1
  134. package/lib/duet/{p-b1b8e510.entry.js → p-3364cfd2.entry.js} +1 -1
  135. package/lib/duet/p-350cea4e.system.entry.js +4 -0
  136. package/lib/duet/{p-bd9a7d8f.js → p-35a3794e.js} +0 -0
  137. package/lib/duet/p-39e9d638.entry.js +4 -0
  138. package/lib/duet/{p-1e7222c2.entry.js → p-3a7e519e.entry.js} +1 -1
  139. package/lib/duet/{p-9ce1baab.system.entry.js → p-3bcf2054.system.entry.js} +1 -1
  140. package/lib/duet/{p-322d1c38.js → p-3c1971d8.js} +1 -1
  141. package/lib/duet/{p-ef45cfe9.system.entry.js → p-3cad13af.system.entry.js} +1 -1
  142. package/lib/duet/p-408e8cdb.system.js +4 -0
  143. package/lib/duet/p-4a14da52.entry.js +4 -0
  144. package/lib/duet/{p-f96c4093.system.entry.js → p-4e17a6cb.system.entry.js} +1 -1
  145. package/lib/duet/{p-fbd83d67.entry.js → p-50b796eb.entry.js} +1 -1
  146. package/lib/duet/{p-22f56356.system.entry.js → p-5727cd82.system.entry.js} +1 -1
  147. package/lib/duet/{p-9c94be45.entry.js → p-582f3a2c.entry.js} +1 -1
  148. package/lib/duet/{p-e39471b6.entry.js → p-5b9621e2.entry.js} +1 -1
  149. package/lib/duet/{p-3e1ef509.system.entry.js → p-5f79eff8.system.entry.js} +1 -1
  150. package/lib/duet/{p-95626e7e.system.entry.js → p-60e721aa.system.entry.js} +1 -1
  151. package/lib/duet/{p-b03a46b6.entry.js → p-60ef3d05.entry.js} +1 -1
  152. package/lib/duet/{p-57ea2576.system.js → p-61fc3872.system.js} +1 -1
  153. package/lib/duet/{p-1cd7177f.entry.js → p-637df820.entry.js} +1 -1
  154. package/lib/duet/{p-07263910.system.entry.js → p-6402041d.system.entry.js} +1 -1
  155. package/lib/duet/p-64c0aa2a.entry.js +4 -0
  156. package/lib/duet/{p-28b67b94.entry.js → p-65451003.entry.js} +1 -1
  157. package/lib/duet/{p-1bfbc988.entry.js → p-659d6cb7.entry.js} +1 -1
  158. package/lib/duet/{p-91fa68a5.js → p-66fdebc5.js} +1 -1
  159. package/lib/duet/p-6708db8a.entry.js +4 -0
  160. package/lib/duet/{p-e08b8909.entry.js → p-68635a1c.entry.js} +1 -1
  161. package/lib/duet/p-6e363557.system.js +4 -0
  162. package/lib/duet/p-70fafc98.system.js +4 -0
  163. package/lib/duet/p-720a36f2.entry.js +4 -0
  164. package/lib/duet/{p-f53c8019.entry.js → p-72629304.entry.js} +1 -1
  165. package/lib/duet/p-75a104e3.entry.js +4 -0
  166. package/lib/duet/{p-02ad46a0.system.entry.js → p-75e5d4d1.system.entry.js} +1 -1
  167. package/lib/duet/{p-33cf6ed1.entry.js → p-7ab0bad8.entry.js} +1 -1
  168. package/lib/duet/{p-e834c8d5.system.entry.js → p-7ceaf4ef.system.entry.js} +1 -1
  169. package/lib/duet/{p-a1d12e94.system.entry.js → p-7f8cce41.system.entry.js} +1 -1
  170. package/lib/duet/{p-6d2da245.entry.js → p-7fed7f57.entry.js} +1 -1
  171. package/lib/duet/p-8143f3de.js +4 -0
  172. package/lib/duet/p-8c2f14d8.system.entry.js +4 -0
  173. package/lib/duet/{p-4670a654.entry.js → p-8c730326.entry.js} +1 -1
  174. package/lib/duet/{p-de093c16.entry.js → p-9125ed25.entry.js} +1 -1
  175. package/lib/duet/p-933c2774.system.entry.js +4 -0
  176. package/lib/duet/{p-b7e50cfa.entry.js → p-9584411c.entry.js} +1 -1
  177. package/lib/duet/p-987edcd0.js +15 -0
  178. package/lib/duet/p-9930e52e.entry.js +4 -0
  179. package/lib/duet/p-9a09ac2b.system.entry.js +4 -0
  180. package/lib/duet/{p-64109493.entry.js → p-a09ddd8f.entry.js} +1 -1
  181. package/lib/duet/{p-504dbf8f.system.entry.js → p-a2b2fa13.system.entry.js} +1 -1
  182. package/lib/duet/{p-2826f987.js → p-ad07f399.js} +1 -1
  183. package/lib/duet/{p-605bc214.system.entry.js → p-b1ad7a52.system.entry.js} +1 -1
  184. package/lib/duet/{p-f0b1850a.system.entry.js → p-b5dc29b8.system.entry.js} +1 -1
  185. package/lib/duet/p-ba6214be.entry.js +4 -0
  186. package/lib/duet/{p-92d38668.system.entry.js → p-be349a3d.system.entry.js} +1 -1
  187. package/lib/duet/{p-56e172f5.system.entry.js → p-c0f3f60f.system.entry.js} +1 -1
  188. package/lib/duet/{p-fd98468a.system.js → p-c18a599e.system.js} +0 -0
  189. package/lib/duet/p-c3c95a34.system.entry.js +4 -0
  190. package/lib/duet/{p-d4b4bfa6.entry.js → p-c506017d.entry.js} +1 -1
  191. package/lib/duet/p-c74cecf2.system.entry.js +4 -0
  192. package/lib/duet/p-c9a11360.entry.js +4 -0
  193. package/lib/duet/p-cd21755b.entry.js +4 -0
  194. package/lib/duet/p-cd597d62.system.entry.js +4 -0
  195. package/lib/duet/p-cff461b6.entry.js +4 -0
  196. package/lib/duet/{p-7b6db837.system.entry.js → p-d0fb19f7.system.entry.js} +1 -1
  197. package/lib/duet/{p-69a5dc6b.entry.js → p-d1dfa30e.entry.js} +1 -1
  198. package/lib/duet/{p-1cec5a70.system.entry.js → p-d4e706ac.system.entry.js} +1 -1
  199. package/lib/duet/{p-8cb47a70.system.entry.js → p-d5e2bb48.system.entry.js} +1 -1
  200. package/lib/duet/p-dd79932a.entry.js +4 -0
  201. package/lib/duet/p-dd9b8fcb.system.entry.js +4 -0
  202. package/lib/duet/p-ddb6344c.system.js +4 -0
  203. package/lib/duet/{p-47645ea8.system.entry.js → p-de43620d.system.entry.js} +1 -1
  204. package/lib/duet/p-e038da47.system.entry.js +4 -0
  205. package/lib/duet/p-eb55ccd2.system.js +4 -0
  206. package/lib/duet/p-ebc4e334.js +4 -0
  207. package/lib/duet/{p-5fc7e1f7.system.entry.js → p-f37ffb6f.system.entry.js} +1 -1
  208. package/lib/duet/p-f8744611.entry.js +4 -0
  209. package/lib/duet/p-fa99eaa4.system.js +4 -0
  210. package/lib/duet/{p-746655ba.entry.js → p-fd00b025.entry.js} +1 -1
  211. package/lib/esm/{dom-21034390.js → dom-58cd15f6.js} +1 -1
  212. package/lib/esm/duet-alert.entry.js +2 -2
  213. package/lib/esm/duet-badge.entry.js +1 -1
  214. package/lib/esm/duet-button_2.entry.js +4 -4
  215. package/lib/esm/duet-caption_4.entry.js +17 -10
  216. package/lib/esm/duet-card.entry.js +5 -5
  217. package/lib/esm/duet-checkbox.entry.js +2 -2
  218. package/lib/esm/duet-choice_2.entry.js +54 -25
  219. package/lib/esm/duet-collapsible.entry.js +3 -448
  220. package/lib/esm/duet-cookie-consent.entry.js +1 -1
  221. package/lib/esm/duet-date-picker.entry.js +7 -7
  222. package/lib/esm/duet-divider_2.entry.js +1 -1
  223. package/lib/esm/duet-editable-table-button.entry.js +85 -0
  224. package/lib/esm/duet-editable-table_4.entry.js +1438 -0
  225. package/lib/esm/duet-empty-state.entry.js +1 -1
  226. package/lib/esm/duet-fieldset.entry.js +1 -1
  227. package/lib/esm/duet-footer.entry.js +2 -2
  228. package/lib/esm/duet-grid_2.entry.js +69 -4
  229. package/lib/esm/duet-header_2.entry.js +3 -3
  230. package/lib/esm/duet-hero.entry.js +2 -2
  231. package/lib/esm/duet-icon.entry.js +5 -13
  232. package/lib/esm/duet-input_2.entry.js +6 -6
  233. package/lib/esm/duet-layout.entry.js +1 -1
  234. package/lib/esm/duet-list_2.entry.js +2 -2
  235. package/lib/esm/duet-modal.entry.js +3 -3
  236. package/lib/esm/duet-notification_2.entry.js +2 -2
  237. package/lib/esm/duet-number-input.entry.js +2 -2
  238. package/lib/esm/duet-progress.entry.js +71 -0
  239. package/lib/esm/duet-radio_2.entry.js +2 -2
  240. package/lib/esm/duet-range-slider.entry.js +2 -2
  241. package/lib/esm/duet-select.entry.js +5 -5
  242. package/lib/esm/duet-step_2.entry.js +1 -1
  243. package/lib/esm/duet-tab_2.entry.js +3 -3
  244. package/lib/esm/duet-textarea.entry.js +5 -5
  245. package/lib/esm/duet-toggle.entry.js +1 -1
  246. package/lib/esm/duet-tooltip.entry.js +2 -2
  247. package/lib/esm/duet-tray.entry.js +3 -3
  248. package/lib/esm/duet-upload-aria-status.entry.js +96 -0
  249. package/lib/esm/duet-visually-hidden.entry.js +1 -1
  250. package/lib/esm/duet.js +4 -4
  251. package/lib/esm/{focus-utils-1995e5a9.js → focus-utils-c1fa24c4.js} +1 -1
  252. package/lib/esm/{index-6e246691.js → index-05e43a37.js} +91 -78
  253. package/lib/esm/{language-utils-d5c38f65.js → language-utils-344d894c.js} +6 -3
  254. package/lib/esm/loader.js +3 -3
  255. package/lib/esm/{shadow-css-31e2d504.js → shadow-css-7c726abb.js} +9 -10
  256. package/lib/esm/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
  257. package/lib/esm/tokens-e110dc89.js +453 -0
  258. package/lib/esm/{tokens.module-edb66c04.js → tokens.module-49cbf963.js} +3 -1
  259. package/lib/esm/watch-options-dd55bce8.js +57 -0
  260. package/lib/esm-es5/{dom-21034390.js → dom-58cd15f6.js} +0 -0
  261. package/lib/esm-es5/duet-alert.entry.js +1 -1
  262. package/lib/esm-es5/duet-badge.entry.js +1 -1
  263. package/lib/esm-es5/duet-button_2.entry.js +1 -1
  264. package/lib/esm-es5/duet-caption_4.entry.js +2 -2
  265. package/lib/esm-es5/duet-card.entry.js +1 -1
  266. package/lib/esm-es5/duet-checkbox.entry.js +1 -1
  267. package/lib/esm-es5/duet-choice_2.entry.js +1 -1
  268. package/lib/esm-es5/duet-collapsible.entry.js +2 -2
  269. package/lib/esm-es5/duet-cookie-consent.entry.js +1 -1
  270. package/lib/esm-es5/duet-date-picker.entry.js +1 -1
  271. package/lib/esm-es5/duet-divider_2.entry.js +1 -1
  272. package/lib/esm-es5/duet-editable-table-button.entry.js +4 -0
  273. package/lib/esm-es5/duet-editable-table_4.entry.js +4 -0
  274. package/lib/esm-es5/duet-empty-state.entry.js +1 -1
  275. package/lib/esm-es5/duet-fieldset.entry.js +1 -1
  276. package/lib/esm-es5/duet-footer.entry.js +1 -1
  277. package/lib/esm-es5/duet-grid_2.entry.js +2 -2
  278. package/lib/esm-es5/duet-header_2.entry.js +1 -1
  279. package/lib/esm-es5/duet-hero.entry.js +1 -1
  280. package/lib/esm-es5/duet-icon.entry.js +2 -2
  281. package/lib/esm-es5/duet-input_2.entry.js +1 -1
  282. package/lib/esm-es5/duet-layout.entry.js +1 -1
  283. package/lib/esm-es5/duet-list_2.entry.js +1 -1
  284. package/lib/esm-es5/duet-modal.entry.js +1 -1
  285. package/lib/esm-es5/duet-notification_2.entry.js +1 -1
  286. package/lib/esm-es5/duet-number-input.entry.js +1 -1
  287. package/lib/esm-es5/duet-progress.entry.js +4 -0
  288. package/lib/esm-es5/duet-radio_2.entry.js +1 -1
  289. package/lib/esm-es5/duet-range-slider.entry.js +1 -1
  290. package/lib/esm-es5/duet-select.entry.js +1 -1
  291. package/lib/esm-es5/duet-step_2.entry.js +1 -1
  292. package/lib/esm-es5/duet-tab_2.entry.js +2 -2
  293. package/lib/esm-es5/duet-textarea.entry.js +1 -1
  294. package/lib/esm-es5/duet-toggle.entry.js +1 -1
  295. package/lib/esm-es5/duet-tooltip.entry.js +1 -1
  296. package/lib/esm-es5/duet-tray.entry.js +1 -1
  297. package/lib/esm-es5/duet-upload-aria-status.entry.js +4 -0
  298. package/lib/esm-es5/duet-visually-hidden.entry.js +1 -1
  299. package/lib/esm-es5/duet.js +1 -1
  300. package/lib/esm-es5/{focus-utils-1995e5a9.js → focus-utils-c1fa24c4.js} +1 -1
  301. package/lib/esm-es5/index-05e43a37.js +4 -0
  302. package/lib/esm-es5/{language-utils-d5c38f65.js → language-utils-344d894c.js} +1 -1
  303. package/lib/esm-es5/loader.js +1 -1
  304. package/lib/esm-es5/shadow-css-7c726abb.js +15 -0
  305. package/lib/esm-es5/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
  306. package/lib/esm-es5/tokens-e110dc89.js +4 -0
  307. package/lib/esm-es5/tokens.module-49cbf963.js +4 -0
  308. package/lib/esm-es5/watch-options-dd55bce8.js +4 -0
  309. package/lib/html.html-data.json +427 -10
  310. package/lib/types/components/duet-choice/duet-choice.d.ts +23 -4
  311. package/lib/types/components/duet-date-picker/duet-date-picker.d.ts +5 -5
  312. package/lib/types/components/duet-editable-table/duet-editable-table-button.d.ts +72 -0
  313. package/lib/types/components/duet-editable-table/duet-editable-table-item.d.ts +72 -0
  314. package/lib/types/components/duet-editable-table/duet-editable-table-tabledata.d.ts +7 -0
  315. package/lib/types/components/duet-editable-table/duet-editable-table.d.ts +84 -0
  316. package/lib/types/components/duet-grid/duet-grid.d.ts +17 -2
  317. package/lib/types/components/duet-heading/duet-heading.d.ts +2 -2
  318. package/lib/types/components/duet-paragraph/duet-paragraph.d.ts +9 -1
  319. package/lib/types/components/duet-progress/duet-progress.d.ts +64 -0
  320. package/lib/types/components/duet-upload/duet-upload.d.ts +404 -0
  321. package/lib/types/components/duet-upload/errorcodes.utils.d.ts +8 -0
  322. package/lib/types/components/duet-upload/mock.helpers.d.ts +2 -0
  323. package/lib/types/components/duet-upload/upload-editable-item-error.d.ts +7 -0
  324. package/lib/types/components/duet-upload/upload-editable-item-inprogres.d.ts +7 -0
  325. package/lib/types/components/duet-upload/upload-editable-item-success.d.ts +8 -0
  326. package/lib/types/components/duet-upload/upload-validators.d.ts +12 -0
  327. package/lib/types/components/duet-upload/upload.helpers.d.ts +1 -0
  328. package/lib/types/components/duet-upload/xhr.helpers.d.ts +18 -0
  329. package/lib/types/components/duet-upload-aria-status/duet-upload-aria-status.d.ts +49 -0
  330. package/lib/types/components.d.ts +791 -21
  331. package/lib/types/utils/js-utils.d.ts +1 -0
  332. package/lib/types/utils/language-utils.d.ts +5 -1
  333. package/lib/types/utils/watch-options.d.ts +2 -0
  334. package/package.json +6 -6
  335. package/lib/cjs/duet-table.cjs.entry.js +0 -132
  336. package/lib/duet/p-0058512b.js +0 -4
  337. package/lib/duet/p-0224db45.entry.js +0 -4
  338. package/lib/duet/p-15c15c6a.js +0 -15
  339. package/lib/duet/p-202bbd70.entry.js +0 -4
  340. package/lib/duet/p-33426ddc.entry.js +0 -4
  341. package/lib/duet/p-3d3f773d.system.entry.js +0 -4
  342. package/lib/duet/p-3f78a826.system.js +0 -4
  343. package/lib/duet/p-418b2ce7.system.js +0 -4
  344. package/lib/duet/p-43e39d98.system.js +0 -4
  345. package/lib/duet/p-44ffb960.entry.js +0 -4
  346. package/lib/duet/p-5230ee3c.system.entry.js +0 -4
  347. package/lib/duet/p-5aa0d34d.entry.js +0 -4
  348. package/lib/duet/p-6a230911.system.entry.js +0 -4
  349. package/lib/duet/p-6a356ab1.system.js +0 -4
  350. package/lib/duet/p-6a760b8a.entry.js +0 -4
  351. package/lib/duet/p-712e7dde.system.entry.js +0 -4
  352. package/lib/duet/p-82dc2e0b.entry.js +0 -4
  353. package/lib/duet/p-8c8e82aa.system.js +0 -4
  354. package/lib/duet/p-8c980350.system.entry.js +0 -4
  355. package/lib/duet/p-8f03c3eb.entry.js +0 -4
  356. package/lib/duet/p-96808a2e.system.entry.js +0 -4
  357. package/lib/duet/p-96c103b2.system.entry.js +0 -4
  358. package/lib/duet/p-9a89ec39.js +0 -4
  359. package/lib/duet/p-9ff25646.entry.js +0 -4
  360. package/lib/duet/p-b694cbf5.system.js +0 -4
  361. package/lib/duet/p-b82927b0.system.entry.js +0 -4
  362. package/lib/duet/p-ba205dca.entry.js +0 -4
  363. package/lib/duet/p-be19c57b.system.entry.js +0 -4
  364. package/lib/duet/p-c5beceed.js +0 -4
  365. package/lib/duet/p-d35fd913.system.entry.js +0 -4
  366. package/lib/duet/p-d7623eb8.system.entry.js +0 -4
  367. package/lib/duet/p-de842863.entry.js +0 -4
  368. package/lib/duet/p-e58ca7af.system.js +0 -16
  369. package/lib/esm/duet-table.entry.js +0 -128
  370. package/lib/esm/watch-options-de55ea78.js +0 -35
  371. package/lib/esm-es5/duet-table.entry.js +0 -4
  372. package/lib/esm-es5/index-6e246691.js +0 -4
  373. package/lib/esm-es5/shadow-css-31e2d504.js +0 -15
  374. package/lib/esm-es5/tokens.module-edb66c04.js +0 -4
  375. package/lib/esm-es5/watch-options-de55ea78.js +0 -4
@@ -0,0 +1,1438 @@
1
+ /*!
2
+ * Built with Duet Design System
3
+ */
4
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-05e43a37.js';
5
+ import { s as sanitizeString, g as getLocaleString } from './language-utils-344d894c.js';
6
+ import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
7
+ import { m as mediaQueryMedium, h as mediaQueryLarge, i as mediaQueryXLarge, j as mediaQueryXxLarge, k as mediaQueryXxxLarge, l as mediaQuerySmall, n as sizeNavigation, s as sizeHeader } from './tokens.module-49cbf963.js';
8
+ import { c as createID } from './create-id-981107da.js';
9
+ import './string-utils-2f1793b8.js';
10
+
11
+ const debounce = (func, timeout = 50) => {
12
+ let timer;
13
+ return (...args) => {
14
+ clearTimeout(timer);
15
+ timer = setTimeout(() => {
16
+ func.apply(undefined, args);
17
+ }, timeout);
18
+ };
19
+ };
20
+
21
+ const duetEditableTableCss = "duet-editable-table{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}.duet-editable-table-header tr .duet-editable-table-header-hidden{padding:0 !important;font-size:0;border-bottom:0}";
22
+
23
+ let DuetEditableTable = class {
24
+ constructor(hostRef) {
25
+ registerInstance(this, hostRef);
26
+ /**
27
+ * State() variables
28
+ * @internal
29
+ */
30
+ this.tick = Date.now();
31
+ /**
32
+ * Map of items that contain list of things.
33
+ */
34
+ this.items = new Map();
35
+ /**
36
+ * Array of internationalized defaults for the default groups labels.
37
+ */
38
+ this.groupsLabelDefaults = {
39
+ fi: "Kaikki",
40
+ en: "All items",
41
+ sv: "Alla objekt",
42
+ };
43
+ /**
44
+ * Array of internationalized defaults for the default action labels.
45
+ */
46
+ this.actionLabelDefaults = {
47
+ fi: "Toiminnot",
48
+ en: "Actions",
49
+ sv: "Handlingar",
50
+ };
51
+ /**
52
+ * Array of group names that you want the editable table to display (can be used to hide or show groups depending on conditions).
53
+ * @default { id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults }.
54
+ * @example [{ id: "success", label: {fi: "Onnistunut", en: "Success", sv: "Alt klart", }}].
55
+ */
56
+ this.groups = [
57
+ { id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults },
58
+ ];
59
+ /**
60
+ * Array of actions that are mapped via the map variable to the various groups defined in group.
61
+ * @default undefined
62
+ * @example [{
63
+ variation: "default",
64
+ icon: "action-edit-2",
65
+ id: "edit",
66
+ map: ["success"],
67
+ label: {
68
+ fi: " Label",
69
+ en: " Label",
70
+ sv: " Label",
71
+ }
72
+ }]
73
+ */
74
+ this.actions = undefined;
75
+ /**
76
+ * Shows or hides the table labels.
77
+ */
78
+ this.hideGroups = false;
79
+ /**
80
+ * Exposes the aria role for optimizing accessibility.
81
+ */
82
+ this.accessibleRole = undefined;
83
+ /**
84
+ * Private methods.
85
+ */
86
+ this.kick = debounce(() => {
87
+ this.tick = Date.now();
88
+ }, 100); // will trigger re-render
89
+ this.filterMap = needle => {
90
+ if (needle === "all") {
91
+ return Array.from(this.items);
92
+ }
93
+ return Array.from(this.items).filter(item => needle === item[1].group);
94
+ };
95
+ }
96
+ /**
97
+ * Component lifecycle events.
98
+ */
99
+ componentWillLoad() {
100
+ if (typeof this.groups === "string") {
101
+ this.internalGroupArray = sanitizeString(this.groups);
102
+ }
103
+ else {
104
+ this.internalGroupArray = this.groups;
105
+ }
106
+ if (typeof this.actions === "string") {
107
+ this.internalActionsArray = sanitizeString(this.actions);
108
+ }
109
+ else {
110
+ this.internalActionsArray = this.actions;
111
+ }
112
+ inheritGlobalTheme(this);
113
+ }
114
+ /**
115
+ * Method to force an update of a tabular data array.
116
+ * when called the method will rerender the entire tabular structure.
117
+ */
118
+ async updateTable(passedItems = undefined) {
119
+ this.items = new Map(passedItems || this.items);
120
+ this.kick();
121
+ }
122
+ render() {
123
+ return (h(Host, { class: {
124
+ "duet-theme-turva": this.theme === "turva",
125
+ } }, this.internalGroupArray.map(group => {
126
+ const currentGroup = this.filterMap(group.id);
127
+ if (!currentGroup.length) {
128
+ return;
129
+ }
130
+ return (h("duet-table", { variation: "plain", breakpoint: "none", role: "", margin: this.hideGroups ? "none" : "auto" }, h("table", { class: "duet-editable-table", "aria-role": this.accessibleRole }, h("thead", { class: "duet-editable-table-header" }, h("tr", null, h("th", { class: {
131
+ "duet-editable-table-header-hidden": this.hideGroups,
132
+ } }, !this.hideGroups ? (getLocaleString(group.label)) : (h("duet-visually-hidden", null, getLocaleString(group.label)))), h("th", { class: {
133
+ "duet-editable-table-header-hidden": this.hideGroups,
134
+ } }, h("duet-visually-hidden", null, group.actionLabel
135
+ ? getLocaleString(group.actionLabel)
136
+ : getLocaleString(this.actionLabelDefaults))))), h("tbody", null, currentGroup.map(dataAsArray => {
137
+ const [key, value] = dataAsArray;
138
+ return (h("duet-editable-table-item", { keyName: key, data: Object.assign({}, value), groupId: group.id, part: group.id, actions: this.internalActionsArray }));
139
+ })))));
140
+ })));
141
+ }
142
+ get element() { return getElement(this); }
143
+ };
144
+ DuetEditableTable.style = duetEditableTableCss;
145
+
146
+ //simple functional component that renders the data in the table
147
+ const TableData = ({ data, groupId }, _children) => {
148
+ if (typeof data === "string") {
149
+ return h("td", { innerHTML: data, class: "duet-editable-table-content", part: `${groupId}content` });
150
+ }
151
+ else {
152
+ return (h("td", { class: "duet-editable-table-content", part: `${groupId}content` }, data));
153
+ }
154
+ };
155
+
156
+ const duetEditableTableItemCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{display:table-row;height:32px}.duet-editable-table-content,.duet-editable-table-actions{height:32px;padding:12px 0;vertical-align:middle;break-word:break-all;border-bottom:1px solid #e1e3e6}.duet-editable-table-actions-items{display:flex;justify-content:flex-end}.duet-editable-table-actions-items duet-editable-table-button{padding-left:8px}.duet-editable-table .editable-item-small{font-size:0.75rem;font-weight:400}";
157
+
158
+ let DuetEditableTableItem = class {
159
+ constructor(hostRef) {
160
+ registerInstance(this, hostRef);
161
+ this.duetEditableItemAction = createEvent(this, "duetEditableItemAction", 7);
162
+ this.isHovering = false;
163
+ /**
164
+ * Theme of the empty state component.
165
+ */
166
+ this.theme = "";
167
+ /**
168
+ * Actions that can be performed on the element
169
+ */
170
+ this.actions = undefined;
171
+ /**
172
+ * GroupId used to pierce the shadowdom - gets concatenated with "content & actions" and used as part="groupIDcontent/actions" to pierce the content/Action item
173
+ * @internal
174
+ */
175
+ this.groupId = "";
176
+ /**
177
+ * Key used to identify item, when running actions
178
+ */
179
+ this.keyName = "";
180
+ /**
181
+ * Object of data itemsused to render the entire row
182
+ */
183
+ this.data = undefined;
184
+ }
185
+ watchPropHandler(_newValue, _oldValue) {
186
+ // console.log("The new value of activated is: ", _newValue)
187
+ }
188
+ /**
189
+ /**
190
+ * Component lifecycle events.
191
+ */
192
+ componentWillLoad() {
193
+ inheritGlobalTheme(this);
194
+ }
195
+ /**
196
+ /**
197
+ * private functions
198
+ */
199
+ /**
200
+ * render() function
201
+ * Always the last one in the class.
202
+ */
203
+ render() {
204
+ return (h(Host, { role: "row" }, h(TableData, { data: this.data.item, groupId: this.groupId }), h("td", { class: "duet-editable-table-actions" }, h("div", { class: "duet-editable-table-actions-items", part: `${this.groupId}actions` }, this.actions.map(result => {
205
+ const { map = undefined } = result;
206
+ // if map has been specified, only show the current action if groupID matches the map array
207
+ if (map && !map.includes(this.groupId)) {
208
+ return;
209
+ }
210
+ return (h("duet-editable-table-button", { keyName: this.keyName, group: this.data.group, uid: this.data.uid, actions: result, theme: this.theme }));
211
+ })))));
212
+ }
213
+ get el() { return getElement(this); }
214
+ static get watchers() { return {
215
+ "data": ["watchPropHandler"]
216
+ }; }
217
+ };
218
+ DuetEditableTableItem.style = duetEditableTableItemCss;
219
+
220
+ const duetTableCss = "duet-table{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none;margin-bottom:20px !important;display:block;font-variant-numeric:tabular-nums}duet-table table,duet-table thead,duet-table tbody,duet-table tfoot,duet-table th,duet-table td,duet-table tr{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}duet-table.duet-m-0{margin:0 !important}duet-table table{width:100%;font-family:\"localtapiola-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";font-size:1rem;text-align:left;border-spacing:0;border-collapse:separate}duet-table.duet-theme-turva table{font-family:\"turva-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}duet-table td{-webkit-hyphens:auto;hyphens:auto;color:#00294d}duet-table.duet-theme-turva td{color:#171c3a}duet-table th{font-weight:600;line-height:1.25;color:#657787;text-align:left}duet-table.duet-theme-turva th{color:#747475}duet-table tbody th{font-weight:600;color:#00294d}duet-table.duet-theme-turva tbody th{color:#171c3a}.duet-table-flattened table,.duet-table-flattened thead,.duet-table-flattened tbody,.duet-table-flattened tfoot,.duet-table-flattened th,.duet-table-flattened td,.duet-table-flattened tr{display:block}.duet-table-flattened thead tr{position:absolute !important;top:0;width:1px !important;height:1px !important;padding:0 !important;overflow:hidden !important;clip:rect(1px, 1px, 1px, 1px) !important;border:0 !important}.duet-table-flattened td{line-height:1.25}.duet-table-flattened td:not(:last-child){margin-bottom:16px !important}.duet-table-flattened tbody td,.duet-table-flattened tbody th,.duet-table-flattened tfoot td{padding:0 !important;text-align:left !important}.duet-table-flattened tbody th{font-weight:600;line-height:1.25;color:#657787;text-align:left}.duet-table-flattened td[data-heading]::before{margin-bottom:4px !important;display:block;font-size:1rem;font-weight:600;color:#00294d;content:attr(data-heading)}.duet-table-flattened.duet-theme-turva td[data-heading]::before{color:#171c3a}.duet-table-sticky thead th{position:sticky;top:0;background:white}.duet-table-striped td,.duet-table-striped th{padding:20px !important}@media (max-width: 35.9375em){.duet-table-striped td,.duet-table-striped th{padding:20px 12px !important}}.duet-table-striped tbody th{background:white}.duet-table-striped.duet-table-sticky thead th{border-bottom:1px solid #e1e3e6}.duet-table-striped.duet-table-sticky.duet-theme-turva thead th{border-bottom-color:#e4e4e6}.duet-table-striped tbody:not(:first-of-type) th{padding-top:40px !important}.duet-table-striped tbody:only-of-type tr:nth-of-type(odd){background:rgba(0, 80, 128, 0.04)}.duet-table-striped.duet-theme-turva tbody:only-of-type tr:nth-of-type(odd){background:rgba(23, 28, 58, 0.04)}.duet-table-striped tbody:not(:only-of-type) tr:nth-of-type(even){background:rgba(0, 80, 128, 0.04)}.duet-table-striped.duet-theme-turva tbody:not(:only-of-type) tr:nth-of-type(even){background:rgba(23, 28, 58, 0.04)}.duet-table-striped tfoot td{border-top:1px solid #e1e3e6}.duet-table-striped.duet-theme-turva tfoot td{border-top-color:#e4e4e6}.duet-table-striped.duet-table-flattened tbody:not(:first-of-type) th{padding-top:20px !important}.duet-table-striped.duet-table-flattened tr{padding:20px !important}.duet-table-striped.duet-table-flattened tfoot td{border-top:0}.duet-table-striped.duet-table-flattened tfoot tr{border-top:1px solid #e1e3e6}.duet-table-striped.duet-table-flattened.duet-theme-turva tfoot tr{border-top-color:#e4e4e6}.duet-table-minimal th,.duet-table-plain th{padding:16px !important;border-bottom:1px solid #657787}.duet-table-minimal th:first-child,.duet-table-plain th:first-child{padding-left:0 !important}.duet-table-minimal th:last-child,.duet-table-plain th:last-child{padding-right:0 !important}.duet-theme-turva.duet-table-minimal th,.duet-theme-turva.duet-table-plain th{border-bottom-color:#444445}.duet-table-minimal tbody th,.duet-table-plain tbody th{padding-top:40px !important;border-bottom-color:#e1e3e6}.duet-theme-turva.duet-table-minimal tbody th,.duet-theme-turva.duet-table-plain tbody th{border-bottom-color:#e4e4e6}.duet-table-minimal td,.duet-table-plain td{padding:16px !important}.duet-table-minimal td:first-child,.duet-table-plain td:first-child{padding-left:0 !important}.duet-table-minimal td:last-child,.duet-table-plain td:last-child{padding-right:0 !important}.duet-table-minimal tbody td,.duet-table-plain tbody td{border-bottom:1px solid #e1e3e6}.duet-theme-turva.duet-table-minimal tbody td,.duet-theme-turva.duet-table-plain tbody td{border-bottom-color:#e4e4e6}.duet-table-flattened.duet-table-minimal tbody:first-of-type th,.duet-table-flattened.duet-table-plain tbody:first-of-type th{padding-top:0 !important}.duet-table-flattened.duet-table-minimal td,.duet-table-flattened.duet-table-plain td,.duet-table-flattened.duet-table-minimal tbody th,.duet-table-flattened.duet-table-plain tbody th{border-bottom:0}.duet-table-flattened.duet-table-minimal tr,.duet-table-flattened.duet-table-plain tr{padding:20px 0 !important}.duet-table-flattened.duet-table-minimal tbody th,.duet-table-flattened.duet-table-plain tbody th{padding-top:20px !important}.duet-table-flattened.duet-table-minimal tfoot td,.duet-table-flattened.duet-table-plain tfoot td{margin-bottom:4px !important}.duet-table-flattened.duet-table-minimal tbody:not(:only-of-type) tr:first-child,.duet-table-flattened.duet-table-plain tbody:not(:only-of-type) tr:first-child{border-bottom:0}.duet-table-plain.duet-table-flattened tbody tr{border-bottom:1px solid #e1e3e6}.duet-table-plain.duet-table-flattened.duet-theme-turva tbody tr{border-bottom-color:#e4e4e6}.duet-table-minimal tbody tr,.duet-table-minimal tbody tr td{vertical-align:top;border-bottom:0 none}.duet-table-minimal tbody tr:last-of-type,.duet-table-minimal tbody tr:last-of-type td{border-bottom:1px solid #e1e3e6}.duet-table-minimal.duet-table-flattened tbody tr,.duet-table-minimal.duet-table-flattened tbody tr td{border-bottom:0 none}.duet-table-minimal.duet-table-flattened tbody tr td[data-heading]::before{display:none}.duet-table-minimal.duet-table-flattened tfoot{border-top:1px solid #e1e3e6}.duet-table-minimal.duet-table-flattened.duet-theme-turva tfoot{border-top-color:#e4e4e6}.duet-table-scrollable{position:relative;width:100%;overflow-x:auto;background:linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0)), linear-gradient(-90deg, #fff 0%, rgba(255, 255, 255, 0)) 100% 0, radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0)), radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0)) 100% 0%;background-repeat:no-repeat;background-attachment:local, local, scroll, scroll;background-size:100px 100%, 100px 100%, 12px 100%, 12px 100%}.duet-table-selected-column{background:rgba(0, 119, 179, 0.08)}.duet-theme-turva .duet-table-selected-column{background:rgba(68, 68, 69, 0.08)}";
221
+
222
+ // remove wrapping speech marks.
223
+ // media query tokens are wrapped in speech marks,
224
+ // which need to be removed before use with matchMedia.
225
+ const unwrap = (str) => str.substring(1, str.length - 1);
226
+ const breakpointToToken = {
227
+ none: "all",
228
+ "none-scrollable": "all",
229
+ small: unwrap(mediaQuerySmall),
230
+ medium: unwrap(mediaQueryMedium),
231
+ large: unwrap(mediaQueryLarge),
232
+ "x-large": unwrap(mediaQueryXLarge),
233
+ "xx-large": unwrap(mediaQueryXxLarge),
234
+ "xxx-large": unwrap(mediaQueryXxxLarge),
235
+ };
236
+ const stickyTopValues = {
237
+ none: 0,
238
+ "with-links": parseFloat(sizeNavigation) * 16,
239
+ "without-links": parseFloat(sizeHeader) * 16,
240
+ };
241
+ let DuetTable = class {
242
+ constructor(hostRef) {
243
+ registerInstance(this, hostRef);
244
+ /**
245
+ * Tracks whether the breakpoint is matched. This is set to true by default so that JavaScript disabled in SSR mode we get accessible table data first.
246
+ */
247
+ this.matchesBreakpoint = true;
248
+ /**
249
+ * Controls the margin of the component.
250
+ */
251
+ this.margin = "auto";
252
+ /**
253
+ * Style variation of the table.
254
+ */
255
+ this.variation = "striped";
256
+ /**
257
+ * Controls whether the table has a sticky header.
258
+ * Sticky headers are not compatible with breakpoint="none-scrollable".
259
+ */
260
+ this.sticky = false;
261
+ /**
262
+ * Adjust the distance from top of the viewport (in pixels) when the
263
+ * table header becomes sticky.
264
+ */
265
+ this.stickyDistance = "with-links";
266
+ /**
267
+ * By default the table is responsive - it will be flattened at narrow viewport widths.
268
+ * This prop controls the breakpoint at which the table should be rendered as a _regular_ table.
269
+ * Set to "none" to disable the responsive functionality.
270
+ * Set to "none-scrollable" to disable responsive functionality _and_ allow horizontal scrolling -
271
+ * this is useful for comparison tables where it's important to maintain column and row layout.
272
+ */
273
+ this.breakpoint = "small";
274
+ this.handleMediaQueryChange = (mq) => {
275
+ this.matchesBreakpoint = mq.matches;
276
+ };
277
+ }
278
+ connectedCallback() {
279
+ this.mq = matchMedia(breakpointToToken[this.breakpoint]);
280
+ this.mq.addListener(this.handleMediaQueryChange);
281
+ this.handleMediaQueryChange(this.mq);
282
+ this.observer = new MutationObserver(() => this.copyHeadingsToCells());
283
+ this.observer.observe(this.element, {
284
+ childList: true,
285
+ subtree: true,
286
+ });
287
+ }
288
+ componentWillLoad() {
289
+ inheritGlobalTheme(this);
290
+ this.copyHeadingsToCells();
291
+ if (this.sticky && this.breakpoint === "none-scrollable") {
292
+ console.warn(`[DUET WARNING]: sticky and breakpoint="none-scrollable" are incompatible. Scrollable takes precedence`);
293
+ }
294
+ if (this.sticky) {
295
+ const stickyTop = stickyTopValues[this.stickyDistance];
296
+ const headingElements = this.element.querySelectorAll("thead th");
297
+ headingElements.forEach(th => (th.style.top = `${stickyTop}px`));
298
+ }
299
+ }
300
+ componentDidLoad() {
301
+ // this clears all pending mutations,
302
+ // that way we avoid dealing with any initial changes
303
+ // and only get genuine mutations as rows are added/removed
304
+ this.observer.takeRecords();
305
+ }
306
+ disconnectedCallback() {
307
+ this.observer.disconnect();
308
+ this.observer = null;
309
+ this.mq.removeListener(this.handleMediaQueryChange);
310
+ this.mq = null;
311
+ this.matchesBreakpoint = true;
312
+ }
313
+ copyHeadingsToCells() {
314
+ const headingElements = this.element.querySelectorAll("thead th");
315
+ const rowElements = this.element.querySelectorAll("tbody tr");
316
+ const headings = Array.from(headingElements).map(th => th.textContent.trim());
317
+ rowElements.forEach(tr => {
318
+ tr.querySelectorAll("td").forEach((td, i) => {
319
+ if (headings[i]) {
320
+ td.dataset.heading = headings[i];
321
+ }
322
+ });
323
+ });
324
+ }
325
+ render() {
326
+ return (h(Host, { class: {
327
+ [`duet-table-${this.variation}`]: true,
328
+ "duet-table-flattened": !this.matchesBreakpoint,
329
+ // sticky only valid when in regular table layout
330
+ "duet-table-sticky": this.matchesBreakpoint && this.sticky,
331
+ "duet-table-scrollable": this.breakpoint === "none-scrollable",
332
+ "duet-m-0": this.margin === "none",
333
+ "duet-theme-turva": this.theme === "turva",
334
+ } }, h("slot", null)));
335
+ }
336
+ get element() { return getElement(this); }
337
+ };
338
+ DuetTable.style = duetTableCss;
339
+
340
+ const errorCodes = [
341
+ {
342
+ type: "default",
343
+ system_message: "unknown error",
344
+ message: {
345
+ fi: "Tapahtui tuntematon virhe, ole hyvä ja yritä uudelleen.",
346
+ sv: "Ett okänt fel uppstod, försök igen.",
347
+ en: "An unknown error occured, please try again."
348
+ }
349
+ },
350
+ {
351
+ type: "400",
352
+ system_message: "Bad Request: The server could not understand the request due to invalid syntax.",
353
+ message: {
354
+ fi: "Tiedostoa ei hyväksytty.",
355
+ sv: "Servern avvisade din fil.",
356
+ en: "The server rejected your file."
357
+ }
358
+ },
359
+ {
360
+ type: "401",
361
+ system_message: "Not Authenticated: The client must authenticate itself to get the requested response...",
362
+ message: {
363
+ fi: "Vain kirjautunut käyttäjä voi lähettää tiedostoja.",
364
+ sv: "Du måste vara inloggad för att ladda upp filer.",
365
+ en: "You need to be logged in to upload files."
366
+ }
367
+ },
368
+ {
369
+ type: "403",
370
+ system_message: "No Access: The client does not have access rights to the content.",
371
+ message: {
372
+ fi: "Ei oikeuksia lähettää tiedostoja.",
373
+ sv: "Du har inte rätt åtkomsträttigheter för att ladda upp filer.",
374
+ en: "You do not have the correct access rights to upload files."
375
+ }
376
+ },
377
+ {
378
+ type: "413",
379
+ system_message: "Payload too large",
380
+ message: {
381
+ fi: "Tiedosto oli liian vastaanotettavaksi.",
382
+ sv: "Filen var för stor för servern att hantera.",
383
+ en: "The file was to large for the server to handle."
384
+ }
385
+ },
386
+ {
387
+ type: "415",
388
+ system_message: "Unsupported media type",
389
+ message: {
390
+ fi: "Tiedoston tyyppi oli väärä.",
391
+ sv: "Servern avvisade filen eftersom den hade fel typ.",
392
+ en: "The server rejected the file because it had the wrong type."
393
+ }
394
+ },
395
+ {
396
+ type: "429",
397
+ system_message: "Too many request from same address",
398
+ message: {
399
+ fi: "Liian monta yritystä, ole hyvä ja yritä myöhemmin uudelleen.",
400
+ sv: "Servern har fått många förfrågningar från dig, försök igen senare.",
401
+ en: "The server has received to many request from you, please try again later."
402
+ }
403
+ },
404
+ {
405
+ type: "500",
406
+ system_message: "Internal Server Error",
407
+ message: {
408
+ fi: "Palvelin ilmoitti tuntemattomasta virheestä ja lataus epäonnistui.",
409
+ sv: "Servern rapporterade ett okänt fel och uppladdningen misslyckades.",
410
+ en: "The server reported an unknown error and the upload failed."
411
+ }
412
+ },
413
+ {
414
+ type: "duet-upload-100",
415
+ system_message: "File extension not allowed",
416
+ message: {
417
+ fi: "Tiedoston tyyppi ei ole sallittu.",
418
+ sv: "Du kan inte ladda upp filer av den type.",
419
+ en: "You cannot upload files with that extension."
420
+ }
421
+ },
422
+ {
423
+ type: "duet-upload-001",
424
+ system_message: "File transfer failed",
425
+ message: {
426
+ fi: "Tiedoston lähetys keskeytyi, ole hyvä ja yritä uudelleen.",
427
+ sv: "Din anslutning till servern avbröts, försök igen.",
428
+ en: "Your connection to the server was interrupted, try again."
429
+ }
430
+ },
431
+ {
432
+ type: "duet-upload-101",
433
+ system_message: "File mimetype not allowed",
434
+ message: {
435
+ fi: "Tiedoston tyyppi ei ole sallittu.",
436
+ sv: "Du kan inte ladda upp filer av den typ.",
437
+ en: "You cannot upload files of that type."
438
+ }
439
+ },
440
+ {
441
+ type: "duet-upload-201",
442
+ system_message: "File is too large",
443
+ message: {
444
+ fi: "Tiedosto on liian iso.",
445
+ sv: "Filen är större än tillåtet.",
446
+ en: "The file is larger than permitted."
447
+ }
448
+ },
449
+ {
450
+ type: "duet-upload-202",
451
+ system_message: "The combined size of all files is too large",
452
+ message: {
453
+ fi: "Tiedostojen yhteenlaskettu koko on liian iso.",
454
+ sv: "Du har nått den maximala kombinerade filstorleken.",
455
+ en: "You have reached the maximum combined filesize."
456
+ }
457
+ },
458
+ {
459
+ type: "duet-upload-301",
460
+ system_message: "The maximum file limit has been reached",
461
+ message: {
462
+ fi: "Liitteiden maksimimäärä saavutettu.",
463
+ sv: "Maximalt antal bilagor har uppnåtts.",
464
+ en: "Maximum number of attachments reached."
465
+ }
466
+ }
467
+ ];
468
+
469
+ const getError = (code) => {
470
+ let error = {
471
+ type: undefined,
472
+ system_message: undefined,
473
+ message: undefined,
474
+ };
475
+ error = errorCodes.filter(errorItem => {
476
+ // the == is intentional we may be comparing numbers to strings - and that is ok here
477
+ return errorItem.type == code;
478
+ })[0];
479
+ if (!error) {
480
+ error = errorCodes.filter(errorItem => {
481
+ return errorItem.type === "default";
482
+ })[0];
483
+ }
484
+ return error;
485
+ };
486
+ const getI18nError = (errorCode) => {
487
+ const errorFromJson = getError(errorCode);
488
+ const i18String = getLocaleString(errorFromJson.message);
489
+ if (i18String === "" || !i18String) {
490
+ return errorFromJson.system_message;
491
+ }
492
+ else {
493
+ return i18String;
494
+ }
495
+ };
496
+
497
+ const ErrorItem = ({ data }) => {
498
+ const { item, error } = data;
499
+ const { name } = item;
500
+ const { type } = error;
501
+ return (h("span", { class: "duet-upload-item-error", role: "status" },
502
+ h("duet-paragraph", { class: "duet-upload-item-name", color: "danger", margin: "none", weight: "semi-bold" },
503
+ h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
504
+ " ",
505
+ name),
506
+ h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type))));
507
+ };
508
+
509
+ const ProgressItem = ({ progress, name }) => (h("span", null,
510
+ h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
511
+ h("duet-spacer", { size: "xx-small" }),
512
+ h("duet-progress", { progress: Math.ceil(progress), "aria-hidden": true })));
513
+
514
+ const formatBytes = (bytes, decimals = 2) => {
515
+ if (bytes === 0) {
516
+ return "0 Bytes";
517
+ }
518
+ const k = 1024;
519
+ const dm = decimals < 0 ? 0 : decimals;
520
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
521
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
522
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
523
+ };
524
+
525
+ const SuccessItem = ({ data, showLinks }) => {
526
+ const { item, size, uploaded, url, meta } = data;
527
+ const { name } = item;
528
+ const ContentName = (h("span", { class: "duet-upload-item-name" },
529
+ h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
530
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
531
+ name));
532
+ const SizeText = (h("span", { class: "duet-upload-item-size", style: { fontSize: "14px", fontWeight: "400" } },
533
+ "(",
534
+ formatBytes(size),
535
+ ")"));
536
+ const FilenameLine = uploaded && url && showLinks ? (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
537
+ h("duet-link", { url: url, external: true }, ContentName),
538
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
539
+ SizeText)) : (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
540
+ ContentName,
541
+ h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
542
+ SizeText));
543
+ const Badges = meta && meta.badges ? (h("span", null,
544
+ h("duet-spacer", { size: "xx-small" }),
545
+ meta.badges.map(badgeText => (h("duet-badge", { color: "primary" }, badgeText))))) : undefined;
546
+ return (h("span", { class: "duet-upload-item-success" },
547
+ h("div", null, FilenameLine),
548
+ Badges));
549
+ };
550
+
551
+ const validateFileExtension = (name, allowedExtensions) => {
552
+ if (!allowedExtensions) {
553
+ return true;
554
+ }
555
+ const ext = name.split(".");
556
+ const validExtension = allowedExtensions.split(",");
557
+ const extension = ext[ext.length - 1];
558
+ return validExtension.includes(extension);
559
+ };
560
+ const validateFileMime = (type, allowedMimetypes) => {
561
+ if (!allowedMimetypes || !type) {
562
+ return true;
563
+ }
564
+ const validMimeTypes = allowedMimetypes.split(",");
565
+ let valid = false;
566
+ validMimeTypes.forEach(mimeType => {
567
+ const allowedTypes = mimeType.split("/");
568
+ const fileType = type.split("/");
569
+ if (allowedTypes[0] === fileType[0] && (allowedTypes[1] === fileType[1] || allowedTypes[1] === "*")) {
570
+ valid = true;
571
+ }
572
+ });
573
+ return valid;
574
+ };
575
+ const validateFileSize = (size, maxBytes) => {
576
+ if (!maxBytes || !size) {
577
+ return true;
578
+ }
579
+ return maxBytes >= size;
580
+ };
581
+ const validateFile = (item, validators) => {
582
+ const { allowedMimetypes, allowedExtensions, maxBytes } = validators;
583
+ let valid = false;
584
+ let errorMessage = getError("default");
585
+ if (item) {
586
+ const { name, type, size } = item;
587
+ const mime = validateFileMime(type, allowedMimetypes);
588
+ const ext = validateFileExtension(name, allowedExtensions);
589
+ const bytes = validateFileSize(size, maxBytes);
590
+ if (!mime) {
591
+ errorMessage = getError("duet-upload-101");
592
+ }
593
+ if (!ext) {
594
+ errorMessage = getError("duet-upload-100");
595
+ }
596
+ if (!bytes) {
597
+ errorMessage = getError("duet-upload-201");
598
+ }
599
+ valid = mime && ext && bytes;
600
+ }
601
+ else {
602
+ valid = false;
603
+ }
604
+ return {
605
+ valid,
606
+ errorMessage: valid ? undefined : getLocaleString(errorMessage.message),
607
+ errorSystem: valid ? undefined : errorMessage.system_message,
608
+ errorType: valid ? undefined : errorMessage.type,
609
+ };
610
+ };
611
+ const validateTotalSizeIsAboveMax = (filelist, maxTotalBytes) => {
612
+ let total = 0;
613
+ if (maxTotalBytes) {
614
+ filelist.forEach(item => {
615
+ if (item.valid && item.size) {
616
+ total += item.size;
617
+ }
618
+ });
619
+ if (total < maxTotalBytes) {
620
+ return true;
621
+ }
622
+ }
623
+ return false;
624
+ };
625
+ const validateTotalAmountIsAboveMax = (filelist, maxFiles) => {
626
+ let total = 0;
627
+ if (maxFiles) {
628
+ filelist.forEach(item => {
629
+ if (item.valid) {
630
+ total++;
631
+ }
632
+ });
633
+ if (total > maxFiles) {
634
+ return true;
635
+ }
636
+ }
637
+ return false;
638
+ };
639
+
640
+ const makeXhrRequest = ({ payload, options, onFailure, onSuccess, onProgress }) => {
641
+ const { type = "POST", xhr, uri, argument = null, headers = null } = options;
642
+ xhr.open(type, `${uri}${argument || ""}`, true);
643
+ const { data, name } = payload;
644
+ // headers must be added after open
645
+ if (headers) {
646
+ Object.keys(headers).forEach(key => {
647
+ xhr.setRequestHeader(key, headers[key]);
648
+ });
649
+ }
650
+ if (type === "POST") {
651
+ xhr.onreadystatechange = () => {
652
+ // Call a function when the state changes.
653
+ if (xhr.readyState === XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status < 300) {
654
+ // Request finished without errors
655
+ onSuccess(xhr, name, xhr.status);
656
+ }
657
+ if (xhr.readyState === XMLHttpRequest.DONE && xhr.status >= 300 && xhr.status < 999) {
658
+ // Request finished with errors
659
+ onFailure(xhr, name, xhr.status);
660
+ }
661
+ };
662
+ onProgress(name);
663
+ }
664
+ xhr.send(data);
665
+ return xhr;
666
+ };
667
+
668
+ 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}";
669
+
670
+ let DuetUpload = class {
671
+ constructor(hostRef) {
672
+ registerInstance(this, hostRef);
673
+ this.duetChange = createEvent(this, "duetChange", 3);
674
+ this.duetBlur = createEvent(this, "duetBlur", 7);
675
+ this.duetFocus = createEvent(this, "duetFocus", 7);
676
+ this.duetDone = createEvent(this, "duetDone", 3);
677
+ this.duetState = createEvent(this, "duetState", 3);
678
+ this.duetDelete = createEvent(this, "duetDelete", 3);
679
+ this.duetCancel = createEvent(this, "duetCancel", 3);
680
+ this.duetProgress = createEvent(this, "duetProgress", 3);
681
+ this.duetUpload = createEvent(this, "duetUpload", 3);
682
+ /**
683
+ * Own Properties
684
+ */
685
+ this.buttonId = createID("DuetButton");
686
+ this.labelId = createID("DuetLabel");
687
+ this.uploadId = createID("DuetUpload");
688
+ this.editableTableId = createID("DuetEditableTable");
689
+ this.filesInProgress = new Map();
690
+ this.fileMaxReached = false;
691
+ this.bytesMaxReached = false;
692
+ this.internalStatusMessageLabel = undefined;
693
+ /**
694
+ * Properties
695
+ */
696
+ this.DefaultGroups = {
697
+ inprogress: "inprogress",
698
+ success: "success",
699
+ failure: "failure",
700
+ };
701
+ /**
702
+ * State() variables
703
+ */
704
+ this.tick = Date.now();
705
+ /**
706
+ * If external is set to true, the upload component will not actually upload the files, but only keep states
707
+ * it will be up to you to handle the upload and return progress information to the upload-component
708
+ */
709
+ this.external = false;
710
+ /**
711
+ * If set the upload component will not display an upload button, you will have to create one yourself
712
+ * and call the exposed method startUpload
713
+ */
714
+ this.hideButton = false;
715
+ /**
716
+ * Default actions added to the internally used duet-editable-table
717
+ */
718
+ this.actions = [
719
+ {
720
+ icon: "action-delete",
721
+ color: "color-danger",
722
+ color_hover: "category-home",
723
+ id: "delete",
724
+ map: ["success", "failure"],
725
+ label: {
726
+ fi: "Poista tiedosto",
727
+ en: "Poista tiedosto",
728
+ sv: "Ta bort filen",
729
+ },
730
+ },
731
+ {
732
+ icon: "navigation-close",
733
+ color: "primary",
734
+ color_hover: "category-home",
735
+ id: "cancel",
736
+ map: ["inprogress"],
737
+ label: {
738
+ fi: "Keskeytä lähetys",
739
+ en: "Cancel the upload",
740
+ sv: "Stop överföringen",
741
+ },
742
+ },
743
+ ];
744
+ /**
745
+ * If enabled the editable-table will display links on successfully uploaded items,
746
+ * this requires the server can respond with link URIs in the correct format
747
+ * and that the files are accessible to the user
748
+ */
749
+ this.showLinks = false;
750
+ /**
751
+ * Property to change the aria upload progress text read aloud by screenreaders
752
+ * @default {
753
+ * fi: {
754
+ * inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
755
+ * inProgressWithErrors:
756
+ * "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
757
+ * done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
758
+ * doneWithErrors:
759
+ * "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
760
+ * files: "tiedostot",
761
+ * file: "tiedosto",
762
+ * },
763
+ * sv: {
764
+ * inProgress: "Adding {filesUploaded} of {filesTotal}",
765
+ * inProgressWithErrors:
766
+ * "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
767
+ * done: "Alla {filesTotal} har lagts till",
768
+ * doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
769
+ * files: "filer",
770
+ * file: "fil",
771
+ * },
772
+ * en: {
773
+ * inProgress: "Adding {filesUploaded} of {filesTotal}",
774
+ * inProgressWithErrors:
775
+ * "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
776
+ * done: "All {filesTotal} added successfully",
777
+ * doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
778
+ * files: "tiedostoa",
779
+ * file: "tiedosto",
780
+ * },
781
+ * }
782
+ */
783
+ this.statusLabelDefaults = {
784
+ fi: {
785
+ inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
786
+ inProgressWithErrors: "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
787
+ done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
788
+ doneWithErrors: "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
789
+ files: "tiedostot",
790
+ file: "tiedosto",
791
+ },
792
+ sv: {
793
+ inProgress: "Adding {filesUploaded} of {filesTotal}",
794
+ inProgressWithErrors: "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
795
+ done: "Alla {filesTotal} har lagts till",
796
+ doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
797
+ files: "filer",
798
+ file: "fil",
799
+ },
800
+ en: {
801
+ inProgress: "Adding {filesUploaded} of {filesTotal}",
802
+ inProgressWithErrors: "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
803
+ done: "All {filesTotal} added successfully",
804
+ doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
805
+ files: "tiedostoa",
806
+ file: "tiedosto",
807
+ },
808
+ };
809
+ /**
810
+ * Strings used for the status aria-label
811
+ */
812
+ this.statusMessageLabel = getLocaleString(this.statusLabelDefaults);
813
+ /**
814
+ * Property to change button label defaults on the component.
815
+ * @default {
816
+ fi: "Lisää liite",
817
+ sv: "Lägg till en bilaga",
818
+ en: "Add an attachment",
819
+ }
820
+ */
821
+ this.buttonLabelDefaults = {
822
+ fi: "Lisää liite",
823
+ sv: "Lägg till en bilaga",
824
+ en: "Add an attachment",
825
+ };
826
+ /**
827
+ * Label of button
828
+ * @default { fi: "Lisää liite", sv: "Lägg till en bilaga", en: "Add an attachment" }
829
+ */
830
+ this.buttonLabel = getLocaleString(this.buttonLabelDefaults);
831
+ /**
832
+ * accessible aria-Label of button
833
+ */
834
+ this.accessibleButtonLabel = undefined;
835
+ /**
836
+ * Theme of the input.
837
+ */
838
+ this.theme = "";
839
+ /**
840
+ * Makes the input component disabled. This prevents users from being able to
841
+ * interact with the upload component, and conveys its inactive state to assistive technologies.
842
+ */
843
+ this.disabled = false;
844
+ /**
845
+ * Controls the margin of the component.
846
+ */
847
+ this.margin = "auto";
848
+ /**
849
+ * Set whether the input is required or not. Please note that this is necessary for
850
+ * accessible inputs when the user is required to fill them. When using this property
851
+ * you need to also set “novalidate” attribute to your form element to prevent
852
+ * browser from displaying its own validation errors.
853
+ */
854
+ this.required = false;
855
+ /**
856
+ * Visually hides the groups labels in the editable table list used to display the list of files
857
+ */
858
+ this.hideGroups = false;
859
+ /**
860
+ * Map of string that contain list of uploaded files.
861
+ */
862
+ this.files = new Map();
863
+ /**
864
+ * Property to read if the internally used editable-table contains errors or not
865
+ */
866
+ this.valid = !this.required;
867
+ /**
868
+ * Property to change labelDefaults defaults on the component.
869
+ * normally you would handle these strings on an application level and override @label when needed
870
+ * @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
871
+ */
872
+ this.labelDefaults = {
873
+ fi: "Lisää liite",
874
+ sv: "Lägg till en bilaga",
875
+ en: "Add attachments",
876
+ };
877
+ /**
878
+ * Label for the input.
879
+ * @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
880
+ */
881
+ this.label = getLocaleString(this.labelDefaults);
882
+ /**
883
+ * Property to change descriptionDefaults defaults on the component.
884
+ * @default {
885
+ 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.",
886
+ 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.",
887
+ 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.",
888
+ }
889
+ */
890
+ this.descriptionDefaults = {
891
+ 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.",
892
+ 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.",
893
+ 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.",
894
+ };
895
+ /**
896
+ * Description for the upload component.
897
+ * @default {
898
+ 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.",
899
+ 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.",
900
+ 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.",
901
+ }
902
+ */
903
+ this.description = getLocaleString(this.descriptionDefaults);
904
+ /**
905
+ * Defaults for the filelist's empty state.
906
+ * @default {
907
+ fi: "Ei vielä lisättyjä tiedostoja.",
908
+ sv: "Inga filer har lagts till ännu.",
909
+ en: "No files added yet.",
910
+ }
911
+ */
912
+ this.fileListEmptyDefaults = {
913
+ fi: "Ei vielä lisättyjä tiedostoja.",
914
+ sv: "Inga filer har lagts till ännu.",
915
+ en: "No files added yet.",
916
+ };
917
+ /**
918
+ * Label for the filelist's empty state.
919
+ * @default { fi: "Ei vielä lisättyjä tiedostoja.",sv: "Inga filer har lagts till ännu.",en: "No files added yet."}
920
+ */
921
+ this.fileListEmpty = getLocaleString(this.fileListEmptyDefaults);
922
+ /**
923
+ * Display the input in error state along with an error message.
924
+ */
925
+ this.error = "";
926
+ /**
927
+ * Use maxBytes to specify the maximum size in Bytes of a file that can be uploaded.
928
+ */
929
+ this.maxBytes = 200000000;
930
+ /**
931
+ * Use maxBytesTotal to specify the maximum size in Bytes of All files combined that can be uploaded.
932
+ */
933
+ this.maxBytesTotal = undefined;
934
+ /**
935
+ * Use maxFiles to specify the maximum amount of files that can be uploaded
936
+ */
937
+ this.maxFiles = 99;
938
+ /**
939
+ * A string of commaseperated file type values that are allowed
940
+ * @example: .pdf,.doc,.docx
941
+ */
942
+ this.allowedExtensions = "all";
943
+ /**
944
+ * A string of commaseperated mime type values that are allowed
945
+ * @example: image/*,application/msword,
946
+ */
947
+ this.allowedMimetypes = "*";
948
+ /**
949
+ * Use multiple to allow the user to select multiple files when uploading
950
+ */
951
+ this.multiple = true;
952
+ /**
953
+ * Use limitSelection to enforce the value in allowedExtension & allowedMimetypes when selecting files,
954
+ * by default this is off, setting this to true will limit the users choices to what has been explicitly set
955
+ */
956
+ this.limitSelection = false;
957
+ /**
958
+ * Private functions
959
+ */
960
+ this.listenForActionEvents = () => {
961
+ this.element.addEventListener("duetEditableItemAction", (e) => {
962
+ const detail = e.detail;
963
+ const { action, keyName, originalEvent } = detail;
964
+ switch (action) {
965
+ case "delete":
966
+ this.onDelete(keyName, originalEvent);
967
+ break;
968
+ case "cancel":
969
+ this.onCancel(keyName, originalEvent);
970
+ break;
971
+ // code block
972
+ }
973
+ });
974
+ };
975
+ this.verifyValidity = () => {
976
+ const { invalid, valid } = this.getFilesAsArray();
977
+ const oldValid = this.valid;
978
+ this.valid = invalid.length === 0 && valid.length !== 0;
979
+ if (this.valid !== oldValid) {
980
+ this.duetState.emit({
981
+ originalEvent: undefined,
982
+ data: { valid: this.valid, from: "componentWillRender" },
983
+ component: "duet-upload",
984
+ });
985
+ }
986
+ };
987
+ this.getGroupFromItemData = (item) => {
988
+ if (item.valid && item.progress === 100) {
989
+ // if the item has a group, move the file to that group instead
990
+ // of into the standard success group
991
+ if (item.group) {
992
+ return item.group;
993
+ }
994
+ return this.DefaultGroups.success;
995
+ }
996
+ else if (item.progress > 0 && item.progress !== 100) {
997
+ return this.DefaultGroups.inprogress;
998
+ }
999
+ else if (!item.valid) {
1000
+ return this.DefaultGroups.failure;
1001
+ }
1002
+ else if (item.group) {
1003
+ return item.group;
1004
+ }
1005
+ else {
1006
+ return "none";
1007
+ }
1008
+ };
1009
+ this.getItemHTMLFromItemData = (data, group) => {
1010
+ if (group === this.DefaultGroups.success) {
1011
+ return h(SuccessItem, { data: data, showLinks: this.showLinks });
1012
+ }
1013
+ else if (group === this.DefaultGroups.inprogress) {
1014
+ return h(ProgressItem, { progress: data.progress, name: data.item.name });
1015
+ }
1016
+ else if (group === this.DefaultGroups.failure) {
1017
+ return h(ErrorItem, { data: data });
1018
+ }
1019
+ else if (data.group) {
1020
+ return data.html;
1021
+ }
1022
+ else {
1023
+ return "none";
1024
+ }
1025
+ };
1026
+ this.convertToDuetEditableTableItems = () => {
1027
+ // we're always recreating the map - in order to force an update down stream.
1028
+ const itemData = new Map();
1029
+ //walk the files Map and convert to DuetEditableTableItemData
1030
+ this.files.forEach((data, key, _originalMap) => {
1031
+ const group = this.getGroupFromItemData(data);
1032
+ const item = this.getItemHTMLFromItemData(data, group);
1033
+ itemData.set(key, {
1034
+ uid: data.uid,
1035
+ item,
1036
+ group,
1037
+ });
1038
+ });
1039
+ return itemData;
1040
+ };
1041
+ this.kick = debounce(() => {
1042
+ this.tick = Date.now();
1043
+ }, 30); // will trigger re-render
1044
+ this.genHashName = () => Date.now().toString(36) + Math.random();
1045
+ this.updateValueInMap = (item, key, value, kick = true) => {
1046
+ const fileItem = this.files.get(item);
1047
+ fileItem[key] = value;
1048
+ this.files.set(item, fileItem);
1049
+ if (kick) {
1050
+ this.kick();
1051
+ }
1052
+ };
1053
+ this.updateProgress = (ev, name) => {
1054
+ const updateProgressHelper = percentComplete => {
1055
+ this.updateValueInMap(name, "progress", percentComplete);
1056
+ this.onProgress(name, percentComplete, ev);
1057
+ };
1058
+ if (ev.lengthComputable) {
1059
+ const percentComplete = (ev.loaded / ev.total) * 100;
1060
+ updateProgressHelper(percentComplete);
1061
+ }
1062
+ else {
1063
+ console.log("cant read progress");
1064
+ }
1065
+ };
1066
+ this.trackProgress = (name, remove = false) => {
1067
+ if (remove) {
1068
+ this.filesInProgress.delete(name);
1069
+ }
1070
+ else {
1071
+ this.filesInProgress.set(name, "inprogress");
1072
+ }
1073
+ if (this.filesInProgress.size === 0) {
1074
+ this.onDone();
1075
+ }
1076
+ };
1077
+ this.getFilesAsArray = () => {
1078
+ const filesInQueue = [];
1079
+ const filesInError = [];
1080
+ this.files.forEach(value => {
1081
+ if (value.valid && !value.deleted) {
1082
+ filesInQueue.push(value);
1083
+ }
1084
+ else if (!value.valid && !value.deleted) {
1085
+ filesInError.push(value);
1086
+ }
1087
+ });
1088
+ return { valid: filesInQueue, invalid: filesInError };
1089
+ };
1090
+ this.resetFormFields = () => {
1091
+ /**
1092
+ * You cannot modify a FileList, nor remove single items from it
1093
+ * This completely removes all items in the FileList
1094
+ * We reset the form fields to always be able to re-upload files
1095
+ * and because we handle all uploads and states internally in the component (not relying on native form elements)
1096
+ */
1097
+ /* TODO: it may be a good idea to just update the list so that this always matches what is in the files map,
1098
+ * TODO: this would remove the capability of Re-uploading, unless we can catch and remove the user file from the form filelist before the upload is canceled by the browser
1099
+ * TODO: but for now we'll just reset the form fields
1100
+ */
1101
+ this.nativeInput.value = "";
1102
+ };
1103
+ this.startUpload = async (ev, metaData = undefined) => {
1104
+ await this.setFocus();
1105
+ this.metaData = metaData;
1106
+ this.nativeInput.click();
1107
+ this.onUpload(ev, metaData);
1108
+ ev.stopPropagation();
1109
+ ev.preventDefault();
1110
+ return;
1111
+ };
1112
+ /**
1113
+ * Eventlisteners for the XHR requests
1114
+ */
1115
+ this.transferComplete = name => {
1116
+ this.updateValueInMap(name, "progress", 100, false);
1117
+ this.trackProgress(name, true);
1118
+ };
1119
+ this.transferDone = (xhr, name, status) => {
1120
+ this.updateValueInMap(name, "status", status, false);
1121
+ this.updateValueInMap(name, "uploaded", true, false);
1122
+ try {
1123
+ const response = JSON.parse(xhr.response);
1124
+ this.updateValueInMap(name, "url", response.url);
1125
+ }
1126
+ catch (e) {
1127
+ this.updateValueInMap(name, "url", null);
1128
+ console.error("Server did not respond with expected response {url: string}");
1129
+ }
1130
+ return;
1131
+ };
1132
+ this.transferDoneWithFailure = (xhr, name, status) => {
1133
+ try {
1134
+ const { error } = JSON.parse(xhr.response);
1135
+ this.updateValueInMap(name, "error", { message: error.message, type: error.type }, false);
1136
+ }
1137
+ catch (e) {
1138
+ console.error("Server did not respond with expected response error:{message: string, type: int}");
1139
+ this.updateValueInMap(name, "error", { type: status }, false);
1140
+ }
1141
+ this.updateValueInMap(name, "valid", false, true);
1142
+ };
1143
+ this.transferFailed = name => {
1144
+ this.updateValueInMap(name, "error", getError("duet-upload-001"));
1145
+ };
1146
+ this.transferCanceled = name => {
1147
+ this.files.delete(name);
1148
+ this.validateTotals(name);
1149
+ this.kick();
1150
+ };
1151
+ this.validateTotals = (name) => {
1152
+ const isTotalSizeOverMaxSize = validateTotalSizeIsAboveMax(this.files, this.maxBytesTotal);
1153
+ const isTotalFileAmountAboveMax = validateTotalAmountIsAboveMax(this.files, this.maxFiles);
1154
+ if (isTotalSizeOverMaxSize && name) {
1155
+ this.updateValueInMap(name, "error", getError("duet-upload-202"), false);
1156
+ }
1157
+ if (isTotalFileAmountAboveMax && name) {
1158
+ this.updateValueInMap(name, "error", getError("duet-upload-301"), false);
1159
+ }
1160
+ this.bytesMaxReached = isTotalSizeOverMaxSize;
1161
+ this.fileMaxReached = isTotalFileAmountAboveMax;
1162
+ return {
1163
+ bytesMaxReached: isTotalSizeOverMaxSize,
1164
+ fileMaxReached: isTotalFileAmountAboveMax,
1165
+ };
1166
+ };
1167
+ this.onDelete = (key, ev) => {
1168
+ const deletedItem = this.files.get(key);
1169
+ this.files.delete(key);
1170
+ this.validateTotals();
1171
+ this.kick();
1172
+ this.duetDelete.emit({
1173
+ originalEvent: ev,
1174
+ data: { deletion: deletedItem },
1175
+ component: "duet-upload",
1176
+ });
1177
+ if (!this.external) {
1178
+ this.makeXHRDeleteRequest(deletedItem);
1179
+ }
1180
+ this.resetFormFields();
1181
+ };
1182
+ this.onCancel = (key, ev) => {
1183
+ const cancelledItem = this.files.get(key);
1184
+ this.files.delete(key);
1185
+ if (!this.external) {
1186
+ const { xhr } = cancelledItem;
1187
+ xhr.abort();
1188
+ }
1189
+ else {
1190
+ this.kick();
1191
+ }
1192
+ this.resetFormFields();
1193
+ this.duetCancel.emit({
1194
+ originalEvent: ev,
1195
+ data: { cancelled: cancelledItem },
1196
+ component: "duet-upload",
1197
+ });
1198
+ };
1199
+ this.onUpload = (ev, metaData) => {
1200
+ this.duetUpload.emit({
1201
+ originalEvent: ev,
1202
+ metaData,
1203
+ component: "duet-upload",
1204
+ });
1205
+ };
1206
+ this.onBlur = (ev) => {
1207
+ this.duetBlur.emit({
1208
+ originalEvent: ev,
1209
+ component: "duet-upload",
1210
+ });
1211
+ };
1212
+ this.onProgress = (key, percentComplete, ev) => {
1213
+ this.duetChange.emit({
1214
+ originalEvent: ev,
1215
+ data: {
1216
+ key,
1217
+ percentComplete,
1218
+ },
1219
+ component: "duet-upload",
1220
+ });
1221
+ };
1222
+ this.onFocus = (ev) => {
1223
+ this.duetFocus.emit({
1224
+ originalEvent: ev,
1225
+ component: "duet-upload",
1226
+ });
1227
+ };
1228
+ this.onDone = () => {
1229
+ this.duetDone.emit({
1230
+ component: "duet-upload",
1231
+ data: { files: this.files },
1232
+ });
1233
+ };
1234
+ }
1235
+ watchValidHandler(newValue, oldValue) {
1236
+ if (newValue !== oldValue) {
1237
+ this.kick();
1238
+ }
1239
+ }
1240
+ /**
1241
+ * Component lifecycle events.
1242
+ */
1243
+ componentWillLoad() {
1244
+ if (typeof this.statusMessageLabel === "string") {
1245
+ this.internalStatusMessageLabel = sanitizeString(this.groups);
1246
+ }
1247
+ else {
1248
+ this.internalStatusMessageLabel = this.statusMessageLabel;
1249
+ }
1250
+ inheritGlobalTheme(this);
1251
+ this.listenForActionEvents();
1252
+ }
1253
+ componentWillRender() {
1254
+ // listen to the events from the component
1255
+ this.verifyValidity();
1256
+ }
1257
+ /**
1258
+ * XHR request utilities
1259
+ */
1260
+ makeXHRPostRequest(data) {
1261
+ const xhr = new XMLHttpRequest();
1262
+ const name = data.get("name");
1263
+ xhr.upload.addEventListener("progress", ev => {
1264
+ this.updateProgress(ev, name);
1265
+ });
1266
+ xhr.upload.addEventListener("load", () => {
1267
+ this.transferComplete(name);
1268
+ });
1269
+ xhr.upload.addEventListener("error", () => {
1270
+ this.transferFailed(name);
1271
+ });
1272
+ xhr.upload.addEventListener("abort", () => {
1273
+ this.transferCanceled(name);
1274
+ });
1275
+ return makeXhrRequest({
1276
+ payload: { data, name },
1277
+ options: { type: "POST", uri: this.uri, xhr, argument: null, headers: null },
1278
+ onFailure: this.transferDoneWithFailure,
1279
+ onSuccess: this.transferDone,
1280
+ onProgress: this.trackProgress,
1281
+ });
1282
+ }
1283
+ makeXHRDeleteRequest(data) {
1284
+ const { uid, item } = data;
1285
+ const xhr = new XMLHttpRequest();
1286
+ // don't present server issues to user on deletes, just remove them from the visible list
1287
+ return makeXhrRequest({
1288
+ payload: { data: null, name },
1289
+ options: {
1290
+ type: "DELETE",
1291
+ xhr,
1292
+ uri: this.uri,
1293
+ arguments: `?key=${uid}&name=${item.name}`,
1294
+ headers: {
1295
+ "x-fileuid": uid,
1296
+ "x-filename": item.name,
1297
+ },
1298
+ },
1299
+ onFailure: this.transferDoneWithFailure,
1300
+ onSuccess: this.transferDone,
1301
+ onProgress: this.trackProgress,
1302
+ });
1303
+ }
1304
+ /**
1305
+ * Component event handling.
1306
+ */
1307
+ async onChange(ev) {
1308
+ var _a;
1309
+ const selectedFiles = Array.from((_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.files);
1310
+ // FileList is a nice array like structure but
1311
+ // to ensure uniqueness of files we use a mapping structure and
1312
+ // key to the name (makes it easier to delete as well)
1313
+ if (selectedFiles) {
1314
+ for (const item of selectedFiles) {
1315
+ const { valid, errorMessage, errorType, errorSystem } = validateFile(item, {
1316
+ maxBytes: this.maxBytes,
1317
+ allowedExtensions: this.allowedExtensions,
1318
+ allowedMimetypes: this.allowedMimetypes,
1319
+ });
1320
+ const uid = this.genHashName();
1321
+ const fileListItem = {
1322
+ uid,
1323
+ item: item,
1324
+ size: item.size,
1325
+ meta: this.metaData,
1326
+ uploaded: false,
1327
+ valid,
1328
+ error: {
1329
+ type: valid ? undefined : errorType,
1330
+ message: valid ? undefined : errorMessage,
1331
+ system_message: valid ? undefined : errorSystem,
1332
+ },
1333
+ progress: 0,
1334
+ deleted: false,
1335
+ xhr: false,
1336
+ url: false,
1337
+ };
1338
+ this.files.set(item.name, fileListItem);
1339
+ // validate that we haven't hit any maxfiles or maxbytes limits before we upload
1340
+ const { bytesMaxReached, fileMaxReached } = this.validateTotals(item.name);
1341
+ if (bytesMaxReached) {
1342
+ // in case one of the global maxes have been reached, invalidate the file
1343
+ this.updateValueInMap(item.name, "valid", false, false);
1344
+ }
1345
+ else if (fileMaxReached) {
1346
+ // in case one of the global maxes have been reached, invalidate the file
1347
+ this.updateValueInMap(item.name, "valid", false, false);
1348
+ }
1349
+ else if (valid && !this.external) {
1350
+ // if all is well AND external file upload handling has not been set, start upload
1351
+ const data = new FormData();
1352
+ data.append("file", item);
1353
+ data.append("uid", uid);
1354
+ data.append("name", item.name);
1355
+ data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size, meta: fileListItem.meta }));
1356
+ try {
1357
+ fileListItem.xhr = await this.makeXHRPostRequest(data);
1358
+ }
1359
+ catch (e) {
1360
+ // in case one of the global maxes have been reached, invalidate the file
1361
+ this.updateValueInMap(item.name, "valid", false, false);
1362
+ }
1363
+ }
1364
+ // kick the stat to force update
1365
+ this.kick();
1366
+ }
1367
+ }
1368
+ // reset the form, so that a user may upload a file again (with the same name)
1369
+ this.resetFormFields();
1370
+ // reset the internal metaData state
1371
+ this.metaData = undefined;
1372
+ this.duetChange.emit({
1373
+ originalEvent: ev,
1374
+ data: { files: this.files },
1375
+ component: "duet-upload",
1376
+ });
1377
+ }
1378
+ /**
1379
+ * Sets focus on the specified `duet-input`. Use this method instead of the global
1380
+ * `input.focus()`.
1381
+ */
1382
+ async setFocus(options) {
1383
+ if (this.nativeInput) {
1384
+ this.nativeInput.focus(options);
1385
+ }
1386
+ return;
1387
+ }
1388
+ /**
1389
+ * Method for invoking the upload sequence
1390
+ */
1391
+ async upload(metaData = undefined) {
1392
+ await this.setFocus();
1393
+ this.metaData = metaData;
1394
+ this.nativeInput.click();
1395
+ return;
1396
+ }
1397
+ /**
1398
+ * Get list of files, divided in errors and valid sections
1399
+ */
1400
+ async getFiles() {
1401
+ if (!this.files || this.files.size === 0) {
1402
+ return false;
1403
+ }
1404
+ return this.getFilesAsArray();
1405
+ }
1406
+ /**
1407
+ * Convenience method for updating the value of a key:value inside an item in the files attribute
1408
+ */
1409
+ async updateValue(item, key, value) {
1410
+ this.updateValueInMap(item, key, value);
1411
+ }
1412
+ /**
1413
+ * render() function
1414
+ * Always the last one in the class.
1415
+ */
1416
+ render() {
1417
+ const identifier = this.identifier || this.uploadId;
1418
+ let caption = this.description.replace(/{maxfiles}/g, this.maxFiles.toString());
1419
+ caption = caption.replace(/{maxbytes}/g, `${Math.floor(this.maxBytes / 1024 / 1024)} MB`);
1420
+ caption = caption.replace(/{filetypes}/g, this.allowedExtensions.split(",").join(", "));
1421
+ 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: {
1422
+ "duet-upload-filelist-empty": !this.files.size,
1423
+ "duet-upload-filelist": true,
1424
+ "duet-upload-filelist-filled": this.files.size,
1425
+ }, 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.internalStatusMessageLabel })), !!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 => {
1426
+ this.nativeInput = input;
1427
+ }, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
1428
+ "duet-upload": true,
1429
+ }, disabled: this.disabled, "aria-hidden": "true", required: this.required, name: this.name, id: this.identifier, multiple: this.multiple, capture: "user" })))));
1430
+ }
1431
+ get element() { return getElement(this); }
1432
+ static get watchers() { return {
1433
+ "valid": ["watchValidHandler"]
1434
+ }; }
1435
+ };
1436
+ DuetUpload.style = duetUploadCss;
1437
+
1438
+ export { DuetEditableTable as duet_editable_table, DuetEditableTableItem as duet_editable_table_item, DuetTable as duet_table, DuetUpload as duet_upload };