@watermarkinsights/ripple 3.0.1-0 → 3.0.2-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 (224) hide show
  1. package/dist/{ripple/functions-316c1b23.js → cjs/functions-e3f5ae65.js} +188 -2391
  2. package/dist/cjs/global-1e540de6.js +38 -0
  3. package/dist/cjs/http-service-9e8c4dd5.js +57 -0
  4. package/dist/cjs/index-d930307d.js +1392 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/interfaces-30a74c1f.js +35 -0
  7. package/dist/cjs/loader.cjs.js +22 -0
  8. package/dist/cjs/priv-chart-popover.cjs.entry.js +89 -0
  9. package/dist/cjs/priv-datepicker.cjs.entry.js +672 -0
  10. package/dist/cjs/priv-navigator-button.cjs.entry.js +29 -0
  11. package/dist/cjs/priv-navigator-item.cjs.entry.js +34 -0
  12. package/dist/cjs/ripple.cjs.js +20 -0
  13. package/dist/cjs/wm-action-menu_2.cjs.entry.js +318 -0
  14. package/dist/cjs/wm-button.cjs.entry.js +152 -0
  15. package/dist/cjs/wm-chart-slice.cjs.entry.js +22 -0
  16. package/dist/cjs/wm-chart.cjs.entry.js +508 -0
  17. package/dist/cjs/wm-datepicker.cjs.entry.js +257 -0
  18. package/dist/cjs/wm-input.cjs.entry.js +110 -0
  19. package/dist/cjs/wm-modal-footer.cjs.entry.js +43 -0
  20. package/dist/cjs/wm-modal-header.cjs.entry.js +45 -0
  21. package/dist/cjs/wm-modal.cjs.entry.js +149 -0
  22. package/dist/cjs/wm-navigator.cjs.entry.js +279 -0
  23. package/dist/cjs/wm-network-uploader.cjs.entry.js +431 -0
  24. package/dist/cjs/wm-option_2.cjs.entry.js +483 -0
  25. package/dist/cjs/wm-pagination.cjs.entry.js +176 -0
  26. package/dist/cjs/wm-search.cjs.entry.js +231 -0
  27. package/dist/cjs/wm-snackbar.cjs.entry.js +160 -0
  28. package/dist/cjs/wm-tab-item_3.cjs.entry.js +316 -0
  29. package/dist/cjs/wm-tag-input.cjs.entry.js +538 -0
  30. package/dist/cjs/wm-timepicker.cjs.entry.js +386 -0
  31. package/dist/cjs/wm-toggletip.cjs.entry.js +128 -0
  32. package/dist/cjs/wm-uploader.cjs.entry.js +342 -0
  33. package/dist/cjs/wm-wrapper.cjs.entry.js +21 -0
  34. package/dist/collection/collection-manifest.json +131 -0
  35. package/dist/{ripple/ripple.css → collection/components/wm-action-menu/wm-action-menu.css} +80 -42
  36. package/dist/collection/components/wm-action-menu/wm-action-menu.js +392 -0
  37. package/dist/collection/components/wm-button/wm-button.css +572 -0
  38. package/dist/collection/components/wm-button/wm-button.js +365 -0
  39. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.css +132 -0
  40. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -0
  41. package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -0
  42. package/dist/collection/components/wm-chart/wm-chart.css +337 -0
  43. package/dist/collection/components/wm-chart/wm-chart.js +710 -0
  44. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +374 -0
  45. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1003 -0
  46. package/dist/collection/components/wm-datepicker/wm-datepicker.css +211 -0
  47. package/dist/collection/components/wm-datepicker/wm-datepicker.js +439 -0
  48. package/dist/collection/components/wm-input/wm-input.css +220 -0
  49. package/dist/collection/components/wm-input/wm-input.js +302 -0
  50. package/dist/collection/components/wm-menuitem/wm-menuitem.css +118 -0
  51. package/dist/collection/components/wm-menuitem/wm-menuitem.js +411 -0
  52. package/dist/collection/components/wm-modal/wm-modal-footer.css +84 -0
  53. package/dist/collection/components/wm-modal/wm-modal-footer.js +159 -0
  54. package/dist/collection/components/wm-modal/wm-modal-header.css +78 -0
  55. package/dist/collection/components/wm-modal/wm-modal-header.js +109 -0
  56. package/dist/collection/components/wm-modal/wm-modal.css +155 -0
  57. package/dist/collection/components/wm-modal/wm-modal.js +356 -0
  58. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.css +94 -0
  59. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -0
  60. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.css +67 -0
  61. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -0
  62. package/dist/collection/components/wm-navigator/wm-navigator.css +137 -0
  63. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -0
  64. package/dist/collection/components/wm-option/wm-option.css +162 -0
  65. package/dist/collection/components/wm-option/wm-option.js +394 -0
  66. package/dist/collection/components/wm-pagination/wm-pagination.css +217 -0
  67. package/dist/collection/components/wm-pagination/wm-pagination.js +348 -0
  68. package/dist/collection/components/wm-search/wm-search.css +155 -0
  69. package/dist/collection/components/wm-search/wm-search.js +439 -0
  70. package/dist/collection/components/wm-select/wm-select.css +315 -0
  71. package/dist/collection/components/wm-select/wm-select.js +676 -0
  72. package/dist/collection/components/wm-snackbar/wm-snackbar.css +331 -0
  73. package/dist/collection/components/wm-snackbar/wm-snackbar.js +240 -0
  74. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +104 -0
  75. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +202 -0
  76. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.css +73 -0
  77. package/dist/{ripple/wm-tab-list.entry.js → collection/components/wm-tabs/wm-tab-list/wm-tab-list.js} +131 -17
  78. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.css +57 -0
  79. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -0
  80. package/dist/collection/components/wm-tag-input/wm-tag-input.css +431 -0
  81. package/dist/collection/components/wm-tag-input/wm-tag-input.js +754 -0
  82. package/dist/collection/components/wm-timepicker/wm-timepicker.css +370 -0
  83. package/dist/collection/components/wm-timepicker/wm-timepicker.js +567 -0
  84. package/dist/collection/components/wm-toggletip/wm-toggletip.css +350 -0
  85. package/dist/collection/components/wm-toggletip/wm-toggletip.js +217 -0
  86. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.css +642 -0
  87. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -0
  88. package/dist/collection/components/wm-uploader/wm-uploader.css +666 -0
  89. package/dist/collection/components/wm-uploader/wm-uploader.js +673 -0
  90. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -0
  91. package/dist/collection/dev/scripts.js +20 -0
  92. package/dist/collection/global/__mocks__/functions.js +5 -0
  93. package/dist/collection/global/functions.js +420 -0
  94. package/dist/{ripple/app-globals-b5693c90.js → collection/global/global.js} +3 -8
  95. package/dist/{ripple/interfaces-50753346.js → collection/global/interfaces.js} +4 -6
  96. package/dist/collection/global/services/__mocks__/http-service.js +130 -0
  97. package/dist/collection/global/services/http-service.js +50 -0
  98. package/dist/collection/lang/lang.js +5 -0
  99. package/dist/collection/lang/piglatin.js +93 -0
  100. package/dist/esm/functions-0deb7f8e.js +6117 -0
  101. package/dist/esm/global-d6b49e98.js +36 -0
  102. package/dist/{ripple → esm}/http-service-5d037e16.js +0 -0
  103. package/dist/esm/index-5a842e48.js +1363 -0
  104. package/dist/esm/index.js +1 -0
  105. package/dist/esm/interfaces-61c6305b.js +32 -0
  106. package/dist/esm/loader.js +18 -0
  107. package/dist/esm/polyfills/core-js.js +11 -0
  108. package/dist/esm/polyfills/css-shim.js +1 -0
  109. package/dist/esm/polyfills/dom.js +79 -0
  110. package/dist/esm/polyfills/es5-html-element.js +1 -0
  111. package/dist/esm/polyfills/index.js +34 -0
  112. package/dist/esm/polyfills/system.js +6 -0
  113. package/dist/{ripple → esm}/priv-chart-popover.entry.js +2 -2
  114. package/dist/{ripple → esm}/priv-datepicker.entry.js +3 -3
  115. package/dist/{ripple → esm}/priv-navigator-button.entry.js +1 -1
  116. package/dist/{ripple → esm}/priv-navigator-item.entry.js +1 -1
  117. package/dist/esm/ripple.js +18 -0
  118. package/dist/{ripple/wm-action-menu.entry.js → esm/wm-action-menu_2.entry.js} +114 -3
  119. package/dist/{ripple → esm}/wm-button.entry.js +3 -3
  120. package/dist/{ripple → esm}/wm-chart-slice.entry.js +1 -1
  121. package/dist/{ripple → esm}/wm-chart.entry.js +2 -2
  122. package/dist/{ripple → esm}/wm-datepicker.entry.js +27 -32
  123. package/dist/{ripple → esm}/wm-input.entry.js +2 -2
  124. package/dist/{ripple → esm}/wm-modal-footer.entry.js +2 -2
  125. package/dist/{ripple → esm}/wm-modal-header.entry.js +2 -2
  126. package/dist/{ripple → esm}/wm-modal.entry.js +2 -2
  127. package/dist/{ripple → esm}/wm-navigator.entry.js +3 -3
  128. package/dist/{ripple → esm}/wm-network-uploader.entry.js +2 -2
  129. package/dist/{ripple/wm-select.entry.js → esm/wm-option_2.entry.js} +119 -3
  130. package/dist/{ripple → esm}/wm-pagination.entry.js +2 -2
  131. package/dist/{ripple → esm}/wm-search.entry.js +2 -2
  132. package/dist/{ripple → esm}/wm-snackbar.entry.js +2 -2
  133. package/dist/esm/wm-tab-item_3.entry.js +310 -0
  134. package/dist/{ripple → esm}/wm-tag-input.entry.js +2 -2
  135. package/dist/{ripple → esm}/wm-timepicker.entry.js +2 -2
  136. package/dist/{ripple → esm}/wm-toggletip.entry.js +2 -2
  137. package/dist/{ripple → esm}/wm-uploader.entry.js +2 -2
  138. package/dist/{ripple → esm}/wm-wrapper.entry.js +1 -1
  139. package/dist/index.cjs.js +1 -0
  140. package/dist/index.js +1 -0
  141. package/dist/loader/cdn.js +3 -0
  142. package/dist/loader/index.cjs.js +3 -0
  143. package/dist/loader/index.d.ts +13 -0
  144. package/dist/loader/index.es2017.js +3 -0
  145. package/dist/loader/index.js +4 -0
  146. package/dist/loader/package.json +10 -0
  147. package/dist/ripple/index.esm.js +0 -1
  148. package/dist/ripple/p-103f8cae.entry.js +1 -0
  149. package/dist/ripple/p-129d94fa.entry.js +1 -0
  150. package/dist/ripple/p-139fe143.entry.js +1 -0
  151. package/dist/ripple/p-16367805.entry.js +1 -0
  152. package/dist/ripple/p-1d334060.entry.js +1 -0
  153. package/dist/ripple/p-2562f330.entry.js +1 -0
  154. package/dist/ripple/p-278b26ef.entry.js +1 -0
  155. package/dist/ripple/p-2c21bb72.entry.js +1 -0
  156. package/dist/ripple/p-2f5fda71.entry.js +1 -0
  157. package/dist/ripple/p-3e6f04d5.entry.js +1 -0
  158. package/dist/ripple/p-7185de7f.entry.js +1 -0
  159. package/dist/ripple/p-770d0798.entry.js +1 -0
  160. package/dist/ripple/p-846b4c5f.entry.js +1 -0
  161. package/dist/ripple/p-888bec42.js +1 -0
  162. package/dist/ripple/p-90779d53.entry.js +1 -0
  163. package/dist/ripple/p-934543f2.js +1 -0
  164. package/dist/ripple/p-9a087fee.entry.js +1 -0
  165. package/dist/ripple/p-a6d6eae7.js +1 -0
  166. package/dist/ripple/p-a942ad10.entry.js +1 -0
  167. package/dist/ripple/p-bfb4652d.entry.js +1 -0
  168. package/dist/ripple/p-c0fe5201.entry.js +1 -0
  169. package/dist/ripple/p-c2e27acc.entry.js +1 -0
  170. package/dist/ripple/p-c2edda64.entry.js +1 -0
  171. package/dist/ripple/p-d1fdcbcf.entry.js +1 -0
  172. package/dist/ripple/p-d40b6afb.entry.js +1 -0
  173. package/dist/ripple/p-da73db1c.entry.js +1 -0
  174. package/dist/ripple/p-e3843249.js +1 -0
  175. package/dist/ripple/p-ea5cd8b8.js +16 -0
  176. package/dist/ripple/p-ed0f43f4.entry.js +1 -0
  177. package/dist/ripple/p-ffafd363.entry.js +1 -0
  178. package/dist/ripple/ripple.esm.js +1 -125
  179. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +43 -0
  180. package/dist/types/components/wm-button/wm-button.d.ts +36 -0
  181. package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -0
  182. package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -0
  183. package/dist/types/components/wm-chart/wm-chart.d.ts +77 -0
  184. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +75 -0
  185. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +39 -0
  186. package/dist/types/components/wm-input/wm-input.d.ts +30 -0
  187. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +30 -0
  188. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -0
  189. package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -0
  190. package/dist/types/components/wm-modal/wm-modal.d.ts +34 -0
  191. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -0
  192. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -0
  193. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -0
  194. package/dist/types/components/wm-option/wm-option.d.ts +28 -0
  195. package/dist/types/components/wm-pagination/wm-pagination.d.ts +31 -0
  196. package/dist/types/components/wm-search/wm-search.d.ts +78 -0
  197. package/dist/types/components/wm-select/wm-select.d.ts +63 -0
  198. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +32 -0
  199. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +35 -0
  200. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +50 -0
  201. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -0
  202. package/dist/types/components/wm-tag-input/{wm-tag-input.d.ts~ds312_tagInputMaxTags → wm-tag-input.d.ts} +1 -1
  203. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +59 -0
  204. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -0
  205. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -0
  206. package/dist/types/components/wm-uploader/wm-uploader.d.ts +75 -0
  207. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -0
  208. package/dist/types/{components.d.ts~ds312_tagInputMaxTags → components.d.ts} +0 -0
  209. package/dist/types/global/__mocks__/functions.d.ts +5 -0
  210. package/dist/types/global/global.d.ts +1 -0
  211. package/dist/types/global/interfaces.d.ts +33 -0
  212. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -0
  213. package/dist/types/global/services/http-service.d.ts +4 -0
  214. package/dist/types/lang/lang.d.ts +5 -0
  215. package/dist/types/{stencil-public-runtime.d.ts~ds312_tagInputMaxTags → stencil-public-runtime.d.ts} +190 -182
  216. package/package.json +1 -1
  217. package/dist/ripple/css-shim-bbdf0cc6.js +0 -4
  218. package/dist/ripple/dom-1f98a75f.js +0 -73
  219. package/dist/ripple/index-20b65f86.js +0 -2938
  220. package/dist/ripple/shadow-css-67b66845.js +0 -389
  221. package/dist/ripple/wm-menuitem.entry.js +0 -114
  222. package/dist/ripple/wm-option.entry.js +0 -119
  223. package/dist/ripple/wm-tab-item.entry.js +0 -78
  224. package/dist/ripple/wm-tab-panel.entry.js +0 -38
