@watermarkinsights/ripple 3.8.0-4 → 3.8.0-5
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-1f0edc61.js → functions-83193a8d.js} +506 -532
- package/dist/cjs/{global-80d74e31.js → global-2f521eb7.js} +65 -65
- package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
- package/dist/cjs/{index-0e7e3668.js → index-cd179539.js} +64 -96
- 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 +674 -674
- 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 +3 -3
- package/dist/cjs/wm-action-menu_2.cjs.entry.js +342 -342
- package/dist/cjs/wm-button.cjs.entry.js +228 -228
- package/dist/cjs/wm-chart-slice.cjs.entry.js +14 -14
- package/dist/cjs/wm-chart.cjs.entry.js +475 -475
- package/dist/cjs/wm-datepicker.cjs.entry.js +273 -273
- package/dist/cjs/wm-input.cjs.entry.js +136 -136
- 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 +164 -164
- package/dist/cjs/wm-navigation_3.cjs.entry.js +220 -220
- package/dist/cjs/wm-navigator.cjs.entry.js +269 -269
- package/dist/cjs/wm-network-uploader.cjs.entry.js +422 -422
- package/dist/cjs/wm-option_2.cjs.entry.js +497 -497
- package/dist/cjs/wm-pagination.cjs.entry.js +168 -168
- package/dist/cjs/wm-search.cjs.entry.js +233 -233
- package/dist/cjs/wm-snackbar.cjs.entry.js +172 -172
- package/dist/cjs/wm-tab-item_3.cjs.entry.js +298 -298
- package/dist/cjs/wm-tag-input.cjs.entry.js +581 -581
- package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
- package/dist/cjs/wm-toggletip.cjs.entry.js +126 -126
- package/dist/cjs/wm-uploader.cjs.entry.js +348 -348
- 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.css +6 -1
- package/dist/collection/components/wm-button/wm-button.js +491 -491
- 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 +115 -115
- package/dist/collection/components/wm-chart/wm-chart.js +718 -718
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +4 -3
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1039 -1039
- package/dist/collection/components/wm-datepicker/wm-datepicker.css +2 -1
- package/dist/collection/components/wm-datepicker/wm-datepicker.js +483 -483
- package/dist/collection/components/wm-input/wm-input.css +2 -1
- 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 +461 -461
- package/dist/collection/components/wm-navigation/wm-navigation-hamburger.css +2 -1
- package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +152 -152
- package/dist/collection/components/wm-navigation/wm-navigation-item.js +105 -105
- package/dist/collection/components/wm-navigation/wm-navigation.js +193 -193
- 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.css +3 -2
- 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 +480 -480
- package/dist/collection/components/wm-select/wm-select.css +3 -2
- package/dist/collection/components/wm-select/wm-select.js +720 -720
- package/dist/collection/components/wm-snackbar/wm-snackbar.css +3 -2
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +2 -2
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +216 -216
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +330 -330
- 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.css +3 -2
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +810 -810
- package/dist/collection/components/wm-timepicker/wm-timepicker.css +3 -2
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +583 -583
- package/dist/collection/components/wm-toggletip/wm-toggletip.css +2 -1
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.css +2 -1
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -753
- package/dist/collection/components/wm-uploader/wm-uploader.css +2 -1
- 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 +468 -468
- 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/missing.js +39 -39
- package/dist/collection/lang/piglatin.js +93 -93
- package/dist/esm/{functions-b130b95f.js → functions-7eebdc16.js} +506 -532
- package/dist/esm/{global-22a1aa43.js → global-0dc2eb57.js} +65 -65
- package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
- package/dist/esm/{index-cd8f9ae2.js → index-66f8130e.js} +64 -96
- 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/css-shim.js +1 -1
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- 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 +674 -674
- 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 +3 -3
- package/dist/esm/wm-action-menu_2.entry.js +342 -342
- package/dist/esm/wm-button.entry.js +228 -228
- package/dist/esm/wm-chart-slice.entry.js +14 -14
- package/dist/esm/wm-chart.entry.js +475 -475
- package/dist/esm/wm-datepicker.entry.js +273 -273
- package/dist/esm/wm-input.entry.js +136 -136
- 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 +164 -164
- package/dist/esm/wm-navigation_3.entry.js +220 -220
- package/dist/esm/wm-navigator.entry.js +269 -269
- package/dist/esm/wm-network-uploader.entry.js +422 -422
- package/dist/esm/wm-option_2.entry.js +497 -497
- package/dist/esm/wm-pagination.entry.js +168 -168
- package/dist/esm/wm-search.entry.js +233 -233
- package/dist/esm/wm-snackbar.entry.js +172 -172
- package/dist/esm/wm-tab-item_3.entry.js +298 -298
- package/dist/esm/wm-tag-input.entry.js +581 -581
- package/dist/esm/wm-timepicker.entry.js +385 -385
- package/dist/esm/wm-toggletip.entry.js +126 -126
- package/dist/esm/wm-uploader.entry.js +348 -348
- package/dist/esm/wm-wrapper.entry.js +13 -13
- package/dist/esm-es5/functions-7eebdc16.js +15 -0
- package/dist/esm-es5/{global-22a1aa43.js → global-0dc2eb57.js} +1 -1
- package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +1 -1
- package/dist/esm-es5/index-66f8130e.js +1 -0
- package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
- package/dist/esm-es5/priv-datepicker.entry.js +1 -1
- package/dist/esm-es5/priv-navigator-button.entry.js +1 -1
- package/dist/esm-es5/priv-navigator-item.entry.js +1 -1
- package/dist/esm-es5/ripple.js +1 -1
- package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
- package/dist/esm-es5/wm-button.entry.js +1 -1
- package/dist/esm-es5/wm-chart-slice.entry.js +1 -1
- package/dist/esm-es5/wm-chart.entry.js +1 -1
- package/dist/esm-es5/wm-datepicker.entry.js +1 -1
- package/dist/esm-es5/wm-input.entry.js +1 -1
- package/dist/esm-es5/wm-modal-footer.entry.js +1 -1
- package/dist/esm-es5/wm-modal-header.entry.js +1 -1
- package/dist/esm-es5/wm-modal.entry.js +1 -1
- package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
- package/dist/esm-es5/wm-navigator.entry.js +1 -1
- package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
- package/dist/esm-es5/wm-option_2.entry.js +1 -1
- package/dist/esm-es5/wm-pagination.entry.js +1 -1
- package/dist/esm-es5/wm-search.entry.js +1 -1
- package/dist/esm-es5/wm-snackbar.entry.js +1 -1
- package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
- package/dist/esm-es5/wm-tag-input.entry.js +1 -1
- package/dist/esm-es5/wm-timepicker.entry.js +1 -1
- package/dist/esm-es5/wm-toggletip.entry.js +1 -1
- package/dist/esm-es5/wm-uploader.entry.js +1 -1
- package/dist/esm-es5/wm-wrapper.entry.js +1 -1
- package/dist/loader/index.d.ts +1 -0
- package/dist/ripple/{p-880d231c.system.js → p-00e0bf57.system.js} +1 -1
- package/dist/ripple/p-061a0f47.entry.js +1 -0
- package/dist/ripple/p-0b345e33.system.entry.js +1 -0
- package/dist/ripple/p-0b746618.entry.js +1 -0
- package/dist/ripple/p-0c58f50d.entry.js +1 -0
- package/dist/ripple/p-0d8bd4ee.entry.js +1 -0
- package/dist/ripple/p-0f8d7b58.system.entry.js +1 -0
- package/dist/ripple/p-119a14c1.entry.js +1 -0
- package/dist/ripple/{p-26d5f144.system.js → p-149db379.system.js} +1 -1
- package/dist/ripple/{p-040262af.system.entry.js → p-18af6ca6.system.entry.js} +1 -1
- package/dist/ripple/{p-12bd075c.system.entry.js → p-1ec7130b.system.entry.js} +1 -1
- package/dist/ripple/{p-c19298a5.system.entry.js → p-261ea633.system.entry.js} +1 -1
- package/dist/ripple/{p-9a9743f5.system.entry.js → p-2d49a016.system.entry.js} +1 -1
- package/dist/ripple/p-312f22ca.entry.js +1 -0
- package/dist/ripple/p-37907055.entry.js +1 -0
- package/dist/ripple/p-3c592c3b.entry.js +1 -0
- package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
- package/dist/ripple/p-48b385e6.entry.js +1 -0
- package/dist/ripple/p-501404ff.entry.js +1 -0
- package/dist/ripple/p-593e891e.entry.js +1 -0
- package/dist/ripple/p-5a08d74b.entry.js +1 -0
- package/dist/ripple/p-5a87e7d6.entry.js +1 -0
- package/dist/ripple/p-62a0f6a4.system.entry.js +1 -0
- package/dist/ripple/{p-e2398de1.js → p-6b6643f9.js} +1 -1
- package/dist/ripple/p-7093d32b.entry.js +1 -0
- package/dist/ripple/p-716fd2fa.system.entry.js +1 -0
- package/dist/ripple/{p-450d329a.system.entry.js → p-71bb4f49.system.entry.js} +1 -1
- package/dist/ripple/{p-e758db14.system.entry.js → p-7a9aac92.system.entry.js} +1 -1
- package/dist/ripple/{p-504579c2.system.entry.js → p-7bc744bf.system.entry.js} +1 -1
- package/dist/ripple/p-7fc8d607.system.entry.js +1 -0
- package/dist/ripple/p-820a1198.entry.js +1 -0
- package/dist/ripple/p-8b0eb05e.entry.js +1 -0
- package/dist/ripple/p-8bc0b663.system.entry.js +1 -0
- package/dist/ripple/p-99548d58.system.js +1 -0
- package/dist/ripple/p-99db8501.entry.js +1 -0
- package/dist/ripple/p-9b8f993d.entry.js +1 -0
- package/dist/ripple/p-9baa3039.js +1 -0
- package/dist/ripple/p-9d02957d.system.js +1 -0
- package/dist/ripple/p-a59094c9.system.entry.js +1 -0
- package/dist/ripple/p-a59713ca.entry.js +1 -0
- package/dist/ripple/p-a7e0ab85.entry.js +1 -0
- package/dist/ripple/{p-a5177480.system.entry.js → p-b3ce2033.system.entry.js} +1 -1
- package/dist/ripple/{p-6b8753b3.system.entry.js → p-bb31d263.system.entry.js} +1 -1
- package/dist/ripple/p-c34de6f3.system.entry.js +1 -0
- package/dist/ripple/p-c3615fa0.system.entry.js +1 -0
- package/dist/ripple/p-c45caf33.system.entry.js +1 -0
- package/dist/ripple/{p-6eed4845.system.entry.js → p-c652f945.system.entry.js} +1 -1
- package/dist/ripple/p-c68975d3.entry.js +1 -0
- package/dist/ripple/p-ca21ca3a.js +16 -0
- package/dist/ripple/p-cb283dba.system.entry.js +1 -0
- package/dist/ripple/p-ceabb993.entry.js +1 -0
- package/dist/ripple/p-d044fcf4.system.js +15 -0
- package/dist/ripple/p-d0643c9b.entry.js +1 -0
- package/dist/ripple/p-de09f545.system.entry.js +1 -0
- package/dist/ripple/{p-db4f099c.system.entry.js → p-dea73ebd.system.entry.js} +1 -1
- package/dist/ripple/p-e639b06c.system.entry.js +1 -0
- package/dist/ripple/{p-eb63bbcb.system.entry.js → p-eb0c2d8f.system.entry.js} +1 -1
- package/dist/ripple/p-f4fcd826.entry.js +1 -0
- package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
- package/dist/ripple/{p-08987f25.system.entry.js → p-f781014a.system.entry.js} +1 -1
- package/dist/ripple/p-f927e5da.entry.js +1 -0
- package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
- package/dist/ripple/p-ffc746cb.entry.js +1 -0
- package/dist/ripple/ripple.esm.js +1 -1
- package/dist/ripple/ripple.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 +43 -43
- 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 +11 -11
- package/dist/types/components/wm-chart/wm-chart.d.ts +82 -82
- package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
- package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +42 -42
- 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-navigation/wm-navigation-hamburger.d.ts +20 -20
- package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +11 -11
- package/dist/types/components/wm-navigation/wm-navigation.d.ts +28 -28
- 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 +92 -92
- package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +61 -61
- 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 +42 -42
- 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 +4 -6
- package/package.json +47 -47
- package/dist/esm-es5/functions-b130b95f.js +0 -15
- package/dist/esm-es5/index-cd8f9ae2.js +0 -1
- package/dist/ripple/p-08f8a387.system.js +0 -15
- package/dist/ripple/p-11e94b56.system.entry.js +0 -1
- package/dist/ripple/p-16b81b95.system.entry.js +0 -1
- package/dist/ripple/p-1aa63d75.entry.js +0 -1
- package/dist/ripple/p-1bc95574.system.entry.js +0 -1
- package/dist/ripple/p-20856a2d.system.js +0 -1
- package/dist/ripple/p-244877c8.entry.js +0 -1
- package/dist/ripple/p-28c23453.system.entry.js +0 -1
- package/dist/ripple/p-313b6073.system.js +0 -1
- package/dist/ripple/p-38062c39.js +0 -1
- package/dist/ripple/p-3ba3afca.entry.js +0 -1
- package/dist/ripple/p-3faf2b4d.entry.js +0 -1
- package/dist/ripple/p-4372e470.entry.js +0 -1
- package/dist/ripple/p-4be373bc.entry.js +0 -1
- package/dist/ripple/p-5345ef2c.entry.js +0 -1
- package/dist/ripple/p-5866f8c0.entry.js +0 -1
- package/dist/ripple/p-64176f58.entry.js +0 -1
- package/dist/ripple/p-6aa11b0c.system.entry.js +0 -1
- package/dist/ripple/p-6c1a8429.system.entry.js +0 -1
- package/dist/ripple/p-764fa608.entry.js +0 -1
- package/dist/ripple/p-7e118839.entry.js +0 -1
- package/dist/ripple/p-8a0450fd.entry.js +0 -1
- package/dist/ripple/p-8dd28361.entry.js +0 -1
- package/dist/ripple/p-91e122c6.entry.js +0 -1
- package/dist/ripple/p-97909b0f.entry.js +0 -1
- package/dist/ripple/p-a6cc08a5.system.entry.js +0 -1
- package/dist/ripple/p-a8584619.system.entry.js +0 -1
- package/dist/ripple/p-a9dd6fe1.entry.js +0 -1
- package/dist/ripple/p-add208d8.entry.js +0 -1
- package/dist/ripple/p-b3568fc3.system.entry.js +0 -1
- package/dist/ripple/p-b635fdfe.system.entry.js +0 -1
- package/dist/ripple/p-bfef8d9c.entry.js +0 -1
- package/dist/ripple/p-c0fd9e19.system.entry.js +0 -1
- package/dist/ripple/p-ce80b46d.entry.js +0 -1
- package/dist/ripple/p-d0ab4cf2.entry.js +0 -1
- package/dist/ripple/p-d0d3421d.system.entry.js +0 -1
- package/dist/ripple/p-d43a4e01.entry.js +0 -1
- package/dist/ripple/p-d4e46468.entry.js +0 -1
- package/dist/ripple/p-ddf5044a.entry.js +0 -1
- package/dist/ripple/p-e03a7b17.entry.js +0 -1
- package/dist/ripple/p-ea22b946.js +0 -16
- package/dist/ripple/p-ef344252.entry.js +0 -1
- package/dist/ripple/p-f44803ff.system.entry.js +0 -1
- package/dist/ripple/p-fa35e47b.entry.js +0 -1
|
@@ -3880,17 +3880,11 @@ function icuUnitToEcma(unit) {
|
|
|
3880
3880
|
return unit.replace(/^(.*?)-/, '');
|
|
3881
3881
|
}
|
|
3882
3882
|
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
|
|
3883
|
-
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)
|
|
3883
|
+
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
|
|
3884
3884
|
var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
|
|
3885
3885
|
var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
|
|
3886
3886
|
function parseSignificantPrecision(str) {
|
|
3887
3887
|
var result = {};
|
|
3888
|
-
if (str[str.length - 1] === 'r') {
|
|
3889
|
-
result.roundingPriority = 'morePrecision';
|
|
3890
|
-
}
|
|
3891
|
-
else if (str[str.length - 1] === 's') {
|
|
3892
|
-
result.roundingPriority = 'lessPrecision';
|
|
3893
|
-
}
|
|
3894
3888
|
str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
|
|
3895
3889
|
// @@@ case
|
|
3896
3890
|
if (typeof g2 !== 'string') {
|
|
@@ -4117,13 +4111,8 @@ function parseNumberSkeleton(tokens) {
|
|
|
4117
4111
|
}
|
|
4118
4112
|
return '';
|
|
4119
4113
|
});
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
if (opt === 'w') {
|
|
4123
|
-
result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' });
|
|
4124
|
-
}
|
|
4125
|
-
else if (opt) {
|
|
4126
|
-
result = __assign(__assign({}, result), parseSignificantPrecision(opt));
|
|
4114
|
+
if (token.options.length) {
|
|
4115
|
+
result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
|
|
4127
4116
|
}
|
|
4128
4117
|
continue;
|
|
4129
4118
|
}
|
|
@@ -4145,8 +4134,8 @@ function parseNumberSkeleton(tokens) {
|
|
|
4145
4134
|
}
|
|
4146
4135
|
|
|
4147
4136
|
var _a;
|
|
4148
|
-
var SPACE_SEPARATOR_START_REGEX = new RegExp("^"
|
|
4149
|
-
var SPACE_SEPARATOR_END_REGEX = new RegExp(
|
|
4137
|
+
var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
|
|
4138
|
+
var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
|
|
4150
4139
|
function createLocation(start, end) {
|
|
4151
4140
|
return { start: start, end: end };
|
|
4152
4141
|
}
|
|
@@ -4393,7 +4382,7 @@ var Parser = /** @class */ (function () {
|
|
|
4393
4382
|
return {
|
|
4394
4383
|
val: {
|
|
4395
4384
|
type: TYPE.literal,
|
|
4396
|
-
value: "<"
|
|
4385
|
+
value: "<" + tagName + "/>",
|
|
4397
4386
|
location: createLocation(startPosition, this.clonePosition()),
|
|
4398
4387
|
},
|
|
4399
4388
|
err: null,
|
|
@@ -4998,7 +4987,7 @@ var Parser = /** @class */ (function () {
|
|
|
4998
4987
|
}
|
|
4999
4988
|
var code = codePointAt(this.message, offset);
|
|
5000
4989
|
if (code === undefined) {
|
|
5001
|
-
throw Error("Offset "
|
|
4990
|
+
throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
|
|
5002
4991
|
}
|
|
5003
4992
|
return code;
|
|
5004
4993
|
};
|
|
@@ -5066,7 +5055,7 @@ var Parser = /** @class */ (function () {
|
|
|
5066
5055
|
*/
|
|
5067
5056
|
Parser.prototype.bumpTo = function (targetOffset) {
|
|
5068
5057
|
if (this.offset() > targetOffset) {
|
|
5069
|
-
throw Error("targetOffset "
|
|
5058
|
+
throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
|
|
5070
5059
|
}
|
|
5071
5060
|
targetOffset = Math.min(targetOffset, this.message.length);
|
|
5072
5061
|
while (true) {
|
|
@@ -5075,7 +5064,7 @@ var Parser = /** @class */ (function () {
|
|
|
5075
5064
|
break;
|
|
5076
5065
|
}
|
|
5077
5066
|
if (offset > targetOffset) {
|
|
5078
|
-
throw Error("targetOffset "
|
|
5067
|
+
throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
|
|
5079
5068
|
}
|
|
5080
5069
|
this.bump();
|
|
5081
5070
|
if (this.isEOF()) {
|
|
@@ -5541,28 +5530,28 @@ var FormatError = /** @class */ (function (_super) {
|
|
|
5541
5530
|
return _this;
|
|
5542
5531
|
}
|
|
5543
5532
|
FormatError.prototype.toString = function () {
|
|
5544
|
-
return "[formatjs Error: "
|
|
5533
|
+
return "[formatjs Error: " + this.code + "] " + this.message;
|
|
5545
5534
|
};
|
|
5546
5535
|
return FormatError;
|
|
5547
5536
|
}(Error));
|
|
5548
5537
|
var InvalidValueError = /** @class */ (function (_super) {
|
|
5549
5538
|
__extends(InvalidValueError, _super);
|
|
5550
5539
|
function InvalidValueError(variableId, value, options, originalMessage) {
|
|
5551
|
-
return _super.call(this, "Invalid values for \""
|
|
5540
|
+
return _super.call(this, "Invalid values for \"" + variableId + "\": \"" + value + "\". Options are \"" + Object.keys(options).join('", "') + "\"", ErrorCode.INVALID_VALUE, originalMessage) || this;
|
|
5552
5541
|
}
|
|
5553
5542
|
return InvalidValueError;
|
|
5554
5543
|
}(FormatError));
|
|
5555
5544
|
var InvalidValueTypeError = /** @class */ (function (_super) {
|
|
5556
5545
|
__extends(InvalidValueTypeError, _super);
|
|
5557
5546
|
function InvalidValueTypeError(value, type, originalMessage) {
|
|
5558
|
-
return _super.call(this, "Value for \""
|
|
5547
|
+
return _super.call(this, "Value for \"" + value + "\" must be of type " + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
|
|
5559
5548
|
}
|
|
5560
5549
|
return InvalidValueTypeError;
|
|
5561
5550
|
}(FormatError));
|
|
5562
5551
|
var MissingValueError = /** @class */ (function (_super) {
|
|
5563
5552
|
__extends(MissingValueError, _super);
|
|
5564
5553
|
function MissingValueError(variableId, originalMessage) {
|
|
5565
|
-
return _super.call(this, "The intl string context variable \""
|
|
5554
|
+
return _super.call(this, "The intl string context variable \"" + variableId + "\" was not provided to the string \"" + originalMessage + "\"", ErrorCode.MISSING_VALUE, originalMessage) || this;
|
|
5566
5555
|
}
|
|
5567
5556
|
return MissingValueError;
|
|
5568
5557
|
}(FormatError));
|
|
@@ -5723,7 +5712,7 @@ originalMessage) {
|
|
|
5723
5712
|
continue;
|
|
5724
5713
|
}
|
|
5725
5714
|
if (isPluralElement(el)) {
|
|
5726
|
-
var opt = el.options["="
|
|
5715
|
+
var opt = el.options["=" + value];
|
|
5727
5716
|
if (!opt) {
|
|
5728
5717
|
if (!Intl.PluralRules) {
|
|
5729
5718
|
throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
|
|
@@ -5794,7 +5783,7 @@ function createDefaultFormatters(cache) {
|
|
|
5794
5783
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5795
5784
|
args[_i] = arguments[_i];
|
|
5796
5785
|
}
|
|
5797
|
-
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args
|
|
5786
|
+
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
5798
5787
|
}, {
|
|
5799
5788
|
cache: createFastMemoizeCache$1(cache.number),
|
|
5800
5789
|
strategy: strategies.variadic,
|
|
@@ -5805,7 +5794,7 @@ function createDefaultFormatters(cache) {
|
|
|
5805
5794
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5806
5795
|
args[_i] = arguments[_i];
|
|
5807
5796
|
}
|
|
5808
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args
|
|
5797
|
+
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
5809
5798
|
}, {
|
|
5810
5799
|
cache: createFastMemoizeCache$1(cache.dateTime),
|
|
5811
5800
|
strategy: strategies.variadic,
|
|
@@ -5816,7 +5805,7 @@ function createDefaultFormatters(cache) {
|
|
|
5816
5805
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5817
5806
|
args[_i] = arguments[_i];
|
|
5818
5807
|
}
|
|
5819
|
-
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args
|
|
5808
|
+
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
5820
5809
|
}, {
|
|
5821
5810
|
cache: createFastMemoizeCache$1(cache.pluralRules),
|
|
5822
5811
|
strategy: strategies.variadic,
|
|
@@ -5974,13 +5963,7 @@ var IntlErrorCode;
|
|
|
5974
5963
|
var IntlError = /** @class */ (function (_super) {
|
|
5975
5964
|
__extends(IntlError, _super);
|
|
5976
5965
|
function IntlError(code, message, exception) {
|
|
5977
|
-
var _this = this;
|
|
5978
|
-
var err = exception
|
|
5979
|
-
? exception instanceof Error
|
|
5980
|
-
? exception
|
|
5981
|
-
: new Error(String(exception))
|
|
5982
|
-
: undefined;
|
|
5983
|
-
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, " \n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
|
|
5966
|
+
var _this = _super.call(this, "[@formatjs/intl Error " + code + "] " + message + " \n" + (exception ? "\n" + exception.message + "\n" + exception.stack : '')) || this;
|
|
5984
5967
|
_this.code = code;
|
|
5985
5968
|
// @ts-ignore just so we don't need to declare dep on @types/node
|
|
5986
5969
|
if (typeof Error.captureStackTrace === 'function') {
|
|
@@ -6012,26 +5995,19 @@ var MissingDataError = /** @class */ (function (_super) {
|
|
|
6012
5995
|
}
|
|
6013
5996
|
return MissingDataError;
|
|
6014
5997
|
}(IntlError));
|
|
6015
|
-
var IntlFormatError = /** @class */ (function (_super) {
|
|
6016
|
-
__extends(IntlFormatError, _super);
|
|
6017
|
-
function IntlFormatError(message, locale, exception) {
|
|
6018
|
-
return _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, " \nLocale: ").concat(locale, "\n"), exception) || this;
|
|
6019
|
-
}
|
|
6020
|
-
return IntlFormatError;
|
|
6021
|
-
}(IntlError));
|
|
6022
5998
|
var MessageFormatError = /** @class */ (function (_super) {
|
|
6023
5999
|
__extends(MessageFormatError, _super);
|
|
6024
6000
|
function MessageFormatError(message, locale, descriptor, exception) {
|
|
6025
|
-
var _this = _super.call(this,
|
|
6001
|
+
var _this = _super.call(this, IntlErrorCode.FORMAT_ERROR, message + " \nLocale: " + locale + "\nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", exception) || this;
|
|
6026
6002
|
_this.descriptor = descriptor;
|
|
6027
6003
|
return _this;
|
|
6028
6004
|
}
|
|
6029
6005
|
return MessageFormatError;
|
|
6030
|
-
}(
|
|
6006
|
+
}(IntlError));
|
|
6031
6007
|
var MissingTranslationError = /** @class */ (function (_super) {
|
|
6032
6008
|
__extends(MissingTranslationError, _super);
|
|
6033
6009
|
function MissingTranslationError(descriptor, locale) {
|
|
6034
|
-
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \""
|
|
6010
|
+
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"" + descriptor.id + "\" for locale \"" + locale + "\", using " + (descriptor.defaultMessage ? 'default message' : 'id') + " as fallback.") || this;
|
|
6035
6011
|
_this.descriptor = descriptor;
|
|
6036
6012
|
return _this;
|
|
6037
6013
|
}
|
|
@@ -6058,7 +6034,6 @@ var DEFAULT_INTL_CONFIG = {
|
|
|
6058
6034
|
timeZone: undefined,
|
|
6059
6035
|
defaultLocale: 'en',
|
|
6060
6036
|
defaultFormats: {},
|
|
6061
|
-
fallbackOnEmptyString: true,
|
|
6062
6037
|
onError: defaultErrorHandler,
|
|
6063
6038
|
};
|
|
6064
6039
|
function createIntlCache() {
|
|
@@ -6101,7 +6076,7 @@ function createFormatters(cache) {
|
|
|
6101
6076
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6102
6077
|
args[_i] = arguments[_i];
|
|
6103
6078
|
}
|
|
6104
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args
|
|
6079
|
+
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
6105
6080
|
}, {
|
|
6106
6081
|
cache: createFastMemoizeCache(cache.dateTime),
|
|
6107
6082
|
strategy: strategies.variadic,
|
|
@@ -6112,7 +6087,7 @@ function createFormatters(cache) {
|
|
|
6112
6087
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6113
6088
|
args[_i] = arguments[_i];
|
|
6114
6089
|
}
|
|
6115
|
-
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args
|
|
6090
|
+
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
6116
6091
|
}, {
|
|
6117
6092
|
cache: createFastMemoizeCache(cache.number),
|
|
6118
6093
|
strategy: strategies.variadic,
|
|
@@ -6123,7 +6098,7 @@ function createFormatters(cache) {
|
|
|
6123
6098
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6124
6099
|
args[_i] = arguments[_i];
|
|
6125
6100
|
}
|
|
6126
|
-
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args
|
|
6101
|
+
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args)))();
|
|
6127
6102
|
}, {
|
|
6128
6103
|
cache: createFastMemoizeCache(cache.pluralRules),
|
|
6129
6104
|
strategy: strategies.variadic,
|
|
@@ -6146,7 +6121,7 @@ function createFormatters(cache) {
|
|
|
6146
6121
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6147
6122
|
args[_i] = arguments[_i];
|
|
6148
6123
|
}
|
|
6149
|
-
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArray([void 0], args
|
|
6124
|
+
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArray([void 0], args)))();
|
|
6150
6125
|
}, {
|
|
6151
6126
|
cache: createFastMemoizeCache(cache.relativeTime),
|
|
6152
6127
|
strategy: strategies.variadic,
|
|
@@ -6157,7 +6132,7 @@ function createFormatters(cache) {
|
|
|
6157
6132
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6158
6133
|
args[_i] = arguments[_i];
|
|
6159
6134
|
}
|
|
6160
|
-
return new (ListFormat.bind.apply(ListFormat, __spreadArray([void 0], args
|
|
6135
|
+
return new (ListFormat.bind.apply(ListFormat, __spreadArray([void 0], args)))();
|
|
6161
6136
|
}, {
|
|
6162
6137
|
cache: createFastMemoizeCache(cache.list),
|
|
6163
6138
|
strategy: strategies.variadic,
|
|
@@ -6167,7 +6142,7 @@ function createFormatters(cache) {
|
|
|
6167
6142
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6168
6143
|
args[_i] = arguments[_i];
|
|
6169
6144
|
}
|
|
6170
|
-
return new (DisplayNames.bind.apply(DisplayNames, __spreadArray([void 0], args
|
|
6145
|
+
return new (DisplayNames.bind.apply(DisplayNames, __spreadArray([void 0], args)))();
|
|
6171
6146
|
}, {
|
|
6172
6147
|
cache: createFastMemoizeCache(cache.displayNames),
|
|
6173
6148
|
strategy: strategies.variadic,
|
|
@@ -6183,7 +6158,7 @@ function getNamedFormat(formats, type, name, onError) {
|
|
|
6183
6158
|
if (format) {
|
|
6184
6159
|
return format;
|
|
6185
6160
|
}
|
|
6186
|
-
onError(new UnsupportedFormatterError("No "
|
|
6161
|
+
onError(new UnsupportedFormatterError("No " + type + " format named: " + name));
|
|
6187
6162
|
}
|
|
6188
6163
|
|
|
6189
6164
|
/**
|
|
@@ -6218,7 +6193,7 @@ function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
|
|
|
6218
6193
|
return __assign(__assign(__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
|
|
6219
6194
|
}
|
|
6220
6195
|
function formatMessage(_a, state, messageDescriptor, values, opts) {
|
|
6221
|
-
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats,
|
|
6196
|
+
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;
|
|
6222
6197
|
if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }
|
|
6223
6198
|
var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
|
|
6224
6199
|
// `id` is a required field of a Message Descriptor.
|
|
@@ -6248,9 +6223,6 @@ function formatMessage(_a, state, messageDescriptor, values, opts) {
|
|
|
6248
6223
|
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
|
6249
6224
|
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
|
6250
6225
|
if (!message) {
|
|
6251
|
-
if (fallbackOnEmptyString === false && message === '') {
|
|
6252
|
-
return message;
|
|
6253
|
-
}
|
|
6254
6226
|
if (!defaultMessage ||
|
|
6255
6227
|
(locale && locale.toLowerCase() !== defaultLocale.toLowerCase())) {
|
|
6256
6228
|
// This prevents warnings from littering the console in development
|
|
@@ -6264,7 +6236,7 @@ function formatMessage(_a, state, messageDescriptor, values, opts) {
|
|
|
6264
6236
|
return formatter.format(values);
|
|
6265
6237
|
}
|
|
6266
6238
|
catch (e) {
|
|
6267
|
-
onError(new MessageFormatError("Error formatting default message for: \""
|
|
6239
|
+
onError(new MessageFormatError("Error formatting default message for: \"" + id + "\", rendering default message verbatim", locale, messageDescriptor, e));
|
|
6268
6240
|
return typeof defaultMessage === 'string' ? defaultMessage : id;
|
|
6269
6241
|
}
|
|
6270
6242
|
}
|
|
@@ -6276,7 +6248,7 @@ function formatMessage(_a, state, messageDescriptor, values, opts) {
|
|
|
6276
6248
|
return formatter.format(values);
|
|
6277
6249
|
}
|
|
6278
6250
|
catch (e) {
|
|
6279
|
-
onError(new MessageFormatError("Error formatting message: \""
|
|
6251
|
+
onError(new MessageFormatError("Error formatting message: \"" + id + "\", using " + (defaultMessage ? 'default message' : 'id') + " as fallback.", locale, messageDescriptor, e));
|
|
6280
6252
|
}
|
|
6281
6253
|
if (defaultMessage) {
|
|
6282
6254
|
try {
|
|
@@ -6284,7 +6256,7 @@ function formatMessage(_a, state, messageDescriptor, values, opts) {
|
|
|
6284
6256
|
return formatter.format(values);
|
|
6285
6257
|
}
|
|
6286
6258
|
catch (e) {
|
|
6287
|
-
onError(new MessageFormatError("Error formatting the default message for: \""
|
|
6259
|
+
onError(new MessageFormatError("Error formatting the default message for: \"" + id + "\", rendering message verbatim", locale, messageDescriptor, e));
|
|
6288
6260
|
}
|
|
6289
6261
|
}
|
|
6290
6262
|
if (typeof message === 'string') {
|
|
@@ -6322,7 +6294,9 @@ function getFormatter$2(_a, type, getDateTimeFormat, options) {
|
|
|
6322
6294
|
if (options === void 0) { options = {}; }
|
|
6323
6295
|
var format = options.format;
|
|
6324
6296
|
var defaults = __assign(__assign({}, (timeZone && { timeZone: timeZone })), (format && getNamedFormat(formats, type, format, onError)));
|
|
6325
|
-
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS,
|
|
6297
|
+
var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS,
|
|
6298
|
+
// @ts-expect-error es2020 has a lot stuff from es2021 bleed in
|
|
6299
|
+
defaults);
|
|
6326
6300
|
if (type === 'time' &&
|
|
6327
6301
|
!filteredOptions.hour &&
|
|
6328
6302
|
!filteredOptions.minute &&
|
|
@@ -6439,7 +6413,7 @@ var LIST_FORMAT_OPTIONS = [
|
|
|
6439
6413
|
];
|
|
6440
6414
|
var now = Date.now();
|
|
6441
6415
|
function generateToken(i) {
|
|
6442
|
-
return
|
|
6416
|
+
return now + "_" + i + "_" + now;
|
|
6443
6417
|
}
|
|
6444
6418
|
function formatList(opts, getListFormat, values, options) {
|
|
6445
6419
|
if (options === void 0) { options = {}; }
|
|
@@ -6506,7 +6480,7 @@ function formatPlural(_a, getPluralRules, value, options) {
|
|
|
6506
6480
|
return getPluralRules(locale, filteredOptions).select(value);
|
|
6507
6481
|
}
|
|
6508
6482
|
catch (e) {
|
|
6509
|
-
onError(new
|
|
6483
|
+
onError(new MessageFormatError('Error formatting plural.', e));
|
|
6510
6484
|
}
|
|
6511
6485
|
return 'other';
|
|
6512
6486
|
}
|
|
@@ -6533,7 +6507,7 @@ function formatRelativeTime(config, getRelativeTimeFormat, value, unit, options)
|
|
|
6533
6507
|
return getFormatter$1(config, getRelativeTimeFormat, options).format(value, unit);
|
|
6534
6508
|
}
|
|
6535
6509
|
catch (e) {
|
|
6536
|
-
config.onError(new
|
|
6510
|
+
config.onError(new MessageFormatError('Error formatting relative time.', e));
|
|
6537
6511
|
}
|
|
6538
6512
|
return String(value);
|
|
6539
6513
|
}
|
|
@@ -6613,7 +6587,7 @@ function createIntl(config, cache) {
|
|
|
6613
6587
|
var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
|
|
6614
6588
|
if (!locale) {
|
|
6615
6589
|
if (onError) {
|
|
6616
|
-
onError(new InvalidConfigError("\"locale\" was not configured, using \""
|
|
6590
|
+
onError(new InvalidConfigError("\"locale\" was not configured, using \"" + defaultLocale + "\" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details"));
|
|
6617
6591
|
}
|
|
6618
6592
|
// Since there's no registered locale data for `locale`, this will
|
|
6619
6593
|
// fallback to the `defaultLocale` to make sure things can render.
|
|
@@ -6623,481 +6597,481 @@ function createIntl(config, cache) {
|
|
|
6623
6597
|
resolvedConfig.locale = resolvedConfig.defaultLocale || 'en';
|
|
6624
6598
|
}
|
|
6625
6599
|
else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
|
|
6626
|
-
onError(new MissingDataError("Missing locale data for locale: \""
|
|
6600
|
+
onError(new MissingDataError("Missing locale data for locale: \"" + locale + "\" in Intl.NumberFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details"));
|
|
6627
6601
|
}
|
|
6628
6602
|
else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length &&
|
|
6629
6603
|
onError) {
|
|
6630
|
-
onError(new MissingDataError("Missing locale data for locale: \""
|
|
6604
|
+
onError(new MissingDataError("Missing locale data for locale: \"" + locale + "\" in Intl.DateTimeFormat. Using default locale: \"" + defaultLocale + "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details"));
|
|
6631
6605
|
}
|
|
6632
6606
|
verifyConfigMessages(resolvedConfig);
|
|
6633
6607
|
return __assign(__assign({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
|
|
6634
6608
|
}
|
|
6635
6609
|
|
|
6636
|
-
const DEFAULT_LANGUAGE = "en";
|
|
6637
|
-
function getBrowserLang() {
|
|
6638
|
-
const langAttr = document.documentElement.getAttribute("lang");
|
|
6639
|
-
if (!!langAttr) {
|
|
6640
|
-
return langAttr;
|
|
6641
|
-
}
|
|
6642
|
-
else if (window.navigator && window.navigator.language) {
|
|
6643
|
-
const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
|
|
6644
|
-
return lang.slice(0, 2);
|
|
6645
|
-
}
|
|
6646
|
-
else {
|
|
6647
|
-
return DEFAULT_LANGUAGE;
|
|
6648
|
-
}
|
|
6649
|
-
}
|
|
6650
|
-
// prevents memory leak
|
|
6651
|
-
const cache = createIntlCache();
|
|
6652
|
-
const locale = getBrowserLang();
|
|
6653
|
-
const intl = createIntl({
|
|
6654
|
-
locale: locale,
|
|
6655
|
-
defaultLocale: "en",
|
|
6656
|
-
messages: lang[locale] || en,
|
|
6657
|
-
}, cache);
|
|
6658
|
-
function generateId() {
|
|
6659
|
-
return "wmcl-" + Math.random().toString(36).substr(2, 10);
|
|
6660
|
-
}
|
|
6661
|
-
// limits how many times a function fires
|
|
6662
|
-
// use when the function should run periodically, but not too often (e.g. window resize)
|
|
6663
|
-
function throttle(fn, wait) {
|
|
6664
|
-
let timeout;
|
|
6665
|
-
let shouldWait = false;
|
|
6666
|
-
return function () {
|
|
6667
|
-
const context = this;
|
|
6668
|
-
if (!shouldWait) {
|
|
6669
|
-
fn.apply(context, arguments);
|
|
6670
|
-
shouldWait = true;
|
|
6671
|
-
clearTimeout(timeout);
|
|
6672
|
-
timeout = setTimeout(function () {
|
|
6673
|
-
shouldWait = false;
|
|
6674
|
-
}, wait);
|
|
6675
|
-
}
|
|
6676
|
-
};
|
|
6677
|
-
}
|
|
6678
|
-
// waits until it hasn't been called for [timeout] ms.
|
|
6679
|
-
// use when the function should run only after something (event) is done firing
|
|
6680
|
-
function debounce(fn, wait) {
|
|
6681
|
-
let timeout;
|
|
6682
|
-
return function () {
|
|
6683
|
-
const context = this;
|
|
6684
|
-
const functionCall = () => fn.apply(context, arguments);
|
|
6685
|
-
clearTimeout(timeout);
|
|
6686
|
-
timeout = setTimeout(functionCall, wait);
|
|
6687
|
-
};
|
|
6688
|
-
}
|
|
6689
|
-
function getTextDir() {
|
|
6690
|
-
const dir = document.querySelector("html").getAttribute("dir");
|
|
6691
|
-
return dir ? dir.toLowerCase() : "";
|
|
6692
|
-
}
|
|
6693
|
-
function getPosition(el) {
|
|
6694
|
-
const coords = el.getBoundingClientRect();
|
|
6695
|
-
let x = coords.x;
|
|
6696
|
-
let y = coords.y;
|
|
6697
|
-
// Edge doesn't have x and y
|
|
6698
|
-
if (!x) {
|
|
6699
|
-
if (getTextDir() === "rtl") {
|
|
6700
|
-
x = coords.right;
|
|
6701
|
-
}
|
|
6702
|
-
else {
|
|
6703
|
-
x = coords.left;
|
|
6704
|
-
}
|
|
6705
|
-
y = coords.top;
|
|
6706
|
-
}
|
|
6707
|
-
return { x, y };
|
|
6708
|
-
}
|
|
6709
|
-
function findParentWithScrollbar(el) {
|
|
6710
|
-
while (!!el) {
|
|
6711
|
-
if (el.scrollHeight > el.clientHeight && ["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
|
|
6712
|
-
return el;
|
|
6713
|
-
}
|
|
6714
|
-
el = el.parentElement;
|
|
6715
|
-
}
|
|
6716
|
-
}
|
|
6717
|
-
function findParentWithHiddenOverflow(el) {
|
|
6718
|
-
while (!!el) {
|
|
6719
|
-
if (window.getComputedStyle(el).overflowY !== "visible") {
|
|
6720
|
-
return el;
|
|
6721
|
-
}
|
|
6722
|
-
el = el.parentElement;
|
|
6723
|
-
}
|
|
6724
|
-
}
|
|
6725
|
-
function getClosableElementMeasurements(fixedEl, closableEl) {
|
|
6726
|
-
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
6727
|
-
// if parent is not found, measurements are checked against the viewport
|
|
6728
|
-
return {
|
|
6729
|
-
closableElHeight: closableEl.clientHeight,
|
|
6730
|
-
closableElWidth: closableEl.clientWidth,
|
|
6731
|
-
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
6732
|
-
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
6733
|
-
spaceAbove: parent
|
|
6734
|
-
? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
|
|
6735
|
-
: fixedEl.getBoundingClientRect().top,
|
|
6736
|
-
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
6737
|
-
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
6738
|
-
spaceBelow: parent
|
|
6739
|
-
? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
|
|
6740
|
-
: document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom,
|
|
6741
|
-
spaceLeft: parent
|
|
6742
|
-
? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
|
|
6743
|
-
: fixedEl.getBoundingClientRect().left,
|
|
6744
|
-
spaceRight: parent
|
|
6745
|
-
? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
|
|
6746
|
-
: document.documentElement.clientWidth - fixedEl.getBoundingClientRect().right,
|
|
6747
|
-
};
|
|
6748
|
-
}
|
|
6749
|
-
function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
|
|
6750
|
-
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
6751
|
-
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
6752
|
-
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
6753
|
-
) {
|
|
6754
|
-
const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6755
|
-
//we want to open up only if there's not enough space below AND there is enough space above
|
|
6756
|
-
const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
|
|
6757
|
-
return openUp;
|
|
6758
|
-
}
|
|
6759
|
-
function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
|
|
6760
|
-
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
6761
|
-
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
6762
|
-
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
6763
|
-
) {
|
|
6764
|
-
const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6765
|
-
//we want to open up only if there's not enough space below AND there is enough space above
|
|
6766
|
-
const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
|
|
6767
|
-
return openDown;
|
|
6768
|
-
}
|
|
6769
|
-
function shouldShiftRight(fixedEl, closableEl) {
|
|
6770
|
-
const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6771
|
-
const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
|
|
6772
|
-
return needsSpaceLeft;
|
|
6773
|
-
}
|
|
6774
|
-
function shouldShiftLeft(fixedEl, closableEl) {
|
|
6775
|
-
const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6776
|
-
const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
|
|
6777
|
-
return needsSpaceRight;
|
|
6778
|
-
}
|
|
6779
|
-
function adjustTooltipPosition(tPos, el, tooltipEl) {
|
|
6780
|
-
// position must be reset before measurements are taken in adjustTooltipPosition
|
|
6781
|
-
// otherwise text-wrapping from previous position makes width measurement inconsistent
|
|
6782
|
-
tooltipEl.style.top = "";
|
|
6783
|
-
tooltipEl.style.left = "";
|
|
6784
|
-
const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getClosableElementMeasurements(el, tooltipEl);
|
|
6785
|
-
const tooltipWidth = tooltipEl.getBoundingClientRect().width;
|
|
6786
|
-
const tooltipHeight = tooltipEl.getBoundingClientRect().height;
|
|
6787
|
-
const enoughSpaceAbove = spaceAbove > tooltipHeight;
|
|
6788
|
-
const enoughSpaceBelow = spaceBelow > tooltipHeight;
|
|
6789
|
-
// a tooltip should never be closer than 24px to the edge of a screen
|
|
6790
|
-
const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
|
|
6791
|
-
const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
|
|
6792
|
-
const swapAbove = (position) => {
|
|
6793
|
-
return !enoughSpaceAbove ? position.replace("top", "bottom") : position;
|
|
6794
|
-
};
|
|
6795
|
-
const swapBelow = (position) => {
|
|
6796
|
-
return !enoughSpaceBelow && enoughSpaceAbove ? position.replace("bottom", "top") : position;
|
|
6797
|
-
};
|
|
6798
|
-
const swapLeft = (position, centeredPosition) => {
|
|
6799
|
-
if (!enoughSpaceLeft && enoughSpaceRight) {
|
|
6800
|
-
position = position.replace("left", "right");
|
|
6801
|
-
}
|
|
6802
|
-
else if (!enoughSpaceLeft && !enoughSpaceRight) {
|
|
6803
|
-
position = centeredPosition;
|
|
6804
|
-
}
|
|
6805
|
-
return position;
|
|
6806
|
-
};
|
|
6807
|
-
const swapRight = (position, centeredPosition) => {
|
|
6808
|
-
if (!enoughSpaceRight && enoughSpaceLeft) {
|
|
6809
|
-
position = position.replace("right", "left");
|
|
6810
|
-
}
|
|
6811
|
-
else if (!enoughSpaceRight && !enoughSpaceLeft) {
|
|
6812
|
-
position = centeredPosition;
|
|
6813
|
-
}
|
|
6814
|
-
return position;
|
|
6815
|
-
};
|
|
6816
|
-
// horizontal checks must occur before vertical checks, because horizontal can affect vertical positioning but not vice versa
|
|
6817
|
-
switch (tPos) {
|
|
6818
|
-
case "left":
|
|
6819
|
-
tPos = swapLeft(tPos, "bottom");
|
|
6820
|
-
case "right":
|
|
6821
|
-
tPos = swapRight(tPos, "bottom");
|
|
6822
|
-
case "top-left":
|
|
6823
|
-
tPos = swapLeft(tPos, "top");
|
|
6824
|
-
tPos = swapAbove(tPos);
|
|
6825
|
-
case "top-right":
|
|
6826
|
-
tPos = swapRight(tPos, "top");
|
|
6827
|
-
tPos = swapAbove(tPos);
|
|
6828
|
-
case "bottom-left":
|
|
6829
|
-
tPos = swapLeft(tPos, "bottom");
|
|
6830
|
-
tPos = swapBelow(tPos);
|
|
6831
|
-
case "bottom-right":
|
|
6832
|
-
tPos = swapRight(tPos, "bottom");
|
|
6833
|
-
tPos = swapBelow(tPos);
|
|
6834
|
-
case "top":
|
|
6835
|
-
tPos = swapAbove(tPos);
|
|
6836
|
-
case "bottom":
|
|
6837
|
-
tPos = swapBelow(tPos);
|
|
6838
|
-
}
|
|
6839
|
-
return tPos;
|
|
6840
|
-
}
|
|
6841
|
-
function hasRoomRight(x, spaceNeeded) {
|
|
6842
|
-
let horizOffset = 0;
|
|
6843
|
-
// if (getTextDir() === "ltr") {
|
|
6844
|
-
if (x.type === "click") {
|
|
6845
|
-
// if it's a mouse event, deal with mouse coords
|
|
6846
|
-
horizOffset = x.clientX;
|
|
6847
|
-
// if it's a focus event, the offset is 0
|
|
6848
|
-
}
|
|
6849
|
-
else if (x.type === "focus") {
|
|
6850
|
-
horizOffset = 0;
|
|
6851
|
-
}
|
|
6852
|
-
else {
|
|
6853
|
-
// otherwise an element was passed, calculate how far it is from the edge of the window
|
|
6854
|
-
let el = x; // re-assignment is for clarity
|
|
6855
|
-
while (el) {
|
|
6856
|
-
if (el.tagName == "BODY") {
|
|
6857
|
-
// deal with browser quirks with body/window/document and page scroll
|
|
6858
|
-
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
|
|
6859
|
-
horizOffset += el.offsetLeft - xScroll + el.clientLeft;
|
|
6860
|
-
}
|
|
6861
|
-
else {
|
|
6862
|
-
// for all other non-BODY elements
|
|
6863
|
-
horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
|
|
6864
|
-
}
|
|
6865
|
-
el = el.offsetParent;
|
|
6866
|
-
}
|
|
6867
|
-
// }
|
|
6868
|
-
}
|
|
6869
|
-
return window.innerWidth - horizOffset >= spaceNeeded;
|
|
6870
|
-
}
|
|
6871
|
-
function checkForActiveElInShadow(element) {
|
|
6872
|
-
while (element && element.shadowRoot) {
|
|
6873
|
-
element = element.shadowRoot.activeElement;
|
|
6874
|
-
}
|
|
6875
|
-
return element;
|
|
6876
|
-
}
|
|
6877
|
-
function checkForFocusableElInShadow(element) {
|
|
6878
|
-
const selectors = [
|
|
6879
|
-
"button",
|
|
6880
|
-
"a",
|
|
6881
|
-
"input",
|
|
6882
|
-
"select",
|
|
6883
|
-
"textarea",
|
|
6884
|
-
"wm-button",
|
|
6885
|
-
"wm-search",
|
|
6886
|
-
"wm-select",
|
|
6887
|
-
"wm-action-menu",
|
|
6888
|
-
"wm-tab-item",
|
|
6889
|
-
"wm-datepicker",
|
|
6890
|
-
];
|
|
6891
|
-
let focusableEl = element;
|
|
6892
|
-
selectors.forEach((selector) => {
|
|
6893
|
-
if (focusableEl && focusableEl.shadowRoot) {
|
|
6894
|
-
let elInShadow = focusableEl.shadowRoot.querySelector(selector);
|
|
6895
|
-
if (elInShadow) {
|
|
6896
|
-
if (selector.startsWith("wm-")) {
|
|
6897
|
-
focusableEl = checkForFocusableElInShadow(elInShadow);
|
|
6898
|
-
}
|
|
6899
|
-
else {
|
|
6900
|
-
focusableEl = elInShadow;
|
|
6901
|
-
}
|
|
6902
|
-
}
|
|
6903
|
-
}
|
|
6904
|
-
});
|
|
6905
|
-
return focusableEl;
|
|
6906
|
-
}
|
|
6907
|
-
function isFocusable(element) {
|
|
6908
|
-
if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
|
|
6909
|
-
return true;
|
|
6910
|
-
}
|
|
6911
|
-
if (element.disabled) {
|
|
6912
|
-
return false;
|
|
6913
|
-
}
|
|
6914
|
-
switch (element.nodeName) {
|
|
6915
|
-
case "A":
|
|
6916
|
-
return !!element.href && element.rel != "ignore";
|
|
6917
|
-
case "INPUT":
|
|
6918
|
-
return element.type != "hidden" && element.type != "file";
|
|
6919
|
-
case "BUTTON":
|
|
6920
|
-
case "SELECT":
|
|
6921
|
-
case "TEXTAREA":
|
|
6922
|
-
case "WM-BUTTON":
|
|
6923
|
-
case "WM-SELECT":
|
|
6924
|
-
case "WM-ACTION-MENU":
|
|
6925
|
-
case "WM-DATEPICKER":
|
|
6926
|
-
case "WM-TIMEPICKER":
|
|
6927
|
-
case "WM-INPUT":
|
|
6928
|
-
case "WM-TAG-INPUT":
|
|
6929
|
-
case "WM-TAB-ITEM":
|
|
6930
|
-
case "WM-SEARCH":
|
|
6931
|
-
return true;
|
|
6932
|
-
default:
|
|
6933
|
-
return false;
|
|
6934
|
-
}
|
|
6935
|
-
}
|
|
6936
|
-
function getFirstFocusableDescendant(element) {
|
|
6937
|
-
if (isFocusable(element)) {
|
|
6938
|
-
return checkForFocusableElInShadow(element);
|
|
6939
|
-
}
|
|
6940
|
-
else if (element.childNodes.length > 0) {
|
|
6941
|
-
element.childNodes.forEach((i) => {
|
|
6942
|
-
const childEl = getFirstFocusableDescendant(i);
|
|
6943
|
-
return childEl && checkForFocusableElInShadow(childEl);
|
|
6944
|
-
});
|
|
6945
|
-
}
|
|
6946
|
-
}
|
|
6947
|
-
function hasValidType(file, types) {
|
|
6948
|
-
const acceptedExtensions = types.split(" ");
|
|
6949
|
-
const parts = file.name && file.name.split(".");
|
|
6950
|
-
const ext = parts && parts.length > 1 && parts[parts.length - 1];
|
|
6951
|
-
return ext
|
|
6952
|
-
? acceptedExtensions.includes(ext.toLowerCase())
|
|
6953
|
-
: // fallback: if we couldn't obtain an extension,
|
|
6954
|
-
// validate based on MIME type...
|
|
6955
|
-
!!file.type
|
|
6956
|
-
? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
|
|
6957
|
-
: // ...and if that failed too, accept the file
|
|
6958
|
-
// as it's preferable to accept an invalid file
|
|
6959
|
-
// than refusing a valid one (back-end will take care of what slips through)
|
|
6960
|
-
true;
|
|
6961
|
-
}
|
|
6962
|
-
// takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
|
|
6963
|
-
function getAcceptedMimeTypesList(acceptedExtensions) {
|
|
6964
|
-
// this is just a list of common file types (regardless of whether they are/can be valid or not)
|
|
6965
|
-
// front end checks are just a convenience to users, independent of security.
|
|
6966
|
-
// it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
|
|
6967
|
-
const lookupTable = {
|
|
6968
|
-
aac: ["audio/aac"],
|
|
6969
|
-
abw: ["application/x-abiword"],
|
|
6970
|
-
arc: ["application/x-freearc"],
|
|
6971
|
-
avi: ["video/x-msvideo"],
|
|
6972
|
-
azw: ["application/vnd.amazon.ebook"],
|
|
6973
|
-
bin: ["application/octet-stream"],
|
|
6974
|
-
bmp: ["image/bmp"],
|
|
6975
|
-
bz: ["application/x-bzip"],
|
|
6976
|
-
bz2: ["application/x-bzip2"],
|
|
6977
|
-
csh: ["application/x-csh"],
|
|
6978
|
-
css: ["text/css"],
|
|
6979
|
-
csv: ["text/csv"],
|
|
6980
|
-
doc: ["application/msword"],
|
|
6981
|
-
docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
6982
|
-
eot: ["application/vnd.ms-fontobject"],
|
|
6983
|
-
epub: ["application/epub+zip"],
|
|
6984
|
-
gz: ["application/gzip"],
|
|
6985
|
-
gif: ["image/gif"],
|
|
6986
|
-
htm: ["text/html"],
|
|
6987
|
-
html: ["text/html"],
|
|
6988
|
-
ico: ["image/vnd.microsoft.icon"],
|
|
6989
|
-
ics: ["text/calendar"],
|
|
6990
|
-
jar: ["application/java-archive"],
|
|
6991
|
-
jpeg: ["image/jpeg"],
|
|
6992
|
-
jpg: ["image/jpeg"],
|
|
6993
|
-
js: ["text/javascript"],
|
|
6994
|
-
json: ["application/json"],
|
|
6995
|
-
jsonld: ["application/ld+json"],
|
|
6996
|
-
log: ["text/plain"],
|
|
6997
|
-
mid: ["audio/x-midi"],
|
|
6998
|
-
midi: ["audio/x-midi"],
|
|
6999
|
-
mjs: ["text/javascript"],
|
|
7000
|
-
mp3: ["audio/mpeg"],
|
|
7001
|
-
mpeg: ["video/mpeg"],
|
|
7002
|
-
mpkg: ["application/vnd.apple.installer+xml"],
|
|
7003
|
-
odp: ["application/vnd.oasis.opendocument.presentation"],
|
|
7004
|
-
ods: ["application/vnd.oasis.opendocument.spreadsheet"],
|
|
7005
|
-
odt: ["application/vnd.oasis.opendocument.text"],
|
|
7006
|
-
oga: ["audio/ogg"],
|
|
7007
|
-
ogv: ["video/ogg"],
|
|
7008
|
-
ogx: ["application/ogg"],
|
|
7009
|
-
opus: ["audio/opus"],
|
|
7010
|
-
otf: ["font/otf"],
|
|
7011
|
-
png: ["image/png"],
|
|
7012
|
-
pdf: ["application/pdf"],
|
|
7013
|
-
php: ["application/php"],
|
|
7014
|
-
ppt: ["application/vnd.ms-powerpoint"],
|
|
7015
|
-
pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
7016
|
-
rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
|
|
7017
|
-
rtf: ["application/rtf"],
|
|
7018
|
-
sh: ["application/x-sh"],
|
|
7019
|
-
svg: ["image/svg+xml"],
|
|
7020
|
-
swf: ["application/x-shockwave-flash"],
|
|
7021
|
-
tar: ["application/x-tar"],
|
|
7022
|
-
tif: ["image/tiff"],
|
|
7023
|
-
tiff: ["image/tiff"],
|
|
7024
|
-
ts: ["video/mp2t"],
|
|
7025
|
-
ttf: ["font/ttf"],
|
|
7026
|
-
txt: ["text/plain"],
|
|
7027
|
-
vsd: ["application/vnd.visio"],
|
|
7028
|
-
wav: ["audio/wav"],
|
|
7029
|
-
weba: ["audio/webm"],
|
|
7030
|
-
webm: ["video/webm"],
|
|
7031
|
-
webp: ["image/webp"],
|
|
7032
|
-
woff: ["font/woff"],
|
|
7033
|
-
woff2: ["font/woff2"],
|
|
7034
|
-
xhtml: ["application/xhtml+xml"],
|
|
7035
|
-
xls: ["application/vnd.ms-excel"],
|
|
7036
|
-
xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
7037
|
-
xml: ["application/xml", "text/xml"],
|
|
7038
|
-
xul: ["application/vnd.mozilla.xul+xml"],
|
|
7039
|
-
zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
|
|
7040
|
-
"3gp": ["video/3gpp", "audio/3gpp"],
|
|
7041
|
-
"3g2": ["video/3gpp2", "audio/3gpp2"],
|
|
7042
|
-
"7z": ["application/x-7z-compressed"],
|
|
7043
|
-
};
|
|
7044
|
-
return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
|
|
7045
|
-
}
|
|
7046
|
-
function snakeCaseToCamelCase(str) {
|
|
7047
|
-
const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
|
|
7048
|
-
if (snakeCaseRegexp.test(str)) {
|
|
7049
|
-
let camelCase = "";
|
|
7050
|
-
let arr = str.split("_");
|
|
7051
|
-
arr.forEach((word, idx) => {
|
|
7052
|
-
camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
|
|
7053
|
-
});
|
|
7054
|
-
return camelCase;
|
|
7055
|
-
}
|
|
7056
|
-
else {
|
|
7057
|
-
return str;
|
|
7058
|
-
}
|
|
7059
|
-
}
|
|
7060
|
-
function getNewIndexToFocus(currentIndex, direction, listLength) {
|
|
7061
|
-
let newIndex = currentIndex;
|
|
7062
|
-
if (direction === "ArrowDown") {
|
|
7063
|
-
newIndex = (currentIndex + 1) % listLength;
|
|
7064
|
-
}
|
|
7065
|
-
if (direction === "ArrowUp") {
|
|
7066
|
-
newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
|
|
7067
|
-
}
|
|
7068
|
-
return newIndex;
|
|
7069
|
-
}
|
|
7070
|
-
function isRelatedTarget(ev, id) {
|
|
7071
|
-
// used for onBlur events to check the element that has been clicked
|
|
7072
|
-
const ids = id.split(" ");
|
|
7073
|
-
return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
|
|
7074
|
-
}
|
|
7075
|
-
function toBool(val) {
|
|
7076
|
-
// string "false" needs to be treated as bool False because react wrappers convert bool to string.
|
|
7077
|
-
return val == "false" ? false : !!val;
|
|
7078
|
-
}
|
|
7079
|
-
/*
|
|
7080
|
-
* this is going to be needed to solve the extra tabbing on navigator
|
|
7081
|
-
* and for programmatic focus of tabs
|
|
7082
|
-
* Here's a draft, not bug proof, see:
|
|
7083
|
-
* https://stackoverflow.com/a/10730308/3741713
|
|
7084
|
-
|
|
7085
|
-
function getKeyboardFocusableElements(element = document) {
|
|
7086
|
-
const els = Array.from(element.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), wm-search, wm-timepicker, wm-tab-list, wm-tab-item, wm-button, wm-action-menu'));
|
|
7087
|
-
return els.filter((el: Element) => !el.hasAttribute("disabled")) as HTMLElement[];
|
|
7088
|
-
}
|
|
7089
|
-
|
|
7090
|
-
export function getPreviousKeyboardFocusableElement(element: HTMLElement) {
|
|
7091
|
-
const els = getKeyboardFocusableElements();
|
|
7092
|
-
const current = els.indexOf(element);
|
|
7093
|
-
return els[current - 1] as HTMLElement;
|
|
7094
|
-
}
|
|
7095
|
-
|
|
7096
|
-
export function getNextKeyboardFocusableElement(element: HTMLElement) {
|
|
7097
|
-
const els = getKeyboardFocusableElements();
|
|
7098
|
-
const current = els.indexOf(element);
|
|
7099
|
-
return els[current + 1] as HTMLElement;
|
|
7100
|
-
}
|
|
6610
|
+
const DEFAULT_LANGUAGE = "en";
|
|
6611
|
+
function getBrowserLang() {
|
|
6612
|
+
const langAttr = document.documentElement.getAttribute("lang");
|
|
6613
|
+
if (!!langAttr) {
|
|
6614
|
+
return langAttr;
|
|
6615
|
+
}
|
|
6616
|
+
else if (window.navigator && window.navigator.language) {
|
|
6617
|
+
const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
|
|
6618
|
+
return lang.slice(0, 2);
|
|
6619
|
+
}
|
|
6620
|
+
else {
|
|
6621
|
+
return DEFAULT_LANGUAGE;
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
// prevents memory leak
|
|
6625
|
+
const cache = createIntlCache();
|
|
6626
|
+
const locale = getBrowserLang();
|
|
6627
|
+
const intl = createIntl({
|
|
6628
|
+
locale: locale,
|
|
6629
|
+
defaultLocale: "en",
|
|
6630
|
+
messages: lang[locale] || en,
|
|
6631
|
+
}, cache);
|
|
6632
|
+
function generateId() {
|
|
6633
|
+
return "wmcl-" + Math.random().toString(36).substr(2, 10);
|
|
6634
|
+
}
|
|
6635
|
+
// limits how many times a function fires
|
|
6636
|
+
// use when the function should run periodically, but not too often (e.g. window resize)
|
|
6637
|
+
function throttle(fn, wait) {
|
|
6638
|
+
let timeout;
|
|
6639
|
+
let shouldWait = false;
|
|
6640
|
+
return function () {
|
|
6641
|
+
const context = this;
|
|
6642
|
+
if (!shouldWait) {
|
|
6643
|
+
fn.apply(context, arguments);
|
|
6644
|
+
shouldWait = true;
|
|
6645
|
+
clearTimeout(timeout);
|
|
6646
|
+
timeout = setTimeout(function () {
|
|
6647
|
+
shouldWait = false;
|
|
6648
|
+
}, wait);
|
|
6649
|
+
}
|
|
6650
|
+
};
|
|
6651
|
+
}
|
|
6652
|
+
// waits until it hasn't been called for [timeout] ms.
|
|
6653
|
+
// use when the function should run only after something (event) is done firing
|
|
6654
|
+
function debounce(fn, wait) {
|
|
6655
|
+
let timeout;
|
|
6656
|
+
return function () {
|
|
6657
|
+
const context = this;
|
|
6658
|
+
const functionCall = () => fn.apply(context, arguments);
|
|
6659
|
+
clearTimeout(timeout);
|
|
6660
|
+
timeout = setTimeout(functionCall, wait);
|
|
6661
|
+
};
|
|
6662
|
+
}
|
|
6663
|
+
function getTextDir() {
|
|
6664
|
+
const dir = document.querySelector("html").getAttribute("dir");
|
|
6665
|
+
return dir ? dir.toLowerCase() : "";
|
|
6666
|
+
}
|
|
6667
|
+
function getPosition(el) {
|
|
6668
|
+
const coords = el.getBoundingClientRect();
|
|
6669
|
+
let x = coords.x;
|
|
6670
|
+
let y = coords.y;
|
|
6671
|
+
// Edge doesn't have x and y
|
|
6672
|
+
if (!x) {
|
|
6673
|
+
if (getTextDir() === "rtl") {
|
|
6674
|
+
x = coords.right;
|
|
6675
|
+
}
|
|
6676
|
+
else {
|
|
6677
|
+
x = coords.left;
|
|
6678
|
+
}
|
|
6679
|
+
y = coords.top;
|
|
6680
|
+
}
|
|
6681
|
+
return { x, y };
|
|
6682
|
+
}
|
|
6683
|
+
function findParentWithScrollbar(el) {
|
|
6684
|
+
while (!!el) {
|
|
6685
|
+
if (el.scrollHeight > el.clientHeight && ["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
|
|
6686
|
+
return el;
|
|
6687
|
+
}
|
|
6688
|
+
el = el.parentElement;
|
|
6689
|
+
}
|
|
6690
|
+
}
|
|
6691
|
+
function findParentWithHiddenOverflow(el) {
|
|
6692
|
+
while (!!el) {
|
|
6693
|
+
if (window.getComputedStyle(el).overflowY !== "visible") {
|
|
6694
|
+
return el;
|
|
6695
|
+
}
|
|
6696
|
+
el = el.parentElement;
|
|
6697
|
+
}
|
|
6698
|
+
}
|
|
6699
|
+
function getClosableElementMeasurements(fixedEl, closableEl) {
|
|
6700
|
+
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
6701
|
+
// if parent is not found, measurements are checked against the viewport
|
|
6702
|
+
return {
|
|
6703
|
+
closableElHeight: closableEl.clientHeight,
|
|
6704
|
+
closableElWidth: closableEl.clientWidth,
|
|
6705
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
6706
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
6707
|
+
spaceAbove: parent
|
|
6708
|
+
? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
|
|
6709
|
+
: fixedEl.getBoundingClientRect().top,
|
|
6710
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
6711
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
6712
|
+
spaceBelow: parent
|
|
6713
|
+
? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
|
|
6714
|
+
: document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom,
|
|
6715
|
+
spaceLeft: parent
|
|
6716
|
+
? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
|
|
6717
|
+
: fixedEl.getBoundingClientRect().left,
|
|
6718
|
+
spaceRight: parent
|
|
6719
|
+
? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
|
|
6720
|
+
: document.documentElement.clientWidth - fixedEl.getBoundingClientRect().right,
|
|
6721
|
+
};
|
|
6722
|
+
}
|
|
6723
|
+
function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
|
|
6724
|
+
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
6725
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
6726
|
+
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
6727
|
+
) {
|
|
6728
|
+
const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6729
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
6730
|
+
const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
|
|
6731
|
+
return openUp;
|
|
6732
|
+
}
|
|
6733
|
+
function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
|
|
6734
|
+
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
6735
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
6736
|
+
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
6737
|
+
) {
|
|
6738
|
+
const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6739
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
6740
|
+
const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
|
|
6741
|
+
return openDown;
|
|
6742
|
+
}
|
|
6743
|
+
function shouldShiftRight(fixedEl, closableEl) {
|
|
6744
|
+
const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6745
|
+
const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
|
|
6746
|
+
return needsSpaceLeft;
|
|
6747
|
+
}
|
|
6748
|
+
function shouldShiftLeft(fixedEl, closableEl) {
|
|
6749
|
+
const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
|
|
6750
|
+
const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
|
|
6751
|
+
return needsSpaceRight;
|
|
6752
|
+
}
|
|
6753
|
+
function adjustTooltipPosition(tPos, el, tooltipEl) {
|
|
6754
|
+
// position must be reset before measurements are taken in adjustTooltipPosition
|
|
6755
|
+
// otherwise text-wrapping from previous position makes width measurement inconsistent
|
|
6756
|
+
tooltipEl.style.top = "";
|
|
6757
|
+
tooltipEl.style.left = "";
|
|
6758
|
+
const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getClosableElementMeasurements(el, tooltipEl);
|
|
6759
|
+
const tooltipWidth = tooltipEl.getBoundingClientRect().width;
|
|
6760
|
+
const tooltipHeight = tooltipEl.getBoundingClientRect().height;
|
|
6761
|
+
const enoughSpaceAbove = spaceAbove > tooltipHeight;
|
|
6762
|
+
const enoughSpaceBelow = spaceBelow > tooltipHeight;
|
|
6763
|
+
// a tooltip should never be closer than 24px to the edge of a screen
|
|
6764
|
+
const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
|
|
6765
|
+
const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
|
|
6766
|
+
const swapAbove = (position) => {
|
|
6767
|
+
return !enoughSpaceAbove ? position.replace("top", "bottom") : position;
|
|
6768
|
+
};
|
|
6769
|
+
const swapBelow = (position) => {
|
|
6770
|
+
return !enoughSpaceBelow && enoughSpaceAbove ? position.replace("bottom", "top") : position;
|
|
6771
|
+
};
|
|
6772
|
+
const swapLeft = (position, centeredPosition) => {
|
|
6773
|
+
if (!enoughSpaceLeft && enoughSpaceRight) {
|
|
6774
|
+
position = position.replace("left", "right");
|
|
6775
|
+
}
|
|
6776
|
+
else if (!enoughSpaceLeft && !enoughSpaceRight) {
|
|
6777
|
+
position = centeredPosition;
|
|
6778
|
+
}
|
|
6779
|
+
return position;
|
|
6780
|
+
};
|
|
6781
|
+
const swapRight = (position, centeredPosition) => {
|
|
6782
|
+
if (!enoughSpaceRight && enoughSpaceLeft) {
|
|
6783
|
+
position = position.replace("right", "left");
|
|
6784
|
+
}
|
|
6785
|
+
else if (!enoughSpaceRight && !enoughSpaceLeft) {
|
|
6786
|
+
position = centeredPosition;
|
|
6787
|
+
}
|
|
6788
|
+
return position;
|
|
6789
|
+
};
|
|
6790
|
+
// horizontal checks must occur before vertical checks, because horizontal can affect vertical positioning but not vice versa
|
|
6791
|
+
switch (tPos) {
|
|
6792
|
+
case "left":
|
|
6793
|
+
tPos = swapLeft(tPos, "bottom");
|
|
6794
|
+
case "right":
|
|
6795
|
+
tPos = swapRight(tPos, "bottom");
|
|
6796
|
+
case "top-left":
|
|
6797
|
+
tPos = swapLeft(tPos, "top");
|
|
6798
|
+
tPos = swapAbove(tPos);
|
|
6799
|
+
case "top-right":
|
|
6800
|
+
tPos = swapRight(tPos, "top");
|
|
6801
|
+
tPos = swapAbove(tPos);
|
|
6802
|
+
case "bottom-left":
|
|
6803
|
+
tPos = swapLeft(tPos, "bottom");
|
|
6804
|
+
tPos = swapBelow(tPos);
|
|
6805
|
+
case "bottom-right":
|
|
6806
|
+
tPos = swapRight(tPos, "bottom");
|
|
6807
|
+
tPos = swapBelow(tPos);
|
|
6808
|
+
case "top":
|
|
6809
|
+
tPos = swapAbove(tPos);
|
|
6810
|
+
case "bottom":
|
|
6811
|
+
tPos = swapBelow(tPos);
|
|
6812
|
+
}
|
|
6813
|
+
return tPos;
|
|
6814
|
+
}
|
|
6815
|
+
function hasRoomRight(x, spaceNeeded) {
|
|
6816
|
+
let horizOffset = 0;
|
|
6817
|
+
// if (getTextDir() === "ltr") {
|
|
6818
|
+
if (x.type === "click") {
|
|
6819
|
+
// if it's a mouse event, deal with mouse coords
|
|
6820
|
+
horizOffset = x.clientX;
|
|
6821
|
+
// if it's a focus event, the offset is 0
|
|
6822
|
+
}
|
|
6823
|
+
else if (x.type === "focus") {
|
|
6824
|
+
horizOffset = 0;
|
|
6825
|
+
}
|
|
6826
|
+
else {
|
|
6827
|
+
// otherwise an element was passed, calculate how far it is from the edge of the window
|
|
6828
|
+
let el = x; // re-assignment is for clarity
|
|
6829
|
+
while (el) {
|
|
6830
|
+
if (el.tagName == "BODY") {
|
|
6831
|
+
// deal with browser quirks with body/window/document and page scroll
|
|
6832
|
+
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
|
|
6833
|
+
horizOffset += el.offsetLeft - xScroll + el.clientLeft;
|
|
6834
|
+
}
|
|
6835
|
+
else {
|
|
6836
|
+
// for all other non-BODY elements
|
|
6837
|
+
horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
|
|
6838
|
+
}
|
|
6839
|
+
el = el.offsetParent;
|
|
6840
|
+
}
|
|
6841
|
+
// }
|
|
6842
|
+
}
|
|
6843
|
+
return window.innerWidth - horizOffset >= spaceNeeded;
|
|
6844
|
+
}
|
|
6845
|
+
function checkForActiveElInShadow(element) {
|
|
6846
|
+
while (element && element.shadowRoot) {
|
|
6847
|
+
element = element.shadowRoot.activeElement;
|
|
6848
|
+
}
|
|
6849
|
+
return element;
|
|
6850
|
+
}
|
|
6851
|
+
function checkForFocusableElInShadow(element) {
|
|
6852
|
+
const selectors = [
|
|
6853
|
+
"button",
|
|
6854
|
+
"a",
|
|
6855
|
+
"input",
|
|
6856
|
+
"select",
|
|
6857
|
+
"textarea",
|
|
6858
|
+
"wm-button",
|
|
6859
|
+
"wm-search",
|
|
6860
|
+
"wm-select",
|
|
6861
|
+
"wm-action-menu",
|
|
6862
|
+
"wm-tab-item",
|
|
6863
|
+
"wm-datepicker",
|
|
6864
|
+
];
|
|
6865
|
+
let focusableEl = element;
|
|
6866
|
+
selectors.forEach((selector) => {
|
|
6867
|
+
if (focusableEl && focusableEl.shadowRoot) {
|
|
6868
|
+
let elInShadow = focusableEl.shadowRoot.querySelector(selector);
|
|
6869
|
+
if (elInShadow) {
|
|
6870
|
+
if (selector.startsWith("wm-")) {
|
|
6871
|
+
focusableEl = checkForFocusableElInShadow(elInShadow);
|
|
6872
|
+
}
|
|
6873
|
+
else {
|
|
6874
|
+
focusableEl = elInShadow;
|
|
6875
|
+
}
|
|
6876
|
+
}
|
|
6877
|
+
}
|
|
6878
|
+
});
|
|
6879
|
+
return focusableEl;
|
|
6880
|
+
}
|
|
6881
|
+
function isFocusable(element) {
|
|
6882
|
+
if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
|
|
6883
|
+
return true;
|
|
6884
|
+
}
|
|
6885
|
+
if (element.disabled) {
|
|
6886
|
+
return false;
|
|
6887
|
+
}
|
|
6888
|
+
switch (element.nodeName) {
|
|
6889
|
+
case "A":
|
|
6890
|
+
return !!element.href && element.rel != "ignore";
|
|
6891
|
+
case "INPUT":
|
|
6892
|
+
return element.type != "hidden" && element.type != "file";
|
|
6893
|
+
case "BUTTON":
|
|
6894
|
+
case "SELECT":
|
|
6895
|
+
case "TEXTAREA":
|
|
6896
|
+
case "WM-BUTTON":
|
|
6897
|
+
case "WM-SELECT":
|
|
6898
|
+
case "WM-ACTION-MENU":
|
|
6899
|
+
case "WM-DATEPICKER":
|
|
6900
|
+
case "WM-TIMEPICKER":
|
|
6901
|
+
case "WM-INPUT":
|
|
6902
|
+
case "WM-TAG-INPUT":
|
|
6903
|
+
case "WM-TAB-ITEM":
|
|
6904
|
+
case "WM-SEARCH":
|
|
6905
|
+
return true;
|
|
6906
|
+
default:
|
|
6907
|
+
return false;
|
|
6908
|
+
}
|
|
6909
|
+
}
|
|
6910
|
+
function getFirstFocusableDescendant(element) {
|
|
6911
|
+
if (isFocusable(element)) {
|
|
6912
|
+
return checkForFocusableElInShadow(element);
|
|
6913
|
+
}
|
|
6914
|
+
else if (element.childNodes.length > 0) {
|
|
6915
|
+
element.childNodes.forEach((i) => {
|
|
6916
|
+
const childEl = getFirstFocusableDescendant(i);
|
|
6917
|
+
return childEl && checkForFocusableElInShadow(childEl);
|
|
6918
|
+
});
|
|
6919
|
+
}
|
|
6920
|
+
}
|
|
6921
|
+
function hasValidType(file, types) {
|
|
6922
|
+
const acceptedExtensions = types.split(" ");
|
|
6923
|
+
const parts = file.name && file.name.split(".");
|
|
6924
|
+
const ext = parts && parts.length > 1 && parts[parts.length - 1];
|
|
6925
|
+
return ext
|
|
6926
|
+
? acceptedExtensions.includes(ext.toLowerCase())
|
|
6927
|
+
: // fallback: if we couldn't obtain an extension,
|
|
6928
|
+
// validate based on MIME type...
|
|
6929
|
+
!!file.type
|
|
6930
|
+
? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
|
|
6931
|
+
: // ...and if that failed too, accept the file
|
|
6932
|
+
// as it's preferable to accept an invalid file
|
|
6933
|
+
// than refusing a valid one (back-end will take care of what slips through)
|
|
6934
|
+
true;
|
|
6935
|
+
}
|
|
6936
|
+
// takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
|
|
6937
|
+
function getAcceptedMimeTypesList(acceptedExtensions) {
|
|
6938
|
+
// this is just a list of common file types (regardless of whether they are/can be valid or not)
|
|
6939
|
+
// front end checks are just a convenience to users, independent of security.
|
|
6940
|
+
// it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
|
|
6941
|
+
const lookupTable = {
|
|
6942
|
+
aac: ["audio/aac"],
|
|
6943
|
+
abw: ["application/x-abiword"],
|
|
6944
|
+
arc: ["application/x-freearc"],
|
|
6945
|
+
avi: ["video/x-msvideo"],
|
|
6946
|
+
azw: ["application/vnd.amazon.ebook"],
|
|
6947
|
+
bin: ["application/octet-stream"],
|
|
6948
|
+
bmp: ["image/bmp"],
|
|
6949
|
+
bz: ["application/x-bzip"],
|
|
6950
|
+
bz2: ["application/x-bzip2"],
|
|
6951
|
+
csh: ["application/x-csh"],
|
|
6952
|
+
css: ["text/css"],
|
|
6953
|
+
csv: ["text/csv"],
|
|
6954
|
+
doc: ["application/msword"],
|
|
6955
|
+
docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
6956
|
+
eot: ["application/vnd.ms-fontobject"],
|
|
6957
|
+
epub: ["application/epub+zip"],
|
|
6958
|
+
gz: ["application/gzip"],
|
|
6959
|
+
gif: ["image/gif"],
|
|
6960
|
+
htm: ["text/html"],
|
|
6961
|
+
html: ["text/html"],
|
|
6962
|
+
ico: ["image/vnd.microsoft.icon"],
|
|
6963
|
+
ics: ["text/calendar"],
|
|
6964
|
+
jar: ["application/java-archive"],
|
|
6965
|
+
jpeg: ["image/jpeg"],
|
|
6966
|
+
jpg: ["image/jpeg"],
|
|
6967
|
+
js: ["text/javascript"],
|
|
6968
|
+
json: ["application/json"],
|
|
6969
|
+
jsonld: ["application/ld+json"],
|
|
6970
|
+
log: ["text/plain"],
|
|
6971
|
+
mid: ["audio/x-midi"],
|
|
6972
|
+
midi: ["audio/x-midi"],
|
|
6973
|
+
mjs: ["text/javascript"],
|
|
6974
|
+
mp3: ["audio/mpeg"],
|
|
6975
|
+
mpeg: ["video/mpeg"],
|
|
6976
|
+
mpkg: ["application/vnd.apple.installer+xml"],
|
|
6977
|
+
odp: ["application/vnd.oasis.opendocument.presentation"],
|
|
6978
|
+
ods: ["application/vnd.oasis.opendocument.spreadsheet"],
|
|
6979
|
+
odt: ["application/vnd.oasis.opendocument.text"],
|
|
6980
|
+
oga: ["audio/ogg"],
|
|
6981
|
+
ogv: ["video/ogg"],
|
|
6982
|
+
ogx: ["application/ogg"],
|
|
6983
|
+
opus: ["audio/opus"],
|
|
6984
|
+
otf: ["font/otf"],
|
|
6985
|
+
png: ["image/png"],
|
|
6986
|
+
pdf: ["application/pdf"],
|
|
6987
|
+
php: ["application/php"],
|
|
6988
|
+
ppt: ["application/vnd.ms-powerpoint"],
|
|
6989
|
+
pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
6990
|
+
rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
|
|
6991
|
+
rtf: ["application/rtf"],
|
|
6992
|
+
sh: ["application/x-sh"],
|
|
6993
|
+
svg: ["image/svg+xml"],
|
|
6994
|
+
swf: ["application/x-shockwave-flash"],
|
|
6995
|
+
tar: ["application/x-tar"],
|
|
6996
|
+
tif: ["image/tiff"],
|
|
6997
|
+
tiff: ["image/tiff"],
|
|
6998
|
+
ts: ["video/mp2t"],
|
|
6999
|
+
ttf: ["font/ttf"],
|
|
7000
|
+
txt: ["text/plain"],
|
|
7001
|
+
vsd: ["application/vnd.visio"],
|
|
7002
|
+
wav: ["audio/wav"],
|
|
7003
|
+
weba: ["audio/webm"],
|
|
7004
|
+
webm: ["video/webm"],
|
|
7005
|
+
webp: ["image/webp"],
|
|
7006
|
+
woff: ["font/woff"],
|
|
7007
|
+
woff2: ["font/woff2"],
|
|
7008
|
+
xhtml: ["application/xhtml+xml"],
|
|
7009
|
+
xls: ["application/vnd.ms-excel"],
|
|
7010
|
+
xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
7011
|
+
xml: ["application/xml", "text/xml"],
|
|
7012
|
+
xul: ["application/vnd.mozilla.xul+xml"],
|
|
7013
|
+
zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
|
|
7014
|
+
"3gp": ["video/3gpp", "audio/3gpp"],
|
|
7015
|
+
"3g2": ["video/3gpp2", "audio/3gpp2"],
|
|
7016
|
+
"7z": ["application/x-7z-compressed"],
|
|
7017
|
+
};
|
|
7018
|
+
return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
|
|
7019
|
+
}
|
|
7020
|
+
function snakeCaseToCamelCase(str) {
|
|
7021
|
+
const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
|
|
7022
|
+
if (snakeCaseRegexp.test(str)) {
|
|
7023
|
+
let camelCase = "";
|
|
7024
|
+
let arr = str.split("_");
|
|
7025
|
+
arr.forEach((word, idx) => {
|
|
7026
|
+
camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
|
|
7027
|
+
});
|
|
7028
|
+
return camelCase;
|
|
7029
|
+
}
|
|
7030
|
+
else {
|
|
7031
|
+
return str;
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
function getNewIndexToFocus(currentIndex, direction, listLength) {
|
|
7035
|
+
let newIndex = currentIndex;
|
|
7036
|
+
if (direction === "ArrowDown") {
|
|
7037
|
+
newIndex = (currentIndex + 1) % listLength;
|
|
7038
|
+
}
|
|
7039
|
+
if (direction === "ArrowUp") {
|
|
7040
|
+
newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
|
|
7041
|
+
}
|
|
7042
|
+
return newIndex;
|
|
7043
|
+
}
|
|
7044
|
+
function isRelatedTarget(ev, id) {
|
|
7045
|
+
// used for onBlur events to check the element that has been clicked
|
|
7046
|
+
const ids = id.split(" ");
|
|
7047
|
+
return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
|
|
7048
|
+
}
|
|
7049
|
+
function toBool(val) {
|
|
7050
|
+
// string "false" needs to be treated as bool False because react wrappers convert bool to string.
|
|
7051
|
+
return val == "false" ? false : !!val;
|
|
7052
|
+
}
|
|
7053
|
+
/*
|
|
7054
|
+
* this is going to be needed to solve the extra tabbing on navigator
|
|
7055
|
+
* and for programmatic focus of tabs
|
|
7056
|
+
* Here's a draft, not bug proof, see:
|
|
7057
|
+
* https://stackoverflow.com/a/10730308/3741713
|
|
7058
|
+
|
|
7059
|
+
function getKeyboardFocusableElements(element = document) {
|
|
7060
|
+
const els = Array.from(element.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), wm-search, wm-timepicker, wm-tab-list, wm-tab-item, wm-button, wm-action-menu'));
|
|
7061
|
+
return els.filter((el: Element) => !el.hasAttribute("disabled")) as HTMLElement[];
|
|
7062
|
+
}
|
|
7063
|
+
|
|
7064
|
+
export function getPreviousKeyboardFocusableElement(element: HTMLElement) {
|
|
7065
|
+
const els = getKeyboardFocusableElements();
|
|
7066
|
+
const current = els.indexOf(element);
|
|
7067
|
+
return els[current - 1] as HTMLElement;
|
|
7068
|
+
}
|
|
7069
|
+
|
|
7070
|
+
export function getNextKeyboardFocusableElement(element: HTMLElement) {
|
|
7071
|
+
const els = getKeyboardFocusableElements();
|
|
7072
|
+
const current = els.indexOf(element);
|
|
7073
|
+
return els[current + 1] as HTMLElement;
|
|
7074
|
+
}
|
|
7101
7075
|
*/
|
|
7102
7076
|
|
|
7103
7077
|
exports.adjustTooltipPosition = adjustTooltipPosition;
|