@watermarkinsights/ripple 3.27.0 → 3.27.1

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 (277) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-b2e0cb4e.js → chartFunctions-42cfb4d3.js} +596 -596
  3. package/dist/cjs/{functions-9807717e.js → functions-85c3c557.js} +498 -498
  4. package/dist/cjs/{global-42a24725.js → global-9982752f.js} +72 -72
  5. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  6. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  7. package/dist/cjs/{intl-526c75ec.js → intl-1c36fe38.js} +131 -131
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/priv-chart-popover.cjs.entry.js +91 -91
  10. package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
  11. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  12. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  13. package/dist/cjs/ripple.cjs.js +1 -1
  14. package/dist/cjs/wm-action-menu_2.cjs.entry.js +334 -334
  15. package/dist/cjs/wm-button.cjs.entry.js +189 -189
  16. package/dist/cjs/wm-chart-slice.cjs.entry.js +18 -18
  17. package/dist/cjs/wm-chart.cjs.entry.js +183 -183
  18. package/dist/cjs/wm-datepicker.cjs.entry.js +263 -263
  19. package/dist/cjs/wm-file-list.cjs.entry.js +35 -35
  20. package/dist/cjs/wm-file.cjs.entry.js +181 -181
  21. package/dist/cjs/wm-input.cjs.entry.js +136 -136
  22. package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
  23. package/dist/cjs/wm-modal-header.cjs.entry.js +32 -32
  24. package/dist/cjs/wm-modal.cjs.entry.js +152 -152
  25. package/dist/cjs/wm-navigation_3.cjs.entry.js +186 -186
  26. package/dist/cjs/wm-navigator.cjs.entry.js +264 -264
  27. package/dist/cjs/wm-network-uploader.cjs.entry.js +465 -465
  28. package/dist/cjs/wm-option_2.cjs.entry.js +768 -768
  29. package/dist/cjs/wm-pagination.cjs.entry.js +179 -179
  30. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +155 -155
  31. package/dist/cjs/wm-search.cjs.entry.js +184 -184
  32. package/dist/cjs/wm-snackbar.cjs.entry.js +134 -134
  33. package/dist/cjs/wm-tab-item_3.cjs.entry.js +264 -264
  34. package/dist/cjs/wm-tag-input-row.cjs.entry.js +14 -14
  35. package/dist/cjs/wm-tag-input.cjs.entry.js +948 -941
  36. package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
  37. package/dist/cjs/wm-toggletip.cjs.entry.js +120 -120
  38. package/dist/cjs/wm-uploader.cjs.entry.js +441 -441
  39. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  40. package/dist/collection/components/charts/chartFunctions.js +562 -562
  41. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +267 -267
  42. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +125 -125
  43. package/dist/collection/components/charts/wm-chart/wm-chart.js +450 -450
  44. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +207 -207
  45. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +143 -143
  46. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +121 -121
  47. package/dist/collection/components/wm-action-menu/wm-action-menu.js +472 -472
  48. package/dist/collection/components/wm-button/wm-button.js +486 -486
  49. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +983 -983
  50. package/dist/collection/components/wm-datepicker/wm-datepicker.js +491 -491
  51. package/dist/collection/components/wm-file/wm-file.js +313 -313
  52. package/dist/collection/components/wm-file-list/wm-file-list.js +152 -152
  53. package/dist/collection/components/wm-input/wm-input.js +509 -509
  54. package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
  55. package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
  56. package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
  57. package/dist/collection/components/wm-modal/wm-modal.js +462 -462
  58. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +119 -119
  59. package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
  60. package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
  61. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
  62. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
  63. package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
  64. package/dist/collection/components/wm-option/wm-option.js +435 -435
  65. package/dist/collection/components/wm-pagination/wm-pagination.js +362 -362
  66. package/dist/collection/components/wm-search/wm-search.js +439 -439
  67. package/dist/collection/components/wm-select/wm-select.js +1054 -1054
  68. package/dist/collection/components/wm-snackbar/wm-snackbar.js +267 -267
  69. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
  70. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
  71. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
  72. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
  73. package/dist/collection/components/wm-tag-input/wm-tag-input.css +21 -17
  74. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1302 -1295
  75. package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
  76. package/dist/collection/components/wm-toggletip/wm-toggletip.js +243 -243
  77. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +772 -772
  78. package/dist/collection/components/wm-uploader/wm-uploader.js +964 -964
  79. package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -28
  80. package/dist/collection/dev/scripts.js +20 -20
  81. package/dist/collection/global/__mocks__/functions.js +6 -6
  82. package/dist/collection/global/functions.js +541 -541
  83. package/dist/collection/global/global.js +79 -79
  84. package/dist/collection/global/interfaces.js +49 -49
  85. package/dist/collection/global/intl.js +132 -132
  86. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  87. package/dist/collection/global/services/http-service.js +50 -50
  88. package/dist/collection/lang/lang.js +5 -5
  89. package/dist/collection/lang/missing.js +43 -43
  90. package/dist/collection/lang/piglatin.js +93 -93
  91. package/dist/esm/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +596 -596
  92. package/dist/esm/{functions-f32b1ca4.js → functions-cbb19d50.js} +498 -498
  93. package/dist/esm/{global-7ee0d78d.js → global-2c7bbfe6.js} +72 -72
  94. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  95. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  96. package/dist/esm/{intl-d101e1a9.js → intl-ffbca53d.js} +131 -131
  97. package/dist/esm/loader.js +1 -1
  98. package/dist/esm/polyfills/core-js.js +0 -0
  99. package/dist/esm/polyfills/dom.js +0 -0
  100. package/dist/esm/polyfills/es5-html-element.js +0 -0
  101. package/dist/esm/polyfills/index.js +0 -0
  102. package/dist/esm/polyfills/system.js +0 -0
  103. package/dist/esm/priv-chart-popover.entry.js +91 -91
  104. package/dist/esm/priv-datepicker.entry.js +657 -657
  105. package/dist/esm/priv-navigator-button.entry.js +19 -19
  106. package/dist/esm/priv-navigator-item.entry.js +23 -23
  107. package/dist/esm/ripple.js +1 -1
  108. package/dist/esm/wm-action-menu_2.entry.js +334 -334
  109. package/dist/esm/wm-button.entry.js +189 -189
  110. package/dist/esm/wm-chart-slice.entry.js +18 -18
  111. package/dist/esm/wm-chart.entry.js +183 -183
  112. package/dist/esm/wm-datepicker.entry.js +263 -263
  113. package/dist/esm/wm-file-list.entry.js +35 -35
  114. package/dist/esm/wm-file.entry.js +181 -181
  115. package/dist/esm/wm-input.entry.js +136 -136
  116. package/dist/esm/wm-modal-footer.entry.js +33 -33
  117. package/dist/esm/wm-modal-header.entry.js +32 -32
  118. package/dist/esm/wm-modal.entry.js +152 -152
  119. package/dist/esm/wm-navigation_3.entry.js +186 -186
  120. package/dist/esm/wm-navigator.entry.js +264 -264
  121. package/dist/esm/wm-network-uploader.entry.js +465 -465
  122. package/dist/esm/wm-option_2.entry.js +768 -768
  123. package/dist/esm/wm-pagination.entry.js +179 -179
  124. package/dist/esm/wm-progress-indicator_3.entry.js +155 -155
  125. package/dist/esm/wm-search.entry.js +184 -184
  126. package/dist/esm/wm-snackbar.entry.js +134 -134
  127. package/dist/esm/wm-tab-item_3.entry.js +264 -264
  128. package/dist/esm/wm-tag-input-row.entry.js +14 -14
  129. package/dist/esm/wm-tag-input.entry.js +948 -941
  130. package/dist/esm/wm-timepicker.entry.js +385 -385
  131. package/dist/esm/wm-toggletip.entry.js +120 -120
  132. package/dist/esm/wm-uploader.entry.js +441 -441
  133. package/dist/esm/wm-wrapper.entry.js +12 -12
  134. package/dist/esm-es5/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +1 -1
  135. package/dist/esm-es5/{global-7ee0d78d.js → global-2c7bbfe6.js} +1 -1
  136. package/dist/esm-es5/{intl-d101e1a9.js → intl-ffbca53d.js} +1 -1
  137. package/dist/esm-es5/loader.js +1 -1
  138. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  139. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  140. package/dist/esm-es5/ripple.js +1 -1
  141. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  142. package/dist/esm-es5/wm-button.entry.js +1 -1
  143. package/dist/esm-es5/wm-chart.entry.js +1 -1
  144. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  145. package/dist/esm-es5/wm-file.entry.js +1 -1
  146. package/dist/esm-es5/wm-input.entry.js +1 -1
  147. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  148. package/dist/esm-es5/wm-modal.entry.js +1 -1
  149. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  150. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  151. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  152. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  153. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  154. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  155. package/dist/esm-es5/wm-search.entry.js +1 -1
  156. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  157. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  158. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  159. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  160. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  161. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  162. package/dist/ripple/{p-725c14b0.system.entry.js → p-00022d17.system.entry.js} +1 -1
  163. package/dist/ripple/{p-b97de06f.system.entry.js → p-0450cdbe.system.entry.js} +1 -1
  164. package/dist/ripple/{p-bfe1062d.entry.js → p-05a17658.entry.js} +1 -1
  165. package/dist/ripple/p-0b6a7b77.system.entry.js +1 -0
  166. package/dist/ripple/{p-b6bf2866.entry.js → p-0e789be7.entry.js} +1 -1
  167. package/dist/ripple/{p-b617b64f.system.entry.js → p-15779c22.system.entry.js} +1 -1
  168. package/dist/ripple/{p-04faca6b.entry.js → p-17487f1b.entry.js} +1 -1
  169. package/dist/ripple/{p-122da0d1.system.entry.js → p-197c83de.system.entry.js} +1 -1
  170. package/dist/ripple/{p-11d98b00.system.entry.js → p-1bad4efe.system.entry.js} +1 -1
  171. package/dist/ripple/{p-252ba295.system.entry.js → p-2ff923ee.system.entry.js} +1 -1
  172. package/dist/ripple/{p-a6afe65a.entry.js → p-31712996.entry.js} +1 -1
  173. package/dist/ripple/{p-f69276d5.system.entry.js → p-31c18f5e.system.entry.js} +1 -1
  174. package/dist/ripple/{p-df28f438.system.js → p-32944b70.system.js} +1 -1
  175. package/dist/ripple/{p-73d277ba.system.entry.js → p-36effc40.system.entry.js} +1 -1
  176. package/dist/ripple/{p-0be94e77.entry.js → p-3807bcae.entry.js} +1 -1
  177. package/dist/ripple/{p-88d17f6b.system.entry.js → p-3aa48fad.system.entry.js} +1 -1
  178. package/dist/ripple/{p-82a97531.system.entry.js → p-419f133c.system.entry.js} +1 -1
  179. package/dist/ripple/{p-13ec8ac0.entry.js → p-438a1e8e.entry.js} +1 -1
  180. package/dist/ripple/{p-19689aac.js → p-4698b365.js} +1 -1
  181. package/dist/ripple/{p-f8d45250.system.entry.js → p-54086f7b.system.entry.js} +1 -1
  182. package/dist/ripple/{p-47f53321.entry.js → p-5497694c.entry.js} +1 -1
  183. package/dist/ripple/{p-fb370a69.entry.js → p-58fbf116.entry.js} +1 -1
  184. package/dist/ripple/{p-14dfc4e7.entry.js → p-65a741c1.entry.js} +1 -1
  185. package/dist/ripple/{p-ac63b3aa.entry.js → p-7e74274b.entry.js} +1 -1
  186. package/dist/ripple/{p-81752607.system.js → p-81ad3fe5.system.js} +1 -1
  187. package/dist/ripple/{p-f3e42327.system.entry.js → p-89db9c27.system.entry.js} +1 -1
  188. package/dist/ripple/{p-4753fbfc.system.entry.js → p-947f01e2.system.entry.js} +1 -1
  189. package/dist/ripple/{p-3aee75e7.entry.js → p-978429f9.entry.js} +1 -1
  190. package/dist/ripple/{p-2c8fd902.system.entry.js → p-97d5b4bd.system.entry.js} +1 -1
  191. package/dist/ripple/{p-67c0ad56.system.entry.js → p-9d6a574b.system.entry.js} +1 -1
  192. package/dist/ripple/{p-c545fe1c.entry.js → p-a3ba2bdd.entry.js} +1 -1
  193. package/dist/ripple/{p-c7567fd3.entry.js → p-a42f5231.entry.js} +1 -1
  194. package/dist/ripple/p-a51aec3f.entry.js +1 -0
  195. package/dist/ripple/{p-b831988d.entry.js → p-a5b86b47.entry.js} +1 -1
  196. package/dist/ripple/{p-4cadf985.entry.js → p-a90b8a08.entry.js} +1 -1
  197. package/dist/ripple/{p-d9b66dca.system.entry.js → p-aabe172c.system.entry.js} +1 -1
  198. package/dist/ripple/{p-69121ad1.entry.js → p-ab2a0aee.entry.js} +1 -1
  199. package/dist/ripple/{p-5fb0aa58.js → p-aed93a25.js} +1 -1
  200. package/dist/ripple/{p-f39ee84b.entry.js → p-b2d75e7d.entry.js} +1 -1
  201. package/dist/ripple/{p-19b897ce.js → p-b410c675.js} +1 -1
  202. package/dist/ripple/{p-4809e419.system.entry.js → p-b6f558f7.system.entry.js} +1 -1
  203. package/dist/ripple/p-bb048fe7.entry.js +1 -0
  204. package/dist/ripple/{p-2805fed6.system.entry.js → p-bced37cf.system.entry.js} +1 -1
  205. package/dist/ripple/{p-c9a1834d.system.entry.js → p-bd0c1e7c.system.entry.js} +1 -1
  206. package/dist/ripple/{p-89f1991f.entry.js → p-c0e183f4.entry.js} +1 -1
  207. package/dist/ripple/{p-7eca18bd.system.entry.js → p-c27eda00.system.entry.js} +1 -1
  208. package/dist/ripple/{p-894bc6c4.system.entry.js → p-cd3e0b8b.system.entry.js} +1 -1
  209. package/dist/ripple/{p-f6b2e4ac.system.js → p-d1af63b5.system.js} +1 -1
  210. package/dist/ripple/{p-30572b71.system.js → p-d41ba263.system.js} +1 -1
  211. package/dist/ripple/{p-db7e6e89.entry.js → p-d8993992.entry.js} +1 -1
  212. package/dist/ripple/{p-f13b239c.system.entry.js → p-da525ed1.system.entry.js} +1 -1
  213. package/dist/ripple/{p-33af1eee.entry.js → p-e6f46289.entry.js} +1 -1
  214. package/dist/ripple/{p-e928f350.entry.js → p-fc967b2c.entry.js} +1 -1
  215. package/dist/ripple/ripple.esm.js +1 -1
  216. package/dist/ripple/ripple.js +1 -1
  217. package/dist/types/components/charts/chartFunctions.d.ts +37 -37
  218. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  219. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  220. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +47 -47
  221. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +29 -29
  222. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +20 -20
  223. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  224. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +49 -49
  225. package/dist/types/components/wm-button/wm-button.d.ts +44 -44
  226. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  227. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +42 -42
  228. package/dist/types/components/wm-file/wm-file.d.ts +40 -40
  229. package/dist/types/components/wm-file-list/wm-file-list.d.ts +16 -16
  230. package/dist/types/components/wm-input/wm-input.d.ts +57 -57
  231. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  232. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  233. package/dist/types/components/wm-modal/wm-modal-header.d.ts +10 -10
  234. package/dist/types/components/wm-modal/wm-modal.d.ts +40 -40
  235. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +16 -16
  236. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  237. package/dist/types/components/wm-navigation/wm-navigation.d.ts +26 -26
  238. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  239. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  240. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  241. package/dist/types/components/wm-option/wm-option.d.ts +34 -34
  242. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  243. package/dist/types/components/wm-search/wm-search.d.ts +77 -77
  244. package/dist/types/components/wm-select/wm-select.d.ts +101 -101
  245. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +30 -30
  246. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +37 -37
  247. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +52 -52
  248. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  249. package/dist/types/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.d.ts +11 -11
  250. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +137 -136
  251. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
  252. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -25
  253. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  254. package/dist/types/components/wm-uploader/wm-uploader.d.ts +99 -99
  255. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  256. package/dist/types/components.d.ts +27 -27
  257. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  258. package/dist/types/global/functions.d.ts +40 -40
  259. package/dist/types/global/global.d.ts +1 -1
  260. package/dist/types/global/interfaces.d.ts +74 -74
  261. package/dist/types/global/intl.d.ts +29 -29
  262. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  263. package/dist/types/global/services/http-service.d.ts +4 -4
  264. package/dist/types/lang/lang.d.ts +5 -5
  265. package/package.json +46 -46
  266. package/dist/ripple/p-37de8e2f.entry.js +0 -1
  267. package/dist/ripple/p-b378e064.system.entry.js +0 -1
  268. package/dist/ripple/p-d2037549.entry.js +0 -1
  269. /package/dist/esm-es5/{functions-f32b1ca4.js → functions-cbb19d50.js} +0 -0
  270. /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  271. /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  272. /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  273. /package/dist/ripple/{p-cfa80f5b.js → p-91480a89.js} +0 -0
  274. /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  275. /package/dist/ripple/{p-9eb5a71e.system.js → p-b267e710.system.js} +0 -0
  276. /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  277. /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
