@watermarkinsights/ripple 3.5.0-3 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{functions-653e695c.js → functions-8fb310fe.js} +442 -442
  3. package/dist/cjs/{global-ee710089.js → global-d687de5e.js} +65 -65
  4. package/dist/cjs/{http-service-494d81de.js → http-service-9e8c4dd5.js} +49 -49
  5. package/dist/cjs/{interfaces-a3338581.js → interfaces-30a74c1f.js} +29 -29
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/priv-chart-popover.cjs.entry.js +78 -78
  8. package/dist/cjs/priv-datepicker.cjs.entry.js +667 -667
  9. package/dist/cjs/priv-navigator-button.cjs.entry.js +18 -18
  10. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  11. package/dist/cjs/ripple.cjs.js +2 -2
  12. package/dist/cjs/wm-action-menu_2.cjs.entry.js +341 -341
  13. package/dist/cjs/wm-button.cjs.entry.js +218 -218
  14. package/dist/cjs/wm-chart-slice.cjs.entry.js +13 -13
  15. package/dist/cjs/wm-chart.cjs.entry.js +474 -473
  16. package/dist/cjs/wm-datepicker.cjs.entry.js +256 -256
  17. package/dist/cjs/wm-input.cjs.entry.js +133 -133
  18. package/dist/cjs/wm-modal-footer.cjs.entry.js +31 -31
  19. package/dist/cjs/wm-modal-header.cjs.entry.js +34 -34
  20. package/dist/cjs/wm-modal.cjs.entry.js +161 -161
  21. package/dist/cjs/wm-navigator.cjs.entry.js +268 -268
  22. package/dist/cjs/wm-network-uploader.cjs.entry.js +420 -420
  23. package/dist/cjs/wm-option_2.cjs.entry.js +492 -491
  24. package/dist/cjs/wm-pagination.cjs.entry.js +167 -167
  25. package/dist/cjs/wm-search.cjs.entry.js +231 -231
  26. package/dist/cjs/wm-snackbar.cjs.entry.js +170 -170
  27. package/dist/cjs/wm-tab-item_3.cjs.entry.js +300 -300
  28. package/dist/cjs/wm-tag-input.cjs.entry.js +556 -556
  29. package/dist/cjs/wm-timepicker.cjs.entry.js +380 -384
  30. package/dist/cjs/wm-toggletip.cjs.entry.js +124 -124
  31. package/dist/cjs/wm-uploader.cjs.entry.js +346 -346
  32. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  33. package/dist/collection/components/wm-action-menu/wm-action-menu.js +460 -460
  34. package/dist/collection/components/wm-button/wm-button.js +485 -485
  35. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -232
  36. package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -64
  37. package/dist/collection/components/wm-chart/wm-chart.js +719 -718
  38. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1015 -1015
  39. package/dist/collection/components/wm-datepicker/wm-datepicker.js +462 -462
  40. package/dist/collection/components/wm-input/wm-input.js +423 -423
  41. package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
  42. package/dist/collection/components/wm-modal/wm-modal-footer.js +141 -141
  43. package/dist/collection/components/wm-modal/wm-modal-header.js +92 -92
  44. package/dist/collection/components/wm-modal/wm-modal.js +459 -459
  45. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
  46. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
  47. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
  48. package/dist/collection/components/wm-option/wm-option.js +422 -422
  49. package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
  50. package/dist/collection/components/wm-search/wm-search.js +479 -479
  51. package/dist/collection/components/wm-select/wm-select.js +718 -717
  52. package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
  53. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +219 -219
  54. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +331 -331
  55. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
  56. package/dist/collection/components/wm-tag-input/wm-tag-input.js +787 -787
  57. package/dist/collection/components/wm-timepicker/wm-timepicker.css +3 -2
  58. package/dist/collection/components/wm-timepicker/wm-timepicker.js +579 -589
  59. package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
  60. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -753
  61. package/dist/collection/components/wm-uploader/wm-uploader.js +748 -748
  62. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
  63. package/dist/collection/dev/scripts.js +20 -20
  64. package/dist/collection/global/__mocks__/functions.js +6 -6
  65. package/dist/collection/global/functions.js +445 -445
  66. package/dist/collection/global/global.js +72 -72
  67. package/dist/collection/global/interfaces.js +49 -49
  68. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  69. package/dist/collection/global/services/http-service.js +50 -50
  70. package/dist/collection/lang/lang.js +5 -5
  71. package/dist/collection/lang/piglatin.js +93 -93
  72. package/dist/esm/{functions-e528c934.js → functions-c315390d.js} +442 -442
  73. package/dist/esm/{global-b94f59e6.js → global-3ff216e8.js} +65 -65
  74. package/dist/esm/{http-service-3dc3b3e7.js → http-service-5d037e16.js} +49 -49
  75. package/dist/esm/{interfaces-2b97fab2.js → interfaces-61c6305b.js} +29 -29
  76. package/dist/esm/loader.js +2 -2
  77. package/dist/esm/polyfills/core-js.js +0 -0
  78. package/dist/esm/polyfills/dom.js +0 -0
  79. package/dist/esm/polyfills/es5-html-element.js +0 -0
  80. package/dist/esm/polyfills/index.js +0 -0
  81. package/dist/esm/polyfills/system.js +0 -0
  82. package/dist/esm/priv-chart-popover.entry.js +78 -78
  83. package/dist/esm/priv-datepicker.entry.js +667 -667
  84. package/dist/esm/priv-navigator-button.entry.js +18 -18
  85. package/dist/esm/priv-navigator-item.entry.js +23 -23
  86. package/dist/esm/ripple.js +2 -2
  87. package/dist/esm/wm-action-menu_2.entry.js +341 -341
  88. package/dist/esm/wm-button.entry.js +218 -218
  89. package/dist/esm/wm-chart-slice.entry.js +13 -13
  90. package/dist/esm/wm-chart.entry.js +474 -473
  91. package/dist/esm/wm-datepicker.entry.js +256 -256
  92. package/dist/esm/wm-input.entry.js +133 -133
  93. package/dist/esm/wm-modal-footer.entry.js +31 -31
  94. package/dist/esm/wm-modal-header.entry.js +34 -34
  95. package/dist/esm/wm-modal.entry.js +161 -161
  96. package/dist/esm/wm-navigator.entry.js +268 -268
  97. package/dist/esm/wm-network-uploader.entry.js +420 -420
  98. package/dist/esm/wm-option_2.entry.js +492 -491
  99. package/dist/esm/wm-pagination.entry.js +167 -167
  100. package/dist/esm/wm-search.entry.js +231 -231
  101. package/dist/esm/wm-snackbar.entry.js +170 -170
  102. package/dist/esm/wm-tab-item_3.entry.js +300 -300
  103. package/dist/esm/wm-tag-input.entry.js +556 -556
  104. package/dist/esm/wm-timepicker.entry.js +380 -384
  105. package/dist/esm/wm-toggletip.entry.js +124 -124
  106. package/dist/esm/wm-uploader.entry.js +346 -346
  107. package/dist/esm/wm-wrapper.entry.js +12 -12
  108. package/dist/ripple/{p-fcdc6395.entry.js → p-042d6449.entry.js} +1 -1
  109. package/dist/ripple/{p-e7616311.entry.js → p-34694011.entry.js} +1 -1
  110. package/dist/ripple/{p-e9e8334e.entry.js → p-36da5d4a.entry.js} +1 -1
  111. package/dist/ripple/{p-33524565.entry.js → p-374b4fa6.entry.js} +1 -1
  112. package/dist/ripple/p-3eb955b4.entry.js +1 -0
  113. package/dist/ripple/{p-dc9c9fda.entry.js → p-41f39509.entry.js} +1 -1
  114. package/dist/ripple/{p-1e0c41a9.entry.js → p-5ffa983b.entry.js} +1 -1
  115. package/dist/ripple/p-75a9ba2f.entry.js +1 -0
  116. package/dist/ripple/{p-8923b7d0.entry.js → p-7bbd123c.entry.js} +1 -1
  117. package/dist/ripple/{p-43f1298b.js → p-888bec42.js} +0 -0
  118. package/dist/ripple/{p-cd58a15c.entry.js → p-a50439f1.entry.js} +1 -1
  119. package/dist/ripple/{p-fd8070fb.js → p-a6d6eae7.js} +0 -0
  120. package/dist/ripple/{p-65e3a656.entry.js → p-b03382ea.entry.js} +1 -1
  121. package/dist/ripple/{p-b3d5ea85.entry.js → p-b4a8c8d3.entry.js} +1 -1
  122. package/dist/ripple/{p-8cd1396e.entry.js → p-ba9d3069.entry.js} +1 -1
  123. package/dist/ripple/{p-092b01f3.entry.js → p-c5e44367.entry.js} +1 -1
  124. package/dist/ripple/{p-efdaf3b6.entry.js → p-c724ce54.entry.js} +1 -1
  125. package/dist/ripple/{p-3003d26d.entry.js → p-d5fafa9c.entry.js} +1 -1
  126. package/dist/ripple/p-d69c1688.entry.js +1 -0
  127. package/dist/ripple/p-ddf5bb8f.js +1 -0
  128. package/dist/ripple/{p-4cc71463.entry.js → p-dea72d46.entry.js} +1 -1
  129. package/dist/ripple/{p-aa973691.entry.js → p-e574fb73.entry.js} +1 -1
  130. package/dist/ripple/{p-588b4475.js → p-e60fe2f5.js} +0 -0
  131. package/dist/ripple/{p-ec9697db.entry.js → p-ec5db255.entry.js} +1 -1
  132. package/dist/ripple/ripple.esm.js +1 -1
  133. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +48 -48
  134. package/dist/types/components/wm-button/wm-button.d.ts +44 -44
  135. package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -23
  136. package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -8
  137. package/dist/types/components/wm-chart/wm-chart.d.ts +82 -81
  138. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +76 -76
  139. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
  140. package/dist/types/components/wm-input/wm-input.d.ts +46 -46
  141. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  142. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -15
  143. package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -12
  144. package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
  145. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  146. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  147. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  148. package/dist/types/components/wm-option/wm-option.d.ts +32 -32
  149. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  150. package/dist/types/components/wm-search/wm-search.d.ts +86 -86
  151. package/dist/types/components/wm-select/wm-select.d.ts +66 -66
  152. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
  153. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
  154. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
  155. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  156. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +91 -91
  157. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +61 -62
  158. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
  159. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  160. package/dist/types/components/wm-uploader/wm-uploader.d.ts +80 -80
  161. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  162. package/dist/types/components.d.ts +24 -24
  163. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  164. package/dist/types/global/functions.d.ts +40 -40
  165. package/dist/types/global/global.d.ts +1 -1
  166. package/dist/types/global/interfaces.d.ts +34 -34
  167. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  168. package/dist/types/global/services/http-service.d.ts +4 -4
  169. package/dist/types/lang/lang.d.ts +5 -5
  170. package/package.json +46 -46
  171. package/dist/ripple/p-7a96bb97.js +0 -1
  172. package/dist/ripple/p-83b8aaaf.entry.js +0 -1
  173. package/dist/ripple/p-b5189f72.entry.js +0 -1
  174. package/dist/ripple/p-bc27b604.entry.js +0 -1
