@watermarkinsights/ripple 5.13.0 → 5.13.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-globals-6l2OXl3R.js +92 -0
- package/dist/cjs/chartFunctions-uCzSt0yo.js +741 -0
- package/dist/cjs/functions-CqAwq8Fq.js +10526 -0
- package/dist/cjs/index-Cig4P4gJ.js +2086 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/interfaces-C7YbtGnk.js +37 -0
- package/dist/cjs/intl-BUs7ck9m.js +283 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/priv-calendar.cjs.entry.js +568 -0
- package/dist/cjs/priv-chart-popover.cjs.entry.js +136 -0
- package/dist/cjs/priv-navigator-button_2.cjs.entry.js +54 -0
- package/dist/cjs/priv-option-list_2.cjs.entry.js +556 -0
- package/dist/cjs/ripple.cjs.js +25 -0
- package/dist/cjs/wm-action-menu_4.cjs.entry.js +701 -0
- package/dist/cjs/wm-chart-slice.cjs.entry.js +20 -0
- package/dist/cjs/wm-chart.cjs.entry.js +159 -0
- package/dist/cjs/wm-date-range.cjs.entry.js +479 -0
- package/dist/cjs/wm-datepicker.cjs.entry.js +249 -0
- package/dist/cjs/wm-file-list.cjs.entry.js +20 -0
- package/dist/cjs/wm-file.cjs.entry.js +184 -0
- package/dist/cjs/wm-flyout.cjs.entry.js +169 -0
- package/dist/cjs/wm-input.cjs.entry.js +113 -0
- package/dist/cjs/wm-line-chart.cjs.entry.js +451 -0
- package/dist/cjs/wm-modal-footer.cjs.entry.js +46 -0
- package/dist/cjs/wm-modal-header.cjs.entry.js +38 -0
- package/dist/cjs/wm-modal-pss-footer.cjs.entry.js +42 -0
- package/dist/cjs/wm-modal-pss-header.cjs.entry.js +41 -0
- package/dist/cjs/wm-modal-pss.cjs.entry.js +137 -0
- package/dist/cjs/wm-modal.cjs.entry.js +135 -0
- package/dist/cjs/wm-navigation-hamburger.cjs.entry.js +50 -0
- package/dist/{ripple/wm-tab-panel.entry.js → cjs/wm-navigation-item.cjs.entry.js} +12 -24
- package/dist/cjs/wm-navigation.cjs.entry.js +118 -0
- package/dist/cjs/wm-navigator.cjs.entry.js +329 -0
- package/dist/{ripple/wm-search.entry.js → cjs/wm-nested-select.cjs.entry.js} +273 -171
- package/dist/cjs/wm-optgroup.cjs.entry.js +70 -0
- package/dist/cjs/wm-pagination.cjs.entry.js +225 -0
- package/dist/cjs/wm-progress-indicator.cjs.entry.js +109 -0
- package/dist/cjs/wm-progress-monitor.cjs.entry.js +73 -0
- package/dist/cjs/wm-progress-slice.cjs.entry.js +15 -0
- package/dist/cjs/wm-search.cjs.entry.js +210 -0
- package/dist/cjs/wm-select.cjs.entry.js +251 -0
- package/dist/cjs/wm-tab-item.cjs.entry.js +65 -0
- package/dist/cjs/wm-tab-list.cjs.entry.js +177 -0
- package/dist/cjs/wm-tab-panel.cjs.entry.js +34 -0
- package/dist/cjs/wm-tag-input.cjs.entry.js +879 -0
- package/dist/cjs/wm-tag-option.cjs.entry.js +37 -0
- package/dist/cjs/wm-textarea.cjs.entry.js +81 -0
- package/dist/cjs/wm-timepicker.cjs.entry.js +302 -0
- package/dist/cjs/wm-toggletip.cjs.entry.js +178 -0
- package/dist/cjs/wm-uploader.cjs.entry.js +315 -0
- package/dist/cjs/wm-wrapper.cjs.entry.js +19 -0
- package/dist/collection/collection-manifest.json +59 -0
- package/dist/collection/components/charts/chartFunctions.js +675 -0
- package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.css +922 -0
- package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +261 -0
- package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +128 -0
- package/dist/collection/components/charts/wm-chart/wm-chart.css +1288 -0
- package/dist/collection/components/charts/wm-chart/wm-chart.js +445 -0
- package/dist/collection/components/charts/wm-line-chart/wm-line-chart.css +1080 -0
- package/dist/collection/components/charts/wm-line-chart/wm-line-chart.js +742 -0
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.css +1288 -0
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +271 -0
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.css +922 -0
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +154 -0
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +124 -0
- package/dist/collection/components/datepickers/datepicker.css +1057 -0
- package/dist/collection/components/datepickers/priv-calendar/priv-calendar.css +1292 -0
- package/dist/collection/components/datepickers/priv-calendar/priv-calendar.js +849 -0
- package/dist/collection/components/datepickers/wm-date-range.js +869 -0
- package/dist/collection/components/datepickers/wm-datepicker.js +538 -0
- package/dist/collection/components/selects/priv-option-list/priv-option-list.css +931 -0
- package/dist/collection/components/selects/priv-option-list/priv-option-list.js +791 -0
- package/dist/collection/components/selects/wm-nested-select/wm-nested-select.css +1194 -0
- package/dist/collection/components/selects/wm-nested-select/wm-nested-select.js +644 -0
- package/dist/collection/components/selects/wm-optgroup/wm-optgroup.css +843 -0
- package/dist/collection/components/selects/wm-optgroup/wm-optgroup.js +265 -0
- package/dist/collection/components/selects/wm-option/wm-option.css +944 -0
- package/dist/collection/components/selects/wm-option/wm-option.js +539 -0
- package/dist/collection/components/selects/wm-select/wm-select.css +1117 -0
- package/dist/collection/components/selects/wm-select/wm-select.js +606 -0
- package/dist/collection/components/wm-action-menu/wm-action-menu.css +904 -0
- package/dist/collection/components/wm-action-menu/wm-action-menu.js +444 -0
- package/dist/collection/components/wm-button/wm-button.css +1371 -0
- package/dist/collection/components/wm-button/wm-button.js +510 -0
- package/dist/collection/components/wm-file/wm-file.css +940 -0
- package/dist/collection/components/wm-file/wm-file.js +423 -0
- package/dist/collection/components/wm-file-list/wm-file-list.css +833 -0
- package/dist/collection/components/wm-file-list/wm-file-list.js +47 -0
- package/dist/collection/components/wm-flyout/wm-flyout.css +1027 -0
- package/dist/collection/components/wm-flyout/wm-flyout.js +460 -0
- package/dist/collection/components/wm-input/wm-input.css +1017 -0
- package/dist/collection/components/wm-input/wm-input.js +498 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.css +904 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.js +425 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.css +858 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.js +152 -0
- package/dist/collection/components/wm-modal/wm-modal-header.css +857 -0
- package/dist/collection/components/wm-modal/wm-modal-header.js +83 -0
- package/dist/collection/components/wm-modal/wm-modal.css +905 -0
- package/dist/collection/components/wm-modal/wm-modal.js +356 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss-footer.css +865 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss-footer.js +148 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss-header.css +859 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss-header.js +86 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss.css +941 -0
- package/dist/collection/components/wm-modal-pss/wm-modal-pss.js +369 -0
- package/dist/collection/components/wm-navigation/wm-navigation-hamburger.css +860 -0
- package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +120 -0
- package/dist/collection/components/wm-navigation/wm-navigation-item.css +869 -0
- package/dist/collection/components/wm-navigation/wm-navigation-item.js +99 -0
- package/dist/collection/components/wm-navigation/wm-navigation.css +911 -0
- package/dist/collection/components/wm-navigation/wm-navigation.js +192 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.css +863 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +90 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.css +843 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +130 -0
- package/dist/collection/components/wm-navigator/wm-navigator.css +916 -0
- package/dist/collection/components/wm-navigator/wm-navigator.js +515 -0
- package/dist/collection/components/wm-pagination/wm-pagination.css +984 -0
- package/dist/collection/components/wm-pagination/wm-pagination.js +373 -0
- package/dist/collection/components/wm-search/wm-search.css +909 -0
- package/dist/collection/components/wm-search/wm-search.js +462 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.css +1091 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +279 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +882 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +187 -0
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.css +854 -0
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +276 -0
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.css +838 -0
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +97 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.css +1289 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +1245 -0
- package/dist/collection/components/wm-tag-input/wm-tag-option/wm-tag-option.js +251 -0
- package/dist/collection/components/wm-textarea/wm-textarea.css +993 -0
- package/dist/collection/components/wm-textarea/wm-textarea.js +331 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.css +1107 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +559 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.css +1165 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +295 -0
- package/dist/collection/components/wm-uploader/wm-uploader.css +1673 -0
- package/dist/collection/components/wm-uploader/wm-uploader.js +618 -0
- package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -0
- package/dist/collection/dev/action-menu.js +0 -0
- package/dist/collection/dev/button.js +0 -0
- package/dist/collection/dev/chart-small.js +56 -0
- package/dist/collection/dev/chart.js +18 -0
- package/dist/collection/dev/date-range.js +6 -0
- package/dist/collection/dev/datepicker.js +46 -0
- package/dist/collection/dev/file-list.js +16 -0
- package/dist/collection/dev/file.js +0 -0
- package/dist/collection/dev/flyout.js +194 -0
- package/dist/collection/dev/input.js +6 -0
- package/dist/collection/dev/line-chart.js +0 -0
- package/dist/collection/dev/modal.js +48 -0
- package/dist/collection/dev/navigation.js +13 -0
- package/dist/collection/dev/navigator.js +34 -0
- package/dist/collection/dev/nested-select.js +36 -0
- package/dist/collection/dev/pagination.js +7 -0
- package/dist/collection/dev/progress-monitor.js +0 -0
- package/dist/collection/dev/pss-modal.js +8 -0
- package/dist/collection/dev/scripts.js +49 -0
- package/dist/collection/dev/search.js +72 -0
- package/dist/collection/dev/select.js +57 -0
- package/dist/collection/dev/snackbar.js +60 -0
- package/dist/collection/dev/tabs.js +44 -0
- package/dist/collection/dev/tag-input.js +32 -0
- package/dist/collection/dev/textarea.js +28 -0
- package/dist/collection/dev/timepicker.js +32 -0
- package/dist/collection/dev/toggletip.js +9 -0
- package/dist/collection/dev/uploader.js +139 -0
- package/dist/collection/global/__mocks__/functions.js +6 -0
- package/dist/collection/global/functions.js +841 -0
- package/dist/{ripple/app-globals-B7cOtGhY.js → collection/global/global.js} +2 -84
- package/dist/{ripple/interfaces-CrANcZM9.js → collection/global/interfaces.js} +4 -6
- package/dist/collection/global/intl.js +274 -0
- package/dist/collection/global/services/__mocks__/http-service.js +130 -0
- package/dist/collection/global/services/http-service.js +50 -0
- package/dist/collection/lang/lang.js +5 -0
- package/dist/collection/lang/missing.js +43 -0
- package/dist/collection/lang/piglatin.js +101 -0
- package/dist/components/index.js +85 -0
- package/dist/components/p-BlQdbOh_.js +294 -0
- package/dist/components/p-BvE5BEYe.js +146 -0
- package/dist/components/p-BzGDMpdL.js +592 -0
- package/dist/{ripple/wm-modal-header.entry.js → components/p-CLem5EoD.js} +35 -29
- package/dist/components/p-COwzv5zO.js +34 -0
- package/dist/components/p-CWx2NF6K.js +231 -0
- package/dist/{ripple/wm-progress-monitor.entry.js → components/p-D9GMUh0-.js} +217 -57
- package/dist/{ripple/wm-option.entry.js → components/p-DCSxoWXP.js} +384 -134
- package/dist/components/p-DG_w4q3M.js +196 -0
- package/dist/{ripple/intl-7p27BJSM.js → components/p-DStPjkvu.js} +1 -1
- package/dist/components/p-DdlNyc6u.js +10485 -0
- package/dist/{ripple/wm-toggletip.entry.js → components/p-DvXS4oTB.js} +44 -171
- package/dist/components/p-HPnDWE3g.js +1686 -0
- package/dist/components/p-K9lgwbAO.js +724 -0
- package/dist/{ripple/wm-textarea.entry.js → components/p-e_A35rK5.js} +132 -57
- package/dist/components/priv-calendar.js +6 -0
- package/dist/components/priv-chart-popover.js +6 -0
- package/dist/components/priv-navigator-button.js +6 -0
- package/dist/components/priv-navigator-item.js +6 -0
- package/dist/components/priv-option-list.js +6 -0
- package/dist/components/wm-action-menu.js +6 -0
- package/dist/components/wm-button.js +6 -0
- package/dist/components/wm-chart-slice.js +41 -0
- package/dist/components/wm-chart.js +197 -0
- package/dist/components/wm-date-range.js +522 -0
- package/dist/components/wm-datepicker.js +287 -0
- package/dist/components/wm-file-list.js +38 -0
- package/dist/components/wm-file.js +228 -0
- package/dist/components/wm-flyout.js +208 -0
- package/dist/components/wm-input.js +152 -0
- package/dist/components/wm-line-chart.js +497 -0
- package/dist/components/wm-menuitem.js +6 -0
- package/dist/components/wm-modal-footer.js +73 -0
- package/dist/components/wm-modal-header.js +61 -0
- package/dist/components/wm-modal-pss-footer.js +69 -0
- package/dist/components/wm-modal-pss-header.js +64 -0
- package/dist/components/wm-modal-pss.js +162 -0
- package/dist/components/wm-modal.js +161 -0
- package/dist/components/wm-navigation-hamburger.js +70 -0
- package/dist/components/wm-navigation-item.js +40 -0
- package/dist/components/wm-navigation.js +144 -0
- package/dist/components/wm-navigator.js +369 -0
- package/dist/{ripple/wm-flyout.entry.js → components/wm-nested-select.js} +313 -137
- package/dist/components/wm-optgroup.js +107 -0
- package/dist/components/wm-option.js +6 -0
- package/dist/components/wm-pagination.js +251 -0
- package/dist/components/wm-progress-indicator.js +144 -0
- package/dist/components/wm-progress-monitor.js +93 -0
- package/dist/components/wm-progress-slice.js +37 -0
- package/dist/components/wm-search.js +250 -0
- package/dist/components/wm-select.js +6 -0
- package/dist/components/wm-snackbar.js +209 -0
- package/dist/components/wm-tab-item.js +85 -0
- package/dist/components/wm-tab-list.js +217 -0
- package/dist/components/wm-tab-panel.js +52 -0
- package/dist/components/wm-tag-input.js +919 -0
- package/dist/components/wm-tag-option.js +63 -0
- package/dist/components/wm-textarea.js +113 -0
- package/dist/components/wm-timepicker.js +333 -0
- package/dist/components/wm-toggletip.js +200 -0
- package/dist/components/wm-uploader.js +348 -0
- package/dist/components/wm-wrapper.js +34 -0
- package/dist/esm/app-globals-eAJzxs1b.js +90 -0
- package/dist/{ripple/chartFunctions-CmeM8Tyx.js → esm/chartFunctions-C4yzutWl.js} +3 -4
- package/dist/{ripple/functions-DVLl0rH_.js → esm/functions-CU95tthb.js} +144 -7767
- package/dist/esm/index-EopL5zo4.js +2075 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/interfaces-CyJHzEjr.js +34 -0
- package/dist/esm/intl-CN471tL5.js +277 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/priv-calendar.entry.js +566 -0
- package/dist/esm/priv-chart-popover.entry.js +134 -0
- package/dist/esm/priv-navigator-button_2.entry.js +51 -0
- package/dist/esm/priv-option-list_2.entry.js +553 -0
- package/dist/esm/ripple.js +21 -0
- package/dist/esm/wm-action-menu_4.entry.js +696 -0
- package/dist/{ripple → esm}/wm-chart-slice.entry.js +1 -1
- package/dist/esm/wm-chart.entry.js +157 -0
- package/dist/esm/wm-date-range.entry.js +477 -0
- package/dist/esm/wm-datepicker.entry.js +247 -0
- package/dist/esm/wm-file-list.entry.js +18 -0
- package/dist/{ripple/wm-chart.entry.js → esm/wm-file.entry.js} +161 -136
- package/dist/esm/wm-flyout.entry.js +167 -0
- package/dist/esm/wm-input.entry.js +111 -0
- package/dist/esm/wm-line-chart.entry.js +449 -0
- package/dist/{ripple/wm-modal.entry.js → esm/wm-modal-footer.entry.js} +28 -117
- package/dist/{ripple/wm-input.entry.js → esm/wm-modal-header.entry.js} +24 -99
- package/dist/{ripple/wm-menuitem.entry.js → esm/wm-modal-pss-footer.entry.js} +28 -113
- package/dist/{ripple/wm-optgroup.entry.js → esm/wm-modal-pss-header.entry.js} +28 -57
- package/dist/esm/wm-modal-pss.entry.js +135 -0
- package/dist/esm/wm-modal.entry.js +133 -0
- package/dist/esm/wm-navigation-hamburger.entry.js +48 -0
- package/dist/{ripple/wm-file-list.entry.js → esm/wm-navigation-item.entry.js} +7 -7
- package/dist/{ripple/wm-file.entry.js → esm/wm-navigation.entry.js} +91 -157
- package/dist/esm/wm-navigator.entry.js +327 -0
- package/dist/{ripple/wm-select.entry.js → esm/wm-nested-select.entry.js} +193 -134
- package/dist/esm/wm-optgroup.entry.js +68 -0
- package/dist/esm/wm-pagination.entry.js +223 -0
- package/dist/esm/wm-progress-indicator.entry.js +107 -0
- package/dist/esm/wm-progress-monitor.entry.js +71 -0
- package/dist/{ripple → esm}/wm-progress-slice.entry.js +1 -1
- package/dist/esm/wm-search.entry.js +208 -0
- package/dist/esm/wm-select.entry.js +249 -0
- package/dist/esm/wm-tab-item.entry.js +63 -0
- package/dist/esm/wm-tab-list.entry.js +175 -0
- package/dist/esm/wm-tab-panel.entry.js +32 -0
- package/dist/esm/wm-tag-input.entry.js +877 -0
- package/dist/{ripple → esm}/wm-tag-option.entry.js +2 -2
- package/dist/esm/wm-textarea.entry.js +79 -0
- package/dist/esm/wm-timepicker.entry.js +300 -0
- package/dist/esm/wm-toggletip.entry.js +176 -0
- package/dist/esm/wm-uploader.entry.js +313 -0
- package/dist/{ripple → esm}/wm-wrapper.entry.js +1 -1
- package/dist/esm-es5/app-globals-eAJzxs1b.js +1 -0
- package/dist/esm-es5/chartFunctions-C4yzutWl.js +1 -0
- package/dist/esm-es5/functions-CU95tthb.js +1 -0
- package/dist/esm-es5/index-EopL5zo4.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/interfaces-CyJHzEjr.js +1 -0
- package/dist/esm-es5/intl-CN471tL5.js +1 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/priv-calendar.entry.js +1 -0
- package/dist/esm-es5/priv-chart-popover.entry.js +1 -0
- package/dist/esm-es5/priv-navigator-button_2.entry.js +1 -0
- package/dist/esm-es5/priv-option-list_2.entry.js +1 -0
- package/dist/esm-es5/ripple.js +1 -0
- package/dist/esm-es5/wm-action-menu_4.entry.js +1 -0
- package/dist/esm-es5/wm-chart-slice.entry.js +1 -0
- package/dist/esm-es5/wm-chart.entry.js +1 -0
- package/dist/esm-es5/wm-date-range.entry.js +1 -0
- package/dist/{ripple/wm-uploader.entry.js → esm-es5/wm-datepicker.entry.js} +1 -313
- package/dist/{ripple/wm-tab-item.entry.js → esm-es5/wm-file-list.entry.js} +1 -63
- package/dist/esm-es5/wm-file.entry.js +1 -0
- package/dist/esm-es5/wm-flyout.entry.js +1 -0
- package/dist/esm-es5/wm-input.entry.js +1 -0
- package/dist/esm-es5/wm-line-chart.entry.js +1 -0
- package/dist/{ripple/wm-navigation.entry.js → esm-es5/wm-modal-footer.entry.js} +1 -116
- package/dist/esm-es5/wm-modal-header.entry.js +1 -0
- package/dist/esm-es5/wm-modal-pss-footer.entry.js +1 -0
- package/dist/esm-es5/wm-modal-pss-header.entry.js +1 -0
- package/dist/esm-es5/wm-modal-pss.entry.js +1 -0
- package/dist/esm-es5/wm-modal.entry.js +1 -0
- package/dist/esm-es5/wm-navigation-hamburger.entry.js +1 -0
- package/dist/esm-es5/wm-navigation-item.entry.js +1 -0
- package/dist/esm-es5/wm-navigation.entry.js +1 -0
- package/dist/esm-es5/wm-navigator.entry.js +1 -0
- package/dist/esm-es5/wm-nested-select.entry.js +1 -0
- package/dist/esm-es5/wm-optgroup.entry.js +1 -0
- package/dist/esm-es5/wm-pagination.entry.js +1 -0
- package/dist/{ripple/wm-modal-footer.entry.js → esm-es5/wm-progress-indicator.entry.js} +1 -44
- package/dist/esm-es5/wm-progress-monitor.entry.js +1 -0
- package/dist/esm-es5/wm-progress-slice.entry.js +1 -0
- package/dist/esm-es5/wm-search.entry.js +1 -0
- package/dist/esm-es5/wm-select.entry.js +1 -0
- package/dist/esm-es5/wm-tab-item.entry.js +1 -0
- package/dist/esm-es5/wm-tab-list.entry.js +1 -0
- package/dist/esm-es5/wm-tab-panel.entry.js +1 -0
- package/dist/esm-es5/wm-tag-input.entry.js +1 -0
- package/dist/esm-es5/wm-tag-option.entry.js +1 -0
- package/dist/esm-es5/wm-textarea.entry.js +1 -0
- package/dist/esm-es5/wm-timepicker.entry.js +1 -0
- package/dist/esm-es5/wm-toggletip.entry.js +1 -0
- package/dist/esm-es5/wm-uploader.entry.js +1 -0
- package/dist/esm-es5/wm-wrapper.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +2 -0
- package/dist/loader/index.cjs.js +2 -0
- package/dist/loader/index.d.ts +24 -0
- package/dist/loader/index.es2017.js +2 -0
- package/dist/loader/index.js +3 -0
- package/dist/ripple/index.esm.js +0 -1
- package/dist/ripple/p-007883c7.entry.js +1 -0
- package/dist/ripple/p-01456c1a.system.entry.js +1 -0
- package/dist/ripple/p-0b716fc3.system.entry.js +1 -0
- package/dist/ripple/p-11c9e7ee.system.entry.js +1 -0
- package/dist/ripple/p-176778bc.system.entry.js +1 -0
- package/dist/ripple/p-1f7e1851.entry.js +1 -0
- package/dist/ripple/p-28e8965b.system.entry.js +1 -0
- package/dist/ripple/p-29302f19.entry.js +1 -0
- package/dist/ripple/p-2bd007af.system.entry.js +1 -0
- package/dist/ripple/p-2f629074.system.entry.js +1 -0
- package/dist/ripple/{priv-navigator-item.entry.js → p-3042aae4.entry.js} +1 -30
- package/dist/ripple/p-340b73a9.system.entry.js +1 -0
- package/dist/ripple/p-369b764a.entry.js +1 -0
- package/dist/ripple/p-384d9208.system.entry.js +1 -0
- package/dist/ripple/p-3b08f15d.system.entry.js +1 -0
- package/dist/ripple/p-3d459e5a.entry.js +1 -0
- package/dist/ripple/p-3e1202c6.entry.js +1 -0
- package/dist/ripple/p-3e9a2ef6.system.entry.js +1 -0
- package/dist/ripple/p-418e3d1a.system.entry.js +1 -0
- package/dist/ripple/p-44d2ecd5.entry.js +1 -0
- package/dist/ripple/p-4841e9cd.entry.js +1 -0
- package/dist/ripple/p-492a8a9f.entry.js +1 -0
- package/dist/ripple/p-4a28da80.system.entry.js +1 -0
- package/dist/ripple/{priv-option-list.entry.js → p-4b264fb2.entry.js} +1 -385
- package/dist/ripple/p-4b4671e7.entry.js +1 -0
- package/dist/ripple/p-4b5bb9c8.entry.js +1 -0
- package/dist/ripple/{wm-modal-pss-header.entry.js → p-4f4868cb.system.entry.js} +1 -39
- package/dist/ripple/p-54aeadde.entry.js +1 -0
- package/dist/ripple/p-56422175.entry.js +1 -0
- package/dist/ripple/p-568bb1f9.entry.js +1 -0
- package/dist/ripple/p-5802a317.system.entry.js +1 -0
- package/dist/ripple/p-5ae17300.system.entry.js +1 -0
- package/dist/ripple/p-5e3fbe45.entry.js +1 -0
- package/dist/ripple/p-60363868.entry.js +1 -0
- package/dist/ripple/p-792f7c79.entry.js +1 -0
- package/dist/ripple/p-7aa1c452.system.entry.js +1 -0
- package/dist/ripple/p-7fbbb63a.system.entry.js +1 -0
- package/dist/ripple/p-812615ae.entry.js +1 -0
- package/dist/ripple/{wm-snackbar.entry.js → p-86b22f7b.entry.js} +1 -185
- package/dist/ripple/p-8cbefd04.entry.js +1 -0
- package/dist/ripple/{wm-progress-indicator.entry.js → p-8ee4401f.entry.js} +1 -107
- package/dist/ripple/{priv-chart-popover.entry.js → p-94e4dc77.system.entry.js} +1 -134
- package/dist/ripple/p-9a8e3525.entry.js +1 -0
- package/dist/ripple/p-9c14176e.system.entry.js +1 -0
- package/dist/ripple/p-9c993a3e.system.entry.js +1 -0
- package/dist/ripple/p-BIzU753x.system.js +1 -0
- package/dist/ripple/p-BNmjUWhs.js +1 -0
- package/dist/ripple/p-CDk__KSi.system.js +1 -0
- package/dist/ripple/p-CFV9VgE2.system.js +1 -0
- package/dist/ripple/p-CGHKc6U6.js +1 -0
- package/dist/ripple/p-CTau6pR2.system.js +2 -0
- package/dist/ripple/p-CU95tthb.js +1 -0
- package/dist/ripple/p-CcozwjO1.js +1 -0
- package/dist/ripple/p-CwkTkxrj.system.js +1 -0
- package/dist/ripple/p-CyJHzEjr.js +1 -0
- package/dist/ripple/p-EopL5zo4.js +2 -0
- package/dist/ripple/p-GtT-372c.system.js +1 -0
- package/dist/ripple/p-YWpyar7R.system.js +1 -0
- package/dist/ripple/p-a4d4a752.entry.js +1 -0
- package/dist/ripple/p-a7b4f720.system.entry.js +1 -0
- package/dist/ripple/p-adffc8d9.system.entry.js +1 -0
- package/dist/ripple/p-b53e397f.entry.js +1 -0
- package/dist/ripple/p-b6956929.system.entry.js +1 -0
- package/dist/ripple/p-b79f5594.system.entry.js +1 -0
- package/dist/ripple/p-b94e08f4.system.entry.js +1 -0
- package/dist/ripple/p-bb930411.entry.js +1 -0
- package/dist/ripple/p-bd0f8d31.system.entry.js +1 -0
- package/dist/ripple/p-be146306.system.entry.js +1 -0
- package/dist/ripple/p-c59fa446.system.entry.js +1 -0
- package/dist/ripple/p-c7269416.entry.js +1 -0
- package/dist/ripple/p-c7f446e9.system.entry.js +1 -0
- package/dist/ripple/p-ca8c26b0.entry.js +1 -0
- package/dist/ripple/p-cccfdbb8.entry.js +1 -0
- package/dist/ripple/p-cfb2bbf1.system.entry.js +1 -0
- package/dist/ripple/p-d298ef0a.system.entry.js +1 -0
- package/dist/ripple/p-d66f8dfc.system.entry.js +1 -0
- package/dist/ripple/p-d715f567.system.entry.js +1 -0
- package/dist/ripple/p-d8cd69fb.entry.js +1 -0
- package/dist/ripple/p-d9033c6b.entry.js +1 -0
- package/dist/ripple/p-da5ad94c.system.entry.js +1 -0
- package/dist/ripple/p-da6646bf.entry.js +1 -0
- package/dist/ripple/p-dc44a726.entry.js +1 -0
- package/dist/ripple/p-e04561b5.system.entry.js +1 -0
- package/dist/ripple/p-e8cdf66c.entry.js +1 -0
- package/dist/ripple/p-ec1c0b3e.system.entry.js +1 -0
- package/dist/ripple/p-ef9c66dd.entry.js +1 -0
- package/dist/ripple/p-f44dafc1.entry.js +1 -0
- package/dist/ripple/p-f4c59921.system.entry.js +1 -0
- package/dist/ripple/p-f6e9cb0e.entry.js +1 -0
- package/dist/ripple/p-faa45b92.system.entry.js +1 -0
- package/dist/ripple/p-faf34fd1.system.entry.js +1 -0
- package/dist/ripple/{wm-tab-list.entry.js → p-fd006ae2.entry.js} +1 -175
- package/dist/ripple/p-fd9c8220.system.entry.js +1 -0
- package/dist/ripple/p-fe1ac4e0.entry.js +1 -0
- package/dist/ripple/p-fe5c9681.entry.js +1 -0
- package/dist/ripple/p-feb343ad.system.entry.js +1 -0
- package/dist/ripple/p-ff3cbb1d.entry.js +1 -0
- package/dist/ripple/p-rbkCjczS.system.js +1 -0
- package/dist/ripple/ripple.esm.js +1 -48
- package/dist/ripple/ripple.js +127 -0
- package/package.json +2 -2
- package/dist/ripple/index-CU5QNCKv.js +0 -4167
- package/dist/ripple/priv-calendar.entry.js +0 -566
- package/dist/ripple/priv-navigator-button.entry.js +0 -24
- package/dist/ripple/wm-action-menu.entry.js +0 -201
- package/dist/ripple/wm-button.entry.js +0 -197
- package/dist/ripple/wm-date-range.entry.js +0 -477
- package/dist/ripple/wm-datepicker.entry.js +0 -247
- package/dist/ripple/wm-line-chart.entry.js +0 -449
- package/dist/ripple/wm-modal-pss-footer.entry.js +0 -40
- package/dist/ripple/wm-modal-pss.entry.js +0 -135
- package/dist/ripple/wm-navigation-hamburger.entry.js +0 -48
- package/dist/ripple/wm-navigation-item.entry.js +0 -18
- package/dist/ripple/wm-navigator.entry.js +0 -368
- package/dist/ripple/wm-nested-select.entry.js +0 -308
- package/dist/ripple/wm-pagination.entry.js +0 -223
- package/dist/ripple/wm-tag-input.entry.js +0 -877
- package/dist/ripple/wm-timepicker.entry.js +0 -300
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
import * as lang from "../lang/lang";
|
|
2
|
+
import { createIntl, createIntlCache } from "@formatjs/intl";
|
|
3
|
+
const DEFAULT_LANGUAGE = "en";
|
|
4
|
+
function getBrowserLang() {
|
|
5
|
+
const langAttr = document.documentElement.getAttribute("lang");
|
|
6
|
+
if (!!langAttr) {
|
|
7
|
+
return langAttr;
|
|
8
|
+
}
|
|
9
|
+
else if (window.navigator && window.navigator.language) {
|
|
10
|
+
const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
|
|
11
|
+
return lang.slice(0, 2);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return DEFAULT_LANGUAGE;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// prevents memory leak
|
|
18
|
+
const cache = createIntlCache();
|
|
19
|
+
const locale = getBrowserLang();
|
|
20
|
+
export const intl = createIntl({
|
|
21
|
+
locale: locale,
|
|
22
|
+
defaultLocale: "en",
|
|
23
|
+
messages: lang[locale] || lang.en,
|
|
24
|
+
}, cache);
|
|
25
|
+
export function generateId() {
|
|
26
|
+
return "wmcl-" + Math.random().toString(36).substr(2, 10);
|
|
27
|
+
}
|
|
28
|
+
// limits how many times a function fires
|
|
29
|
+
// use when the function should run periodically, but not too often (e.g. window resize)
|
|
30
|
+
export function throttle(fn, wait) {
|
|
31
|
+
let timeout;
|
|
32
|
+
let shouldWait = false;
|
|
33
|
+
return function () {
|
|
34
|
+
const context = this;
|
|
35
|
+
if (!shouldWait) {
|
|
36
|
+
fn.apply(context, arguments);
|
|
37
|
+
shouldWait = true;
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
timeout = setTimeout(function () {
|
|
40
|
+
shouldWait = false;
|
|
41
|
+
}, wait);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// waits until it hasn't been called for [timeout] ms.
|
|
46
|
+
// use when the function should run only after something (event) is done firing
|
|
47
|
+
export function debounce(fn, wait) {
|
|
48
|
+
let timeout;
|
|
49
|
+
return function () {
|
|
50
|
+
const context = this;
|
|
51
|
+
const functionCall = () => fn.apply(context, arguments);
|
|
52
|
+
clearTimeout(timeout);
|
|
53
|
+
timeout = setTimeout(functionCall, wait);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function getTextDir() {
|
|
57
|
+
const dir = document.querySelector("html").getAttribute("dir");
|
|
58
|
+
return dir ? dir.toLowerCase() : "";
|
|
59
|
+
}
|
|
60
|
+
export function getPosition(el) {
|
|
61
|
+
const coords = el.getBoundingClientRect();
|
|
62
|
+
let x = coords.x;
|
|
63
|
+
let y = coords.y;
|
|
64
|
+
// Edge doesn't have x and y
|
|
65
|
+
if (!x) {
|
|
66
|
+
if (getTextDir() === "rtl") {
|
|
67
|
+
x = coords.right;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
x = coords.left;
|
|
71
|
+
}
|
|
72
|
+
y = coords.top;
|
|
73
|
+
}
|
|
74
|
+
return { x, y };
|
|
75
|
+
}
|
|
76
|
+
export function findScrollableParent(el) {
|
|
77
|
+
while (!!el) {
|
|
78
|
+
if (["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
|
|
79
|
+
return el;
|
|
80
|
+
}
|
|
81
|
+
el = el.parentElement;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function findParentWithHiddenOverflow(el) {
|
|
85
|
+
while (!!el) {
|
|
86
|
+
if (window.getComputedStyle(el).overflowY !== "visible") {
|
|
87
|
+
return el;
|
|
88
|
+
}
|
|
89
|
+
el = el.parentElement;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function isElOrChild(componentEl, el) {
|
|
93
|
+
var _a;
|
|
94
|
+
// determines whether or not the element is the component, a child of the component, or exists within the component's shadowroot
|
|
95
|
+
return el === componentEl || componentEl.contains(el) || ((_a = componentEl.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(el));
|
|
96
|
+
}
|
|
97
|
+
export function getContextMeasurements(el) {
|
|
98
|
+
const fixedRect = el.getBoundingClientRect();
|
|
99
|
+
const parentEl = findParentWithHiddenOverflow(el);
|
|
100
|
+
const parentRect = parentEl && parentEl.getBoundingClientRect();
|
|
101
|
+
// if parentEl is not found, measurements are checked against the viewport
|
|
102
|
+
return {
|
|
103
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
104
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
105
|
+
spaceAbove: parentRect ? fixedRect.top - parentRect.top : fixedRect.top,
|
|
106
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
107
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
108
|
+
spaceBelow: parentRect
|
|
109
|
+
? parentRect.bottom - fixedRect.bottom
|
|
110
|
+
: document.documentElement.clientHeight - fixedRect.bottom,
|
|
111
|
+
spaceLeft: parentRect ? fixedRect.left - parentRect.left : fixedRect.left,
|
|
112
|
+
spaceRight: parentRect
|
|
113
|
+
? parentRect.right - fixedRect.right
|
|
114
|
+
: document.documentElement.clientWidth - fixedRect.right,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
|
|
118
|
+
closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
|
|
119
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
120
|
+
offsetBelow = 0) {
|
|
121
|
+
const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
|
|
122
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
123
|
+
const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
|
|
124
|
+
return openUp;
|
|
125
|
+
}
|
|
126
|
+
export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
|
|
127
|
+
closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
|
|
128
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
129
|
+
offsetBelow = 0) {
|
|
130
|
+
const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
|
|
131
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
132
|
+
const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
|
|
133
|
+
return openDown;
|
|
134
|
+
}
|
|
135
|
+
export function shouldShiftRight(fixedEl, closableElWidth) {
|
|
136
|
+
const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
|
|
137
|
+
const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
|
|
138
|
+
return needsSpaceLeft;
|
|
139
|
+
}
|
|
140
|
+
export function shouldShiftLeft(fixedEl, closableElWidth) {
|
|
141
|
+
const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
|
|
142
|
+
const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
|
|
143
|
+
return needsSpaceRight;
|
|
144
|
+
}
|
|
145
|
+
export function adjustTooltipPlacement(placement, anchorEl, tooltipHeight, tooltipWidth) {
|
|
146
|
+
const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getContextMeasurements(anchorEl);
|
|
147
|
+
const enoughSpaceAbove = spaceAbove > tooltipHeight;
|
|
148
|
+
const enoughSpaceBelow = spaceBelow > tooltipHeight;
|
|
149
|
+
// a tooltip should never be closer than 24px to the edge of a screen
|
|
150
|
+
const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
|
|
151
|
+
const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
|
|
152
|
+
const swapAbove = (placement) => {
|
|
153
|
+
return !enoughSpaceAbove ? placement.replace("top", "bottom") : placement;
|
|
154
|
+
};
|
|
155
|
+
const swapBelow = (placement) => {
|
|
156
|
+
return !enoughSpaceBelow && enoughSpaceAbove ? placement.replace("bottom", "top") : placement;
|
|
157
|
+
};
|
|
158
|
+
const swapLeft = (placement, centeredPosition) => {
|
|
159
|
+
if (!enoughSpaceLeft && enoughSpaceRight) {
|
|
160
|
+
placement = placement.replace("left", "right");
|
|
161
|
+
}
|
|
162
|
+
else if (!enoughSpaceLeft && !enoughSpaceRight) {
|
|
163
|
+
placement = centeredPosition;
|
|
164
|
+
}
|
|
165
|
+
return placement;
|
|
166
|
+
};
|
|
167
|
+
const swapRight = (placement, centeredPosition) => {
|
|
168
|
+
if (!enoughSpaceRight && enoughSpaceLeft) {
|
|
169
|
+
placement = placement.replace("right", "left");
|
|
170
|
+
}
|
|
171
|
+
else if (!enoughSpaceRight && !enoughSpaceLeft) {
|
|
172
|
+
placement = centeredPosition;
|
|
173
|
+
}
|
|
174
|
+
return placement;
|
|
175
|
+
};
|
|
176
|
+
// horizontal checks must occur before vertical checks, because horizontal can affect vertical placement but not vice versa
|
|
177
|
+
switch (placement) {
|
|
178
|
+
case "left":
|
|
179
|
+
placement = swapLeft(placement, "bottom");
|
|
180
|
+
case "right":
|
|
181
|
+
placement = swapRight(placement, "bottom");
|
|
182
|
+
case "top-left":
|
|
183
|
+
placement = swapLeft(placement, "top");
|
|
184
|
+
placement = swapAbove(placement);
|
|
185
|
+
case "top-right":
|
|
186
|
+
placement = swapRight(placement, "top");
|
|
187
|
+
placement = swapAbove(placement);
|
|
188
|
+
case "bottom-left":
|
|
189
|
+
placement = swapLeft(placement, "bottom");
|
|
190
|
+
placement = swapBelow(placement);
|
|
191
|
+
case "bottom-right":
|
|
192
|
+
placement = swapRight(placement, "bottom");
|
|
193
|
+
placement = swapBelow(placement);
|
|
194
|
+
case "top":
|
|
195
|
+
placement = swapAbove(placement);
|
|
196
|
+
case "bottom":
|
|
197
|
+
placement = swapBelow(placement);
|
|
198
|
+
}
|
|
199
|
+
return placement;
|
|
200
|
+
}
|
|
201
|
+
export function showTooltip(placement, anchorEl, tooltipText) {
|
|
202
|
+
// until popover is supported by firefox, we have to check for and position additional tooltip rendered within the modal's dialog element
|
|
203
|
+
// this additional tooltip is only rendered in browsers that do not support popover
|
|
204
|
+
const tooltipEls = document.querySelectorAll(".wm-tooltip");
|
|
205
|
+
tooltipEls.forEach((tooltipEl) => {
|
|
206
|
+
//@ts-ignore
|
|
207
|
+
if (!!tooltipEl.showPopover) {
|
|
208
|
+
//@ts-ignore
|
|
209
|
+
tooltipEl.showPopover();
|
|
210
|
+
}
|
|
211
|
+
tooltipEl.classList.add("show");
|
|
212
|
+
tooltipEl.textContent = tooltipText;
|
|
213
|
+
// tooltip only has a maxWidth if it contains whitespace and can break
|
|
214
|
+
const hasNoWhitespace = tooltipText.match(/^[^\s]+$/);
|
|
215
|
+
if (hasNoWhitespace) {
|
|
216
|
+
tooltipEl.classList.add("single-word");
|
|
217
|
+
tooltipEl.style.setProperty("--wmTooltipMaxWidth", "none");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
tooltipEl.classList.remove("single-word");
|
|
221
|
+
tooltipEl.style.removeProperty("--wmTooltipMaxWidth");
|
|
222
|
+
}
|
|
223
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
224
|
+
const anchorRect = anchorEl.getBoundingClientRect();
|
|
225
|
+
const adjustedPlacement = adjustTooltipPlacement(placement, anchorEl, tooltipRect.height, tooltipRect.width);
|
|
226
|
+
let verticalPos, horizontalPos;
|
|
227
|
+
[verticalPos, horizontalPos] = positionTooltip(adjustedPlacement, anchorRect, tooltipRect.height, tooltipRect.width);
|
|
228
|
+
tooltipEl.style.setProperty("--wmTooltipTop", verticalPos + "px");
|
|
229
|
+
tooltipEl.style.setProperty("--wmTooltipLeft", horizontalPos + "px");
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
export function hideTooltip() {
|
|
233
|
+
const tooltipEls = document.querySelectorAll(".wm-tooltip");
|
|
234
|
+
tooltipEls.forEach((tooltipEl) => {
|
|
235
|
+
//@ts-ignore
|
|
236
|
+
if (!!tooltipEl.hidePopover) {
|
|
237
|
+
//@ts-ignore
|
|
238
|
+
tooltipEl.hidePopover();
|
|
239
|
+
}
|
|
240
|
+
tooltipEl.classList.remove("show");
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function positionTooltip(placement, anchorRect, tooltipHeight, tooltipWidth) {
|
|
244
|
+
// to get the center positions, calculate the difference between the button width and the tooltip width
|
|
245
|
+
const verticalDiff = (anchorRect.height - tooltipHeight) / 2;
|
|
246
|
+
const horizontalDiff = (anchorRect.width - tooltipWidth) / 2;
|
|
247
|
+
// the naming convention defaults to center in the absence of a value
|
|
248
|
+
// "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
|
|
249
|
+
// therefore we first set to center and adjust accordingly
|
|
250
|
+
let verticalPos = anchorRect.top + verticalDiff;
|
|
251
|
+
let horizontalPos = anchorRect.left + horizontalDiff;
|
|
252
|
+
if (placement.includes("top")) {
|
|
253
|
+
verticalPos = anchorRect.top - tooltipHeight - 8;
|
|
254
|
+
}
|
|
255
|
+
if (placement.includes("bottom")) {
|
|
256
|
+
verticalPos = anchorRect.bottom + 8;
|
|
257
|
+
}
|
|
258
|
+
if (placement.includes("left")) {
|
|
259
|
+
horizontalPos = anchorRect.left - tooltipWidth - 8;
|
|
260
|
+
}
|
|
261
|
+
if (placement.includes("right")) {
|
|
262
|
+
horizontalPos = anchorRect.right + 8;
|
|
263
|
+
}
|
|
264
|
+
// after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
|
|
265
|
+
// this only occurs when the tooltip is overflowing to the left and is placed top or bottom
|
|
266
|
+
// (button placed too far left, or screen size under 268px)
|
|
267
|
+
horizontalPos = Math.max(horizontalPos, 24);
|
|
268
|
+
return [verticalPos, horizontalPos];
|
|
269
|
+
}
|
|
270
|
+
export function hasRoomRight(x, spaceNeeded) {
|
|
271
|
+
let horizOffset = 0;
|
|
272
|
+
// if (getTextDir() === "ltr") {
|
|
273
|
+
if (x.type === "click") {
|
|
274
|
+
// if it's a mouse event, deal with mouse coords
|
|
275
|
+
horizOffset = x.clientX;
|
|
276
|
+
// if it's a focus event, the offset is 0
|
|
277
|
+
}
|
|
278
|
+
else if (x.type === "focus") {
|
|
279
|
+
horizOffset = 0;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// otherwise an element was passed, calculate how far it is from the edge of the window
|
|
283
|
+
let el = x; // re-assignment is for clarity
|
|
284
|
+
while (el) {
|
|
285
|
+
if (el.tagName == "BODY") {
|
|
286
|
+
// deal with browser quirks with body/window/document and page scroll
|
|
287
|
+
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
|
|
288
|
+
horizOffset += el.offsetLeft - xScroll + el.clientLeft;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
// for all other non-BODY elements
|
|
292
|
+
horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
|
|
293
|
+
}
|
|
294
|
+
el = el.offsetParent;
|
|
295
|
+
}
|
|
296
|
+
// }
|
|
297
|
+
}
|
|
298
|
+
return window.innerWidth - horizOffset >= spaceNeeded;
|
|
299
|
+
}
|
|
300
|
+
export function checkForActiveElInShadow(element) {
|
|
301
|
+
while (element && element.shadowRoot) {
|
|
302
|
+
element = element.shadowRoot.activeElement;
|
|
303
|
+
}
|
|
304
|
+
return element;
|
|
305
|
+
}
|
|
306
|
+
export function checkForFocusableElInShadow(element) {
|
|
307
|
+
const selectors = [
|
|
308
|
+
"button",
|
|
309
|
+
"a",
|
|
310
|
+
"input",
|
|
311
|
+
"select",
|
|
312
|
+
"textarea",
|
|
313
|
+
"wm-button",
|
|
314
|
+
"wm-search",
|
|
315
|
+
"wm-select",
|
|
316
|
+
"wm-action-menu",
|
|
317
|
+
"wm-tab-item",
|
|
318
|
+
"wm-datepicker",
|
|
319
|
+
];
|
|
320
|
+
let focusableEl = element;
|
|
321
|
+
selectors.forEach((selector) => {
|
|
322
|
+
if (focusableEl && focusableEl.shadowRoot) {
|
|
323
|
+
let elInShadow = focusableEl.shadowRoot.querySelector(selector);
|
|
324
|
+
if (elInShadow) {
|
|
325
|
+
if (selector.startsWith("wm-")) {
|
|
326
|
+
focusableEl = checkForFocusableElInShadow(elInShadow);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
focusableEl = elInShadow;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return focusableEl;
|
|
335
|
+
}
|
|
336
|
+
export function isFocusable(element) {
|
|
337
|
+
if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
if (element.disabled) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
switch (element.nodeName) {
|
|
344
|
+
case "A":
|
|
345
|
+
return !!element.href && element.rel != "ignore";
|
|
346
|
+
case "INPUT":
|
|
347
|
+
return element.type != "hidden" && element.type != "file";
|
|
348
|
+
case "BUTTON":
|
|
349
|
+
case "SELECT":
|
|
350
|
+
case "TEXTAREA":
|
|
351
|
+
case "WM-BUTTON":
|
|
352
|
+
case "WM-SELECT":
|
|
353
|
+
case "WM-ACTION-MENU":
|
|
354
|
+
case "WM-DATEPICKER":
|
|
355
|
+
case "WM-TIMEPICKER":
|
|
356
|
+
case "WM-INPUT":
|
|
357
|
+
case "WM-TAG-INPUT":
|
|
358
|
+
case "WM-TAB-ITEM":
|
|
359
|
+
case "WM-SEARCH":
|
|
360
|
+
return true;
|
|
361
|
+
default:
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
export function getFirstFocusableDescendant(element) {
|
|
366
|
+
if (isFocusable(element)) {
|
|
367
|
+
return checkForFocusableElInShadow(element);
|
|
368
|
+
}
|
|
369
|
+
else if (element.childNodes.length > 0) {
|
|
370
|
+
element.childNodes.forEach((i) => {
|
|
371
|
+
const childEl = getFirstFocusableDescendant(i);
|
|
372
|
+
return childEl && checkForFocusableElInShadow(childEl);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
export function getLastFocusableDescendant(element) {
|
|
377
|
+
if (isFocusable(element)) {
|
|
378
|
+
return checkForFocusableElInShadow(element);
|
|
379
|
+
}
|
|
380
|
+
else if (element.childNodes.length > 0) {
|
|
381
|
+
// Convert to array and reverse to process children from last to first
|
|
382
|
+
const children = Array.from(element.childNodes).reverse();
|
|
383
|
+
return children.reduce((focusable, child) => {
|
|
384
|
+
if (focusable)
|
|
385
|
+
return focusable;
|
|
386
|
+
const childEl = getLastFocusableDescendant(child);
|
|
387
|
+
return childEl ? checkForFocusableElInShadow(childEl) : null;
|
|
388
|
+
}, null);
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
// takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
|
|
393
|
+
export function getAcceptedMimeTypesList(acceptedExtensions) {
|
|
394
|
+
// this is just a list of common file types (regardless of whether they are/can be valid or not)
|
|
395
|
+
// front end checks are just a convenience to users, independent of security.
|
|
396
|
+
// it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
|
|
397
|
+
const lookupTable = {
|
|
398
|
+
aac: ["audio/aac"],
|
|
399
|
+
abw: ["application/x-abiword"],
|
|
400
|
+
arc: ["application/x-freearc"],
|
|
401
|
+
avi: ["video/x-msvideo"],
|
|
402
|
+
azw: ["application/vnd.amazon.ebook"],
|
|
403
|
+
bin: ["application/octet-stream"],
|
|
404
|
+
bmp: ["image/bmp"],
|
|
405
|
+
bz: ["application/x-bzip"],
|
|
406
|
+
bz2: ["application/x-bzip2"],
|
|
407
|
+
csh: ["application/x-csh"],
|
|
408
|
+
css: ["text/css"],
|
|
409
|
+
csv: ["text/csv"],
|
|
410
|
+
doc: ["application/msword"],
|
|
411
|
+
docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
412
|
+
eot: ["application/vnd.ms-fontobject"],
|
|
413
|
+
epub: ["application/epub+zip"],
|
|
414
|
+
gz: ["application/gzip"],
|
|
415
|
+
gif: ["image/gif"],
|
|
416
|
+
htm: ["text/html"],
|
|
417
|
+
html: ["text/html"],
|
|
418
|
+
ico: ["image/vnd.microsoft.icon"],
|
|
419
|
+
ics: ["text/calendar"],
|
|
420
|
+
jar: ["application/java-archive"],
|
|
421
|
+
jpeg: ["image/jpeg"],
|
|
422
|
+
jpg: ["image/jpeg"],
|
|
423
|
+
js: ["text/javascript"],
|
|
424
|
+
json: ["application/json"],
|
|
425
|
+
jsonld: ["application/ld+json"],
|
|
426
|
+
log: ["text/plain"],
|
|
427
|
+
mid: ["audio/x-midi"],
|
|
428
|
+
midi: ["audio/x-midi"],
|
|
429
|
+
mjs: ["text/javascript"],
|
|
430
|
+
mp3: ["audio/mpeg"],
|
|
431
|
+
mpeg: ["video/mpeg"],
|
|
432
|
+
mpkg: ["application/vnd.apple.installer+xml"],
|
|
433
|
+
odp: ["application/vnd.oasis.opendocument.presentation"],
|
|
434
|
+
ods: ["application/vnd.oasis.opendocument.spreadsheet"],
|
|
435
|
+
odt: ["application/vnd.oasis.opendocument.text"],
|
|
436
|
+
oga: ["audio/ogg"],
|
|
437
|
+
ogv: ["video/ogg"],
|
|
438
|
+
ogx: ["application/ogg"],
|
|
439
|
+
opus: ["audio/opus"],
|
|
440
|
+
otf: ["font/otf"],
|
|
441
|
+
png: ["image/png"],
|
|
442
|
+
pdf: ["application/pdf"],
|
|
443
|
+
php: ["application/php"],
|
|
444
|
+
ppt: ["application/vnd.ms-powerpoint"],
|
|
445
|
+
pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
446
|
+
rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
|
|
447
|
+
rtf: ["application/rtf"],
|
|
448
|
+
sh: ["application/x-sh"],
|
|
449
|
+
svg: ["image/svg+xml"],
|
|
450
|
+
swf: ["application/x-shockwave-flash"],
|
|
451
|
+
tar: ["application/x-tar"],
|
|
452
|
+
tif: ["image/tiff"],
|
|
453
|
+
tiff: ["image/tiff"],
|
|
454
|
+
ts: ["video/mp2t"],
|
|
455
|
+
ttf: ["font/ttf"],
|
|
456
|
+
txt: ["text/plain"],
|
|
457
|
+
vsd: ["application/vnd.visio"],
|
|
458
|
+
wav: ["audio/wav"],
|
|
459
|
+
weba: ["audio/webm"],
|
|
460
|
+
webm: ["video/webm"],
|
|
461
|
+
webp: ["image/webp"],
|
|
462
|
+
woff: ["font/woff"],
|
|
463
|
+
woff2: ["font/woff2"],
|
|
464
|
+
xhtml: ["application/xhtml+xml"],
|
|
465
|
+
xls: ["application/vnd.ms-excel"],
|
|
466
|
+
xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
467
|
+
xml: ["application/xml", "text/xml"],
|
|
468
|
+
xul: ["application/vnd.mozilla.xul+xml"],
|
|
469
|
+
zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
|
|
470
|
+
"3gp": ["video/3gpp", "audio/3gpp"],
|
|
471
|
+
"3g2": ["video/3gpp2", "audio/3gpp2"],
|
|
472
|
+
"7z": ["application/x-7z-compressed"],
|
|
473
|
+
};
|
|
474
|
+
return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
|
|
475
|
+
}
|
|
476
|
+
export function snakeCaseToCamelCase(str) {
|
|
477
|
+
const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
|
|
478
|
+
if (snakeCaseRegexp.test(str)) {
|
|
479
|
+
let camelCase = "";
|
|
480
|
+
let arr = str.split("_");
|
|
481
|
+
arr.forEach((word, idx) => {
|
|
482
|
+
camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
|
|
483
|
+
});
|
|
484
|
+
return camelCase;
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
return str;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
export function csvToArray(csv) {
|
|
491
|
+
return csv ? csv.split(/, ?/) : [];
|
|
492
|
+
}
|
|
493
|
+
export function getNewIndexToFocus(currentIndex, direction, listLength) {
|
|
494
|
+
let newIndex = currentIndex;
|
|
495
|
+
if (direction === "ArrowDown") {
|
|
496
|
+
newIndex = (currentIndex + 1) % listLength;
|
|
497
|
+
}
|
|
498
|
+
if (direction === "ArrowUp") {
|
|
499
|
+
newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
|
|
500
|
+
}
|
|
501
|
+
return newIndex;
|
|
502
|
+
}
|
|
503
|
+
export function isRelatedTarget(ev, id) {
|
|
504
|
+
// used for onBlur events to check the element that has been clicked
|
|
505
|
+
const ids = id.split(" ");
|
|
506
|
+
return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
|
|
507
|
+
}
|
|
508
|
+
export function toBool(val) {
|
|
509
|
+
// string "false" needs to be treated as bool False because react wrappers convert bool to string.
|
|
510
|
+
return val == "false" ? false : !!val;
|
|
511
|
+
}
|
|
512
|
+
export function measureText(originEl, placeholderText) {
|
|
513
|
+
const measurementEl = document.createElement("div");
|
|
514
|
+
const originStyles = getComputedStyle(originEl);
|
|
515
|
+
measurementEl.style.position = "absolute";
|
|
516
|
+
measurementEl.style.top = "-100vh";
|
|
517
|
+
measurementEl.style.fontFamily = originStyles.fontFamily;
|
|
518
|
+
measurementEl.style.fontWeight = originStyles.fontWeight;
|
|
519
|
+
measurementEl.style.fontSize = originStyles.fontSize;
|
|
520
|
+
measurementEl.textContent = placeholderText;
|
|
521
|
+
document.body.appendChild(measurementEl);
|
|
522
|
+
const boundingClientRect = measurementEl.getBoundingClientRect();
|
|
523
|
+
document.body.removeChild(measurementEl);
|
|
524
|
+
return boundingClientRect;
|
|
525
|
+
}
|
|
526
|
+
export function truncateText(textEl, text, availableSpace, endAmt) {
|
|
527
|
+
const cloneEl = document.createElement("div");
|
|
528
|
+
cloneEl.style.visibility = "hidden";
|
|
529
|
+
cloneEl.style.position = "absolute";
|
|
530
|
+
cloneEl.style.top = "-200vh";
|
|
531
|
+
cloneEl.style.left = "-200vh";
|
|
532
|
+
cloneEl.textContent = text;
|
|
533
|
+
textEl.appendChild(cloneEl);
|
|
534
|
+
const ellipses = "...";
|
|
535
|
+
const minimumLength = 2 + ellipses.length + endAmt;
|
|
536
|
+
let canFitText = availableSpace > cloneEl.clientWidth;
|
|
537
|
+
if (!canFitText && text.length > minimumLength) {
|
|
538
|
+
let frontChars = text.slice(0, text.length - endAmt - ellipses.length).trim();
|
|
539
|
+
let endChars = text.slice(-endAmt).trim();
|
|
540
|
+
let truncatedText = frontChars + ellipses + endChars;
|
|
541
|
+
cloneEl.textContent = truncatedText;
|
|
542
|
+
canFitText = availableSpace > cloneEl.clientWidth;
|
|
543
|
+
while (!canFitText && truncatedText.length > minimumLength) {
|
|
544
|
+
frontChars = frontChars.slice(0, -1).trim();
|
|
545
|
+
truncatedText = frontChars + ellipses + endChars;
|
|
546
|
+
cloneEl.textContent = truncatedText;
|
|
547
|
+
canFitText = availableSpace > cloneEl.clientWidth;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const truncatedText = cloneEl.textContent;
|
|
551
|
+
cloneEl.remove();
|
|
552
|
+
return truncatedText;
|
|
553
|
+
}
|
|
554
|
+
export function transposeMatrix(originalMatrix) {
|
|
555
|
+
let newMatrix = [];
|
|
556
|
+
for (let i = 0; i < originalMatrix[0].length; i++) {
|
|
557
|
+
let column = [];
|
|
558
|
+
for (let j = 0; j < originalMatrix.length; j++) {
|
|
559
|
+
column.push(originalMatrix[j][i]);
|
|
560
|
+
}
|
|
561
|
+
newMatrix.push(column);
|
|
562
|
+
}
|
|
563
|
+
return newMatrix;
|
|
564
|
+
}
|
|
565
|
+
// wrap around includes 0, so it won't work for something like dates (wrapping around months)
|
|
566
|
+
export function wrapAround(currentIdx, step, endIdx) {
|
|
567
|
+
currentIdx += step;
|
|
568
|
+
if (currentIdx > endIdx) {
|
|
569
|
+
currentIdx = (currentIdx - 1) % endIdx;
|
|
570
|
+
}
|
|
571
|
+
while (currentIdx < 0) {
|
|
572
|
+
currentIdx = endIdx - Math.abs(currentIdx) + 1;
|
|
573
|
+
}
|
|
574
|
+
return currentIdx;
|
|
575
|
+
}
|
|
576
|
+
export function skipByInterval(list, skipInterval) {
|
|
577
|
+
let skippedList = [];
|
|
578
|
+
for (let i = 0; i < list.length; i += 1 + skipInterval) {
|
|
579
|
+
skippedList.push(list[i]);
|
|
580
|
+
}
|
|
581
|
+
return skippedList;
|
|
582
|
+
}
|
|
583
|
+
export function getSmallestSkipInterval(list, maxLength) {
|
|
584
|
+
let skipInterval = 0;
|
|
585
|
+
let skippedList = list;
|
|
586
|
+
while (skipByInterval(list, skipInterval).length > maxLength) {
|
|
587
|
+
skipInterval++;
|
|
588
|
+
skippedList = skipByInterval(list, skipInterval);
|
|
589
|
+
}
|
|
590
|
+
return { skipInterval: skipInterval, skippedList: skippedList };
|
|
591
|
+
}
|
|
592
|
+
export function calcPercentageInRange(value, rangeLowest, rangeHighest) {
|
|
593
|
+
const rangeDistance = rangeHighest - rangeLowest;
|
|
594
|
+
const adjustedValue = Math.abs(value - rangeLowest);
|
|
595
|
+
const percentage = (adjustedValue / rangeDistance) * 100;
|
|
596
|
+
return percentage;
|
|
597
|
+
}
|
|
598
|
+
export function triggerFormSubmit(formEl) {
|
|
599
|
+
// requestSubmit is not supported by Safari v<16, use a polyfill for this
|
|
600
|
+
if (formEl.requestSubmit) {
|
|
601
|
+
formEl.requestSubmit();
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
const submitButton = document.createElement("button");
|
|
605
|
+
submitButton.style.display = "none";
|
|
606
|
+
formEl.appendChild(submitButton);
|
|
607
|
+
submitButton.click();
|
|
608
|
+
document.removeChild(submitButton);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
export function handleDisabledAttribute(el, isDisabled) {
|
|
612
|
+
if (isDisabled == false && el.hasAttribute("disabled")) {
|
|
613
|
+
el.removeAttribute("disabled");
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
// get the prev/next element with an option to circle through the list
|
|
617
|
+
export function findPrev(list, item, loop = false) {
|
|
618
|
+
if (!!list && !item)
|
|
619
|
+
return list[list.length - 1]; // if list was passed but no item, get the last item
|
|
620
|
+
if (!list.includes(item))
|
|
621
|
+
return; // if list is empty or doesn't include item
|
|
622
|
+
let current = list.indexOf(item);
|
|
623
|
+
let beforeFirst = loop ? list.length - 1 : 0; // before first item can be first (hard stop) or back to last
|
|
624
|
+
let prev = current > 0 ? current - 1 : beforeFirst;
|
|
625
|
+
return list[prev];
|
|
626
|
+
}
|
|
627
|
+
export function findNext(list, item, loop = false) {
|
|
628
|
+
if (!!list && !item)
|
|
629
|
+
return list[0]; // if list was passed but no item, get the first item
|
|
630
|
+
if (!list.includes(item))
|
|
631
|
+
return; // if list is empty or doesn't include item
|
|
632
|
+
let current = list.indexOf(item);
|
|
633
|
+
const last = list.length - 1;
|
|
634
|
+
let afterLast = loop ? 0 : last; // after last item can be last (hard stop) or back to first
|
|
635
|
+
let next = current !== last ? current + 1 : afterLast;
|
|
636
|
+
return list[next];
|
|
637
|
+
}
|
|
638
|
+
export function safeMultiplyFloat(factor1, factor2) {
|
|
639
|
+
// There can be floating point precision errors when multiplying floats.
|
|
640
|
+
// For example 0.2 * 3 will result in 0.6000000000000001 instead of the expected 0.6
|
|
641
|
+
const factor1DecimalCount = countDecimals(factor1);
|
|
642
|
+
const factor2DecimalCount = countDecimals(factor2);
|
|
643
|
+
const expectedDecimals = factor1DecimalCount + factor2DecimalCount;
|
|
644
|
+
return parseFloat((factor1 * factor2).toFixed(expectedDecimals));
|
|
645
|
+
}
|
|
646
|
+
function countDecimals(num) {
|
|
647
|
+
const asString = num.toString();
|
|
648
|
+
const decimalPointIndex = asString.indexOf(".");
|
|
649
|
+
if (decimalPointIndex == -1) {
|
|
650
|
+
return 0;
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
return asString.split(".")[1].length;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
export function getMonthLength(month, year) {
|
|
657
|
+
const months30 = [4, 6, 9, 11];
|
|
658
|
+
const leapYear = year % 4 === 0;
|
|
659
|
+
return month === 2 ? (leapYear ? 29 : 28) : months30.includes(month) ? 30 : 31;
|
|
660
|
+
}
|
|
661
|
+
export function dateToISO(date) {
|
|
662
|
+
return `${date.getUTCFullYear()}-${(date.getUTCMonth() + 1).toString().padStart(2, "0")}-${date
|
|
663
|
+
.getDate()
|
|
664
|
+
.toString()
|
|
665
|
+
.padStart(2, "0")}`;
|
|
666
|
+
}
|
|
667
|
+
function splitISO(isoDate) {
|
|
668
|
+
const [year, month, day] = isoDate.split("-");
|
|
669
|
+
return {
|
|
670
|
+
year: { asInt: parseInt(year), asString: year },
|
|
671
|
+
month: { asInt: parseInt(month), asString: month },
|
|
672
|
+
day: { asInt: parseInt(day), asString: day },
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
export function makeISO(y, m, d) {
|
|
676
|
+
return `${y}-${m.toString().padStart(2, "0")}-${d.toString().padStart(2, "0")}`;
|
|
677
|
+
}
|
|
678
|
+
export const dateFind = {
|
|
679
|
+
year: {
|
|
680
|
+
asString: (date) => splitISO(date).year.asString,
|
|
681
|
+
asInt: (date) => splitISO(date).year.asInt,
|
|
682
|
+
increase: (date, n) => {
|
|
683
|
+
const _date = splitISO(date);
|
|
684
|
+
const y = _date.year.asInt;
|
|
685
|
+
const m = _date.month.asInt;
|
|
686
|
+
const d = _date.day.asInt;
|
|
687
|
+
return makeISO(y + n, m, d);
|
|
688
|
+
},
|
|
689
|
+
decrease: (date, n) => {
|
|
690
|
+
const _date = splitISO(date);
|
|
691
|
+
const y = _date.year.asInt;
|
|
692
|
+
const m = _date.month.asInt;
|
|
693
|
+
const d = _date.day.asInt;
|
|
694
|
+
return makeISO(y - n, m, d);
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
month: {
|
|
698
|
+
asString: (date) => splitISO(date).month.asString,
|
|
699
|
+
asInt: (date) => splitISO(date).month.asInt,
|
|
700
|
+
increase: (date, n) => {
|
|
701
|
+
const _date = splitISO(date);
|
|
702
|
+
const yearsToAdd = Math.floor(n / 12);
|
|
703
|
+
const monthsToAdd = n % 12;
|
|
704
|
+
let y = _date.year.asInt;
|
|
705
|
+
let m = _date.month.asInt;
|
|
706
|
+
const d = _date.day.asInt;
|
|
707
|
+
y = m + monthsToAdd > 12 ? y + 1 : y;
|
|
708
|
+
y = y + yearsToAdd;
|
|
709
|
+
m = m + monthsToAdd;
|
|
710
|
+
// modulo requires zero-indexing
|
|
711
|
+
m = ((m - 1) % 12) + 1;
|
|
712
|
+
return makeISO(y, m, d);
|
|
713
|
+
},
|
|
714
|
+
decrease: (date, n) => {
|
|
715
|
+
const _date = splitISO(date);
|
|
716
|
+
const yearsToRemove = Math.floor(n / 12);
|
|
717
|
+
const monthsToRemove = n % 12;
|
|
718
|
+
let y = _date.year.asInt;
|
|
719
|
+
let m = _date.month.asInt;
|
|
720
|
+
const d = _date.day.asInt;
|
|
721
|
+
y = m - monthsToRemove < 1 ? y - 1 : y;
|
|
722
|
+
y = y - yearsToRemove;
|
|
723
|
+
// ensure no negative value by shifting up
|
|
724
|
+
m = m + 12;
|
|
725
|
+
m = m - monthsToRemove;
|
|
726
|
+
// modulo needs zero-indexing
|
|
727
|
+
m = ((m - 1) % 12) + 1;
|
|
728
|
+
return makeISO(y, m, d);
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
day: {
|
|
732
|
+
asString: (date) => splitISO(date).day.asString,
|
|
733
|
+
asInt: (date) => splitISO(date).day.asInt,
|
|
734
|
+
increase: (date, n) => {
|
|
735
|
+
if (n > 7)
|
|
736
|
+
throw new Error("this.dateFind.day.increase(): max 7 days");
|
|
737
|
+
const _date = splitISO(date);
|
|
738
|
+
let y = _date.year.asInt;
|
|
739
|
+
let m = _date.month.asInt;
|
|
740
|
+
let d = _date.day.asInt;
|
|
741
|
+
const maxDays = getMonthLength(m, y);
|
|
742
|
+
const goesToNextMonth = d + n > maxDays;
|
|
743
|
+
const goesToNextYear = goesToNextMonth && m === 12;
|
|
744
|
+
m = goesToNextMonth ? (goesToNextYear ? 1 : m + 1) : m;
|
|
745
|
+
y = goesToNextYear ? y + 1 : y;
|
|
746
|
+
d = ((d - 1 + n) % maxDays) + 1;
|
|
747
|
+
return makeISO(y, m, d);
|
|
748
|
+
},
|
|
749
|
+
decrease: (date, n) => {
|
|
750
|
+
if (n > 7)
|
|
751
|
+
throw new Error("this.dateFind.day.decrease(): max 7 days");
|
|
752
|
+
const _date = splitISO(date);
|
|
753
|
+
let y = _date.year.asInt;
|
|
754
|
+
let m = _date.month.asInt;
|
|
755
|
+
let d = _date.day.asInt;
|
|
756
|
+
const prevMonth = m === 1 ? 12 : m - 1;
|
|
757
|
+
const maxDays = getMonthLength(prevMonth, y);
|
|
758
|
+
const goesToPreviousMonth = d - n < 1;
|
|
759
|
+
const goesToPreviousYear = goesToPreviousMonth && m === 1;
|
|
760
|
+
// ensure no negative value by shifting up
|
|
761
|
+
d = d + maxDays;
|
|
762
|
+
d = d - n;
|
|
763
|
+
// modulo needs zero-indexing
|
|
764
|
+
d = ((d - 1) % maxDays) + 1;
|
|
765
|
+
m = goesToPreviousMonth ? (goesToPreviousYear ? 12 : m - 1) : m;
|
|
766
|
+
y = goesToPreviousYear ? y - 1 : y;
|
|
767
|
+
return makeISO(y, m, d);
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
};
|
|
771
|
+
export const calendar_months = [
|
|
772
|
+
intl.formatMessage({
|
|
773
|
+
id: "date.january",
|
|
774
|
+
defaultMessage: "January",
|
|
775
|
+
description: "Month of the year",
|
|
776
|
+
}),
|
|
777
|
+
intl.formatMessage({
|
|
778
|
+
id: "date.february",
|
|
779
|
+
defaultMessage: "February",
|
|
780
|
+
description: "Month of the year",
|
|
781
|
+
}),
|
|
782
|
+
intl.formatMessage({
|
|
783
|
+
id: "date.march",
|
|
784
|
+
defaultMessage: "March",
|
|
785
|
+
description: "Month of the year",
|
|
786
|
+
}),
|
|
787
|
+
intl.formatMessage({
|
|
788
|
+
id: "date.april",
|
|
789
|
+
defaultMessage: "April",
|
|
790
|
+
description: "Month of the year",
|
|
791
|
+
}),
|
|
792
|
+
intl.formatMessage({
|
|
793
|
+
id: "date.may",
|
|
794
|
+
defaultMessage: "May",
|
|
795
|
+
description: "Month of the year",
|
|
796
|
+
}),
|
|
797
|
+
intl.formatMessage({
|
|
798
|
+
id: "date.june",
|
|
799
|
+
defaultMessage: "June",
|
|
800
|
+
description: "Month of the year",
|
|
801
|
+
}),
|
|
802
|
+
intl.formatMessage({
|
|
803
|
+
id: "date.july",
|
|
804
|
+
defaultMessage: "July",
|
|
805
|
+
description: "Month of the year",
|
|
806
|
+
}),
|
|
807
|
+
intl.formatMessage({
|
|
808
|
+
id: "date.august",
|
|
809
|
+
defaultMessage: "August",
|
|
810
|
+
description: "Month of the year",
|
|
811
|
+
}),
|
|
812
|
+
intl.formatMessage({
|
|
813
|
+
id: "date.september",
|
|
814
|
+
defaultMessage: "September",
|
|
815
|
+
description: "Month of the year",
|
|
816
|
+
}),
|
|
817
|
+
intl.formatMessage({
|
|
818
|
+
id: "date.october",
|
|
819
|
+
defaultMessage: "October",
|
|
820
|
+
description: "Month of the year",
|
|
821
|
+
}),
|
|
822
|
+
intl.formatMessage({
|
|
823
|
+
id: "date.november",
|
|
824
|
+
defaultMessage: "November",
|
|
825
|
+
description: "Month of the year",
|
|
826
|
+
}),
|
|
827
|
+
intl.formatMessage({
|
|
828
|
+
id: "date.december",
|
|
829
|
+
defaultMessage: "December",
|
|
830
|
+
description: "Month of the year",
|
|
831
|
+
}),
|
|
832
|
+
];
|
|
833
|
+
export const weekdays = [
|
|
834
|
+
intl.formatMessage({ id: "date.sunday", defaultMessage: "Sunday" }),
|
|
835
|
+
intl.formatMessage({ id: "date.monday", defaultMessage: "Monday" }),
|
|
836
|
+
intl.formatMessage({ id: "date.tuesday", defaultMessage: "Tuesday" }),
|
|
837
|
+
intl.formatMessage({ id: "date.wednesday", defaultMessage: "Wednesday" }),
|
|
838
|
+
intl.formatMessage({ id: "date.thursday", defaultMessage: "Thursday" }),
|
|
839
|
+
intl.formatMessage({ id: "date.friday", defaultMessage: "Friday" }),
|
|
840
|
+
intl.formatMessage({ id: "date.saturday", defaultMessage: "Saturday" }),
|
|
841
|
+
];
|