@watermarkinsights/ripple 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-34fdd3ce.js → chartFunctions-0ea0888f.js} +420 -420
  3. package/dist/cjs/{functions-120449cf.js → functions-8d3ceccd.js} +1894 -450
  4. package/dist/cjs/{global-c1940f7b.js → global-39ada944.js} +62 -62
  5. package/dist/cjs/{http-service-494d81de.js → http-service-9e8c4dd5.js} +49 -49
  6. package/dist/cjs/{index-acad7ab3.js → index-df6a3611.js} +4 -1
  7. package/dist/cjs/{interfaces-a3338581.js → interfaces-30a74c1f.js} +29 -29
  8. package/dist/cjs/loader.cjs.js +4 -4
  9. package/dist/cjs/priv-chart-popover.cjs.entry.js +87 -87
  10. package/dist/cjs/priv-datepicker.cjs.entry.js +658 -658
  11. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  12. package/dist/cjs/priv-navigator-item.cjs.entry.js +24 -24
  13. package/dist/cjs/ripple.cjs.js +4 -4
  14. package/dist/cjs/wm-action-menu_2.cjs.entry.js +336 -336
  15. package/dist/cjs/wm-button.cjs.entry.js +242 -242
  16. package/dist/cjs/wm-chart-slice.cjs.entry.js +14 -14
  17. package/dist/cjs/wm-chart.cjs.entry.js +111 -111
  18. package/dist/cjs/wm-datepicker.cjs.entry.js +266 -266
  19. package/dist/cjs/wm-input.cjs.entry.js +135 -135
  20. package/dist/cjs/wm-modal-footer.cjs.entry.js +34 -34
  21. package/dist/cjs/wm-modal-header.cjs.entry.js +37 -37
  22. package/dist/cjs/wm-modal.cjs.entry.js +164 -164
  23. package/dist/cjs/wm-navigation_3.cjs.entry.js +228 -228
  24. package/dist/cjs/wm-navigator.cjs.entry.js +269 -269
  25. package/dist/cjs/wm-network-uploader.cjs.entry.js +455 -455
  26. package/dist/cjs/wm-option_2.cjs.entry.js +717 -710
  27. package/dist/cjs/wm-pagination.cjs.entry.js +168 -168
  28. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +130 -130
  29. package/dist/cjs/wm-search.cjs.entry.js +233 -233
  30. package/dist/cjs/wm-snackbar.cjs.entry.js +171 -171
  31. package/dist/cjs/wm-tab-item_3.cjs.entry.js +297 -297
  32. package/dist/cjs/wm-tag-input.cjs.entry.js +580 -580
  33. package/dist/cjs/wm-timepicker.cjs.entry.js +384 -384
  34. package/dist/cjs/wm-toggletip.cjs.entry.js +125 -125
  35. package/dist/cjs/wm-uploader.cjs.entry.js +630 -632
  36. package/dist/cjs/wm-wrapper.cjs.entry.js +13 -13
  37. package/dist/collection/collection-manifest.json +1 -1
  38. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +258 -258
  39. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +115 -115
  40. package/dist/collection/components/charts/wm-chart/wm-chart.js +328 -328
  41. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +195 -195
  42. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +88 -88
  43. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +111 -111
  44. package/dist/collection/components/wm-action-menu/wm-action-menu.js +448 -448
  45. package/dist/collection/components/wm-button/wm-button.js +504 -504
  46. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1024 -1024
  47. package/dist/collection/components/wm-datepicker/wm-datepicker.js +471 -471
  48. package/dist/collection/components/wm-input/wm-input.js +423 -423
  49. package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
  50. package/dist/collection/components/wm-modal/wm-modal-footer.js +136 -136
  51. package/dist/collection/components/wm-modal/wm-modal-header.js +87 -87
  52. package/dist/collection/components/wm-modal/wm-modal.js +461 -461
  53. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +162 -162
  54. package/dist/collection/components/wm-navigation/wm-navigation-item.js +121 -121
  55. package/dist/collection/components/wm-navigation/wm-navigation.js +218 -218
  56. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
  57. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
  58. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
  59. package/dist/collection/components/wm-option/wm-option.css +13 -0
  60. package/dist/collection/components/wm-option/wm-option.js +427 -419
  61. package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
  62. package/dist/collection/components/wm-search/wm-search.js +480 -480
  63. package/dist/collection/components/wm-select/wm-select.css +5 -2
  64. package/dist/collection/components/wm-select/wm-select.js +978 -978
  65. package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
  66. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +216 -216
  67. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +330 -330
  68. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
  69. package/dist/collection/components/wm-tag-input/wm-tag-input.js +810 -810
  70. package/dist/collection/components/wm-timepicker/wm-timepicker.js +583 -583
  71. package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
  72. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +787 -787
  73. package/dist/collection/components/wm-uploader/wm-uploader.js +1072 -1077
  74. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
  75. package/dist/collection/dev/scripts.js +20 -20
  76. package/dist/collection/global/__mocks__/functions.js +6 -6
  77. package/dist/collection/global/chartFunctions.js +421 -421
  78. package/dist/collection/global/functions.js +441 -441
  79. package/dist/collection/global/global.js +69 -69
  80. package/dist/collection/global/interfaces.js +49 -49
  81. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  82. package/dist/collection/global/services/http-service.js +50 -50
  83. package/dist/collection/lang/lang.js +5 -5
  84. package/dist/collection/lang/missing.js +43 -43
  85. package/dist/collection/lang/piglatin.js +93 -93
  86. package/dist/esm/{chartFunctions-20f05eb5.js → chartFunctions-6f90586d.js} +420 -420
  87. package/dist/esm/{functions-036af8dc.js → functions-11c0c4e2.js} +1894 -450
  88. package/dist/esm/{global-e98c740f.js → global-d36a84c5.js} +62 -62
  89. package/dist/esm/{http-service-3dc3b3e7.js → http-service-5d037e16.js} +49 -49
  90. package/dist/esm/{index-7603f98e.js → index-17c79cc6.js} +4 -1
  91. package/dist/esm/{interfaces-2b97fab2.js → interfaces-61c6305b.js} +29 -29
  92. package/dist/esm/loader.js +4 -4
  93. package/dist/esm/polyfills/core-js.js +0 -0
  94. package/dist/esm/polyfills/css-shim.js +1 -1
  95. package/dist/esm/polyfills/dom.js +0 -0
  96. package/dist/esm/polyfills/es5-html-element.js +0 -0
  97. package/dist/esm/polyfills/index.js +0 -0
  98. package/dist/esm/polyfills/system.js +0 -0
  99. package/dist/esm/priv-chart-popover.entry.js +87 -87
  100. package/dist/esm/priv-datepicker.entry.js +658 -658
  101. package/dist/esm/priv-navigator-button.entry.js +19 -19
  102. package/dist/esm/priv-navigator-item.entry.js +24 -24
  103. package/dist/esm/ripple.js +4 -4
  104. package/dist/esm/wm-action-menu_2.entry.js +336 -336
  105. package/dist/esm/wm-button.entry.js +242 -242
  106. package/dist/esm/wm-chart-slice.entry.js +14 -14
  107. package/dist/esm/wm-chart.entry.js +111 -111
  108. package/dist/esm/wm-datepicker.entry.js +266 -266
  109. package/dist/esm/wm-input.entry.js +135 -135
  110. package/dist/esm/wm-modal-footer.entry.js +34 -34
  111. package/dist/esm/wm-modal-header.entry.js +37 -37
  112. package/dist/esm/wm-modal.entry.js +164 -164
  113. package/dist/esm/wm-navigation_3.entry.js +228 -228
  114. package/dist/esm/wm-navigator.entry.js +269 -269
  115. package/dist/esm/wm-network-uploader.entry.js +455 -455
  116. package/dist/esm/wm-option_2.entry.js +717 -710
  117. package/dist/esm/wm-pagination.entry.js +168 -168
  118. package/dist/esm/wm-progress-indicator_3.entry.js +130 -130
  119. package/dist/esm/wm-search.entry.js +233 -233
  120. package/dist/esm/wm-snackbar.entry.js +171 -171
  121. package/dist/esm/wm-tab-item_3.entry.js +297 -297
  122. package/dist/esm/wm-tag-input.entry.js +580 -580
  123. package/dist/esm/wm-timepicker.entry.js +384 -384
  124. package/dist/esm/wm-toggletip.entry.js +125 -125
  125. package/dist/esm/wm-uploader.entry.js +630 -632
  126. package/dist/esm/wm-wrapper.entry.js +13 -13
  127. package/dist/esm-es5/{chartFunctions-20f05eb5.js → chartFunctions-6f90586d.js} +1 -1
  128. package/dist/esm-es5/functions-11c0c4e2.js +1 -0
  129. package/dist/esm-es5/{global-e98c740f.js → global-d36a84c5.js} +1 -1
  130. package/dist/esm-es5/{http-service-3dc3b3e7.js → http-service-5d037e16.js} +0 -0
  131. package/dist/esm-es5/{index-7603f98e.js → index-17c79cc6.js} +1 -1
  132. package/dist/esm-es5/{interfaces-2b97fab2.js → interfaces-61c6305b.js} +0 -0
  133. package/dist/esm-es5/loader.js +1 -1
  134. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  135. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  136. package/dist/esm-es5/priv-navigator-button.entry.js +1 -1
  137. package/dist/esm-es5/priv-navigator-item.entry.js +1 -1
  138. package/dist/esm-es5/ripple.js +1 -1
  139. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  140. package/dist/esm-es5/wm-button.entry.js +1 -1
  141. package/dist/esm-es5/wm-chart-slice.entry.js +1 -1
  142. package/dist/esm-es5/wm-chart.entry.js +1 -1
  143. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  144. package/dist/esm-es5/wm-input.entry.js +1 -1
  145. package/dist/esm-es5/wm-modal-footer.entry.js +1 -1
  146. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  147. package/dist/esm-es5/wm-modal.entry.js +1 -1
  148. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  149. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  150. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  151. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  152. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  153. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  154. package/dist/esm-es5/wm-search.entry.js +1 -1
  155. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  156. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  157. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  158. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  159. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  160. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  161. package/dist/esm-es5/wm-wrapper.entry.js +1 -1
  162. package/dist/ripple/{p-1ccd994d.system.entry.js → p-06012eb7.system.entry.js} +1 -1
  163. package/dist/ripple/{p-06adbeb9.system.entry.js → p-07ebdcd4.system.entry.js} +1 -1
  164. package/dist/ripple/{p-f5df5903.system.js → p-08b7ec08.system.js} +0 -0
  165. package/dist/ripple/{p-7173b0a7.system.entry.js → p-08fc668c.system.entry.js} +1 -1
  166. package/dist/ripple/p-0e22a3a4.entry.js +1 -0
  167. package/dist/ripple/p-262c75ff.entry.js +1 -0
  168. package/dist/ripple/{p-2193190b.js → p-26f94f8f.js} +1 -1
  169. package/dist/ripple/{p-90ed3268.system.entry.js → p-27253ed2.system.entry.js} +1 -1
  170. package/dist/ripple/{p-0556279c.system.entry.js → p-2af0b657.system.entry.js} +1 -1
  171. package/dist/ripple/p-2e5cb321.entry.js +1 -0
  172. package/dist/ripple/{p-9d02957d.system.js → p-313b6073.system.js} +0 -0
  173. package/dist/ripple/{p-6bf5cbf4.system.entry.js → p-3e875e87.system.entry.js} +1 -1
  174. package/dist/ripple/p-4073ac6a.entry.js +1 -0
  175. package/dist/ripple/p-410687ea.entry.js +1 -0
  176. package/dist/ripple/p-41374812.system.js +1 -0
  177. package/dist/ripple/p-42dbd978.entry.js +1 -0
  178. package/dist/ripple/{p-752da0fb.system.entry.js → p-4439bdd1.system.entry.js} +1 -1
  179. package/dist/ripple/{p-bbcafbd6.system.entry.js → p-4650a83c.system.entry.js} +1 -1
  180. package/dist/ripple/{p-4ecd3430.js → p-490dafa4.js} +1 -1
  181. package/dist/ripple/p-4afa52d4.entry.js +1 -0
  182. package/dist/ripple/p-4f3f7b2b.entry.js +1 -0
  183. package/dist/ripple/p-5018f8ae.entry.js +1 -0
  184. package/dist/ripple/{p-cd3d74d1.system.entry.js → p-57a718f0.system.entry.js} +1 -1
  185. package/dist/ripple/p-57c94258.entry.js +1 -0
  186. package/dist/ripple/{p-1df2adee.system.entry.js → p-59678b70.system.entry.js} +1 -1
  187. package/dist/ripple/p-626d5017.entry.js +1 -0
  188. package/dist/ripple/{p-3a535823.system.js → p-6a8fd452.system.js} +1 -1
  189. package/dist/ripple/{p-c1443a0e.system.entry.js → p-6ffdab0d.system.entry.js} +1 -1
  190. package/dist/ripple/p-70d0e993.js +1 -0
  191. package/dist/ripple/{p-a0c3ef16.system.js → p-726b9452.system.js} +1 -1
  192. package/dist/ripple/p-758501d7.entry.js +1 -0
  193. package/dist/ripple/{p-af3ce4fc.system.entry.js → p-7cb0035a.system.entry.js} +1 -1
  194. package/dist/ripple/p-80a00759.entry.js +1 -0
  195. package/dist/ripple/p-80b62707.entry.js +1 -0
  196. package/dist/ripple/{p-995ba16f.system.entry.js → p-84d0d2ff.system.entry.js} +1 -1
  197. package/dist/ripple/p-86b9bfcf.system.entry.js +1 -0
  198. package/dist/ripple/{p-43f1298b.js → p-888bec42.js} +0 -0
  199. package/dist/ripple/p-8a2cabf2.entry.js +1 -0
  200. package/dist/ripple/{p-62eac2d6.system.entry.js → p-8b54c589.system.entry.js} +1 -1
  201. package/dist/ripple/{p-7ef6a7cf.system.entry.js → p-910b6dd5.system.entry.js} +1 -1
  202. package/dist/ripple/p-962f51ff.entry.js +1 -0
  203. package/dist/ripple/p-97683ddc.entry.js +1 -0
  204. package/dist/ripple/p-9c60325b.entry.js +1 -0
  205. package/dist/ripple/{p-fd8070fb.js → p-a6d6eae7.js} +0 -0
  206. package/dist/ripple/p-b0536ddb.entry.js +1 -0
  207. package/dist/ripple/{p-d48c56c7.system.entry.js → p-b4837126.system.entry.js} +1 -1
  208. package/dist/ripple/{p-04d8b674.system.js → p-b5b7c71f.system.js} +1 -1
  209. package/dist/ripple/{p-8612829b.system.entry.js → p-b793bc6f.system.entry.js} +1 -1
  210. package/dist/ripple/p-c2abdcba.js +1 -0
  211. package/dist/ripple/{p-04e44b30.system.entry.js → p-c49ef079.system.entry.js} +1 -1
  212. package/dist/ripple/{p-895f5ec5.system.entry.js → p-c4c21c82.system.entry.js} +1 -1
  213. package/dist/ripple/p-c656fcf1.entry.js +1 -0
  214. package/dist/ripple/p-caef11cc.entry.js +1 -0
  215. package/dist/ripple/p-cb357a84.entry.js +1 -0
  216. package/dist/ripple/p-d2a11410.entry.js +1 -0
  217. package/dist/ripple/{p-49fd7ede.system.entry.js → p-d927de70.system.entry.js} +1 -1
  218. package/dist/ripple/{p-ae6cfbca.system.entry.js → p-db44eb6f.system.entry.js} +1 -1
  219. package/dist/ripple/p-db899686.system.js +1 -0
  220. package/dist/ripple/{p-f23b3986.system.entry.js → p-dc7e5609.system.entry.js} +1 -1
  221. package/dist/ripple/p-dfa80ed1.entry.js +1 -0
  222. package/dist/ripple/p-e012273a.entry.js +1 -0
  223. package/dist/ripple/p-e4cb8aad.entry.js +1 -0
  224. package/dist/ripple/{p-e4439bc3.system.entry.js → p-f0d3ceb1.system.entry.js} +1 -1
  225. package/dist/ripple/{p-3b3e847c.system.entry.js → p-f17076c4.system.entry.js} +1 -1
  226. package/dist/ripple/p-fa632547.entry.js +1 -0
  227. package/dist/ripple/{p-0e9ccc6f.system.entry.js → p-fe4c1194.system.entry.js} +1 -1
  228. package/dist/ripple/{p-ca383a43.system.entry.js → p-ffc34819.system.entry.js} +1 -1
  229. package/dist/ripple/ripple.esm.js +1 -1
  230. package/dist/ripple/ripple.js +1 -1
  231. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  232. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  233. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +36 -36
  234. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +27 -27
  235. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +17 -17
  236. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  237. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +47 -47
  238. package/dist/types/components/wm-button/wm-button.d.ts +43 -43
  239. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  240. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
  241. package/dist/types/components/wm-input/wm-input.d.ts +46 -46
  242. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  243. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  244. package/dist/types/components/wm-modal/wm-modal-header.d.ts +11 -11
  245. package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
  246. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +21 -21
  247. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  248. package/dist/types/components/wm-navigation/wm-navigation.d.ts +28 -28
  249. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  250. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  251. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  252. package/dist/types/components/wm-option/wm-option.d.ts +35 -35
  253. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  254. package/dist/types/components/wm-search/wm-search.d.ts +86 -86
  255. package/dist/types/components/wm-select/wm-select.d.ts +94 -93
  256. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
  257. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
  258. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
  259. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  260. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +92 -92
  261. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +61 -61
  262. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
  263. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  264. package/dist/types/components/wm-uploader/wm-uploader.d.ts +118 -119
  265. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  266. package/dist/types/components.d.ts +26 -26
  267. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  268. package/dist/types/global/chartFunctions.d.ts +29 -29
  269. package/dist/types/global/functions.d.ts +42 -42
  270. package/dist/types/global/global.d.ts +1 -1
  271. package/dist/types/global/interfaces.d.ts +44 -44
  272. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  273. package/dist/types/global/services/http-service.d.ts +4 -4
  274. package/dist/types/lang/lang.d.ts +5 -5
  275. package/package.json +47 -47
  276. package/dist/esm-es5/functions-036af8dc.js +0 -15
  277. package/dist/ripple/p-17ceb8c1.entry.js +0 -1
  278. package/dist/ripple/p-1887286e.entry.js +0 -1
  279. package/dist/ripple/p-1d795f42.entry.js +0 -1
  280. package/dist/ripple/p-2996bfe6.entry.js +0 -1
  281. package/dist/ripple/p-2f860b24.entry.js +0 -1
  282. package/dist/ripple/p-358bde27.entry.js +0 -1
  283. package/dist/ripple/p-3680b55d.entry.js +0 -1
  284. package/dist/ripple/p-3a1d6fc4.entry.js +0 -1
  285. package/dist/ripple/p-4d59fe86.entry.js +0 -1
  286. package/dist/ripple/p-6aa6a818.entry.js +0 -1
  287. package/dist/ripple/p-726c979a.system.js +0 -15
  288. package/dist/ripple/p-7ae1a630.entry.js +0 -1
  289. package/dist/ripple/p-7ecbf258.entry.js +0 -1
  290. package/dist/ripple/p-7fae0cc2.entry.js +0 -1
  291. package/dist/ripple/p-8de546e8.entry.js +0 -1
  292. package/dist/ripple/p-93dee724.entry.js +0 -1
  293. package/dist/ripple/p-97c2b06f.entry.js +0 -1
  294. package/dist/ripple/p-9ae81a59.system.js +0 -1
  295. package/dist/ripple/p-9c92c93f.entry.js +0 -1
  296. package/dist/ripple/p-9e09d7a1.entry.js +0 -1
  297. package/dist/ripple/p-a04ba6c8.entry.js +0 -1
  298. package/dist/ripple/p-a9e0ce88.entry.js +0 -1
  299. package/dist/ripple/p-b3c71506.js +0 -1
  300. package/dist/ripple/p-bee0b62d.entry.js +0 -1
  301. package/dist/ripple/p-da403a48.system.entry.js +0 -1
  302. package/dist/ripple/p-de3367ee.js +0 -16
  303. package/dist/ripple/p-e083fca6.entry.js +0 -1
  304. package/dist/ripple/p-e524d462.entry.js +0 -1
  305. package/dist/ripple/p-e8d39f68.entry.js +0 -1
  306. package/dist/ripple/p-ed91be1a.entry.js +0 -1
  307. package/dist/ripple/p-fda61e7e.entry.js +0 -1
  308. package/dist/ripple/p-fe952112.entry.js +0 -1