@@ -1,353 +1,353 @@
1
1
  import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-66f8130e.js';
2
- import { g as generateId, i as intl, p as hasValidType } from './functions-e528c934.js';
2
+ import { g as generateId, i as intl, p as hasValidType } from './functions-c315390d.js';
3
3
 
4
4
  const wmUploaderCss = "@charset \"UTF-8\";:host .wm-button,wm-uploader .wm-button{-ms-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1), border 500ms cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1), border 500ms cubic-bezier(0.4, 0, 0.2, 1);-moz-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1), border 500ms cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1), border 500ms cubic-bezier(0.4, 0, 0.2, 1);-webkit-border-radius:5px;-moz-border-radius:5px;-ms-border-radius:5px;border-radius:5px;width:inherit;border:2px solid #575195;color:#575195;font-family:inherit;font-size:0.75rem;font-weight:700;height:2.75rem;padding:0 1.3333333333em;cursor:pointer;position:relative;background:#fff;display:flex;justify-content:center;align-items:center;text-decoration:none;text-transform:uppercase;letter-spacing:0.01875rem;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}@media screen and (min-width: 48rem){:host .wm-button,wm-uploader .wm-button{height:3.3333333333em}}:host .wm-button.nowrap,wm-uploader .wm-button.nowrap{display:inline-block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host .wm-button:focus,wm-uploader .wm-button:focus{outline:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}:host .wm-button::-moz-focus-inner,wm-uploader .wm-button::-moz-focus-inner{border:0;outline:none}:host .wm-button.user-is-tabbing:focus:not(:disabled):not(.disabled):not(.-primary):not(.-secondary):not(.-secondary):not(.-selectoronly) .button-text,wm-uploader .wm-button.user-is-tabbing:focus:not(:disabled):not(.disabled):not(.-primary):not(.-secondary):not(.-secondary):not(.-selectoronly) .button-text{background:linear-gradient(90deg, #3862e9 66%, transparent 0) repeat-x;background-size:6px 3px;background-position:0 1em;border-radius:0;line-height:normal}:host .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled),wm-uploader .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled){-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}:host .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled):not(.dark),wm-uploader .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled):not(.dark){-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e}:host .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled):not(.dark)::-moz-focus-inner,wm-uploader .wm-button.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled):not(.dark)::-moz-focus-inner{border:0}:host .wm-button.dark:not(.-textonly):not(:disabled):not(.disabled),wm-uploader .wm-button.dark:not(.-textonly):not(:disabled):not(.disabled){background:transparent;border:2px solid #fff;color:#fff}:host .wm-button.dark:not(.-textonly):not(:disabled):not(.disabled):hover,wm-uploader .wm-button.dark:not(.-textonly):not(:disabled):not(.disabled):hover{color:#575195;background:#e6e6e6;border:2px solid #e6e6e6}:host .wm-button.dark.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled).dark,wm-uploader .wm-button.dark.user-is-tabbing:focus:not(.-textonly):not(:disabled):not(.disabled).dark{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;outline:none}:host .wm-button:active:not(:disabled):not(.disabled):not(.-textonly):not(.-actionbutton):not(.displayedoption),wm-uploader .wm-button:active:not(:disabled):not(.disabled):not(.-textonly):not(.-actionbutton):not(.displayedoption){-ms-transform:scale(0.9, 0.9);-webkit-transform:scale(0.9, 0.9);-moz-transform:scale(0.9, 0.9);transform:scale(0.9, 0.9)}:host .wm-button:hover,wm-uploader .wm-button:hover{background:#464177;color:#fff}:host .wm-button .mdi,wm-uploader .wm-button .mdi{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:host .wm-button:not(.-icononly):not(.-navigational) .mdi,wm-uploader .wm-button:not(.-icononly):not(.-navigational) .mdi{margin-right:0.3125rem}:host .wm-button[dir=RTL] :not(.-icononly) .mdi,wm-uploader .wm-button[dir=RTL] :not(.-icononly) .mdi{margin-left:0.3125rem;margin-right:0}:host .wm-button.-primary:not(.-textonly),wm-uploader .wm-button.-primary:not(.-textonly){background:#575195;color:#fff}:host .wm-button.-primary:not(.-textonly):not(:focus),wm-uploader .wm-button.-primary:not(.-textonly):not(:focus){-webkit-box-shadow:0 2px 2px 0 rgba(87, 81, 149, 0.12), 0 2px 2px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 2px 2px 0 rgba(87, 81, 149, 0.12), 0 2px 2px 0 rgba(0, 0, 0, 0.2);box-shadow:0 2px 2px 0 rgba(87, 81, 149, 0.12), 0 2px 2px 0 rgba(0, 0, 0, 0.2)}:host .wm-button.-primary:not(.-textonly):hover,wm-uploader .wm-button.-primary:not(.-textonly):hover{background:#464177}:host .wm-button.-primary:not(.-textonly).dark:not(:disabled):not(.disabled),wm-uploader .wm-button.-primary:not(.-textonly).dark:not(:disabled):not(.disabled){color:#575195;background:#fff;border:2px solid #fff}:host .wm-button.-primary:not(.-textonly).dark:not(:disabled):not(.disabled):hover,wm-uploader .wm-button.-primary:not(.-textonly).dark:not(:disabled):not(.disabled):hover{color:#575195;background:#e6e6e6;border:2px solid #e6e6e6}:host .wm-button.-textonly,wm-uploader .wm-button.-textonly{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;display:inline-block;letter-spacing:0;text-transform:none;text-align:initial;font-size:0.875rem;border:none;background:transparent;padding-left:0;padding-right:0;height:auto;border-radius:0;line-height:1}:host .wm-button.-textonly+.-textonly,wm-uploader .wm-button.-textonly+.-textonly{margin-left:0.3125rem}:host .wm-button.-textonly:focus,wm-uploader .wm-button.-textonly:focus{outline:none}:host .wm-button.-textonly::-moz-focus-inner,wm-uploader .wm-button.-textonly::-moz-focus-inner{border:0;outline:none}:host .wm-button.-textonly.user-is-tabbing:focus:not(:disabled):not(.disabled) .button-text,wm-uploader .wm-button.-textonly.user-is-tabbing:focus:not(:disabled):not(.disabled) .button-text{background:linear-gradient(90deg, #3862e9 66%, transparent 0) repeat-x;background-size:6px 3px;background-position:0 1em;border-radius:0;line-height:normal}:host .wm-button.-textonly.user-is-tabbing:focus:not(:disabled):not(.disabled).dark .button-text,wm-uploader .wm-button.-textonly.user-is-tabbing:focus:not(:disabled):not(.disabled).dark .button-text{background:linear-gradient(90deg, #fff 66%, transparent 0) repeat-x;background-size:6px 3px;background-position:0 1em;border-radius:0;line-height:normal}:host .wm-button.-textonly.small,wm-uploader .wm-button.-textonly.small{font-size:0.625rem}:host .wm-button.-textonly:hover:not(:disabled):not(.disabled):not(.-permanentlydelete),wm-uploader .wm-button.-textonly:hover:not(:disabled):not(.disabled):not(.-permanentlydelete){text-decoration:underline;color:#454077}:host .wm-button.-textonly.-permanentlydelete,wm-uploader .wm-button.-textonly.-permanentlydelete{color:#c0392b}:host .wm-button.-textonly.-permanentlydelete:hover,wm-uploader .wm-button.-textonly.-permanentlydelete:hover{text-decoration:underline;color:#c0392b !important}:host .wm-button.-textonly.dark,wm-uploader .wm-button.-textonly.dark{color:#fff}:host .wm-button.-textonly.dark:hover,wm-uploader .wm-button.-textonly.dark:hover{text-decoration:underline;color:#fff !important}:host .wm-button.-icononly,wm-uploader .wm-button.-icononly,:host .wm-button.-navigational,wm-uploader .wm-button.-navigational{-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;border-radius:50%;font-size:1rem;padding:0;height:auto;line-height:1;min-width:2.75rem;min-height:2.75rem;text-align:center;letter-spacing:normal}:host .wm-button.-icononly:not(:focus),wm-uploader .wm-button.-icononly:not(:focus),:host .wm-button.-navigational:not(:focus),wm-uploader .wm-button.-navigational:not(:focus){-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}@media screen and (min-width: 48rem){:host .wm-button.-icononly,wm-uploader .wm-button.-icononly,:host .wm-button.-navigational,wm-uploader .wm-button.-navigational{min-width:2.5rem;min-height:2.5rem}}:host .wm-button.-icononly,wm-uploader .wm-button.-icononly{border-width:1px !important}:host .wm-button.-icononly:before,wm-uploader .wm-button.-icononly:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:host .wm-button.-navigational,wm-uploader .wm-button.-navigational{border:none !important;background-color:transparent}:host .wm-button.-navigational:not(.dark):not(:disabled),wm-uploader .wm-button.-navigational:not(.dark):not(:disabled){color:#575195}:host .wm-button.-navigational:not(.dark):not(:disabled):hover,wm-uploader .wm-button.-navigational:not(.dark):not(:disabled):hover,:host .wm-button.-navigational:not(.dark):not(:disabled).selected,wm-uploader .wm-button.-navigational:not(.dark):not(:disabled).selected{background-color:#d7d6d9}:host .wm-button.-navigational:before,wm-uploader .wm-button.-navigational:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:host .wm-button.-permanentlydelete:not(.-textonly),wm-uploader .wm-button.-permanentlydelete:not(.-textonly){background:#c0392b;border-color:#c0392b;color:#fff}:host .wm-button.-selectoronly,wm-uploader .wm-button.-selectoronly{-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;display:block;background:transparent;border:1px solid #575195;border-radius:3px 3px 3px 3px;height:2.75rem;min-width:11.4375rem;padding:0 1.875rem 0 0.9375rem;line-height:normal;font-family:inherit;color:#575195;font-weight:500;font-size:0.875rem;text-transform:none;letter-spacing:0.01875rem;text-align:left}@media screen and (min-width: 48rem){:host .wm-button.-selectoronly,wm-uploader .wm-button.-selectoronly{height:2.5rem}}:host .wm-button.-selectoronly:before,wm-uploader .wm-button.-selectoronly:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\";position:absolute;right:0.5625rem;top:50%;transform:translateY(-50%);pointer-events:none}:host .wm-button.-selectoronly:hover:not(:disabled):not(.disabled),wm-uploader .wm-button.-selectoronly:hover:not(:disabled):not(.disabled){background:transparent;text-decoration:none}:host .wm-button.-selectoronly:active,wm-uploader .wm-button.-selectoronly:active{-ms-transform:scale(1, 1) !important;transform:scale(1, 1) !important}:host .wm-button.-selectoronly::-moz-focus-inner,wm-uploader .wm-button.-selectoronly::-moz-focus-inner{border:0}:host .wm-button.-selectoronly .overflowcontrol,wm-uploader .wm-button.-selectoronly .overflowcontrol{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:visible}:host .wm-button:disabled,wm-uploader .wm-button:disabled,:host .wm-button.disabled,wm-uploader .wm-button.disabled{background:inherit;border-color:#737373;color:#737373;cursor:default;pointer-events:none}:host .wm-button:disabled.dark,wm-uploader .wm-button:disabled.dark,:host .wm-button.disabled.dark,wm-uploader .wm-button.disabled.dark{color:#a6a6a6;border-color:#a6a6a6}:host .wm-button:disabled.-primary,wm-uploader .wm-button:disabled.-primary,:host .wm-button:disabled.-permanentlydelete,wm-uploader .wm-button:disabled.-permanentlydelete,:host .wm-button.disabled.-primary,wm-uploader .wm-button.disabled.-primary,:host .wm-button.disabled.-permanentlydelete,wm-uploader .wm-button.disabled.-permanentlydelete{background:#737373;color:#fff;border-color:#737373}:host .wm-button:disabled.-primary.dark,wm-uploader .wm-button:disabled.-primary.dark,:host .wm-button.disabled.-primary.dark,wm-uploader .wm-button.disabled.-primary.dark{background:#a6a6a6;border-color:#a6a6a6;color:#353b48}:host .wm-button:disabled.-secondary,wm-uploader .wm-button:disabled.-secondary,:host .wm-button.disabled.-secondary,wm-uploader .wm-button.disabled.-secondary{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}:host .wm-button:disabled.-selectoronly,wm-uploader .wm-button:disabled.-selectoronly,:host .wm-button.disabled.-selectoronly,wm-uploader .wm-button.disabled.-selectoronly{color:#737373}:host .wm-button:disabled.-textonly,wm-uploader .wm-button:disabled.-textonly,:host .wm-button.disabled.-textonly,wm-uploader .wm-button.disabled.-textonly{color:#6b6b6b;background:transparent}:host a.wm-button,wm-uploader a.wm-button,:host label.wm-button,wm-uploader label.wm-button{height:auto;padding-top:0.75rem;padding-bottom:0.75rem}:host,wm-uploader{width:100%;height:100%;display:block;position:relative}:host[dir=RTL] .mdi,wm-uploader[dir=RTL] .mdi{margin-left:0.3125rem;margin-right:0}:host input:focus+.wm-button.user-is-tabbing,wm-uploader input:focus+.wm-button.user-is-tabbing{-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e !important;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e !important;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e !important}:host *,wm-uploader *{box-sizing:border-box}.sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}.header{margin-bottom:1rem}.header .slot-wrapper{display:flex;justify-content:flex-start;align-items:flex-start}.header .info-wrapper{align-items:center}.header .info-wrapper .info{font-size:0.875rem;margin-left:1rem}.footer{display:flex;flex-direction:column;align-items:flex-end;padding:0.9375rem 1.875rem}.footer .notif-wrapper{align-items:flex-end}.footer .filecount-wrapper{display:flex;align-items:center}.footer .filecount-wrapper .filecount{font-size:0.875rem;margin-right:1rem}.notif-wrapper{position:relative;display:flex;flex-direction:column;margin-bottom:1rem}.notif{padding-top:0.25rem;font-size:0.875rem;font-style:italic;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.info-wrapper{position:relative;display:flex}.file-info{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.file-info+.file-controls{flex:none;margin-left:1rem}.empty-block{margin:5rem auto;display:flex;flex-direction:column;align-items:center}.empty-block .upload-file{margin-bottom:1.875rem}.empty-block .empty-message{font-size:0.875rem;margin-bottom:0.4375rem}.empty-block .empty-message.large{font-size:1.5rem}.empty-block .info-wrapper{justify-content:center;width:100%}.empty-block .info-wrapper .wm-button{width:auto}.list-container{overflow-y:auto}.list-container.type1{padding:0 1.875rem;height:16.25rem}ul{list-style:none;padding:0;width:100%}ul li{font-size:0.875rem}ul li .file{-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:relative;height:3.75rem;padding:0.5rem 1.25rem;background:#f4f4f4;border:1px solid #6b6b6b;display:flex;justify-content:space-between;align-items:center}ul li .file+.file{margin-top:1.25rem}ul li .file .filename{font-weight:500}ul li .file wm-button+wm-button{margin-left:1rem}ul.file-list .file.--saved,ul.inprogress-list .file{margin-bottom:1.625rem}ul .progress{position:absolute;left:0;top:0;right:0;height:8px}ul.error-list li{margin-bottom:1.25rem;color:#c0392b}ul.error-list li .file{border:1px solid #c0392b;background-color:#f5ebea;height:3.75rem}ul.error-list li .error-message{padding-top:0.25rem;font-style:italic}";