@@ -1,964 +1,964 @@
1
- import { h, Host } from "@stencil/core";
2
- import { forceUpdate } from "@stencil/core";
3
- import { generateId, hasValidType } from "../../global/functions";
4
- import { uploaderMessages } from "../../global/intl";
5
- export class Uploader {
6
- constructor() {
7
- this.inputId = generateId();
8
- this.uploaderType = undefined;
9
- this.type = undefined;
10
- this.label = undefined;
11
- this.buttonText = undefined;
12
- this.info = undefined;
13
- this.emptyStateText = undefined;
14
- this.icon = undefined;
15
- this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
16
- this.maxSize = undefined;
17
- this.maxFiles = undefined;
18
- this.sortBy = "date";
19
- this.showInfo = "time";
20
- this.errorMessage = undefined;
21
- this.requiredField = undefined;
22
- this.files = undefined;
23
- this.fileList = [];
24
- this.filesToUpload = [];
25
- this.isTabbing = false;
26
- this.rejectedFiles = undefined;
27
- this.errorList = [];
28
- this.notif = undefined;
29
- this.internalErrorMessage = undefined;
30
- this.announcement = "";
31
- this.numFilesInProgress = undefined;
32
- this.isCondensed = false;
33
- }
34
- get uploadButtonEl() {
35
- return this.el.shadowRoot.querySelector(`#${this.inputId}`);
36
- }
37
- get tempUploaderType() {
38
- // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
39
- return this.type || this.uploaderType;
40
- }
41
- get effectiveMaxSize() {
42
- const defaultMaxSize = 100;
43
- // maxsize cannot be set to over 100Mb
44
- const maxSizeLimit = 100;
45
- return this.maxSize ? Math.min(this.maxSize, maxSizeLimit) : defaultMaxSize;
46
- }
47
- get fileLimitReached() {
48
- return this.maxFiles && this.fileList.length >= this.maxFiles;
49
- }
50
- get displayedErrorMessage() {
51
- return this.errorMessage || this.internalErrorMessage || "";
52
- }
53
- toggleTabbingOn() {
54
- this.isTabbing = true;
55
- }
56
- toggleTabbingOff() {
57
- this.isTabbing = false;
58
- }
59
- handleUploadProgress(ev) {
60
- this.fileList.map((i) => {
61
- if (i.id === ev.detail.id) {
62
- i.progress = ev.detail.progress;
63
- forceUpdate(this.el);
64
- }
65
- });
66
- if (ev.detail.progress === 100) {
67
- // inProgressList is not a perfect reflection of how many files are uploading
68
- // because even after progress reached 100% the item should remain in the array
69
- // (should only be removed once it appears in fileList)
70
- this.numFilesInProgress -= 1;
71
- }
72
- // aggregate the percentages for SR to announce progress
73
- if (!this.srProgress && this.numFilesInProgress) {
74
- const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
75
- this.srProgress = setInterval(() => {
76
- const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
77
- this.announce(uploaderMessages.getUploadProgress(Math.floor(aggregate / total)));
78
- }, 5000);
79
- }
80
- }
81
- handleFileErrorCleared(ev) {
82
- const filename = ev.detail.name;
83
- this.errorList = this.errorList.filter((error) => error.name != filename);
84
- this.uploadButtonEl.focus();
85
- }
86
- handleFileDeleted(ev) {
87
- this.clearErrors();
88
- forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
89
- this.wmUploaderDeleteFile.emit(ev.detail);
90
- this.wmFileDelete.emit(ev.detail);
91
- this.wmDeleteFile.emit(ev.detail); // deprecated
92
- }
93
- handleFilePreviewed(ev) {
94
- this.clearErrors();
95
- this.wmUploaderPreviewFile.emit(ev.detail);
96
- this.wmFilePreview.emit(ev.detail);
97
- }
98
- handleFileDownloaded(ev) {
99
- this.clearErrors();
100
- this.wmUploaderDownloadFile.emit(ev.detail);
101
- this.wmFileDownload.emit(ev.detail);
102
- this.wmDownloadFile.emit(ev.detail); // deprecated
103
- }
104
- parseFiles() {
105
- if (!!this.files) {
106
- if (typeof this.files === "string") {
107
- let list = JSON.parse(this.files);
108
- if (typeof list === "object") {
109
- // if size is in byte format, convert to display format
110
- list.forEach((item) => {
111
- if (item.size && (typeof item.size === "number" || item.size.match(/^[0-9]+$/))) {
112
- const convertedSize = this.convertBytes(item.size);
113
- item.size = `${convertedSize.size.toFixed(0)} ${convertedSize.unit}`;
114
- }
115
- });
116
- this.fileList = list;
117
- }
118
- else {
119
- throw new Error("could not parse string passed to files attribute");
120
- }
121
- }
122
- else {
123
- throw new Error("Attribute 'files' should be a string");
124
- }
125
- }
126
- }
127
- focusAfterRemoval(newFiles, oldFiles) {
128
- if (this.isTabbing && newFiles.length < oldFiles.length) {
129
- const newFileIds = newFiles.map((file) => file.id);
130
- const oldFileIds = oldFiles.map((file) => file.id);
131
- // even in the case that multiple files have been removed at once, work off of the first in that group
132
- const removedFileId = oldFileIds.filter((id) => !newFileIds.includes(id))[0];
133
- if (oldFileIds.indexOf(removedFileId) > 0) {
134
- const fileIdPrecedingRemoved = oldFileIds[oldFileIds.indexOf(removedFileId) - 1];
135
- const fileElPrecedingRemoved = this.el.shadowRoot.querySelector("#file-" + fileIdPrecedingRemoved);
136
- const focusedElementsButtons = fileElPrecedingRemoved === null || fileElPrecedingRemoved === void 0 ? void 0 : fileElPrecedingRemoved.shadowRoot.querySelectorAll("wm-button");
137
- if (focusedElementsButtons && focusedElementsButtons.length > 0) {
138
- const lastButtonInFile = focusedElementsButtons[focusedElementsButtons.length - 1];
139
- lastButtonInFile.focus();
140
- }
141
- else {
142
- // if preceding file has no file action buttons, rerun function with adjusted params
143
- // by removing the fileElPrecedingRemoved from the newFiles list, it is now considered the removedFile and looks to focus it's preceding file
144
- // if it continues to cannot find an appropriate preceding file and becomes the first file in the list, it focuses the upload button
145
- this.focusAfterRemoval(newFiles.filter((file) => file.id !== fileIdPrecedingRemoved), oldFiles);
146
- }
147
- }
148
- else {
149
- this.uploadButtonEl.focus();
150
- }
151
- }
152
- }
153
- parseRejectedFiles() {
154
- if (!!this.rejectedFiles) {
155
- if (typeof this.files === "string") {
156
- const list = JSON.parse(this.rejectedFiles);
157
- if (typeof list === "object") {
158
- this.errorList = list;
159
- }
160
- else {
161
- throw new Error("could not parse string passed to errors attribute");
162
- }
163
- }
164
- else {
165
- throw new Error("Attribute 'rejected-files' should be a string");
166
- }
167
- }
168
- }
169
- uploadNotifications(newNum, oldNum) {
170
- if (oldNum > 0 && newNum === 0) {
171
- setTimeout(() => {
172
- this.notif = "";
173
- this.internalErrorMessage = "";
174
- }, 20 * 1000);
175
- this.notif = uploaderMessages.finishedUploading;
176
- this.announce(uploaderMessages.finishedUploading);
177
- this.numFilesInProgress = null;
178
- clearInterval(this.srProgress);
179
- forceUpdate(this.el);
180
- }
181
- else if (newNum > 0 && newNum != oldNum) {
182
- this.notif = uploaderMessages.getFilesUploading(newNum);
183
- this.announce(uploaderMessages.getFilesUploading(newNum));
184
- forceUpdate(this.el);
185
- }
186
- }
187
- handleErrorMessageChange() {
188
- if (this.errorMessage) {
189
- this.announce(this.errorMessage);
190
- }
191
- }
192
- isValidSize(size) {
193
- return this.convertBytes(size, "MB").size <= this.effectiveMaxSize;
194
- }
195
- convertBytes(bytes, unit) {
196
- // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
197
- const unitOrder = ["bytes", "KB", "MB", "GB", "TB"];
198
- let unitIndex = 0;
199
- let result = typeof bytes === "number" ? bytes : parseInt(bytes);
200
- if (unit) {
201
- // convert until result matches desired unit
202
- while (unitOrder.indexOf(unit) > unitIndex) {
203
- result /= 1024;
204
- unitIndex++;
205
- }
206
- }
207
- else {
208
- // convert until result is appropriate unit (value is under 1000)
209
- while (result > 1000) {
210
- result /= 1024;
211
- unitIndex++;
212
- }
213
- }
214
- return { size: result, unit: unitOrder[unitIndex] };
215
- }
216
- isDuplicate(name) {
217
- const hasDuplicateUploadingFile = this.filesToUpload.some((fileToUpload) => fileToUpload.name === name);
218
- const hasDuplicateUploadedFile = this.fileList.some((f) => {
219
- const filename = f.type ? f.name + "." + f.type : f.name;
220
- return filename === name;
221
- });
222
- return hasDuplicateUploadingFile || hasDuplicateUploadedFile;
223
- }
224
- isEmpty() {
225
- return !this.fileList.length && !this.errorList.length;
226
- }
227
- get isDisabled() {
228
- // disable if is the uploader is maxed out or if something is uploading
229
- return this.fileLimitReached || this.numFilesInProgress > 0;
230
- }
231
- isItemUploading(item) {
232
- return item.hasOwnProperty("progress") && item.progress < 100;
233
- }
234
- announce(message) {
235
- if (this.liveRegion.textContent === message) {
236
- message += "\u00A0";
237
- }
238
- this.announcement = message;
239
- }
240
- clearErrors() {
241
- this.errorList = [];
242
- this.notif = "";
243
- this.internalErrorMessage = "";
244
- }
245
- handleFiles(ev) {
246
- this.filesToUpload = [];
247
- const files = Array.from(ev.target.files);
248
- const validTypes = this.fileTypes.split(" ").join(", ");
249
- if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
250
- this.internalErrorMessage = uploaderMessages.fileLimitExceeded;
251
- this.announce(uploaderMessages.fileLimitExceeded);
252
- }
253
- else {
254
- files &&
255
- files.map((file) => {
256
- if (!hasValidType(file, this.fileTypes)) {
257
- const error = {
258
- name: file.name,
259
- message: uploaderMessages.getInvalidFileType(validTypes),
260
- };
261
- this.errorList.push(error);
262
- }
263
- else if (file.size === 0) {
264
- const error = {
265
- name: file.name,
266
- message: uploaderMessages.zeroFileSize,
267
- };
268
- this.errorList.push(error);
269
- }
270
- else if (!this.isValidSize(file.size)) {
271
- const error = {
272
- name: file.name,
273
- message: uploaderMessages.getFileTooLarge(this.effectiveMaxSize),
274
- };
275
- this.errorList.push(error);
276
- }
277
- else if (this.isDuplicate(file.name)) {
278
- const error = {
279
- name: file.name,
280
- message: uploaderMessages.duplicateName,
281
- };
282
- this.errorList.push(error);
283
- }
284
- else {
285
- this.filesToUpload.push(file);
286
- }
287
- });
288
- if (this.filesToUpload.length > 0) {
289
- this.numFilesInProgress = this.filesToUpload.length;
290
- this.wmUploaderFilesSelected.emit(this.filesToUpload);
291
- this.wmFilesSelected.emit(this.filesToUpload); // deprecated
292
- }
293
- }
294
- ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
295
- }
296
- componentWillLoad() {
297
- if (!this.buttonText) {
298
- throw new Error("wm-uploader: button-text is a required prop");
299
- }
300
- if (this.type) {
301
- console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
302
- }
303
- if (this.tempUploaderType === "1" && !this.emptyStateText) {
304
- throw new Error("wm-uploader: empty-state-text is a required prop");
305
- }
306
- this.parseFiles();
307
- this.clearErrors();
308
- this.parseRejectedFiles();
309
- }
310
- componentDidLoad() {
311
- if (document.body.classList.contains("wmcl-user-is-tabbing")) {
312
- this.toggleTabbingOn();
313
- }
314
- }
315
- uploadButtonOnClick(ev) {
316
- if (this.isDisabled) {
317
- // this is a temporary fix.
318
- // we need the disabled button to be programmatically focusable
319
- // to allow return focus after closing the browser file panel
320
- // since it's focusable the button should respond when activated
321
- // it looks disabled, and announces the reason why the action cannot
322
- // be taken when activated.
323
- ev.preventDefault();
324
- if (this.numFilesInProgress > 0) {
325
- const srMsg = uploaderMessages.waitToUpload;
326
- this.announce(srMsg);
327
- }
328
- else if (this.fileLimitReached) {
329
- this.internalErrorMessage = uploaderMessages.fileLimitReached;
330
- this.announce(uploaderMessages.fileLimitReached);
331
- }
332
- }
333
- else {
334
- this.clearErrors();
335
- }
336
- }
337
- renderUploadSvg() {
338
- return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" }, h("path", { transform: "rotate(-180.000000) translate(-452, -255.5)", fill: "#eae8ec", d: "M361,249.681818 L361,197.318182 C361,194.118182 365.555061,191.5 371.122358,191.5 L391.316463,191.5 L391.286495,200.562515 L369.871211,200.600292 L369.885404,200.622146 L369.886423,246.655947 L443.657038,246.840767 L443.657038,200.622146 L421.683537,200.622146 L421.683537,191.5 L441.978865,191.5 C447.546162,191.5 452,194.118182 452,197.318182 L452,249.681818 C452,252.881818 447.546162,255.5 441.978865,255.5 L371.122358,255.5 C365.504449,255.5 361,252.881818 361,249.681818 Z M391.5,207 L406,221 L420.5,207 L409.625,207 L409.625,172 L402.375,172 L402.375,207 L391.5,207 Z" })));
339
- }
340
- renderIcon() {
341
- // mdi attachment icon (paper clip) is horizontal but we want it vertical
342
- const rotate = this.icon && this.icon === "f066";
343
- return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
344
- }
345
- renderInfo() {
346
- return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
347
- }
348
- renderNotif() {
349
- return h("div", { class: "notif" }, this.notif);
350
- }
351
- renderError() {
352
- return h("div", { id: "error" }, this.displayedErrorMessage);
353
- }
354
- renderUploadButton(classes) {
355
- let accessibleLabel = `${this.label && this.label !== this.buttonText ? `${this.label}, ` : ""}${this.buttonText}`;
356
- return (h("div", { class: "info-wrapper" }, h("input", { name: this.inputId, id: this.inputId, class: "sr-only", "aria-label": accessibleLabel, "aria-required": this.requiredField ? "true" : null, "aria-describedby": `${this.displayedErrorMessage ? "error " : ""}file-count max-size accepted-types`, type: "file", multiple: true, onClick: (ev) => this.uploadButtonOnClick(ev), onChange: (ev) => this.handleFiles(ev) }), h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` }, this.renderIcon(), this.buttonText), this.renderInfo()));
357
- }
358
- renderEmptyState() {
359
- return (h("div", { class: "empty-block" }, this.renderUploadSvg(), h("div", { class: `empty-message` }, this.emptyStateText), this.renderUploadButton("-primary empty-button"), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()));
360
- }
361
- renderErrorList() {
362
- let srMessage = this.errorList.reduce(function (acc, err) {
363
- return acc + `${err.name}: ${err.message} `;
364
- }, "");
365
- this.announce(srMessage);
366
- return (h("ul", { class: "error-list" }, this.errorList.map((err) => (h("wm-file", { file: `{"name": "${err.name}"}`, "error-message": err.message })))));
367
- }
368
- formatTimestamp(timestamp) {
369
- const uploadDate = new Date(Date.parse(timestamp));
370
- const day = uploadDate.getDate();
371
- const month = uploadDate.getMonth() + 1;
372
- const year = uploadDate.getFullYear();
373
- const time = uploadDate.toLocaleTimeString("en-us", { hour: "numeric", minute: "2-digit" });
374
- const formattedDate = `${month}/${day}/${year} ${time}`;
375
- return formattedDate;
376
- }
377
- renderInProgressFileList() {
378
- return (h("ul", { class: "inprogress-list" }, this.fileList
379
- .filter((item) => this.isItemUploading(item))
380
- .map((item) => (h("wm-file", { file: JSON.stringify(item), "show-info": this.showInfo })))));
381
- }
382
- renderUploadedFileList() {
383
- return (h("ul", { class: "file-list" }, this.fileList
384
- .filter((item) => !this.isItemUploading(item))
385
- .map((item) => {
386
- item.lastUpdated = this.formatTimestamp(item.lastUpdated);
387
- return h("wm-file", { id: `file-${item.id}`, file: JSON.stringify(item), "show-info": this.showInfo });
388
- })));
389
- }
390
- renderFiles() {
391
- // if we switch to accepting display format for the wm-uploader's file lastUpdateds, sorting by date will become impossible
392
- this.sortBy === "name"
393
- ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
394
- : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
395
- return (h("div", null, this.renderInProgressFileList(), this.renderUploadedFileList()));
396
- }
397
- legacyRenderHeader() {
398
- return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: "slot-wrapper" }, h("slot", null), h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()))));
399
- }
400
- renderHeader() {
401
- const validTypes = "." + this.fileTypes.split(" ").join(", .");
402
- return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`), this.renderRequirements()), h("div", { id: "accepted-types", class: "accepted-types" }, uploaderMessages.getAcceptedFileTypes(validTypes, this.fileTypes.split(" ").length)), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()));
403
- }
404
- renderRequirements() {
405
- return (h("div", { class: "requirements" }, this.maxFiles && (h("span", { id: "file-count" }, uploaderMessages.getFileCount(this.fileList.length, this.maxFiles))), this.maxSize && h("span", { id: "max-size" }, uploaderMessages.getMaxSize(this.effectiveMaxSize))));
406
- }
407
- renderFooter() {
408
- return (h("div", { class: "footer" }, h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: "filecount-wrapper" }, h("div", { class: "filecount" }, uploaderMessages.getFilesAdded(this.fileList.length)), this.renderUploadButton(`-primary ${this.isDisabled ? "disabled" : ""}`)), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError())));
409
- }
410
- renderWithItems() {
411
- // it's possible progress is passed in as a string, so we need to check for "100" as well
412
- const hasNewlyUploadedFiles = this.fileList.filter((file) => file.progress === (typeof file.progress === "number" ? 100 : "100")).length > 0;
413
- return (h("div", null, !this.tempUploaderType && this.renderHeader(), this.tempUploaderType === "2" && this.legacyRenderHeader(), h("div", { class: `list-container type${this.tempUploaderType} ${!this.tempUploaderType && hasNewlyUploadedFiles ? "checkmark-spacer" : ""}` }, this.errorList.length > 0 && this.renderErrorList(), this.fileList.length > 0 && this.renderFiles()), this.tempUploaderType === "1" && this.renderFooter()));
414
- }
415
- renderLabel() {
416
- return (h("div", { class: `wrapper ${this.displayedErrorMessage ? "invalid" : ""}` }, h("div", { id: "label", class: `label` }, this.label, this.requiredField && (h("span", { class: "required", "aria-hidden": "true" }, "*")))));
417
- }
418
- render() {
419
- return (h(Host, null, this.label && this.renderLabel(), this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(), h("div", { ref: (el) => (this.liveRegion = el), class: "live-region sr-only", "aria-live": "assertive" // since it's directly linked to the action the user took, it should be read in priority. With polite, some messages get dismissed in favor of the page title
420
- ,
421
- "aria-atomic": "true" }, this.announcement)));
422
- }
423
- static get is() { return "wm-uploader"; }
424
- static get encapsulation() { return "shadow"; }
425
- static get delegatesFocus() { return true; }
426
- static get originalStyleUrls() {
427
- return {
428
- "$": ["wm-uploader.scss"]
429
- };
430
- }
431
- static get styleUrls() {
432
- return {
433
- "$": ["wm-uploader.css"]
434
- };
435
- }
436
- static get properties() {
437
- return {
438
- "uploaderType": {
439
- "type": "string",
440
- "mutable": true,
441
- "complexType": {
442
- "original": "\"1\" | \"2\"",
443
- "resolved": "\"1\" | \"2\" | undefined",
444
- "references": {}
445
- },
446
- "required": false,
447
- "optional": true,
448
- "docs": {
449
- "tags": [],
450
- "text": ""
451
- },
452
- "attribute": "uploader-type",
453
- "reflect": false
454
- },
455
- "type": {
456
- "type": "string",
457
- "mutable": false,
458
- "complexType": {
459
- "original": "\"1\" | \"2\"",
460
- "resolved": "\"1\" | \"2\" | undefined",
461
- "references": {}
462
- },
463
- "required": false,
464
- "optional": true,
465
- "docs": {
466
- "tags": [],
467
- "text": ""
468
- },
469
- "attribute": "type",
470
- "reflect": false
471
- },
472
- "label": {
473
- "type": "string",
474
- "mutable": false,
475
- "complexType": {
476
- "original": "string",
477
- "resolved": "string | undefined",
478
- "references": {}
479
- },
480
- "required": false,
481
- "optional": true,
482
- "docs": {
483
- "tags": [],
484
- "text": ""
485
- },
486
- "attribute": "label",
487
- "reflect": false
488
- },
489
- "buttonText": {
490
- "type": "string",
491
- "mutable": false,
492
- "complexType": {
493
- "original": "string",
494
- "resolved": "string",
495
- "references": {}
496
- },
497
- "required": true,
498
- "optional": false,
499
- "docs": {
500
- "tags": [],
501
- "text": ""
502
- },
503
- "attribute": "button-text",
504
- "reflect": false
505
- },
506
- "info": {
507
- "type": "string",
508
- "mutable": false,
509
- "complexType": {
510
- "original": "string",
511
- "resolved": "string | undefined",
512
- "references": {}
513
- },
514
- "required": false,
515
- "optional": true,
516
- "docs": {
517
- "tags": [],
518
- "text": ""
519
- },
520
- "attribute": "info",
521
- "reflect": false
522
- },
523
- "emptyStateText": {
524
- "type": "string",
525
- "mutable": false,
526
- "complexType": {
527
- "original": "string",
528
- "resolved": "string",
529
- "references": {}
530
- },
531
- "required": true,
532
- "optional": false,
533
- "docs": {
534
- "tags": [],
535
- "text": ""
536
- },
537
- "attribute": "empty-state-text",
538
- "reflect": false
539
- },
540
- "icon": {
541
- "type": "string",
542
- "mutable": false,
543
- "complexType": {
544
- "original": "string",
545
- "resolved": "string",
546
- "references": {}
547
- },
548
- "required": true,
549
- "optional": false,
550
- "docs": {
551
- "tags": [],
552
- "text": ""
553
- },
554
- "attribute": "icon",
555
- "reflect": false
556
- },
557
- "fileTypes": {
558
- "type": "string",
559
- "mutable": false,
560
- "complexType": {
561
- "original": "string",
562
- "resolved": "string",
563
- "references": {}
564
- },
565
- "required": false,
566
- "optional": false,
567
- "docs": {
568
- "tags": [],
569
- "text": ""
570
- },
571
- "attribute": "file-types",
572
- "reflect": false,
573
- "defaultValue": "\"pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv\""
574
- },
575
- "maxSize": {
576
- "type": "number",
577
- "mutable": false,
578
- "complexType": {
579
- "original": "number | null",
580
- "resolved": "null | number | undefined",
581
- "references": {}
582
- },
583
- "required": false,
584
- "optional": true,
585
- "docs": {
586
- "tags": [],
587
- "text": ""
588
- },
589
- "attribute": "max-size",
590
- "reflect": false
591
- },
592
- "maxFiles": {
593
- "type": "number",
594
- "mutable": false,
595
- "complexType": {
596
- "original": "number",
597
- "resolved": "number | undefined",
598
- "references": {}
599
- },
600
- "required": false,
601
- "optional": true,
602
- "docs": {
603
- "tags": [],
604
- "text": ""
605
- },
606
- "attribute": "max-files",
607
- "reflect": false
608
- },
609
- "sortBy": {
610
- "type": "string",
611
- "mutable": false,
612
- "complexType": {
613
- "original": "\"name\" | \"date\"",
614
- "resolved": "\"date\" | \"name\"",
615
- "references": {}
616
- },
617
- "required": false,
618
- "optional": false,
619
- "docs": {
620
- "tags": [],
621
- "text": ""
622
- },
623
- "attribute": "sort-by",
624
- "reflect": false,
625
- "defaultValue": "\"date\""
626
- },
627
- "showInfo": {
628
- "type": "string",
629
- "mutable": false,
630
- "complexType": {
631
- "original": "\"time\" | \"size\" | \"none\"",
632
- "resolved": "\"none\" | \"size\" | \"time\"",
633
- "references": {}
634
- },
635
- "required": false,
636
- "optional": false,
637
- "docs": {
638
- "tags": [],
639
- "text": ""
640
- },
641
- "attribute": "show-info",
642
- "reflect": false,
643
- "defaultValue": "\"time\""
644
- },
645
- "errorMessage": {
646
- "type": "string",
647
- "mutable": false,
648
- "complexType": {
649
- "original": "string",
650
- "resolved": "string | undefined",
651
- "references": {}
652
- },
653
- "required": false,
654
- "optional": true,
655
- "docs": {
656
- "tags": [],
657
- "text": ""
658
- },
659
- "attribute": "error-message",
660
- "reflect": false
661
- },
662
- "requiredField": {
663
- "type": "boolean",
664
- "mutable": false,
665
- "complexType": {
666
- "original": "boolean",
667
- "resolved": "boolean | undefined",
668
- "references": {}
669
- },
670
- "required": false,
671
- "optional": true,
672
- "docs": {
673
- "tags": [],
674
- "text": ""
675
- },
676
- "attribute": "required-field",
677
- "reflect": false
678
- },
679
- "files": {
680
- "type": "string",
681
- "mutable": false,
682
- "complexType": {
683
- "original": "string",
684
- "resolved": "string | undefined",
685
- "references": {}
686
- },
687
- "required": false,
688
- "optional": true,
689
- "docs": {
690
- "tags": [],
691
- "text": ""
692
- },
693
- "attribute": "files",
694
- "reflect": false
695
- },
696
- "filesToUpload": {
697
- "type": "unknown",
698
- "mutable": true,
699
- "complexType": {
700
- "original": "File[]",
701
- "resolved": "File[]",
702
- "references": {
703
- "File": {
704
- "location": "global"
705
- }
706
- }
707
- },
708
- "required": false,
709
- "optional": false,
710
- "docs": {
711
- "tags": [],
712
- "text": ""
713
- },
714
- "defaultValue": "[]"
715
- },
716
- "rejectedFiles": {
717
- "type": "string",
718
- "mutable": false,
719
- "complexType": {
720
- "original": "string",
721
- "resolved": "string | undefined",
722
- "references": {}
723
- },
724
- "required": false,
725
- "optional": true,
726
- "docs": {
727
- "tags": [],
728
- "text": ""
729
- },
730
- "attribute": "rejected-files",
731
- "reflect": false
732
- }
733
- };
734
- }
735
- static get states() {
736
- return {
737
- "fileList": {},
738
- "isTabbing": {},
739
- "errorList": {},
740
- "notif": {},
741
- "internalErrorMessage": {},
742
- "announcement": {},
743
- "numFilesInProgress": {},
744
- "isCondensed": {}
745
- };
746
- }
747
- static get events() {
748
- return [{
749
- "method": "wmUploaderFilesSelected",
750
- "name": "wmUploaderFilesSelected",
751
- "bubbles": true,
752
- "cancelable": true,
753
- "composed": true,
754
- "docs": {
755
- "tags": [],
756
- "text": ""
757
- },
758
- "complexType": {
759
- "original": "any",
760
- "resolved": "any",
761
- "references": {}
762
- }
763
- }, {
764
- "method": "wmFilesSelected",
765
- "name": "wmFilesSelected",
766
- "bubbles": true,
767
- "cancelable": true,
768
- "composed": true,
769
- "docs": {
770
- "tags": [],
771
- "text": ""
772
- },
773
- "complexType": {
774
- "original": "any",
775
- "resolved": "any",
776
- "references": {}
777
- }
778
- }, {
779
- "method": "wmUploaderDeleteFile",
780
- "name": "wmUploaderDeleteFile",
781
- "bubbles": true,
782
- "cancelable": true,
783
- "composed": true,
784
- "docs": {
785
- "tags": [],
786
- "text": ""
787
- },
788
- "complexType": {
789
- "original": "any",
790
- "resolved": "any",
791
- "references": {}
792
- }
793
- }, {
794
- "method": "wmDeleteFile",
795
- "name": "wmDeleteFile",
796
- "bubbles": true,
797
- "cancelable": true,
798
- "composed": true,
799
- "docs": {
800
- "tags": [],
801
- "text": ""
802
- },
803
- "complexType": {
804
- "original": "any",
805
- "resolved": "any",
806
- "references": {}
807
- }
808
- }, {
809
- "method": "wmUploaderDownloadFile",
810
- "name": "wmUploaderDownloadFile",
811
- "bubbles": true,
812
- "cancelable": true,
813
- "composed": true,
814
- "docs": {
815
- "tags": [],
816
- "text": ""
817
- },
818
- "complexType": {
819
- "original": "any",
820
- "resolved": "any",
821
- "references": {}
822
- }
823
- }, {
824
- "method": "wmDownloadFile",
825
- "name": "wmDownloadFile",
826
- "bubbles": true,
827
- "cancelable": true,
828
- "composed": true,
829
- "docs": {
830
- "tags": [],
831
- "text": ""
832
- },
833
- "complexType": {
834
- "original": "any",
835
- "resolved": "any",
836
- "references": {}
837
- }
838
- }, {
839
- "method": "wmUploaderPreviewFile",
840
- "name": "wmUploaderPreviewFile",
841
- "bubbles": true,
842
- "cancelable": true,
843
- "composed": true,
844
- "docs": {
845
- "tags": [],
846
- "text": ""
847
- },
848
- "complexType": {
849
- "original": "any",
850
- "resolved": "any",
851
- "references": {}
852
- }
853
- }, {
854
- "method": "wmFileDelete",
855
- "name": "wmFileDelete",
856
- "bubbles": true,
857
- "cancelable": true,
858
- "composed": true,
859
- "docs": {
860
- "tags": [],
861
- "text": ""
862
- },
863
- "complexType": {
864
- "original": "string",
865
- "resolved": "string",
866
- "references": {}
867
- }
868
- }, {
869
- "method": "wmFileDownload",
870
- "name": "wmFileDownload",
871
- "bubbles": true,
872
- "cancelable": true,
873
- "composed": true,
874
- "docs": {
875
- "tags": [],
876
- "text": ""
877
- },
878
- "complexType": {
879
- "original": "string",
880
- "resolved": "string",
881
- "references": {}
882
- }
883
- }, {
884
- "method": "wmFilePreview",
885
- "name": "wmFilePreview",
886
- "bubbles": true,
887
- "cancelable": true,
888
- "composed": true,
889
- "docs": {
890
- "tags": [],
891
- "text": ""
892
- },
893
- "complexType": {
894
- "original": "string",
895
- "resolved": "string",
896
- "references": {}
897
- }
898
- }];
899
- }
900
- static get elementRef() { return "el"; }
901
- static get watchers() {
902
- return [{
903
- "propName": "files",
904
- "methodName": "parseFiles"
905
- }, {
906
- "propName": "fileList",
907
- "methodName": "focusAfterRemoval"
908
- }, {
909
- "propName": "rejectedFiles",
910
- "methodName": "parseRejectedFiles"
911
- }, {
912
- "propName": "numFilesInProgress",
913
- "methodName": "uploadNotifications"
914
- }, {
915
- "propName": "errorMessage",
916
- "methodName": "handleErrorMessageChange"
917
- }];
918
- }
919
- static get listeners() {
920
- return [{
921
- "name": "wmUserIsTabbing",
922
- "method": "toggleTabbingOn",
923
- "target": "window",
924
- "capture": false,
925
- "passive": false
926
- }, {
927
- "name": "wmUserIsNotTabbing",
928
- "method": "toggleTabbingOff",
929
- "target": "window",
930
- "capture": false,
931
- "passive": false
932
- }, {
933
- "name": "wmUploadProgress",
934
- "method": "handleUploadProgress",
935
- "target": undefined,
936
- "capture": false,
937
- "passive": false
938
- }, {
939
- "name": "wmFileClearErrorClicked",
940
- "method": "handleFileErrorCleared",
941
- "target": undefined,
942
- "capture": false,
943
- "passive": false
944
- }, {
945
- "name": "wmIntFileDeleted",
946
- "method": "handleFileDeleted",
947
- "target": undefined,
948
- "capture": false,
949
- "passive": false
950
- }, {
951
- "name": "wmIntFilePreviewed",
952
- "method": "handleFilePreviewed",
953
- "target": undefined,
954
- "capture": false,
955
- "passive": false
956
- }, {
957
- "name": "wmIntFileDownloaded",
958
- "method": "handleFileDownloaded",
959
- "target": undefined,
960
- "capture": false,
961
- "passive": false
962
- }];
963
- }
964
- }
1
+ import { h, Host } from "@stencil/core";
2
+ import { forceUpdate } from "@stencil/core";
3
+ import { generateId, hasValidType } from "../../global/functions";
4
+ import { uploaderMessages } from "../../global/intl";
5
+ export class Uploader {
6
+ constructor() {
7
+ this.inputId = generateId();
8
+ this.uploaderType = undefined;
9
+ this.type = undefined;
10
+ this.label = undefined;
11
+ this.buttonText = undefined;
12
+ this.info = undefined;
13
+ this.emptyStateText = undefined;
14
+ this.icon = undefined;
15
+ this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
16
+ this.maxSize = undefined;
17
+ this.maxFiles = undefined;
18
+ this.sortBy = "date";
19
+ this.showInfo = "time";
20
+ this.errorMessage = undefined;
21
+ this.requiredField = undefined;
22
+ this.files = undefined;
23
+ this.fileList = [];
24
+ this.filesToUpload = [];
25
+ this.isTabbing = false;
26
+ this.rejectedFiles = undefined;
27
+ this.errorList = [];
28
+ this.notif = undefined;
29
+ this.internalErrorMessage = undefined;
30
+ this.announcement = "";
31
+ this.numFilesInProgress = undefined;
32
+ this.isCondensed = false;
33
+ }
34
+ get uploadButtonEl() {
35
+ return this.el.shadowRoot.querySelector(`#${this.inputId}`);
36
+ }
37
+ get tempUploaderType() {
38
+ // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
39
+ return this.type || this.uploaderType;
40
+ }
41
+ get effectiveMaxSize() {
42
+ const defaultMaxSize = 100;
43
+ // maxsize cannot be set to over 100Mb
44
+ const maxSizeLimit = 100;
45
+ return this.maxSize ? Math.min(this.maxSize, maxSizeLimit) : defaultMaxSize;
46
+ }
47
+ get fileLimitReached() {
48
+ return this.maxFiles && this.fileList.length >= this.maxFiles;
49
+ }
50
+ get displayedErrorMessage() {
51
+ return this.errorMessage || this.internalErrorMessage || "";
52
+ }
53
+ toggleTabbingOn() {
54
+ this.isTabbing = true;
55
+ }
56
+ toggleTabbingOff() {
57
+ this.isTabbing = false;
58
+ }
59
+ handleUploadProgress(ev) {
60
+ this.fileList.map((i) => {
61
+ if (i.id === ev.detail.id) {
62
+ i.progress = ev.detail.progress;
63
+ forceUpdate(this.el);
64
+ }
65
+ });
66
+ if (ev.detail.progress === 100) {
67
+ // inProgressList is not a perfect reflection of how many files are uploading
68
+ // because even after progress reached 100% the item should remain in the array
69
+ // (should only be removed once it appears in fileList)
70
+ this.numFilesInProgress -= 1;
71
+ }
72
+ // aggregate the percentages for SR to announce progress
73
+ if (!this.srProgress && this.numFilesInProgress) {
74
+ const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
75
+ this.srProgress = setInterval(() => {
76
+ const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
77
+ this.announce(uploaderMessages.getUploadProgress(Math.floor(aggregate / total)));
78
+ }, 5000);
79
+ }
80
+ }
81
+ handleFileErrorCleared(ev) {
82
+ const filename = ev.detail.name;
83
+ this.errorList = this.errorList.filter((error) => error.name != filename);
84
+ this.uploadButtonEl.focus();
85
+ }
86
+ handleFileDeleted(ev) {
87
+ this.clearErrors();
88
+ forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
89
+ this.wmUploaderDeleteFile.emit(ev.detail);
90
+ this.wmFileDelete.emit(ev.detail);
91
+ this.wmDeleteFile.emit(ev.detail); // deprecated
92
+ }
93
+ handleFilePreviewed(ev) {
94
+ this.clearErrors();
95
+ this.wmUploaderPreviewFile.emit(ev.detail);
96
+ this.wmFilePreview.emit(ev.detail);
97
+ }
98
+ handleFileDownloaded(ev) {
99
+ this.clearErrors();
100
+ this.wmUploaderDownloadFile.emit(ev.detail);
101
+ this.wmFileDownload.emit(ev.detail);
102
+ this.wmDownloadFile.emit(ev.detail); // deprecated
103
+ }
104
+ parseFiles() {
105
+ if (!!this.files) {
106
+ if (typeof this.files === "string") {
107
+ let list = JSON.parse(this.files);
108
+ if (typeof list === "object") {
109
+ // if size is in byte format, convert to display format
110
+ list.forEach((item) => {
111
+ if (item.size && (typeof item.size === "number" || item.size.match(/^[0-9]+$/))) {
112
+ const convertedSize = this.convertBytes(item.size);
113
+ item.size = `${convertedSize.size.toFixed(0)} ${convertedSize.unit}`;
114
+ }
115
+ });
116
+ this.fileList = list;
117
+ }
118
+ else {
119
+ throw new Error("could not parse string passed to files attribute");
120
+ }
121
+ }
122
+ else {
123
+ throw new Error("Attribute 'files' should be a string");
124
+ }
125
+ }
126
+ }
127
+ focusAfterRemoval(newFiles, oldFiles) {
128
+ if (this.isTabbing && newFiles.length < oldFiles.length) {
129
+ const newFileIds = newFiles.map((file) => file.id);
130
+ const oldFileIds = oldFiles.map((file) => file.id);
131
+ // even in the case that multiple files have been removed at once, work off of the first in that group
132
+ const removedFileId = oldFileIds.filter((id) => !newFileIds.includes(id))[0];
133
+ if (oldFileIds.indexOf(removedFileId) > 0) {
134
+ const fileIdPrecedingRemoved = oldFileIds[oldFileIds.indexOf(removedFileId) - 1];
135
+ const fileElPrecedingRemoved = this.el.shadowRoot.querySelector("#file-" + fileIdPrecedingRemoved);
136
+ const focusedElementsButtons = fileElPrecedingRemoved === null || fileElPrecedingRemoved === void 0 ? void 0 : fileElPrecedingRemoved.shadowRoot.querySelectorAll("wm-button");
137
+ if (focusedElementsButtons && focusedElementsButtons.length > 0) {
138
+ const lastButtonInFile = focusedElementsButtons[focusedElementsButtons.length - 1];
139
+ lastButtonInFile.focus();
140
+ }
141
+ else {
142
+ // if preceding file has no file action buttons, rerun function with adjusted params
143
+ // by removing the fileElPrecedingRemoved from the newFiles list, it is now considered the removedFile and looks to focus it's preceding file
144
+ // if it continues to cannot find an appropriate preceding file and becomes the first file in the list, it focuses the upload button
145
+ this.focusAfterRemoval(newFiles.filter((file) => file.id !== fileIdPrecedingRemoved), oldFiles);
146
+ }
147
+ }
148
+ else {
149
+ this.uploadButtonEl.focus();
150
+ }
151
+ }
152
+ }
153
+ parseRejectedFiles() {
154
+ if (!!this.rejectedFiles) {
155
+ if (typeof this.files === "string") {
156
+ const list = JSON.parse(this.rejectedFiles);
157
+ if (typeof list === "object") {
158
+ this.errorList = list;
159
+ }
160
+ else {
161
+ throw new Error("could not parse string passed to errors attribute");
162
+ }
163
+ }
164
+ else {
165
+ throw new Error("Attribute 'rejected-files' should be a string");
166
+ }
167
+ }
168
+ }
169
+ uploadNotifications(newNum, oldNum) {
170
+ if (oldNum > 0 && newNum === 0) {
171
+ setTimeout(() => {
172
+ this.notif = "";
173
+ this.internalErrorMessage = "";
174
+ }, 20 * 1000);
175
+ this.notif = uploaderMessages.finishedUploading;
176
+ this.announce(uploaderMessages.finishedUploading);
177
+ this.numFilesInProgress = null;
178
+ clearInterval(this.srProgress);
179
+ forceUpdate(this.el);
180
+ }
181
+ else if (newNum > 0 && newNum != oldNum) {
182
+ this.notif = uploaderMessages.getFilesUploading(newNum);
183
+ this.announce(uploaderMessages.getFilesUploading(newNum));
184
+ forceUpdate(this.el);
185
+ }
186
+ }
187
+ handleErrorMessageChange() {
188
+ if (this.errorMessage) {
189
+ this.announce(this.errorMessage);
190
+ }
191
+ }
192
+ isValidSize(size) {
193
+ return this.convertBytes(size, "MB").size <= this.effectiveMaxSize;
194
+ }
195
+ convertBytes(bytes, unit) {
196
+ // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
197
+ const unitOrder = ["bytes", "KB", "MB", "GB", "TB"];
198
+ let unitIndex = 0;
199
+ let result = typeof bytes === "number" ? bytes : parseInt(bytes);
200
+ if (unit) {
201
+ // convert until result matches desired unit
202
+ while (unitOrder.indexOf(unit) > unitIndex) {
203
+ result /= 1024;
204
+ unitIndex++;
205
+ }
206
+ }
207
+ else {
208
+ // convert until result is appropriate unit (value is under 1000)
209
+ while (result > 1000) {
210
+ result /= 1024;
211
+ unitIndex++;
212
+ }
213
+ }
214
+ return { size: result, unit: unitOrder[unitIndex] };
215
+ }
216
+ isDuplicate(name) {
217
+ const hasDuplicateUploadingFile = this.filesToUpload.some((fileToUpload) => fileToUpload.name === name);
218
+ const hasDuplicateUploadedFile = this.fileList.some((f) => {
219
+ const filename = f.type ? f.name + "." + f.type : f.name;
220
+ return filename === name;
221
+ });
222
+ return hasDuplicateUploadingFile || hasDuplicateUploadedFile;
223
+ }
224
+ isEmpty() {
225
+ return !this.fileList.length && !this.errorList.length;
226
+ }
227
+ get isDisabled() {
228
+ // disable if is the uploader is maxed out or if something is uploading
229
+ return this.fileLimitReached || this.numFilesInProgress > 0;
230
+ }
231
+ isItemUploading(item) {
232
+ return item.hasOwnProperty("progress") && item.progress < 100;
233
+ }
234
+ announce(message) {
235
+ if (this.liveRegion.textContent === message) {
236
+ message += "\u00A0";
237
+ }
238
+ this.announcement = message;
239
+ }
240
+ clearErrors() {
241
+ this.errorList = [];
242
+ this.notif = "";
243
+ this.internalErrorMessage = "";
244
+ }
245
+ handleFiles(ev) {
246
+ this.filesToUpload = [];
247
+ const files = Array.from(ev.target.files);
248
+ const validTypes = this.fileTypes.split(" ").join(", ");
249
+ if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
250
+ this.internalErrorMessage = uploaderMessages.fileLimitExceeded;
251
+ this.announce(uploaderMessages.fileLimitExceeded);
252
+ }
253
+ else {
254
+ files &&
255
+ files.map((file) => {
256
+ if (!hasValidType(file, this.fileTypes)) {
257
+ const error = {
258
+ name: file.name,
259
+ message: uploaderMessages.getInvalidFileType(validTypes),
260
+ };
261
+ this.errorList.push(error);
262
+ }
263
+ else if (file.size === 0) {
264
+ const error = {
265
+ name: file.name,
266
+ message: uploaderMessages.zeroFileSize,
267
+ };
268
+ this.errorList.push(error);
269
+ }
270
+ else if (!this.isValidSize(file.size)) {
271
+ const error = {
272
+ name: file.name,
273
+ message: uploaderMessages.getFileTooLarge(this.effectiveMaxSize),
274
+ };
275
+ this.errorList.push(error);
276
+ }
277
+ else if (this.isDuplicate(file.name)) {
278
+ const error = {
279
+ name: file.name,
280
+ message: uploaderMessages.duplicateName,
281
+ };
282
+ this.errorList.push(error);
283
+ }
284
+ else {
285
+ this.filesToUpload.push(file);
286
+ }
287
+ });
288
+ if (this.filesToUpload.length > 0) {
289
+ this.numFilesInProgress = this.filesToUpload.length;
290
+ this.wmUploaderFilesSelected.emit(this.filesToUpload);
291
+ this.wmFilesSelected.emit(this.filesToUpload); // deprecated
292
+ }
293
+ }
294
+ ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
295
+ }
296
+ componentWillLoad() {
297
+ if (!this.buttonText) {
298
+ throw new Error("wm-uploader: button-text is a required prop");
299
+ }
300
+ if (this.type) {
301
+ console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
302
+ }
303
+ if (this.tempUploaderType === "1" && !this.emptyStateText) {
304
+ throw new Error("wm-uploader: empty-state-text is a required prop");
305
+ }
306
+ this.parseFiles();
307
+ this.clearErrors();
308
+ this.parseRejectedFiles();
309
+ }
310
+ componentDidLoad() {
311
+ if (document.body.classList.contains("wmcl-user-is-tabbing")) {
312
+ this.toggleTabbingOn();
313
+ }
314
+ }
315
+ uploadButtonOnClick(ev) {
316
+ if (this.isDisabled) {
317
+ // this is a temporary fix.
318
+ // we need the disabled button to be programmatically focusable
319
+ // to allow return focus after closing the browser file panel
320
+ // since it's focusable the button should respond when activated
321
+ // it looks disabled, and announces the reason why the action cannot
322
+ // be taken when activated.
323
+ ev.preventDefault();
324
+ if (this.numFilesInProgress > 0) {
325
+ const srMsg = uploaderMessages.waitToUpload;
326
+ this.announce(srMsg);
327
+ }
328
+ else if (this.fileLimitReached) {
329
+ this.internalErrorMessage = uploaderMessages.fileLimitReached;
330
+ this.announce(uploaderMessages.fileLimitReached);
331
+ }
332
+ }
333
+ else {
334
+ this.clearErrors();
335
+ }
336
+ }
337
+ renderUploadSvg() {
338
+ return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" }, h("path", { transform: "rotate(-180.000000) translate(-452, -255.5)", fill: "#eae8ec", d: "M361,249.681818 L361,197.318182 C361,194.118182 365.555061,191.5 371.122358,191.5 L391.316463,191.5 L391.286495,200.562515 L369.871211,200.600292 L369.885404,200.622146 L369.886423,246.655947 L443.657038,246.840767 L443.657038,200.622146 L421.683537,200.622146 L421.683537,191.5 L441.978865,191.5 C447.546162,191.5 452,194.118182 452,197.318182 L452,249.681818 C452,252.881818 447.546162,255.5 441.978865,255.5 L371.122358,255.5 C365.504449,255.5 361,252.881818 361,249.681818 Z M391.5,207 L406,221 L420.5,207 L409.625,207 L409.625,172 L402.375,172 L402.375,207 L391.5,207 Z" })));
339
+ }
340
+ renderIcon() {
341
+ // mdi attachment icon (paper clip) is horizontal but we want it vertical
342
+ const rotate = this.icon && this.icon === "f066";
343
+ return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
344
+ }
345
+ renderInfo() {
346
+ return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
347
+ }
348
+ renderNotif() {
349
+ return h("div", { class: "notif" }, this.notif);
350
+ }
351
+ renderError() {
352
+ return h("div", { id: "error" }, this.displayedErrorMessage);
353
+ }
354
+ renderUploadButton(classes) {
355
+ let accessibleLabel = `${this.label && this.label !== this.buttonText ? `${this.label}, ` : ""}${this.buttonText}`;
356
+ return (h("div", { class: "info-wrapper" }, h("input", { name: this.inputId, id: this.inputId, class: "sr-only", "aria-label": accessibleLabel, "aria-required": this.requiredField ? "true" : null, "aria-describedby": `${this.displayedErrorMessage ? "error " : ""}file-count max-size accepted-types`, type: "file", multiple: true, onClick: (ev) => this.uploadButtonOnClick(ev), onChange: (ev) => this.handleFiles(ev) }), h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` }, this.renderIcon(), this.buttonText), this.renderInfo()));
357
+ }
358
+ renderEmptyState() {
359
+ return (h("div", { class: "empty-block" }, this.renderUploadSvg(), h("div", { class: `empty-message` }, this.emptyStateText), this.renderUploadButton("-primary empty-button"), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()));
360
+ }
361
+ renderErrorList() {
362
+ let srMessage = this.errorList.reduce(function (acc, err) {
363
+ return acc + `${err.name}: ${err.message} `;
364
+ }, "");
365
+ this.announce(srMessage);
366
+ return (h("ul", { class: "error-list" }, this.errorList.map((err) => (h("wm-file", { file: `{"name": "${err.name}"}`, "error-message": err.message })))));
367
+ }
368
+ formatTimestamp(timestamp) {
369
+ const uploadDate = new Date(Date.parse(timestamp));
370
+ const day = uploadDate.getDate();
371
+ const month = uploadDate.getMonth() + 1;
372
+ const year = uploadDate.getFullYear();
373
+ const time = uploadDate.toLocaleTimeString("en-us", { hour: "numeric", minute: "2-digit" });
374
+ const formattedDate = `${month}/${day}/${year} ${time}`;
375
+ return formattedDate;
376
+ }
377
+ renderInProgressFileList() {
378
+ return (h("ul", { class: "inprogress-list" }, this.fileList
379
+ .filter((item) => this.isItemUploading(item))
380
+ .map((item) => (h("wm-file", { file: JSON.stringify(item), "show-info": this.showInfo })))));
381
+ }
382
+ renderUploadedFileList() {
383
+ return (h("ul", { class: "file-list" }, this.fileList
384
+ .filter((item) => !this.isItemUploading(item))
385
+ .map((item) => {
386
+ item.lastUpdated = this.formatTimestamp(item.lastUpdated);
387
+ return h("wm-file", { id: `file-${item.id}`, file: JSON.stringify(item), "show-info": this.showInfo });
388
+ })));
389
+ }
390
+ renderFiles() {
391
+ // if we switch to accepting display format for the wm-uploader's file lastUpdateds, sorting by date will become impossible
392
+ this.sortBy === "name"
393
+ ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
394
+ : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
395
+ return (h("div", null, this.renderInProgressFileList(), this.renderUploadedFileList()));
396
+ }
397
+ legacyRenderHeader() {
398
+ return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: "slot-wrapper" }, h("slot", null), h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()))));
399
+ }
400
+ renderHeader() {
401
+ const validTypes = "." + this.fileTypes.split(" ").join(", .");
402
+ return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`), this.renderRequirements()), h("div", { id: "accepted-types", class: "accepted-types" }, uploaderMessages.getAcceptedFileTypes(validTypes, this.fileTypes.split(" ").length)), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError()));
403
+ }
404
+ renderRequirements() {
405
+ return (h("div", { class: "requirements" }, this.maxFiles && (h("span", { id: "file-count" }, uploaderMessages.getFileCount(this.fileList.length, this.maxFiles))), this.maxSize && h("span", { id: "max-size" }, uploaderMessages.getMaxSize(this.effectiveMaxSize))));
406
+ }
407
+ renderFooter() {
408
+ return (h("div", { class: "footer" }, h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` }, h("div", { class: "filecount-wrapper" }, h("div", { class: "filecount" }, uploaderMessages.getFilesAdded(this.fileList.length)), this.renderUploadButton(`-primary ${this.isDisabled ? "disabled" : ""}`)), this.notif && this.renderNotif(), this.displayedErrorMessage && this.renderError())));
409
+ }
410
+ renderWithItems() {
411
+ // it's possible progress is passed in as a string, so we need to check for "100" as well
412
+ const hasNewlyUploadedFiles = this.fileList.filter((file) => file.progress === (typeof file.progress === "number" ? 100 : "100")).length > 0;
413
+ return (h("div", null, !this.tempUploaderType && this.renderHeader(), this.tempUploaderType === "2" && this.legacyRenderHeader(), h("div", { class: `list-container type${this.tempUploaderType} ${!this.tempUploaderType && hasNewlyUploadedFiles ? "checkmark-spacer" : ""}` }, this.errorList.length > 0 && this.renderErrorList(), this.fileList.length > 0 && this.renderFiles()), this.tempUploaderType === "1" && this.renderFooter()));
414
+ }
415
+ renderLabel() {
416
+ return (h("div", { class: `wrapper ${this.displayedErrorMessage ? "invalid" : ""}` }, h("div", { id: "label", class: `label` }, this.label, this.requiredField && (h("span", { class: "required", "aria-hidden": "true" }, "*")))));
417
+ }
418
+ render() {
419
+ return (h(Host, null, this.label && this.renderLabel(), this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(), h("div", { ref: (el) => (this.liveRegion = el), class: "live-region sr-only", "aria-live": "assertive" // since it's directly linked to the action the user took, it should be read in priority. With polite, some messages get dismissed in favor of the page title
420
+ ,
421
+ "aria-atomic": "true" }, this.announcement)));
422
+ }
423
+ static get is() { return "wm-uploader"; }
424
+ static get encapsulation() { return "shadow"; }
425
+ static get delegatesFocus() { return true; }
426
+ static get originalStyleUrls() {
427
+ return {
428
+ "$": ["wm-uploader.scss"]
429
+ };
430
+ }
431
+ static get styleUrls() {
432
+ return {
433
+ "$": ["wm-uploader.css"]
434
+ };
435
+ }
436
+ static get properties() {
437
+ return {
438
+ "uploaderType": {
439
+ "type": "string",
440
+ "mutable": true,
441
+ "complexType": {
442
+ "original": "\"1\" | \"2\"",
443
+ "resolved": "\"1\" | \"2\" | undefined",
444
+ "references": {}
445
+ },
446
+ "required": false,
447
+ "optional": true,
448
+ "docs": {
449
+ "tags": [],
450
+ "text": ""
451
+ },
452
+ "attribute": "uploader-type",
453
+ "reflect": false
454
+ },
455
+ "type": {
456
+ "type": "string",
457
+ "mutable": false,
458
+ "complexType": {
459
+ "original": "\"1\" | \"2\"",
460
+ "resolved": "\"1\" | \"2\" | undefined",
461
+ "references": {}
462
+ },
463
+ "required": false,
464
+ "optional": true,
465
+ "docs": {
466
+ "tags": [],
467
+ "text": ""
468
+ },
469
+ "attribute": "type",
470
+ "reflect": false
471
+ },
472
+ "label": {
473
+ "type": "string",
474
+ "mutable": false,
475
+ "complexType": {
476
+ "original": "string",
477
+ "resolved": "string | undefined",
478
+ "references": {}
479
+ },
480
+ "required": false,
481
+ "optional": true,
482
+ "docs": {
483
+ "tags": [],
484
+ "text": ""
485
+ },
486
+ "attribute": "label",
487
+ "reflect": false
488
+ },
489
+ "buttonText": {
490
+ "type": "string",
491
+ "mutable": false,
492
+ "complexType": {
493
+ "original": "string",
494
+ "resolved": "string",
495
+ "references": {}
496
+ },
497
+ "required": true,
498
+ "optional": false,
499
+ "docs": {
500
+ "tags": [],
501
+ "text": ""
502
+ },
503
+ "attribute": "button-text",
504
+ "reflect": false
505
+ },
506
+ "info": {
507
+ "type": "string",
508
+ "mutable": false,
509
+ "complexType": {
510
+ "original": "string",
511
+ "resolved": "string | undefined",
512
+ "references": {}
513
+ },
514
+ "required": false,
515
+ "optional": true,
516
+ "docs": {
517
+ "tags": [],
518
+ "text": ""
519
+ },
520
+ "attribute": "info",
521
+ "reflect": false
522
+ },
523
+ "emptyStateText": {
524
+ "type": "string",
525
+ "mutable": false,
526
+ "complexType": {
527
+ "original": "string",
528
+ "resolved": "string",
529
+ "references": {}
530
+ },
531
+ "required": true,
532
+ "optional": false,
533
+ "docs": {
534
+ "tags": [],
535
+ "text": ""
536
+ },
537
+ "attribute": "empty-state-text",
538
+ "reflect": false
539
+ },
540
+ "icon": {
541
+ "type": "string",
542
+ "mutable": false,
543
+ "complexType": {
544
+ "original": "string",
545
+ "resolved": "string",
546
+ "references": {}
547
+ },
548
+ "required": true,
549
+ "optional": false,
550
+ "docs": {
551
+ "tags": [],
552
+ "text": ""
553
+ },
554
+ "attribute": "icon",
555
+ "reflect": false
556
+ },
557
+ "fileTypes": {
558
+ "type": "string",
559
+ "mutable": false,
560
+ "complexType": {
561
+ "original": "string",
562
+ "resolved": "string",
563
+ "references": {}
564
+ },
565
+ "required": false,
566
+ "optional": false,
567
+ "docs": {
568
+ "tags": [],
569
+ "text": ""
570
+ },
571
+ "attribute": "file-types",
572
+ "reflect": false,
573
+ "defaultValue": "\"pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv\""
574
+ },
575
+ "maxSize": {
576
+ "type": "number",
577
+ "mutable": false,
578
+ "complexType": {
579
+ "original": "number | null",
580
+ "resolved": "null | number | undefined",
581
+ "references": {}
582
+ },
583
+ "required": false,
584
+ "optional": true,
585
+ "docs": {
586
+ "tags": [],
587
+ "text": ""
588
+ },
589
+ "attribute": "max-size",
590
+ "reflect": false
591
+ },
592
+ "maxFiles": {
593
+ "type": "number",
594
+ "mutable": false,
595
+ "complexType": {
596
+ "original": "number",
597
+ "resolved": "number | undefined",
598
+ "references": {}
599
+ },
600
+ "required": false,
601
+ "optional": true,
602
+ "docs": {
603
+ "tags": [],
604
+ "text": ""
605
+ },
606
+ "attribute": "max-files",
607
+ "reflect": false
608
+ },
609
+ "sortBy": {
610
+ "type": "string",
611
+ "mutable": false,
612
+ "complexType": {
613
+ "original": "\"name\" | \"date\"",
614
+ "resolved": "\"date\" | \"name\"",
615
+ "references": {}
616
+ },
617
+ "required": false,
618
+ "optional": false,
619
+ "docs": {
620
+ "tags": [],
621
+ "text": ""
622
+ },
623
+ "attribute": "sort-by",
624
+ "reflect": false,
625
+ "defaultValue": "\"date\""
626
+ },
627
+ "showInfo": {
628
+ "type": "string",
629
+ "mutable": false,
630
+ "complexType": {
631
+ "original": "\"time\" | \"size\" | \"none\"",
632
+ "resolved": "\"none\" | \"size\" | \"time\"",
633
+ "references": {}
634
+ },
635
+ "required": false,
636
+ "optional": false,
637
+ "docs": {
638
+ "tags": [],
639
+ "text": ""
640
+ },
641
+ "attribute": "show-info",
642
+ "reflect": false,
643
+ "defaultValue": "\"time\""
644
+ },
645
+ "errorMessage": {
646
+ "type": "string",
647
+ "mutable": false,
648
+ "complexType": {
649
+ "original": "string",
650
+ "resolved": "string | undefined",
651
+ "references": {}
652
+ },
653
+ "required": false,
654
+ "optional": true,
655
+ "docs": {
656
+ "tags": [],
657
+ "text": ""
658
+ },
659
+ "attribute": "error-message",
660
+ "reflect": false
661
+ },
662
+ "requiredField": {
663
+ "type": "boolean",
664
+ "mutable": false,
665
+ "complexType": {
666
+ "original": "boolean",
667
+ "resolved": "boolean | undefined",
668
+ "references": {}
669
+ },
670
+ "required": false,
671
+ "optional": true,
672
+ "docs": {
673
+ "tags": [],
674
+ "text": ""
675
+ },
676
+ "attribute": "required-field",
677
+ "reflect": false
678
+ },
679
+ "files": {
680
+ "type": "string",
681
+ "mutable": false,
682
+ "complexType": {
683
+ "original": "string",
684
+ "resolved": "string | undefined",
685
+ "references": {}
686
+ },
687
+ "required": false,
688
+ "optional": true,
689
+ "docs": {
690
+ "tags": [],
691
+ "text": ""
692
+ },
693
+ "attribute": "files",
694
+ "reflect": false
695
+ },
696
+ "filesToUpload": {
697
+ "type": "unknown",
698
+ "mutable": true,
699
+ "complexType": {
700
+ "original": "File[]",
701
+ "resolved": "File[]",
702
+ "references": {
703
+ "File": {
704
+ "location": "global"
705
+ }
706
+ }
707
+ },
708
+ "required": false,
709
+ "optional": false,
710
+ "docs": {
711
+ "tags": [],
712
+ "text": ""
713
+ },
714
+ "defaultValue": "[]"
715
+ },
716
+ "rejectedFiles": {
717
+ "type": "string",
718
+ "mutable": false,
719
+ "complexType": {
720
+ "original": "string",
721
+ "resolved": "string | undefined",
722
+ "references": {}
723
+ },
724
+ "required": false,
725
+ "optional": true,
726
+ "docs": {
727
+ "tags": [],
728
+ "text": ""
729
+ },
730
+ "attribute": "rejected-files",
731
+ "reflect": false
732
+ }
733
+ };
734
+ }
735
+ static get states() {
736
+ return {
737
+ "fileList": {},
738
+ "isTabbing": {},
739
+ "errorList": {},
740
+ "notif": {},
741
+ "internalErrorMessage": {},
742
+ "announcement": {},
743
+ "numFilesInProgress": {},
744
+ "isCondensed": {}
745
+ };
746
+ }
747
+ static get events() {
748
+ return [{
749
+ "method": "wmUploaderFilesSelected",
750
+ "name": "wmUploaderFilesSelected",
751
+ "bubbles": true,
752
+ "cancelable": true,
753
+ "composed": true,
754
+ "docs": {
755
+ "tags": [],
756
+ "text": ""
757
+ },
758
+ "complexType": {
759
+ "original": "any",
760
+ "resolved": "any",
761
+ "references": {}
762
+ }
763
+ }, {
764
+ "method": "wmFilesSelected",
765
+ "name": "wmFilesSelected",
766
+ "bubbles": true,
767
+ "cancelable": true,
768
+ "composed": true,
769
+ "docs": {
770
+ "tags": [],
771
+ "text": ""
772
+ },
773
+ "complexType": {
774
+ "original": "any",
775
+ "resolved": "any",
776
+ "references": {}
777
+ }
778
+ }, {
779
+ "method": "wmUploaderDeleteFile",
780
+ "name": "wmUploaderDeleteFile",
781
+ "bubbles": true,
782
+ "cancelable": true,
783
+ "composed": true,
784
+ "docs": {
785
+ "tags": [],
786
+ "text": ""
787
+ },
788
+ "complexType": {
789
+ "original": "any",
790
+ "resolved": "any",
791
+ "references": {}
792
+ }
793
+ }, {
794
+ "method": "wmDeleteFile",
795
+ "name": "wmDeleteFile",
796
+ "bubbles": true,
797
+ "cancelable": true,
798
+ "composed": true,
799
+ "docs": {
800
+ "tags": [],
801
+ "text": ""
802
+ },
803
+ "complexType": {
804
+ "original": "any",
805
+ "resolved": "any",
806
+ "references": {}
807
+ }
808
+ }, {
809
+ "method": "wmUploaderDownloadFile",
810
+ "name": "wmUploaderDownloadFile",
811
+ "bubbles": true,
812
+ "cancelable": true,
813
+ "composed": true,
814
+ "docs": {
815
+ "tags": [],
816
+ "text": ""
817
+ },
818
+ "complexType": {
819
+ "original": "any",
820
+ "resolved": "any",
821
+ "references": {}
822
+ }
823
+ }, {
824
+ "method": "wmDownloadFile",
825
+ "name": "wmDownloadFile",
826
+ "bubbles": true,
827
+ "cancelable": true,
828
+ "composed": true,
829
+ "docs": {
830
+ "tags": [],
831
+ "text": ""
832
+ },
833
+ "complexType": {
834
+ "original": "any",
835
+ "resolved": "any",
836
+ "references": {}
837
+ }
838
+ }, {
839
+ "method": "wmUploaderPreviewFile",
840
+ "name": "wmUploaderPreviewFile",
841
+ "bubbles": true,
842
+ "cancelable": true,
843
+ "composed": true,
844
+ "docs": {
845
+ "tags": [],
846
+ "text": ""
847
+ },
848
+ "complexType": {
849
+ "original": "any",
850
+ "resolved": "any",
851
+ "references": {}
852
+ }
853
+ }, {
854
+ "method": "wmFileDelete",
855
+ "name": "wmFileDelete",
856
+ "bubbles": true,
857
+ "cancelable": true,
858
+ "composed": true,
859
+ "docs": {
860
+ "tags": [],
861
+ "text": ""
862
+ },
863
+ "complexType": {
864
+ "original": "string",
865
+ "resolved": "string",
866
+ "references": {}
867
+ }
868
+ }, {
869
+ "method": "wmFileDownload",
870
+ "name": "wmFileDownload",
871
+ "bubbles": true,
872
+ "cancelable": true,
873
+ "composed": true,
874
+ "docs": {
875
+ "tags": [],
876
+ "text": ""
877
+ },
878
+ "complexType": {
879
+ "original": "string",
880
+ "resolved": "string",
881
+ "references": {}
882
+ }
883
+ }, {
884
+ "method": "wmFilePreview",
885
+ "name": "wmFilePreview",
886
+ "bubbles": true,
887
+ "cancelable": true,
888
+ "composed": true,
889
+ "docs": {
890
+ "tags": [],
891
+ "text": ""
892
+ },
893
+ "complexType": {
894
+ "original": "string",
895
+ "resolved": "string",
896
+ "references": {}
897
+ }
898
+ }];
899
+ }
900
+ static get elementRef() { return "el"; }
901
+ static get watchers() {
902
+ return [{
903
+ "propName": "files",
904
+ "methodName": "parseFiles"
905
+ }, {
906
+ "propName": "fileList",
907
+ "methodName": "focusAfterRemoval"
908
+ }, {
909
+ "propName": "rejectedFiles",
910
+ "methodName": "parseRejectedFiles"
911
+ }, {
912
+ "propName": "numFilesInProgress",
913
+ "methodName": "uploadNotifications"
914
+ }, {
915
+ "propName": "errorMessage",
916
+ "methodName": "handleErrorMessageChange"
917
+ }];
918
+ }
919
+ static get listeners() {
920
+ return [{
921
+ "name": "wmUserIsTabbing",
922
+ "method": "toggleTabbingOn",
923
+ "target": "window",
924
+ "capture": false,
925
+ "passive": false
926
+ }, {
927
+ "name": "wmUserIsNotTabbing",
928
+ "method": "toggleTabbingOff",
929
+ "target": "window",
930
+ "capture": false,
931
+ "passive": false
932
+ }, {
933
+ "name": "wmUploadProgress",
934
+ "method": "handleUploadProgress",
935
+ "target": undefined,
936
+ "capture": false,
937
+ "passive": false
938
+ }, {
939
+ "name": "wmFileClearErrorClicked",
940
+ "method": "handleFileErrorCleared",
941
+ "target": undefined,
942
+ "capture": false,
943
+ "passive": false
944
+ }, {
945
+ "name": "wmIntFileDeleted",
946
+ "method": "handleFileDeleted",
947
+ "target": undefined,
948
+ "capture": false,
949
+ "passive": false
950
+ }, {
951
+ "name": "wmIntFilePreviewed",
952
+ "method": "handleFilePreviewed",
953
+ "target": undefined,
954
+ "capture": false,
955
+ "passive": false
956
+ }, {
957
+ "name": "wmIntFileDownloaded",
958
+ "method": "handleFileDownloaded",
959
+ "target": undefined,
960
+ "capture": false,
961
+ "passive": false
962
+ }];
963
+ }
964
+ }