@watermarkinsights/ripple 3.4.0 → 3.5.0-3
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.
- package/README.md +3 -3
- package/dist/cjs/functions-653e695c.js +6164 -0
- package/dist/cjs/{global-caec45e5.js → global-ee710089.js} +65 -65
- package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
- package/dist/cjs/{index-921ef454.js → index-cd179539.js} +157 -103
- package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/priv-chart-popover.cjs.entry.js +79 -79
- package/dist/cjs/priv-datepicker.cjs.entry.js +668 -668
- package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
- package/dist/cjs/priv-navigator-item.cjs.entry.js +24 -24
- package/dist/cjs/ripple.cjs.js +5 -5
- package/dist/cjs/wm-action-menu_2.cjs.entry.js +342 -342
- package/dist/cjs/wm-button.cjs.entry.js +219 -219
- package/dist/cjs/wm-chart-slice.cjs.entry.js +14 -14
- package/dist/cjs/wm-chart.cjs.entry.js +475 -517
- package/dist/cjs/wm-datepicker.cjs.entry.js +257 -257
- package/dist/cjs/wm-input.cjs.entry.js +134 -134
- package/dist/cjs/wm-modal-footer.cjs.entry.js +32 -32
- package/dist/cjs/wm-modal-header.cjs.entry.js +35 -35
- package/dist/cjs/wm-modal.cjs.entry.js +162 -162
- package/dist/cjs/wm-navigator.cjs.entry.js +269 -269
- package/dist/cjs/wm-network-uploader.cjs.entry.js +421 -421
- package/dist/cjs/wm-option_2.cjs.entry.js +492 -492
- package/dist/cjs/wm-pagination.cjs.entry.js +168 -168
- package/dist/cjs/wm-search.cjs.entry.js +232 -232
- package/dist/cjs/wm-snackbar.cjs.entry.js +171 -171
- package/dist/cjs/wm-tab-item_3.cjs.entry.js +301 -301
- package/dist/cjs/wm-tag-input.cjs.entry.js +557 -557
- package/dist/cjs/wm-timepicker.cjs.entry.js +384 -384
- package/dist/cjs/wm-toggletip.cjs.entry.js +125 -125
- package/dist/cjs/wm-uploader.cjs.entry.js +347 -347
- package/dist/cjs/wm-wrapper.cjs.entry.js +13 -13
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/wm-action-menu/wm-action-menu.js +460 -460
- package/dist/collection/components/wm-button/wm-button.js +485 -485
- package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -232
- package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -64
- package/dist/collection/components/wm-chart/wm-chart.css +71 -84
- package/dist/collection/components/wm-chart/wm-chart.js +718 -765
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1015 -1015
- package/dist/collection/components/wm-datepicker/wm-datepicker.js +462 -462
- package/dist/collection/components/wm-input/wm-input.js +423 -423
- package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
- package/dist/collection/components/wm-modal/wm-modal-footer.js +141 -141
- package/dist/collection/components/wm-modal/wm-modal-header.js +92 -92
- package/dist/collection/components/wm-modal/wm-modal.js +459 -459
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
- package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
- package/dist/collection/components/wm-option/wm-option.js +422 -422
- package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
- package/dist/collection/components/wm-search/wm-search.js +479 -479
- package/dist/collection/components/wm-select/wm-select.js +717 -717
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +219 -219
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +331 -331
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +787 -787
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +589 -589
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -753
- package/dist/collection/components/wm-uploader/wm-uploader.js +748 -748
- package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
- package/dist/collection/dev/scripts.js +20 -20
- package/dist/collection/global/__mocks__/functions.js +6 -6
- package/dist/collection/global/functions.js +445 -445
- package/dist/collection/global/global.js +72 -72
- package/dist/collection/global/interfaces.js +49 -49
- package/dist/collection/global/services/__mocks__/http-service.js +130 -130
- package/dist/collection/global/services/http-service.js +50 -50
- package/dist/collection/lang/lang.js +5 -5
- package/dist/collection/lang/piglatin.js +93 -93
- package/dist/esm/functions-e528c934.js +6144 -0
- package/dist/esm/{global-08ca269c.js → global-b94f59e6.js} +65 -65
- package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
- package/dist/esm/{index-f8b130b6.js → index-66f8130e.js} +157 -103
- package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +2 -2
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/priv-chart-popover.entry.js +79 -79
- package/dist/esm/priv-datepicker.entry.js +668 -668
- package/dist/esm/priv-navigator-button.entry.js +19 -19
- package/dist/esm/priv-navigator-item.entry.js +24 -24
- package/dist/esm/ripple.js +5 -5
- package/dist/esm/wm-action-menu_2.entry.js +342 -342
- package/dist/esm/wm-button.entry.js +219 -219
- package/dist/esm/wm-chart-slice.entry.js +14 -14
- package/dist/esm/wm-chart.entry.js +475 -517
- package/dist/esm/wm-datepicker.entry.js +257 -257
- package/dist/esm/wm-input.entry.js +134 -134
- package/dist/esm/wm-modal-footer.entry.js +32 -32
- package/dist/esm/wm-modal-header.entry.js +35 -35
- package/dist/esm/wm-modal.entry.js +162 -162
- package/dist/esm/wm-navigator.entry.js +269 -269
- package/dist/esm/wm-network-uploader.entry.js +421 -421
- package/dist/esm/wm-option_2.entry.js +492 -492
- package/dist/esm/wm-pagination.entry.js +168 -168
- package/dist/esm/wm-search.entry.js +232 -232
- package/dist/esm/wm-snackbar.entry.js +171 -171
- package/dist/esm/wm-tab-item_3.entry.js +301 -301
- package/dist/esm/wm-tag-input.entry.js +557 -557
- package/dist/esm/wm-timepicker.entry.js +384 -384
- package/dist/esm/wm-toggletip.entry.js +125 -125
- package/dist/esm/wm-uploader.entry.js +347 -347
- package/dist/esm/wm-wrapper.entry.js +13 -13
- package/dist/ripple/p-092b01f3.entry.js +1 -0
- package/dist/ripple/{p-c995acbc.entry.js → p-0c58f50d.entry.js} +1 -1
- package/dist/ripple/p-11c09317.entry.js +1 -0
- package/dist/ripple/p-1e0c41a9.entry.js +1 -0
- package/dist/ripple/p-3003d26d.entry.js +1 -0
- package/dist/ripple/p-33524565.entry.js +1 -0
- package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
- package/dist/ripple/{p-5e49aba7.entry.js → p-4cc71463.entry.js} +1 -1
- package/dist/ripple/p-588b4475.js +16 -0
- package/dist/ripple/p-65e3a656.entry.js +1 -0
- package/dist/ripple/p-7a96bb97.js +1 -0
- package/dist/ripple/p-83b8aaaf.entry.js +1 -0
- package/dist/ripple/p-8923b7d0.entry.js +1 -0
- package/dist/ripple/{p-d52033d5.entry.js → p-8b0eb05e.entry.js} +1 -1
- package/dist/ripple/p-8cd1396e.entry.js +1 -0
- package/dist/ripple/{p-22a1a636.entry.js → p-99db8501.entry.js} +1 -1
- package/dist/ripple/p-9baa3039.js +1 -0
- package/dist/ripple/p-aa973691.entry.js +1 -0
- package/dist/ripple/{p-a61977b2.entry.js → p-b3d5ea85.entry.js} +1 -1
- package/dist/ripple/{p-7d009793.entry.js → p-b5189f72.entry.js} +1 -1
- package/dist/ripple/p-bc27b604.entry.js +1 -0
- package/dist/ripple/p-bc9ca97b.entry.js +1 -0
- package/dist/ripple/{p-bba99fcd.entry.js → p-cd58a15c.entry.js} +1 -1
- package/dist/ripple/p-dc9c9fda.entry.js +1 -0
- package/dist/ripple/p-e7616311.entry.js +1 -0
- package/dist/ripple/p-e9e8334e.entry.js +1 -0
- package/dist/ripple/p-ec9697db.entry.js +1 -0
- package/dist/ripple/p-efdaf3b6.entry.js +1 -0
- package/dist/ripple/p-fcdc6395.entry.js +1 -0
- package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
- package/dist/ripple/ripple.esm.js +1 -1
- package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +48 -48
- package/dist/types/components/wm-button/wm-button.d.ts +44 -44
- package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -23
- package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -8
- package/dist/types/components/wm-chart/wm-chart.d.ts +81 -80
- package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +76 -76
- package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
- package/dist/types/components/wm-input/wm-input.d.ts +46 -46
- package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
- package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -15
- package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -12
- package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
- package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
- package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
- package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
- package/dist/types/components/wm-option/wm-option.d.ts +32 -32
- package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
- package/dist/types/components/wm-search/wm-search.d.ts +86 -86
- package/dist/types/components/wm-select/wm-select.d.ts +66 -66
- package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
- package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
- package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
- package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
- package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +91 -91
- package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
- package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
- package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
- package/dist/types/components/wm-uploader/wm-uploader.d.ts +80 -80
- package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
- package/dist/types/components.d.ts +24 -24
- package/dist/types/global/__mocks__/functions.d.ts +6 -6
- package/dist/types/global/functions.d.ts +40 -0
- package/dist/types/global/global.d.ts +1 -1
- package/dist/types/global/interfaces.d.ts +34 -34
- package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
- package/dist/types/global/services/http-service.d.ts +4 -4
- package/dist/types/lang/lang.d.ts +5 -5
- package/dist/types/stencil-public-runtime.d.ts +194 -186
- package/package.json +46 -46
- package/dist/cjs/functions-a6491ba8.js +0 -7943
- package/dist/esm/functions-5aebd578.js +0 -7923
- package/dist/ripple/p-0865e7cf.js +0 -16
- package/dist/ripple/p-0f663e59.entry.js +0 -1
- package/dist/ripple/p-1b790a7d.entry.js +0 -1
- package/dist/ripple/p-3b4c01b8.entry.js +0 -1
- package/dist/ripple/p-54c1f704.entry.js +0 -1
- package/dist/ripple/p-76c615e9.entry.js +0 -1
- package/dist/ripple/p-7d993d52.js +0 -1
- package/dist/ripple/p-8198cc9c.entry.js +0 -1
- package/dist/ripple/p-839d35bd.entry.js +0 -1
- package/dist/ripple/p-8708b8cb.entry.js +0 -1
- package/dist/ripple/p-8bd66955.entry.js +0 -1
- package/dist/ripple/p-957e3a05.entry.js +0 -1
- package/dist/ripple/p-af6eb4d5.entry.js +0 -1
- package/dist/ripple/p-b3f9f575.entry.js +0 -1
- package/dist/ripple/p-cd30198d.entry.js +0 -1
- package/dist/ripple/p-d9d6bf11.js +0 -1
- package/dist/ripple/p-e097c562.entry.js +0 -1
- package/dist/ripple/p-e9db6122.entry.js +0 -1
- package/dist/ripple/p-eabbd1e9.entry.js +0 -1
- package/dist/ripple/p-ec496b8b.entry.js +0 -1
- package/dist/ripple/p-fc8ec142.entry.js +0 -1
|
@@ -1,353 +1,353 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-
|
|
2
|
-
import { g as generateId, i as intl, p as hasValidType } from './functions-
|
|
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';
|
|
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 };
|