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