@watermarkinsights/ripple 3.27.0 → 3.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/{chartFunctions-b2e0cb4e.js → chartFunctions-42cfb4d3.js} +596 -596
- package/dist/cjs/{functions-9807717e.js → functions-85c3c557.js} +498 -498
- package/dist/cjs/{global-42a24725.js → global-9982752f.js} +72 -72
- package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
- package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
- package/dist/cjs/{intl-526c75ec.js → intl-1c36fe38.js} +131 -131
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/priv-chart-popover.cjs.entry.js +91 -91
- package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
- package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
- package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
- package/dist/cjs/ripple.cjs.js +1 -1
- package/dist/cjs/wm-action-menu_2.cjs.entry.js +334 -334
- package/dist/cjs/wm-button.cjs.entry.js +189 -189
- package/dist/cjs/wm-chart-slice.cjs.entry.js +18 -18
- package/dist/cjs/wm-chart.cjs.entry.js +183 -183
- package/dist/cjs/wm-datepicker.cjs.entry.js +263 -263
- package/dist/cjs/wm-file-list.cjs.entry.js +35 -35
- package/dist/cjs/wm-file.cjs.entry.js +181 -181
- package/dist/cjs/wm-input.cjs.entry.js +136 -136
- package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
- package/dist/cjs/wm-modal-header.cjs.entry.js +32 -32
- package/dist/cjs/wm-modal.cjs.entry.js +152 -152
- package/dist/cjs/wm-navigation_3.cjs.entry.js +186 -186
- package/dist/cjs/wm-navigator.cjs.entry.js +264 -264
- package/dist/cjs/wm-network-uploader.cjs.entry.js +465 -465
- package/dist/cjs/wm-option_2.cjs.entry.js +768 -768
- package/dist/cjs/wm-pagination.cjs.entry.js +179 -179
- package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +155 -155
- package/dist/cjs/wm-search.cjs.entry.js +184 -184
- package/dist/cjs/wm-snackbar.cjs.entry.js +134 -134
- package/dist/cjs/wm-tab-item_3.cjs.entry.js +264 -264
- package/dist/cjs/wm-tag-input-row.cjs.entry.js +14 -14
- package/dist/cjs/wm-tag-input.cjs.entry.js +948 -941
- package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
- package/dist/cjs/wm-toggletip.cjs.entry.js +120 -120
- package/dist/cjs/wm-uploader.cjs.entry.js +441 -441
- package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
- package/dist/collection/components/charts/chartFunctions.js +562 -562
- package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +267 -267
- package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +125 -125
- package/dist/collection/components/charts/wm-chart/wm-chart.js +450 -450
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +207 -207
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +143 -143
- package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +121 -121
- package/dist/collection/components/wm-action-menu/wm-action-menu.js +472 -472
- package/dist/collection/components/wm-button/wm-button.js +486 -486
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +983 -983
- package/dist/collection/components/wm-datepicker/wm-datepicker.js +491 -491
- package/dist/collection/components/wm-file/wm-file.js +313 -313
- package/dist/collection/components/wm-file-list/wm-file-list.js +152 -152
- package/dist/collection/components/wm-input/wm-input.js +509 -509
- package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
- package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
- package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
- package/dist/collection/components/wm-modal/wm-modal.js +462 -462
- package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +119 -119
- package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
- package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
- package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
- package/dist/collection/components/wm-option/wm-option.js +435 -435
- package/dist/collection/components/wm-pagination/wm-pagination.js +362 -362
- package/dist/collection/components/wm-search/wm-search.js +439 -439
- package/dist/collection/components/wm-select/wm-select.js +1054 -1054
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +267 -267
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
- package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
- package/dist/collection/components/wm-tag-input/wm-tag-input.css +21 -17
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +1302 -1295
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +243 -243
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +772 -772
- package/dist/collection/components/wm-uploader/wm-uploader.js +964 -964
- package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -28
- package/dist/collection/dev/scripts.js +20 -20
- package/dist/collection/global/__mocks__/functions.js +6 -6
- package/dist/collection/global/functions.js +541 -541
- package/dist/collection/global/global.js +79 -79
- package/dist/collection/global/interfaces.js +49 -49
- package/dist/collection/global/intl.js +132 -132
- 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 +43 -43
- package/dist/collection/lang/piglatin.js +93 -93
- package/dist/esm/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +596 -596
- package/dist/esm/{functions-f32b1ca4.js → functions-cbb19d50.js} +498 -498
- package/dist/esm/{global-7ee0d78d.js → global-2c7bbfe6.js} +72 -72
- package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
- package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
- package/dist/esm/{intl-d101e1a9.js → intl-ffbca53d.js} +131 -131
- package/dist/esm/loader.js +1 -1
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/priv-chart-popover.entry.js +91 -91
- package/dist/esm/priv-datepicker.entry.js +657 -657
- package/dist/esm/priv-navigator-button.entry.js +19 -19
- package/dist/esm/priv-navigator-item.entry.js +23 -23
- package/dist/esm/ripple.js +1 -1
- package/dist/esm/wm-action-menu_2.entry.js +334 -334
- package/dist/esm/wm-button.entry.js +189 -189
- package/dist/esm/wm-chart-slice.entry.js +18 -18
- package/dist/esm/wm-chart.entry.js +183 -183
- package/dist/esm/wm-datepicker.entry.js +263 -263
- package/dist/esm/wm-file-list.entry.js +35 -35
- package/dist/esm/wm-file.entry.js +181 -181
- package/dist/esm/wm-input.entry.js +136 -136
- package/dist/esm/wm-modal-footer.entry.js +33 -33
- package/dist/esm/wm-modal-header.entry.js +32 -32
- package/dist/esm/wm-modal.entry.js +152 -152
- package/dist/esm/wm-navigation_3.entry.js +186 -186
- package/dist/esm/wm-navigator.entry.js +264 -264
- package/dist/esm/wm-network-uploader.entry.js +465 -465
- package/dist/esm/wm-option_2.entry.js +768 -768
- package/dist/esm/wm-pagination.entry.js +179 -179
- package/dist/esm/wm-progress-indicator_3.entry.js +155 -155
- package/dist/esm/wm-search.entry.js +184 -184
- package/dist/esm/wm-snackbar.entry.js +134 -134
- package/dist/esm/wm-tab-item_3.entry.js +264 -264
- package/dist/esm/wm-tag-input-row.entry.js +14 -14
- package/dist/esm/wm-tag-input.entry.js +948 -941
- package/dist/esm/wm-timepicker.entry.js +385 -385
- package/dist/esm/wm-toggletip.entry.js +120 -120
- package/dist/esm/wm-uploader.entry.js +441 -441
- package/dist/esm/wm-wrapper.entry.js +12 -12
- package/dist/esm-es5/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +1 -1
- package/dist/esm-es5/{global-7ee0d78d.js → global-2c7bbfe6.js} +1 -1
- package/dist/esm-es5/{intl-d101e1a9.js → intl-ffbca53d.js} +1 -1
- 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/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.entry.js +1 -1
- package/dist/esm-es5/wm-datepicker.entry.js +1 -1
- package/dist/esm-es5/wm-file.entry.js +1 -1
- package/dist/esm-es5/wm-input.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-progress-indicator_3.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/ripple/{p-725c14b0.system.entry.js → p-00022d17.system.entry.js} +1 -1
- package/dist/ripple/{p-b97de06f.system.entry.js → p-0450cdbe.system.entry.js} +1 -1
- package/dist/ripple/{p-bfe1062d.entry.js → p-05a17658.entry.js} +1 -1
- package/dist/ripple/p-0b6a7b77.system.entry.js +1 -0
- package/dist/ripple/{p-b6bf2866.entry.js → p-0e789be7.entry.js} +1 -1
- package/dist/ripple/{p-b617b64f.system.entry.js → p-15779c22.system.entry.js} +1 -1
- package/dist/ripple/{p-04faca6b.entry.js → p-17487f1b.entry.js} +1 -1
- package/dist/ripple/{p-122da0d1.system.entry.js → p-197c83de.system.entry.js} +1 -1
- package/dist/ripple/{p-11d98b00.system.entry.js → p-1bad4efe.system.entry.js} +1 -1
- package/dist/ripple/{p-252ba295.system.entry.js → p-2ff923ee.system.entry.js} +1 -1
- package/dist/ripple/{p-a6afe65a.entry.js → p-31712996.entry.js} +1 -1
- package/dist/ripple/{p-f69276d5.system.entry.js → p-31c18f5e.system.entry.js} +1 -1
- package/dist/ripple/{p-df28f438.system.js → p-32944b70.system.js} +1 -1
- package/dist/ripple/{p-73d277ba.system.entry.js → p-36effc40.system.entry.js} +1 -1
- package/dist/ripple/{p-0be94e77.entry.js → p-3807bcae.entry.js} +1 -1
- package/dist/ripple/{p-88d17f6b.system.entry.js → p-3aa48fad.system.entry.js} +1 -1
- package/dist/ripple/{p-82a97531.system.entry.js → p-419f133c.system.entry.js} +1 -1
- package/dist/ripple/{p-13ec8ac0.entry.js → p-438a1e8e.entry.js} +1 -1
- package/dist/ripple/{p-19689aac.js → p-4698b365.js} +1 -1
- package/dist/ripple/{p-f8d45250.system.entry.js → p-54086f7b.system.entry.js} +1 -1
- package/dist/ripple/{p-47f53321.entry.js → p-5497694c.entry.js} +1 -1
- package/dist/ripple/{p-fb370a69.entry.js → p-58fbf116.entry.js} +1 -1
- package/dist/ripple/{p-14dfc4e7.entry.js → p-65a741c1.entry.js} +1 -1
- package/dist/ripple/{p-ac63b3aa.entry.js → p-7e74274b.entry.js} +1 -1
- package/dist/ripple/{p-81752607.system.js → p-81ad3fe5.system.js} +1 -1
- package/dist/ripple/{p-f3e42327.system.entry.js → p-89db9c27.system.entry.js} +1 -1
- package/dist/ripple/{p-4753fbfc.system.entry.js → p-947f01e2.system.entry.js} +1 -1
- package/dist/ripple/{p-3aee75e7.entry.js → p-978429f9.entry.js} +1 -1
- package/dist/ripple/{p-2c8fd902.system.entry.js → p-97d5b4bd.system.entry.js} +1 -1
- package/dist/ripple/{p-67c0ad56.system.entry.js → p-9d6a574b.system.entry.js} +1 -1
- package/dist/ripple/{p-c545fe1c.entry.js → p-a3ba2bdd.entry.js} +1 -1
- package/dist/ripple/{p-c7567fd3.entry.js → p-a42f5231.entry.js} +1 -1
- package/dist/ripple/p-a51aec3f.entry.js +1 -0
- package/dist/ripple/{p-b831988d.entry.js → p-a5b86b47.entry.js} +1 -1
- package/dist/ripple/{p-4cadf985.entry.js → p-a90b8a08.entry.js} +1 -1
- package/dist/ripple/{p-d9b66dca.system.entry.js → p-aabe172c.system.entry.js} +1 -1
- package/dist/ripple/{p-69121ad1.entry.js → p-ab2a0aee.entry.js} +1 -1
- package/dist/ripple/{p-5fb0aa58.js → p-aed93a25.js} +1 -1
- package/dist/ripple/{p-f39ee84b.entry.js → p-b2d75e7d.entry.js} +1 -1
- package/dist/ripple/{p-19b897ce.js → p-b410c675.js} +1 -1
- package/dist/ripple/{p-4809e419.system.entry.js → p-b6f558f7.system.entry.js} +1 -1
- package/dist/ripple/p-bb048fe7.entry.js +1 -0
- package/dist/ripple/{p-2805fed6.system.entry.js → p-bced37cf.system.entry.js} +1 -1
- package/dist/ripple/{p-c9a1834d.system.entry.js → p-bd0c1e7c.system.entry.js} +1 -1
- package/dist/ripple/{p-89f1991f.entry.js → p-c0e183f4.entry.js} +1 -1
- package/dist/ripple/{p-7eca18bd.system.entry.js → p-c27eda00.system.entry.js} +1 -1
- package/dist/ripple/{p-894bc6c4.system.entry.js → p-cd3e0b8b.system.entry.js} +1 -1
- package/dist/ripple/{p-f6b2e4ac.system.js → p-d1af63b5.system.js} +1 -1
- package/dist/ripple/{p-30572b71.system.js → p-d41ba263.system.js} +1 -1
- package/dist/ripple/{p-db7e6e89.entry.js → p-d8993992.entry.js} +1 -1
- package/dist/ripple/{p-f13b239c.system.entry.js → p-da525ed1.system.entry.js} +1 -1
- package/dist/ripple/{p-33af1eee.entry.js → p-e6f46289.entry.js} +1 -1
- package/dist/ripple/{p-e928f350.entry.js → p-fc967b2c.entry.js} +1 -1
- package/dist/ripple/ripple.esm.js +1 -1
- package/dist/ripple/ripple.js +1 -1
- package/dist/types/components/charts/chartFunctions.d.ts +37 -37
- package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
- package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
- package/dist/types/components/charts/wm-chart/wm-chart.d.ts +47 -47
- package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +29 -29
- package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +20 -20
- package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
- package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +49 -49
- package/dist/types/components/wm-button/wm-button.d.ts +44 -44
- 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-file/wm-file.d.ts +40 -40
- package/dist/types/components/wm-file-list/wm-file-list.d.ts +16 -16
- package/dist/types/components/wm-input/wm-input.d.ts +57 -57
- package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
- package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
- package/dist/types/components/wm-modal/wm-modal-header.d.ts +10 -10
- package/dist/types/components/wm-modal/wm-modal.d.ts +40 -40
- package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +16 -16
- package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
- package/dist/types/components/wm-navigation/wm-navigation.d.ts +26 -26
- 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 +34 -34
- package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
- package/dist/types/components/wm-search/wm-search.d.ts +77 -77
- package/dist/types/components/wm-select/wm-select.d.ts +101 -101
- package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +30 -30
- package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +37 -37
- package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +52 -52
- 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-row/wm-tag-input-row.d.ts +11 -11
- package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +137 -136
- package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
- package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -25
- 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 +99 -99
- package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
- package/dist/types/components.d.ts +27 -27
- package/dist/types/global/__mocks__/functions.d.ts +6 -6
- package/dist/types/global/functions.d.ts +40 -40
- package/dist/types/global/global.d.ts +1 -1
- package/dist/types/global/interfaces.d.ts +74 -74
- package/dist/types/global/intl.d.ts +29 -29
- 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/package.json +46 -46
- package/dist/ripple/p-37de8e2f.entry.js +0 -1
- package/dist/ripple/p-b378e064.system.entry.js +0 -1
- package/dist/ripple/p-d2037549.entry.js +0 -1
- /package/dist/esm-es5/{functions-f32b1ca4.js → functions-cbb19d50.js} +0 -0
- /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
- /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
- /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
- /package/dist/ripple/{p-cfa80f5b.js → p-91480a89.js} +0 -0
- /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
- /package/dist/ripple/{p-9eb5a71e.system.js → p-b267e710.system.js} +0 -0
- /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
- /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
|
@@ -1,947 +1,954 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-e887b1ce.js';
|
|
2
|
-
import { g as generateId, d as debounce, q as csvToArray, i as intl, r as safeParseJSON, u as measureText, j as truncateText, h as hideTooltip, s as showTooltip, m as shouldOpenUp } from './functions-
|
|
3
|
-
import { g as globalMessages } from './intl-
|
|
2
|
+
import { g as generateId, d as debounce, q as csvToArray, i as intl, r as safeParseJSON, u as measureText, j as truncateText, h as hideTooltip, s as showTooltip, m as shouldOpenUp } from './functions-cbb19d50.js';
|
|
3
|
+
import { g as globalMessages } from './intl-ffbca53d.js';
|
|
4
4
|
|
|
5
|
-
const wmTagInputCss = ":host,wm-tag-input{font-family:inherit;width:100%;display:block;max-height:80vh}:host *,wm-tag-input *{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px}:host .wrapper,wm-tag-input .wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;font-size:0.875rem}:host .wrapper .label,wm-tag-input .wrapper .label{display:block;line-height:normal;font-weight:600;white-space:nowrap;margin-bottom:0.25rem}:host .wrapper .label .required,wm-tag-input .wrapper .label .required{color:#c0392b}:host .wrapper.label-left,wm-tag-input .wrapper.label-left{-ms-flex-direction:row;flex-direction:row}:host .wrapper.label-left .label-wrapper,wm-tag-input .wrapper.label-left .label-wrapper{line-height:2.5rem}:host .wrapper.label-left .label-wrapper .label,wm-tag-input .wrapper.label-left .label-wrapper .label{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:2.5rem;white-space:normal;margin-bottom:0;margin-right:0.75rem}:host .wrapper.label-none label,wm-tag-input .wrapper.label-none label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host .wrapper.invalid .label,wm-tag-input .wrapper.invalid .label{color:#c0392b}:host .wrapper.invalid .label:after,wm-tag-input .wrapper.invalid .label:after{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f026\";margin-left:0.3125rem}[dir=RTL] :host .wrapper.invalid .label:after,[dir=RTL] wm-tag-input .wrapper.invalid .label:after{margin-left:0;margin-right:0.3125rem}:host .wrapper.rtl.label-left .label,wm-tag-input .wrapper.rtl.label-left .label{margin-right:0;margin-left:0.75rem}:host .wrapper,wm-tag-input .wrapper{width:100%;height:100%;max-height:inherit;min-height:inherit;position:relative}:host .field-wrapper,wm-tag-input .field-wrapper{position:relative;width:100%;border:1px solid #4a4a4a;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px}:host .field-wrapper.focused,wm-tag-input .field-wrapper.focused{-webkit-box-shadow:0 0 0 1px #19a1a9;-moz-box-shadow:0 0 0 1px #19a1a9;box-shadow:0 0 0 1px #19a1a9;outline:none;border-color:#19a1a9}:host .field-wrapper.invalid,wm-tag-input .field-wrapper.invalid{-webkit-box-shadow:0 0 0 1px #c0392b;-moz-box-shadow:0 0 0 1px #c0392b;box-shadow:0 0 0 1px #c0392b;border-color:#c0392b}:host .character-count,wm-tag-input .character-count{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:5rem;background-color:rgba(74, 74, 74, 0.05);font-size:0.875rem;font-weight:500;-ms-flex-item-align:stretch;align-self:stretch}:host .tags-and-input-wrapper,wm-tag-input .tags-and-input-wrapper{position:relative;width:100%;padding:0.5rem 0.25rem 0.5rem 0;margin-bottom:-0.5rem;overflow:hidden}:host .upper-row,wm-tag-input .upper-row{width:100%;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-pack:justify;justify-content:space-between}:host .upper-row:before,wm-tag-input .upper-row:before{-ms-flex-item-align:start;align-self:flex-start;display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f349\";color:#b5b5b5;padding:0.75rem 0.5rem 0.75rem 0.75rem;line-height:normal;font-size:1.12rem}:host .lower-row,wm-tag-input .lower-row{width:100%;min-height:1.875rem}:host #max-tags,wm-tag-input #max-tags{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:1.875rem;background-color:#e6e6e6;padding:0.5rem 1rem;color:#4a4a4a;font-size:0.875rem;border-top:1px solid rgba(35, 35, 35, 0.6);border-radius:0 0 3px 3px}:host .tag-area,wm-tag-input .tag-area{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin:0;padding:0}:host .tag-area:focus,wm-tag-input .tag-area:focus{outline:none}:host .tag-area [role=option],wm-tag-input .tag-area [role=option]{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;height:1.75rem;list-style:none;color:#4a4a4a;background-color:rgba(3, 0, 0, 0.1);padding:0.5rem 0.625rem;margin-bottom:0.5rem;margin-right:0.25rem;margin-left:0.25rem;-webkit-transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);white-space:pre}:host .tag-area [role=option].highlight,wm-tag-input .tag-area [role=option].highlight{-webkit-animation:fadeIn 1s;animation:fadeIn 1s}@-webkit-keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}@keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}:host .tag-area [role=option].focused,wm-tag-input .tag-area [role=option].focused{background-color:#d1d1d1}:host .tag-area [role=option].locked,wm-tag-input .tag-area [role=option].locked{background-color:#6b6b6b;color:white}:host .tag-area [role=option] .icon,wm-tag-input .tag-area [role=option] .icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:1.25rem;width:1.25rem;padding:0;margin-left:0.5rem}:host .tag-area [role=option] .icon.remove-btn,wm-tag-input .tag-area [role=option] .icon.remove-btn{border:1px solid #575195;color:#575195;border-radius:50%;cursor:pointer;-webkit-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1)}:host .tag-area [role=option] .icon.remove-btn:hover,wm-tag-input .tag-area [role=option] .icon.remove-btn:hover{color:white;background-color:#575195}:host .tag-area [role=option] .icon.remove-btn:before,wm-tag-input .tag-area [role=option] .icon.remove-btn:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f156\"}:host .tag-area [role=option] .icon.lock,wm-tag-input .tag-area [role=option] .icon.lock{color:white}:host .tag-area [role=option] .icon.lock:before,wm-tag-input .tag-area [role=option] .icon.lock:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f341\"}:host input,wm-tag-input input{font-family:inherit;border:none;height:1.75rem;padding:0;margin-bottom:0.5rem;margin-right:0.25rem;padding-left:0.5rem;right:0px}:host input.hidden,wm-tag-input input.hidden{display:none}:host input:focus,wm-tag-input input:focus{outline:none}:host .dropdown-wrapper,wm-tag-input .dropdown-wrapper{margin:0;padding:0;-webkit-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-ms-transition:transform 0.25s ease;-webkit-transition:transform 0.25s ease;-moz-transition:transform 0.25s ease;-webkit-transition:-webkit-transform 0.25s ease;transition:-webkit-transform 0.25s ease;transition:transform 0.25s ease;transition:transform 0.25s ease, -webkit-transform 0.25s ease;-ms-transform:scale(1, 0);-webkit-transform:scale(1, 0);-moz-transform:scale(1, 0);transform:scale(1, 0);-ms-transform-origin:center top;-webkit-transform-origin:center top;-moz-transform-origin:center top;transform-origin:center top;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:absolute;top:calc(100% + 2px);right:0;background:#fff;z-index:100;width:100%;font-size:0.875rem}:host .dropdown-wrapper .dropdown,wm-tag-input .dropdown-wrapper .dropdown{-webkit-overflow-scrolling:touch;overflow:auto;max-height:12.5rem;margin:0;padding:0}:host .dropdown-wrapper.open,wm-tag-input .dropdown-wrapper.open{-ms-transform:scale(1, 1);-webkit-transform:scale(1, 1);-moz-transform:scale(1, 1);transform:scale(1, 1)}:host .dropdown-wrapper.upwards,wm-tag-input .dropdown-wrapper.upwards{top:unset;bottom:calc(100% + 2px);-ms-transform-origin:center bottom;-webkit-transform-origin:center bottom;-moz-transform-origin:center bottom;transform-origin:center bottom}:host .dropdown-wrapper li,:host .dropdown-wrapper div,wm-tag-input .dropdown-wrapper li,wm-tag-input .dropdown-wrapper div{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:0 1rem;background:#fff;list-style:none;min-height:2.6875rem;white-space:pre-wrap;overflow-wrap:anywhere}:host .dropdown-wrapper li[role=option],:host .dropdown-wrapper li.add-new-btn,:host .dropdown-wrapper div[role=option],:host .dropdown-wrapper div.add-new-btn,wm-tag-input .dropdown-wrapper li[role=option],wm-tag-input .dropdown-wrapper li.add-new-btn,wm-tag-input .dropdown-wrapper div[role=option],wm-tag-input .dropdown-wrapper div.add-new-btn{cursor:pointer;color:#575195;font-weight:bold;width:100%;border:none}:host .dropdown-wrapper li[role=option][aria-selected=true],:host .dropdown-wrapper li.add-new-btn[aria-selected=true],:host .dropdown-wrapper div[role=option][aria-selected=true],:host .dropdown-wrapper div.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper li[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper li.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper div[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper div.add-new-btn[aria-selected=true]{color:#6b6b6b;font-style:italic;font-weight:normal;cursor:unset}:host .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper li[role=option].focused,:host .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper li.add-new-btn.focused,:host .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper div[role=option].focused,:host .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper div.add-new-btn.focused,wm-tag-input .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li[role=option].focused,wm-tag-input .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li.add-new-btn.focused,wm-tag-input .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div[role=option].focused,wm-tag-input .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div.add-new-btn.focused{outline:none;background:#f4f4f4}:host .dropdown-wrapper li.help-text,:host .dropdown-wrapper div.help-text,wm-tag-input .dropdown-wrapper li.help-text,wm-tag-input .dropdown-wrapper div.help-text{color:#4a4a4a;height:auto;min-height:2.6875rem;padding-top:0.25rem;padding-bottom:0.25rem;white-space:normal}:host .dropdown-wrapper li:not(:last-child),:host .dropdown-wrapper div:not(:last-child),wm-tag-input .dropdown-wrapper li:not(:last-child),wm-tag-input .dropdown-wrapper div:not(:last-child){border-bottom:2px solid rgba(46, 27, 70, 0.05)}:host .info-text,wm-tag-input .info-text{font-style:italic;margin-top:0.25rem}:host .table-wrapper,wm-tag-input .table-wrapper{overflow:auto;margin-top:1.5rem}:host .table-wrapper #table,wm-tag-input .table-wrapper #table{width:100%;border-spacing:0px}:host .table-wrapper #table.fixed-widths,wm-tag-input .table-wrapper #table.fixed-widths{table-layout:fixed}:host .table-wrapper #table .headers,wm-tag-input .table-wrapper #table .headers{height:2.5rem;background-color:#eeedf4}:host .table-wrapper #table .headers th,wm-tag-input .table-wrapper #table .headers th{text-align:left;font-size:0.75rem;font-weight:700;text-transform:uppercase;padding:0 1.5rem}:host .table-wrapper tr:nth-child(even),wm-tag-input .table-wrapper tr:nth-child(even){background-color:#fafafa}:host .table-wrapper tr.selected,wm-tag-input .table-wrapper tr.selected{background-color:rgba(25, 161, 169, 0.2);-webkit-box-shadow:inset 0 0 0 1px #19a1a9;box-shadow:inset 0 0 0 1px #19a1a9;font-weight:500}:host .table-wrapper tr.focused:not(.locked),:host .table-wrapper tr:hover:not(.locked),wm-tag-input .table-wrapper tr.focused:not(.locked),wm-tag-input .table-wrapper tr:hover:not(.locked){background-color:#e9e7ec;-webkit-box-shadow:none;box-shadow:none}:host .table-wrapper tr.locked td,wm-tag-input .table-wrapper tr.locked td{cursor:auto}:host .table-wrapper tr.locked td:first-child .cell-content-wrapper:before,wm-tag-input .table-wrapper tr.locked td:first-child .cell-content-wrapper:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f33e\";margin-right:0.5rem;color:#4a4a4a}:host .table-wrapper td,wm-tag-input .table-wrapper td{height:3.75rem;vertical-align:middle;padding:0 1.5rem;cursor:pointer}:host .table-wrapper td.focused,wm-tag-input .table-wrapper td.focused{-webkit-box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e;box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e}:host .table-wrapper td .cell-content-wrapper.trunc,wm-tag-input .table-wrapper td .cell-content-wrapper.trunc{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .table-wrapper td .description,wm-tag-input .table-wrapper td .description{display:none}:host .no-results,wm-tag-input .no-results{padding:1.25rem 1.5rem}:host .sr-only,wm-tag-input .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host #error,wm-tag-input #error{display:block;font-style:italic;color:#c0392b;font-size:0.875rem;margin-top:0.25rem}";
|
|
5
|
+
const wmTagInputCss = ":host,wm-tag-input{font-family:inherit;width:100%;display:block;max-height:80vh}:host *,wm-tag-input *{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px}:host .wrapper,wm-tag-input .wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;font-size:0.875rem}:host .wrapper .label,wm-tag-input .wrapper .label{display:block;line-height:normal;font-weight:600;white-space:nowrap;margin-bottom:0.25rem}:host .wrapper .label .required,wm-tag-input .wrapper .label .required{color:#c0392b}:host .wrapper.label-left,wm-tag-input .wrapper.label-left{-ms-flex-direction:row;flex-direction:row}:host .wrapper.label-left .label-wrapper,wm-tag-input .wrapper.label-left .label-wrapper{line-height:2.5rem}:host .wrapper.label-left .label-wrapper .label,wm-tag-input .wrapper.label-left .label-wrapper .label{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:2.5rem;white-space:normal;margin-bottom:0;margin-right:0.75rem}:host .wrapper.label-none label,wm-tag-input .wrapper.label-none label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host .wrapper.invalid .label,wm-tag-input .wrapper.invalid .label{color:#c0392b}:host .wrapper.invalid .label:after,wm-tag-input .wrapper.invalid .label:after{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f026\";margin-left:0.3125rem}[dir=RTL] :host .wrapper.invalid .label:after,[dir=RTL] wm-tag-input .wrapper.invalid .label:after{margin-left:0;margin-right:0.3125rem}:host .wrapper.rtl.label-left .label,wm-tag-input .wrapper.rtl.label-left .label{margin-right:0;margin-left:0.75rem}:host .wrapper,wm-tag-input .wrapper{width:100%;height:100%;max-height:inherit;min-height:inherit;position:relative}:host .field-wrapper,wm-tag-input .field-wrapper{position:relative;width:100%;border:1px solid #4a4a4a;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px}:host .field-wrapper.focused,wm-tag-input .field-wrapper.focused{-webkit-box-shadow:0 0 0 1px #19a1a9;-moz-box-shadow:0 0 0 1px #19a1a9;box-shadow:0 0 0 1px #19a1a9;outline:none;border-color:#19a1a9}:host .field-wrapper.invalid,wm-tag-input .field-wrapper.invalid{-webkit-box-shadow:0 0 0 1px #c0392b;-moz-box-shadow:0 0 0 1px #c0392b;box-shadow:0 0 0 1px #c0392b;border-color:#c0392b}:host .wrapper:not(.label-left) .field-wrapper,wm-tag-input .wrapper:not(.label-left) .field-wrapper{-ms-flex-negative:0;flex-shrink:0}:host .character-count,wm-tag-input .character-count{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:5rem;background-color:rgba(74, 74, 74, 0.05);font-size:0.875rem;font-weight:500;-ms-flex-item-align:stretch;align-self:stretch}:host .tags-and-input-wrapper,wm-tag-input .tags-and-input-wrapper{position:relative;width:100%;padding:8px 8px 8px 0;overflow:auto;max-height:200px}:host .upper-row,wm-tag-input .upper-row{width:100%;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-pack:justify;justify-content:space-between}:host .upper-row:before,wm-tag-input .upper-row:before{-ms-flex-item-align:start;align-self:flex-start;display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f349\";color:#b5b5b5;padding:0.75rem 0.5rem 0.75rem 0.75rem;line-height:normal;font-size:1.12rem}:host .lower-row,wm-tag-input .lower-row{width:100%;min-height:1.875rem}:host #max-tags,wm-tag-input #max-tags{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:1.875rem;background-color:#e6e6e6;padding:0.5rem 1rem;color:#4a4a4a;font-size:0.875rem;border-top:1px solid rgba(35, 35, 35, 0.6);border-radius:0 0 3px 3px}:host .tag-area,wm-tag-input .tag-area{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0;margin:0;gap:8px}:host .tag-area:focus,wm-tag-input .tag-area:focus{outline:none}:host .tag-area [role=option],wm-tag-input .tag-area [role=option]{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;height:1.75rem;list-style:none;color:#4a4a4a;background-color:rgba(3, 0, 0, 0.1);padding:0.5rem 0.625rem;-webkit-transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);white-space:pre}:host .tag-area [role=option].highlight,wm-tag-input .tag-area [role=option].highlight{-webkit-animation:fadeIn 1s;animation:fadeIn 1s}@-webkit-keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}@keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}:host .tag-area [role=option].focused,wm-tag-input .tag-area [role=option].focused{background-color:#d1d1d1}:host .tag-area [role=option].locked,wm-tag-input .tag-area [role=option].locked{background-color:#6b6b6b;color:white}:host .tag-area [role=option] .icon,wm-tag-input .tag-area [role=option] .icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:1.25rem;width:1.25rem;padding:0;margin-left:0.5rem}:host .tag-area [role=option] .icon.remove-btn,wm-tag-input .tag-area [role=option] .icon.remove-btn{border:1px solid #575195;color:#575195;border-radius:50%;cursor:pointer;-webkit-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1)}:host .tag-area [role=option] .icon.remove-btn:hover,wm-tag-input .tag-area [role=option] .icon.remove-btn:hover{color:white;background-color:#575195}:host .tag-area [role=option] .icon.remove-btn:before,wm-tag-input .tag-area [role=option] .icon.remove-btn:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f156\"}:host .tag-area [role=option] .icon.lock,wm-tag-input .tag-area [role=option] .icon.lock{color:white}:host .tag-area [role=option] .icon.lock:before,wm-tag-input .tag-area [role=option] .icon.lock:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f341\"}:host .input,wm-tag-input .input{font-family:inherit;border:none;height:1.75rem;padding:0;margin:0;right:8px}:host .input.hidden,wm-tag-input .input.hidden{display:none}:host .input:focus,wm-tag-input .input:focus{outline:none}:host .tag-area+.input.extended,wm-tag-input .tag-area+.input.extended{-webkit-margin-before:8px;margin-block-start:8px}:host .dropdown-wrapper,wm-tag-input .dropdown-wrapper{margin:0;padding:0;-webkit-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-ms-transition:transform 0.25s ease;-webkit-transition:transform 0.25s ease;-moz-transition:transform 0.25s ease;-webkit-transition:-webkit-transform 0.25s ease;transition:-webkit-transform 0.25s ease;transition:transform 0.25s ease;transition:transform 0.25s ease, -webkit-transform 0.25s ease;-ms-transform:scale(1, 0);-webkit-transform:scale(1, 0);-moz-transform:scale(1, 0);transform:scale(1, 0);-ms-transform-origin:center top;-webkit-transform-origin:center top;-moz-transform-origin:center top;transform-origin:center top;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:absolute;top:calc(100% + 2px);right:0;background:#fff;z-index:100;width:100%;font-size:0.875rem}:host .dropdown-wrapper .dropdown,wm-tag-input .dropdown-wrapper .dropdown{-webkit-overflow-scrolling:touch;overflow:auto;max-height:12.5rem;margin:0;padding:0}:host .dropdown-wrapper.open,wm-tag-input .dropdown-wrapper.open{-ms-transform:scale(1, 1);-webkit-transform:scale(1, 1);-moz-transform:scale(1, 1);transform:scale(1, 1)}:host .dropdown-wrapper.upwards,wm-tag-input .dropdown-wrapper.upwards{top:unset;bottom:calc(100% + 2px);-ms-transform-origin:center bottom;-webkit-transform-origin:center bottom;-moz-transform-origin:center bottom;transform-origin:center bottom}:host .dropdown-wrapper li,:host .dropdown-wrapper div,wm-tag-input .dropdown-wrapper li,wm-tag-input .dropdown-wrapper div{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:0 1rem;background:#fff;list-style:none;min-height:2.6875rem;white-space:pre-wrap;overflow-wrap:anywhere}:host .dropdown-wrapper li[role=option],:host .dropdown-wrapper li.add-new-btn,:host .dropdown-wrapper div[role=option],:host .dropdown-wrapper div.add-new-btn,wm-tag-input .dropdown-wrapper li[role=option],wm-tag-input .dropdown-wrapper li.add-new-btn,wm-tag-input .dropdown-wrapper div[role=option],wm-tag-input .dropdown-wrapper div.add-new-btn{cursor:pointer;color:#575195;font-weight:bold;width:100%;border:none}:host .dropdown-wrapper li[role=option][aria-selected=true],:host .dropdown-wrapper li.add-new-btn[aria-selected=true],:host .dropdown-wrapper div[role=option][aria-selected=true],:host .dropdown-wrapper div.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper li[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper li.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper div[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper div.add-new-btn[aria-selected=true]{color:#6b6b6b;font-style:italic;font-weight:normal;cursor:unset}:host .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper li[role=option].focused,:host .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper li.add-new-btn.focused,:host .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper div[role=option].focused,:host .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper div.add-new-btn.focused,wm-tag-input .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li[role=option].focused,wm-tag-input .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li.add-new-btn.focused,wm-tag-input .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div[role=option].focused,wm-tag-input .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div.add-new-btn.focused{outline:none;background:#f4f4f4}:host .dropdown-wrapper li.help-text,:host .dropdown-wrapper div.help-text,wm-tag-input .dropdown-wrapper li.help-text,wm-tag-input .dropdown-wrapper div.help-text{color:#4a4a4a;height:auto;min-height:2.6875rem;padding-top:0.25rem;padding-bottom:0.25rem;white-space:normal}:host .dropdown-wrapper li:not(:last-child),:host .dropdown-wrapper div:not(:last-child),wm-tag-input .dropdown-wrapper li:not(:last-child),wm-tag-input .dropdown-wrapper div:not(:last-child){border-bottom:2px solid rgba(46, 27, 70, 0.05)}:host .info-text,wm-tag-input .info-text{font-style:italic;margin-top:0.25rem}:host .table-wrapper,wm-tag-input .table-wrapper{overflow:auto;margin-top:1.5rem}:host .table-wrapper #table,wm-tag-input .table-wrapper #table{width:100%;border-spacing:0px}:host .table-wrapper #table.fixed-widths,wm-tag-input .table-wrapper #table.fixed-widths{table-layout:fixed}:host .table-wrapper #table .headers,wm-tag-input .table-wrapper #table .headers{height:2.5rem;background-color:#eeedf4}:host .table-wrapper #table .headers th,wm-tag-input .table-wrapper #table .headers th{text-align:left;font-size:0.75rem;font-weight:700;text-transform:uppercase;padding:0 1.5rem}:host .table-wrapper tr:nth-child(even),wm-tag-input .table-wrapper tr:nth-child(even){background-color:#fafafa}:host .table-wrapper tr.selected,wm-tag-input .table-wrapper tr.selected{background-color:rgba(25, 161, 169, 0.2);-webkit-box-shadow:inset 0 0 0 1px #19a1a9;box-shadow:inset 0 0 0 1px #19a1a9;font-weight:500}:host .table-wrapper tr.focused:not(.locked),:host .table-wrapper tr:hover:not(.locked),wm-tag-input .table-wrapper tr.focused:not(.locked),wm-tag-input .table-wrapper tr:hover:not(.locked){background-color:#e9e7ec;-webkit-box-shadow:none;box-shadow:none}:host .table-wrapper tr.locked td,wm-tag-input .table-wrapper tr.locked td{cursor:auto}:host .table-wrapper tr.locked td:first-child .cell-content-wrapper:before,wm-tag-input .table-wrapper tr.locked td:first-child .cell-content-wrapper:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f33e\";margin-right:0.5rem;color:#4a4a4a}:host .table-wrapper td,wm-tag-input .table-wrapper td{height:3.75rem;vertical-align:middle;padding:0 1.5rem;cursor:pointer}:host .table-wrapper td.focused,wm-tag-input .table-wrapper td.focused{-webkit-box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e;box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e}:host .table-wrapper td .cell-content-wrapper.trunc,wm-tag-input .table-wrapper td .cell-content-wrapper.trunc{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .table-wrapper td .description,wm-tag-input .table-wrapper td .description{display:none}:host .no-results,wm-tag-input .no-results{padding:1.25rem 1.5rem}:host .sr-only,wm-tag-input .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host #error,wm-tag-input #error{display:block;font-style:italic;color:#c0392b;font-size:0.875rem;margin-top:0.25rem}";
|
|
6
6
|
|
|
7
|
-
const TagInput = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
registerInstance(this, hostRef);
|
|
10
|
-
this.wmTagInputChanged = createEvent(this, "wmTagInputChanged", 7);
|
|
11
|
-
this.uid = this.el.id ? this.el.id : generateId();
|
|
12
|
-
this.openUp = false;
|
|
13
|
-
this.debouncedUpdate = debounce(() => forceUpdate(this.el), 30);
|
|
14
|
-
this.label = undefined;
|
|
15
|
-
this.labelPosition = "top";
|
|
16
|
-
this.options = "";
|
|
17
|
-
this.selectedTags = "";
|
|
18
|
-
this.info = undefined;
|
|
19
|
-
this.errorMessage = undefined;
|
|
20
|
-
this.addNew = true;
|
|
21
|
-
this.placeholder = undefined;
|
|
22
|
-
this.requiredField = false;
|
|
23
|
-
this.characterLimit = 50;
|
|
24
|
-
this.maxTags = undefined;
|
|
25
|
-
this.tagInputType = "dropdown";
|
|
26
|
-
this.colHeaders = undefined;
|
|
27
|
-
this.colWidths = undefined;
|
|
28
|
-
this.colWrap = undefined;
|
|
29
|
-
this.messageConfig = "";
|
|
30
|
-
this.focusedListItem = undefined;
|
|
31
|
-
this.focusedTag = null;
|
|
32
|
-
this.tablePosition = { row: 0, column: 1 };
|
|
33
|
-
this.isExpanded = false;
|
|
34
|
-
this.tagsList = csvToArray(this.selectedTags);
|
|
35
|
-
this.optionsList = csvToArray(this.options);
|
|
36
|
-
this.charCount = 0;
|
|
37
|
-
this.liveRegionMessage = "";
|
|
38
|
-
}
|
|
39
|
-
get tooltipVisible() {
|
|
40
|
-
return document.getElementById("wm-tooltip").classList.contains("open");
|
|
41
|
-
}
|
|
42
|
-
get focusedElement() {
|
|
43
|
-
return this.el.shadowRoot.activeElement;
|
|
44
|
-
}
|
|
45
|
-
get listItemEls() {
|
|
46
|
-
return Array.from(this.dropdownEl.querySelectorAll("li"));
|
|
47
|
-
}
|
|
48
|
-
get tagEls() {
|
|
49
|
-
return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
|
|
50
|
-
}
|
|
51
|
-
get nonLockedTagEls() {
|
|
52
|
-
return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
|
|
53
|
-
}
|
|
54
|
-
get optionEls() {
|
|
55
|
-
return Array.from(this.dropdownEl.querySelectorAll(".option"));
|
|
56
|
-
}
|
|
57
|
-
get wmRowEls() {
|
|
58
|
-
return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
|
|
59
|
-
}
|
|
60
|
-
get localRowEls() {
|
|
61
|
-
return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
|
|
62
|
-
}
|
|
63
|
-
get filteredRows() {
|
|
64
|
-
return this.wmRowEls.filter((row) => {
|
|
65
|
-
const query = this.inputEl ? this.inputEl.value.toLowerCase() : "";
|
|
66
|
-
const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
|
|
67
|
-
return colValues.includes(query);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
get nonLockedTagsList() {
|
|
71
|
-
let list = [];
|
|
72
|
-
if (this.tagInputType === "table") {
|
|
73
|
-
this.tagsList.forEach((id) => {
|
|
74
|
-
const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
|
|
75
|
-
if (!correspondingRowEl.locked) {
|
|
76
|
-
list.push(id);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
else if (this.tagInputType === "dropdown") {
|
|
81
|
-
list = this.tagsList;
|
|
82
|
-
}
|
|
83
|
-
return list;
|
|
84
|
-
}
|
|
85
|
-
get tagLimitReached() {
|
|
86
|
-
return !!(this.maxTags && this.tagsList.length >= this.maxTags);
|
|
87
|
-
}
|
|
88
|
-
get noResultsMessage() {
|
|
89
|
-
return intl.formatMessage({
|
|
90
|
-
id: "tagInput.noResults",
|
|
91
|
-
defaultMessage: "No results match your search.",
|
|
92
|
-
description: "Message displayed when a user's search returns empty.",
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
get componentMessages() {
|
|
96
|
-
const addNewHelpText = intl.formatMessage({
|
|
97
|
-
id: "tagInput.addNewHelpText",
|
|
98
|
-
defaultMessage: "Press the Enter or Comma key to add a new tag.",
|
|
99
|
-
description: "Help text appearing in a dropdown. Use imperative",
|
|
100
|
-
});
|
|
101
|
-
const selectionHelpText = intl.formatMessage({
|
|
102
|
-
id: "tagInput.selectionHelpText",
|
|
103
|
-
defaultMessage: "Search and select a tag.",
|
|
104
|
-
description: "Help text appearing in a dropdown. Use imperative",
|
|
105
|
-
});
|
|
106
|
-
const maxTagsReachedMessage = intl.formatMessage({
|
|
107
|
-
id: "tagInput.maxTagsReached",
|
|
108
|
-
defaultMessage: "No more tags can be added because the limit has been reached.",
|
|
109
|
-
});
|
|
110
|
-
const tagAreaInstructions = intl.formatMessage({
|
|
111
|
-
id: "tagInput.tagAreaInstructions",
|
|
112
|
-
defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
|
|
113
|
-
});
|
|
114
|
-
const tagsAddedMessage = intl.formatMessage({
|
|
115
|
-
id: "tagInput.tagsAdded",
|
|
116
|
-
defaultMessage: "Tags added",
|
|
117
|
-
description: "For the user to understand how close they are to the tag limit, followed by x/y count",
|
|
118
|
-
});
|
|
119
|
-
const defaultConfig = {
|
|
120
|
-
addNewHelpText: addNewHelpText,
|
|
121
|
-
selectionHelpText: selectionHelpText,
|
|
122
|
-
maxTagsReached: maxTagsReachedMessage,
|
|
123
|
-
tagAreaInstructions: tagAreaInstructions,
|
|
124
|
-
tagsAdded: tagsAddedMessage,
|
|
125
|
-
};
|
|
126
|
-
const userProvidedConfig = safeParseJSON(this.messageConfig);
|
|
127
|
-
return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
|
|
128
|
-
}
|
|
129
|
-
get inputMinimumWidth() {
|
|
130
|
-
// 150px is the minimum width of the input field, or the length of the placeholder text
|
|
131
|
-
const inputElStyles = getComputedStyle(this.inputEl);
|
|
132
|
-
const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
|
|
133
|
-
const inputElBuffer = [
|
|
134
|
-
inputElStyles.paddingLeft,
|
|
135
|
-
inputElStyles.paddingRight,
|
|
136
|
-
inputElStyles.marginLeft,
|
|
137
|
-
inputElStyles.marginRight,
|
|
138
|
-
tagElStyles.marginRight,
|
|
139
|
-
].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
|
|
140
|
-
const minimumWidth = Math.max(150, measureText(this.inputEl, this.placeholder).width + inputElBuffer);
|
|
141
|
-
return minimumWidth;
|
|
142
|
-
}
|
|
143
|
-
generateTagAddedMessage(tag) {
|
|
144
|
-
return intl.formatMessage({
|
|
145
|
-
id: "tagInput.tagAdded",
|
|
146
|
-
defaultMessage: "{tagName} added.",
|
|
147
|
-
description: "A confirmation for adding a tag.",
|
|
148
|
-
}, { tagName: tag });
|
|
149
|
-
}
|
|
150
|
-
generateTagAlreadyAddedMessage(tag) {
|
|
151
|
-
return intl.formatMessage({
|
|
152
|
-
id: "tagInput.tagAlreadyAdded",
|
|
153
|
-
defaultMessage: "{tagName} has already been added.",
|
|
154
|
-
description: "An alert for adding a tag that is already present.",
|
|
155
|
-
}, { tagName: tag });
|
|
156
|
-
}
|
|
157
|
-
componentWillLoad() {
|
|
158
|
-
if (!this.placeholder) {
|
|
159
|
-
this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
|
|
160
|
-
}
|
|
161
|
-
if (!this.label) {
|
|
162
|
-
console.error("wm-tag-input must have a label property");
|
|
163
|
-
}
|
|
164
|
-
this.consolidateSelectedTags();
|
|
165
|
-
this.el.focus = () => {
|
|
166
|
-
const firstFocusableTag = this.nonLockedTagEls[0];
|
|
167
|
-
if (firstFocusableTag) {
|
|
168
|
-
this.tagAreaEl.focus();
|
|
169
|
-
this.focusTag(firstFocusableTag);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
this.inputEl.focus();
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
// on resize of component, trigger componentDidRender -> positionInput
|
|
176
|
-
const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
|
|
177
|
-
resizeObserver.observe(this.el);
|
|
178
|
-
}
|
|
179
|
-
componentDidLoad() {
|
|
180
|
-
// prevent highlighting of pre-selected tags
|
|
181
|
-
this.tagEls.forEach((el) => el.classList.remove("highlight"));
|
|
182
|
-
}
|
|
183
|
-
componentDidRender() {
|
|
184
|
-
this.positionInput();
|
|
185
|
-
// check each tag if truncation is needed
|
|
186
|
-
this.tagEls.forEach((tag) => {
|
|
187
|
-
const textEl = tag.querySelector(".tag-text");
|
|
188
|
-
const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
|
|
189
|
-
const leftBound = textEl.getBoundingClientRect().left;
|
|
190
|
-
// the numbers represent spacing values for padding, margin, and delete icon
|
|
191
|
-
const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
|
|
192
|
-
let displayText = tag.dataset.tag;
|
|
193
|
-
if (this.tagInputType === "table") {
|
|
194
|
-
// table variant doesn't display the tag id, but the contents of the first column
|
|
195
|
-
const referencedRow = this.el.querySelector(`#${displayText}`);
|
|
196
|
-
displayText = referencedRow ? referencedRow.col1 : "";
|
|
197
|
-
}
|
|
198
|
-
textEl.textContent = truncateText(textEl, displayText, rightBound - leftBound, 5);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
consolidateSelectedTags() {
|
|
202
|
-
this.tagsList.forEach((tag) => {
|
|
203
|
-
if (!this.includesCaseInsensitive(this.optionsList, tag)) {
|
|
204
|
-
this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
this.optionsList = csvToArray(this.options);
|
|
208
|
-
}
|
|
209
|
-
createPlaceholderDefault(addNew, hasOptions) {
|
|
210
|
-
const addAndSearchPlaceholder = intl.formatMessage({
|
|
211
|
-
id: "tagInput.placeholderAddAndSearch",
|
|
212
|
-
defaultMessage: "Add or search for a tag",
|
|
213
|
-
description: "Placeholder text. Use imperative",
|
|
214
|
-
});
|
|
215
|
-
const searchPlaceholder = intl.formatMessage({
|
|
216
|
-
id: "tagInput.placeholderSearch",
|
|
217
|
-
defaultMessage: "Search and select a tag",
|
|
218
|
-
description: "Placeholder text. Use imperative",
|
|
219
|
-
});
|
|
220
|
-
const addPlaceholder = intl.formatMessage({
|
|
221
|
-
id: "tagInput.placeholderAdd",
|
|
222
|
-
defaultMessage: "Add a new tag",
|
|
223
|
-
description: "Placeholder text. Use imperative",
|
|
224
|
-
});
|
|
225
|
-
let placeholder = "";
|
|
226
|
-
if (addNew && hasOptions) {
|
|
227
|
-
placeholder = addAndSearchPlaceholder;
|
|
228
|
-
}
|
|
229
|
-
else if (!addNew && hasOptions) {
|
|
230
|
-
placeholder = searchPlaceholder;
|
|
231
|
-
}
|
|
232
|
-
else if (addNew) {
|
|
233
|
-
placeholder = addPlaceholder;
|
|
234
|
-
}
|
|
235
|
-
return placeholder;
|
|
236
|
-
}
|
|
237
|
-
reflectSelectedTags(newValue, oldValue) {
|
|
238
|
-
const isAddition = newValue.length > oldValue.length;
|
|
239
|
-
let changedTag = "";
|
|
240
|
-
let selectedTags = this.tagsList;
|
|
241
|
-
if (isAddition) {
|
|
242
|
-
changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
|
|
246
|
-
}
|
|
247
|
-
// event emitted by type table uses element references instead of strings
|
|
248
|
-
if (this.tagInputType === "table") {
|
|
249
|
-
changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
|
|
250
|
-
selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
|
|
251
|
-
}
|
|
252
|
-
this.selectedTags = this.listToCSV(this.tagsList);
|
|
253
|
-
let detail = { value: selectedTags, tagChanged: changedTag };
|
|
254
|
-
this.wmTagInputChanged.emit(detail);
|
|
255
|
-
}
|
|
256
|
-
handleErrorMessageChange() {
|
|
257
|
-
if (this.errorMessage) {
|
|
258
|
-
this.announce(this.errorMessage);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
handleRowUpdate() {
|
|
262
|
-
forceUpdate(this.el);
|
|
263
|
-
}
|
|
264
|
-
closeIfNotElOrChild(ev) {
|
|
265
|
-
const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
|
|
266
|
-
if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
|
|
267
|
-
this.closeDropdown();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
// From wm-button
|
|
271
|
-
// we need to listen for scroll events during the capture phase because they do not bubble up
|
|
272
|
-
// there can be layouts where the main content has 100vh and overflows
|
|
273
|
-
// in these cases window will register no scroll events unless we catch on they way down
|
|
274
|
-
dismissTooltip() {
|
|
275
|
-
if (this.tooltipVisible) {
|
|
276
|
-
hideTooltip();
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
handleInputKeyDown(ev) {
|
|
280
|
-
if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
|
|
281
|
-
this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
|
|
282
|
-
}
|
|
283
|
-
// prevent keydown triggering on tag area
|
|
284
|
-
ev.stopPropagation();
|
|
285
|
-
switch (ev.key) {
|
|
286
|
-
case "Enter":
|
|
287
|
-
case ",":
|
|
288
|
-
ev.preventDefault();
|
|
289
|
-
this.handleInputEnter();
|
|
290
|
-
break;
|
|
291
|
-
case "ArrowDown":
|
|
292
|
-
ev.preventDefault();
|
|
293
|
-
this.handleInputArrowDown();
|
|
294
|
-
break;
|
|
295
|
-
case "ArrowUp":
|
|
296
|
-
ev.preventDefault();
|
|
297
|
-
this.handleInputArrowUp();
|
|
298
|
-
break;
|
|
299
|
-
case "ArrowLeft":
|
|
300
|
-
if (this.tagInputType === "table" && this.tablePosition.row) {
|
|
301
|
-
ev.preventDefault();
|
|
302
|
-
this.moveLeftCell();
|
|
303
|
-
}
|
|
304
|
-
break;
|
|
305
|
-
case "ArrowRight":
|
|
306
|
-
if (this.tagInputType === "table" && this.tablePosition.row) {
|
|
307
|
-
ev.preventDefault();
|
|
308
|
-
this.moveRightCell();
|
|
309
|
-
}
|
|
310
|
-
break;
|
|
311
|
-
case "Escape":
|
|
312
|
-
if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
313
|
-
this.closeDropdown();
|
|
314
|
-
}
|
|
315
|
-
break;
|
|
316
|
-
case "ArrowLeft":
|
|
317
|
-
case "Backspace":
|
|
318
|
-
this.handleInputBackspace();
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
handleInputFocus() {
|
|
323
|
-
if (this.tagInputType === "dropdown") {
|
|
324
|
-
this.openDropdown();
|
|
325
|
-
this.clearListItemFocus();
|
|
326
|
-
}
|
|
327
|
-
// force update needed to apply styled state of field-wrapper el
|
|
328
|
-
forceUpdate(this.el);
|
|
329
|
-
}
|
|
330
|
-
handleInputChanged(value) {
|
|
331
|
-
this.charCount = value.length;
|
|
332
|
-
if (this.tagInputType === "dropdown") {
|
|
333
|
-
this.clearListItemFocus();
|
|
334
|
-
if (this.charCount >= this.characterLimit - 5) {
|
|
335
|
-
this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
|
|
336
|
-
}
|
|
337
|
-
if (!this.isExpanded) {
|
|
338
|
-
this.openDropdown();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
else if (this.tagInputType === "table") {
|
|
342
|
-
this.clearCellFocus();
|
|
343
|
-
}
|
|
344
|
-
this.announceExistingOptions();
|
|
345
|
-
}
|
|
346
|
-
handleInputEnter() {
|
|
347
|
-
if (this.tagInputType === "dropdown") {
|
|
348
|
-
if (this.focusedListItem) {
|
|
349
|
-
this.handleListItemClick(this.focusedListItem);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
this.submitInput(this.addNew, this.inputEl.value.trim());
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
|
|
356
|
-
this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
submitInput(canAddNew, value) {
|
|
360
|
-
const hasNonWhiteSpaceCharacters = value.match(/\S/);
|
|
361
|
-
if (canAddNew && hasNonWhiteSpaceCharacters) {
|
|
362
|
-
this.addTag(value);
|
|
363
|
-
this.optionsList = this.addOption(value);
|
|
364
|
-
this.resetInput();
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
handleInputArrowDown() {
|
|
368
|
-
if (this.tagInputType === "table") {
|
|
369
|
-
this.moveDownRow();
|
|
370
|
-
}
|
|
371
|
-
else if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
372
|
-
this.moveDownListItem();
|
|
373
|
-
}
|
|
374
|
-
else if (this.tagInputType === "dropdown") {
|
|
375
|
-
this.openDropdown();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
handleInputArrowUp() {
|
|
379
|
-
if (this.tagInputType === "table") {
|
|
380
|
-
this.moveUpRow();
|
|
381
|
-
}
|
|
382
|
-
else if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
383
|
-
this.moveUpListItem();
|
|
384
|
-
}
|
|
385
|
-
else if (this.tagInputType === "dropdown") {
|
|
386
|
-
this.openDropdown();
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
handleInputBackspace() {
|
|
390
|
-
if (this.inputEl.value === "" && this.tagsList.length > 0) {
|
|
391
|
-
// wait for events to finish firing before redirecting focus
|
|
392
|
-
// prevents double input in input area and tag area
|
|
393
|
-
window.requestAnimationFrame(() => {
|
|
394
|
-
if (this.nonLockedTagsList.length > 0) {
|
|
395
|
-
this.tagAreaEl.focus();
|
|
396
|
-
this.focusTag(this.tagEls[this.tagEls.length - 1]);
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
handleListItemKeyDown(ev) {
|
|
402
|
-
const typedEvTarget = ev.target;
|
|
403
|
-
switch (ev.key) {
|
|
404
|
-
case "Enter":
|
|
405
|
-
case " ":
|
|
406
|
-
ev.preventDefault();
|
|
407
|
-
typedEvTarget.click();
|
|
408
|
-
break;
|
|
409
|
-
case "ArrowDown":
|
|
410
|
-
ev.preventDefault();
|
|
411
|
-
this.moveDownListItem();
|
|
412
|
-
break;
|
|
413
|
-
case "ArrowUp":
|
|
414
|
-
ev.preventDefault();
|
|
415
|
-
this.moveUpListItem();
|
|
416
|
-
break;
|
|
417
|
-
case "Escape":
|
|
418
|
-
if (this.focusedElement !== this.inputEl) {
|
|
419
|
-
this.inputEl.focus();
|
|
420
|
-
}
|
|
421
|
-
else if (this.tagInputType === "dropdown") {
|
|
422
|
-
this.closeDropdown();
|
|
423
|
-
}
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
handleListItemClick(item) {
|
|
428
|
-
const tag = item.dataset.option.trim() || "";
|
|
429
|
-
if (this.includesCaseInsensitive(this.tagsList, tag)) {
|
|
430
|
-
this.announce(this.generateTagAlreadyAddedMessage(tag));
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
this.resetInput();
|
|
434
|
-
this.addTag(tag);
|
|
435
|
-
this.optionsList = this.addOption(tag);
|
|
436
|
-
this.focusedListItem = null;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
handleTableRowClick(rowId) {
|
|
440
|
-
const referencedRow = this.el.querySelector(`#${rowId}`);
|
|
441
|
-
const isLocked = referencedRow.locked;
|
|
442
|
-
if (!isLocked) {
|
|
443
|
-
if (this.includesCaseInsensitive(this.tagsList, rowId)) {
|
|
444
|
-
this.removeTag(rowId);
|
|
445
|
-
}
|
|
446
|
-
else if (!this.tagLimitReached) {
|
|
447
|
-
this.addTag(rowId);
|
|
448
|
-
this.resetInput();
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
handleTagAreaKeyDown(ev) {
|
|
453
|
-
switch (ev.key) {
|
|
454
|
-
case "ArrowLeft":
|
|
455
|
-
case "ArrowUp":
|
|
456
|
-
ev.preventDefault();
|
|
457
|
-
this.moveLeftTag();
|
|
458
|
-
break;
|
|
459
|
-
case "ArrowRight":
|
|
460
|
-
case "ArrowDown":
|
|
461
|
-
ev.preventDefault();
|
|
462
|
-
this.moveRightTag();
|
|
463
|
-
break;
|
|
464
|
-
case "Backspace":
|
|
465
|
-
case "Delete":
|
|
466
|
-
this.handleTagAreaDelete();
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
handleTagAreaDelete() {
|
|
471
|
-
const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
|
|
472
|
-
if (this.focusedTag && !isLocked) {
|
|
473
|
-
this.removeTag(this.focusedTag.dataset.tag);
|
|
474
|
-
if (this.nonLockedTagsList.length === 0) {
|
|
475
|
-
// focus input if no tags are left
|
|
476
|
-
this.inputEl.focus();
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
|
|
480
|
-
// if removing the last tag, reassign focused tag to previous task
|
|
481
|
-
this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
|
|
482
|
-
this.focusTag(this.focusedTag);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
handleBlur(ev, component) {
|
|
487
|
-
const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
|
|
488
|
-
this.dismissTooltip();
|
|
489
|
-
this.clearCellFocus();
|
|
490
|
-
if (isntElOrChild) {
|
|
491
|
-
this.fieldWrapperEl.classList.remove("focused");
|
|
492
|
-
if (this.tagInputType === "dropdown") {
|
|
493
|
-
this.closeDropdown();
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
handleCellMouseEnter(ev) {
|
|
498
|
-
const cell = ev.target;
|
|
499
|
-
const contentWrapper = cell.querySelector(".cell-content-wrapper");
|
|
500
|
-
const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
|
|
501
|
-
if (isTruncated) {
|
|
502
|
-
// innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
|
|
503
|
-
showTooltip("bottom", cell, cell.innerText);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
handleTagAreaFocus() {
|
|
507
|
-
if (this.tagInputType === "dropdown") {
|
|
508
|
-
this.closeDropdown();
|
|
509
|
-
}
|
|
510
|
-
const firstFocusableTag = this.nonLockedTagEls[0];
|
|
511
|
-
firstFocusableTag && this.focusTag(firstFocusableTag);
|
|
512
|
-
}
|
|
513
|
-
handleRemoveButtonClick(tag) {
|
|
514
|
-
this.moveLeftTag();
|
|
515
|
-
this.removeTag(tag);
|
|
516
|
-
}
|
|
517
|
-
moveDownListItem() {
|
|
518
|
-
if (this.listItemEls.length > 0) {
|
|
519
|
-
const firstListItem = this.listItemEls[0];
|
|
520
|
-
if (!this.focusedListItem) {
|
|
521
|
-
this.focusListItem(firstListItem);
|
|
522
|
-
}
|
|
523
|
-
else if (this.focusedListItem.nextElementSibling) {
|
|
524
|
-
this.focusListItem(this.focusedListItem.nextElementSibling);
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
this.focusListItem(firstListItem);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
moveUpListItem() {
|
|
532
|
-
if (this.listItemEls.length > 0) {
|
|
533
|
-
const lastListItem = this.listItemEls[this.listItemEls.length - 1];
|
|
534
|
-
if (!this.focusedListItem) {
|
|
535
|
-
this.focusListItem(lastListItem);
|
|
536
|
-
}
|
|
537
|
-
else if (this.focusedListItem.previousElementSibling) {
|
|
538
|
-
this.focusListItem(this.focusedListItem.previousElementSibling);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
this.clearListItemFocus();
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
moveDownRow() {
|
|
546
|
-
if (this.filteredRows.length > 0) {
|
|
547
|
-
if (this.tablePosition.row === 0) {
|
|
548
|
-
this.tablePosition.row = 1;
|
|
549
|
-
}
|
|
550
|
-
else if (this.tablePosition.row === this.filteredRows.length) {
|
|
551
|
-
this.tablePosition.row = 1;
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
this.tablePosition.row++;
|
|
555
|
-
}
|
|
556
|
-
// skip locked rows
|
|
557
|
-
const rowToFocus = this.filteredRows[this.tablePosition.row - 1];
|
|
558
|
-
if (rowToFocus.locked) {
|
|
559
|
-
this.moveDownRow();
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
this.focusCell(this.tablePosition);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
moveUpRow() {
|
|
567
|
-
if (this.filteredRows.length > 0) {
|
|
568
|
-
if (this.tablePosition.row === 0) {
|
|
569
|
-
this.tablePosition.row = this.filteredRows.length;
|
|
570
|
-
}
|
|
571
|
-
else if (this.tablePosition.row === 1) {
|
|
572
|
-
this.tablePosition.row = 0;
|
|
573
|
-
}
|
|
574
|
-
else {
|
|
575
|
-
this.tablePosition.row--;
|
|
576
|
-
}
|
|
577
|
-
// skip locked rows
|
|
578
|
-
const rowToFocus = this.filteredRows[this.tablePosition.row - 1];
|
|
579
|
-
if (rowToFocus && rowToFocus.locked) {
|
|
580
|
-
this.moveUpRow();
|
|
581
|
-
}
|
|
582
|
-
else if (rowToFocus) {
|
|
583
|
-
this.focusCell(this.tablePosition);
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
this.clearCellFocus();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
moveLeftCell() {
|
|
591
|
-
if (this.tablePosition.column != 1) {
|
|
592
|
-
this.tablePosition.column--;
|
|
593
|
-
this.focusCell(this.tablePosition);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
moveRightCell() {
|
|
597
|
-
const numCols = csvToArray(this.colHeaders).length;
|
|
598
|
-
if (this.tablePosition.column < numCols) {
|
|
599
|
-
this.tablePosition.column++;
|
|
600
|
-
this.focusCell(this.tablePosition);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
moveLeftTag() {
|
|
604
|
-
const lastTag = this.tagEls[this.tagEls.length - 1];
|
|
605
|
-
if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
|
|
606
|
-
this.focusedTag = this.focusedTag.previousElementSibling;
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
this.focusedTag = lastTag;
|
|
610
|
-
}
|
|
611
|
-
// skip locked tags
|
|
612
|
-
if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
|
|
613
|
-
this.moveLeftTag();
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
this.focusTag(this.focusedTag);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
moveRightTag() {
|
|
620
|
-
const firstTag = this.tagEls[0];
|
|
621
|
-
if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
|
|
622
|
-
this.focusedTag = this.focusedTag.nextElementSibling;
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
|
-
this.focusedTag = firstTag;
|
|
626
|
-
}
|
|
627
|
-
// skip locked tags
|
|
628
|
-
if (this.focusedTag.classList.contains("locked")) {
|
|
629
|
-
this.moveRightTag();
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
this.focusTag(this.focusedTag);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
addOption(option) {
|
|
636
|
-
let newOptionsList = this.optionsList;
|
|
637
|
-
const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
|
|
638
|
-
if (!optionAlreadyExists) {
|
|
639
|
-
newOptionsList = newOptionsList.concat(option);
|
|
640
|
-
}
|
|
641
|
-
return newOptionsList;
|
|
642
|
-
}
|
|
643
|
-
removeOption(option) {
|
|
644
|
-
this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
|
|
645
|
-
}
|
|
646
|
-
addTag(tag) {
|
|
647
|
-
let newTagsList = this.tagsList;
|
|
648
|
-
const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
|
|
649
|
-
const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
|
|
650
|
-
if (!tagAlreadyAdded) {
|
|
651
|
-
let textToAnnounce = tag;
|
|
652
|
-
if (this.tagInputType === "table") {
|
|
653
|
-
const referencedRow = this.el.querySelector(`#${tag}`);
|
|
654
|
-
textToAnnounce = referencedRow.col1;
|
|
655
|
-
}
|
|
656
|
-
this.announce(this.generateTagAddedMessage(textToAnnounce));
|
|
657
|
-
this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
|
|
658
|
-
// if maxTags has been reached, focus should go to the tagArea
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
this.
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
this.
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
this.
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
this.
|
|
756
|
-
this.
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
return list.
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
this.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
7
|
+
const TagInput = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.wmTagInputChanged = createEvent(this, "wmTagInputChanged", 7);
|
|
11
|
+
this.uid = this.el.id ? this.el.id : generateId();
|
|
12
|
+
this.openUp = false;
|
|
13
|
+
this.debouncedUpdate = debounce(() => forceUpdate(this.el), 30);
|
|
14
|
+
this.label = undefined;
|
|
15
|
+
this.labelPosition = "top";
|
|
16
|
+
this.options = "";
|
|
17
|
+
this.selectedTags = "";
|
|
18
|
+
this.info = undefined;
|
|
19
|
+
this.errorMessage = undefined;
|
|
20
|
+
this.addNew = true;
|
|
21
|
+
this.placeholder = undefined;
|
|
22
|
+
this.requiredField = false;
|
|
23
|
+
this.characterLimit = 50;
|
|
24
|
+
this.maxTags = undefined;
|
|
25
|
+
this.tagInputType = "dropdown";
|
|
26
|
+
this.colHeaders = undefined;
|
|
27
|
+
this.colWidths = undefined;
|
|
28
|
+
this.colWrap = undefined;
|
|
29
|
+
this.messageConfig = "";
|
|
30
|
+
this.focusedListItem = undefined;
|
|
31
|
+
this.focusedTag = null;
|
|
32
|
+
this.tablePosition = { row: 0, column: 1 };
|
|
33
|
+
this.isExpanded = false;
|
|
34
|
+
this.tagsList = csvToArray(this.selectedTags);
|
|
35
|
+
this.optionsList = csvToArray(this.options);
|
|
36
|
+
this.charCount = 0;
|
|
37
|
+
this.liveRegionMessage = "";
|
|
38
|
+
}
|
|
39
|
+
get tooltipVisible() {
|
|
40
|
+
return document.getElementById("wm-tooltip").classList.contains("open");
|
|
41
|
+
}
|
|
42
|
+
get focusedElement() {
|
|
43
|
+
return this.el.shadowRoot.activeElement;
|
|
44
|
+
}
|
|
45
|
+
get listItemEls() {
|
|
46
|
+
return Array.from(this.dropdownEl.querySelectorAll("li"));
|
|
47
|
+
}
|
|
48
|
+
get tagEls() {
|
|
49
|
+
return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
|
|
50
|
+
}
|
|
51
|
+
get nonLockedTagEls() {
|
|
52
|
+
return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
|
|
53
|
+
}
|
|
54
|
+
get optionEls() {
|
|
55
|
+
return Array.from(this.dropdownEl.querySelectorAll(".option"));
|
|
56
|
+
}
|
|
57
|
+
get wmRowEls() {
|
|
58
|
+
return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
|
|
59
|
+
}
|
|
60
|
+
get localRowEls() {
|
|
61
|
+
return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
|
|
62
|
+
}
|
|
63
|
+
get filteredRows() {
|
|
64
|
+
return this.wmRowEls.filter((row) => {
|
|
65
|
+
const query = this.inputEl ? this.inputEl.value.toLowerCase() : "";
|
|
66
|
+
const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
|
|
67
|
+
return colValues.includes(query);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
get nonLockedTagsList() {
|
|
71
|
+
let list = [];
|
|
72
|
+
if (this.tagInputType === "table") {
|
|
73
|
+
this.tagsList.forEach((id) => {
|
|
74
|
+
const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
|
|
75
|
+
if (!correspondingRowEl.locked) {
|
|
76
|
+
list.push(id);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (this.tagInputType === "dropdown") {
|
|
81
|
+
list = this.tagsList;
|
|
82
|
+
}
|
|
83
|
+
return list;
|
|
84
|
+
}
|
|
85
|
+
get tagLimitReached() {
|
|
86
|
+
return !!(this.maxTags && this.tagsList.length >= this.maxTags);
|
|
87
|
+
}
|
|
88
|
+
get noResultsMessage() {
|
|
89
|
+
return intl.formatMessage({
|
|
90
|
+
id: "tagInput.noResults",
|
|
91
|
+
defaultMessage: "No results match your search.",
|
|
92
|
+
description: "Message displayed when a user's search returns empty.",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
get componentMessages() {
|
|
96
|
+
const addNewHelpText = intl.formatMessage({
|
|
97
|
+
id: "tagInput.addNewHelpText",
|
|
98
|
+
defaultMessage: "Press the Enter or Comma key to add a new tag.",
|
|
99
|
+
description: "Help text appearing in a dropdown. Use imperative",
|
|
100
|
+
});
|
|
101
|
+
const selectionHelpText = intl.formatMessage({
|
|
102
|
+
id: "tagInput.selectionHelpText",
|
|
103
|
+
defaultMessage: "Search and select a tag.",
|
|
104
|
+
description: "Help text appearing in a dropdown. Use imperative",
|
|
105
|
+
});
|
|
106
|
+
const maxTagsReachedMessage = intl.formatMessage({
|
|
107
|
+
id: "tagInput.maxTagsReached",
|
|
108
|
+
defaultMessage: "No more tags can be added because the limit has been reached.",
|
|
109
|
+
});
|
|
110
|
+
const tagAreaInstructions = intl.formatMessage({
|
|
111
|
+
id: "tagInput.tagAreaInstructions",
|
|
112
|
+
defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
|
|
113
|
+
});
|
|
114
|
+
const tagsAddedMessage = intl.formatMessage({
|
|
115
|
+
id: "tagInput.tagsAdded",
|
|
116
|
+
defaultMessage: "Tags added",
|
|
117
|
+
description: "For the user to understand how close they are to the tag limit, followed by x/y count",
|
|
118
|
+
});
|
|
119
|
+
const defaultConfig = {
|
|
120
|
+
addNewHelpText: addNewHelpText,
|
|
121
|
+
selectionHelpText: selectionHelpText,
|
|
122
|
+
maxTagsReached: maxTagsReachedMessage,
|
|
123
|
+
tagAreaInstructions: tagAreaInstructions,
|
|
124
|
+
tagsAdded: tagsAddedMessage,
|
|
125
|
+
};
|
|
126
|
+
const userProvidedConfig = safeParseJSON(this.messageConfig);
|
|
127
|
+
return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
|
|
128
|
+
}
|
|
129
|
+
get inputMinimumWidth() {
|
|
130
|
+
// 150px is the minimum width of the input field, or the length of the placeholder text
|
|
131
|
+
const inputElStyles = getComputedStyle(this.inputEl);
|
|
132
|
+
const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
|
|
133
|
+
const inputElBuffer = [
|
|
134
|
+
inputElStyles.paddingLeft,
|
|
135
|
+
inputElStyles.paddingRight,
|
|
136
|
+
inputElStyles.marginLeft,
|
|
137
|
+
inputElStyles.marginRight,
|
|
138
|
+
tagElStyles.marginRight,
|
|
139
|
+
].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
|
|
140
|
+
const minimumWidth = Math.max(150, measureText(this.inputEl, this.placeholder).width + inputElBuffer);
|
|
141
|
+
return minimumWidth;
|
|
142
|
+
}
|
|
143
|
+
generateTagAddedMessage(tag) {
|
|
144
|
+
return intl.formatMessage({
|
|
145
|
+
id: "tagInput.tagAdded",
|
|
146
|
+
defaultMessage: "{tagName} added.",
|
|
147
|
+
description: "A confirmation for adding a tag.",
|
|
148
|
+
}, { tagName: tag });
|
|
149
|
+
}
|
|
150
|
+
generateTagAlreadyAddedMessage(tag) {
|
|
151
|
+
return intl.formatMessage({
|
|
152
|
+
id: "tagInput.tagAlreadyAdded",
|
|
153
|
+
defaultMessage: "{tagName} has already been added.",
|
|
154
|
+
description: "An alert for adding a tag that is already present.",
|
|
155
|
+
}, { tagName: tag });
|
|
156
|
+
}
|
|
157
|
+
componentWillLoad() {
|
|
158
|
+
if (!this.placeholder) {
|
|
159
|
+
this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
|
|
160
|
+
}
|
|
161
|
+
if (!this.label) {
|
|
162
|
+
console.error("wm-tag-input must have a label property");
|
|
163
|
+
}
|
|
164
|
+
this.consolidateSelectedTags();
|
|
165
|
+
this.el.focus = () => {
|
|
166
|
+
const firstFocusableTag = this.nonLockedTagEls[0];
|
|
167
|
+
if (firstFocusableTag) {
|
|
168
|
+
this.tagAreaEl.focus();
|
|
169
|
+
this.focusTag(firstFocusableTag);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.inputEl.focus();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
// on resize of component, trigger componentDidRender -> positionInput
|
|
176
|
+
const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
|
|
177
|
+
resizeObserver.observe(this.el);
|
|
178
|
+
}
|
|
179
|
+
componentDidLoad() {
|
|
180
|
+
// prevent highlighting of pre-selected tags
|
|
181
|
+
this.tagEls.forEach((el) => el.classList.remove("highlight"));
|
|
182
|
+
}
|
|
183
|
+
componentDidRender() {
|
|
184
|
+
this.positionInput();
|
|
185
|
+
// check each tag if truncation is needed
|
|
186
|
+
this.tagEls.forEach((tag) => {
|
|
187
|
+
const textEl = tag.querySelector(".tag-text");
|
|
188
|
+
const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
|
|
189
|
+
const leftBound = textEl.getBoundingClientRect().left;
|
|
190
|
+
// the numbers represent spacing values for padding, margin, and delete icon
|
|
191
|
+
const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
|
|
192
|
+
let displayText = tag.dataset.tag;
|
|
193
|
+
if (this.tagInputType === "table") {
|
|
194
|
+
// table variant doesn't display the tag id, but the contents of the first column
|
|
195
|
+
const referencedRow = this.el.querySelector(`#${displayText}`);
|
|
196
|
+
displayText = referencedRow ? referencedRow.col1 : "";
|
|
197
|
+
}
|
|
198
|
+
textEl.textContent = truncateText(textEl, displayText, rightBound - leftBound, 5);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
consolidateSelectedTags() {
|
|
202
|
+
this.tagsList.forEach((tag) => {
|
|
203
|
+
if (!this.includesCaseInsensitive(this.optionsList, tag)) {
|
|
204
|
+
this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
this.optionsList = csvToArray(this.options);
|
|
208
|
+
}
|
|
209
|
+
createPlaceholderDefault(addNew, hasOptions) {
|
|
210
|
+
const addAndSearchPlaceholder = intl.formatMessage({
|
|
211
|
+
id: "tagInput.placeholderAddAndSearch",
|
|
212
|
+
defaultMessage: "Add or search for a tag",
|
|
213
|
+
description: "Placeholder text. Use imperative",
|
|
214
|
+
});
|
|
215
|
+
const searchPlaceholder = intl.formatMessage({
|
|
216
|
+
id: "tagInput.placeholderSearch",
|
|
217
|
+
defaultMessage: "Search and select a tag",
|
|
218
|
+
description: "Placeholder text. Use imperative",
|
|
219
|
+
});
|
|
220
|
+
const addPlaceholder = intl.formatMessage({
|
|
221
|
+
id: "tagInput.placeholderAdd",
|
|
222
|
+
defaultMessage: "Add a new tag",
|
|
223
|
+
description: "Placeholder text. Use imperative",
|
|
224
|
+
});
|
|
225
|
+
let placeholder = "";
|
|
226
|
+
if (addNew && hasOptions) {
|
|
227
|
+
placeholder = addAndSearchPlaceholder;
|
|
228
|
+
}
|
|
229
|
+
else if (!addNew && hasOptions) {
|
|
230
|
+
placeholder = searchPlaceholder;
|
|
231
|
+
}
|
|
232
|
+
else if (addNew) {
|
|
233
|
+
placeholder = addPlaceholder;
|
|
234
|
+
}
|
|
235
|
+
return placeholder;
|
|
236
|
+
}
|
|
237
|
+
reflectSelectedTags(newValue, oldValue) {
|
|
238
|
+
const isAddition = newValue.length > oldValue.length;
|
|
239
|
+
let changedTag = "";
|
|
240
|
+
let selectedTags = this.tagsList;
|
|
241
|
+
if (isAddition) {
|
|
242
|
+
changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
|
|
246
|
+
}
|
|
247
|
+
// event emitted by type table uses element references instead of strings
|
|
248
|
+
if (this.tagInputType === "table") {
|
|
249
|
+
changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
|
|
250
|
+
selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
|
|
251
|
+
}
|
|
252
|
+
this.selectedTags = this.listToCSV(this.tagsList);
|
|
253
|
+
let detail = { value: selectedTags, tagChanged: changedTag };
|
|
254
|
+
this.wmTagInputChanged.emit(detail);
|
|
255
|
+
}
|
|
256
|
+
handleErrorMessageChange() {
|
|
257
|
+
if (this.errorMessage) {
|
|
258
|
+
this.announce(this.errorMessage);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
handleRowUpdate() {
|
|
262
|
+
forceUpdate(this.el);
|
|
263
|
+
}
|
|
264
|
+
closeIfNotElOrChild(ev) {
|
|
265
|
+
const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
|
|
266
|
+
if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
|
|
267
|
+
this.closeDropdown();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// From wm-button
|
|
271
|
+
// we need to listen for scroll events during the capture phase because they do not bubble up
|
|
272
|
+
// there can be layouts where the main content has 100vh and overflows
|
|
273
|
+
// in these cases window will register no scroll events unless we catch on they way down
|
|
274
|
+
dismissTooltip() {
|
|
275
|
+
if (this.tooltipVisible) {
|
|
276
|
+
hideTooltip();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
handleInputKeyDown(ev) {
|
|
280
|
+
if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
|
|
281
|
+
this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
|
|
282
|
+
}
|
|
283
|
+
// prevent keydown triggering on tag area
|
|
284
|
+
ev.stopPropagation();
|
|
285
|
+
switch (ev.key) {
|
|
286
|
+
case "Enter":
|
|
287
|
+
case ",":
|
|
288
|
+
ev.preventDefault();
|
|
289
|
+
this.handleInputEnter();
|
|
290
|
+
break;
|
|
291
|
+
case "ArrowDown":
|
|
292
|
+
ev.preventDefault();
|
|
293
|
+
this.handleInputArrowDown();
|
|
294
|
+
break;
|
|
295
|
+
case "ArrowUp":
|
|
296
|
+
ev.preventDefault();
|
|
297
|
+
this.handleInputArrowUp();
|
|
298
|
+
break;
|
|
299
|
+
case "ArrowLeft":
|
|
300
|
+
if (this.tagInputType === "table" && this.tablePosition.row) {
|
|
301
|
+
ev.preventDefault();
|
|
302
|
+
this.moveLeftCell();
|
|
303
|
+
}
|
|
304
|
+
break;
|
|
305
|
+
case "ArrowRight":
|
|
306
|
+
if (this.tagInputType === "table" && this.tablePosition.row) {
|
|
307
|
+
ev.preventDefault();
|
|
308
|
+
this.moveRightCell();
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
case "Escape":
|
|
312
|
+
if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
313
|
+
this.closeDropdown();
|
|
314
|
+
}
|
|
315
|
+
break;
|
|
316
|
+
case "ArrowLeft":
|
|
317
|
+
case "Backspace":
|
|
318
|
+
this.handleInputBackspace();
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
handleInputFocus() {
|
|
323
|
+
if (this.tagInputType === "dropdown") {
|
|
324
|
+
this.openDropdown();
|
|
325
|
+
this.clearListItemFocus();
|
|
326
|
+
}
|
|
327
|
+
// force update needed to apply styled state of field-wrapper el
|
|
328
|
+
forceUpdate(this.el);
|
|
329
|
+
}
|
|
330
|
+
handleInputChanged(value) {
|
|
331
|
+
this.charCount = value.length;
|
|
332
|
+
if (this.tagInputType === "dropdown") {
|
|
333
|
+
this.clearListItemFocus();
|
|
334
|
+
if (this.charCount >= this.characterLimit - 5) {
|
|
335
|
+
this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
|
|
336
|
+
}
|
|
337
|
+
if (!this.isExpanded) {
|
|
338
|
+
this.openDropdown();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (this.tagInputType === "table") {
|
|
342
|
+
this.clearCellFocus();
|
|
343
|
+
}
|
|
344
|
+
this.announceExistingOptions();
|
|
345
|
+
}
|
|
346
|
+
handleInputEnter() {
|
|
347
|
+
if (this.tagInputType === "dropdown") {
|
|
348
|
+
if (this.focusedListItem) {
|
|
349
|
+
this.handleListItemClick(this.focusedListItem);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
this.submitInput(this.addNew, this.inputEl.value.trim());
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
|
|
356
|
+
this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
submitInput(canAddNew, value) {
|
|
360
|
+
const hasNonWhiteSpaceCharacters = value.match(/\S/);
|
|
361
|
+
if (canAddNew && hasNonWhiteSpaceCharacters) {
|
|
362
|
+
this.addTag(value);
|
|
363
|
+
this.optionsList = this.addOption(value);
|
|
364
|
+
this.resetInput();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
handleInputArrowDown() {
|
|
368
|
+
if (this.tagInputType === "table") {
|
|
369
|
+
this.moveDownRow();
|
|
370
|
+
}
|
|
371
|
+
else if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
372
|
+
this.moveDownListItem();
|
|
373
|
+
}
|
|
374
|
+
else if (this.tagInputType === "dropdown") {
|
|
375
|
+
this.openDropdown();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
handleInputArrowUp() {
|
|
379
|
+
if (this.tagInputType === "table") {
|
|
380
|
+
this.moveUpRow();
|
|
381
|
+
}
|
|
382
|
+
else if (this.tagInputType === "dropdown" && this.isExpanded) {
|
|
383
|
+
this.moveUpListItem();
|
|
384
|
+
}
|
|
385
|
+
else if (this.tagInputType === "dropdown") {
|
|
386
|
+
this.openDropdown();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
handleInputBackspace() {
|
|
390
|
+
if (this.inputEl.value === "" && this.tagsList.length > 0) {
|
|
391
|
+
// wait for events to finish firing before redirecting focus
|
|
392
|
+
// prevents double input in input area and tag area
|
|
393
|
+
window.requestAnimationFrame(() => {
|
|
394
|
+
if (this.nonLockedTagsList.length > 0) {
|
|
395
|
+
this.tagAreaEl.focus();
|
|
396
|
+
this.focusTag(this.tagEls[this.tagEls.length - 1]);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
handleListItemKeyDown(ev) {
|
|
402
|
+
const typedEvTarget = ev.target;
|
|
403
|
+
switch (ev.key) {
|
|
404
|
+
case "Enter":
|
|
405
|
+
case " ":
|
|
406
|
+
ev.preventDefault();
|
|
407
|
+
typedEvTarget.click();
|
|
408
|
+
break;
|
|
409
|
+
case "ArrowDown":
|
|
410
|
+
ev.preventDefault();
|
|
411
|
+
this.moveDownListItem();
|
|
412
|
+
break;
|
|
413
|
+
case "ArrowUp":
|
|
414
|
+
ev.preventDefault();
|
|
415
|
+
this.moveUpListItem();
|
|
416
|
+
break;
|
|
417
|
+
case "Escape":
|
|
418
|
+
if (this.focusedElement !== this.inputEl) {
|
|
419
|
+
this.inputEl.focus();
|
|
420
|
+
}
|
|
421
|
+
else if (this.tagInputType === "dropdown") {
|
|
422
|
+
this.closeDropdown();
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
handleListItemClick(item) {
|
|
428
|
+
const tag = item.dataset.option.trim() || "";
|
|
429
|
+
if (this.includesCaseInsensitive(this.tagsList, tag)) {
|
|
430
|
+
this.announce(this.generateTagAlreadyAddedMessage(tag));
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
this.resetInput();
|
|
434
|
+
this.addTag(tag);
|
|
435
|
+
this.optionsList = this.addOption(tag);
|
|
436
|
+
this.focusedListItem = null;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
handleTableRowClick(rowId) {
|
|
440
|
+
const referencedRow = this.el.querySelector(`#${rowId}`);
|
|
441
|
+
const isLocked = referencedRow.locked;
|
|
442
|
+
if (!isLocked) {
|
|
443
|
+
if (this.includesCaseInsensitive(this.tagsList, rowId)) {
|
|
444
|
+
this.removeTag(rowId);
|
|
445
|
+
}
|
|
446
|
+
else if (!this.tagLimitReached) {
|
|
447
|
+
this.addTag(rowId);
|
|
448
|
+
this.resetInput();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
handleTagAreaKeyDown(ev) {
|
|
453
|
+
switch (ev.key) {
|
|
454
|
+
case "ArrowLeft":
|
|
455
|
+
case "ArrowUp":
|
|
456
|
+
ev.preventDefault();
|
|
457
|
+
this.moveLeftTag();
|
|
458
|
+
break;
|
|
459
|
+
case "ArrowRight":
|
|
460
|
+
case "ArrowDown":
|
|
461
|
+
ev.preventDefault();
|
|
462
|
+
this.moveRightTag();
|
|
463
|
+
break;
|
|
464
|
+
case "Backspace":
|
|
465
|
+
case "Delete":
|
|
466
|
+
this.handleTagAreaDelete();
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
handleTagAreaDelete() {
|
|
471
|
+
const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
|
|
472
|
+
if (this.focusedTag && !isLocked) {
|
|
473
|
+
this.removeTag(this.focusedTag.dataset.tag);
|
|
474
|
+
if (this.nonLockedTagsList.length === 0) {
|
|
475
|
+
// focus input if no tags are left
|
|
476
|
+
this.inputEl.focus();
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
|
|
480
|
+
// if removing the last tag, reassign focused tag to previous task
|
|
481
|
+
this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
|
|
482
|
+
this.focusTag(this.focusedTag);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
handleBlur(ev, component) {
|
|
487
|
+
const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
|
|
488
|
+
this.dismissTooltip();
|
|
489
|
+
this.clearCellFocus();
|
|
490
|
+
if (isntElOrChild) {
|
|
491
|
+
this.fieldWrapperEl.classList.remove("focused");
|
|
492
|
+
if (this.tagInputType === "dropdown") {
|
|
493
|
+
this.closeDropdown();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
handleCellMouseEnter(ev) {
|
|
498
|
+
const cell = ev.target;
|
|
499
|
+
const contentWrapper = cell.querySelector(".cell-content-wrapper");
|
|
500
|
+
const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
|
|
501
|
+
if (isTruncated) {
|
|
502
|
+
// innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
|
|
503
|
+
showTooltip("bottom", cell, cell.innerText);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
handleTagAreaFocus() {
|
|
507
|
+
if (this.tagInputType === "dropdown") {
|
|
508
|
+
this.closeDropdown();
|
|
509
|
+
}
|
|
510
|
+
const firstFocusableTag = this.nonLockedTagEls[0];
|
|
511
|
+
firstFocusableTag && this.focusTag(firstFocusableTag);
|
|
512
|
+
}
|
|
513
|
+
handleRemoveButtonClick(tag) {
|
|
514
|
+
this.moveLeftTag();
|
|
515
|
+
this.removeTag(tag);
|
|
516
|
+
}
|
|
517
|
+
moveDownListItem() {
|
|
518
|
+
if (this.listItemEls.length > 0) {
|
|
519
|
+
const firstListItem = this.listItemEls[0];
|
|
520
|
+
if (!this.focusedListItem) {
|
|
521
|
+
this.focusListItem(firstListItem);
|
|
522
|
+
}
|
|
523
|
+
else if (this.focusedListItem.nextElementSibling) {
|
|
524
|
+
this.focusListItem(this.focusedListItem.nextElementSibling);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
this.focusListItem(firstListItem);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
moveUpListItem() {
|
|
532
|
+
if (this.listItemEls.length > 0) {
|
|
533
|
+
const lastListItem = this.listItemEls[this.listItemEls.length - 1];
|
|
534
|
+
if (!this.focusedListItem) {
|
|
535
|
+
this.focusListItem(lastListItem);
|
|
536
|
+
}
|
|
537
|
+
else if (this.focusedListItem.previousElementSibling) {
|
|
538
|
+
this.focusListItem(this.focusedListItem.previousElementSibling);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
this.clearListItemFocus();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
moveDownRow() {
|
|
546
|
+
if (this.filteredRows.length > 0) {
|
|
547
|
+
if (this.tablePosition.row === 0) {
|
|
548
|
+
this.tablePosition.row = 1;
|
|
549
|
+
}
|
|
550
|
+
else if (this.tablePosition.row === this.filteredRows.length) {
|
|
551
|
+
this.tablePosition.row = 1;
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
this.tablePosition.row++;
|
|
555
|
+
}
|
|
556
|
+
// skip locked rows
|
|
557
|
+
const rowToFocus = this.filteredRows[this.tablePosition.row - 1];
|
|
558
|
+
if (rowToFocus.locked) {
|
|
559
|
+
this.moveDownRow();
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
this.focusCell(this.tablePosition);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
moveUpRow() {
|
|
567
|
+
if (this.filteredRows.length > 0) {
|
|
568
|
+
if (this.tablePosition.row === 0) {
|
|
569
|
+
this.tablePosition.row = this.filteredRows.length;
|
|
570
|
+
}
|
|
571
|
+
else if (this.tablePosition.row === 1) {
|
|
572
|
+
this.tablePosition.row = 0;
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
this.tablePosition.row--;
|
|
576
|
+
}
|
|
577
|
+
// skip locked rows
|
|
578
|
+
const rowToFocus = this.filteredRows[this.tablePosition.row - 1];
|
|
579
|
+
if (rowToFocus && rowToFocus.locked) {
|
|
580
|
+
this.moveUpRow();
|
|
581
|
+
}
|
|
582
|
+
else if (rowToFocus) {
|
|
583
|
+
this.focusCell(this.tablePosition);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
this.clearCellFocus();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
moveLeftCell() {
|
|
591
|
+
if (this.tablePosition.column != 1) {
|
|
592
|
+
this.tablePosition.column--;
|
|
593
|
+
this.focusCell(this.tablePosition);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
moveRightCell() {
|
|
597
|
+
const numCols = csvToArray(this.colHeaders).length;
|
|
598
|
+
if (this.tablePosition.column < numCols) {
|
|
599
|
+
this.tablePosition.column++;
|
|
600
|
+
this.focusCell(this.tablePosition);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
moveLeftTag() {
|
|
604
|
+
const lastTag = this.tagEls[this.tagEls.length - 1];
|
|
605
|
+
if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
|
|
606
|
+
this.focusedTag = this.focusedTag.previousElementSibling;
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
this.focusedTag = lastTag;
|
|
610
|
+
}
|
|
611
|
+
// skip locked tags
|
|
612
|
+
if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
|
|
613
|
+
this.moveLeftTag();
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
this.focusTag(this.focusedTag);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
moveRightTag() {
|
|
620
|
+
const firstTag = this.tagEls[0];
|
|
621
|
+
if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
|
|
622
|
+
this.focusedTag = this.focusedTag.nextElementSibling;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
this.focusedTag = firstTag;
|
|
626
|
+
}
|
|
627
|
+
// skip locked tags
|
|
628
|
+
if (this.focusedTag.classList.contains("locked")) {
|
|
629
|
+
this.moveRightTag();
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
this.focusTag(this.focusedTag);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
addOption(option) {
|
|
636
|
+
let newOptionsList = this.optionsList;
|
|
637
|
+
const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
|
|
638
|
+
if (!optionAlreadyExists) {
|
|
639
|
+
newOptionsList = newOptionsList.concat(option);
|
|
640
|
+
}
|
|
641
|
+
return newOptionsList;
|
|
642
|
+
}
|
|
643
|
+
removeOption(option) {
|
|
644
|
+
this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
|
|
645
|
+
}
|
|
646
|
+
addTag(tag) {
|
|
647
|
+
let newTagsList = this.tagsList;
|
|
648
|
+
const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
|
|
649
|
+
const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
|
|
650
|
+
if (!tagAlreadyAdded) {
|
|
651
|
+
let textToAnnounce = tag;
|
|
652
|
+
if (this.tagInputType === "table") {
|
|
653
|
+
const referencedRow = this.el.querySelector(`#${tag}`);
|
|
654
|
+
textToAnnounce = referencedRow.col1;
|
|
655
|
+
}
|
|
656
|
+
this.announce(this.generateTagAddedMessage(textToAnnounce));
|
|
657
|
+
this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
|
|
658
|
+
// if maxTags has been reached, focus should go to the tagArea
|
|
659
|
+
// otherwise, input field should be focused and in view
|
|
660
|
+
if (this.tagLimitReached) {
|
|
661
|
+
this.tagAreaEl.focus();
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
// wait for component to render new selected tag before bringing bottom of wrapper in view
|
|
665
|
+
window.requestAnimationFrame(() => (this.tagsAndInputWrapperEl.scrollTop = this.tagsAndInputWrapperEl.scrollHeight));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
removeTag(tag) {
|
|
670
|
+
let textToAnnounce = tag;
|
|
671
|
+
if (this.tagInputType === "table") {
|
|
672
|
+
const referencedRow = this.el.querySelector(`#${tag}`);
|
|
673
|
+
textToAnnounce = referencedRow.col1;
|
|
674
|
+
}
|
|
675
|
+
const tagRemovedMessage = intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: textToAnnounce });
|
|
676
|
+
this.announce(tagRemovedMessage);
|
|
677
|
+
this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
|
|
678
|
+
if (this.tagInputType === "dropdown") {
|
|
679
|
+
// if a tag was introduced by the user, also remove it from the dropdown options
|
|
680
|
+
const devOptionsList = csvToArray(this.options);
|
|
681
|
+
if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
|
|
682
|
+
this.removeOption(tag);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
focusListItem(item) {
|
|
687
|
+
this.focusedListItem = item;
|
|
688
|
+
this.inputEl.setAttribute("aria-activedescendant", this.focusedListItem.id);
|
|
689
|
+
item.scrollIntoView({ block: "nearest" });
|
|
690
|
+
}
|
|
691
|
+
focusTag(element) {
|
|
692
|
+
if (element.classList.contains("locked")) {
|
|
693
|
+
this.focusedTag = null;
|
|
694
|
+
this.tagAreaEl.setAttribute("aria-activedescendant", "");
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
this.focusedTag = element;
|
|
698
|
+
this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
|
|
699
|
+
this.focusedTag.scrollIntoView({ block: "nearest" });
|
|
700
|
+
}
|
|
701
|
+
window.requestAnimationFrame(() => {
|
|
702
|
+
hideTooltip();
|
|
703
|
+
const textEl = element.querySelector(".tag-text");
|
|
704
|
+
const fullText = element.dataset.tag;
|
|
705
|
+
const isTruncated = fullText !== textEl.textContent && textEl.textContent.includes("...");
|
|
706
|
+
isTruncated && showTooltip("bottom", element, fullText);
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
focusCell(position) {
|
|
710
|
+
this.clearCellFocus(false);
|
|
711
|
+
if (position.row) {
|
|
712
|
+
const rowToFocus = this.localRowEls[position.row];
|
|
713
|
+
const rowCells = rowToFocus.querySelectorAll("td");
|
|
714
|
+
const cellToFocus = rowCells[position.column - 1];
|
|
715
|
+
const contentWrapper = cellToFocus.querySelector(".cell-content-wrapper");
|
|
716
|
+
const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
|
|
717
|
+
rowToFocus.classList.add("focused");
|
|
718
|
+
cellToFocus.classList.add("focused");
|
|
719
|
+
cellToFocus.scrollIntoView({ block: "nearest" });
|
|
720
|
+
this.inputEl.setAttribute("aria-activedescendant", cellToFocus.id);
|
|
721
|
+
this.dismissTooltip();
|
|
722
|
+
if (isTruncated) {
|
|
723
|
+
// innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
|
|
724
|
+
showTooltip("bottom", cellToFocus, cellToFocus.innerText);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
clearTagFocus() {
|
|
729
|
+
this.tagAreaEl.setAttribute("aria-activedescendant", "");
|
|
730
|
+
this.focusedTag = null;
|
|
731
|
+
}
|
|
732
|
+
clearCellFocus(resetPosition = true) {
|
|
733
|
+
this.inputEl.setAttribute("aria-activedescendant", "");
|
|
734
|
+
if (resetPosition) {
|
|
735
|
+
this.tablePosition = { row: 0, column: 1 };
|
|
736
|
+
}
|
|
737
|
+
this.localRowEls.forEach((row) => {
|
|
738
|
+
row.classList.remove("focused");
|
|
739
|
+
row.querySelectorAll("td").forEach((cell) => {
|
|
740
|
+
cell.classList.remove("focused");
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
openDropdown() {
|
|
745
|
+
// offset of -2px to avoid overlapping the focus border
|
|
746
|
+
this.openUp = shouldOpenUp(this.el, this.dropdownEl.clientHeight, this.el.clientHeight, -2);
|
|
747
|
+
this.isExpanded = true;
|
|
748
|
+
}
|
|
749
|
+
closeDropdown() {
|
|
750
|
+
this.clearListItemFocus();
|
|
751
|
+
this.isExpanded = false;
|
|
752
|
+
}
|
|
753
|
+
clearListItemFocus() {
|
|
754
|
+
this.focusedListItem = null;
|
|
755
|
+
this.inputEl.setAttribute("aria-activedescendant", "");
|
|
756
|
+
this.listItemEls.forEach((el) => {
|
|
757
|
+
el.classList.remove("focused");
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
resetInput() {
|
|
761
|
+
this.charCount = 0;
|
|
762
|
+
this.inputEl.value = "";
|
|
763
|
+
}
|
|
764
|
+
announce(message) {
|
|
765
|
+
// \u00A0 is a non-breaking space character, which causes the message to be read as a new one
|
|
766
|
+
if (this.liveRegionEl.textContent === message) {
|
|
767
|
+
message += "\u00A0";
|
|
768
|
+
}
|
|
769
|
+
this.liveRegionMessage = message;
|
|
770
|
+
}
|
|
771
|
+
announceExistingOptions() {
|
|
772
|
+
// request animation frame to wait for re-rendering of filtered options
|
|
773
|
+
window.requestAnimationFrame(() => {
|
|
774
|
+
let numResults = 0;
|
|
775
|
+
if (this.tagInputType === "dropdown") {
|
|
776
|
+
numResults = this.optionEls.length;
|
|
777
|
+
}
|
|
778
|
+
else if (this.tagInputType === "table") {
|
|
779
|
+
numResults = this.filteredRows.length;
|
|
780
|
+
}
|
|
781
|
+
const existingOptionsMessage = intl.formatMessage({
|
|
782
|
+
id: "tagInput.existingOptions",
|
|
783
|
+
defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
|
|
784
|
+
}, { num: numResults });
|
|
785
|
+
this.announce(existingOptionsMessage);
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
generateCharacterLimitWarning(charCount, charLimit) {
|
|
789
|
+
let message = globalMessages.getCharactersEntered(charCount, charLimit);
|
|
790
|
+
if (charCount >= charLimit) {
|
|
791
|
+
message += ` ${globalMessages.characterLimitReached}`;
|
|
792
|
+
}
|
|
793
|
+
return message;
|
|
794
|
+
}
|
|
795
|
+
positionInput() {
|
|
796
|
+
const lastTag = this.tagEls[this.tagEls.length - 1];
|
|
797
|
+
// default placement to fall back to when no tags are present, or not enough space is available
|
|
798
|
+
this.inputEl.style.position = "static";
|
|
799
|
+
this.inputEl.style.width = "100%";
|
|
800
|
+
this.inputEl.classList.add("extended");
|
|
801
|
+
if (lastTag) {
|
|
802
|
+
const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
|
|
803
|
+
if (spaceAvailable >= this.inputMinimumWidth) {
|
|
804
|
+
// because the input has right: 0px
|
|
805
|
+
// all thats needed to properly place it is setting position: absolute, top, and width
|
|
806
|
+
this.inputEl.style.position = "absolute";
|
|
807
|
+
this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
|
|
808
|
+
this.inputEl.style.width = (spaceAvailable - 8).toString() + "px";
|
|
809
|
+
this.inputEl.classList.remove("extended");
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
handleTagMouseEnter(ev) {
|
|
814
|
+
const displayedText = ev.target.querySelector(".tag-text").textContent;
|
|
815
|
+
const fullText = ev.target.dataset.tag;
|
|
816
|
+
const isTruncated = displayedText !== fullText && displayedText.includes("...");
|
|
817
|
+
isTruncated && showTooltip("bottom", ev.target, fullText);
|
|
818
|
+
}
|
|
819
|
+
/// Helpers
|
|
820
|
+
listToCSV(list) {
|
|
821
|
+
return list.join(",");
|
|
822
|
+
}
|
|
823
|
+
includesCaseInsensitive(list, element) {
|
|
824
|
+
const lowercaseList = list.map((str) => str.toLowerCase());
|
|
825
|
+
return lowercaseList.includes(element.toLowerCase());
|
|
826
|
+
}
|
|
827
|
+
filterCaseInsensitive(list, element) {
|
|
828
|
+
return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
|
|
829
|
+
}
|
|
830
|
+
sortCaseInsensitive(list) {
|
|
831
|
+
// The vanilla .sort method places words that start with capital letters above others (ASCII order)
|
|
832
|
+
// so we need to pass in our own compare function to sort case-insensitive
|
|
833
|
+
return list.sort((a, b) => {
|
|
834
|
+
a = a.toLowerCase();
|
|
835
|
+
b = b.toLowerCase();
|
|
836
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
/// Renders
|
|
840
|
+
renderTags() {
|
|
841
|
+
let lockedTags = [];
|
|
842
|
+
let unlockedTags = [];
|
|
843
|
+
this.tagsList.forEach((tag, idx) => {
|
|
844
|
+
const id = `tag${idx + 1}`;
|
|
845
|
+
let tagText = "";
|
|
846
|
+
let isLocked = false;
|
|
847
|
+
if (this.tagInputType === "dropdown") {
|
|
848
|
+
tagText = tag;
|
|
849
|
+
}
|
|
850
|
+
else if (this.tagInputType === "table") {
|
|
851
|
+
// display table tags using col1 of the row with the same id
|
|
852
|
+
// if one can't be found, display as empty
|
|
853
|
+
const referencedRow = this.el.querySelector(`#${tag}`);
|
|
854
|
+
tagText = referencedRow ? referencedRow.col1 : "";
|
|
855
|
+
isLocked = referencedRow ? referencedRow.locked : false;
|
|
856
|
+
}
|
|
857
|
+
// make sure locked tags always appear in front of list
|
|
858
|
+
const targetList = isLocked ? lockedTags : unlockedTags;
|
|
859
|
+
targetList.push(h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""} ${isLocked ? "locked" : ""}`, "data-tag": tag, role: "option", onMouseEnter: (ev) => this.handleTagMouseEnter(ev), onMouseLeave: hideTooltip }, h("span", { class: "sr-only" }, tag), h("span", { class: "tag-text", "aria-hidden": "true" }, tagText), isLocked ? (h("div", { class: "icon lock" })) : (h("button", { class: "icon remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) }))));
|
|
860
|
+
});
|
|
861
|
+
return [...lockedTags, ...unlockedTags];
|
|
862
|
+
}
|
|
863
|
+
renderDropdown() {
|
|
864
|
+
return (h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, ref: (el) => (this.dropdownEl = el) }, h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), h("ul", { class: "dropdown", id: "dropdown", role: "listbox", "aria-multiselectable": "true", "aria-expanded": this.isExpanded ? "true" : false, "aria-label": this.label, tabindex: -1 }, this.inputEl && this.renderAddNewButton(), this.renderListItems(this.optionsList))));
|
|
865
|
+
}
|
|
866
|
+
renderListItems(optionsList) {
|
|
867
|
+
optionsList = this.sortCaseInsensitive(optionsList);
|
|
868
|
+
// filter by input
|
|
869
|
+
if (this.inputEl && this.inputEl.value) {
|
|
870
|
+
optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
|
|
871
|
+
}
|
|
872
|
+
return optionsList.map((option, idx) => {
|
|
873
|
+
const id = `option${idx + 1}`;
|
|
874
|
+
const isFocused = this.focusedListItem && this.focusedListItem.id === id;
|
|
875
|
+
const isSelected = this.includesCaseInsensitive(this.tagsList, option);
|
|
876
|
+
return (h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, "aria-selected": isSelected ? "true" : "false", "aria-disabled": isSelected ? "true" : "false", onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target) }, option));
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
renderAddNewButton() {
|
|
880
|
+
const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
|
|
881
|
+
const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
|
|
882
|
+
if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
|
|
883
|
+
const id = `add-new-btn`;
|
|
884
|
+
const isFocused = this.focusedListItem && this.focusedListItem.id === id;
|
|
885
|
+
return (h("li", { role: "option", class: `add-new-btn ${isFocused ? "focused" : ""}`, id: id, "data-option": this.inputEl.value, onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value.trim()}"`));
|
|
886
|
+
}
|
|
887
|
+
else
|
|
888
|
+
return "";
|
|
889
|
+
}
|
|
890
|
+
renderHelpText() {
|
|
891
|
+
let helpText = "";
|
|
892
|
+
if (this.optionsList.length > 0) {
|
|
893
|
+
helpText += this.componentMessages.selectionHelpText;
|
|
894
|
+
}
|
|
895
|
+
if (this.addNew) {
|
|
896
|
+
helpText += " " + this.componentMessages.addNewHelpText;
|
|
897
|
+
}
|
|
898
|
+
return helpText;
|
|
899
|
+
}
|
|
900
|
+
renderTagCounter() {
|
|
901
|
+
if (this.maxTags) {
|
|
902
|
+
return (h("div", { class: "lower-row" }, h("div", { id: "max-tags" }, `${this.componentMessages.tagsAdded}: ${this.tagsList.length}/${this.maxTags}`, this.tagLimitReached && ` - ${this.componentMessages.maxTagsReached}`)));
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
renderTable() {
|
|
906
|
+
return (h("div", { class: "table-wrapper", onScroll: () => this.dismissTooltip() }, h("table", { id: "table", role: "grid", class: `${this.colWidths ? "fixed-widths" : ""}`, "aria-label": this.label, "aria-multiselectable": "true" }, this.renderTableHeaders(), this.filteredRows.length ? this.renderTableRows() : h("div", { class: "no-results" }, this.noResultsMessage))));
|
|
907
|
+
}
|
|
908
|
+
renderTableHeaders() {
|
|
909
|
+
return (h("tr", { class: "headers", role: "row" }, csvToArray(this.colHeaders).map((header, idx) => {
|
|
910
|
+
let overflowRule = "wrap";
|
|
911
|
+
if (this.colWrap && csvToArray(this.colWrap)[idx]) {
|
|
912
|
+
overflowRule = csvToArray(this.colWrap)[idx];
|
|
913
|
+
}
|
|
914
|
+
return (h("th", { class: `header-cell ${overflowRule}`, role: "columnheader",
|
|
915
|
+
// @ts-ignore
|
|
916
|
+
width: this.colWidths ? csvToArray(this.colWidths)[idx] : "" }, header));
|
|
917
|
+
})));
|
|
918
|
+
}
|
|
919
|
+
renderTableRows() {
|
|
920
|
+
return this.filteredRows.map((row) => {
|
|
921
|
+
const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
|
|
922
|
+
return (h("tr", { id: row.id, class: `${row.locked ? "locked" : ""} ${isSelected ? "selected" : ""}`, role: "row", onClick: () => this.handleTableRowClick(row.id) }, this.renderTableCells(row)));
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
renderTableCells(row) {
|
|
926
|
+
const colValues = [row.col1, row.col2, row.col3, row.col4].filter((val) => !!val);
|
|
927
|
+
const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
|
|
928
|
+
return colValues.map((val, idx) => {
|
|
929
|
+
const localId = `${row.id}-col${idx + 1}`;
|
|
930
|
+
let overflowRule = "wrap";
|
|
931
|
+
if (this.colWrap && csvToArray(this.colWrap)[idx]) {
|
|
932
|
+
overflowRule = csvToArray(this.colWrap)[idx];
|
|
933
|
+
}
|
|
934
|
+
return (h("td", { id: localId, role: "gridcell", "aria-describedby": `${localId}-description`, "aria-selected": isSelected.toString(), onMouseEnter: (ev) => this.handleCellMouseEnter(ev), onMouseLeave: () => this.dismissTooltip() }, h("div", { class: `cell-content-wrapper ${overflowRule}` }, val), h("div", { class: "description", id: `${localId}-description` }, row.locked ? "locked" : "")));
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
render() {
|
|
938
|
+
return (h(Host, { id: this.uid }, h("div", { class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label, this.requiredField && (h("span", { class: "required", "aria-hidden": "true" }, "*")))), h("div", { class: `field-wrapper ${this.focusedElement ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, h("div", { class: "upper-row" }, h("div", { class: "tags-and-input-wrapper", ref: (el) => (this.tagsAndInputWrapperEl = el) }, this.tagsList.length > 0 && (h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-activedescendant": "", "aria-orientation": "horizontal", "aria-label": `${this.label} ${this.tagsList.length > 0 ? this.componentMessages.tagAreaInstructions : ""}`, tabindex: this.nonLockedTagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
|
|
939
|
+
this.clearTagFocus();
|
|
940
|
+
this.handleBlur(ev, this.el);
|
|
941
|
+
}, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags())), h("input", { id: `input${this.uid}`, class: `input ${this.tagLimitReached ? "hidden" : ""}`, role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-required": this.requiredField ? "true" : null, "aria-controls": this.tagInputType, "aria-describedby": `help-text${this.errorMessage ? " error " : ""}`, "aria-label": `${this.label} ${this.tagInputType === "dropdown" ? globalMessages.getCharacterLimit(this.characterLimit) : ""}`, "aria-expanded": this.tagInputType === "dropdown" ? this.isExpanded.toString() : null, placeholder: this.placeholder, maxLength: this.tagInputType === "dropdown" ? this.characterLimit : undefined, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
|
|
942
|
+
this.handleBlur(ev, this.el);
|
|
943
|
+
}, onFocus: () => this.handleInputFocus(), onKeyDown: (ev) => this.handleInputKeyDown(ev) })), this.tagInputType === "dropdown" && (h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.tagInputType === "dropdown" && this.renderDropdown()), this.info && (h("div", { id: "info", class: "info-text" }, this.info)), this.errorMessage && h("div", { id: "error" }, this.errorMessage), h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.tagInputType === "table" && this.renderTable())));
|
|
944
|
+
}
|
|
945
|
+
static get delegatesFocus() { return true; }
|
|
946
|
+
get el() { return getElement(this); }
|
|
947
|
+
static get watchers() { return {
|
|
948
|
+
"tagsList": ["reflectSelectedTags"],
|
|
949
|
+
"errorMessage": ["handleErrorMessageChange"]
|
|
950
|
+
}; }
|
|
951
|
+
};
|
|
945
952
|
TagInput.style = wmTagInputCss;
|
|
946
953
|
|
|
947
954
|
export { TagInput as wm_tag_input };
|