@@ -1,1077 +1,1072 @@
1
- import { Component, Element, Event, h, Host, Prop, State, Listen, Watch } from "@stencil/core";
2
- import { forceUpdate } from "@stencil/core";
3
- import { debounce, generateId, hasValidType, intl } from "../../global/functions";
4
- export class Uploader {
5
- constructor() {
6
- this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
7
- this.defaultMaxSize = 100;
8
- this.maxSize = this.defaultMaxSize; // in Mb
9
- this.sortBy = "date"; // name is descending (a -> z), date is ascending (earlier -> later)
10
- this.showInfo = "time";
11
- this.fileList = []; // the string above transformed into the actual array
12
- this.filesToUpload = []; // input.files that passed validation
13
- this.isTabbing = false;
14
- this.errorList = []; // for errors on a particular file
15
- this.isCondensed = false;
16
- this.inputId = generateId();
17
- this.debouncedResize = debounce(() => {
18
- this.isCondensed = this.el.clientWidth < 500;
19
- // rerender to show filename truncation changes
20
- forceUpdate(this.el);
21
- }, 50);
22
- }
23
- get tooltipEl() {
24
- return document.getElementById("wm-tooltip");
25
- }
26
- get uploadButtonEl() {
27
- return this.el.shadowRoot.querySelector(`#${this.inputId}`);
28
- }
29
- get tempUploaderType() {
30
- // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
31
- return this.type || this.uploaderType;
32
- }
33
- get chMeasure() {
34
- return this.el.shadowRoot.querySelector(".ch-measure").clientWidth;
35
- }
36
- get fileLimitReached() {
37
- return this.maxFiles && this.fileList.length >= this.maxFiles;
38
- }
39
- get fileUploadLimitMessage() {
40
- return intl.formatMessage({
41
- id: "uploader.fileUploadLimit",
42
- defaultMessage: "Upload unsuccessful because file selection would exceed the maximum number of files",
43
- description: "Message displayed when trying to upload too many files",
44
- });
45
- }
46
- get fileCountMessage() {
47
- return intl.formatMessage({
48
- id: "uploader.fileCount",
49
- defaultMessage: "{x} of {y} Files",
50
- description: "A count of the number of files currently uploaded",
51
- }, { x: this.fileList.length, y: this.maxFiles });
52
- }
53
- get maxSizeMessage() {
54
- return intl.formatMessage({
55
- id: "uploader.maxSize",
56
- defaultMessage: "Maximum file size {maxSize}MB",
57
- description: "An indicator of the maximum file size the uploader allows",
58
- }, {
59
- maxSize: this.maxSize,
60
- });
61
- }
62
- get acceptedFileTypesMessage() {
63
- const validTypes = "." + this.fileTypes.split(" ").join(", .");
64
- return intl.formatMessage({
65
- id: "uploader.acceptedFileTypes",
66
- defaultMessage: "Accepted file {amount, plural, =1 {type} other {types}}: {fileTypes}",
67
- }, {
68
- fileTypes: validTypes,
69
- amount: this.fileTypes.split(" ").length,
70
- });
71
- }
72
- get previewActionMessage() {
73
- return intl.formatMessage({
74
- id: "uploader.previewAction",
75
- defaultMessage: "Preview File",
76
- description: "Label of a button that triggers a file to be previewed",
77
- });
78
- }
79
- get downloadActionMessage() {
80
- return intl.formatMessage({
81
- id: "uploader.downloadAction",
82
- defaultMessage: "Download File",
83
- description: "Label of a button that triggers a file to be downloaded",
84
- });
85
- }
86
- get deleteActionMessage() {
87
- return intl.formatMessage({
88
- id: "uploader.deleteAction",
89
- defaultMessage: "Delete File",
90
- description: "Label of a button that triggers a file to be delete",
91
- });
92
- }
93
- get clearButtonText() {
94
- return intl.formatMessage({
95
- id: "uploader.clearErrorText",
96
- defaultMessage: "Clear",
97
- description: "Text for a button used to clear an error",
98
- });
99
- }
100
- get actionMenuLabel() {
101
- return intl.formatMessage({
102
- id: "uploader.actionMenuLabel",
103
- defaultMessage: "Actions",
104
- description: "Label of a button that opens a menu of file actions",
105
- });
106
- }
107
- toggleTabbingOn() {
108
- this.isTabbing = true;
109
- }
110
- toggleTabbingOff() {
111
- this.isTabbing = false;
112
- }
113
- handleUploadProgress(ev) {
114
- this.fileList.map((i) => {
115
- if (i.id === ev.detail.id) {
116
- i.progress = ev.detail.progress;
117
- forceUpdate(this.el);
118
- }
119
- });
120
- if (ev.detail.progress === 100) {
121
- // inProgressList is not a perfect reflection of how many files are uploading
122
- // because even after progress reached 100% the item should remain in the array
123
- // (should only be removed once it appears in fileList)
124
- this.numFilesInProgress -= 1;
125
- }
126
- // aggregate the percentages for SR to announce progress
127
- if (!this.srProgress && this.numFilesInProgress) {
128
- const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
129
- this.srProgress = setInterval(() => {
130
- const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
131
- if (this.liveRegion) {
132
- this.liveRegion.innerHTML = intl.formatMessage({
133
- id: "uploader.uploadProgress",
134
- defaultMessage: "Upload progress: {percentage}%",
135
- }, { percentage: Math.floor(aggregate / total) });
136
- }
137
- }, 5000);
138
- }
139
- }
140
- parseFiles() {
141
- if (!!this.files) {
142
- if (typeof this.files === "string") {
143
- const list = JSON.parse(this.files);
144
- if (typeof list === "object") {
145
- this.fileList = list;
146
- }
147
- else {
148
- throw new Error("could not parse string passed to files attribute");
149
- }
150
- }
151
- else {
152
- throw new Error("Attribute 'files' should be a string");
153
- }
154
- }
155
- }
156
- parseRejectedFiles() {
157
- if (!!this.rejectedFiles) {
158
- if (typeof this.files === "string") {
159
- const list = JSON.parse(this.rejectedFiles);
160
- if (typeof list === "object") {
161
- this.errorList = list;
162
- }
163
- else {
164
- throw new Error("could not parse string passed to errors attribute");
165
- }
166
- }
167
- else {
168
- throw new Error("Attribute 'rejected-files' should be a string");
169
- }
170
- }
171
- }
172
- setMaxSize() {
173
- // Max size can't be set above 100Mb
174
- this.maxSize = this.maxSize > this.defaultMaxSize ? this.defaultMaxSize : this.maxSize;
175
- }
176
- uploadNotifications(newNum, oldNum) {
177
- if (oldNum > 0 && newNum === 0) {
178
- setTimeout(() => {
179
- this.notif = null;
180
- }, 20 * 1000);
181
- const message = intl.formatMessage({
182
- id: "uploader.finishedUploading",
183
- defaultMessage: "Finished uploading",
184
- });
185
- this.notif = { id: 5, message, isError: false };
186
- if (this.liveRegion) {
187
- this.liveRegion.innerHTML = message;
188
- }
189
- this.numFilesInProgress = null;
190
- clearInterval(this.srProgress);
191
- forceUpdate(this.el);
192
- }
193
- else if (newNum > 0 && newNum != oldNum) {
194
- const message = intl.formatMessage({
195
- id: "uploader.filesUploading",
196
- defaultMessage: "{num, plural, one {1 file uploading} other {# files uploading}}",
197
- }, { num: newNum });
198
- this.notif = { id: 6, message, isError: false };
199
- if (this.liveRegion) {
200
- this.liveRegion.innerHTML = message;
201
- }
202
- forceUpdate(this.el);
203
- }
204
- }
205
- isValidSize(size) {
206
- return this.convertBytes(size, "MB").size <= this.maxSize;
207
- }
208
- convertBytes(bytes, unit) {
209
- // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
210
- const unitOrder = ["bytes", "KB", "MB", "GB", "TB"];
211
- let unitIndex = 0;
212
- let result = typeof bytes === "number" ? bytes : parseInt(bytes);
213
- if (unit) {
214
- // convert until result matches desired unit
215
- while (unitOrder.indexOf(unit) > unitIndex) {
216
- result /= 1024;
217
- unitIndex++;
218
- }
219
- }
220
- else {
221
- // convert until result is appropriate unit (value is under 1000)
222
- while (result > 1000) {
223
- result /= 1024;
224
- unitIndex++;
225
- }
226
- }
227
- return { size: result, unit: unitOrder[unitIndex] };
228
- }
229
- isDuplicate(name) {
230
- return this.fileList.find((f) => {
231
- const filename = f.type ? f.name + "." + f.type : f.name;
232
- return filename === name;
233
- });
234
- }
235
- isEmpty() {
236
- return !this.fileList.length && !this.errorList.length;
237
- }
238
- get isDisabled() {
239
- if (!this.notif) {
240
- if (this.fileLimitReached) {
241
- const errMessage = this.fileUploadLimitMessage;
242
- this.notif = { id: 1, message: errMessage, isError: true };
243
- if (this.liveRegion) {
244
- this.liveRegion.innerHTML = errMessage;
245
- }
246
- }
247
- else {
248
- this.notif = null;
249
- }
250
- }
251
- else if (this.notif.id === 1) {
252
- // to make sure SR don't repeat the error, don't reset it if it already is showing
253
- // just dismiss it if isMax is not true anymore
254
- if (!this.fileLimitReached) {
255
- this.notif = null;
256
- }
257
- // finally do nothing if error 2 is showing (special case when user selects too many files)
258
- }
259
- // disable if is the uploader is maxed out or if something is uploading
260
- return this.fileLimitReached || this.numFilesInProgress > 0;
261
- }
262
- isItemUploading(item) {
263
- return item.hasOwnProperty("progress") && item.progress < 100;
264
- }
265
- clearError(filename) {
266
- this.errorList = this.errorList.filter((error) => error.name != filename);
267
- this.notif = null;
268
- }
269
- clearErrors() {
270
- this.errorList = [];
271
- this.notif = null;
272
- }
273
- handleFiles(ev) {
274
- this.filesToUpload = [];
275
- const validTypes = this.fileTypes.split(" ").join(", ");
276
- const files = Array.from(ev.target.files);
277
- if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
278
- const errMessage = intl.formatMessage({
279
- id: "uploader.fileUploadExceeded",
280
- defaultMessage: "The number of selected files exceeds the limit.",
281
- });
282
- this.notif = { id: 2, message: errMessage, isError: true };
283
- if (this.liveRegion) {
284
- this.liveRegion.innerHTML = errMessage;
285
- }
286
- }
287
- else {
288
- files &&
289
- files.map((file) => {
290
- if (!hasValidType(file, this.fileTypes)) {
291
- const error = {
292
- name: file.name,
293
- message: intl.formatMessage({
294
- id: "uploader.invalidFileType",
295
- defaultMessage: "The file type is invalid. Accepted types: {validTypes}",
296
- }, { validTypes }),
297
- };
298
- this.errorList.push(error);
299
- }
300
- else if (file.size === 0) {
301
- const error = {
302
- name: file.name,
303
- message: intl.formatMessage({
304
- id: "uploader.zeroFileSize",
305
- defaultMessage: "The file must be more than 0 bytes",
306
- description: "Error message when user attempts to upload a file of no size",
307
- }),
308
- };
309
- this.errorList.push(error);
310
- }
311
- else if (!this.isValidSize(file.size)) {
312
- const error = {
313
- name: file.name,
314
- message: intl.formatMessage({
315
- id: "uploader.fileTooLarge",
316
- defaultMessage: "The selected file is too large. Maximum file size is {size}Mb",
317
- }, { size: this.maxSize }),
318
- };
319
- this.errorList.push(error);
320
- }
321
- else if (this.isDuplicate(file.name)) {
322
- const error = {
323
- name: file.name,
324
- message: intl.formatMessage({
325
- id: "uploader.duplicateName",
326
- defaultMessage: "A file with this name already exists.",
327
- }),
328
- };
329
- this.errorList.push(error);
330
- }
331
- else {
332
- this.filesToUpload.push(file);
333
- }
334
- });
335
- if (this.filesToUpload.length > 0) {
336
- this.numFilesInProgress = this.filesToUpload.length;
337
- this.wmUploaderFilesSelected.emit(this.filesToUpload);
338
- this.wmFilesSelected.emit(this.filesToUpload); // deprecated
339
- }
340
- }
341
- ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
342
- }
343
- previewFile(file) {
344
- this.clearErrors();
345
- this.wmUploaderPreviewFile.emit(file.id);
346
- }
347
- downloadFile(file) {
348
- this.clearErrors();
349
- this.wmUploaderDownloadFile.emit(file.id);
350
- this.wmDownloadFile.emit(file.id); // deprecated
351
- }
352
- deleteFile(file) {
353
- this.clearErrors();
354
- forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
355
- this.wmUploaderDeleteFile.emit(file.id);
356
- this.wmDeleteFile.emit(file.id); // deprecated
357
- }
358
- componentWillLoad() {
359
- if (!this.buttonText) {
360
- throw new Error("wm-uploader: button-text is a required prop");
361
- }
362
- if (this.type) {
363
- console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
364
- }
365
- if (this.tempUploaderType === "1" && !this.emptyStateText) {
366
- throw new Error("wm-uploader: empty-state-text is a required prop");
367
- }
368
- // rerender on resize in case layout needs to change
369
- const resizeObserver = new ResizeObserver(() => this.debouncedResize());
370
- resizeObserver.observe(this.el);
371
- this.setMaxSize();
372
- this.parseFiles();
373
- this.clearErrors();
374
- this.parseRejectedFiles();
375
- }
376
- componentDidLoad() {
377
- if (document.body.classList.contains("wmcl-user-is-tabbing")) {
378
- this.toggleTabbingOn();
379
- }
380
- }
381
- showTooltip(anchorEl, tooltipText) {
382
- this.tooltipEl.textContent = tooltipText;
383
- this.positionTooltip("bottom", anchorEl, this.tooltipEl);
384
- this.tooltipEl.style.transitionDelay = "500ms";
385
- this.tooltipEl.style.opacity = "1";
386
- }
387
- hideTooltip() {
388
- this.tooltipEl.style.transitionDelay = "0s";
389
- this.tooltipEl.style.opacity = "0";
390
- }
391
- positionTooltip(tPos, anchorEl, tooltipEl) {
392
- const tooltipHeight = tooltipEl.getBoundingClientRect().height;
393
- const tooltipWidth = tooltipEl.getBoundingClientRect().width;
394
- // to get the center positions, calculate the difference between the button width and the tooltip width
395
- const verticalDiff = (anchorEl.getBoundingClientRect().height - tooltipHeight) / 2;
396
- const horizontalDiff = (anchorEl.getBoundingClientRect().width - tooltipWidth) / 2;
397
- // the naming convention defaults to center in the absence of a value
398
- // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
399
- // therefore we first set to center and adjust accordingly
400
- let verticalPos = anchorEl.getBoundingClientRect().top + verticalDiff;
401
- let horizontalPos = anchorEl.getBoundingClientRect().left + horizontalDiff;
402
- if (tPos.includes("top")) {
403
- verticalPos = anchorEl.getBoundingClientRect().top - tooltipHeight - 8;
404
- }
405
- if (tPos.includes("bottom")) {
406
- verticalPos = anchorEl.getBoundingClientRect().bottom + 8;
407
- }
408
- if (tPos.includes("left")) {
409
- horizontalPos = anchorEl.getBoundingClientRect().left - tooltipWidth - 8;
410
- }
411
- if (tPos.includes("right")) {
412
- horizontalPos = anchorEl.getBoundingClientRect().right + 8;
413
- }
414
- // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
415
- // this only occurs when the tooltip is overflowing to the left and is positioned top or bottom
416
- // (button placed too far left, or screen size under 268px)
417
- horizontalPos = Math.max(horizontalPos, 24);
418
- tooltipEl.style.top = (verticalPos / 16).toString() + "rem";
419
- tooltipEl.style.left = (horizontalPos / 16).toString() + "rem";
420
- }
421
- uploadButtonOnClick(ev) {
422
- if (this.isDisabled) {
423
- // this is a temporary fix.
424
- // we need the disabled button to be programmatically focusable
425
- // to allow return focus after closing the browser file panel
426
- // since it's focusable the button should respond when activated
427
- // it looks disabled, and announces the reason why the action cannot
428
- // be taken when activated.
429
- // this is not pretty duplicating a intl message + the logic of isDisabled,
430
- // but not worth a bigger refactor since this is only until we get the UX for disabled elements and refactor all interactive els.
431
- ev.preventDefault();
432
- if (this.liveRegion) {
433
- let errMsg = "";
434
- if (this.numFilesInProgress > 0) {
435
- errMsg = intl.formatMessage({
436
- id: "uploader.waitToUpload",
437
- defaultMessage: "Please wait for current upload to complete before uploading new files.",
438
- description: "Message for screen reader users",
439
- });
440
- }
441
- else if (this.fileLimitReached) {
442
- errMsg = this.fileUploadLimitMessage;
443
- }
444
- if (errMsg) {
445
- // clear and set again to re-announce if button is clicked several times
446
- // (can't be done inside setTimeout because of scope, hence the promise)
447
- this.liveRegion.innerHTML = "";
448
- new Promise((resolve) => {
449
- setTimeout(() => {
450
- resolve("");
451
- }, 500);
452
- }).then(() => (this.liveRegion.innerHTML = errMsg));
453
- }
454
- }
455
- }
456
- else {
457
- this.clearErrors();
458
- }
459
- }
460
- renderUploadSvg() {
461
- return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" },
462
- 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" })));
463
- }
464
- renderIcon() {
465
- // mdi attachment icon (paper clip) is horizontal but we want it vertical
466
- const rotate = this.icon && this.icon === "f066";
467
- return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
468
- }
469
- renderInfo() {
470
- return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
471
- }
472
- renderNotif() {
473
- return this.notif ? h("div", { class: `notif ${this.notif.isError ? "error" : ""}` }, this.notif.message) : "";
474
- }
475
- renderUploadButton(classes) {
476
- return (h("div", { class: "info-wrapper" },
477
- h("input", { name: this.inputId, id: this.inputId, class: "sr-only", "aria-describedby": "file-count max-size accepted-types", type: "file", multiple: true, onClick: (ev) => this.uploadButtonOnClick(ev), onChange: (ev) => this.handleFiles(ev) }),
478
- h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` },
479
- this.renderIcon(),
480
- this.buttonText),
481
- this.renderInfo()));
482
- }
483
- renderEmptyState() {
484
- return (h("div", { class: "empty-block" },
485
- this.renderUploadSvg(),
486
- h("div", { class: `empty-message` }, this.emptyStateText),
487
- this.renderUploadButton("-primary empty-button"),
488
- this.renderNotif()));
489
- }
490
- renderFileName(filename, isUploading) {
491
- return (h("div", { class: "left-group" },
492
- h("div", { class: "name-wrapper" },
493
- h("span", { class: "filename", "data-filename": filename, onMouseEnter: (ev) => this.handleFilenameMouseEnter(ev, filename), onMouseLeave: () => this.hideTooltip() }),
494
- isUploading && h("span", { class: "sr-only" }, "uploading"),
495
- h("div", { class: "sr-only ch-measure" }))));
496
- }
497
- renderErrorList() {
498
- if (!!this.errorList.length) {
499
- if (this.liveRegion) {
500
- let srMessage = this.errorList.reduce(function (acc, err) {
501
- return acc + `${err.name}: ${err.message} `;
502
- }, "");
503
- this.liveRegion.innerHTML = srMessage;
504
- }
505
- return (h("ul", { class: "error-list" }, this.errorList.map((err) => {
506
- const clearButtonLabel = intl.formatMessage({
507
- id: "uploader.clearErrorLabel",
508
- defaultMessage: "Clear {fileName} error",
509
- description: "Label for a button used to clear an error, including filename",
510
- }, { fileName: err.name });
511
- return (h("li", null,
512
- h("div", { class: "file --error" },
513
- this.renderFileName(err.name, false),
514
- h("wm-button", { "permanently-delete": true, "button-type": "textonly", "label-for-identical-buttons": clearButtonLabel, onClick: () => {
515
- this.clearError(err.name);
516
- this.uploadButtonEl.focus();
517
- } }, this.clearButtonText)),
518
- h("div", { class: "error-message" }, err.message)));
519
- })));
520
- }
521
- }
522
- renderFileInProgress(item) {
523
- const filename = item.type ? `${item.name}.${item.type}` : item.name;
524
- return (h("li", null,
525
- h("div", { class: "file --progress" },
526
- h("div", { class: "progress", style: {
527
- background: `linear-gradient(to right, rgba(67, 126, 142, 1) ${item.progress}%, transparent ${item.progress}%)`,
528
- } }),
529
- this.renderFileName(filename, this.isItemUploading(item)))));
530
- }
531
- renderFile(item) {
532
- const filename = item.type ? `${item.name}.${item.type}` : item.name;
533
- const hasSingleFileAction = item.fileActions && item.fileActions.split(" ").length === 1;
534
- const showActionMenu = !this.tempUploaderType && this.isCondensed && !hasSingleFileAction;
535
- const showFileInfo = !this.tempUploaderType && !this.isCondensed;
536
- // @ts-ignore it's possible progress is passed in as a string, so we need to check for "100" as well
537
- const showCheckmark = !this.tempUploaderType && (item.progress === 100 || item.progress === "100");
538
- return (h("li", { class: `${this.isCondensed ? "condensed" : ""} ${showCheckmark ? "checked" : ""}` },
539
- h("div", { class: "file --saved" },
540
- this.renderFileName(filename, this.isItemUploading(item)),
541
- h("div", { class: "right-group" },
542
- showFileInfo && this.renderFileInfo(item),
543
- showActionMenu ? this.renderActionMenu(item) : this.renderFileActions(item)))));
544
- }
545
- handleFilenameMouseEnter(ev, filename) {
546
- // only show tooltip if file name is being truncated (has ellipses)
547
- if (ev.target.textContent.includes("...")) {
548
- this.showTooltip(ev.target, filename);
549
- }
550
- }
551
- componentDidRender() {
552
- const files = this.el.shadowRoot.querySelectorAll(".file");
553
- files.forEach((file) => this.truncateFileName(file));
554
- }
555
- truncateFileName(file) {
556
- const leftGroup = file.querySelector(".left-group");
557
- const leftBoundary = leftGroup.getBoundingClientRect().left;
558
- const rightGroup = file.querySelector(".right-group");
559
- const rightBoundary = rightGroup
560
- ? rightGroup.getBoundingClientRect().left
561
- : file.getBoundingClientRect().right - 20;
562
- const filenameEl = file.querySelector(".filename");
563
- const availableSpace = rightBoundary - leftBoundary;
564
- let filename = filenameEl.dataset.filename;
565
- const canFitText = availableSpace > filename.length * this.chMeasure;
566
- if (!canFitText) {
567
- const extension = filename.slice(filename.lastIndexOf("."));
568
- const numFittingCharacters = Math.floor(availableSpace / this.chMeasure);
569
- // three ellipses, three constant characters, extension
570
- const postEllipsesLength = 3 + 3 + extension.length;
571
- let preEllipsesLength = Math.max(2, numFittingCharacters - postEllipsesLength);
572
- const preEllipsesText = filename.slice(0, preEllipsesLength);
573
- const postEllipsesText = filename.slice(filename.indexOf(extension) - 3, filename.length);
574
- filename = `${preEllipsesText.trim()}...${postEllipsesText.trim()}`;
575
- }
576
- filenameEl.textContent = filename;
577
- }
578
- renderFileActions(item) {
579
- const defaultFileActions = "download delete";
580
- const availableActions = item.fileActions || defaultFileActions;
581
- const previewButton = (h("wm-button", { class: "preview-button", "button-type": "icononly", tooltip: "Preview", "tooltip-position": "bottom", "label-for-identical-buttons": `preview ${item.name}`, icon: "f208", onClick: () => this.previewFile(item) }));
582
- const downloadButton = (h("wm-button", { class: "download-button", "button-type": "icononly", tooltip: "Download", "tooltip-position": "bottom", "label-for-identical-buttons": `download ${item.name}`, icon: "f1da", onClick: () => this.downloadFile(item) }));
583
- const deleteButton = (h("wm-button", { class: "delete-button", "button-type": "icononly", tooltip: "Delete", "tooltip-position": "bottom", "label-for-identical-buttons": `delete ${item.name}`, icon: "f1c0", onClick: () => this.deleteFile(item) }));
584
- return (h("div", { class: "file-controls" },
585
- availableActions.includes("preview") && previewButton,
586
- availableActions.includes("download") && downloadButton,
587
- availableActions.includes("delete") && deleteButton));
588
- }
589
- renderActionMenu(item) {
590
- const defaultFileActions = "download delete";
591
- const availableActions = item.fileActions || defaultFileActions;
592
- const previewItem = (h("wm-menuitem", { icon: "f208", onClick: () => this.previewFile(item) }, this.previewActionMessage));
593
- const downloadItem = (h("wm-menuitem", { icon: "f1da", onClick: () => this.downloadFile(item) }, this.downloadActionMessage));
594
- const deleteItem = (h("wm-menuitem", { icon: "f1c0", onClick: () => this.deleteFile(item) }, this.deleteActionMessage));
595
- return (h("wm-action-menu", { "action-menu-type": "icon", tooltip: this.actionMenuLabel, "tooltip-position": "bottom", "label-for-identical-buttons": `${item.name} ${this.actionMenuLabel}` },
596
- availableActions.includes("preview") && previewItem,
597
- availableActions.includes("download") && downloadItem,
598
- availableActions.includes("delete") && deleteItem));
599
- }
600
- renderFileInfo(item) {
601
- let elementToRender = undefined;
602
- if (this.showInfo === "time") {
603
- const uploadDate = new Date(Date.parse(item.lastUpdated));
604
- const day = uploadDate.getDate();
605
- const month = uploadDate.getMonth() + 1;
606
- const year = uploadDate.getFullYear();
607
- const time = uploadDate.toLocaleTimeString("en-us", { hour: "numeric", minute: "2-digit" });
608
- const formattedDate = `${month}/${day}/${year} ${time}`;
609
- elementToRender = h("div", { class: "file-info" }, formattedDate);
610
- }
611
- else if (this.showInfo === "size" && item.size) {
612
- const convertedSize = this.convertBytes(item.size);
613
- elementToRender = h("div", { class: "file-info" }, `${convertedSize.size.toFixed(0)} ${convertedSize.unit}`);
614
- }
615
- return elementToRender;
616
- }
617
- renderFileList() {
618
- if (this.fileList) {
619
- this.sortBy === "name"
620
- ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
621
- : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
622
- return (h("div", null,
623
- h("ul", { class: "inprogress-list" }, this.fileList.filter((item) => this.isItemUploading(item)).map((item) => this.renderFileInProgress(item))),
624
- h("ul", { class: "file-list" }, this.fileList.filter((item) => !this.isItemUploading(item)).map((item) => this.renderFile(item)))));
625
- }
626
- }
627
- legacyRenderHeader() {
628
- return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
629
- h("div", { class: "slot-wrapper" },
630
- h("slot", null),
631
- h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
632
- this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`),
633
- this.renderNotif()))));
634
- }
635
- renderHeader() {
636
- return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
637
- h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
638
- this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`),
639
- this.renderRequirements()),
640
- h("div", { id: "accepted-types", class: "accepted-types" }, this.acceptedFileTypesMessage),
641
- this.renderNotif()));
642
- }
643
- renderRequirements() {
644
- return (h("div", { class: "requirements" },
645
- this.maxFiles && h("span", { id: "file-count" }, this.fileCountMessage),
646
- this.maxSize !== this.defaultMaxSize && h("span", { id: "max-size" }, this.maxSizeMessage)));
647
- }
648
- renderFooter() {
649
- return (h("div", { class: "footer" },
650
- h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
651
- h("div", { class: "filecount-wrapper" },
652
- h("div", { class: "filecount" }, intl.formatMessage({
653
- id: "uploader.filesAdded",
654
- defaultMessage: "{numFiles, plural, one {1 file added} other {# files added}}",
655
- }, { numFiles: this.fileList.length })),
656
- this.renderUploadButton(`-primary ${this.isDisabled ? "disabled" : ""}`)),
657
- this.renderNotif())));
658
- }
659
- renderWithItems() {
660
- // it's possible progress is passed in as a string, so we need to check for "100" as well
661
- const hasNewlyUploadedFiles = this.fileList.filter((file) => file.progress === (typeof file.progress === "number" ? 100 : "100")).length > 0;
662
- return (h("div", null,
663
- !this.tempUploaderType && this.renderHeader(),
664
- this.tempUploaderType === "2" && this.legacyRenderHeader(),
665
- h("div", { class: `list-container type${this.tempUploaderType} ${!this.tempUploaderType && hasNewlyUploadedFiles ? "checkmark-spacer" : ""}` },
666
- this.renderErrorList(),
667
- this.renderFileList()),
668
- this.tempUploaderType === "1" && this.renderFooter()));
669
- }
670
- render() {
671
- return (h(Host, null,
672
- this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(),
673
- 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
674
- , "aria-atomic": "true" })));
675
- }
676
- static get is() { return "wm-uploader"; }
677
- static get encapsulation() { return "shadow"; }
678
- static get originalStyleUrls() { return {
679
- "$": ["wm-uploader.scss"]
680
- }; }
681
- static get styleUrls() { return {
682
- "$": ["wm-uploader.css"]
683
- }; }
684
- static get properties() { return {
685
- "uploaderType": {
686
- "type": "string",
687
- "mutable": true,
688
- "complexType": {
689
- "original": "\"1\" | \"2\"",
690
- "resolved": "\"1\" | \"2\" | undefined",
691
- "references": {}
692
- },
693
- "required": false,
694
- "optional": true,
695
- "docs": {
696
- "tags": [],
697
- "text": ""
698
- },
699
- "attribute": "uploader-type",
700
- "reflect": false
701
- },
702
- "type": {
703
- "type": "string",
704
- "mutable": false,
705
- "complexType": {
706
- "original": "\"1\" | \"2\"",
707
- "resolved": "\"1\" | \"2\" | undefined",
708
- "references": {}
709
- },
710
- "required": false,
711
- "optional": true,
712
- "docs": {
713
- "tags": [],
714
- "text": ""
715
- },
716
- "attribute": "type",
717
- "reflect": false
718
- },
719
- "buttonText": {
720
- "type": "string",
721
- "mutable": false,
722
- "complexType": {
723
- "original": "string",
724
- "resolved": "string",
725
- "references": {}
726
- },
727
- "required": true,
728
- "optional": false,
729
- "docs": {
730
- "tags": [],
731
- "text": ""
732
- },
733
- "attribute": "button-text",
734
- "reflect": false
735
- },
736
- "info": {
737
- "type": "string",
738
- "mutable": false,
739
- "complexType": {
740
- "original": "string",
741
- "resolved": "string | undefined",
742
- "references": {}
743
- },
744
- "required": false,
745
- "optional": true,
746
- "docs": {
747
- "tags": [],
748
- "text": ""
749
- },
750
- "attribute": "info",
751
- "reflect": false
752
- },
753
- "emptyStateText": {
754
- "type": "string",
755
- "mutable": false,
756
- "complexType": {
757
- "original": "string",
758
- "resolved": "string",
759
- "references": {}
760
- },
761
- "required": true,
762
- "optional": false,
763
- "docs": {
764
- "tags": [],
765
- "text": ""
766
- },
767
- "attribute": "empty-state-text",
768
- "reflect": false
769
- },
770
- "icon": {
771
- "type": "string",
772
- "mutable": false,
773
- "complexType": {
774
- "original": "string",
775
- "resolved": "string",
776
- "references": {}
777
- },
778
- "required": true,
779
- "optional": false,
780
- "docs": {
781
- "tags": [],
782
- "text": ""
783
- },
784
- "attribute": "icon",
785
- "reflect": false
786
- },
787
- "fileTypes": {
788
- "type": "string",
789
- "mutable": false,
790
- "complexType": {
791
- "original": "string",
792
- "resolved": "string",
793
- "references": {}
794
- },
795
- "required": false,
796
- "optional": false,
797
- "docs": {
798
- "tags": [],
799
- "text": ""
800
- },
801
- "attribute": "file-types",
802
- "reflect": false,
803
- "defaultValue": "\"pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv\""
804
- },
805
- "maxSize": {
806
- "type": "number",
807
- "mutable": true,
808
- "complexType": {
809
- "original": "number",
810
- "resolved": "number",
811
- "references": {}
812
- },
813
- "required": false,
814
- "optional": false,
815
- "docs": {
816
- "tags": [],
817
- "text": ""
818
- },
819
- "attribute": "max-size",
820
- "reflect": false,
821
- "defaultValue": "this.defaultMaxSize"
822
- },
823
- "maxFiles": {
824
- "type": "number",
825
- "mutable": false,
826
- "complexType": {
827
- "original": "number",
828
- "resolved": "number | undefined",
829
- "references": {}
830
- },
831
- "required": false,
832
- "optional": true,
833
- "docs": {
834
- "tags": [],
835
- "text": ""
836
- },
837
- "attribute": "max-files",
838
- "reflect": false
839
- },
840
- "sortBy": {
841
- "type": "string",
842
- "mutable": false,
843
- "complexType": {
844
- "original": "\"name\" | \"date\"",
845
- "resolved": "\"date\" | \"name\"",
846
- "references": {}
847
- },
848
- "required": false,
849
- "optional": false,
850
- "docs": {
851
- "tags": [],
852
- "text": ""
853
- },
854
- "attribute": "sort-by",
855
- "reflect": false,
856
- "defaultValue": "\"date\""
857
- },
858
- "showInfo": {
859
- "type": "string",
860
- "mutable": false,
861
- "complexType": {
862
- "original": "\"time\" | \"size\" | \"none\"",
863
- "resolved": "\"none\" | \"size\" | \"time\"",
864
- "references": {}
865
- },
866
- "required": false,
867
- "optional": false,
868
- "docs": {
869
- "tags": [],
870
- "text": ""
871
- },
872
- "attribute": "show-info",
873
- "reflect": false,
874
- "defaultValue": "\"time\""
875
- },
876
- "files": {
877
- "type": "string",
878
- "mutable": false,
879
- "complexType": {
880
- "original": "string",
881
- "resolved": "string | undefined",
882
- "references": {}
883
- },
884
- "required": false,
885
- "optional": true,
886
- "docs": {
887
- "tags": [],
888
- "text": ""
889
- },
890
- "attribute": "files",
891
- "reflect": false
892
- },
893
- "filesToUpload": {
894
- "type": "unknown",
895
- "mutable": false,
896
- "complexType": {
897
- "original": "File[]",
898
- "resolved": "File[]",
899
- "references": {
900
- "File": {
901
- "location": "global"
902
- }
903
- }
904
- },
905
- "required": false,
906
- "optional": false,
907
- "docs": {
908
- "tags": [],
909
- "text": ""
910
- },
911
- "defaultValue": "[]"
912
- },
913
- "rejectedFiles": {
914
- "type": "string",
915
- "mutable": false,
916
- "complexType": {
917
- "original": "string",
918
- "resolved": "string | undefined",
919
- "references": {}
920
- },
921
- "required": false,
922
- "optional": true,
923
- "docs": {
924
- "tags": [],
925
- "text": ""
926
- },
927
- "attribute": "rejected-files",
928
- "reflect": false
929
- }
930
- }; }
931
- static get states() { return {
932
- "isTabbing": {},
933
- "errorList": {},
934
- "notif": {},
935
- "numFilesInProgress": {},
936
- "isCondensed": {}
937
- }; }
938
- static get events() { return [{
939
- "method": "wmUploaderFilesSelected",
940
- "name": "wmUploaderFilesSelected",
941
- "bubbles": true,
942
- "cancelable": true,
943
- "composed": true,
944
- "docs": {
945
- "tags": [],
946
- "text": ""
947
- },
948
- "complexType": {
949
- "original": "any",
950
- "resolved": "any",
951
- "references": {}
952
- }
953
- }, {
954
- "method": "wmFilesSelected",
955
- "name": "wmFilesSelected",
956
- "bubbles": true,
957
- "cancelable": true,
958
- "composed": true,
959
- "docs": {
960
- "tags": [],
961
- "text": ""
962
- },
963
- "complexType": {
964
- "original": "any",
965
- "resolved": "any",
966
- "references": {}
967
- }
968
- }, {
969
- "method": "wmUploaderDeleteFile",
970
- "name": "wmUploaderDeleteFile",
971
- "bubbles": true,
972
- "cancelable": true,
973
- "composed": true,
974
- "docs": {
975
- "tags": [],
976
- "text": ""
977
- },
978
- "complexType": {
979
- "original": "any",
980
- "resolved": "any",
981
- "references": {}
982
- }
983
- }, {
984
- "method": "wmDeleteFile",
985
- "name": "wmDeleteFile",
986
- "bubbles": true,
987
- "cancelable": true,
988
- "composed": true,
989
- "docs": {
990
- "tags": [],
991
- "text": ""
992
- },
993
- "complexType": {
994
- "original": "any",
995
- "resolved": "any",
996
- "references": {}
997
- }
998
- }, {
999
- "method": "wmUploaderDownloadFile",
1000
- "name": "wmUploaderDownloadFile",
1001
- "bubbles": true,
1002
- "cancelable": true,
1003
- "composed": true,
1004
- "docs": {
1005
- "tags": [],
1006
- "text": ""
1007
- },
1008
- "complexType": {
1009
- "original": "any",
1010
- "resolved": "any",
1011
- "references": {}
1012
- }
1013
- }, {
1014
- "method": "wmDownloadFile",
1015
- "name": "wmDownloadFile",
1016
- "bubbles": true,
1017
- "cancelable": true,
1018
- "composed": true,
1019
- "docs": {
1020
- "tags": [],
1021
- "text": ""
1022
- },
1023
- "complexType": {
1024
- "original": "any",
1025
- "resolved": "any",
1026
- "references": {}
1027
- }
1028
- }, {
1029
- "method": "wmUploaderPreviewFile",
1030
- "name": "wmUploaderPreviewFile",
1031
- "bubbles": true,
1032
- "cancelable": true,
1033
- "composed": true,
1034
- "docs": {
1035
- "tags": [],
1036
- "text": ""
1037
- },
1038
- "complexType": {
1039
- "original": "any",
1040
- "resolved": "any",
1041
- "references": {}
1042
- }
1043
- }]; }
1044
- static get elementRef() { return "el"; }
1045
- static get watchers() { return [{
1046
- "propName": "files",
1047
- "methodName": "parseFiles"
1048
- }, {
1049
- "propName": "rejectedFiles",
1050
- "methodName": "parseRejectedFiles"
1051
- }, {
1052
- "propName": "maxSize",
1053
- "methodName": "setMaxSize"
1054
- }, {
1055
- "propName": "numFilesInProgress",
1056
- "methodName": "uploadNotifications"
1057
- }]; }
1058
- static get listeners() { return [{
1059
- "name": "wmUserIsTabbing",
1060
- "method": "toggleTabbingOn",
1061
- "target": "window",
1062
- "capture": false,
1063
- "passive": false
1064
- }, {
1065
- "name": "wmUserIsNotTabbing",
1066
- "method": "toggleTabbingOff",
1067
- "target": "window",
1068
- "capture": false,
1069
- "passive": false
1070
- }, {
1071
- "name": "wmUploadProgress",
1072
- "method": "handleUploadProgress",
1073
- "target": undefined,
1074
- "capture": false,
1075
- "passive": false
1076
- }]; }
1077
- }
1
+ import { Component, Element, Event, h, Host, Prop, State, Listen, Watch } from "@stencil/core";
2
+ import { forceUpdate } from "@stencil/core";
3
+ import { debounce, generateId, hasValidType, intl } from "../../global/functions";
4
+ export class Uploader {
5
+ constructor() {
6
+ this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
7
+ this.sortBy = "date"; // name is descending (a -> z), date is ascending (earlier -> later)
8
+ this.showInfo = "time";
9
+ this.fileList = []; // the string above transformed into the actual array
10
+ this.filesToUpload = []; // input.files that passed validation
11
+ this.isTabbing = false;
12
+ this.errorList = []; // for errors on a particular file
13
+ this.isCondensed = false;
14
+ this.inputId = generateId();
15
+ this.debouncedResize = debounce(() => {
16
+ this.isCondensed = this.el.clientWidth < 500;
17
+ // rerender to show filename truncation changes
18
+ forceUpdate(this.el);
19
+ }, 50);
20
+ }
21
+ get tooltipEl() {
22
+ return document.getElementById("wm-tooltip");
23
+ }
24
+ get uploadButtonEl() {
25
+ return this.el.shadowRoot.querySelector(`#${this.inputId}`);
26
+ }
27
+ get tempUploaderType() {
28
+ // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
29
+ return this.type || this.uploaderType;
30
+ }
31
+ get effectiveMaxSize() {
32
+ const defaultMaxSize = 100;
33
+ // maxsize cannot be set to over 100Mb
34
+ const maxSizeLimit = 100;
35
+ return this.maxSize ? Math.min(this.maxSize, maxSizeLimit) : defaultMaxSize;
36
+ }
37
+ get chMeasure() {
38
+ return this.el.shadowRoot.querySelector(".ch-measure").clientWidth;
39
+ }
40
+ get fileLimitReached() {
41
+ return this.maxFiles && this.fileList.length >= this.maxFiles;
42
+ }
43
+ get fileUploadLimitMessage() {
44
+ return intl.formatMessage({
45
+ id: "uploader.fileUploadLimit",
46
+ defaultMessage: "Upload unsuccessful because file selection would exceed the maximum number of files",
47
+ description: "Message displayed when trying to upload too many files",
48
+ });
49
+ }
50
+ get fileCountMessage() {
51
+ return intl.formatMessage({
52
+ id: "uploader.fileCount",
53
+ defaultMessage: "{x} of {y} Files",
54
+ description: "A count of the number of files currently uploaded",
55
+ }, { x: this.fileList.length, y: this.maxFiles });
56
+ }
57
+ get maxSizeMessage() {
58
+ return intl.formatMessage({
59
+ id: "uploader.maxSize",
60
+ defaultMessage: "Maximum file size {maxSize}MB",
61
+ description: "An indicator of the maximum file size the uploader allows",
62
+ }, {
63
+ maxSize: this.effectiveMaxSize,
64
+ });
65
+ }
66
+ get acceptedFileTypesMessage() {
67
+ const validTypes = "." + this.fileTypes.split(" ").join(", .");
68
+ return intl.formatMessage({
69
+ id: "uploader.acceptedFileTypes",
70
+ defaultMessage: "Accepted file {amount, plural, =1 {type} other {types}}: {fileTypes}",
71
+ }, {
72
+ fileTypes: validTypes,
73
+ amount: this.fileTypes.split(" ").length,
74
+ });
75
+ }
76
+ get previewActionMessage() {
77
+ return intl.formatMessage({
78
+ id: "uploader.previewAction",
79
+ defaultMessage: "Preview File",
80
+ description: "Label of a button that triggers a file to be previewed",
81
+ });
82
+ }
83
+ get downloadActionMessage() {
84
+ return intl.formatMessage({
85
+ id: "uploader.downloadAction",
86
+ defaultMessage: "Download File",
87
+ description: "Label of a button that triggers a file to be downloaded",
88
+ });
89
+ }
90
+ get deleteActionMessage() {
91
+ return intl.formatMessage({
92
+ id: "uploader.deleteAction",
93
+ defaultMessage: "Delete File",
94
+ description: "Label of a button that triggers a file to be delete",
95
+ });
96
+ }
97
+ get clearButtonText() {
98
+ return intl.formatMessage({
99
+ id: "uploader.clearErrorText",
100
+ defaultMessage: "Clear",
101
+ description: "Text for a button used to clear an error",
102
+ });
103
+ }
104
+ get actionMenuLabel() {
105
+ return intl.formatMessage({
106
+ id: "uploader.actionMenuLabel",
107
+ defaultMessage: "Actions",
108
+ description: "Label of a button that opens a menu of file actions",
109
+ });
110
+ }
111
+ toggleTabbingOn() {
112
+ this.isTabbing = true;
113
+ }
114
+ toggleTabbingOff() {
115
+ this.isTabbing = false;
116
+ }
117
+ handleUploadProgress(ev) {
118
+ this.fileList.map((i) => {
119
+ if (i.id === ev.detail.id) {
120
+ i.progress = ev.detail.progress;
121
+ forceUpdate(this.el);
122
+ }
123
+ });
124
+ if (ev.detail.progress === 100) {
125
+ // inProgressList is not a perfect reflection of how many files are uploading
126
+ // because even after progress reached 100% the item should remain in the array
127
+ // (should only be removed once it appears in fileList)
128
+ this.numFilesInProgress -= 1;
129
+ }
130
+ // aggregate the percentages for SR to announce progress
131
+ if (!this.srProgress && this.numFilesInProgress) {
132
+ const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
133
+ this.srProgress = setInterval(() => {
134
+ const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
135
+ if (this.liveRegion) {
136
+ this.liveRegion.innerHTML = intl.formatMessage({
137
+ id: "uploader.uploadProgress",
138
+ defaultMessage: "Upload progress: {percentage}%",
139
+ }, { percentage: Math.floor(aggregate / total) });
140
+ }
141
+ }, 5000);
142
+ }
143
+ }
144
+ parseFiles() {
145
+ if (!!this.files) {
146
+ if (typeof this.files === "string") {
147
+ const list = JSON.parse(this.files);
148
+ if (typeof list === "object") {
149
+ this.fileList = list;
150
+ }
151
+ else {
152
+ throw new Error("could not parse string passed to files attribute");
153
+ }
154
+ }
155
+ else {
156
+ throw new Error("Attribute 'files' should be a string");
157
+ }
158
+ }
159
+ }
160
+ parseRejectedFiles() {
161
+ if (!!this.rejectedFiles) {
162
+ if (typeof this.files === "string") {
163
+ const list = JSON.parse(this.rejectedFiles);
164
+ if (typeof list === "object") {
165
+ this.errorList = list;
166
+ }
167
+ else {
168
+ throw new Error("could not parse string passed to errors attribute");
169
+ }
170
+ }
171
+ else {
172
+ throw new Error("Attribute 'rejected-files' should be a string");
173
+ }
174
+ }
175
+ }
176
+ uploadNotifications(newNum, oldNum) {
177
+ if (oldNum > 0 && newNum === 0) {
178
+ setTimeout(() => {
179
+ this.notif = null;
180
+ }, 20 * 1000);
181
+ const message = intl.formatMessage({
182
+ id: "uploader.finishedUploading",
183
+ defaultMessage: "Finished uploading",
184
+ });
185
+ this.notif = { id: 5, message, isError: false };
186
+ if (this.liveRegion) {
187
+ this.liveRegion.innerHTML = message;
188
+ }
189
+ this.numFilesInProgress = null;
190
+ clearInterval(this.srProgress);
191
+ forceUpdate(this.el);
192
+ }
193
+ else if (newNum > 0 && newNum != oldNum) {
194
+ const message = intl.formatMessage({
195
+ id: "uploader.filesUploading",
196
+ defaultMessage: "{num, plural, one {1 file uploading} other {# files uploading}}",
197
+ }, { num: newNum });
198
+ this.notif = { id: 6, message, isError: false };
199
+ if (this.liveRegion) {
200
+ this.liveRegion.innerHTML = message;
201
+ }
202
+ forceUpdate(this.el);
203
+ }
204
+ }
205
+ isValidSize(size) {
206
+ return this.convertBytes(size, "MB").size <= this.effectiveMaxSize;
207
+ }
208
+ convertBytes(bytes, unit) {
209
+ // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
210
+ const unitOrder = ["bytes", "KB", "MB", "GB", "TB"];
211
+ let unitIndex = 0;
212
+ let result = typeof bytes === "number" ? bytes : parseInt(bytes);
213
+ if (unit) {
214
+ // convert until result matches desired unit
215
+ while (unitOrder.indexOf(unit) > unitIndex) {
216
+ result /= 1024;
217
+ unitIndex++;
218
+ }
219
+ }
220
+ else {
221
+ // convert until result is appropriate unit (value is under 1000)
222
+ while (result > 1000) {
223
+ result /= 1024;
224
+ unitIndex++;
225
+ }
226
+ }
227
+ return { size: result, unit: unitOrder[unitIndex] };
228
+ }
229
+ isDuplicate(name) {
230
+ return this.fileList.find((f) => {
231
+ const filename = f.type ? f.name + "." + f.type : f.name;
232
+ return filename === name;
233
+ });
234
+ }
235
+ isEmpty() {
236
+ return !this.fileList.length && !this.errorList.length;
237
+ }
238
+ get isDisabled() {
239
+ if (!this.notif) {
240
+ if (this.fileLimitReached) {
241
+ const errMessage = this.fileUploadLimitMessage;
242
+ this.notif = { id: 1, message: errMessage, isError: true };
243
+ if (this.liveRegion) {
244
+ this.liveRegion.innerHTML = errMessage;
245
+ }
246
+ }
247
+ else {
248
+ this.notif = null;
249
+ }
250
+ }
251
+ else if (this.notif.id === 1) {
252
+ // to make sure SR don't repeat the error, don't reset it if it already is showing
253
+ // just dismiss it if isMax is not true anymore
254
+ if (!this.fileLimitReached) {
255
+ this.notif = null;
256
+ }
257
+ // finally do nothing if error 2 is showing (special case when user selects too many files)
258
+ }
259
+ // disable if is the uploader is maxed out or if something is uploading
260
+ return this.fileLimitReached || this.numFilesInProgress > 0;
261
+ }
262
+ isItemUploading(item) {
263
+ return item.hasOwnProperty("progress") && item.progress < 100;
264
+ }
265
+ clearError(filename) {
266
+ this.errorList = this.errorList.filter((error) => error.name != filename);
267
+ this.notif = null;
268
+ }
269
+ clearErrors() {
270
+ this.errorList = [];
271
+ this.notif = null;
272
+ }
273
+ handleFiles(ev) {
274
+ this.filesToUpload = [];
275
+ const validTypes = this.fileTypes.split(" ").join(", ");
276
+ const files = Array.from(ev.target.files);
277
+ if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
278
+ const errMessage = intl.formatMessage({
279
+ id: "uploader.fileUploadExceeded",
280
+ defaultMessage: "The number of selected files exceeds the limit.",
281
+ });
282
+ this.notif = { id: 2, message: errMessage, isError: true };
283
+ if (this.liveRegion) {
284
+ this.liveRegion.innerHTML = errMessage;
285
+ }
286
+ }
287
+ else {
288
+ files &&
289
+ files.map((file) => {
290
+ if (!hasValidType(file, this.fileTypes)) {
291
+ const error = {
292
+ name: file.name,
293
+ message: intl.formatMessage({
294
+ id: "uploader.invalidFileType",
295
+ defaultMessage: "The file type is invalid. Accepted types: {validTypes}",
296
+ }, { validTypes }),
297
+ };
298
+ this.errorList.push(error);
299
+ }
300
+ else if (file.size === 0) {
301
+ const error = {
302
+ name: file.name,
303
+ message: intl.formatMessage({
304
+ id: "uploader.zeroFileSize",
305
+ defaultMessage: "The file must be more than 0 bytes",
306
+ description: "Error message when user attempts to upload a file of no size",
307
+ }),
308
+ };
309
+ this.errorList.push(error);
310
+ }
311
+ else if (!this.isValidSize(file.size)) {
312
+ const error = {
313
+ name: file.name,
314
+ message: intl.formatMessage({
315
+ id: "uploader.fileTooLarge",
316
+ defaultMessage: "The selected file is too large. Maximum file size is {size}Mb",
317
+ }, { size: this.effectiveMaxSize }),
318
+ };
319
+ this.errorList.push(error);
320
+ }
321
+ else if (this.isDuplicate(file.name)) {
322
+ const error = {
323
+ name: file.name,
324
+ message: intl.formatMessage({
325
+ id: "uploader.duplicateName",
326
+ defaultMessage: "A file with this name already exists.",
327
+ }),
328
+ };
329
+ this.errorList.push(error);
330
+ }
331
+ else {
332
+ this.filesToUpload.push(file);
333
+ }
334
+ });
335
+ if (this.filesToUpload.length > 0) {
336
+ this.numFilesInProgress = this.filesToUpload.length;
337
+ this.wmUploaderFilesSelected.emit(this.filesToUpload);
338
+ this.wmFilesSelected.emit(this.filesToUpload); // deprecated
339
+ }
340
+ }
341
+ ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
342
+ }
343
+ previewFile(file) {
344
+ this.clearErrors();
345
+ this.wmUploaderPreviewFile.emit(file.id);
346
+ }
347
+ downloadFile(file) {
348
+ this.clearErrors();
349
+ this.wmUploaderDownloadFile.emit(file.id);
350
+ this.wmDownloadFile.emit(file.id); // deprecated
351
+ }
352
+ deleteFile(file) {
353
+ this.clearErrors();
354
+ forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
355
+ this.wmUploaderDeleteFile.emit(file.id);
356
+ this.wmDeleteFile.emit(file.id); // deprecated
357
+ }
358
+ componentWillLoad() {
359
+ if (!this.buttonText) {
360
+ throw new Error("wm-uploader: button-text is a required prop");
361
+ }
362
+ if (this.type) {
363
+ console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
364
+ }
365
+ if (this.tempUploaderType === "1" && !this.emptyStateText) {
366
+ throw new Error("wm-uploader: empty-state-text is a required prop");
367
+ }
368
+ // rerender on resize in case layout needs to change
369
+ const resizeObserver = new ResizeObserver(() => this.debouncedResize());
370
+ resizeObserver.observe(this.el);
371
+ this.parseFiles();
372
+ this.clearErrors();
373
+ this.parseRejectedFiles();
374
+ }
375
+ componentDidLoad() {
376
+ if (document.body.classList.contains("wmcl-user-is-tabbing")) {
377
+ this.toggleTabbingOn();
378
+ }
379
+ }
380
+ showTooltip(anchorEl, tooltipText) {
381
+ this.tooltipEl.textContent = tooltipText;
382
+ this.positionTooltip("bottom", anchorEl, this.tooltipEl);
383
+ this.tooltipEl.style.transitionDelay = "500ms";
384
+ this.tooltipEl.style.opacity = "1";
385
+ }
386
+ hideTooltip() {
387
+ this.tooltipEl.style.transitionDelay = "0s";
388
+ this.tooltipEl.style.opacity = "0";
389
+ }
390
+ positionTooltip(tPos, anchorEl, tooltipEl) {
391
+ const tooltipHeight = tooltipEl.getBoundingClientRect().height;
392
+ const tooltipWidth = tooltipEl.getBoundingClientRect().width;
393
+ // to get the center positions, calculate the difference between the button width and the tooltip width
394
+ const verticalDiff = (anchorEl.getBoundingClientRect().height - tooltipHeight) / 2;
395
+ const horizontalDiff = (anchorEl.getBoundingClientRect().width - tooltipWidth) / 2;
396
+ // the naming convention defaults to center in the absence of a value
397
+ // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
398
+ // therefore we first set to center and adjust accordingly
399
+ let verticalPos = anchorEl.getBoundingClientRect().top + verticalDiff;
400
+ let horizontalPos = anchorEl.getBoundingClientRect().left + horizontalDiff;
401
+ if (tPos.includes("top")) {
402
+ verticalPos = anchorEl.getBoundingClientRect().top - tooltipHeight - 8;
403
+ }
404
+ if (tPos.includes("bottom")) {
405
+ verticalPos = anchorEl.getBoundingClientRect().bottom + 8;
406
+ }
407
+ if (tPos.includes("left")) {
408
+ horizontalPos = anchorEl.getBoundingClientRect().left - tooltipWidth - 8;
409
+ }
410
+ if (tPos.includes("right")) {
411
+ horizontalPos = anchorEl.getBoundingClientRect().right + 8;
412
+ }
413
+ // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
414
+ // this only occurs when the tooltip is overflowing to the left and is positioned top or bottom
415
+ // (button placed too far left, or screen size under 268px)
416
+ horizontalPos = Math.max(horizontalPos, 24);
417
+ tooltipEl.style.top = (verticalPos / 16).toString() + "rem";
418
+ tooltipEl.style.left = (horizontalPos / 16).toString() + "rem";
419
+ }
420
+ uploadButtonOnClick(ev) {
421
+ if (this.isDisabled) {
422
+ // this is a temporary fix.
423
+ // we need the disabled button to be programmatically focusable
424
+ // to allow return focus after closing the browser file panel
425
+ // since it's focusable the button should respond when activated
426
+ // it looks disabled, and announces the reason why the action cannot
427
+ // be taken when activated.
428
+ // this is not pretty duplicating a intl message + the logic of isDisabled,
429
+ // but not worth a bigger refactor since this is only until we get the UX for disabled elements and refactor all interactive els.
430
+ ev.preventDefault();
431
+ if (this.liveRegion) {
432
+ let errMsg = "";
433
+ if (this.numFilesInProgress > 0) {
434
+ errMsg = intl.formatMessage({
435
+ id: "uploader.waitToUpload",
436
+ defaultMessage: "Please wait for current upload to complete before uploading new files.",
437
+ description: "Message for screen reader users",
438
+ });
439
+ }
440
+ else if (this.fileLimitReached) {
441
+ errMsg = this.fileUploadLimitMessage;
442
+ }
443
+ if (errMsg) {
444
+ // clear and set again to re-announce if button is clicked several times
445
+ // (can't be done inside setTimeout because of scope, hence the promise)
446
+ this.liveRegion.innerHTML = "";
447
+ new Promise((resolve) => {
448
+ setTimeout(() => {
449
+ resolve("");
450
+ }, 500);
451
+ }).then(() => (this.liveRegion.innerHTML = errMsg));
452
+ }
453
+ }
454
+ }
455
+ else {
456
+ this.clearErrors();
457
+ }
458
+ }
459
+ renderUploadSvg() {
460
+ return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" },
461
+ 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" })));
462
+ }
463
+ renderIcon() {
464
+ // mdi attachment icon (paper clip) is horizontal but we want it vertical
465
+ const rotate = this.icon && this.icon === "f066";
466
+ return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
467
+ }
468
+ renderInfo() {
469
+ return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
470
+ }
471
+ renderNotif() {
472
+ return this.notif ? h("div", { class: `notif ${this.notif.isError ? "error" : ""}` }, this.notif.message) : "";
473
+ }
474
+ renderUploadButton(classes) {
475
+ return (h("div", { class: "info-wrapper" },
476
+ h("input", { name: this.inputId, id: this.inputId, class: "sr-only", "aria-describedby": "file-count max-size accepted-types", type: "file", multiple: true, onClick: (ev) => this.uploadButtonOnClick(ev), onChange: (ev) => this.handleFiles(ev) }),
477
+ h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` },
478
+ this.renderIcon(),
479
+ this.buttonText),
480
+ this.renderInfo()));
481
+ }
482
+ renderEmptyState() {
483
+ return (h("div", { class: "empty-block" },
484
+ this.renderUploadSvg(),
485
+ h("div", { class: `empty-message` }, this.emptyStateText),
486
+ this.renderUploadButton("-primary empty-button"),
487
+ this.renderNotif()));
488
+ }
489
+ renderFileName(filename, isUploading) {
490
+ return (h("div", { class: "left-group" },
491
+ h("div", { class: "name-wrapper" },
492
+ h("span", { class: "filename", "data-filename": filename, onMouseEnter: (ev) => this.handleFilenameMouseEnter(ev, filename), onMouseLeave: () => this.hideTooltip() }),
493
+ isUploading && h("span", { class: "sr-only" }, "uploading"),
494
+ h("div", { class: "sr-only ch-measure" }))));
495
+ }
496
+ renderErrorList() {
497
+ if (!!this.errorList.length) {
498
+ if (this.liveRegion) {
499
+ let srMessage = this.errorList.reduce(function (acc, err) {
500
+ return acc + `${err.name}: ${err.message} `;
501
+ }, "");
502
+ this.liveRegion.innerHTML = srMessage;
503
+ }
504
+ return (h("ul", { class: "error-list" }, this.errorList.map((err) => {
505
+ const clearButtonLabel = intl.formatMessage({
506
+ id: "uploader.clearErrorLabel",
507
+ defaultMessage: "Clear {fileName} error",
508
+ description: "Label for a button used to clear an error, including filename",
509
+ }, { fileName: err.name });
510
+ return (h("li", null,
511
+ h("div", { class: "file --error" },
512
+ this.renderFileName(err.name, false),
513
+ h("wm-button", { "permanently-delete": true, "button-type": "textonly", "label-for-identical-buttons": clearButtonLabel, onClick: () => {
514
+ this.clearError(err.name);
515
+ this.uploadButtonEl.focus();
516
+ } }, this.clearButtonText)),
517
+ h("div", { class: "error-message" }, err.message)));
518
+ })));
519
+ }
520
+ }
521
+ renderFileInProgress(item) {
522
+ const filename = item.type ? `${item.name}.${item.type}` : item.name;
523
+ return (h("li", null,
524
+ h("div", { class: "file --progress" },
525
+ h("div", { class: "progress", style: {
526
+ background: `linear-gradient(to right, rgba(67, 126, 142, 1) ${item.progress}%, transparent ${item.progress}%)`,
527
+ } }),
528
+ this.renderFileName(filename, this.isItemUploading(item)))));
529
+ }
530
+ renderFile(item) {
531
+ const filename = item.type ? `${item.name}.${item.type}` : item.name;
532
+ const hasSingleFileAction = item.fileActions && item.fileActions.split(" ").length === 1;
533
+ const showActionMenu = !this.tempUploaderType && this.isCondensed && !hasSingleFileAction;
534
+ const showFileInfo = !this.tempUploaderType && !this.isCondensed;
535
+ // @ts-ignore it's possible progress is passed in as a string, so we need to check for "100" as well
536
+ const showCheckmark = !this.tempUploaderType && (item.progress === 100 || item.progress === "100");
537
+ return (h("li", { class: `${this.isCondensed ? "condensed" : ""} ${showCheckmark ? "checked" : ""}` },
538
+ h("div", { class: "file --saved" },
539
+ this.renderFileName(filename, this.isItemUploading(item)),
540
+ h("div", { class: "right-group" },
541
+ showFileInfo && this.renderFileInfo(item),
542
+ showActionMenu ? this.renderActionMenu(item) : this.renderFileActions(item)))));
543
+ }
544
+ handleFilenameMouseEnter(ev, filename) {
545
+ // only show tooltip if file name is being truncated (has ellipses)
546
+ if (ev.target.textContent.includes("...")) {
547
+ this.showTooltip(ev.target, filename);
548
+ }
549
+ }
550
+ componentDidRender() {
551
+ const files = this.el.shadowRoot.querySelectorAll(".file");
552
+ files.forEach((file) => this.truncateFileName(file));
553
+ }
554
+ truncateFileName(file) {
555
+ const leftGroup = file.querySelector(".left-group");
556
+ const leftBoundary = leftGroup.getBoundingClientRect().left;
557
+ const rightGroup = file.querySelector(".right-group");
558
+ const rightBoundary = rightGroup
559
+ ? rightGroup.getBoundingClientRect().left
560
+ : file.getBoundingClientRect().right - 20;
561
+ const filenameEl = file.querySelector(".filename");
562
+ const availableSpace = rightBoundary - leftBoundary;
563
+ let filename = filenameEl.dataset.filename;
564
+ const canFitText = availableSpace > filename.length * this.chMeasure;
565
+ if (!canFitText) {
566
+ const extension = filename.slice(filename.lastIndexOf("."));
567
+ const numFittingCharacters = Math.floor(availableSpace / this.chMeasure);
568
+ // three ellipses, three constant characters, extension
569
+ const postEllipsesLength = 3 + 3 + extension.length;
570
+ let preEllipsesLength = Math.max(2, numFittingCharacters - postEllipsesLength);
571
+ const preEllipsesText = filename.slice(0, preEllipsesLength);
572
+ const postEllipsesText = filename.slice(filename.indexOf(extension) - 3, filename.length);
573
+ filename = `${preEllipsesText.trim()}...${postEllipsesText.trim()}`;
574
+ }
575
+ filenameEl.textContent = filename;
576
+ }
577
+ renderFileActions(item) {
578
+ const defaultFileActions = "download delete";
579
+ const availableActions = item.fileActions || defaultFileActions;
580
+ const previewButton = (h("wm-button", { class: "preview-button", "button-type": "icononly", tooltip: "Preview", "tooltip-position": "bottom", "label-for-identical-buttons": `preview ${item.name}`, icon: "f208", onClick: () => this.previewFile(item) }));
581
+ const downloadButton = (h("wm-button", { class: "download-button", "button-type": "icononly", tooltip: "Download", "tooltip-position": "bottom", "label-for-identical-buttons": `download ${item.name}`, icon: "f1da", onClick: () => this.downloadFile(item) }));
582
+ const deleteButton = (h("wm-button", { class: "delete-button", "button-type": "icononly", tooltip: "Delete", "tooltip-position": "bottom", "label-for-identical-buttons": `delete ${item.name}`, icon: "f1c0", onClick: () => this.deleteFile(item) }));
583
+ return (h("div", { class: "file-controls" },
584
+ availableActions.includes("preview") && previewButton,
585
+ availableActions.includes("download") && downloadButton,
586
+ availableActions.includes("delete") && deleteButton));
587
+ }
588
+ renderActionMenu(item) {
589
+ const defaultFileActions = "download delete";
590
+ const availableActions = item.fileActions || defaultFileActions;
591
+ const previewItem = (h("wm-menuitem", { icon: "f208", onClick: () => this.previewFile(item) }, this.previewActionMessage));
592
+ const downloadItem = (h("wm-menuitem", { icon: "f1da", onClick: () => this.downloadFile(item) }, this.downloadActionMessage));
593
+ const deleteItem = (h("wm-menuitem", { icon: "f1c0", onClick: () => this.deleteFile(item) }, this.deleteActionMessage));
594
+ return (h("wm-action-menu", { "action-menu-type": "icon", tooltip: this.actionMenuLabel, "tooltip-position": "bottom", "label-for-identical-buttons": `${item.name} ${this.actionMenuLabel}` },
595
+ availableActions.includes("preview") && previewItem,
596
+ availableActions.includes("download") && downloadItem,
597
+ availableActions.includes("delete") && deleteItem));
598
+ }
599
+ renderFileInfo(item) {
600
+ let elementToRender = undefined;
601
+ if (this.showInfo === "time") {
602
+ const uploadDate = new Date(Date.parse(item.lastUpdated));
603
+ const day = uploadDate.getDate();
604
+ const month = uploadDate.getMonth() + 1;
605
+ const year = uploadDate.getFullYear();
606
+ const time = uploadDate.toLocaleTimeString("en-us", { hour: "numeric", minute: "2-digit" });
607
+ const formattedDate = `${month}/${day}/${year} ${time}`;
608
+ elementToRender = h("div", { class: "file-info" }, formattedDate);
609
+ }
610
+ else if (this.showInfo === "size" && item.size) {
611
+ const convertedSize = this.convertBytes(item.size);
612
+ elementToRender = h("div", { class: "file-info" }, `${convertedSize.size.toFixed(0)} ${convertedSize.unit}`);
613
+ }
614
+ return elementToRender;
615
+ }
616
+ renderFileList() {
617
+ if (this.fileList) {
618
+ this.sortBy === "name"
619
+ ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
620
+ : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
621
+ return (h("div", null,
622
+ h("ul", { class: "inprogress-list" }, this.fileList.filter((item) => this.isItemUploading(item)).map((item) => this.renderFileInProgress(item))),
623
+ h("ul", { class: "file-list" }, this.fileList.filter((item) => !this.isItemUploading(item)).map((item) => this.renderFile(item)))));
624
+ }
625
+ }
626
+ legacyRenderHeader() {
627
+ return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
628
+ h("div", { class: "slot-wrapper" },
629
+ h("slot", null),
630
+ h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
631
+ this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`),
632
+ this.renderNotif()))));
633
+ }
634
+ renderHeader() {
635
+ return (h("div", { class: `header ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
636
+ h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
637
+ this.renderUploadButton(`-secondary ${this.isDisabled ? "disabled" : ""}`),
638
+ this.renderRequirements()),
639
+ h("div", { id: "accepted-types", class: "accepted-types" }, this.acceptedFileTypesMessage),
640
+ this.renderNotif()));
641
+ }
642
+ renderRequirements() {
643
+ return (h("div", { class: "requirements" },
644
+ this.maxFiles && h("span", { id: "file-count" }, this.fileCountMessage),
645
+ this.maxSize && h("span", { id: "max-size" }, this.maxSizeMessage)));
646
+ }
647
+ renderFooter() {
648
+ return (h("div", { class: "footer" },
649
+ h("div", { class: `notif-wrapper ${this.tempUploaderType ? `type${this.tempUploaderType}` : ""}` },
650
+ h("div", { class: "filecount-wrapper" },
651
+ h("div", { class: "filecount" }, intl.formatMessage({
652
+ id: "uploader.filesAdded",
653
+ defaultMessage: "{numFiles, plural, one {1 file added} other {# files added}}",
654
+ }, { numFiles: this.fileList.length })),
655
+ this.renderUploadButton(`-primary ${this.isDisabled ? "disabled" : ""}`)),
656
+ this.renderNotif())));
657
+ }
658
+ renderWithItems() {
659
+ // it's possible progress is passed in as a string, so we need to check for "100" as well
660
+ const hasNewlyUploadedFiles = this.fileList.filter((file) => file.progress === (typeof file.progress === "number" ? 100 : "100")).length > 0;
661
+ return (h("div", null,
662
+ !this.tempUploaderType && this.renderHeader(),
663
+ this.tempUploaderType === "2" && this.legacyRenderHeader(),
664
+ h("div", { class: `list-container type${this.tempUploaderType} ${!this.tempUploaderType && hasNewlyUploadedFiles ? "checkmark-spacer" : ""}` },
665
+ this.renderErrorList(),
666
+ this.renderFileList()),
667
+ this.tempUploaderType === "1" && this.renderFooter()));
668
+ }
669
+ render() {
670
+ return (h(Host, null,
671
+ this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(),
672
+ 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
673
+ , "aria-atomic": "true" })));
674
+ }
675
+ static get is() { return "wm-uploader"; }
676
+ static get encapsulation() { return "shadow"; }
677
+ static get originalStyleUrls() { return {
678
+ "$": ["wm-uploader.scss"]
679
+ }; }
680
+ static get styleUrls() { return {
681
+ "$": ["wm-uploader.css"]
682
+ }; }
683
+ static get properties() { return {
684
+ "uploaderType": {
685
+ "type": "string",
686
+ "mutable": true,
687
+ "complexType": {
688
+ "original": "\"1\" | \"2\"",
689
+ "resolved": "\"1\" | \"2\" | undefined",
690
+ "references": {}
691
+ },
692
+ "required": false,
693
+ "optional": true,
694
+ "docs": {
695
+ "tags": [],
696
+ "text": ""
697
+ },
698
+ "attribute": "uploader-type",
699
+ "reflect": false
700
+ },
701
+ "type": {
702
+ "type": "string",
703
+ "mutable": false,
704
+ "complexType": {
705
+ "original": "\"1\" | \"2\"",
706
+ "resolved": "\"1\" | \"2\" | undefined",
707
+ "references": {}
708
+ },
709
+ "required": false,
710
+ "optional": true,
711
+ "docs": {
712
+ "tags": [],
713
+ "text": ""
714
+ },
715
+ "attribute": "type",
716
+ "reflect": false
717
+ },
718
+ "buttonText": {
719
+ "type": "string",
720
+ "mutable": false,
721
+ "complexType": {
722
+ "original": "string",
723
+ "resolved": "string",
724
+ "references": {}
725
+ },
726
+ "required": true,
727
+ "optional": false,
728
+ "docs": {
729
+ "tags": [],
730
+ "text": ""
731
+ },
732
+ "attribute": "button-text",
733
+ "reflect": false
734
+ },
735
+ "info": {
736
+ "type": "string",
737
+ "mutable": false,
738
+ "complexType": {
739
+ "original": "string",
740
+ "resolved": "string | undefined",
741
+ "references": {}
742
+ },
743
+ "required": false,
744
+ "optional": true,
745
+ "docs": {
746
+ "tags": [],
747
+ "text": ""
748
+ },
749
+ "attribute": "info",
750
+ "reflect": false
751
+ },
752
+ "emptyStateText": {
753
+ "type": "string",
754
+ "mutable": false,
755
+ "complexType": {
756
+ "original": "string",
757
+ "resolved": "string",
758
+ "references": {}
759
+ },
760
+ "required": true,
761
+ "optional": false,
762
+ "docs": {
763
+ "tags": [],
764
+ "text": ""
765
+ },
766
+ "attribute": "empty-state-text",
767
+ "reflect": false
768
+ },
769
+ "icon": {
770
+ "type": "string",
771
+ "mutable": false,
772
+ "complexType": {
773
+ "original": "string",
774
+ "resolved": "string",
775
+ "references": {}
776
+ },
777
+ "required": true,
778
+ "optional": false,
779
+ "docs": {
780
+ "tags": [],
781
+ "text": ""
782
+ },
783
+ "attribute": "icon",
784
+ "reflect": false
785
+ },
786
+ "fileTypes": {
787
+ "type": "string",
788
+ "mutable": false,
789
+ "complexType": {
790
+ "original": "string",
791
+ "resolved": "string",
792
+ "references": {}
793
+ },
794
+ "required": false,
795
+ "optional": false,
796
+ "docs": {
797
+ "tags": [],
798
+ "text": ""
799
+ },
800
+ "attribute": "file-types",
801
+ "reflect": false,
802
+ "defaultValue": "\"pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv\""
803
+ },
804
+ "maxSize": {
805
+ "type": "number",
806
+ "mutable": false,
807
+ "complexType": {
808
+ "original": "number | null",
809
+ "resolved": "null | number | undefined",
810
+ "references": {}
811
+ },
812
+ "required": false,
813
+ "optional": true,
814
+ "docs": {
815
+ "tags": [],
816
+ "text": ""
817
+ },
818
+ "attribute": "max-size",
819
+ "reflect": false
820
+ },
821
+ "maxFiles": {
822
+ "type": "number",
823
+ "mutable": false,
824
+ "complexType": {
825
+ "original": "number",
826
+ "resolved": "number | undefined",
827
+ "references": {}
828
+ },
829
+ "required": false,
830
+ "optional": true,
831
+ "docs": {
832
+ "tags": [],
833
+ "text": ""
834
+ },
835
+ "attribute": "max-files",
836
+ "reflect": false
837
+ },
838
+ "sortBy": {
839
+ "type": "string",
840
+ "mutable": false,
841
+ "complexType": {
842
+ "original": "\"name\" | \"date\"",
843
+ "resolved": "\"date\" | \"name\"",
844
+ "references": {}
845
+ },
846
+ "required": false,
847
+ "optional": false,
848
+ "docs": {
849
+ "tags": [],
850
+ "text": ""
851
+ },
852
+ "attribute": "sort-by",
853
+ "reflect": false,
854
+ "defaultValue": "\"date\""
855
+ },
856
+ "showInfo": {
857
+ "type": "string",
858
+ "mutable": false,
859
+ "complexType": {
860
+ "original": "\"time\" | \"size\" | \"none\"",
861
+ "resolved": "\"none\" | \"size\" | \"time\"",
862
+ "references": {}
863
+ },
864
+ "required": false,
865
+ "optional": false,
866
+ "docs": {
867
+ "tags": [],
868
+ "text": ""
869
+ },
870
+ "attribute": "show-info",
871
+ "reflect": false,
872
+ "defaultValue": "\"time\""
873
+ },
874
+ "files": {
875
+ "type": "string",
876
+ "mutable": false,
877
+ "complexType": {
878
+ "original": "string",
879
+ "resolved": "string | undefined",
880
+ "references": {}
881
+ },
882
+ "required": false,
883
+ "optional": true,
884
+ "docs": {
885
+ "tags": [],
886
+ "text": ""
887
+ },
888
+ "attribute": "files",
889
+ "reflect": false
890
+ },
891
+ "filesToUpload": {
892
+ "type": "unknown",
893
+ "mutable": false,
894
+ "complexType": {
895
+ "original": "File[]",
896
+ "resolved": "File[]",
897
+ "references": {
898
+ "File": {
899
+ "location": "global"
900
+ }
901
+ }
902
+ },
903
+ "required": false,
904
+ "optional": false,
905
+ "docs": {
906
+ "tags": [],
907
+ "text": ""
908
+ },
909
+ "defaultValue": "[]"
910
+ },
911
+ "rejectedFiles": {
912
+ "type": "string",
913
+ "mutable": false,
914
+ "complexType": {
915
+ "original": "string",
916
+ "resolved": "string | undefined",
917
+ "references": {}
918
+ },
919
+ "required": false,
920
+ "optional": true,
921
+ "docs": {
922
+ "tags": [],
923
+ "text": ""
924
+ },
925
+ "attribute": "rejected-files",
926
+ "reflect": false
927
+ }
928
+ }; }
929
+ static get states() { return {
930
+ "isTabbing": {},
931
+ "errorList": {},
932
+ "notif": {},
933
+ "numFilesInProgress": {},
934
+ "isCondensed": {}
935
+ }; }
936
+ static get events() { return [{
937
+ "method": "wmUploaderFilesSelected",
938
+ "name": "wmUploaderFilesSelected",
939
+ "bubbles": true,
940
+ "cancelable": true,
941
+ "composed": true,
942
+ "docs": {
943
+ "tags": [],
944
+ "text": ""
945
+ },
946
+ "complexType": {
947
+ "original": "any",
948
+ "resolved": "any",
949
+ "references": {}
950
+ }
951
+ }, {
952
+ "method": "wmFilesSelected",
953
+ "name": "wmFilesSelected",
954
+ "bubbles": true,
955
+ "cancelable": true,
956
+ "composed": true,
957
+ "docs": {
958
+ "tags": [],
959
+ "text": ""
960
+ },
961
+ "complexType": {
962
+ "original": "any",
963
+ "resolved": "any",
964
+ "references": {}
965
+ }
966
+ }, {
967
+ "method": "wmUploaderDeleteFile",
968
+ "name": "wmUploaderDeleteFile",
969
+ "bubbles": true,
970
+ "cancelable": true,
971
+ "composed": true,
972
+ "docs": {
973
+ "tags": [],
974
+ "text": ""
975
+ },
976
+ "complexType": {
977
+ "original": "any",
978
+ "resolved": "any",
979
+ "references": {}
980
+ }
981
+ }, {
982
+ "method": "wmDeleteFile",
983
+ "name": "wmDeleteFile",
984
+ "bubbles": true,
985
+ "cancelable": true,
986
+ "composed": true,
987
+ "docs": {
988
+ "tags": [],
989
+ "text": ""
990
+ },
991
+ "complexType": {
992
+ "original": "any",
993
+ "resolved": "any",
994
+ "references": {}
995
+ }
996
+ }, {
997
+ "method": "wmUploaderDownloadFile",
998
+ "name": "wmUploaderDownloadFile",
999
+ "bubbles": true,
1000
+ "cancelable": true,
1001
+ "composed": true,
1002
+ "docs": {
1003
+ "tags": [],
1004
+ "text": ""
1005
+ },
1006
+ "complexType": {
1007
+ "original": "any",
1008
+ "resolved": "any",
1009
+ "references": {}
1010
+ }
1011
+ }, {
1012
+ "method": "wmDownloadFile",
1013
+ "name": "wmDownloadFile",
1014
+ "bubbles": true,
1015
+ "cancelable": true,
1016
+ "composed": true,
1017
+ "docs": {
1018
+ "tags": [],
1019
+ "text": ""
1020
+ },
1021
+ "complexType": {
1022
+ "original": "any",
1023
+ "resolved": "any",
1024
+ "references": {}
1025
+ }
1026
+ }, {
1027
+ "method": "wmUploaderPreviewFile",
1028
+ "name": "wmUploaderPreviewFile",
1029
+ "bubbles": true,
1030
+ "cancelable": true,
1031
+ "composed": true,
1032
+ "docs": {
1033
+ "tags": [],
1034
+ "text": ""
1035
+ },
1036
+ "complexType": {
1037
+ "original": "any",
1038
+ "resolved": "any",
1039
+ "references": {}
1040
+ }
1041
+ }]; }
1042
+ static get elementRef() { return "el"; }
1043
+ static get watchers() { return [{
1044
+ "propName": "files",
1045
+ "methodName": "parseFiles"
1046
+ }, {
1047
+ "propName": "rejectedFiles",
1048
+ "methodName": "parseRejectedFiles"
1049
+ }, {
1050
+ "propName": "numFilesInProgress",
1051
+ "methodName": "uploadNotifications"
1052
+ }]; }
1053
+ static get listeners() { return [{
1054
+ "name": "wmUserIsTabbing",
1055
+ "method": "toggleTabbingOn",
1056
+ "target": "window",
1057
+ "capture": false,
1058
+ "passive": false
1059
+ }, {
1060
+ "name": "wmUserIsNotTabbing",
1061
+ "method": "toggleTabbingOff",
1062
+ "target": "window",
1063
+ "capture": false,
1064
+ "passive": false
1065
+ }, {
1066
+ "name": "wmUploadProgress",
1067
+ "method": "handleUploadProgress",
1068
+ "target": undefined,
1069
+ "capture": false,
1070
+ "passive": false
1071
+ }]; }
1072
+ }