@watermarkinsights/ripple 3.0.1-0 → 3.0.2-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ripple/functions-316c1b23.js → cjs/functions-e3f5ae65.js} +188 -2391
- package/dist/cjs/global-1e540de6.js +38 -0
- package/dist/cjs/http-service-9e8c4dd5.js +57 -0
- package/dist/cjs/index-d930307d.js +1392 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/interfaces-30a74c1f.js +35 -0
- package/dist/cjs/loader.cjs.js +22 -0
- package/dist/cjs/priv-chart-popover.cjs.entry.js +89 -0
- package/dist/cjs/priv-datepicker.cjs.entry.js +672 -0
- package/dist/cjs/priv-navigator-button.cjs.entry.js +29 -0
- package/dist/cjs/priv-navigator-item.cjs.entry.js +34 -0
- package/dist/cjs/ripple.cjs.js +20 -0
- package/dist/cjs/wm-action-menu_2.cjs.entry.js +318 -0
- package/dist/cjs/wm-button.cjs.entry.js +152 -0
- package/dist/cjs/wm-chart-slice.cjs.entry.js +22 -0
- package/dist/cjs/wm-chart.cjs.entry.js +508 -0
- package/dist/cjs/wm-datepicker.cjs.entry.js +257 -0
- package/dist/cjs/wm-input.cjs.entry.js +110 -0
- package/dist/cjs/wm-modal-footer.cjs.entry.js +43 -0
- package/dist/cjs/wm-modal-header.cjs.entry.js +45 -0
- package/dist/cjs/wm-modal.cjs.entry.js +149 -0
- package/dist/cjs/wm-navigator.cjs.entry.js +279 -0
- package/dist/cjs/wm-network-uploader.cjs.entry.js +431 -0
- package/dist/cjs/wm-option_2.cjs.entry.js +483 -0
- package/dist/cjs/wm-pagination.cjs.entry.js +176 -0
- package/dist/cjs/wm-search.cjs.entry.js +231 -0
- package/dist/cjs/wm-snackbar.cjs.entry.js +160 -0
- package/dist/cjs/wm-tab-item_3.cjs.entry.js +316 -0
- package/dist/cjs/wm-tag-input.cjs.entry.js +538 -0
- package/dist/cjs/wm-timepicker.cjs.entry.js +386 -0
- package/dist/cjs/wm-toggletip.cjs.entry.js +128 -0
- package/dist/cjs/wm-uploader.cjs.entry.js +342 -0
- package/dist/cjs/wm-wrapper.cjs.entry.js +21 -0
- package/dist/collection/collection-manifest.json +131 -0
- package/dist/{ripple/ripple.css → collection/components/wm-action-menu/wm-action-menu.css} +80 -42
- package/dist/collection/components/wm-action-menu/wm-action-menu.js +392 -0
- package/dist/collection/components/wm-button/wm-button.css +572 -0
- package/dist/collection/components/wm-button/wm-button.js +365 -0
- package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.css +132 -0
- package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -0
- package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -0
- package/dist/collection/components/wm-chart/wm-chart.css +337 -0
- package/dist/collection/components/wm-chart/wm-chart.js +710 -0
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +374 -0
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1003 -0
- package/dist/collection/components/wm-datepicker/wm-datepicker.css +211 -0
- package/dist/collection/components/wm-datepicker/wm-datepicker.js +439 -0
- package/dist/collection/components/wm-input/wm-input.css +220 -0
- package/dist/collection/components/wm-input/wm-input.js +302 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.css +118 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.js +411 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.css +84 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.js +159 -0
- package/dist/collection/components/wm-modal/wm-modal-header.css +78 -0
- package/dist/collection/components/wm-modal/wm-modal-header.js +109 -0
- package/dist/collection/components/wm-modal/wm-modal.css +155 -0
- package/dist/collection/components/wm-modal/wm-modal.js +356 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.css +94 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.css +67 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -0
- package/dist/collection/components/wm-navigator/wm-navigator.css +137 -0
- package/dist/collection/components/wm-navigator/wm-navigator.js +468 -0
- package/dist/collection/components/wm-option/wm-option.css +162 -0
- package/dist/collection/components/wm-option/wm-option.js +394 -0
- package/dist/collection/components/wm-pagination/wm-pagination.css +217 -0
- package/dist/collection/components/wm-pagination/wm-pagination.js +348 -0
- package/dist/collection/components/wm-search/wm-search.css +155 -0
- package/dist/collection/components/wm-search/wm-search.js +439 -0
- package/dist/collection/components/wm-select/wm-select.css +315 -0
- package/dist/collection/components/wm-select/wm-select.js +676 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.css +331 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +240 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +104 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +202 -0
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.css +73 -0
- package/dist/{ripple/wm-tab-list.entry.js → collection/components/wm-tabs/wm-tab-list/wm-tab-list.js} +131 -17
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.css +57 -0
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.css +431 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +754 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.css +370 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +567 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.css +350 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +217 -0
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.css +642 -0
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -0
- package/dist/collection/components/wm-uploader/wm-uploader.css +666 -0
- package/dist/collection/components/wm-uploader/wm-uploader.js +673 -0
- package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -0
- package/dist/collection/dev/scripts.js +20 -0
- package/dist/collection/global/__mocks__/functions.js +5 -0
- package/dist/collection/global/functions.js +420 -0
- package/dist/{ripple/app-globals-b5693c90.js → collection/global/global.js} +3 -8
- package/dist/{ripple/interfaces-50753346.js → collection/global/interfaces.js} +4 -6
- package/dist/collection/global/services/__mocks__/http-service.js +130 -0
- package/dist/collection/global/services/http-service.js +50 -0
- package/dist/collection/lang/lang.js +5 -0
- package/dist/collection/lang/piglatin.js +93 -0
- package/dist/esm/functions-0deb7f8e.js +6117 -0
- package/dist/esm/global-d6b49e98.js +36 -0
- package/dist/{ripple → esm}/http-service-5d037e16.js +0 -0
- package/dist/esm/index-5a842e48.js +1363 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/interfaces-61c6305b.js +32 -0
- package/dist/esm/loader.js +18 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/{ripple → esm}/priv-chart-popover.entry.js +2 -2
- package/dist/{ripple → esm}/priv-datepicker.entry.js +3 -3
- package/dist/{ripple → esm}/priv-navigator-button.entry.js +1 -1
- package/dist/{ripple → esm}/priv-navigator-item.entry.js +1 -1
- package/dist/esm/ripple.js +18 -0
- package/dist/{ripple/wm-action-menu.entry.js → esm/wm-action-menu_2.entry.js} +114 -3
- package/dist/{ripple → esm}/wm-button.entry.js +3 -3
- package/dist/{ripple → esm}/wm-chart-slice.entry.js +1 -1
- package/dist/{ripple → esm}/wm-chart.entry.js +2 -2
- package/dist/{ripple → esm}/wm-datepicker.entry.js +27 -32
- package/dist/{ripple → esm}/wm-input.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal-footer.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal-header.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal.entry.js +2 -2
- package/dist/{ripple → esm}/wm-navigator.entry.js +3 -3
- package/dist/{ripple → esm}/wm-network-uploader.entry.js +2 -2
- package/dist/{ripple/wm-select.entry.js → esm/wm-option_2.entry.js} +119 -3
- package/dist/{ripple → esm}/wm-pagination.entry.js +2 -2
- package/dist/{ripple → esm}/wm-search.entry.js +2 -2
- package/dist/{ripple → esm}/wm-snackbar.entry.js +2 -2
- package/dist/esm/wm-tab-item_3.entry.js +310 -0
- package/dist/{ripple → esm}/wm-tag-input.entry.js +2 -2
- package/dist/{ripple → esm}/wm-timepicker.entry.js +2 -2
- package/dist/{ripple → esm}/wm-toggletip.entry.js +2 -2
- package/dist/{ripple → esm}/wm-uploader.entry.js +2 -2
- package/dist/{ripple → esm}/wm-wrapper.entry.js +1 -1
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +13 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +10 -0
- package/dist/ripple/index.esm.js +0 -1
- package/dist/ripple/p-103f8cae.entry.js +1 -0
- package/dist/ripple/p-129d94fa.entry.js +1 -0
- package/dist/ripple/p-139fe143.entry.js +1 -0
- package/dist/ripple/p-16367805.entry.js +1 -0
- package/dist/ripple/p-1d334060.entry.js +1 -0
- package/dist/ripple/p-2562f330.entry.js +1 -0
- package/dist/ripple/p-278b26ef.entry.js +1 -0
- package/dist/ripple/p-2c21bb72.entry.js +1 -0
- package/dist/ripple/p-2f5fda71.entry.js +1 -0
- package/dist/ripple/p-3e6f04d5.entry.js +1 -0
- package/dist/ripple/p-7185de7f.entry.js +1 -0
- package/dist/ripple/p-770d0798.entry.js +1 -0
- package/dist/ripple/p-846b4c5f.entry.js +1 -0
- package/dist/ripple/p-888bec42.js +1 -0
- package/dist/ripple/p-90779d53.entry.js +1 -0
- package/dist/ripple/p-934543f2.js +1 -0
- package/dist/ripple/p-9a087fee.entry.js +1 -0
- package/dist/ripple/p-a6d6eae7.js +1 -0
- package/dist/ripple/p-a942ad10.entry.js +1 -0
- package/dist/ripple/p-bfb4652d.entry.js +1 -0
- package/dist/ripple/p-c0fe5201.entry.js +1 -0
- package/dist/ripple/p-c2e27acc.entry.js +1 -0
- package/dist/ripple/p-c2edda64.entry.js +1 -0
- package/dist/ripple/p-d1fdcbcf.entry.js +1 -0
- package/dist/ripple/p-d40b6afb.entry.js +1 -0
- package/dist/ripple/p-da73db1c.entry.js +1 -0
- package/dist/ripple/p-e3843249.js +1 -0
- package/dist/ripple/p-ea5cd8b8.js +16 -0
- package/dist/ripple/p-ed0f43f4.entry.js +1 -0
- package/dist/ripple/p-ffafd363.entry.js +1 -0
- package/dist/ripple/ripple.esm.js +1 -125
- package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +43 -0
- package/dist/types/components/wm-button/wm-button.d.ts +36 -0
- package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -0
- package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -0
- package/dist/types/components/wm-chart/wm-chart.d.ts +77 -0
- package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +75 -0
- package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +39 -0
- package/dist/types/components/wm-input/wm-input.d.ts +30 -0
- package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +30 -0
- package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -0
- package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -0
- package/dist/types/components/wm-modal/wm-modal.d.ts +34 -0
- package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -0
- package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -0
- package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -0
- package/dist/types/components/wm-option/wm-option.d.ts +28 -0
- package/dist/types/components/wm-pagination/wm-pagination.d.ts +31 -0
- package/dist/types/components/wm-search/wm-search.d.ts +78 -0
- package/dist/types/components/wm-select/wm-select.d.ts +63 -0
- package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +32 -0
- package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +35 -0
- package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +50 -0
- package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -0
- package/dist/types/components/wm-tag-input/{wm-tag-input.d.ts~ds312_tagInputMaxTags → wm-tag-input.d.ts} +1 -1
- package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +59 -0
- package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -0
- package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -0
- package/dist/types/components/wm-uploader/wm-uploader.d.ts +75 -0
- package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -0
- package/dist/types/{components.d.ts~ds312_tagInputMaxTags → components.d.ts} +0 -0
- package/dist/types/global/__mocks__/functions.d.ts +5 -0
- package/dist/types/global/global.d.ts +1 -0
- package/dist/types/global/interfaces.d.ts +33 -0
- package/dist/types/global/services/__mocks__/http-service.d.ts +6 -0
- package/dist/types/global/services/http-service.d.ts +4 -0
- package/dist/types/lang/lang.d.ts +5 -0
- package/dist/types/{stencil-public-runtime.d.ts~ds312_tagInputMaxTags → stencil-public-runtime.d.ts} +190 -182
- package/package.json +1 -1
- package/dist/ripple/css-shim-bbdf0cc6.js +0 -4
- package/dist/ripple/dom-1f98a75f.js +0 -73
- package/dist/ripple/index-20b65f86.js +0 -2938
- package/dist/ripple/shadow-css-67b66845.js +0 -389
- package/dist/ripple/wm-menuitem.entry.js +0 -114
- package/dist/ripple/wm-option.entry.js +0 -119
- package/dist/ripple/wm-tab-item.entry.js +0 -78
- package/dist/ripple/wm-tab-panel.entry.js +0 -38
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-d930307d.js');
|
|
6
|
+
const functions = require('./functions-e3f5ae65.js');
|
|
7
|
+
|
|
8
|
+
const wmTagInputCss = "@charset \"UTF-8\";:host,wm-tag-input{font-family:inherit;width:100%}:host *,wm-tag-input *{box-sizing:border-box;font-size:14px}:host .wrapper,wm-tag-input .wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;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{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:flex;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;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:\"\";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%;position:relative}:host .field-wrapper,wm-tag-input .field-wrapper{position:relative;min-height:2.5rem;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 #20cbd4;-moz-box-shadow:0 0 0 1px #20cbd4;box-shadow:0 0 0 1px #20cbd4;outline:none;border-color:#20cbd4}:host .character-count,wm-tag-input .character-count{display:flex;align-items:center;justify-content:center;min-width:5rem;background-color:rgba(74, 74, 74, 0.05);font-size:0.875rem;font-weight:500;align-self:stretch}:host .tags-and-input-wrapper,wm-tag-input .tags-and-input-wrapper{width:100%;padding:0.5rem 0.25rem;margin-bottom:-0.5rem}:host .upper-row,wm-tag-input .upper-row{width:100%;display:flex;flex:1;justify-content:space-between;align-items:center}:host .lower-row,wm-tag-input .lower-row{width:100%;border-radius:0 0 3px 3px}:host #max-tags,wm-tag-input #max-tags{display:flex;align-items:center;height:1.875rem;background-color:#6b6b6b;padding:0.5rem 1rem;color:white;font-size:0.875rem}:host .tag-area,wm-tag-input .tag-area{display:flex;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:inline-flex;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;transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)}:host .tag-area [role=option].highlight,wm-tag-input .tag-area [role=option].highlight{animation:fadeIn 1s}@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] .remove-btn,wm-tag-input .tag-area [role=option] .remove-btn{display:inline-flex;justify-content:center;align-items:center;height:1.25rem;width:1.25rem;border:1px solid #575195;color:#575195;border-radius:50%;padding:0;margin-left:0.5rem;cursor:pointer;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] .remove-btn:hover,wm-tag-input .tag-area [role=option] .remove-btn:hover{color:white;background-color:#575195}:host .tag-area [role=option] .remove-btn:before,wm-tag-input .tag-area [role=option] .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:\"\"}:host .input-wrapper,wm-tag-input .input-wrapper{flex:1 0 150px}:host .input-wrapper input,wm-tag-input .input-wrapper input{font-family:inherit;border:none;height:1.75rem;padding:0;margin-bottom:0.5rem;margin-right:0.25rem;margin-left:0.25rem;width:100%}:host .input-wrapper input.hidden,wm-tag-input .input-wrapper input.hidden{display:none}:host .input-wrapper input:focus,wm-tag-input .input-wrapper 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;transition: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:flex;align-items:center;padding:0 1rem;background:#fff;list-style:none;height:2.6875rem}: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;min-height:2.6875rem;padding-top:0.25rem;padding-bottom:0.25rem}: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 .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;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}";
|
|
9
|
+
|
|
10
|
+
const TagInput = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
this.wmTagInputChanged = index.createEvent(this, "wmTagInputChanged", 7);
|
|
14
|
+
this.labelPosition = "top";
|
|
15
|
+
this.options = ""; // csv
|
|
16
|
+
this.selectedTags = ""; // csv
|
|
17
|
+
this.addNew = true;
|
|
18
|
+
this.characterLimit = 50;
|
|
19
|
+
this.uid = this.el.id ? this.el.id : functions.generateId();
|
|
20
|
+
this.openUp = false;
|
|
21
|
+
this.isExpanded = false;
|
|
22
|
+
this.tagsList = this.csvToArray(this.selectedTags);
|
|
23
|
+
this.optionsList = this.csvToArray(this.options);
|
|
24
|
+
this.charCount = 0;
|
|
25
|
+
this.liveRegionMessage = "";
|
|
26
|
+
this.tagAreaInstructions = functions.intl.formatMessage({
|
|
27
|
+
id: "tagInput.tagAreaInstructions",
|
|
28
|
+
defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
|
|
29
|
+
});
|
|
30
|
+
this.maxTagsReachedMessage = functions.intl.formatMessage({
|
|
31
|
+
id: "tagInput.maxTagsReached",
|
|
32
|
+
defaultMessage: "The maximum amount of tags has been reached, no additional tags can be added.",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get focusedElement() {
|
|
36
|
+
return this.el.shadowRoot.activeElement;
|
|
37
|
+
}
|
|
38
|
+
get listItemEls() {
|
|
39
|
+
return Array.from(this.dropdownEl.querySelectorAll("li"));
|
|
40
|
+
}
|
|
41
|
+
get tagEls() {
|
|
42
|
+
return Array.from(this.tagAreaEl.querySelectorAll(".tag"));
|
|
43
|
+
}
|
|
44
|
+
get optionEls() {
|
|
45
|
+
return Array.from(this.dropdownEl.querySelectorAll(".option"));
|
|
46
|
+
}
|
|
47
|
+
generateTagAddedMessage(tag) {
|
|
48
|
+
return functions.intl.formatMessage({
|
|
49
|
+
id: "tagInput.tagAdded",
|
|
50
|
+
defaultMessage: "{tagName} added.",
|
|
51
|
+
description: "A confirmation for adding a tag.",
|
|
52
|
+
}, { tagName: tag });
|
|
53
|
+
}
|
|
54
|
+
generateTagAlreadyAddedMessage(tag) {
|
|
55
|
+
return functions.intl.formatMessage({
|
|
56
|
+
id: "tagInput.tagAlreadyAdded",
|
|
57
|
+
defaultMessage: "{tagName} has already been added.",
|
|
58
|
+
description: "An alert for adding a tag that is already present.",
|
|
59
|
+
}, { tagName: tag });
|
|
60
|
+
}
|
|
61
|
+
generateTagCounterMessage() {
|
|
62
|
+
return functions.intl.formatMessage({
|
|
63
|
+
id: "tagInput.tagsAddedCounter",
|
|
64
|
+
defaultMessage: "Tags added: {x, number}/{y, number}",
|
|
65
|
+
description: "For the user to understand how close they are to the tag limit.",
|
|
66
|
+
}, {
|
|
67
|
+
x: this.tagsList.length,
|
|
68
|
+
y: this.maxTags,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
componentWillLoad() {
|
|
72
|
+
if (!this.placeholder) {
|
|
73
|
+
this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
|
|
74
|
+
}
|
|
75
|
+
if (!this.label) {
|
|
76
|
+
console.error("wm-tag-input must have a label property");
|
|
77
|
+
}
|
|
78
|
+
this.consolidateSelectedTags();
|
|
79
|
+
}
|
|
80
|
+
componentDidLoad() {
|
|
81
|
+
// prevent highlighting of pre-selected tags
|
|
82
|
+
this.tagEls.forEach((el) => el.classList.remove("highlight"));
|
|
83
|
+
}
|
|
84
|
+
consolidateSelectedTags() {
|
|
85
|
+
this.tagsList.forEach((tag) => {
|
|
86
|
+
if (!this.includesCaseInsensitive(this.optionsList, tag)) {
|
|
87
|
+
this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
this.optionsList = this.csvToArray(this.options);
|
|
91
|
+
}
|
|
92
|
+
createPlaceholderDefault(addNew, hasOptions) {
|
|
93
|
+
const addAndSearchPlaceholder = functions.intl.formatMessage({
|
|
94
|
+
id: "tagInput.placeholderAddAndSearch",
|
|
95
|
+
defaultMessage: "Add or search for a tag",
|
|
96
|
+
});
|
|
97
|
+
const searchPlaceholder = functions.intl.formatMessage({
|
|
98
|
+
id: "tagInput.placeholderSearch",
|
|
99
|
+
defaultMessage: "Search and select a tag",
|
|
100
|
+
});
|
|
101
|
+
const addPlaceholder = functions.intl.formatMessage({
|
|
102
|
+
id: "tagInput.placeholderAdd",
|
|
103
|
+
defaultMessage: "Add a new tag",
|
|
104
|
+
});
|
|
105
|
+
let placeholder = "";
|
|
106
|
+
if (addNew && hasOptions) {
|
|
107
|
+
placeholder = addAndSearchPlaceholder;
|
|
108
|
+
}
|
|
109
|
+
else if (!addNew && hasOptions) {
|
|
110
|
+
placeholder = searchPlaceholder;
|
|
111
|
+
}
|
|
112
|
+
else if (addNew) {
|
|
113
|
+
placeholder = addPlaceholder;
|
|
114
|
+
}
|
|
115
|
+
return placeholder;
|
|
116
|
+
}
|
|
117
|
+
reflectSelectedTags() {
|
|
118
|
+
this.selectedTags = this.listToCSV(this.tagsList);
|
|
119
|
+
this.wmTagInputChanged.emit({ value: this.tagsList });
|
|
120
|
+
}
|
|
121
|
+
closeIfNotElOrChild(ev) {
|
|
122
|
+
const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
|
|
123
|
+
if (isntElOrChild && this.isExpanded) {
|
|
124
|
+
this.closeDropdown();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
handleInputKeyDown(ev) {
|
|
128
|
+
if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
|
|
129
|
+
this.announceCharacterLimitWarning(this.inputEl.value.length, this.characterLimit);
|
|
130
|
+
}
|
|
131
|
+
// prevent keydown triggering on tag area
|
|
132
|
+
ev.stopPropagation();
|
|
133
|
+
switch (ev.key) {
|
|
134
|
+
case "Enter":
|
|
135
|
+
case ",":
|
|
136
|
+
ev.preventDefault();
|
|
137
|
+
this.submitInput(this.addNew, this.inputEl.value.trim());
|
|
138
|
+
break;
|
|
139
|
+
case "ArrowDown":
|
|
140
|
+
ev.preventDefault();
|
|
141
|
+
this.handleInputArrowDown();
|
|
142
|
+
break;
|
|
143
|
+
case "ArrowUp":
|
|
144
|
+
ev.preventDefault();
|
|
145
|
+
this.handleInputArrowUp();
|
|
146
|
+
break;
|
|
147
|
+
case "Escape":
|
|
148
|
+
if (this.isExpanded) {
|
|
149
|
+
this.closeDropdown();
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case "ArrowLeft":
|
|
153
|
+
case "Backspace":
|
|
154
|
+
this.handleInputBackspace();
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
handleInputChanged(value) {
|
|
159
|
+
this.charCount = value.length;
|
|
160
|
+
if (this.charCount >= this.characterLimit - 5) {
|
|
161
|
+
this.announceCharacterLimitWarning(this.charCount, this.characterLimit);
|
|
162
|
+
}
|
|
163
|
+
this.announceExistingOptions();
|
|
164
|
+
if (!this.isExpanded) {
|
|
165
|
+
this.openDropdown();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
submitInput(canAddNew, value) {
|
|
169
|
+
if (canAddNew && value) {
|
|
170
|
+
this.tagsList = this.addTag(value);
|
|
171
|
+
this.optionsList = this.addOption(value);
|
|
172
|
+
this.resetInput();
|
|
173
|
+
// if maxTags has been reached, focus should go to the tagArea instead of the input
|
|
174
|
+
if (this.maxTags && this.tagsList.length >= this.maxTags) {
|
|
175
|
+
this.tagAreaEl.focus();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
handleInputArrowDown() {
|
|
180
|
+
if (this.isExpanded) {
|
|
181
|
+
this.moveDownListItem();
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.openDropdown();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
handleInputArrowUp() {
|
|
188
|
+
if (this.isExpanded) {
|
|
189
|
+
this.moveUpListItem();
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
this.openDropdown();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
handleInputBackspace() {
|
|
196
|
+
if (this.inputEl.value === "" && this.tagsList.length > 0) {
|
|
197
|
+
// wait for events to finish firing before redirecting focus
|
|
198
|
+
// prevents double input in input area and tag area
|
|
199
|
+
window.requestAnimationFrame(() => {
|
|
200
|
+
this.tagAreaEl.focus();
|
|
201
|
+
this.focusTag(this.tagEls[this.tagEls.length - 1]);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
handleListItemKeyDown(ev) {
|
|
206
|
+
const typedEvTarget = ev.target;
|
|
207
|
+
switch (ev.key) {
|
|
208
|
+
case "Enter":
|
|
209
|
+
case " ":
|
|
210
|
+
ev.preventDefault();
|
|
211
|
+
typedEvTarget.click();
|
|
212
|
+
break;
|
|
213
|
+
case "ArrowDown":
|
|
214
|
+
ev.preventDefault();
|
|
215
|
+
this.moveDownListItem();
|
|
216
|
+
break;
|
|
217
|
+
case "ArrowUp":
|
|
218
|
+
ev.preventDefault();
|
|
219
|
+
this.moveUpListItem();
|
|
220
|
+
break;
|
|
221
|
+
case "Escape":
|
|
222
|
+
if (this.focusedElement !== this.inputEl) {
|
|
223
|
+
this.inputEl.focus();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
this.closeDropdown();
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
handleListItemClick(ev) {
|
|
232
|
+
const typedEvTarget = ev.target;
|
|
233
|
+
const tag = typedEvTarget.dataset.option.trim() || "";
|
|
234
|
+
if (this.includesCaseInsensitive(this.tagsList, tag)) {
|
|
235
|
+
this.announce(this.generateTagAlreadyAddedMessage(tag));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this.announce(this.generateTagAddedMessage(tag));
|
|
239
|
+
this.resetInput();
|
|
240
|
+
this.tagsList = this.addTag(tag);
|
|
241
|
+
this.optionsList = this.addOption(tag);
|
|
242
|
+
this.focusedListItem = null;
|
|
243
|
+
// if maxTags has been reached, focus should go to the tagArea instead of the input
|
|
244
|
+
const elementToFocus = this.maxTags && this.tagsList.length >= this.maxTags ? this.tagAreaEl : this.inputEl;
|
|
245
|
+
elementToFocus.focus();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
handleTagAreaKeyDown(ev) {
|
|
249
|
+
switch (ev.key) {
|
|
250
|
+
case "ArrowLeft":
|
|
251
|
+
case "ArrowUp":
|
|
252
|
+
ev.preventDefault();
|
|
253
|
+
this.moveLeftTag();
|
|
254
|
+
break;
|
|
255
|
+
case "ArrowRight":
|
|
256
|
+
case "ArrowDown":
|
|
257
|
+
ev.preventDefault();
|
|
258
|
+
this.moveRightTag();
|
|
259
|
+
break;
|
|
260
|
+
case "Backspace":
|
|
261
|
+
case "Delete":
|
|
262
|
+
this.handleTagAreaDelete();
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
handleTagAreaDelete() {
|
|
267
|
+
if (this.focusedTag && this.focusedTag.dataset.tag) {
|
|
268
|
+
this.removeTag(this.focusedTag.dataset.tag);
|
|
269
|
+
if (this.tagsList.length === 0) {
|
|
270
|
+
// focus input if no tags are left
|
|
271
|
+
this.inputEl.focus();
|
|
272
|
+
}
|
|
273
|
+
else if (this.focusedTag === this.tagEls[this.tagEls.length - 1]) {
|
|
274
|
+
// reassign focus if removing the last tag but there are still tags remaining
|
|
275
|
+
this.focusedTag = this.tagEls[this.tagEls.length - 2];
|
|
276
|
+
this.focusTag(this.focusedTag);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
handleBlur(ev, component) {
|
|
281
|
+
const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
|
|
282
|
+
if (isntElOrChild) {
|
|
283
|
+
this.closeDropdown();
|
|
284
|
+
this.fieldWrapperEl.classList.remove("focused");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
handleTagAreaFocus() {
|
|
288
|
+
this.closeDropdown();
|
|
289
|
+
if (!this.focusedTag) {
|
|
290
|
+
this.focusedTag = this.tagEls[0];
|
|
291
|
+
}
|
|
292
|
+
this.focusTag(this.focusedTag);
|
|
293
|
+
}
|
|
294
|
+
handleRemoveButtonClick(tag) {
|
|
295
|
+
this.moveLeftTag();
|
|
296
|
+
this.removeTag(tag);
|
|
297
|
+
}
|
|
298
|
+
moveDownListItem() {
|
|
299
|
+
if (this.listItemEls.length > 0) {
|
|
300
|
+
const firstListItem = this.listItemEls[0];
|
|
301
|
+
if (!this.focusedListItem) {
|
|
302
|
+
this.focusListItem(firstListItem);
|
|
303
|
+
}
|
|
304
|
+
else if (this.focusedListItem.nextElementSibling) {
|
|
305
|
+
this.focusListItem(this.focusedListItem.nextElementSibling);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this.focusListItem(firstListItem);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
moveUpListItem() {
|
|
313
|
+
if (this.listItemEls.length > 0) {
|
|
314
|
+
const lastListItem = this.listItemEls[this.listItemEls.length - 1];
|
|
315
|
+
if (!this.focusedListItem) {
|
|
316
|
+
this.focusListItem(lastListItem);
|
|
317
|
+
}
|
|
318
|
+
else if (this.focusedListItem.previousElementSibling) {
|
|
319
|
+
this.focusListItem(this.focusedListItem.previousElementSibling);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this.focusedListItem = null;
|
|
323
|
+
this.inputEl.focus();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
moveLeftTag() {
|
|
328
|
+
const lastTag = this.tagEls[this.tagEls.length - 1];
|
|
329
|
+
if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
|
|
330
|
+
this.focusedTag = this.focusedTag.previousElementSibling;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
this.focusedTag = lastTag;
|
|
334
|
+
}
|
|
335
|
+
this.focusTag(this.focusedTag);
|
|
336
|
+
}
|
|
337
|
+
moveRightTag() {
|
|
338
|
+
const firstTag = this.tagEls[0];
|
|
339
|
+
if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
|
|
340
|
+
this.focusedTag = this.focusedTag.nextElementSibling;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.focusedTag = firstTag;
|
|
344
|
+
}
|
|
345
|
+
this.focusTag(this.focusedTag);
|
|
346
|
+
}
|
|
347
|
+
addOption(option) {
|
|
348
|
+
let newOptionsList = this.optionsList;
|
|
349
|
+
const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
|
|
350
|
+
if (!optionAlreadyExists) {
|
|
351
|
+
newOptionsList = newOptionsList.concat(option);
|
|
352
|
+
}
|
|
353
|
+
return newOptionsList;
|
|
354
|
+
}
|
|
355
|
+
removeOption(option) {
|
|
356
|
+
this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
|
|
357
|
+
}
|
|
358
|
+
addTag(tag) {
|
|
359
|
+
let newTagsList = this.tagsList;
|
|
360
|
+
const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
|
|
361
|
+
const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
|
|
362
|
+
if (!tagAlreadyAdded) {
|
|
363
|
+
this.announce(this.generateTagAddedMessage(tag));
|
|
364
|
+
newTagsList = newTagsList.concat(tagExistsAsOption || tag);
|
|
365
|
+
}
|
|
366
|
+
return newTagsList;
|
|
367
|
+
}
|
|
368
|
+
removeTag(tag) {
|
|
369
|
+
const tagRemovedMessage = functions.intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: tag });
|
|
370
|
+
this.announce(tagRemovedMessage);
|
|
371
|
+
this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
|
|
372
|
+
const devOptionsList = this.csvToArray(this.options);
|
|
373
|
+
if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
|
|
374
|
+
this.removeOption(tag);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
focusListItem(item) {
|
|
378
|
+
this.focusedListItem = item;
|
|
379
|
+
item.focus();
|
|
380
|
+
}
|
|
381
|
+
focusTag(element) {
|
|
382
|
+
this.focusedTag = element;
|
|
383
|
+
this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
|
|
384
|
+
}
|
|
385
|
+
clearTagFocus() {
|
|
386
|
+
this.tagAreaEl.removeAttribute("aria-activedescendant");
|
|
387
|
+
this.focusedTag = null;
|
|
388
|
+
}
|
|
389
|
+
openDropdown() {
|
|
390
|
+
this.openUp = functions.shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight);
|
|
391
|
+
this.isExpanded = true;
|
|
392
|
+
}
|
|
393
|
+
closeDropdown() {
|
|
394
|
+
this.focusedListItem = null;
|
|
395
|
+
this.isExpanded = false;
|
|
396
|
+
}
|
|
397
|
+
clearListItemFocus() {
|
|
398
|
+
this.focusedListItem = null;
|
|
399
|
+
this.listItemEls.forEach((el) => {
|
|
400
|
+
el.tabIndex = -1;
|
|
401
|
+
el.classList.remove("focused");
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
resetInput() {
|
|
405
|
+
this.charCount = 0;
|
|
406
|
+
this.inputEl.value = "";
|
|
407
|
+
}
|
|
408
|
+
announce(message) {
|
|
409
|
+
// \u00A0 is a non-breaking space character, which causes the message to be read as a new one
|
|
410
|
+
if (this.liveRegionEl.textContent === message) {
|
|
411
|
+
message += "\u00A0";
|
|
412
|
+
}
|
|
413
|
+
this.liveRegionMessage = message;
|
|
414
|
+
}
|
|
415
|
+
announceExistingOptions() {
|
|
416
|
+
// request animation frame to wait for re-rendering of filtered options
|
|
417
|
+
window.requestAnimationFrame(() => {
|
|
418
|
+
const existingOptionsMessage = functions.intl.formatMessage({
|
|
419
|
+
id: "tagInput.existingOptions",
|
|
420
|
+
defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
|
|
421
|
+
}, { num: this.optionEls.length });
|
|
422
|
+
if (this.optionEls.length > 0) {
|
|
423
|
+
this.announce(existingOptionsMessage);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
announceCharacterLimitWarning(charCount, charLimit) {
|
|
428
|
+
const charactersEnteredMessage = functions.intl.formatMessage({
|
|
429
|
+
id: "tagInput.charactersEntered",
|
|
430
|
+
defaultMessage: "{x, number} of {y, number} characters entered.",
|
|
431
|
+
}, { x: charCount, y: charLimit });
|
|
432
|
+
const characterLimitReachedMessage = functions.intl.formatMessage({
|
|
433
|
+
id: "tagInput.characterLimitReached",
|
|
434
|
+
defaultMessage: "No additional characters will be entered.",
|
|
435
|
+
});
|
|
436
|
+
this.announce(`${charactersEnteredMessage}${charCount >= charLimit ? " " + characterLimitReachedMessage : ""}`);
|
|
437
|
+
}
|
|
438
|
+
/// Helpers
|
|
439
|
+
listToCSV(list) {
|
|
440
|
+
return list.join(",");
|
|
441
|
+
}
|
|
442
|
+
csvToArray(csv) {
|
|
443
|
+
return csv ? csv.split(/, ?/) : [];
|
|
444
|
+
}
|
|
445
|
+
includesCaseInsensitive(list, element) {
|
|
446
|
+
const lowercaseList = list.map((str) => str.toLowerCase());
|
|
447
|
+
return lowercaseList.includes(element.toLowerCase());
|
|
448
|
+
}
|
|
449
|
+
filterCaseInsensitive(list, element) {
|
|
450
|
+
return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
|
|
451
|
+
}
|
|
452
|
+
sortCaseInsensitive(list) {
|
|
453
|
+
// The vanilla .sort method places words that start with capital letters above others (ASCII order)
|
|
454
|
+
// so we need to pass in our own compare function to sort case-insensitive
|
|
455
|
+
return list.sort((a, b) => {
|
|
456
|
+
a = a.toLowerCase();
|
|
457
|
+
b = b.toLowerCase();
|
|
458
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
/// Renders
|
|
462
|
+
renderTags() {
|
|
463
|
+
return this.tagsList.map((tag, idx) => {
|
|
464
|
+
const id = `tag${idx + 1}`;
|
|
465
|
+
return (index.h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""}`, "data-tag": tag, role: "option" }, tag, index.h("button", { class: "remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) })));
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
renderListItems(optionsList) {
|
|
469
|
+
optionsList = this.sortCaseInsensitive(optionsList);
|
|
470
|
+
// filter by input
|
|
471
|
+
if (this.inputEl && this.inputEl.value) {
|
|
472
|
+
optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
|
|
473
|
+
}
|
|
474
|
+
return optionsList.map((option, idx) => {
|
|
475
|
+
const id = `option${idx + 1}`;
|
|
476
|
+
const isFocused = this.focusedListItem && this.focusedListItem.id === id;
|
|
477
|
+
const isSelected = this.includesCaseInsensitive(this.tagsList, option);
|
|
478
|
+
return (index.h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, tabIndex: isFocused ? 0 : -1, "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) }, option));
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
renderAddNewButton() {
|
|
482
|
+
if (this.inputEl.value.length > 0 &&
|
|
483
|
+
this.addNew &&
|
|
484
|
+
!this.includesCaseInsensitive(this.optionsList, this.inputEl.value)) {
|
|
485
|
+
const id = `add-new-btn`;
|
|
486
|
+
const isFocused = this.focusedListItem && this.focusedListItem.id === id;
|
|
487
|
+
return (index.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), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value}"`));
|
|
488
|
+
}
|
|
489
|
+
else
|
|
490
|
+
return "";
|
|
491
|
+
}
|
|
492
|
+
renderHelpText() {
|
|
493
|
+
const helpTextHasOptions = functions.intl.formatMessage({
|
|
494
|
+
id: "tagInput.helpTextCanSelect",
|
|
495
|
+
defaultMessage: "Search and select a tag.",
|
|
496
|
+
});
|
|
497
|
+
const helpTextEditable = functions.intl.formatMessage({
|
|
498
|
+
id: "tagInput.helpTextEditable",
|
|
499
|
+
defaultMessage: "Press the Enter or Comma key to add a new tag.",
|
|
500
|
+
});
|
|
501
|
+
let helpText = "";
|
|
502
|
+
if (this.optionsList.length > 0) {
|
|
503
|
+
helpText += helpTextHasOptions;
|
|
504
|
+
}
|
|
505
|
+
if (this.addNew) {
|
|
506
|
+
helpText += " " + helpTextEditable;
|
|
507
|
+
}
|
|
508
|
+
return helpText;
|
|
509
|
+
}
|
|
510
|
+
renderTagCounter() {
|
|
511
|
+
if (this.maxTags) {
|
|
512
|
+
return (index.h("div", { class: "lower-row" }, index.h("div", { id: "max-tags" }, this.generateTagCounterMessage(), this.tagsList.length >= this.maxTags && index.h("span", { class: "sr-only" }, this.maxTagsReachedMessage))));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
render() {
|
|
516
|
+
const isFocused = this.focusedElement &&
|
|
517
|
+
(this.focusedElement === this.inputEl ||
|
|
518
|
+
this.focusedElement === this.tagAreaEl ||
|
|
519
|
+
this.focusedElement.classList.contains("add-new-btn") ||
|
|
520
|
+
(this.optionsList.length > 0 && this.listItemEls.includes(this.focusedElement)));
|
|
521
|
+
return (index.h(index.Host, { id: this.uid }, index.h("div", { class: `wrapper label-${this.labelPosition}` }, index.h("div", { class: "label-wrapper" }, index.h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label)), index.h("div", { class: `field-wrapper ${isFocused ? "focused" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, index.h("div", { class: "upper-row" }, index.h("div", { class: "tags-and-input-wrapper" }, index.h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-horizontal": "true", "aria-label": this.tagsList.length > 0 && `${this.label} ${this.tagAreaInstructions}`, tabindex: this.tagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
|
|
522
|
+
this.clearTagFocus();
|
|
523
|
+
this.handleBlur(ev, this.el);
|
|
524
|
+
}, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags(), index.h("div", { class: "input-wrapper", role: "none" }, index.h("input", { id: `input${this.uid}`, class: this.maxTags && this.tagsList.length >= this.maxTags ? "hidden" : "", role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-controls": "dropdown", "aria-describedby": "help-text", "aria-label": this.label, placeholder: this.placeholder, maxLength: this.characterLimit, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
|
|
525
|
+
this.handleBlur(ev, this.el);
|
|
526
|
+
}, onFocus: () => {
|
|
527
|
+
this.openDropdown();
|
|
528
|
+
this.clearListItemFocus();
|
|
529
|
+
}, onKeyDown: (ev) => this.handleInputKeyDown(ev) })))), index.h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit)), this.renderTagCounter(), index.h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}` }, index.h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), index.h("ul", { class: "dropdown", ref: (el) => (this.dropdownEl = el), 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)))), this.info ? (index.h("div", { id: "info", class: "info-text" }, this.info)) : (""), index.h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage))));
|
|
530
|
+
}
|
|
531
|
+
get el() { return index.getElement(this); }
|
|
532
|
+
static get watchers() { return {
|
|
533
|
+
"tagsList": ["reflectSelectedTags"]
|
|
534
|
+
}; }
|
|
535
|
+
};
|
|
536
|
+
TagInput.style = wmTagInputCss;
|
|
537
|
+
|
|
538
|
+
exports.wm_tag_input = TagInput;
|