@@ -0,0 +1,673 @@
1
+ import { Component, Element, Event, h, Host, Prop, State, Listen, Watch } from "@stencil/core";
2
+ import { forceUpdate } from "@stencil/core";
3
+ import { intl, generateId, hasValidType } from "../../global/functions";
4
+ export class Uploader {
5
+ constructor() {
6
+ this.type = "1";
7
+ this.fileTypes = "pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv";
8
+ this.maxSize = 100; // in Mb
9
+ this.sortBy = "date"; // name is descending (a -> z), date is ascending (earlier -> later)
10
+ this.fileList = []; // the string above transformed into the actual array
11
+ this.filesToUpload = []; // input.files that passed validation
12
+ this.isTabbing = false;
13
+ this.errorList = []; // for errors on a particular file
14
+ this.inputId = generateId();
15
+ }
16
+ toggleTabbingOn() {
17
+ this.isTabbing = true;
18
+ }
19
+ toggleTabbingOff() {
20
+ this.isTabbing = false;
21
+ }
22
+ handleUploadProgress(ev) {
23
+ this.fileList.map((i) => {
24
+ if (i.id === ev.detail.id) {
25
+ i.progress = ev.detail.progress;
26
+ forceUpdate(this.el);
27
+ }
28
+ });
29
+ if (ev.detail.progress === 100) {
30
+ // inProgressList is not a perfect reflection of how many files are uploading
31
+ // because even after progress reached 100% the item should remain in the array
32
+ // (should only be removed once it appears in fileList)
33
+ this.numFilesInProgress -= 1;
34
+ }
35
+ // aggregate the percentages for SR to announce progress
36
+ if (!this.srProgress && this.numFilesInProgress) {
37
+ const total = this.numFilesInProgress; // if we don't reassign this number changes when a file is done and the percentage becomes wrong
38
+ this.srProgress = setInterval(() => {
39
+ const aggregate = this.fileList.reduce((avg, item) => (item.progress ? avg + item.progress : avg), 0);
40
+ if (this.liveRegion) {
41
+ this.liveRegion.innerHTML = intl.formatMessage({
42
+ id: "uploader.uploadProgress",
43
+ defaultMessage: "Upload progress: {percentage}%",
44
+ }, { percentage: Math.floor(aggregate / total) });
45
+ }
46
+ }, 5000);
47
+ }
48
+ }
49
+ parseFiles() {
50
+ if (!!this.files) {
51
+ if (typeof this.files === "string") {
52
+ const list = JSON.parse(this.files);
53
+ if (typeof list === "object") {
54
+ this.fileList = list;
55
+ }
56
+ else {
57
+ throw new Error("could not parse string passed to files attribute");
58
+ }
59
+ }
60
+ else {
61
+ throw new Error("Attribute 'files' should be a string");
62
+ }
63
+ }
64
+ }
65
+ parseRejectedFiles() {
66
+ if (!!this.rejectedFiles) {
67
+ if (typeof this.files === "string") {
68
+ const list = JSON.parse(this.rejectedFiles);
69
+ if (typeof list === "object") {
70
+ this.errorList = list;
71
+ }
72
+ else {
73
+ throw new Error("could not parse string passed to errors attribute");
74
+ }
75
+ }
76
+ else {
77
+ throw new Error("Attribute 'rejected-files' should be a string");
78
+ }
79
+ }
80
+ }
81
+ setMaxSize() {
82
+ // Max size can't be set above 100Mb
83
+ this.maxSize = this.maxSize > 100 ? 100 : this.maxSize;
84
+ }
85
+ uploadNotifications(newNum, oldNum) {
86
+ if (oldNum > 0 && newNum === 0) {
87
+ setTimeout(() => {
88
+ this.notif = null;
89
+ }, 20 * 1000);
90
+ const message = intl.formatMessage({
91
+ id: "uploader.finishedUploading",
92
+ defaultMessage: "Finished uploading",
93
+ });
94
+ this.notif = { id: 5, message };
95
+ if (this.liveRegion) {
96
+ this.liveRegion.innerHTML = message;
97
+ }
98
+ this.numFilesInProgress = null;
99
+ clearInterval(this.srProgress);
100
+ forceUpdate(this.el);
101
+ }
102
+ else if (newNum > 0 && newNum != oldNum) {
103
+ const message = intl.formatMessage({
104
+ id: "uploader.filesUploading",
105
+ defaultMessage: "{num, plural, one {1 file uploading} other {# files uploading}}",
106
+ }, { num: newNum });
107
+ this.notif = { id: 6, message };
108
+ if (this.liveRegion) {
109
+ this.liveRegion.innerHTML = message;
110
+ }
111
+ forceUpdate(this.el);
112
+ }
113
+ }
114
+ isValidSize(size) {
115
+ // https://stackoverflow.com/questions/2365100/converting-bytes-to-megabytes
116
+ return size / 1024 / 1024 <= this.maxSize;
117
+ }
118
+ isDuplicate(name) {
119
+ return this.fileList.find((f) => {
120
+ const filename = f.type ? f.name + "." + f.type : f.name;
121
+ return filename === name;
122
+ });
123
+ }
124
+ isEmpty() {
125
+ return !this.fileList.length && !this.errorList.length;
126
+ }
127
+ isDisabled() {
128
+ const isMax = !!this.maxFiles && this.fileList.length >= this.maxFiles;
129
+ if (!this.notif) {
130
+ if (isMax) {
131
+ const errMessage = intl.formatMessage({
132
+ id: "uploader.fileUploadLimit",
133
+ defaultMessage: "You have reached the file upload limit.",
134
+ });
135
+ this.notif = { id: 1, message: errMessage };
136
+ if (this.liveRegion) {
137
+ this.liveRegion.innerHTML = errMessage;
138
+ }
139
+ }
140
+ else {
141
+ this.notif = null;
142
+ }
143
+ }
144
+ else if (this.notif.id === 1) {
145
+ // to make sure SR don't repeat the error, don't reset it if it already is showing
146
+ // just dismiss it if isMax is not true anymore
147
+ if (!isMax) {
148
+ this.notif = null;
149
+ }
150
+ // finally do nothing if error 2 is showing (special case when user selects too many files)
151
+ }
152
+ // disable if is the uploader is maxed out or if something is uploading
153
+ return isMax || this.numFilesInProgress > 0;
154
+ }
155
+ isItemUploading(item) {
156
+ return item.hasOwnProperty("progress") && item.progress < 100;
157
+ }
158
+ clearErrors() {
159
+ this.errorList = [];
160
+ this.notif = null;
161
+ }
162
+ handleFiles(ev) {
163
+ this.filesToUpload = [];
164
+ const validTypes = this.fileTypes.split(" ").join(", ");
165
+ const files = Array.from(ev.target.files);
166
+ if (!!this.maxFiles && this.fileList.length + files.length > this.maxFiles) {
167
+ const errMessage = intl.formatMessage({
168
+ id: "uploader.fileUploadExceeded",
169
+ defaultMessage: "The number of selected files exceeds the limit.",
170
+ });
171
+ this.notif = { id: 2, message: errMessage };
172
+ if (this.liveRegion) {
173
+ this.liveRegion.innerHTML = errMessage;
174
+ }
175
+ }
176
+ else {
177
+ files &&
178
+ files.map((file) => {
179
+ if (!hasValidType(file, this.fileTypes)) {
180
+ const error = {
181
+ name: file.name,
182
+ message: intl.formatMessage({
183
+ id: "uploader.invalidFileType",
184
+ defaultMessage: "The file type is invalid. Accepted types: {validTypes}",
185
+ }, { validTypes }),
186
+ };
187
+ this.errorList.push(error);
188
+ }
189
+ else if (!this.isValidSize(file.size)) {
190
+ const error = {
191
+ name: file.name,
192
+ message: intl.formatMessage({
193
+ id: "uploader.fileTooLarge",
194
+ defaultMessage: "The selected file is too large. Maximum file size is {size}Mb",
195
+ }, { size: this.maxSize }),
196
+ };
197
+ this.errorList.push(error);
198
+ }
199
+ else if (this.isDuplicate(file.name)) {
200
+ const error = {
201
+ name: file.name,
202
+ message: intl.formatMessage({
203
+ id: "uploader.duplicateName",
204
+ defaultMessage: "A file with this name already exists.",
205
+ }),
206
+ };
207
+ this.errorList.push(error);
208
+ }
209
+ else {
210
+ this.filesToUpload.push(file);
211
+ }
212
+ });
213
+ if (this.filesToUpload.length > 0) {
214
+ this.numFilesInProgress = this.filesToUpload.length;
215
+ this.wmFilesSelected.emit(this.filesToUpload);
216
+ }
217
+ }
218
+ ev.target.value = ""; // reset to ensure that onChange is triggered when the same file is selected a second time
219
+ }
220
+ downloadFile(file) {
221
+ this.clearErrors();
222
+ this.wmDownloadFile.emit(file.id);
223
+ }
224
+ deleteFile(file) {
225
+ this.clearErrors();
226
+ forceUpdate(this.el); // for the button to stop being disabled if num files become < max-files
227
+ this.wmDeleteFile.emit(file.id);
228
+ }
229
+ componentWillLoad() {
230
+ if (!this.buttonText) {
231
+ throw new Error("wm-uploader: button-text is a required prop");
232
+ }
233
+ if (this.type === "1" && !this.emptyStateText) {
234
+ throw new Error("wm-uploader: empty-state-text is a required prop");
235
+ }
236
+ this.setMaxSize();
237
+ this.parseFiles();
238
+ this.clearErrors();
239
+ this.parseRejectedFiles();
240
+ }
241
+ componentDidLoad() {
242
+ // awkward way to handle Edge bug where file input dialog doesn't open on Enter key
243
+ // first, detect polyfill by checking the class name that it adds to the component
244
+ // (it's important NOT to execute the code below in normal browsers as it would open the dialog twice)
245
+ this.el.classList.contains("sc-wm-uploader-h") &&
246
+ // then add an even listener to force a click event when Enter key is pressed
247
+ this.inputEl &&
248
+ this.inputEl.addEventListener("keydown", (ev) => {
249
+ if (this.inputEl && ev.keyCode === 13) {
250
+ this.inputEl.click();
251
+ }
252
+ });
253
+ if (document.body.classList.contains("wmcl-user-is-tabbing")) {
254
+ this.toggleTabbingOn();
255
+ }
256
+ }
257
+ renderUploadSvg() {
258
+ return (h("svg", { class: "upload-file", width: "91", height: "84", viewBox: "0 0 91 84" },
259
+ 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" })));
260
+ }
261
+ renderIcon() {
262
+ // mdi attachment icon (paper clip) is horizontal but we want it vertical
263
+ const rotate = this.icon && this.icon === "f066";
264
+ return (this.icon && (h("span", { class: `mdi ${rotate ? "rotate" : ""}` }, String.fromCodePoint(parseInt(`0x${this.icon}`)))));
265
+ }
266
+ renderInfo() {
267
+ return this.info && this.type === "2" ? h("span", { class: "info" }, this.info) : "";
268
+ }
269
+ renderNotif() {
270
+ return this.notif ? h("div", { class: "notif" }, this.notif.message) : "";
271
+ }
272
+ renderUploadButton(classes) {
273
+ return (h("div", { class: "info-wrapper" },
274
+ 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() }),
275
+ h("label", { htmlFor: this.inputId, class: `wm-button ${classes}${this.isTabbing ? " user-is-tabbing" : ""}` },
276
+ this.renderIcon(),
277
+ this.buttonText),
278
+ this.renderInfo()));
279
+ }
280
+ renderEmptyState() {
281
+ return (h("div", { class: "empty-block" },
282
+ this.renderUploadSvg(),
283
+ h("div", { class: `empty-message` }, this.emptyStateText),
284
+ this.renderUploadButton("-primary empty-button"),
285
+ this.renderNotif()));
286
+ }
287
+ renderErrorList() {
288
+ if (!!this.errorList.length) {
289
+ if (this.liveRegion) {
290
+ let srMessage = this.errorList.reduce(function (acc, err) {
291
+ return acc + `${err.name}: ${err.message} `;
292
+ }, "");
293
+ this.liveRegion.innerHTML = srMessage;
294
+ }
295
+ return (h("ul", { class: "error-list" }, this.errorList.map((err) => (h("li", null,
296
+ h("div", { class: "file --error" },
297
+ h("div", { class: "file-info" },
298
+ h("span", { class: "filename" }, err.name))),
299
+ h("div", { class: "error-message" }, err.message))))));
300
+ }
301
+ }
302
+ renderFileInProgress(item) {
303
+ const filename = item.type ? item.name + "." + item.type : item.name;
304
+ return (h("li", null,
305
+ h("div", { class: "file --progress" },
306
+ h("div", { class: "progress", style: {
307
+ background: `linear-gradient(to right, rgba(67, 126, 142, 1) ${item.progress}%, transparent ${item.progress}%)`,
308
+ } }),
309
+ h("div", { class: "file-info" },
310
+ h("span", { class: "filename" },
311
+ filename,
312
+ " ",
313
+ h("span", { class: "sr-only" }, "uploading"))))));
314
+ }
315
+ renderFile(item) {
316
+ return (h("li", null,
317
+ h("div", { class: "file --saved" },
318
+ h("div", { class: "file-info" },
319
+ h("span", { class: "filename" }, item.name + "." + item.type)),
320
+ h("div", { class: "file-controls" },
321
+ h("wm-button", { class: "download-button", "button-style": "icononly", tooltip: "download", "tooltip-position": "bottom", "label-for-identical-buttons": `download ${item.name}`, icon: "f1da", onClick: () => this.downloadFile(item) }),
322
+ h("wm-button", { class: "delete-button", "button-style": "icononly", tooltip: "remove", "tooltip-position": "bottom", "label-for-identical-buttons": `remove ${item.name}`, icon: "f1c0", onClick: () => this.deleteFile(item) })))));
323
+ }
324
+ renderFileList() {
325
+ if (this.fileList) {
326
+ this.sortBy === "name"
327
+ ? this.fileList.sort((a, b) => a.name.localeCompare(b.name))
328
+ : this.fileList.sort((a, b) => Date.parse(a.lastUpdated) - Date.parse(b.lastUpdated));
329
+ return (h("div", null,
330
+ h("ul", { class: "inprogress-list" }, this.fileList.filter((item) => this.isItemUploading(item)).map((item) => this.renderFileInProgress(item))),
331
+ h("ul", { class: "file-list" }, this.fileList.filter((item) => !this.isItemUploading(item)).map((item) => this.renderFile(item)))));
332
+ }
333
+ }
334
+ renderHeader() {
335
+ return (this.type === "2" && (h("div", { class: "header" },
336
+ h("div", { class: "slot-wrapper" },
337
+ h("slot", null),
338
+ h("div", { class: "notif-wrapper" },
339
+ this.renderUploadButton(`-secondary ${this.isDisabled() ? "disabled" : ""}`),
340
+ this.renderNotif())))));
341
+ }
342
+ renderFooter() {
343
+ return (this.type === "1" && (h("div", { class: "footer" },
344
+ h("div", { class: "notif-wrapper" },
345
+ h("div", { class: "filecount-wrapper" },
346
+ h("div", { class: "filecount" }, intl.formatMessage({
347
+ id: "uploader.filesAdded",
348
+ defaultMessage: "{numFiles, plural, one {1 file added} other {# files added}}",
349
+ }, { numFiles: this.fileList.length })),
350
+ this.renderUploadButton(`-primary ${this.isDisabled() ? "disabled" : ""}`)),
351
+ this.renderNotif()))));
352
+ }
353
+ renderWithItems() {
354
+ return (h("div", null,
355
+ this.renderHeader(),
356
+ h("div", { class: `list-container type${this.type}` },
357
+ this.renderErrorList(),
358
+ this.renderFileList()),
359
+ this.renderFooter()));
360
+ }
361
+ render() {
362
+ return (h(Host, null,
363
+ this.isEmpty() && this.type === "1" ? this.renderEmptyState() : this.renderWithItems(),
364
+ 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
365
+ , "aria-atomic": "true" })));
366
+ }
367
+ static get is() { return "wm-uploader"; }
368
+ static get encapsulation() { return "shadow"; }
369
+ static get originalStyleUrls() { return {
370
+ "$": ["wm-uploader.scss"]
371
+ }; }
372
+ static get styleUrls() { return {
373
+ "$": ["wm-uploader.css"]
374
+ }; }
375
+ static get properties() { return {
376
+ "type": {
377
+ "type": "string",
378
+ "mutable": false,
379
+ "complexType": {
380
+ "original": "\"1\" | \"2\"",
381
+ "resolved": "\"1\" | \"2\"",
382
+ "references": {}
383
+ },
384
+ "required": false,
385
+ "optional": false,
386
+ "docs": {
387
+ "tags": [],
388
+ "text": ""
389
+ },
390
+ "attribute": "type",
391
+ "reflect": false,
392
+ "defaultValue": "\"1\""
393
+ },
394
+ "buttonText": {
395
+ "type": "string",
396
+ "mutable": false,
397
+ "complexType": {
398
+ "original": "string",
399
+ "resolved": "string",
400
+ "references": {}
401
+ },
402
+ "required": true,
403
+ "optional": false,
404
+ "docs": {
405
+ "tags": [],
406
+ "text": ""
407
+ },
408
+ "attribute": "button-text",
409
+ "reflect": false
410
+ },
411
+ "info": {
412
+ "type": "string",
413
+ "mutable": false,
414
+ "complexType": {
415
+ "original": "string",
416
+ "resolved": "string | undefined",
417
+ "references": {}
418
+ },
419
+ "required": false,
420
+ "optional": true,
421
+ "docs": {
422
+ "tags": [],
423
+ "text": ""
424
+ },
425
+ "attribute": "info",
426
+ "reflect": false
427
+ },
428
+ "emptyStateText": {
429
+ "type": "string",
430
+ "mutable": false,
431
+ "complexType": {
432
+ "original": "string",
433
+ "resolved": "string",
434
+ "references": {}
435
+ },
436
+ "required": true,
437
+ "optional": false,
438
+ "docs": {
439
+ "tags": [],
440
+ "text": ""
441
+ },
442
+ "attribute": "empty-state-text",
443
+ "reflect": false
444
+ },
445
+ "icon": {
446
+ "type": "string",
447
+ "mutable": false,
448
+ "complexType": {
449
+ "original": "string",
450
+ "resolved": "string",
451
+ "references": {}
452
+ },
453
+ "required": true,
454
+ "optional": false,
455
+ "docs": {
456
+ "tags": [],
457
+ "text": ""
458
+ },
459
+ "attribute": "icon",
460
+ "reflect": false
461
+ },
462
+ "fileTypes": {
463
+ "type": "string",
464
+ "mutable": false,
465
+ "complexType": {
466
+ "original": "string",
467
+ "resolved": "string",
468
+ "references": {}
469
+ },
470
+ "required": false,
471
+ "optional": false,
472
+ "docs": {
473
+ "tags": [],
474
+ "text": ""
475
+ },
476
+ "attribute": "file-types",
477
+ "reflect": false,
478
+ "defaultValue": "\"pdf txt log xml doc docx xls xlsx ppt pptx gif jpg jpeg png csv\""
479
+ },
480
+ "maxSize": {
481
+ "type": "number",
482
+ "mutable": false,
483
+ "complexType": {
484
+ "original": "number",
485
+ "resolved": "number",
486
+ "references": {}
487
+ },
488
+ "required": false,
489
+ "optional": false,
490
+ "docs": {
491
+ "tags": [],
492
+ "text": ""
493
+ },
494
+ "attribute": "max-size",
495
+ "reflect": false,
496
+ "defaultValue": "100"
497
+ },
498
+ "maxFiles": {
499
+ "type": "number",
500
+ "mutable": false,
501
+ "complexType": {
502
+ "original": "number",
503
+ "resolved": "number | undefined",
504
+ "references": {}
505
+ },
506
+ "required": false,
507
+ "optional": true,
508
+ "docs": {
509
+ "tags": [],
510
+ "text": ""
511
+ },
512
+ "attribute": "max-files",
513
+ "reflect": false
514
+ },
515
+ "sortBy": {
516
+ "type": "string",
517
+ "mutable": false,
518
+ "complexType": {
519
+ "original": "\"name\" | \"date\"",
520
+ "resolved": "\"date\" | \"name\"",
521
+ "references": {}
522
+ },
523
+ "required": false,
524
+ "optional": false,
525
+ "docs": {
526
+ "tags": [],
527
+ "text": ""
528
+ },
529
+ "attribute": "sort-by",
530
+ "reflect": false,
531
+ "defaultValue": "\"date\""
532
+ },
533
+ "files": {
534
+ "type": "string",
535
+ "mutable": false,
536
+ "complexType": {
537
+ "original": "string",
538
+ "resolved": "string | undefined",
539
+ "references": {}
540
+ },
541
+ "required": false,
542
+ "optional": true,
543
+ "docs": {
544
+ "tags": [],
545
+ "text": ""
546
+ },
547
+ "attribute": "files",
548
+ "reflect": false
549
+ },
550
+ "filesToUpload": {
551
+ "type": "unknown",
552
+ "mutable": false,
553
+ "complexType": {
554
+ "original": "File[]",
555
+ "resolved": "File[]",
556
+ "references": {
557
+ "File": {
558
+ "location": "global"
559
+ }
560
+ }
561
+ },
562
+ "required": false,
563
+ "optional": false,
564
+ "docs": {
565
+ "tags": [],
566
+ "text": ""
567
+ },
568
+ "defaultValue": "[]"
569
+ },
570
+ "rejectedFiles": {
571
+ "type": "string",
572
+ "mutable": false,
573
+ "complexType": {
574
+ "original": "string",
575
+ "resolved": "string | undefined",
576
+ "references": {}
577
+ },
578
+ "required": false,
579
+ "optional": true,
580
+ "docs": {
581
+ "tags": [],
582
+ "text": ""
583
+ },
584
+ "attribute": "rejected-files",
585
+ "reflect": false
586
+ }
587
+ }; }
588
+ static get states() { return {
589
+ "isTabbing": {},
590
+ "errorList": {},
591
+ "notif": {},
592
+ "numFilesInProgress": {}
593
+ }; }
594
+ static get events() { return [{
595
+ "method": "wmFilesSelected",
596
+ "name": "wmFilesSelected",
597
+ "bubbles": true,
598
+ "cancelable": true,
599
+ "composed": true,
600
+ "docs": {
601
+ "tags": [],
602
+ "text": ""
603
+ },
604
+ "complexType": {
605
+ "original": "any",
606
+ "resolved": "any",
607
+ "references": {}
608
+ }
609
+ }, {
610
+ "method": "wmDeleteFile",
611
+ "name": "wmDeleteFile",
612
+ "bubbles": true,
613
+ "cancelable": true,
614
+ "composed": true,
615
+ "docs": {
616
+ "tags": [],
617
+ "text": ""
618
+ },
619
+ "complexType": {
620
+ "original": "any",
621
+ "resolved": "any",
622
+ "references": {}
623
+ }
624
+ }, {
625
+ "method": "wmDownloadFile",
626
+ "name": "wmDownloadFile",
627
+ "bubbles": true,
628
+ "cancelable": true,
629
+ "composed": true,
630
+ "docs": {
631
+ "tags": [],
632
+ "text": ""
633
+ },
634
+ "complexType": {
635
+ "original": "any",
636
+ "resolved": "any",
637
+ "references": {}
638
+ }
639
+ }]; }
640
+ static get elementRef() { return "el"; }
641
+ static get watchers() { return [{
642
+ "propName": "files",
643
+ "methodName": "parseFiles"
644
+ }, {
645
+ "propName": "rejectedFiles",
646
+ "methodName": "parseRejectedFiles"
647
+ }, {
648
+ "propName": "maxSize",
649
+ "methodName": "setMaxSize"
650
+ }, {
651
+ "propName": "numFilesInProgress",
652
+ "methodName": "uploadNotifications"
653
+ }]; }
654
+ static get listeners() { return [{
655
+ "name": "wmUserIsTabbing",
656
+ "method": "toggleTabbingOn",
657
+ "target": "window",
658
+ "capture": false,
659
+ "passive": false
660
+ }, {
661
+ "name": "wmUserIsNotTabbing",
662
+ "method": "toggleTabbingOff",
663
+ "target": "window",
664
+ "capture": false,
665
+ "passive": false
666
+ }, {
667
+ "name": "wmUploadProgress",
668
+ "method": "handleUploadProgress",
669
+ "target": undefined,
670
+ "capture": false,
671
+ "passive": false
672
+ }]; }
673
+ }
@@ -0,0 +1,27 @@
1
+ import { Component, Element, Event } from "@stencil/core";
2
+ export class Wrapper {
3
+ componentDidLoad() {
4
+ this.wmWrapperLoaded.emit();
5
+ }
6
+ render() {
7
+ return;
8
+ }
9
+ static get is() { return "wm-wrapper"; }
10
+ static get events() { return [{
11
+ "method": "wmWrapperLoaded",
12
+ "name": "wmWrapperLoaded",
13
+ "bubbles": true,
14
+ "cancelable": true,
15
+ "composed": true,
16
+ "docs": {
17
+ "tags": [],
18
+ "text": ""
19
+ },
20
+ "complexType": {
21
+ "original": "void",
22
+ "resolved": "void",
23
+ "references": {}
24
+ }
25
+ }]; }
26
+ static get elementRef() { return "el"; }
27
+ }