5
5
 
6
- const Uploader = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.wmUploaderFilesSelected = createEvent(this, "wmUploaderFilesSelected", 7);
10
- this.wmFilesSelected = createEvent(this, "wmFilesSelected", 7);
11
- this.wmUploaderDeleteFile = createEvent(this, "wmUploaderDeleteFile", 7);
12
- this.wmDeleteFile = createEvent(this, "wmDeleteFile", 7);
13
- this.wmUploaderDownloadFile = createEvent(this, "wmUploaderDownloadFile", 7);
14
- this.wmDownloadFile = createEvent(this, "wmDownloadFile", 7);
15
- this.uploaderType = null; // only mutable for the deprecation transition
16
- this.type = null; // DEPRECATED in favor of uploaderType
17
- this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
18
- this.maxSize = 100; // in Mb
19
- this.sortBy = "date"; // name is descending (a -> z), date is ascending (earlier -> later)
20
- this.fileList = []; // the string above transformed into the actual array
21
- this.filesToUpload = []; // input.files that passed validation
22
- this.isTabbing = false;
23
- this.errorList = []; // for errors on a particular file
24
- this.inputId = generateId();
25
- }
26
- get tempUploaderType() {
27
- // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
28
- // don't forget to reset this.uploaderType's default value to "1"
29
- return this.type || this.uploaderType || "1";
30
- }
31
- toggleTabbingOn() {
32
- this.isTabbing = true;
33
- }
34
- toggleTabbingOff() {
35
- this.isTabbing = false;
36
- }
37
- handleUploadProgress(ev) {
38
- this.fileList.map((i) => {
39
- if (i.id === ev.detail.id) {
40
- i.progress = ev.detail.progress;
41
- forceUpdate(this.el);
42
- }
43
- });
44
- if (ev.detail.progress === 100) {
45
- // inProgressList is not a perfect reflection of how many files are uploading
46
- // because even after progress reached 100% the item should remain in the array
47
- // (should only be removed once it appears in fileList)
48
- this.numFilesInProgress -= 1;
49
- }
50
- // aggregate the percentages for SR to announce progress
51
- if (!this.srProgress && this.numFilesInProgress) {
52
- const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
53
- this.srProgress = setInterval(() => {
54
- const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
55
- if (this.liveRegion) {
56
- this.liveRegion.innerHTML = intl.formatMessage({
57
- id: "uploader.uploadProgress",
58
- defaultMessage: "Upload progress: {percentage}%",
59
- }, { percentage: Math.floor(aggregate / total) });
60
- }
61
- }, 5000);
62
- }
63
- }
64
- parseFiles() {
65
- if (!!this.files) {
66
- if (typeof this.files === "string") {
67
- const list = JSON.parse(this.files);
68
- if (typeof list === "object") {
69
- this.fileList = list;
70
- }
71
- else {
72
- throw new Error("could not parse string passed to files attribute");
73
- }
74
- }
75
- else {
76
- throw new Error("Attribute 'files' should be a string");
77
- }
78
- }
79
- }
80
- parseRejectedFiles() {
81
- if (!!this.rejectedFiles) {
82
- if (typeof this.files === "string") {
83
- const list = JSON.parse(this.rejectedFiles);
84
- if (typeof list === "object") {
85
- this.errorList = list;
86
- }
87
- else {
88
- throw new Error("could not parse string passed to errors attribute");
89
- }
90
- }
91
- else {
92
- throw new Error("Attribute 'rejected-files' should be a string");
93
- }
94
- }
95
- }
96
- setMaxSize() {
97
- // Max size can't be set above 100Mb
98
- this.maxSize = this.maxSize > 100 ? 100 : this.maxSize;
99
- }
100
- uploadNotifications(newNum, oldNum) {
101
- if (oldNum > 0 && newNum === 0) {
102
- setTimeout(() => {
103
- this.notif = null;
104
- }, 20 * 1000);
105
- const message = intl.formatMessage({
106
- id: "uploader.finishedUploading",
107
- defaultMessage: "Finished uploading",
108
- });
109
- this.notif = { id: 5, message };
110
- if (this.liveRegion) {
111
- this.liveRegion.innerHTML = message;
112
- }
113
- this.numFilesInProgress = null;
114
- clearInterval(this.srProgress);
115
- forceUpdate(this.el);
116
- }
117
- else if (newNum > 0 && newNum != oldNum) {
118
- const message = intl.formatMessage({
119
- id: "uploader.filesUploading",
120
- defaultMessage: "{num, plural, one {1 file uploading} other {# files uploading}}",
121
- }, { num: newNum });
122
- this.notif = { id: 6, message };
123
- if (this.liveRegion) {
124
- this.liveRegion.innerHTML = message;
125
- }
126
- forceUpdate(this.el);
127
- }
128
- }
129
- isValidSize(size) {
130
- // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
131
- return size / 1024 / 1024 <= this.maxSize;
132
- }
133
- isDuplicate(name) {
134
- return this.fileList.find((f) => {
135
- const filename = f.type ? f.name + "." + f.type : f.name;
136
- return filename === name;
137
- });
138
- }
139
- isEmpty() {
140
- return !this.fileList.length && !this.errorList.length;
141
- }
142
- isDisabled() {
143
- const isMax = !!this.maxFiles && this.fileList.length >= this.maxFiles;
144
- if (!this.notif) {
145
- if (isMax) {
146
- const errMessage = intl.formatMessage({
147
- id: "uploader.fileUploadLimit",
148
- defaultMessage: "You have reached the file upload limit.",
149
- });
150
- this.notif = { id: 1, message: errMessage };
151
- if (this.liveRegion) {
152
- this.liveRegion.innerHTML = errMessage;
153
- }
154
- }
155
- else {
156
- this.notif = null;
157
- }
158
- }
159
- else if (this.notif.id === 1) {
160
- // to make sure SR don't repeat the error, don't reset it if it already is showing
161
- // just dismiss it if isMax is not true anymore
162
- if (!isMax) {
163
- this.notif = null;
164
- }
165
- // finally do nothing if error 2 is showing (special case when user selects too many files)
166
- }
167
- // disable if is the uploader is maxed out or if something is uploading
168
- return isMax || this.numFilesInProgress > 0;
169
- }
170
- isItemUploading(item) {
171
- return item.hasOwnProperty("progress") && item.progress < 100;
172
- }
173
- clearErrors() {
174
- this.errorList = [];
175
- this.notif = null;
176
- }
177
- handleFiles(ev) {
178
- this.filesToUpload = [];
179
- const validTypes = this.fileTypes.split(" ").join(", ");
180
- const files = Array.from(ev.target.files);
181
- if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
182
- const errMessage = intl.formatMessage({
183
- id: "uploader.fileUploadExceeded",
184
- defaultMessage: "The number of selected files exceeds the limit.",
185
- });
186
- this.notif = { id: 2, message: errMessage };
187
- if (this.liveRegion) {
188
- this.liveRegion.innerHTML = errMessage;
189
- }
190
- }
191
- else {
192
- files &&
193
- files.map((file) => {
194
- if (!hasValidType(file, this.fileTypes)) {
195
- const error = {
196
- name: file.name,
197
- message: intl.formatMessage({
198
- id: "uploader.invalidFileType",
199
- defaultMessage: "The file type is invalid. Accepted types: {validTypes}",
200
- }, { validTypes }),
201
- };
202
- this.errorList.push(error);
203
- }
204
- else if (!this.isValidSize(file.size)) {
205
- const error = {
206
- name: file.name,
207
- message: intl.formatMessage({
208
- id: "uploader.fileTooLarge",
209
- defaultMessage: "The selected file is too large. Maximum file size is {size}Mb",
210
- }, { size: this.maxSize }),
211
- };
212
- this.errorList.push(error);
213
- }
214
- else if (this.isDuplicate(file.name)) {
215
- const error = {
216
- name: file.name,
217
- message: intl.formatMessage({
218
- id: "uploader.duplicateName",
219
- defaultMessage: "A file with this name already exists.",
220
- }),
221
- };
222
- this.errorList.push(error);
223
- }
224
- else {
225
- this.filesToUpload.push(file);
226
- }
227
- });
228
- if (this.filesToUpload.length > 0) {
229
- this.numFilesInProgress = this.filesToUpload.length;
230
- this.wmUploaderFilesSelected.emit(this.filesToUpload);
231
- this.wmFilesSelected.emit(this.filesToUpload); // deprecated
232
- }
233
- }
234
- ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
235
- }
236
- downloadFile(file) {
237
- this.clearErrors();
238
- this.wmUploaderDownloadFile.emit(file.id);
239
- this.wmDownloadFile.emit(file.id); // deprecated
240
- }
241
- deleteFile(file) {
242
- this.clearErrors();
243
- forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
244
- this.wmUploaderDeleteFile.emit(file.id);
245
- this.wmDeleteFile.emit(file.id); // deprecated
246
- }
247
- componentWillLoad() {
248
- if (!this.buttonText) {
249
- throw new Error("wm-uploader: button-text is a required prop");
250
- }
251
- if (this.type) {
252
- console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
253
- }
254
- if (this.tempUploaderType === "1" && !this.emptyStateText) {
255
- throw new Error("wm-uploader: empty-state-text is a required prop");
256
- }
257
- this.setMaxSize();
258
- this.parseFiles();
259
- this.clearErrors();
260
- this.parseRejectedFiles();
261
- }
262
- componentDidLoad() {
263
- // awkward way to handle Edge bug where file input dialog doesn't open on Enter key
264
- // first, detect polyfill by checking the class name that it adds to the component
265
- // (it's important NOT to execute the code below in normal browsers as it would open the dialog twice)
266
- this.el.classList.contains("sc-wm-uploader-h") &&
267
- // then add an even listener to force a click event when Enter key is pressed
268
- this.inputEl &&
269
- this.inputEl.addEventListener("keydown", (ev) => {
270
- if (this.inputEl && ev.keyCode === 13) {
271
- this.inputEl.click();
272
- }
273
- });
274
- if (document.body.classList.contains("wmcl-user-is-tabbing")) {
275
- this.toggleTabbingOn();
276
- }
277
- }
278
- renderUploadSvg() {
279
- return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" }, h("path", { transform: "rotate(-180.000000) translate(-452, -255.5)", fill: "#eae8ec", d: "M361,249.681818 L361,197.318182 C361,194.118182 365.555061,191.5 371.122358,191.5 L391.316463,191.5 L391.286495,200.562515 L369.871211,200.600292 L369.885404,200.622146 L369.886423,246.655947 L443.657038,246.840767 L443.657038,200.622146 L421.683537,200.622146 L421.683537,191.5 L441.978865,191.5 C447.546162,191.5 452,194.118182 452,197.318182 L452,249.681818 C452,252.881818 447.546162,255.5 441.978865,255.5 L371.122358,255.5 C365.504449,255.5 361,252.881818 361,249.681818 Z M391.5,207 L406,221 L420.5,207 L409.625,207 L409.625,172 L402.375,172 L402.375,207 L391.5,207 Z" })));
280
- }
281
- renderIcon() {
282
- // mdi attachment icon (paper clip) is horizontal but we want it vertical
283
- const rotate = this.icon && this.icon === "f066";
284
- return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
285
- }
286
- renderInfo() {
287
- return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
288
- }
289
- renderNotif() {
290
- return this.notif ? h("div", { class: "notif" }, this.notif.message) : "";
291
- }
292
- renderUploadButton(classes) {
293
- return (h("div", { class: "info-wrapper" }, h("input", { ref: (el) => (this.inputEl = el), name: this.inputId, id: this.inputId, class: "sr-only", type: "file", multiple: true, onClick: () => this.clearErrors(), onChange: (e) => this.handleFiles(e), disabled: this.isDisabled() }), h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` }, this.renderIcon(), this.buttonText), this.renderInfo()));
294
- }
295
- renderEmptyState() {
296
- return (h("div", { class: "empty-block" }, this.renderUploadSvg(), h("div", { class: `empty-message` }, this.emptyStateText), this.renderUploadButton("-primary empty-button"), this.renderNotif()));
297
- }
298
- renderErrorList() {
299
- if (!!this.errorList.length) {
300
- if (this.liveRegion) {
301
- let srMessage = this.errorList.reduce(function (acc, err) {
302
- return acc + `${err.name}: ${err.message} `;
303
- }, "");
304
- this.liveRegion.innerHTML = srMessage;
305
- }
306
- return (h("ul", { class: "error-list" }, this.errorList.map((err) => (h("li", null, h("div", { class: "file --error" }, h("div", { class: "file-info" }, h("span", { class: "filename" }, err.name))), h("div", { class: "error-message" }, err.message))))));
307
- }
308
- }
309
- renderFileInProgress(item) {
310
- const filename = item.type ? item.name + "." + item.type : item.name;
311
- return (h("li", null, h("div", { class: "file --progress" }, h("div", { class: "progress", style: {
312
- background: `linear-gradient(to right, rgba(67, 126, 142, 1) ${item.progress}%, transparent ${item.progress}%)`,
313
- } }), h("div", { class: "file-info" }, h("span", { class: "filename" }, filename, " ", h("span", { class: "sr-only" }, "uploading"))))));
314
- }
315
- renderFile(item) {
316
- return (h("li", null, h("div", { class: "file --saved" }, h("div", { class: "file-info" }, h("span", { class: "filename" }, item.name + "." + item.type)), h("div", { class: "file-controls" }, 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) }), h("wm-button", { class: "delete-button", "button-type": "icononly", tooltip: "remove", "tooltip-position": "bottom", "label-for-identical-buttons": `remove ${item.name}`, icon: "f1c0", onClick: () => this.deleteFile(item) })))));
317
- }
318
- renderFileList() {
319
- if (this.fileList) {
320
- this.sortBy === "name"
321
- ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
322
- : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
323
- return (h("div", null, h("ul", { class: "inprogress-list" }, this.fileList.filter((item) => this.isItemUploading(item)).map((item) => this.renderFileInProgress(item))), h("ul", { class: "file-list" }, this.fileList.filter((item) => !this.isItemUploading(item)).map((item) => this.renderFile(item)))));
324
- }
325
- }
326
- renderHeader() {
327
- return (this.tempUploaderType === "2" && (h("div", { class: "header" }, h("div", { class: "slot-wrapper" }, h("slot", null), h("div", { class: "notif-wrapper" }, this.renderUploadButton(`-secondary ${this.isDisabled() ? "disabled" : ""}`), this.renderNotif())))));
328
- }
329
- renderFooter() {
330
- return (this.tempUploaderType === "1" && (h("div", { class: "footer" }, h("div", { class: "notif-wrapper" }, h("div", { class: "filecount-wrapper" }, h("div", { class: "filecount" }, intl.formatMessage({
331
- id: "uploader.filesAdded",
332
- defaultMessage: "{numFiles, plural, one {1 file added} other {# files added}}",
333
- }, { numFiles: this.fileList.length })), this.renderUploadButton(`-primary ${this.isDisabled() ? "disabled" : ""}`)), this.renderNotif()))));
334
- }
335
- renderWithItems() {
336
- return (h("div", null, this.renderHeader(), h("div", { class: `list-container type${this.tempUploaderType}` }, this.renderErrorList(), this.renderFileList()), this.renderFooter()));
337
- }
338
- render() {
339
- return (h(Host, null, this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(), h("div", { ref: (el) => (this.liveRegion = el), class: "live-region sr-only", "aria-live": "assertive" // since it's directly linked to the action the user took, it should be read in priority. With polite, some messages get dismissed in favor of the page title
340
- ,
341
- "aria-atomic": "true" })));
342
- }
343
- get el() { return getElement(this); }
344
- static get watchers() { return {
345
- "files": ["parseFiles"],
346
- "rejectedFiles": ["parseRejectedFiles"],
347
- "maxSize": ["setMaxSize"],
348
- "numFilesInProgress": ["uploadNotifications"]
349
- }; }
350
- };
6
+ const Uploader = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.wmUploaderFilesSelected = createEvent(this, "wmUploaderFilesSelected", 7);
10
+ this.wmFilesSelected = createEvent(this, "wmFilesSelected", 7);
11
+ this.wmUploaderDeleteFile = createEvent(this, "wmUploaderDeleteFile", 7);
12
+ this.wmDeleteFile = createEvent(this, "wmDeleteFile", 7);
13
+ this.wmUploaderDownloadFile = createEvent(this, "wmUploaderDownloadFile", 7);
14
+ this.wmDownloadFile = createEvent(this, "wmDownloadFile", 7);
15
+ this.uploaderType = null; // only mutable for the deprecation transition
16
+ this.type = null; // DEPRECATED in favor of uploaderType
17
+ this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
18
+ this.maxSize = 100; // in Mb
19
+ this.sortBy = "date"; // name is descending (a -> z), date is ascending (earlier -> later)
20
+ this.fileList = []; // the string above transformed into the actual array
21
+ this.filesToUpload = []; // input.files that passed validation
22
+ this.isTabbing = false;
23
+ this.errorList = []; // for errors on a particular file
24
+ this.inputId = generateId();
25
+ }
26
+ get tempUploaderType() {
27
+ // replace instances of this.tempUploaderType with this.uploaderType once type is fully phased out
28
+ // don't forget to reset this.uploaderType's default value to "1"
29
+ return this.type || this.uploaderType || "1";
30
+ }
31
+ toggleTabbingOn() {
32
+ this.isTabbing = true;
33
+ }
34
+ toggleTabbingOff() {
35
+ this.isTabbing = false;
36
+ }
37
+ handleUploadProgress(ev) {
38
+ this.fileList.map((i) => {
39
+ if (i.id === ev.detail.id) {
40
+ i.progress = ev.detail.progress;
41
+ forceUpdate(this.el);
42
+ }
43
+ });
44
+ if (ev.detail.progress === 100) {
45
+ // inProgressList is not a perfect reflection of how many files are uploading
46
+ // because even after progress reached 100% the item should remain in the array
47
+ // (should only be removed once it appears in fileList)
48
+ this.numFilesInProgress -= 1;
49
+ }
50
+ // aggregate the percentages for SR to announce progress
51
+ if (!this.srProgress && this.numFilesInProgress) {
52
+ const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
53
+ this.srProgress = setInterval(() => {
54
+ const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
55
+ if (this.liveRegion) {
56
+ this.liveRegion.innerHTML = intl.formatMessage({
57
+ id: "uploader.uploadProgress",
58
+ defaultMessage: "Upload progress: {percentage}%",
59
+ }, { percentage: Math.floor(aggregate / total) });
60
+ }
61
+ }, 5000);
62
+ }
63
+ }
64
+ parseFiles() {
65
+ if (!!this.files) {
66
+ if (typeof this.files === "string") {
67
+ const list = JSON.parse(this.files);
68
+ if (typeof list === "object") {
69
+ this.fileList = list;
70
+ }
71
+ else {
72
+ throw new Error("could not parse string passed to files attribute");
73
+ }
74
+ }
75
+ else {
76
+ throw new Error("Attribute 'files' should be a string");
77
+ }
78
+ }
79
+ }
80
+ parseRejectedFiles() {
81
+ if (!!this.rejectedFiles) {
82
+ if (typeof this.files === "string") {
83
+ const list = JSON.parse(this.rejectedFiles);
84
+ if (typeof list === "object") {
85
+ this.errorList = list;
86
+ }
87
+ else {
88
+ throw new Error("could not parse string passed to errors attribute");
89
+ }
90
+ }
91
+ else {
92
+ throw new Error("Attribute 'rejected-files' should be a string");
93
+ }
94
+ }
95
+ }
96
+ setMaxSize() {
97
+ // Max size can't be set above 100Mb
98
+ this.maxSize = this.maxSize > 100 ? 100 : this.maxSize;
99
+ }
100
+ uploadNotifications(newNum, oldNum) {
101
+ if (oldNum > 0 && newNum === 0) {
102
+ setTimeout(() => {
103
+ this.notif = null;
104
+ }, 20 * 1000);
105
+ const message = intl.formatMessage({
106
+ id: "uploader.finishedUploading",
107
+ defaultMessage: "Finished uploading",
108
+ });
109
+ this.notif = { id: 5, message };
110
+ if (this.liveRegion) {
111
+ this.liveRegion.innerHTML = message;
112
+ }
113
+ this.numFilesInProgress = null;
114
+ clearInterval(this.srProgress);
115
+ forceUpdate(this.el);
116
+ }
117
+ else if (newNum > 0 && newNum != oldNum) {
118
+ const message = intl.formatMessage({
119
+ id: "uploader.filesUploading",
120
+ defaultMessage: "{num, plural, one {1 file uploading} other {# files uploading}}",
121
+ }, { num: newNum });
122
+ this.notif = { id: 6, message };
123
+ if (this.liveRegion) {
124
+ this.liveRegion.innerHTML = message;
125
+ }
126
+ forceUpdate(this.el);
127
+ }
128
+ }
129
+ isValidSize(size) {
130
+ // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
131
+ return size / 1024 / 1024 <= this.maxSize;
132
+ }
133
+ isDuplicate(name) {
134
+ return this.fileList.find((f) => {
135
+ const filename = f.type ? f.name + "." + f.type : f.name;
136
+ return filename === name;
137
+ });
138
+ }
139
+ isEmpty() {
140
+ return !this.fileList.length && !this.errorList.length;
141
+ }
142
+ isDisabled() {
143
+ const isMax = !!this.maxFiles && this.fileList.length >= this.maxFiles;
144
+ if (!this.notif) {
145
+ if (isMax) {
146
+ const errMessage = intl.formatMessage({
147
+ id: "uploader.fileUploadLimit",
148
+ defaultMessage: "You have reached the file upload limit.",
149
+ });
150
+ this.notif = { id: 1, message: errMessage };
151
+ if (this.liveRegion) {
152
+ this.liveRegion.innerHTML = errMessage;
153
+ }
154
+ }
155
+ else {
156
+ this.notif = null;
157
+ }
158
+ }
159
+ else if (this.notif.id === 1) {
160
+ // to make sure SR don't repeat the error, don't reset it if it already is showing
161
+ // just dismiss it if isMax is not true anymore
162
+ if (!isMax) {
163
+ this.notif = null;
164
+ }
165
+ // finally do nothing if error 2 is showing (special case when user selects too many files)
166
+ }
167
+ // disable if is the uploader is maxed out or if something is uploading
168
+ return isMax || this.numFilesInProgress > 0;
169
+ }
170
+ isItemUploading(item) {
171
+ return item.hasOwnProperty("progress") && item.progress < 100;
172
+ }
173
+ clearErrors() {
174
+ this.errorList = [];
175
+ this.notif = null;
176
+ }
177
+ handleFiles(ev) {
178
+ this.filesToUpload = [];
179
+ const validTypes = this.fileTypes.split(" ").join(", ");
180
+ const files = Array.from(ev.target.files);
181
+ if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
182
+ const errMessage = intl.formatMessage({
183
+ id: "uploader.fileUploadExceeded",
184
+ defaultMessage: "The number of selected files exceeds the limit.",
185
+ });
186
+ this.notif = { id: 2, message: errMessage };
187
+ if (this.liveRegion) {
188
+ this.liveRegion.innerHTML = errMessage;
189
+ }
190
+ }
191
+ else {
192
+ files &&
193
+ files.map((file) => {
194
+ if (!hasValidType(file, this.fileTypes)) {
195
+ const error = {
196
+ name: file.name,
197
+ message: intl.formatMessage({
198
+ id: "uploader.invalidFileType",
199
+ defaultMessage: "The file type is invalid. Accepted types: {validTypes}",
200
+ }, { validTypes }),
201
+ };
202
+ this.errorList.push(error);
203
+ }
204
+ else if (!this.isValidSize(file.size)) {
205
+ const error = {
206
+ name: file.name,
207
+ message: intl.formatMessage({
208
+ id: "uploader.fileTooLarge",
209
+ defaultMessage: "The selected file is too large. Maximum file size is {size}Mb",
210
+ }, { size: this.maxSize }),
211
+ };
212
+ this.errorList.push(error);
213
+ }
214
+ else if (this.isDuplicate(file.name)) {
215
+ const error = {
216
+ name: file.name,
217
+ message: intl.formatMessage({
218
+ id: "uploader.duplicateName",
219
+ defaultMessage: "A file with this name already exists.",
220
+ }),
221
+ };
222
+ this.errorList.push(error);
223
+ }
224
+ else {
225
+ this.filesToUpload.push(file);
226
+ }
227
+ });
228
+ if (this.filesToUpload.length > 0) {
229
+ this.numFilesInProgress = this.filesToUpload.length;
230
+ this.wmUploaderFilesSelected.emit(this.filesToUpload);
231
+ this.wmFilesSelected.emit(this.filesToUpload); // deprecated
232
+ }
233
+ }
234
+ ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
235
+ }
236
+ downloadFile(file) {
237
+ this.clearErrors();
238
+ this.wmUploaderDownloadFile.emit(file.id);
239
+ this.wmDownloadFile.emit(file.id); // deprecated
240
+ }
241
+ deleteFile(file) {
242
+ this.clearErrors();
243
+ forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
244
+ this.wmUploaderDeleteFile.emit(file.id);
245
+ this.wmDeleteFile.emit(file.id); // deprecated
246
+ }
247
+ componentWillLoad() {
248
+ if (!this.buttonText) {
249
+ throw new Error("wm-uploader: button-text is a required prop");
250
+ }
251
+ if (this.type) {
252
+ console.warn("wm-uploader: type has been deprecated as of v3.1.0. Please use uploader-type instead.");
253
+ }
254
+ if (this.tempUploaderType === "1" && !this.emptyStateText) {
255
+ throw new Error("wm-uploader: empty-state-text is a required prop");
256
+ }
257
+ this.setMaxSize();
258
+ this.parseFiles();
259
+ this.clearErrors();
260
+ this.parseRejectedFiles();
261
+ }
262
+ componentDidLoad() {
263
+ // awkward way to handle Edge bug where file input dialog doesn't open on Enter key
264
+ // first, detect polyfill by checking the class name that it adds to the component
265
+ // (it's important NOT to execute the code below in normal browsers as it would open the dialog twice)
266
+ this.el.classList.contains("sc-wm-uploader-h") &&
267
+ // then add an even listener to force a click event when Enter key is pressed
268
+ this.inputEl &&
269
+ this.inputEl.addEventListener("keydown", (ev) => {
270
+ if (this.inputEl && ev.keyCode === 13) {
271
+ this.inputEl.click();
272
+ }
273
+ });
274
+ if (document.body.classList.contains("wmcl-user-is-tabbing")) {
275
+ this.toggleTabbingOn();
276
+ }
277
+ }
278
+ renderUploadSvg() {
279
+ return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" }, h("path", { transform: "rotate(-180.000000) translate(-452, -255.5)", fill: "#eae8ec", d: "M361,249.681818 L361,197.318182 C361,194.118182 365.555061,191.5 371.122358,191.5 L391.316463,191.5 L391.286495,200.562515 L369.871211,200.600292 L369.885404,200.622146 L369.886423,246.655947 L443.657038,246.840767 L443.657038,200.622146 L421.683537,200.622146 L421.683537,191.5 L441.978865,191.5 C447.546162,191.5 452,194.118182 452,197.318182 L452,249.681818 C452,252.881818 447.546162,255.5 441.978865,255.5 L371.122358,255.5 C365.504449,255.5 361,252.881818 361,249.681818 Z M391.5,207 L406,221 L420.5,207 L409.625,207 L409.625,172 L402.375,172 L402.375,207 L391.5,207 Z" })));
280
+ }
281
+ renderIcon() {
282
+ // mdi attachment icon (paper clip) is horizontal but we want it vertical
283
+ const rotate = this.icon && this.icon === "f066";
284
+ return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
285
+ }
286
+ renderInfo() {
287
+ return this.info && this.tempUploaderType === "2" ? h("span", { class: "info" }, this.info) : "";
288
+ }
289
+ renderNotif() {
290
+ return this.notif ? h("div", { class: "notif" }, this.notif.message) : "";
291
+ }
292
+ renderUploadButton(classes) {
293
+ return (h("div", { class: "info-wrapper" }, h("input", { ref: (el) => (this.inputEl = el), name: this.inputId, id: this.inputId, class: "sr-only", type: "file", multiple: true, onClick: () => this.clearErrors(), onChange: (e) => this.handleFiles(e), disabled: this.isDisabled() }), h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` }, this.renderIcon(), this.buttonText), this.renderInfo()));
294
+ }
295
+ renderEmptyState() {
296
+ return (h("div", { class: "empty-block" }, this.renderUploadSvg(), h("div", { class: `empty-message` }, this.emptyStateText), this.renderUploadButton("-primary empty-button"), this.renderNotif()));
297
+ }
298
+ renderErrorList() {
299
+ if (!!this.errorList.length) {
300
+ if (this.liveRegion) {
301
+ let srMessage = this.errorList.reduce(function (acc, err) {
302
+ return acc + `${err.name}: ${err.message} `;
303
+ }, "");
304
+ this.liveRegion.innerHTML = srMessage;
305
+ }
306
+ return (h("ul", { class: "error-list" }, this.errorList.map((err) => (h("li", null, h("div", { class: "file --error" }, h("div", { class: "file-info" }, h("span", { class: "filename" }, err.name))), h("div", { class: "error-message" }, err.message))))));
307
+ }
308
+ }
309
+ renderFileInProgress(item) {
310
+ const filename = item.type ? item.name + "." + item.type : item.name;
311
+ return (h("li", null, h("div", { class: "file --progress" }, h("div", { class: "progress", style: {
312
+ background: `linear-gradient(to right, rgba(67, 126, 142, 1) ${item.progress}%, transparent ${item.progress}%)`,
313
+ } }), h("div", { class: "file-info" }, h("span", { class: "filename" }, filename, " ", h("span", { class: "sr-only" }, "uploading"))))));
314
+ }
315
+ renderFile(item) {
316
+ return (h("li", null, h("div", { class: "file --saved" }, h("div", { class: "file-info" }, h("span", { class: "filename" }, item.name + "." + item.type)), h("div", { class: "file-controls" }, 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) }), h("wm-button", { class: "delete-button", "button-type": "icononly", tooltip: "remove", "tooltip-position": "bottom", "label-for-identical-buttons": `remove ${item.name}`, icon: "f1c0", onClick: () => this.deleteFile(item) })))));
317
+ }
318
+ renderFileList() {
319
+ if (this.fileList) {
320
+ this.sortBy === "name"
321
+ ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
322
+ : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
323
+ return (h("div", null, h("ul", { class: "inprogress-list" }, this.fileList.filter((item) => this.isItemUploading(item)).map((item) => this.renderFileInProgress(item))), h("ul", { class: "file-list" }, this.fileList.filter((item) => !this.isItemUploading(item)).map((item) => this.renderFile(item)))));
324
+ }
325
+ }
326
+ renderHeader() {
327
+ return (this.tempUploaderType === "2" && (h("div", { class: "header" }, h("div", { class: "slot-wrapper" }, h("slot", null), h("div", { class: "notif-wrapper" }, this.renderUploadButton(`-secondary ${this.isDisabled() ? "disabled" : ""}`), this.renderNotif())))));
328
+ }
329
+ renderFooter() {
330
+ return (this.tempUploaderType === "1" && (h("div", { class: "footer" }, h("div", { class: "notif-wrapper" }, h("div", { class: "filecount-wrapper" }, h("div", { class: "filecount" }, intl.formatMessage({
331
+ id: "uploader.filesAdded",
332
+ defaultMessage: "{numFiles, plural, one {1 file added} other {# files added}}",
333
+ }, { numFiles: this.fileList.length })), this.renderUploadButton(`-primary ${this.isDisabled() ? "disabled" : ""}`)), this.renderNotif()))));
334
+ }
335
+ renderWithItems() {
336
+ return (h("div", null, this.renderHeader(), h("div", { class: `list-container type${this.tempUploaderType}` }, this.renderErrorList(), this.renderFileList()), this.renderFooter()));
337
+ }
338
+ render() {
339
+ return (h(Host, null, this.isEmpty() && this.tempUploaderType === "1" ? this.renderEmptyState() : this.renderWithItems(), h("div", { ref: (el) => (this.liveRegion = el), class: "live-region sr-only", "aria-live": "assertive" // since it's directly linked to the action the user took, it should be read in priority. With polite, some messages get dismissed in favor of the page title
340
+ ,
341
+ "aria-atomic": "true" })));
342
+ }
343
+ get el() { return getElement(this); }
344
+ static get watchers() { return {
345
+ "files": ["parseFiles"],
346
+ "rejectedFiles": ["parseRejectedFiles"],
347
+ "maxSize": ["setMaxSize"],
348
+ "numFilesInProgress": ["uploadNotifications"]
349
+ }; }
350
+ };
351
351
  Uploader.style = wmUploaderCss;
352
352
 
353
353
  export { Uploader as wm_uploader };