diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..59b4521 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,34 @@ +Issue number: resolves # + +--------- + + + + + +## What is the current behavior? + + +## What is the new behavior? + + +- +- +- + +## Does this introduce a breaking change? + +- [ ] Yes +- [ ] No + + + + +## Other information + + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 967f0c3..f50d75f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ node_modules ts-types videos -package-lock.json diff --git a/cypress/e2e/examples.cy.ts b/cypress/e2e/examples.cy.ts index 4080d3a..da8a4e5 100644 --- a/cypress/e2e/examples.cy.ts +++ b/cypress/e2e/examples.cy.ts @@ -749,6 +749,402 @@ describe('Search descriptions with and without normalize', () => { }); }); +// // // // // +// // // // // Multi-language search normalize +// // // // // + +describe('Multi-language search with searchNormalize: true', () => { + const id = 'multi-language-search-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + // Latin (French / Spanish) + it('Latin: finds Crème brûlée when searching "creme"', () => { + cy.open(id).search('creme').checkFirstOption('Crème brûlée'); + }); + + it('Latin: finds Niño when searching "nino"', () => { + cy.getVs(id).search('nino').checkFirstOption('Niño'); + }); + + // German + it('German: finds München when searching "Munchen"', () => { + cy.getVs(id).search('Munchen').checkFirstOption('München'); + }); + + it('German: finds Mädchen when searching "Madchen"', () => { + cy.getVs(id).search('Madchen').checkFirstOption('Mädchen'); + }); + + it('German: ß is atomic — searching "Grosse" does NOT find "Größe"', () => { + cy.getVs(id).search('Grosse').hasNoOptions(); + }); + + // Norwegian + it('Norwegian: finds Ålesund when searching "Alesund" (å decomposes)', () => { + cy.getVs(id).search('Alesund').checkFirstOption('Ålesund'); + }); + + it('Norwegian: ø is atomic — searching "Bjorn" does NOT find "Bjørn"', () => { + cy.getVs(id).search('Bjorn').hasNoOptions(); + }); + + // Swedish + it('Swedish: finds Göteborg when searching "Goteborg"', () => { + cy.getVs(id).search('Goteborg').checkFirstOption('Göteborg'); + }); + + it('Swedish: finds Malmö when searching "Malmo"', () => { + cy.getVs(id).search('Malmo').checkFirstOption('Malmö'); + }); + + // Finnish + it('Finnish: finds Jyväskylä when searching "Jyvaskyla"', () => { + cy.getVs(id).search('Jyvaskyla').checkFirstOption('Jyväskylä'); + }); + + it('Finnish: finds Hämeenlinna when searching "Hameenlinna"', () => { + cy.getVs(id).search('Hameenlinna').checkFirstOption('Hämeenlinna'); + }); + + // Greek + it('Greek: finds Ένα when searching with accent', () => { + cy.getVs(id).search('Ένα').checkFirstOption('Ένα'); + }); + + it('Greek: finds Ένα when searching "Ενα" (without accent)', () => { + cy.getVs(id).search('Ενα').checkFirstOption('Ένα'); + }); + + it('Greek: finds Αθήνα by normalized description ("Πρωτευουσα")', () => { + cy.getVs(id).search('Πρωτευουσα').checkFirstOption('Αθήνα'); + }); + + // Cyrillic + it('Cyrillic: finds Ёжик when searching with ё (exact)', () => { + cy.getVs(id).search('Ёжик').checkFirstOption('Ёжик'); + }); + + it('Cyrillic: finds Ёжик when searching "Ежик" (е instead of ё)', () => { + cy.getVs(id).search('Ежик').checkFirstOption('Ёжик'); + }); + + it('Cyrillic: finds Ёжик by normalized description (зверёк → зверек)', () => { + cy.getVs(id).search('зверек').checkFirstOption('Ёжик'); + }); + + // Vietnamese + it('Vietnamese: finds Việt Nam when searching "Viet Nam"', () => { + cy.getVs(id).search('Viet Nam').checkFirstOption('Việt Nam'); + }); + + it('Vietnamese: finds Hà Nội when searching "Ha Noi"', () => { + cy.getVs(id).search('Ha Noi').checkFirstOption('Hà Nội'); + }); + + // Chinese + it('Chinese: finds 北京 when searching "北京" (preserved as-is)', () => { + cy.getVs(id).search('北京').checkFirstOption('北京'); + }); + + it('Chinese: finds 北京 by description "首都"', () => { + cy.getVs(id).search('首都').checkFirstOption('北京'); + }); + + // Japanese + it('Japanese: finds 東京 when searching kanji', () => { + cy.getVs(id).search('東京').checkFirstOption('東京'); + }); + + it('Japanese: finds カタカナ (katakana preserved as-is)', () => { + cy.getVs(id).search('カタカナ').checkFirstOption('カタカナ'); + }); + + // Korean + it('Korean: finds 서울 (NFD-normalized symmetrically)', () => { + cy.getVs(id).search('서울').checkFirstOption('서울'); + }); + + it('Korean: finds 한국어', () => { + cy.getVs(id).search('한국어').checkFirstOption('한국어'); + }); + + // Arabic + it('Arabic: finds مُرَحَّباً when searching "مرحبا" (tashkeel stripped)', () => { + cy.getVs(id).search('مرحبا').checkFirstOption('مُرَحَّباً'); + }); + + // Thai + it('Thai: finds กรุงเทพ when searching exact text', () => { + cy.getVs(id).search('กรุงเทพ').checkFirstOption('กรุงเทพ'); + }); + + // Intra-word punctuation regression — guards the second .replace() pass + // that strips non-letter characters in a Unicode-aware way. + it('Intra-word punctuation: finds "co-op" when searching "coop"', () => { + cy.getVs(id).search('coop').checkFirstOption('co-op'); + }); + + it('Intra-word punctuation: finds "e-mail" when searching "email"', () => { + cy.getVs(id).search('email').checkFirstOption('e-mail'); + }); + + // Whitespace folding regression — labels with spaces match spaceless searches + it('Whitespace folding: finds "Foo Bar" when searching "FooBar" (no space)', () => { + cy.getVs(id).search('FooBar').checkFirstOption('Foo Bar'); + }); + + it('Whitespace folding: finds "Foo Bar" when searching "Foo Bar" (with space)', () => { + cy.getVs(id).search('Foo Bar').checkFirstOption('Foo Bar'); + }); + + it('Whitespace folding: finds "Việt Nam" when searching "VietNam" (no space)', () => { + cy.getVs(id).search('VietNam').checkFirstOption('Việt Nam'); + }); + + // Symmetric punctuation — label has no punctuation, search has it + it('Symmetric punctuation: finds "walkthrough" when searching "walk-through"', () => { + cy.getVs(id).search('walk-through').checkFirstOption('walkthrough'); + }); + + // Numbers (\p{N}) preserved alongside letters; non-letter chars fold both ways + it('Numbers preserved: finds "Mars-2024" when searching "Mars2024"', () => { + cy.getVs(id).search('Mars2024').checkFirstOption('Mars-2024'); + }); + + it('Numbers preserved: finds "Mars-2024" when searching "Mars 2024" (with space)', () => { + cy.getVs(id).search('Mars 2024').checkFirstOption('Mars-2024'); + }); + + // Leading/trailing whitespace in the search input still matches + it('Search whitespace: leading/trailing whitespace still finds Crème brûlée', () => { + cy.getVs(id).search(' creme ').checkFirstOption('Crème brûlée'); + }); + + // Edge case — pure-punctuation search normalizes to "" and currently + // matches every label via includes(""). This test documents the + // behavior; if it's later considered a bug, update the assertion. + it('Empty-after-normalize: pure-punctuation search currently matches options', () => { + cy.getVs(id).search('!@#'); + cy.getDropbox(null, id).find('[role="option"]').should('have.length.greaterThan', 1); + }); + + // Negative case + it('does not find non-existent text', () => { + cy.getVs(id).search('zzznotfound').hasNoOptions().close(); + }); +}); + +describe('Multi-language search with searchNormalize: false', () => { + const id = 'multi-language-search-no-normalize-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + // Exact matches — should work + it('Latin: finds Crème brûlée only when searching with diacritics', () => { + cy.open(id).search('Crème').checkFirstOption('Crème brûlée'); + }); + + it('Greek: finds Ένα when searching exact "Ένα"', () => { + cy.getVs(id).search('Ένα').checkFirstOption('Ένα'); + }); + + it('Cyrillic: finds Ёжик when searching exact "Ёжик"', () => { + cy.getVs(id).search('Ёжик').checkFirstOption('Ёжик'); + }); + + it('Chinese: finds 北京 (no normalization needed)', () => { + cy.getVs(id).search('北京').checkFirstOption('北京'); + }); + + it('Japanese: finds 東京 (no normalization needed)', () => { + cy.getVs(id).search('東京').checkFirstOption('東京'); + }); + + it('Korean: finds 서울 (no normalization needed)', () => { + cy.getVs(id).search('서울').checkFirstOption('서울'); + }); + + // Negative cases — without normalize, accent-stripped searches should not match + it('Latin: does NOT find Crème brûlée when searching "creme" (no normalize)', () => { + cy.getVs(id).search('creme').hasNoOptions(); + }); + + it('German: does NOT find München when searching "Munchen"', () => { + cy.getVs(id).search('Munchen').hasNoOptions(); + }); + + it('Swedish: does NOT find Göteborg when searching "Goteborg"', () => { + cy.getVs(id).search('Goteborg').hasNoOptions(); + }); + + it('Finnish: does NOT find Jyväskylä when searching "Jyvaskyla"', () => { + cy.getVs(id).search('Jyvaskyla').hasNoOptions(); + }); + + it('Greek: does NOT find Ένα when searching "Ενα" (no accent)', () => { + cy.getVs(id).search('Ενα').hasNoOptions(); + }); + + it('Cyrillic: does NOT find Ёжик when searching "Ежик" (е instead of ё)', () => { + cy.getVs(id).search('Ежик').hasNoOptions(); + }); + + it('Vietnamese: does NOT find Việt Nam when searching "Viet Nam"', () => { + cy.getVs(id).search('Viet Nam').hasNoOptions(); + }); + + it('Arabic: does NOT find مُرَحَّباً when searching "مرحبا" (tashkeel mismatch)', () => { + cy.getVs(id).search('مرحبا').hasNoOptions(); + }); + + it('Intra-word punctuation: does NOT find "co-op" when searching "coop"', () => { + cy.getVs(id).search('coop').hasNoOptions().close(); + }); +}); + +describe('Multi-language tags variant with searchNormalize: true', () => { + const id = 'multi-language-tags-search-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + it('finds München with normalized search "Munchen"', () => { + cy.open(id).search('Munchen').checkFirstOption('München'); + }); + + it('selects München and renders it as a value tag', () => { + cy.getVs(id).selectOption('munchen'); + cy.getVs(id).hasValueTags(['München']); + }); + + it('finds Việt Nam with normalized search and adds a second tag', () => { + cy.getVs(id).search('Viet Nam').checkFirstOption('Việt Nam'); + cy.getVs(id).selectOption('vietnam'); + cy.getVs(id).hasValueTags(['München', 'Việt Nam']); + cy.getVs(id).checkValueTagsCount(2); + }); + + it('finds Ёжик with normalized search "Ежик" and adds Cyrillic tag', () => { + cy.getVs(id).search('Ежик').checkFirstOption('Ёжик'); + cy.getVs(id).selectOption('yozhik'); + cy.getVs(id).hasValueTags(['München', 'Việt Nam', 'Ёжик']); + cy.getVs(id).checkValueTagsCount(3); + }); + + it('removes a value tag and reduces tag count', () => { + cy.getVs(id).removeValueTag('München').checkValueTagsCount(2); + }); + + it('finds CJK options as-is (Chinese 北京)', () => { + cy.getVs(id).search('北京').checkFirstOption('北京'); + cy.getVs(id).selectOption('beijing'); + cy.getVs(id).checkValueTagsCount(3).close(); + }); +}); + +describe('Multi-language tags variant with searchNormalize: false', () => { + const id = 'multi-language-tags-search-no-normalize-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + it('does NOT find München when searching "Munchen" (no normalize)', () => { + cy.open(id).search('Munchen').hasNoOptions(); + }); + + it('finds München only when searching with diacritics and tags it', () => { + cy.getVs(id).search('München').checkFirstOption('München'); + cy.getVs(id).selectOption('munchen'); + cy.getVs(id).hasValueTags(['München']); + cy.getVs(id).checkValueTagsCount(1); + }); + + it('finds Ёжик only with exact ё (not "Ежик")', () => { + cy.getVs(id).search('Ежик').hasNoOptions(); + cy.getVs(id).search('Ёжик').checkFirstOption('Ёжик'); + cy.getVs(id).selectOption('yozhik'); + cy.getVs(id).hasValueTags(['München', 'Ёжик']); + cy.getVs(id).checkValueTagsCount(2).close(); + }); +}); + +describe('Multi-language popup variant with searchNormalize: true', () => { + const id = 'multi-language-popup-search-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + it('opens as a popup and finds München with normalized search', () => { + cy.open(id).search('Munchen').checkFirstOption('München'); + }); + + it('finds Việt Nam with normalized search inside popup', () => { + cy.getVs(id).search('Viet Nam').checkFirstOption('Việt Nam'); + }); + + it('finds Ёжик with normalized search "Ежик" inside popup', () => { + cy.getVs(id).search('Ежик').checkFirstOption('Ёжик'); + }); + + it('finds CJK options as-is (Japanese 東京)', () => { + cy.getVs(id).search('東京').checkFirstOption('東京'); + cy.closePopup(id); + }); +}); + +describe('Multi-language popup variant with searchNormalize: false', () => { + const id = 'multi-language-popup-search-no-normalize-select'; + + it('go to section', () => { + cy.goToSection('Multi-language search normalize'); + }); + + it('opens as a popup and does NOT find München with normalized search', () => { + cy.open(id).search('Munchen').hasNoOptions(); + }); + + it('finds München only when searching with diacritics inside popup', () => { + cy.getVs(id).search('München').checkFirstOption('München'); + }); + + it('CJK options still match as-is (no normalization needed)', () => { + cy.getVs(id).search('서울').checkFirstOption('서울'); + cy.closePopup(id); + }); +}); + +describe('Latin diacritics regression with normalize', () => { + const normalizedId = 'with-description-normalized-search-select'; + + it('go to section', () => { + cy.goToSection('Description search normalize'); + }); + + it('still normalizes Latin descriptions (brulee finds brûlée)', () => { + cy.open(normalizedId).search('brulee').checkFirstOption('Beta'); + }); + + it('still normalizes Latin descriptions (cafe finds café)', () => { + cy.getVs(normalizedId).search('cafe').checkFirstOption('Alpha'); + }); + + it('still normalizes Latin descriptions (nino finds niño)', () => { + cy.getVs(normalizedId).search('nino').checkFirstOption('Gamma').close(); + }); +}); + +// // // // // +// // // // // Show dropbox as popup +// // // // // + describe('Show dropbox as popup - Clear search text', () => { const id = 'multiple-show-as-popup-select'; diff --git a/dist-archive/virtual-select-1.1.5.min.css b/dist-archive/virtual-select-1.1.5.min.css index 0966e2a..48aa3d6 100644 --- a/dist-archive/virtual-select-1.1.5.min.css +++ b/dist-archive/virtual-select-1.1.5.min.css @@ -3,7 +3,7 @@ * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) */ -@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} +@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} /*! * Popover v1.0.13 * https://sa-si-dev.github.io/popover diff --git a/dist-archive/virtual-select-1.1.5.min.js b/dist-archive/virtual-select-1.1.5.min.js index 8c5129e..169586d 100644 --- a/dist-archive/virtual-select-1.1.5.min.js +++ b/dist-archive/virtual-select-1.1.5.min.js @@ -2,4 +2,4 @@ * Virtual Select v1.1.5 * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) - */!function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);i1&&void 0!==arguments[1]&&arguments[1]}},{key:"isEmpty",value:function(e){var t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"===i(e)&&0===Object.keys(e).length&&(t=!0):t=!0,t}},{key:"isNotEmpty",value:function(e){return!t.isEmpty(e)}},{key:"normalizeValues",value:function(e){if(Array.isArray(e)){for(var t=new Array(e.length),i=0;i2&&void 0!==arguments[2]&&arguments[2];if(!Array.isArray(t)||!t.length)return t;var s=o?e(t):t,n=s.indexOf(i);return-1!==n&&s.splice(n,1),s}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"getRandomInt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-i-1))+i}},{key:"regexEscape",value:function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}},{key:"normalizeString",value:function(e){return e.normalize("NFD").replace(/[^\w]/g,"")}},{key:"willTextOverflow",value:function(e,t){var i=document.createElement("div");i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="nowrap",i.style.fontSize=window.getComputedStyle(e).fontSize,i.style.fontFamily=window.getComputedStyle(e).fontFamily,i.textContent=t,document.body.appendChild(i);var o=i.clientWidth;return document.body.removeChild(i),o>e.clientWidth}},{key:"replaceDoubleQuotesWithHTML",value:function(e){return e.replace(/"/g,""")}},{key:"containsHTML",value:function(e){return/<[a-z][\s\S]*>/i.test(e)}},{key:"containsHTMLorJS",value:function(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}],(n=null)&&o(s.prototype,n),r&&o(s,r),Object.defineProperty(s,"prototype",{writable:!1}),s;var s,n,r}();function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o,s,n,r,a=[],l=!0,u=!1;try{if(n=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(o=n.call(i)).done)&&(a.push(o.value),a.length!==t);l=!0);}catch(e){u=!0,s=e}finally{try{if(!l&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(u)throw s}}return a}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"==typeof e)return c(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);ie.offsetWidth}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setAttr",value:function(e,t,i){e&&e.setAttribute(t,i)}},{key:"setAttrFromEle",value:function(e,t,i,o){var s={};i.forEach(function(t){s[t]=e.getAttribute(t)}),i.forEach(function(e){var i=s[e];(i||-1!==o.indexOf(e)&&""===i)&&t.setAttribute(e,i)})}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"setStyles",value:function(e,t){e&&t&&Object.keys(t).forEach(function(i){e.style[i]=t[i]})}},{key:"setAria",value:function(e,t,i){if(e){var o=t;"role"!==o&&(o="aria-".concat(o)),e.setAttribute(o,i)}}},{key:"getElements",value:function(e){return e?void 0===e.forEach?[e]:e:[]}},{key:"getElementsBySelector",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=void 0!==i?i:document;return""!==t&&(e=o.querySelectorAll(t)),void 0!==e?Array.from(e):[]}},{key:"addEvent",value:function(t,i,o,s){t&&n.removeArrayEmpty(i.split(" ")).forEach(function(i){e.getElements(t).forEach(function(e){e.addEventListener(i,o,{capture:s})})})}},{key:"dispatchEvent",value:function(t,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t){var s=e.getElements(t);setTimeout(function(){s.forEach(function(e){e.dispatchEvent(new CustomEvent(i,{bubbles:o}))})},0)}}},{key:"getAttributesText",value:function(e){var t="";return e?(Object.entries(e).forEach(function(e){var i=a(e,2),o=i[0],s=i[1];void 0!==s&&(t+=" ".concat(o,'="').concat(s,'" '))}),t):t}},{key:"convertPropToDataAttr",value:function(e){return e?"data-".concat(e).replace(/([A-Z])/g,"-$1").toLowerCase():""}},{key:"changeTabIndex",value:function(t,i){t?e.getElements(t).forEach(function(e){e.tabIndex=i}):console.log(t,"Invalid element provided.")}},{key:"removeEvent",value:function(t,i,o){t&&e.getElements(t).forEach(function(e){e.removeEventListener(i,o)})}}],(i=null)&&p(t.prototype,i),o&&p(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,o)}return i}function f(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,o=Array(t);i\n \n
\n
\n ").concat(this.placeholder,'\n
\n
\n
\n \n
\n
\n\n ').concat(this.renderDropbox({wrapperClasses:t}),"\n ");this.$ele.innerHTML=u,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),d.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}}},{key:"renderDropbox",value:function(e){var t=e.wrapperClasses,i="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null,o="vscomp-dropbox";this.additionalDropboxClasses&&(o+=" ".concat(this.additionalDropboxClasses));var s="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(s+=" ".concat(this.additionalDropboxContainerClasses));var n='
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
').concat(this.noOptionsText,'
\n
').concat(this.noSearchResultsText,'
\n\n \n
\n \n
');if(i){var r=document.createElement("div");return this.$dropboxWrapper=r,this.hasDropboxWrapper=!0,r.innerHTML=n,i.appendChild(r),d.addClass(r,"vscomp-dropbox-wrapper ".concat(t)),this.keepAlwaysOpen||(d.setAttr(r,"tabindex","-1"),d.setAria(r,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}},{key:"renderOptions",value:function(){var e=this;this.calculateAriaMetadata();var t,i="",o=this.getVisibleOptions(),s="",r="",a=!(!this.markSearchResults||!this.searchValue),l=this.labelRenderer,u=this.disableOptionGroupCheckbox,c=this.uniqueId,p=this.searchGroup,h="function"==typeof l,d=n.convertToBoolean,v="";if(a&&(t=new RegExp("(".concat(n.regexEscape(this.searchValue),")(?!([^<]+)?>)"),"gi")),this.multiple&&(s=''),this.allowNewOption){var f=this.getTooltipAttrText("New Option");r='")}o.forEach(function(o){var n,f=o.index,b="vscomp-option",y=e.getTooltipAttrText("",!0,!0),m=s,g="",O="",S="",x="",w="-1",k=d(o.isSelected),C="";if(o.classNames&&(b+=" ".concat(o.classNames)),o.isFocused&&(w="0",b+=" focused"),o.isDisabled&&(b+=" disabled",C='aria-disabled="true"'),o.isGroupTitle&&(v=o.label,b+=" group-title",u&&(m="")),k&&(b+=" selected"),o.isGroupOption){var E="";b+=" group-option",S='data-group-index="'.concat(o.groupIndex,'"'),o.customData?(v=void 0!==o.customData.group_name?"".concat(o.customData.group_name,", "):"",E=void 0!==o.customData.description?" ".concat(o.customData.description,","):"",x='aria-label="'.concat(v," ").concat(o.label,", ").concat(E,'"')):x='aria-label="'.concat(v,", ").concat(o.label,'"')}n=h?l(o):o.label,o.description&&(O='
").concat(o.description,"
")),o.isCurrentNew?(b+=" current-new",g+=r):!a||o.isGroupTitle&&!p||(n=n.replace(t,"$1"));var $="";e.ariaSetSize>0&&($='aria-setsize="'.concat(e.ariaSetSize,'"'),o.filteredIndex&&($+=' aria-posinset="'.concat(o.filteredIndex,'"'))),i+='
\n ").concat(n,"\n \n ").concat(O,"\n ").concat(g,"\n
")}),v="",this.$options.innerHTML=i,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}},{key:"renderSearch",value:function(){if(this.hasSearchContainer){var e="",t="";if(this.multiple&&!this.disableSelectAll&&(e='\n \n ').concat(this.selectAllText,"\n ")),this.hasSearch){var i=this.ariaLabelSearchClearButtonText?'aria-label="'.concat(this.ariaLabelSearchClearButtonText,'"'):"";t='\n \n ×")}var o='
\n '.concat(e,"\n ").concat(t,"\n
");this.$search.innerHTML=o,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}}},{key:"addEvents",value:function(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}},{key:"addEvent",value:function(e,t,i){var o=this,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var n="".concat(i,"-").concat(t),r=o.events[n];r||(r=o[i].bind(o),o.events[n]=r),d.addEvent(e,t,r,s)})}},{key:"removeEvents",value:function(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}},{key:"removeEvent",value:function(e,t,i){var o=this;e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var s="".concat(i,"-").concat(t),n=o.events[s];n&&d.removeEvent(e,t,n)})}},{key:"onDocumentClick",value:function(t){var i=t.target.closest(".vscomp-wrapper");if(i){var o=i.parentElement.virtualSelect;o&&o!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}else e.openInstances.forEach(function(e){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()})}},{key:"onKeyDown",value:function(e){var t=e.which||e.keyCode,i=C[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){var o=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(o&&(document.activeElement===o||o.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}i&&this[i](e)}else this.toggleAllOptions()}},{key:"onEnterPress",value:function(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}},{key:"onDownArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}},{key:"onUpArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}},{key:"onBackspaceOrDeletePress",value:function(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}},{key:"onToggleButtonPress",value:function(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}var t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}},{key:"onClearButtonClick",value:function(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}},{key:"onOptionsScroll",value:function(){this.setVisibleOptions(!0)}},{key:"onOptionsClick",value:function(e){var t=e.target.closest(".vscomp-option");t&&!d.hasClass(t,"disabled")&&(d.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}},{key:"onGroupTitleClick",value:function(e){if(e&&this.multiple&&!this.disableOptionGroupCheckbox){var t=!d.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}}},{key:"onDropboxContainerClick",value:function(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}},{key:"onDropboxCloseButtonClick",value:function(){this.closeDropbox()}},{key:"onOptionsMouseOver",value:function(e){var t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(d.hasClass(t,"disabled")||d.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}},{key:"onOptionsTouchMove",value:function(){this.removeOptionFocus()}},{key:"onSearch",value:function(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}},{key:"preventPropagation",value:function(e){e.stopPropagation()}},{key:"onSearchClear",value:function(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}},{key:"onToggleAllOptions",value:function(){this.toggleAllOptions()}},{key:"onDropboxContainerTopOrBottomFocus",value:function(){this.closeDropbox()}},{key:"onResize",value:function(){this.setOptionsContainerHeight(!0)}},{key:"addMutationObserver",value:function(){var e=this;if(this.hasDropboxWrapper){var t=this.$ele;this.mutationObserver=new MutationObserver(function(i){var o=!1,s=!1;i.forEach(function(e){o||(o=g(e.addedNodes).some(function(e){return!(e!==t&&!e.contains(t))})),s||(s=g(e.removedNodes).some(function(e){return!(e!==t&&!e.contains(t))}))}),s&&!o&&e.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}}},{key:"removeMutationObserver",value:function(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}},{key:"beforeValueSet",value:function(e){this.toggleAllOptionsClass(!e&&void 0)}},{key:"beforeSelectNewValue",value:function(e){var t=this,i=this.getNewOption();if(i){var o=i.index;this.newValues.push(i.value),this.setOptionProp(o,"isCurrentNew",!1),this.setOptionProp(o,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(function(){t.setSearchValue(""),t.focusSearchInput()},0)}},{key:"afterRenderWrapper",value:function(){d.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}},{key:"afterRenderOptions",value:function(){var e=this,t=this.getVisibleOptions(),i=!this.options.length&&!this.hasServerSearch,o=!i&&!t.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(d.toggleClass(this.$allWrappers,"has-no-search-results",o),o?(d.setAttr(this.$noSearchResults,"tabindex","0"),d.setAttr(this.$noSearchResults,"aria-hidden","false")):(d.setAttr(this.$noSearchResults,"tabindex","-1"),d.setAttr(this.$noSearchResults,"aria-hidden","true"))),d.toggleClass(this.$allWrappers,"has-no-options",i),i?(d.setAttr(this.$noOptions,"tabindex","0"),d.setAttr(this.$noOptions,"aria-hidden","false")):(d.setAttr(this.$noOptions,"tabindex","-1"),d.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(function(){var t=d.getElementsBySelector(".focused",e.$dropboxContainer)[0];void 0!==t&&t.focus({preventScroll:!0})},20)}},{key:"afterSetOptionsContainerHeight",value:function(e){e&&this.showAsPopup&&this.setVisibleOptions()}},{key:"afterSetSearchValue",value:function(){var e=this;this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(function(){e.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}},{key:"afterSetVisibleOptionsCount",value:function(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}},{key:"afterValueSet",value:function(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}},{key:"afterSetOptions",value:function(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}},{key:"setProps",value:function(e){var t=this.setDefaultProps(e);this.setPropsFromElementAttr(t);var i=n.convertToBoolean;this.$ele=t.ele,this.dropboxWrapper=t.dropboxWrapper,this.valueKey=t.valueKey,this.labelKey=t.labelKey,this.descriptionKey=t.descriptionKey,this.aliasKey=t.aliasKey,this.optionHeightText=t.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(t.multiple),this.hasSearch=i(t.search),this.searchByStartsWith=i(t.searchByStartsWith),this.searchGroup=i(t.searchGroup),this.hideClearButton=i(t.hideClearButton),this.autoSelectFirstOption=i(t.autoSelectFirstOption),this.hasOptionDescription=i(t.hasOptionDescription),this.silentInitialValueSet=i(t.silentInitialValueSet),this.allowNewOption=i(t.allowNewOption),this.markSearchResults=i(t.markSearchResults),this.showSelectedOptionsFirst=i(t.showSelectedOptionsFirst),this.disableSelectAll=i(t.disableSelectAll),this.keepAlwaysOpen=i(t.keepAlwaysOpen),this.showDropboxAsPopup=i(t.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(t.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(t.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(t.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(t.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(t.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(t.disableAllOptionsSelectedText),this.showValueAsTags=i(t.showValueAsTags),this.disableOptionGroupCheckbox=i(t.disableOptionGroupCheckbox),this.enableSecureText=i(t.enableSecureText),this.setValueAsArray=i(t.setValueAsArray),this.disableValidation=i(t.disableValidation),this.initialDisabled=i(t.disabled),this.required=i(t.required),this.autofocus=i(t.autofocus),this.useGroupValue=i(t.useGroupValue),this.focusSelectedOptionOnOpen=i(t.focusSelectedOptionOnOpen),this.noOptionsText=t.noOptionsText,this.noSearchResultsText=t.noSearchResultsText,this.selectAllText=t.selectAllText,this.searchNormalize=t.searchNormalize,this.searchPlaceholderText=t.searchPlaceholderText,this.searchFormLabel=t.searchFormLabel,this.optionsSelectedText=t.optionsSelectedText,this.optionSelectedText=t.optionSelectedText,this.allOptionsSelectedText=t.allOptionsSelectedText,this.clearButtonText=t.clearButtonText,this.moreText=t.moreText,this.placeholder=t.placeholder,this.position=t.position,this.textDirection=t.textDirection,this.dropboxWidth=t.dropboxWidth,this.tooltipFontSize=t.tooltipFontSize,this.tooltipAlignment=t.tooltipAlignment,this.tooltipMaxWidth=t.tooltipMaxWidth,this.updatePositionThrottle=t.updatePositionThrottle,this.noOfDisplayValues=parseInt(t.noOfDisplayValues),this.zIndex=parseInt(t.zIndex),this.maxValues=parseInt(t.maxValues),this.minValues=parseInt(t.minValues),this.name=this.secureText(t.name),this.additionalClasses=t.additionalClasses,this.additionalDropboxClasses=t.additionalDropboxClasses,this.additionalDropboxContainerClasses=t.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=t.additionalToggleButtonClasses,this.popupDropboxBreakpoint=t.popupDropboxBreakpoint,this.popupPosition=t.popupPosition,this.onServerSearch=t.onServerSearch,this.labelRenderer=t.labelRenderer,this.selectedLabelRenderer=t.selectedLabelRenderer,this.initialSelectedValue=0===t.selectedValue?"0":t.selectedValue,this.emptyValue=t.emptyValue,this.ariaLabelText=t.ariaLabelText,this.ariaLabelledby=t.ariaLabelledby,this.ariaLabelClearButtonText=t.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=t.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=t.ariaLabelSearchClearButtonText,this.maxWidth=t.maxWidth,this.searchDelay=t.searchDelay,this.showDuration=parseInt(t.showDuration),this.hideDuration=parseInt(t.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===t.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(t.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}},{key:"setDefaultProps",value:function(e){var t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}},{key:"setPropsFromElementAttr",value:function(e){var t=e.ele;Object.keys(k).forEach(function(i){var o=t.getAttribute(i);-1===E.indexOf(i)||""!==o&&"true"!==o||(o=!0),o&&(e[k[i]]=o)})}},{key:"setEleProps",value:function(){var t=this.$ele;t.virtualSelect=this,t.value=this.multiple?[]:"",t.name=this.name,t.disabled=!1,t.required=this.required,t.autofocus=this.autofocus,t.multiple=this.multiple,t.form=t.closest("form"),t.reset=e.reset,t.setValue=e.setValueMethod,t.setOptions=e.setOptionsMethod,t.setDisabledOptions=e.setDisabledOptionsMethod,t.setEnabledOptions=e.setEnabledOptionsMethod,t.toggleSelectAll=e.toggleSelectAll,t.isAllSelected=e.isAllSelected,t.addOption=e.addOptionMethod,t.getNewValue=e.getNewValueMethod,t.getDisplayValue=e.getDisplayValueMethod,t.getSelectedOptions=e.getSelectedOptionsMethod,t.getDisabledOptions=e.getDisabledOptionsMethod,t.open=e.openMethod,t.close=e.closeMethod,t.focus=e.focusMethod,t.enable=e.enableMethod,t.disable=e.disableMethod,t.destroy=e.destroyMethod,t.validate=e.validateMethod,t.toggleRequired=e.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}},{key:"setValueMethod",value:function(e,t){var i={},o={},s=[],r=this.multiple,a=n.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){var l=this.maxValues;l&&a.length>l&&a.splice(l)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach(function(e,t){i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}if(this.options.forEach(function(e){var t=n.normalizeValues(e.value);!0!==i[t]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,s.push(e.value))}),r)this.hasOptionGroup&&this.setGroupsSelectedProp(),s.sort(function(e,t){return o[n.normalizeValues(e)]-o[n.normalizeValues(t)]});else{var u=m(s,1);s=u[0]}this.beforeValueSet(),this.setValue(s,{disableEvent:t}),this.afterValueSet()}},{key:"setGroupOptionsValue",value:function(e){var t=[],i={},o={};return e.forEach(function(e){o[e]=!0}),this.options.forEach(function(e){var s=e.value,n=!0===o[s];e.isGroupTitle?n&&(i[e.index]=!0):(n||i[e.groupIndex])&&t.push(s)}),t}},{key:"setGroupsSelectedProp",value:function(){var e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(function(t){t.isGroupTitle&&(t.isSelected=e(t.index))})}},{key:"setOptionsMethod",value:function(e,t){this.setOptions(e),this.afterSetOptions(t)}},{key:"setDisabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setDisabledOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];if(e)if(!0===e)t&&this.options.forEach(function(e){return e.isDisabled=!0,i.push(e.value),e});else{i=e.map(function(e){return e.toString()});var o={};i.forEach(function(e){o[e]=!0}),t&&this.options.forEach(function(e){return e.isDisabled=!0===o[e.value],e})}else t&&this.options.forEach(function(e){return e.isDisabled=!1,e});this.disabledOptions=i}},{key:"setEnabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setEnabledOptions",value:function(e){if(void 0!==e){var t=[];if(!0===e)this.options.forEach(function(e){return e.isDisabled=!1,e});else{var i={};e.forEach(function(e){i[e]=!0}),this.options.forEach(function(e){var o=!0!==i[e.value];return e.isDisabled=o,o&&t.push(e.value),e})}this.disabledOptions=t}}},{key:"setOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=[],o=this.disabledOptions.length,s=this.valueKey,r=this.labelKey,a=this.descriptionKey,l=this.aliasKey,u=this.hasOptionDescription,c=n.getString,p=n.convertToBoolean,h=this.secureText.bind(this),d=this.getAlias.bind(this),v=0,f=!1,m={},g=!1;this.disabledOptions.forEach(function(e){m[e]=!0});var O=function(t){"object"!==y(t)&&(t=b(b({},s,t),r,t));var S=h(c(t[s])),x=h(c(t[r])),w=t.options,k=!!w,C={index:v,value:S,valueNormalized:S.toLowerCase(),label:x,labelNormalized:e.searchNormalize&&""!==x.trim()?n.normalizeString(x).toLowerCase():x.toLowerCase(),alias:d(t[l]),isVisible:p(t.isVisible,!0),isNew:t.isNew||!1,isGroupTitle:k,classNames:t.classNames};if(g||""!==S||(g=!0),o&&(C.isDisabled=!0===m[S]),t.isGroupOption&&(C.isGroupOption=!0,C.groupIndex=t.groupIndex),u){var E=h(c(t[a]));C.description=E,C.descriptionNormalized=e.searchNormalize&&""!==E.trim()?n.normalizeString(E).toLowerCase():E.toLowerCase()}if(t.customData&&(C.customData=t.customData),i.push(C),v+=1,k){var $=C.index;f=!0,w.forEach(function(e){e.isGroupOption=!0,e.groupIndex=$,O(e)})}};Array.isArray(t)&&t.forEach(O);var S=i.length,x=this.$ele;x.options=i,x.length=S,this.options=i,this.visibleOptionsCount=S,this.lastOptionIndex=S-1,this.newValues=[],this.hasOptionGroup=f,this.hasEmptyValueOption=g,this.setSortedOptions()}},{key:"setServerOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setOptionsMethod(t,!0);var i=this.selectedOptions,o=this.options,s=!1;if(i.length){var n={};s=!0,o.forEach(function(e){n[e.value]=!0}),i.forEach(function(e){!0!==n[e.value]&&(e.isVisible=!1,o.push(e))}),this.setOptionsMethod(o,!0)}this.allowNewOption&&this.searchValue&&(o.some(function(t){return t.label.toLowerCase()===e.searchValue})||(s=!0,this.setNewOption())),s?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),d.removeClass(this.$allWrappers,"server-searching")}},{key:"setSelectedOptions",value:function(){this.selectedOptions=this.options.filter(function(e){return e.isSelected})}},{key:"setSortedOptions",value:function(){var e=g(this.options);this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}},{key:"setVisibleOptions",value:function(){var e=g(this.sortedOptions),t=2*this.optionsCount,i=this.getVisibleStartIndex(),o=this.getNewOption(),s=i+t-1,n=0;o&&(o.visibleIndex=n,n+=1),e=e.filter(function(e){var t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=i&&n<=s,e.visibleIndex=n,n+=1),t}),o&&(e=[o].concat(g(e))),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}},{key:"setOptionsPosition",value:function(e){var t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform="translate3d(0, ".concat(t,"px, 0)"),d.setData(this.$options,"top",t)}},{key:"setOptionsTooltip",value:function(){var e=this,t=this.getVisibleOptions(),i=this.hasOptionDescription;t.forEach(function(t){var o=e.$dropboxContainer.querySelector('.vscomp-option[data-index="'.concat(t.index,'"]'));d.setData(o.querySelector(".vscomp-option-text"),"tooltip",t.label),i&&d.setData(o.querySelector(".vscomp-option-description"),"tooltip",t.description)})}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.disableEvent,o=void 0!==i&&i,s=t.disableValidation,r=void 0!==s&&s,a=n.normalizeValues(e);this.hasEmptyValueOption&&""===a||a?Array.isArray(a)?this.selectedValues=g(a):this.selectedValues=[a]:this.selectedValues=[];var l=this.getValue();this.$ele.value=l,this.$hiddenInput.value=this.getInputValue(l),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();var u=n.isNotEmpty(this.selectedValues);d.toggleClass(this.$allWrappers,"has-value",u),d.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),d.setAttr(this.$clearButton,"tabindex",u?"0":"-1"),d.setAria(this.$clearButton,"hidden",!1===u),r||this.validate(),o||d.dispatchEvent(this.$ele,"change",!0)}},{key:"setValueText",value:function(){var e=this,t=this.multiple,i=this.selectedValues,o=this.noOfDisplayValues,s=this.showValueAsTags,r=this.$valueText,a=this.selectedLabelRenderer,l=[],u=[],c=i.length,p=0,h=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!s;if(h&&this.hideValueTooltipOnSelectAll)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(function(t){if(t.isCurrentNew)return!1;if(p>=o)return!0;var i=t.label;if("function"==typeof a&&(i=a(t)),l.push(i),p+=1,s){var c=n.willTextOverflow(r.parentElement,i)?e.getTooltipAttrText(i,!1,!0):"",h="";if(e.ariaLabelTagClearButtonText){var d=i.replace(/<[^>]+>/gi,"").trim();h='aria-label="'.concat(d,", ").concat(e.ariaLabelTagClearButtonText,'"')}var v='\n ').concat(i,'\n \n \n \n ');u.push(v)}else u.push(i);return!1});var v=c-o;v>0&&u.push('+ '.concat(v," ").concat(this.moreText,""));var f=l.join(", ");if(""===f)r.innerHTML=this.placeholder;else if(r.innerHTML=f,t){var b=this.maxValues;if(this.alwaysShowSelectedOptionsCount||d.hasEllipsis(r)||b||s){var y=''.concat(c,"");if(b&&(y+=' / '.concat(b,"")),h)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else if(s)r.innerHTML=u.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){var m=1===c?this.optionSelectedText:this.optionsSelectedText;r.innerHTML="".concat(y," ").concat(m)}}else u=[]}}var g="";0===c?g=this.placeholder:s||(g=u.join(", ")),s||d.setData(r,"tooltip",g),t&&(s?this.updatePosition():d.setData(r,"tooltipEllipsisOnly",0===c))}},{key:"setSearchValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e!==this.searchValueOriginal||i){t||(this.$searchInput.value=e);var o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,d.toggleClass(this.$allWrappers,"has-search-value",e),d.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),d.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}}},{key:"setVisibleOptionsCount",value:function(){var e,t=0,i=!1,o=this.searchGroup,s=this.showOptionsOnlyOnSearch,r=this.searchByStartsWith,a=this.searchValue;a=this.searchNormalize&&""!==a.trim()?n.normalizeString(a):a;var l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(function(n){var u;n.isCurrentNew||(s&&!a?(n.isVisible=!1,u={isVisible:!1,hasExactOption:!1}):u=l({data:n,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),u.isVisible&&(t+=1),i||(i=u.hasExactOption))}),this.allowNewOption&&(a&&!i?(this.setNewOption(),t+=1):this.removeNewOption()),this.visibleOptionsCount=t,this.afterSetVisibleOptionsCount()}},{key:"calculateAriaMetadata",value:function(){var e=this,t=0,i=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(function(o){if(o.isCurrentNew)o.filteredIndex=void 0;else if(!0===o.isVisible){var s=o.isGroupTitle&&e.multiple&&!e.disableOptionGroupCheckbox;!o.isGroupTitle||s?(i+=1,t+=1,o.filteredIndex=i):o.filteredIndex=void 0}else o.filteredIndex=void 0}),this.allowNewOption){var o=this.getNewOption();o&&!0===o.isVisible?(i+=1,t+=1,o.filteredIndex=i):o&&(o.filteredIndex=void 0)}this.ariaSetSize=t}},{key:"setOptionProp",value:function(e,t,i){this.options[e]&&(this.options[e][t]=i)}},{key:"setOptionsHeight",value:function(){this.$optionsList.style.height="".concat(this.optionHeight*this.visibleOptionsCount,"px")}},{key:"setOptionsContainerHeight",value:function(e){var t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(d.setStyle(this.$noOptions,"height",t),d.setStyle(this.$noSearchResults,"height",t))),d.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}},{key:"setNewOption",value:function(e){var t=e||this.searchValueOriginal.trim();if(t){var i=this.getNewOption();if(i){var o=i.index;this.setOptionProp(o,"value",this.secureText(t)),this.setOptionProp(o,"label",this.secureText(t))}else{var s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}}},{key:"setSelectedProp",value:function(){var e={};this.selectedValues.forEach(function(t){e[t]=!0}),this.options.forEach(function(t){!0===e[t.value]&&(t.isSelected=!0)})}},{key:"setNewOptionsFromValue",value:function(e){if(e){var t=this.setNewOption.bind(this),i={};this.options.forEach(function(e){i[e.value]=!0}),e.forEach(function(e){e&&!0!==i[e]&&t(e)})}}},{key:"setDropboxWrapperWidth",value:function(){if(!this.showAsPopup){var e=this.dropboxWidth||"".concat(this.$wrapper.offsetWidth,"px");d.setStyle(this.$dropboxContainer,"max-width",e)}}},{key:"setEleStyles",value:function(){var e=this.maxWidth,t={};e&&(t["max-width"]=e),d.setStyles(this.$ele,t)}},{key:"setDropboxStyles",value:function(){var e=this.dropboxWidth,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),d.setStyles(this.$dropboxContainer,i),d.setStyles(this.$dropbox,t)}},{key:"setOptionAttr",value:function(){var e=this.$visibleOptions,t=this.options,i="".concat(this.optionHeight,"px"),o=d.setStyle,s=d.getData,n=d.setData;e&&e.length&&e.forEach(function(e){var r=t[s(e,"index")];o(e,"height",i),n(e,"value",r.value)})}},{key:"setValueTagAttr",value:function(){var e=this.$valueTags;if(e&&e.length){var t=d.getData,i=d.setData,o=this.options;e.forEach(function(e){var s=t(e,"index");if(void 0!==s){var n=o[s];i(e,"value",n.value)}})}}},{key:"setScrollTop",value:function(){var e=this.selectedValues;if(!this.showSelectedOptionsFirst&&this.focusSelectedOptionOnOpen&&0!==e.length){var t,i={};e.forEach(function(e){i[e]=!0}),this.options.some(function(e){return!!i[e.value]&&(t=e.visibleIndex,!0)}),t&&(this.$optionsContainer.scrollTop=this.optionHeight*t)}}},{key:"getVisibleOptions",value:function(){return this.visibleOptions||[]}},{key:"getValue",value:function(){var e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",n.normalizeValues(e)}},{key:"getGroupValue",value:function(){var e=[],t={};return this.options.forEach(function(i){if(i.isSelected){var o=i.value;i.isGroupTitle?o&&(t[i.index]=!0,e.push(o)):!0!==t[i.groupIndex]&&e.push(o)}}),e}},{key:"getInputValue",value:function(e){var t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}},{key:"getFirstVisibleOptionIndex",value:function(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}},{key:"getVisibleStartIndex",value:function(){var e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}},{key:"getTooltipAttrText",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o={"data-tooltip":(n.containsHTML(e)?n.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":t,"data-tooltip-allow-html":i};return d.getAttributesText(o)}},{key:"getOptionObj",value:function(e){if(e){var t=n.getString,i=this.secureText.bind(this),o=i(t(e.value)),s=i(t(e.label)),r=i(t(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:s,labelNormalized:this.searchNormalize&&""!==s.trim()?n.normalizeString(s).toLowerCase():s.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?n.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}}},{key:"getNewOption",value:function(){var e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}},{key:"getOptionIndex",value:function(e){var t;return this.options.some(function(i){return i.value===e&&(t=i.index,!0)}),t}},{key:"getNewValue",value:function(){var e={};this.newValues.forEach(function(t){e[t]=!0});var t=this.selectedValues.filter(function(t){return!0===e[t]});return this.multiple?t:t[0]}},{key:"getAlias",value:function(e){var t=e;return t&&(t=(t=Array.isArray(t)?t.join(","):t.toString().trim()).toLowerCase()),t||""}},{key:"getDisplayValue",value:function(){var e=[];return this.options.forEach(function(t){t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}},{key:"getSelectedOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fullDetails,i=void 0!==t&&t,o=e.keepSelectionOrder,s=void 0!==o&&o,n=this.valueKey,r=this.labelKey,a=this.selectedValues,l=[];if(this.options.forEach(function(e){if(e.isSelected&&!e.isGroupTitle)if(i)l.push(e);else{var t=b(b({},n,e.value),r,e.label);e.isNew&&(t.isNew=!0),e.customData&&(t.customData=e.customData),l.push(t)}}),s){var u={};a.forEach(function(e,t){u[e]=t}),l.sort(function(e,t){return u[e.value]-u[t.value]})}return this.multiple||i?l:l[0]}},{key:"getDisabledOptions",value:function(){var e=this.valueKey,t=this.labelKey,i=this.disabledOptions,o={},s=[];return i.forEach(function(e){o[e]=!0}),this.options.forEach(function(i){var n=i.value,r=i.label;o[n]&&s.push(b(b({},e,n),t,r))}),s}},{key:"getVisibleOptionGroupsMapping",value:function(e){var t=this.options,i={},o=this.isOptionVisible.bind(this);return(t=this.structureOptionGroup(t)).forEach(function(t){i[t.index]=t.options.some(function(t){return o({data:t,searchValue:e}).isVisible})}),i}},{key:"getOptionsCount",value:function(e){var t;if(this.showAsPopup){var i=80*window.innerHeight/100-48;this.hasSearchContainer&&(i-=40),t=Math.floor(i/this.optionHeight)}else t=parseInt(e);return t}},{key:"getOptionsHeight",value:function(){return"".concat(this.optionsCount*this.optionHeight,"px")}},{key:"getSibling",value:function(e,t){var i="next"===t?"nextElementSibling":"previousElementSibling",o=e;do{o&&(o=o[i])}while(d.hasClass(o,"disabled")||d.hasClass(o,"group-title"));return o}},{key:"getUniqueId",value:function(){var e=n.getRandomInt(1e4);return document.querySelector("#vscomp-ele-wrapper-".concat(e))?this.getUniqueId():e}},{key:"initDropboxPopover",value:function(){var e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}},{key:"openDropbox",value:function(t){var i=this;e.lastInteractedInstance=this;var o="";t||(o=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=t,e.openInstances.forEach(function(e){if(e!==i){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),e.openInstances.add(this),d.setAttr(this.$dropboxWrapper,"tabindex","0"),d.setAria(this.$dropboxWrapper,"hidden",!1),d.setAttr(this.$dropboxContainerTop,"tabindex","0"),d.setAria(this.$dropboxContainerTop,"hidden",!1),d.setAttr(this.$dropboxContainerBottom,"tabindex","0"),d.setAria(this.$dropboxContainerBottom,"hidden",!1),t?d.setStyle(this.$dropboxContainer,"display","inline-flex"):(d.dispatchEvent(this.$ele,"beforeOpen"),d.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),d.removeClass(this.$allWrappers,"closed"),d.changeTabIndex(this.$allWrappers,0),t||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=o),this.dropboxPopover&&!t?this.dropboxPopover.show():this.afterShowPopper()}},{key:"afterShowPopper",value:function(){var e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),d.addClass(this.$allWrappers,"focused"),this.showAsPopup?(d.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),d.dispatchEvent(this.$ele,"afterOpen"))}},{key:"closeDropbox",value:function(t){if(this.isSilentClose=t,e.openInstances.delete(this),!1!==this.isOpened())if(this.keepAlwaysOpen)this.removeOptionFocus();else{var i=document.activeElement,o=i&&this.$wrapper.contains(i)||this.hasDropboxWrapper&&i&&this.$dropboxWrapper.contains(i);this.shouldFocusWrapperOnClose&&e.lastInteractedInstance===this&&!t&&(null===i||i===document.body||o)&&this.$wrapper.focus(),t?d.setStyle(this.$dropboxContainer,"display",""):(d.dispatchEvent(this.$ele,"beforeClose"),d.setAria(this.$wrapper,"expanded",!1),d.setAria(this.$wrapper,"activedescendant",""),d.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!t?(this.dropboxPopover.hide(),d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}}},{key:"afterHidePopper",value:function(){var e=this.isSilentClose;this.isSilentClose=!1,d.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(d.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),d.addClass(this.$allWrappers,"closed"),e||d.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)}},{key:"moveSelectedOptionsFirst",value:function(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}},{key:"toggleDropbox",value:function(){e.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}},{key:"updatePosition",value:function(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}},{key:"isOpened",value:function(){return!d.hasClass(this.$wrapper,"closed")}},{key:"focusSearchInput",value:function(){var e=this.$searchInput;e&&e.focus()}},{key:"focusElementOnOpen",value:function(){var e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(d.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{var i=this.$dropbox.querySelector('[tabindex="0"]');void 0!==d.getData(i,"index")?this.focusOption({direction:"next"}):i?i.focus():this.focusFirstVisibleOption()}}},{key:"focusFirstVisibleOption",value:function(){var e=this.$optionsContainer.querySelector("[data-index='".concat(this.getFirstVisibleOptionIndex(),"']"));e?(d.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),d.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'))&&e.focus()}},{key:"focusOption",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.direction,o=t.$option,s=t.focusFirst,n=this.$dropboxContainer.querySelector(".vscomp-option.focused");if(o)e=o;else if(!n||s){var r=this.getFirstVisibleOptionIndex();e=this.$dropboxContainer.querySelector('.vscomp-option[data-visible-index="'.concat(r,'"]')),(d.hasClass(e,"disabled")||d.hasClass(e,"group-title"))&&(e=this.getSibling(e,"next"))}else e=this.getSibling(n,i);e&&e!==n&&(n&&this.toggleOptionFocusedState(n,!1),this.toggleOptionFocusedState(e,!0),this.toggleFocusedProp(d.getData(e,"index"),!0),this.moveFocusedOptionToView(e))}},{key:"moveFocusedOptionToView",value:function(e){var t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(t){var i,o=this.$optionsContainer.getBoundingClientRect(),s=t.getBoundingClientRect(),n=o.top,r=o.bottom,a=o.height,l=s.top,u=s.bottom,c=s.height,p=t.offsetTop,h=d.getData(this.$options,"top","number");n>l?i=p+h:r1&&void 0!==arguments[1]?arguments[1]:{}).event;if(e){var i=!d.hasClass(e,"selected");if(i){if(this.multiple&&this.isMaxValuesSelected)return}else if(!this.multiple)return void this.closeDropbox();var o=this.selectedValues,s=d.getData(e,"value"),r=d.getData(e,"index","number"),a=d.hasClass(e,"current-new"),l=!1,u=this.lastSelectedOptionIndex;if(this.lastSelectedOptionIndex=null,this.toggleSelectedProp(r,i),i){if(this.multiple)o.push(s),this.toggleAllOptionsClass(),this.toggleGroupOptionsParent(e),t&&t.shiftKey&&(l=!0);else{o.length&&this.toggleSelectedProp(this.getOptionIndex(o[0]),!1),o=[s];var c=this.$dropboxContainer.querySelector(".vscomp-option.selected");c&&this.toggleOptionSelectedState(c,!1),this.closeDropbox(),a||this.setSearchValue("")}this.lastSelectedOptionIndex=r,this.toggleOptionSelectedState(e)}else this.multiple&&(this.toggleOptionSelectedState(e),n.removeItemFromArray(o,s),this.toggleAllOptionsClass(!1),this.toggleGroupOptionsParent(e,!1));a&&this.beforeSelectNewValue(s),this.setValue(o),l&&this.selectRangeOptions(u,r)}}},{key:"selectFocusedOption",value:function(){this.selectOption(this.$dropboxContainer.querySelector(".vscomp-option.focused"))}},{key:"selectRangeOptions",value:function(e,t){var i=this;if("number"==typeof e&&!this.maxValues){var o,s,n=this.selectedValues,r=this.hasOptionGroup,a={};if(eo&&t0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),d.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}}},{key:"isAllOptionsSelected",value:function(e){var t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible)})),t}},{key:"isAllGroupOptionsSelected",value:function(e){var t=!1;return this.options.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e})),t}},{key:"toggleGroupOptionsParent",value:function(e,t){if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var i=d.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));var o=this.$options.querySelector('.vscomp-option[data-index="'.concat(i,'"]')),s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,s),this.toggleGroupTitleProp(i,s)}}},{key:"toggleGroupTitleProp",value:function(e,t){var i="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,i)}},{key:"toggleGroupOptions",value:function(e,t){var i=this;if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var o=d.getData(e,"index","number"),s=this.selectedValues,r=this.selectAllOnlyVisible,a={},l=n.removeItemFromArray;s.forEach(function(e){a[e]=!0}),this.options.forEach(function(e){if(!e.isDisabled&&e.groupIndex===o){var i=e.value;!t||r&&!e.isVisible?(e.isSelected=!1,a[i]&&l(s,i)):(e.isSelected=!0,a[i]||s.push(i))}}),this.toggleAllOptionsClass(!!t&&null),this.setValue(s),setTimeout(function(){i.renderOptions()},0)}}},{key:"toggleGroupTitleCheckbox",value:function(e,t){if(e){var i=d.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}}},{key:"toggleFocusedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}},{key:"toggleSelectedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setOptionProp(e,"isSelected",t)}},{key:"scrollToTop",value:function(){this.$optionsContainer.scrollTop>0&&(this.$optionsContainer.scrollTop=0)}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.options.forEach(function(e){e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&d.removeClass(this.$allWrappers,"has-error"),d.dispatchEvent(this.$ele,"reset")}},{key:"addOption",value:function(e,t){if(e){this.lastOptionIndex+=1;var i=this.getOptionObj(f(f({},e),{},{index:this.lastOptionIndex}));this.options.push(i),this.sortedOptions.push(i),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}}},{key:"removeOption",value:function(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}},{key:"removeNewOption",value:function(){var e=this.getNewOption();e&&this.removeOption(e.index)}},{key:"sortOptions",value:function(e){return e.sort(function(e,t){var i=e.isSelected||e.isAnySelected,o=t.isSelected||t.isAnySelected;return i||o?i&&(!o||e.index0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.virtualSelect.reset(e,t)}},{key:"setValueMethod",value:function(){var e;(e=this.virtualSelect).setValueMethod.apply(e,arguments)}},{key:"setOptionsMethod",value:function(){var e;(e=this.virtualSelect).setOptionsMethod.apply(e,arguments)}},{key:"setDisabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setDisabledOptionsMethod.apply(e,arguments)}},{key:"setEnabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setEnabledOptionsMethod.apply(e,arguments)}},{key:"toggleSelectAll",value:function(e){this.virtualSelect.toggleAllOptions(e)}},{key:"isAllSelected",value:function(){return this.virtualSelect.isAllSelected}},{key:"addOptionMethod",value:function(e){this.virtualSelect.addOption(e,!0)}},{key:"getNewValueMethod",value:function(){return this.virtualSelect.getNewValue()}},{key:"getDisplayValueMethod",value:function(){return this.virtualSelect.getDisplayValue()}},{key:"getSelectedOptionsMethod",value:function(e){return this.virtualSelect.getSelectedOptions(e)}},{key:"getDisabledOptionsMethod",value:function(){return this.virtualSelect.getDisabledOptions()}},{key:"openMethod",value:function(){return this.virtualSelect.openDropbox()}},{key:"closeMethod",value:function(){return this.virtualSelect.closeDropbox()}},{key:"focusMethod",value:function(){return this.virtualSelect.focus()}},{key:"enableMethod",value:function(){return this.virtualSelect.enable()}},{key:"disableMethod",value:function(){return this.virtualSelect.disable()}},{key:"destroyMethod",value:function(){return this.virtualSelect.destroy()}},{key:"validateMethod",value:function(){return this.virtualSelect.validate()}},{key:"toggleRequiredMethod",value:function(e){return this.virtualSelect.toggleRequired(e)}},{key:"onResizeMethod",value:function(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(function(e){e.parentElement.virtualSelect.onResize()})}}],i&&x(t.prototype,i),o&&x(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();document.addEventListener("reset",T.onFormReset),document.addEventListener("submit",T.onFormSubmit),window.addEventListener("resize",T.onResizeMethod),k=T.getAttrProps(),window.VirtualSelect=T,T.openInstances=new Set,T.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=new Array(t);ii-s-t.width?"left":"right",vertical:n>o-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),i=window.pageXOffset,o=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+o,right:t.right+i,bottom:t.bottom+o,left:t.left+i}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"show",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",i)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,i=e.parentElement;i;){var o=getComputedStyle(i).overflow;if(-1!==o.indexOf("scroll")||-1!==o.indexOf("auto")){t=i;break}i=i.parentElement}return t}}],i&&function(e,t){for(var i=0;ig?g-f:M:k+c>L&&("right"===E?n="left":k=L+fO?O-h:P:C+p>I&&("bottom"===E?n="top":C=I+hc-R&&(G=c-R):"left"!==E&&"right"!==E||((H=y/2+m-j)p-R&&(H=p-R)),i.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}i.hide(this.$popperEle)}},{key:"resetPosition",value:function(){i.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=t.resetPosition,s=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),o&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=i.getData(e.$popperEle,"left"),o=i.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(o),"px, 0)"),r=e.showDuration;i.show(e.$popperEle,"inline-flex"),i.getCoords(e.$popperEle),i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(s)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var o=parseInt(i.getData(e.$popperEle,"fromLeft")),s=parseInt(i.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(o,"px, ").concat(s,"px, 0)"),r=e.hideDuration;i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){i.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){i.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(i.getData(this.$popperEle,"left")),t=parseInt(i.getData(this.$popperEle,"top"));i.show(this.$popperEle,"inline-flex"),i.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var i=0;i1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var i,o=0;return function(){for(var s=arguments.length,n=new Array(s),r=0;re.length)&&(t=e.length);for(var i=0,o=new Array(t);i'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&p(t.prototype,i),s&&p(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,s}();d=b.getAttrProps(),window.PopoverComponent=b}(); \ No newline at end of file + */!function(){"use strict";const e=/[^\p{L}\p{N}_]/gu;class t{static getString(e){return e||0===e?e.toString():""}static convertToBoolean(e,t=!1){let s;return s=!0===e||"true"===e||!1!==e&&"false"!==e&&t,s}static isEmpty(e){let t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"==typeof e&&0===Object.keys(e).length&&(t=!0):t=!0,t}static isNotEmpty(e){return!t.isEmpty(e)}static normalizeValues(e){if(Array.isArray(e)){const t=new Array(e.length);for(let s=0;s!!e):[]}static getRandomInt(e,t=0){const s=Math.ceil(t),i=Math.floor(e);return Math.floor(Math.random()*(i-s-1))+s}static regexEscape(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static normalizeString(t){return t.normalize("NFD").replace(e,"")}static willTextOverflow(e,t){const s=document.createElement("div");s.style.position="absolute",s.style.visibility="hidden",s.style.whiteSpace="nowrap",s.style.fontSize=window.getComputedStyle(e).fontSize,s.style.fontFamily=window.getComputedStyle(e).fontFamily,s.textContent=t,document.body.appendChild(s);const i=s.clientWidth;return document.body.removeChild(s),i>e.clientWidth}static replaceDoubleQuotesWithHTML(e){return e.replace(/"/g,""")}static containsHTML(e){return/<[a-z][\s\S]*>/i.test(e)}static containsHTMLorJS(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}class s{static addClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.add(...i)})}static removeClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.remove(...i)})}static toggleClass(e,t,i){if(!e)return;let o;void 0!==i&&(o=Boolean(i)),s.getElements(e).forEach(e=>{e.classList.toggle(t,o)})}static hasClass(e,t){return!!e&&e.classList.contains(t)}static hasEllipsis(e){return!!e&&e.scrollWidth>e.offsetWidth}static getData(e,t,s){if(!e)return;let i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}static setData(e,t,s){e&&(e.dataset[t]=s)}static setAttr(e,t,s){e&&e.setAttribute(t,s)}static setAttrFromEle(e,t,s,i){const o={};s.forEach(t=>{o[t]=e.getAttribute(t)}),s.forEach(e=>{const s=o[e];(s||-1!==i.indexOf(e)&&""===s)&&t.setAttribute(e,s)})}static setStyle(e,t,s){e&&(e.style[t]=s)}static setStyles(e,t){e&&t&&Object.keys(t).forEach(s=>{e.style[s]=t[s]})}static setAria(e,t,s){if(!e)return;let i=t;"role"!==i&&(i=`aria-${i}`),e.setAttribute(i,s)}static getElements(e){return e?void 0===e.forEach?[e]:e:[]}static getElementsBySelector(e="",t=void 0){let s;const i=void 0!==t?t:document;return""!==e&&(s=i.querySelectorAll(e)),void 0!==s?Array.from(s):[]}static addEvent(e,i,o,n){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{s.getElements(e).forEach(e=>{e.addEventListener(t,o,{capture:n})})})}static dispatchEvent(e,t,i=!1){if(!e)return;const o=s.getElements(e);setTimeout(()=>{o.forEach(e=>{e.dispatchEvent(new CustomEvent(t,{bubbles:i}))})},0)}static getAttributesText(e){let t="";return e?(Object.entries(e).forEach(([e,s])=>{void 0!==s&&(t+=` ${e}="${s}" `)}),t):t}static convertPropToDataAttr(e){return e?`data-${e}`.replace(/([A-Z])/g,"-$1").toLowerCase():""}static changeTabIndex(e,t){e?s.getElements(e).forEach(e=>{e.tabIndex=t}):console.log(e,"Invalid element provided.")}static removeEvent(e,t,i){e&&s.getElements(e).forEach(e=>{e.removeEventListener(t,i)})}}const i={13:"onEnterPress",38:"onUpArrowPress",40:"onDownArrowPress",46:"onBackspaceOrDeletePress",8:"onBackspaceOrDeletePress"},o=["autofocus","disabled","multiple","required"],n=["autofocus","class","disabled","id","multiple","name","placeholder","required"];let r;const a=["additionalClasses","additionalDropboxClasses","additionalDropboxContainerClasses","additionalToggleButtonClasses","aliasKey","allOptionsSelectedText","allowNewOption","alwaysShowSelectedOptionsCount","alwaysShowSelectedOptionsLabel","ariaLabelledby","ariaLabelText","ariaLabelClearButtonText","ariaLabelTagClearButtonText","ariaLabelSearchClearButtonText","autoSelectFirstOption","clearButtonText","descriptionKey","disableAllOptionsSelectedText","disableOptionGroupCheckbox","disableSelectAll","disableValidation","dropboxWidth","dropboxWrapper","emptyValue","enableSecureText","focusSelectedOptionOnOpen","hasOptionDescription","hideClearButton","hideValueTooltipOnSelectAll","keepAlwaysOpen","labelKey","markSearchResults","maxValues","maxWidth","minValues","moreText","noOfDisplayValues","noOptionsText","noSearchResultsText","optionHeight","optionSelectedText","optionsCount","optionsSelectedText","popupDropboxBreakpoint","popupPosition","position","search","searchByStartsWith","searchDelay","searchFormLabel","searchGroup","searchNormalize","searchPlaceholderText","selectAllOnlyVisible","selectAllText","setValueAsArray","showDropboxAsPopup","showOptionsOnlyOnSearch","showSelectedOptionsFirst","showValueAsTags","silentInitialValueSet","textDirection","tooltipAlignment","tooltipFontSize","tooltipMaxWidth","updatePositionThrottle","useGroupValue","valueKey","zIndex"];class l{constructor(e){try{this.createSecureTextElements(),this.setProps(e),this.setDisabledOptions(e.disabledOptions),this.setOptions(e.options),this.render()}catch(e){console.warn("Couldn't initiate Virtual Select"),console.error(e)}}render(){if(!this.$ele)return;const{uniqueId:e}=this;let t="vscomp-wrapper",i="vscomp-toggle-button";const o=this.showValueAsTags?"":this.getTooltipAttrText(this.placeholder,!0,!0),n=this.getTooltipAttrText(this.clearButtonText),r=this.ariaLabelledby?`aria-labelledby="${this.ariaLabelledby}"`:"",a=this.ariaLabelText?`aria-label="${this.ariaLabelText}"`:"",l=this.ariaLabelClearButtonText?`aria-label="${this.ariaLabelClearButtonText}"`:"";let p=!1;this.additionalClasses&&(t+=` ${this.additionalClasses}`),this.additionalToggleButtonClasses&&(i+=` ${this.additionalToggleButtonClasses}`),this.multiple&&(t+=" multiple",this.disableSelectAll||(t+=" has-select-all")),this.hideClearButton||(t+=" has-clear-button"),this.keepAlwaysOpen?(t+=" keep-always-open",p=!0):t+=" closed",this.showAsPopup&&(t+=" show-as-popup"),this.hasSearch&&(t+=" has-search-input"),this.showValueAsTags&&(t+=" show-value-as-tags"),this.textDirection&&(t+=` text-direction-${this.textDirection}`),this.popupPosition&&(t+=` popup-position-${this.popupPosition.toLowerCase()}`);const h=`
\n \n
\n
\n ${this.placeholder}\n
\n
\n
\n \n
\n
\n\n ${this.renderDropbox({wrapperClasses:t})}\n
`;this.$ele.innerHTML=h,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),s.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}renderDropbox({wrapperClasses:e}){const t="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null;let i="vscomp-dropbox";this.additionalDropboxClasses&&(i+=` ${this.additionalDropboxClasses}`);let o="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(o+=` ${this.additionalDropboxContainerClasses}`);const n=`
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
${this.noOptionsText}
\n
${this.noSearchResultsText}
\n\n \n
\n \n
`;if(t){const i=document.createElement("div");return this.$dropboxWrapper=i,this.hasDropboxWrapper=!0,i.innerHTML=n,t.appendChild(i),s.addClass(i,`vscomp-dropbox-wrapper ${e}`),this.keepAlwaysOpen||(s.setAttr(i,"tabindex","-1"),s.setAria(i,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}renderOptions(){this.calculateAriaMetadata();let e="";const s=this.getVisibleOptions();let i="",o="";const n=!(!this.markSearchResults||!this.searchValue);let r;const{labelRenderer:a,disableOptionGroupCheckbox:l,uniqueId:p,searchGroup:h}=this,c="function"==typeof a,{convertToBoolean:u}=t;let d="";if(n&&(r=new RegExp(`(${t.regexEscape(this.searchValue)})(?!([^<]+)?>)`,"gi")),this.multiple&&(i=''),this.allowNewOption){const e=this.getTooltipAttrText("New Option");o=``}s.forEach(t=>{const{index:s}=t;let v,b="vscomp-option";const f=this.getTooltipAttrText("",!0,!0);let m=i,g="",O="",y="",x="",S="-1";const $=u(t.isSelected);let w="";if(t.classNames&&(b+=` ${t.classNames}`),t.isFocused&&(S="0",b+=" focused"),t.isDisabled&&(b+=" disabled",w='aria-disabled="true"'),t.isGroupTitle&&(d=t.label,b+=" group-title",l&&(m="")),$&&(b+=" selected"),t.isGroupOption){let e="";b+=" group-option",y=`data-group-index="${t.groupIndex}"`,t.customData?(d=void 0!==t.customData.group_name?`${t.customData.group_name}, `:"",e=void 0!==t.customData.description?` ${t.customData.description},`:"",x=`aria-label="${d} ${t.label}, ${e}"`):x=`aria-label="${d}, ${t.label}"`}v=c?a(t):t.label,t.description&&(O=`
${t.description}
`),t.isCurrentNew?(b+=" current-new",g+=o):!n||t.isGroupTitle&&!h||(v=v.replace(r,"$1"));let C="";this.ariaSetSize>0&&(C=`aria-setsize="${this.ariaSetSize}"`,t.filteredIndex&&(C+=` aria-posinset="${t.filteredIndex}"`)),e+=`
\n ${m}\n \n ${v}\n \n ${O}\n ${g}\n
`}),d="",this.$options.innerHTML=e,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}renderSearch(){if(!this.hasSearchContainer)return;let e="",t="";if(this.multiple&&!this.disableSelectAll&&(e=`\n \n ${this.selectAllText}\n `),this.hasSearch){const e=this.ariaLabelSearchClearButtonText?`aria-label="${this.ariaLabelSearchClearButtonText}"`:"";t=`\n \n ×`}const s=`
\n ${e}\n ${t}\n
`;this.$search.innerHTML=s,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}addEvents(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}addEvent(e,i,o,n=!1){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`;let r=this.events[i];r||(r=this[o].bind(this),this.events[i]=r),s.addEvent(e,t,r,n)})}removeEvents(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}removeEvent(e,i,o){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`,n=this.events[i];n&&s.removeEvent(e,t,n)})}onDocumentClick(e){const t=e.target.closest(".vscomp-wrapper");if(!t)return void l.openInstances.forEach(e=>{const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()});const s=t.parentElement.virtualSelect;s&&s!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}onKeyDown(e){const t=e.which||e.keyCode,s=i[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){const e=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(e&&(document.activeElement===e||e.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}s&&this[s](e)}else this.toggleAllOptions()}onEnterPress(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}onDownArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}onUpArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}onBackspaceOrDeletePress(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}onToggleButtonPress(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}const t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}onClearButtonClick(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}onOptionsScroll(){this.setVisibleOptions(!0)}onOptionsClick(e){const t=e.target.closest(".vscomp-option");t&&!s.hasClass(t,"disabled")&&(s.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}onGroupTitleClick(e){if(!e||!this.multiple||this.disableOptionGroupCheckbox)return;const t=!s.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}onDropboxContainerClick(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}onDropboxCloseButtonClick(){this.closeDropbox()}onOptionsMouseOver(e){const t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(s.hasClass(t,"disabled")||s.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}onOptionsTouchMove(){this.removeOptionFocus()}onSearch(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}preventPropagation(e){e.stopPropagation()}onSearchClear(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}onToggleAllOptions(){this.toggleAllOptions()}onDropboxContainerTopOrBottomFocus(){this.closeDropbox()}onResize(){this.setOptionsContainerHeight(!0)}addMutationObserver(){if(!this.hasDropboxWrapper)return;const e=this.$ele;this.mutationObserver=new MutationObserver(t=>{let s=!1,i=!1;t.forEach(t=>{s||(s=[...t.addedNodes].some(t=>!(t!==e&&!t.contains(e)))),i||(i=[...t.removedNodes].some(t=>!(t!==e&&!t.contains(e))))}),i&&!s&&this.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}removeMutationObserver(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}beforeValueSet(e){this.toggleAllOptionsClass(!e&&void 0)}beforeSelectNewValue(e){const t=this.getNewOption();if(t){const e=t.index;this.newValues.push(t.value),this.setOptionProp(e,"isCurrentNew",!1),this.setOptionProp(e,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(()=>{this.setSearchValue(""),this.focusSearchInput()},0)}afterRenderWrapper(){s.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}afterRenderOptions(){const e=this.getVisibleOptions(),t=!this.options.length&&!this.hasServerSearch,i=!t&&!e.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(s.toggleClass(this.$allWrappers,"has-no-search-results",i),i?(s.setAttr(this.$noSearchResults,"tabindex","0"),s.setAttr(this.$noSearchResults,"aria-hidden","false")):(s.setAttr(this.$noSearchResults,"tabindex","-1"),s.setAttr(this.$noSearchResults,"aria-hidden","true"))),s.toggleClass(this.$allWrappers,"has-no-options",t),t?(s.setAttr(this.$noOptions,"tabindex","0"),s.setAttr(this.$noOptions,"aria-hidden","false")):(s.setAttr(this.$noOptions,"tabindex","-1"),s.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(()=>{const e=s.getElementsBySelector(".focused",this.$dropboxContainer)[0];void 0!==e&&e.focus({preventScroll:!0})},20)}afterSetOptionsContainerHeight(e){e&&this.showAsPopup&&this.setVisibleOptions()}afterSetSearchValue(){this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(()=>{this.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}afterSetVisibleOptionsCount(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}afterValueSet(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}afterSetOptions(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}setProps(e){const s=this.setDefaultProps(e);this.setPropsFromElementAttr(s);const{convertToBoolean:i}=t;this.$ele=s.ele,this.dropboxWrapper=s.dropboxWrapper,this.valueKey=s.valueKey,this.labelKey=s.labelKey,this.descriptionKey=s.descriptionKey,this.aliasKey=s.aliasKey,this.optionHeightText=s.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(s.multiple),this.hasSearch=i(s.search),this.searchByStartsWith=i(s.searchByStartsWith),this.searchGroup=i(s.searchGroup),this.hideClearButton=i(s.hideClearButton),this.autoSelectFirstOption=i(s.autoSelectFirstOption),this.hasOptionDescription=i(s.hasOptionDescription),this.silentInitialValueSet=i(s.silentInitialValueSet),this.allowNewOption=i(s.allowNewOption),this.markSearchResults=i(s.markSearchResults),this.showSelectedOptionsFirst=i(s.showSelectedOptionsFirst),this.disableSelectAll=i(s.disableSelectAll),this.keepAlwaysOpen=i(s.keepAlwaysOpen),this.showDropboxAsPopup=i(s.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(s.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(s.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(s.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(s.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(s.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(s.disableAllOptionsSelectedText),this.showValueAsTags=i(s.showValueAsTags),this.disableOptionGroupCheckbox=i(s.disableOptionGroupCheckbox),this.enableSecureText=i(s.enableSecureText),this.setValueAsArray=i(s.setValueAsArray),this.disableValidation=i(s.disableValidation),this.initialDisabled=i(s.disabled),this.required=i(s.required),this.autofocus=i(s.autofocus),this.useGroupValue=i(s.useGroupValue),this.focusSelectedOptionOnOpen=i(s.focusSelectedOptionOnOpen),this.noOptionsText=s.noOptionsText,this.noSearchResultsText=s.noSearchResultsText,this.selectAllText=s.selectAllText,this.searchNormalize=s.searchNormalize,this.searchPlaceholderText=s.searchPlaceholderText,this.searchFormLabel=s.searchFormLabel,this.optionsSelectedText=s.optionsSelectedText,this.optionSelectedText=s.optionSelectedText,this.allOptionsSelectedText=s.allOptionsSelectedText,this.clearButtonText=s.clearButtonText,this.moreText=s.moreText,this.placeholder=s.placeholder,this.position=s.position,this.textDirection=s.textDirection,this.dropboxWidth=s.dropboxWidth,this.tooltipFontSize=s.tooltipFontSize,this.tooltipAlignment=s.tooltipAlignment,this.tooltipMaxWidth=s.tooltipMaxWidth,this.updatePositionThrottle=s.updatePositionThrottle,this.noOfDisplayValues=parseInt(s.noOfDisplayValues),this.zIndex=parseInt(s.zIndex),this.maxValues=parseInt(s.maxValues),this.minValues=parseInt(s.minValues),this.name=this.secureText(s.name),this.additionalClasses=s.additionalClasses,this.additionalDropboxClasses=s.additionalDropboxClasses,this.additionalDropboxContainerClasses=s.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=s.additionalToggleButtonClasses,this.popupDropboxBreakpoint=s.popupDropboxBreakpoint,this.popupPosition=s.popupPosition,this.onServerSearch=s.onServerSearch,this.labelRenderer=s.labelRenderer,this.selectedLabelRenderer=s.selectedLabelRenderer,this.initialSelectedValue=0===s.selectedValue?"0":s.selectedValue,this.emptyValue=s.emptyValue,this.ariaLabelText=s.ariaLabelText,this.ariaLabelledby=s.ariaLabelledby,this.ariaLabelClearButtonText=s.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=s.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=s.ariaLabelSearchClearButtonText,this.maxWidth=s.maxWidth,this.searchDelay=s.searchDelay,this.showDuration=parseInt(s.showDuration),this.hideDuration=parseInt(s.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===s.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(s.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}setDefaultProps(e){const t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}setPropsFromElementAttr(e){const t=e.ele;Object.keys(r).forEach(s=>{let i=t.getAttribute(s);-1===o.indexOf(s)||""!==i&&"true"!==i||(i=!0),i&&(e[r[s]]=i)})}setEleProps(){const{$ele:e}=this;e.virtualSelect=this,e.value=this.multiple?[]:"",e.name=this.name,e.disabled=!1,e.required=this.required,e.autofocus=this.autofocus,e.multiple=this.multiple,e.form=e.closest("form"),e.reset=l.reset,e.setValue=l.setValueMethod,e.setOptions=l.setOptionsMethod,e.setDisabledOptions=l.setDisabledOptionsMethod,e.setEnabledOptions=l.setEnabledOptionsMethod,e.toggleSelectAll=l.toggleSelectAll,e.isAllSelected=l.isAllSelected,e.addOption=l.addOptionMethod,e.getNewValue=l.getNewValueMethod,e.getDisplayValue=l.getDisplayValueMethod,e.getSelectedOptions=l.getSelectedOptionsMethod,e.getDisabledOptions=l.getDisabledOptionsMethod,e.open=l.openMethod,e.close=l.closeMethod,e.focus=l.focusMethod,e.enable=l.enableMethod,e.disable=l.disableMethod,e.destroy=l.destroyMethod,e.validate=l.validateMethod,e.toggleRequired=l.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}setValueMethod(e,s){const i={},o={};let n=[];const r=this.multiple;let a=t.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){const{maxValues:e}=this;e&&a.length>e&&a.splice(e)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach((e,t)=>{i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}this.options.forEach(e=>{const s=t.normalizeValues(e.value);!0!==i[s]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,n.push(e.value))}),r?(this.hasOptionGroup&&this.setGroupsSelectedProp(),n.sort((e,s)=>o[t.normalizeValues(e)]-o[t.normalizeValues(s)])):[n]=n,this.beforeValueSet(),this.setValue(n,{disableEvent:s}),this.afterValueSet()}setGroupOptionsValue(e){const t=[],s={},i={};return e.forEach(e=>{i[e]=!0}),this.options.forEach(e=>{const{value:o}=e,n=!0===i[o];e.isGroupTitle?n&&(s[e.index]=!0):(n||s[e.groupIndex])&&t.push(o)}),t}setGroupsSelectedProp(){const e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(t=>{t.isGroupTitle&&(t.isSelected=e(t.index))})}setOptionsMethod(e,t){this.setOptions(e),this.afterSetOptions(t)}setDisabledOptionsMethod(e,t=!1){this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setDisabledOptions(e,t=!1){let s=[];if(e)if(!0===e)t&&this.options.forEach(e=>(e.isDisabled=!0,s.push(e.value),e));else{s=e.map(e=>e.toString());const i={};s.forEach(e=>{i[e]=!0}),t&&this.options.forEach(e=>(e.isDisabled=!0===i[e.value],e))}else t&&this.options.forEach(e=>(e.isDisabled=!1,e));this.disabledOptions=s}setEnabledOptionsMethod(e,t=!1){this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setEnabledOptions(e){if(void 0===e)return;const t=[];if(!0===e)this.options.forEach(e=>(e.isDisabled=!1,e));else{const s={};e.forEach(e=>{s[e]=!0}),this.options.forEach(e=>{const i=!0!==s[e.value];return e.isDisabled=i,i&&t.push(e.value),e})}this.disabledOptions=t}setOptions(e=[]){const s=[],i=this.disabledOptions.length,{valueKey:o,labelKey:n,descriptionKey:r,aliasKey:a,hasOptionDescription:l}=this,{getString:p,convertToBoolean:h}=t,c=this.secureText.bind(this),u=this.getAlias.bind(this);let d=0,v=!1;const b={};let f=!1;this.disabledOptions.forEach(e=>{b[e]=!0});const m=e=>{"object"!=typeof e&&(e={[o]:e,[n]:e});const g=c(p(e[o])),O=c(p(e[n])),y=e.options,x=!!y,S={index:d,value:g,valueNormalized:g.toLowerCase(),label:O,labelNormalized:this.searchNormalize&&""!==O.trim()?t.normalizeString(O).toLowerCase():O.toLowerCase(),alias:u(e[a]),isVisible:h(e.isVisible,!0),isNew:e.isNew||!1,isGroupTitle:x,classNames:e.classNames};if(f||""!==g||(f=!0),i&&(S.isDisabled=!0===b[g]),e.isGroupOption&&(S.isGroupOption=!0,S.groupIndex=e.groupIndex),l){const s=c(p(e[r]));S.description=s,S.descriptionNormalized=this.searchNormalize&&""!==s.trim()?t.normalizeString(s).toLowerCase():s.toLowerCase()}if(e.customData&&(S.customData=e.customData),s.push(S),d+=1,x){const e=S.index;v=!0,y.forEach(t=>{t.isGroupOption=!0,t.groupIndex=e,m(t)})}};Array.isArray(e)&&e.forEach(m);const g=s.length,{$ele:O}=this;O.options=s,O.length=g,this.options=s,this.visibleOptionsCount=g,this.lastOptionIndex=g-1,this.newValues=[],this.hasOptionGroup=v,this.hasEmptyValueOption=f,this.setSortedOptions()}setServerOptions(e=[]){this.setOptionsMethod(e,!0);const{selectedOptions:t}=this,i=this.options;let o=!1;if(t.length){const e={};o=!0,i.forEach(t=>{e[t.value]=!0}),t.forEach(t=>{!0!==e[t.value]&&(t.isVisible=!1,i.push(t))}),this.setOptionsMethod(i,!0)}this.allowNewOption&&this.searchValue&&(i.some(e=>e.label.toLowerCase()===this.searchValue)||(o=!0,this.setNewOption())),o?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),s.removeClass(this.$allWrappers,"server-searching")}setSelectedOptions(){this.selectedOptions=this.options.filter(e=>e.isSelected)}setSortedOptions(){let e=[...this.options];this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}setVisibleOptions(){let e=[...this.sortedOptions];const t=2*this.optionsCount,s=this.getVisibleStartIndex(),i=this.getNewOption(),o=s+t-1;let n=0;i&&(i.visibleIndex=n,n+=1),e=e.filter(e=>{let t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=s&&n<=o,e.visibleIndex=n,n+=1),t}),i&&(e=[i,...e]),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}setOptionsPosition(e){const t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform=`translate3d(0, ${t}px, 0)`,s.setData(this.$options,"top",t)}setOptionsTooltip(){const e=this.getVisibleOptions(),{hasOptionDescription:t}=this;e.forEach(e=>{const i=this.$dropboxContainer.querySelector(`.vscomp-option[data-index="${e.index}"]`);s.setData(i.querySelector(".vscomp-option-text"),"tooltip",e.label),t&&s.setData(i.querySelector(".vscomp-option-description"),"tooltip",e.description)})}setValue(e,{disableEvent:i=!1,disableValidation:o=!1}={}){const n=t.normalizeValues(e);this.hasEmptyValueOption&&""===n||n?Array.isArray(n)?this.selectedValues=[...n]:this.selectedValues=[n]:this.selectedValues=[];const r=this.getValue();this.$ele.value=r,this.$hiddenInput.value=this.getInputValue(r),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();const a=t.isNotEmpty(this.selectedValues);s.toggleClass(this.$allWrappers,"has-value",a),s.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),s.setAttr(this.$clearButton,"tabindex",a?"0":"-1"),s.setAria(this.$clearButton,"hidden",!1===a),o||this.validate(),i||s.dispatchEvent(this.$ele,"change",!0)}setValueText(){const{multiple:e,selectedValues:i,noOfDisplayValues:o,showValueAsTags:n,$valueText:r,selectedLabelRenderer:a}=this,l=[];let p=[];const h=i.length;let c=0;const u=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!n;if(u&&this.hideValueTooltipOnSelectAll)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(e=>{if(e.isCurrentNew)return!1;if(c>=o)return!0;let{label:s}=e;if("function"==typeof a&&(s=a(e)),l.push(s),c+=1,n){const i=t.willTextOverflow(r.parentElement,s)?this.getTooltipAttrText(s,!1,!0):"";let o="";this.ariaLabelTagClearButtonText&&(o=`aria-label="${s.replace(/<[^>]+>/gi,"").trim()}, ${this.ariaLabelTagClearButtonText}"`);const n=`\n ${s}\n \n \n \n `;p.push(n)}else p.push(s);return!1});const i=h-o;i>0&&p.push(`+ ${i} ${this.moreText}`);const d=l.join(", ");if(""===d)r.innerHTML=this.placeholder;else if(r.innerHTML=d,e){const{maxValues:e}=this;if(this.alwaysShowSelectedOptionsCount||s.hasEllipsis(r)||e||n){let t=`${h}`;if(e&&(t+=` / ${e}`),u)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else if(n)r.innerHTML=p.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){const e=1===h?this.optionSelectedText:this.optionsSelectedText;r.innerHTML=`${t} ${e}`}}else p=[]}}let d="";0===h?d=this.placeholder:n||(d=p.join(", ")),n||s.setData(r,"tooltip",d),e&&(n?this.updatePosition():s.setData(r,"tooltipEllipsisOnly",0===h))}setSearchValue(e,t=!1,i=!1){if(e===this.searchValueOriginal&&!i)return;t||(this.$searchInput.value=e);const o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,s.toggleClass(this.$allWrappers,"has-search-value",e),s.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),s.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}setVisibleOptionsCount(){let e,s=0,i=!1;const{searchGroup:o,showOptionsOnlyOnSearch:n,searchByStartsWith:r}=this;let{searchValue:a}=this;a=this.searchNormalize&&""!==a.trim()?t.normalizeString(a):a;const l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(t=>{if(t.isCurrentNew)return;let p;n&&!a?(t.isVisible=!1,p={isVisible:!1,hasExactOption:!1}):p=l({data:t,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),p.isVisible&&(s+=1),i||(i=p.hasExactOption)}),this.allowNewOption&&(a&&!i?(this.setNewOption(),s+=1):this.removeNewOption()),this.visibleOptionsCount=s,this.afterSetVisibleOptionsCount()}calculateAriaMetadata(){let e=0,t=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(s=>{if(s.isCurrentNew)s.filteredIndex=void 0;else if(!0===s.isVisible){const i=s.isGroupTitle&&this.multiple&&!this.disableOptionGroupCheckbox;!s.isGroupTitle||i?(t+=1,e+=1,s.filteredIndex=t):s.filteredIndex=void 0}else s.filteredIndex=void 0}),this.allowNewOption){const s=this.getNewOption();s&&!0===s.isVisible?(t+=1,e+=1,s.filteredIndex=t):s&&(s.filteredIndex=void 0)}this.ariaSetSize=e}setOptionProp(e,t,s){this.options[e]&&(this.options[e][t]=s)}setOptionsHeight(){this.$optionsList.style.height=this.optionHeight*this.visibleOptionsCount+"px"}setOptionsContainerHeight(e){let t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(s.setStyle(this.$noOptions,"height",t),s.setStyle(this.$noSearchResults,"height",t))),s.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}setNewOption(e){const t=e||this.searchValueOriginal.trim();if(!t)return;const s=this.getNewOption();if(s){const e=s.index;this.setOptionProp(e,"value",this.secureText(t)),this.setOptionProp(e,"label",this.secureText(t))}else{const s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}setSelectedProp(){const e={};this.selectedValues.forEach(t=>{e[t]=!0}),this.options.forEach(t=>{!0===e[t.value]&&(t.isSelected=!0)})}setNewOptionsFromValue(e){if(!e)return;const t=this.setNewOption.bind(this),s={};this.options.forEach(e=>{s[e.value]=!0}),e.forEach(e=>{e&&!0!==s[e]&&t(e)})}setDropboxWrapperWidth(){if(this.showAsPopup)return;const e=this.dropboxWidth||`${this.$wrapper.offsetWidth}px`;s.setStyle(this.$dropboxContainer,"max-width",e)}setEleStyles(){const{maxWidth:e}=this,t={};e&&(t["max-width"]=e),s.setStyles(this.$ele,t)}setDropboxStyles(){const{dropboxWidth:e}=this,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),s.setStyles(this.$dropboxContainer,i),s.setStyles(this.$dropbox,t)}setOptionAttr(){const{$visibleOptions:e}=this,{options:t}=this,i=`${this.optionHeight}px`,{setStyle:o,getData:n,setData:r}=s;e&&e.length&&e.forEach(e=>{const s=t[n(e,"index")];o(e,"height",i),r(e,"value",s.value)})}setValueTagAttr(){const{$valueTags:e}=this;if(!e||!e.length)return;const{getData:t,setData:i}=s,{options:o}=this;e.forEach(e=>{const s=t(e,"index");if(void 0!==s){const t=o[s];i(e,"value",t.value)}})}setScrollTop(){const{selectedValues:e}=this;if(this.showSelectedOptionsFirst||!this.focusSelectedOptionOnOpen||0===e.length)return;const t={};let s;e.forEach(e=>{t[e]=!0}),this.options.some(e=>!!t[e.value]&&(s=e.visibleIndex,!0)),s&&(this.$optionsContainer.scrollTop=this.optionHeight*s)}getVisibleOptions(){return this.visibleOptions||[]}getValue(){let e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",t.normalizeValues(e)}getGroupValue(){const e=[],t={};return this.options.forEach(s=>{if(!s.isSelected)return;const{value:i}=s;s.isGroupTitle?i&&(t[s.index]=!0,e.push(i)):!0!==t[s.groupIndex]&&e.push(i)}),e}getInputValue(e){let t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}getFirstVisibleOptionIndex(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}getVisibleStartIndex(){let e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}getTooltipAttrText(e,i=!1,o=!1){const n={"data-tooltip":(t.containsHTML(e)?t.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":i,"data-tooltip-allow-html":o};return s.getAttributesText(n)}getOptionObj(e){if(!e)return;const{getString:s}=t,i=this.secureText.bind(this),o=i(s(e.value)),n=i(s(e.label)),r=i(s(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:n,labelNormalized:this.searchNormalize&&""!==n.trim()?t.normalizeString(n).toLowerCase():n.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?t.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}getNewOption(){const e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}getOptionIndex(e){let t;return this.options.some(s=>s.value===e&&(t=s.index,!0)),t}getNewValue(){const e={};this.newValues.forEach(t=>{e[t]=!0});const t=this.selectedValues.filter(t=>!0===e[t]);return this.multiple?t:t[0]}getAlias(e){let t=e;return t&&(t=Array.isArray(t)?t.join(","):t.toString().trim(),t=t.toLowerCase()),t||""}getDisplayValue(){const e=[];return this.options.forEach(t=>{t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}getSelectedOptions({fullDetails:e=!1,keepSelectionOrder:t=!1}={}){const{valueKey:s,labelKey:i,selectedValues:o}=this,n=[];if(this.options.forEach(t=>{if(t.isSelected&&!t.isGroupTitle)if(e)n.push(t);else{const e={[s]:t.value,[i]:t.label};t.isNew&&(e.isNew=!0),t.customData&&(e.customData=t.customData),n.push(e)}}),t){const e={};o.forEach((t,s)=>{e[t]=s}),n.sort((t,s)=>e[t.value]-e[s.value])}return this.multiple||e?n:n[0]}getDisabledOptions(){const{valueKey:e,labelKey:t,disabledOptions:s}=this,i={},o=[];return s.forEach(e=>{i[e]=!0}),this.options.forEach(({value:s,label:n})=>{i[s]&&o.push({[e]:s,[t]:n})}),o}getVisibleOptionGroupsMapping(e){let{options:t}=this;const s={},i=this.isOptionVisible.bind(this);return t=this.structureOptionGroup(t),t.forEach(t=>{s[t.index]=t.options.some(t=>i({data:t,searchValue:e}).isVisible)}),s}getOptionsCount(e){let t;if(this.showAsPopup){let e=80*window.innerHeight/100-48;this.hasSearchContainer&&(e-=40),t=Math.floor(e/this.optionHeight)}else t=parseInt(e);return t}getOptionsHeight(){return this.optionsCount*this.optionHeight+"px"}getSibling(e,t){const i="next"===t?"nextElementSibling":"previousElementSibling";let o=e;do{o&&(o=o[i])}while(s.hasClass(o,"disabled")||s.hasClass(o,"group-title"));return o}getUniqueId(){const e=t.getRandomInt(1e4);return document.querySelector(`#vscomp-ele-wrapper-${e}`)?this.getUniqueId():e}initDropboxPopover(){const e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}openDropbox(e){l.lastInteractedInstance=this;let t="";e||(t=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=e,l.openInstances.forEach(e=>{if(e!==this){const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),l.openInstances.add(this),s.setAttr(this.$dropboxWrapper,"tabindex","0"),s.setAria(this.$dropboxWrapper,"hidden",!1),s.setAttr(this.$dropboxContainerTop,"tabindex","0"),s.setAria(this.$dropboxContainerTop,"hidden",!1),s.setAttr(this.$dropboxContainerBottom,"tabindex","0"),s.setAria(this.$dropboxContainerBottom,"hidden",!1),e?s.setStyle(this.$dropboxContainer,"display","inline-flex"):(s.dispatchEvent(this.$ele,"beforeOpen"),s.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),s.removeClass(this.$allWrappers,"closed"),s.changeTabIndex(this.$allWrappers,0),e||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=t),this.dropboxPopover&&!e?this.dropboxPopover.show():this.afterShowPopper()}afterShowPopper(){const e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),s.addClass(this.$allWrappers,"focused"),this.showAsPopup?(s.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),s.dispatchEvent(this.$ele,"afterOpen"))}closeDropbox(e){if(this.isSilentClose=e,l.openInstances.delete(this),!1===this.isOpened())return;if(this.keepAlwaysOpen)return void this.removeOptionFocus();const t=document.activeElement,i=t&&this.$wrapper.contains(t)||this.hasDropboxWrapper&&t&&this.$dropboxWrapper.contains(t);this.shouldFocusWrapperOnClose&&l.lastInteractedInstance===this&&!e&&(null===t||t===document.body||i)&&this.$wrapper.focus(),e?s.setStyle(this.$dropboxContainer,"display",""):(s.dispatchEvent(this.$ele,"beforeClose"),s.setAria(this.$wrapper,"expanded",!1),s.setAria(this.$wrapper,"activedescendant",""),s.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!e?(this.dropboxPopover.hide(),s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}afterHidePopper(){const e=this.isSilentClose;this.isSilentClose=!1,s.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(s.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),s.addClass(this.$allWrappers,"closed"),e||s.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)}moveSelectedOptionsFirst(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}toggleDropbox(){l.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}updatePosition(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}isOpened(){return!s.hasClass(this.$wrapper,"closed")}focusSearchInput(){const e=this.$searchInput;e&&e.focus()}focusElementOnOpen(){const e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(s.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{const e=this.$dropbox.querySelector('[tabindex="0"]');void 0!==s.getData(e,"index")?this.focusOption({direction:"next"}):e?e.focus():this.focusFirstVisibleOption()}}focusFirstVisibleOption(){let e=this.$optionsContainer.querySelector(`[data-index='${this.getFirstVisibleOptionIndex()}']`);e?(s.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),s.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'),e&&e.focus())}focusOption({direction:e,$option:t,focusFirst:i}={}){const o=this.$dropboxContainer.querySelector(".vscomp-option.focused");let n;if(t)n=t;else if(!o||i){const e=this.getFirstVisibleOptionIndex();n=this.$dropboxContainer.querySelector(`.vscomp-option[data-visible-index="${e}"]`),(s.hasClass(n,"disabled")||s.hasClass(n,"group-title"))&&(n=this.getSibling(n,"next"))}else n=this.getSibling(o,e);n&&n!==o&&(o&&this.toggleOptionFocusedState(o,!1),this.toggleOptionFocusedState(n,!0),this.toggleFocusedProp(s.getData(n,"index"),!0),this.moveFocusedOptionToView(n))}moveFocusedOptionToView(e){const t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(!t)return;let i;const o=this.$optionsContainer.getBoundingClientRect(),n=t.getBoundingClientRect(),r=o.top,a=o.bottom,l=o.height,p=n.top,h=n.bottom,c=n.height,u=t.offsetTop,d=s.getData(this.$options,"top","number");r>p?i=u+d:a{if(e.isDisabled||e.isGroupTitle||!e.isVisible||e.isSelected)return;const{index:t}=e;if(t>o&&t{e(parseInt(t))})}setTimeout(()=>{this.renderOptions()},0)}toggleAllOptions(e){if(!this.multiple||this.disableSelectAll)return;const t="boolean"==typeof isSelected?e:!s.hasClass(this.$toggleAllCheckbox,"checked"),i=[],{selectAllOnlyVisible:o}=this;this.options.forEach(e=>{const s=e;if(s.isDisabled||s.isCurrentNew)return;const{isVisible:n,isSelected:r}=s;!t&&(!o||n||!r)||t&&o&&!n&&!r?s.isSelected=!1:(s.isSelected=!0,s.isGroupTitle||i.push(s.value))}),this.toggleAllOptionsClass(t),this.setValue(i),this.renderOptions()}toggleAllOptionsClass(e){if(!this.multiple)return;let t=!1;"boolean"==typeof e||(e=this.isAllOptionsSelected()),!e&&this.selectAllOnlyVisible&&""!==this.searchValue&&(this.visibleOptionsCount>0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),s.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}isAllOptionsSelected(e){let t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible))),t}isAllGroupOptionsSelected(e){let t=!1;return this.options.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e)),t}toggleGroupOptionsParent(e,t){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;let i=s.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));const o=this.$options.querySelector(`.vscomp-option[data-index="${i}"]`),n="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,n),this.toggleGroupTitleProp(i,n)}toggleGroupTitleProp(e,t){const s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,s)}toggleGroupOptions(e,i){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;const o=s.getData(e,"index","number"),{selectedValues:n,selectAllOnlyVisible:r}=this,a={},{removeItemFromArray:l}=t;n.forEach(e=>{a[e]=!0}),this.options.forEach(e=>{if(e.isDisabled||e.groupIndex!==o)return;const{value:t}=e;!i||r&&!e.isVisible?(e.isSelected=!1,a[t]&&l(n,t)):(e.isSelected=!0,a[t]||n.push(t))}),this.toggleAllOptionsClass(!!i&&null),this.setValue(n),setTimeout(()=>{this.renderOptions()},0)}toggleGroupTitleCheckbox(e,t){if(!e)return;const i=s.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}toggleFocusedProp(e,t=!1){this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}toggleSelectedProp(e,t=!1){this.setOptionProp(e,"isSelected",t)}scrollToTop(){const{scrollTop:e}=this.$optionsContainer;e>0&&(this.$optionsContainer.scrollTop=0)}reset(e=!1,t=!1){this.options.forEach(e=>{e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&s.removeClass(this.$allWrappers,"has-error"),s.dispatchEvent(this.$ele,"reset")}addOption(e,t){if(!e)return;this.lastOptionIndex+=1;const s=this.getOptionObj({...e,index:this.lastOptionIndex});this.options.push(s),this.sortedOptions.push(s),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}removeOption(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}removeNewOption(){const e=this.getNewOption();e&&this.removeOption(e.index)}sortOptions(e){return e.sort((e,t)=>{const s=e.isSelected||e.isAnySelected,i=t.isSelected||t.isAnySelected;return s||i?s&&(!i||e.index{const s=e.options;e.isAnySelected=s.some(e=>e.isSelected),e.isAnySelected&&t(s)}),t(s),this.destructureOptionGroup(s)}isOptionVisible({data:e,searchValue:s,hasExactOption:i,visibleOptionGroupsMapping:o,searchGroup:n,searchByStartsWith:r}){const a=null!=e.valueNormalized?e.valueNormalized:e.value.toLowerCase();let l=e.labelNormalized;if(null==l){const s=(e.label||"").trim();l=this.searchNormalize&&""!==s?t.normalizeString(s).toLowerCase():s.toLowerCase()}const{description:p,alias:h}=e;let{descriptionNormalized:c}=e;if(null==c){const e=p||"";c=this.searchNormalize&&""!==e.trim()?t.normalizeString(e).toLowerCase():e.toLowerCase()}let u=r?l.startsWith(s):l.includes(s);return!e.isGroupTitle||n&&u||(u=o[e.index]),r||!h||u||(u=h.includes(s)),r||!c||u||(u=c.includes(s)),e.isVisible=u,i||(i=l===s||a===s),{isVisible:u,hasExactOption:i}}structureOptionGroup(e){const t=[],s={};return e.forEach(e=>{if(e.isGroupTitle){const i=[];e.options=i,s[e.index]=i,t.push(e)}}),e.forEach(e=>{e.isGroupOption&&s[e.groupIndex].push(e)}),t}destructureOptionGroup(e){let t=[];return e.forEach(e=>{t.push(e),t=t.concat(e.options)}),t}serverSearch(){s.removeClass(this.$allWrappers,"has-no-search-results"),s.addClass(this.$allWrappers,"server-searching"),this.setSelectedOptions(),this.onServerSearch(this.searchValue,this)}removeValue(e){const{selectedValues:i}=this,o=s.getData(e,"value");t.removeItemFromArray(i,o),this.setValueMethod(i)}focus(){this.$wrapper.focus()}enable(){this.$ele.disabled=!1,this.$ele.removeAttribute("disabled"),this.$hiddenInput.removeAttribute("disabled"),s.setAria(this.$wrapper,"disabled",!1),s.changeTabIndex(this.$wrapper,0)}disable(){this.$ele.disabled=!0,this.$ele.setAttribute("disabled",""),this.$hiddenInput.setAttribute("disabled",""),s.setAria(this.$wrapper,"disabled",!0),s.changeTabIndex(this.$wrapper,-1),this.$wrapper.blur()}validate(){if(this.disableValidation)return!0;let e=!1;const{selectedValues:i,minValues:o}=this;return this.required&&(t.isEmpty(i)||this.multiple&&o&&i.length{t.virtualSelect?i.push(t.virtualSelect):(e.ele=t,"SELECT"===t.tagName&&l.setPropsFromSelect(e),i.push(new l(e)))}),s?i[0]:i}static getAttrProps(){const{convertPropToDataAttr:e}=s,t={};return n.forEach(e=>{t[e]=e}),a.forEach(s=>{t[e(s)]=s}),t}static setPropsFromSelect(e){const t=e.ele,i=[],n=[],a=e=>{const t=[];return Array.from(e.children).forEach(e=>{const{value:s}=e,o={value:s};"OPTGROUP"===e.tagName?(o.label=e.getAttribute("label"),o.options=a(e)):o.label=e.innerHTML,t.push(o),e.disabled&&i.push(s),e.selected&&n.push(s)}),t},l=a(t),p=document.createElement("div");s.setAttrFromEle(t,p,Object.keys(r),o),t.parentNode.insertBefore(p,t),t.remove(),e.ele=p,e.options=l,e.disabledOptions=i,e.selectedValue=n}static onFormReset(e){const t=e.target.closest("form");t&&t.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.reset(!0)})}static onFormSubmit(e){l.validate(e.target.closest("form"))||e.preventDefault()}static validate(e){if(!e)return!0;let t=!1;return e.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{const s=e.parentElement.virtualSelect.validate();t||s||(t=!0)}),!t}static reset(e=!1,t=!1){this.virtualSelect.reset(e,t)}static setValueMethod(...e){this.virtualSelect.setValueMethod(...e)}static setOptionsMethod(...e){this.virtualSelect.setOptionsMethod(...e)}static setDisabledOptionsMethod(...e){this.virtualSelect.setDisabledOptionsMethod(...e)}static setEnabledOptionsMethod(...e){this.virtualSelect.setEnabledOptionsMethod(...e)}static toggleSelectAll(e){this.virtualSelect.toggleAllOptions(e)}static isAllSelected(){return this.virtualSelect.isAllSelected}static addOptionMethod(e){this.virtualSelect.addOption(e,!0)}static getNewValueMethod(){return this.virtualSelect.getNewValue()}static getDisplayValueMethod(){return this.virtualSelect.getDisplayValue()}static getSelectedOptionsMethod(e){return this.virtualSelect.getSelectedOptions(e)}static getDisabledOptionsMethod(){return this.virtualSelect.getDisabledOptions()}static openMethod(){return this.virtualSelect.openDropbox()}static closeMethod(){return this.virtualSelect.closeDropbox()}static focusMethod(){return this.virtualSelect.focus()}static enableMethod(){return this.virtualSelect.enable()}static disableMethod(){return this.virtualSelect.disable()}static destroyMethod(){return this.virtualSelect.destroy()}static validateMethod(){return this.virtualSelect.validate()}static toggleRequiredMethod(e){return this.virtualSelect.toggleRequired(e)}static onResizeMethod(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.onResize()})}}document.addEventListener("reset",l.onFormReset),document.addEventListener("submit",l.onFormSubmit),window.addEventListener("resize",l.onResizeMethod),r=l.getAttrProps(),window.VirtualSelect=l,l.openInstances=new Set,l.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,s){if(e){if("string"==typeof e)return t(e,s);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,s):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,i=new Array(t);ss-o-t.width?"left":"right",vertical:n>i-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),s=window.pageXOffset,i=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+i,right:t.right+s,bottom:t.bottom+i,left:t.left+s}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,s){if(e){var i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}}},{key:"setData",value:function(e,t,s){e&&(e.dataset[t]=s)}},{key:"setStyle",value:function(e,t,s){e&&(e.style[t]=s)}},{key:"show",value:function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",s)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,s=e.parentElement;s;){var i=getComputedStyle(s).overflow;if(-1!==i.indexOf("scroll")||-1!==i.indexOf("auto")){t=s;break}s=s.parentElement}return t}}],s&&function(e,t){for(var s=0;sO?O-b:M:w+h>L&&("right"===E?n="left":w=L+by?y-u:P:C+c>I&&("bottom"===E?n="top":C=I+uh-j&&(G=h-j):"left"!==E&&"right"!==E||((H=m/2+g-R)c-j&&(H=c-j)),s.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}s.hide(this.$popperEle)}},{key:"resetPosition",value:function(){s.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.resetPosition,o=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),i&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=s.getData(e.$popperEle,"left"),i=s.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(i),"px, 0)"),r=e.showDuration;s.show(e.$popperEle,"inline-flex"),s.getCoords(e.$popperEle),s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(o)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var i=parseInt(s.getData(e.$popperEle,"fromLeft")),o=parseInt(s.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(i,"px, ").concat(o,"px, 0)"),r=e.hideDuration;s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){s.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){s.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(s.getData(this.$popperEle,"left")),t=parseInt(s.getData(this.$popperEle,"top"));s.show(this.$popperEle,"inline-flex"),s.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var s=0;s1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var s,i=0;return function(){for(var o=arguments.length,n=new Array(o),r=0;re.length)&&(t=e.length);for(var s=0,i=new Array(t);s'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&c(t.prototype,s),o&&c(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,s,o}();d=f.getAttrProps(),window.PopoverComponent=f}(); \ No newline at end of file diff --git a/dist/virtual-select.js b/dist/virtual-select.js index 9a44cda..1176824 100644 --- a/dist/virtual-select.js +++ b/dist/virtual-select.js @@ -10,675 +10,554 @@ // UNUSED EXPORTS: VirtualSelect ;// ./src/utils/utils.js -function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } -function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } -function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } -function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } -function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -var Utils = /*#__PURE__*/function () { - function Utils() { - _classCallCheck(this, Utils); - } - return _createClass(Utils, null, [{ - key: "getString", - value: - /** - * @param {any} text - * @returns {string} - * @memberof Utils - */ - function getString(text) { - return text || text === 0 ? text.toString() : ''; - } +const NON_WORD_CHARS_REGEX = /[^\p{L}\p{N}_]/gu; +class Utils { + /** + * @param {any} text + * @returns {string} + * @memberof Utils + */ + static getString(text) { + return text || text === 0 ? text.toString() : ''; + } + + /** + * @param {any} value + * @param {boolean} defaultValue + * @returns {boolean} + * @memberof Utils + */ + static convertToBoolean(value, defaultValue = false) { + let result; + if (value === true || value === 'true') { + result = true; + } else if (value === false || value === 'false') { + result = false; + } else { + result = defaultValue; + } + return result; + } - /** - * @param {any} value - * @param {boolean} defaultValue - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "convertToBoolean", - value: function convertToBoolean(value) { - var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var result; - if (value === true || value === 'true') { + /** + * @param {any} value + * @returns {boolean} + * @memberof Utils + */ + static isEmpty(value) { + let result = false; + if (!value) { + result = true; + } else if (Array.isArray(value)) { + if (value.length === 0) { result = true; - } else if (value === false || value === 'false') { - result = false; - } else { - result = defaultValue; } - return result; + } else if (typeof value === 'object' && Object.keys(value).length === 0) { + result = true; } + return result; + } - /** - * @param {any} value - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "isEmpty", - value: function isEmpty(value) { - var result = false; - if (!value) { - result = true; - } else if (Array.isArray(value)) { - if (value.length === 0) { - result = true; + /** + * @param {any} value + * @returns {boolean} + * @memberof Utils + */ + static isNotEmpty(value) { + return !Utils.isEmpty(value); + } + + /** + * Normalizes values by converting booleans to strings while preserving other types + * Handles both single values and arrays efficiently + * @param {*} value - The value to normalize + * @return {*} - Normalized value(s) + * @memberof Utils + */ + static normalizeValues(value) { + // Fast path for arrays + if (Array.isArray(value)) { + const result = new Array(value.length); + for (let i = 0; i < value.length; i += 1) { + const v = value[i]; + if (v === true) { + result[i] = 'true'; + } else if (v === false) { + result[i] = 'false'; + } else { + result[i] = v; } - } else if (_typeof(value) === 'object' && Object.keys(value).length === 0) { - result = true; } return result; } - /** - * @param {any} value - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "isNotEmpty", - value: function isNotEmpty(value) { - return !Utils.isEmpty(value); + // Handle single values + if (value === true) { + return 'true'; } - - /** - * Normalizes values by converting booleans to strings while preserving other types - * Handles both single values and arrays efficiently - * @param {*} value - The value to normalize - * @return {*} - Normalized value(s) - * @memberof Utils - */ - }, { - key: "normalizeValues", - value: function normalizeValues(value) { - // Fast path for arrays - if (Array.isArray(value)) { - var result = new Array(value.length); - for (var i = 0; i < value.length; i += 1) { - var v = value[i]; - if (v === true) { - result[i] = 'true'; - } else if (v === false) { - result[i] = 'false'; - } else { - result[i] = v; - } - } - return result; - } - - // Handle single values - if (value === true) { - return 'true'; - } - if (value === false) { - return 'false'; - } - return value; + if (value === false) { + return 'false'; } + return value; + } - /** - * @param {any[]} array - * @param {any} value - * @param {boolean} cloneArray - * @returns {any[]} - * @memberof Utils - */ - }, { - key: "removeItemFromArray", - value: function removeItemFromArray(array, value) { - var cloneArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (!Array.isArray(array) || !array.length) { - return array; - } - var inputArr = cloneArray ? _toConsumableArray(array) : array; - var index = inputArr.indexOf(value); - if (index !== -1) { - inputArr.splice(index, 1); - } - return inputArr; + /** + * @param {any[]} array + * @param {any} value + * @param {boolean} cloneArray + * @returns {any[]} + * @memberof Utils + */ + static removeItemFromArray(array, value, cloneArray = false) { + if (!Array.isArray(array) || !array.length) { + return array; } - - /** - * @param {any[]} array - * @returns {any[]} - * @memberof Utils - */ - }, { - key: "removeArrayEmpty", - value: function removeArrayEmpty(array) { - if (!Array.isArray(array) || !array.length) { - return []; - } - return array.filter(function (d) { - return !!d; - }); + const inputArr = cloneArray ? [...array] : array; + const index = inputArr.indexOf(value); + if (index !== -1) { + inputArr.splice(index, 1); } + return inputArr; + } - /** - * @param {number} max - * @param {number} max - * @returns {number} - * @memberof Utils - */ - }, { - key: "getRandomInt", - value: function getRandomInt(max) { - var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var minN = Math.ceil(min); - var maxN = Math.floor(max); - return Math.floor(Math.random() * (maxN - minN - 1)) + minN; + /** + * @param {any[]} array + * @returns {any[]} + * @memberof Utils + */ + static removeArrayEmpty(array) { + if (!Array.isArray(array) || !array.length) { + return []; } + return array.filter(d => !!d); + } - /** - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "regexEscape", - value: function regexEscape(text) { - var ESC_REGEX = /[-/\\^$*+?.()|[\]{}]/g; - return text.replace(ESC_REGEX, '\\$&'); - } + /** + * @param {number} max + * @param {number} max + * @returns {number} + * @memberof Utils + */ + static getRandomInt(max, min = 0) { + const minN = Math.ceil(min); + const maxN = Math.floor(max); + return Math.floor(Math.random() * (maxN - minN - 1)) + minN; + } - /** - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "normalizeString", - value: function normalizeString(text) { - var NON_WORD_REGEX = /[^\w]/g; - return text.normalize('NFD').replace(NON_WORD_REGEX, ''); - } + /** + * @param {string} text + * @return {string} + * @memberof Utils + */ + static regexEscape(text) { + const ESC_REGEX = /[-/\\^$*+?.()|[\]{}]/g; + return text.replace(ESC_REGEX, '\\$&'); + } - /** - * @static - * @param {*} container - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "willTextOverflow", - value: function willTextOverflow(container, text) { - var tempElement = document.createElement('div'); - tempElement.style.position = 'absolute'; - tempElement.style.visibility = 'hidden'; - tempElement.style.whiteSpace = 'nowrap'; - tempElement.style.fontSize = window.getComputedStyle(container).fontSize; - tempElement.style.fontFamily = window.getComputedStyle(container).fontFamily; - tempElement.textContent = text; - document.body.appendChild(tempElement); - var textWidth = tempElement.clientWidth; - document.body.removeChild(tempElement); - return textWidth > container.clientWidth; - } + /** + * Normalizes a string for diacritic-insensitive search. Decomposes the input + * via NFD, then strips every character that is not a Unicode letter + * (\p{L}), number (\p{N}), or underscore. As a side effect this removes + * combining marks (so "München" matches "Munchen", "Việt Nam" matches + * "Viet Nam", "Ёжик" matches "Ежик") as well as punctuation and whitespace + * (so "co-op" matches "coop" and "Foo Bar" collapses into "FooBar"). + * Base letters and numbers from many scripts (Latin, Greek, Cyrillic, CJK, + * etc.) are preserved, but scripts that rely on combining marks are NOT + * fully preserved — every Unicode combining mark is removed, which affects + * Thai vowel signs, Devanagari matras, hiragana/katakana voicing marks + * (dakuten/handakuten), etc. This produces fuzzier matching for those + * scripts; use `searchNormalize: false` if exact-match behavior is + * required. + * + * Note: a few atomic letters do not decompose under NFD (e.g. "ø", "æ", "ß") + * and are kept as-is — a search for "Bjorn" will not match "Bjørn". + * + * @param {string} text + * @return {string} + * @memberof Utils + */ + static normalizeString(text) { + return text.normalize('NFD').replace(NON_WORD_CHARS_REGEX, ''); + } - /** - * @static - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "replaceDoubleQuotesWithHTML", - value: function replaceDoubleQuotesWithHTML(text) { - return text.replace(/"/g, '"'); - } + /** + * @static + * @param {*} container + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static willTextOverflow(container, text) { + const tempElement = document.createElement('div'); + tempElement.style.position = 'absolute'; + tempElement.style.visibility = 'hidden'; + tempElement.style.whiteSpace = 'nowrap'; + tempElement.style.fontSize = window.getComputedStyle(container).fontSize; + tempElement.style.fontFamily = window.getComputedStyle(container).fontFamily; + tempElement.textContent = text; + document.body.appendChild(tempElement); + const textWidth = tempElement.clientWidth; + document.body.removeChild(tempElement); + return textWidth > container.clientWidth; + } - /** - * @static - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "containsHTML", - value: function containsHTML(text) { - return /<[a-z][\s\S]*>/i.test(text); - } + /** + * @static + * @param {string} text + * @return {string} + * @memberof Utils + */ + static replaceDoubleQuotesWithHTML(text) { + return text.replace(/"/g, '"'); + } - /** - * @static - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "containsHTMLorJS", - value: function containsHTMLorJS(text) { - return /<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(text); - } - }]); -}(); + /** + * @static + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static containsHTML(text) { + return /<[a-z][\s\S]*>/i.test(text); + } + + /** + * @static + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static containsHTMLorJS(text) { + return /<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(text); + } +} ;// ./src/utils/dom-utils.js -function dom_utils_typeof(o) { "@babel/helpers - typeof"; return dom_utils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, dom_utils_typeof(o); } -function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || dom_utils_unsupportedIterableToArray(r, e) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } -function dom_utils_toConsumableArray(r) { return dom_utils_arrayWithoutHoles(r) || dom_utils_iterableToArray(r) || dom_utils_unsupportedIterableToArray(r) || dom_utils_nonIterableSpread(); } -function dom_utils_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function dom_utils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return dom_utils_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? dom_utils_arrayLikeToArray(r, a) : void 0; } } -function dom_utils_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function dom_utils_arrayWithoutHoles(r) { if (Array.isArray(r)) return dom_utils_arrayLikeToArray(r); } -function dom_utils_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function dom_utils_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function dom_utils_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, dom_utils_toPropertyKey(o.key), o); } } -function dom_utils_createClass(e, r, t) { return r && dom_utils_defineProperties(e.prototype, r), t && dom_utils_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function dom_utils_toPropertyKey(t) { var i = dom_utils_toPrimitive(t, "string"); return "symbol" == dom_utils_typeof(i) ? i : i + ""; } -function dom_utils_toPrimitive(t, r) { if ("object" != dom_utils_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != dom_utils_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -var DomUtils = /*#__PURE__*/function () { - function DomUtils() { - dom_utils_classCallCheck(this, DomUtils); - } - return dom_utils_createClass(DomUtils, null, [{ - key: "addClass", - value: - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - */ - function addClass($ele, classNames) { - if (!$ele) { - return; - } - var classNamesArr = classNames.split(' '); - DomUtils.getElements($ele).forEach(function ($this) { - var _$this$classList; - (_$this$classList = $this.classList).add.apply(_$this$classList, dom_utils_toConsumableArray(classNamesArr)); - }); - } +class DomUtils { + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + */ + static addClass($ele, classNames) { + if (!$ele) { + return; + } + const classNamesArr = classNames.split(' '); + DomUtils.getElements($ele).forEach($this => { + $this.classList.add(...classNamesArr); + }); + } - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - */ - }, { - key: "removeClass", - value: function removeClass($ele, classNames) { - if (!$ele) { - return; - } - var classNamesArr = classNames.split(' '); - DomUtils.getElements($ele).forEach(function ($this) { - var _$this$classList2; - (_$this$classList2 = $this.classList).remove.apply(_$this$classList2, dom_utils_toConsumableArray(classNamesArr)); - }); + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + */ + static removeClass($ele, classNames) { + if (!$ele) { + return; + } + const classNamesArr = classNames.split(' '); + DomUtils.getElements($ele).forEach($this => { + $this.classList.remove(...classNamesArr); + }); + } + + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + * @param {boolean} [isAdd] + */ + static toggleClass($ele, classNames, isAdd) { + if (!$ele) { + return; } - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - * @param {boolean} [isAdd] - */ - }, { - key: "toggleClass", - value: function toggleClass($ele, classNames, isAdd) { - if (!$ele) { - return; - } + /** @type {boolean | undefined} */ + let isAdding; + if (isAdd !== undefined) { + isAdding = Boolean(isAdd); + } + DomUtils.getElements($ele).forEach($this => { + $this.classList.toggle(classNames, isAdding); + }); + } - /** @type {boolean | undefined} */ - var isAdding; - if (isAdd !== undefined) { - isAdding = Boolean(isAdd); - } - DomUtils.getElements($ele).forEach(function ($this) { - $this.classList.toggle(classNames, isAdding); - }); + /** + * @param {HTMLElement} $ele + * @param {string} className + * @returns {boolean} + */ + static hasClass($ele, className) { + if (!$ele) { + return false; } + return $ele.classList.contains(className); + } - /** - * @param {HTMLElement} $ele - * @param {string} className - * @returns {boolean} - */ - }, { - key: "hasClass", - value: function hasClass($ele, className) { - if (!$ele) { - return false; - } - return $ele.classList.contains(className); + /** + * @param {HTMLElement} $ele + * @returns {boolean} + */ + static hasEllipsis($ele) { + if (!$ele) { + return false; } + return $ele.scrollWidth > $ele.offsetWidth; + } - /** - * @param {HTMLElement} $ele - * @returns {boolean} - */ - }, { - key: "hasEllipsis", - value: function hasEllipsis($ele) { - if (!$ele) { - return false; - } - return $ele.scrollWidth > $ele.offsetWidth; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} [type] + * @returns {any} + */ + static getData($ele, name, type) { + if (!$ele) { + return undefined; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} [type] - * @returns {any} - */ - }, { - key: "getData", - value: function getData($ele, name, type) { - if (!$ele) { - return undefined; - } + /** @type {any} */ + let value = $ele ? $ele.dataset[name] : ''; + if (type === 'number') { + value = parseFloat(value) || 0; + } else if (value === 'true') { + value = true; + } else if (value === 'false') { + value = false; + } + return value; + } - /** @type {any} */ - var value = $ele ? $ele.dataset[name] : ''; - if (type === 'number') { - value = parseFloat(value) || 0; - } else if (value === 'true') { - value = true; - } else if (value === 'false') { - value = false; - } - return value; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setData($ele, name, value) { + if (!$ele) { + return; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setData", - value: function setData($ele, name, value) { - if (!$ele) { - return; - } + // eslint-disable-next-line no-param-reassign + $ele.dataset[name] = value; + } - // eslint-disable-next-line no-param-reassign - $ele.dataset[name] = value; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setAttr($ele, name, value) { + if (!$ele) { + return; } + $ele.setAttribute(name, value); + } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setAttr", - value: function setAttr($ele, name, value) { - if (!$ele) { - return; - } - $ele.setAttribute(name, value); - } + /** + * @param {HTMLElement} $from + * @param {HTMLElement} $to + * @param {string[]} attrList + * @param {string[]} valueLessProps + */ + static setAttrFromEle($from, $to, attrList, valueLessProps) { + /** @type {any} */ + const values = {}; + attrList.forEach(attr => { + values[attr] = $from.getAttribute(attr); + }); + attrList.forEach(attr => { + const value = values[attr]; + if (value || valueLessProps.indexOf(attr) !== -1 && value === '') { + $to.setAttribute(attr, value); + } + }); + } - /** - * @param {HTMLElement} $from - * @param {HTMLElement} $to - * @param {string[]} attrList - * @param {string[]} valueLessProps - */ - }, { - key: "setAttrFromEle", - value: function setAttrFromEle($from, $to, attrList, valueLessProps) { - /** @type {any} */ - var values = {}; - attrList.forEach(function (attr) { - values[attr] = $from.getAttribute(attr); - }); - attrList.forEach(function (attr) { - var value = values[attr]; - if (value || valueLessProps.indexOf(attr) !== -1 && value === '') { - $to.setAttribute(attr, value); - } - }); + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setStyle($ele, name, value) { + if (!$ele) { + return; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setStyle", - value: function setStyle($ele, name, value) { - if (!$ele) { - return; - } + // @ts-ignore + // eslint-disable-next-line no-param-reassign + $ele.style[name] = value; + } + /** + * @param {HTMLElement} $ele + * @param {any} props + */ + static setStyles($ele, props) { + if (!$ele || !props) { + return; + } + Object.keys(props).forEach(name => { // @ts-ignore // eslint-disable-next-line no-param-reassign - $ele.style[name] = value; - } + $ele.style[name] = props[name]; + }); + } - /** - * @param {HTMLElement} $ele - * @param {any} props - */ - }, { - key: "setStyles", - value: function setStyles($ele, props) { - if (!$ele || !props) { - return; - } - Object.keys(props).forEach(function (name) { - // @ts-ignore - // eslint-disable-next-line no-param-reassign - $ele.style[name] = props[name]; - }); + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setAria($ele, name, value) { + if (!$ele) { + return; } - - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setAria", - value: function setAria($ele, name, value) { - if (!$ele) { - return; - } - var attrName = name; - if (attrName !== 'role') { - attrName = "aria-".concat(attrName); - } - $ele.setAttribute(attrName, value); + let attrName = name; + if (attrName !== 'role') { + attrName = `aria-${attrName}`; } + $ele.setAttribute(attrName, value); + } - /** - * @param {any} $ele - * @returns {any[]} - */ - }, { - key: "getElements", - value: function getElements($ele) { - if (!$ele) { - return []; - } - return $ele.forEach === undefined ? [$ele] : $ele; + /** + * @param {any} $ele + * @returns {any[]} + */ + static getElements($ele) { + if (!$ele) { + return []; } + return $ele.forEach === undefined ? [$ele] : $ele; + } - /** - * @static - * @param {string} [$selector=''] - * @param {*} [$parentEle=undefined] - * @return {*} - * @memberof DomUtils - */ - }, { - key: "getElementsBySelector", - value: function getElementsBySelector() { - var $selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var $parentEle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; - var elements; - var parent = $parentEle !== undefined ? $parentEle : document; - if ($selector !== '') { - elements = parent.querySelectorAll($selector); - } - return elements !== undefined ? Array.from(elements) : []; + /** + * @static + * @param {string} [$selector=''] + * @param {*} [$parentEle=undefined] + * @return {*} + * @memberof DomUtils + */ + static getElementsBySelector($selector = '', $parentEle = undefined) { + let elements; + const parent = $parentEle !== undefined ? $parentEle : document; + if ($selector !== '') { + elements = parent.querySelectorAll($selector); } + return elements !== undefined ? Array.from(elements) : []; + } - /** - * @param {HTMLElement} $ele - * @param {string} events - * @param {Function} callback - * @param {boolean} capture - */ - }, { - key: "addEvent", - value: function addEvent($ele, events, callback, capture) { - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var $eleArray = DomUtils.getElements($ele); - $eleArray.forEach(function ($this) { - $this.addEventListener(event, callback, { - capture: capture - }); + /** + * @param {HTMLElement} $ele + * @param {string} events + * @param {Function} callback + * @param {boolean} capture + */ + static addEvent($ele, events, callback, capture) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const $eleArray = DomUtils.getElements($ele); + $eleArray.forEach($this => { + $this.addEventListener(event, callback, { + capture }); }); - } + }); + } - /** - * @param {HTMLElement} $ele - * @param {string} eventName - * @param {boolean} [bubbles] - */ - }, { - key: "dispatchEvent", - value: function dispatchEvent($ele, eventName) { - var bubbles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (!$ele) { - return; - } - var $eleArray = DomUtils.getElements($ele); + /** + * @param {HTMLElement} $ele + * @param {string} eventName + * @param {boolean} [bubbles] + */ + static dispatchEvent($ele, eventName, bubbles = false) { + if (!$ele) { + return; + } + const $eleArray = DomUtils.getElements($ele); + + /** using setTimeout to trigger asynchronous event */ + setTimeout(() => { + $eleArray.forEach($this => { + $this.dispatchEvent(new CustomEvent(eventName, { + bubbles + })); + }); + }, 0); + } - /** using setTimeout to trigger asynchronous event */ - setTimeout(function () { - $eleArray.forEach(function ($this) { - $this.dispatchEvent(new CustomEvent(eventName, { - bubbles: bubbles - })); - }); - }, 0); + /** + * convert object to dom attributes + * @param {ObjectString} data + */ + static getAttributesText(data) { + let html = ''; + if (!data) { + return html; } - /** - * convert object to dom attributes - * @param {ObjectString} data - */ - }, { - key: "getAttributesText", - value: function getAttributesText(data) { - var html = ''; - if (!data) { - return html; + // @ts-ignore + Object.entries(data).forEach(([k, v]) => { + if (v !== undefined) { + html += ` ${k}="${v}" `; } + }); + return html; + } - // @ts-ignore - Object.entries(data).forEach(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - k = _ref2[0], - v = _ref2[1]; - if (v !== undefined) { - html += " ".concat(k, "=\"").concat(v, "\" "); - } - }); - return html; - } - - /** - * convert "maxValue" to "data-max-value" - * @param {string} prop - */ - }, { - key: "convertPropToDataAttr", - value: function convertPropToDataAttr(prop) { - return prop ? "data-".concat(prop).replace(/([A-Z])/g, '-$1').toLowerCase() : ''; - } + /** + * convert "maxValue" to "data-max-value" + * @param {string} prop + */ + static convertPropToDataAttr(prop) { + return prop ? `data-${prop}`.replace(/([A-Z])/g, '-$1').toLowerCase() : ''; + } - /** - * Changes the tab index of an element passed as an input - * @static - * @param {HTMLElement | NodeListOf} $ele - * @param {number} newTabIndex - * @memberof DomUtils - */ - }, { - key: "changeTabIndex", - value: function changeTabIndex($ele, newTabIndex) { - if (!$ele) { - // eslint-disable-next-line no-console - console.log($ele, 'Invalid element provided.'); - return; - } - DomUtils.getElements($ele).forEach(function ($this) { - // eslint-disable-next-line no-param-reassign - $this.tabIndex = newTabIndex; - }); + /** + * Changes the tab index of an element passed as an input + * @static + * @param {HTMLElement | NodeListOf} $ele + * @param {number} newTabIndex + * @memberof DomUtils + */ + static changeTabIndex($ele, newTabIndex) { + if (!$ele) { + // eslint-disable-next-line no-console + console.log($ele, 'Invalid element provided.'); + return; } + DomUtils.getElements($ele).forEach($this => { + // eslint-disable-next-line no-param-reassign + $this.tabIndex = newTabIndex; + }); + } - /** - * @param {HTMLElement} $ele - * @param {string} event - * @param {Function} callback - */ - }, { - key: "removeEvent", - value: function removeEvent($ele, event, callback) { - if (!$ele) { - return; - } - var $eleArray = DomUtils.getElements($ele); - $eleArray.forEach(function ($this) { - $this.removeEventListener(event, callback); - }); - } - }]); -}(); + /** + * @param {HTMLElement} $ele + * @param {string} event + * @param {Function} callback + */ + static removeEvent($ele, event, callback) { + if (!$ele) { + return; + } + const $eleArray = DomUtils.getElements($ele); + $eleArray.forEach($this => { + $this.removeEventListener(event, callback); + }); + } +} ;// ./src/virtual-select.js -function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } -function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } -function _defineProperty(e, r, t) { return (r = virtual_select_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function virtual_select_typeof(o) { "@babel/helpers - typeof"; return virtual_select_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, virtual_select_typeof(o); } -function virtual_select_slicedToArray(r, e) { return virtual_select_arrayWithHoles(r) || virtual_select_iterableToArrayLimit(r, e) || virtual_select_unsupportedIterableToArray(r, e) || virtual_select_nonIterableRest(); } -function virtual_select_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function virtual_select_iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function virtual_select_arrayWithHoles(r) { if (Array.isArray(r)) return r; } -function virtual_select_toConsumableArray(r) { return virtual_select_arrayWithoutHoles(r) || virtual_select_iterableToArray(r) || virtual_select_unsupportedIterableToArray(r) || virtual_select_nonIterableSpread(); } -function virtual_select_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function virtual_select_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return virtual_select_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? virtual_select_arrayLikeToArray(r, a) : void 0; } } -function virtual_select_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function virtual_select_arrayWithoutHoles(r) { if (Array.isArray(r)) return virtual_select_arrayLikeToArray(r); } -function virtual_select_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function virtual_select_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function virtual_select_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, virtual_select_toPropertyKey(o.key), o); } } -function virtual_select_createClass(e, r, t) { return r && virtual_select_defineProperties(e.prototype, r), t && virtual_select_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function virtual_select_toPropertyKey(t) { var i = virtual_select_toPrimitive(t, "string"); return "symbol" == virtual_select_typeof(i) ? i : i + ""; } -function virtual_select_toPrimitive(t, r) { if ("object" != virtual_select_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != virtual_select_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** cSpell:ignore nocheck, Labelledby, vscomp, tabindex, combobox, haspopup, listbox, activedescendant */ /* eslint-disable class-methods-use-this */ // @ts-nocheck -var dropboxCloseButtonFullHeight = 48; -var searchHeight = 40; -var keyDownMethodMapping = { +const dropboxCloseButtonFullHeight = 48; +const searchHeight = 40; +const keyDownMethodMapping = { 13: 'onEnterPress', 38: 'onUpArrowPress', 40: 'onDownArrowPress', @@ -686,18 +565,17 @@ var keyDownMethodMapping = { // Delete 8: 'onBackspaceOrDeletePress' // Backspace }; -var valueLessProps = ['autofocus', 'disabled', 'multiple', 'required']; -var nativeProps = ['autofocus', 'class', 'disabled', 'id', 'multiple', 'name', 'placeholder', 'required']; -var attrPropsMapping; -var dataProps = ['additionalClasses', 'additionalDropboxClasses', 'additionalDropboxContainerClasses', 'additionalToggleButtonClasses', 'aliasKey', 'allOptionsSelectedText', 'allowNewOption', 'alwaysShowSelectedOptionsCount', 'alwaysShowSelectedOptionsLabel', 'ariaLabelledby', 'ariaLabelText', 'ariaLabelClearButtonText', 'ariaLabelTagClearButtonText', 'ariaLabelSearchClearButtonText', 'autoSelectFirstOption', 'clearButtonText', 'descriptionKey', 'disableAllOptionsSelectedText', 'disableOptionGroupCheckbox', 'disableSelectAll', 'disableValidation', 'dropboxWidth', 'dropboxWrapper', 'emptyValue', 'enableSecureText', 'focusSelectedOptionOnOpen', 'hasOptionDescription', 'hideClearButton', 'hideValueTooltipOnSelectAll', 'keepAlwaysOpen', 'labelKey', 'markSearchResults', 'maxValues', 'maxWidth', 'minValues', 'moreText', 'noOfDisplayValues', 'noOptionsText', 'noSearchResultsText', 'optionHeight', 'optionSelectedText', 'optionsCount', 'optionsSelectedText', 'popupDropboxBreakpoint', 'popupPosition', 'position', 'search', 'searchByStartsWith', 'searchDelay', 'searchFormLabel', 'searchGroup', 'searchNormalize', 'searchPlaceholderText', 'selectAllOnlyVisible', 'selectAllText', 'setValueAsArray', 'showDropboxAsPopup', 'showOptionsOnlyOnSearch', 'showSelectedOptionsFirst', 'showValueAsTags', 'silentInitialValueSet', 'textDirection', 'tooltipAlignment', 'tooltipFontSize', 'tooltipMaxWidth', 'updatePositionThrottle', 'useGroupValue', 'valueKey', 'zIndex']; +const valueLessProps = ['autofocus', 'disabled', 'multiple', 'required']; +const nativeProps = ['autofocus', 'class', 'disabled', 'id', 'multiple', 'name', 'placeholder', 'required']; +let attrPropsMapping; +const dataProps = ['additionalClasses', 'additionalDropboxClasses', 'additionalDropboxContainerClasses', 'additionalToggleButtonClasses', 'aliasKey', 'allOptionsSelectedText', 'allowNewOption', 'alwaysShowSelectedOptionsCount', 'alwaysShowSelectedOptionsLabel', 'ariaLabelledby', 'ariaLabelText', 'ariaLabelClearButtonText', 'ariaLabelTagClearButtonText', 'ariaLabelSearchClearButtonText', 'autoSelectFirstOption', 'clearButtonText', 'descriptionKey', 'disableAllOptionsSelectedText', 'disableOptionGroupCheckbox', 'disableSelectAll', 'disableValidation', 'dropboxWidth', 'dropboxWrapper', 'emptyValue', 'enableSecureText', 'focusSelectedOptionOnOpen', 'hasOptionDescription', 'hideClearButton', 'hideValueTooltipOnSelectAll', 'keepAlwaysOpen', 'labelKey', 'markSearchResults', 'maxValues', 'maxWidth', 'minValues', 'moreText', 'noOfDisplayValues', 'noOptionsText', 'noSearchResultsText', 'optionHeight', 'optionSelectedText', 'optionsCount', 'optionsSelectedText', 'popupDropboxBreakpoint', 'popupPosition', 'position', 'search', 'searchByStartsWith', 'searchDelay', 'searchFormLabel', 'searchGroup', 'searchNormalize', 'searchPlaceholderText', 'selectAllOnlyVisible', 'selectAllText', 'setValueAsArray', 'showDropboxAsPopup', 'showOptionsOnlyOnSearch', 'showSelectedOptionsFirst', 'showValueAsTags', 'silentInitialValueSet', 'textDirection', 'tooltipAlignment', 'tooltipFontSize', 'tooltipMaxWidth', 'updatePositionThrottle', 'useGroupValue', 'valueKey', 'zIndex']; /** Class representing VirtualSelect */ -var VirtualSelect = /*#__PURE__*/function () { +class VirtualSelect { /** * @param {virtualSelectOptions} options */ - function VirtualSelect(options) { - virtual_select_classCallCheck(this, VirtualSelect); + constructor(options) { try { this.createSecureTextElements(); this.setProps(options); @@ -713,3368 +591,3138 @@ var VirtualSelect = /*#__PURE__*/function () { } /** render methods - start */ - return virtual_select_createClass(VirtualSelect, [{ - key: "render", - value: function render() { - if (!this.$ele) { - return; - } - var uniqueId = this.uniqueId; - var wrapperClasses = 'vscomp-wrapper'; - var toggleButtonClasses = 'vscomp-toggle-button'; - var valueTooltip = this.showValueAsTags ? '' : this.getTooltipAttrText(this.placeholder, true, true); - var clearButtonTooltip = this.getTooltipAttrText(this.clearButtonText); - var ariaLabelledbyText = this.ariaLabelledby ? "aria-labelledby=\"".concat(this.ariaLabelledby, "\"") : ''; - var ariaLabelText = this.ariaLabelText ? "aria-label=\"".concat(this.ariaLabelText, "\"") : ''; - var ariaLabelClearBtnTxt = this.ariaLabelClearButtonText ? "aria-label=\"".concat(this.ariaLabelClearButtonText, "\"") : ''; - var isExpanded = false; - if (this.additionalClasses) { - wrapperClasses += " ".concat(this.additionalClasses); - } - if (this.additionalToggleButtonClasses) { - toggleButtonClasses += " ".concat(this.additionalToggleButtonClasses); - } - if (this.multiple) { - wrapperClasses += ' multiple'; - if (!this.disableSelectAll) { - wrapperClasses += ' has-select-all'; + render() { + if (!this.$ele) { + return; + } + const { + uniqueId + } = this; + let wrapperClasses = 'vscomp-wrapper'; + let toggleButtonClasses = 'vscomp-toggle-button'; + const valueTooltip = this.showValueAsTags ? '' : this.getTooltipAttrText(this.placeholder, true, true); + const clearButtonTooltip = this.getTooltipAttrText(this.clearButtonText); + const ariaLabelledbyText = this.ariaLabelledby ? `aria-labelledby="${this.ariaLabelledby}"` : ''; + const ariaLabelText = this.ariaLabelText ? `aria-label="${this.ariaLabelText}"` : ''; + const ariaLabelClearBtnTxt = this.ariaLabelClearButtonText ? `aria-label="${this.ariaLabelClearButtonText}"` : ''; + let isExpanded = false; + if (this.additionalClasses) { + wrapperClasses += ` ${this.additionalClasses}`; + } + if (this.additionalToggleButtonClasses) { + toggleButtonClasses += ` ${this.additionalToggleButtonClasses}`; + } + if (this.multiple) { + wrapperClasses += ' multiple'; + if (!this.disableSelectAll) { + wrapperClasses += ' has-select-all'; + } + } + if (!this.hideClearButton) { + wrapperClasses += ' has-clear-button'; + } + if (this.keepAlwaysOpen) { + wrapperClasses += ' keep-always-open'; + isExpanded = true; + } else { + wrapperClasses += ' closed'; + } + if (this.showAsPopup) { + wrapperClasses += ' show-as-popup'; + } + if (this.hasSearch) { + wrapperClasses += ' has-search-input'; + } + if (this.showValueAsTags) { + wrapperClasses += ' show-value-as-tags'; + } + if (this.textDirection) { + wrapperClasses += ` text-direction-${this.textDirection}`; + } + if (this.popupPosition) { + wrapperClasses += ` popup-position-${this.popupPosition.toLowerCase()}`; + } + + // eslint-disable-next-line no-trailing-spaces + const html = `
+ +
+
+ ${this.placeholder} +
+
+
+ +
+
+ + ${this.renderDropbox({ + wrapperClasses + })} +
`; + this.$ele.innerHTML = html; + this.$body = document.querySelector('body'); + this.$wrapper = this.$ele.querySelector('.vscomp-wrapper'); + if (this.hasDropboxWrapper) { + this.$allWrappers = [this.$wrapper, this.$dropboxWrapper]; + this.$dropboxContainer = this.$dropboxWrapper.querySelector('.vscomp-dropbox-container'); + DomUtils.addClass(this.$dropboxContainer, 'pop-comp-wrapper'); + } else { + this.$allWrappers = [this.$wrapper]; + this.$dropboxContainer = this.$wrapper.querySelector('.vscomp-dropbox-container'); + } + this.$toggleButton = this.$ele.querySelector('.vscomp-toggle-button'); + this.$clearButton = this.$ele.querySelector('.vscomp-clear-button'); + this.$valueText = this.$ele.querySelector('.vscomp-value'); + this.$hiddenInput = this.$ele.querySelector('.vscomp-hidden-input'); + this.$dropbox = this.$dropboxContainer.querySelector('.vscomp-dropbox'); + this.$dropboxCloseButton = this.$dropboxContainer.querySelector('.vscomp-dropbox-close-button'); + this.$dropboxContainerBottom = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-bottom'); + this.$dropboxContainerTop = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-top'); + this.$search = this.$dropboxContainer.querySelector('.vscomp-search-wrapper'); + this.$optionsContainer = this.$dropboxContainer.querySelector('.vscomp-options-container'); + this.$optionsList = this.$dropboxContainer.querySelector('.vscomp-options-list'); + this.$options = this.$dropboxContainer.querySelector('.vscomp-options'); + this.$noOptions = this.$dropboxContainer.querySelector('.vscomp-no-options'); + this.$noSearchResults = this.$dropboxContainer.querySelector('.vscomp-no-search-results'); + this.afterRenderWrapper(); + } + renderDropbox({ + wrapperClasses + }) { + const $wrapper = this.dropboxWrapper !== 'self' ? document.querySelector(this.dropboxWrapper) : null; + let dropboxClasses = 'vscomp-dropbox'; + if (this.additionalDropboxClasses) { + dropboxClasses += ` ${this.additionalDropboxClasses}`; + } + let dropboxContainerClasses = 'vscomp-dropbox-container'; + if (this.additionalDropboxContainerClasses) { + dropboxContainerClasses += ` ${this.additionalDropboxContainerClasses}`; + } + + // eslint-disable-next-line no-trailing-spaces + const html = `
+ +
+
+ +
+
+ +
+
+
+
+ +
+
${this.noOptionsText}
+
${this.noSearchResultsText}
+ + +
+ +
`; + if ($wrapper) { + const $dropboxWrapper = document.createElement('div'); + this.$dropboxWrapper = $dropboxWrapper; + this.hasDropboxWrapper = true; + $dropboxWrapper.innerHTML = html; + $wrapper.appendChild($dropboxWrapper); + DomUtils.addClass($dropboxWrapper, `vscomp-dropbox-wrapper ${wrapperClasses}`); + if (!this.keepAlwaysOpen) { + DomUtils.setAttr($dropboxWrapper, 'tabindex', '-1'); + DomUtils.setAria($dropboxWrapper, 'hidden', true); + } + return ''; + } + this.hasDropboxWrapper = false; + return html; + } + renderOptions() { + // Calculate ARIA metadata before rendering to ensure it's always up to date + this.calculateAriaMetadata(); + let html = ''; + const visibleOptions = this.getVisibleOptions(); + let checkboxHtml = ''; + let newOptionIconHtml = ''; + const markSearchResults = !!(this.markSearchResults && this.searchValue); + let searchRegex; + const { + labelRenderer, + disableOptionGroupCheckbox, + uniqueId, + searchGroup + } = this; + const hasLabelRenderer = typeof labelRenderer === 'function'; + const { + convertToBoolean + } = Utils; + let groupName = ''; + if (markSearchResults) { + searchRegex = new RegExp(`(${Utils.regexEscape(this.searchValue)})(?!([^<]+)?>)`, 'gi'); + } + if (this.multiple) { + checkboxHtml = ''; + } + if (this.allowNewOption) { + const newOptionTooltip = this.getTooltipAttrText('New Option'); + newOptionIconHtml = ``; + } + visibleOptions.forEach(d => { + const { + index + } = d; + let optionLabel; + let optionClasses = 'vscomp-option'; + const optionTooltip = this.getTooltipAttrText('', true, true); + let leftSection = checkboxHtml; + let rightSection = ''; + let description = ''; + let groupIndexText = ''; + let ariaLabel = ''; + let tabIndexValue = '-1'; + const isSelected = convertToBoolean(d.isSelected); + let ariaDisabledText = ''; + if (d.classNames) { + optionClasses += ` ${d.classNames}`; + } + if (d.isFocused) { + tabIndexValue = '0'; + optionClasses += ' focused'; + } + if (d.isDisabled) { + optionClasses += ' disabled'; + ariaDisabledText = 'aria-disabled="true"'; + } + if (d.isGroupTitle) { + groupName = d.label; + optionClasses += ' group-title'; + if (disableOptionGroupCheckbox) { + leftSection = ''; + } + } + if (isSelected) { + optionClasses += ' selected'; + } + if (d.isGroupOption) { + let optionDesc = ''; + optionClasses += ' group-option'; + groupIndexText = `data-group-index="${d.groupIndex}"`; + if (d.customData) { + groupName = d.customData.group_name !== undefined ? `${d.customData.group_name}, ` : ''; + optionDesc = d.customData.description !== undefined ? ` ${d.customData.description},` : ''; + ariaLabel = `aria-label="${groupName} ${d.label}, ${optionDesc}"`; + } else { + ariaLabel = `aria-label="${groupName}, ${d.label}"`; } } - if (!this.hideClearButton) { - wrapperClasses += ' has-clear-button'; - } - if (this.keepAlwaysOpen) { - wrapperClasses += ' keep-always-open'; - isExpanded = true; + if (hasLabelRenderer) { + optionLabel = labelRenderer(d); } else { - wrapperClasses += ' closed'; - } - if (this.showAsPopup) { - wrapperClasses += ' show-as-popup'; - } - if (this.hasSearch) { - wrapperClasses += ' has-search-input'; - } - if (this.showValueAsTags) { - wrapperClasses += ' show-value-as-tags'; - } - if (this.textDirection) { - wrapperClasses += " text-direction-".concat(this.textDirection); - } - if (this.popupPosition) { - wrapperClasses += " popup-position-".concat(this.popupPosition.toLowerCase()); - } + optionLabel = d.label; + } + if (d.description) { + description = `
${d.description}
`; + } + if (d.isCurrentNew) { + optionClasses += ' current-new'; + rightSection += newOptionIconHtml; + } else if (markSearchResults && (!d.isGroupTitle || searchGroup)) { + optionLabel = optionLabel.replace(searchRegex, '$1'); + } + + // Add aria-setsize and aria-posinset for virtualized listbox accessibility + let ariaAttrs = ''; + if (this.ariaSetSize > 0) { + ariaAttrs = `aria-setsize="${this.ariaSetSize}"`; + if (d.filteredIndex) { + ariaAttrs += ` aria-posinset="${d.filteredIndex}"`; + } + } + html += `
+ ${leftSection} + + ${optionLabel} + + ${description} + ${rightSection} +
`; + }); + groupName = ''; + this.$options.innerHTML = html; + this.$visibleOptions = this.$options.querySelectorAll('.vscomp-option'); + this.afterRenderOptions(); + } + renderSearch() { + if (!this.hasSearchContainer) { + return; + } + let checkboxHtml = ''; + let searchInput = ''; + if (this.multiple && !this.disableSelectAll) { + checkboxHtml = ` + + ${this.selectAllText} + `; + } + if (this.hasSearch) { + const ariaLabelSearchClearBtnTxt = this.ariaLabelSearchClearButtonText ? `aria-label="${this.ariaLabelSearchClearButtonText}"` : ''; + searchInput = ` + + ×`; + } + const html = `
+ ${checkboxHtml} + ${searchInput} +
`; + this.$search.innerHTML = html; + this.$searchInput = this.$dropboxContainer.querySelector('.vscomp-search-input'); + this.$searchClear = this.$dropboxContainer.querySelector('.vscomp-search-clear'); + this.$toggleAllButton = this.$dropboxContainer.querySelector('.vscomp-toggle-all-button'); + this.$toggleAllCheckbox = this.$dropboxContainer.querySelector('.vscomp-toggle-all-checkbox'); + this.addEvent(this.$searchInput, 'input', 'onSearch'); + // Prevents the change event from bubbling and triggering the main onChange handler twice. + this.addEvent(this.$searchInput, 'change', 'preventPropagation'); + this.addEvent(this.$searchClear, 'click keydown', 'onSearchClear'); + this.addEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); + this.addEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); + this.addEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + /** render methods - end */ + + /** dom event methods - start */ + addEvents() { + this.addEvent(document, 'click', 'onDocumentClick', true); + this.addEvent(this.$allWrappers, 'keydown', 'onKeyDown'); + this.addEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); + this.addEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); + this.addEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); + this.addEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); + this.addEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); + this.addEvent(this.$options, 'click', 'onOptionsClick'); + this.addEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); + this.addEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); + this.addMutationObserver(); + } + addEvent($ele, events, method, capture = false) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const eventsKey = `${method}-${event}`; + let callback = this.events[eventsKey]; + if (!callback) { + callback = this[method].bind(this); + this.events[eventsKey] = callback; + } + DomUtils.addEvent($ele, event, callback, capture); + }); + } - // eslint-disable-next-line no-trailing-spaces - var html = "
\n \n
\n
\n ").concat(this.placeholder, "\n
\n
\n
\n \n
\n
\n\n ").concat(this.renderDropbox({ - wrapperClasses: wrapperClasses - }), "\n
"); - this.$ele.innerHTML = html; - this.$body = document.querySelector('body'); - this.$wrapper = this.$ele.querySelector('.vscomp-wrapper'); - if (this.hasDropboxWrapper) { - this.$allWrappers = [this.$wrapper, this.$dropboxWrapper]; - this.$dropboxContainer = this.$dropboxWrapper.querySelector('.vscomp-dropbox-container'); - DomUtils.addClass(this.$dropboxContainer, 'pop-comp-wrapper'); - } else { - this.$allWrappers = [this.$wrapper]; - this.$dropboxContainer = this.$wrapper.querySelector('.vscomp-dropbox-container'); - } - this.$toggleButton = this.$ele.querySelector('.vscomp-toggle-button'); - this.$clearButton = this.$ele.querySelector('.vscomp-clear-button'); - this.$valueText = this.$ele.querySelector('.vscomp-value'); - this.$hiddenInput = this.$ele.querySelector('.vscomp-hidden-input'); - this.$dropbox = this.$dropboxContainer.querySelector('.vscomp-dropbox'); - this.$dropboxCloseButton = this.$dropboxContainer.querySelector('.vscomp-dropbox-close-button'); - this.$dropboxContainerBottom = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-bottom'); - this.$dropboxContainerTop = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-top'); - this.$search = this.$dropboxContainer.querySelector('.vscomp-search-wrapper'); - this.$optionsContainer = this.$dropboxContainer.querySelector('.vscomp-options-container'); - this.$optionsList = this.$dropboxContainer.querySelector('.vscomp-options-list'); - this.$options = this.$dropboxContainer.querySelector('.vscomp-options'); - this.$noOptions = this.$dropboxContainer.querySelector('.vscomp-no-options'); - this.$noSearchResults = this.$dropboxContainer.querySelector('.vscomp-no-search-results'); - this.afterRenderWrapper(); - } - }, { - key: "renderDropbox", - value: function renderDropbox(_ref) { - var wrapperClasses = _ref.wrapperClasses; - var $wrapper = this.dropboxWrapper !== 'self' ? document.querySelector(this.dropboxWrapper) : null; - var dropboxClasses = 'vscomp-dropbox'; - if (this.additionalDropboxClasses) { - dropboxClasses += " ".concat(this.additionalDropboxClasses); - } - var dropboxContainerClasses = 'vscomp-dropbox-container'; - if (this.additionalDropboxContainerClasses) { - dropboxContainerClasses += " ".concat(this.additionalDropboxContainerClasses); - } + /** dom event methods - start */ + removeEvents() { + this.removeEvent(document, 'click', 'onDocumentClick'); + this.removeEvent(this.$allWrappers, 'keydown', 'onKeyDown'); + this.removeEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); + this.removeEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); + this.removeEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); + this.removeEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); + this.removeEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); + this.removeEvent(this.$options, 'click', 'onOptionsClick'); + this.removeEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); + this.removeEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); + + // Remove search-related events that are added in renderSearch() + if (this.$searchInput) { + this.removeEvent(this.$searchInput, 'input', 'onSearch'); + this.removeEvent(this.$searchInput, 'change', 'preventPropagation'); + if (this.$searchClear) { + this.removeEvent(this.$searchClear, 'click', 'onSearchClear'); + this.removeEvent(this.$searchClear, 'keydown', 'onSearchClear'); + } + } + if (this.$toggleAllButton) { + this.removeEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); + } + if (this.$dropboxContainerBottom) { + this.removeEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + if (this.$dropboxContainerTop) { + this.removeEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + this.removeMutationObserver(); + } + removeEvent($ele, events, method) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const eventsKey = `${method}-${event}`; + const callback = this.events[eventsKey]; + if (callback) { + DomUtils.removeEvent($ele, event, callback); + } + }); + } + onDocumentClick(e) { + const $clickedEle = e.target.closest('.vscomp-wrapper'); + + // Close all if clicking outside any dropdown + if (!$clickedEle) { + VirtualSelect.openInstances.forEach(instance => { + // Don't focus when closing due to clicking outside + const instanceObj = instance; + instanceObj.shouldFocusWrapperOnClose = false; + instanceObj.closeDropbox(); + }); + return; + } - // eslint-disable-next-line no-trailing-spaces - var html = "
\n
 
\n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
").concat(this.noOptionsText, "
\n
").concat(this.noSearchResultsText, "
\n\n \n
\n
 
\n
"); - if ($wrapper) { - var $dropboxWrapper = document.createElement('div'); - this.$dropboxWrapper = $dropboxWrapper; - this.hasDropboxWrapper = true; - $dropboxWrapper.innerHTML = html; - $wrapper.appendChild($dropboxWrapper); - DomUtils.addClass($dropboxWrapper, "vscomp-dropbox-wrapper ".concat(wrapperClasses)); - if (!this.keepAlwaysOpen) { - DomUtils.setAttr($dropboxWrapper, 'tabindex', '-1'); - DomUtils.setAria($dropboxWrapper, 'hidden', true); - } - return ''; - } - this.hasDropboxWrapper = false; - return html; + // If clicking a different dropdown, close current one + const clickedInstance = $clickedEle.parentElement.virtualSelect; + if (clickedInstance && clickedInstance !== this && this.isOpened() && !this.keepAlwaysOpen) { + // Don't focus when closing due to another dropdown being opened + this.shouldFocusWrapperOnClose = false; + this.closeDropbox(); } - }, { - key: "renderOptions", - value: function renderOptions() { - var _this = this; - // Calculate ARIA metadata before rendering to ensure it's always up to date - this.calculateAriaMetadata(); - var html = ''; - var visibleOptions = this.getVisibleOptions(); - var checkboxHtml = ''; - var newOptionIconHtml = ''; - var markSearchResults = !!(this.markSearchResults && this.searchValue); - var searchRegex; - var labelRenderer = this.labelRenderer, - disableOptionGroupCheckbox = this.disableOptionGroupCheckbox, - uniqueId = this.uniqueId, - searchGroup = this.searchGroup; - var hasLabelRenderer = typeof labelRenderer === 'function'; - var convertToBoolean = Utils.convertToBoolean; - var groupName = ''; - if (markSearchResults) { - searchRegex = new RegExp("(".concat(Utils.regexEscape(this.searchValue), ")(?!([^<]+)?>)"), 'gi'); - } - if (this.multiple) { - checkboxHtml = ''; - } - if (this.allowNewOption) { - var newOptionTooltip = this.getTooltipAttrText('New Option'); - newOptionIconHtml = ""); + } + onKeyDown(e) { + const key = e.which || e.keyCode; + const method = keyDownMethodMapping[key]; + if (document.activeElement === this.$searchInput && !e.shiftKey && key === 9 && !this.multiple) { + e.preventDefault(); + this.focusFirstVisibleOption(); + } + if (document.activeElement === this.$toggleAllButton && key === 13) { + this.toggleAllOptions(); + return; + } + + // Handle the Escape key when showing the dropdown as a popup, closing it + if (key === 27 || e.key === 'Escape') { + const wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper; + if (wrapper && (document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) { + this.closeDropbox(); + return; } - visibleOptions.forEach(function (d) { - var index = d.index; - var optionLabel; - var optionClasses = 'vscomp-option'; - var optionTooltip = _this.getTooltipAttrText('', true, true); - var leftSection = checkboxHtml; - var rightSection = ''; - var description = ''; - var groupIndexText = ''; - var ariaLabel = ''; - var tabIndexValue = '-1'; - var isSelected = convertToBoolean(d.isSelected); - var ariaDisabledText = ''; - if (d.classNames) { - optionClasses += " ".concat(d.classNames); - } - if (d.isFocused) { - tabIndexValue = '0'; - optionClasses += ' focused'; - } - if (d.isDisabled) { - optionClasses += ' disabled'; - ariaDisabledText = 'aria-disabled="true"'; - } - if (d.isGroupTitle) { - groupName = d.label; - optionClasses += ' group-title'; - if (disableOptionGroupCheckbox) { - leftSection = ''; - } - } - if (isSelected) { - optionClasses += ' selected'; - } - if (d.isGroupOption) { - var optionDesc = ''; - optionClasses += ' group-option'; - groupIndexText = "data-group-index=\"".concat(d.groupIndex, "\""); - if (d.customData) { - groupName = d.customData.group_name !== undefined ? "".concat(d.customData.group_name, ", ") : ''; - optionDesc = d.customData.description !== undefined ? " ".concat(d.customData.description, ",") : ''; - ariaLabel = "aria-label=\"".concat(groupName, " ").concat(d.label, ", ").concat(optionDesc, "\""); - } else { - ariaLabel = "aria-label=\"".concat(groupName, ", ").concat(d.label, "\""); - } - } - if (hasLabelRenderer) { - optionLabel = labelRenderer(d); - } else { - optionLabel = d.label; - } - if (d.description) { - description = "
").concat(d.description, "
"); - } - if (d.isCurrentNew) { - optionClasses += ' current-new'; - rightSection += newOptionIconHtml; - } else if (markSearchResults && (!d.isGroupTitle || searchGroup)) { - optionLabel = optionLabel.replace(searchRegex, '$1'); - } - - // Add aria-setsize and aria-posinset for virtualized listbox accessibility - var ariaAttrs = ''; - if (_this.ariaSetSize > 0) { - ariaAttrs = "aria-setsize=\"".concat(_this.ariaSetSize, "\""); - if (d.filteredIndex) { - ariaAttrs += " aria-posinset=\"".concat(d.filteredIndex, "\""); - } - } - html += "
\n ").concat(leftSection, "\n \n ").concat(optionLabel, "\n \n ").concat(description, "\n ").concat(rightSection, "\n
"); - }); - groupName = ''; - this.$options.innerHTML = html; - this.$visibleOptions = this.$options.querySelectorAll('.vscomp-option'); - this.afterRenderOptions(); - } - }, { - key: "renderSearch", - value: function renderSearch() { - if (!this.hasSearchContainer) { - return; - } - var checkboxHtml = ''; - var searchInput = ''; - if (this.multiple && !this.disableSelectAll) { - checkboxHtml = "\n \n ").concat(this.selectAllText, "\n "); - } - if (this.hasSearch) { - var ariaLabelSearchClearBtnTxt = this.ariaLabelSearchClearButtonText ? "aria-label=\"".concat(this.ariaLabelSearchClearButtonText, "\"") : ''; - searchInput = "\n \n ×"); - } - var html = "
\n ".concat(checkboxHtml, "\n ").concat(searchInput, "\n
"); - this.$search.innerHTML = html; - this.$searchInput = this.$dropboxContainer.querySelector('.vscomp-search-input'); - this.$searchClear = this.$dropboxContainer.querySelector('.vscomp-search-clear'); - this.$toggleAllButton = this.$dropboxContainer.querySelector('.vscomp-toggle-all-button'); - this.$toggleAllCheckbox = this.$dropboxContainer.querySelector('.vscomp-toggle-all-checkbox'); - this.addEvent(this.$searchInput, 'input', 'onSearch'); - // Prevents the change event from bubbling and triggering the main onChange handler twice. - this.addEvent(this.$searchInput, 'change', 'preventPropagation'); - this.addEvent(this.$searchClear, 'click keydown', 'onSearchClear'); - this.addEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); - this.addEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); - this.addEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - /** render methods - end */ - - /** dom event methods - start */ - }, { - key: "addEvents", - value: function addEvents() { - this.addEvent(document, 'click', 'onDocumentClick', true); - this.addEvent(this.$allWrappers, 'keydown', 'onKeyDown'); - this.addEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); - this.addEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); - this.addEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); - this.addEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); - this.addEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); - this.addEvent(this.$options, 'click', 'onOptionsClick'); - this.addEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); - this.addEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); - this.addMutationObserver(); - } - }, { - key: "addEvent", - value: function addEvent($ele, events, method) { - var _this2 = this; - var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var eventsKey = "".concat(method, "-").concat(event); - var callback = _this2.events[eventsKey]; - if (!callback) { - callback = _this2[method].bind(_this2); - _this2.events[eventsKey] = callback; - } - DomUtils.addEvent($ele, event, callback, capture); - }); } - - /** dom event methods - start */ - }, { - key: "removeEvents", - value: function removeEvents() { - this.removeEvent(document, 'click', 'onDocumentClick'); - this.removeEvent(this.$allWrappers, 'keydown', 'onKeyDown'); - this.removeEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); - this.removeEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); - this.removeEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); - this.removeEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); - this.removeEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); - this.removeEvent(this.$options, 'click', 'onOptionsClick'); - this.removeEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); - this.removeEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); - - // Remove search-related events that are added in renderSearch() - if (this.$searchInput) { - this.removeEvent(this.$searchInput, 'input', 'onSearch'); - this.removeEvent(this.$searchInput, 'change', 'preventPropagation'); - if (this.$searchClear) { - this.removeEvent(this.$searchClear, 'click', 'onSearchClear'); - this.removeEvent(this.$searchClear, 'keydown', 'onSearchClear'); - } - } - if (this.$toggleAllButton) { - this.removeEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); - } - if (this.$dropboxContainerBottom) { - this.removeEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - if (this.$dropboxContainerTop) { - this.removeEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - this.removeMutationObserver(); + if (method) { + this[method](e); } - }, { - key: "removeEvent", - value: function removeEvent($ele, events, method) { - var _this3 = this; - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var eventsKey = "".concat(method, "-").concat(event); - var callback = _this3.events[eventsKey]; - if (callback) { - DomUtils.removeEvent($ele, event, callback); - } + } + onEnterPress(e) { + e.preventDefault(); + if (this.isOpened()) { + this.selectFocusedOption(); + } else if (this.$ele.disabled === false) { + this.openDropbox(); + } + } + onDownArrowPress(e) { + // Allow default behavior (cursor movement) when search input is focused + if (document.activeElement === this.$searchInput) { + return; + } + e.preventDefault(); + if (this.isOpened()) { + this.focusOption({ + direction: 'next' }); + } else { + this.openDropbox(); } - }, { - key: "onDocumentClick", - value: function onDocumentClick(e) { - var $clickedEle = e.target.closest('.vscomp-wrapper'); - - // Close all if clicking outside any dropdown - if (!$clickedEle) { - VirtualSelect.openInstances.forEach(function (instance) { - // Don't focus when closing due to clicking outside - var instanceObj = instance; - instanceObj.shouldFocusWrapperOnClose = false; - instanceObj.closeDropbox(); - }); - return; - } - - // If clicking a different dropdown, close current one - var clickedInstance = $clickedEle.parentElement.virtualSelect; - if (clickedInstance && clickedInstance !== this && this.isOpened() && !this.keepAlwaysOpen) { - // Don't focus when closing due to another dropdown being opened - this.shouldFocusWrapperOnClose = false; - this.closeDropbox(); - } + } + onUpArrowPress(e) { + // Allow default behavior (cursor movement) when search input is focused + if (document.activeElement === this.$searchInput) { + return; } - }, { - key: "onKeyDown", - value: function onKeyDown(e) { - var key = e.which || e.keyCode; - var method = keyDownMethodMapping[key]; - if (document.activeElement === this.$searchInput && !e.shiftKey && key === 9 && !this.multiple) { - e.preventDefault(); - this.focusFirstVisibleOption(); - } - if (document.activeElement === this.$toggleAllButton && key === 13) { - this.toggleAllOptions(); - return; - } - - // Handle the Escape key when showing the dropdown as a popup, closing it - if (key === 27 || e.key === 'Escape') { - var wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper; - if (wrapper && (document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) { - this.closeDropbox(); - return; - } - } - if (method) { - this[method](e); - } + e.preventDefault(); + if (this.isOpened()) { + this.focusOption({ + direction: 'previous' + }); + } else { + this.openDropbox(); } - }, { - key: "onEnterPress", - value: function onEnterPress(e) { + } + onBackspaceOrDeletePress(e) { + if (e.target === this.$wrapper) { e.preventDefault(); - if (this.isOpened()) { - this.selectFocusedOption(); - } else if (this.$ele.disabled === false) { - this.openDropbox(); + if (this.selectedValues.length > 0) { + this.reset(); } } - }, { - key: "onDownArrowPress", - value: function onDownArrowPress(e) { - // Allow default behavior (cursor movement) when search input is focused - if (document.activeElement === this.$searchInput) { + } + onToggleButtonPress(e) { + if (e.type === 'keydown') { + // Allow default Tab navigation and other non-activation keys + if (e.code !== 'Enter' && e.code !== 'Space') { return; } e.preventDefault(); - if (this.isOpened()) { - this.focusOption({ - direction: 'next' - }); + } + const $target = e.target; + if ($target.closest('.vscomp-value-tag-clear-button')) { + e.stopPropagation(); + this.removeValue($target.closest('.vscomp-value-tag')); + return; + } + if (!$target.closest('.toggle-button-child')) { + // Let the event bubble normally + this.toggleDropbox(); + } + } + onClearButtonClick(e) { + if (e.type === 'click') { + this.reset(); + } else if (e.type === 'keydown' && (e.code === 'Enter' || e.code === 'Space')) { + e.stopPropagation(); + this.reset(); + } + } + onOptionsScroll() { + this.setVisibleOptions(true); + } + onOptionsClick(e) { + const $option = e.target.closest('.vscomp-option'); + if ($option && !DomUtils.hasClass($option, 'disabled')) { + if (DomUtils.hasClass($option, 'group-title')) { + this.onGroupTitleClick($option); } else { - this.openDropbox(); + this.selectOption($option, { + event: e + }); } } - }, { - key: "onUpArrowPress", - value: function onUpArrowPress(e) { - // Allow default behavior (cursor movement) when search input is focused - if (document.activeElement === this.$searchInput) { - return; - } - e.preventDefault(); - if (this.isOpened()) { + } + onGroupTitleClick($ele) { + if (!$ele || !this.multiple || this.disableOptionGroupCheckbox) { + return; + } + const isAdding = !DomUtils.hasClass($ele, 'selected'); + this.toggleGroupTitleCheckbox($ele, isAdding); + this.toggleGroupOptions($ele, isAdding); + } + onDropboxContainerClick(e) { + if (!e.target.closest('.vscomp-dropbox')) { + this.closeDropbox(); + } + } + onDropboxCloseButtonClick() { + this.closeDropbox(); + } + onOptionsMouseOver(e) { + const $ele = e.target.closest('.vscomp-option'); + if ($ele && this.isOpened()) { + if (DomUtils.hasClass($ele, 'disabled') || DomUtils.hasClass($ele, 'group-title')) { + this.removeOptionFocus(); + } else { this.focusOption({ - direction: 'previous' + $option: $ele }); - } else { - this.openDropbox(); - } - } - }, { - key: "onBackspaceOrDeletePress", - value: function onBackspaceOrDeletePress(e) { - if (e.target === this.$wrapper) { - e.preventDefault(); - if (this.selectedValues.length > 0) { - this.reset(); - } } } - }, { - key: "onToggleButtonPress", - value: function onToggleButtonPress(e) { - if (e.type === 'keydown') { - // Allow default Tab navigation and other non-activation keys - if (e.code !== 'Enter' && e.code !== 'Space') { - return; - } - e.preventDefault(); - } - var $target = e.target; - if ($target.closest('.vscomp-value-tag-clear-button')) { - e.stopPropagation(); - this.removeValue($target.closest('.vscomp-value-tag')); - return; - } - if (!$target.closest('.toggle-button-child')) { - // Let the event bubble normally - this.toggleDropbox(); - } + } + onOptionsTouchMove() { + this.removeOptionFocus(); + } + onSearch(e) { + e.stopPropagation(); + this.setSearchValue(e.target.value, true); + } + preventPropagation(e) { + e.stopPropagation(); + } + onSearchClear(e) { + e.stopPropagation(); + if (e.code === 'Enter' || e.code === 'Space' || e.type === 'click') { + this.setSearchValue(''); + this.focusSearchInput(); } - }, { - key: "onClearButtonClick", - value: function onClearButtonClick(e) { - if (e.type === 'click') { - this.reset(); - } else if (e.type === 'keydown' && (e.code === 'Enter' || e.code === 'Space')) { - e.stopPropagation(); - this.reset(); - } + } + onToggleAllOptions() { + this.toggleAllOptions(); + } + onDropboxContainerTopOrBottomFocus() { + this.closeDropbox(); + } + onResize() { + this.setOptionsContainerHeight(true); + } + + /** to remove dropboxWrapper on removing vscomp-ele when it is rendered outside of vscomp-ele */ + addMutationObserver() { + if (!this.hasDropboxWrapper) { + return; } - }, { - key: "onOptionsScroll", - value: function onOptionsScroll() { - this.setVisibleOptions(true); - } - }, { - key: "onOptionsClick", - value: function onOptionsClick(e) { - var $option = e.target.closest('.vscomp-option'); - if ($option && !DomUtils.hasClass($option, 'disabled')) { - if (DomUtils.hasClass($option, 'group-title')) { - this.onGroupTitleClick($option); - } else { - this.selectOption($option, { - event: e - }); + const $vscompEle = this.$ele; + this.mutationObserver = new MutationObserver(mutations => { + let isAdded = false; + let isRemoved = false; + mutations.forEach(mutation => { + if (!isAdded) { + isAdded = [...mutation.addedNodes].some($ele => !!($ele === $vscompEle || $ele.contains($vscompEle))); } - } - } - }, { - key: "onGroupTitleClick", - value: function onGroupTitleClick($ele) { - if (!$ele || !this.multiple || this.disableOptionGroupCheckbox) { - return; - } - var isAdding = !DomUtils.hasClass($ele, 'selected'); - this.toggleGroupTitleCheckbox($ele, isAdding); - this.toggleGroupOptions($ele, isAdding); - } - }, { - key: "onDropboxContainerClick", - value: function onDropboxContainerClick(e) { - if (!e.target.closest('.vscomp-dropbox')) { - this.closeDropbox(); - } + if (!isRemoved) { + isRemoved = [...mutation.removedNodes].some($ele => !!($ele === $vscompEle || $ele.contains($vscompEle))); + } + }); + if (isRemoved && !isAdded) { + this.destroy(); + } + }); + this.mutationObserver.observe(document.querySelector('body'), { + childList: true, + subtree: true + }); + } + removeMutationObserver() { + if (this.hasDropboxWrapper) { + this.mutationObserver.disconnect(); } - }, { - key: "onDropboxCloseButtonClick", - value: function onDropboxCloseButtonClick() { - this.closeDropbox(); + } + + /** dom event methods - end */ + /** before event methods - start */ + beforeValueSet(isReset) { + this.toggleAllOptionsClass(isReset ? false : undefined); + } + beforeSelectNewValue(selectedValue) { + const newOption = this.getNewOption(); + if (newOption) { + const newIndex = newOption.index; + this.newValues.push(newOption.value); + this.setOptionProp(newIndex, 'isCurrentNew', false); + this.setOptionProp(newIndex, 'isNew', true); + } else if (selectedValue) { + // In single-select flow the temporary current-new option can be removed + // when dropdown close resets search, so re-add as a persisted new option. + this.setNewOption(selectedValue); + this.toggleSelectedProp(this.lastOptionIndex, true); + } + + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.setSearchValue(''); + this.focusSearchInput(); + }, 0); + } + /** before event methods - end */ + + /** after event methods - start */ + afterRenderWrapper() { + DomUtils.addClass(this.$ele, 'vscomp-ele'); + this.renderSearch(); + this.setEleStyles(); + this.setDropboxStyles(); + this.setVisibleOptionsCount(); + this.setOptionsContainerHeight(); + this.addEvents(); + this.setEleProps(); + if (!this.keepAlwaysOpen && !this.showAsPopup) { + this.initDropboxPopover(); + } + if (this.initialSelectedValue) { + this.setValueMethod(this.initialSelectedValue, this.silentInitialValueSet); + } else if (this.autoSelectFirstOption && this.visibleOptions.length) { + this.setValueMethod(this.visibleOptions[0].value, this.silentInitialValueSet); + } + if (this.showOptionsOnlyOnSearch) { + this.setSearchValue('', false, true); + } + if (this.initialDisabled) { + this.disable(); + } + if (this.autofocus) { + this.focus(); } - }, { - key: "onOptionsMouseOver", - value: function onOptionsMouseOver(e) { - var $ele = e.target.closest('.vscomp-option'); - if ($ele && this.isOpened()) { - if (DomUtils.hasClass($ele, 'disabled') || DomUtils.hasClass($ele, 'group-title')) { - this.removeOptionFocus(); - } else { - this.focusOption({ - $option: $ele + } + afterRenderOptions() { + const visibleOptions = this.getVisibleOptions(); + const hasNoOptions = !this.options.length && !this.hasServerSearch; + const hasNoSearchResults = !hasNoOptions && !visibleOptions.length; + if (!this.allowNewOption || this.hasServerSearch || this.showOptionsOnlyOnSearch) { + DomUtils.toggleClass(this.$allWrappers, 'has-no-search-results', hasNoSearchResults); + if (hasNoSearchResults) { + DomUtils.setAttr(this.$noSearchResults, 'tabindex', '0'); + DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'false'); + } else { + DomUtils.setAttr(this.$noSearchResults, 'tabindex', '-1'); + DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'true'); + } + } + DomUtils.toggleClass(this.$allWrappers, 'has-no-options', hasNoOptions); + if (hasNoOptions) { + DomUtils.setAttr(this.$noOptions, 'tabindex', '0'); + DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'false'); + } else { + DomUtils.setAttr(this.$noOptions, 'tabindex', '-1'); + DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'true'); + } + this.setOptionAttr(); + this.setOptionsPosition(); + this.setOptionsTooltip(); + if (document.activeElement !== this.$searchInput) { + setTimeout(() => { + const focusedOption = DomUtils.getElementsBySelector('.focused', this.$dropboxContainer)[0]; + if (focusedOption !== undefined) { + focusedOption.focus({ + preventScroll: true }); } - } - } - }, { - key: "onOptionsTouchMove", - value: function onOptionsTouchMove() { - this.removeOptionFocus(); + }, 20); } - }, { - key: "onSearch", - value: function onSearch(e) { - e.stopPropagation(); - this.setSearchValue(e.target.value, true); + } + afterSetOptionsContainerHeight(reset) { + if (reset && this.showAsPopup) { + this.setVisibleOptions(); } - }, { - key: "preventPropagation", - value: function preventPropagation(e) { - e.stopPropagation(); + } + afterSetSearchValue() { + if (this.hasServerSearch) { + clearTimeout(this.serverSearchTimeout); + this.serverSearchTimeout = setTimeout(() => { + this.serverSearch(); + }, this.searchDelay); + } else { + this.setVisibleOptionsCount(); } - }, { - key: "onSearchClear", - value: function onSearchClear(e) { - e.stopPropagation(); - if (e.code === 'Enter' || e.code === 'Space' || e.type === 'click') { - this.setSearchValue(''); - this.focusSearchInput(); - } + if (this.selectAllOnlyVisible) { + this.toggleAllOptionsClass(); } - }, { - key: "onToggleAllOptions", - value: function onToggleAllOptions() { - this.toggleAllOptions(); + this.focusOption({ + focusFirst: true + }); + } + afterSetVisibleOptionsCount() { + this.scrollToTop(); + this.setOptionsHeight(); + this.setVisibleOptions(); + this.updatePosition(); + } + afterValueSet() { + this.scrollToTop(); + this.setSearchValue(''); + this.renderOptions(); + } + afterSetOptions(keepValue) { + if (keepValue) { + this.setSelectedProp(); } - }, { - key: "onDropboxContainerTopOrBottomFocus", - value: function onDropboxContainerTopOrBottomFocus() { - this.closeDropbox(); + this.setOptionsHeight(); + this.setVisibleOptions(); + if (this.showOptionsOnlyOnSearch) { + this.setSearchValue('', false, true); } - }, { - key: "onResize", - value: function onResize() { - this.setOptionsContainerHeight(true); + if (!keepValue) { + this.reset(); } + } + /** after event methods - end */ - /** to remove dropboxWrapper on removing vscomp-ele when it is rendered outside of vscomp-ele */ - }, { - key: "addMutationObserver", - value: function addMutationObserver() { - var _this4 = this; - if (!this.hasDropboxWrapper) { - return; - } - var $vscompEle = this.$ele; - this.mutationObserver = new MutationObserver(function (mutations) { - var isAdded = false; - var isRemoved = false; - mutations.forEach(function (mutation) { - if (!isAdded) { - isAdded = virtual_select_toConsumableArray(mutation.addedNodes).some(function ($ele) { - return !!($ele === $vscompEle || $ele.contains($vscompEle)); - }); - } - if (!isRemoved) { - isRemoved = virtual_select_toConsumableArray(mutation.removedNodes).some(function ($ele) { - return !!($ele === $vscompEle || $ele.contains($vscompEle)); - }); - } - }); - if (isRemoved && !isAdded) { - _this4.destroy(); - } - }); - this.mutationObserver.observe(document.querySelector('body'), { - childList: true, - subtree: true - }); - } - }, { - key: "removeMutationObserver", - value: function removeMutationObserver() { - if (this.hasDropboxWrapper) { - this.mutationObserver.disconnect(); - } - } + /** set methods - start */ + /** + * @param {virtualSelectOptions} params + */ + setProps(params) { + const options = this.setDefaultProps(params); + this.setPropsFromElementAttr(options); + const { + convertToBoolean + } = Utils; + this.$ele = options.ele; + this.dropboxWrapper = options.dropboxWrapper; + this.valueKey = options.valueKey; + this.labelKey = options.labelKey; + this.descriptionKey = options.descriptionKey; + this.aliasKey = options.aliasKey; + this.optionHeightText = options.optionHeight; + this.optionHeight = parseFloat(this.optionHeightText); + this.multiple = convertToBoolean(options.multiple); + this.hasSearch = convertToBoolean(options.search); + this.searchByStartsWith = convertToBoolean(options.searchByStartsWith); + this.searchGroup = convertToBoolean(options.searchGroup); + this.hideClearButton = convertToBoolean(options.hideClearButton); + this.autoSelectFirstOption = convertToBoolean(options.autoSelectFirstOption); + this.hasOptionDescription = convertToBoolean(options.hasOptionDescription); + this.silentInitialValueSet = convertToBoolean(options.silentInitialValueSet); + this.allowNewOption = convertToBoolean(options.allowNewOption); + this.markSearchResults = convertToBoolean(options.markSearchResults); + this.showSelectedOptionsFirst = convertToBoolean(options.showSelectedOptionsFirst); + this.disableSelectAll = convertToBoolean(options.disableSelectAll); + this.keepAlwaysOpen = convertToBoolean(options.keepAlwaysOpen); + this.showDropboxAsPopup = convertToBoolean(options.showDropboxAsPopup); + this.hideValueTooltipOnSelectAll = convertToBoolean(options.hideValueTooltipOnSelectAll); + this.showOptionsOnlyOnSearch = convertToBoolean(options.showOptionsOnlyOnSearch); + this.selectAllOnlyVisible = convertToBoolean(options.selectAllOnlyVisible); + this.alwaysShowSelectedOptionsCount = convertToBoolean(options.alwaysShowSelectedOptionsCount); + this.alwaysShowSelectedOptionsLabel = convertToBoolean(options.alwaysShowSelectedOptionsLabel); + this.disableAllOptionsSelectedText = convertToBoolean(options.disableAllOptionsSelectedText); + this.showValueAsTags = convertToBoolean(options.showValueAsTags); + this.disableOptionGroupCheckbox = convertToBoolean(options.disableOptionGroupCheckbox); + this.enableSecureText = convertToBoolean(options.enableSecureText); + this.setValueAsArray = convertToBoolean(options.setValueAsArray); + this.disableValidation = convertToBoolean(options.disableValidation); + this.initialDisabled = convertToBoolean(options.disabled); + this.required = convertToBoolean(options.required); + this.autofocus = convertToBoolean(options.autofocus); + this.useGroupValue = convertToBoolean(options.useGroupValue); + this.focusSelectedOptionOnOpen = convertToBoolean(options.focusSelectedOptionOnOpen); + this.noOptionsText = options.noOptionsText; + this.noSearchResultsText = options.noSearchResultsText; + this.selectAllText = options.selectAllText; + this.searchNormalize = options.searchNormalize; + this.searchPlaceholderText = options.searchPlaceholderText; + this.searchFormLabel = options.searchFormLabel; + this.optionsSelectedText = options.optionsSelectedText; + this.optionSelectedText = options.optionSelectedText; + this.allOptionsSelectedText = options.allOptionsSelectedText; + this.clearButtonText = options.clearButtonText; + this.moreText = options.moreText; + this.placeholder = options.placeholder; + this.position = options.position; + this.textDirection = options.textDirection; + this.dropboxWidth = options.dropboxWidth; + this.tooltipFontSize = options.tooltipFontSize; + this.tooltipAlignment = options.tooltipAlignment; + this.tooltipMaxWidth = options.tooltipMaxWidth; + this.updatePositionThrottle = options.updatePositionThrottle; + this.noOfDisplayValues = parseInt(options.noOfDisplayValues); + this.zIndex = parseInt(options.zIndex); + this.maxValues = parseInt(options.maxValues); + this.minValues = parseInt(options.minValues); + this.name = this.secureText(options.name); + this.additionalClasses = options.additionalClasses; + this.additionalDropboxClasses = options.additionalDropboxClasses; + this.additionalDropboxContainerClasses = options.additionalDropboxContainerClasses; + this.additionalToggleButtonClasses = options.additionalToggleButtonClasses; + this.popupDropboxBreakpoint = options.popupDropboxBreakpoint; + this.popupPosition = options.popupPosition; + this.onServerSearch = options.onServerSearch; + this.labelRenderer = options.labelRenderer; + this.selectedLabelRenderer = options.selectedLabelRenderer; + this.initialSelectedValue = options.selectedValue === 0 ? '0' : options.selectedValue; + this.emptyValue = options.emptyValue; + this.ariaLabelText = options.ariaLabelText; + this.ariaLabelledby = options.ariaLabelledby; + this.ariaLabelClearButtonText = options.ariaLabelClearButtonText; + this.ariaLabelTagClearButtonText = options.ariaLabelTagClearButtonText; + this.ariaLabelSearchClearButtonText = options.ariaLabelSearchClearButtonText; + this.maxWidth = options.maxWidth; + this.searchDelay = options.searchDelay; + this.showDuration = parseInt(options.showDuration); + this.hideDuration = parseInt(options.hideDuration); + + /** @type {string[]} */ + this.selectedValues = []; + /** @type {virtualSelectOption[]} */ + this.selectedOptions = []; + this.newValues = []; + this.events = {}; + this.tooltipEnterDelay = 200; + this.searchValue = ''; + this.searchValueOriginal = ''; + this.isAllSelected = false; + if (options.search === undefined && this.multiple || this.allowNewOption || this.showOptionsOnlyOnSearch) { + this.hasSearch = true; + } + this.hasServerSearch = typeof this.onServerSearch === 'function'; + if (this.maxValues || this.hasServerSearch || this.showOptionsOnlyOnSearch) { + this.disableSelectAll = true; + this.disableOptionGroupCheckbox = true; + } + if (this.keepAlwaysOpen) { + this.dropboxWrapper = 'self'; + } + this.showAsPopup = this.showDropboxAsPopup && !this.keepAlwaysOpen && window.innerWidth <= parseFloat(this.popupDropboxBreakpoint); + this.hasSearchContainer = this.hasSearch || this.multiple && !this.disableSelectAll; + this.optionsCount = this.getOptionsCount(options.optionsCount); + this.halfOptionsCount = Math.ceil(this.optionsCount / 2); + this.optionsHeight = this.getOptionsHeight(); + this.uniqueId = this.getUniqueId(); + this.shouldFocusWrapperOnClose = true; // Initialize focus management property + this.ariaSetSize = 0; + } - /** dom event methods - end */ - /** before event methods - start */ - }, { - key: "beforeValueSet", - value: function beforeValueSet(isReset) { - this.toggleAllOptionsClass(isReset ? false : undefined); - } - }, { - key: "beforeSelectNewValue", - value: function beforeSelectNewValue(selectedValue) { - var _this5 = this; - var newOption = this.getNewOption(); - if (newOption) { - var newIndex = newOption.index; - this.newValues.push(newOption.value); - this.setOptionProp(newIndex, 'isCurrentNew', false); - this.setOptionProp(newIndex, 'isNew', true); - } else if (selectedValue) { - // In single-select flow the temporary current-new option can be removed - // when dropdown close resets search, so re-add as a persisted new option. - this.setNewOption(selectedValue); - this.toggleSelectedProp(this.lastOptionIndex, true); + /** + * @param {virtualSelectOptions} options + */ + setDefaultProps(options) { + const defaultOptions = { + dropboxWrapper: 'self', + valueKey: 'value', + labelKey: 'label', + descriptionKey: 'description', + aliasKey: 'alias', + ariaLabelText: 'Options list', + ariaLabelClearButtonText: 'Clear button', + ariaLabelTagClearButtonText: 'Remove option', + ariaLabelSearchClearButtonText: 'Clear search input', + optionsCount: 5, + noOfDisplayValues: 50, + optionHeight: '40px', + noOptionsText: 'No options found', + noSearchResultsText: 'No results found', + selectAllText: 'Select All', + searchNormalize: false, + searchPlaceholderText: 'Search...', + searchFormLabel: 'Search', + clearButtonText: 'Clear', + moreText: 'more...', + optionsSelectedText: 'options selected', + optionSelectedText: 'option selected', + allOptionsSelectedText: 'All', + placeholder: 'Select', + position: 'bottom left', + zIndex: options.keepAlwaysOpen ? 1 : 2, + tooltipFontSize: '14px', + tooltipAlignment: 'center', + tooltipMaxWidth: '300px', + updatePositionThrottle: 100, + name: '', + additionalClasses: '', + additionalDropboxClasses: '', + additionalDropboxContainerClasses: '', + additionalToggleButtonClasses: '', + maxValues: 0, + showDropboxAsPopup: true, + popupDropboxBreakpoint: '576px', + popupPosition: 'center', + hideValueTooltipOnSelectAll: true, + emptyValue: '', + searchDelay: 300, + focusSelectedOptionOnOpen: true, + showDuration: 300, + hideDuration: 200 + }; + if (options.hasOptionDescription) { + defaultOptions.optionsCount = 4; + defaultOptions.optionHeight = '50px'; + } + return Object.assign(defaultOptions, options); + } + setPropsFromElementAttr(options) { + const $ele = options.ele; + Object.keys(attrPropsMapping).forEach(k => { + let value = $ele.getAttribute(k); + if (valueLessProps.indexOf(k) !== -1 && (value === '' || value === 'true')) { + value = true; } - - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this5.setSearchValue(''); - _this5.focusSearchInput(); - }, 0); - } - /** before event methods - end */ - - /** after event methods - start */ - }, { - key: "afterRenderWrapper", - value: function afterRenderWrapper() { - DomUtils.addClass(this.$ele, 'vscomp-ele'); - this.renderSearch(); - this.setEleStyles(); - this.setDropboxStyles(); - this.setVisibleOptionsCount(); - this.setOptionsContainerHeight(); - this.addEvents(); - this.setEleProps(); - if (!this.keepAlwaysOpen && !this.showAsPopup) { - this.initDropboxPopover(); + if (value) { + // eslint-disable-next-line no-param-reassign + options[attrPropsMapping[k]] = value; } - if (this.initialSelectedValue) { - this.setValueMethod(this.initialSelectedValue, this.silentInitialValueSet); - } else if (this.autoSelectFirstOption && this.visibleOptions.length) { - this.setValueMethod(this.visibleOptions[0].value, this.silentInitialValueSet); + }); + } + setEleProps() { + const { + $ele + } = this; + $ele.virtualSelect = this; + $ele.value = this.multiple ? [] : ''; + $ele.name = this.name; + $ele.disabled = false; + $ele.required = this.required; + $ele.autofocus = this.autofocus; + $ele.multiple = this.multiple; + $ele.form = $ele.closest('form'); + $ele.reset = VirtualSelect.reset; + $ele.setValue = VirtualSelect.setValueMethod; + $ele.setOptions = VirtualSelect.setOptionsMethod; + $ele.setDisabledOptions = VirtualSelect.setDisabledOptionsMethod; + $ele.setEnabledOptions = VirtualSelect.setEnabledOptionsMethod; + $ele.toggleSelectAll = VirtualSelect.toggleSelectAll; + $ele.isAllSelected = VirtualSelect.isAllSelected; + $ele.addOption = VirtualSelect.addOptionMethod; + $ele.getNewValue = VirtualSelect.getNewValueMethod; + $ele.getDisplayValue = VirtualSelect.getDisplayValueMethod; + $ele.getSelectedOptions = VirtualSelect.getSelectedOptionsMethod; + $ele.getDisabledOptions = VirtualSelect.getDisabledOptionsMethod; + $ele.open = VirtualSelect.openMethod; + $ele.close = VirtualSelect.closeMethod; + $ele.focus = VirtualSelect.focusMethod; + $ele.enable = VirtualSelect.enableMethod; + $ele.disable = VirtualSelect.disableMethod; + $ele.destroy = VirtualSelect.destroyMethod; + $ele.validate = VirtualSelect.validateMethod; + $ele.toggleRequired = VirtualSelect.toggleRequiredMethod; + if (this.hasDropboxWrapper) { + this.$dropboxWrapper.virtualSelect = this; + } + } + setValueMethod(newValue, silentChange) { + const valuesMapping = {}; + const valuesOrder = {}; + let validValues = []; + const isMultiSelect = this.multiple; + // Normalize input value first + let value = Utils.normalizeValues(newValue); + if (value) { + if (!Array.isArray(value)) { + value = [value]; } - if (this.showOptionsOnlyOnSearch) { - this.setSearchValue('', false, true); + if (isMultiSelect) { + const { + maxValues + } = this; + if (maxValues && value.length > maxValues) { + value.splice(maxValues); + } + } else if (value.length > 1) { + value = [value[0]]; } - if (this.initialDisabled) { - this.disable(); + if (this.useGroupValue) { + value = this.setGroupOptionsValue(value); } - if (this.autofocus) { - this.focus(); + value.forEach((d, i) => { + valuesMapping[d] = true; + valuesOrder[d] = i; + }); + if (this.allowNewOption && value) { + this.setNewOptionsFromValue(value); } } - }, { - key: "afterRenderOptions", - value: function afterRenderOptions() { - var _this6 = this; - var visibleOptions = this.getVisibleOptions(); - var hasNoOptions = !this.options.length && !this.hasServerSearch; - var hasNoSearchResults = !hasNoOptions && !visibleOptions.length; - if (!this.allowNewOption || this.hasServerSearch || this.showOptionsOnlyOnSearch) { - DomUtils.toggleClass(this.$allWrappers, 'has-no-search-results', hasNoSearchResults); - if (hasNoSearchResults) { - DomUtils.setAttr(this.$noSearchResults, 'tabindex', '0'); - DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'false'); - } else { - DomUtils.setAttr(this.$noSearchResults, 'tabindex', '-1'); - DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'true'); - } - } - DomUtils.toggleClass(this.$allWrappers, 'has-no-options', hasNoOptions); - if (hasNoOptions) { - DomUtils.setAttr(this.$noOptions, 'tabindex', '0'); - DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'false'); + this.options.forEach(d => { + // Compare with normalized option values + const normalizedOptionValue = Utils.normalizeValues(d.value); + if (valuesMapping[normalizedOptionValue] === true && !d.isDisabled && !d.isGroupTitle) { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + // Store original value but compare with normalized value + validValues.push(d.value); } else { - DomUtils.setAttr(this.$noOptions, 'tabindex', '-1'); - DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'true'); + // eslint-disable-next-line no-param-reassign + d.isSelected = false; } - this.setOptionAttr(); - this.setOptionsPosition(); - this.setOptionsTooltip(); - if (document.activeElement !== this.$searchInput) { - setTimeout(function () { - var focusedOption = DomUtils.getElementsBySelector('.focused', _this6.$dropboxContainer)[0]; - if (focusedOption !== undefined) { - focusedOption.focus({ - preventScroll: true - }); - } - }, 20); + }); + if (isMultiSelect) { + if (this.hasOptionGroup) { + this.setGroupsSelectedProp(); } + + /** sorting validValues in the given values order */ + validValues.sort((a, b) => valuesOrder[Utils.normalizeValues(a)] - valuesOrder[Utils.normalizeValues(b)]); + } else { + /** taking first value for single select */ + [validValues] = validValues; } - }, { - key: "afterSetOptionsContainerHeight", - value: function afterSetOptionsContainerHeight(reset) { - if (reset && this.showAsPopup) { - this.setVisibleOptions(); + this.beforeValueSet(); + this.setValue(validValues, { + disableEvent: silentChange + }); + this.afterValueSet(); + } + setGroupOptionsValue(preparedValues) { + const selectedValues = []; + const selectedGroups = {}; + const valuesMapping = {}; + preparedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + const { + value + } = d; + const isSelected = valuesMapping[value] === true; + if (d.isGroupTitle) { + if (isSelected) { + selectedGroups[d.index] = true; + } + } else if (isSelected || selectedGroups[d.groupIndex]) { + selectedValues.push(value); } + }); + return selectedValues; + } + setGroupsSelectedProp() { + const isAllGroupOptionsSelected = this.isAllGroupOptionsSelected.bind(this); + this.options.forEach(d => { + if (d.isGroupTitle) { + // eslint-disable-next-line no-param-reassign + d.isSelected = isAllGroupOptionsSelected(d.index); + } + }); + } + setOptionsMethod(options, keepValue) { + this.setOptions(options); + this.afterSetOptions(keepValue); + } + setDisabledOptionsMethod(disabledOptions, keepValue = false) { + this.setDisabledOptions(disabledOptions, true); + if (!keepValue) { + this.setValueMethod(null); + this.toggleAllOptionsClass(); } - }, { - key: "afterSetSearchValue", - value: function afterSetSearchValue() { - var _this7 = this; - if (this.hasServerSearch) { - clearTimeout(this.serverSearchTimeout); - this.serverSearchTimeout = setTimeout(function () { - _this7.serverSearch(); - }, this.searchDelay); - } else { - this.setVisibleOptionsCount(); + this.setVisibleOptions(); + } + setDisabledOptions(disabledOptions, setOptionsProp = false) { + let disabledOptionsArr = []; + if (!disabledOptions) { + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = false; + return d; + }); } - if (this.selectAllOnlyVisible) { - this.toggleAllOptionsClass(); + } else if (disabledOptions === true) { + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = true; + disabledOptionsArr.push(d.value); + return d; + }); } - this.focusOption({ - focusFirst: true + } else { + disabledOptionsArr = disabledOptions.map(d => d.toString()); + const disabledOptionsMapping = {}; + disabledOptionsArr.forEach(d => { + disabledOptionsMapping[d] = true; }); + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = disabledOptionsMapping[d.value] === true; + return d; + }); + } } - }, { - key: "afterSetVisibleOptionsCount", - value: function afterSetVisibleOptionsCount() { - this.scrollToTop(); - this.setOptionsHeight(); - this.setVisibleOptions(); - this.updatePosition(); - } - }, { - key: "afterValueSet", - value: function afterValueSet() { - this.scrollToTop(); - this.setSearchValue(''); - this.renderOptions(); + this.disabledOptions = disabledOptionsArr; + } + setEnabledOptionsMethod(disabledOptions, keepValue = false) { + this.setEnabledOptions(disabledOptions); + if (!keepValue) { + this.setValueMethod(null); + this.toggleAllOptionsClass(); } - }, { - key: "afterSetOptions", - value: function afterSetOptions(keepValue) { - if (keepValue) { - this.setSelectedProp(); - } - this.setOptionsHeight(); - this.setVisibleOptions(); - if (this.showOptionsOnlyOnSearch) { - this.setSearchValue('', false, true); - } - if (!keepValue) { - this.reset(); - } + this.setVisibleOptions(); + } + setEnabledOptions(enabledOptions) { + if (enabledOptions === undefined) { + return; } - /** after event methods - end */ - - /** set methods - start */ - /** - * @param {virtualSelectOptions} params - */ - }, { - key: "setProps", - value: function setProps(params) { - var options = this.setDefaultProps(params); - this.setPropsFromElementAttr(options); - var convertToBoolean = Utils.convertToBoolean; - this.$ele = options.ele; - this.dropboxWrapper = options.dropboxWrapper; - this.valueKey = options.valueKey; - this.labelKey = options.labelKey; - this.descriptionKey = options.descriptionKey; - this.aliasKey = options.aliasKey; - this.optionHeightText = options.optionHeight; - this.optionHeight = parseFloat(this.optionHeightText); - this.multiple = convertToBoolean(options.multiple); - this.hasSearch = convertToBoolean(options.search); - this.searchByStartsWith = convertToBoolean(options.searchByStartsWith); - this.searchGroup = convertToBoolean(options.searchGroup); - this.hideClearButton = convertToBoolean(options.hideClearButton); - this.autoSelectFirstOption = convertToBoolean(options.autoSelectFirstOption); - this.hasOptionDescription = convertToBoolean(options.hasOptionDescription); - this.silentInitialValueSet = convertToBoolean(options.silentInitialValueSet); - this.allowNewOption = convertToBoolean(options.allowNewOption); - this.markSearchResults = convertToBoolean(options.markSearchResults); - this.showSelectedOptionsFirst = convertToBoolean(options.showSelectedOptionsFirst); - this.disableSelectAll = convertToBoolean(options.disableSelectAll); - this.keepAlwaysOpen = convertToBoolean(options.keepAlwaysOpen); - this.showDropboxAsPopup = convertToBoolean(options.showDropboxAsPopup); - this.hideValueTooltipOnSelectAll = convertToBoolean(options.hideValueTooltipOnSelectAll); - this.showOptionsOnlyOnSearch = convertToBoolean(options.showOptionsOnlyOnSearch); - this.selectAllOnlyVisible = convertToBoolean(options.selectAllOnlyVisible); - this.alwaysShowSelectedOptionsCount = convertToBoolean(options.alwaysShowSelectedOptionsCount); - this.alwaysShowSelectedOptionsLabel = convertToBoolean(options.alwaysShowSelectedOptionsLabel); - this.disableAllOptionsSelectedText = convertToBoolean(options.disableAllOptionsSelectedText); - this.showValueAsTags = convertToBoolean(options.showValueAsTags); - this.disableOptionGroupCheckbox = convertToBoolean(options.disableOptionGroupCheckbox); - this.enableSecureText = convertToBoolean(options.enableSecureText); - this.setValueAsArray = convertToBoolean(options.setValueAsArray); - this.disableValidation = convertToBoolean(options.disableValidation); - this.initialDisabled = convertToBoolean(options.disabled); - this.required = convertToBoolean(options.required); - this.autofocus = convertToBoolean(options.autofocus); - this.useGroupValue = convertToBoolean(options.useGroupValue); - this.focusSelectedOptionOnOpen = convertToBoolean(options.focusSelectedOptionOnOpen); - this.noOptionsText = options.noOptionsText; - this.noSearchResultsText = options.noSearchResultsText; - this.selectAllText = options.selectAllText; - this.searchNormalize = options.searchNormalize; - this.searchPlaceholderText = options.searchPlaceholderText; - this.searchFormLabel = options.searchFormLabel; - this.optionsSelectedText = options.optionsSelectedText; - this.optionSelectedText = options.optionSelectedText; - this.allOptionsSelectedText = options.allOptionsSelectedText; - this.clearButtonText = options.clearButtonText; - this.moreText = options.moreText; - this.placeholder = options.placeholder; - this.position = options.position; - this.textDirection = options.textDirection; - this.dropboxWidth = options.dropboxWidth; - this.tooltipFontSize = options.tooltipFontSize; - this.tooltipAlignment = options.tooltipAlignment; - this.tooltipMaxWidth = options.tooltipMaxWidth; - this.updatePositionThrottle = options.updatePositionThrottle; - this.noOfDisplayValues = parseInt(options.noOfDisplayValues); - this.zIndex = parseInt(options.zIndex); - this.maxValues = parseInt(options.maxValues); - this.minValues = parseInt(options.minValues); - this.name = this.secureText(options.name); - this.additionalClasses = options.additionalClasses; - this.additionalDropboxClasses = options.additionalDropboxClasses; - this.additionalDropboxContainerClasses = options.additionalDropboxContainerClasses; - this.additionalToggleButtonClasses = options.additionalToggleButtonClasses; - this.popupDropboxBreakpoint = options.popupDropboxBreakpoint; - this.popupPosition = options.popupPosition; - this.onServerSearch = options.onServerSearch; - this.labelRenderer = options.labelRenderer; - this.selectedLabelRenderer = options.selectedLabelRenderer; - this.initialSelectedValue = options.selectedValue === 0 ? '0' : options.selectedValue; - this.emptyValue = options.emptyValue; - this.ariaLabelText = options.ariaLabelText; - this.ariaLabelledby = options.ariaLabelledby; - this.ariaLabelClearButtonText = options.ariaLabelClearButtonText; - this.ariaLabelTagClearButtonText = options.ariaLabelTagClearButtonText; - this.ariaLabelSearchClearButtonText = options.ariaLabelSearchClearButtonText; - this.maxWidth = options.maxWidth; - this.searchDelay = options.searchDelay; - this.showDuration = parseInt(options.showDuration); - this.hideDuration = parseInt(options.hideDuration); + const disabledOptionsArr = []; + if (enabledOptions === true) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = false; + return d; + }); + } else { + const enabledOptionsMapping = {}; + enabledOptions.forEach(d => { + enabledOptionsMapping[d] = true; + }); + this.options.forEach(d => { + const isDisabled = enabledOptionsMapping[d.value] !== true; - /** @type {string[]} */ - this.selectedValues = []; - /** @type {virtualSelectOption[]} */ - this.selectedOptions = []; - this.newValues = []; - this.events = {}; - this.tooltipEnterDelay = 200; - this.searchValue = ''; - this.searchValueOriginal = ''; - this.isAllSelected = false; - if (options.search === undefined && this.multiple || this.allowNewOption || this.showOptionsOnlyOnSearch) { - this.hasSearch = true; - } - this.hasServerSearch = typeof this.onServerSearch === 'function'; - if (this.maxValues || this.hasServerSearch || this.showOptionsOnlyOnSearch) { - this.disableSelectAll = true; - this.disableOptionGroupCheckbox = true; - } - if (this.keepAlwaysOpen) { - this.dropboxWrapper = 'self'; - } - this.showAsPopup = this.showDropboxAsPopup && !this.keepAlwaysOpen && window.innerWidth <= parseFloat(this.popupDropboxBreakpoint); - this.hasSearchContainer = this.hasSearch || this.multiple && !this.disableSelectAll; - this.optionsCount = this.getOptionsCount(options.optionsCount); - this.halfOptionsCount = Math.ceil(this.optionsCount / 2); - this.optionsHeight = this.getOptionsHeight(); - this.uniqueId = this.getUniqueId(); - this.shouldFocusWrapperOnClose = true; // Initialize focus management property - this.ariaSetSize = 0; + // eslint-disable-next-line no-param-reassign + d.isDisabled = isDisabled; + if (isDisabled) { + disabledOptionsArr.push(d.value); + } + return d; + }); } - - /** - * @param {virtualSelectOptions} options - */ - }, { - key: "setDefaultProps", - value: function setDefaultProps(options) { - var defaultOptions = { - dropboxWrapper: 'self', - valueKey: 'value', - labelKey: 'label', - descriptionKey: 'description', - aliasKey: 'alias', - ariaLabelText: 'Options list', - ariaLabelClearButtonText: 'Clear button', - ariaLabelTagClearButtonText: 'Remove option', - ariaLabelSearchClearButtonText: 'Clear search input', - optionsCount: 5, - noOfDisplayValues: 50, - optionHeight: '40px', - noOptionsText: 'No options found', - noSearchResultsText: 'No results found', - selectAllText: 'Select All', - searchNormalize: false, - searchPlaceholderText: 'Search...', - searchFormLabel: 'Search', - clearButtonText: 'Clear', - moreText: 'more...', - optionsSelectedText: 'options selected', - optionSelectedText: 'option selected', - allOptionsSelectedText: 'All', - placeholder: 'Select', - position: 'bottom left', - zIndex: options.keepAlwaysOpen ? 1 : 2, - tooltipFontSize: '14px', - tooltipAlignment: 'center', - tooltipMaxWidth: '300px', - updatePositionThrottle: 100, - name: '', - additionalClasses: '', - additionalDropboxClasses: '', - additionalDropboxContainerClasses: '', - additionalToggleButtonClasses: '', - maxValues: 0, - showDropboxAsPopup: true, - popupDropboxBreakpoint: '576px', - popupPosition: 'center', - hideValueTooltipOnSelectAll: true, - emptyValue: '', - searchDelay: 300, - focusSelectedOptionOnOpen: true, - showDuration: 300, - hideDuration: 200 + this.disabledOptions = disabledOptionsArr; + } + setOptions(options = []) { + const preparedOptions = []; + const hasDisabledOptions = this.disabledOptions.length; + const { + valueKey, + labelKey, + descriptionKey, + aliasKey, + hasOptionDescription + } = this; + const { + getString, + convertToBoolean + } = Utils; + const secureText = this.secureText.bind(this); + const getAlias = this.getAlias.bind(this); + let index = 0; + let hasOptionGroup = false; + const disabledOptionsMapping = {}; + let hasEmptyValueOption = false; + this.disabledOptions.forEach(d => { + disabledOptionsMapping[d] = true; + }); + const prepareOption = d => { + if (typeof d !== 'object') { + // eslint-disable-next-line no-param-reassign + d = { + [valueKey]: d, + [labelKey]: d + }; + } + const value = secureText(getString(d[valueKey])); + const label = secureText(getString(d[labelKey])); + const childOptions = d.options; + const isGroupTitle = !!childOptions; + const option = { + index, + value, + valueNormalized: value.toLowerCase(), + label, + labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), + alias: getAlias(d[aliasKey]), + isVisible: convertToBoolean(d.isVisible, true), + isNew: d.isNew || false, + isGroupTitle, + classNames: d.classNames }; - if (options.hasOptionDescription) { - defaultOptions.optionsCount = 4; - defaultOptions.optionHeight = '50px'; + if (!hasEmptyValueOption && value === '') { + hasEmptyValueOption = true; + } + if (hasDisabledOptions) { + option.isDisabled = disabledOptionsMapping[value] === true; + } + if (d.isGroupOption) { + option.isGroupOption = true; + option.groupIndex = d.groupIndex; + } + if (hasOptionDescription) { + const description = secureText(getString(d[descriptionKey])); + option.description = description; + option.descriptionNormalized = this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(); + } + if (d.customData) { + option.customData = d.customData; + } + preparedOptions.push(option); + index += 1; + if (isGroupTitle) { + const groupIndex = option.index; + hasOptionGroup = true; + childOptions.forEach(childData => { + // eslint-disable-next-line no-param-reassign + childData.isGroupOption = true; + // eslint-disable-next-line no-param-reassign + childData.groupIndex = groupIndex; + prepareOption(childData); + }); } - return Object.assign(defaultOptions, options); - } - }, { - key: "setPropsFromElementAttr", - value: function setPropsFromElementAttr(options) { - var $ele = options.ele; - Object.keys(attrPropsMapping).forEach(function (k) { - var value = $ele.getAttribute(k); - if (valueLessProps.indexOf(k) !== -1 && (value === '' || value === 'true')) { - value = true; - } - if (value) { + }; + if (Array.isArray(options)) { + options.forEach(prepareOption); + } + const optionsLength = preparedOptions.length; + const { + $ele + } = this; + $ele.options = preparedOptions; + $ele.length = optionsLength; + this.options = preparedOptions; + this.visibleOptionsCount = optionsLength; + this.lastOptionIndex = optionsLength - 1; + this.newValues = []; + this.hasOptionGroup = hasOptionGroup; + this.hasEmptyValueOption = hasEmptyValueOption; + this.setSortedOptions(); + } + setServerOptions(options = []) { + this.setOptionsMethod(options, true); + const { + selectedOptions + } = this; + const newOptions = this.options; + let optionsUpdated = false; + + /** merging already selected options details with new options */ + if (selectedOptions.length) { + const newOptionsValueMapping = {}; + optionsUpdated = true; + newOptions.forEach(d => { + newOptionsValueMapping[d.value] = true; + }); + selectedOptions.forEach(d => { + if (newOptionsValueMapping[d.value] !== true) { // eslint-disable-next-line no-param-reassign - options[attrPropsMapping[k]] = value; + d.isVisible = false; + newOptions.push(d); } }); + this.setOptionsMethod(newOptions, true); } - }, { - key: "setEleProps", - value: function setEleProps() { - var $ele = this.$ele; - $ele.virtualSelect = this; - $ele.value = this.multiple ? [] : ''; - $ele.name = this.name; - $ele.disabled = false; - $ele.required = this.required; - $ele.autofocus = this.autofocus; - $ele.multiple = this.multiple; - $ele.form = $ele.closest('form'); - $ele.reset = VirtualSelect.reset; - $ele.setValue = VirtualSelect.setValueMethod; - $ele.setOptions = VirtualSelect.setOptionsMethod; - $ele.setDisabledOptions = VirtualSelect.setDisabledOptionsMethod; - $ele.setEnabledOptions = VirtualSelect.setEnabledOptionsMethod; - $ele.toggleSelectAll = VirtualSelect.toggleSelectAll; - $ele.isAllSelected = VirtualSelect.isAllSelected; - $ele.addOption = VirtualSelect.addOptionMethod; - $ele.getNewValue = VirtualSelect.getNewValueMethod; - $ele.getDisplayValue = VirtualSelect.getDisplayValueMethod; - $ele.getSelectedOptions = VirtualSelect.getSelectedOptionsMethod; - $ele.getDisabledOptions = VirtualSelect.getDisabledOptionsMethod; - $ele.open = VirtualSelect.openMethod; - $ele.close = VirtualSelect.closeMethod; - $ele.focus = VirtualSelect.focusMethod; - $ele.enable = VirtualSelect.enableMethod; - $ele.disable = VirtualSelect.disableMethod; - $ele.destroy = VirtualSelect.destroyMethod; - $ele.validate = VirtualSelect.validateMethod; - $ele.toggleRequired = VirtualSelect.toggleRequiredMethod; - if (this.hasDropboxWrapper) { - this.$dropboxWrapper.virtualSelect = this; + + /** merging new search option */ + if (this.allowNewOption && this.searchValue) { + const hasExactOption = newOptions.some(d => d.label.toLowerCase() === this.searchValue); + if (!hasExactOption) { + optionsUpdated = true; + this.setNewOption(); } } - }, { - key: "setValueMethod", - value: function setValueMethod(newValue, silentChange) { - var valuesMapping = {}; - var valuesOrder = {}; - var validValues = []; - var isMultiSelect = this.multiple; - // Normalize input value first - var value = Utils.normalizeValues(newValue); - if (value) { - if (!Array.isArray(value)) { - value = [value]; - } - if (isMultiSelect) { - var maxValues = this.maxValues; - if (maxValues && value.length > maxValues) { - value.splice(maxValues); - } - } else if (value.length > 1) { - value = [value[0]]; - } - if (this.useGroupValue) { - value = this.setGroupOptionsValue(value); - } - value.forEach(function (d, i) { - valuesMapping[d] = true; - valuesOrder[d] = i; - }); - if (this.allowNewOption && value) { - this.setNewOptionsFromValue(value); - } - } - this.options.forEach(function (d) { - // Compare with normalized option values - var normalizedOptionValue = Utils.normalizeValues(d.value); - if (valuesMapping[normalizedOptionValue] === true && !d.isDisabled && !d.isGroupTitle) { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - // Store original value but compare with normalized value - validValues.push(d.value); - } else { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - } - }); - if (isMultiSelect) { - if (this.hasOptionGroup) { - this.setGroupsSelectedProp(); - } - - /** sorting validValues in the given values order */ - validValues.sort(function (a, b) { - return valuesOrder[Utils.normalizeValues(a)] - valuesOrder[Utils.normalizeValues(b)]; - }); - } else { - /** taking first value for single select */ - var _validValues = validValues; - var _validValues2 = virtual_select_slicedToArray(_validValues, 1); - validValues = _validValues2[0]; - } - this.beforeValueSet(); - this.setValue(validValues, { - disableEvent: silentChange - }); - this.afterValueSet(); - } - }, { - key: "setGroupOptionsValue", - value: function setGroupOptionsValue(preparedValues) { - var selectedValues = []; - var selectedGroups = {}; - var valuesMapping = {}; - preparedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - var value = d.value; - var isSelected = valuesMapping[value] === true; - if (d.isGroupTitle) { - if (isSelected) { - selectedGroups[d.index] = true; - } - } else if (isSelected || selectedGroups[d.groupIndex]) { - selectedValues.push(value); - } - }); - return selectedValues; - } - }, { - key: "setGroupsSelectedProp", - value: function setGroupsSelectedProp() { - var isAllGroupOptionsSelected = this.isAllGroupOptionsSelected.bind(this); - this.options.forEach(function (d) { - if (d.isGroupTitle) { - // eslint-disable-next-line no-param-reassign - d.isSelected = isAllGroupOptionsSelected(d.index); - } - }); - } - }, { - key: "setOptionsMethod", - value: function setOptionsMethod(options, keepValue) { - this.setOptions(options); - this.afterSetOptions(keepValue); - } - }, { - key: "setDisabledOptionsMethod", - value: function setDisabledOptionsMethod(disabledOptions) { - var keepValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setDisabledOptions(disabledOptions, true); - if (!keepValue) { - this.setValueMethod(null); + if (optionsUpdated) { + this.setVisibleOptionsCount(); + if (this.multiple) { this.toggleAllOptionsClass(); } - this.setVisibleOptions(); + this.setValueText(); + } else { + this.updatePosition(); } - }, { - key: "setDisabledOptions", - value: function setDisabledOptions(disabledOptions) { - var setOptionsProp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var disabledOptionsArr = []; - if (!disabledOptions) { - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = false; - return d; - }); - } - } else if (disabledOptions === true) { - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = true; - disabledOptionsArr.push(d.value); - return d; - }); - } + this.setVisibleOptionsCount(); + DomUtils.removeClass(this.$allWrappers, 'server-searching'); + } + setSelectedOptions() { + this.selectedOptions = this.options.filter(d => d.isSelected); + } + setSortedOptions() { + let sortedOptions = [...this.options]; + if (this.showSelectedOptionsFirst && this.selectedValues.length) { + if (this.hasOptionGroup) { + sortedOptions = this.sortOptionsGroup(sortedOptions); } else { - disabledOptionsArr = disabledOptions.map(function (d) { - return d.toString(); - }); - var disabledOptionsMapping = {}; - disabledOptionsArr.forEach(function (d) { - disabledOptionsMapping[d] = true; - }); - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = disabledOptionsMapping[d.value] === true; - return d; - }); - } - } - this.disabledOptions = disabledOptionsArr; - } - }, { - key: "setEnabledOptionsMethod", - value: function setEnabledOptionsMethod(disabledOptions) { - var keepValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setEnabledOptions(disabledOptions); - if (!keepValue) { - this.setValueMethod(null); - this.toggleAllOptionsClass(); + sortedOptions = this.sortOptions(sortedOptions); } - this.setVisibleOptions(); } - }, { - key: "setEnabledOptions", - value: function setEnabledOptions(enabledOptions) { - if (enabledOptions === undefined) { - return; - } - var disabledOptionsArr = []; - if (enabledOptions === true) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = false; - return d; - }); - } else { - var enabledOptionsMapping = {}; - enabledOptions.forEach(function (d) { - enabledOptionsMapping[d] = true; - }); - this.options.forEach(function (d) { - var isDisabled = enabledOptionsMapping[d.value] !== true; - - // eslint-disable-next-line no-param-reassign - d.isDisabled = isDisabled; - if (isDisabled) { - disabledOptionsArr.push(d.value); - } - return d; - }); + this.sortedOptions = sortedOptions; + } + setVisibleOptions() { + let visibleOptions = [...this.sortedOptions]; + const maxOptionsToShow = this.optionsCount * 2; + const startIndex = this.getVisibleStartIndex(); + const newOption = this.getNewOption(); + const endIndex = startIndex + maxOptionsToShow - 1; + let i = 0; + if (newOption) { + newOption.visibleIndex = i; + i += 1; + } + visibleOptions = visibleOptions.filter(d => { + let inView = false; + if (d.isVisible && !d.isCurrentNew) { + inView = i >= startIndex && i <= endIndex; + // eslint-disable-next-line no-param-reassign + d.visibleIndex = i; + i += 1; } - this.disabledOptions = disabledOptionsArr; - } - }, { - key: "setOptions", - value: function setOptions() { - var _this8 = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - var preparedOptions = []; - var hasDisabledOptions = this.disabledOptions.length; - var valueKey = this.valueKey, - labelKey = this.labelKey, - descriptionKey = this.descriptionKey, - aliasKey = this.aliasKey, - hasOptionDescription = this.hasOptionDescription; - var getString = Utils.getString, - convertToBoolean = Utils.convertToBoolean; - var secureText = this.secureText.bind(this); - var getAlias = this.getAlias.bind(this); - var index = 0; - var hasOptionGroup = false; - var disabledOptionsMapping = {}; - var hasEmptyValueOption = false; - this.disabledOptions.forEach(function (d) { - disabledOptionsMapping[d] = true; + return inView; + }); + if (newOption) { + visibleOptions = [newOption, ...visibleOptions]; + } + this.visibleOptions = visibleOptions; + // update number of visible options + this.visibleOptionsCount = visibleOptions.length; + this.renderOptions(); + } + setOptionsPosition(startIndex) { + // We use the parseInt to fix a Chrome issue when dealing with decimal pixels in translate3d + const top = parseInt((startIndex || this.getVisibleStartIndex()) * this.optionHeight); + this.$options.style.transform = `translate3d(0, ${top}px, 0)`; + DomUtils.setData(this.$options, 'top', top); + } + setOptionsTooltip() { + const visibleOptions = this.getVisibleOptions(); + const { + hasOptionDescription + } = this; + visibleOptions.forEach(d => { + const $optionEle = this.$dropboxContainer.querySelector(`.vscomp-option[data-index="${d.index}"]`); + DomUtils.setData($optionEle.querySelector('.vscomp-option-text'), 'tooltip', d.label); + if (hasOptionDescription) { + DomUtils.setData($optionEle.querySelector('.vscomp-option-description'), 'tooltip', d.description); + } + }); + } + setValue(value, { + disableEvent = false, + disableValidation = false + } = {}) { + // Normalize input value first + const normalizedValue = Utils.normalizeValues(value); + const isValidValue = this.hasEmptyValueOption && normalizedValue === '' || normalizedValue; + if (!isValidValue) { + this.selectedValues = []; + } else if (Array.isArray(normalizedValue)) { + this.selectedValues = [...normalizedValue]; + } else { + this.selectedValues = [normalizedValue]; + } + const newValue = this.getValue(); + this.$ele.value = newValue; + this.$hiddenInput.value = this.getInputValue(newValue); + this.isMaxValuesSelected = !!(this.maxValues && this.maxValues <= this.selectedValues.length); + this.toggleAllOptionsClass(); + this.setValueText(); + const hasValue = Utils.isNotEmpty(this.selectedValues); + DomUtils.toggleClass(this.$allWrappers, 'has-value', hasValue); + DomUtils.toggleClass(this.$allWrappers, 'max-value-selected', this.isMaxValuesSelected); + DomUtils.setAttr(this.$clearButton, 'tabindex', hasValue ? '0' : '-1'); + DomUtils.setAria(this.$clearButton, 'hidden', hasValue === false); + if (!disableValidation) { + this.validate(); + } + if (!disableEvent) { + DomUtils.dispatchEvent(this.$ele, 'change', true); + } + } + setValueText() { + const { + multiple, + selectedValues, + noOfDisplayValues, + showValueAsTags, + $valueText, + selectedLabelRenderer + } = this; + const valueText = []; + let valueTooltip = []; + const selectedLength = selectedValues.length; + let selectedValuesCount = 0; + const showAllText = this.isAllSelected && !this.hasServerSearch && !this.disableAllOptionsSelectedText && !showValueAsTags; + + /** show all values selected text without tooltip text */ + if (showAllText && this.hideValueTooltipOnSelectAll) { + $valueText.innerHTML = `${this.allOptionsSelectedText} (${selectedLength})`; + } else { + const selectedOptions = this.getSelectedOptions({ + fullDetails: true, + keepSelectionOrder: true }); - var _prepareOption = function prepareOption(d) { - if (virtual_select_typeof(d) !== 'object') { - // eslint-disable-next-line no-param-reassign - d = _defineProperty(_defineProperty({}, valueKey, d), labelKey, d); - } - var value = secureText(getString(d[valueKey])); - var label = secureText(getString(d[labelKey])); - var childOptions = d.options; - var isGroupTitle = !!childOptions; - var option = { - index: index, - value: value, - valueNormalized: value.toLowerCase(), - label: label, - labelNormalized: _this8.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), - alias: getAlias(d[aliasKey]), - isVisible: convertToBoolean(d.isVisible, true), - isNew: d.isNew || false, - isGroupTitle: isGroupTitle, - classNames: d.classNames - }; - if (!hasEmptyValueOption && value === '') { - hasEmptyValueOption = true; - } - if (hasDisabledOptions) { - option.isDisabled = disabledOptionsMapping[value] === true; - } - if (d.isGroupOption) { - option.isGroupOption = true; - option.groupIndex = d.groupIndex; - } - if (hasOptionDescription) { - var description = secureText(getString(d[descriptionKey])); - option.description = description; - option.descriptionNormalized = _this8.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(); - } - if (d.customData) { - option.customData = d.customData; + selectedOptions.some(d => { + if (d.isCurrentNew) { + return false; } - preparedOptions.push(option); - index += 1; - if (isGroupTitle) { - var groupIndex = option.index; - hasOptionGroup = true; - childOptions.forEach(function (childData) { - // eslint-disable-next-line no-param-reassign - childData.isGroupOption = true; - // eslint-disable-next-line no-param-reassign - childData.groupIndex = groupIndex; - _prepareOption(childData); - }); + if (selectedValuesCount >= noOfDisplayValues) { + return true; } - }; - if (Array.isArray(options)) { - options.forEach(_prepareOption); - } - var optionsLength = preparedOptions.length; - var $ele = this.$ele; - $ele.options = preparedOptions; - $ele.length = optionsLength; - this.options = preparedOptions; - this.visibleOptionsCount = optionsLength; - this.lastOptionIndex = optionsLength - 1; - this.newValues = []; - this.hasOptionGroup = hasOptionGroup; - this.hasEmptyValueOption = hasEmptyValueOption; - this.setSortedOptions(); - } - }, { - key: "setServerOptions", - value: function setServerOptions() { - var _this9 = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - this.setOptionsMethod(options, true); - var selectedOptions = this.selectedOptions; - var newOptions = this.options; - var optionsUpdated = false; - - /** merging already selected options details with new options */ - if (selectedOptions.length) { - var newOptionsValueMapping = {}; - optionsUpdated = true; - newOptions.forEach(function (d) { - newOptionsValueMapping[d.value] = true; - }); - selectedOptions.forEach(function (d) { - if (newOptionsValueMapping[d.value] !== true) { - // eslint-disable-next-line no-param-reassign - d.isVisible = false; - newOptions.push(d); + let { + label + } = d; + if (typeof selectedLabelRenderer === 'function') { + label = selectedLabelRenderer(d); + } + valueText.push(label); + selectedValuesCount += 1; + if (showValueAsTags) { + // Will cause text overflow in runtime and if so,the tooltip information is prepared + const valueTooltipForTags = Utils.willTextOverflow($valueText.parentElement, label) ? this.getTooltipAttrText(label, false, true) : ''; + + // replace is nedded to remove html tags from aria-label (ex: when there is an icon in the label) + let ariaLabelClearBtnTxt = ''; + if (this.ariaLabelTagClearButtonText) { + const stripHtmlLabel = label.replace(/<[^>]+>/ig, '').trim(); + ariaLabelClearBtnTxt = `aria-label="${stripHtmlLabel}, ${this.ariaLabelTagClearButtonText}"`; } - }); - this.setOptionsMethod(newOptions, true); - } - - /** merging new search option */ - if (this.allowNewOption && this.searchValue) { - var hasExactOption = newOptions.some(function (d) { - return d.label.toLowerCase() === _this9.searchValue; - }); - if (!hasExactOption) { - optionsUpdated = true; - this.setNewOption(); - } - } - if (optionsUpdated) { - this.setVisibleOptionsCount(); - if (this.multiple) { - this.toggleAllOptionsClass(); - } - this.setValueText(); - } else { - this.updatePosition(); - } - this.setVisibleOptionsCount(); - DomUtils.removeClass(this.$allWrappers, 'server-searching'); - } - }, { - key: "setSelectedOptions", - value: function setSelectedOptions() { - this.selectedOptions = this.options.filter(function (d) { - return d.isSelected; - }); - } - }, { - key: "setSortedOptions", - value: function setSortedOptions() { - var sortedOptions = virtual_select_toConsumableArray(this.options); - if (this.showSelectedOptionsFirst && this.selectedValues.length) { - if (this.hasOptionGroup) { - sortedOptions = this.sortOptionsGroup(sortedOptions); + const valueTagHtml = ` + ${label} + + + + `; + valueTooltip.push(valueTagHtml); } else { - sortedOptions = this.sortOptions(sortedOptions); - } - } - this.sortedOptions = sortedOptions; - } - }, { - key: "setVisibleOptions", - value: function setVisibleOptions() { - var visibleOptions = virtual_select_toConsumableArray(this.sortedOptions); - var maxOptionsToShow = this.optionsCount * 2; - var startIndex = this.getVisibleStartIndex(); - var newOption = this.getNewOption(); - var endIndex = startIndex + maxOptionsToShow - 1; - var i = 0; - if (newOption) { - newOption.visibleIndex = i; - i += 1; - } - visibleOptions = visibleOptions.filter(function (d) { - var inView = false; - if (d.isVisible && !d.isCurrentNew) { - inView = i >= startIndex && i <= endIndex; - // eslint-disable-next-line no-param-reassign - d.visibleIndex = i; - i += 1; - } - return inView; - }); - if (newOption) { - visibleOptions = [newOption].concat(virtual_select_toConsumableArray(visibleOptions)); - } - this.visibleOptions = visibleOptions; - // update number of visible options - this.visibleOptionsCount = visibleOptions.length; - this.renderOptions(); - } - }, { - key: "setOptionsPosition", - value: function setOptionsPosition(startIndex) { - // We use the parseInt to fix a Chrome issue when dealing with decimal pixels in translate3d - var top = parseInt((startIndex || this.getVisibleStartIndex()) * this.optionHeight); - this.$options.style.transform = "translate3d(0, ".concat(top, "px, 0)"); - DomUtils.setData(this.$options, 'top', top); - } - }, { - key: "setOptionsTooltip", - value: function setOptionsTooltip() { - var _this0 = this; - var visibleOptions = this.getVisibleOptions(); - var hasOptionDescription = this.hasOptionDescription; - visibleOptions.forEach(function (d) { - var $optionEle = _this0.$dropboxContainer.querySelector(".vscomp-option[data-index=\"".concat(d.index, "\"]")); - DomUtils.setData($optionEle.querySelector('.vscomp-option-text'), 'tooltip', d.label); - if (hasOptionDescription) { - DomUtils.setData($optionEle.querySelector('.vscomp-option-description'), 'tooltip', d.description); + valueTooltip.push(label); } + return false; }); - } - }, { - key: "setValue", - value: function setValue(value) { - var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref2$disableEvent = _ref2.disableEvent, - disableEvent = _ref2$disableEvent === void 0 ? false : _ref2$disableEvent, - _ref2$disableValidati = _ref2.disableValidation, - disableValidation = _ref2$disableValidati === void 0 ? false : _ref2$disableValidati; - // Normalize input value first - var normalizedValue = Utils.normalizeValues(value); - var isValidValue = this.hasEmptyValueOption && normalizedValue === '' || normalizedValue; - if (!isValidValue) { - this.selectedValues = []; - } else if (Array.isArray(normalizedValue)) { - this.selectedValues = virtual_select_toConsumableArray(normalizedValue); - } else { - this.selectedValues = [normalizedValue]; - } - var newValue = this.getValue(); - this.$ele.value = newValue; - this.$hiddenInput.value = this.getInputValue(newValue); - this.isMaxValuesSelected = !!(this.maxValues && this.maxValues <= this.selectedValues.length); - this.toggleAllOptionsClass(); - this.setValueText(); - var hasValue = Utils.isNotEmpty(this.selectedValues); - DomUtils.toggleClass(this.$allWrappers, 'has-value', hasValue); - DomUtils.toggleClass(this.$allWrappers, 'max-value-selected', this.isMaxValuesSelected); - DomUtils.setAttr(this.$clearButton, 'tabindex', hasValue ? '0' : '-1'); - DomUtils.setAria(this.$clearButton, 'hidden', hasValue === false); - if (!disableValidation) { - this.validate(); + const moreSelectedOptions = selectedLength - noOfDisplayValues; + if (moreSelectedOptions > 0) { + valueTooltip.push(`+ ${moreSelectedOptions} ${this.moreText}`); } - if (!disableEvent) { - DomUtils.dispatchEvent(this.$ele, 'change', true); - } - } - }, { - key: "setValueText", - value: function setValueText() { - var _this1 = this; - var multiple = this.multiple, - selectedValues = this.selectedValues, - noOfDisplayValues = this.noOfDisplayValues, - showValueAsTags = this.showValueAsTags, - $valueText = this.$valueText, - selectedLabelRenderer = this.selectedLabelRenderer; - var valueText = []; - var valueTooltip = []; - var selectedLength = selectedValues.length; - var selectedValuesCount = 0; - var showAllText = this.isAllSelected && !this.hasServerSearch && !this.disableAllOptionsSelectedText && !showValueAsTags; - - /** show all values selected text without tooltip text */ - if (showAllText && this.hideValueTooltipOnSelectAll) { - $valueText.innerHTML = "".concat(this.allOptionsSelectedText, " (").concat(selectedLength, ")"); + const aggregatedValueText = valueText.join(', '); + if (aggregatedValueText === '') { + $valueText.innerHTML = this.placeholder; } else { - var selectedOptions = this.getSelectedOptions({ - fullDetails: true, - keepSelectionOrder: true - }); - selectedOptions.some(function (d) { - if (d.isCurrentNew) { - return false; - } - if (selectedValuesCount >= noOfDisplayValues) { - return true; - } - var label = d.label; - if (typeof selectedLabelRenderer === 'function') { - label = selectedLabelRenderer(d); - } - valueText.push(label); - selectedValuesCount += 1; - if (showValueAsTags) { - // Will cause text overflow in runtime and if so,the tooltip information is prepared - var valueTooltipForTags = Utils.willTextOverflow($valueText.parentElement, label) ? _this1.getTooltipAttrText(label, false, true) : ''; - - // replace is nedded to remove html tags from aria-label (ex: when there is an icon in the label) - var ariaLabelClearBtnTxt = ''; - if (_this1.ariaLabelTagClearButtonText) { - var stripHtmlLabel = label.replace(/<[^>]+>/ig, '').trim(); - ariaLabelClearBtnTxt = "aria-label=\"".concat(stripHtmlLabel, ", ").concat(_this1.ariaLabelTagClearButtonText, "\""); + $valueText.innerHTML = aggregatedValueText; + if (multiple) { + const { + maxValues + } = this; + const showSelectedCount = this.alwaysShowSelectedOptionsCount || DomUtils.hasEllipsis($valueText); + if (showSelectedCount || maxValues || showValueAsTags) { + let countText = `${selectedLength}`; + if (maxValues) { + countText += ` / ${maxValues}`; } - var valueTagHtml = "\n ").concat(label, "\n \n \n \n "); - valueTooltip.push(valueTagHtml); - } else { - valueTooltip.push(label); - } - return false; - }); - var moreSelectedOptions = selectedLength - noOfDisplayValues; - if (moreSelectedOptions > 0) { - valueTooltip.push("+ ".concat(moreSelectedOptions, " ").concat(this.moreText, "")); - } - var aggregatedValueText = valueText.join(', '); - if (aggregatedValueText === '') { - $valueText.innerHTML = this.placeholder; - } else { - $valueText.innerHTML = aggregatedValueText; - if (multiple) { - var maxValues = this.maxValues; - var showSelectedCount = this.alwaysShowSelectedOptionsCount || DomUtils.hasEllipsis($valueText); - if (showSelectedCount || maxValues || showValueAsTags) { - var countText = "".concat(selectedLength, ""); - if (maxValues) { - countText += " / ".concat(maxValues, ""); - } - /** show all values selected text with tooltip text */ - if (showAllText) { - $valueText.innerHTML = "".concat(this.allOptionsSelectedText, " (").concat(selectedLength, ")"); - } else if (showValueAsTags) { - $valueText.innerHTML = valueTooltip.join(''); - this.$valueTags = $valueText.querySelectorAll('.vscomp-value-tag'); - this.setValueTagAttr(); - } else if (!this.alwaysShowSelectedOptionsLabel) { - /** replace comma separated list of selections with shorter text indicating selection count */ - var optionsSelectedText = selectedLength === 1 ? this.optionSelectedText : this.optionsSelectedText; - $valueText.innerHTML = "".concat(countText, " ").concat(optionsSelectedText); - } - } else { - /** removing tooltip if full value text is visible */ - valueTooltip = []; + /** show all values selected text with tooltip text */ + if (showAllText) { + $valueText.innerHTML = `${this.allOptionsSelectedText} (${selectedLength})`; + } else if (showValueAsTags) { + $valueText.innerHTML = valueTooltip.join(''); + this.$valueTags = $valueText.querySelectorAll('.vscomp-value-tag'); + this.setValueTagAttr(); + } else if (!this.alwaysShowSelectedOptionsLabel) { + /** replace comma separated list of selections with shorter text indicating selection count */ + const optionsSelectedText = selectedLength === 1 ? this.optionSelectedText : this.optionsSelectedText; + $valueText.innerHTML = `${countText} ${optionsSelectedText}`; } + } else { + /** removing tooltip if full value text is visible */ + valueTooltip = []; } } } - var tooltipText = ''; - if (selectedLength === 0) { - tooltipText = this.placeholder; - } else if (!showValueAsTags) { - tooltipText = valueTooltip.join(', '); - } + } + let tooltipText = ''; + if (selectedLength === 0) { + tooltipText = this.placeholder; + } else if (!showValueAsTags) { + tooltipText = valueTooltip.join(', '); + } + if (!showValueAsTags) { + DomUtils.setData($valueText, 'tooltip', tooltipText); + } + if (multiple) { if (!showValueAsTags) { - DomUtils.setData($valueText, 'tooltip', tooltipText); - } - if (multiple) { - if (!showValueAsTags) { - DomUtils.setData($valueText, 'tooltipEllipsisOnly', selectedLength === 0); - } else { - this.updatePosition(); - } + DomUtils.setData($valueText, 'tooltipEllipsisOnly', selectedLength === 0); + } else { + this.updatePosition(); } } - }, { - key: "setSearchValue", - value: function setSearchValue(value) { - var skipInputSet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var forceSet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (value === this.searchValueOriginal && !forceSet) { + } + setSearchValue(value, skipInputSet = false, forceSet = false) { + if (value === this.searchValueOriginal && !forceSet) { + return; + } + if (!skipInputSet) { + this.$searchInput.value = value; + } + const searchValue = value.replace(/\\/g, '').toLowerCase().trim(); + this.searchValue = searchValue; + this.searchValueOriginal = value; + DomUtils.toggleClass(this.$allWrappers, 'has-search-value', value); + DomUtils.setAttr(this.$searchClear, 'tabindex', value !== '' ? '0' : '-1'); + DomUtils.setAria(this.$searchClear, 'hidden', value === ''); + this.afterSetSearchValue(); + } + setVisibleOptionsCount() { + let visibleOptionsCount = 0; + let hasExactOption = false; + let visibleOptionGroupsMapping; + const { + searchGroup, + showOptionsOnlyOnSearch, + searchByStartsWith + } = this; + + /** If searchNormalize we'll normalize the searchValue */ + let { + searchValue + } = this; + searchValue = this.searchNormalize && searchValue.trim() !== '' ? Utils.normalizeString(searchValue) : searchValue; + const isOptionVisible = this.isOptionVisible.bind(this); + if (this.hasOptionGroup) { + visibleOptionGroupsMapping = this.getVisibleOptionGroupsMapping(searchValue); + } + this.options.forEach(d => { + if (d.isCurrentNew) { return; } - if (!skipInputSet) { - this.$searchInput.value = value; + let result; + if (showOptionsOnlyOnSearch && !searchValue) { + // eslint-disable-next-line no-param-reassign + d.isVisible = false; + result = { + isVisible: false, + hasExactOption: false + }; + } else { + result = isOptionVisible({ + data: d, + searchValue, + hasExactOption, + visibleOptionGroupsMapping, + searchGroup, + searchByStartsWith + }); } - var searchValue = value.replace(/\\/g, '').toLowerCase().trim(); - this.searchValue = searchValue; - this.searchValueOriginal = value; - DomUtils.toggleClass(this.$allWrappers, 'has-search-value', value); - DomUtils.setAttr(this.$searchClear, 'tabindex', value !== '' ? '0' : '-1'); - DomUtils.setAria(this.$searchClear, 'hidden', value === ''); - this.afterSetSearchValue(); - } - }, { - key: "setVisibleOptionsCount", - value: function setVisibleOptionsCount() { - var visibleOptionsCount = 0; - var hasExactOption = false; - var visibleOptionGroupsMapping; - var searchGroup = this.searchGroup, - showOptionsOnlyOnSearch = this.showOptionsOnlyOnSearch, - searchByStartsWith = this.searchByStartsWith; - - /** If searchNormalize we'll normalize the searchValue */ - var searchValue = this.searchValue; - searchValue = this.searchNormalize && searchValue.trim() !== '' ? Utils.normalizeString(searchValue) : searchValue; - var isOptionVisible = this.isOptionVisible.bind(this); - if (this.hasOptionGroup) { - visibleOptionGroupsMapping = this.getVisibleOptionGroupsMapping(searchValue); + if (result.isVisible) { + visibleOptionsCount += 1; } - this.options.forEach(function (d) { - if (d.isCurrentNew) { - return; - } - var result; - if (showOptionsOnlyOnSearch && !searchValue) { - // eslint-disable-next-line no-param-reassign - d.isVisible = false; - result = { - isVisible: false, - hasExactOption: false - }; - } else { - result = isOptionVisible({ - data: d, - searchValue: searchValue, - hasExactOption: hasExactOption, - visibleOptionGroupsMapping: visibleOptionGroupsMapping, - searchGroup: searchGroup, - searchByStartsWith: searchByStartsWith - }); - } - if (result.isVisible) { - visibleOptionsCount += 1; - } - if (!hasExactOption) { - hasExactOption = result.hasExactOption; - } - }); - if (this.allowNewOption) { - if (searchValue && !hasExactOption) { - this.setNewOption(); - visibleOptionsCount += 1; - } else { - this.removeNewOption(); - } + if (!hasExactOption) { + hasExactOption = result.hasExactOption; + } + }); + if (this.allowNewOption) { + if (searchValue && !hasExactOption) { + this.setNewOption(); + visibleOptionsCount += 1; + } else { + this.removeNewOption(); } - this.visibleOptionsCount = visibleOptionsCount; - this.afterSetVisibleOptionsCount(); } + this.visibleOptionsCount = visibleOptionsCount; + this.afterSetVisibleOptionsCount(); + } - /** - * Calculates ARIA metadata (aria-setsize and aria-posinset) for virtualized listbox accessibility. - * This method iterates through ALL filtered options (not just rendered ones) to calculate - * the correct position in the full filtered set. This ensures screen readers announce - * correct positions even when only a subset of options is rendered (e.g., "Option 50, 50 of 10001"). - * - * Example: With 10,001 filtered options showing only 5 at a time: - * - All 10,001 options get filteredIndex values: 1, 2, 3, ..., 10001 - * - ariaSetSize = 10001 - * - When options 50-54 are rendered, they have filteredIndex: 50, 51, 52, 53, 54 - * - Screen reader announces: "Option 50, 50 of 10001" - */ - }, { - key: "calculateAriaMetadata", - value: function calculateAriaMetadata() { - var _this10 = this; - var ariaSetSize = 0; - var filteredPosition = 0; - var optionsSource = this.sortedOptions && this.sortedOptions.length ? this.sortedOptions : this.options; - - // Iterate through ALL options (not just rendered ones) to calculate positions in the full filtered set - optionsSource.forEach(function (d) { - if (d.isCurrentNew) { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - return; - } - if (d.isVisible === true) { - var isSelectableGroupTitle = d.isGroupTitle && _this10.multiple && !_this10.disableOptionGroupCheckbox; - if (!d.isGroupTitle || isSelectableGroupTitle) { - filteredPosition += 1; - ariaSetSize += 1; - // eslint-disable-next-line no-param-reassign - d.filteredIndex = filteredPosition; - } else { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - } - } else { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - } - }); - if (this.allowNewOption) { - var newOption = this.getNewOption(); - if (newOption && newOption.isVisible === true) { + /** + * Calculates ARIA metadata (aria-setsize and aria-posinset) for virtualized listbox accessibility. + * This method iterates through ALL filtered options (not just rendered ones) to calculate + * the correct position in the full filtered set. This ensures screen readers announce + * correct positions even when only a subset of options is rendered (e.g., "Option 50, 50 of 10001"). + * + * Example: With 10,001 filtered options showing only 5 at a time: + * - All 10,001 options get filteredIndex values: 1, 2, 3, ..., 10001 + * - ariaSetSize = 10001 + * - When options 50-54 are rendered, they have filteredIndex: 50, 51, 52, 53, 54 + * - Screen reader announces: "Option 50, 50 of 10001" + */ + calculateAriaMetadata() { + let ariaSetSize = 0; + let filteredPosition = 0; + const optionsSource = this.sortedOptions && this.sortedOptions.length ? this.sortedOptions : this.options; + + // Iterate through ALL options (not just rendered ones) to calculate positions in the full filtered set + optionsSource.forEach(d => { + if (d.isCurrentNew) { + // eslint-disable-next-line no-param-reassign + d.filteredIndex = undefined; + return; + } + if (d.isVisible === true) { + const isSelectableGroupTitle = d.isGroupTitle && this.multiple && !this.disableOptionGroupCheckbox; + if (!d.isGroupTitle || isSelectableGroupTitle) { filteredPosition += 1; ariaSetSize += 1; // eslint-disable-next-line no-param-reassign - newOption.filteredIndex = filteredPosition; - } else if (newOption) { + d.filteredIndex = filteredPosition; + } else { // eslint-disable-next-line no-param-reassign - newOption.filteredIndex = undefined; - } - } - this.ariaSetSize = ariaSetSize; - } - }, { - key: "setOptionProp", - value: function setOptionProp(index, key, value) { - if (!this.options[index]) { - return; - } - this.options[index][key] = value; - } - }, { - key: "setOptionsHeight", - value: function setOptionsHeight() { - this.$optionsList.style.height = "".concat(this.optionHeight * this.visibleOptionsCount, "px"); - } - }, { - key: "setOptionsContainerHeight", - value: function setOptionsContainerHeight(reset) { - var optionsHeight; - if (reset) { - if (this.showAsPopup) { - this.optionsCount = this.getOptionsCount(); - this.halfOptionsCount = Math.ceil(this.optionsCount / 2); - optionsHeight = this.getOptionsHeight(); - this.optionsHeight = optionsHeight; + d.filteredIndex = undefined; } } else { - optionsHeight = this.optionsHeight; - if (this.keepAlwaysOpen) { - DomUtils.setStyle(this.$noOptions, 'height', optionsHeight); - DomUtils.setStyle(this.$noSearchResults, 'height', optionsHeight); - } - } - DomUtils.setStyle(this.$optionsContainer, 'max-height', optionsHeight); - this.afterSetOptionsContainerHeight(reset); - } - }, { - key: "setNewOption", - value: function setNewOption(newValue) { - var value = newValue || this.searchValueOriginal.trim(); - if (!value) { - return; - } - var newOption = this.getNewOption(); - if (newOption) { - var newIndex = newOption.index; - this.setOptionProp(newIndex, 'value', this.secureText(value)); - this.setOptionProp(newIndex, 'label', this.secureText(value)); - } else { - var data = { - value: value, - label: value - }; - if (newValue) { - data.isNew = true; - this.newValues.push(value); - } else { - data.isCurrentNew = true; - } - this.addOption(data); + // eslint-disable-next-line no-param-reassign + d.filteredIndex = undefined; + } + }); + if (this.allowNewOption) { + const newOption = this.getNewOption(); + if (newOption && newOption.isVisible === true) { + filteredPosition += 1; + ariaSetSize += 1; + // eslint-disable-next-line no-param-reassign + newOption.filteredIndex = filteredPosition; + } else if (newOption) { + // eslint-disable-next-line no-param-reassign + newOption.filteredIndex = undefined; } } - }, { - key: "setSelectedProp", - value: function setSelectedProp() { - var valuesMapping = {}; - this.selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - if (valuesMapping[d.value] === true) { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - } - }); - } - }, { - key: "setNewOptionsFromValue", - value: function setNewOptionsFromValue(values) { - if (!values) { - return; - } - var setNewOption = this.setNewOption.bind(this); - var availableValuesMapping = {}; - this.options.forEach(function (d) { - availableValuesMapping[d.value] = true; - }); - values.forEach(function (d) { - if (d && availableValuesMapping[d] !== true) { - setNewOption(d); - } - }); + this.ariaSetSize = ariaSetSize; + } + setOptionProp(index, key, value) { + if (!this.options[index]) { + return; } - }, { - key: "setDropboxWrapperWidth", - value: function setDropboxWrapperWidth() { + this.options[index][key] = value; + } + setOptionsHeight() { + this.$optionsList.style.height = `${this.optionHeight * this.visibleOptionsCount}px`; + } + setOptionsContainerHeight(reset) { + let optionsHeight; + if (reset) { if (this.showAsPopup) { - return; + this.optionsCount = this.getOptionsCount(); + this.halfOptionsCount = Math.ceil(this.optionsCount / 2); + optionsHeight = this.getOptionsHeight(); + this.optionsHeight = optionsHeight; } - var width = this.dropboxWidth || "".concat(this.$wrapper.offsetWidth, "px"); - DomUtils.setStyle(this.$dropboxContainer, 'max-width', width); - } - }, { - key: "setEleStyles", - value: function setEleStyles() { - var maxWidth = this.maxWidth; - var styles = {}; - if (maxWidth) { - styles['max-width'] = maxWidth; + } else { + optionsHeight = this.optionsHeight; + if (this.keepAlwaysOpen) { + DomUtils.setStyle(this.$noOptions, 'height', optionsHeight); + DomUtils.setStyle(this.$noSearchResults, 'height', optionsHeight); } - DomUtils.setStyles(this.$ele, styles); - } - }, { - key: "setDropboxStyles", - value: function setDropboxStyles() { - var dropboxWidth = this.dropboxWidth; - var styles = {}; - var containerStyles = { - 'z-index': this.zIndex + } + DomUtils.setStyle(this.$optionsContainer, 'max-height', optionsHeight); + this.afterSetOptionsContainerHeight(reset); + } + setNewOption(newValue) { + const value = newValue || this.searchValueOriginal.trim(); + if (!value) { + return; + } + const newOption = this.getNewOption(); + if (newOption) { + const newIndex = newOption.index; + this.setOptionProp(newIndex, 'value', this.secureText(value)); + this.setOptionProp(newIndex, 'label', this.secureText(value)); + } else { + const data = { + value, + label: value }; - if (dropboxWidth) { - if (this.showAsPopup) { - styles['max-width'] = dropboxWidth; - } else { - containerStyles.width = dropboxWidth; - } - } - DomUtils.setStyles(this.$dropboxContainer, containerStyles); - DomUtils.setStyles(this.$dropbox, styles); - } - }, { - key: "setOptionAttr", - value: function setOptionAttr() { - var $visibleOptions = this.$visibleOptions; - var options = this.options; - var optionHeight = "".concat(this.optionHeight, "px"); - var setStyle = DomUtils.setStyle, - getData = DomUtils.getData, - setData = DomUtils.setData; - if ($visibleOptions && $visibleOptions.length) { - $visibleOptions.forEach(function ($option) { - var optionDetails = options[getData($option, 'index')]; - setStyle($option, 'height', optionHeight); - setData($option, 'value', optionDetails.value); - }); + if (newValue) { + data.isNew = true; + this.newValues.push(value); + } else { + data.isCurrentNew = true; } + this.addOption(data); } - }, { - key: "setValueTagAttr", - value: function setValueTagAttr() { - var $valueTags = this.$valueTags; - if (!$valueTags || !$valueTags.length) { - return; + } + setSelectedProp() { + const valuesMapping = {}; + this.selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + if (valuesMapping[d.value] === true) { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; } - var getData = DomUtils.getData, - setData = DomUtils.setData; - var options = this.options; - $valueTags.forEach(function ($valueTag) { - var index = getData($valueTag, 'index'); - if (typeof index !== 'undefined') { - var optionDetails = options[index]; - setData($valueTag, 'value', optionDetails.value); - } - }); + }); + } + setNewOptionsFromValue(values) { + if (!values) { + return; + } + const setNewOption = this.setNewOption.bind(this); + const availableValuesMapping = {}; + this.options.forEach(d => { + availableValuesMapping[d.value] = true; + }); + values.forEach(d => { + if (d && availableValuesMapping[d] !== true) { + setNewOption(d); + } + }); + } + setDropboxWrapperWidth() { + if (this.showAsPopup) { + return; } - }, { - key: "setScrollTop", - value: function setScrollTop() { - var selectedValues = this.selectedValues; - if (this.showSelectedOptionsFirst || !this.focusSelectedOptionOnOpen || selectedValues.length === 0) { - return; + const width = this.dropboxWidth || `${this.$wrapper.offsetWidth}px`; + DomUtils.setStyle(this.$dropboxContainer, 'max-width', width); + } + setEleStyles() { + const { + maxWidth + } = this; + const styles = {}; + if (maxWidth) { + styles['max-width'] = maxWidth; + } + DomUtils.setStyles(this.$ele, styles); + } + setDropboxStyles() { + const { + dropboxWidth + } = this; + const styles = {}; + const containerStyles = { + 'z-index': this.zIndex + }; + if (dropboxWidth) { + if (this.showAsPopup) { + styles['max-width'] = dropboxWidth; + } else { + containerStyles.width = dropboxWidth; } - var valuesMapping = {}; - var selectedOptionIndex; - selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.some(function (d) { - if (valuesMapping[d.value]) { - selectedOptionIndex = d.visibleIndex; - return true; - } - return false; + } + DomUtils.setStyles(this.$dropboxContainer, containerStyles); + DomUtils.setStyles(this.$dropbox, styles); + } + setOptionAttr() { + const { + $visibleOptions + } = this; + const { + options + } = this; + const optionHeight = `${this.optionHeight}px`; + const { + setStyle, + getData, + setData + } = DomUtils; + if ($visibleOptions && $visibleOptions.length) { + $visibleOptions.forEach($option => { + const optionDetails = options[getData($option, 'index')]; + setStyle($option, 'height', optionHeight); + setData($option, 'value', optionDetails.value); }); - if (selectedOptionIndex) { - this.$optionsContainer.scrollTop = this.optionHeight * selectedOptionIndex; + } + } + setValueTagAttr() { + const { + $valueTags + } = this; + if (!$valueTags || !$valueTags.length) { + return; + } + const { + getData, + setData + } = DomUtils; + const { + options + } = this; + $valueTags.forEach($valueTag => { + const index = getData($valueTag, 'index'); + if (typeof index !== 'undefined') { + const optionDetails = options[index]; + setData($valueTag, 'value', optionDetails.value); + } + }); + } + setScrollTop() { + const { + selectedValues + } = this; + if (this.showSelectedOptionsFirst || !this.focusSelectedOptionOnOpen || selectedValues.length === 0) { + return; + } + const valuesMapping = {}; + let selectedOptionIndex; + selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.some(d => { + if (valuesMapping[d.value]) { + selectedOptionIndex = d.visibleIndex; + return true; } + return false; + }); + if (selectedOptionIndex) { + this.$optionsContainer.scrollTop = this.optionHeight * selectedOptionIndex; } - /** set methods - end */ + } + /** set methods - end */ - /** get methods - start */ - }, { - key: "getVisibleOptions", - value: function getVisibleOptions() { - return this.visibleOptions || []; - } - }, { - key: "getValue", - value: function getValue() { - var value; - if (this.multiple) { - value = this.useGroupValue ? this.getGroupValue() : this.selectedValues; - } else { - value = this.selectedValues[0] || ''; + /** get methods - start */ + getVisibleOptions() { + return this.visibleOptions || []; + } + getValue() { + let value; + if (this.multiple) { + value = this.useGroupValue ? this.getGroupValue() : this.selectedValues; + } else { + value = this.selectedValues[0] || ''; + } + return Utils.normalizeValues(value); + } + getGroupValue() { + const selectedValues = []; + const selectedGroups = {}; + this.options.forEach(d => { + if (!d.isSelected) { + return; } - return Utils.normalizeValues(value); - } - }, { - key: "getGroupValue", - value: function getGroupValue() { - var selectedValues = []; - var selectedGroups = {}; - this.options.forEach(function (d) { - if (!d.isSelected) { - return; - } - var value = d.value; - if (d.isGroupTitle) { - if (value) { - selectedGroups[d.index] = true; - selectedValues.push(value); - } - } else if (selectedGroups[d.groupIndex] !== true) { + const { + value + } = d; + if (d.isGroupTitle) { + if (value) { + selectedGroups[d.index] = true; selectedValues.push(value); } - }); - return selectedValues; - } - }, { - key: "getInputValue", - value: function getInputValue(preparedValue) { - var value = preparedValue; - if (value && value.length) { - if (this.setValueAsArray && this.multiple) { - value = JSON.stringify(value); - } - } else { - value = this.emptyValue; + } else if (selectedGroups[d.groupIndex] !== true) { + selectedValues.push(value); } - return value; - } - }, { - key: "getFirstVisibleOptionIndex", - value: function getFirstVisibleOptionIndex() { - return Math.ceil(this.$optionsContainer.scrollTop / this.optionHeight); - } - }, { - key: "getVisibleStartIndex", - value: function getVisibleStartIndex() { - var firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); - var startIndex = firstVisibleOptionIndex - this.halfOptionsCount; - if (startIndex < 0) { - startIndex = 0; + }); + return selectedValues; + } + getInputValue(preparedValue) { + let value = preparedValue; + if (value && value.length) { + if (this.setValueAsArray && this.multiple) { + value = JSON.stringify(value); } - return startIndex; - } - }, { - key: "getTooltipAttrText", - value: function getTooltipAttrText(text) { - var ellipsisOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var allowHtml = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var tootltipText = Utils.containsHTML(text) ? Utils.replaceDoubleQuotesWithHTML(text) : text; - var data = { - 'data-tooltip': tootltipText || '', - 'data-tooltip-enter-delay': this.tooltipEnterDelay, - 'data-tooltip-z-index': this.zIndex, - 'data-tooltip-font-size': this.tooltipFontSize, - 'data-tooltip-alignment': this.tooltipAlignment, - 'data-tooltip-max-width': this.tooltipMaxWidth, - 'data-tooltip-ellipsis-only': ellipsisOnly, - 'data-tooltip-allow-html': allowHtml - }; - return DomUtils.getAttributesText(data); + } else { + value = this.emptyValue; + } + return value; + } + getFirstVisibleOptionIndex() { + return Math.ceil(this.$optionsContainer.scrollTop / this.optionHeight); + } + getVisibleStartIndex() { + const firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); + let startIndex = firstVisibleOptionIndex - this.halfOptionsCount; + if (startIndex < 0) { + startIndex = 0; } + return startIndex; + } + getTooltipAttrText(text, ellipsisOnly = false, allowHtml = false) { + const tootltipText = Utils.containsHTML(text) ? Utils.replaceDoubleQuotesWithHTML(text) : text; + const data = { + 'data-tooltip': tootltipText || '', + 'data-tooltip-enter-delay': this.tooltipEnterDelay, + 'data-tooltip-z-index': this.zIndex, + 'data-tooltip-font-size': this.tooltipFontSize, + 'data-tooltip-alignment': this.tooltipAlignment, + 'data-tooltip-max-width': this.tooltipMaxWidth, + 'data-tooltip-ellipsis-only': ellipsisOnly, + 'data-tooltip-allow-html': allowHtml + }; + return DomUtils.getAttributesText(data); + } - /** - * @param {any} data - * @returns {any} - */ - }, { - key: "getOptionObj", - value: function getOptionObj(data) { - if (!data) { - return undefined; - } - var getString = Utils.getString; - var secureText = this.secureText.bind(this); - var value = secureText(getString(data.value)); - var label = secureText(getString(data.label)); - var description = secureText(getString(data.description)); - return { - index: data.index, - value: value, - valueNormalized: value.toLowerCase(), - label: label, - labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), - description: description, - descriptionNormalized: this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(), - alias: this.getAlias(data.alias), - isCurrentNew: data.isCurrentNew || false, - isNew: data.isNew || false, - isVisible: true - }; + /** + * @param {any} data + * @returns {any} + */ + getOptionObj(data) { + if (!data) { + return undefined; + } + const { + getString + } = Utils; + const secureText = this.secureText.bind(this); + const value = secureText(getString(data.value)); + const label = secureText(getString(data.label)); + const description = secureText(getString(data.description)); + return { + index: data.index, + value, + valueNormalized: value.toLowerCase(), + label, + labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), + description, + descriptionNormalized: this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(), + alias: this.getAlias(data.alias), + isCurrentNew: data.isCurrentNew || false, + isNew: data.isNew || false, + isVisible: true + }; + } + getNewOption() { + const lastOption = this.options[this.lastOptionIndex]; + if (!lastOption || !lastOption.isCurrentNew) { + return undefined; } - }, { - key: "getNewOption", - value: function getNewOption() { - var lastOption = this.options[this.lastOptionIndex]; - if (!lastOption || !lastOption.isCurrentNew) { - return undefined; + return lastOption; + } + getOptionIndex(value) { + let index; + this.options.some(d => { + if (d.value === value) { + index = d.index; + return true; } - return lastOption; - } - }, { - key: "getOptionIndex", - value: function getOptionIndex(value) { - var index; - this.options.some(function (d) { - if (d.value === value) { - index = d.index; - return true; - } - return false; - }); - return index; + return false; + }); + return index; + } + getNewValue() { + const valuesMapping = {}; + this.newValues.forEach(d => { + valuesMapping[d] = true; + }); + const result = this.selectedValues.filter(d => valuesMapping[d] === true); + return this.multiple ? result : result[0]; + } + getAlias(alias) { + let result = alias; + if (result) { + if (Array.isArray(result)) { + result = result.join(','); + } else { + result = result.toString().trim(); + } + result = result.toLowerCase(); } - }, { - key: "getNewValue", - value: function getNewValue() { - var valuesMapping = {}; - this.newValues.forEach(function (d) { - valuesMapping[d] = true; - }); - var result = this.selectedValues.filter(function (d) { - return valuesMapping[d] === true; - }); - return this.multiple ? result : result[0]; - } - }, { - key: "getAlias", - value: function getAlias(alias) { - var result = alias; - if (result) { - if (Array.isArray(result)) { - result = result.join(','); + return result || ''; + } + getDisplayValue() { + const displayValues = []; + this.options.forEach(d => { + if (d.isSelected) { + displayValues.push(d.label); + } + }); + return this.multiple ? displayValues : displayValues[0] || ''; + } + getSelectedOptions({ + fullDetails = false, + keepSelectionOrder = false + } = {}) { + const { + valueKey, + labelKey, + selectedValues + } = this; + const selectedOptions = []; + this.options.forEach(d => { + if (d.isSelected && !d.isGroupTitle) { + if (fullDetails) { + selectedOptions.push(d); } else { - result = result.toString().trim(); - } - result = result.toLowerCase(); - } - return result || ''; - } - }, { - key: "getDisplayValue", - value: function getDisplayValue() { - var displayValues = []; - this.options.forEach(function (d) { - if (d.isSelected) { - displayValues.push(d.label); - } - }); - return this.multiple ? displayValues : displayValues[0] || ''; - } - }, { - key: "getSelectedOptions", - value: function getSelectedOptions() { - var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref3$fullDetails = _ref3.fullDetails, - fullDetails = _ref3$fullDetails === void 0 ? false : _ref3$fullDetails, - _ref3$keepSelectionOr = _ref3.keepSelectionOrder, - keepSelectionOrder = _ref3$keepSelectionOr === void 0 ? false : _ref3$keepSelectionOr; - var valueKey = this.valueKey, - labelKey = this.labelKey, - selectedValues = this.selectedValues; - var selectedOptions = []; - this.options.forEach(function (d) { - if (d.isSelected && !d.isGroupTitle) { - if (fullDetails) { - selectedOptions.push(d); - } else { - var data = _defineProperty(_defineProperty({}, valueKey, d.value), labelKey, d.label); - if (d.isNew) { - data.isNew = true; - } - if (d.customData) { - data.customData = d.customData; - } - selectedOptions.push(data); + const data = { + [valueKey]: d.value, + [labelKey]: d.label + }; + if (d.isNew) { + data.isNew = true; + } + if (d.customData) { + data.customData = d.customData; } + selectedOptions.push(data); } - }); - if (keepSelectionOrder) { - var valuesOrder = {}; - selectedValues.forEach(function (d, i) { - valuesOrder[d] = i; - }); - selectedOptions.sort(function (a, b) { - return valuesOrder[a.value] - valuesOrder[b.value]; - }); } - return this.multiple || fullDetails ? selectedOptions : selectedOptions[0]; - } - }, { - key: "getDisabledOptions", - value: function getDisabledOptions() { - var valueKey = this.valueKey, - labelKey = this.labelKey, - disabledOptions = this.disabledOptions; - var disabledOptionsValueMapping = {}; - var result = []; - disabledOptions.forEach(function (value) { - disabledOptionsValueMapping[value] = true; - }); - this.options.forEach(function (_ref4) { - var value = _ref4.value, - label = _ref4.label; - if (disabledOptionsValueMapping[value]) { - result.push(_defineProperty(_defineProperty({}, valueKey, value), labelKey, label)); - } + }); + if (keepSelectionOrder) { + const valuesOrder = {}; + selectedValues.forEach((d, i) => { + valuesOrder[d] = i; }); - return result; + selectedOptions.sort((a, b) => valuesOrder[a.value] - valuesOrder[b.value]); } - }, { - key: "getVisibleOptionGroupsMapping", - value: function getVisibleOptionGroupsMapping(searchValue) { - var options = this.options; - var result = {}; - var isOptionVisible = this.isOptionVisible.bind(this); - options = this.structureOptionGroup(options); - options.forEach(function (d) { - result[d.index] = d.options.some(function (e) { - return isOptionVisible({ - data: e, - searchValue: searchValue - }).isVisible; + return this.multiple || fullDetails ? selectedOptions : selectedOptions[0]; + } + getDisabledOptions() { + const { + valueKey, + labelKey, + disabledOptions + } = this; + const disabledOptionsValueMapping = {}; + const result = []; + disabledOptions.forEach(value => { + disabledOptionsValueMapping[value] = true; + }); + this.options.forEach(({ + value, + label + }) => { + if (disabledOptionsValueMapping[value]) { + result.push({ + [valueKey]: value, + [labelKey]: label }); - }); - return result; - } - }, { - key: "getOptionsCount", - value: function getOptionsCount(count) { - var result; - if (this.showAsPopup) { - var availableHeight = window.innerHeight * 80 / 100 - dropboxCloseButtonFullHeight; - if (this.hasSearchContainer) { - availableHeight -= searchHeight; - } - result = Math.floor(availableHeight / this.optionHeight); - } else { - result = parseInt(count); - } - return result; - } - }, { - key: "getOptionsHeight", - value: function getOptionsHeight() { - return "".concat(this.optionsCount * this.optionHeight, "px"); - } - - /** getting next/prev valid option element */ - }, { - key: "getSibling", - value: function getSibling($ele, direction) { - var propName = direction === 'next' ? 'nextElementSibling' : 'previousElementSibling'; - var $sibling = $ele; - do { - if ($sibling) { - $sibling = $sibling[propName]; - } - } while (DomUtils.hasClass($sibling, 'disabled') || DomUtils.hasClass($sibling, 'group-title')); - return $sibling; - } - }, { - key: "getUniqueId", - value: function getUniqueId() { - var uniqueId = Utils.getRandomInt(10000); - var isAlreadyUsed = document.querySelector("#vscomp-ele-wrapper-".concat(uniqueId)); - if (isAlreadyUsed) { - return this.getUniqueId(); - } - return uniqueId; - } - /** get methods - end */ - }, { - key: "initDropboxPopover", - value: function initDropboxPopover() { - var data = { - ele: this.$ele, - target: this.$dropboxContainer, - position: this.position, - zIndex: this.zIndex, - margin: 4, - transitionDistance: 30, - hideArrowIcon: true, - disableManualAction: true, - disableUpdatePosition: !this.hasDropboxWrapper, - updatePositionThrottle: this.updatePositionThrottle, - showDuration: this.showDuration, - hideDuration: this.hideDuration, - afterShow: this.afterShowPopper.bind(this), - afterHide: this.afterHidePopper.bind(this) - }; - this.dropboxPopover = new PopoverComponent(data); - } - }, { - key: "openDropbox", - value: function openDropbox(isSilent) { - var _this11 = this; - // Set this instance as the last interacted one immediately - VirtualSelect.lastInteractedInstance = this; - var originalTransition = ''; - // Disable transitions for programmatic opening - if (!isSilent) { - // Store original transition - originalTransition = this.$dropboxContainer.style.transition; - this.$dropboxContainer.style.transition = 'none'; } - // Perform the open operation - this.isSilentOpen = isSilent; - - // Close all other open instances first - VirtualSelect.openInstances.forEach(function (instance) { - if (instance !== _this11) { - // Don't focus when closing due to another dropdown being opened - var instanceObj = instance; - instanceObj.shouldFocusWrapperOnClose = false; - instanceObj.closeDropbox(true); // silent close - } - }); + }); + return result; + } + getVisibleOptionGroupsMapping(searchValue) { + let { + options + } = this; + const result = {}; + const isOptionVisible = this.isOptionVisible.bind(this); + options = this.structureOptionGroup(options); + options.forEach(d => { + result[d.index] = d.options.some(e => isOptionVisible({ + data: e, + searchValue + }).isVisible); + }); + return result; + } + getOptionsCount(count) { + let result; + if (this.showAsPopup) { + let availableHeight = window.innerHeight * 80 / 100 - dropboxCloseButtonFullHeight; + if (this.hasSearchContainer) { + availableHeight -= searchHeight; + } + result = Math.floor(availableHeight / this.optionHeight); + } else { + result = parseInt(count); + } + return result; + } + getOptionsHeight() { + return `${this.optionsCount * this.optionHeight}px`; + } - // Add to open instances - VirtualSelect.openInstances.add(this); - DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxWrapper, 'hidden', false); - DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxContainerTop, 'hidden', false); - DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', false); - if (isSilent) { - DomUtils.setStyle(this.$dropboxContainer, 'display', 'inline-flex'); - } else { - DomUtils.dispatchEvent(this.$ele, 'beforeOpen'); - DomUtils.setAria(this.$wrapper, 'expanded', true); - } - this.setDropboxWrapperWidth(); - DomUtils.removeClass(this.$allWrappers, 'closed'); - DomUtils.changeTabIndex(this.$allWrappers, 0); - if (!isSilent) { - // Force synchronous layout and style calculation - // Trigger reflow - this.$dropboxContainer.offsetHeight; // eslint-disable-line no-unused-expressions - // Restore transitions immediately after reflow - this.$dropboxContainer.style.transition = originalTransition; - } - if (this.dropboxPopover && !isSilent) { - this.dropboxPopover.show(); - } else { - this.afterShowPopper(); + /** getting next/prev valid option element */ + getSibling($ele, direction) { + const propName = direction === 'next' ? 'nextElementSibling' : 'previousElementSibling'; + let $sibling = $ele; + do { + if ($sibling) { + $sibling = $sibling[propName]; } + } while (DomUtils.hasClass($sibling, 'disabled') || DomUtils.hasClass($sibling, 'group-title')); + return $sibling; + } + getUniqueId() { + const uniqueId = Utils.getRandomInt(10000); + const isAlreadyUsed = document.querySelector(`#vscomp-ele-wrapper-${uniqueId}`); + if (isAlreadyUsed) { + return this.getUniqueId(); } - }, { - key: "afterShowPopper", - value: function afterShowPopper() { - var isSilent = this.isSilentOpen; - this.isSilentOpen = false; - if (!isSilent) { - this.moveSelectedOptionsFirst(); - this.setScrollTop(); - DomUtils.addClass(this.$allWrappers, 'focused'); - if (this.showAsPopup) { - DomUtils.addClass(this.$body, 'vscomp-popup-active'); - this.isPopupActive = true; - } else { - this.focusElementOnOpen(); - } - DomUtils.dispatchEvent(this.$ele, 'afterOpen'); - } + return uniqueId; + } + /** get methods - end */ + + initDropboxPopover() { + const data = { + ele: this.$ele, + target: this.$dropboxContainer, + position: this.position, + zIndex: this.zIndex, + margin: 4, + transitionDistance: 30, + hideArrowIcon: true, + disableManualAction: true, + disableUpdatePosition: !this.hasDropboxWrapper, + updatePositionThrottle: this.updatePositionThrottle, + showDuration: this.showDuration, + hideDuration: this.hideDuration, + afterShow: this.afterShowPopper.bind(this), + afterHide: this.afterHidePopper.bind(this) + }; + this.dropboxPopover = new PopoverComponent(data); + } + openDropbox(isSilent) { + // Set this instance as the last interacted one immediately + VirtualSelect.lastInteractedInstance = this; + let originalTransition = ''; + // Disable transitions for programmatic opening + if (!isSilent) { + // Store original transition + originalTransition = this.$dropboxContainer.style.transition; + this.$dropboxContainer.style.transition = 'none'; + } + // Perform the open operation + this.isSilentOpen = isSilent; + + // Close all other open instances first + VirtualSelect.openInstances.forEach(instance => { + if (instance !== this) { + // Don't focus when closing due to another dropdown being opened + const instanceObj = instance; + instanceObj.shouldFocusWrapperOnClose = false; + instanceObj.closeDropbox(true); // silent close + } + }); + + // Add to open instances + VirtualSelect.openInstances.add(this); + DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxWrapper, 'hidden', false); + DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxContainerTop, 'hidden', false); + DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', false); + if (isSilent) { + DomUtils.setStyle(this.$dropboxContainer, 'display', 'inline-flex'); + } else { + DomUtils.dispatchEvent(this.$ele, 'beforeOpen'); + DomUtils.setAria(this.$wrapper, 'expanded', true); + } + this.setDropboxWrapperWidth(); + DomUtils.removeClass(this.$allWrappers, 'closed'); + DomUtils.changeTabIndex(this.$allWrappers, 0); + if (!isSilent) { + // Force synchronous layout and style calculation + // Trigger reflow + this.$dropboxContainer.offsetHeight; // eslint-disable-line no-unused-expressions + // Restore transitions immediately after reflow + this.$dropboxContainer.style.transition = originalTransition; + } + if (this.dropboxPopover && !isSilent) { + this.dropboxPopover.show(); + } else { + this.afterShowPopper(); } - }, { - key: "closeDropbox", - value: function closeDropbox(isSilent) { - this.isSilentClose = isSilent; - - // Remove from open instances - VirtualSelect.openInstances["delete"](this); - if (this.isOpened() === false) { - return; - } - if (this.keepAlwaysOpen) { - this.removeOptionFocus(); - return; - } - - // Return focus to wrapper only when no other meaningful element currently has focus - var active = document.activeElement; - var withinComponent = active && this.$wrapper.contains(active) || this.hasDropboxWrapper && active && this.$dropboxWrapper.contains(active); - var shouldRefocus = this.shouldFocusWrapperOnClose && VirtualSelect.lastInteractedInstance === this && !isSilent && (active === null || active === document.body || withinComponent); - if (shouldRefocus) { - this.$wrapper.focus(); - } - if (isSilent) { - DomUtils.setStyle(this.$dropboxContainer, 'display', ''); - } else { - DomUtils.dispatchEvent(this.$ele, 'beforeClose'); - DomUtils.setAria(this.$wrapper, 'expanded', false); - DomUtils.setAria(this.$wrapper, 'activedescendant', ''); - // Also clear aria-activedescendant on the listbox container - DomUtils.setAria(this.$dropboxContainer, 'activedescendant', ''); - } - if (this.dropboxPopover && !isSilent) { - this.dropboxPopover.hide(); - DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); - DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); - DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } + afterShowPopper() { + const isSilent = this.isSilentOpen; + this.isSilentOpen = false; + if (!isSilent) { + this.moveSelectedOptionsFirst(); + this.setScrollTop(); + DomUtils.addClass(this.$allWrappers, 'focused'); + if (this.showAsPopup) { + DomUtils.addClass(this.$body, 'vscomp-popup-active'); + this.isPopupActive = true; } else { - this.afterHidePopper(); + this.focusElementOnOpen(); } - this.setSearchValue(''); + DomUtils.dispatchEvent(this.$ele, 'afterOpen'); } - }, { - key: "afterHidePopper", - value: function afterHidePopper() { - var isSilent = this.isSilentClose; - this.isSilentClose = false; - DomUtils.removeClass(this.$allWrappers, 'focused'); - this.removeOptionFocus(); - if (!isSilent && this.isPopupActive) { - DomUtils.removeClass(this.$body, 'vscomp-popup-active'); - this.isPopupActive = false; - } - DomUtils.addClass(this.$allWrappers, 'closed'); - if (!isSilent) { - DomUtils.dispatchEvent(this.$ele, 'afterClose'); - } + } + closeDropbox(isSilent) { + this.isSilentClose = isSilent; - // Reset for next close - this.shouldFocusWrapperOnClose = true; + // Remove from open instances + VirtualSelect.openInstances.delete(this); + if (this.isOpened() === false) { + return; + } + if (this.keepAlwaysOpen) { + this.removeOptionFocus(); + return; + } - // Restore accessibility attributes that were inadvertently removed + // Return focus to wrapper only when no other meaningful element currently has focus + const active = document.activeElement; + const withinComponent = active && this.$wrapper.contains(active) || this.hasDropboxWrapper && active && this.$dropboxWrapper.contains(active); + const shouldRefocus = this.shouldFocusWrapperOnClose && VirtualSelect.lastInteractedInstance === this && !isSilent && (active === null || active === document.body || withinComponent); + if (shouldRefocus) { + this.$wrapper.focus(); + } + if (isSilent) { + DomUtils.setStyle(this.$dropboxContainer, 'display', ''); + } else { + DomUtils.dispatchEvent(this.$ele, 'beforeClose'); + DomUtils.setAria(this.$wrapper, 'expanded', false); + DomUtils.setAria(this.$wrapper, 'activedescendant', ''); + // Also clear aria-activedescendant on the listbox container + DomUtils.setAria(this.$dropboxContainer, 'activedescendant', ''); + } + if (this.dropboxPopover && !isSilent) { + this.dropboxPopover.hide(); DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } else { + this.afterHidePopper(); } - }, { - key: "moveSelectedOptionsFirst", - value: function moveSelectedOptionsFirst() { - if (!this.$optionsContainer.scrollTop || !this.selectedValues.length) { - this.setVisibleOptions(); - } - if (!this.showSelectedOptionsFirst) { - return; - } - this.setSortedOptions(); - this.scrollToTop(); + this.setSearchValue(''); + } + afterHidePopper() { + const isSilent = this.isSilentClose; + this.isSilentClose = false; + DomUtils.removeClass(this.$allWrappers, 'focused'); + this.removeOptionFocus(); + if (!isSilent && this.isPopupActive) { + DomUtils.removeClass(this.$body, 'vscomp-popup-active'); + this.isPopupActive = false; + } + DomUtils.addClass(this.$allWrappers, 'closed'); + if (!isSilent) { + DomUtils.dispatchEvent(this.$ele, 'afterClose'); + } + + // Reset for next close + this.shouldFocusWrapperOnClose = true; + + // Restore accessibility attributes that were inadvertently removed + DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); + DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); + DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } + moveSelectedOptionsFirst() { + if (!this.$optionsContainer.scrollTop || !this.selectedValues.length) { this.setVisibleOptions(); } - }, { - key: "toggleDropbox", - value: function toggleDropbox() { - VirtualSelect.lastInteractedInstance = this; - if (this.isOpened()) { - this.closeDropbox(); - } else { - this.openDropbox(); - } + if (!this.showSelectedOptionsFirst) { + return; } - }, { - key: "updatePosition", - value: function updatePosition() { - if (!this.dropboxPopover || !this.isOpened()) { - return; - } - this.$ele.updatePosition(); - } - }, { - key: "isOpened", - value: function isOpened() { - return !DomUtils.hasClass(this.$wrapper, 'closed'); - } - }, { - key: "focusSearchInput", - value: function focusSearchInput() { - var $ele = this.$searchInput; - if ($ele) { - $ele.focus(); - } + this.setSortedOptions(); + this.scrollToTop(); + this.setVisibleOptions(); + } + toggleDropbox() { + VirtualSelect.lastInteractedInstance = this; + if (this.isOpened()) { + this.closeDropbox(); + } else { + this.openDropbox(); } - }, { - key: "focusElementOnOpen", - value: function focusElementOnOpen() { - var $ele = this.$searchInput; - var hasNoOptions = !this.options.length && !this.hasServerSearch; - if ($ele) { - if (hasNoOptions && !this.allowNewOption) { - DomUtils.setAttr($ele, 'disabled', ''); - this.$noOptions.focus(); - } else { - $ele.removeAttribute('disabled'); - $ele.focus(); - } + } + updatePosition() { + if (!this.dropboxPopover || !this.isOpened()) { + return; + } + this.$ele.updatePosition(); + } + isOpened() { + return !DomUtils.hasClass(this.$wrapper, 'closed'); + } + focusSearchInput() { + const $ele = this.$searchInput; + if ($ele) { + $ele.focus(); + } + } + focusElementOnOpen() { + const $ele = this.$searchInput; + const hasNoOptions = !this.options.length && !this.hasServerSearch; + if ($ele) { + if (hasNoOptions && !this.allowNewOption) { + DomUtils.setAttr($ele, 'disabled', ''); + this.$noOptions.focus(); } else { - var $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); - var optIndex = DomUtils.getData($focusableEle, 'index'); - if (optIndex !== undefined) { - this.focusOption({ - direction: 'next' - }); - } else if ($focusableEle) { - $focusableEle.focus(); - } else { - this.focusFirstVisibleOption(); - } + $ele.removeAttribute('disabled'); + $ele.focus(); } - } - }, { - key: "focusFirstVisibleOption", - value: function focusFirstVisibleOption() { - var $focusableEle = this.$optionsContainer.querySelector("[data-index='".concat(this.getFirstVisibleOptionIndex(), "']")); - if ($focusableEle) { - if (DomUtils.hasClass($focusableEle, 'group-title')) { - $focusableEle = this.getSibling($focusableEle, 'next'); - } - DomUtils.setAttr($focusableEle, 'tabindex', '0'); - this.$optionsContainer.scrollTop = this.optionHeight * this.getFirstVisibleOptionIndex(); + } else { + const $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); + const optIndex = DomUtils.getData($focusableEle, 'index'); + if (optIndex !== undefined) { this.focusOption({ - focusFirst: true + direction: 'next' }); + } else if ($focusableEle) { $focusableEle.focus(); } else { - $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); - if ($focusableEle) { - $focusableEle.focus(); - } + this.focusFirstVisibleOption(); } } - }, { - key: "focusOption", - value: function focusOption() { - var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - direction = _ref5.direction, - $option = _ref5.$option, - focusFirst = _ref5.focusFirst; - var $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); - var $newFocusedEle; - if ($option) { - $newFocusedEle = $option; - } else if (!$focusedEle || focusFirst) { - /* if no element on focus choose first visible one */ - var firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); - $newFocusedEle = this.$dropboxContainer.querySelector(".vscomp-option[data-visible-index=\"".concat(firstVisibleOptionIndex, "\"]")); - if (DomUtils.hasClass($newFocusedEle, 'disabled') || DomUtils.hasClass($newFocusedEle, 'group-title')) { - $newFocusedEle = this.getSibling($newFocusedEle, 'next'); - } - } else { - $newFocusedEle = this.getSibling($focusedEle, direction); - } - if ($newFocusedEle && $newFocusedEle !== $focusedEle) { - if ($focusedEle) { - this.toggleOptionFocusedState($focusedEle, false); - } - this.toggleOptionFocusedState($newFocusedEle, true); - this.toggleFocusedProp(DomUtils.getData($newFocusedEle, 'index'), true); - this.moveFocusedOptionToView($newFocusedEle); + } + focusFirstVisibleOption() { + let $focusableEle = this.$optionsContainer.querySelector(`[data-index='${this.getFirstVisibleOptionIndex()}']`); + if ($focusableEle) { + if (DomUtils.hasClass($focusableEle, 'group-title')) { + $focusableEle = this.getSibling($focusableEle, 'next'); + } + DomUtils.setAttr($focusableEle, 'tabindex', '0'); + this.$optionsContainer.scrollTop = this.optionHeight * this.getFirstVisibleOptionIndex(); + this.focusOption({ + focusFirst: true + }); + $focusableEle.focus(); + } else { + $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); + if ($focusableEle) { + $focusableEle.focus(); } } - }, { - key: "moveFocusedOptionToView", - value: function moveFocusedOptionToView($ele) { - var $focusedEle = $ele || this.$dropboxContainer.querySelector('.vscomp-option.focused'); - if (!$focusedEle) { - return; - } - var newScrollTop; - var containerRect = this.$optionsContainer.getBoundingClientRect(); - var optionRect = $focusedEle.getBoundingClientRect(); - var containerTop = containerRect.top; - var containerBottom = containerRect.bottom; - var containerHeight = containerRect.height; - var optionTop = optionRect.top; - var optionBottom = optionRect.bottom; - var optionHeight = optionRect.height; - var optionOffsetTop = $focusedEle.offsetTop; - var optionsTop = DomUtils.getData(this.$options, 'top', 'number'); - - /* if option hidden on top */ - if (containerTop > optionTop) { - newScrollTop = optionOffsetTop + optionsTop; - } else if (containerBottom < optionBottom) { - /* if option hidden on bottom */ - newScrollTop = optionOffsetTop - containerHeight + optionHeight + optionsTop; - } - if (newScrollTop !== undefined) { - this.$optionsContainer.scrollTop = newScrollTop; - } + } + focusOption({ + direction, + $option, + focusFirst + } = {}) { + const $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); + let $newFocusedEle; + if ($option) { + $newFocusedEle = $option; + } else if (!$focusedEle || focusFirst) { + /* if no element on focus choose first visible one */ + const firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); + $newFocusedEle = this.$dropboxContainer.querySelector(`.vscomp-option[data-visible-index="${firstVisibleOptionIndex}"]`); + if (DomUtils.hasClass($newFocusedEle, 'disabled') || DomUtils.hasClass($newFocusedEle, 'group-title')) { + $newFocusedEle = this.getSibling($newFocusedEle, 'next'); + } + } else { + $newFocusedEle = this.getSibling($focusedEle, direction); + } + if ($newFocusedEle && $newFocusedEle !== $focusedEle) { + if ($focusedEle) { + this.toggleOptionFocusedState($focusedEle, false); + } + this.toggleOptionFocusedState($newFocusedEle, true); + this.toggleFocusedProp(DomUtils.getData($newFocusedEle, 'index'), true); + this.moveFocusedOptionToView($newFocusedEle); } - }, { - key: "removeOptionFocus", - value: function removeOptionFocus() { - var $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); - if (!$focusedEle) { - return; - } - this.toggleOptionFocusedState($focusedEle, false); - this.toggleFocusedProp(null); - } - }, { - key: "selectOption", - value: function selectOption($ele) { - var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - event = _ref6.event; - if (!$ele) { + } + moveFocusedOptionToView($ele) { + const $focusedEle = $ele || this.$dropboxContainer.querySelector('.vscomp-option.focused'); + if (!$focusedEle) { + return; + } + let newScrollTop; + const containerRect = this.$optionsContainer.getBoundingClientRect(); + const optionRect = $focusedEle.getBoundingClientRect(); + const containerTop = containerRect.top; + const containerBottom = containerRect.bottom; + const containerHeight = containerRect.height; + const optionTop = optionRect.top; + const optionBottom = optionRect.bottom; + const optionHeight = optionRect.height; + const optionOffsetTop = $focusedEle.offsetTop; + const optionsTop = DomUtils.getData(this.$options, 'top', 'number'); + + /* if option hidden on top */ + if (containerTop > optionTop) { + newScrollTop = optionOffsetTop + optionsTop; + } else if (containerBottom < optionBottom) { + /* if option hidden on bottom */ + newScrollTop = optionOffsetTop - containerHeight + optionHeight + optionsTop; + } + if (newScrollTop !== undefined) { + this.$optionsContainer.scrollTop = newScrollTop; + } + } + removeOptionFocus() { + const $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); + if (!$focusedEle) { + return; + } + this.toggleOptionFocusedState($focusedEle, false); + this.toggleFocusedProp(null); + } + selectOption($ele, { + event + } = {}) { + if (!$ele) { + return; + } + const isAdding = !DomUtils.hasClass($ele, 'selected'); + if (isAdding) { + if (this.multiple && this.isMaxValuesSelected) { return; } - var isAdding = !DomUtils.hasClass($ele, 'selected'); - if (isAdding) { - if (this.multiple && this.isMaxValuesSelected) { - return; + } else if (!this.multiple) { + /** on selecting same value in single select */ + this.closeDropbox(); + return; + } + let { + selectedValues + } = this; + const selectedValue = DomUtils.getData($ele, 'value'); + const selectedIndex = DomUtils.getData($ele, 'index', 'number'); + const isNewOption = DomUtils.hasClass($ele, 'current-new'); + let shouldSelectRange = false; + const { + lastSelectedOptionIndex + } = this; + this.lastSelectedOptionIndex = null; + this.toggleSelectedProp(selectedIndex, isAdding); + if (isAdding) { + if (this.multiple) { + selectedValues.push(selectedValue); + this.toggleAllOptionsClass(); + this.toggleGroupOptionsParent($ele); + if (event && event.shiftKey) { + shouldSelectRange = true; + } + } else { + if (selectedValues.length) { + this.toggleSelectedProp(this.getOptionIndex(selectedValues[0]), false); + } + selectedValues = [selectedValue]; + const $prevSelectedOption = this.$dropboxContainer.querySelector('.vscomp-option.selected'); + if ($prevSelectedOption) { + this.toggleOptionSelectedState($prevSelectedOption, false); } - } else if (!this.multiple) { - /** on selecting same value in single select */ this.closeDropbox(); - return; - } - var selectedValues = this.selectedValues; - var selectedValue = DomUtils.getData($ele, 'value'); - var selectedIndex = DomUtils.getData($ele, 'index', 'number'); - var isNewOption = DomUtils.hasClass($ele, 'current-new'); - var shouldSelectRange = false; - var lastSelectedOptionIndex = this.lastSelectedOptionIndex; - this.lastSelectedOptionIndex = null; - this.toggleSelectedProp(selectedIndex, isAdding); - if (isAdding) { - if (this.multiple) { - selectedValues.push(selectedValue); - this.toggleAllOptionsClass(); - this.toggleGroupOptionsParent($ele); - if (event && event.shiftKey) { - shouldSelectRange = true; - } - } else { - if (selectedValues.length) { - this.toggleSelectedProp(this.getOptionIndex(selectedValues[0]), false); - } - selectedValues = [selectedValue]; - var $prevSelectedOption = this.$dropboxContainer.querySelector('.vscomp-option.selected'); - if ($prevSelectedOption) { - this.toggleOptionSelectedState($prevSelectedOption, false); - } - this.closeDropbox(); - if (!isNewOption) { - this.setSearchValue(''); - } + if (!isNewOption) { + this.setSearchValue(''); } - this.lastSelectedOptionIndex = selectedIndex; - this.toggleOptionSelectedState($ele); - } else if (this.multiple) { - this.toggleOptionSelectedState($ele); - Utils.removeItemFromArray(selectedValues, selectedValue); - this.toggleAllOptionsClass(false); - this.toggleGroupOptionsParent($ele, false); - } - if (isNewOption) { - this.beforeSelectNewValue(selectedValue); - } - this.setValue(selectedValues); - if (shouldSelectRange) { - this.selectRangeOptions(lastSelectedOptionIndex, selectedIndex); } + this.lastSelectedOptionIndex = selectedIndex; + this.toggleOptionSelectedState($ele); + } else if (this.multiple) { + this.toggleOptionSelectedState($ele); + Utils.removeItemFromArray(selectedValues, selectedValue); + this.toggleAllOptionsClass(false); + this.toggleGroupOptionsParent($ele, false); + } + if (isNewOption) { + this.beforeSelectNewValue(selectedValue); } - }, { - key: "selectFocusedOption", - value: function selectFocusedOption() { - this.selectOption(this.$dropboxContainer.querySelector('.vscomp-option.focused')); + this.setValue(selectedValues); + if (shouldSelectRange) { + this.selectRangeOptions(lastSelectedOptionIndex, selectedIndex); } - }, { - key: "selectRangeOptions", - value: function selectRangeOptions(lastSelectedOptionIndex, selectedIndex) { - var _this12 = this; - if (typeof lastSelectedOptionIndex !== 'number' || this.maxValues) { + } + selectFocusedOption() { + this.selectOption(this.$dropboxContainer.querySelector('.vscomp-option.focused')); + } + selectRangeOptions(lastSelectedOptionIndex, selectedIndex) { + if (typeof lastSelectedOptionIndex !== 'number' || this.maxValues) { + return; + } + const { + selectedValues, + hasOptionGroup + } = this; + let groupIndexes = {}; + let startIndex; + let endIndex; + if (lastSelectedOptionIndex < selectedIndex) { + startIndex = lastSelectedOptionIndex; + endIndex = selectedIndex; + } else { + startIndex = selectedIndex; + endIndex = lastSelectedOptionIndex; + } + this.options.forEach(d => { + if (d.isDisabled || d.isGroupTitle || !d.isVisible || d.isSelected) { return; } - var selectedValues = this.selectedValues, - hasOptionGroup = this.hasOptionGroup; - var groupIndexes = {}; - var startIndex; - var endIndex; - if (lastSelectedOptionIndex < selectedIndex) { - startIndex = lastSelectedOptionIndex; - endIndex = selectedIndex; - } else { - startIndex = selectedIndex; - endIndex = lastSelectedOptionIndex; - } - this.options.forEach(function (d) { - if (d.isDisabled || d.isGroupTitle || !d.isVisible || d.isSelected) { - return; - } - var index = d.index; - if (index > startIndex && index < endIndex) { - if (hasOptionGroup) { - var groupIndex = d.groupIndex; - if (typeof groupIndex === 'number') { - groupIndexes[groupIndex] = true; - } + const { + index + } = d; + if (index > startIndex && index < endIndex) { + if (hasOptionGroup) { + const { + groupIndex + } = d; + if (typeof groupIndex === 'number') { + groupIndexes[groupIndex] = true; } - - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - selectedValues.push(d.value); } + + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + selectedValues.push(d.value); + } + }); + this.toggleAllOptionsClass(); + this.setValue(selectedValues); + groupIndexes = Object.keys(groupIndexes); + if (groupIndexes.length) { + const toggleGroupTitleProp = this.toggleGroupTitleProp.bind(this); + groupIndexes.forEach(i => { + toggleGroupTitleProp(parseInt(i)); }); - this.toggleAllOptionsClass(); - this.setValue(selectedValues); - groupIndexes = Object.keys(groupIndexes); - if (groupIndexes.length) { - var toggleGroupTitleProp = this.toggleGroupTitleProp.bind(this); - groupIndexes.forEach(function (i) { - toggleGroupTitleProp(parseInt(i)); - }); - } + } - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this12.renderOptions(); - }, 0); - } - }, { - key: "toggleAllOptions", - value: function toggleAllOptions(selectAll) { - if (!this.multiple || this.disableSelectAll) { + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.renderOptions(); + }, 0); + } + toggleAllOptions(selectAll) { + if (!this.multiple || this.disableSelectAll) { + return; + } + const selectingAll = typeof isSelected === 'boolean' ? selectAll : !DomUtils.hasClass(this.$toggleAllCheckbox, 'checked'); + const selectedValues = []; + const { + selectAllOnlyVisible + } = this; + this.options.forEach(d => { + const option = d; + if (option.isDisabled || option.isCurrentNew) { return; } - var selectingAll = typeof isSelected === 'boolean' ? selectAll : !DomUtils.hasClass(this.$toggleAllCheckbox, 'checked'); - var selectedValues = []; - var selectAllOnlyVisible = this.selectAllOnlyVisible; - this.options.forEach(function (d) { - var option = d; - if (option.isDisabled || option.isCurrentNew) { - return; - } - var isVisible = option.isVisible, - isSelected = option.isSelected; + const { + isVisible, + isSelected + } = option; - /** unselected items are */ - if (/** when unselecting all, selectAllOnlyVisible feature disabled or visible items or already unselected items */ - !selectingAll && (!selectAllOnlyVisible || isVisible || !isSelected) || (/** when selecting all, selectAllOnlyVisible feature enabled and hidden items those are not already selected */ - selectingAll && selectAllOnlyVisible && !isVisible && !isSelected)) { - option.isSelected = false; - } else { - option.isSelected = true; - if (!option.isGroupTitle) { - selectedValues.push(option.value); - } + /** unselected items are */ + if (/** when unselecting all, selectAllOnlyVisible feature disabled or visible items or already unselected items */ + !selectingAll && (!selectAllOnlyVisible || isVisible || !isSelected) || (/** when selecting all, selectAllOnlyVisible feature enabled and hidden items those are not already selected */ + selectingAll && selectAllOnlyVisible && !isVisible && !isSelected)) { + option.isSelected = false; + } else { + option.isSelected = true; + if (!option.isGroupTitle) { + selectedValues.push(option.value); } - }); - this.toggleAllOptionsClass(selectingAll); - this.setValue(selectedValues); - this.renderOptions(); - } - }, { - key: "toggleAllOptionsClass", - value: function toggleAllOptionsClass(isAllSelected) { - if (!this.multiple) { - return; - } - var valuePassed = typeof isAllSelected === 'boolean'; - var isAllVisibleSelected = false; - if (!valuePassed) { - // eslint-disable-next-line no-param-reassign - isAllSelected = this.isAllOptionsSelected(); } + }); + this.toggleAllOptionsClass(selectingAll); + this.setValue(selectedValues); + this.renderOptions(); + } + toggleAllOptionsClass(isAllSelected) { + if (!this.multiple) { + return; + } + const valuePassed = typeof isAllSelected === 'boolean'; + let isAllVisibleSelected = false; + if (!valuePassed) { + // eslint-disable-next-line no-param-reassign + isAllSelected = this.isAllOptionsSelected(); + } - /** When all options not selected, checking if all visible options selected - * Also, in a search mode, validate that we still have visible items - */ - if (!isAllSelected && this.selectAllOnlyVisible && this.searchValue !== '' && (this.visibleOptionsCount > 0 || this.searchValue === '')) { - isAllVisibleSelected = this.isAllOptionsSelected(true); - } - DomUtils.toggleClass(this.$toggleAllCheckbox, 'checked', isAllSelected || isAllVisibleSelected); - this.isAllSelected = isAllSelected; - } - }, { - key: "isAllOptionsSelected", - value: function isAllOptionsSelected(visibleOnly) { - var isAllSelected = false; - if (this.options.length && this.selectedValues.length) { - isAllSelected = !this.options.some( - /** - * stop looping if any option is not selected - * for selectAllOnlyVisible case hidden option need not to be selected - */ - function (d) { - return !d.isSelected && !d.isDisabled && !d.isGroupTitle && (!visibleOnly || d.isVisible); - }); - } - return isAllSelected; - } - }, { - key: "isAllGroupOptionsSelected", - value: function isAllGroupOptionsSelected(groupIndex) { - var isAllSelected = false; - if (this.options.length) { - isAllSelected = !this.options.some(function (d) { - return !d.isSelected && !d.isDisabled && !d.isGroupTitle && d.groupIndex === groupIndex; - }); - } - return isAllSelected; + /** When all options not selected, checking if all visible options selected + * Also, in a search mode, validate that we still have visible items + */ + if (!isAllSelected && this.selectAllOnlyVisible && this.searchValue !== '' && (this.visibleOptionsCount > 0 || this.searchValue === '')) { + isAllVisibleSelected = this.isAllOptionsSelected(true); } - }, { - key: "toggleGroupOptionsParent", - value: function toggleGroupOptionsParent($option, isSelected) { - if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$option) { - return; - } - var groupIndex = DomUtils.getData($option, 'groupIndex'); - if (groupIndex !== undefined) { - groupIndex = parseInt(groupIndex); - } - var $group = this.$options.querySelector(".vscomp-option[data-index=\"".concat(groupIndex, "\"]")); - var isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); - this.toggleGroupTitleCheckbox($group, isAllSelected); - this.toggleGroupTitleProp(groupIndex, isAllSelected); - } - }, { - key: "toggleGroupTitleProp", - value: function toggleGroupTitleProp(groupIndex, isSelected) { - var isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); - this.toggleSelectedProp(groupIndex, isAllSelected); - } - }, { - key: "toggleGroupOptions", - value: function toggleGroupOptions($ele, isSelected) { - var _this13 = this; - if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$ele) { + DomUtils.toggleClass(this.$toggleAllCheckbox, 'checked', isAllSelected || isAllVisibleSelected); + this.isAllSelected = isAllSelected; + } + isAllOptionsSelected(visibleOnly) { + let isAllSelected = false; + if (this.options.length && this.selectedValues.length) { + isAllSelected = !this.options.some( + /** + * stop looping if any option is not selected + * for selectAllOnlyVisible case hidden option need not to be selected + */ + d => !d.isSelected && !d.isDisabled && !d.isGroupTitle && (!visibleOnly || d.isVisible)); + } + return isAllSelected; + } + isAllGroupOptionsSelected(groupIndex) { + let isAllSelected = false; + if (this.options.length) { + isAllSelected = !this.options.some(d => !d.isSelected && !d.isDisabled && !d.isGroupTitle && d.groupIndex === groupIndex); + } + return isAllSelected; + } + toggleGroupOptionsParent($option, isSelected) { + if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$option) { + return; + } + let groupIndex = DomUtils.getData($option, 'groupIndex'); + if (groupIndex !== undefined) { + groupIndex = parseInt(groupIndex); + } + const $group = this.$options.querySelector(`.vscomp-option[data-index="${groupIndex}"]`); + const isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); + this.toggleGroupTitleCheckbox($group, isAllSelected); + this.toggleGroupTitleProp(groupIndex, isAllSelected); + } + toggleGroupTitleProp(groupIndex, isSelected) { + const isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); + this.toggleSelectedProp(groupIndex, isAllSelected); + } + toggleGroupOptions($ele, isSelected) { + if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$ele) { + return; + } + const groupIndex = DomUtils.getData($ele, 'index', 'number'); + const { + selectedValues, + selectAllOnlyVisible + } = this; + const valuesMapping = {}; + const { + removeItemFromArray + } = Utils; + selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + if (d.isDisabled || d.groupIndex !== groupIndex) { return; } - var groupIndex = DomUtils.getData($ele, 'index', 'number'); - var selectedValues = this.selectedValues, - selectAllOnlyVisible = this.selectAllOnlyVisible; - var valuesMapping = {}; - var removeItemFromArray = Utils.removeItemFromArray; - selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - if (d.isDisabled || d.groupIndex !== groupIndex) { - return; + const { + value + } = d; + if (!isSelected || selectAllOnlyVisible && !d.isVisible) { + // eslint-disable-next-line no-param-reassign + d.isSelected = false; + if (valuesMapping[value]) { + removeItemFromArray(selectedValues, value); } - var value = d.value; - if (!isSelected || selectAllOnlyVisible && !d.isVisible) { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - if (valuesMapping[value]) { - removeItemFromArray(selectedValues, value); - } - } else { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - if (!valuesMapping[value]) { - selectedValues.push(value); - } + } else { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + if (!valuesMapping[value]) { + selectedValues.push(value); } - }); - this.toggleAllOptionsClass(isSelected ? null : false); - this.setValue(selectedValues); - - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this13.renderOptions(); - }, 0); - } - }, { - key: "toggleGroupTitleCheckbox", - value: function toggleGroupTitleCheckbox($ele, isSelected) { - if (!$ele) { - return; - } - var selectedIndex = DomUtils.getData($ele, 'index', 'number'); - this.toggleSelectedProp(selectedIndex, isSelected); - this.toggleOptionSelectedState($ele, isSelected); - } - }, { - key: "toggleFocusedProp", - value: function toggleFocusedProp(index) { - var isFocused = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (this.focusedOptionIndex) { - this.setOptionProp(this.focusedOptionIndex, 'isFocused', false); - } - this.setOptionProp(index, 'isFocused', isFocused); - this.focusedOptionIndex = index; - } - }, { - key: "toggleSelectedProp", - value: function toggleSelectedProp(index) { - var isSelected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setOptionProp(index, 'isSelected', isSelected); - } - }, { - key: "scrollToTop", - value: function scrollToTop() { - var scrollTop = this.$optionsContainer.scrollTop; - if (scrollTop > 0) { - this.$optionsContainer.scrollTop = 0; } + }); + this.toggleAllOptionsClass(isSelected ? null : false); + this.setValue(selectedValues); + + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.renderOptions(); + }, 0); + } + toggleGroupTitleCheckbox($ele, isSelected) { + if (!$ele) { + return; } - }, { - key: "reset", - value: function reset() { - var formReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var disableChangeEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - }); - this.beforeValueSet(true); - this.setValue(null, { - disableEvent: disableChangeEvent, - disableValidation: formReset - }); - this.afterValueSet(); - if (formReset) { - DomUtils.removeClass(this.$allWrappers, 'has-error'); - } - DomUtils.dispatchEvent(this.$ele, 'reset'); + const selectedIndex = DomUtils.getData($ele, 'index', 'number'); + this.toggleSelectedProp(selectedIndex, isSelected); + this.toggleOptionSelectedState($ele, isSelected); + } + toggleFocusedProp(index, isFocused = false) { + if (this.focusedOptionIndex) { + this.setOptionProp(this.focusedOptionIndex, 'isFocused', false); } - }, { - key: "addOption", - value: function addOption(data, rerender) { - if (!data) { - return; - } - this.lastOptionIndex += 1; - var newOption = this.getOptionObj(_objectSpread(_objectSpread({}, data), {}, { - index: this.lastOptionIndex - })); - this.options.push(newOption); - this.sortedOptions.push(newOption); - if (rerender) { - this.visibleOptionsCount += 1; - this.afterSetOptions(); - } + this.setOptionProp(index, 'isFocused', isFocused); + this.focusedOptionIndex = index; + } + toggleSelectedProp(index, isSelected = false) { + this.setOptionProp(index, 'isSelected', isSelected); + } + scrollToTop() { + const { + scrollTop + } = this.$optionsContainer; + if (scrollTop > 0) { + this.$optionsContainer.scrollTop = 0; } - }, { - key: "removeOption", - value: function removeOption(index) { - if (!index && index !== 0) { - return; - } - this.options.splice(index, 1); - this.lastOptionIndex -= 1; - } - }, { - key: "removeNewOption", - value: function removeNewOption() { - var newOption = this.getNewOption(); - if (newOption) { - this.removeOption(newOption.index); - } + } + reset(formReset = false, disableChangeEvent = false) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isSelected = false; + }); + this.beforeValueSet(true); + this.setValue(null, { + disableEvent: disableChangeEvent, + disableValidation: formReset + }); + this.afterValueSet(); + if (formReset) { + DomUtils.removeClass(this.$allWrappers, 'has-error'); + } + DomUtils.dispatchEvent(this.$ele, 'reset'); + } + addOption(data, rerender) { + if (!data) { + return; + } + this.lastOptionIndex += 1; + const newOption = this.getOptionObj({ + ...data, + index: this.lastOptionIndex + }); + this.options.push(newOption); + this.sortedOptions.push(newOption); + if (rerender) { + this.visibleOptionsCount += 1; + this.afterSetOptions(); } - }, { - key: "sortOptions", - value: function sortOptions(options) { - return options.sort(function (a, b) { - var aIsSelected = a.isSelected || a.isAnySelected; - var bIsSelected = b.isSelected || b.isAnySelected; - if (!aIsSelected && !bIsSelected) { - return 0; - } - if (aIsSelected && (!bIsSelected || a.index < b.index)) { - return -1; - } - return 1; - }); + } + removeOption(index) { + if (!index && index !== 0) { + return; } - }, { - key: "sortOptionsGroup", - value: function sortOptionsGroup(options) { - var sortOptions = this.sortOptions.bind(this); - var structuredOptions = this.structureOptionGroup(options); - structuredOptions.forEach(function (d) { - var childOptions = d.options; - // eslint-disable-next-line no-param-reassign - d.isAnySelected = childOptions.some(function (e) { - return e.isSelected; - }); - if (d.isAnySelected) { - sortOptions(childOptions); - } - }); - sortOptions(structuredOptions); - return this.destructureOptionGroup(structuredOptions); - } - }, { - key: "isOptionVisible", - value: function isOptionVisible(_ref7) { - var data = _ref7.data, - searchValue = _ref7.searchValue, - hasExactOption = _ref7.hasExactOption, - visibleOptionGroupsMapping = _ref7.visibleOptionGroupsMapping, - searchGroup = _ref7.searchGroup, - searchByStartsWith = _ref7.searchByStartsWith; - var value = data.valueNormalized != null ? data.valueNormalized : data.value.toLowerCase(); - var label = data.labelNormalized; - if (label == null) { - var rawLabel = (data.label || '').trim(); - if (this.searchNormalize && rawLabel !== '') { - label = Utils.normalizeString(rawLabel).toLowerCase(); - } else { - label = rawLabel.toLowerCase(); - } - } - var description = data.description, - alias = data.alias; - var descriptionNormalized = data.descriptionNormalized; - if (descriptionNormalized == null) { - var rawDescription = description || ''; - if (this.searchNormalize && rawDescription.trim() !== '') { - descriptionNormalized = Utils.normalizeString(rawDescription).toLowerCase(); - } else { - descriptionNormalized = rawDescription.toLowerCase(); - } - } - var isVisible = searchByStartsWith ? label.startsWith(searchValue) : label.includes(searchValue); - if (data.isGroupTitle && (!searchGroup || !isVisible)) { - isVisible = visibleOptionGroupsMapping[data.index]; - } - if (!searchByStartsWith && alias && !isVisible) { - isVisible = alias.includes(searchValue); - } - if (!searchByStartsWith && descriptionNormalized && !isVisible) { - isVisible = descriptionNormalized.includes(searchValue); - } - + this.options.splice(index, 1); + this.lastOptionIndex -= 1; + } + removeNewOption() { + const newOption = this.getNewOption(); + if (newOption) { + this.removeOption(newOption.index); + } + } + sortOptions(options) { + return options.sort((a, b) => { + const aIsSelected = a.isSelected || a.isAnySelected; + const bIsSelected = b.isSelected || b.isAnySelected; + if (!aIsSelected && !bIsSelected) { + return 0; + } + if (aIsSelected && (!bIsSelected || a.index < b.index)) { + return -1; + } + return 1; + }); + } + sortOptionsGroup(options) { + const sortOptions = this.sortOptions.bind(this); + const structuredOptions = this.structureOptionGroup(options); + structuredOptions.forEach(d => { + const childOptions = d.options; // eslint-disable-next-line no-param-reassign - data.isVisible = isVisible; - if (!hasExactOption) { - // eslint-disable-next-line no-param-reassign - hasExactOption = label === searchValue || value === searchValue; + d.isAnySelected = childOptions.some(e => e.isSelected); + if (d.isAnySelected) { + sortOptions(childOptions); + } + }); + sortOptions(structuredOptions); + return this.destructureOptionGroup(structuredOptions); + } + isOptionVisible({ + data, + searchValue, + hasExactOption, + visibleOptionGroupsMapping, + searchGroup, + searchByStartsWith + }) { + const value = data.valueNormalized != null ? data.valueNormalized : data.value.toLowerCase(); + let label = data.labelNormalized; + if (label == null) { + const rawLabel = (data.label || '').trim(); + if (this.searchNormalize && rawLabel !== '') { + label = Utils.normalizeString(rawLabel).toLowerCase(); + } else { + label = rawLabel.toLowerCase(); + } + } + const { + description, + alias + } = data; + let { + descriptionNormalized + } = data; + if (descriptionNormalized == null) { + const rawDescription = description || ''; + if (this.searchNormalize && rawDescription.trim() !== '') { + descriptionNormalized = Utils.normalizeString(rawDescription).toLowerCase(); + } else { + descriptionNormalized = rawDescription.toLowerCase(); } - return { - isVisible: isVisible, - hasExactOption: hasExactOption - }; } - }, { - key: "structureOptionGroup", - value: function structureOptionGroup(options) { - var result = []; - var childOptions = {}; - - /** getting all group title */ - options.forEach(function (d) { - if (d.isGroupTitle) { - var childArray = []; - // eslint-disable-next-line no-param-reassign - d.options = childArray; - childOptions[d.index] = childArray; - result.push(d); - } - }); - - /** getting all group options */ - options.forEach(function (d) { - if (d.isGroupOption) { - childOptions[d.groupIndex].push(d); - } - }); - return result; + let isVisible = searchByStartsWith ? label.startsWith(searchValue) : label.includes(searchValue); + if (data.isGroupTitle && (!searchGroup || !isVisible)) { + isVisible = visibleOptionGroupsMapping[data.index]; } - }, { - key: "destructureOptionGroup", - value: function destructureOptionGroup(options) { - var result = []; - options.forEach(function (d) { - result.push(d); - result = result.concat(d.options); - }); - return result; + if (!searchByStartsWith && alias && !isVisible) { + isVisible = alias.includes(searchValue); } - }, { - key: "serverSearch", - value: function serverSearch() { - DomUtils.removeClass(this.$allWrappers, 'has-no-search-results'); - DomUtils.addClass(this.$allWrappers, 'server-searching'); - this.setSelectedOptions(); - this.onServerSearch(this.searchValue, this); - } - }, { - key: "removeValue", - value: function removeValue($ele) { - var selectedValues = this.selectedValues; - var selectedValue = DomUtils.getData($ele, 'value'); - Utils.removeItemFromArray(selectedValues, selectedValue); - this.setValueMethod(selectedValues); + if (!searchByStartsWith && descriptionNormalized && !isVisible) { + isVisible = descriptionNormalized.includes(searchValue); } - }, { - key: "focus", - value: function focus() { - this.$wrapper.focus(); + + // eslint-disable-next-line no-param-reassign + data.isVisible = isVisible; + if (!hasExactOption) { + // eslint-disable-next-line no-param-reassign + hasExactOption = label === searchValue || value === searchValue; } - }, { - key: "enable", - value: function enable() { - this.$ele.disabled = false; - this.$ele.removeAttribute('disabled'); - this.$hiddenInput.removeAttribute('disabled'); - DomUtils.setAria(this.$wrapper, 'disabled', false); - DomUtils.changeTabIndex(this.$wrapper, 0); - } - }, { - key: "disable", - value: function disable() { - this.$ele.disabled = true; - this.$ele.setAttribute('disabled', ''); - this.$hiddenInput.setAttribute('disabled', ''); - DomUtils.setAria(this.$wrapper, 'disabled', true); - DomUtils.changeTabIndex(this.$wrapper, -1); - this.$wrapper.blur(); - } - }, { - key: "validate", - value: function validate() { - if (this.disableValidation) { - return true; + return { + isVisible, + hasExactOption + }; + } + structureOptionGroup(options) { + const result = []; + const childOptions = {}; + + /** getting all group title */ + options.forEach(d => { + if (d.isGroupTitle) { + const childArray = []; + // eslint-disable-next-line no-param-reassign + d.options = childArray; + childOptions[d.index] = childArray; + result.push(d); } - var hasError = false; - var selectedValues = this.selectedValues, - minValues = this.minValues; - if (this.required && (Utils.isEmpty(selectedValues) || (/** required minium options not selected */ - this.multiple && minValues && selectedValues.length < minValues))) { - hasError = true; + }); + + /** getting all group options */ + options.forEach(d => { + if (d.isGroupOption) { + childOptions[d.groupIndex].push(d); } - DomUtils.toggleClass(this.$allWrappers, 'has-error', hasError); - return !hasError; - } - }, { - key: "destroy", - value: function destroy() { - var $ele = this.$ele; - $ele.virtualSelect = undefined; - $ele.value = undefined; - $ele.innerHTML = ''; + }); + return result; + } + destructureOptionGroup(options) { + let result = []; + options.forEach(d => { + result.push(d); + result = result.concat(d.options); + }); + return result; + } + serverSearch() { + DomUtils.removeClass(this.$allWrappers, 'has-no-search-results'); + DomUtils.addClass(this.$allWrappers, 'server-searching'); + this.setSelectedOptions(); + this.onServerSearch(this.searchValue, this); + } + removeValue($ele) { + const { + selectedValues + } = this; + const selectedValue = DomUtils.getData($ele, 'value'); + Utils.removeItemFromArray(selectedValues, selectedValue); + this.setValueMethod(selectedValues); + } + focus() { + this.$wrapper.focus(); + } + enable() { + this.$ele.disabled = false; + this.$ele.removeAttribute('disabled'); + this.$hiddenInput.removeAttribute('disabled'); + DomUtils.setAria(this.$wrapper, 'disabled', false); + DomUtils.changeTabIndex(this.$wrapper, 0); + } + disable() { + this.$ele.disabled = true; + this.$ele.setAttribute('disabled', ''); + this.$hiddenInput.setAttribute('disabled', ''); + DomUtils.setAria(this.$wrapper, 'disabled', true); + DomUtils.changeTabIndex(this.$wrapper, -1); + this.$wrapper.blur(); + } + validate() { + if (this.disableValidation) { + return true; + } + let hasError = false; + const { + selectedValues, + minValues + } = this; + if (this.required && (Utils.isEmpty(selectedValues) || (/** required minium options not selected */ + this.multiple && minValues && selectedValues.length < minValues))) { + hasError = true; + } + DomUtils.toggleClass(this.$allWrappers, 'has-error', hasError); + return !hasError; + } + destroy() { + const { + $ele + } = this; + $ele.virtualSelect = undefined; + $ele.value = undefined; + $ele.innerHTML = ''; - // Remove from open instances - VirtualSelect.openInstances["delete"](this); + // Remove from open instances + VirtualSelect.openInstances.delete(this); - // Reset the last interacted instance only if this is the last interacted instance - if (this === VirtualSelect.lastInteractedInstance) { - VirtualSelect.lastInteractedInstance = null; - } + // Reset the last interacted instance only if this is the last interacted instance + if (this === VirtualSelect.lastInteractedInstance) { + VirtualSelect.lastInteractedInstance = null; + } - // Clear any pending server search timeout to prevent memory leaks - if (this.serverSearchTimeout) { - clearTimeout(this.serverSearchTimeout); - this.serverSearchTimeout = null; - } + // Clear any pending server search timeout to prevent memory leaks + if (this.serverSearchTimeout) { + clearTimeout(this.serverSearchTimeout); + this.serverSearchTimeout = null; + } - /** Remove all event listeners to prevent memory leaks and ensure proper cleanup */ - this.removeEvents(); - if (this.hasDropboxWrapper) { - this.$dropboxWrapper.remove(); - } - if (this.dropboxPopover) { - this.dropboxPopover.destroy(); - } - DomUtils.removeClass($ele, 'vscomp-ele'); - } - }, { - key: "createSecureTextElements", - value: function createSecureTextElements() { - this.$secureDiv = document.createElement('div'); - this.$secureText = document.createTextNode(''); - this.$secureDiv.appendChild(this.$secureText); - } - }, { - key: "secureText", - value: function secureText(text) { - if (!text || !this.enableSecureText) { - return text; - } - /** escape potentially harmful JavaScript so, label and value fields cannot trigger XSS */ - this.$secureText.nodeValue = Utils.replaceDoubleQuotesWithHTML(text); - return this.$secureDiv.innerHTML; - } - }, { - key: "toggleRequired", - value: function toggleRequired(isRequired) { - this.required = Utils.convertToBoolean(isRequired); - this.$ele.required = this.required; - } - }, { - key: "toggleOptionSelectedState", - value: function toggleOptionSelectedState($ele, value) { - var isSelected = value; - if (typeof isSelected === 'undefined') { - isSelected = !DomUtils.hasClass($ele, 'selected'); - } - DomUtils.toggleClass($ele, 'selected', isSelected); - DomUtils.setAria($ele, 'selected', isSelected); + /** Remove all event listeners to prevent memory leaks and ensure proper cleanup */ + this.removeEvents(); + if (this.hasDropboxWrapper) { + this.$dropboxWrapper.remove(); } - }, { - key: "toggleOptionFocusedState", - value: function toggleOptionFocusedState($ele, isFocused) { - if (!$ele) { - return; - } - DomUtils.toggleClass($ele, 'focused', isFocused); - DomUtils.setAttr($ele, 'tabindex', isFocused ? '0' : '-1'); - if (document.activeElement !== this.$searchInput) { - $ele.focus(); - } - if (isFocused) { - DomUtils.setAria(this.$wrapper, 'activedescendant', $ele.id); - // Also set aria-activedescendant on the listbox container for better screen reader support - DomUtils.setAria(this.$dropboxContainer, 'activedescendant', $ele.id); - } + if (this.dropboxPopover) { + this.dropboxPopover.destroy(); + } + DomUtils.removeClass($ele, 'vscomp-ele'); + } + createSecureTextElements() { + this.$secureDiv = document.createElement('div'); + this.$secureText = document.createTextNode(''); + this.$secureDiv.appendChild(this.$secureText); + } + secureText(text) { + if (!text || !this.enableSecureText) { + return text; + } + /** escape potentially harmful JavaScript so, label and value fields cannot trigger XSS */ + this.$secureText.nodeValue = Utils.replaceDoubleQuotesWithHTML(text); + return this.$secureDiv.innerHTML; + } + toggleRequired(isRequired) { + this.required = Utils.convertToBoolean(isRequired); + this.$ele.required = this.required; + } + toggleOptionSelectedState($ele, value) { + let isSelected = value; + if (typeof isSelected === 'undefined') { + isSelected = !DomUtils.hasClass($ele, 'selected'); + } + DomUtils.toggleClass($ele, 'selected', isSelected); + DomUtils.setAria($ele, 'selected', isSelected); + } + toggleOptionFocusedState($ele, isFocused) { + if (!$ele) { + return; + } + DomUtils.toggleClass($ele, 'focused', isFocused); + DomUtils.setAttr($ele, 'tabindex', isFocused ? '0' : '-1'); + if (document.activeElement !== this.$searchInput) { + $ele.focus(); } + if (isFocused) { + DomUtils.setAria(this.$wrapper, 'activedescendant', $ele.id); + // Also set aria-activedescendant on the listbox container for better screen reader support + DomUtils.setAria(this.$dropboxContainer, 'activedescendant', $ele.id); + } + } - /** static methods - start */ - }], [{ - key: "init", - value: function init(options) { - var $eleArray = options.ele; - if (!$eleArray) { + /** static methods - start */ + static init(options) { + let $eleArray = options.ele; + if (!$eleArray) { + return undefined; + } + let singleEle = false; + if (typeof $eleArray === 'string') { + $eleArray = document.querySelectorAll($eleArray); + const eleLength = $eleArray.length; + if (eleLength === 0) { return undefined; } - var singleEle = false; - if (typeof $eleArray === 'string') { - $eleArray = document.querySelectorAll($eleArray); - var eleLength = $eleArray.length; - if (eleLength === 0) { - return undefined; - } - if (eleLength === 1) { - singleEle = true; - } - } - if ($eleArray.length === undefined || $eleArray.forEach === undefined) { - $eleArray = [$eleArray]; + if (eleLength === 1) { singleEle = true; } - var instances = []; - $eleArray.forEach(function ($ele) { - /** skipping initialization on calling init method multiple times */ - if ($ele.virtualSelect) { - instances.push($ele.virtualSelect); - return; - } - - // eslint-disable-next-line no-param-reassign - options.ele = $ele; - if ($ele.tagName === 'SELECT') { - VirtualSelect.setPropsFromSelect(options); - } - instances.push(new VirtualSelect(options)); - }); - return singleEle ? instances[0] : instances; - } - }, { - key: "getAttrProps", - value: function getAttrProps() { - var convertPropToDataAttr = DomUtils.convertPropToDataAttr; - var result = {}; - nativeProps.forEach(function (d) { - result[d] = d; - }); - dataProps.forEach(function (d) { - result[convertPropToDataAttr(d)] = d; - }); - return result; } - }, { - key: "setPropsFromSelect", - value: function setPropsFromSelect(props) { - var $ele = props.ele; - var disabledOptions = []; - var selectedValue = []; - var _getNativeOptions = function getNativeOptions($container) { - var options = []; - var $options = Array.from($container.children); - $options.forEach(function ($option) { - var value = $option.value; - var option = { - value: value - }; - if ($option.tagName === 'OPTGROUP') { - option.label = $option.getAttribute('label'); - option.options = _getNativeOptions($option); - } else { - option.label = $option.innerHTML; - } - options.push(option); - if ($option.disabled) { - disabledOptions.push(value); - } - if ($option.selected) { - selectedValue.push(value); - } - }); - return options; - }; - var optionsList = _getNativeOptions($ele); - - /** creating div element to initiate plugin and removing native element */ - var $newEle = document.createElement('div'); - DomUtils.setAttrFromEle($ele, $newEle, Object.keys(attrPropsMapping), valueLessProps); - $ele.parentNode.insertBefore($newEle, $ele); - $ele.remove(); - - // eslint-disable-next-line no-param-reassign - props.ele = $newEle; - // eslint-disable-next-line no-param-reassign - props.options = optionsList; - // eslint-disable-next-line no-param-reassign - props.disabledOptions = disabledOptions; - // eslint-disable-next-line no-param-reassign - props.selectedValue = selectedValue; + if ($eleArray.length === undefined || $eleArray.forEach === undefined) { + $eleArray = [$eleArray]; + singleEle = true; } - }, { - key: "onFormReset", - value: function onFormReset(e) { - var $form = e.target.closest('form'); - if (!$form) { + const instances = []; + $eleArray.forEach($ele => { + /** skipping initialization on calling init method multiple times */ + if ($ele.virtualSelect) { + instances.push($ele.virtualSelect); return; } - $form.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - $ele.parentElement.virtualSelect.reset(true); - }); - } - }, { - key: "onFormSubmit", - value: function onFormSubmit(e) { - if (!VirtualSelect.validate(e.target.closest('form'))) { - e.preventDefault(); - } - } - }, { - key: "validate", - value: function validate($container) { - if (!$container) { - return true; + + // eslint-disable-next-line no-param-reassign + options.ele = $ele; + if ($ele.tagName === 'SELECT') { + VirtualSelect.setPropsFromSelect(options); } - var hasError = false; - $container.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - var result = $ele.parentElement.virtualSelect.validate(); - if (!hasError && !result) { - hasError = true; + instances.push(new VirtualSelect(options)); + }); + return singleEle ? instances[0] : instances; + } + static getAttrProps() { + const { + convertPropToDataAttr + } = DomUtils; + const result = {}; + nativeProps.forEach(d => { + result[d] = d; + }); + dataProps.forEach(d => { + result[convertPropToDataAttr(d)] = d; + }); + return result; + } + static setPropsFromSelect(props) { + const $ele = props.ele; + const disabledOptions = []; + const selectedValue = []; + const getNativeOptions = $container => { + const options = []; + const $options = Array.from($container.children); + $options.forEach($option => { + const { + value + } = $option; + const option = { + value + }; + if ($option.tagName === 'OPTGROUP') { + option.label = $option.getAttribute('label'); + option.options = getNativeOptions($option); + } else { + option.label = $option.innerHTML; + } + options.push(option); + if ($option.disabled) { + disabledOptions.push(value); + } + if ($option.selected) { + selectedValue.push(value); } }); - return !hasError; - } - }, { - key: "reset", - value: function reset() { - var formReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var disableChangeEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.virtualSelect.reset(formReset, disableChangeEvent); - } - }, { - key: "setValueMethod", - value: function setValueMethod() { - var _this$virtualSelect; - (_this$virtualSelect = this.virtualSelect).setValueMethod.apply(_this$virtualSelect, arguments); - } - }, { - key: "setOptionsMethod", - value: function setOptionsMethod() { - var _this$virtualSelect2; - (_this$virtualSelect2 = this.virtualSelect).setOptionsMethod.apply(_this$virtualSelect2, arguments); - } - }, { - key: "setDisabledOptionsMethod", - value: function setDisabledOptionsMethod() { - var _this$virtualSelect3; - (_this$virtualSelect3 = this.virtualSelect).setDisabledOptionsMethod.apply(_this$virtualSelect3, arguments); - } - }, { - key: "setEnabledOptionsMethod", - value: function setEnabledOptionsMethod() { - var _this$virtualSelect4; - (_this$virtualSelect4 = this.virtualSelect).setEnabledOptionsMethod.apply(_this$virtualSelect4, arguments); - } - }, { - key: "toggleSelectAll", - value: function toggleSelectAll(isSelected) { - this.virtualSelect.toggleAllOptions(isSelected); - } - }, { - key: "isAllSelected", - value: function isAllSelected() { - return this.virtualSelect.isAllSelected; - } - }, { - key: "addOptionMethod", - value: function addOptionMethod(data) { - this.virtualSelect.addOption(data, true); - } - }, { - key: "getNewValueMethod", - value: function getNewValueMethod() { - return this.virtualSelect.getNewValue(); - } - }, { - key: "getDisplayValueMethod", - value: function getDisplayValueMethod() { - return this.virtualSelect.getDisplayValue(); - } - }, { - key: "getSelectedOptionsMethod", - value: function getSelectedOptionsMethod(params) { - return this.virtualSelect.getSelectedOptions(params); - } - }, { - key: "getDisabledOptionsMethod", - value: function getDisabledOptionsMethod() { - return this.virtualSelect.getDisabledOptions(); - } - }, { - key: "openMethod", - value: function openMethod() { - return this.virtualSelect.openDropbox(); - } - }, { - key: "closeMethod", - value: function closeMethod() { - return this.virtualSelect.closeDropbox(); - } - }, { - key: "focusMethod", - value: function focusMethod() { - return this.virtualSelect.focus(); - } - }, { - key: "enableMethod", - value: function enableMethod() { - return this.virtualSelect.enable(); - } - }, { - key: "disableMethod", - value: function disableMethod() { - return this.virtualSelect.disable(); - } - }, { - key: "destroyMethod", - value: function destroyMethod() { - return this.virtualSelect.destroy(); - } - }, { - key: "validateMethod", - value: function validateMethod() { - return this.virtualSelect.validate(); - } - }, { - key: "toggleRequiredMethod", - value: function toggleRequiredMethod(isRequired) { - return this.virtualSelect.toggleRequired(isRequired); - } - }, { - key: "onResizeMethod", - value: function onResizeMethod() { - document.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - $ele.parentElement.virtualSelect.onResize(); - }); + return options; + }; + const optionsList = getNativeOptions($ele); + + /** creating div element to initiate plugin and removing native element */ + const $newEle = document.createElement('div'); + DomUtils.setAttrFromEle($ele, $newEle, Object.keys(attrPropsMapping), valueLessProps); + $ele.parentNode.insertBefore($newEle, $ele); + $ele.remove(); + + // eslint-disable-next-line no-param-reassign + props.ele = $newEle; + // eslint-disable-next-line no-param-reassign + props.options = optionsList; + // eslint-disable-next-line no-param-reassign + props.disabledOptions = disabledOptions; + // eslint-disable-next-line no-param-reassign + props.selectedValue = selectedValue; + } + static onFormReset(e) { + const $form = e.target.closest('form'); + if (!$form) { + return; + } + $form.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + $ele.parentElement.virtualSelect.reset(true); + }); + } + static onFormSubmit(e) { + if (!VirtualSelect.validate(e.target.closest('form'))) { + e.preventDefault(); } - /** static methods - end */ - }]); -}(); + } + static validate($container) { + if (!$container) { + return true; + } + let hasError = false; + $container.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + const result = $ele.parentElement.virtualSelect.validate(); + if (!hasError && !result) { + hasError = true; + } + }); + return !hasError; + } + static reset(formReset = false, disableChangeEvent = false) { + this.virtualSelect.reset(formReset, disableChangeEvent); + } + static setValueMethod(...params) { + this.virtualSelect.setValueMethod(...params); + } + static setOptionsMethod(...params) { + this.virtualSelect.setOptionsMethod(...params); + } + static setDisabledOptionsMethod(...params) { + this.virtualSelect.setDisabledOptionsMethod(...params); + } + static setEnabledOptionsMethod(...params) { + this.virtualSelect.setEnabledOptionsMethod(...params); + } + static toggleSelectAll(isSelected) { + this.virtualSelect.toggleAllOptions(isSelected); + } + static isAllSelected() { + return this.virtualSelect.isAllSelected; + } + static addOptionMethod(data) { + this.virtualSelect.addOption(data, true); + } + static getNewValueMethod() { + return this.virtualSelect.getNewValue(); + } + static getDisplayValueMethod() { + return this.virtualSelect.getDisplayValue(); + } + static getSelectedOptionsMethod(params) { + return this.virtualSelect.getSelectedOptions(params); + } + static getDisabledOptionsMethod() { + return this.virtualSelect.getDisabledOptions(); + } + static openMethod() { + return this.virtualSelect.openDropbox(); + } + static closeMethod() { + return this.virtualSelect.closeDropbox(); + } + static focusMethod() { + return this.virtualSelect.focus(); + } + static enableMethod() { + return this.virtualSelect.enable(); + } + static disableMethod() { + return this.virtualSelect.disable(); + } + static destroyMethod() { + return this.virtualSelect.destroy(); + } + static validateMethod() { + return this.virtualSelect.validate(); + } + static toggleRequiredMethod(isRequired) { + return this.virtualSelect.toggleRequired(isRequired); + } + static onResizeMethod() { + document.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + $ele.parentElement.virtualSelect.onResize(); + }); + } + /** static methods - end */ +} document.addEventListener('reset', VirtualSelect.onFormReset); document.addEventListener('submit', VirtualSelect.onFormSubmit); window.addEventListener('resize', VirtualSelect.onResizeMethod); diff --git a/dist/virtual-select.min.css b/dist/virtual-select.min.css index 0966e2a..48aa3d6 100644 --- a/dist/virtual-select.min.css +++ b/dist/virtual-select.min.css @@ -3,7 +3,7 @@ * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) */ -@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} +@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} /*! * Popover v1.0.13 * https://sa-si-dev.github.io/popover diff --git a/dist/virtual-select.min.js b/dist/virtual-select.min.js index 8c5129e..169586d 100644 --- a/dist/virtual-select.min.js +++ b/dist/virtual-select.min.js @@ -2,4 +2,4 @@ * Virtual Select v1.1.5 * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) - */!function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);i1&&void 0!==arguments[1]&&arguments[1]}},{key:"isEmpty",value:function(e){var t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"===i(e)&&0===Object.keys(e).length&&(t=!0):t=!0,t}},{key:"isNotEmpty",value:function(e){return!t.isEmpty(e)}},{key:"normalizeValues",value:function(e){if(Array.isArray(e)){for(var t=new Array(e.length),i=0;i2&&void 0!==arguments[2]&&arguments[2];if(!Array.isArray(t)||!t.length)return t;var s=o?e(t):t,n=s.indexOf(i);return-1!==n&&s.splice(n,1),s}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"getRandomInt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-i-1))+i}},{key:"regexEscape",value:function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}},{key:"normalizeString",value:function(e){return e.normalize("NFD").replace(/[^\w]/g,"")}},{key:"willTextOverflow",value:function(e,t){var i=document.createElement("div");i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="nowrap",i.style.fontSize=window.getComputedStyle(e).fontSize,i.style.fontFamily=window.getComputedStyle(e).fontFamily,i.textContent=t,document.body.appendChild(i);var o=i.clientWidth;return document.body.removeChild(i),o>e.clientWidth}},{key:"replaceDoubleQuotesWithHTML",value:function(e){return e.replace(/"/g,""")}},{key:"containsHTML",value:function(e){return/<[a-z][\s\S]*>/i.test(e)}},{key:"containsHTMLorJS",value:function(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}],(n=null)&&o(s.prototype,n),r&&o(s,r),Object.defineProperty(s,"prototype",{writable:!1}),s;var s,n,r}();function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o,s,n,r,a=[],l=!0,u=!1;try{if(n=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(o=n.call(i)).done)&&(a.push(o.value),a.length!==t);l=!0);}catch(e){u=!0,s=e}finally{try{if(!l&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(u)throw s}}return a}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"==typeof e)return c(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);ie.offsetWidth}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setAttr",value:function(e,t,i){e&&e.setAttribute(t,i)}},{key:"setAttrFromEle",value:function(e,t,i,o){var s={};i.forEach(function(t){s[t]=e.getAttribute(t)}),i.forEach(function(e){var i=s[e];(i||-1!==o.indexOf(e)&&""===i)&&t.setAttribute(e,i)})}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"setStyles",value:function(e,t){e&&t&&Object.keys(t).forEach(function(i){e.style[i]=t[i]})}},{key:"setAria",value:function(e,t,i){if(e){var o=t;"role"!==o&&(o="aria-".concat(o)),e.setAttribute(o,i)}}},{key:"getElements",value:function(e){return e?void 0===e.forEach?[e]:e:[]}},{key:"getElementsBySelector",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=void 0!==i?i:document;return""!==t&&(e=o.querySelectorAll(t)),void 0!==e?Array.from(e):[]}},{key:"addEvent",value:function(t,i,o,s){t&&n.removeArrayEmpty(i.split(" ")).forEach(function(i){e.getElements(t).forEach(function(e){e.addEventListener(i,o,{capture:s})})})}},{key:"dispatchEvent",value:function(t,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t){var s=e.getElements(t);setTimeout(function(){s.forEach(function(e){e.dispatchEvent(new CustomEvent(i,{bubbles:o}))})},0)}}},{key:"getAttributesText",value:function(e){var t="";return e?(Object.entries(e).forEach(function(e){var i=a(e,2),o=i[0],s=i[1];void 0!==s&&(t+=" ".concat(o,'="').concat(s,'" '))}),t):t}},{key:"convertPropToDataAttr",value:function(e){return e?"data-".concat(e).replace(/([A-Z])/g,"-$1").toLowerCase():""}},{key:"changeTabIndex",value:function(t,i){t?e.getElements(t).forEach(function(e){e.tabIndex=i}):console.log(t,"Invalid element provided.")}},{key:"removeEvent",value:function(t,i,o){t&&e.getElements(t).forEach(function(e){e.removeEventListener(i,o)})}}],(i=null)&&p(t.prototype,i),o&&p(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,o)}return i}function f(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,o=Array(t);i\n \n
\n
\n ").concat(this.placeholder,'\n
\n
\n
\n \n
\n
\n\n ').concat(this.renderDropbox({wrapperClasses:t}),"\n ");this.$ele.innerHTML=u,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),d.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}}},{key:"renderDropbox",value:function(e){var t=e.wrapperClasses,i="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null,o="vscomp-dropbox";this.additionalDropboxClasses&&(o+=" ".concat(this.additionalDropboxClasses));var s="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(s+=" ".concat(this.additionalDropboxContainerClasses));var n='
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
').concat(this.noOptionsText,'
\n
').concat(this.noSearchResultsText,'
\n\n \n
\n \n
');if(i){var r=document.createElement("div");return this.$dropboxWrapper=r,this.hasDropboxWrapper=!0,r.innerHTML=n,i.appendChild(r),d.addClass(r,"vscomp-dropbox-wrapper ".concat(t)),this.keepAlwaysOpen||(d.setAttr(r,"tabindex","-1"),d.setAria(r,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}},{key:"renderOptions",value:function(){var e=this;this.calculateAriaMetadata();var t,i="",o=this.getVisibleOptions(),s="",r="",a=!(!this.markSearchResults||!this.searchValue),l=this.labelRenderer,u=this.disableOptionGroupCheckbox,c=this.uniqueId,p=this.searchGroup,h="function"==typeof l,d=n.convertToBoolean,v="";if(a&&(t=new RegExp("(".concat(n.regexEscape(this.searchValue),")(?!([^<]+)?>)"),"gi")),this.multiple&&(s=''),this.allowNewOption){var f=this.getTooltipAttrText("New Option");r='")}o.forEach(function(o){var n,f=o.index,b="vscomp-option",y=e.getTooltipAttrText("",!0,!0),m=s,g="",O="",S="",x="",w="-1",k=d(o.isSelected),C="";if(o.classNames&&(b+=" ".concat(o.classNames)),o.isFocused&&(w="0",b+=" focused"),o.isDisabled&&(b+=" disabled",C='aria-disabled="true"'),o.isGroupTitle&&(v=o.label,b+=" group-title",u&&(m="")),k&&(b+=" selected"),o.isGroupOption){var E="";b+=" group-option",S='data-group-index="'.concat(o.groupIndex,'"'),o.customData?(v=void 0!==o.customData.group_name?"".concat(o.customData.group_name,", "):"",E=void 0!==o.customData.description?" ".concat(o.customData.description,","):"",x='aria-label="'.concat(v," ").concat(o.label,", ").concat(E,'"')):x='aria-label="'.concat(v,", ").concat(o.label,'"')}n=h?l(o):o.label,o.description&&(O='
").concat(o.description,"
")),o.isCurrentNew?(b+=" current-new",g+=r):!a||o.isGroupTitle&&!p||(n=n.replace(t,"$1"));var $="";e.ariaSetSize>0&&($='aria-setsize="'.concat(e.ariaSetSize,'"'),o.filteredIndex&&($+=' aria-posinset="'.concat(o.filteredIndex,'"'))),i+='
\n ").concat(n,"\n \n ").concat(O,"\n ").concat(g,"\n
")}),v="",this.$options.innerHTML=i,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}},{key:"renderSearch",value:function(){if(this.hasSearchContainer){var e="",t="";if(this.multiple&&!this.disableSelectAll&&(e='\n \n ').concat(this.selectAllText,"\n ")),this.hasSearch){var i=this.ariaLabelSearchClearButtonText?'aria-label="'.concat(this.ariaLabelSearchClearButtonText,'"'):"";t='\n \n ×")}var o='
\n '.concat(e,"\n ").concat(t,"\n
");this.$search.innerHTML=o,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}}},{key:"addEvents",value:function(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}},{key:"addEvent",value:function(e,t,i){var o=this,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var n="".concat(i,"-").concat(t),r=o.events[n];r||(r=o[i].bind(o),o.events[n]=r),d.addEvent(e,t,r,s)})}},{key:"removeEvents",value:function(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}},{key:"removeEvent",value:function(e,t,i){var o=this;e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var s="".concat(i,"-").concat(t),n=o.events[s];n&&d.removeEvent(e,t,n)})}},{key:"onDocumentClick",value:function(t){var i=t.target.closest(".vscomp-wrapper");if(i){var o=i.parentElement.virtualSelect;o&&o!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}else e.openInstances.forEach(function(e){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()})}},{key:"onKeyDown",value:function(e){var t=e.which||e.keyCode,i=C[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){var o=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(o&&(document.activeElement===o||o.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}i&&this[i](e)}else this.toggleAllOptions()}},{key:"onEnterPress",value:function(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}},{key:"onDownArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}},{key:"onUpArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}},{key:"onBackspaceOrDeletePress",value:function(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}},{key:"onToggleButtonPress",value:function(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}var t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}},{key:"onClearButtonClick",value:function(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}},{key:"onOptionsScroll",value:function(){this.setVisibleOptions(!0)}},{key:"onOptionsClick",value:function(e){var t=e.target.closest(".vscomp-option");t&&!d.hasClass(t,"disabled")&&(d.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}},{key:"onGroupTitleClick",value:function(e){if(e&&this.multiple&&!this.disableOptionGroupCheckbox){var t=!d.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}}},{key:"onDropboxContainerClick",value:function(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}},{key:"onDropboxCloseButtonClick",value:function(){this.closeDropbox()}},{key:"onOptionsMouseOver",value:function(e){var t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(d.hasClass(t,"disabled")||d.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}},{key:"onOptionsTouchMove",value:function(){this.removeOptionFocus()}},{key:"onSearch",value:function(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}},{key:"preventPropagation",value:function(e){e.stopPropagation()}},{key:"onSearchClear",value:function(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}},{key:"onToggleAllOptions",value:function(){this.toggleAllOptions()}},{key:"onDropboxContainerTopOrBottomFocus",value:function(){this.closeDropbox()}},{key:"onResize",value:function(){this.setOptionsContainerHeight(!0)}},{key:"addMutationObserver",value:function(){var e=this;if(this.hasDropboxWrapper){var t=this.$ele;this.mutationObserver=new MutationObserver(function(i){var o=!1,s=!1;i.forEach(function(e){o||(o=g(e.addedNodes).some(function(e){return!(e!==t&&!e.contains(t))})),s||(s=g(e.removedNodes).some(function(e){return!(e!==t&&!e.contains(t))}))}),s&&!o&&e.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}}},{key:"removeMutationObserver",value:function(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}},{key:"beforeValueSet",value:function(e){this.toggleAllOptionsClass(!e&&void 0)}},{key:"beforeSelectNewValue",value:function(e){var t=this,i=this.getNewOption();if(i){var o=i.index;this.newValues.push(i.value),this.setOptionProp(o,"isCurrentNew",!1),this.setOptionProp(o,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(function(){t.setSearchValue(""),t.focusSearchInput()},0)}},{key:"afterRenderWrapper",value:function(){d.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}},{key:"afterRenderOptions",value:function(){var e=this,t=this.getVisibleOptions(),i=!this.options.length&&!this.hasServerSearch,o=!i&&!t.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(d.toggleClass(this.$allWrappers,"has-no-search-results",o),o?(d.setAttr(this.$noSearchResults,"tabindex","0"),d.setAttr(this.$noSearchResults,"aria-hidden","false")):(d.setAttr(this.$noSearchResults,"tabindex","-1"),d.setAttr(this.$noSearchResults,"aria-hidden","true"))),d.toggleClass(this.$allWrappers,"has-no-options",i),i?(d.setAttr(this.$noOptions,"tabindex","0"),d.setAttr(this.$noOptions,"aria-hidden","false")):(d.setAttr(this.$noOptions,"tabindex","-1"),d.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(function(){var t=d.getElementsBySelector(".focused",e.$dropboxContainer)[0];void 0!==t&&t.focus({preventScroll:!0})},20)}},{key:"afterSetOptionsContainerHeight",value:function(e){e&&this.showAsPopup&&this.setVisibleOptions()}},{key:"afterSetSearchValue",value:function(){var e=this;this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(function(){e.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}},{key:"afterSetVisibleOptionsCount",value:function(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}},{key:"afterValueSet",value:function(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}},{key:"afterSetOptions",value:function(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}},{key:"setProps",value:function(e){var t=this.setDefaultProps(e);this.setPropsFromElementAttr(t);var i=n.convertToBoolean;this.$ele=t.ele,this.dropboxWrapper=t.dropboxWrapper,this.valueKey=t.valueKey,this.labelKey=t.labelKey,this.descriptionKey=t.descriptionKey,this.aliasKey=t.aliasKey,this.optionHeightText=t.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(t.multiple),this.hasSearch=i(t.search),this.searchByStartsWith=i(t.searchByStartsWith),this.searchGroup=i(t.searchGroup),this.hideClearButton=i(t.hideClearButton),this.autoSelectFirstOption=i(t.autoSelectFirstOption),this.hasOptionDescription=i(t.hasOptionDescription),this.silentInitialValueSet=i(t.silentInitialValueSet),this.allowNewOption=i(t.allowNewOption),this.markSearchResults=i(t.markSearchResults),this.showSelectedOptionsFirst=i(t.showSelectedOptionsFirst),this.disableSelectAll=i(t.disableSelectAll),this.keepAlwaysOpen=i(t.keepAlwaysOpen),this.showDropboxAsPopup=i(t.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(t.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(t.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(t.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(t.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(t.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(t.disableAllOptionsSelectedText),this.showValueAsTags=i(t.showValueAsTags),this.disableOptionGroupCheckbox=i(t.disableOptionGroupCheckbox),this.enableSecureText=i(t.enableSecureText),this.setValueAsArray=i(t.setValueAsArray),this.disableValidation=i(t.disableValidation),this.initialDisabled=i(t.disabled),this.required=i(t.required),this.autofocus=i(t.autofocus),this.useGroupValue=i(t.useGroupValue),this.focusSelectedOptionOnOpen=i(t.focusSelectedOptionOnOpen),this.noOptionsText=t.noOptionsText,this.noSearchResultsText=t.noSearchResultsText,this.selectAllText=t.selectAllText,this.searchNormalize=t.searchNormalize,this.searchPlaceholderText=t.searchPlaceholderText,this.searchFormLabel=t.searchFormLabel,this.optionsSelectedText=t.optionsSelectedText,this.optionSelectedText=t.optionSelectedText,this.allOptionsSelectedText=t.allOptionsSelectedText,this.clearButtonText=t.clearButtonText,this.moreText=t.moreText,this.placeholder=t.placeholder,this.position=t.position,this.textDirection=t.textDirection,this.dropboxWidth=t.dropboxWidth,this.tooltipFontSize=t.tooltipFontSize,this.tooltipAlignment=t.tooltipAlignment,this.tooltipMaxWidth=t.tooltipMaxWidth,this.updatePositionThrottle=t.updatePositionThrottle,this.noOfDisplayValues=parseInt(t.noOfDisplayValues),this.zIndex=parseInt(t.zIndex),this.maxValues=parseInt(t.maxValues),this.minValues=parseInt(t.minValues),this.name=this.secureText(t.name),this.additionalClasses=t.additionalClasses,this.additionalDropboxClasses=t.additionalDropboxClasses,this.additionalDropboxContainerClasses=t.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=t.additionalToggleButtonClasses,this.popupDropboxBreakpoint=t.popupDropboxBreakpoint,this.popupPosition=t.popupPosition,this.onServerSearch=t.onServerSearch,this.labelRenderer=t.labelRenderer,this.selectedLabelRenderer=t.selectedLabelRenderer,this.initialSelectedValue=0===t.selectedValue?"0":t.selectedValue,this.emptyValue=t.emptyValue,this.ariaLabelText=t.ariaLabelText,this.ariaLabelledby=t.ariaLabelledby,this.ariaLabelClearButtonText=t.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=t.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=t.ariaLabelSearchClearButtonText,this.maxWidth=t.maxWidth,this.searchDelay=t.searchDelay,this.showDuration=parseInt(t.showDuration),this.hideDuration=parseInt(t.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===t.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(t.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}},{key:"setDefaultProps",value:function(e){var t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}},{key:"setPropsFromElementAttr",value:function(e){var t=e.ele;Object.keys(k).forEach(function(i){var o=t.getAttribute(i);-1===E.indexOf(i)||""!==o&&"true"!==o||(o=!0),o&&(e[k[i]]=o)})}},{key:"setEleProps",value:function(){var t=this.$ele;t.virtualSelect=this,t.value=this.multiple?[]:"",t.name=this.name,t.disabled=!1,t.required=this.required,t.autofocus=this.autofocus,t.multiple=this.multiple,t.form=t.closest("form"),t.reset=e.reset,t.setValue=e.setValueMethod,t.setOptions=e.setOptionsMethod,t.setDisabledOptions=e.setDisabledOptionsMethod,t.setEnabledOptions=e.setEnabledOptionsMethod,t.toggleSelectAll=e.toggleSelectAll,t.isAllSelected=e.isAllSelected,t.addOption=e.addOptionMethod,t.getNewValue=e.getNewValueMethod,t.getDisplayValue=e.getDisplayValueMethod,t.getSelectedOptions=e.getSelectedOptionsMethod,t.getDisabledOptions=e.getDisabledOptionsMethod,t.open=e.openMethod,t.close=e.closeMethod,t.focus=e.focusMethod,t.enable=e.enableMethod,t.disable=e.disableMethod,t.destroy=e.destroyMethod,t.validate=e.validateMethod,t.toggleRequired=e.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}},{key:"setValueMethod",value:function(e,t){var i={},o={},s=[],r=this.multiple,a=n.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){var l=this.maxValues;l&&a.length>l&&a.splice(l)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach(function(e,t){i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}if(this.options.forEach(function(e){var t=n.normalizeValues(e.value);!0!==i[t]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,s.push(e.value))}),r)this.hasOptionGroup&&this.setGroupsSelectedProp(),s.sort(function(e,t){return o[n.normalizeValues(e)]-o[n.normalizeValues(t)]});else{var u=m(s,1);s=u[0]}this.beforeValueSet(),this.setValue(s,{disableEvent:t}),this.afterValueSet()}},{key:"setGroupOptionsValue",value:function(e){var t=[],i={},o={};return e.forEach(function(e){o[e]=!0}),this.options.forEach(function(e){var s=e.value,n=!0===o[s];e.isGroupTitle?n&&(i[e.index]=!0):(n||i[e.groupIndex])&&t.push(s)}),t}},{key:"setGroupsSelectedProp",value:function(){var e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(function(t){t.isGroupTitle&&(t.isSelected=e(t.index))})}},{key:"setOptionsMethod",value:function(e,t){this.setOptions(e),this.afterSetOptions(t)}},{key:"setDisabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setDisabledOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];if(e)if(!0===e)t&&this.options.forEach(function(e){return e.isDisabled=!0,i.push(e.value),e});else{i=e.map(function(e){return e.toString()});var o={};i.forEach(function(e){o[e]=!0}),t&&this.options.forEach(function(e){return e.isDisabled=!0===o[e.value],e})}else t&&this.options.forEach(function(e){return e.isDisabled=!1,e});this.disabledOptions=i}},{key:"setEnabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setEnabledOptions",value:function(e){if(void 0!==e){var t=[];if(!0===e)this.options.forEach(function(e){return e.isDisabled=!1,e});else{var i={};e.forEach(function(e){i[e]=!0}),this.options.forEach(function(e){var o=!0!==i[e.value];return e.isDisabled=o,o&&t.push(e.value),e})}this.disabledOptions=t}}},{key:"setOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=[],o=this.disabledOptions.length,s=this.valueKey,r=this.labelKey,a=this.descriptionKey,l=this.aliasKey,u=this.hasOptionDescription,c=n.getString,p=n.convertToBoolean,h=this.secureText.bind(this),d=this.getAlias.bind(this),v=0,f=!1,m={},g=!1;this.disabledOptions.forEach(function(e){m[e]=!0});var O=function(t){"object"!==y(t)&&(t=b(b({},s,t),r,t));var S=h(c(t[s])),x=h(c(t[r])),w=t.options,k=!!w,C={index:v,value:S,valueNormalized:S.toLowerCase(),label:x,labelNormalized:e.searchNormalize&&""!==x.trim()?n.normalizeString(x).toLowerCase():x.toLowerCase(),alias:d(t[l]),isVisible:p(t.isVisible,!0),isNew:t.isNew||!1,isGroupTitle:k,classNames:t.classNames};if(g||""!==S||(g=!0),o&&(C.isDisabled=!0===m[S]),t.isGroupOption&&(C.isGroupOption=!0,C.groupIndex=t.groupIndex),u){var E=h(c(t[a]));C.description=E,C.descriptionNormalized=e.searchNormalize&&""!==E.trim()?n.normalizeString(E).toLowerCase():E.toLowerCase()}if(t.customData&&(C.customData=t.customData),i.push(C),v+=1,k){var $=C.index;f=!0,w.forEach(function(e){e.isGroupOption=!0,e.groupIndex=$,O(e)})}};Array.isArray(t)&&t.forEach(O);var S=i.length,x=this.$ele;x.options=i,x.length=S,this.options=i,this.visibleOptionsCount=S,this.lastOptionIndex=S-1,this.newValues=[],this.hasOptionGroup=f,this.hasEmptyValueOption=g,this.setSortedOptions()}},{key:"setServerOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setOptionsMethod(t,!0);var i=this.selectedOptions,o=this.options,s=!1;if(i.length){var n={};s=!0,o.forEach(function(e){n[e.value]=!0}),i.forEach(function(e){!0!==n[e.value]&&(e.isVisible=!1,o.push(e))}),this.setOptionsMethod(o,!0)}this.allowNewOption&&this.searchValue&&(o.some(function(t){return t.label.toLowerCase()===e.searchValue})||(s=!0,this.setNewOption())),s?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),d.removeClass(this.$allWrappers,"server-searching")}},{key:"setSelectedOptions",value:function(){this.selectedOptions=this.options.filter(function(e){return e.isSelected})}},{key:"setSortedOptions",value:function(){var e=g(this.options);this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}},{key:"setVisibleOptions",value:function(){var e=g(this.sortedOptions),t=2*this.optionsCount,i=this.getVisibleStartIndex(),o=this.getNewOption(),s=i+t-1,n=0;o&&(o.visibleIndex=n,n+=1),e=e.filter(function(e){var t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=i&&n<=s,e.visibleIndex=n,n+=1),t}),o&&(e=[o].concat(g(e))),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}},{key:"setOptionsPosition",value:function(e){var t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform="translate3d(0, ".concat(t,"px, 0)"),d.setData(this.$options,"top",t)}},{key:"setOptionsTooltip",value:function(){var e=this,t=this.getVisibleOptions(),i=this.hasOptionDescription;t.forEach(function(t){var o=e.$dropboxContainer.querySelector('.vscomp-option[data-index="'.concat(t.index,'"]'));d.setData(o.querySelector(".vscomp-option-text"),"tooltip",t.label),i&&d.setData(o.querySelector(".vscomp-option-description"),"tooltip",t.description)})}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.disableEvent,o=void 0!==i&&i,s=t.disableValidation,r=void 0!==s&&s,a=n.normalizeValues(e);this.hasEmptyValueOption&&""===a||a?Array.isArray(a)?this.selectedValues=g(a):this.selectedValues=[a]:this.selectedValues=[];var l=this.getValue();this.$ele.value=l,this.$hiddenInput.value=this.getInputValue(l),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();var u=n.isNotEmpty(this.selectedValues);d.toggleClass(this.$allWrappers,"has-value",u),d.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),d.setAttr(this.$clearButton,"tabindex",u?"0":"-1"),d.setAria(this.$clearButton,"hidden",!1===u),r||this.validate(),o||d.dispatchEvent(this.$ele,"change",!0)}},{key:"setValueText",value:function(){var e=this,t=this.multiple,i=this.selectedValues,o=this.noOfDisplayValues,s=this.showValueAsTags,r=this.$valueText,a=this.selectedLabelRenderer,l=[],u=[],c=i.length,p=0,h=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!s;if(h&&this.hideValueTooltipOnSelectAll)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(function(t){if(t.isCurrentNew)return!1;if(p>=o)return!0;var i=t.label;if("function"==typeof a&&(i=a(t)),l.push(i),p+=1,s){var c=n.willTextOverflow(r.parentElement,i)?e.getTooltipAttrText(i,!1,!0):"",h="";if(e.ariaLabelTagClearButtonText){var d=i.replace(/<[^>]+>/gi,"").trim();h='aria-label="'.concat(d,", ").concat(e.ariaLabelTagClearButtonText,'"')}var v='\n ').concat(i,'\n \n \n \n ');u.push(v)}else u.push(i);return!1});var v=c-o;v>0&&u.push('+ '.concat(v," ").concat(this.moreText,""));var f=l.join(", ");if(""===f)r.innerHTML=this.placeholder;else if(r.innerHTML=f,t){var b=this.maxValues;if(this.alwaysShowSelectedOptionsCount||d.hasEllipsis(r)||b||s){var y=''.concat(c,"");if(b&&(y+=' / '.concat(b,"")),h)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else if(s)r.innerHTML=u.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){var m=1===c?this.optionSelectedText:this.optionsSelectedText;r.innerHTML="".concat(y," ").concat(m)}}else u=[]}}var g="";0===c?g=this.placeholder:s||(g=u.join(", ")),s||d.setData(r,"tooltip",g),t&&(s?this.updatePosition():d.setData(r,"tooltipEllipsisOnly",0===c))}},{key:"setSearchValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e!==this.searchValueOriginal||i){t||(this.$searchInput.value=e);var o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,d.toggleClass(this.$allWrappers,"has-search-value",e),d.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),d.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}}},{key:"setVisibleOptionsCount",value:function(){var e,t=0,i=!1,o=this.searchGroup,s=this.showOptionsOnlyOnSearch,r=this.searchByStartsWith,a=this.searchValue;a=this.searchNormalize&&""!==a.trim()?n.normalizeString(a):a;var l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(function(n){var u;n.isCurrentNew||(s&&!a?(n.isVisible=!1,u={isVisible:!1,hasExactOption:!1}):u=l({data:n,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),u.isVisible&&(t+=1),i||(i=u.hasExactOption))}),this.allowNewOption&&(a&&!i?(this.setNewOption(),t+=1):this.removeNewOption()),this.visibleOptionsCount=t,this.afterSetVisibleOptionsCount()}},{key:"calculateAriaMetadata",value:function(){var e=this,t=0,i=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(function(o){if(o.isCurrentNew)o.filteredIndex=void 0;else if(!0===o.isVisible){var s=o.isGroupTitle&&e.multiple&&!e.disableOptionGroupCheckbox;!o.isGroupTitle||s?(i+=1,t+=1,o.filteredIndex=i):o.filteredIndex=void 0}else o.filteredIndex=void 0}),this.allowNewOption){var o=this.getNewOption();o&&!0===o.isVisible?(i+=1,t+=1,o.filteredIndex=i):o&&(o.filteredIndex=void 0)}this.ariaSetSize=t}},{key:"setOptionProp",value:function(e,t,i){this.options[e]&&(this.options[e][t]=i)}},{key:"setOptionsHeight",value:function(){this.$optionsList.style.height="".concat(this.optionHeight*this.visibleOptionsCount,"px")}},{key:"setOptionsContainerHeight",value:function(e){var t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(d.setStyle(this.$noOptions,"height",t),d.setStyle(this.$noSearchResults,"height",t))),d.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}},{key:"setNewOption",value:function(e){var t=e||this.searchValueOriginal.trim();if(t){var i=this.getNewOption();if(i){var o=i.index;this.setOptionProp(o,"value",this.secureText(t)),this.setOptionProp(o,"label",this.secureText(t))}else{var s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}}},{key:"setSelectedProp",value:function(){var e={};this.selectedValues.forEach(function(t){e[t]=!0}),this.options.forEach(function(t){!0===e[t.value]&&(t.isSelected=!0)})}},{key:"setNewOptionsFromValue",value:function(e){if(e){var t=this.setNewOption.bind(this),i={};this.options.forEach(function(e){i[e.value]=!0}),e.forEach(function(e){e&&!0!==i[e]&&t(e)})}}},{key:"setDropboxWrapperWidth",value:function(){if(!this.showAsPopup){var e=this.dropboxWidth||"".concat(this.$wrapper.offsetWidth,"px");d.setStyle(this.$dropboxContainer,"max-width",e)}}},{key:"setEleStyles",value:function(){var e=this.maxWidth,t={};e&&(t["max-width"]=e),d.setStyles(this.$ele,t)}},{key:"setDropboxStyles",value:function(){var e=this.dropboxWidth,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),d.setStyles(this.$dropboxContainer,i),d.setStyles(this.$dropbox,t)}},{key:"setOptionAttr",value:function(){var e=this.$visibleOptions,t=this.options,i="".concat(this.optionHeight,"px"),o=d.setStyle,s=d.getData,n=d.setData;e&&e.length&&e.forEach(function(e){var r=t[s(e,"index")];o(e,"height",i),n(e,"value",r.value)})}},{key:"setValueTagAttr",value:function(){var e=this.$valueTags;if(e&&e.length){var t=d.getData,i=d.setData,o=this.options;e.forEach(function(e){var s=t(e,"index");if(void 0!==s){var n=o[s];i(e,"value",n.value)}})}}},{key:"setScrollTop",value:function(){var e=this.selectedValues;if(!this.showSelectedOptionsFirst&&this.focusSelectedOptionOnOpen&&0!==e.length){var t,i={};e.forEach(function(e){i[e]=!0}),this.options.some(function(e){return!!i[e.value]&&(t=e.visibleIndex,!0)}),t&&(this.$optionsContainer.scrollTop=this.optionHeight*t)}}},{key:"getVisibleOptions",value:function(){return this.visibleOptions||[]}},{key:"getValue",value:function(){var e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",n.normalizeValues(e)}},{key:"getGroupValue",value:function(){var e=[],t={};return this.options.forEach(function(i){if(i.isSelected){var o=i.value;i.isGroupTitle?o&&(t[i.index]=!0,e.push(o)):!0!==t[i.groupIndex]&&e.push(o)}}),e}},{key:"getInputValue",value:function(e){var t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}},{key:"getFirstVisibleOptionIndex",value:function(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}},{key:"getVisibleStartIndex",value:function(){var e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}},{key:"getTooltipAttrText",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o={"data-tooltip":(n.containsHTML(e)?n.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":t,"data-tooltip-allow-html":i};return d.getAttributesText(o)}},{key:"getOptionObj",value:function(e){if(e){var t=n.getString,i=this.secureText.bind(this),o=i(t(e.value)),s=i(t(e.label)),r=i(t(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:s,labelNormalized:this.searchNormalize&&""!==s.trim()?n.normalizeString(s).toLowerCase():s.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?n.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}}},{key:"getNewOption",value:function(){var e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}},{key:"getOptionIndex",value:function(e){var t;return this.options.some(function(i){return i.value===e&&(t=i.index,!0)}),t}},{key:"getNewValue",value:function(){var e={};this.newValues.forEach(function(t){e[t]=!0});var t=this.selectedValues.filter(function(t){return!0===e[t]});return this.multiple?t:t[0]}},{key:"getAlias",value:function(e){var t=e;return t&&(t=(t=Array.isArray(t)?t.join(","):t.toString().trim()).toLowerCase()),t||""}},{key:"getDisplayValue",value:function(){var e=[];return this.options.forEach(function(t){t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}},{key:"getSelectedOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fullDetails,i=void 0!==t&&t,o=e.keepSelectionOrder,s=void 0!==o&&o,n=this.valueKey,r=this.labelKey,a=this.selectedValues,l=[];if(this.options.forEach(function(e){if(e.isSelected&&!e.isGroupTitle)if(i)l.push(e);else{var t=b(b({},n,e.value),r,e.label);e.isNew&&(t.isNew=!0),e.customData&&(t.customData=e.customData),l.push(t)}}),s){var u={};a.forEach(function(e,t){u[e]=t}),l.sort(function(e,t){return u[e.value]-u[t.value]})}return this.multiple||i?l:l[0]}},{key:"getDisabledOptions",value:function(){var e=this.valueKey,t=this.labelKey,i=this.disabledOptions,o={},s=[];return i.forEach(function(e){o[e]=!0}),this.options.forEach(function(i){var n=i.value,r=i.label;o[n]&&s.push(b(b({},e,n),t,r))}),s}},{key:"getVisibleOptionGroupsMapping",value:function(e){var t=this.options,i={},o=this.isOptionVisible.bind(this);return(t=this.structureOptionGroup(t)).forEach(function(t){i[t.index]=t.options.some(function(t){return o({data:t,searchValue:e}).isVisible})}),i}},{key:"getOptionsCount",value:function(e){var t;if(this.showAsPopup){var i=80*window.innerHeight/100-48;this.hasSearchContainer&&(i-=40),t=Math.floor(i/this.optionHeight)}else t=parseInt(e);return t}},{key:"getOptionsHeight",value:function(){return"".concat(this.optionsCount*this.optionHeight,"px")}},{key:"getSibling",value:function(e,t){var i="next"===t?"nextElementSibling":"previousElementSibling",o=e;do{o&&(o=o[i])}while(d.hasClass(o,"disabled")||d.hasClass(o,"group-title"));return o}},{key:"getUniqueId",value:function(){var e=n.getRandomInt(1e4);return document.querySelector("#vscomp-ele-wrapper-".concat(e))?this.getUniqueId():e}},{key:"initDropboxPopover",value:function(){var e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}},{key:"openDropbox",value:function(t){var i=this;e.lastInteractedInstance=this;var o="";t||(o=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=t,e.openInstances.forEach(function(e){if(e!==i){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),e.openInstances.add(this),d.setAttr(this.$dropboxWrapper,"tabindex","0"),d.setAria(this.$dropboxWrapper,"hidden",!1),d.setAttr(this.$dropboxContainerTop,"tabindex","0"),d.setAria(this.$dropboxContainerTop,"hidden",!1),d.setAttr(this.$dropboxContainerBottom,"tabindex","0"),d.setAria(this.$dropboxContainerBottom,"hidden",!1),t?d.setStyle(this.$dropboxContainer,"display","inline-flex"):(d.dispatchEvent(this.$ele,"beforeOpen"),d.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),d.removeClass(this.$allWrappers,"closed"),d.changeTabIndex(this.$allWrappers,0),t||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=o),this.dropboxPopover&&!t?this.dropboxPopover.show():this.afterShowPopper()}},{key:"afterShowPopper",value:function(){var e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),d.addClass(this.$allWrappers,"focused"),this.showAsPopup?(d.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),d.dispatchEvent(this.$ele,"afterOpen"))}},{key:"closeDropbox",value:function(t){if(this.isSilentClose=t,e.openInstances.delete(this),!1!==this.isOpened())if(this.keepAlwaysOpen)this.removeOptionFocus();else{var i=document.activeElement,o=i&&this.$wrapper.contains(i)||this.hasDropboxWrapper&&i&&this.$dropboxWrapper.contains(i);this.shouldFocusWrapperOnClose&&e.lastInteractedInstance===this&&!t&&(null===i||i===document.body||o)&&this.$wrapper.focus(),t?d.setStyle(this.$dropboxContainer,"display",""):(d.dispatchEvent(this.$ele,"beforeClose"),d.setAria(this.$wrapper,"expanded",!1),d.setAria(this.$wrapper,"activedescendant",""),d.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!t?(this.dropboxPopover.hide(),d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}}},{key:"afterHidePopper",value:function(){var e=this.isSilentClose;this.isSilentClose=!1,d.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(d.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),d.addClass(this.$allWrappers,"closed"),e||d.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)}},{key:"moveSelectedOptionsFirst",value:function(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}},{key:"toggleDropbox",value:function(){e.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}},{key:"updatePosition",value:function(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}},{key:"isOpened",value:function(){return!d.hasClass(this.$wrapper,"closed")}},{key:"focusSearchInput",value:function(){var e=this.$searchInput;e&&e.focus()}},{key:"focusElementOnOpen",value:function(){var e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(d.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{var i=this.$dropbox.querySelector('[tabindex="0"]');void 0!==d.getData(i,"index")?this.focusOption({direction:"next"}):i?i.focus():this.focusFirstVisibleOption()}}},{key:"focusFirstVisibleOption",value:function(){var e=this.$optionsContainer.querySelector("[data-index='".concat(this.getFirstVisibleOptionIndex(),"']"));e?(d.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),d.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'))&&e.focus()}},{key:"focusOption",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.direction,o=t.$option,s=t.focusFirst,n=this.$dropboxContainer.querySelector(".vscomp-option.focused");if(o)e=o;else if(!n||s){var r=this.getFirstVisibleOptionIndex();e=this.$dropboxContainer.querySelector('.vscomp-option[data-visible-index="'.concat(r,'"]')),(d.hasClass(e,"disabled")||d.hasClass(e,"group-title"))&&(e=this.getSibling(e,"next"))}else e=this.getSibling(n,i);e&&e!==n&&(n&&this.toggleOptionFocusedState(n,!1),this.toggleOptionFocusedState(e,!0),this.toggleFocusedProp(d.getData(e,"index"),!0),this.moveFocusedOptionToView(e))}},{key:"moveFocusedOptionToView",value:function(e){var t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(t){var i,o=this.$optionsContainer.getBoundingClientRect(),s=t.getBoundingClientRect(),n=o.top,r=o.bottom,a=o.height,l=s.top,u=s.bottom,c=s.height,p=t.offsetTop,h=d.getData(this.$options,"top","number");n>l?i=p+h:r1&&void 0!==arguments[1]?arguments[1]:{}).event;if(e){var i=!d.hasClass(e,"selected");if(i){if(this.multiple&&this.isMaxValuesSelected)return}else if(!this.multiple)return void this.closeDropbox();var o=this.selectedValues,s=d.getData(e,"value"),r=d.getData(e,"index","number"),a=d.hasClass(e,"current-new"),l=!1,u=this.lastSelectedOptionIndex;if(this.lastSelectedOptionIndex=null,this.toggleSelectedProp(r,i),i){if(this.multiple)o.push(s),this.toggleAllOptionsClass(),this.toggleGroupOptionsParent(e),t&&t.shiftKey&&(l=!0);else{o.length&&this.toggleSelectedProp(this.getOptionIndex(o[0]),!1),o=[s];var c=this.$dropboxContainer.querySelector(".vscomp-option.selected");c&&this.toggleOptionSelectedState(c,!1),this.closeDropbox(),a||this.setSearchValue("")}this.lastSelectedOptionIndex=r,this.toggleOptionSelectedState(e)}else this.multiple&&(this.toggleOptionSelectedState(e),n.removeItemFromArray(o,s),this.toggleAllOptionsClass(!1),this.toggleGroupOptionsParent(e,!1));a&&this.beforeSelectNewValue(s),this.setValue(o),l&&this.selectRangeOptions(u,r)}}},{key:"selectFocusedOption",value:function(){this.selectOption(this.$dropboxContainer.querySelector(".vscomp-option.focused"))}},{key:"selectRangeOptions",value:function(e,t){var i=this;if("number"==typeof e&&!this.maxValues){var o,s,n=this.selectedValues,r=this.hasOptionGroup,a={};if(eo&&t0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),d.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}}},{key:"isAllOptionsSelected",value:function(e){var t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible)})),t}},{key:"isAllGroupOptionsSelected",value:function(e){var t=!1;return this.options.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e})),t}},{key:"toggleGroupOptionsParent",value:function(e,t){if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var i=d.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));var o=this.$options.querySelector('.vscomp-option[data-index="'.concat(i,'"]')),s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,s),this.toggleGroupTitleProp(i,s)}}},{key:"toggleGroupTitleProp",value:function(e,t){var i="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,i)}},{key:"toggleGroupOptions",value:function(e,t){var i=this;if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var o=d.getData(e,"index","number"),s=this.selectedValues,r=this.selectAllOnlyVisible,a={},l=n.removeItemFromArray;s.forEach(function(e){a[e]=!0}),this.options.forEach(function(e){if(!e.isDisabled&&e.groupIndex===o){var i=e.value;!t||r&&!e.isVisible?(e.isSelected=!1,a[i]&&l(s,i)):(e.isSelected=!0,a[i]||s.push(i))}}),this.toggleAllOptionsClass(!!t&&null),this.setValue(s),setTimeout(function(){i.renderOptions()},0)}}},{key:"toggleGroupTitleCheckbox",value:function(e,t){if(e){var i=d.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}}},{key:"toggleFocusedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}},{key:"toggleSelectedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setOptionProp(e,"isSelected",t)}},{key:"scrollToTop",value:function(){this.$optionsContainer.scrollTop>0&&(this.$optionsContainer.scrollTop=0)}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.options.forEach(function(e){e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&d.removeClass(this.$allWrappers,"has-error"),d.dispatchEvent(this.$ele,"reset")}},{key:"addOption",value:function(e,t){if(e){this.lastOptionIndex+=1;var i=this.getOptionObj(f(f({},e),{},{index:this.lastOptionIndex}));this.options.push(i),this.sortedOptions.push(i),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}}},{key:"removeOption",value:function(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}},{key:"removeNewOption",value:function(){var e=this.getNewOption();e&&this.removeOption(e.index)}},{key:"sortOptions",value:function(e){return e.sort(function(e,t){var i=e.isSelected||e.isAnySelected,o=t.isSelected||t.isAnySelected;return i||o?i&&(!o||e.index0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.virtualSelect.reset(e,t)}},{key:"setValueMethod",value:function(){var e;(e=this.virtualSelect).setValueMethod.apply(e,arguments)}},{key:"setOptionsMethod",value:function(){var e;(e=this.virtualSelect).setOptionsMethod.apply(e,arguments)}},{key:"setDisabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setDisabledOptionsMethod.apply(e,arguments)}},{key:"setEnabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setEnabledOptionsMethod.apply(e,arguments)}},{key:"toggleSelectAll",value:function(e){this.virtualSelect.toggleAllOptions(e)}},{key:"isAllSelected",value:function(){return this.virtualSelect.isAllSelected}},{key:"addOptionMethod",value:function(e){this.virtualSelect.addOption(e,!0)}},{key:"getNewValueMethod",value:function(){return this.virtualSelect.getNewValue()}},{key:"getDisplayValueMethod",value:function(){return this.virtualSelect.getDisplayValue()}},{key:"getSelectedOptionsMethod",value:function(e){return this.virtualSelect.getSelectedOptions(e)}},{key:"getDisabledOptionsMethod",value:function(){return this.virtualSelect.getDisabledOptions()}},{key:"openMethod",value:function(){return this.virtualSelect.openDropbox()}},{key:"closeMethod",value:function(){return this.virtualSelect.closeDropbox()}},{key:"focusMethod",value:function(){return this.virtualSelect.focus()}},{key:"enableMethod",value:function(){return this.virtualSelect.enable()}},{key:"disableMethod",value:function(){return this.virtualSelect.disable()}},{key:"destroyMethod",value:function(){return this.virtualSelect.destroy()}},{key:"validateMethod",value:function(){return this.virtualSelect.validate()}},{key:"toggleRequiredMethod",value:function(e){return this.virtualSelect.toggleRequired(e)}},{key:"onResizeMethod",value:function(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(function(e){e.parentElement.virtualSelect.onResize()})}}],i&&x(t.prototype,i),o&&x(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();document.addEventListener("reset",T.onFormReset),document.addEventListener("submit",T.onFormSubmit),window.addEventListener("resize",T.onResizeMethod),k=T.getAttrProps(),window.VirtualSelect=T,T.openInstances=new Set,T.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=new Array(t);ii-s-t.width?"left":"right",vertical:n>o-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),i=window.pageXOffset,o=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+o,right:t.right+i,bottom:t.bottom+o,left:t.left+i}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"show",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",i)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,i=e.parentElement;i;){var o=getComputedStyle(i).overflow;if(-1!==o.indexOf("scroll")||-1!==o.indexOf("auto")){t=i;break}i=i.parentElement}return t}}],i&&function(e,t){for(var i=0;ig?g-f:M:k+c>L&&("right"===E?n="left":k=L+fO?O-h:P:C+p>I&&("bottom"===E?n="top":C=I+hc-R&&(G=c-R):"left"!==E&&"right"!==E||((H=y/2+m-j)p-R&&(H=p-R)),i.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}i.hide(this.$popperEle)}},{key:"resetPosition",value:function(){i.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=t.resetPosition,s=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),o&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=i.getData(e.$popperEle,"left"),o=i.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(o),"px, 0)"),r=e.showDuration;i.show(e.$popperEle,"inline-flex"),i.getCoords(e.$popperEle),i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(s)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var o=parseInt(i.getData(e.$popperEle,"fromLeft")),s=parseInt(i.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(o,"px, ").concat(s,"px, 0)"),r=e.hideDuration;i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){i.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){i.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(i.getData(this.$popperEle,"left")),t=parseInt(i.getData(this.$popperEle,"top"));i.show(this.$popperEle,"inline-flex"),i.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var i=0;i1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var i,o=0;return function(){for(var s=arguments.length,n=new Array(s),r=0;re.length)&&(t=e.length);for(var i=0,o=new Array(t);i'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&p(t.prototype,i),s&&p(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,s}();d=b.getAttrProps(),window.PopoverComponent=b}(); \ No newline at end of file + */!function(){"use strict";const e=/[^\p{L}\p{N}_]/gu;class t{static getString(e){return e||0===e?e.toString():""}static convertToBoolean(e,t=!1){let s;return s=!0===e||"true"===e||!1!==e&&"false"!==e&&t,s}static isEmpty(e){let t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"==typeof e&&0===Object.keys(e).length&&(t=!0):t=!0,t}static isNotEmpty(e){return!t.isEmpty(e)}static normalizeValues(e){if(Array.isArray(e)){const t=new Array(e.length);for(let s=0;s!!e):[]}static getRandomInt(e,t=0){const s=Math.ceil(t),i=Math.floor(e);return Math.floor(Math.random()*(i-s-1))+s}static regexEscape(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static normalizeString(t){return t.normalize("NFD").replace(e,"")}static willTextOverflow(e,t){const s=document.createElement("div");s.style.position="absolute",s.style.visibility="hidden",s.style.whiteSpace="nowrap",s.style.fontSize=window.getComputedStyle(e).fontSize,s.style.fontFamily=window.getComputedStyle(e).fontFamily,s.textContent=t,document.body.appendChild(s);const i=s.clientWidth;return document.body.removeChild(s),i>e.clientWidth}static replaceDoubleQuotesWithHTML(e){return e.replace(/"/g,""")}static containsHTML(e){return/<[a-z][\s\S]*>/i.test(e)}static containsHTMLorJS(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}class s{static addClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.add(...i)})}static removeClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.remove(...i)})}static toggleClass(e,t,i){if(!e)return;let o;void 0!==i&&(o=Boolean(i)),s.getElements(e).forEach(e=>{e.classList.toggle(t,o)})}static hasClass(e,t){return!!e&&e.classList.contains(t)}static hasEllipsis(e){return!!e&&e.scrollWidth>e.offsetWidth}static getData(e,t,s){if(!e)return;let i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}static setData(e,t,s){e&&(e.dataset[t]=s)}static setAttr(e,t,s){e&&e.setAttribute(t,s)}static setAttrFromEle(e,t,s,i){const o={};s.forEach(t=>{o[t]=e.getAttribute(t)}),s.forEach(e=>{const s=o[e];(s||-1!==i.indexOf(e)&&""===s)&&t.setAttribute(e,s)})}static setStyle(e,t,s){e&&(e.style[t]=s)}static setStyles(e,t){e&&t&&Object.keys(t).forEach(s=>{e.style[s]=t[s]})}static setAria(e,t,s){if(!e)return;let i=t;"role"!==i&&(i=`aria-${i}`),e.setAttribute(i,s)}static getElements(e){return e?void 0===e.forEach?[e]:e:[]}static getElementsBySelector(e="",t=void 0){let s;const i=void 0!==t?t:document;return""!==e&&(s=i.querySelectorAll(e)),void 0!==s?Array.from(s):[]}static addEvent(e,i,o,n){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{s.getElements(e).forEach(e=>{e.addEventListener(t,o,{capture:n})})})}static dispatchEvent(e,t,i=!1){if(!e)return;const o=s.getElements(e);setTimeout(()=>{o.forEach(e=>{e.dispatchEvent(new CustomEvent(t,{bubbles:i}))})},0)}static getAttributesText(e){let t="";return e?(Object.entries(e).forEach(([e,s])=>{void 0!==s&&(t+=` ${e}="${s}" `)}),t):t}static convertPropToDataAttr(e){return e?`data-${e}`.replace(/([A-Z])/g,"-$1").toLowerCase():""}static changeTabIndex(e,t){e?s.getElements(e).forEach(e=>{e.tabIndex=t}):console.log(e,"Invalid element provided.")}static removeEvent(e,t,i){e&&s.getElements(e).forEach(e=>{e.removeEventListener(t,i)})}}const i={13:"onEnterPress",38:"onUpArrowPress",40:"onDownArrowPress",46:"onBackspaceOrDeletePress",8:"onBackspaceOrDeletePress"},o=["autofocus","disabled","multiple","required"],n=["autofocus","class","disabled","id","multiple","name","placeholder","required"];let r;const a=["additionalClasses","additionalDropboxClasses","additionalDropboxContainerClasses","additionalToggleButtonClasses","aliasKey","allOptionsSelectedText","allowNewOption","alwaysShowSelectedOptionsCount","alwaysShowSelectedOptionsLabel","ariaLabelledby","ariaLabelText","ariaLabelClearButtonText","ariaLabelTagClearButtonText","ariaLabelSearchClearButtonText","autoSelectFirstOption","clearButtonText","descriptionKey","disableAllOptionsSelectedText","disableOptionGroupCheckbox","disableSelectAll","disableValidation","dropboxWidth","dropboxWrapper","emptyValue","enableSecureText","focusSelectedOptionOnOpen","hasOptionDescription","hideClearButton","hideValueTooltipOnSelectAll","keepAlwaysOpen","labelKey","markSearchResults","maxValues","maxWidth","minValues","moreText","noOfDisplayValues","noOptionsText","noSearchResultsText","optionHeight","optionSelectedText","optionsCount","optionsSelectedText","popupDropboxBreakpoint","popupPosition","position","search","searchByStartsWith","searchDelay","searchFormLabel","searchGroup","searchNormalize","searchPlaceholderText","selectAllOnlyVisible","selectAllText","setValueAsArray","showDropboxAsPopup","showOptionsOnlyOnSearch","showSelectedOptionsFirst","showValueAsTags","silentInitialValueSet","textDirection","tooltipAlignment","tooltipFontSize","tooltipMaxWidth","updatePositionThrottle","useGroupValue","valueKey","zIndex"];class l{constructor(e){try{this.createSecureTextElements(),this.setProps(e),this.setDisabledOptions(e.disabledOptions),this.setOptions(e.options),this.render()}catch(e){console.warn("Couldn't initiate Virtual Select"),console.error(e)}}render(){if(!this.$ele)return;const{uniqueId:e}=this;let t="vscomp-wrapper",i="vscomp-toggle-button";const o=this.showValueAsTags?"":this.getTooltipAttrText(this.placeholder,!0,!0),n=this.getTooltipAttrText(this.clearButtonText),r=this.ariaLabelledby?`aria-labelledby="${this.ariaLabelledby}"`:"",a=this.ariaLabelText?`aria-label="${this.ariaLabelText}"`:"",l=this.ariaLabelClearButtonText?`aria-label="${this.ariaLabelClearButtonText}"`:"";let p=!1;this.additionalClasses&&(t+=` ${this.additionalClasses}`),this.additionalToggleButtonClasses&&(i+=` ${this.additionalToggleButtonClasses}`),this.multiple&&(t+=" multiple",this.disableSelectAll||(t+=" has-select-all")),this.hideClearButton||(t+=" has-clear-button"),this.keepAlwaysOpen?(t+=" keep-always-open",p=!0):t+=" closed",this.showAsPopup&&(t+=" show-as-popup"),this.hasSearch&&(t+=" has-search-input"),this.showValueAsTags&&(t+=" show-value-as-tags"),this.textDirection&&(t+=` text-direction-${this.textDirection}`),this.popupPosition&&(t+=` popup-position-${this.popupPosition.toLowerCase()}`);const h=`
\n \n
\n
\n ${this.placeholder}\n
\n
\n
\n \n
\n
\n\n ${this.renderDropbox({wrapperClasses:t})}\n
`;this.$ele.innerHTML=h,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),s.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}renderDropbox({wrapperClasses:e}){const t="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null;let i="vscomp-dropbox";this.additionalDropboxClasses&&(i+=` ${this.additionalDropboxClasses}`);let o="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(o+=` ${this.additionalDropboxContainerClasses}`);const n=`
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
${this.noOptionsText}
\n
${this.noSearchResultsText}
\n\n \n
\n \n
`;if(t){const i=document.createElement("div");return this.$dropboxWrapper=i,this.hasDropboxWrapper=!0,i.innerHTML=n,t.appendChild(i),s.addClass(i,`vscomp-dropbox-wrapper ${e}`),this.keepAlwaysOpen||(s.setAttr(i,"tabindex","-1"),s.setAria(i,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}renderOptions(){this.calculateAriaMetadata();let e="";const s=this.getVisibleOptions();let i="",o="";const n=!(!this.markSearchResults||!this.searchValue);let r;const{labelRenderer:a,disableOptionGroupCheckbox:l,uniqueId:p,searchGroup:h}=this,c="function"==typeof a,{convertToBoolean:u}=t;let d="";if(n&&(r=new RegExp(`(${t.regexEscape(this.searchValue)})(?!([^<]+)?>)`,"gi")),this.multiple&&(i=''),this.allowNewOption){const e=this.getTooltipAttrText("New Option");o=``}s.forEach(t=>{const{index:s}=t;let v,b="vscomp-option";const f=this.getTooltipAttrText("",!0,!0);let m=i,g="",O="",y="",x="",S="-1";const $=u(t.isSelected);let w="";if(t.classNames&&(b+=` ${t.classNames}`),t.isFocused&&(S="0",b+=" focused"),t.isDisabled&&(b+=" disabled",w='aria-disabled="true"'),t.isGroupTitle&&(d=t.label,b+=" group-title",l&&(m="")),$&&(b+=" selected"),t.isGroupOption){let e="";b+=" group-option",y=`data-group-index="${t.groupIndex}"`,t.customData?(d=void 0!==t.customData.group_name?`${t.customData.group_name}, `:"",e=void 0!==t.customData.description?` ${t.customData.description},`:"",x=`aria-label="${d} ${t.label}, ${e}"`):x=`aria-label="${d}, ${t.label}"`}v=c?a(t):t.label,t.description&&(O=`
${t.description}
`),t.isCurrentNew?(b+=" current-new",g+=o):!n||t.isGroupTitle&&!h||(v=v.replace(r,"$1"));let C="";this.ariaSetSize>0&&(C=`aria-setsize="${this.ariaSetSize}"`,t.filteredIndex&&(C+=` aria-posinset="${t.filteredIndex}"`)),e+=`
\n ${m}\n \n ${v}\n \n ${O}\n ${g}\n
`}),d="",this.$options.innerHTML=e,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}renderSearch(){if(!this.hasSearchContainer)return;let e="",t="";if(this.multiple&&!this.disableSelectAll&&(e=`\n \n ${this.selectAllText}\n `),this.hasSearch){const e=this.ariaLabelSearchClearButtonText?`aria-label="${this.ariaLabelSearchClearButtonText}"`:"";t=`\n \n ×`}const s=`
\n ${e}\n ${t}\n
`;this.$search.innerHTML=s,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}addEvents(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}addEvent(e,i,o,n=!1){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`;let r=this.events[i];r||(r=this[o].bind(this),this.events[i]=r),s.addEvent(e,t,r,n)})}removeEvents(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}removeEvent(e,i,o){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`,n=this.events[i];n&&s.removeEvent(e,t,n)})}onDocumentClick(e){const t=e.target.closest(".vscomp-wrapper");if(!t)return void l.openInstances.forEach(e=>{const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()});const s=t.parentElement.virtualSelect;s&&s!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}onKeyDown(e){const t=e.which||e.keyCode,s=i[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){const e=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(e&&(document.activeElement===e||e.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}s&&this[s](e)}else this.toggleAllOptions()}onEnterPress(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}onDownArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}onUpArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}onBackspaceOrDeletePress(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}onToggleButtonPress(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}const t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}onClearButtonClick(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}onOptionsScroll(){this.setVisibleOptions(!0)}onOptionsClick(e){const t=e.target.closest(".vscomp-option");t&&!s.hasClass(t,"disabled")&&(s.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}onGroupTitleClick(e){if(!e||!this.multiple||this.disableOptionGroupCheckbox)return;const t=!s.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}onDropboxContainerClick(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}onDropboxCloseButtonClick(){this.closeDropbox()}onOptionsMouseOver(e){const t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(s.hasClass(t,"disabled")||s.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}onOptionsTouchMove(){this.removeOptionFocus()}onSearch(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}preventPropagation(e){e.stopPropagation()}onSearchClear(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}onToggleAllOptions(){this.toggleAllOptions()}onDropboxContainerTopOrBottomFocus(){this.closeDropbox()}onResize(){this.setOptionsContainerHeight(!0)}addMutationObserver(){if(!this.hasDropboxWrapper)return;const e=this.$ele;this.mutationObserver=new MutationObserver(t=>{let s=!1,i=!1;t.forEach(t=>{s||(s=[...t.addedNodes].some(t=>!(t!==e&&!t.contains(e)))),i||(i=[...t.removedNodes].some(t=>!(t!==e&&!t.contains(e))))}),i&&!s&&this.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}removeMutationObserver(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}beforeValueSet(e){this.toggleAllOptionsClass(!e&&void 0)}beforeSelectNewValue(e){const t=this.getNewOption();if(t){const e=t.index;this.newValues.push(t.value),this.setOptionProp(e,"isCurrentNew",!1),this.setOptionProp(e,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(()=>{this.setSearchValue(""),this.focusSearchInput()},0)}afterRenderWrapper(){s.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}afterRenderOptions(){const e=this.getVisibleOptions(),t=!this.options.length&&!this.hasServerSearch,i=!t&&!e.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(s.toggleClass(this.$allWrappers,"has-no-search-results",i),i?(s.setAttr(this.$noSearchResults,"tabindex","0"),s.setAttr(this.$noSearchResults,"aria-hidden","false")):(s.setAttr(this.$noSearchResults,"tabindex","-1"),s.setAttr(this.$noSearchResults,"aria-hidden","true"))),s.toggleClass(this.$allWrappers,"has-no-options",t),t?(s.setAttr(this.$noOptions,"tabindex","0"),s.setAttr(this.$noOptions,"aria-hidden","false")):(s.setAttr(this.$noOptions,"tabindex","-1"),s.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(()=>{const e=s.getElementsBySelector(".focused",this.$dropboxContainer)[0];void 0!==e&&e.focus({preventScroll:!0})},20)}afterSetOptionsContainerHeight(e){e&&this.showAsPopup&&this.setVisibleOptions()}afterSetSearchValue(){this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(()=>{this.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}afterSetVisibleOptionsCount(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}afterValueSet(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}afterSetOptions(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}setProps(e){const s=this.setDefaultProps(e);this.setPropsFromElementAttr(s);const{convertToBoolean:i}=t;this.$ele=s.ele,this.dropboxWrapper=s.dropboxWrapper,this.valueKey=s.valueKey,this.labelKey=s.labelKey,this.descriptionKey=s.descriptionKey,this.aliasKey=s.aliasKey,this.optionHeightText=s.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(s.multiple),this.hasSearch=i(s.search),this.searchByStartsWith=i(s.searchByStartsWith),this.searchGroup=i(s.searchGroup),this.hideClearButton=i(s.hideClearButton),this.autoSelectFirstOption=i(s.autoSelectFirstOption),this.hasOptionDescription=i(s.hasOptionDescription),this.silentInitialValueSet=i(s.silentInitialValueSet),this.allowNewOption=i(s.allowNewOption),this.markSearchResults=i(s.markSearchResults),this.showSelectedOptionsFirst=i(s.showSelectedOptionsFirst),this.disableSelectAll=i(s.disableSelectAll),this.keepAlwaysOpen=i(s.keepAlwaysOpen),this.showDropboxAsPopup=i(s.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(s.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(s.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(s.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(s.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(s.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(s.disableAllOptionsSelectedText),this.showValueAsTags=i(s.showValueAsTags),this.disableOptionGroupCheckbox=i(s.disableOptionGroupCheckbox),this.enableSecureText=i(s.enableSecureText),this.setValueAsArray=i(s.setValueAsArray),this.disableValidation=i(s.disableValidation),this.initialDisabled=i(s.disabled),this.required=i(s.required),this.autofocus=i(s.autofocus),this.useGroupValue=i(s.useGroupValue),this.focusSelectedOptionOnOpen=i(s.focusSelectedOptionOnOpen),this.noOptionsText=s.noOptionsText,this.noSearchResultsText=s.noSearchResultsText,this.selectAllText=s.selectAllText,this.searchNormalize=s.searchNormalize,this.searchPlaceholderText=s.searchPlaceholderText,this.searchFormLabel=s.searchFormLabel,this.optionsSelectedText=s.optionsSelectedText,this.optionSelectedText=s.optionSelectedText,this.allOptionsSelectedText=s.allOptionsSelectedText,this.clearButtonText=s.clearButtonText,this.moreText=s.moreText,this.placeholder=s.placeholder,this.position=s.position,this.textDirection=s.textDirection,this.dropboxWidth=s.dropboxWidth,this.tooltipFontSize=s.tooltipFontSize,this.tooltipAlignment=s.tooltipAlignment,this.tooltipMaxWidth=s.tooltipMaxWidth,this.updatePositionThrottle=s.updatePositionThrottle,this.noOfDisplayValues=parseInt(s.noOfDisplayValues),this.zIndex=parseInt(s.zIndex),this.maxValues=parseInt(s.maxValues),this.minValues=parseInt(s.minValues),this.name=this.secureText(s.name),this.additionalClasses=s.additionalClasses,this.additionalDropboxClasses=s.additionalDropboxClasses,this.additionalDropboxContainerClasses=s.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=s.additionalToggleButtonClasses,this.popupDropboxBreakpoint=s.popupDropboxBreakpoint,this.popupPosition=s.popupPosition,this.onServerSearch=s.onServerSearch,this.labelRenderer=s.labelRenderer,this.selectedLabelRenderer=s.selectedLabelRenderer,this.initialSelectedValue=0===s.selectedValue?"0":s.selectedValue,this.emptyValue=s.emptyValue,this.ariaLabelText=s.ariaLabelText,this.ariaLabelledby=s.ariaLabelledby,this.ariaLabelClearButtonText=s.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=s.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=s.ariaLabelSearchClearButtonText,this.maxWidth=s.maxWidth,this.searchDelay=s.searchDelay,this.showDuration=parseInt(s.showDuration),this.hideDuration=parseInt(s.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===s.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(s.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}setDefaultProps(e){const t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}setPropsFromElementAttr(e){const t=e.ele;Object.keys(r).forEach(s=>{let i=t.getAttribute(s);-1===o.indexOf(s)||""!==i&&"true"!==i||(i=!0),i&&(e[r[s]]=i)})}setEleProps(){const{$ele:e}=this;e.virtualSelect=this,e.value=this.multiple?[]:"",e.name=this.name,e.disabled=!1,e.required=this.required,e.autofocus=this.autofocus,e.multiple=this.multiple,e.form=e.closest("form"),e.reset=l.reset,e.setValue=l.setValueMethod,e.setOptions=l.setOptionsMethod,e.setDisabledOptions=l.setDisabledOptionsMethod,e.setEnabledOptions=l.setEnabledOptionsMethod,e.toggleSelectAll=l.toggleSelectAll,e.isAllSelected=l.isAllSelected,e.addOption=l.addOptionMethod,e.getNewValue=l.getNewValueMethod,e.getDisplayValue=l.getDisplayValueMethod,e.getSelectedOptions=l.getSelectedOptionsMethod,e.getDisabledOptions=l.getDisabledOptionsMethod,e.open=l.openMethod,e.close=l.closeMethod,e.focus=l.focusMethod,e.enable=l.enableMethod,e.disable=l.disableMethod,e.destroy=l.destroyMethod,e.validate=l.validateMethod,e.toggleRequired=l.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}setValueMethod(e,s){const i={},o={};let n=[];const r=this.multiple;let a=t.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){const{maxValues:e}=this;e&&a.length>e&&a.splice(e)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach((e,t)=>{i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}this.options.forEach(e=>{const s=t.normalizeValues(e.value);!0!==i[s]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,n.push(e.value))}),r?(this.hasOptionGroup&&this.setGroupsSelectedProp(),n.sort((e,s)=>o[t.normalizeValues(e)]-o[t.normalizeValues(s)])):[n]=n,this.beforeValueSet(),this.setValue(n,{disableEvent:s}),this.afterValueSet()}setGroupOptionsValue(e){const t=[],s={},i={};return e.forEach(e=>{i[e]=!0}),this.options.forEach(e=>{const{value:o}=e,n=!0===i[o];e.isGroupTitle?n&&(s[e.index]=!0):(n||s[e.groupIndex])&&t.push(o)}),t}setGroupsSelectedProp(){const e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(t=>{t.isGroupTitle&&(t.isSelected=e(t.index))})}setOptionsMethod(e,t){this.setOptions(e),this.afterSetOptions(t)}setDisabledOptionsMethod(e,t=!1){this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setDisabledOptions(e,t=!1){let s=[];if(e)if(!0===e)t&&this.options.forEach(e=>(e.isDisabled=!0,s.push(e.value),e));else{s=e.map(e=>e.toString());const i={};s.forEach(e=>{i[e]=!0}),t&&this.options.forEach(e=>(e.isDisabled=!0===i[e.value],e))}else t&&this.options.forEach(e=>(e.isDisabled=!1,e));this.disabledOptions=s}setEnabledOptionsMethod(e,t=!1){this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setEnabledOptions(e){if(void 0===e)return;const t=[];if(!0===e)this.options.forEach(e=>(e.isDisabled=!1,e));else{const s={};e.forEach(e=>{s[e]=!0}),this.options.forEach(e=>{const i=!0!==s[e.value];return e.isDisabled=i,i&&t.push(e.value),e})}this.disabledOptions=t}setOptions(e=[]){const s=[],i=this.disabledOptions.length,{valueKey:o,labelKey:n,descriptionKey:r,aliasKey:a,hasOptionDescription:l}=this,{getString:p,convertToBoolean:h}=t,c=this.secureText.bind(this),u=this.getAlias.bind(this);let d=0,v=!1;const b={};let f=!1;this.disabledOptions.forEach(e=>{b[e]=!0});const m=e=>{"object"!=typeof e&&(e={[o]:e,[n]:e});const g=c(p(e[o])),O=c(p(e[n])),y=e.options,x=!!y,S={index:d,value:g,valueNormalized:g.toLowerCase(),label:O,labelNormalized:this.searchNormalize&&""!==O.trim()?t.normalizeString(O).toLowerCase():O.toLowerCase(),alias:u(e[a]),isVisible:h(e.isVisible,!0),isNew:e.isNew||!1,isGroupTitle:x,classNames:e.classNames};if(f||""!==g||(f=!0),i&&(S.isDisabled=!0===b[g]),e.isGroupOption&&(S.isGroupOption=!0,S.groupIndex=e.groupIndex),l){const s=c(p(e[r]));S.description=s,S.descriptionNormalized=this.searchNormalize&&""!==s.trim()?t.normalizeString(s).toLowerCase():s.toLowerCase()}if(e.customData&&(S.customData=e.customData),s.push(S),d+=1,x){const e=S.index;v=!0,y.forEach(t=>{t.isGroupOption=!0,t.groupIndex=e,m(t)})}};Array.isArray(e)&&e.forEach(m);const g=s.length,{$ele:O}=this;O.options=s,O.length=g,this.options=s,this.visibleOptionsCount=g,this.lastOptionIndex=g-1,this.newValues=[],this.hasOptionGroup=v,this.hasEmptyValueOption=f,this.setSortedOptions()}setServerOptions(e=[]){this.setOptionsMethod(e,!0);const{selectedOptions:t}=this,i=this.options;let o=!1;if(t.length){const e={};o=!0,i.forEach(t=>{e[t.value]=!0}),t.forEach(t=>{!0!==e[t.value]&&(t.isVisible=!1,i.push(t))}),this.setOptionsMethod(i,!0)}this.allowNewOption&&this.searchValue&&(i.some(e=>e.label.toLowerCase()===this.searchValue)||(o=!0,this.setNewOption())),o?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),s.removeClass(this.$allWrappers,"server-searching")}setSelectedOptions(){this.selectedOptions=this.options.filter(e=>e.isSelected)}setSortedOptions(){let e=[...this.options];this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}setVisibleOptions(){let e=[...this.sortedOptions];const t=2*this.optionsCount,s=this.getVisibleStartIndex(),i=this.getNewOption(),o=s+t-1;let n=0;i&&(i.visibleIndex=n,n+=1),e=e.filter(e=>{let t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=s&&n<=o,e.visibleIndex=n,n+=1),t}),i&&(e=[i,...e]),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}setOptionsPosition(e){const t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform=`translate3d(0, ${t}px, 0)`,s.setData(this.$options,"top",t)}setOptionsTooltip(){const e=this.getVisibleOptions(),{hasOptionDescription:t}=this;e.forEach(e=>{const i=this.$dropboxContainer.querySelector(`.vscomp-option[data-index="${e.index}"]`);s.setData(i.querySelector(".vscomp-option-text"),"tooltip",e.label),t&&s.setData(i.querySelector(".vscomp-option-description"),"tooltip",e.description)})}setValue(e,{disableEvent:i=!1,disableValidation:o=!1}={}){const n=t.normalizeValues(e);this.hasEmptyValueOption&&""===n||n?Array.isArray(n)?this.selectedValues=[...n]:this.selectedValues=[n]:this.selectedValues=[];const r=this.getValue();this.$ele.value=r,this.$hiddenInput.value=this.getInputValue(r),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();const a=t.isNotEmpty(this.selectedValues);s.toggleClass(this.$allWrappers,"has-value",a),s.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),s.setAttr(this.$clearButton,"tabindex",a?"0":"-1"),s.setAria(this.$clearButton,"hidden",!1===a),o||this.validate(),i||s.dispatchEvent(this.$ele,"change",!0)}setValueText(){const{multiple:e,selectedValues:i,noOfDisplayValues:o,showValueAsTags:n,$valueText:r,selectedLabelRenderer:a}=this,l=[];let p=[];const h=i.length;let c=0;const u=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!n;if(u&&this.hideValueTooltipOnSelectAll)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(e=>{if(e.isCurrentNew)return!1;if(c>=o)return!0;let{label:s}=e;if("function"==typeof a&&(s=a(e)),l.push(s),c+=1,n){const i=t.willTextOverflow(r.parentElement,s)?this.getTooltipAttrText(s,!1,!0):"";let o="";this.ariaLabelTagClearButtonText&&(o=`aria-label="${s.replace(/<[^>]+>/gi,"").trim()}, ${this.ariaLabelTagClearButtonText}"`);const n=`\n ${s}\n \n \n \n `;p.push(n)}else p.push(s);return!1});const i=h-o;i>0&&p.push(`+ ${i} ${this.moreText}`);const d=l.join(", ");if(""===d)r.innerHTML=this.placeholder;else if(r.innerHTML=d,e){const{maxValues:e}=this;if(this.alwaysShowSelectedOptionsCount||s.hasEllipsis(r)||e||n){let t=`${h}`;if(e&&(t+=` / ${e}`),u)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else if(n)r.innerHTML=p.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){const e=1===h?this.optionSelectedText:this.optionsSelectedText;r.innerHTML=`${t} ${e}`}}else p=[]}}let d="";0===h?d=this.placeholder:n||(d=p.join(", ")),n||s.setData(r,"tooltip",d),e&&(n?this.updatePosition():s.setData(r,"tooltipEllipsisOnly",0===h))}setSearchValue(e,t=!1,i=!1){if(e===this.searchValueOriginal&&!i)return;t||(this.$searchInput.value=e);const o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,s.toggleClass(this.$allWrappers,"has-search-value",e),s.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),s.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}setVisibleOptionsCount(){let e,s=0,i=!1;const{searchGroup:o,showOptionsOnlyOnSearch:n,searchByStartsWith:r}=this;let{searchValue:a}=this;a=this.searchNormalize&&""!==a.trim()?t.normalizeString(a):a;const l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(t=>{if(t.isCurrentNew)return;let p;n&&!a?(t.isVisible=!1,p={isVisible:!1,hasExactOption:!1}):p=l({data:t,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),p.isVisible&&(s+=1),i||(i=p.hasExactOption)}),this.allowNewOption&&(a&&!i?(this.setNewOption(),s+=1):this.removeNewOption()),this.visibleOptionsCount=s,this.afterSetVisibleOptionsCount()}calculateAriaMetadata(){let e=0,t=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(s=>{if(s.isCurrentNew)s.filteredIndex=void 0;else if(!0===s.isVisible){const i=s.isGroupTitle&&this.multiple&&!this.disableOptionGroupCheckbox;!s.isGroupTitle||i?(t+=1,e+=1,s.filteredIndex=t):s.filteredIndex=void 0}else s.filteredIndex=void 0}),this.allowNewOption){const s=this.getNewOption();s&&!0===s.isVisible?(t+=1,e+=1,s.filteredIndex=t):s&&(s.filteredIndex=void 0)}this.ariaSetSize=e}setOptionProp(e,t,s){this.options[e]&&(this.options[e][t]=s)}setOptionsHeight(){this.$optionsList.style.height=this.optionHeight*this.visibleOptionsCount+"px"}setOptionsContainerHeight(e){let t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(s.setStyle(this.$noOptions,"height",t),s.setStyle(this.$noSearchResults,"height",t))),s.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}setNewOption(e){const t=e||this.searchValueOriginal.trim();if(!t)return;const s=this.getNewOption();if(s){const e=s.index;this.setOptionProp(e,"value",this.secureText(t)),this.setOptionProp(e,"label",this.secureText(t))}else{const s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}setSelectedProp(){const e={};this.selectedValues.forEach(t=>{e[t]=!0}),this.options.forEach(t=>{!0===e[t.value]&&(t.isSelected=!0)})}setNewOptionsFromValue(e){if(!e)return;const t=this.setNewOption.bind(this),s={};this.options.forEach(e=>{s[e.value]=!0}),e.forEach(e=>{e&&!0!==s[e]&&t(e)})}setDropboxWrapperWidth(){if(this.showAsPopup)return;const e=this.dropboxWidth||`${this.$wrapper.offsetWidth}px`;s.setStyle(this.$dropboxContainer,"max-width",e)}setEleStyles(){const{maxWidth:e}=this,t={};e&&(t["max-width"]=e),s.setStyles(this.$ele,t)}setDropboxStyles(){const{dropboxWidth:e}=this,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),s.setStyles(this.$dropboxContainer,i),s.setStyles(this.$dropbox,t)}setOptionAttr(){const{$visibleOptions:e}=this,{options:t}=this,i=`${this.optionHeight}px`,{setStyle:o,getData:n,setData:r}=s;e&&e.length&&e.forEach(e=>{const s=t[n(e,"index")];o(e,"height",i),r(e,"value",s.value)})}setValueTagAttr(){const{$valueTags:e}=this;if(!e||!e.length)return;const{getData:t,setData:i}=s,{options:o}=this;e.forEach(e=>{const s=t(e,"index");if(void 0!==s){const t=o[s];i(e,"value",t.value)}})}setScrollTop(){const{selectedValues:e}=this;if(this.showSelectedOptionsFirst||!this.focusSelectedOptionOnOpen||0===e.length)return;const t={};let s;e.forEach(e=>{t[e]=!0}),this.options.some(e=>!!t[e.value]&&(s=e.visibleIndex,!0)),s&&(this.$optionsContainer.scrollTop=this.optionHeight*s)}getVisibleOptions(){return this.visibleOptions||[]}getValue(){let e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",t.normalizeValues(e)}getGroupValue(){const e=[],t={};return this.options.forEach(s=>{if(!s.isSelected)return;const{value:i}=s;s.isGroupTitle?i&&(t[s.index]=!0,e.push(i)):!0!==t[s.groupIndex]&&e.push(i)}),e}getInputValue(e){let t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}getFirstVisibleOptionIndex(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}getVisibleStartIndex(){let e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}getTooltipAttrText(e,i=!1,o=!1){const n={"data-tooltip":(t.containsHTML(e)?t.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":i,"data-tooltip-allow-html":o};return s.getAttributesText(n)}getOptionObj(e){if(!e)return;const{getString:s}=t,i=this.secureText.bind(this),o=i(s(e.value)),n=i(s(e.label)),r=i(s(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:n,labelNormalized:this.searchNormalize&&""!==n.trim()?t.normalizeString(n).toLowerCase():n.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?t.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}getNewOption(){const e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}getOptionIndex(e){let t;return this.options.some(s=>s.value===e&&(t=s.index,!0)),t}getNewValue(){const e={};this.newValues.forEach(t=>{e[t]=!0});const t=this.selectedValues.filter(t=>!0===e[t]);return this.multiple?t:t[0]}getAlias(e){let t=e;return t&&(t=Array.isArray(t)?t.join(","):t.toString().trim(),t=t.toLowerCase()),t||""}getDisplayValue(){const e=[];return this.options.forEach(t=>{t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}getSelectedOptions({fullDetails:e=!1,keepSelectionOrder:t=!1}={}){const{valueKey:s,labelKey:i,selectedValues:o}=this,n=[];if(this.options.forEach(t=>{if(t.isSelected&&!t.isGroupTitle)if(e)n.push(t);else{const e={[s]:t.value,[i]:t.label};t.isNew&&(e.isNew=!0),t.customData&&(e.customData=t.customData),n.push(e)}}),t){const e={};o.forEach((t,s)=>{e[t]=s}),n.sort((t,s)=>e[t.value]-e[s.value])}return this.multiple||e?n:n[0]}getDisabledOptions(){const{valueKey:e,labelKey:t,disabledOptions:s}=this,i={},o=[];return s.forEach(e=>{i[e]=!0}),this.options.forEach(({value:s,label:n})=>{i[s]&&o.push({[e]:s,[t]:n})}),o}getVisibleOptionGroupsMapping(e){let{options:t}=this;const s={},i=this.isOptionVisible.bind(this);return t=this.structureOptionGroup(t),t.forEach(t=>{s[t.index]=t.options.some(t=>i({data:t,searchValue:e}).isVisible)}),s}getOptionsCount(e){let t;if(this.showAsPopup){let e=80*window.innerHeight/100-48;this.hasSearchContainer&&(e-=40),t=Math.floor(e/this.optionHeight)}else t=parseInt(e);return t}getOptionsHeight(){return this.optionsCount*this.optionHeight+"px"}getSibling(e,t){const i="next"===t?"nextElementSibling":"previousElementSibling";let o=e;do{o&&(o=o[i])}while(s.hasClass(o,"disabled")||s.hasClass(o,"group-title"));return o}getUniqueId(){const e=t.getRandomInt(1e4);return document.querySelector(`#vscomp-ele-wrapper-${e}`)?this.getUniqueId():e}initDropboxPopover(){const e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}openDropbox(e){l.lastInteractedInstance=this;let t="";e||(t=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=e,l.openInstances.forEach(e=>{if(e!==this){const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),l.openInstances.add(this),s.setAttr(this.$dropboxWrapper,"tabindex","0"),s.setAria(this.$dropboxWrapper,"hidden",!1),s.setAttr(this.$dropboxContainerTop,"tabindex","0"),s.setAria(this.$dropboxContainerTop,"hidden",!1),s.setAttr(this.$dropboxContainerBottom,"tabindex","0"),s.setAria(this.$dropboxContainerBottom,"hidden",!1),e?s.setStyle(this.$dropboxContainer,"display","inline-flex"):(s.dispatchEvent(this.$ele,"beforeOpen"),s.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),s.removeClass(this.$allWrappers,"closed"),s.changeTabIndex(this.$allWrappers,0),e||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=t),this.dropboxPopover&&!e?this.dropboxPopover.show():this.afterShowPopper()}afterShowPopper(){const e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),s.addClass(this.$allWrappers,"focused"),this.showAsPopup?(s.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),s.dispatchEvent(this.$ele,"afterOpen"))}closeDropbox(e){if(this.isSilentClose=e,l.openInstances.delete(this),!1===this.isOpened())return;if(this.keepAlwaysOpen)return void this.removeOptionFocus();const t=document.activeElement,i=t&&this.$wrapper.contains(t)||this.hasDropboxWrapper&&t&&this.$dropboxWrapper.contains(t);this.shouldFocusWrapperOnClose&&l.lastInteractedInstance===this&&!e&&(null===t||t===document.body||i)&&this.$wrapper.focus(),e?s.setStyle(this.$dropboxContainer,"display",""):(s.dispatchEvent(this.$ele,"beforeClose"),s.setAria(this.$wrapper,"expanded",!1),s.setAria(this.$wrapper,"activedescendant",""),s.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!e?(this.dropboxPopover.hide(),s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}afterHidePopper(){const e=this.isSilentClose;this.isSilentClose=!1,s.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(s.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),s.addClass(this.$allWrappers,"closed"),e||s.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)}moveSelectedOptionsFirst(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}toggleDropbox(){l.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}updatePosition(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}isOpened(){return!s.hasClass(this.$wrapper,"closed")}focusSearchInput(){const e=this.$searchInput;e&&e.focus()}focusElementOnOpen(){const e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(s.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{const e=this.$dropbox.querySelector('[tabindex="0"]');void 0!==s.getData(e,"index")?this.focusOption({direction:"next"}):e?e.focus():this.focusFirstVisibleOption()}}focusFirstVisibleOption(){let e=this.$optionsContainer.querySelector(`[data-index='${this.getFirstVisibleOptionIndex()}']`);e?(s.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),s.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'),e&&e.focus())}focusOption({direction:e,$option:t,focusFirst:i}={}){const o=this.$dropboxContainer.querySelector(".vscomp-option.focused");let n;if(t)n=t;else if(!o||i){const e=this.getFirstVisibleOptionIndex();n=this.$dropboxContainer.querySelector(`.vscomp-option[data-visible-index="${e}"]`),(s.hasClass(n,"disabled")||s.hasClass(n,"group-title"))&&(n=this.getSibling(n,"next"))}else n=this.getSibling(o,e);n&&n!==o&&(o&&this.toggleOptionFocusedState(o,!1),this.toggleOptionFocusedState(n,!0),this.toggleFocusedProp(s.getData(n,"index"),!0),this.moveFocusedOptionToView(n))}moveFocusedOptionToView(e){const t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(!t)return;let i;const o=this.$optionsContainer.getBoundingClientRect(),n=t.getBoundingClientRect(),r=o.top,a=o.bottom,l=o.height,p=n.top,h=n.bottom,c=n.height,u=t.offsetTop,d=s.getData(this.$options,"top","number");r>p?i=u+d:a{if(e.isDisabled||e.isGroupTitle||!e.isVisible||e.isSelected)return;const{index:t}=e;if(t>o&&t{e(parseInt(t))})}setTimeout(()=>{this.renderOptions()},0)}toggleAllOptions(e){if(!this.multiple||this.disableSelectAll)return;const t="boolean"==typeof isSelected?e:!s.hasClass(this.$toggleAllCheckbox,"checked"),i=[],{selectAllOnlyVisible:o}=this;this.options.forEach(e=>{const s=e;if(s.isDisabled||s.isCurrentNew)return;const{isVisible:n,isSelected:r}=s;!t&&(!o||n||!r)||t&&o&&!n&&!r?s.isSelected=!1:(s.isSelected=!0,s.isGroupTitle||i.push(s.value))}),this.toggleAllOptionsClass(t),this.setValue(i),this.renderOptions()}toggleAllOptionsClass(e){if(!this.multiple)return;let t=!1;"boolean"==typeof e||(e=this.isAllOptionsSelected()),!e&&this.selectAllOnlyVisible&&""!==this.searchValue&&(this.visibleOptionsCount>0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),s.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}isAllOptionsSelected(e){let t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible))),t}isAllGroupOptionsSelected(e){let t=!1;return this.options.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e)),t}toggleGroupOptionsParent(e,t){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;let i=s.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));const o=this.$options.querySelector(`.vscomp-option[data-index="${i}"]`),n="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,n),this.toggleGroupTitleProp(i,n)}toggleGroupTitleProp(e,t){const s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,s)}toggleGroupOptions(e,i){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;const o=s.getData(e,"index","number"),{selectedValues:n,selectAllOnlyVisible:r}=this,a={},{removeItemFromArray:l}=t;n.forEach(e=>{a[e]=!0}),this.options.forEach(e=>{if(e.isDisabled||e.groupIndex!==o)return;const{value:t}=e;!i||r&&!e.isVisible?(e.isSelected=!1,a[t]&&l(n,t)):(e.isSelected=!0,a[t]||n.push(t))}),this.toggleAllOptionsClass(!!i&&null),this.setValue(n),setTimeout(()=>{this.renderOptions()},0)}toggleGroupTitleCheckbox(e,t){if(!e)return;const i=s.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}toggleFocusedProp(e,t=!1){this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}toggleSelectedProp(e,t=!1){this.setOptionProp(e,"isSelected",t)}scrollToTop(){const{scrollTop:e}=this.$optionsContainer;e>0&&(this.$optionsContainer.scrollTop=0)}reset(e=!1,t=!1){this.options.forEach(e=>{e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&s.removeClass(this.$allWrappers,"has-error"),s.dispatchEvent(this.$ele,"reset")}addOption(e,t){if(!e)return;this.lastOptionIndex+=1;const s=this.getOptionObj({...e,index:this.lastOptionIndex});this.options.push(s),this.sortedOptions.push(s),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}removeOption(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}removeNewOption(){const e=this.getNewOption();e&&this.removeOption(e.index)}sortOptions(e){return e.sort((e,t)=>{const s=e.isSelected||e.isAnySelected,i=t.isSelected||t.isAnySelected;return s||i?s&&(!i||e.index{const s=e.options;e.isAnySelected=s.some(e=>e.isSelected),e.isAnySelected&&t(s)}),t(s),this.destructureOptionGroup(s)}isOptionVisible({data:e,searchValue:s,hasExactOption:i,visibleOptionGroupsMapping:o,searchGroup:n,searchByStartsWith:r}){const a=null!=e.valueNormalized?e.valueNormalized:e.value.toLowerCase();let l=e.labelNormalized;if(null==l){const s=(e.label||"").trim();l=this.searchNormalize&&""!==s?t.normalizeString(s).toLowerCase():s.toLowerCase()}const{description:p,alias:h}=e;let{descriptionNormalized:c}=e;if(null==c){const e=p||"";c=this.searchNormalize&&""!==e.trim()?t.normalizeString(e).toLowerCase():e.toLowerCase()}let u=r?l.startsWith(s):l.includes(s);return!e.isGroupTitle||n&&u||(u=o[e.index]),r||!h||u||(u=h.includes(s)),r||!c||u||(u=c.includes(s)),e.isVisible=u,i||(i=l===s||a===s),{isVisible:u,hasExactOption:i}}structureOptionGroup(e){const t=[],s={};return e.forEach(e=>{if(e.isGroupTitle){const i=[];e.options=i,s[e.index]=i,t.push(e)}}),e.forEach(e=>{e.isGroupOption&&s[e.groupIndex].push(e)}),t}destructureOptionGroup(e){let t=[];return e.forEach(e=>{t.push(e),t=t.concat(e.options)}),t}serverSearch(){s.removeClass(this.$allWrappers,"has-no-search-results"),s.addClass(this.$allWrappers,"server-searching"),this.setSelectedOptions(),this.onServerSearch(this.searchValue,this)}removeValue(e){const{selectedValues:i}=this,o=s.getData(e,"value");t.removeItemFromArray(i,o),this.setValueMethod(i)}focus(){this.$wrapper.focus()}enable(){this.$ele.disabled=!1,this.$ele.removeAttribute("disabled"),this.$hiddenInput.removeAttribute("disabled"),s.setAria(this.$wrapper,"disabled",!1),s.changeTabIndex(this.$wrapper,0)}disable(){this.$ele.disabled=!0,this.$ele.setAttribute("disabled",""),this.$hiddenInput.setAttribute("disabled",""),s.setAria(this.$wrapper,"disabled",!0),s.changeTabIndex(this.$wrapper,-1),this.$wrapper.blur()}validate(){if(this.disableValidation)return!0;let e=!1;const{selectedValues:i,minValues:o}=this;return this.required&&(t.isEmpty(i)||this.multiple&&o&&i.length{t.virtualSelect?i.push(t.virtualSelect):(e.ele=t,"SELECT"===t.tagName&&l.setPropsFromSelect(e),i.push(new l(e)))}),s?i[0]:i}static getAttrProps(){const{convertPropToDataAttr:e}=s,t={};return n.forEach(e=>{t[e]=e}),a.forEach(s=>{t[e(s)]=s}),t}static setPropsFromSelect(e){const t=e.ele,i=[],n=[],a=e=>{const t=[];return Array.from(e.children).forEach(e=>{const{value:s}=e,o={value:s};"OPTGROUP"===e.tagName?(o.label=e.getAttribute("label"),o.options=a(e)):o.label=e.innerHTML,t.push(o),e.disabled&&i.push(s),e.selected&&n.push(s)}),t},l=a(t),p=document.createElement("div");s.setAttrFromEle(t,p,Object.keys(r),o),t.parentNode.insertBefore(p,t),t.remove(),e.ele=p,e.options=l,e.disabledOptions=i,e.selectedValue=n}static onFormReset(e){const t=e.target.closest("form");t&&t.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.reset(!0)})}static onFormSubmit(e){l.validate(e.target.closest("form"))||e.preventDefault()}static validate(e){if(!e)return!0;let t=!1;return e.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{const s=e.parentElement.virtualSelect.validate();t||s||(t=!0)}),!t}static reset(e=!1,t=!1){this.virtualSelect.reset(e,t)}static setValueMethod(...e){this.virtualSelect.setValueMethod(...e)}static setOptionsMethod(...e){this.virtualSelect.setOptionsMethod(...e)}static setDisabledOptionsMethod(...e){this.virtualSelect.setDisabledOptionsMethod(...e)}static setEnabledOptionsMethod(...e){this.virtualSelect.setEnabledOptionsMethod(...e)}static toggleSelectAll(e){this.virtualSelect.toggleAllOptions(e)}static isAllSelected(){return this.virtualSelect.isAllSelected}static addOptionMethod(e){this.virtualSelect.addOption(e,!0)}static getNewValueMethod(){return this.virtualSelect.getNewValue()}static getDisplayValueMethod(){return this.virtualSelect.getDisplayValue()}static getSelectedOptionsMethod(e){return this.virtualSelect.getSelectedOptions(e)}static getDisabledOptionsMethod(){return this.virtualSelect.getDisabledOptions()}static openMethod(){return this.virtualSelect.openDropbox()}static closeMethod(){return this.virtualSelect.closeDropbox()}static focusMethod(){return this.virtualSelect.focus()}static enableMethod(){return this.virtualSelect.enable()}static disableMethod(){return this.virtualSelect.disable()}static destroyMethod(){return this.virtualSelect.destroy()}static validateMethod(){return this.virtualSelect.validate()}static toggleRequiredMethod(e){return this.virtualSelect.toggleRequired(e)}static onResizeMethod(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.onResize()})}}document.addEventListener("reset",l.onFormReset),document.addEventListener("submit",l.onFormSubmit),window.addEventListener("resize",l.onResizeMethod),r=l.getAttrProps(),window.VirtualSelect=l,l.openInstances=new Set,l.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,s){if(e){if("string"==typeof e)return t(e,s);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,s):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,i=new Array(t);ss-o-t.width?"left":"right",vertical:n>i-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),s=window.pageXOffset,i=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+i,right:t.right+s,bottom:t.bottom+i,left:t.left+s}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,s){if(e){var i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}}},{key:"setData",value:function(e,t,s){e&&(e.dataset[t]=s)}},{key:"setStyle",value:function(e,t,s){e&&(e.style[t]=s)}},{key:"show",value:function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",s)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,s=e.parentElement;s;){var i=getComputedStyle(s).overflow;if(-1!==i.indexOf("scroll")||-1!==i.indexOf("auto")){t=s;break}s=s.parentElement}return t}}],s&&function(e,t){for(var s=0;sO?O-b:M:w+h>L&&("right"===E?n="left":w=L+by?y-u:P:C+c>I&&("bottom"===E?n="top":C=I+uh-j&&(G=h-j):"left"!==E&&"right"!==E||((H=m/2+g-R)c-j&&(H=c-j)),s.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}s.hide(this.$popperEle)}},{key:"resetPosition",value:function(){s.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.resetPosition,o=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),i&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=s.getData(e.$popperEle,"left"),i=s.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(i),"px, 0)"),r=e.showDuration;s.show(e.$popperEle,"inline-flex"),s.getCoords(e.$popperEle),s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(o)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var i=parseInt(s.getData(e.$popperEle,"fromLeft")),o=parseInt(s.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(i,"px, ").concat(o,"px, 0)"),r=e.hideDuration;s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){s.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){s.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(s.getData(this.$popperEle,"left")),t=parseInt(s.getData(this.$popperEle,"top"));s.show(this.$popperEle,"inline-flex"),s.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var s=0;s1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var s,i=0;return function(){for(var o=arguments.length,n=new Array(o),r=0;re.length)&&(t=e.length);for(var s=0,i=new Array(t);s'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&c(t.prototype,s),o&&c(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,s,o}();d=f.getAttrProps(),window.PopoverComponent=f}(); \ No newline at end of file diff --git a/docs/assets/script.js b/docs/assets/script.js index a706b09..41585a2 100644 --- a/docs/assets/script.js +++ b/docs/assets/script.js @@ -279,6 +279,199 @@ function initPageExamples() { searchNormalize: true, }); + const multiLanguageOptions = [ + // Latin (French / Spanish) + { label: 'Crème brûlée', value: 'creme-brulee', description: 'French dessert' }, + { label: 'Niño', value: 'nino', description: 'Spanish word for child' }, + { label: 'Café au lait', value: 'cafe-au-lait', description: 'Coffee with milk (French)' }, + { label: 'Déjà vu', value: 'deja-vu', description: 'Already seen (French)' }, + { label: 'Naïve', value: 'naive', description: 'Innocent / unsophisticated (French)' }, + { label: 'Façade', value: 'facade', description: 'Front of a building (French)' }, + { label: 'Résumé', value: 'resume', description: 'Curriculum vitae (French)' }, + { label: 'Mañana', value: 'manana', description: 'Tomorrow (Spanish)' }, + { label: 'Año nuevo', value: 'ano-nuevo', description: 'New year (Spanish)' }, + { label: 'Châtelet', value: 'chatelet', description: 'Paris metro station (French)' }, + // German + { label: 'München', value: 'munchen', description: 'Hauptstadt Bayerns' }, + { label: 'Mädchen', value: 'madchen', description: 'Junges weibliches Kind' }, + { label: 'Größe', value: 'grosse', description: 'Maß für die Ausdehnung' }, + { label: 'Köln', value: 'koln', description: 'Stadt am Rhein' }, + { label: 'Düsseldorf', value: 'dusseldorf', description: 'Landeshauptstadt von NRW' }, + { label: 'Brötchen', value: 'brotchen', description: 'Kleines Brot' }, + { label: 'Schlüssel', value: 'schlussel', description: 'Werkzeug zum Öffnen von Schlössern' }, + { label: 'Müller', value: 'muller', description: 'Häufiger deutscher Familienname' }, + { label: 'Straße', value: 'strasse', description: 'Verkehrsweg in einer Stadt' }, + { label: 'Über', value: 'uber', description: 'Präposition: oberhalb von' }, + // Norwegian + { label: 'Ålesund', value: 'alesund', description: 'By på vestlandskysten' }, + { label: 'Bjørn', value: 'bjorn', description: 'Stort pattedyr' }, + { label: 'Tromsø', value: 'tromso', description: 'Nordnorsk by' }, + { label: 'Trondheim', value: 'trondheim', description: 'Norges tredje største by' }, + { label: 'Geiranger', value: 'geiranger', description: 'Berømt fjordbygd' }, + { label: 'Sør-Trøndelag', value: 'sor-trondelag', description: 'Tidligere fylke i Norge' }, + { label: 'Hønefoss', value: 'honefoss', description: 'By i Buskerud' }, + { label: 'Ærøskøbing', value: 'aeroskobing', description: 'Lille kjøpstad (dansk-norsk)' }, + // Swedish + { label: 'Göteborg', value: 'goteborg', description: 'Stad på Sveriges västkust' }, + { label: 'Malmö', value: 'malmo', description: 'Stad i södra Sverige' }, + { label: 'Stockholm', value: 'stockholm', description: 'Sveriges huvudstad' }, + { label: 'Småland', value: 'smaland', description: 'Landskap i södra Sverige' }, + { label: 'Östersund', value: 'ostersund', description: 'Stad i Jämtland' }, + { label: 'Växjö', value: 'vaxjo', description: 'Stad i Småland' }, + { label: 'Köping', value: 'koping', description: 'Stad i Västmanland' }, + { label: 'Söderhamn', value: 'soderhamn', description: 'Kuststad i Hälsingland' }, + // Finnish + { label: 'Jyväskylä', value: 'jyvaskyla', description: 'Kaupunki Keski-Suomessa' }, + { label: 'Hämeenlinna', value: 'hameenlinna', description: 'Kaupunki Kanta-Hämeessä' }, + { label: 'Helsinki', value: 'helsinki', description: 'Suomen pääkaupunki' }, + { label: 'Tampere', value: 'tampere', description: 'Suomen kolmanneksi suurin kaupunki' }, + { label: 'Hyvää päivää', value: 'hyvaa-paivaa', description: 'Tervehdys (good day)' }, + { label: 'Sää', value: 'saa', description: 'Ilman tila (weather)' }, + { label: 'Pää', value: 'paa', description: 'Ihmisen tai eläimen ruumiinosa (head)' }, + { label: 'Säveltäjä', value: 'saveltaja', description: 'Musiikin tekijä (composer)' }, + // Greek + { label: 'Ένα', value: 'ena', description: 'Πρώτο στοιχείο' }, + { label: 'Αθήνα', value: 'athina', description: 'Πρωτεύουσα της Ελλάδας' }, + { label: 'Δύο', value: 'dyo', description: 'Δεύτερο στοιχείο' }, + { label: 'Τρία', value: 'tria', description: 'Τρίτο στοιχείο' }, + { label: 'Θεσσαλονίκη', value: 'thessaloniki', description: 'Δεύτερη μεγαλύτερη πόλη της Ελλάδας' }, + { label: 'Ήλιος', value: 'ilios', description: 'Το άστρο της ημέρας' }, + { label: 'Φιλοσοφία', value: 'philosophia', description: 'Αγάπη για τη σοφία' }, + { label: 'Δημοκρατία', value: 'dimokratia', description: 'Πολίτευμα του λαού' }, + { label: 'Καλημέρα', value: 'kalimera', description: 'Πρωινός χαιρετισμός' }, + // Cyrillic + { label: 'Ёжик', value: 'yozhik', description: 'Колючий зверёк' }, + { label: 'Москва', value: 'moskva', description: 'Столица России' }, + { label: 'Йогурт', value: 'yogurt', description: 'Молочный продукт' }, + { label: 'Привет', value: 'privet', description: 'Дружеское приветствие' }, + { label: 'Россия', value: 'rossiya', description: 'Самая большая страна мира' }, + { label: 'Спасибо', value: 'spasibo', description: 'Выражение благодарности' }, + { label: 'Здравствуйте', value: 'zdravstvuyte', description: 'Формальное приветствие' }, + { label: 'Книга', value: 'kniga', description: 'Печатное издание' }, + { label: 'Санкт-Петербург', value: 'spb', description: 'Северная столица России' }, + // Vietnamese + { label: 'Việt Nam', value: 'vietnam', description: 'Quốc gia Đông Nam Á' }, + { label: 'Hà Nội', value: 'hanoi', description: 'Thủ đô của Việt Nam' }, + { label: 'Sài Gòn', value: 'saigon', description: 'Thành phố lớn nhất Việt Nam' }, + { label: 'Đà Nẵng', value: 'danang', description: 'Thành phố biển miền Trung' }, + { label: 'Huế', value: 'hue', description: 'Cố đô của Việt Nam' }, + { label: 'Phở', value: 'pho', description: 'Món ăn truyền thống' }, + { label: 'Bánh mì', value: 'banh-mi', description: 'Bánh sandwich Việt Nam' }, + { label: 'Áo dài', value: 'ao-dai', description: 'Trang phục truyền thống' }, + { label: 'Nguyễn', value: 'nguyen', description: 'Họ phổ biến nhất Việt Nam' }, + // Chinese + { label: '北京', value: 'beijing', description: '中国的首都' }, + { label: '你好', value: 'nihao', description: '问候语' }, + { label: '上海', value: 'shanghai', description: '中国最大的城市' }, + { label: '中国', value: 'zhongguo', description: '亚洲东部国家' }, + { label: '谢谢', value: 'xiexie', description: '感谢的话语' }, + { label: '学生', value: 'xuesheng', description: '在学校学习的人' }, + { label: '老师', value: 'laoshi', description: '教育学生的人' }, + { label: '朋友', value: 'pengyou', description: '亲密的伙伴' }, + { label: '苹果', value: 'pingguo', description: '一种水果' }, + // Japanese + { label: '東京', value: 'tokyo', description: '日本の首都' }, + { label: 'カタカナ', value: 'katakana', description: '日本の文字' }, + { label: '日本', value: 'nihon', description: 'アジアの島国' }, + { label: 'こんにちは', value: 'konnichiwa', description: '日中の挨拶' }, + { label: 'ありがとう', value: 'arigatou', description: '感謝を表す言葉' }, + { label: 'さようなら', value: 'sayounara', description: '別れの挨拶' }, + { label: 'ひらがな', value: 'hiragana', description: '日本の音節文字' }, + { label: '寿司', value: 'sushi', description: '日本の伝統料理' }, + { label: '富士山', value: 'fujisan', description: '日本一高い山' }, + // Korean + { label: '서울', value: 'seoul', description: '한국의 수도' }, + { label: '한국어', value: 'hangugeo', description: '한국의 언어' }, + { label: '부산', value: 'busan', description: '한국 제2의 도시' }, + { label: '김치', value: 'kimchi', description: '한국 전통 음식' }, + { label: '안녕하세요', value: 'annyeonghaseyo', description: '공식적인 인사말' }, + { label: '감사합니다', value: 'gamsahamnida', description: '감사를 표현하는 말' }, + { label: '한글', value: 'hangeul', description: '한국의 문자 체계' }, + { label: '사랑', value: 'sarang', description: '깊은 애정의 감정' }, + { label: '가족', value: 'gajok', description: '함께 사는 사람들' }, + // Arabic + { label: 'مُرَحَّباً', value: 'marhaba', description: 'تحية' }, + { label: 'شُكْراً', value: 'shukran', description: 'تعبير عن الامتنان' }, + { label: 'السَّلام', value: 'salam', description: 'تحية إسلامية تعني السلام' }, + { label: 'مَدِينَة', value: 'madina', description: 'مكان كبير يسكنه الناس' }, + { label: 'كِتَاب', value: 'kitab', description: 'مجموعة من الصفحات للقراءة' }, + { label: 'القَاهِرَة', value: 'cairo', description: 'عاصمة مصر' }, + { label: 'دِمَشْق', value: 'dimashq', description: 'عاصمة سوريا' }, + // Thai + { label: 'กรุงเทพ', value: 'bangkok', description: 'เมืองหลวงของประเทศไทย' }, + { label: 'สวัสดี', value: 'sawasdee', description: 'คำทักทายภาษาไทย' }, + { label: 'ขอบคุณ', value: 'khopkhun', description: 'คำแสดงความขอบคุณ' }, + { label: 'ประเทศไทย', value: 'thailand', description: 'ประเทศในเอเชียตะวันออกเฉียงใต้' }, + { label: 'เชียงใหม่', value: 'chiangmai', description: 'จังหวัดในภาคเหนือ' }, + { label: 'อาหาร', value: 'ahaan', description: 'สิ่งที่กิน' }, + { label: 'ภูเก็ต', value: 'phuket', description: 'เกาะในภาคใต้ของประเทศไทย' }, + // Intra-word punctuation (regression coverage for ASCII non-letter stripping) + { label: 'co-op', value: 'coop-label', description: 'A jointly-owned enterprise' }, + { label: 'e-mail', value: 'email-label', description: 'Electronic mail message' }, + // Whitespace folding: multi-word labels collapse with spaceless searches + { label: 'Foo Bar', value: 'foo-bar-space', description: 'Multi-word label with whitespace' }, + // Symmetric punctuation: label has no punctuation, search may include it + { label: 'walkthrough', value: 'walkthrough-plain', description: 'Guide without punctuation' }, + // Numbers preserved alongside letters; non-letter chars fold + { label: 'Mars-2024', value: 'mars-2024', description: 'Mission name with hyphen and digits' }, + // Edge case: label that normalizes to an empty string under searchNormalize: true + { label: '!@#', value: 'punct-only', description: 'Punctuation-only label' }, + ]; + + initVirtualSelect({ + ele: '#multi-language-search-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + searchNormalize: true, + }); + + initVirtualSelect({ + ele: '#multi-language-search-no-normalize-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + searchNormalize: false, + }); + + initVirtualSelect({ + ele: '#multi-language-tags-search-select', + options: multiLanguageOptions, + multiple: true, + search: true, + hasOptionDescription: true, + showValueAsTags: true, + searchNormalize: true, + }); + + initVirtualSelect({ + ele: '#multi-language-tags-search-no-normalize-select', + options: multiLanguageOptions, + multiple: true, + search: true, + hasOptionDescription: true, + showValueAsTags: true, + searchNormalize: false, + }); + + initVirtualSelect({ + ele: '#multi-language-popup-search-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + popupDropboxBreakpoint: '3000px', + searchNormalize: true, + }); + + initVirtualSelect({ + ele: '#multi-language-popup-search-no-normalize-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + popupDropboxBreakpoint: '3000px', + searchNormalize: false, + }); + initVirtualSelect({ ele: '#single-show-as-popup-select', popupDropboxBreakpoint: '3000px', diff --git a/docs/assets/virtual-select.js b/docs/assets/virtual-select.js index 9a44cda..1176824 100644 --- a/docs/assets/virtual-select.js +++ b/docs/assets/virtual-select.js @@ -10,675 +10,554 @@ // UNUSED EXPORTS: VirtualSelect ;// ./src/utils/utils.js -function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } -function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } -function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } -function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } -function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -var Utils = /*#__PURE__*/function () { - function Utils() { - _classCallCheck(this, Utils); - } - return _createClass(Utils, null, [{ - key: "getString", - value: - /** - * @param {any} text - * @returns {string} - * @memberof Utils - */ - function getString(text) { - return text || text === 0 ? text.toString() : ''; - } +const NON_WORD_CHARS_REGEX = /[^\p{L}\p{N}_]/gu; +class Utils { + /** + * @param {any} text + * @returns {string} + * @memberof Utils + */ + static getString(text) { + return text || text === 0 ? text.toString() : ''; + } + + /** + * @param {any} value + * @param {boolean} defaultValue + * @returns {boolean} + * @memberof Utils + */ + static convertToBoolean(value, defaultValue = false) { + let result; + if (value === true || value === 'true') { + result = true; + } else if (value === false || value === 'false') { + result = false; + } else { + result = defaultValue; + } + return result; + } - /** - * @param {any} value - * @param {boolean} defaultValue - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "convertToBoolean", - value: function convertToBoolean(value) { - var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var result; - if (value === true || value === 'true') { + /** + * @param {any} value + * @returns {boolean} + * @memberof Utils + */ + static isEmpty(value) { + let result = false; + if (!value) { + result = true; + } else if (Array.isArray(value)) { + if (value.length === 0) { result = true; - } else if (value === false || value === 'false') { - result = false; - } else { - result = defaultValue; } - return result; + } else if (typeof value === 'object' && Object.keys(value).length === 0) { + result = true; } + return result; + } - /** - * @param {any} value - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "isEmpty", - value: function isEmpty(value) { - var result = false; - if (!value) { - result = true; - } else if (Array.isArray(value)) { - if (value.length === 0) { - result = true; + /** + * @param {any} value + * @returns {boolean} + * @memberof Utils + */ + static isNotEmpty(value) { + return !Utils.isEmpty(value); + } + + /** + * Normalizes values by converting booleans to strings while preserving other types + * Handles both single values and arrays efficiently + * @param {*} value - The value to normalize + * @return {*} - Normalized value(s) + * @memberof Utils + */ + static normalizeValues(value) { + // Fast path for arrays + if (Array.isArray(value)) { + const result = new Array(value.length); + for (let i = 0; i < value.length; i += 1) { + const v = value[i]; + if (v === true) { + result[i] = 'true'; + } else if (v === false) { + result[i] = 'false'; + } else { + result[i] = v; } - } else if (_typeof(value) === 'object' && Object.keys(value).length === 0) { - result = true; } return result; } - /** - * @param {any} value - * @returns {boolean} - * @memberof Utils - */ - }, { - key: "isNotEmpty", - value: function isNotEmpty(value) { - return !Utils.isEmpty(value); + // Handle single values + if (value === true) { + return 'true'; } - - /** - * Normalizes values by converting booleans to strings while preserving other types - * Handles both single values and arrays efficiently - * @param {*} value - The value to normalize - * @return {*} - Normalized value(s) - * @memberof Utils - */ - }, { - key: "normalizeValues", - value: function normalizeValues(value) { - // Fast path for arrays - if (Array.isArray(value)) { - var result = new Array(value.length); - for (var i = 0; i < value.length; i += 1) { - var v = value[i]; - if (v === true) { - result[i] = 'true'; - } else if (v === false) { - result[i] = 'false'; - } else { - result[i] = v; - } - } - return result; - } - - // Handle single values - if (value === true) { - return 'true'; - } - if (value === false) { - return 'false'; - } - return value; + if (value === false) { + return 'false'; } + return value; + } - /** - * @param {any[]} array - * @param {any} value - * @param {boolean} cloneArray - * @returns {any[]} - * @memberof Utils - */ - }, { - key: "removeItemFromArray", - value: function removeItemFromArray(array, value) { - var cloneArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (!Array.isArray(array) || !array.length) { - return array; - } - var inputArr = cloneArray ? _toConsumableArray(array) : array; - var index = inputArr.indexOf(value); - if (index !== -1) { - inputArr.splice(index, 1); - } - return inputArr; + /** + * @param {any[]} array + * @param {any} value + * @param {boolean} cloneArray + * @returns {any[]} + * @memberof Utils + */ + static removeItemFromArray(array, value, cloneArray = false) { + if (!Array.isArray(array) || !array.length) { + return array; } - - /** - * @param {any[]} array - * @returns {any[]} - * @memberof Utils - */ - }, { - key: "removeArrayEmpty", - value: function removeArrayEmpty(array) { - if (!Array.isArray(array) || !array.length) { - return []; - } - return array.filter(function (d) { - return !!d; - }); + const inputArr = cloneArray ? [...array] : array; + const index = inputArr.indexOf(value); + if (index !== -1) { + inputArr.splice(index, 1); } + return inputArr; + } - /** - * @param {number} max - * @param {number} max - * @returns {number} - * @memberof Utils - */ - }, { - key: "getRandomInt", - value: function getRandomInt(max) { - var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var minN = Math.ceil(min); - var maxN = Math.floor(max); - return Math.floor(Math.random() * (maxN - minN - 1)) + minN; + /** + * @param {any[]} array + * @returns {any[]} + * @memberof Utils + */ + static removeArrayEmpty(array) { + if (!Array.isArray(array) || !array.length) { + return []; } + return array.filter(d => !!d); + } - /** - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "regexEscape", - value: function regexEscape(text) { - var ESC_REGEX = /[-/\\^$*+?.()|[\]{}]/g; - return text.replace(ESC_REGEX, '\\$&'); - } + /** + * @param {number} max + * @param {number} max + * @returns {number} + * @memberof Utils + */ + static getRandomInt(max, min = 0) { + const minN = Math.ceil(min); + const maxN = Math.floor(max); + return Math.floor(Math.random() * (maxN - minN - 1)) + minN; + } - /** - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "normalizeString", - value: function normalizeString(text) { - var NON_WORD_REGEX = /[^\w]/g; - return text.normalize('NFD').replace(NON_WORD_REGEX, ''); - } + /** + * @param {string} text + * @return {string} + * @memberof Utils + */ + static regexEscape(text) { + const ESC_REGEX = /[-/\\^$*+?.()|[\]{}]/g; + return text.replace(ESC_REGEX, '\\$&'); + } - /** - * @static - * @param {*} container - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "willTextOverflow", - value: function willTextOverflow(container, text) { - var tempElement = document.createElement('div'); - tempElement.style.position = 'absolute'; - tempElement.style.visibility = 'hidden'; - tempElement.style.whiteSpace = 'nowrap'; - tempElement.style.fontSize = window.getComputedStyle(container).fontSize; - tempElement.style.fontFamily = window.getComputedStyle(container).fontFamily; - tempElement.textContent = text; - document.body.appendChild(tempElement); - var textWidth = tempElement.clientWidth; - document.body.removeChild(tempElement); - return textWidth > container.clientWidth; - } + /** + * Normalizes a string for diacritic-insensitive search. Decomposes the input + * via NFD, then strips every character that is not a Unicode letter + * (\p{L}), number (\p{N}), or underscore. As a side effect this removes + * combining marks (so "München" matches "Munchen", "Việt Nam" matches + * "Viet Nam", "Ёжик" matches "Ежик") as well as punctuation and whitespace + * (so "co-op" matches "coop" and "Foo Bar" collapses into "FooBar"). + * Base letters and numbers from many scripts (Latin, Greek, Cyrillic, CJK, + * etc.) are preserved, but scripts that rely on combining marks are NOT + * fully preserved — every Unicode combining mark is removed, which affects + * Thai vowel signs, Devanagari matras, hiragana/katakana voicing marks + * (dakuten/handakuten), etc. This produces fuzzier matching for those + * scripts; use `searchNormalize: false` if exact-match behavior is + * required. + * + * Note: a few atomic letters do not decompose under NFD (e.g. "ø", "æ", "ß") + * and are kept as-is — a search for "Bjorn" will not match "Bjørn". + * + * @param {string} text + * @return {string} + * @memberof Utils + */ + static normalizeString(text) { + return text.normalize('NFD').replace(NON_WORD_CHARS_REGEX, ''); + } - /** - * @static - * @param {string} text - * @return {string} - * @memberof Utils - */ - }, { - key: "replaceDoubleQuotesWithHTML", - value: function replaceDoubleQuotesWithHTML(text) { - return text.replace(/"/g, '"'); - } + /** + * @static + * @param {*} container + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static willTextOverflow(container, text) { + const tempElement = document.createElement('div'); + tempElement.style.position = 'absolute'; + tempElement.style.visibility = 'hidden'; + tempElement.style.whiteSpace = 'nowrap'; + tempElement.style.fontSize = window.getComputedStyle(container).fontSize; + tempElement.style.fontFamily = window.getComputedStyle(container).fontFamily; + tempElement.textContent = text; + document.body.appendChild(tempElement); + const textWidth = tempElement.clientWidth; + document.body.removeChild(tempElement); + return textWidth > container.clientWidth; + } - /** - * @static - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "containsHTML", - value: function containsHTML(text) { - return /<[a-z][\s\S]*>/i.test(text); - } + /** + * @static + * @param {string} text + * @return {string} + * @memberof Utils + */ + static replaceDoubleQuotesWithHTML(text) { + return text.replace(/"/g, '"'); + } - /** - * @static - * @param {string} text - * @return {boolean} - * @memberof Utils - */ - }, { - key: "containsHTMLorJS", - value: function containsHTMLorJS(text) { - return /<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(text); - } - }]); -}(); + /** + * @static + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static containsHTML(text) { + return /<[a-z][\s\S]*>/i.test(text); + } + + /** + * @static + * @param {string} text + * @return {boolean} + * @memberof Utils + */ + static containsHTMLorJS(text) { + return /<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(text); + } +} ;// ./src/utils/dom-utils.js -function dom_utils_typeof(o) { "@babel/helpers - typeof"; return dom_utils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, dom_utils_typeof(o); } -function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || dom_utils_unsupportedIterableToArray(r, e) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } -function dom_utils_toConsumableArray(r) { return dom_utils_arrayWithoutHoles(r) || dom_utils_iterableToArray(r) || dom_utils_unsupportedIterableToArray(r) || dom_utils_nonIterableSpread(); } -function dom_utils_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function dom_utils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return dom_utils_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? dom_utils_arrayLikeToArray(r, a) : void 0; } } -function dom_utils_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function dom_utils_arrayWithoutHoles(r) { if (Array.isArray(r)) return dom_utils_arrayLikeToArray(r); } -function dom_utils_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function dom_utils_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function dom_utils_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, dom_utils_toPropertyKey(o.key), o); } } -function dom_utils_createClass(e, r, t) { return r && dom_utils_defineProperties(e.prototype, r), t && dom_utils_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function dom_utils_toPropertyKey(t) { var i = dom_utils_toPrimitive(t, "string"); return "symbol" == dom_utils_typeof(i) ? i : i + ""; } -function dom_utils_toPrimitive(t, r) { if ("object" != dom_utils_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != dom_utils_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -var DomUtils = /*#__PURE__*/function () { - function DomUtils() { - dom_utils_classCallCheck(this, DomUtils); - } - return dom_utils_createClass(DomUtils, null, [{ - key: "addClass", - value: - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - */ - function addClass($ele, classNames) { - if (!$ele) { - return; - } - var classNamesArr = classNames.split(' '); - DomUtils.getElements($ele).forEach(function ($this) { - var _$this$classList; - (_$this$classList = $this.classList).add.apply(_$this$classList, dom_utils_toConsumableArray(classNamesArr)); - }); - } +class DomUtils { + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + */ + static addClass($ele, classNames) { + if (!$ele) { + return; + } + const classNamesArr = classNames.split(' '); + DomUtils.getElements($ele).forEach($this => { + $this.classList.add(...classNamesArr); + }); + } - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - */ - }, { - key: "removeClass", - value: function removeClass($ele, classNames) { - if (!$ele) { - return; - } - var classNamesArr = classNames.split(' '); - DomUtils.getElements($ele).forEach(function ($this) { - var _$this$classList2; - (_$this$classList2 = $this.classList).remove.apply(_$this$classList2, dom_utils_toConsumableArray(classNamesArr)); - }); + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + */ + static removeClass($ele, classNames) { + if (!$ele) { + return; + } + const classNamesArr = classNames.split(' '); + DomUtils.getElements($ele).forEach($this => { + $this.classList.remove(...classNamesArr); + }); + } + + /** + * @param {HTMLElement | NodeListOf} $ele + * @param {string} classNames + * @param {boolean} [isAdd] + */ + static toggleClass($ele, classNames, isAdd) { + if (!$ele) { + return; } - /** - * @param {HTMLElement | NodeListOf} $ele - * @param {string} classNames - * @param {boolean} [isAdd] - */ - }, { - key: "toggleClass", - value: function toggleClass($ele, classNames, isAdd) { - if (!$ele) { - return; - } + /** @type {boolean | undefined} */ + let isAdding; + if (isAdd !== undefined) { + isAdding = Boolean(isAdd); + } + DomUtils.getElements($ele).forEach($this => { + $this.classList.toggle(classNames, isAdding); + }); + } - /** @type {boolean | undefined} */ - var isAdding; - if (isAdd !== undefined) { - isAdding = Boolean(isAdd); - } - DomUtils.getElements($ele).forEach(function ($this) { - $this.classList.toggle(classNames, isAdding); - }); + /** + * @param {HTMLElement} $ele + * @param {string} className + * @returns {boolean} + */ + static hasClass($ele, className) { + if (!$ele) { + return false; } + return $ele.classList.contains(className); + } - /** - * @param {HTMLElement} $ele - * @param {string} className - * @returns {boolean} - */ - }, { - key: "hasClass", - value: function hasClass($ele, className) { - if (!$ele) { - return false; - } - return $ele.classList.contains(className); + /** + * @param {HTMLElement} $ele + * @returns {boolean} + */ + static hasEllipsis($ele) { + if (!$ele) { + return false; } + return $ele.scrollWidth > $ele.offsetWidth; + } - /** - * @param {HTMLElement} $ele - * @returns {boolean} - */ - }, { - key: "hasEllipsis", - value: function hasEllipsis($ele) { - if (!$ele) { - return false; - } - return $ele.scrollWidth > $ele.offsetWidth; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} [type] + * @returns {any} + */ + static getData($ele, name, type) { + if (!$ele) { + return undefined; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} [type] - * @returns {any} - */ - }, { - key: "getData", - value: function getData($ele, name, type) { - if (!$ele) { - return undefined; - } + /** @type {any} */ + let value = $ele ? $ele.dataset[name] : ''; + if (type === 'number') { + value = parseFloat(value) || 0; + } else if (value === 'true') { + value = true; + } else if (value === 'false') { + value = false; + } + return value; + } - /** @type {any} */ - var value = $ele ? $ele.dataset[name] : ''; - if (type === 'number') { - value = parseFloat(value) || 0; - } else if (value === 'true') { - value = true; - } else if (value === 'false') { - value = false; - } - return value; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setData($ele, name, value) { + if (!$ele) { + return; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setData", - value: function setData($ele, name, value) { - if (!$ele) { - return; - } + // eslint-disable-next-line no-param-reassign + $ele.dataset[name] = value; + } - // eslint-disable-next-line no-param-reassign - $ele.dataset[name] = value; + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setAttr($ele, name, value) { + if (!$ele) { + return; } + $ele.setAttribute(name, value); + } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setAttr", - value: function setAttr($ele, name, value) { - if (!$ele) { - return; - } - $ele.setAttribute(name, value); - } + /** + * @param {HTMLElement} $from + * @param {HTMLElement} $to + * @param {string[]} attrList + * @param {string[]} valueLessProps + */ + static setAttrFromEle($from, $to, attrList, valueLessProps) { + /** @type {any} */ + const values = {}; + attrList.forEach(attr => { + values[attr] = $from.getAttribute(attr); + }); + attrList.forEach(attr => { + const value = values[attr]; + if (value || valueLessProps.indexOf(attr) !== -1 && value === '') { + $to.setAttribute(attr, value); + } + }); + } - /** - * @param {HTMLElement} $from - * @param {HTMLElement} $to - * @param {string[]} attrList - * @param {string[]} valueLessProps - */ - }, { - key: "setAttrFromEle", - value: function setAttrFromEle($from, $to, attrList, valueLessProps) { - /** @type {any} */ - var values = {}; - attrList.forEach(function (attr) { - values[attr] = $from.getAttribute(attr); - }); - attrList.forEach(function (attr) { - var value = values[attr]; - if (value || valueLessProps.indexOf(attr) !== -1 && value === '') { - $to.setAttribute(attr, value); - } - }); + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setStyle($ele, name, value) { + if (!$ele) { + return; } - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setStyle", - value: function setStyle($ele, name, value) { - if (!$ele) { - return; - } + // @ts-ignore + // eslint-disable-next-line no-param-reassign + $ele.style[name] = value; + } + /** + * @param {HTMLElement} $ele + * @param {any} props + */ + static setStyles($ele, props) { + if (!$ele || !props) { + return; + } + Object.keys(props).forEach(name => { // @ts-ignore // eslint-disable-next-line no-param-reassign - $ele.style[name] = value; - } + $ele.style[name] = props[name]; + }); + } - /** - * @param {HTMLElement} $ele - * @param {any} props - */ - }, { - key: "setStyles", - value: function setStyles($ele, props) { - if (!$ele || !props) { - return; - } - Object.keys(props).forEach(function (name) { - // @ts-ignore - // eslint-disable-next-line no-param-reassign - $ele.style[name] = props[name]; - }); + /** + * @param {HTMLElement} $ele + * @param {string} name + * @param {string} value + */ + static setAria($ele, name, value) { + if (!$ele) { + return; } - - /** - * @param {HTMLElement} $ele - * @param {string} name - * @param {string} value - */ - }, { - key: "setAria", - value: function setAria($ele, name, value) { - if (!$ele) { - return; - } - var attrName = name; - if (attrName !== 'role') { - attrName = "aria-".concat(attrName); - } - $ele.setAttribute(attrName, value); + let attrName = name; + if (attrName !== 'role') { + attrName = `aria-${attrName}`; } + $ele.setAttribute(attrName, value); + } - /** - * @param {any} $ele - * @returns {any[]} - */ - }, { - key: "getElements", - value: function getElements($ele) { - if (!$ele) { - return []; - } - return $ele.forEach === undefined ? [$ele] : $ele; + /** + * @param {any} $ele + * @returns {any[]} + */ + static getElements($ele) { + if (!$ele) { + return []; } + return $ele.forEach === undefined ? [$ele] : $ele; + } - /** - * @static - * @param {string} [$selector=''] - * @param {*} [$parentEle=undefined] - * @return {*} - * @memberof DomUtils - */ - }, { - key: "getElementsBySelector", - value: function getElementsBySelector() { - var $selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var $parentEle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; - var elements; - var parent = $parentEle !== undefined ? $parentEle : document; - if ($selector !== '') { - elements = parent.querySelectorAll($selector); - } - return elements !== undefined ? Array.from(elements) : []; + /** + * @static + * @param {string} [$selector=''] + * @param {*} [$parentEle=undefined] + * @return {*} + * @memberof DomUtils + */ + static getElementsBySelector($selector = '', $parentEle = undefined) { + let elements; + const parent = $parentEle !== undefined ? $parentEle : document; + if ($selector !== '') { + elements = parent.querySelectorAll($selector); } + return elements !== undefined ? Array.from(elements) : []; + } - /** - * @param {HTMLElement} $ele - * @param {string} events - * @param {Function} callback - * @param {boolean} capture - */ - }, { - key: "addEvent", - value: function addEvent($ele, events, callback, capture) { - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var $eleArray = DomUtils.getElements($ele); - $eleArray.forEach(function ($this) { - $this.addEventListener(event, callback, { - capture: capture - }); + /** + * @param {HTMLElement} $ele + * @param {string} events + * @param {Function} callback + * @param {boolean} capture + */ + static addEvent($ele, events, callback, capture) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const $eleArray = DomUtils.getElements($ele); + $eleArray.forEach($this => { + $this.addEventListener(event, callback, { + capture }); }); - } + }); + } - /** - * @param {HTMLElement} $ele - * @param {string} eventName - * @param {boolean} [bubbles] - */ - }, { - key: "dispatchEvent", - value: function dispatchEvent($ele, eventName) { - var bubbles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (!$ele) { - return; - } - var $eleArray = DomUtils.getElements($ele); + /** + * @param {HTMLElement} $ele + * @param {string} eventName + * @param {boolean} [bubbles] + */ + static dispatchEvent($ele, eventName, bubbles = false) { + if (!$ele) { + return; + } + const $eleArray = DomUtils.getElements($ele); + + /** using setTimeout to trigger asynchronous event */ + setTimeout(() => { + $eleArray.forEach($this => { + $this.dispatchEvent(new CustomEvent(eventName, { + bubbles + })); + }); + }, 0); + } - /** using setTimeout to trigger asynchronous event */ - setTimeout(function () { - $eleArray.forEach(function ($this) { - $this.dispatchEvent(new CustomEvent(eventName, { - bubbles: bubbles - })); - }); - }, 0); + /** + * convert object to dom attributes + * @param {ObjectString} data + */ + static getAttributesText(data) { + let html = ''; + if (!data) { + return html; } - /** - * convert object to dom attributes - * @param {ObjectString} data - */ - }, { - key: "getAttributesText", - value: function getAttributesText(data) { - var html = ''; - if (!data) { - return html; + // @ts-ignore + Object.entries(data).forEach(([k, v]) => { + if (v !== undefined) { + html += ` ${k}="${v}" `; } + }); + return html; + } - // @ts-ignore - Object.entries(data).forEach(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - k = _ref2[0], - v = _ref2[1]; - if (v !== undefined) { - html += " ".concat(k, "=\"").concat(v, "\" "); - } - }); - return html; - } - - /** - * convert "maxValue" to "data-max-value" - * @param {string} prop - */ - }, { - key: "convertPropToDataAttr", - value: function convertPropToDataAttr(prop) { - return prop ? "data-".concat(prop).replace(/([A-Z])/g, '-$1').toLowerCase() : ''; - } + /** + * convert "maxValue" to "data-max-value" + * @param {string} prop + */ + static convertPropToDataAttr(prop) { + return prop ? `data-${prop}`.replace(/([A-Z])/g, '-$1').toLowerCase() : ''; + } - /** - * Changes the tab index of an element passed as an input - * @static - * @param {HTMLElement | NodeListOf} $ele - * @param {number} newTabIndex - * @memberof DomUtils - */ - }, { - key: "changeTabIndex", - value: function changeTabIndex($ele, newTabIndex) { - if (!$ele) { - // eslint-disable-next-line no-console - console.log($ele, 'Invalid element provided.'); - return; - } - DomUtils.getElements($ele).forEach(function ($this) { - // eslint-disable-next-line no-param-reassign - $this.tabIndex = newTabIndex; - }); + /** + * Changes the tab index of an element passed as an input + * @static + * @param {HTMLElement | NodeListOf} $ele + * @param {number} newTabIndex + * @memberof DomUtils + */ + static changeTabIndex($ele, newTabIndex) { + if (!$ele) { + // eslint-disable-next-line no-console + console.log($ele, 'Invalid element provided.'); + return; } + DomUtils.getElements($ele).forEach($this => { + // eslint-disable-next-line no-param-reassign + $this.tabIndex = newTabIndex; + }); + } - /** - * @param {HTMLElement} $ele - * @param {string} event - * @param {Function} callback - */ - }, { - key: "removeEvent", - value: function removeEvent($ele, event, callback) { - if (!$ele) { - return; - } - var $eleArray = DomUtils.getElements($ele); - $eleArray.forEach(function ($this) { - $this.removeEventListener(event, callback); - }); - } - }]); -}(); + /** + * @param {HTMLElement} $ele + * @param {string} event + * @param {Function} callback + */ + static removeEvent($ele, event, callback) { + if (!$ele) { + return; + } + const $eleArray = DomUtils.getElements($ele); + $eleArray.forEach($this => { + $this.removeEventListener(event, callback); + }); + } +} ;// ./src/virtual-select.js -function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } -function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } -function _defineProperty(e, r, t) { return (r = virtual_select_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } -function virtual_select_typeof(o) { "@babel/helpers - typeof"; return virtual_select_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, virtual_select_typeof(o); } -function virtual_select_slicedToArray(r, e) { return virtual_select_arrayWithHoles(r) || virtual_select_iterableToArrayLimit(r, e) || virtual_select_unsupportedIterableToArray(r, e) || virtual_select_nonIterableRest(); } -function virtual_select_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function virtual_select_iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function virtual_select_arrayWithHoles(r) { if (Array.isArray(r)) return r; } -function virtual_select_toConsumableArray(r) { return virtual_select_arrayWithoutHoles(r) || virtual_select_iterableToArray(r) || virtual_select_unsupportedIterableToArray(r) || virtual_select_nonIterableSpread(); } -function virtual_select_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function virtual_select_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return virtual_select_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? virtual_select_arrayLikeToArray(r, a) : void 0; } } -function virtual_select_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } -function virtual_select_arrayWithoutHoles(r) { if (Array.isArray(r)) return virtual_select_arrayLikeToArray(r); } -function virtual_select_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } -function virtual_select_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } -function virtual_select_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, virtual_select_toPropertyKey(o.key), o); } } -function virtual_select_createClass(e, r, t) { return r && virtual_select_defineProperties(e.prototype, r), t && virtual_select_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function virtual_select_toPropertyKey(t) { var i = virtual_select_toPrimitive(t, "string"); return "symbol" == virtual_select_typeof(i) ? i : i + ""; } -function virtual_select_toPrimitive(t, r) { if ("object" != virtual_select_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != virtual_select_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** cSpell:ignore nocheck, Labelledby, vscomp, tabindex, combobox, haspopup, listbox, activedescendant */ /* eslint-disable class-methods-use-this */ // @ts-nocheck -var dropboxCloseButtonFullHeight = 48; -var searchHeight = 40; -var keyDownMethodMapping = { +const dropboxCloseButtonFullHeight = 48; +const searchHeight = 40; +const keyDownMethodMapping = { 13: 'onEnterPress', 38: 'onUpArrowPress', 40: 'onDownArrowPress', @@ -686,18 +565,17 @@ var keyDownMethodMapping = { // Delete 8: 'onBackspaceOrDeletePress' // Backspace }; -var valueLessProps = ['autofocus', 'disabled', 'multiple', 'required']; -var nativeProps = ['autofocus', 'class', 'disabled', 'id', 'multiple', 'name', 'placeholder', 'required']; -var attrPropsMapping; -var dataProps = ['additionalClasses', 'additionalDropboxClasses', 'additionalDropboxContainerClasses', 'additionalToggleButtonClasses', 'aliasKey', 'allOptionsSelectedText', 'allowNewOption', 'alwaysShowSelectedOptionsCount', 'alwaysShowSelectedOptionsLabel', 'ariaLabelledby', 'ariaLabelText', 'ariaLabelClearButtonText', 'ariaLabelTagClearButtonText', 'ariaLabelSearchClearButtonText', 'autoSelectFirstOption', 'clearButtonText', 'descriptionKey', 'disableAllOptionsSelectedText', 'disableOptionGroupCheckbox', 'disableSelectAll', 'disableValidation', 'dropboxWidth', 'dropboxWrapper', 'emptyValue', 'enableSecureText', 'focusSelectedOptionOnOpen', 'hasOptionDescription', 'hideClearButton', 'hideValueTooltipOnSelectAll', 'keepAlwaysOpen', 'labelKey', 'markSearchResults', 'maxValues', 'maxWidth', 'minValues', 'moreText', 'noOfDisplayValues', 'noOptionsText', 'noSearchResultsText', 'optionHeight', 'optionSelectedText', 'optionsCount', 'optionsSelectedText', 'popupDropboxBreakpoint', 'popupPosition', 'position', 'search', 'searchByStartsWith', 'searchDelay', 'searchFormLabel', 'searchGroup', 'searchNormalize', 'searchPlaceholderText', 'selectAllOnlyVisible', 'selectAllText', 'setValueAsArray', 'showDropboxAsPopup', 'showOptionsOnlyOnSearch', 'showSelectedOptionsFirst', 'showValueAsTags', 'silentInitialValueSet', 'textDirection', 'tooltipAlignment', 'tooltipFontSize', 'tooltipMaxWidth', 'updatePositionThrottle', 'useGroupValue', 'valueKey', 'zIndex']; +const valueLessProps = ['autofocus', 'disabled', 'multiple', 'required']; +const nativeProps = ['autofocus', 'class', 'disabled', 'id', 'multiple', 'name', 'placeholder', 'required']; +let attrPropsMapping; +const dataProps = ['additionalClasses', 'additionalDropboxClasses', 'additionalDropboxContainerClasses', 'additionalToggleButtonClasses', 'aliasKey', 'allOptionsSelectedText', 'allowNewOption', 'alwaysShowSelectedOptionsCount', 'alwaysShowSelectedOptionsLabel', 'ariaLabelledby', 'ariaLabelText', 'ariaLabelClearButtonText', 'ariaLabelTagClearButtonText', 'ariaLabelSearchClearButtonText', 'autoSelectFirstOption', 'clearButtonText', 'descriptionKey', 'disableAllOptionsSelectedText', 'disableOptionGroupCheckbox', 'disableSelectAll', 'disableValidation', 'dropboxWidth', 'dropboxWrapper', 'emptyValue', 'enableSecureText', 'focusSelectedOptionOnOpen', 'hasOptionDescription', 'hideClearButton', 'hideValueTooltipOnSelectAll', 'keepAlwaysOpen', 'labelKey', 'markSearchResults', 'maxValues', 'maxWidth', 'minValues', 'moreText', 'noOfDisplayValues', 'noOptionsText', 'noSearchResultsText', 'optionHeight', 'optionSelectedText', 'optionsCount', 'optionsSelectedText', 'popupDropboxBreakpoint', 'popupPosition', 'position', 'search', 'searchByStartsWith', 'searchDelay', 'searchFormLabel', 'searchGroup', 'searchNormalize', 'searchPlaceholderText', 'selectAllOnlyVisible', 'selectAllText', 'setValueAsArray', 'showDropboxAsPopup', 'showOptionsOnlyOnSearch', 'showSelectedOptionsFirst', 'showValueAsTags', 'silentInitialValueSet', 'textDirection', 'tooltipAlignment', 'tooltipFontSize', 'tooltipMaxWidth', 'updatePositionThrottle', 'useGroupValue', 'valueKey', 'zIndex']; /** Class representing VirtualSelect */ -var VirtualSelect = /*#__PURE__*/function () { +class VirtualSelect { /** * @param {virtualSelectOptions} options */ - function VirtualSelect(options) { - virtual_select_classCallCheck(this, VirtualSelect); + constructor(options) { try { this.createSecureTextElements(); this.setProps(options); @@ -713,3368 +591,3138 @@ var VirtualSelect = /*#__PURE__*/function () { } /** render methods - start */ - return virtual_select_createClass(VirtualSelect, [{ - key: "render", - value: function render() { - if (!this.$ele) { - return; - } - var uniqueId = this.uniqueId; - var wrapperClasses = 'vscomp-wrapper'; - var toggleButtonClasses = 'vscomp-toggle-button'; - var valueTooltip = this.showValueAsTags ? '' : this.getTooltipAttrText(this.placeholder, true, true); - var clearButtonTooltip = this.getTooltipAttrText(this.clearButtonText); - var ariaLabelledbyText = this.ariaLabelledby ? "aria-labelledby=\"".concat(this.ariaLabelledby, "\"") : ''; - var ariaLabelText = this.ariaLabelText ? "aria-label=\"".concat(this.ariaLabelText, "\"") : ''; - var ariaLabelClearBtnTxt = this.ariaLabelClearButtonText ? "aria-label=\"".concat(this.ariaLabelClearButtonText, "\"") : ''; - var isExpanded = false; - if (this.additionalClasses) { - wrapperClasses += " ".concat(this.additionalClasses); - } - if (this.additionalToggleButtonClasses) { - toggleButtonClasses += " ".concat(this.additionalToggleButtonClasses); - } - if (this.multiple) { - wrapperClasses += ' multiple'; - if (!this.disableSelectAll) { - wrapperClasses += ' has-select-all'; + render() { + if (!this.$ele) { + return; + } + const { + uniqueId + } = this; + let wrapperClasses = 'vscomp-wrapper'; + let toggleButtonClasses = 'vscomp-toggle-button'; + const valueTooltip = this.showValueAsTags ? '' : this.getTooltipAttrText(this.placeholder, true, true); + const clearButtonTooltip = this.getTooltipAttrText(this.clearButtonText); + const ariaLabelledbyText = this.ariaLabelledby ? `aria-labelledby="${this.ariaLabelledby}"` : ''; + const ariaLabelText = this.ariaLabelText ? `aria-label="${this.ariaLabelText}"` : ''; + const ariaLabelClearBtnTxt = this.ariaLabelClearButtonText ? `aria-label="${this.ariaLabelClearButtonText}"` : ''; + let isExpanded = false; + if (this.additionalClasses) { + wrapperClasses += ` ${this.additionalClasses}`; + } + if (this.additionalToggleButtonClasses) { + toggleButtonClasses += ` ${this.additionalToggleButtonClasses}`; + } + if (this.multiple) { + wrapperClasses += ' multiple'; + if (!this.disableSelectAll) { + wrapperClasses += ' has-select-all'; + } + } + if (!this.hideClearButton) { + wrapperClasses += ' has-clear-button'; + } + if (this.keepAlwaysOpen) { + wrapperClasses += ' keep-always-open'; + isExpanded = true; + } else { + wrapperClasses += ' closed'; + } + if (this.showAsPopup) { + wrapperClasses += ' show-as-popup'; + } + if (this.hasSearch) { + wrapperClasses += ' has-search-input'; + } + if (this.showValueAsTags) { + wrapperClasses += ' show-value-as-tags'; + } + if (this.textDirection) { + wrapperClasses += ` text-direction-${this.textDirection}`; + } + if (this.popupPosition) { + wrapperClasses += ` popup-position-${this.popupPosition.toLowerCase()}`; + } + + // eslint-disable-next-line no-trailing-spaces + const html = `
+ +
+
+ ${this.placeholder} +
+
+
+ +
+
+ + ${this.renderDropbox({ + wrapperClasses + })} +
`; + this.$ele.innerHTML = html; + this.$body = document.querySelector('body'); + this.$wrapper = this.$ele.querySelector('.vscomp-wrapper'); + if (this.hasDropboxWrapper) { + this.$allWrappers = [this.$wrapper, this.$dropboxWrapper]; + this.$dropboxContainer = this.$dropboxWrapper.querySelector('.vscomp-dropbox-container'); + DomUtils.addClass(this.$dropboxContainer, 'pop-comp-wrapper'); + } else { + this.$allWrappers = [this.$wrapper]; + this.$dropboxContainer = this.$wrapper.querySelector('.vscomp-dropbox-container'); + } + this.$toggleButton = this.$ele.querySelector('.vscomp-toggle-button'); + this.$clearButton = this.$ele.querySelector('.vscomp-clear-button'); + this.$valueText = this.$ele.querySelector('.vscomp-value'); + this.$hiddenInput = this.$ele.querySelector('.vscomp-hidden-input'); + this.$dropbox = this.$dropboxContainer.querySelector('.vscomp-dropbox'); + this.$dropboxCloseButton = this.$dropboxContainer.querySelector('.vscomp-dropbox-close-button'); + this.$dropboxContainerBottom = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-bottom'); + this.$dropboxContainerTop = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-top'); + this.$search = this.$dropboxContainer.querySelector('.vscomp-search-wrapper'); + this.$optionsContainer = this.$dropboxContainer.querySelector('.vscomp-options-container'); + this.$optionsList = this.$dropboxContainer.querySelector('.vscomp-options-list'); + this.$options = this.$dropboxContainer.querySelector('.vscomp-options'); + this.$noOptions = this.$dropboxContainer.querySelector('.vscomp-no-options'); + this.$noSearchResults = this.$dropboxContainer.querySelector('.vscomp-no-search-results'); + this.afterRenderWrapper(); + } + renderDropbox({ + wrapperClasses + }) { + const $wrapper = this.dropboxWrapper !== 'self' ? document.querySelector(this.dropboxWrapper) : null; + let dropboxClasses = 'vscomp-dropbox'; + if (this.additionalDropboxClasses) { + dropboxClasses += ` ${this.additionalDropboxClasses}`; + } + let dropboxContainerClasses = 'vscomp-dropbox-container'; + if (this.additionalDropboxContainerClasses) { + dropboxContainerClasses += ` ${this.additionalDropboxContainerClasses}`; + } + + // eslint-disable-next-line no-trailing-spaces + const html = `
+ +
+
+ +
+
+ +
+
+
+
+ +
+
${this.noOptionsText}
+
${this.noSearchResultsText}
+ + +
+ +
`; + if ($wrapper) { + const $dropboxWrapper = document.createElement('div'); + this.$dropboxWrapper = $dropboxWrapper; + this.hasDropboxWrapper = true; + $dropboxWrapper.innerHTML = html; + $wrapper.appendChild($dropboxWrapper); + DomUtils.addClass($dropboxWrapper, `vscomp-dropbox-wrapper ${wrapperClasses}`); + if (!this.keepAlwaysOpen) { + DomUtils.setAttr($dropboxWrapper, 'tabindex', '-1'); + DomUtils.setAria($dropboxWrapper, 'hidden', true); + } + return ''; + } + this.hasDropboxWrapper = false; + return html; + } + renderOptions() { + // Calculate ARIA metadata before rendering to ensure it's always up to date + this.calculateAriaMetadata(); + let html = ''; + const visibleOptions = this.getVisibleOptions(); + let checkboxHtml = ''; + let newOptionIconHtml = ''; + const markSearchResults = !!(this.markSearchResults && this.searchValue); + let searchRegex; + const { + labelRenderer, + disableOptionGroupCheckbox, + uniqueId, + searchGroup + } = this; + const hasLabelRenderer = typeof labelRenderer === 'function'; + const { + convertToBoolean + } = Utils; + let groupName = ''; + if (markSearchResults) { + searchRegex = new RegExp(`(${Utils.regexEscape(this.searchValue)})(?!([^<]+)?>)`, 'gi'); + } + if (this.multiple) { + checkboxHtml = ''; + } + if (this.allowNewOption) { + const newOptionTooltip = this.getTooltipAttrText('New Option'); + newOptionIconHtml = ``; + } + visibleOptions.forEach(d => { + const { + index + } = d; + let optionLabel; + let optionClasses = 'vscomp-option'; + const optionTooltip = this.getTooltipAttrText('', true, true); + let leftSection = checkboxHtml; + let rightSection = ''; + let description = ''; + let groupIndexText = ''; + let ariaLabel = ''; + let tabIndexValue = '-1'; + const isSelected = convertToBoolean(d.isSelected); + let ariaDisabledText = ''; + if (d.classNames) { + optionClasses += ` ${d.classNames}`; + } + if (d.isFocused) { + tabIndexValue = '0'; + optionClasses += ' focused'; + } + if (d.isDisabled) { + optionClasses += ' disabled'; + ariaDisabledText = 'aria-disabled="true"'; + } + if (d.isGroupTitle) { + groupName = d.label; + optionClasses += ' group-title'; + if (disableOptionGroupCheckbox) { + leftSection = ''; + } + } + if (isSelected) { + optionClasses += ' selected'; + } + if (d.isGroupOption) { + let optionDesc = ''; + optionClasses += ' group-option'; + groupIndexText = `data-group-index="${d.groupIndex}"`; + if (d.customData) { + groupName = d.customData.group_name !== undefined ? `${d.customData.group_name}, ` : ''; + optionDesc = d.customData.description !== undefined ? ` ${d.customData.description},` : ''; + ariaLabel = `aria-label="${groupName} ${d.label}, ${optionDesc}"`; + } else { + ariaLabel = `aria-label="${groupName}, ${d.label}"`; } } - if (!this.hideClearButton) { - wrapperClasses += ' has-clear-button'; - } - if (this.keepAlwaysOpen) { - wrapperClasses += ' keep-always-open'; - isExpanded = true; + if (hasLabelRenderer) { + optionLabel = labelRenderer(d); } else { - wrapperClasses += ' closed'; - } - if (this.showAsPopup) { - wrapperClasses += ' show-as-popup'; - } - if (this.hasSearch) { - wrapperClasses += ' has-search-input'; - } - if (this.showValueAsTags) { - wrapperClasses += ' show-value-as-tags'; - } - if (this.textDirection) { - wrapperClasses += " text-direction-".concat(this.textDirection); - } - if (this.popupPosition) { - wrapperClasses += " popup-position-".concat(this.popupPosition.toLowerCase()); - } + optionLabel = d.label; + } + if (d.description) { + description = `
${d.description}
`; + } + if (d.isCurrentNew) { + optionClasses += ' current-new'; + rightSection += newOptionIconHtml; + } else if (markSearchResults && (!d.isGroupTitle || searchGroup)) { + optionLabel = optionLabel.replace(searchRegex, '$1'); + } + + // Add aria-setsize and aria-posinset for virtualized listbox accessibility + let ariaAttrs = ''; + if (this.ariaSetSize > 0) { + ariaAttrs = `aria-setsize="${this.ariaSetSize}"`; + if (d.filteredIndex) { + ariaAttrs += ` aria-posinset="${d.filteredIndex}"`; + } + } + html += `
+ ${leftSection} + + ${optionLabel} + + ${description} + ${rightSection} +
`; + }); + groupName = ''; + this.$options.innerHTML = html; + this.$visibleOptions = this.$options.querySelectorAll('.vscomp-option'); + this.afterRenderOptions(); + } + renderSearch() { + if (!this.hasSearchContainer) { + return; + } + let checkboxHtml = ''; + let searchInput = ''; + if (this.multiple && !this.disableSelectAll) { + checkboxHtml = ` + + ${this.selectAllText} + `; + } + if (this.hasSearch) { + const ariaLabelSearchClearBtnTxt = this.ariaLabelSearchClearButtonText ? `aria-label="${this.ariaLabelSearchClearButtonText}"` : ''; + searchInput = ` + + ×`; + } + const html = `
+ ${checkboxHtml} + ${searchInput} +
`; + this.$search.innerHTML = html; + this.$searchInput = this.$dropboxContainer.querySelector('.vscomp-search-input'); + this.$searchClear = this.$dropboxContainer.querySelector('.vscomp-search-clear'); + this.$toggleAllButton = this.$dropboxContainer.querySelector('.vscomp-toggle-all-button'); + this.$toggleAllCheckbox = this.$dropboxContainer.querySelector('.vscomp-toggle-all-checkbox'); + this.addEvent(this.$searchInput, 'input', 'onSearch'); + // Prevents the change event from bubbling and triggering the main onChange handler twice. + this.addEvent(this.$searchInput, 'change', 'preventPropagation'); + this.addEvent(this.$searchClear, 'click keydown', 'onSearchClear'); + this.addEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); + this.addEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); + this.addEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + /** render methods - end */ + + /** dom event methods - start */ + addEvents() { + this.addEvent(document, 'click', 'onDocumentClick', true); + this.addEvent(this.$allWrappers, 'keydown', 'onKeyDown'); + this.addEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); + this.addEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); + this.addEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); + this.addEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); + this.addEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); + this.addEvent(this.$options, 'click', 'onOptionsClick'); + this.addEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); + this.addEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); + this.addMutationObserver(); + } + addEvent($ele, events, method, capture = false) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const eventsKey = `${method}-${event}`; + let callback = this.events[eventsKey]; + if (!callback) { + callback = this[method].bind(this); + this.events[eventsKey] = callback; + } + DomUtils.addEvent($ele, event, callback, capture); + }); + } - // eslint-disable-next-line no-trailing-spaces - var html = "
\n \n
\n
\n ").concat(this.placeholder, "\n
\n
\n
\n \n
\n
\n\n ").concat(this.renderDropbox({ - wrapperClasses: wrapperClasses - }), "\n
"); - this.$ele.innerHTML = html; - this.$body = document.querySelector('body'); - this.$wrapper = this.$ele.querySelector('.vscomp-wrapper'); - if (this.hasDropboxWrapper) { - this.$allWrappers = [this.$wrapper, this.$dropboxWrapper]; - this.$dropboxContainer = this.$dropboxWrapper.querySelector('.vscomp-dropbox-container'); - DomUtils.addClass(this.$dropboxContainer, 'pop-comp-wrapper'); - } else { - this.$allWrappers = [this.$wrapper]; - this.$dropboxContainer = this.$wrapper.querySelector('.vscomp-dropbox-container'); - } - this.$toggleButton = this.$ele.querySelector('.vscomp-toggle-button'); - this.$clearButton = this.$ele.querySelector('.vscomp-clear-button'); - this.$valueText = this.$ele.querySelector('.vscomp-value'); - this.$hiddenInput = this.$ele.querySelector('.vscomp-hidden-input'); - this.$dropbox = this.$dropboxContainer.querySelector('.vscomp-dropbox'); - this.$dropboxCloseButton = this.$dropboxContainer.querySelector('.vscomp-dropbox-close-button'); - this.$dropboxContainerBottom = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-bottom'); - this.$dropboxContainerTop = this.$dropboxContainer.querySelector('.vscomp-dropbox-container-top'); - this.$search = this.$dropboxContainer.querySelector('.vscomp-search-wrapper'); - this.$optionsContainer = this.$dropboxContainer.querySelector('.vscomp-options-container'); - this.$optionsList = this.$dropboxContainer.querySelector('.vscomp-options-list'); - this.$options = this.$dropboxContainer.querySelector('.vscomp-options'); - this.$noOptions = this.$dropboxContainer.querySelector('.vscomp-no-options'); - this.$noSearchResults = this.$dropboxContainer.querySelector('.vscomp-no-search-results'); - this.afterRenderWrapper(); - } - }, { - key: "renderDropbox", - value: function renderDropbox(_ref) { - var wrapperClasses = _ref.wrapperClasses; - var $wrapper = this.dropboxWrapper !== 'self' ? document.querySelector(this.dropboxWrapper) : null; - var dropboxClasses = 'vscomp-dropbox'; - if (this.additionalDropboxClasses) { - dropboxClasses += " ".concat(this.additionalDropboxClasses); - } - var dropboxContainerClasses = 'vscomp-dropbox-container'; - if (this.additionalDropboxContainerClasses) { - dropboxContainerClasses += " ".concat(this.additionalDropboxContainerClasses); - } + /** dom event methods - start */ + removeEvents() { + this.removeEvent(document, 'click', 'onDocumentClick'); + this.removeEvent(this.$allWrappers, 'keydown', 'onKeyDown'); + this.removeEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); + this.removeEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); + this.removeEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); + this.removeEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); + this.removeEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); + this.removeEvent(this.$options, 'click', 'onOptionsClick'); + this.removeEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); + this.removeEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); + + // Remove search-related events that are added in renderSearch() + if (this.$searchInput) { + this.removeEvent(this.$searchInput, 'input', 'onSearch'); + this.removeEvent(this.$searchInput, 'change', 'preventPropagation'); + if (this.$searchClear) { + this.removeEvent(this.$searchClear, 'click', 'onSearchClear'); + this.removeEvent(this.$searchClear, 'keydown', 'onSearchClear'); + } + } + if (this.$toggleAllButton) { + this.removeEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); + } + if (this.$dropboxContainerBottom) { + this.removeEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + if (this.$dropboxContainerTop) { + this.removeEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); + } + this.removeMutationObserver(); + } + removeEvent($ele, events, method) { + if (!$ele) { + return; + } + const eventsArray = Utils.removeArrayEmpty(events.split(' ')); + eventsArray.forEach(event => { + const eventsKey = `${method}-${event}`; + const callback = this.events[eventsKey]; + if (callback) { + DomUtils.removeEvent($ele, event, callback); + } + }); + } + onDocumentClick(e) { + const $clickedEle = e.target.closest('.vscomp-wrapper'); + + // Close all if clicking outside any dropdown + if (!$clickedEle) { + VirtualSelect.openInstances.forEach(instance => { + // Don't focus when closing due to clicking outside + const instanceObj = instance; + instanceObj.shouldFocusWrapperOnClose = false; + instanceObj.closeDropbox(); + }); + return; + } - // eslint-disable-next-line no-trailing-spaces - var html = "
\n
 
\n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
").concat(this.noOptionsText, "
\n
").concat(this.noSearchResultsText, "
\n\n \n
\n
 
\n
"); - if ($wrapper) { - var $dropboxWrapper = document.createElement('div'); - this.$dropboxWrapper = $dropboxWrapper; - this.hasDropboxWrapper = true; - $dropboxWrapper.innerHTML = html; - $wrapper.appendChild($dropboxWrapper); - DomUtils.addClass($dropboxWrapper, "vscomp-dropbox-wrapper ".concat(wrapperClasses)); - if (!this.keepAlwaysOpen) { - DomUtils.setAttr($dropboxWrapper, 'tabindex', '-1'); - DomUtils.setAria($dropboxWrapper, 'hidden', true); - } - return ''; - } - this.hasDropboxWrapper = false; - return html; + // If clicking a different dropdown, close current one + const clickedInstance = $clickedEle.parentElement.virtualSelect; + if (clickedInstance && clickedInstance !== this && this.isOpened() && !this.keepAlwaysOpen) { + // Don't focus when closing due to another dropdown being opened + this.shouldFocusWrapperOnClose = false; + this.closeDropbox(); } - }, { - key: "renderOptions", - value: function renderOptions() { - var _this = this; - // Calculate ARIA metadata before rendering to ensure it's always up to date - this.calculateAriaMetadata(); - var html = ''; - var visibleOptions = this.getVisibleOptions(); - var checkboxHtml = ''; - var newOptionIconHtml = ''; - var markSearchResults = !!(this.markSearchResults && this.searchValue); - var searchRegex; - var labelRenderer = this.labelRenderer, - disableOptionGroupCheckbox = this.disableOptionGroupCheckbox, - uniqueId = this.uniqueId, - searchGroup = this.searchGroup; - var hasLabelRenderer = typeof labelRenderer === 'function'; - var convertToBoolean = Utils.convertToBoolean; - var groupName = ''; - if (markSearchResults) { - searchRegex = new RegExp("(".concat(Utils.regexEscape(this.searchValue), ")(?!([^<]+)?>)"), 'gi'); - } - if (this.multiple) { - checkboxHtml = ''; - } - if (this.allowNewOption) { - var newOptionTooltip = this.getTooltipAttrText('New Option'); - newOptionIconHtml = ""); + } + onKeyDown(e) { + const key = e.which || e.keyCode; + const method = keyDownMethodMapping[key]; + if (document.activeElement === this.$searchInput && !e.shiftKey && key === 9 && !this.multiple) { + e.preventDefault(); + this.focusFirstVisibleOption(); + } + if (document.activeElement === this.$toggleAllButton && key === 13) { + this.toggleAllOptions(); + return; + } + + // Handle the Escape key when showing the dropdown as a popup, closing it + if (key === 27 || e.key === 'Escape') { + const wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper; + if (wrapper && (document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) { + this.closeDropbox(); + return; } - visibleOptions.forEach(function (d) { - var index = d.index; - var optionLabel; - var optionClasses = 'vscomp-option'; - var optionTooltip = _this.getTooltipAttrText('', true, true); - var leftSection = checkboxHtml; - var rightSection = ''; - var description = ''; - var groupIndexText = ''; - var ariaLabel = ''; - var tabIndexValue = '-1'; - var isSelected = convertToBoolean(d.isSelected); - var ariaDisabledText = ''; - if (d.classNames) { - optionClasses += " ".concat(d.classNames); - } - if (d.isFocused) { - tabIndexValue = '0'; - optionClasses += ' focused'; - } - if (d.isDisabled) { - optionClasses += ' disabled'; - ariaDisabledText = 'aria-disabled="true"'; - } - if (d.isGroupTitle) { - groupName = d.label; - optionClasses += ' group-title'; - if (disableOptionGroupCheckbox) { - leftSection = ''; - } - } - if (isSelected) { - optionClasses += ' selected'; - } - if (d.isGroupOption) { - var optionDesc = ''; - optionClasses += ' group-option'; - groupIndexText = "data-group-index=\"".concat(d.groupIndex, "\""); - if (d.customData) { - groupName = d.customData.group_name !== undefined ? "".concat(d.customData.group_name, ", ") : ''; - optionDesc = d.customData.description !== undefined ? " ".concat(d.customData.description, ",") : ''; - ariaLabel = "aria-label=\"".concat(groupName, " ").concat(d.label, ", ").concat(optionDesc, "\""); - } else { - ariaLabel = "aria-label=\"".concat(groupName, ", ").concat(d.label, "\""); - } - } - if (hasLabelRenderer) { - optionLabel = labelRenderer(d); - } else { - optionLabel = d.label; - } - if (d.description) { - description = "
").concat(d.description, "
"); - } - if (d.isCurrentNew) { - optionClasses += ' current-new'; - rightSection += newOptionIconHtml; - } else if (markSearchResults && (!d.isGroupTitle || searchGroup)) { - optionLabel = optionLabel.replace(searchRegex, '$1'); - } - - // Add aria-setsize and aria-posinset for virtualized listbox accessibility - var ariaAttrs = ''; - if (_this.ariaSetSize > 0) { - ariaAttrs = "aria-setsize=\"".concat(_this.ariaSetSize, "\""); - if (d.filteredIndex) { - ariaAttrs += " aria-posinset=\"".concat(d.filteredIndex, "\""); - } - } - html += "
\n ").concat(leftSection, "\n \n ").concat(optionLabel, "\n \n ").concat(description, "\n ").concat(rightSection, "\n
"); - }); - groupName = ''; - this.$options.innerHTML = html; - this.$visibleOptions = this.$options.querySelectorAll('.vscomp-option'); - this.afterRenderOptions(); - } - }, { - key: "renderSearch", - value: function renderSearch() { - if (!this.hasSearchContainer) { - return; - } - var checkboxHtml = ''; - var searchInput = ''; - if (this.multiple && !this.disableSelectAll) { - checkboxHtml = "\n \n ").concat(this.selectAllText, "\n "); - } - if (this.hasSearch) { - var ariaLabelSearchClearBtnTxt = this.ariaLabelSearchClearButtonText ? "aria-label=\"".concat(this.ariaLabelSearchClearButtonText, "\"") : ''; - searchInput = "\n \n ×"); - } - var html = "
\n ".concat(checkboxHtml, "\n ").concat(searchInput, "\n
"); - this.$search.innerHTML = html; - this.$searchInput = this.$dropboxContainer.querySelector('.vscomp-search-input'); - this.$searchClear = this.$dropboxContainer.querySelector('.vscomp-search-clear'); - this.$toggleAllButton = this.$dropboxContainer.querySelector('.vscomp-toggle-all-button'); - this.$toggleAllCheckbox = this.$dropboxContainer.querySelector('.vscomp-toggle-all-checkbox'); - this.addEvent(this.$searchInput, 'input', 'onSearch'); - // Prevents the change event from bubbling and triggering the main onChange handler twice. - this.addEvent(this.$searchInput, 'change', 'preventPropagation'); - this.addEvent(this.$searchClear, 'click keydown', 'onSearchClear'); - this.addEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); - this.addEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); - this.addEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - /** render methods - end */ - - /** dom event methods - start */ - }, { - key: "addEvents", - value: function addEvents() { - this.addEvent(document, 'click', 'onDocumentClick', true); - this.addEvent(this.$allWrappers, 'keydown', 'onKeyDown'); - this.addEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); - this.addEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); - this.addEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); - this.addEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); - this.addEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); - this.addEvent(this.$options, 'click', 'onOptionsClick'); - this.addEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); - this.addEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); - this.addMutationObserver(); - } - }, { - key: "addEvent", - value: function addEvent($ele, events, method) { - var _this2 = this; - var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var eventsKey = "".concat(method, "-").concat(event); - var callback = _this2.events[eventsKey]; - if (!callback) { - callback = _this2[method].bind(_this2); - _this2.events[eventsKey] = callback; - } - DomUtils.addEvent($ele, event, callback, capture); - }); } - - /** dom event methods - start */ - }, { - key: "removeEvents", - value: function removeEvents() { - this.removeEvent(document, 'click', 'onDocumentClick'); - this.removeEvent(this.$allWrappers, 'keydown', 'onKeyDown'); - this.removeEvent(this.$toggleButton, 'click keydown', 'onToggleButtonPress'); - this.removeEvent(this.$clearButton, 'click keydown', 'onClearButtonClick'); - this.removeEvent(this.$dropboxContainer, 'click', 'onDropboxContainerClick'); - this.removeEvent(this.$dropboxCloseButton, 'click', 'onDropboxCloseButtonClick'); - this.removeEvent(this.$optionsContainer, 'scroll', 'onOptionsScroll'); - this.removeEvent(this.$options, 'click', 'onOptionsClick'); - this.removeEvent(this.$options, 'mouseover', 'onOptionsMouseOver'); - this.removeEvent(this.$options, 'touchmove', 'onOptionsTouchMove'); - - // Remove search-related events that are added in renderSearch() - if (this.$searchInput) { - this.removeEvent(this.$searchInput, 'input', 'onSearch'); - this.removeEvent(this.$searchInput, 'change', 'preventPropagation'); - if (this.$searchClear) { - this.removeEvent(this.$searchClear, 'click', 'onSearchClear'); - this.removeEvent(this.$searchClear, 'keydown', 'onSearchClear'); - } - } - if (this.$toggleAllButton) { - this.removeEvent(this.$toggleAllButton, 'click', 'onToggleAllOptions'); - } - if (this.$dropboxContainerBottom) { - this.removeEvent(this.$dropboxContainerBottom, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - if (this.$dropboxContainerTop) { - this.removeEvent(this.$dropboxContainerTop, 'focus', 'onDropboxContainerTopOrBottomFocus'); - } - this.removeMutationObserver(); + if (method) { + this[method](e); } - }, { - key: "removeEvent", - value: function removeEvent($ele, events, method) { - var _this3 = this; - if (!$ele) { - return; - } - var eventsArray = Utils.removeArrayEmpty(events.split(' ')); - eventsArray.forEach(function (event) { - var eventsKey = "".concat(method, "-").concat(event); - var callback = _this3.events[eventsKey]; - if (callback) { - DomUtils.removeEvent($ele, event, callback); - } + } + onEnterPress(e) { + e.preventDefault(); + if (this.isOpened()) { + this.selectFocusedOption(); + } else if (this.$ele.disabled === false) { + this.openDropbox(); + } + } + onDownArrowPress(e) { + // Allow default behavior (cursor movement) when search input is focused + if (document.activeElement === this.$searchInput) { + return; + } + e.preventDefault(); + if (this.isOpened()) { + this.focusOption({ + direction: 'next' }); + } else { + this.openDropbox(); } - }, { - key: "onDocumentClick", - value: function onDocumentClick(e) { - var $clickedEle = e.target.closest('.vscomp-wrapper'); - - // Close all if clicking outside any dropdown - if (!$clickedEle) { - VirtualSelect.openInstances.forEach(function (instance) { - // Don't focus when closing due to clicking outside - var instanceObj = instance; - instanceObj.shouldFocusWrapperOnClose = false; - instanceObj.closeDropbox(); - }); - return; - } - - // If clicking a different dropdown, close current one - var clickedInstance = $clickedEle.parentElement.virtualSelect; - if (clickedInstance && clickedInstance !== this && this.isOpened() && !this.keepAlwaysOpen) { - // Don't focus when closing due to another dropdown being opened - this.shouldFocusWrapperOnClose = false; - this.closeDropbox(); - } + } + onUpArrowPress(e) { + // Allow default behavior (cursor movement) when search input is focused + if (document.activeElement === this.$searchInput) { + return; } - }, { - key: "onKeyDown", - value: function onKeyDown(e) { - var key = e.which || e.keyCode; - var method = keyDownMethodMapping[key]; - if (document.activeElement === this.$searchInput && !e.shiftKey && key === 9 && !this.multiple) { - e.preventDefault(); - this.focusFirstVisibleOption(); - } - if (document.activeElement === this.$toggleAllButton && key === 13) { - this.toggleAllOptions(); - return; - } - - // Handle the Escape key when showing the dropdown as a popup, closing it - if (key === 27 || e.key === 'Escape') { - var wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper; - if (wrapper && (document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) { - this.closeDropbox(); - return; - } - } - if (method) { - this[method](e); - } + e.preventDefault(); + if (this.isOpened()) { + this.focusOption({ + direction: 'previous' + }); + } else { + this.openDropbox(); } - }, { - key: "onEnterPress", - value: function onEnterPress(e) { + } + onBackspaceOrDeletePress(e) { + if (e.target === this.$wrapper) { e.preventDefault(); - if (this.isOpened()) { - this.selectFocusedOption(); - } else if (this.$ele.disabled === false) { - this.openDropbox(); + if (this.selectedValues.length > 0) { + this.reset(); } } - }, { - key: "onDownArrowPress", - value: function onDownArrowPress(e) { - // Allow default behavior (cursor movement) when search input is focused - if (document.activeElement === this.$searchInput) { + } + onToggleButtonPress(e) { + if (e.type === 'keydown') { + // Allow default Tab navigation and other non-activation keys + if (e.code !== 'Enter' && e.code !== 'Space') { return; } e.preventDefault(); - if (this.isOpened()) { - this.focusOption({ - direction: 'next' - }); + } + const $target = e.target; + if ($target.closest('.vscomp-value-tag-clear-button')) { + e.stopPropagation(); + this.removeValue($target.closest('.vscomp-value-tag')); + return; + } + if (!$target.closest('.toggle-button-child')) { + // Let the event bubble normally + this.toggleDropbox(); + } + } + onClearButtonClick(e) { + if (e.type === 'click') { + this.reset(); + } else if (e.type === 'keydown' && (e.code === 'Enter' || e.code === 'Space')) { + e.stopPropagation(); + this.reset(); + } + } + onOptionsScroll() { + this.setVisibleOptions(true); + } + onOptionsClick(e) { + const $option = e.target.closest('.vscomp-option'); + if ($option && !DomUtils.hasClass($option, 'disabled')) { + if (DomUtils.hasClass($option, 'group-title')) { + this.onGroupTitleClick($option); } else { - this.openDropbox(); + this.selectOption($option, { + event: e + }); } } - }, { - key: "onUpArrowPress", - value: function onUpArrowPress(e) { - // Allow default behavior (cursor movement) when search input is focused - if (document.activeElement === this.$searchInput) { - return; - } - e.preventDefault(); - if (this.isOpened()) { + } + onGroupTitleClick($ele) { + if (!$ele || !this.multiple || this.disableOptionGroupCheckbox) { + return; + } + const isAdding = !DomUtils.hasClass($ele, 'selected'); + this.toggleGroupTitleCheckbox($ele, isAdding); + this.toggleGroupOptions($ele, isAdding); + } + onDropboxContainerClick(e) { + if (!e.target.closest('.vscomp-dropbox')) { + this.closeDropbox(); + } + } + onDropboxCloseButtonClick() { + this.closeDropbox(); + } + onOptionsMouseOver(e) { + const $ele = e.target.closest('.vscomp-option'); + if ($ele && this.isOpened()) { + if (DomUtils.hasClass($ele, 'disabled') || DomUtils.hasClass($ele, 'group-title')) { + this.removeOptionFocus(); + } else { this.focusOption({ - direction: 'previous' + $option: $ele }); - } else { - this.openDropbox(); - } - } - }, { - key: "onBackspaceOrDeletePress", - value: function onBackspaceOrDeletePress(e) { - if (e.target === this.$wrapper) { - e.preventDefault(); - if (this.selectedValues.length > 0) { - this.reset(); - } } } - }, { - key: "onToggleButtonPress", - value: function onToggleButtonPress(e) { - if (e.type === 'keydown') { - // Allow default Tab navigation and other non-activation keys - if (e.code !== 'Enter' && e.code !== 'Space') { - return; - } - e.preventDefault(); - } - var $target = e.target; - if ($target.closest('.vscomp-value-tag-clear-button')) { - e.stopPropagation(); - this.removeValue($target.closest('.vscomp-value-tag')); - return; - } - if (!$target.closest('.toggle-button-child')) { - // Let the event bubble normally - this.toggleDropbox(); - } + } + onOptionsTouchMove() { + this.removeOptionFocus(); + } + onSearch(e) { + e.stopPropagation(); + this.setSearchValue(e.target.value, true); + } + preventPropagation(e) { + e.stopPropagation(); + } + onSearchClear(e) { + e.stopPropagation(); + if (e.code === 'Enter' || e.code === 'Space' || e.type === 'click') { + this.setSearchValue(''); + this.focusSearchInput(); } - }, { - key: "onClearButtonClick", - value: function onClearButtonClick(e) { - if (e.type === 'click') { - this.reset(); - } else if (e.type === 'keydown' && (e.code === 'Enter' || e.code === 'Space')) { - e.stopPropagation(); - this.reset(); - } + } + onToggleAllOptions() { + this.toggleAllOptions(); + } + onDropboxContainerTopOrBottomFocus() { + this.closeDropbox(); + } + onResize() { + this.setOptionsContainerHeight(true); + } + + /** to remove dropboxWrapper on removing vscomp-ele when it is rendered outside of vscomp-ele */ + addMutationObserver() { + if (!this.hasDropboxWrapper) { + return; } - }, { - key: "onOptionsScroll", - value: function onOptionsScroll() { - this.setVisibleOptions(true); - } - }, { - key: "onOptionsClick", - value: function onOptionsClick(e) { - var $option = e.target.closest('.vscomp-option'); - if ($option && !DomUtils.hasClass($option, 'disabled')) { - if (DomUtils.hasClass($option, 'group-title')) { - this.onGroupTitleClick($option); - } else { - this.selectOption($option, { - event: e - }); + const $vscompEle = this.$ele; + this.mutationObserver = new MutationObserver(mutations => { + let isAdded = false; + let isRemoved = false; + mutations.forEach(mutation => { + if (!isAdded) { + isAdded = [...mutation.addedNodes].some($ele => !!($ele === $vscompEle || $ele.contains($vscompEle))); } - } - } - }, { - key: "onGroupTitleClick", - value: function onGroupTitleClick($ele) { - if (!$ele || !this.multiple || this.disableOptionGroupCheckbox) { - return; - } - var isAdding = !DomUtils.hasClass($ele, 'selected'); - this.toggleGroupTitleCheckbox($ele, isAdding); - this.toggleGroupOptions($ele, isAdding); - } - }, { - key: "onDropboxContainerClick", - value: function onDropboxContainerClick(e) { - if (!e.target.closest('.vscomp-dropbox')) { - this.closeDropbox(); - } + if (!isRemoved) { + isRemoved = [...mutation.removedNodes].some($ele => !!($ele === $vscompEle || $ele.contains($vscompEle))); + } + }); + if (isRemoved && !isAdded) { + this.destroy(); + } + }); + this.mutationObserver.observe(document.querySelector('body'), { + childList: true, + subtree: true + }); + } + removeMutationObserver() { + if (this.hasDropboxWrapper) { + this.mutationObserver.disconnect(); } - }, { - key: "onDropboxCloseButtonClick", - value: function onDropboxCloseButtonClick() { - this.closeDropbox(); + } + + /** dom event methods - end */ + /** before event methods - start */ + beforeValueSet(isReset) { + this.toggleAllOptionsClass(isReset ? false : undefined); + } + beforeSelectNewValue(selectedValue) { + const newOption = this.getNewOption(); + if (newOption) { + const newIndex = newOption.index; + this.newValues.push(newOption.value); + this.setOptionProp(newIndex, 'isCurrentNew', false); + this.setOptionProp(newIndex, 'isNew', true); + } else if (selectedValue) { + // In single-select flow the temporary current-new option can be removed + // when dropdown close resets search, so re-add as a persisted new option. + this.setNewOption(selectedValue); + this.toggleSelectedProp(this.lastOptionIndex, true); + } + + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.setSearchValue(''); + this.focusSearchInput(); + }, 0); + } + /** before event methods - end */ + + /** after event methods - start */ + afterRenderWrapper() { + DomUtils.addClass(this.$ele, 'vscomp-ele'); + this.renderSearch(); + this.setEleStyles(); + this.setDropboxStyles(); + this.setVisibleOptionsCount(); + this.setOptionsContainerHeight(); + this.addEvents(); + this.setEleProps(); + if (!this.keepAlwaysOpen && !this.showAsPopup) { + this.initDropboxPopover(); + } + if (this.initialSelectedValue) { + this.setValueMethod(this.initialSelectedValue, this.silentInitialValueSet); + } else if (this.autoSelectFirstOption && this.visibleOptions.length) { + this.setValueMethod(this.visibleOptions[0].value, this.silentInitialValueSet); + } + if (this.showOptionsOnlyOnSearch) { + this.setSearchValue('', false, true); + } + if (this.initialDisabled) { + this.disable(); + } + if (this.autofocus) { + this.focus(); } - }, { - key: "onOptionsMouseOver", - value: function onOptionsMouseOver(e) { - var $ele = e.target.closest('.vscomp-option'); - if ($ele && this.isOpened()) { - if (DomUtils.hasClass($ele, 'disabled') || DomUtils.hasClass($ele, 'group-title')) { - this.removeOptionFocus(); - } else { - this.focusOption({ - $option: $ele + } + afterRenderOptions() { + const visibleOptions = this.getVisibleOptions(); + const hasNoOptions = !this.options.length && !this.hasServerSearch; + const hasNoSearchResults = !hasNoOptions && !visibleOptions.length; + if (!this.allowNewOption || this.hasServerSearch || this.showOptionsOnlyOnSearch) { + DomUtils.toggleClass(this.$allWrappers, 'has-no-search-results', hasNoSearchResults); + if (hasNoSearchResults) { + DomUtils.setAttr(this.$noSearchResults, 'tabindex', '0'); + DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'false'); + } else { + DomUtils.setAttr(this.$noSearchResults, 'tabindex', '-1'); + DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'true'); + } + } + DomUtils.toggleClass(this.$allWrappers, 'has-no-options', hasNoOptions); + if (hasNoOptions) { + DomUtils.setAttr(this.$noOptions, 'tabindex', '0'); + DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'false'); + } else { + DomUtils.setAttr(this.$noOptions, 'tabindex', '-1'); + DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'true'); + } + this.setOptionAttr(); + this.setOptionsPosition(); + this.setOptionsTooltip(); + if (document.activeElement !== this.$searchInput) { + setTimeout(() => { + const focusedOption = DomUtils.getElementsBySelector('.focused', this.$dropboxContainer)[0]; + if (focusedOption !== undefined) { + focusedOption.focus({ + preventScroll: true }); } - } - } - }, { - key: "onOptionsTouchMove", - value: function onOptionsTouchMove() { - this.removeOptionFocus(); + }, 20); } - }, { - key: "onSearch", - value: function onSearch(e) { - e.stopPropagation(); - this.setSearchValue(e.target.value, true); + } + afterSetOptionsContainerHeight(reset) { + if (reset && this.showAsPopup) { + this.setVisibleOptions(); } - }, { - key: "preventPropagation", - value: function preventPropagation(e) { - e.stopPropagation(); + } + afterSetSearchValue() { + if (this.hasServerSearch) { + clearTimeout(this.serverSearchTimeout); + this.serverSearchTimeout = setTimeout(() => { + this.serverSearch(); + }, this.searchDelay); + } else { + this.setVisibleOptionsCount(); } - }, { - key: "onSearchClear", - value: function onSearchClear(e) { - e.stopPropagation(); - if (e.code === 'Enter' || e.code === 'Space' || e.type === 'click') { - this.setSearchValue(''); - this.focusSearchInput(); - } + if (this.selectAllOnlyVisible) { + this.toggleAllOptionsClass(); } - }, { - key: "onToggleAllOptions", - value: function onToggleAllOptions() { - this.toggleAllOptions(); + this.focusOption({ + focusFirst: true + }); + } + afterSetVisibleOptionsCount() { + this.scrollToTop(); + this.setOptionsHeight(); + this.setVisibleOptions(); + this.updatePosition(); + } + afterValueSet() { + this.scrollToTop(); + this.setSearchValue(''); + this.renderOptions(); + } + afterSetOptions(keepValue) { + if (keepValue) { + this.setSelectedProp(); } - }, { - key: "onDropboxContainerTopOrBottomFocus", - value: function onDropboxContainerTopOrBottomFocus() { - this.closeDropbox(); + this.setOptionsHeight(); + this.setVisibleOptions(); + if (this.showOptionsOnlyOnSearch) { + this.setSearchValue('', false, true); } - }, { - key: "onResize", - value: function onResize() { - this.setOptionsContainerHeight(true); + if (!keepValue) { + this.reset(); } + } + /** after event methods - end */ - /** to remove dropboxWrapper on removing vscomp-ele when it is rendered outside of vscomp-ele */ - }, { - key: "addMutationObserver", - value: function addMutationObserver() { - var _this4 = this; - if (!this.hasDropboxWrapper) { - return; - } - var $vscompEle = this.$ele; - this.mutationObserver = new MutationObserver(function (mutations) { - var isAdded = false; - var isRemoved = false; - mutations.forEach(function (mutation) { - if (!isAdded) { - isAdded = virtual_select_toConsumableArray(mutation.addedNodes).some(function ($ele) { - return !!($ele === $vscompEle || $ele.contains($vscompEle)); - }); - } - if (!isRemoved) { - isRemoved = virtual_select_toConsumableArray(mutation.removedNodes).some(function ($ele) { - return !!($ele === $vscompEle || $ele.contains($vscompEle)); - }); - } - }); - if (isRemoved && !isAdded) { - _this4.destroy(); - } - }); - this.mutationObserver.observe(document.querySelector('body'), { - childList: true, - subtree: true - }); - } - }, { - key: "removeMutationObserver", - value: function removeMutationObserver() { - if (this.hasDropboxWrapper) { - this.mutationObserver.disconnect(); - } - } + /** set methods - start */ + /** + * @param {virtualSelectOptions} params + */ + setProps(params) { + const options = this.setDefaultProps(params); + this.setPropsFromElementAttr(options); + const { + convertToBoolean + } = Utils; + this.$ele = options.ele; + this.dropboxWrapper = options.dropboxWrapper; + this.valueKey = options.valueKey; + this.labelKey = options.labelKey; + this.descriptionKey = options.descriptionKey; + this.aliasKey = options.aliasKey; + this.optionHeightText = options.optionHeight; + this.optionHeight = parseFloat(this.optionHeightText); + this.multiple = convertToBoolean(options.multiple); + this.hasSearch = convertToBoolean(options.search); + this.searchByStartsWith = convertToBoolean(options.searchByStartsWith); + this.searchGroup = convertToBoolean(options.searchGroup); + this.hideClearButton = convertToBoolean(options.hideClearButton); + this.autoSelectFirstOption = convertToBoolean(options.autoSelectFirstOption); + this.hasOptionDescription = convertToBoolean(options.hasOptionDescription); + this.silentInitialValueSet = convertToBoolean(options.silentInitialValueSet); + this.allowNewOption = convertToBoolean(options.allowNewOption); + this.markSearchResults = convertToBoolean(options.markSearchResults); + this.showSelectedOptionsFirst = convertToBoolean(options.showSelectedOptionsFirst); + this.disableSelectAll = convertToBoolean(options.disableSelectAll); + this.keepAlwaysOpen = convertToBoolean(options.keepAlwaysOpen); + this.showDropboxAsPopup = convertToBoolean(options.showDropboxAsPopup); + this.hideValueTooltipOnSelectAll = convertToBoolean(options.hideValueTooltipOnSelectAll); + this.showOptionsOnlyOnSearch = convertToBoolean(options.showOptionsOnlyOnSearch); + this.selectAllOnlyVisible = convertToBoolean(options.selectAllOnlyVisible); + this.alwaysShowSelectedOptionsCount = convertToBoolean(options.alwaysShowSelectedOptionsCount); + this.alwaysShowSelectedOptionsLabel = convertToBoolean(options.alwaysShowSelectedOptionsLabel); + this.disableAllOptionsSelectedText = convertToBoolean(options.disableAllOptionsSelectedText); + this.showValueAsTags = convertToBoolean(options.showValueAsTags); + this.disableOptionGroupCheckbox = convertToBoolean(options.disableOptionGroupCheckbox); + this.enableSecureText = convertToBoolean(options.enableSecureText); + this.setValueAsArray = convertToBoolean(options.setValueAsArray); + this.disableValidation = convertToBoolean(options.disableValidation); + this.initialDisabled = convertToBoolean(options.disabled); + this.required = convertToBoolean(options.required); + this.autofocus = convertToBoolean(options.autofocus); + this.useGroupValue = convertToBoolean(options.useGroupValue); + this.focusSelectedOptionOnOpen = convertToBoolean(options.focusSelectedOptionOnOpen); + this.noOptionsText = options.noOptionsText; + this.noSearchResultsText = options.noSearchResultsText; + this.selectAllText = options.selectAllText; + this.searchNormalize = options.searchNormalize; + this.searchPlaceholderText = options.searchPlaceholderText; + this.searchFormLabel = options.searchFormLabel; + this.optionsSelectedText = options.optionsSelectedText; + this.optionSelectedText = options.optionSelectedText; + this.allOptionsSelectedText = options.allOptionsSelectedText; + this.clearButtonText = options.clearButtonText; + this.moreText = options.moreText; + this.placeholder = options.placeholder; + this.position = options.position; + this.textDirection = options.textDirection; + this.dropboxWidth = options.dropboxWidth; + this.tooltipFontSize = options.tooltipFontSize; + this.tooltipAlignment = options.tooltipAlignment; + this.tooltipMaxWidth = options.tooltipMaxWidth; + this.updatePositionThrottle = options.updatePositionThrottle; + this.noOfDisplayValues = parseInt(options.noOfDisplayValues); + this.zIndex = parseInt(options.zIndex); + this.maxValues = parseInt(options.maxValues); + this.minValues = parseInt(options.minValues); + this.name = this.secureText(options.name); + this.additionalClasses = options.additionalClasses; + this.additionalDropboxClasses = options.additionalDropboxClasses; + this.additionalDropboxContainerClasses = options.additionalDropboxContainerClasses; + this.additionalToggleButtonClasses = options.additionalToggleButtonClasses; + this.popupDropboxBreakpoint = options.popupDropboxBreakpoint; + this.popupPosition = options.popupPosition; + this.onServerSearch = options.onServerSearch; + this.labelRenderer = options.labelRenderer; + this.selectedLabelRenderer = options.selectedLabelRenderer; + this.initialSelectedValue = options.selectedValue === 0 ? '0' : options.selectedValue; + this.emptyValue = options.emptyValue; + this.ariaLabelText = options.ariaLabelText; + this.ariaLabelledby = options.ariaLabelledby; + this.ariaLabelClearButtonText = options.ariaLabelClearButtonText; + this.ariaLabelTagClearButtonText = options.ariaLabelTagClearButtonText; + this.ariaLabelSearchClearButtonText = options.ariaLabelSearchClearButtonText; + this.maxWidth = options.maxWidth; + this.searchDelay = options.searchDelay; + this.showDuration = parseInt(options.showDuration); + this.hideDuration = parseInt(options.hideDuration); + + /** @type {string[]} */ + this.selectedValues = []; + /** @type {virtualSelectOption[]} */ + this.selectedOptions = []; + this.newValues = []; + this.events = {}; + this.tooltipEnterDelay = 200; + this.searchValue = ''; + this.searchValueOriginal = ''; + this.isAllSelected = false; + if (options.search === undefined && this.multiple || this.allowNewOption || this.showOptionsOnlyOnSearch) { + this.hasSearch = true; + } + this.hasServerSearch = typeof this.onServerSearch === 'function'; + if (this.maxValues || this.hasServerSearch || this.showOptionsOnlyOnSearch) { + this.disableSelectAll = true; + this.disableOptionGroupCheckbox = true; + } + if (this.keepAlwaysOpen) { + this.dropboxWrapper = 'self'; + } + this.showAsPopup = this.showDropboxAsPopup && !this.keepAlwaysOpen && window.innerWidth <= parseFloat(this.popupDropboxBreakpoint); + this.hasSearchContainer = this.hasSearch || this.multiple && !this.disableSelectAll; + this.optionsCount = this.getOptionsCount(options.optionsCount); + this.halfOptionsCount = Math.ceil(this.optionsCount / 2); + this.optionsHeight = this.getOptionsHeight(); + this.uniqueId = this.getUniqueId(); + this.shouldFocusWrapperOnClose = true; // Initialize focus management property + this.ariaSetSize = 0; + } - /** dom event methods - end */ - /** before event methods - start */ - }, { - key: "beforeValueSet", - value: function beforeValueSet(isReset) { - this.toggleAllOptionsClass(isReset ? false : undefined); - } - }, { - key: "beforeSelectNewValue", - value: function beforeSelectNewValue(selectedValue) { - var _this5 = this; - var newOption = this.getNewOption(); - if (newOption) { - var newIndex = newOption.index; - this.newValues.push(newOption.value); - this.setOptionProp(newIndex, 'isCurrentNew', false); - this.setOptionProp(newIndex, 'isNew', true); - } else if (selectedValue) { - // In single-select flow the temporary current-new option can be removed - // when dropdown close resets search, so re-add as a persisted new option. - this.setNewOption(selectedValue); - this.toggleSelectedProp(this.lastOptionIndex, true); + /** + * @param {virtualSelectOptions} options + */ + setDefaultProps(options) { + const defaultOptions = { + dropboxWrapper: 'self', + valueKey: 'value', + labelKey: 'label', + descriptionKey: 'description', + aliasKey: 'alias', + ariaLabelText: 'Options list', + ariaLabelClearButtonText: 'Clear button', + ariaLabelTagClearButtonText: 'Remove option', + ariaLabelSearchClearButtonText: 'Clear search input', + optionsCount: 5, + noOfDisplayValues: 50, + optionHeight: '40px', + noOptionsText: 'No options found', + noSearchResultsText: 'No results found', + selectAllText: 'Select All', + searchNormalize: false, + searchPlaceholderText: 'Search...', + searchFormLabel: 'Search', + clearButtonText: 'Clear', + moreText: 'more...', + optionsSelectedText: 'options selected', + optionSelectedText: 'option selected', + allOptionsSelectedText: 'All', + placeholder: 'Select', + position: 'bottom left', + zIndex: options.keepAlwaysOpen ? 1 : 2, + tooltipFontSize: '14px', + tooltipAlignment: 'center', + tooltipMaxWidth: '300px', + updatePositionThrottle: 100, + name: '', + additionalClasses: '', + additionalDropboxClasses: '', + additionalDropboxContainerClasses: '', + additionalToggleButtonClasses: '', + maxValues: 0, + showDropboxAsPopup: true, + popupDropboxBreakpoint: '576px', + popupPosition: 'center', + hideValueTooltipOnSelectAll: true, + emptyValue: '', + searchDelay: 300, + focusSelectedOptionOnOpen: true, + showDuration: 300, + hideDuration: 200 + }; + if (options.hasOptionDescription) { + defaultOptions.optionsCount = 4; + defaultOptions.optionHeight = '50px'; + } + return Object.assign(defaultOptions, options); + } + setPropsFromElementAttr(options) { + const $ele = options.ele; + Object.keys(attrPropsMapping).forEach(k => { + let value = $ele.getAttribute(k); + if (valueLessProps.indexOf(k) !== -1 && (value === '' || value === 'true')) { + value = true; } - - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this5.setSearchValue(''); - _this5.focusSearchInput(); - }, 0); - } - /** before event methods - end */ - - /** after event methods - start */ - }, { - key: "afterRenderWrapper", - value: function afterRenderWrapper() { - DomUtils.addClass(this.$ele, 'vscomp-ele'); - this.renderSearch(); - this.setEleStyles(); - this.setDropboxStyles(); - this.setVisibleOptionsCount(); - this.setOptionsContainerHeight(); - this.addEvents(); - this.setEleProps(); - if (!this.keepAlwaysOpen && !this.showAsPopup) { - this.initDropboxPopover(); + if (value) { + // eslint-disable-next-line no-param-reassign + options[attrPropsMapping[k]] = value; } - if (this.initialSelectedValue) { - this.setValueMethod(this.initialSelectedValue, this.silentInitialValueSet); - } else if (this.autoSelectFirstOption && this.visibleOptions.length) { - this.setValueMethod(this.visibleOptions[0].value, this.silentInitialValueSet); + }); + } + setEleProps() { + const { + $ele + } = this; + $ele.virtualSelect = this; + $ele.value = this.multiple ? [] : ''; + $ele.name = this.name; + $ele.disabled = false; + $ele.required = this.required; + $ele.autofocus = this.autofocus; + $ele.multiple = this.multiple; + $ele.form = $ele.closest('form'); + $ele.reset = VirtualSelect.reset; + $ele.setValue = VirtualSelect.setValueMethod; + $ele.setOptions = VirtualSelect.setOptionsMethod; + $ele.setDisabledOptions = VirtualSelect.setDisabledOptionsMethod; + $ele.setEnabledOptions = VirtualSelect.setEnabledOptionsMethod; + $ele.toggleSelectAll = VirtualSelect.toggleSelectAll; + $ele.isAllSelected = VirtualSelect.isAllSelected; + $ele.addOption = VirtualSelect.addOptionMethod; + $ele.getNewValue = VirtualSelect.getNewValueMethod; + $ele.getDisplayValue = VirtualSelect.getDisplayValueMethod; + $ele.getSelectedOptions = VirtualSelect.getSelectedOptionsMethod; + $ele.getDisabledOptions = VirtualSelect.getDisabledOptionsMethod; + $ele.open = VirtualSelect.openMethod; + $ele.close = VirtualSelect.closeMethod; + $ele.focus = VirtualSelect.focusMethod; + $ele.enable = VirtualSelect.enableMethod; + $ele.disable = VirtualSelect.disableMethod; + $ele.destroy = VirtualSelect.destroyMethod; + $ele.validate = VirtualSelect.validateMethod; + $ele.toggleRequired = VirtualSelect.toggleRequiredMethod; + if (this.hasDropboxWrapper) { + this.$dropboxWrapper.virtualSelect = this; + } + } + setValueMethod(newValue, silentChange) { + const valuesMapping = {}; + const valuesOrder = {}; + let validValues = []; + const isMultiSelect = this.multiple; + // Normalize input value first + let value = Utils.normalizeValues(newValue); + if (value) { + if (!Array.isArray(value)) { + value = [value]; } - if (this.showOptionsOnlyOnSearch) { - this.setSearchValue('', false, true); + if (isMultiSelect) { + const { + maxValues + } = this; + if (maxValues && value.length > maxValues) { + value.splice(maxValues); + } + } else if (value.length > 1) { + value = [value[0]]; } - if (this.initialDisabled) { - this.disable(); + if (this.useGroupValue) { + value = this.setGroupOptionsValue(value); } - if (this.autofocus) { - this.focus(); + value.forEach((d, i) => { + valuesMapping[d] = true; + valuesOrder[d] = i; + }); + if (this.allowNewOption && value) { + this.setNewOptionsFromValue(value); } } - }, { - key: "afterRenderOptions", - value: function afterRenderOptions() { - var _this6 = this; - var visibleOptions = this.getVisibleOptions(); - var hasNoOptions = !this.options.length && !this.hasServerSearch; - var hasNoSearchResults = !hasNoOptions && !visibleOptions.length; - if (!this.allowNewOption || this.hasServerSearch || this.showOptionsOnlyOnSearch) { - DomUtils.toggleClass(this.$allWrappers, 'has-no-search-results', hasNoSearchResults); - if (hasNoSearchResults) { - DomUtils.setAttr(this.$noSearchResults, 'tabindex', '0'); - DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'false'); - } else { - DomUtils.setAttr(this.$noSearchResults, 'tabindex', '-1'); - DomUtils.setAttr(this.$noSearchResults, 'aria-hidden', 'true'); - } - } - DomUtils.toggleClass(this.$allWrappers, 'has-no-options', hasNoOptions); - if (hasNoOptions) { - DomUtils.setAttr(this.$noOptions, 'tabindex', '0'); - DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'false'); + this.options.forEach(d => { + // Compare with normalized option values + const normalizedOptionValue = Utils.normalizeValues(d.value); + if (valuesMapping[normalizedOptionValue] === true && !d.isDisabled && !d.isGroupTitle) { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + // Store original value but compare with normalized value + validValues.push(d.value); } else { - DomUtils.setAttr(this.$noOptions, 'tabindex', '-1'); - DomUtils.setAttr(this.$noOptions, 'aria-hidden', 'true'); + // eslint-disable-next-line no-param-reassign + d.isSelected = false; } - this.setOptionAttr(); - this.setOptionsPosition(); - this.setOptionsTooltip(); - if (document.activeElement !== this.$searchInput) { - setTimeout(function () { - var focusedOption = DomUtils.getElementsBySelector('.focused', _this6.$dropboxContainer)[0]; - if (focusedOption !== undefined) { - focusedOption.focus({ - preventScroll: true - }); - } - }, 20); + }); + if (isMultiSelect) { + if (this.hasOptionGroup) { + this.setGroupsSelectedProp(); } + + /** sorting validValues in the given values order */ + validValues.sort((a, b) => valuesOrder[Utils.normalizeValues(a)] - valuesOrder[Utils.normalizeValues(b)]); + } else { + /** taking first value for single select */ + [validValues] = validValues; } - }, { - key: "afterSetOptionsContainerHeight", - value: function afterSetOptionsContainerHeight(reset) { - if (reset && this.showAsPopup) { - this.setVisibleOptions(); + this.beforeValueSet(); + this.setValue(validValues, { + disableEvent: silentChange + }); + this.afterValueSet(); + } + setGroupOptionsValue(preparedValues) { + const selectedValues = []; + const selectedGroups = {}; + const valuesMapping = {}; + preparedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + const { + value + } = d; + const isSelected = valuesMapping[value] === true; + if (d.isGroupTitle) { + if (isSelected) { + selectedGroups[d.index] = true; + } + } else if (isSelected || selectedGroups[d.groupIndex]) { + selectedValues.push(value); } + }); + return selectedValues; + } + setGroupsSelectedProp() { + const isAllGroupOptionsSelected = this.isAllGroupOptionsSelected.bind(this); + this.options.forEach(d => { + if (d.isGroupTitle) { + // eslint-disable-next-line no-param-reassign + d.isSelected = isAllGroupOptionsSelected(d.index); + } + }); + } + setOptionsMethod(options, keepValue) { + this.setOptions(options); + this.afterSetOptions(keepValue); + } + setDisabledOptionsMethod(disabledOptions, keepValue = false) { + this.setDisabledOptions(disabledOptions, true); + if (!keepValue) { + this.setValueMethod(null); + this.toggleAllOptionsClass(); } - }, { - key: "afterSetSearchValue", - value: function afterSetSearchValue() { - var _this7 = this; - if (this.hasServerSearch) { - clearTimeout(this.serverSearchTimeout); - this.serverSearchTimeout = setTimeout(function () { - _this7.serverSearch(); - }, this.searchDelay); - } else { - this.setVisibleOptionsCount(); + this.setVisibleOptions(); + } + setDisabledOptions(disabledOptions, setOptionsProp = false) { + let disabledOptionsArr = []; + if (!disabledOptions) { + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = false; + return d; + }); } - if (this.selectAllOnlyVisible) { - this.toggleAllOptionsClass(); + } else if (disabledOptions === true) { + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = true; + disabledOptionsArr.push(d.value); + return d; + }); } - this.focusOption({ - focusFirst: true + } else { + disabledOptionsArr = disabledOptions.map(d => d.toString()); + const disabledOptionsMapping = {}; + disabledOptionsArr.forEach(d => { + disabledOptionsMapping[d] = true; }); + if (setOptionsProp) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = disabledOptionsMapping[d.value] === true; + return d; + }); + } } - }, { - key: "afterSetVisibleOptionsCount", - value: function afterSetVisibleOptionsCount() { - this.scrollToTop(); - this.setOptionsHeight(); - this.setVisibleOptions(); - this.updatePosition(); - } - }, { - key: "afterValueSet", - value: function afterValueSet() { - this.scrollToTop(); - this.setSearchValue(''); - this.renderOptions(); + this.disabledOptions = disabledOptionsArr; + } + setEnabledOptionsMethod(disabledOptions, keepValue = false) { + this.setEnabledOptions(disabledOptions); + if (!keepValue) { + this.setValueMethod(null); + this.toggleAllOptionsClass(); } - }, { - key: "afterSetOptions", - value: function afterSetOptions(keepValue) { - if (keepValue) { - this.setSelectedProp(); - } - this.setOptionsHeight(); - this.setVisibleOptions(); - if (this.showOptionsOnlyOnSearch) { - this.setSearchValue('', false, true); - } - if (!keepValue) { - this.reset(); - } + this.setVisibleOptions(); + } + setEnabledOptions(enabledOptions) { + if (enabledOptions === undefined) { + return; } - /** after event methods - end */ - - /** set methods - start */ - /** - * @param {virtualSelectOptions} params - */ - }, { - key: "setProps", - value: function setProps(params) { - var options = this.setDefaultProps(params); - this.setPropsFromElementAttr(options); - var convertToBoolean = Utils.convertToBoolean; - this.$ele = options.ele; - this.dropboxWrapper = options.dropboxWrapper; - this.valueKey = options.valueKey; - this.labelKey = options.labelKey; - this.descriptionKey = options.descriptionKey; - this.aliasKey = options.aliasKey; - this.optionHeightText = options.optionHeight; - this.optionHeight = parseFloat(this.optionHeightText); - this.multiple = convertToBoolean(options.multiple); - this.hasSearch = convertToBoolean(options.search); - this.searchByStartsWith = convertToBoolean(options.searchByStartsWith); - this.searchGroup = convertToBoolean(options.searchGroup); - this.hideClearButton = convertToBoolean(options.hideClearButton); - this.autoSelectFirstOption = convertToBoolean(options.autoSelectFirstOption); - this.hasOptionDescription = convertToBoolean(options.hasOptionDescription); - this.silentInitialValueSet = convertToBoolean(options.silentInitialValueSet); - this.allowNewOption = convertToBoolean(options.allowNewOption); - this.markSearchResults = convertToBoolean(options.markSearchResults); - this.showSelectedOptionsFirst = convertToBoolean(options.showSelectedOptionsFirst); - this.disableSelectAll = convertToBoolean(options.disableSelectAll); - this.keepAlwaysOpen = convertToBoolean(options.keepAlwaysOpen); - this.showDropboxAsPopup = convertToBoolean(options.showDropboxAsPopup); - this.hideValueTooltipOnSelectAll = convertToBoolean(options.hideValueTooltipOnSelectAll); - this.showOptionsOnlyOnSearch = convertToBoolean(options.showOptionsOnlyOnSearch); - this.selectAllOnlyVisible = convertToBoolean(options.selectAllOnlyVisible); - this.alwaysShowSelectedOptionsCount = convertToBoolean(options.alwaysShowSelectedOptionsCount); - this.alwaysShowSelectedOptionsLabel = convertToBoolean(options.alwaysShowSelectedOptionsLabel); - this.disableAllOptionsSelectedText = convertToBoolean(options.disableAllOptionsSelectedText); - this.showValueAsTags = convertToBoolean(options.showValueAsTags); - this.disableOptionGroupCheckbox = convertToBoolean(options.disableOptionGroupCheckbox); - this.enableSecureText = convertToBoolean(options.enableSecureText); - this.setValueAsArray = convertToBoolean(options.setValueAsArray); - this.disableValidation = convertToBoolean(options.disableValidation); - this.initialDisabled = convertToBoolean(options.disabled); - this.required = convertToBoolean(options.required); - this.autofocus = convertToBoolean(options.autofocus); - this.useGroupValue = convertToBoolean(options.useGroupValue); - this.focusSelectedOptionOnOpen = convertToBoolean(options.focusSelectedOptionOnOpen); - this.noOptionsText = options.noOptionsText; - this.noSearchResultsText = options.noSearchResultsText; - this.selectAllText = options.selectAllText; - this.searchNormalize = options.searchNormalize; - this.searchPlaceholderText = options.searchPlaceholderText; - this.searchFormLabel = options.searchFormLabel; - this.optionsSelectedText = options.optionsSelectedText; - this.optionSelectedText = options.optionSelectedText; - this.allOptionsSelectedText = options.allOptionsSelectedText; - this.clearButtonText = options.clearButtonText; - this.moreText = options.moreText; - this.placeholder = options.placeholder; - this.position = options.position; - this.textDirection = options.textDirection; - this.dropboxWidth = options.dropboxWidth; - this.tooltipFontSize = options.tooltipFontSize; - this.tooltipAlignment = options.tooltipAlignment; - this.tooltipMaxWidth = options.tooltipMaxWidth; - this.updatePositionThrottle = options.updatePositionThrottle; - this.noOfDisplayValues = parseInt(options.noOfDisplayValues); - this.zIndex = parseInt(options.zIndex); - this.maxValues = parseInt(options.maxValues); - this.minValues = parseInt(options.minValues); - this.name = this.secureText(options.name); - this.additionalClasses = options.additionalClasses; - this.additionalDropboxClasses = options.additionalDropboxClasses; - this.additionalDropboxContainerClasses = options.additionalDropboxContainerClasses; - this.additionalToggleButtonClasses = options.additionalToggleButtonClasses; - this.popupDropboxBreakpoint = options.popupDropboxBreakpoint; - this.popupPosition = options.popupPosition; - this.onServerSearch = options.onServerSearch; - this.labelRenderer = options.labelRenderer; - this.selectedLabelRenderer = options.selectedLabelRenderer; - this.initialSelectedValue = options.selectedValue === 0 ? '0' : options.selectedValue; - this.emptyValue = options.emptyValue; - this.ariaLabelText = options.ariaLabelText; - this.ariaLabelledby = options.ariaLabelledby; - this.ariaLabelClearButtonText = options.ariaLabelClearButtonText; - this.ariaLabelTagClearButtonText = options.ariaLabelTagClearButtonText; - this.ariaLabelSearchClearButtonText = options.ariaLabelSearchClearButtonText; - this.maxWidth = options.maxWidth; - this.searchDelay = options.searchDelay; - this.showDuration = parseInt(options.showDuration); - this.hideDuration = parseInt(options.hideDuration); + const disabledOptionsArr = []; + if (enabledOptions === true) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isDisabled = false; + return d; + }); + } else { + const enabledOptionsMapping = {}; + enabledOptions.forEach(d => { + enabledOptionsMapping[d] = true; + }); + this.options.forEach(d => { + const isDisabled = enabledOptionsMapping[d.value] !== true; - /** @type {string[]} */ - this.selectedValues = []; - /** @type {virtualSelectOption[]} */ - this.selectedOptions = []; - this.newValues = []; - this.events = {}; - this.tooltipEnterDelay = 200; - this.searchValue = ''; - this.searchValueOriginal = ''; - this.isAllSelected = false; - if (options.search === undefined && this.multiple || this.allowNewOption || this.showOptionsOnlyOnSearch) { - this.hasSearch = true; - } - this.hasServerSearch = typeof this.onServerSearch === 'function'; - if (this.maxValues || this.hasServerSearch || this.showOptionsOnlyOnSearch) { - this.disableSelectAll = true; - this.disableOptionGroupCheckbox = true; - } - if (this.keepAlwaysOpen) { - this.dropboxWrapper = 'self'; - } - this.showAsPopup = this.showDropboxAsPopup && !this.keepAlwaysOpen && window.innerWidth <= parseFloat(this.popupDropboxBreakpoint); - this.hasSearchContainer = this.hasSearch || this.multiple && !this.disableSelectAll; - this.optionsCount = this.getOptionsCount(options.optionsCount); - this.halfOptionsCount = Math.ceil(this.optionsCount / 2); - this.optionsHeight = this.getOptionsHeight(); - this.uniqueId = this.getUniqueId(); - this.shouldFocusWrapperOnClose = true; // Initialize focus management property - this.ariaSetSize = 0; + // eslint-disable-next-line no-param-reassign + d.isDisabled = isDisabled; + if (isDisabled) { + disabledOptionsArr.push(d.value); + } + return d; + }); } - - /** - * @param {virtualSelectOptions} options - */ - }, { - key: "setDefaultProps", - value: function setDefaultProps(options) { - var defaultOptions = { - dropboxWrapper: 'self', - valueKey: 'value', - labelKey: 'label', - descriptionKey: 'description', - aliasKey: 'alias', - ariaLabelText: 'Options list', - ariaLabelClearButtonText: 'Clear button', - ariaLabelTagClearButtonText: 'Remove option', - ariaLabelSearchClearButtonText: 'Clear search input', - optionsCount: 5, - noOfDisplayValues: 50, - optionHeight: '40px', - noOptionsText: 'No options found', - noSearchResultsText: 'No results found', - selectAllText: 'Select All', - searchNormalize: false, - searchPlaceholderText: 'Search...', - searchFormLabel: 'Search', - clearButtonText: 'Clear', - moreText: 'more...', - optionsSelectedText: 'options selected', - optionSelectedText: 'option selected', - allOptionsSelectedText: 'All', - placeholder: 'Select', - position: 'bottom left', - zIndex: options.keepAlwaysOpen ? 1 : 2, - tooltipFontSize: '14px', - tooltipAlignment: 'center', - tooltipMaxWidth: '300px', - updatePositionThrottle: 100, - name: '', - additionalClasses: '', - additionalDropboxClasses: '', - additionalDropboxContainerClasses: '', - additionalToggleButtonClasses: '', - maxValues: 0, - showDropboxAsPopup: true, - popupDropboxBreakpoint: '576px', - popupPosition: 'center', - hideValueTooltipOnSelectAll: true, - emptyValue: '', - searchDelay: 300, - focusSelectedOptionOnOpen: true, - showDuration: 300, - hideDuration: 200 + this.disabledOptions = disabledOptionsArr; + } + setOptions(options = []) { + const preparedOptions = []; + const hasDisabledOptions = this.disabledOptions.length; + const { + valueKey, + labelKey, + descriptionKey, + aliasKey, + hasOptionDescription + } = this; + const { + getString, + convertToBoolean + } = Utils; + const secureText = this.secureText.bind(this); + const getAlias = this.getAlias.bind(this); + let index = 0; + let hasOptionGroup = false; + const disabledOptionsMapping = {}; + let hasEmptyValueOption = false; + this.disabledOptions.forEach(d => { + disabledOptionsMapping[d] = true; + }); + const prepareOption = d => { + if (typeof d !== 'object') { + // eslint-disable-next-line no-param-reassign + d = { + [valueKey]: d, + [labelKey]: d + }; + } + const value = secureText(getString(d[valueKey])); + const label = secureText(getString(d[labelKey])); + const childOptions = d.options; + const isGroupTitle = !!childOptions; + const option = { + index, + value, + valueNormalized: value.toLowerCase(), + label, + labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), + alias: getAlias(d[aliasKey]), + isVisible: convertToBoolean(d.isVisible, true), + isNew: d.isNew || false, + isGroupTitle, + classNames: d.classNames }; - if (options.hasOptionDescription) { - defaultOptions.optionsCount = 4; - defaultOptions.optionHeight = '50px'; + if (!hasEmptyValueOption && value === '') { + hasEmptyValueOption = true; + } + if (hasDisabledOptions) { + option.isDisabled = disabledOptionsMapping[value] === true; + } + if (d.isGroupOption) { + option.isGroupOption = true; + option.groupIndex = d.groupIndex; + } + if (hasOptionDescription) { + const description = secureText(getString(d[descriptionKey])); + option.description = description; + option.descriptionNormalized = this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(); + } + if (d.customData) { + option.customData = d.customData; + } + preparedOptions.push(option); + index += 1; + if (isGroupTitle) { + const groupIndex = option.index; + hasOptionGroup = true; + childOptions.forEach(childData => { + // eslint-disable-next-line no-param-reassign + childData.isGroupOption = true; + // eslint-disable-next-line no-param-reassign + childData.groupIndex = groupIndex; + prepareOption(childData); + }); } - return Object.assign(defaultOptions, options); - } - }, { - key: "setPropsFromElementAttr", - value: function setPropsFromElementAttr(options) { - var $ele = options.ele; - Object.keys(attrPropsMapping).forEach(function (k) { - var value = $ele.getAttribute(k); - if (valueLessProps.indexOf(k) !== -1 && (value === '' || value === 'true')) { - value = true; - } - if (value) { + }; + if (Array.isArray(options)) { + options.forEach(prepareOption); + } + const optionsLength = preparedOptions.length; + const { + $ele + } = this; + $ele.options = preparedOptions; + $ele.length = optionsLength; + this.options = preparedOptions; + this.visibleOptionsCount = optionsLength; + this.lastOptionIndex = optionsLength - 1; + this.newValues = []; + this.hasOptionGroup = hasOptionGroup; + this.hasEmptyValueOption = hasEmptyValueOption; + this.setSortedOptions(); + } + setServerOptions(options = []) { + this.setOptionsMethod(options, true); + const { + selectedOptions + } = this; + const newOptions = this.options; + let optionsUpdated = false; + + /** merging already selected options details with new options */ + if (selectedOptions.length) { + const newOptionsValueMapping = {}; + optionsUpdated = true; + newOptions.forEach(d => { + newOptionsValueMapping[d.value] = true; + }); + selectedOptions.forEach(d => { + if (newOptionsValueMapping[d.value] !== true) { // eslint-disable-next-line no-param-reassign - options[attrPropsMapping[k]] = value; + d.isVisible = false; + newOptions.push(d); } }); + this.setOptionsMethod(newOptions, true); } - }, { - key: "setEleProps", - value: function setEleProps() { - var $ele = this.$ele; - $ele.virtualSelect = this; - $ele.value = this.multiple ? [] : ''; - $ele.name = this.name; - $ele.disabled = false; - $ele.required = this.required; - $ele.autofocus = this.autofocus; - $ele.multiple = this.multiple; - $ele.form = $ele.closest('form'); - $ele.reset = VirtualSelect.reset; - $ele.setValue = VirtualSelect.setValueMethod; - $ele.setOptions = VirtualSelect.setOptionsMethod; - $ele.setDisabledOptions = VirtualSelect.setDisabledOptionsMethod; - $ele.setEnabledOptions = VirtualSelect.setEnabledOptionsMethod; - $ele.toggleSelectAll = VirtualSelect.toggleSelectAll; - $ele.isAllSelected = VirtualSelect.isAllSelected; - $ele.addOption = VirtualSelect.addOptionMethod; - $ele.getNewValue = VirtualSelect.getNewValueMethod; - $ele.getDisplayValue = VirtualSelect.getDisplayValueMethod; - $ele.getSelectedOptions = VirtualSelect.getSelectedOptionsMethod; - $ele.getDisabledOptions = VirtualSelect.getDisabledOptionsMethod; - $ele.open = VirtualSelect.openMethod; - $ele.close = VirtualSelect.closeMethod; - $ele.focus = VirtualSelect.focusMethod; - $ele.enable = VirtualSelect.enableMethod; - $ele.disable = VirtualSelect.disableMethod; - $ele.destroy = VirtualSelect.destroyMethod; - $ele.validate = VirtualSelect.validateMethod; - $ele.toggleRequired = VirtualSelect.toggleRequiredMethod; - if (this.hasDropboxWrapper) { - this.$dropboxWrapper.virtualSelect = this; + + /** merging new search option */ + if (this.allowNewOption && this.searchValue) { + const hasExactOption = newOptions.some(d => d.label.toLowerCase() === this.searchValue); + if (!hasExactOption) { + optionsUpdated = true; + this.setNewOption(); } } - }, { - key: "setValueMethod", - value: function setValueMethod(newValue, silentChange) { - var valuesMapping = {}; - var valuesOrder = {}; - var validValues = []; - var isMultiSelect = this.multiple; - // Normalize input value first - var value = Utils.normalizeValues(newValue); - if (value) { - if (!Array.isArray(value)) { - value = [value]; - } - if (isMultiSelect) { - var maxValues = this.maxValues; - if (maxValues && value.length > maxValues) { - value.splice(maxValues); - } - } else if (value.length > 1) { - value = [value[0]]; - } - if (this.useGroupValue) { - value = this.setGroupOptionsValue(value); - } - value.forEach(function (d, i) { - valuesMapping[d] = true; - valuesOrder[d] = i; - }); - if (this.allowNewOption && value) { - this.setNewOptionsFromValue(value); - } - } - this.options.forEach(function (d) { - // Compare with normalized option values - var normalizedOptionValue = Utils.normalizeValues(d.value); - if (valuesMapping[normalizedOptionValue] === true && !d.isDisabled && !d.isGroupTitle) { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - // Store original value but compare with normalized value - validValues.push(d.value); - } else { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - } - }); - if (isMultiSelect) { - if (this.hasOptionGroup) { - this.setGroupsSelectedProp(); - } - - /** sorting validValues in the given values order */ - validValues.sort(function (a, b) { - return valuesOrder[Utils.normalizeValues(a)] - valuesOrder[Utils.normalizeValues(b)]; - }); - } else { - /** taking first value for single select */ - var _validValues = validValues; - var _validValues2 = virtual_select_slicedToArray(_validValues, 1); - validValues = _validValues2[0]; - } - this.beforeValueSet(); - this.setValue(validValues, { - disableEvent: silentChange - }); - this.afterValueSet(); - } - }, { - key: "setGroupOptionsValue", - value: function setGroupOptionsValue(preparedValues) { - var selectedValues = []; - var selectedGroups = {}; - var valuesMapping = {}; - preparedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - var value = d.value; - var isSelected = valuesMapping[value] === true; - if (d.isGroupTitle) { - if (isSelected) { - selectedGroups[d.index] = true; - } - } else if (isSelected || selectedGroups[d.groupIndex]) { - selectedValues.push(value); - } - }); - return selectedValues; - } - }, { - key: "setGroupsSelectedProp", - value: function setGroupsSelectedProp() { - var isAllGroupOptionsSelected = this.isAllGroupOptionsSelected.bind(this); - this.options.forEach(function (d) { - if (d.isGroupTitle) { - // eslint-disable-next-line no-param-reassign - d.isSelected = isAllGroupOptionsSelected(d.index); - } - }); - } - }, { - key: "setOptionsMethod", - value: function setOptionsMethod(options, keepValue) { - this.setOptions(options); - this.afterSetOptions(keepValue); - } - }, { - key: "setDisabledOptionsMethod", - value: function setDisabledOptionsMethod(disabledOptions) { - var keepValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setDisabledOptions(disabledOptions, true); - if (!keepValue) { - this.setValueMethod(null); + if (optionsUpdated) { + this.setVisibleOptionsCount(); + if (this.multiple) { this.toggleAllOptionsClass(); } - this.setVisibleOptions(); + this.setValueText(); + } else { + this.updatePosition(); } - }, { - key: "setDisabledOptions", - value: function setDisabledOptions(disabledOptions) { - var setOptionsProp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var disabledOptionsArr = []; - if (!disabledOptions) { - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = false; - return d; - }); - } - } else if (disabledOptions === true) { - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = true; - disabledOptionsArr.push(d.value); - return d; - }); - } + this.setVisibleOptionsCount(); + DomUtils.removeClass(this.$allWrappers, 'server-searching'); + } + setSelectedOptions() { + this.selectedOptions = this.options.filter(d => d.isSelected); + } + setSortedOptions() { + let sortedOptions = [...this.options]; + if (this.showSelectedOptionsFirst && this.selectedValues.length) { + if (this.hasOptionGroup) { + sortedOptions = this.sortOptionsGroup(sortedOptions); } else { - disabledOptionsArr = disabledOptions.map(function (d) { - return d.toString(); - }); - var disabledOptionsMapping = {}; - disabledOptionsArr.forEach(function (d) { - disabledOptionsMapping[d] = true; - }); - if (setOptionsProp) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = disabledOptionsMapping[d.value] === true; - return d; - }); - } - } - this.disabledOptions = disabledOptionsArr; - } - }, { - key: "setEnabledOptionsMethod", - value: function setEnabledOptionsMethod(disabledOptions) { - var keepValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setEnabledOptions(disabledOptions); - if (!keepValue) { - this.setValueMethod(null); - this.toggleAllOptionsClass(); + sortedOptions = this.sortOptions(sortedOptions); } - this.setVisibleOptions(); } - }, { - key: "setEnabledOptions", - value: function setEnabledOptions(enabledOptions) { - if (enabledOptions === undefined) { - return; - } - var disabledOptionsArr = []; - if (enabledOptions === true) { - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isDisabled = false; - return d; - }); - } else { - var enabledOptionsMapping = {}; - enabledOptions.forEach(function (d) { - enabledOptionsMapping[d] = true; - }); - this.options.forEach(function (d) { - var isDisabled = enabledOptionsMapping[d.value] !== true; - - // eslint-disable-next-line no-param-reassign - d.isDisabled = isDisabled; - if (isDisabled) { - disabledOptionsArr.push(d.value); - } - return d; - }); + this.sortedOptions = sortedOptions; + } + setVisibleOptions() { + let visibleOptions = [...this.sortedOptions]; + const maxOptionsToShow = this.optionsCount * 2; + const startIndex = this.getVisibleStartIndex(); + const newOption = this.getNewOption(); + const endIndex = startIndex + maxOptionsToShow - 1; + let i = 0; + if (newOption) { + newOption.visibleIndex = i; + i += 1; + } + visibleOptions = visibleOptions.filter(d => { + let inView = false; + if (d.isVisible && !d.isCurrentNew) { + inView = i >= startIndex && i <= endIndex; + // eslint-disable-next-line no-param-reassign + d.visibleIndex = i; + i += 1; } - this.disabledOptions = disabledOptionsArr; - } - }, { - key: "setOptions", - value: function setOptions() { - var _this8 = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - var preparedOptions = []; - var hasDisabledOptions = this.disabledOptions.length; - var valueKey = this.valueKey, - labelKey = this.labelKey, - descriptionKey = this.descriptionKey, - aliasKey = this.aliasKey, - hasOptionDescription = this.hasOptionDescription; - var getString = Utils.getString, - convertToBoolean = Utils.convertToBoolean; - var secureText = this.secureText.bind(this); - var getAlias = this.getAlias.bind(this); - var index = 0; - var hasOptionGroup = false; - var disabledOptionsMapping = {}; - var hasEmptyValueOption = false; - this.disabledOptions.forEach(function (d) { - disabledOptionsMapping[d] = true; + return inView; + }); + if (newOption) { + visibleOptions = [newOption, ...visibleOptions]; + } + this.visibleOptions = visibleOptions; + // update number of visible options + this.visibleOptionsCount = visibleOptions.length; + this.renderOptions(); + } + setOptionsPosition(startIndex) { + // We use the parseInt to fix a Chrome issue when dealing with decimal pixels in translate3d + const top = parseInt((startIndex || this.getVisibleStartIndex()) * this.optionHeight); + this.$options.style.transform = `translate3d(0, ${top}px, 0)`; + DomUtils.setData(this.$options, 'top', top); + } + setOptionsTooltip() { + const visibleOptions = this.getVisibleOptions(); + const { + hasOptionDescription + } = this; + visibleOptions.forEach(d => { + const $optionEle = this.$dropboxContainer.querySelector(`.vscomp-option[data-index="${d.index}"]`); + DomUtils.setData($optionEle.querySelector('.vscomp-option-text'), 'tooltip', d.label); + if (hasOptionDescription) { + DomUtils.setData($optionEle.querySelector('.vscomp-option-description'), 'tooltip', d.description); + } + }); + } + setValue(value, { + disableEvent = false, + disableValidation = false + } = {}) { + // Normalize input value first + const normalizedValue = Utils.normalizeValues(value); + const isValidValue = this.hasEmptyValueOption && normalizedValue === '' || normalizedValue; + if (!isValidValue) { + this.selectedValues = []; + } else if (Array.isArray(normalizedValue)) { + this.selectedValues = [...normalizedValue]; + } else { + this.selectedValues = [normalizedValue]; + } + const newValue = this.getValue(); + this.$ele.value = newValue; + this.$hiddenInput.value = this.getInputValue(newValue); + this.isMaxValuesSelected = !!(this.maxValues && this.maxValues <= this.selectedValues.length); + this.toggleAllOptionsClass(); + this.setValueText(); + const hasValue = Utils.isNotEmpty(this.selectedValues); + DomUtils.toggleClass(this.$allWrappers, 'has-value', hasValue); + DomUtils.toggleClass(this.$allWrappers, 'max-value-selected', this.isMaxValuesSelected); + DomUtils.setAttr(this.$clearButton, 'tabindex', hasValue ? '0' : '-1'); + DomUtils.setAria(this.$clearButton, 'hidden', hasValue === false); + if (!disableValidation) { + this.validate(); + } + if (!disableEvent) { + DomUtils.dispatchEvent(this.$ele, 'change', true); + } + } + setValueText() { + const { + multiple, + selectedValues, + noOfDisplayValues, + showValueAsTags, + $valueText, + selectedLabelRenderer + } = this; + const valueText = []; + let valueTooltip = []; + const selectedLength = selectedValues.length; + let selectedValuesCount = 0; + const showAllText = this.isAllSelected && !this.hasServerSearch && !this.disableAllOptionsSelectedText && !showValueAsTags; + + /** show all values selected text without tooltip text */ + if (showAllText && this.hideValueTooltipOnSelectAll) { + $valueText.innerHTML = `${this.allOptionsSelectedText} (${selectedLength})`; + } else { + const selectedOptions = this.getSelectedOptions({ + fullDetails: true, + keepSelectionOrder: true }); - var _prepareOption = function prepareOption(d) { - if (virtual_select_typeof(d) !== 'object') { - // eslint-disable-next-line no-param-reassign - d = _defineProperty(_defineProperty({}, valueKey, d), labelKey, d); - } - var value = secureText(getString(d[valueKey])); - var label = secureText(getString(d[labelKey])); - var childOptions = d.options; - var isGroupTitle = !!childOptions; - var option = { - index: index, - value: value, - valueNormalized: value.toLowerCase(), - label: label, - labelNormalized: _this8.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), - alias: getAlias(d[aliasKey]), - isVisible: convertToBoolean(d.isVisible, true), - isNew: d.isNew || false, - isGroupTitle: isGroupTitle, - classNames: d.classNames - }; - if (!hasEmptyValueOption && value === '') { - hasEmptyValueOption = true; - } - if (hasDisabledOptions) { - option.isDisabled = disabledOptionsMapping[value] === true; - } - if (d.isGroupOption) { - option.isGroupOption = true; - option.groupIndex = d.groupIndex; - } - if (hasOptionDescription) { - var description = secureText(getString(d[descriptionKey])); - option.description = description; - option.descriptionNormalized = _this8.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(); - } - if (d.customData) { - option.customData = d.customData; + selectedOptions.some(d => { + if (d.isCurrentNew) { + return false; } - preparedOptions.push(option); - index += 1; - if (isGroupTitle) { - var groupIndex = option.index; - hasOptionGroup = true; - childOptions.forEach(function (childData) { - // eslint-disable-next-line no-param-reassign - childData.isGroupOption = true; - // eslint-disable-next-line no-param-reassign - childData.groupIndex = groupIndex; - _prepareOption(childData); - }); + if (selectedValuesCount >= noOfDisplayValues) { + return true; } - }; - if (Array.isArray(options)) { - options.forEach(_prepareOption); - } - var optionsLength = preparedOptions.length; - var $ele = this.$ele; - $ele.options = preparedOptions; - $ele.length = optionsLength; - this.options = preparedOptions; - this.visibleOptionsCount = optionsLength; - this.lastOptionIndex = optionsLength - 1; - this.newValues = []; - this.hasOptionGroup = hasOptionGroup; - this.hasEmptyValueOption = hasEmptyValueOption; - this.setSortedOptions(); - } - }, { - key: "setServerOptions", - value: function setServerOptions() { - var _this9 = this; - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - this.setOptionsMethod(options, true); - var selectedOptions = this.selectedOptions; - var newOptions = this.options; - var optionsUpdated = false; - - /** merging already selected options details with new options */ - if (selectedOptions.length) { - var newOptionsValueMapping = {}; - optionsUpdated = true; - newOptions.forEach(function (d) { - newOptionsValueMapping[d.value] = true; - }); - selectedOptions.forEach(function (d) { - if (newOptionsValueMapping[d.value] !== true) { - // eslint-disable-next-line no-param-reassign - d.isVisible = false; - newOptions.push(d); + let { + label + } = d; + if (typeof selectedLabelRenderer === 'function') { + label = selectedLabelRenderer(d); + } + valueText.push(label); + selectedValuesCount += 1; + if (showValueAsTags) { + // Will cause text overflow in runtime and if so,the tooltip information is prepared + const valueTooltipForTags = Utils.willTextOverflow($valueText.parentElement, label) ? this.getTooltipAttrText(label, false, true) : ''; + + // replace is nedded to remove html tags from aria-label (ex: when there is an icon in the label) + let ariaLabelClearBtnTxt = ''; + if (this.ariaLabelTagClearButtonText) { + const stripHtmlLabel = label.replace(/<[^>]+>/ig, '').trim(); + ariaLabelClearBtnTxt = `aria-label="${stripHtmlLabel}, ${this.ariaLabelTagClearButtonText}"`; } - }); - this.setOptionsMethod(newOptions, true); - } - - /** merging new search option */ - if (this.allowNewOption && this.searchValue) { - var hasExactOption = newOptions.some(function (d) { - return d.label.toLowerCase() === _this9.searchValue; - }); - if (!hasExactOption) { - optionsUpdated = true; - this.setNewOption(); - } - } - if (optionsUpdated) { - this.setVisibleOptionsCount(); - if (this.multiple) { - this.toggleAllOptionsClass(); - } - this.setValueText(); - } else { - this.updatePosition(); - } - this.setVisibleOptionsCount(); - DomUtils.removeClass(this.$allWrappers, 'server-searching'); - } - }, { - key: "setSelectedOptions", - value: function setSelectedOptions() { - this.selectedOptions = this.options.filter(function (d) { - return d.isSelected; - }); - } - }, { - key: "setSortedOptions", - value: function setSortedOptions() { - var sortedOptions = virtual_select_toConsumableArray(this.options); - if (this.showSelectedOptionsFirst && this.selectedValues.length) { - if (this.hasOptionGroup) { - sortedOptions = this.sortOptionsGroup(sortedOptions); + const valueTagHtml = ` + ${label} + + + + `; + valueTooltip.push(valueTagHtml); } else { - sortedOptions = this.sortOptions(sortedOptions); - } - } - this.sortedOptions = sortedOptions; - } - }, { - key: "setVisibleOptions", - value: function setVisibleOptions() { - var visibleOptions = virtual_select_toConsumableArray(this.sortedOptions); - var maxOptionsToShow = this.optionsCount * 2; - var startIndex = this.getVisibleStartIndex(); - var newOption = this.getNewOption(); - var endIndex = startIndex + maxOptionsToShow - 1; - var i = 0; - if (newOption) { - newOption.visibleIndex = i; - i += 1; - } - visibleOptions = visibleOptions.filter(function (d) { - var inView = false; - if (d.isVisible && !d.isCurrentNew) { - inView = i >= startIndex && i <= endIndex; - // eslint-disable-next-line no-param-reassign - d.visibleIndex = i; - i += 1; - } - return inView; - }); - if (newOption) { - visibleOptions = [newOption].concat(virtual_select_toConsumableArray(visibleOptions)); - } - this.visibleOptions = visibleOptions; - // update number of visible options - this.visibleOptionsCount = visibleOptions.length; - this.renderOptions(); - } - }, { - key: "setOptionsPosition", - value: function setOptionsPosition(startIndex) { - // We use the parseInt to fix a Chrome issue when dealing with decimal pixels in translate3d - var top = parseInt((startIndex || this.getVisibleStartIndex()) * this.optionHeight); - this.$options.style.transform = "translate3d(0, ".concat(top, "px, 0)"); - DomUtils.setData(this.$options, 'top', top); - } - }, { - key: "setOptionsTooltip", - value: function setOptionsTooltip() { - var _this0 = this; - var visibleOptions = this.getVisibleOptions(); - var hasOptionDescription = this.hasOptionDescription; - visibleOptions.forEach(function (d) { - var $optionEle = _this0.$dropboxContainer.querySelector(".vscomp-option[data-index=\"".concat(d.index, "\"]")); - DomUtils.setData($optionEle.querySelector('.vscomp-option-text'), 'tooltip', d.label); - if (hasOptionDescription) { - DomUtils.setData($optionEle.querySelector('.vscomp-option-description'), 'tooltip', d.description); + valueTooltip.push(label); } + return false; }); - } - }, { - key: "setValue", - value: function setValue(value) { - var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref2$disableEvent = _ref2.disableEvent, - disableEvent = _ref2$disableEvent === void 0 ? false : _ref2$disableEvent, - _ref2$disableValidati = _ref2.disableValidation, - disableValidation = _ref2$disableValidati === void 0 ? false : _ref2$disableValidati; - // Normalize input value first - var normalizedValue = Utils.normalizeValues(value); - var isValidValue = this.hasEmptyValueOption && normalizedValue === '' || normalizedValue; - if (!isValidValue) { - this.selectedValues = []; - } else if (Array.isArray(normalizedValue)) { - this.selectedValues = virtual_select_toConsumableArray(normalizedValue); - } else { - this.selectedValues = [normalizedValue]; - } - var newValue = this.getValue(); - this.$ele.value = newValue; - this.$hiddenInput.value = this.getInputValue(newValue); - this.isMaxValuesSelected = !!(this.maxValues && this.maxValues <= this.selectedValues.length); - this.toggleAllOptionsClass(); - this.setValueText(); - var hasValue = Utils.isNotEmpty(this.selectedValues); - DomUtils.toggleClass(this.$allWrappers, 'has-value', hasValue); - DomUtils.toggleClass(this.$allWrappers, 'max-value-selected', this.isMaxValuesSelected); - DomUtils.setAttr(this.$clearButton, 'tabindex', hasValue ? '0' : '-1'); - DomUtils.setAria(this.$clearButton, 'hidden', hasValue === false); - if (!disableValidation) { - this.validate(); + const moreSelectedOptions = selectedLength - noOfDisplayValues; + if (moreSelectedOptions > 0) { + valueTooltip.push(`+ ${moreSelectedOptions} ${this.moreText}`); } - if (!disableEvent) { - DomUtils.dispatchEvent(this.$ele, 'change', true); - } - } - }, { - key: "setValueText", - value: function setValueText() { - var _this1 = this; - var multiple = this.multiple, - selectedValues = this.selectedValues, - noOfDisplayValues = this.noOfDisplayValues, - showValueAsTags = this.showValueAsTags, - $valueText = this.$valueText, - selectedLabelRenderer = this.selectedLabelRenderer; - var valueText = []; - var valueTooltip = []; - var selectedLength = selectedValues.length; - var selectedValuesCount = 0; - var showAllText = this.isAllSelected && !this.hasServerSearch && !this.disableAllOptionsSelectedText && !showValueAsTags; - - /** show all values selected text without tooltip text */ - if (showAllText && this.hideValueTooltipOnSelectAll) { - $valueText.innerHTML = "".concat(this.allOptionsSelectedText, " (").concat(selectedLength, ")"); + const aggregatedValueText = valueText.join(', '); + if (aggregatedValueText === '') { + $valueText.innerHTML = this.placeholder; } else { - var selectedOptions = this.getSelectedOptions({ - fullDetails: true, - keepSelectionOrder: true - }); - selectedOptions.some(function (d) { - if (d.isCurrentNew) { - return false; - } - if (selectedValuesCount >= noOfDisplayValues) { - return true; - } - var label = d.label; - if (typeof selectedLabelRenderer === 'function') { - label = selectedLabelRenderer(d); - } - valueText.push(label); - selectedValuesCount += 1; - if (showValueAsTags) { - // Will cause text overflow in runtime and if so,the tooltip information is prepared - var valueTooltipForTags = Utils.willTextOverflow($valueText.parentElement, label) ? _this1.getTooltipAttrText(label, false, true) : ''; - - // replace is nedded to remove html tags from aria-label (ex: when there is an icon in the label) - var ariaLabelClearBtnTxt = ''; - if (_this1.ariaLabelTagClearButtonText) { - var stripHtmlLabel = label.replace(/<[^>]+>/ig, '').trim(); - ariaLabelClearBtnTxt = "aria-label=\"".concat(stripHtmlLabel, ", ").concat(_this1.ariaLabelTagClearButtonText, "\""); + $valueText.innerHTML = aggregatedValueText; + if (multiple) { + const { + maxValues + } = this; + const showSelectedCount = this.alwaysShowSelectedOptionsCount || DomUtils.hasEllipsis($valueText); + if (showSelectedCount || maxValues || showValueAsTags) { + let countText = `${selectedLength}`; + if (maxValues) { + countText += ` / ${maxValues}`; } - var valueTagHtml = "\n ").concat(label, "\n \n \n \n "); - valueTooltip.push(valueTagHtml); - } else { - valueTooltip.push(label); - } - return false; - }); - var moreSelectedOptions = selectedLength - noOfDisplayValues; - if (moreSelectedOptions > 0) { - valueTooltip.push("+ ".concat(moreSelectedOptions, " ").concat(this.moreText, "")); - } - var aggregatedValueText = valueText.join(', '); - if (aggregatedValueText === '') { - $valueText.innerHTML = this.placeholder; - } else { - $valueText.innerHTML = aggregatedValueText; - if (multiple) { - var maxValues = this.maxValues; - var showSelectedCount = this.alwaysShowSelectedOptionsCount || DomUtils.hasEllipsis($valueText); - if (showSelectedCount || maxValues || showValueAsTags) { - var countText = "".concat(selectedLength, ""); - if (maxValues) { - countText += " / ".concat(maxValues, ""); - } - /** show all values selected text with tooltip text */ - if (showAllText) { - $valueText.innerHTML = "".concat(this.allOptionsSelectedText, " (").concat(selectedLength, ")"); - } else if (showValueAsTags) { - $valueText.innerHTML = valueTooltip.join(''); - this.$valueTags = $valueText.querySelectorAll('.vscomp-value-tag'); - this.setValueTagAttr(); - } else if (!this.alwaysShowSelectedOptionsLabel) { - /** replace comma separated list of selections with shorter text indicating selection count */ - var optionsSelectedText = selectedLength === 1 ? this.optionSelectedText : this.optionsSelectedText; - $valueText.innerHTML = "".concat(countText, " ").concat(optionsSelectedText); - } - } else { - /** removing tooltip if full value text is visible */ - valueTooltip = []; + /** show all values selected text with tooltip text */ + if (showAllText) { + $valueText.innerHTML = `${this.allOptionsSelectedText} (${selectedLength})`; + } else if (showValueAsTags) { + $valueText.innerHTML = valueTooltip.join(''); + this.$valueTags = $valueText.querySelectorAll('.vscomp-value-tag'); + this.setValueTagAttr(); + } else if (!this.alwaysShowSelectedOptionsLabel) { + /** replace comma separated list of selections with shorter text indicating selection count */ + const optionsSelectedText = selectedLength === 1 ? this.optionSelectedText : this.optionsSelectedText; + $valueText.innerHTML = `${countText} ${optionsSelectedText}`; } + } else { + /** removing tooltip if full value text is visible */ + valueTooltip = []; } } } - var tooltipText = ''; - if (selectedLength === 0) { - tooltipText = this.placeholder; - } else if (!showValueAsTags) { - tooltipText = valueTooltip.join(', '); - } + } + let tooltipText = ''; + if (selectedLength === 0) { + tooltipText = this.placeholder; + } else if (!showValueAsTags) { + tooltipText = valueTooltip.join(', '); + } + if (!showValueAsTags) { + DomUtils.setData($valueText, 'tooltip', tooltipText); + } + if (multiple) { if (!showValueAsTags) { - DomUtils.setData($valueText, 'tooltip', tooltipText); - } - if (multiple) { - if (!showValueAsTags) { - DomUtils.setData($valueText, 'tooltipEllipsisOnly', selectedLength === 0); - } else { - this.updatePosition(); - } + DomUtils.setData($valueText, 'tooltipEllipsisOnly', selectedLength === 0); + } else { + this.updatePosition(); } } - }, { - key: "setSearchValue", - value: function setSearchValue(value) { - var skipInputSet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var forceSet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (value === this.searchValueOriginal && !forceSet) { + } + setSearchValue(value, skipInputSet = false, forceSet = false) { + if (value === this.searchValueOriginal && !forceSet) { + return; + } + if (!skipInputSet) { + this.$searchInput.value = value; + } + const searchValue = value.replace(/\\/g, '').toLowerCase().trim(); + this.searchValue = searchValue; + this.searchValueOriginal = value; + DomUtils.toggleClass(this.$allWrappers, 'has-search-value', value); + DomUtils.setAttr(this.$searchClear, 'tabindex', value !== '' ? '0' : '-1'); + DomUtils.setAria(this.$searchClear, 'hidden', value === ''); + this.afterSetSearchValue(); + } + setVisibleOptionsCount() { + let visibleOptionsCount = 0; + let hasExactOption = false; + let visibleOptionGroupsMapping; + const { + searchGroup, + showOptionsOnlyOnSearch, + searchByStartsWith + } = this; + + /** If searchNormalize we'll normalize the searchValue */ + let { + searchValue + } = this; + searchValue = this.searchNormalize && searchValue.trim() !== '' ? Utils.normalizeString(searchValue) : searchValue; + const isOptionVisible = this.isOptionVisible.bind(this); + if (this.hasOptionGroup) { + visibleOptionGroupsMapping = this.getVisibleOptionGroupsMapping(searchValue); + } + this.options.forEach(d => { + if (d.isCurrentNew) { return; } - if (!skipInputSet) { - this.$searchInput.value = value; + let result; + if (showOptionsOnlyOnSearch && !searchValue) { + // eslint-disable-next-line no-param-reassign + d.isVisible = false; + result = { + isVisible: false, + hasExactOption: false + }; + } else { + result = isOptionVisible({ + data: d, + searchValue, + hasExactOption, + visibleOptionGroupsMapping, + searchGroup, + searchByStartsWith + }); } - var searchValue = value.replace(/\\/g, '').toLowerCase().trim(); - this.searchValue = searchValue; - this.searchValueOriginal = value; - DomUtils.toggleClass(this.$allWrappers, 'has-search-value', value); - DomUtils.setAttr(this.$searchClear, 'tabindex', value !== '' ? '0' : '-1'); - DomUtils.setAria(this.$searchClear, 'hidden', value === ''); - this.afterSetSearchValue(); - } - }, { - key: "setVisibleOptionsCount", - value: function setVisibleOptionsCount() { - var visibleOptionsCount = 0; - var hasExactOption = false; - var visibleOptionGroupsMapping; - var searchGroup = this.searchGroup, - showOptionsOnlyOnSearch = this.showOptionsOnlyOnSearch, - searchByStartsWith = this.searchByStartsWith; - - /** If searchNormalize we'll normalize the searchValue */ - var searchValue = this.searchValue; - searchValue = this.searchNormalize && searchValue.trim() !== '' ? Utils.normalizeString(searchValue) : searchValue; - var isOptionVisible = this.isOptionVisible.bind(this); - if (this.hasOptionGroup) { - visibleOptionGroupsMapping = this.getVisibleOptionGroupsMapping(searchValue); + if (result.isVisible) { + visibleOptionsCount += 1; } - this.options.forEach(function (d) { - if (d.isCurrentNew) { - return; - } - var result; - if (showOptionsOnlyOnSearch && !searchValue) { - // eslint-disable-next-line no-param-reassign - d.isVisible = false; - result = { - isVisible: false, - hasExactOption: false - }; - } else { - result = isOptionVisible({ - data: d, - searchValue: searchValue, - hasExactOption: hasExactOption, - visibleOptionGroupsMapping: visibleOptionGroupsMapping, - searchGroup: searchGroup, - searchByStartsWith: searchByStartsWith - }); - } - if (result.isVisible) { - visibleOptionsCount += 1; - } - if (!hasExactOption) { - hasExactOption = result.hasExactOption; - } - }); - if (this.allowNewOption) { - if (searchValue && !hasExactOption) { - this.setNewOption(); - visibleOptionsCount += 1; - } else { - this.removeNewOption(); - } + if (!hasExactOption) { + hasExactOption = result.hasExactOption; + } + }); + if (this.allowNewOption) { + if (searchValue && !hasExactOption) { + this.setNewOption(); + visibleOptionsCount += 1; + } else { + this.removeNewOption(); } - this.visibleOptionsCount = visibleOptionsCount; - this.afterSetVisibleOptionsCount(); } + this.visibleOptionsCount = visibleOptionsCount; + this.afterSetVisibleOptionsCount(); + } - /** - * Calculates ARIA metadata (aria-setsize and aria-posinset) for virtualized listbox accessibility. - * This method iterates through ALL filtered options (not just rendered ones) to calculate - * the correct position in the full filtered set. This ensures screen readers announce - * correct positions even when only a subset of options is rendered (e.g., "Option 50, 50 of 10001"). - * - * Example: With 10,001 filtered options showing only 5 at a time: - * - All 10,001 options get filteredIndex values: 1, 2, 3, ..., 10001 - * - ariaSetSize = 10001 - * - When options 50-54 are rendered, they have filteredIndex: 50, 51, 52, 53, 54 - * - Screen reader announces: "Option 50, 50 of 10001" - */ - }, { - key: "calculateAriaMetadata", - value: function calculateAriaMetadata() { - var _this10 = this; - var ariaSetSize = 0; - var filteredPosition = 0; - var optionsSource = this.sortedOptions && this.sortedOptions.length ? this.sortedOptions : this.options; - - // Iterate through ALL options (not just rendered ones) to calculate positions in the full filtered set - optionsSource.forEach(function (d) { - if (d.isCurrentNew) { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - return; - } - if (d.isVisible === true) { - var isSelectableGroupTitle = d.isGroupTitle && _this10.multiple && !_this10.disableOptionGroupCheckbox; - if (!d.isGroupTitle || isSelectableGroupTitle) { - filteredPosition += 1; - ariaSetSize += 1; - // eslint-disable-next-line no-param-reassign - d.filteredIndex = filteredPosition; - } else { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - } - } else { - // eslint-disable-next-line no-param-reassign - d.filteredIndex = undefined; - } - }); - if (this.allowNewOption) { - var newOption = this.getNewOption(); - if (newOption && newOption.isVisible === true) { + /** + * Calculates ARIA metadata (aria-setsize and aria-posinset) for virtualized listbox accessibility. + * This method iterates through ALL filtered options (not just rendered ones) to calculate + * the correct position in the full filtered set. This ensures screen readers announce + * correct positions even when only a subset of options is rendered (e.g., "Option 50, 50 of 10001"). + * + * Example: With 10,001 filtered options showing only 5 at a time: + * - All 10,001 options get filteredIndex values: 1, 2, 3, ..., 10001 + * - ariaSetSize = 10001 + * - When options 50-54 are rendered, they have filteredIndex: 50, 51, 52, 53, 54 + * - Screen reader announces: "Option 50, 50 of 10001" + */ + calculateAriaMetadata() { + let ariaSetSize = 0; + let filteredPosition = 0; + const optionsSource = this.sortedOptions && this.sortedOptions.length ? this.sortedOptions : this.options; + + // Iterate through ALL options (not just rendered ones) to calculate positions in the full filtered set + optionsSource.forEach(d => { + if (d.isCurrentNew) { + // eslint-disable-next-line no-param-reassign + d.filteredIndex = undefined; + return; + } + if (d.isVisible === true) { + const isSelectableGroupTitle = d.isGroupTitle && this.multiple && !this.disableOptionGroupCheckbox; + if (!d.isGroupTitle || isSelectableGroupTitle) { filteredPosition += 1; ariaSetSize += 1; // eslint-disable-next-line no-param-reassign - newOption.filteredIndex = filteredPosition; - } else if (newOption) { + d.filteredIndex = filteredPosition; + } else { // eslint-disable-next-line no-param-reassign - newOption.filteredIndex = undefined; - } - } - this.ariaSetSize = ariaSetSize; - } - }, { - key: "setOptionProp", - value: function setOptionProp(index, key, value) { - if (!this.options[index]) { - return; - } - this.options[index][key] = value; - } - }, { - key: "setOptionsHeight", - value: function setOptionsHeight() { - this.$optionsList.style.height = "".concat(this.optionHeight * this.visibleOptionsCount, "px"); - } - }, { - key: "setOptionsContainerHeight", - value: function setOptionsContainerHeight(reset) { - var optionsHeight; - if (reset) { - if (this.showAsPopup) { - this.optionsCount = this.getOptionsCount(); - this.halfOptionsCount = Math.ceil(this.optionsCount / 2); - optionsHeight = this.getOptionsHeight(); - this.optionsHeight = optionsHeight; + d.filteredIndex = undefined; } } else { - optionsHeight = this.optionsHeight; - if (this.keepAlwaysOpen) { - DomUtils.setStyle(this.$noOptions, 'height', optionsHeight); - DomUtils.setStyle(this.$noSearchResults, 'height', optionsHeight); - } - } - DomUtils.setStyle(this.$optionsContainer, 'max-height', optionsHeight); - this.afterSetOptionsContainerHeight(reset); - } - }, { - key: "setNewOption", - value: function setNewOption(newValue) { - var value = newValue || this.searchValueOriginal.trim(); - if (!value) { - return; - } - var newOption = this.getNewOption(); - if (newOption) { - var newIndex = newOption.index; - this.setOptionProp(newIndex, 'value', this.secureText(value)); - this.setOptionProp(newIndex, 'label', this.secureText(value)); - } else { - var data = { - value: value, - label: value - }; - if (newValue) { - data.isNew = true; - this.newValues.push(value); - } else { - data.isCurrentNew = true; - } - this.addOption(data); + // eslint-disable-next-line no-param-reassign + d.filteredIndex = undefined; + } + }); + if (this.allowNewOption) { + const newOption = this.getNewOption(); + if (newOption && newOption.isVisible === true) { + filteredPosition += 1; + ariaSetSize += 1; + // eslint-disable-next-line no-param-reassign + newOption.filteredIndex = filteredPosition; + } else if (newOption) { + // eslint-disable-next-line no-param-reassign + newOption.filteredIndex = undefined; } } - }, { - key: "setSelectedProp", - value: function setSelectedProp() { - var valuesMapping = {}; - this.selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - if (valuesMapping[d.value] === true) { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - } - }); - } - }, { - key: "setNewOptionsFromValue", - value: function setNewOptionsFromValue(values) { - if (!values) { - return; - } - var setNewOption = this.setNewOption.bind(this); - var availableValuesMapping = {}; - this.options.forEach(function (d) { - availableValuesMapping[d.value] = true; - }); - values.forEach(function (d) { - if (d && availableValuesMapping[d] !== true) { - setNewOption(d); - } - }); + this.ariaSetSize = ariaSetSize; + } + setOptionProp(index, key, value) { + if (!this.options[index]) { + return; } - }, { - key: "setDropboxWrapperWidth", - value: function setDropboxWrapperWidth() { + this.options[index][key] = value; + } + setOptionsHeight() { + this.$optionsList.style.height = `${this.optionHeight * this.visibleOptionsCount}px`; + } + setOptionsContainerHeight(reset) { + let optionsHeight; + if (reset) { if (this.showAsPopup) { - return; + this.optionsCount = this.getOptionsCount(); + this.halfOptionsCount = Math.ceil(this.optionsCount / 2); + optionsHeight = this.getOptionsHeight(); + this.optionsHeight = optionsHeight; } - var width = this.dropboxWidth || "".concat(this.$wrapper.offsetWidth, "px"); - DomUtils.setStyle(this.$dropboxContainer, 'max-width', width); - } - }, { - key: "setEleStyles", - value: function setEleStyles() { - var maxWidth = this.maxWidth; - var styles = {}; - if (maxWidth) { - styles['max-width'] = maxWidth; + } else { + optionsHeight = this.optionsHeight; + if (this.keepAlwaysOpen) { + DomUtils.setStyle(this.$noOptions, 'height', optionsHeight); + DomUtils.setStyle(this.$noSearchResults, 'height', optionsHeight); } - DomUtils.setStyles(this.$ele, styles); - } - }, { - key: "setDropboxStyles", - value: function setDropboxStyles() { - var dropboxWidth = this.dropboxWidth; - var styles = {}; - var containerStyles = { - 'z-index': this.zIndex + } + DomUtils.setStyle(this.$optionsContainer, 'max-height', optionsHeight); + this.afterSetOptionsContainerHeight(reset); + } + setNewOption(newValue) { + const value = newValue || this.searchValueOriginal.trim(); + if (!value) { + return; + } + const newOption = this.getNewOption(); + if (newOption) { + const newIndex = newOption.index; + this.setOptionProp(newIndex, 'value', this.secureText(value)); + this.setOptionProp(newIndex, 'label', this.secureText(value)); + } else { + const data = { + value, + label: value }; - if (dropboxWidth) { - if (this.showAsPopup) { - styles['max-width'] = dropboxWidth; - } else { - containerStyles.width = dropboxWidth; - } - } - DomUtils.setStyles(this.$dropboxContainer, containerStyles); - DomUtils.setStyles(this.$dropbox, styles); - } - }, { - key: "setOptionAttr", - value: function setOptionAttr() { - var $visibleOptions = this.$visibleOptions; - var options = this.options; - var optionHeight = "".concat(this.optionHeight, "px"); - var setStyle = DomUtils.setStyle, - getData = DomUtils.getData, - setData = DomUtils.setData; - if ($visibleOptions && $visibleOptions.length) { - $visibleOptions.forEach(function ($option) { - var optionDetails = options[getData($option, 'index')]; - setStyle($option, 'height', optionHeight); - setData($option, 'value', optionDetails.value); - }); + if (newValue) { + data.isNew = true; + this.newValues.push(value); + } else { + data.isCurrentNew = true; } + this.addOption(data); } - }, { - key: "setValueTagAttr", - value: function setValueTagAttr() { - var $valueTags = this.$valueTags; - if (!$valueTags || !$valueTags.length) { - return; + } + setSelectedProp() { + const valuesMapping = {}; + this.selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + if (valuesMapping[d.value] === true) { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; } - var getData = DomUtils.getData, - setData = DomUtils.setData; - var options = this.options; - $valueTags.forEach(function ($valueTag) { - var index = getData($valueTag, 'index'); - if (typeof index !== 'undefined') { - var optionDetails = options[index]; - setData($valueTag, 'value', optionDetails.value); - } - }); + }); + } + setNewOptionsFromValue(values) { + if (!values) { + return; + } + const setNewOption = this.setNewOption.bind(this); + const availableValuesMapping = {}; + this.options.forEach(d => { + availableValuesMapping[d.value] = true; + }); + values.forEach(d => { + if (d && availableValuesMapping[d] !== true) { + setNewOption(d); + } + }); + } + setDropboxWrapperWidth() { + if (this.showAsPopup) { + return; } - }, { - key: "setScrollTop", - value: function setScrollTop() { - var selectedValues = this.selectedValues; - if (this.showSelectedOptionsFirst || !this.focusSelectedOptionOnOpen || selectedValues.length === 0) { - return; + const width = this.dropboxWidth || `${this.$wrapper.offsetWidth}px`; + DomUtils.setStyle(this.$dropboxContainer, 'max-width', width); + } + setEleStyles() { + const { + maxWidth + } = this; + const styles = {}; + if (maxWidth) { + styles['max-width'] = maxWidth; + } + DomUtils.setStyles(this.$ele, styles); + } + setDropboxStyles() { + const { + dropboxWidth + } = this; + const styles = {}; + const containerStyles = { + 'z-index': this.zIndex + }; + if (dropboxWidth) { + if (this.showAsPopup) { + styles['max-width'] = dropboxWidth; + } else { + containerStyles.width = dropboxWidth; } - var valuesMapping = {}; - var selectedOptionIndex; - selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.some(function (d) { - if (valuesMapping[d.value]) { - selectedOptionIndex = d.visibleIndex; - return true; - } - return false; + } + DomUtils.setStyles(this.$dropboxContainer, containerStyles); + DomUtils.setStyles(this.$dropbox, styles); + } + setOptionAttr() { + const { + $visibleOptions + } = this; + const { + options + } = this; + const optionHeight = `${this.optionHeight}px`; + const { + setStyle, + getData, + setData + } = DomUtils; + if ($visibleOptions && $visibleOptions.length) { + $visibleOptions.forEach($option => { + const optionDetails = options[getData($option, 'index')]; + setStyle($option, 'height', optionHeight); + setData($option, 'value', optionDetails.value); }); - if (selectedOptionIndex) { - this.$optionsContainer.scrollTop = this.optionHeight * selectedOptionIndex; + } + } + setValueTagAttr() { + const { + $valueTags + } = this; + if (!$valueTags || !$valueTags.length) { + return; + } + const { + getData, + setData + } = DomUtils; + const { + options + } = this; + $valueTags.forEach($valueTag => { + const index = getData($valueTag, 'index'); + if (typeof index !== 'undefined') { + const optionDetails = options[index]; + setData($valueTag, 'value', optionDetails.value); + } + }); + } + setScrollTop() { + const { + selectedValues + } = this; + if (this.showSelectedOptionsFirst || !this.focusSelectedOptionOnOpen || selectedValues.length === 0) { + return; + } + const valuesMapping = {}; + let selectedOptionIndex; + selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.some(d => { + if (valuesMapping[d.value]) { + selectedOptionIndex = d.visibleIndex; + return true; } + return false; + }); + if (selectedOptionIndex) { + this.$optionsContainer.scrollTop = this.optionHeight * selectedOptionIndex; } - /** set methods - end */ + } + /** set methods - end */ - /** get methods - start */ - }, { - key: "getVisibleOptions", - value: function getVisibleOptions() { - return this.visibleOptions || []; - } - }, { - key: "getValue", - value: function getValue() { - var value; - if (this.multiple) { - value = this.useGroupValue ? this.getGroupValue() : this.selectedValues; - } else { - value = this.selectedValues[0] || ''; + /** get methods - start */ + getVisibleOptions() { + return this.visibleOptions || []; + } + getValue() { + let value; + if (this.multiple) { + value = this.useGroupValue ? this.getGroupValue() : this.selectedValues; + } else { + value = this.selectedValues[0] || ''; + } + return Utils.normalizeValues(value); + } + getGroupValue() { + const selectedValues = []; + const selectedGroups = {}; + this.options.forEach(d => { + if (!d.isSelected) { + return; } - return Utils.normalizeValues(value); - } - }, { - key: "getGroupValue", - value: function getGroupValue() { - var selectedValues = []; - var selectedGroups = {}; - this.options.forEach(function (d) { - if (!d.isSelected) { - return; - } - var value = d.value; - if (d.isGroupTitle) { - if (value) { - selectedGroups[d.index] = true; - selectedValues.push(value); - } - } else if (selectedGroups[d.groupIndex] !== true) { + const { + value + } = d; + if (d.isGroupTitle) { + if (value) { + selectedGroups[d.index] = true; selectedValues.push(value); } - }); - return selectedValues; - } - }, { - key: "getInputValue", - value: function getInputValue(preparedValue) { - var value = preparedValue; - if (value && value.length) { - if (this.setValueAsArray && this.multiple) { - value = JSON.stringify(value); - } - } else { - value = this.emptyValue; + } else if (selectedGroups[d.groupIndex] !== true) { + selectedValues.push(value); } - return value; - } - }, { - key: "getFirstVisibleOptionIndex", - value: function getFirstVisibleOptionIndex() { - return Math.ceil(this.$optionsContainer.scrollTop / this.optionHeight); - } - }, { - key: "getVisibleStartIndex", - value: function getVisibleStartIndex() { - var firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); - var startIndex = firstVisibleOptionIndex - this.halfOptionsCount; - if (startIndex < 0) { - startIndex = 0; + }); + return selectedValues; + } + getInputValue(preparedValue) { + let value = preparedValue; + if (value && value.length) { + if (this.setValueAsArray && this.multiple) { + value = JSON.stringify(value); } - return startIndex; - } - }, { - key: "getTooltipAttrText", - value: function getTooltipAttrText(text) { - var ellipsisOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var allowHtml = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var tootltipText = Utils.containsHTML(text) ? Utils.replaceDoubleQuotesWithHTML(text) : text; - var data = { - 'data-tooltip': tootltipText || '', - 'data-tooltip-enter-delay': this.tooltipEnterDelay, - 'data-tooltip-z-index': this.zIndex, - 'data-tooltip-font-size': this.tooltipFontSize, - 'data-tooltip-alignment': this.tooltipAlignment, - 'data-tooltip-max-width': this.tooltipMaxWidth, - 'data-tooltip-ellipsis-only': ellipsisOnly, - 'data-tooltip-allow-html': allowHtml - }; - return DomUtils.getAttributesText(data); + } else { + value = this.emptyValue; + } + return value; + } + getFirstVisibleOptionIndex() { + return Math.ceil(this.$optionsContainer.scrollTop / this.optionHeight); + } + getVisibleStartIndex() { + const firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); + let startIndex = firstVisibleOptionIndex - this.halfOptionsCount; + if (startIndex < 0) { + startIndex = 0; } + return startIndex; + } + getTooltipAttrText(text, ellipsisOnly = false, allowHtml = false) { + const tootltipText = Utils.containsHTML(text) ? Utils.replaceDoubleQuotesWithHTML(text) : text; + const data = { + 'data-tooltip': tootltipText || '', + 'data-tooltip-enter-delay': this.tooltipEnterDelay, + 'data-tooltip-z-index': this.zIndex, + 'data-tooltip-font-size': this.tooltipFontSize, + 'data-tooltip-alignment': this.tooltipAlignment, + 'data-tooltip-max-width': this.tooltipMaxWidth, + 'data-tooltip-ellipsis-only': ellipsisOnly, + 'data-tooltip-allow-html': allowHtml + }; + return DomUtils.getAttributesText(data); + } - /** - * @param {any} data - * @returns {any} - */ - }, { - key: "getOptionObj", - value: function getOptionObj(data) { - if (!data) { - return undefined; - } - var getString = Utils.getString; - var secureText = this.secureText.bind(this); - var value = secureText(getString(data.value)); - var label = secureText(getString(data.label)); - var description = secureText(getString(data.description)); - return { - index: data.index, - value: value, - valueNormalized: value.toLowerCase(), - label: label, - labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), - description: description, - descriptionNormalized: this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(), - alias: this.getAlias(data.alias), - isCurrentNew: data.isCurrentNew || false, - isNew: data.isNew || false, - isVisible: true - }; + /** + * @param {any} data + * @returns {any} + */ + getOptionObj(data) { + if (!data) { + return undefined; + } + const { + getString + } = Utils; + const secureText = this.secureText.bind(this); + const value = secureText(getString(data.value)); + const label = secureText(getString(data.label)); + const description = secureText(getString(data.description)); + return { + index: data.index, + value, + valueNormalized: value.toLowerCase(), + label, + labelNormalized: this.searchNormalize && label.trim() !== '' ? Utils.normalizeString(label).toLowerCase() : label.toLowerCase(), + description, + descriptionNormalized: this.searchNormalize && description.trim() !== '' ? Utils.normalizeString(description).toLowerCase() : description.toLowerCase(), + alias: this.getAlias(data.alias), + isCurrentNew: data.isCurrentNew || false, + isNew: data.isNew || false, + isVisible: true + }; + } + getNewOption() { + const lastOption = this.options[this.lastOptionIndex]; + if (!lastOption || !lastOption.isCurrentNew) { + return undefined; } - }, { - key: "getNewOption", - value: function getNewOption() { - var lastOption = this.options[this.lastOptionIndex]; - if (!lastOption || !lastOption.isCurrentNew) { - return undefined; + return lastOption; + } + getOptionIndex(value) { + let index; + this.options.some(d => { + if (d.value === value) { + index = d.index; + return true; } - return lastOption; - } - }, { - key: "getOptionIndex", - value: function getOptionIndex(value) { - var index; - this.options.some(function (d) { - if (d.value === value) { - index = d.index; - return true; - } - return false; - }); - return index; + return false; + }); + return index; + } + getNewValue() { + const valuesMapping = {}; + this.newValues.forEach(d => { + valuesMapping[d] = true; + }); + const result = this.selectedValues.filter(d => valuesMapping[d] === true); + return this.multiple ? result : result[0]; + } + getAlias(alias) { + let result = alias; + if (result) { + if (Array.isArray(result)) { + result = result.join(','); + } else { + result = result.toString().trim(); + } + result = result.toLowerCase(); } - }, { - key: "getNewValue", - value: function getNewValue() { - var valuesMapping = {}; - this.newValues.forEach(function (d) { - valuesMapping[d] = true; - }); - var result = this.selectedValues.filter(function (d) { - return valuesMapping[d] === true; - }); - return this.multiple ? result : result[0]; - } - }, { - key: "getAlias", - value: function getAlias(alias) { - var result = alias; - if (result) { - if (Array.isArray(result)) { - result = result.join(','); + return result || ''; + } + getDisplayValue() { + const displayValues = []; + this.options.forEach(d => { + if (d.isSelected) { + displayValues.push(d.label); + } + }); + return this.multiple ? displayValues : displayValues[0] || ''; + } + getSelectedOptions({ + fullDetails = false, + keepSelectionOrder = false + } = {}) { + const { + valueKey, + labelKey, + selectedValues + } = this; + const selectedOptions = []; + this.options.forEach(d => { + if (d.isSelected && !d.isGroupTitle) { + if (fullDetails) { + selectedOptions.push(d); } else { - result = result.toString().trim(); - } - result = result.toLowerCase(); - } - return result || ''; - } - }, { - key: "getDisplayValue", - value: function getDisplayValue() { - var displayValues = []; - this.options.forEach(function (d) { - if (d.isSelected) { - displayValues.push(d.label); - } - }); - return this.multiple ? displayValues : displayValues[0] || ''; - } - }, { - key: "getSelectedOptions", - value: function getSelectedOptions() { - var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref3$fullDetails = _ref3.fullDetails, - fullDetails = _ref3$fullDetails === void 0 ? false : _ref3$fullDetails, - _ref3$keepSelectionOr = _ref3.keepSelectionOrder, - keepSelectionOrder = _ref3$keepSelectionOr === void 0 ? false : _ref3$keepSelectionOr; - var valueKey = this.valueKey, - labelKey = this.labelKey, - selectedValues = this.selectedValues; - var selectedOptions = []; - this.options.forEach(function (d) { - if (d.isSelected && !d.isGroupTitle) { - if (fullDetails) { - selectedOptions.push(d); - } else { - var data = _defineProperty(_defineProperty({}, valueKey, d.value), labelKey, d.label); - if (d.isNew) { - data.isNew = true; - } - if (d.customData) { - data.customData = d.customData; - } - selectedOptions.push(data); + const data = { + [valueKey]: d.value, + [labelKey]: d.label + }; + if (d.isNew) { + data.isNew = true; + } + if (d.customData) { + data.customData = d.customData; } + selectedOptions.push(data); } - }); - if (keepSelectionOrder) { - var valuesOrder = {}; - selectedValues.forEach(function (d, i) { - valuesOrder[d] = i; - }); - selectedOptions.sort(function (a, b) { - return valuesOrder[a.value] - valuesOrder[b.value]; - }); } - return this.multiple || fullDetails ? selectedOptions : selectedOptions[0]; - } - }, { - key: "getDisabledOptions", - value: function getDisabledOptions() { - var valueKey = this.valueKey, - labelKey = this.labelKey, - disabledOptions = this.disabledOptions; - var disabledOptionsValueMapping = {}; - var result = []; - disabledOptions.forEach(function (value) { - disabledOptionsValueMapping[value] = true; - }); - this.options.forEach(function (_ref4) { - var value = _ref4.value, - label = _ref4.label; - if (disabledOptionsValueMapping[value]) { - result.push(_defineProperty(_defineProperty({}, valueKey, value), labelKey, label)); - } + }); + if (keepSelectionOrder) { + const valuesOrder = {}; + selectedValues.forEach((d, i) => { + valuesOrder[d] = i; }); - return result; + selectedOptions.sort((a, b) => valuesOrder[a.value] - valuesOrder[b.value]); } - }, { - key: "getVisibleOptionGroupsMapping", - value: function getVisibleOptionGroupsMapping(searchValue) { - var options = this.options; - var result = {}; - var isOptionVisible = this.isOptionVisible.bind(this); - options = this.structureOptionGroup(options); - options.forEach(function (d) { - result[d.index] = d.options.some(function (e) { - return isOptionVisible({ - data: e, - searchValue: searchValue - }).isVisible; + return this.multiple || fullDetails ? selectedOptions : selectedOptions[0]; + } + getDisabledOptions() { + const { + valueKey, + labelKey, + disabledOptions + } = this; + const disabledOptionsValueMapping = {}; + const result = []; + disabledOptions.forEach(value => { + disabledOptionsValueMapping[value] = true; + }); + this.options.forEach(({ + value, + label + }) => { + if (disabledOptionsValueMapping[value]) { + result.push({ + [valueKey]: value, + [labelKey]: label }); - }); - return result; - } - }, { - key: "getOptionsCount", - value: function getOptionsCount(count) { - var result; - if (this.showAsPopup) { - var availableHeight = window.innerHeight * 80 / 100 - dropboxCloseButtonFullHeight; - if (this.hasSearchContainer) { - availableHeight -= searchHeight; - } - result = Math.floor(availableHeight / this.optionHeight); - } else { - result = parseInt(count); - } - return result; - } - }, { - key: "getOptionsHeight", - value: function getOptionsHeight() { - return "".concat(this.optionsCount * this.optionHeight, "px"); - } - - /** getting next/prev valid option element */ - }, { - key: "getSibling", - value: function getSibling($ele, direction) { - var propName = direction === 'next' ? 'nextElementSibling' : 'previousElementSibling'; - var $sibling = $ele; - do { - if ($sibling) { - $sibling = $sibling[propName]; - } - } while (DomUtils.hasClass($sibling, 'disabled') || DomUtils.hasClass($sibling, 'group-title')); - return $sibling; - } - }, { - key: "getUniqueId", - value: function getUniqueId() { - var uniqueId = Utils.getRandomInt(10000); - var isAlreadyUsed = document.querySelector("#vscomp-ele-wrapper-".concat(uniqueId)); - if (isAlreadyUsed) { - return this.getUniqueId(); - } - return uniqueId; - } - /** get methods - end */ - }, { - key: "initDropboxPopover", - value: function initDropboxPopover() { - var data = { - ele: this.$ele, - target: this.$dropboxContainer, - position: this.position, - zIndex: this.zIndex, - margin: 4, - transitionDistance: 30, - hideArrowIcon: true, - disableManualAction: true, - disableUpdatePosition: !this.hasDropboxWrapper, - updatePositionThrottle: this.updatePositionThrottle, - showDuration: this.showDuration, - hideDuration: this.hideDuration, - afterShow: this.afterShowPopper.bind(this), - afterHide: this.afterHidePopper.bind(this) - }; - this.dropboxPopover = new PopoverComponent(data); - } - }, { - key: "openDropbox", - value: function openDropbox(isSilent) { - var _this11 = this; - // Set this instance as the last interacted one immediately - VirtualSelect.lastInteractedInstance = this; - var originalTransition = ''; - // Disable transitions for programmatic opening - if (!isSilent) { - // Store original transition - originalTransition = this.$dropboxContainer.style.transition; - this.$dropboxContainer.style.transition = 'none'; } - // Perform the open operation - this.isSilentOpen = isSilent; - - // Close all other open instances first - VirtualSelect.openInstances.forEach(function (instance) { - if (instance !== _this11) { - // Don't focus when closing due to another dropdown being opened - var instanceObj = instance; - instanceObj.shouldFocusWrapperOnClose = false; - instanceObj.closeDropbox(true); // silent close - } - }); + }); + return result; + } + getVisibleOptionGroupsMapping(searchValue) { + let { + options + } = this; + const result = {}; + const isOptionVisible = this.isOptionVisible.bind(this); + options = this.structureOptionGroup(options); + options.forEach(d => { + result[d.index] = d.options.some(e => isOptionVisible({ + data: e, + searchValue + }).isVisible); + }); + return result; + } + getOptionsCount(count) { + let result; + if (this.showAsPopup) { + let availableHeight = window.innerHeight * 80 / 100 - dropboxCloseButtonFullHeight; + if (this.hasSearchContainer) { + availableHeight -= searchHeight; + } + result = Math.floor(availableHeight / this.optionHeight); + } else { + result = parseInt(count); + } + return result; + } + getOptionsHeight() { + return `${this.optionsCount * this.optionHeight}px`; + } - // Add to open instances - VirtualSelect.openInstances.add(this); - DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxWrapper, 'hidden', false); - DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxContainerTop, 'hidden', false); - DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '0'); - DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', false); - if (isSilent) { - DomUtils.setStyle(this.$dropboxContainer, 'display', 'inline-flex'); - } else { - DomUtils.dispatchEvent(this.$ele, 'beforeOpen'); - DomUtils.setAria(this.$wrapper, 'expanded', true); - } - this.setDropboxWrapperWidth(); - DomUtils.removeClass(this.$allWrappers, 'closed'); - DomUtils.changeTabIndex(this.$allWrappers, 0); - if (!isSilent) { - // Force synchronous layout and style calculation - // Trigger reflow - this.$dropboxContainer.offsetHeight; // eslint-disable-line no-unused-expressions - // Restore transitions immediately after reflow - this.$dropboxContainer.style.transition = originalTransition; - } - if (this.dropboxPopover && !isSilent) { - this.dropboxPopover.show(); - } else { - this.afterShowPopper(); + /** getting next/prev valid option element */ + getSibling($ele, direction) { + const propName = direction === 'next' ? 'nextElementSibling' : 'previousElementSibling'; + let $sibling = $ele; + do { + if ($sibling) { + $sibling = $sibling[propName]; } + } while (DomUtils.hasClass($sibling, 'disabled') || DomUtils.hasClass($sibling, 'group-title')); + return $sibling; + } + getUniqueId() { + const uniqueId = Utils.getRandomInt(10000); + const isAlreadyUsed = document.querySelector(`#vscomp-ele-wrapper-${uniqueId}`); + if (isAlreadyUsed) { + return this.getUniqueId(); } - }, { - key: "afterShowPopper", - value: function afterShowPopper() { - var isSilent = this.isSilentOpen; - this.isSilentOpen = false; - if (!isSilent) { - this.moveSelectedOptionsFirst(); - this.setScrollTop(); - DomUtils.addClass(this.$allWrappers, 'focused'); - if (this.showAsPopup) { - DomUtils.addClass(this.$body, 'vscomp-popup-active'); - this.isPopupActive = true; - } else { - this.focusElementOnOpen(); - } - DomUtils.dispatchEvent(this.$ele, 'afterOpen'); - } + return uniqueId; + } + /** get methods - end */ + + initDropboxPopover() { + const data = { + ele: this.$ele, + target: this.$dropboxContainer, + position: this.position, + zIndex: this.zIndex, + margin: 4, + transitionDistance: 30, + hideArrowIcon: true, + disableManualAction: true, + disableUpdatePosition: !this.hasDropboxWrapper, + updatePositionThrottle: this.updatePositionThrottle, + showDuration: this.showDuration, + hideDuration: this.hideDuration, + afterShow: this.afterShowPopper.bind(this), + afterHide: this.afterHidePopper.bind(this) + }; + this.dropboxPopover = new PopoverComponent(data); + } + openDropbox(isSilent) { + // Set this instance as the last interacted one immediately + VirtualSelect.lastInteractedInstance = this; + let originalTransition = ''; + // Disable transitions for programmatic opening + if (!isSilent) { + // Store original transition + originalTransition = this.$dropboxContainer.style.transition; + this.$dropboxContainer.style.transition = 'none'; + } + // Perform the open operation + this.isSilentOpen = isSilent; + + // Close all other open instances first + VirtualSelect.openInstances.forEach(instance => { + if (instance !== this) { + // Don't focus when closing due to another dropdown being opened + const instanceObj = instance; + instanceObj.shouldFocusWrapperOnClose = false; + instanceObj.closeDropbox(true); // silent close + } + }); + + // Add to open instances + VirtualSelect.openInstances.add(this); + DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxWrapper, 'hidden', false); + DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxContainerTop, 'hidden', false); + DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '0'); + DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', false); + if (isSilent) { + DomUtils.setStyle(this.$dropboxContainer, 'display', 'inline-flex'); + } else { + DomUtils.dispatchEvent(this.$ele, 'beforeOpen'); + DomUtils.setAria(this.$wrapper, 'expanded', true); + } + this.setDropboxWrapperWidth(); + DomUtils.removeClass(this.$allWrappers, 'closed'); + DomUtils.changeTabIndex(this.$allWrappers, 0); + if (!isSilent) { + // Force synchronous layout and style calculation + // Trigger reflow + this.$dropboxContainer.offsetHeight; // eslint-disable-line no-unused-expressions + // Restore transitions immediately after reflow + this.$dropboxContainer.style.transition = originalTransition; + } + if (this.dropboxPopover && !isSilent) { + this.dropboxPopover.show(); + } else { + this.afterShowPopper(); } - }, { - key: "closeDropbox", - value: function closeDropbox(isSilent) { - this.isSilentClose = isSilent; - - // Remove from open instances - VirtualSelect.openInstances["delete"](this); - if (this.isOpened() === false) { - return; - } - if (this.keepAlwaysOpen) { - this.removeOptionFocus(); - return; - } - - // Return focus to wrapper only when no other meaningful element currently has focus - var active = document.activeElement; - var withinComponent = active && this.$wrapper.contains(active) || this.hasDropboxWrapper && active && this.$dropboxWrapper.contains(active); - var shouldRefocus = this.shouldFocusWrapperOnClose && VirtualSelect.lastInteractedInstance === this && !isSilent && (active === null || active === document.body || withinComponent); - if (shouldRefocus) { - this.$wrapper.focus(); - } - if (isSilent) { - DomUtils.setStyle(this.$dropboxContainer, 'display', ''); - } else { - DomUtils.dispatchEvent(this.$ele, 'beforeClose'); - DomUtils.setAria(this.$wrapper, 'expanded', false); - DomUtils.setAria(this.$wrapper, 'activedescendant', ''); - // Also clear aria-activedescendant on the listbox container - DomUtils.setAria(this.$dropboxContainer, 'activedescendant', ''); - } - if (this.dropboxPopover && !isSilent) { - this.dropboxPopover.hide(); - DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); - DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); - DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); - DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } + afterShowPopper() { + const isSilent = this.isSilentOpen; + this.isSilentOpen = false; + if (!isSilent) { + this.moveSelectedOptionsFirst(); + this.setScrollTop(); + DomUtils.addClass(this.$allWrappers, 'focused'); + if (this.showAsPopup) { + DomUtils.addClass(this.$body, 'vscomp-popup-active'); + this.isPopupActive = true; } else { - this.afterHidePopper(); + this.focusElementOnOpen(); } - this.setSearchValue(''); + DomUtils.dispatchEvent(this.$ele, 'afterOpen'); } - }, { - key: "afterHidePopper", - value: function afterHidePopper() { - var isSilent = this.isSilentClose; - this.isSilentClose = false; - DomUtils.removeClass(this.$allWrappers, 'focused'); - this.removeOptionFocus(); - if (!isSilent && this.isPopupActive) { - DomUtils.removeClass(this.$body, 'vscomp-popup-active'); - this.isPopupActive = false; - } - DomUtils.addClass(this.$allWrappers, 'closed'); - if (!isSilent) { - DomUtils.dispatchEvent(this.$ele, 'afterClose'); - } + } + closeDropbox(isSilent) { + this.isSilentClose = isSilent; - // Reset for next close - this.shouldFocusWrapperOnClose = true; + // Remove from open instances + VirtualSelect.openInstances.delete(this); + if (this.isOpened() === false) { + return; + } + if (this.keepAlwaysOpen) { + this.removeOptionFocus(); + return; + } - // Restore accessibility attributes that were inadvertently removed + // Return focus to wrapper only when no other meaningful element currently has focus + const active = document.activeElement; + const withinComponent = active && this.$wrapper.contains(active) || this.hasDropboxWrapper && active && this.$dropboxWrapper.contains(active); + const shouldRefocus = this.shouldFocusWrapperOnClose && VirtualSelect.lastInteractedInstance === this && !isSilent && (active === null || active === document.body || withinComponent); + if (shouldRefocus) { + this.$wrapper.focus(); + } + if (isSilent) { + DomUtils.setStyle(this.$dropboxContainer, 'display', ''); + } else { + DomUtils.dispatchEvent(this.$ele, 'beforeClose'); + DomUtils.setAria(this.$wrapper, 'expanded', false); + DomUtils.setAria(this.$wrapper, 'activedescendant', ''); + // Also clear aria-activedescendant on the listbox container + DomUtils.setAria(this.$dropboxContainer, 'activedescendant', ''); + } + if (this.dropboxPopover && !isSilent) { + this.dropboxPopover.hide(); DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } else { + this.afterHidePopper(); } - }, { - key: "moveSelectedOptionsFirst", - value: function moveSelectedOptionsFirst() { - if (!this.$optionsContainer.scrollTop || !this.selectedValues.length) { - this.setVisibleOptions(); - } - if (!this.showSelectedOptionsFirst) { - return; - } - this.setSortedOptions(); - this.scrollToTop(); + this.setSearchValue(''); + } + afterHidePopper() { + const isSilent = this.isSilentClose; + this.isSilentClose = false; + DomUtils.removeClass(this.$allWrappers, 'focused'); + this.removeOptionFocus(); + if (!isSilent && this.isPopupActive) { + DomUtils.removeClass(this.$body, 'vscomp-popup-active'); + this.isPopupActive = false; + } + DomUtils.addClass(this.$allWrappers, 'closed'); + if (!isSilent) { + DomUtils.dispatchEvent(this.$ele, 'afterClose'); + } + + // Reset for next close + this.shouldFocusWrapperOnClose = true; + + // Restore accessibility attributes that were inadvertently removed + DomUtils.setAttr(this.$dropboxWrapper, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxWrapper, 'hidden', true); + DomUtils.setAttr(this.$dropboxContainerTop, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxContainerTop, 'hidden', true); + DomUtils.setAttr(this.$dropboxContainerBottom, 'tabindex', '-1'); + DomUtils.setAria(this.$dropboxContainerBottom, 'hidden', true); + } + moveSelectedOptionsFirst() { + if (!this.$optionsContainer.scrollTop || !this.selectedValues.length) { this.setVisibleOptions(); } - }, { - key: "toggleDropbox", - value: function toggleDropbox() { - VirtualSelect.lastInteractedInstance = this; - if (this.isOpened()) { - this.closeDropbox(); - } else { - this.openDropbox(); - } + if (!this.showSelectedOptionsFirst) { + return; } - }, { - key: "updatePosition", - value: function updatePosition() { - if (!this.dropboxPopover || !this.isOpened()) { - return; - } - this.$ele.updatePosition(); - } - }, { - key: "isOpened", - value: function isOpened() { - return !DomUtils.hasClass(this.$wrapper, 'closed'); - } - }, { - key: "focusSearchInput", - value: function focusSearchInput() { - var $ele = this.$searchInput; - if ($ele) { - $ele.focus(); - } + this.setSortedOptions(); + this.scrollToTop(); + this.setVisibleOptions(); + } + toggleDropbox() { + VirtualSelect.lastInteractedInstance = this; + if (this.isOpened()) { + this.closeDropbox(); + } else { + this.openDropbox(); } - }, { - key: "focusElementOnOpen", - value: function focusElementOnOpen() { - var $ele = this.$searchInput; - var hasNoOptions = !this.options.length && !this.hasServerSearch; - if ($ele) { - if (hasNoOptions && !this.allowNewOption) { - DomUtils.setAttr($ele, 'disabled', ''); - this.$noOptions.focus(); - } else { - $ele.removeAttribute('disabled'); - $ele.focus(); - } + } + updatePosition() { + if (!this.dropboxPopover || !this.isOpened()) { + return; + } + this.$ele.updatePosition(); + } + isOpened() { + return !DomUtils.hasClass(this.$wrapper, 'closed'); + } + focusSearchInput() { + const $ele = this.$searchInput; + if ($ele) { + $ele.focus(); + } + } + focusElementOnOpen() { + const $ele = this.$searchInput; + const hasNoOptions = !this.options.length && !this.hasServerSearch; + if ($ele) { + if (hasNoOptions && !this.allowNewOption) { + DomUtils.setAttr($ele, 'disabled', ''); + this.$noOptions.focus(); } else { - var $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); - var optIndex = DomUtils.getData($focusableEle, 'index'); - if (optIndex !== undefined) { - this.focusOption({ - direction: 'next' - }); - } else if ($focusableEle) { - $focusableEle.focus(); - } else { - this.focusFirstVisibleOption(); - } + $ele.removeAttribute('disabled'); + $ele.focus(); } - } - }, { - key: "focusFirstVisibleOption", - value: function focusFirstVisibleOption() { - var $focusableEle = this.$optionsContainer.querySelector("[data-index='".concat(this.getFirstVisibleOptionIndex(), "']")); - if ($focusableEle) { - if (DomUtils.hasClass($focusableEle, 'group-title')) { - $focusableEle = this.getSibling($focusableEle, 'next'); - } - DomUtils.setAttr($focusableEle, 'tabindex', '0'); - this.$optionsContainer.scrollTop = this.optionHeight * this.getFirstVisibleOptionIndex(); + } else { + const $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); + const optIndex = DomUtils.getData($focusableEle, 'index'); + if (optIndex !== undefined) { this.focusOption({ - focusFirst: true + direction: 'next' }); + } else if ($focusableEle) { $focusableEle.focus(); } else { - $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); - if ($focusableEle) { - $focusableEle.focus(); - } + this.focusFirstVisibleOption(); } } - }, { - key: "focusOption", - value: function focusOption() { - var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - direction = _ref5.direction, - $option = _ref5.$option, - focusFirst = _ref5.focusFirst; - var $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); - var $newFocusedEle; - if ($option) { - $newFocusedEle = $option; - } else if (!$focusedEle || focusFirst) { - /* if no element on focus choose first visible one */ - var firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); - $newFocusedEle = this.$dropboxContainer.querySelector(".vscomp-option[data-visible-index=\"".concat(firstVisibleOptionIndex, "\"]")); - if (DomUtils.hasClass($newFocusedEle, 'disabled') || DomUtils.hasClass($newFocusedEle, 'group-title')) { - $newFocusedEle = this.getSibling($newFocusedEle, 'next'); - } - } else { - $newFocusedEle = this.getSibling($focusedEle, direction); - } - if ($newFocusedEle && $newFocusedEle !== $focusedEle) { - if ($focusedEle) { - this.toggleOptionFocusedState($focusedEle, false); - } - this.toggleOptionFocusedState($newFocusedEle, true); - this.toggleFocusedProp(DomUtils.getData($newFocusedEle, 'index'), true); - this.moveFocusedOptionToView($newFocusedEle); + } + focusFirstVisibleOption() { + let $focusableEle = this.$optionsContainer.querySelector(`[data-index='${this.getFirstVisibleOptionIndex()}']`); + if ($focusableEle) { + if (DomUtils.hasClass($focusableEle, 'group-title')) { + $focusableEle = this.getSibling($focusableEle, 'next'); + } + DomUtils.setAttr($focusableEle, 'tabindex', '0'); + this.$optionsContainer.scrollTop = this.optionHeight * this.getFirstVisibleOptionIndex(); + this.focusOption({ + focusFirst: true + }); + $focusableEle.focus(); + } else { + $focusableEle = this.$dropbox.querySelector('[tabindex="0"]'); + if ($focusableEle) { + $focusableEle.focus(); } } - }, { - key: "moveFocusedOptionToView", - value: function moveFocusedOptionToView($ele) { - var $focusedEle = $ele || this.$dropboxContainer.querySelector('.vscomp-option.focused'); - if (!$focusedEle) { - return; - } - var newScrollTop; - var containerRect = this.$optionsContainer.getBoundingClientRect(); - var optionRect = $focusedEle.getBoundingClientRect(); - var containerTop = containerRect.top; - var containerBottom = containerRect.bottom; - var containerHeight = containerRect.height; - var optionTop = optionRect.top; - var optionBottom = optionRect.bottom; - var optionHeight = optionRect.height; - var optionOffsetTop = $focusedEle.offsetTop; - var optionsTop = DomUtils.getData(this.$options, 'top', 'number'); - - /* if option hidden on top */ - if (containerTop > optionTop) { - newScrollTop = optionOffsetTop + optionsTop; - } else if (containerBottom < optionBottom) { - /* if option hidden on bottom */ - newScrollTop = optionOffsetTop - containerHeight + optionHeight + optionsTop; - } - if (newScrollTop !== undefined) { - this.$optionsContainer.scrollTop = newScrollTop; - } + } + focusOption({ + direction, + $option, + focusFirst + } = {}) { + const $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); + let $newFocusedEle; + if ($option) { + $newFocusedEle = $option; + } else if (!$focusedEle || focusFirst) { + /* if no element on focus choose first visible one */ + const firstVisibleOptionIndex = this.getFirstVisibleOptionIndex(); + $newFocusedEle = this.$dropboxContainer.querySelector(`.vscomp-option[data-visible-index="${firstVisibleOptionIndex}"]`); + if (DomUtils.hasClass($newFocusedEle, 'disabled') || DomUtils.hasClass($newFocusedEle, 'group-title')) { + $newFocusedEle = this.getSibling($newFocusedEle, 'next'); + } + } else { + $newFocusedEle = this.getSibling($focusedEle, direction); + } + if ($newFocusedEle && $newFocusedEle !== $focusedEle) { + if ($focusedEle) { + this.toggleOptionFocusedState($focusedEle, false); + } + this.toggleOptionFocusedState($newFocusedEle, true); + this.toggleFocusedProp(DomUtils.getData($newFocusedEle, 'index'), true); + this.moveFocusedOptionToView($newFocusedEle); } - }, { - key: "removeOptionFocus", - value: function removeOptionFocus() { - var $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); - if (!$focusedEle) { - return; - } - this.toggleOptionFocusedState($focusedEle, false); - this.toggleFocusedProp(null); - } - }, { - key: "selectOption", - value: function selectOption($ele) { - var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - event = _ref6.event; - if (!$ele) { + } + moveFocusedOptionToView($ele) { + const $focusedEle = $ele || this.$dropboxContainer.querySelector('.vscomp-option.focused'); + if (!$focusedEle) { + return; + } + let newScrollTop; + const containerRect = this.$optionsContainer.getBoundingClientRect(); + const optionRect = $focusedEle.getBoundingClientRect(); + const containerTop = containerRect.top; + const containerBottom = containerRect.bottom; + const containerHeight = containerRect.height; + const optionTop = optionRect.top; + const optionBottom = optionRect.bottom; + const optionHeight = optionRect.height; + const optionOffsetTop = $focusedEle.offsetTop; + const optionsTop = DomUtils.getData(this.$options, 'top', 'number'); + + /* if option hidden on top */ + if (containerTop > optionTop) { + newScrollTop = optionOffsetTop + optionsTop; + } else if (containerBottom < optionBottom) { + /* if option hidden on bottom */ + newScrollTop = optionOffsetTop - containerHeight + optionHeight + optionsTop; + } + if (newScrollTop !== undefined) { + this.$optionsContainer.scrollTop = newScrollTop; + } + } + removeOptionFocus() { + const $focusedEle = this.$dropboxContainer.querySelector('.vscomp-option.focused'); + if (!$focusedEle) { + return; + } + this.toggleOptionFocusedState($focusedEle, false); + this.toggleFocusedProp(null); + } + selectOption($ele, { + event + } = {}) { + if (!$ele) { + return; + } + const isAdding = !DomUtils.hasClass($ele, 'selected'); + if (isAdding) { + if (this.multiple && this.isMaxValuesSelected) { return; } - var isAdding = !DomUtils.hasClass($ele, 'selected'); - if (isAdding) { - if (this.multiple && this.isMaxValuesSelected) { - return; + } else if (!this.multiple) { + /** on selecting same value in single select */ + this.closeDropbox(); + return; + } + let { + selectedValues + } = this; + const selectedValue = DomUtils.getData($ele, 'value'); + const selectedIndex = DomUtils.getData($ele, 'index', 'number'); + const isNewOption = DomUtils.hasClass($ele, 'current-new'); + let shouldSelectRange = false; + const { + lastSelectedOptionIndex + } = this; + this.lastSelectedOptionIndex = null; + this.toggleSelectedProp(selectedIndex, isAdding); + if (isAdding) { + if (this.multiple) { + selectedValues.push(selectedValue); + this.toggleAllOptionsClass(); + this.toggleGroupOptionsParent($ele); + if (event && event.shiftKey) { + shouldSelectRange = true; + } + } else { + if (selectedValues.length) { + this.toggleSelectedProp(this.getOptionIndex(selectedValues[0]), false); + } + selectedValues = [selectedValue]; + const $prevSelectedOption = this.$dropboxContainer.querySelector('.vscomp-option.selected'); + if ($prevSelectedOption) { + this.toggleOptionSelectedState($prevSelectedOption, false); } - } else if (!this.multiple) { - /** on selecting same value in single select */ this.closeDropbox(); - return; - } - var selectedValues = this.selectedValues; - var selectedValue = DomUtils.getData($ele, 'value'); - var selectedIndex = DomUtils.getData($ele, 'index', 'number'); - var isNewOption = DomUtils.hasClass($ele, 'current-new'); - var shouldSelectRange = false; - var lastSelectedOptionIndex = this.lastSelectedOptionIndex; - this.lastSelectedOptionIndex = null; - this.toggleSelectedProp(selectedIndex, isAdding); - if (isAdding) { - if (this.multiple) { - selectedValues.push(selectedValue); - this.toggleAllOptionsClass(); - this.toggleGroupOptionsParent($ele); - if (event && event.shiftKey) { - shouldSelectRange = true; - } - } else { - if (selectedValues.length) { - this.toggleSelectedProp(this.getOptionIndex(selectedValues[0]), false); - } - selectedValues = [selectedValue]; - var $prevSelectedOption = this.$dropboxContainer.querySelector('.vscomp-option.selected'); - if ($prevSelectedOption) { - this.toggleOptionSelectedState($prevSelectedOption, false); - } - this.closeDropbox(); - if (!isNewOption) { - this.setSearchValue(''); - } + if (!isNewOption) { + this.setSearchValue(''); } - this.lastSelectedOptionIndex = selectedIndex; - this.toggleOptionSelectedState($ele); - } else if (this.multiple) { - this.toggleOptionSelectedState($ele); - Utils.removeItemFromArray(selectedValues, selectedValue); - this.toggleAllOptionsClass(false); - this.toggleGroupOptionsParent($ele, false); - } - if (isNewOption) { - this.beforeSelectNewValue(selectedValue); - } - this.setValue(selectedValues); - if (shouldSelectRange) { - this.selectRangeOptions(lastSelectedOptionIndex, selectedIndex); } + this.lastSelectedOptionIndex = selectedIndex; + this.toggleOptionSelectedState($ele); + } else if (this.multiple) { + this.toggleOptionSelectedState($ele); + Utils.removeItemFromArray(selectedValues, selectedValue); + this.toggleAllOptionsClass(false); + this.toggleGroupOptionsParent($ele, false); + } + if (isNewOption) { + this.beforeSelectNewValue(selectedValue); } - }, { - key: "selectFocusedOption", - value: function selectFocusedOption() { - this.selectOption(this.$dropboxContainer.querySelector('.vscomp-option.focused')); + this.setValue(selectedValues); + if (shouldSelectRange) { + this.selectRangeOptions(lastSelectedOptionIndex, selectedIndex); } - }, { - key: "selectRangeOptions", - value: function selectRangeOptions(lastSelectedOptionIndex, selectedIndex) { - var _this12 = this; - if (typeof lastSelectedOptionIndex !== 'number' || this.maxValues) { + } + selectFocusedOption() { + this.selectOption(this.$dropboxContainer.querySelector('.vscomp-option.focused')); + } + selectRangeOptions(lastSelectedOptionIndex, selectedIndex) { + if (typeof lastSelectedOptionIndex !== 'number' || this.maxValues) { + return; + } + const { + selectedValues, + hasOptionGroup + } = this; + let groupIndexes = {}; + let startIndex; + let endIndex; + if (lastSelectedOptionIndex < selectedIndex) { + startIndex = lastSelectedOptionIndex; + endIndex = selectedIndex; + } else { + startIndex = selectedIndex; + endIndex = lastSelectedOptionIndex; + } + this.options.forEach(d => { + if (d.isDisabled || d.isGroupTitle || !d.isVisible || d.isSelected) { return; } - var selectedValues = this.selectedValues, - hasOptionGroup = this.hasOptionGroup; - var groupIndexes = {}; - var startIndex; - var endIndex; - if (lastSelectedOptionIndex < selectedIndex) { - startIndex = lastSelectedOptionIndex; - endIndex = selectedIndex; - } else { - startIndex = selectedIndex; - endIndex = lastSelectedOptionIndex; - } - this.options.forEach(function (d) { - if (d.isDisabled || d.isGroupTitle || !d.isVisible || d.isSelected) { - return; - } - var index = d.index; - if (index > startIndex && index < endIndex) { - if (hasOptionGroup) { - var groupIndex = d.groupIndex; - if (typeof groupIndex === 'number') { - groupIndexes[groupIndex] = true; - } + const { + index + } = d; + if (index > startIndex && index < endIndex) { + if (hasOptionGroup) { + const { + groupIndex + } = d; + if (typeof groupIndex === 'number') { + groupIndexes[groupIndex] = true; } - - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - selectedValues.push(d.value); } + + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + selectedValues.push(d.value); + } + }); + this.toggleAllOptionsClass(); + this.setValue(selectedValues); + groupIndexes = Object.keys(groupIndexes); + if (groupIndexes.length) { + const toggleGroupTitleProp = this.toggleGroupTitleProp.bind(this); + groupIndexes.forEach(i => { + toggleGroupTitleProp(parseInt(i)); }); - this.toggleAllOptionsClass(); - this.setValue(selectedValues); - groupIndexes = Object.keys(groupIndexes); - if (groupIndexes.length) { - var toggleGroupTitleProp = this.toggleGroupTitleProp.bind(this); - groupIndexes.forEach(function (i) { - toggleGroupTitleProp(parseInt(i)); - }); - } + } - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this12.renderOptions(); - }, 0); - } - }, { - key: "toggleAllOptions", - value: function toggleAllOptions(selectAll) { - if (!this.multiple || this.disableSelectAll) { + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.renderOptions(); + }, 0); + } + toggleAllOptions(selectAll) { + if (!this.multiple || this.disableSelectAll) { + return; + } + const selectingAll = typeof isSelected === 'boolean' ? selectAll : !DomUtils.hasClass(this.$toggleAllCheckbox, 'checked'); + const selectedValues = []; + const { + selectAllOnlyVisible + } = this; + this.options.forEach(d => { + const option = d; + if (option.isDisabled || option.isCurrentNew) { return; } - var selectingAll = typeof isSelected === 'boolean' ? selectAll : !DomUtils.hasClass(this.$toggleAllCheckbox, 'checked'); - var selectedValues = []; - var selectAllOnlyVisible = this.selectAllOnlyVisible; - this.options.forEach(function (d) { - var option = d; - if (option.isDisabled || option.isCurrentNew) { - return; - } - var isVisible = option.isVisible, - isSelected = option.isSelected; + const { + isVisible, + isSelected + } = option; - /** unselected items are */ - if (/** when unselecting all, selectAllOnlyVisible feature disabled or visible items or already unselected items */ - !selectingAll && (!selectAllOnlyVisible || isVisible || !isSelected) || (/** when selecting all, selectAllOnlyVisible feature enabled and hidden items those are not already selected */ - selectingAll && selectAllOnlyVisible && !isVisible && !isSelected)) { - option.isSelected = false; - } else { - option.isSelected = true; - if (!option.isGroupTitle) { - selectedValues.push(option.value); - } + /** unselected items are */ + if (/** when unselecting all, selectAllOnlyVisible feature disabled or visible items or already unselected items */ + !selectingAll && (!selectAllOnlyVisible || isVisible || !isSelected) || (/** when selecting all, selectAllOnlyVisible feature enabled and hidden items those are not already selected */ + selectingAll && selectAllOnlyVisible && !isVisible && !isSelected)) { + option.isSelected = false; + } else { + option.isSelected = true; + if (!option.isGroupTitle) { + selectedValues.push(option.value); } - }); - this.toggleAllOptionsClass(selectingAll); - this.setValue(selectedValues); - this.renderOptions(); - } - }, { - key: "toggleAllOptionsClass", - value: function toggleAllOptionsClass(isAllSelected) { - if (!this.multiple) { - return; - } - var valuePassed = typeof isAllSelected === 'boolean'; - var isAllVisibleSelected = false; - if (!valuePassed) { - // eslint-disable-next-line no-param-reassign - isAllSelected = this.isAllOptionsSelected(); } + }); + this.toggleAllOptionsClass(selectingAll); + this.setValue(selectedValues); + this.renderOptions(); + } + toggleAllOptionsClass(isAllSelected) { + if (!this.multiple) { + return; + } + const valuePassed = typeof isAllSelected === 'boolean'; + let isAllVisibleSelected = false; + if (!valuePassed) { + // eslint-disable-next-line no-param-reassign + isAllSelected = this.isAllOptionsSelected(); + } - /** When all options not selected, checking if all visible options selected - * Also, in a search mode, validate that we still have visible items - */ - if (!isAllSelected && this.selectAllOnlyVisible && this.searchValue !== '' && (this.visibleOptionsCount > 0 || this.searchValue === '')) { - isAllVisibleSelected = this.isAllOptionsSelected(true); - } - DomUtils.toggleClass(this.$toggleAllCheckbox, 'checked', isAllSelected || isAllVisibleSelected); - this.isAllSelected = isAllSelected; - } - }, { - key: "isAllOptionsSelected", - value: function isAllOptionsSelected(visibleOnly) { - var isAllSelected = false; - if (this.options.length && this.selectedValues.length) { - isAllSelected = !this.options.some( - /** - * stop looping if any option is not selected - * for selectAllOnlyVisible case hidden option need not to be selected - */ - function (d) { - return !d.isSelected && !d.isDisabled && !d.isGroupTitle && (!visibleOnly || d.isVisible); - }); - } - return isAllSelected; - } - }, { - key: "isAllGroupOptionsSelected", - value: function isAllGroupOptionsSelected(groupIndex) { - var isAllSelected = false; - if (this.options.length) { - isAllSelected = !this.options.some(function (d) { - return !d.isSelected && !d.isDisabled && !d.isGroupTitle && d.groupIndex === groupIndex; - }); - } - return isAllSelected; + /** When all options not selected, checking if all visible options selected + * Also, in a search mode, validate that we still have visible items + */ + if (!isAllSelected && this.selectAllOnlyVisible && this.searchValue !== '' && (this.visibleOptionsCount > 0 || this.searchValue === '')) { + isAllVisibleSelected = this.isAllOptionsSelected(true); } - }, { - key: "toggleGroupOptionsParent", - value: function toggleGroupOptionsParent($option, isSelected) { - if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$option) { - return; - } - var groupIndex = DomUtils.getData($option, 'groupIndex'); - if (groupIndex !== undefined) { - groupIndex = parseInt(groupIndex); - } - var $group = this.$options.querySelector(".vscomp-option[data-index=\"".concat(groupIndex, "\"]")); - var isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); - this.toggleGroupTitleCheckbox($group, isAllSelected); - this.toggleGroupTitleProp(groupIndex, isAllSelected); - } - }, { - key: "toggleGroupTitleProp", - value: function toggleGroupTitleProp(groupIndex, isSelected) { - var isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); - this.toggleSelectedProp(groupIndex, isAllSelected); - } - }, { - key: "toggleGroupOptions", - value: function toggleGroupOptions($ele, isSelected) { - var _this13 = this; - if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$ele) { + DomUtils.toggleClass(this.$toggleAllCheckbox, 'checked', isAllSelected || isAllVisibleSelected); + this.isAllSelected = isAllSelected; + } + isAllOptionsSelected(visibleOnly) { + let isAllSelected = false; + if (this.options.length && this.selectedValues.length) { + isAllSelected = !this.options.some( + /** + * stop looping if any option is not selected + * for selectAllOnlyVisible case hidden option need not to be selected + */ + d => !d.isSelected && !d.isDisabled && !d.isGroupTitle && (!visibleOnly || d.isVisible)); + } + return isAllSelected; + } + isAllGroupOptionsSelected(groupIndex) { + let isAllSelected = false; + if (this.options.length) { + isAllSelected = !this.options.some(d => !d.isSelected && !d.isDisabled && !d.isGroupTitle && d.groupIndex === groupIndex); + } + return isAllSelected; + } + toggleGroupOptionsParent($option, isSelected) { + if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$option) { + return; + } + let groupIndex = DomUtils.getData($option, 'groupIndex'); + if (groupIndex !== undefined) { + groupIndex = parseInt(groupIndex); + } + const $group = this.$options.querySelector(`.vscomp-option[data-index="${groupIndex}"]`); + const isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); + this.toggleGroupTitleCheckbox($group, isAllSelected); + this.toggleGroupTitleProp(groupIndex, isAllSelected); + } + toggleGroupTitleProp(groupIndex, isSelected) { + const isAllSelected = typeof isSelected === 'boolean' ? isSelected : this.isAllGroupOptionsSelected(groupIndex); + this.toggleSelectedProp(groupIndex, isAllSelected); + } + toggleGroupOptions($ele, isSelected) { + if (!this.hasOptionGroup || this.disableOptionGroupCheckbox || !$ele) { + return; + } + const groupIndex = DomUtils.getData($ele, 'index', 'number'); + const { + selectedValues, + selectAllOnlyVisible + } = this; + const valuesMapping = {}; + const { + removeItemFromArray + } = Utils; + selectedValues.forEach(d => { + valuesMapping[d] = true; + }); + this.options.forEach(d => { + if (d.isDisabled || d.groupIndex !== groupIndex) { return; } - var groupIndex = DomUtils.getData($ele, 'index', 'number'); - var selectedValues = this.selectedValues, - selectAllOnlyVisible = this.selectAllOnlyVisible; - var valuesMapping = {}; - var removeItemFromArray = Utils.removeItemFromArray; - selectedValues.forEach(function (d) { - valuesMapping[d] = true; - }); - this.options.forEach(function (d) { - if (d.isDisabled || d.groupIndex !== groupIndex) { - return; + const { + value + } = d; + if (!isSelected || selectAllOnlyVisible && !d.isVisible) { + // eslint-disable-next-line no-param-reassign + d.isSelected = false; + if (valuesMapping[value]) { + removeItemFromArray(selectedValues, value); } - var value = d.value; - if (!isSelected || selectAllOnlyVisible && !d.isVisible) { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - if (valuesMapping[value]) { - removeItemFromArray(selectedValues, value); - } - } else { - // eslint-disable-next-line no-param-reassign - d.isSelected = true; - if (!valuesMapping[value]) { - selectedValues.push(value); - } + } else { + // eslint-disable-next-line no-param-reassign + d.isSelected = true; + if (!valuesMapping[value]) { + selectedValues.push(value); } - }); - this.toggleAllOptionsClass(isSelected ? null : false); - this.setValue(selectedValues); - - /** using setTimeout to fix the issue of dropbox getting closed on select */ - setTimeout(function () { - _this13.renderOptions(); - }, 0); - } - }, { - key: "toggleGroupTitleCheckbox", - value: function toggleGroupTitleCheckbox($ele, isSelected) { - if (!$ele) { - return; - } - var selectedIndex = DomUtils.getData($ele, 'index', 'number'); - this.toggleSelectedProp(selectedIndex, isSelected); - this.toggleOptionSelectedState($ele, isSelected); - } - }, { - key: "toggleFocusedProp", - value: function toggleFocusedProp(index) { - var isFocused = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (this.focusedOptionIndex) { - this.setOptionProp(this.focusedOptionIndex, 'isFocused', false); - } - this.setOptionProp(index, 'isFocused', isFocused); - this.focusedOptionIndex = index; - } - }, { - key: "toggleSelectedProp", - value: function toggleSelectedProp(index) { - var isSelected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.setOptionProp(index, 'isSelected', isSelected); - } - }, { - key: "scrollToTop", - value: function scrollToTop() { - var scrollTop = this.$optionsContainer.scrollTop; - if (scrollTop > 0) { - this.$optionsContainer.scrollTop = 0; } + }); + this.toggleAllOptionsClass(isSelected ? null : false); + this.setValue(selectedValues); + + /** using setTimeout to fix the issue of dropbox getting closed on select */ + setTimeout(() => { + this.renderOptions(); + }, 0); + } + toggleGroupTitleCheckbox($ele, isSelected) { + if (!$ele) { + return; } - }, { - key: "reset", - value: function reset() { - var formReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var disableChangeEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.options.forEach(function (d) { - // eslint-disable-next-line no-param-reassign - d.isSelected = false; - }); - this.beforeValueSet(true); - this.setValue(null, { - disableEvent: disableChangeEvent, - disableValidation: formReset - }); - this.afterValueSet(); - if (formReset) { - DomUtils.removeClass(this.$allWrappers, 'has-error'); - } - DomUtils.dispatchEvent(this.$ele, 'reset'); + const selectedIndex = DomUtils.getData($ele, 'index', 'number'); + this.toggleSelectedProp(selectedIndex, isSelected); + this.toggleOptionSelectedState($ele, isSelected); + } + toggleFocusedProp(index, isFocused = false) { + if (this.focusedOptionIndex) { + this.setOptionProp(this.focusedOptionIndex, 'isFocused', false); } - }, { - key: "addOption", - value: function addOption(data, rerender) { - if (!data) { - return; - } - this.lastOptionIndex += 1; - var newOption = this.getOptionObj(_objectSpread(_objectSpread({}, data), {}, { - index: this.lastOptionIndex - })); - this.options.push(newOption); - this.sortedOptions.push(newOption); - if (rerender) { - this.visibleOptionsCount += 1; - this.afterSetOptions(); - } + this.setOptionProp(index, 'isFocused', isFocused); + this.focusedOptionIndex = index; + } + toggleSelectedProp(index, isSelected = false) { + this.setOptionProp(index, 'isSelected', isSelected); + } + scrollToTop() { + const { + scrollTop + } = this.$optionsContainer; + if (scrollTop > 0) { + this.$optionsContainer.scrollTop = 0; } - }, { - key: "removeOption", - value: function removeOption(index) { - if (!index && index !== 0) { - return; - } - this.options.splice(index, 1); - this.lastOptionIndex -= 1; - } - }, { - key: "removeNewOption", - value: function removeNewOption() { - var newOption = this.getNewOption(); - if (newOption) { - this.removeOption(newOption.index); - } + } + reset(formReset = false, disableChangeEvent = false) { + this.options.forEach(d => { + // eslint-disable-next-line no-param-reassign + d.isSelected = false; + }); + this.beforeValueSet(true); + this.setValue(null, { + disableEvent: disableChangeEvent, + disableValidation: formReset + }); + this.afterValueSet(); + if (formReset) { + DomUtils.removeClass(this.$allWrappers, 'has-error'); + } + DomUtils.dispatchEvent(this.$ele, 'reset'); + } + addOption(data, rerender) { + if (!data) { + return; + } + this.lastOptionIndex += 1; + const newOption = this.getOptionObj({ + ...data, + index: this.lastOptionIndex + }); + this.options.push(newOption); + this.sortedOptions.push(newOption); + if (rerender) { + this.visibleOptionsCount += 1; + this.afterSetOptions(); } - }, { - key: "sortOptions", - value: function sortOptions(options) { - return options.sort(function (a, b) { - var aIsSelected = a.isSelected || a.isAnySelected; - var bIsSelected = b.isSelected || b.isAnySelected; - if (!aIsSelected && !bIsSelected) { - return 0; - } - if (aIsSelected && (!bIsSelected || a.index < b.index)) { - return -1; - } - return 1; - }); + } + removeOption(index) { + if (!index && index !== 0) { + return; } - }, { - key: "sortOptionsGroup", - value: function sortOptionsGroup(options) { - var sortOptions = this.sortOptions.bind(this); - var structuredOptions = this.structureOptionGroup(options); - structuredOptions.forEach(function (d) { - var childOptions = d.options; - // eslint-disable-next-line no-param-reassign - d.isAnySelected = childOptions.some(function (e) { - return e.isSelected; - }); - if (d.isAnySelected) { - sortOptions(childOptions); - } - }); - sortOptions(structuredOptions); - return this.destructureOptionGroup(structuredOptions); - } - }, { - key: "isOptionVisible", - value: function isOptionVisible(_ref7) { - var data = _ref7.data, - searchValue = _ref7.searchValue, - hasExactOption = _ref7.hasExactOption, - visibleOptionGroupsMapping = _ref7.visibleOptionGroupsMapping, - searchGroup = _ref7.searchGroup, - searchByStartsWith = _ref7.searchByStartsWith; - var value = data.valueNormalized != null ? data.valueNormalized : data.value.toLowerCase(); - var label = data.labelNormalized; - if (label == null) { - var rawLabel = (data.label || '').trim(); - if (this.searchNormalize && rawLabel !== '') { - label = Utils.normalizeString(rawLabel).toLowerCase(); - } else { - label = rawLabel.toLowerCase(); - } - } - var description = data.description, - alias = data.alias; - var descriptionNormalized = data.descriptionNormalized; - if (descriptionNormalized == null) { - var rawDescription = description || ''; - if (this.searchNormalize && rawDescription.trim() !== '') { - descriptionNormalized = Utils.normalizeString(rawDescription).toLowerCase(); - } else { - descriptionNormalized = rawDescription.toLowerCase(); - } - } - var isVisible = searchByStartsWith ? label.startsWith(searchValue) : label.includes(searchValue); - if (data.isGroupTitle && (!searchGroup || !isVisible)) { - isVisible = visibleOptionGroupsMapping[data.index]; - } - if (!searchByStartsWith && alias && !isVisible) { - isVisible = alias.includes(searchValue); - } - if (!searchByStartsWith && descriptionNormalized && !isVisible) { - isVisible = descriptionNormalized.includes(searchValue); - } - + this.options.splice(index, 1); + this.lastOptionIndex -= 1; + } + removeNewOption() { + const newOption = this.getNewOption(); + if (newOption) { + this.removeOption(newOption.index); + } + } + sortOptions(options) { + return options.sort((a, b) => { + const aIsSelected = a.isSelected || a.isAnySelected; + const bIsSelected = b.isSelected || b.isAnySelected; + if (!aIsSelected && !bIsSelected) { + return 0; + } + if (aIsSelected && (!bIsSelected || a.index < b.index)) { + return -1; + } + return 1; + }); + } + sortOptionsGroup(options) { + const sortOptions = this.sortOptions.bind(this); + const structuredOptions = this.structureOptionGroup(options); + structuredOptions.forEach(d => { + const childOptions = d.options; // eslint-disable-next-line no-param-reassign - data.isVisible = isVisible; - if (!hasExactOption) { - // eslint-disable-next-line no-param-reassign - hasExactOption = label === searchValue || value === searchValue; + d.isAnySelected = childOptions.some(e => e.isSelected); + if (d.isAnySelected) { + sortOptions(childOptions); + } + }); + sortOptions(structuredOptions); + return this.destructureOptionGroup(structuredOptions); + } + isOptionVisible({ + data, + searchValue, + hasExactOption, + visibleOptionGroupsMapping, + searchGroup, + searchByStartsWith + }) { + const value = data.valueNormalized != null ? data.valueNormalized : data.value.toLowerCase(); + let label = data.labelNormalized; + if (label == null) { + const rawLabel = (data.label || '').trim(); + if (this.searchNormalize && rawLabel !== '') { + label = Utils.normalizeString(rawLabel).toLowerCase(); + } else { + label = rawLabel.toLowerCase(); + } + } + const { + description, + alias + } = data; + let { + descriptionNormalized + } = data; + if (descriptionNormalized == null) { + const rawDescription = description || ''; + if (this.searchNormalize && rawDescription.trim() !== '') { + descriptionNormalized = Utils.normalizeString(rawDescription).toLowerCase(); + } else { + descriptionNormalized = rawDescription.toLowerCase(); } - return { - isVisible: isVisible, - hasExactOption: hasExactOption - }; } - }, { - key: "structureOptionGroup", - value: function structureOptionGroup(options) { - var result = []; - var childOptions = {}; - - /** getting all group title */ - options.forEach(function (d) { - if (d.isGroupTitle) { - var childArray = []; - // eslint-disable-next-line no-param-reassign - d.options = childArray; - childOptions[d.index] = childArray; - result.push(d); - } - }); - - /** getting all group options */ - options.forEach(function (d) { - if (d.isGroupOption) { - childOptions[d.groupIndex].push(d); - } - }); - return result; + let isVisible = searchByStartsWith ? label.startsWith(searchValue) : label.includes(searchValue); + if (data.isGroupTitle && (!searchGroup || !isVisible)) { + isVisible = visibleOptionGroupsMapping[data.index]; } - }, { - key: "destructureOptionGroup", - value: function destructureOptionGroup(options) { - var result = []; - options.forEach(function (d) { - result.push(d); - result = result.concat(d.options); - }); - return result; + if (!searchByStartsWith && alias && !isVisible) { + isVisible = alias.includes(searchValue); } - }, { - key: "serverSearch", - value: function serverSearch() { - DomUtils.removeClass(this.$allWrappers, 'has-no-search-results'); - DomUtils.addClass(this.$allWrappers, 'server-searching'); - this.setSelectedOptions(); - this.onServerSearch(this.searchValue, this); - } - }, { - key: "removeValue", - value: function removeValue($ele) { - var selectedValues = this.selectedValues; - var selectedValue = DomUtils.getData($ele, 'value'); - Utils.removeItemFromArray(selectedValues, selectedValue); - this.setValueMethod(selectedValues); + if (!searchByStartsWith && descriptionNormalized && !isVisible) { + isVisible = descriptionNormalized.includes(searchValue); } - }, { - key: "focus", - value: function focus() { - this.$wrapper.focus(); + + // eslint-disable-next-line no-param-reassign + data.isVisible = isVisible; + if (!hasExactOption) { + // eslint-disable-next-line no-param-reassign + hasExactOption = label === searchValue || value === searchValue; } - }, { - key: "enable", - value: function enable() { - this.$ele.disabled = false; - this.$ele.removeAttribute('disabled'); - this.$hiddenInput.removeAttribute('disabled'); - DomUtils.setAria(this.$wrapper, 'disabled', false); - DomUtils.changeTabIndex(this.$wrapper, 0); - } - }, { - key: "disable", - value: function disable() { - this.$ele.disabled = true; - this.$ele.setAttribute('disabled', ''); - this.$hiddenInput.setAttribute('disabled', ''); - DomUtils.setAria(this.$wrapper, 'disabled', true); - DomUtils.changeTabIndex(this.$wrapper, -1); - this.$wrapper.blur(); - } - }, { - key: "validate", - value: function validate() { - if (this.disableValidation) { - return true; + return { + isVisible, + hasExactOption + }; + } + structureOptionGroup(options) { + const result = []; + const childOptions = {}; + + /** getting all group title */ + options.forEach(d => { + if (d.isGroupTitle) { + const childArray = []; + // eslint-disable-next-line no-param-reassign + d.options = childArray; + childOptions[d.index] = childArray; + result.push(d); } - var hasError = false; - var selectedValues = this.selectedValues, - minValues = this.minValues; - if (this.required && (Utils.isEmpty(selectedValues) || (/** required minium options not selected */ - this.multiple && minValues && selectedValues.length < minValues))) { - hasError = true; + }); + + /** getting all group options */ + options.forEach(d => { + if (d.isGroupOption) { + childOptions[d.groupIndex].push(d); } - DomUtils.toggleClass(this.$allWrappers, 'has-error', hasError); - return !hasError; - } - }, { - key: "destroy", - value: function destroy() { - var $ele = this.$ele; - $ele.virtualSelect = undefined; - $ele.value = undefined; - $ele.innerHTML = ''; + }); + return result; + } + destructureOptionGroup(options) { + let result = []; + options.forEach(d => { + result.push(d); + result = result.concat(d.options); + }); + return result; + } + serverSearch() { + DomUtils.removeClass(this.$allWrappers, 'has-no-search-results'); + DomUtils.addClass(this.$allWrappers, 'server-searching'); + this.setSelectedOptions(); + this.onServerSearch(this.searchValue, this); + } + removeValue($ele) { + const { + selectedValues + } = this; + const selectedValue = DomUtils.getData($ele, 'value'); + Utils.removeItemFromArray(selectedValues, selectedValue); + this.setValueMethod(selectedValues); + } + focus() { + this.$wrapper.focus(); + } + enable() { + this.$ele.disabled = false; + this.$ele.removeAttribute('disabled'); + this.$hiddenInput.removeAttribute('disabled'); + DomUtils.setAria(this.$wrapper, 'disabled', false); + DomUtils.changeTabIndex(this.$wrapper, 0); + } + disable() { + this.$ele.disabled = true; + this.$ele.setAttribute('disabled', ''); + this.$hiddenInput.setAttribute('disabled', ''); + DomUtils.setAria(this.$wrapper, 'disabled', true); + DomUtils.changeTabIndex(this.$wrapper, -1); + this.$wrapper.blur(); + } + validate() { + if (this.disableValidation) { + return true; + } + let hasError = false; + const { + selectedValues, + minValues + } = this; + if (this.required && (Utils.isEmpty(selectedValues) || (/** required minium options not selected */ + this.multiple && minValues && selectedValues.length < minValues))) { + hasError = true; + } + DomUtils.toggleClass(this.$allWrappers, 'has-error', hasError); + return !hasError; + } + destroy() { + const { + $ele + } = this; + $ele.virtualSelect = undefined; + $ele.value = undefined; + $ele.innerHTML = ''; - // Remove from open instances - VirtualSelect.openInstances["delete"](this); + // Remove from open instances + VirtualSelect.openInstances.delete(this); - // Reset the last interacted instance only if this is the last interacted instance - if (this === VirtualSelect.lastInteractedInstance) { - VirtualSelect.lastInteractedInstance = null; - } + // Reset the last interacted instance only if this is the last interacted instance + if (this === VirtualSelect.lastInteractedInstance) { + VirtualSelect.lastInteractedInstance = null; + } - // Clear any pending server search timeout to prevent memory leaks - if (this.serverSearchTimeout) { - clearTimeout(this.serverSearchTimeout); - this.serverSearchTimeout = null; - } + // Clear any pending server search timeout to prevent memory leaks + if (this.serverSearchTimeout) { + clearTimeout(this.serverSearchTimeout); + this.serverSearchTimeout = null; + } - /** Remove all event listeners to prevent memory leaks and ensure proper cleanup */ - this.removeEvents(); - if (this.hasDropboxWrapper) { - this.$dropboxWrapper.remove(); - } - if (this.dropboxPopover) { - this.dropboxPopover.destroy(); - } - DomUtils.removeClass($ele, 'vscomp-ele'); - } - }, { - key: "createSecureTextElements", - value: function createSecureTextElements() { - this.$secureDiv = document.createElement('div'); - this.$secureText = document.createTextNode(''); - this.$secureDiv.appendChild(this.$secureText); - } - }, { - key: "secureText", - value: function secureText(text) { - if (!text || !this.enableSecureText) { - return text; - } - /** escape potentially harmful JavaScript so, label and value fields cannot trigger XSS */ - this.$secureText.nodeValue = Utils.replaceDoubleQuotesWithHTML(text); - return this.$secureDiv.innerHTML; - } - }, { - key: "toggleRequired", - value: function toggleRequired(isRequired) { - this.required = Utils.convertToBoolean(isRequired); - this.$ele.required = this.required; - } - }, { - key: "toggleOptionSelectedState", - value: function toggleOptionSelectedState($ele, value) { - var isSelected = value; - if (typeof isSelected === 'undefined') { - isSelected = !DomUtils.hasClass($ele, 'selected'); - } - DomUtils.toggleClass($ele, 'selected', isSelected); - DomUtils.setAria($ele, 'selected', isSelected); + /** Remove all event listeners to prevent memory leaks and ensure proper cleanup */ + this.removeEvents(); + if (this.hasDropboxWrapper) { + this.$dropboxWrapper.remove(); } - }, { - key: "toggleOptionFocusedState", - value: function toggleOptionFocusedState($ele, isFocused) { - if (!$ele) { - return; - } - DomUtils.toggleClass($ele, 'focused', isFocused); - DomUtils.setAttr($ele, 'tabindex', isFocused ? '0' : '-1'); - if (document.activeElement !== this.$searchInput) { - $ele.focus(); - } - if (isFocused) { - DomUtils.setAria(this.$wrapper, 'activedescendant', $ele.id); - // Also set aria-activedescendant on the listbox container for better screen reader support - DomUtils.setAria(this.$dropboxContainer, 'activedescendant', $ele.id); - } + if (this.dropboxPopover) { + this.dropboxPopover.destroy(); + } + DomUtils.removeClass($ele, 'vscomp-ele'); + } + createSecureTextElements() { + this.$secureDiv = document.createElement('div'); + this.$secureText = document.createTextNode(''); + this.$secureDiv.appendChild(this.$secureText); + } + secureText(text) { + if (!text || !this.enableSecureText) { + return text; + } + /** escape potentially harmful JavaScript so, label and value fields cannot trigger XSS */ + this.$secureText.nodeValue = Utils.replaceDoubleQuotesWithHTML(text); + return this.$secureDiv.innerHTML; + } + toggleRequired(isRequired) { + this.required = Utils.convertToBoolean(isRequired); + this.$ele.required = this.required; + } + toggleOptionSelectedState($ele, value) { + let isSelected = value; + if (typeof isSelected === 'undefined') { + isSelected = !DomUtils.hasClass($ele, 'selected'); + } + DomUtils.toggleClass($ele, 'selected', isSelected); + DomUtils.setAria($ele, 'selected', isSelected); + } + toggleOptionFocusedState($ele, isFocused) { + if (!$ele) { + return; + } + DomUtils.toggleClass($ele, 'focused', isFocused); + DomUtils.setAttr($ele, 'tabindex', isFocused ? '0' : '-1'); + if (document.activeElement !== this.$searchInput) { + $ele.focus(); } + if (isFocused) { + DomUtils.setAria(this.$wrapper, 'activedescendant', $ele.id); + // Also set aria-activedescendant on the listbox container for better screen reader support + DomUtils.setAria(this.$dropboxContainer, 'activedescendant', $ele.id); + } + } - /** static methods - start */ - }], [{ - key: "init", - value: function init(options) { - var $eleArray = options.ele; - if (!$eleArray) { + /** static methods - start */ + static init(options) { + let $eleArray = options.ele; + if (!$eleArray) { + return undefined; + } + let singleEle = false; + if (typeof $eleArray === 'string') { + $eleArray = document.querySelectorAll($eleArray); + const eleLength = $eleArray.length; + if (eleLength === 0) { return undefined; } - var singleEle = false; - if (typeof $eleArray === 'string') { - $eleArray = document.querySelectorAll($eleArray); - var eleLength = $eleArray.length; - if (eleLength === 0) { - return undefined; - } - if (eleLength === 1) { - singleEle = true; - } - } - if ($eleArray.length === undefined || $eleArray.forEach === undefined) { - $eleArray = [$eleArray]; + if (eleLength === 1) { singleEle = true; } - var instances = []; - $eleArray.forEach(function ($ele) { - /** skipping initialization on calling init method multiple times */ - if ($ele.virtualSelect) { - instances.push($ele.virtualSelect); - return; - } - - // eslint-disable-next-line no-param-reassign - options.ele = $ele; - if ($ele.tagName === 'SELECT') { - VirtualSelect.setPropsFromSelect(options); - } - instances.push(new VirtualSelect(options)); - }); - return singleEle ? instances[0] : instances; - } - }, { - key: "getAttrProps", - value: function getAttrProps() { - var convertPropToDataAttr = DomUtils.convertPropToDataAttr; - var result = {}; - nativeProps.forEach(function (d) { - result[d] = d; - }); - dataProps.forEach(function (d) { - result[convertPropToDataAttr(d)] = d; - }); - return result; } - }, { - key: "setPropsFromSelect", - value: function setPropsFromSelect(props) { - var $ele = props.ele; - var disabledOptions = []; - var selectedValue = []; - var _getNativeOptions = function getNativeOptions($container) { - var options = []; - var $options = Array.from($container.children); - $options.forEach(function ($option) { - var value = $option.value; - var option = { - value: value - }; - if ($option.tagName === 'OPTGROUP') { - option.label = $option.getAttribute('label'); - option.options = _getNativeOptions($option); - } else { - option.label = $option.innerHTML; - } - options.push(option); - if ($option.disabled) { - disabledOptions.push(value); - } - if ($option.selected) { - selectedValue.push(value); - } - }); - return options; - }; - var optionsList = _getNativeOptions($ele); - - /** creating div element to initiate plugin and removing native element */ - var $newEle = document.createElement('div'); - DomUtils.setAttrFromEle($ele, $newEle, Object.keys(attrPropsMapping), valueLessProps); - $ele.parentNode.insertBefore($newEle, $ele); - $ele.remove(); - - // eslint-disable-next-line no-param-reassign - props.ele = $newEle; - // eslint-disable-next-line no-param-reassign - props.options = optionsList; - // eslint-disable-next-line no-param-reassign - props.disabledOptions = disabledOptions; - // eslint-disable-next-line no-param-reassign - props.selectedValue = selectedValue; + if ($eleArray.length === undefined || $eleArray.forEach === undefined) { + $eleArray = [$eleArray]; + singleEle = true; } - }, { - key: "onFormReset", - value: function onFormReset(e) { - var $form = e.target.closest('form'); - if (!$form) { + const instances = []; + $eleArray.forEach($ele => { + /** skipping initialization on calling init method multiple times */ + if ($ele.virtualSelect) { + instances.push($ele.virtualSelect); return; } - $form.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - $ele.parentElement.virtualSelect.reset(true); - }); - } - }, { - key: "onFormSubmit", - value: function onFormSubmit(e) { - if (!VirtualSelect.validate(e.target.closest('form'))) { - e.preventDefault(); - } - } - }, { - key: "validate", - value: function validate($container) { - if (!$container) { - return true; + + // eslint-disable-next-line no-param-reassign + options.ele = $ele; + if ($ele.tagName === 'SELECT') { + VirtualSelect.setPropsFromSelect(options); } - var hasError = false; - $container.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - var result = $ele.parentElement.virtualSelect.validate(); - if (!hasError && !result) { - hasError = true; + instances.push(new VirtualSelect(options)); + }); + return singleEle ? instances[0] : instances; + } + static getAttrProps() { + const { + convertPropToDataAttr + } = DomUtils; + const result = {}; + nativeProps.forEach(d => { + result[d] = d; + }); + dataProps.forEach(d => { + result[convertPropToDataAttr(d)] = d; + }); + return result; + } + static setPropsFromSelect(props) { + const $ele = props.ele; + const disabledOptions = []; + const selectedValue = []; + const getNativeOptions = $container => { + const options = []; + const $options = Array.from($container.children); + $options.forEach($option => { + const { + value + } = $option; + const option = { + value + }; + if ($option.tagName === 'OPTGROUP') { + option.label = $option.getAttribute('label'); + option.options = getNativeOptions($option); + } else { + option.label = $option.innerHTML; + } + options.push(option); + if ($option.disabled) { + disabledOptions.push(value); + } + if ($option.selected) { + selectedValue.push(value); } }); - return !hasError; - } - }, { - key: "reset", - value: function reset() { - var formReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var disableChangeEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - this.virtualSelect.reset(formReset, disableChangeEvent); - } - }, { - key: "setValueMethod", - value: function setValueMethod() { - var _this$virtualSelect; - (_this$virtualSelect = this.virtualSelect).setValueMethod.apply(_this$virtualSelect, arguments); - } - }, { - key: "setOptionsMethod", - value: function setOptionsMethod() { - var _this$virtualSelect2; - (_this$virtualSelect2 = this.virtualSelect).setOptionsMethod.apply(_this$virtualSelect2, arguments); - } - }, { - key: "setDisabledOptionsMethod", - value: function setDisabledOptionsMethod() { - var _this$virtualSelect3; - (_this$virtualSelect3 = this.virtualSelect).setDisabledOptionsMethod.apply(_this$virtualSelect3, arguments); - } - }, { - key: "setEnabledOptionsMethod", - value: function setEnabledOptionsMethod() { - var _this$virtualSelect4; - (_this$virtualSelect4 = this.virtualSelect).setEnabledOptionsMethod.apply(_this$virtualSelect4, arguments); - } - }, { - key: "toggleSelectAll", - value: function toggleSelectAll(isSelected) { - this.virtualSelect.toggleAllOptions(isSelected); - } - }, { - key: "isAllSelected", - value: function isAllSelected() { - return this.virtualSelect.isAllSelected; - } - }, { - key: "addOptionMethod", - value: function addOptionMethod(data) { - this.virtualSelect.addOption(data, true); - } - }, { - key: "getNewValueMethod", - value: function getNewValueMethod() { - return this.virtualSelect.getNewValue(); - } - }, { - key: "getDisplayValueMethod", - value: function getDisplayValueMethod() { - return this.virtualSelect.getDisplayValue(); - } - }, { - key: "getSelectedOptionsMethod", - value: function getSelectedOptionsMethod(params) { - return this.virtualSelect.getSelectedOptions(params); - } - }, { - key: "getDisabledOptionsMethod", - value: function getDisabledOptionsMethod() { - return this.virtualSelect.getDisabledOptions(); - } - }, { - key: "openMethod", - value: function openMethod() { - return this.virtualSelect.openDropbox(); - } - }, { - key: "closeMethod", - value: function closeMethod() { - return this.virtualSelect.closeDropbox(); - } - }, { - key: "focusMethod", - value: function focusMethod() { - return this.virtualSelect.focus(); - } - }, { - key: "enableMethod", - value: function enableMethod() { - return this.virtualSelect.enable(); - } - }, { - key: "disableMethod", - value: function disableMethod() { - return this.virtualSelect.disable(); - } - }, { - key: "destroyMethod", - value: function destroyMethod() { - return this.virtualSelect.destroy(); - } - }, { - key: "validateMethod", - value: function validateMethod() { - return this.virtualSelect.validate(); - } - }, { - key: "toggleRequiredMethod", - value: function toggleRequiredMethod(isRequired) { - return this.virtualSelect.toggleRequired(isRequired); - } - }, { - key: "onResizeMethod", - value: function onResizeMethod() { - document.querySelectorAll('.vscomp-ele-wrapper').forEach(function ($ele) { - $ele.parentElement.virtualSelect.onResize(); - }); + return options; + }; + const optionsList = getNativeOptions($ele); + + /** creating div element to initiate plugin and removing native element */ + const $newEle = document.createElement('div'); + DomUtils.setAttrFromEle($ele, $newEle, Object.keys(attrPropsMapping), valueLessProps); + $ele.parentNode.insertBefore($newEle, $ele); + $ele.remove(); + + // eslint-disable-next-line no-param-reassign + props.ele = $newEle; + // eslint-disable-next-line no-param-reassign + props.options = optionsList; + // eslint-disable-next-line no-param-reassign + props.disabledOptions = disabledOptions; + // eslint-disable-next-line no-param-reassign + props.selectedValue = selectedValue; + } + static onFormReset(e) { + const $form = e.target.closest('form'); + if (!$form) { + return; + } + $form.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + $ele.parentElement.virtualSelect.reset(true); + }); + } + static onFormSubmit(e) { + if (!VirtualSelect.validate(e.target.closest('form'))) { + e.preventDefault(); } - /** static methods - end */ - }]); -}(); + } + static validate($container) { + if (!$container) { + return true; + } + let hasError = false; + $container.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + const result = $ele.parentElement.virtualSelect.validate(); + if (!hasError && !result) { + hasError = true; + } + }); + return !hasError; + } + static reset(formReset = false, disableChangeEvent = false) { + this.virtualSelect.reset(formReset, disableChangeEvent); + } + static setValueMethod(...params) { + this.virtualSelect.setValueMethod(...params); + } + static setOptionsMethod(...params) { + this.virtualSelect.setOptionsMethod(...params); + } + static setDisabledOptionsMethod(...params) { + this.virtualSelect.setDisabledOptionsMethod(...params); + } + static setEnabledOptionsMethod(...params) { + this.virtualSelect.setEnabledOptionsMethod(...params); + } + static toggleSelectAll(isSelected) { + this.virtualSelect.toggleAllOptions(isSelected); + } + static isAllSelected() { + return this.virtualSelect.isAllSelected; + } + static addOptionMethod(data) { + this.virtualSelect.addOption(data, true); + } + static getNewValueMethod() { + return this.virtualSelect.getNewValue(); + } + static getDisplayValueMethod() { + return this.virtualSelect.getDisplayValue(); + } + static getSelectedOptionsMethod(params) { + return this.virtualSelect.getSelectedOptions(params); + } + static getDisabledOptionsMethod() { + return this.virtualSelect.getDisabledOptions(); + } + static openMethod() { + return this.virtualSelect.openDropbox(); + } + static closeMethod() { + return this.virtualSelect.closeDropbox(); + } + static focusMethod() { + return this.virtualSelect.focus(); + } + static enableMethod() { + return this.virtualSelect.enable(); + } + static disableMethod() { + return this.virtualSelect.disable(); + } + static destroyMethod() { + return this.virtualSelect.destroy(); + } + static validateMethod() { + return this.virtualSelect.validate(); + } + static toggleRequiredMethod(isRequired) { + return this.virtualSelect.toggleRequired(isRequired); + } + static onResizeMethod() { + document.querySelectorAll('.vscomp-ele-wrapper').forEach($ele => { + $ele.parentElement.virtualSelect.onResize(); + }); + } + /** static methods - end */ +} document.addEventListener('reset', VirtualSelect.onFormReset); document.addEventListener('submit', VirtualSelect.onFormSubmit); window.addEventListener('resize', VirtualSelect.onResizeMethod); diff --git a/docs/assets/virtual-select.min.css b/docs/assets/virtual-select.min.css index 0966e2a..48aa3d6 100644 --- a/docs/assets/virtual-select.min.css +++ b/docs/assets/virtual-select.min.css @@ -3,7 +3,7 @@ * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) */ -@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} +@keyframes vscomp-animation-spin{to{transform:rotateZ(360deg)}}.vscomp-popup-active{overflow:hidden !important}.vscomp-ele{display:inline-block;max-width:250px;width:100%}.vscomp-wrapper{color:#333;display:inline-flex;flex-wrap:wrap;font-family:sans-serif;font-size:14px;position:relative;text-align:left;width:100%}.vscomp-wrapper *,.vscomp-wrapper *::before,.vscomp-wrapper *::after{box-sizing:border-box}.vscomp-wrapper:focus{outline:none}.vscomp-dropbox-wrapper{left:0;position:absolute;top:0}.vscomp-toggle-button{align-items:center;background-color:#fff;border:1px solid #ddd;cursor:pointer;display:flex;padding:7px 30px 7px 10px;position:relative;width:100%}.vscomp-value{height:20px;line-height:20px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vscomp-arrow{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:30px}.vscomp-arrow::after{transform:rotate(45deg);border:1px solid rgba(0,0,0,0);border-bottom-color:#111;border-right-color:#111;content:"";height:8px;margin-top:-6px;width:8px}.vscomp-clear-icon{height:12px;position:relative;width:12px}.vscomp-clear-icon::before,.vscomp-clear-icon::after{background-color:#999;content:"";height:12px;left:5px;position:absolute;top:0;width:2px}.vscomp-clear-icon::before{transform:rotate(45deg)}.vscomp-clear-icon::after{transform:rotate(-45deg)}.vscomp-clear-icon:hover::before,.vscomp-clear-icon:hover::after{background:#333}.vscomp-clear-button{align-items:center;border-radius:50%;display:none;height:24px;justify-content:center;margin-top:-12px;position:absolute;right:30px;top:50%;width:24px}.vscomp-clear-button:hover{background:#ccc}.vscomp-clear-button:hover .vscomp-clear-icon::before,.vscomp-clear-button:hover .vscomp-clear-icon::after{background-color:#333}.vscomp-dropbox-close-button{align-items:center;background-color:#fff;border-radius:50%;bottom:-48px;cursor:pointer;display:none;height:40px;justify-content:center;left:50%;margin-left:-20px;position:absolute;width:40px}.vscomp-value-tag.more-value-count{white-space:nowrap}.vscomp-dropbox-container{width:100%;z-index:2}.vscomp-dropbox{background-color:#fff;width:100%}.vscomp-options-container{max-height:210px;overflow:auto;position:relative}.vscomp-options-bottom-freezer{bottom:0;height:2px;left:0;position:absolute;right:0}.vscomp-option{align-items:center;cursor:pointer;display:flex;flex-wrap:wrap;height:40px;padding:0 15px;position:relative}.vscomp-option.selected{background-color:#eee}.vscomp-option.focused{background-color:#ccc}.vscomp-option.disabled{cursor:default;opacity:.5}.vscomp-option.group-title .vscomp-option-text{cursor:default;opacity:.6}.vscomp-option.group-title.selected{background-color:rgba(0,0,0,0)}.vscomp-option.group-option{padding-left:30px}.vscomp-new-option-icon{height:30px;position:absolute;right:0;top:0;width:30px}.vscomp-new-option-icon::before{border:15px solid #512da8;border-bottom-color:rgba(0,0,0,0);border-left-color:rgba(0,0,0,0);content:"";position:absolute;right:0;top:0}.vscomp-new-option-icon::after{align-items:center;color:#fff;content:"+";display:flex;font-size:18px;height:15px;justify-content:center;position:absolute;right:1px;top:0;width:15px}.vscomp-option-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-user-select:none;user-select:none;width:100%}.vscomp-option-description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#666;font-size:13px;line-height:15px;width:100%}.vscomp-search-container{align-items:center;border-bottom:1px solid #ddd;display:flex;height:40px;padding:0 5px 0 15px;position:relative}.vscomp-search-label,.vscomp-live-region,.vscomp-dropbox-container-top,.vscomp-dropbox-container-bottom{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.vscomp-search-input{background-color:rgba(0,0,0,0);border:0;color:inherit;font-size:15px;height:38px;padding:10px 0;width:calc(100% - 30px)}.vscomp-search-input:focus{outline:none}.vscomp-search-clear{align-items:center;color:#999;cursor:pointer;display:flex;font-size:25px;height:30px;justify-content:center;-webkit-user-select:none;user-select:none;visibility:hidden;width:30px}.vscomp-search-clear:hover{color:inherit}.vscomp-no-options,.vscomp-no-search-results{align-items:center;display:none;justify-content:center;padding:20px 10px}.vscomp-options-loader{display:none;padding:20px 0;text-align:center}.vscomp-options-loader::before{animation:vscomp-animation-spin .8s infinite linear;background-color:#fff;border-radius:50%;box-shadow:-4px -5px 3px -3px rgba(0,0,0,.3);content:"";display:inline-block;height:40px;opacity:.7;width:40px}.vscomp-ele[disabled]{cursor:not-allowed;-webkit-user-select:none;user-select:none}.vscomp-ele[disabled] .vscomp-wrapper{opacity:.7;pointer-events:none}.vscomp-wrapper .checkbox-icon{display:inline-flex;height:15px;margin-right:10px;position:relative;width:15px}.vscomp-wrapper .checkbox-icon::after{transition-duration:.2s;border:2px solid #888;content:"";display:inline-block;height:100%;width:100%}.vscomp-wrapper .checkbox-icon.checked::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-container{align-items:center;background-color:rgba(0,0,0,.5);display:flex;height:100vh;justify-content:center;left:0;opacity:1;overflow:auto;padding:0 10px;position:fixed;top:0;width:100vw}.vscomp-wrapper.show-as-popup .vscomp-dropbox{margin-top:-24px;max-height:calc(80% - 48px);max-width:500px;position:relative;width:80%}.vscomp-wrapper.show-as-popup .vscomp-dropbox-close-button{display:flex}.vscomp-wrapper.popup-position-left .vscomp-dropbox-container{justify-content:flex-start}.vscomp-wrapper.popup-position-right .vscomp-dropbox-container{justify-content:flex-end}.vscomp-wrapper.has-select-all .vscomp-toggle-all-button{align-items:center;cursor:pointer;display:flex}.vscomp-wrapper.has-select-all .vscomp-search-input,.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{width:calc(100% - 55px)}.vscomp-wrapper.has-select-all .vscomp-toggle-all-label{display:none}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-button{width:100%}.vscomp-wrapper:not(.has-search-input) .vscomp-toggle-all-label{display:inline-block}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-text{width:calc(100% - 25px)}.vscomp-wrapper.multiple .vscomp-option .vscomp-option-description{padding-left:25px}.vscomp-wrapper.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(1px, -4px);border-color:#512da8;border-left-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);width:50%}.vscomp-wrapper.focused .vscomp-toggle-button,.vscomp-wrapper:focus .vscomp-toggle-button{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.closed .vscomp-dropbox-container,.vscomp-wrapper.closed.vscomp-dropbox-wrapper{display:none}.vscomp-wrapper:not(.has-value) .vscomp-value{opacity:.5}.vscomp-wrapper.has-clear-button.has-value .vscomp-clear-button{display:flex}.vscomp-wrapper.has-clear-button .vscomp-toggle-button{padding-right:54px}.vscomp-wrapper.has-no-options .vscomp-options-container,.vscomp-wrapper.has-no-search-results .vscomp-options-container{display:none}.vscomp-wrapper.has-no-options .vscomp-no-options{display:flex}.vscomp-wrapper.has-no-search-results .vscomp-no-search-results{display:flex}.vscomp-wrapper.has-search-value .vscomp-search-clear{visibility:visible}.vscomp-wrapper.has-no-options .vscomp-toggle-all-button{opacity:.5;pointer-events:none}.vscomp-wrapper.keep-always-open .vscomp-toggle-button{padding-right:24px}.vscomp-wrapper.keep-always-open .vscomp-clear-button{right:5px}.vscomp-wrapper.keep-always-open .vscomp-arrow{display:none}.vscomp-wrapper.keep-always-open .vscomp-dropbox-container{position:relative;z-index:1}.vscomp-wrapper.keep-always-open .vscomp-dropbox{transition-duration:0s;border:1px solid #ddd;box-shadow:none}.vscomp-wrapper.keep-always-open.focused,.vscomp-wrapper.keep-always-open:focus,.vscomp-wrapper.keep-always-open:hover{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.12),0 1px 5px 0 rgba(0,0,0,.2)}.vscomp-wrapper.server-searching .vscomp-options-list{display:none}.vscomp-wrapper.server-searching .vscomp-options-loader{display:block}.vscomp-wrapper.has-error .vscomp-toggle-button{border-color:#b00020}.vscomp-wrapper.show-value-as-tags .vscomp-toggle-button{padding:4px 22px 0 10px}.vscomp-wrapper.show-value-as-tags .vscomp-value{display:flex;flex-wrap:wrap;height:auto;min-height:28px;overflow:auto;text-overflow:unset;white-space:normal}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;align-items:center;border:1px solid #ddd;border-radius:20px;display:inline-flex;font-size:12px;line-height:16px;margin:0 4px 4px 0;max-width:100%;padding:2px 3px 2px 8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag.more-value-count{padding-right:8px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button{align-items:center;display:flex;height:20px;justify-content:center;width:20px}.vscomp-wrapper.show-value-as-tags .vscomp-value-tag-clear-button .vscomp-clear-icon{transform:scale(0.8)}.vscomp-wrapper.show-value-as-tags .vscomp-arrow{height:34px}.vscomp-wrapper.show-value-as-tags .vscomp-clear-button{margin-top:0;top:5px}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-arrow{display:none}.vscomp-wrapper.show-value-as-tags.has-value .vscomp-clear-button{right:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-toggle-button{padding-bottom:2px}.vscomp-wrapper.show-value-as-tags:not(.has-value) .vscomp-value{align-items:center;padding-bottom:3px}.vscomp-wrapper.text-direction-rtl{direction:rtl}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-button{padding:7px 10px 7px 30px}.vscomp-wrapper.text-direction-rtl .vscomp-arrow{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-clear-button{left:30px;right:auto !important}.vscomp-wrapper.text-direction-rtl .checkbox-icon{margin-left:10px;margin-right:0}.vscomp-wrapper.text-direction-rtl .checkbox-icon.checked::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl .vscomp-search-container{padding:0 15px 0 5px}.vscomp-wrapper.text-direction-rtl .vscomp-toggle-all-label{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option{text-align:right}.vscomp-wrapper.text-direction-rtl .vscomp-option.group-option{padding-right:30px}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon{left:0;right:auto}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::before{border-left-color:#512da8;border-right-color:rgba(0,0,0,0)}.vscomp-wrapper.text-direction-rtl .vscomp-new-option-icon::after{left:1px;right:auto}.vscomp-wrapper.text-direction-rtl.multiple .vscomp-option.selected .checkbox-icon::after{transform:rotate(45deg) translate(-4px, 1px)}.vscomp-wrapper.text-direction-rtl.has-clear-button .vscomp-toggle-button{padding-left:54px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-toggle-button{padding-left:24px}.vscomp-wrapper.text-direction-rtl.keep-always-open .vscomp-clear-button{left:5px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-toggle-button{padding:4px 10px 0 22px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag{margin:0 0 4px 4px;padding:2px 8px 2px 3px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags .vscomp-value-tag.more-value-count{padding-left:8px}.vscomp-wrapper.text-direction-rtl.show-value-as-tags.has-value .vscomp-clear-button{left:2px} /*! * Popover v1.0.13 * https://sa-si-dev.github.io/popover diff --git a/docs/assets/virtual-select.min.js b/docs/assets/virtual-select.min.js index 8c5129e..169586d 100644 --- a/docs/assets/virtual-select.min.js +++ b/docs/assets/virtual-select.min.js @@ -2,4 +2,4 @@ * Virtual Select v1.1.5 * https://sa-si-dev.github.io/virtual-select * Licensed under MIT (https://github.com/sa-si-dev/virtual-select/blob/master/LICENSE) - */!function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);i1&&void 0!==arguments[1]&&arguments[1]}},{key:"isEmpty",value:function(e){var t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"===i(e)&&0===Object.keys(e).length&&(t=!0):t=!0,t}},{key:"isNotEmpty",value:function(e){return!t.isEmpty(e)}},{key:"normalizeValues",value:function(e){if(Array.isArray(e)){for(var t=new Array(e.length),i=0;i2&&void 0!==arguments[2]&&arguments[2];if(!Array.isArray(t)||!t.length)return t;var s=o?e(t):t,n=s.indexOf(i);return-1!==n&&s.splice(n,1),s}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"getRandomInt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),o=Math.floor(e);return Math.floor(Math.random()*(o-i-1))+i}},{key:"regexEscape",value:function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}},{key:"normalizeString",value:function(e){return e.normalize("NFD").replace(/[^\w]/g,"")}},{key:"willTextOverflow",value:function(e,t){var i=document.createElement("div");i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="nowrap",i.style.fontSize=window.getComputedStyle(e).fontSize,i.style.fontFamily=window.getComputedStyle(e).fontFamily,i.textContent=t,document.body.appendChild(i);var o=i.clientWidth;return document.body.removeChild(i),o>e.clientWidth}},{key:"replaceDoubleQuotesWithHTML",value:function(e){return e.replace(/"/g,""")}},{key:"containsHTML",value:function(e){return/<[a-z][\s\S]*>/i.test(e)}},{key:"containsHTMLorJS",value:function(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}],(n=null)&&o(s.prototype,n),r&&o(s,r),Object.defineProperty(s,"prototype",{writable:!1}),s;var s,n,r}();function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o,s,n,r,a=[],l=!0,u=!1;try{if(n=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(o=n.call(i)).done)&&(a.push(o.value),a.length!==t);l=!0);}catch(e){u=!0,s=e}finally{try{if(!l&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(u)throw s}}return a}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"==typeof e)return c(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=Array(t);ie.offsetWidth}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setAttr",value:function(e,t,i){e&&e.setAttribute(t,i)}},{key:"setAttrFromEle",value:function(e,t,i,o){var s={};i.forEach(function(t){s[t]=e.getAttribute(t)}),i.forEach(function(e){var i=s[e];(i||-1!==o.indexOf(e)&&""===i)&&t.setAttribute(e,i)})}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"setStyles",value:function(e,t){e&&t&&Object.keys(t).forEach(function(i){e.style[i]=t[i]})}},{key:"setAria",value:function(e,t,i){if(e){var o=t;"role"!==o&&(o="aria-".concat(o)),e.setAttribute(o,i)}}},{key:"getElements",value:function(e){return e?void 0===e.forEach?[e]:e:[]}},{key:"getElementsBySelector",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=void 0!==i?i:document;return""!==t&&(e=o.querySelectorAll(t)),void 0!==e?Array.from(e):[]}},{key:"addEvent",value:function(t,i,o,s){t&&n.removeArrayEmpty(i.split(" ")).forEach(function(i){e.getElements(t).forEach(function(e){e.addEventListener(i,o,{capture:s})})})}},{key:"dispatchEvent",value:function(t,i){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t){var s=e.getElements(t);setTimeout(function(){s.forEach(function(e){e.dispatchEvent(new CustomEvent(i,{bubbles:o}))})},0)}}},{key:"getAttributesText",value:function(e){var t="";return e?(Object.entries(e).forEach(function(e){var i=a(e,2),o=i[0],s=i[1];void 0!==s&&(t+=" ".concat(o,'="').concat(s,'" '))}),t):t}},{key:"convertPropToDataAttr",value:function(e){return e?"data-".concat(e).replace(/([A-Z])/g,"-$1").toLowerCase():""}},{key:"changeTabIndex",value:function(t,i){t?e.getElements(t).forEach(function(e){e.tabIndex=i}):console.log(t,"Invalid element provided.")}},{key:"removeEvent",value:function(t,i,o){t&&e.getElements(t).forEach(function(e){e.removeEventListener(i,o)})}}],(i=null)&&p(t.prototype,i),o&&p(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,o)}return i}function f(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,o=Array(t);i\n \n
\n
\n ").concat(this.placeholder,'\n
\n
\n
\n \n
\n
\n\n ').concat(this.renderDropbox({wrapperClasses:t}),"\n ");this.$ele.innerHTML=u,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),d.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}}},{key:"renderDropbox",value:function(e){var t=e.wrapperClasses,i="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null,o="vscomp-dropbox";this.additionalDropboxClasses&&(o+=" ".concat(this.additionalDropboxClasses));var s="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(s+=" ".concat(this.additionalDropboxContainerClasses));var n='
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
').concat(this.noOptionsText,'
\n
').concat(this.noSearchResultsText,'
\n\n \n
\n \n
');if(i){var r=document.createElement("div");return this.$dropboxWrapper=r,this.hasDropboxWrapper=!0,r.innerHTML=n,i.appendChild(r),d.addClass(r,"vscomp-dropbox-wrapper ".concat(t)),this.keepAlwaysOpen||(d.setAttr(r,"tabindex","-1"),d.setAria(r,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}},{key:"renderOptions",value:function(){var e=this;this.calculateAriaMetadata();var t,i="",o=this.getVisibleOptions(),s="",r="",a=!(!this.markSearchResults||!this.searchValue),l=this.labelRenderer,u=this.disableOptionGroupCheckbox,c=this.uniqueId,p=this.searchGroup,h="function"==typeof l,d=n.convertToBoolean,v="";if(a&&(t=new RegExp("(".concat(n.regexEscape(this.searchValue),")(?!([^<]+)?>)"),"gi")),this.multiple&&(s=''),this.allowNewOption){var f=this.getTooltipAttrText("New Option");r='")}o.forEach(function(o){var n,f=o.index,b="vscomp-option",y=e.getTooltipAttrText("",!0,!0),m=s,g="",O="",S="",x="",w="-1",k=d(o.isSelected),C="";if(o.classNames&&(b+=" ".concat(o.classNames)),o.isFocused&&(w="0",b+=" focused"),o.isDisabled&&(b+=" disabled",C='aria-disabled="true"'),o.isGroupTitle&&(v=o.label,b+=" group-title",u&&(m="")),k&&(b+=" selected"),o.isGroupOption){var E="";b+=" group-option",S='data-group-index="'.concat(o.groupIndex,'"'),o.customData?(v=void 0!==o.customData.group_name?"".concat(o.customData.group_name,", "):"",E=void 0!==o.customData.description?" ".concat(o.customData.description,","):"",x='aria-label="'.concat(v," ").concat(o.label,", ").concat(E,'"')):x='aria-label="'.concat(v,", ").concat(o.label,'"')}n=h?l(o):o.label,o.description&&(O='
").concat(o.description,"
")),o.isCurrentNew?(b+=" current-new",g+=r):!a||o.isGroupTitle&&!p||(n=n.replace(t,"$1"));var $="";e.ariaSetSize>0&&($='aria-setsize="'.concat(e.ariaSetSize,'"'),o.filteredIndex&&($+=' aria-posinset="'.concat(o.filteredIndex,'"'))),i+='
\n ").concat(n,"\n \n ").concat(O,"\n ").concat(g,"\n
")}),v="",this.$options.innerHTML=i,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}},{key:"renderSearch",value:function(){if(this.hasSearchContainer){var e="",t="";if(this.multiple&&!this.disableSelectAll&&(e='\n \n ').concat(this.selectAllText,"\n ")),this.hasSearch){var i=this.ariaLabelSearchClearButtonText?'aria-label="'.concat(this.ariaLabelSearchClearButtonText,'"'):"";t='\n \n ×")}var o='
\n '.concat(e,"\n ").concat(t,"\n
");this.$search.innerHTML=o,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}}},{key:"addEvents",value:function(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}},{key:"addEvent",value:function(e,t,i){var o=this,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var n="".concat(i,"-").concat(t),r=o.events[n];r||(r=o[i].bind(o),o.events[n]=r),d.addEvent(e,t,r,s)})}},{key:"removeEvents",value:function(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}},{key:"removeEvent",value:function(e,t,i){var o=this;e&&n.removeArrayEmpty(t.split(" ")).forEach(function(t){var s="".concat(i,"-").concat(t),n=o.events[s];n&&d.removeEvent(e,t,n)})}},{key:"onDocumentClick",value:function(t){var i=t.target.closest(".vscomp-wrapper");if(i){var o=i.parentElement.virtualSelect;o&&o!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}else e.openInstances.forEach(function(e){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()})}},{key:"onKeyDown",value:function(e){var t=e.which||e.keyCode,i=C[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){var o=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(o&&(document.activeElement===o||o.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}i&&this[i](e)}else this.toggleAllOptions()}},{key:"onEnterPress",value:function(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}},{key:"onDownArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}},{key:"onUpArrowPress",value:function(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}},{key:"onBackspaceOrDeletePress",value:function(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}},{key:"onToggleButtonPress",value:function(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}var t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}},{key:"onClearButtonClick",value:function(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}},{key:"onOptionsScroll",value:function(){this.setVisibleOptions(!0)}},{key:"onOptionsClick",value:function(e){var t=e.target.closest(".vscomp-option");t&&!d.hasClass(t,"disabled")&&(d.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}},{key:"onGroupTitleClick",value:function(e){if(e&&this.multiple&&!this.disableOptionGroupCheckbox){var t=!d.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}}},{key:"onDropboxContainerClick",value:function(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}},{key:"onDropboxCloseButtonClick",value:function(){this.closeDropbox()}},{key:"onOptionsMouseOver",value:function(e){var t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(d.hasClass(t,"disabled")||d.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}},{key:"onOptionsTouchMove",value:function(){this.removeOptionFocus()}},{key:"onSearch",value:function(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}},{key:"preventPropagation",value:function(e){e.stopPropagation()}},{key:"onSearchClear",value:function(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}},{key:"onToggleAllOptions",value:function(){this.toggleAllOptions()}},{key:"onDropboxContainerTopOrBottomFocus",value:function(){this.closeDropbox()}},{key:"onResize",value:function(){this.setOptionsContainerHeight(!0)}},{key:"addMutationObserver",value:function(){var e=this;if(this.hasDropboxWrapper){var t=this.$ele;this.mutationObserver=new MutationObserver(function(i){var o=!1,s=!1;i.forEach(function(e){o||(o=g(e.addedNodes).some(function(e){return!(e!==t&&!e.contains(t))})),s||(s=g(e.removedNodes).some(function(e){return!(e!==t&&!e.contains(t))}))}),s&&!o&&e.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}}},{key:"removeMutationObserver",value:function(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}},{key:"beforeValueSet",value:function(e){this.toggleAllOptionsClass(!e&&void 0)}},{key:"beforeSelectNewValue",value:function(e){var t=this,i=this.getNewOption();if(i){var o=i.index;this.newValues.push(i.value),this.setOptionProp(o,"isCurrentNew",!1),this.setOptionProp(o,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(function(){t.setSearchValue(""),t.focusSearchInput()},0)}},{key:"afterRenderWrapper",value:function(){d.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}},{key:"afterRenderOptions",value:function(){var e=this,t=this.getVisibleOptions(),i=!this.options.length&&!this.hasServerSearch,o=!i&&!t.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(d.toggleClass(this.$allWrappers,"has-no-search-results",o),o?(d.setAttr(this.$noSearchResults,"tabindex","0"),d.setAttr(this.$noSearchResults,"aria-hidden","false")):(d.setAttr(this.$noSearchResults,"tabindex","-1"),d.setAttr(this.$noSearchResults,"aria-hidden","true"))),d.toggleClass(this.$allWrappers,"has-no-options",i),i?(d.setAttr(this.$noOptions,"tabindex","0"),d.setAttr(this.$noOptions,"aria-hidden","false")):(d.setAttr(this.$noOptions,"tabindex","-1"),d.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(function(){var t=d.getElementsBySelector(".focused",e.$dropboxContainer)[0];void 0!==t&&t.focus({preventScroll:!0})},20)}},{key:"afterSetOptionsContainerHeight",value:function(e){e&&this.showAsPopup&&this.setVisibleOptions()}},{key:"afterSetSearchValue",value:function(){var e=this;this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(function(){e.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}},{key:"afterSetVisibleOptionsCount",value:function(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}},{key:"afterValueSet",value:function(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}},{key:"afterSetOptions",value:function(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}},{key:"setProps",value:function(e){var t=this.setDefaultProps(e);this.setPropsFromElementAttr(t);var i=n.convertToBoolean;this.$ele=t.ele,this.dropboxWrapper=t.dropboxWrapper,this.valueKey=t.valueKey,this.labelKey=t.labelKey,this.descriptionKey=t.descriptionKey,this.aliasKey=t.aliasKey,this.optionHeightText=t.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(t.multiple),this.hasSearch=i(t.search),this.searchByStartsWith=i(t.searchByStartsWith),this.searchGroup=i(t.searchGroup),this.hideClearButton=i(t.hideClearButton),this.autoSelectFirstOption=i(t.autoSelectFirstOption),this.hasOptionDescription=i(t.hasOptionDescription),this.silentInitialValueSet=i(t.silentInitialValueSet),this.allowNewOption=i(t.allowNewOption),this.markSearchResults=i(t.markSearchResults),this.showSelectedOptionsFirst=i(t.showSelectedOptionsFirst),this.disableSelectAll=i(t.disableSelectAll),this.keepAlwaysOpen=i(t.keepAlwaysOpen),this.showDropboxAsPopup=i(t.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(t.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(t.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(t.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(t.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(t.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(t.disableAllOptionsSelectedText),this.showValueAsTags=i(t.showValueAsTags),this.disableOptionGroupCheckbox=i(t.disableOptionGroupCheckbox),this.enableSecureText=i(t.enableSecureText),this.setValueAsArray=i(t.setValueAsArray),this.disableValidation=i(t.disableValidation),this.initialDisabled=i(t.disabled),this.required=i(t.required),this.autofocus=i(t.autofocus),this.useGroupValue=i(t.useGroupValue),this.focusSelectedOptionOnOpen=i(t.focusSelectedOptionOnOpen),this.noOptionsText=t.noOptionsText,this.noSearchResultsText=t.noSearchResultsText,this.selectAllText=t.selectAllText,this.searchNormalize=t.searchNormalize,this.searchPlaceholderText=t.searchPlaceholderText,this.searchFormLabel=t.searchFormLabel,this.optionsSelectedText=t.optionsSelectedText,this.optionSelectedText=t.optionSelectedText,this.allOptionsSelectedText=t.allOptionsSelectedText,this.clearButtonText=t.clearButtonText,this.moreText=t.moreText,this.placeholder=t.placeholder,this.position=t.position,this.textDirection=t.textDirection,this.dropboxWidth=t.dropboxWidth,this.tooltipFontSize=t.tooltipFontSize,this.tooltipAlignment=t.tooltipAlignment,this.tooltipMaxWidth=t.tooltipMaxWidth,this.updatePositionThrottle=t.updatePositionThrottle,this.noOfDisplayValues=parseInt(t.noOfDisplayValues),this.zIndex=parseInt(t.zIndex),this.maxValues=parseInt(t.maxValues),this.minValues=parseInt(t.minValues),this.name=this.secureText(t.name),this.additionalClasses=t.additionalClasses,this.additionalDropboxClasses=t.additionalDropboxClasses,this.additionalDropboxContainerClasses=t.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=t.additionalToggleButtonClasses,this.popupDropboxBreakpoint=t.popupDropboxBreakpoint,this.popupPosition=t.popupPosition,this.onServerSearch=t.onServerSearch,this.labelRenderer=t.labelRenderer,this.selectedLabelRenderer=t.selectedLabelRenderer,this.initialSelectedValue=0===t.selectedValue?"0":t.selectedValue,this.emptyValue=t.emptyValue,this.ariaLabelText=t.ariaLabelText,this.ariaLabelledby=t.ariaLabelledby,this.ariaLabelClearButtonText=t.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=t.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=t.ariaLabelSearchClearButtonText,this.maxWidth=t.maxWidth,this.searchDelay=t.searchDelay,this.showDuration=parseInt(t.showDuration),this.hideDuration=parseInt(t.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===t.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(t.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}},{key:"setDefaultProps",value:function(e){var t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}},{key:"setPropsFromElementAttr",value:function(e){var t=e.ele;Object.keys(k).forEach(function(i){var o=t.getAttribute(i);-1===E.indexOf(i)||""!==o&&"true"!==o||(o=!0),o&&(e[k[i]]=o)})}},{key:"setEleProps",value:function(){var t=this.$ele;t.virtualSelect=this,t.value=this.multiple?[]:"",t.name=this.name,t.disabled=!1,t.required=this.required,t.autofocus=this.autofocus,t.multiple=this.multiple,t.form=t.closest("form"),t.reset=e.reset,t.setValue=e.setValueMethod,t.setOptions=e.setOptionsMethod,t.setDisabledOptions=e.setDisabledOptionsMethod,t.setEnabledOptions=e.setEnabledOptionsMethod,t.toggleSelectAll=e.toggleSelectAll,t.isAllSelected=e.isAllSelected,t.addOption=e.addOptionMethod,t.getNewValue=e.getNewValueMethod,t.getDisplayValue=e.getDisplayValueMethod,t.getSelectedOptions=e.getSelectedOptionsMethod,t.getDisabledOptions=e.getDisabledOptionsMethod,t.open=e.openMethod,t.close=e.closeMethod,t.focus=e.focusMethod,t.enable=e.enableMethod,t.disable=e.disableMethod,t.destroy=e.destroyMethod,t.validate=e.validateMethod,t.toggleRequired=e.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}},{key:"setValueMethod",value:function(e,t){var i={},o={},s=[],r=this.multiple,a=n.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){var l=this.maxValues;l&&a.length>l&&a.splice(l)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach(function(e,t){i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}if(this.options.forEach(function(e){var t=n.normalizeValues(e.value);!0!==i[t]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,s.push(e.value))}),r)this.hasOptionGroup&&this.setGroupsSelectedProp(),s.sort(function(e,t){return o[n.normalizeValues(e)]-o[n.normalizeValues(t)]});else{var u=m(s,1);s=u[0]}this.beforeValueSet(),this.setValue(s,{disableEvent:t}),this.afterValueSet()}},{key:"setGroupOptionsValue",value:function(e){var t=[],i={},o={};return e.forEach(function(e){o[e]=!0}),this.options.forEach(function(e){var s=e.value,n=!0===o[s];e.isGroupTitle?n&&(i[e.index]=!0):(n||i[e.groupIndex])&&t.push(s)}),t}},{key:"setGroupsSelectedProp",value:function(){var e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(function(t){t.isGroupTitle&&(t.isSelected=e(t.index))})}},{key:"setOptionsMethod",value:function(e,t){this.setOptions(e),this.afterSetOptions(t)}},{key:"setDisabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setDisabledOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];if(e)if(!0===e)t&&this.options.forEach(function(e){return e.isDisabled=!0,i.push(e.value),e});else{i=e.map(function(e){return e.toString()});var o={};i.forEach(function(e){o[e]=!0}),t&&this.options.forEach(function(e){return e.isDisabled=!0===o[e.value],e})}else t&&this.options.forEach(function(e){return e.isDisabled=!1,e});this.disabledOptions=i}},{key:"setEnabledOptionsMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}},{key:"setEnabledOptions",value:function(e){if(void 0!==e){var t=[];if(!0===e)this.options.forEach(function(e){return e.isDisabled=!1,e});else{var i={};e.forEach(function(e){i[e]=!0}),this.options.forEach(function(e){var o=!0!==i[e.value];return e.isDisabled=o,o&&t.push(e.value),e})}this.disabledOptions=t}}},{key:"setOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=[],o=this.disabledOptions.length,s=this.valueKey,r=this.labelKey,a=this.descriptionKey,l=this.aliasKey,u=this.hasOptionDescription,c=n.getString,p=n.convertToBoolean,h=this.secureText.bind(this),d=this.getAlias.bind(this),v=0,f=!1,m={},g=!1;this.disabledOptions.forEach(function(e){m[e]=!0});var O=function(t){"object"!==y(t)&&(t=b(b({},s,t),r,t));var S=h(c(t[s])),x=h(c(t[r])),w=t.options,k=!!w,C={index:v,value:S,valueNormalized:S.toLowerCase(),label:x,labelNormalized:e.searchNormalize&&""!==x.trim()?n.normalizeString(x).toLowerCase():x.toLowerCase(),alias:d(t[l]),isVisible:p(t.isVisible,!0),isNew:t.isNew||!1,isGroupTitle:k,classNames:t.classNames};if(g||""!==S||(g=!0),o&&(C.isDisabled=!0===m[S]),t.isGroupOption&&(C.isGroupOption=!0,C.groupIndex=t.groupIndex),u){var E=h(c(t[a]));C.description=E,C.descriptionNormalized=e.searchNormalize&&""!==E.trim()?n.normalizeString(E).toLowerCase():E.toLowerCase()}if(t.customData&&(C.customData=t.customData),i.push(C),v+=1,k){var $=C.index;f=!0,w.forEach(function(e){e.isGroupOption=!0,e.groupIndex=$,O(e)})}};Array.isArray(t)&&t.forEach(O);var S=i.length,x=this.$ele;x.options=i,x.length=S,this.options=i,this.visibleOptionsCount=S,this.lastOptionIndex=S-1,this.newValues=[],this.hasOptionGroup=f,this.hasEmptyValueOption=g,this.setSortedOptions()}},{key:"setServerOptions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.setOptionsMethod(t,!0);var i=this.selectedOptions,o=this.options,s=!1;if(i.length){var n={};s=!0,o.forEach(function(e){n[e.value]=!0}),i.forEach(function(e){!0!==n[e.value]&&(e.isVisible=!1,o.push(e))}),this.setOptionsMethod(o,!0)}this.allowNewOption&&this.searchValue&&(o.some(function(t){return t.label.toLowerCase()===e.searchValue})||(s=!0,this.setNewOption())),s?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),d.removeClass(this.$allWrappers,"server-searching")}},{key:"setSelectedOptions",value:function(){this.selectedOptions=this.options.filter(function(e){return e.isSelected})}},{key:"setSortedOptions",value:function(){var e=g(this.options);this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}},{key:"setVisibleOptions",value:function(){var e=g(this.sortedOptions),t=2*this.optionsCount,i=this.getVisibleStartIndex(),o=this.getNewOption(),s=i+t-1,n=0;o&&(o.visibleIndex=n,n+=1),e=e.filter(function(e){var t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=i&&n<=s,e.visibleIndex=n,n+=1),t}),o&&(e=[o].concat(g(e))),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}},{key:"setOptionsPosition",value:function(e){var t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform="translate3d(0, ".concat(t,"px, 0)"),d.setData(this.$options,"top",t)}},{key:"setOptionsTooltip",value:function(){var e=this,t=this.getVisibleOptions(),i=this.hasOptionDescription;t.forEach(function(t){var o=e.$dropboxContainer.querySelector('.vscomp-option[data-index="'.concat(t.index,'"]'));d.setData(o.querySelector(".vscomp-option-text"),"tooltip",t.label),i&&d.setData(o.querySelector(".vscomp-option-description"),"tooltip",t.description)})}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.disableEvent,o=void 0!==i&&i,s=t.disableValidation,r=void 0!==s&&s,a=n.normalizeValues(e);this.hasEmptyValueOption&&""===a||a?Array.isArray(a)?this.selectedValues=g(a):this.selectedValues=[a]:this.selectedValues=[];var l=this.getValue();this.$ele.value=l,this.$hiddenInput.value=this.getInputValue(l),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();var u=n.isNotEmpty(this.selectedValues);d.toggleClass(this.$allWrappers,"has-value",u),d.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),d.setAttr(this.$clearButton,"tabindex",u?"0":"-1"),d.setAria(this.$clearButton,"hidden",!1===u),r||this.validate(),o||d.dispatchEvent(this.$ele,"change",!0)}},{key:"setValueText",value:function(){var e=this,t=this.multiple,i=this.selectedValues,o=this.noOfDisplayValues,s=this.showValueAsTags,r=this.$valueText,a=this.selectedLabelRenderer,l=[],u=[],c=i.length,p=0,h=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!s;if(h&&this.hideValueTooltipOnSelectAll)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(function(t){if(t.isCurrentNew)return!1;if(p>=o)return!0;var i=t.label;if("function"==typeof a&&(i=a(t)),l.push(i),p+=1,s){var c=n.willTextOverflow(r.parentElement,i)?e.getTooltipAttrText(i,!1,!0):"",h="";if(e.ariaLabelTagClearButtonText){var d=i.replace(/<[^>]+>/gi,"").trim();h='aria-label="'.concat(d,", ").concat(e.ariaLabelTagClearButtonText,'"')}var v='\n ').concat(i,'\n \n \n \n ');u.push(v)}else u.push(i);return!1});var v=c-o;v>0&&u.push('+ '.concat(v," ").concat(this.moreText,""));var f=l.join(", ");if(""===f)r.innerHTML=this.placeholder;else if(r.innerHTML=f,t){var b=this.maxValues;if(this.alwaysShowSelectedOptionsCount||d.hasEllipsis(r)||b||s){var y=''.concat(c,"");if(b&&(y+=' / '.concat(b,"")),h)r.innerHTML="".concat(this.allOptionsSelectedText," (").concat(c,")");else if(s)r.innerHTML=u.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){var m=1===c?this.optionSelectedText:this.optionsSelectedText;r.innerHTML="".concat(y," ").concat(m)}}else u=[]}}var g="";0===c?g=this.placeholder:s||(g=u.join(", ")),s||d.setData(r,"tooltip",g),t&&(s?this.updatePosition():d.setData(r,"tooltipEllipsisOnly",0===c))}},{key:"setSearchValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e!==this.searchValueOriginal||i){t||(this.$searchInput.value=e);var o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,d.toggleClass(this.$allWrappers,"has-search-value",e),d.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),d.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}}},{key:"setVisibleOptionsCount",value:function(){var e,t=0,i=!1,o=this.searchGroup,s=this.showOptionsOnlyOnSearch,r=this.searchByStartsWith,a=this.searchValue;a=this.searchNormalize&&""!==a.trim()?n.normalizeString(a):a;var l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(function(n){var u;n.isCurrentNew||(s&&!a?(n.isVisible=!1,u={isVisible:!1,hasExactOption:!1}):u=l({data:n,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),u.isVisible&&(t+=1),i||(i=u.hasExactOption))}),this.allowNewOption&&(a&&!i?(this.setNewOption(),t+=1):this.removeNewOption()),this.visibleOptionsCount=t,this.afterSetVisibleOptionsCount()}},{key:"calculateAriaMetadata",value:function(){var e=this,t=0,i=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(function(o){if(o.isCurrentNew)o.filteredIndex=void 0;else if(!0===o.isVisible){var s=o.isGroupTitle&&e.multiple&&!e.disableOptionGroupCheckbox;!o.isGroupTitle||s?(i+=1,t+=1,o.filteredIndex=i):o.filteredIndex=void 0}else o.filteredIndex=void 0}),this.allowNewOption){var o=this.getNewOption();o&&!0===o.isVisible?(i+=1,t+=1,o.filteredIndex=i):o&&(o.filteredIndex=void 0)}this.ariaSetSize=t}},{key:"setOptionProp",value:function(e,t,i){this.options[e]&&(this.options[e][t]=i)}},{key:"setOptionsHeight",value:function(){this.$optionsList.style.height="".concat(this.optionHeight*this.visibleOptionsCount,"px")}},{key:"setOptionsContainerHeight",value:function(e){var t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(d.setStyle(this.$noOptions,"height",t),d.setStyle(this.$noSearchResults,"height",t))),d.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}},{key:"setNewOption",value:function(e){var t=e||this.searchValueOriginal.trim();if(t){var i=this.getNewOption();if(i){var o=i.index;this.setOptionProp(o,"value",this.secureText(t)),this.setOptionProp(o,"label",this.secureText(t))}else{var s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}}},{key:"setSelectedProp",value:function(){var e={};this.selectedValues.forEach(function(t){e[t]=!0}),this.options.forEach(function(t){!0===e[t.value]&&(t.isSelected=!0)})}},{key:"setNewOptionsFromValue",value:function(e){if(e){var t=this.setNewOption.bind(this),i={};this.options.forEach(function(e){i[e.value]=!0}),e.forEach(function(e){e&&!0!==i[e]&&t(e)})}}},{key:"setDropboxWrapperWidth",value:function(){if(!this.showAsPopup){var e=this.dropboxWidth||"".concat(this.$wrapper.offsetWidth,"px");d.setStyle(this.$dropboxContainer,"max-width",e)}}},{key:"setEleStyles",value:function(){var e=this.maxWidth,t={};e&&(t["max-width"]=e),d.setStyles(this.$ele,t)}},{key:"setDropboxStyles",value:function(){var e=this.dropboxWidth,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),d.setStyles(this.$dropboxContainer,i),d.setStyles(this.$dropbox,t)}},{key:"setOptionAttr",value:function(){var e=this.$visibleOptions,t=this.options,i="".concat(this.optionHeight,"px"),o=d.setStyle,s=d.getData,n=d.setData;e&&e.length&&e.forEach(function(e){var r=t[s(e,"index")];o(e,"height",i),n(e,"value",r.value)})}},{key:"setValueTagAttr",value:function(){var e=this.$valueTags;if(e&&e.length){var t=d.getData,i=d.setData,o=this.options;e.forEach(function(e){var s=t(e,"index");if(void 0!==s){var n=o[s];i(e,"value",n.value)}})}}},{key:"setScrollTop",value:function(){var e=this.selectedValues;if(!this.showSelectedOptionsFirst&&this.focusSelectedOptionOnOpen&&0!==e.length){var t,i={};e.forEach(function(e){i[e]=!0}),this.options.some(function(e){return!!i[e.value]&&(t=e.visibleIndex,!0)}),t&&(this.$optionsContainer.scrollTop=this.optionHeight*t)}}},{key:"getVisibleOptions",value:function(){return this.visibleOptions||[]}},{key:"getValue",value:function(){var e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",n.normalizeValues(e)}},{key:"getGroupValue",value:function(){var e=[],t={};return this.options.forEach(function(i){if(i.isSelected){var o=i.value;i.isGroupTitle?o&&(t[i.index]=!0,e.push(o)):!0!==t[i.groupIndex]&&e.push(o)}}),e}},{key:"getInputValue",value:function(e){var t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}},{key:"getFirstVisibleOptionIndex",value:function(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}},{key:"getVisibleStartIndex",value:function(){var e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}},{key:"getTooltipAttrText",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o={"data-tooltip":(n.containsHTML(e)?n.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":t,"data-tooltip-allow-html":i};return d.getAttributesText(o)}},{key:"getOptionObj",value:function(e){if(e){var t=n.getString,i=this.secureText.bind(this),o=i(t(e.value)),s=i(t(e.label)),r=i(t(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:s,labelNormalized:this.searchNormalize&&""!==s.trim()?n.normalizeString(s).toLowerCase():s.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?n.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}}},{key:"getNewOption",value:function(){var e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}},{key:"getOptionIndex",value:function(e){var t;return this.options.some(function(i){return i.value===e&&(t=i.index,!0)}),t}},{key:"getNewValue",value:function(){var e={};this.newValues.forEach(function(t){e[t]=!0});var t=this.selectedValues.filter(function(t){return!0===e[t]});return this.multiple?t:t[0]}},{key:"getAlias",value:function(e){var t=e;return t&&(t=(t=Array.isArray(t)?t.join(","):t.toString().trim()).toLowerCase()),t||""}},{key:"getDisplayValue",value:function(){var e=[];return this.options.forEach(function(t){t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}},{key:"getSelectedOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fullDetails,i=void 0!==t&&t,o=e.keepSelectionOrder,s=void 0!==o&&o,n=this.valueKey,r=this.labelKey,a=this.selectedValues,l=[];if(this.options.forEach(function(e){if(e.isSelected&&!e.isGroupTitle)if(i)l.push(e);else{var t=b(b({},n,e.value),r,e.label);e.isNew&&(t.isNew=!0),e.customData&&(t.customData=e.customData),l.push(t)}}),s){var u={};a.forEach(function(e,t){u[e]=t}),l.sort(function(e,t){return u[e.value]-u[t.value]})}return this.multiple||i?l:l[0]}},{key:"getDisabledOptions",value:function(){var e=this.valueKey,t=this.labelKey,i=this.disabledOptions,o={},s=[];return i.forEach(function(e){o[e]=!0}),this.options.forEach(function(i){var n=i.value,r=i.label;o[n]&&s.push(b(b({},e,n),t,r))}),s}},{key:"getVisibleOptionGroupsMapping",value:function(e){var t=this.options,i={},o=this.isOptionVisible.bind(this);return(t=this.structureOptionGroup(t)).forEach(function(t){i[t.index]=t.options.some(function(t){return o({data:t,searchValue:e}).isVisible})}),i}},{key:"getOptionsCount",value:function(e){var t;if(this.showAsPopup){var i=80*window.innerHeight/100-48;this.hasSearchContainer&&(i-=40),t=Math.floor(i/this.optionHeight)}else t=parseInt(e);return t}},{key:"getOptionsHeight",value:function(){return"".concat(this.optionsCount*this.optionHeight,"px")}},{key:"getSibling",value:function(e,t){var i="next"===t?"nextElementSibling":"previousElementSibling",o=e;do{o&&(o=o[i])}while(d.hasClass(o,"disabled")||d.hasClass(o,"group-title"));return o}},{key:"getUniqueId",value:function(){var e=n.getRandomInt(1e4);return document.querySelector("#vscomp-ele-wrapper-".concat(e))?this.getUniqueId():e}},{key:"initDropboxPopover",value:function(){var e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}},{key:"openDropbox",value:function(t){var i=this;e.lastInteractedInstance=this;var o="";t||(o=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=t,e.openInstances.forEach(function(e){if(e!==i){var t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),e.openInstances.add(this),d.setAttr(this.$dropboxWrapper,"tabindex","0"),d.setAria(this.$dropboxWrapper,"hidden",!1),d.setAttr(this.$dropboxContainerTop,"tabindex","0"),d.setAria(this.$dropboxContainerTop,"hidden",!1),d.setAttr(this.$dropboxContainerBottom,"tabindex","0"),d.setAria(this.$dropboxContainerBottom,"hidden",!1),t?d.setStyle(this.$dropboxContainer,"display","inline-flex"):(d.dispatchEvent(this.$ele,"beforeOpen"),d.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),d.removeClass(this.$allWrappers,"closed"),d.changeTabIndex(this.$allWrappers,0),t||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=o),this.dropboxPopover&&!t?this.dropboxPopover.show():this.afterShowPopper()}},{key:"afterShowPopper",value:function(){var e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),d.addClass(this.$allWrappers,"focused"),this.showAsPopup?(d.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),d.dispatchEvent(this.$ele,"afterOpen"))}},{key:"closeDropbox",value:function(t){if(this.isSilentClose=t,e.openInstances.delete(this),!1!==this.isOpened())if(this.keepAlwaysOpen)this.removeOptionFocus();else{var i=document.activeElement,o=i&&this.$wrapper.contains(i)||this.hasDropboxWrapper&&i&&this.$dropboxWrapper.contains(i);this.shouldFocusWrapperOnClose&&e.lastInteractedInstance===this&&!t&&(null===i||i===document.body||o)&&this.$wrapper.focus(),t?d.setStyle(this.$dropboxContainer,"display",""):(d.dispatchEvent(this.$ele,"beforeClose"),d.setAria(this.$wrapper,"expanded",!1),d.setAria(this.$wrapper,"activedescendant",""),d.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!t?(this.dropboxPopover.hide(),d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}}},{key:"afterHidePopper",value:function(){var e=this.isSilentClose;this.isSilentClose=!1,d.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(d.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),d.addClass(this.$allWrappers,"closed"),e||d.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,d.setAttr(this.$dropboxWrapper,"tabindex","-1"),d.setAria(this.$dropboxWrapper,"hidden",!0),d.setAttr(this.$dropboxContainerTop,"tabindex","-1"),d.setAria(this.$dropboxContainerTop,"hidden",!0),d.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),d.setAria(this.$dropboxContainerBottom,"hidden",!0)}},{key:"moveSelectedOptionsFirst",value:function(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}},{key:"toggleDropbox",value:function(){e.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}},{key:"updatePosition",value:function(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}},{key:"isOpened",value:function(){return!d.hasClass(this.$wrapper,"closed")}},{key:"focusSearchInput",value:function(){var e=this.$searchInput;e&&e.focus()}},{key:"focusElementOnOpen",value:function(){var e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(d.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{var i=this.$dropbox.querySelector('[tabindex="0"]');void 0!==d.getData(i,"index")?this.focusOption({direction:"next"}):i?i.focus():this.focusFirstVisibleOption()}}},{key:"focusFirstVisibleOption",value:function(){var e=this.$optionsContainer.querySelector("[data-index='".concat(this.getFirstVisibleOptionIndex(),"']"));e?(d.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),d.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'))&&e.focus()}},{key:"focusOption",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.direction,o=t.$option,s=t.focusFirst,n=this.$dropboxContainer.querySelector(".vscomp-option.focused");if(o)e=o;else if(!n||s){var r=this.getFirstVisibleOptionIndex();e=this.$dropboxContainer.querySelector('.vscomp-option[data-visible-index="'.concat(r,'"]')),(d.hasClass(e,"disabled")||d.hasClass(e,"group-title"))&&(e=this.getSibling(e,"next"))}else e=this.getSibling(n,i);e&&e!==n&&(n&&this.toggleOptionFocusedState(n,!1),this.toggleOptionFocusedState(e,!0),this.toggleFocusedProp(d.getData(e,"index"),!0),this.moveFocusedOptionToView(e))}},{key:"moveFocusedOptionToView",value:function(e){var t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(t){var i,o=this.$optionsContainer.getBoundingClientRect(),s=t.getBoundingClientRect(),n=o.top,r=o.bottom,a=o.height,l=s.top,u=s.bottom,c=s.height,p=t.offsetTop,h=d.getData(this.$options,"top","number");n>l?i=p+h:r1&&void 0!==arguments[1]?arguments[1]:{}).event;if(e){var i=!d.hasClass(e,"selected");if(i){if(this.multiple&&this.isMaxValuesSelected)return}else if(!this.multiple)return void this.closeDropbox();var o=this.selectedValues,s=d.getData(e,"value"),r=d.getData(e,"index","number"),a=d.hasClass(e,"current-new"),l=!1,u=this.lastSelectedOptionIndex;if(this.lastSelectedOptionIndex=null,this.toggleSelectedProp(r,i),i){if(this.multiple)o.push(s),this.toggleAllOptionsClass(),this.toggleGroupOptionsParent(e),t&&t.shiftKey&&(l=!0);else{o.length&&this.toggleSelectedProp(this.getOptionIndex(o[0]),!1),o=[s];var c=this.$dropboxContainer.querySelector(".vscomp-option.selected");c&&this.toggleOptionSelectedState(c,!1),this.closeDropbox(),a||this.setSearchValue("")}this.lastSelectedOptionIndex=r,this.toggleOptionSelectedState(e)}else this.multiple&&(this.toggleOptionSelectedState(e),n.removeItemFromArray(o,s),this.toggleAllOptionsClass(!1),this.toggleGroupOptionsParent(e,!1));a&&this.beforeSelectNewValue(s),this.setValue(o),l&&this.selectRangeOptions(u,r)}}},{key:"selectFocusedOption",value:function(){this.selectOption(this.$dropboxContainer.querySelector(".vscomp-option.focused"))}},{key:"selectRangeOptions",value:function(e,t){var i=this;if("number"==typeof e&&!this.maxValues){var o,s,n=this.selectedValues,r=this.hasOptionGroup,a={};if(eo&&t0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),d.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}}},{key:"isAllOptionsSelected",value:function(e){var t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible)})),t}},{key:"isAllGroupOptionsSelected",value:function(e){var t=!1;return this.options.length&&(t=!this.options.some(function(t){return!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e})),t}},{key:"toggleGroupOptionsParent",value:function(e,t){if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var i=d.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));var o=this.$options.querySelector('.vscomp-option[data-index="'.concat(i,'"]')),s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,s),this.toggleGroupTitleProp(i,s)}}},{key:"toggleGroupTitleProp",value:function(e,t){var i="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,i)}},{key:"toggleGroupOptions",value:function(e,t){var i=this;if(this.hasOptionGroup&&!this.disableOptionGroupCheckbox&&e){var o=d.getData(e,"index","number"),s=this.selectedValues,r=this.selectAllOnlyVisible,a={},l=n.removeItemFromArray;s.forEach(function(e){a[e]=!0}),this.options.forEach(function(e){if(!e.isDisabled&&e.groupIndex===o){var i=e.value;!t||r&&!e.isVisible?(e.isSelected=!1,a[i]&&l(s,i)):(e.isSelected=!0,a[i]||s.push(i))}}),this.toggleAllOptionsClass(!!t&&null),this.setValue(s),setTimeout(function(){i.renderOptions()},0)}}},{key:"toggleGroupTitleCheckbox",value:function(e,t){if(e){var i=d.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}}},{key:"toggleFocusedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}},{key:"toggleSelectedProp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.setOptionProp(e,"isSelected",t)}},{key:"scrollToTop",value:function(){this.$optionsContainer.scrollTop>0&&(this.$optionsContainer.scrollTop=0)}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.options.forEach(function(e){e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&d.removeClass(this.$allWrappers,"has-error"),d.dispatchEvent(this.$ele,"reset")}},{key:"addOption",value:function(e,t){if(e){this.lastOptionIndex+=1;var i=this.getOptionObj(f(f({},e),{},{index:this.lastOptionIndex}));this.options.push(i),this.sortedOptions.push(i),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}}},{key:"removeOption",value:function(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}},{key:"removeNewOption",value:function(){var e=this.getNewOption();e&&this.removeOption(e.index)}},{key:"sortOptions",value:function(e){return e.sort(function(e,t){var i=e.isSelected||e.isAnySelected,o=t.isSelected||t.isAnySelected;return i||o?i&&(!o||e.index0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.virtualSelect.reset(e,t)}},{key:"setValueMethod",value:function(){var e;(e=this.virtualSelect).setValueMethod.apply(e,arguments)}},{key:"setOptionsMethod",value:function(){var e;(e=this.virtualSelect).setOptionsMethod.apply(e,arguments)}},{key:"setDisabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setDisabledOptionsMethod.apply(e,arguments)}},{key:"setEnabledOptionsMethod",value:function(){var e;(e=this.virtualSelect).setEnabledOptionsMethod.apply(e,arguments)}},{key:"toggleSelectAll",value:function(e){this.virtualSelect.toggleAllOptions(e)}},{key:"isAllSelected",value:function(){return this.virtualSelect.isAllSelected}},{key:"addOptionMethod",value:function(e){this.virtualSelect.addOption(e,!0)}},{key:"getNewValueMethod",value:function(){return this.virtualSelect.getNewValue()}},{key:"getDisplayValueMethod",value:function(){return this.virtualSelect.getDisplayValue()}},{key:"getSelectedOptionsMethod",value:function(e){return this.virtualSelect.getSelectedOptions(e)}},{key:"getDisabledOptionsMethod",value:function(){return this.virtualSelect.getDisabledOptions()}},{key:"openMethod",value:function(){return this.virtualSelect.openDropbox()}},{key:"closeMethod",value:function(){return this.virtualSelect.closeDropbox()}},{key:"focusMethod",value:function(){return this.virtualSelect.focus()}},{key:"enableMethod",value:function(){return this.virtualSelect.enable()}},{key:"disableMethod",value:function(){return this.virtualSelect.disable()}},{key:"destroyMethod",value:function(){return this.virtualSelect.destroy()}},{key:"validateMethod",value:function(){return this.virtualSelect.validate()}},{key:"toggleRequiredMethod",value:function(e){return this.virtualSelect.toggleRequired(e)}},{key:"onResizeMethod",value:function(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(function(e){e.parentElement.virtualSelect.onResize()})}}],i&&x(t.prototype,i),o&&x(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,o}();document.addEventListener("reset",T.onFormReset),document.addEventListener("submit",T.onFormSubmit),window.addEventListener("resize",T.onResizeMethod),k=T.getAttrProps(),window.VirtualSelect=T,T.openInstances=new Set,T.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,o=new Array(t);ii-s-t.width?"left":"right",vertical:n>o-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),i=window.pageXOffset,o=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+o,right:t.right+i,bottom:t.bottom+o,left:t.left+i}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,i){if(e){var o=e?e.dataset[t]:"";return"number"===i?o=parseFloat(o)||0:"true"===o?o=!0:"false"===o&&(o=!1),o}}},{key:"setData",value:function(e,t,i){e&&(e.dataset[t]=i)}},{key:"setStyle",value:function(e,t,i){e&&(e.style[t]=i)}},{key:"show",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",i)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,i=e.parentElement;i;){var o=getComputedStyle(i).overflow;if(-1!==o.indexOf("scroll")||-1!==o.indexOf("auto")){t=i;break}i=i.parentElement}return t}}],i&&function(e,t){for(var i=0;ig?g-f:M:k+c>L&&("right"===E?n="left":k=L+fO?O-h:P:C+p>I&&("bottom"===E?n="top":C=I+hc-R&&(G=c-R):"left"!==E&&"right"!==E||((H=y/2+m-j)p-R&&(H=p-R)),i.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}i.hide(this.$popperEle)}},{key:"resetPosition",value:function(){i.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=t.resetPosition,s=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),o&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=i.getData(e.$popperEle,"left"),o=i.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(o),"px, 0)"),r=e.showDuration;i.show(e.$popperEle,"inline-flex"),i.getCoords(e.$popperEle),i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(s)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var o=parseInt(i.getData(e.$popperEle,"fromLeft")),s=parseInt(i.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(o,"px, ").concat(s,"px, 0)"),r=e.hideDuration;i.setStyle(e.$popperEle,"transitionDuration",r+"ms"),i.setStyle(e.$popperEle,"transform",n),i.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){i.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){i.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(i.getData(this.$popperEle,"left")),t=parseInt(i.getData(this.$popperEle,"top"));i.show(this.$popperEle,"inline-flex"),i.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var i=0;i1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var i,o=0;return function(){for(var s=arguments.length,n=new Array(s),r=0;re.length)&&(t=e.length);for(var i=0,o=new Array(t);i'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&p(t.prototype,i),s&&p(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,s}();d=b.getAttrProps(),window.PopoverComponent=b}(); \ No newline at end of file + */!function(){"use strict";const e=/[^\p{L}\p{N}_]/gu;class t{static getString(e){return e||0===e?e.toString():""}static convertToBoolean(e,t=!1){let s;return s=!0===e||"true"===e||!1!==e&&"false"!==e&&t,s}static isEmpty(e){let t=!1;return e?Array.isArray(e)?0===e.length&&(t=!0):"object"==typeof e&&0===Object.keys(e).length&&(t=!0):t=!0,t}static isNotEmpty(e){return!t.isEmpty(e)}static normalizeValues(e){if(Array.isArray(e)){const t=new Array(e.length);for(let s=0;s!!e):[]}static getRandomInt(e,t=0){const s=Math.ceil(t),i=Math.floor(e);return Math.floor(Math.random()*(i-s-1))+s}static regexEscape(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}static normalizeString(t){return t.normalize("NFD").replace(e,"")}static willTextOverflow(e,t){const s=document.createElement("div");s.style.position="absolute",s.style.visibility="hidden",s.style.whiteSpace="nowrap",s.style.fontSize=window.getComputedStyle(e).fontSize,s.style.fontFamily=window.getComputedStyle(e).fontFamily,s.textContent=t,document.body.appendChild(s);const i=s.clientWidth;return document.body.removeChild(s),i>e.clientWidth}static replaceDoubleQuotesWithHTML(e){return e.replace(/"/g,""")}static containsHTML(e){return/<[a-z][\s\S]*>/i.test(e)}static containsHTMLorJS(e){return/<([a-z]+)[\s\S]*?>|on\w+="[^"]*"/i.test(e)}}class s{static addClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.add(...i)})}static removeClass(e,t){if(!e)return;const i=t.split(" ");s.getElements(e).forEach(e=>{e.classList.remove(...i)})}static toggleClass(e,t,i){if(!e)return;let o;void 0!==i&&(o=Boolean(i)),s.getElements(e).forEach(e=>{e.classList.toggle(t,o)})}static hasClass(e,t){return!!e&&e.classList.contains(t)}static hasEllipsis(e){return!!e&&e.scrollWidth>e.offsetWidth}static getData(e,t,s){if(!e)return;let i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}static setData(e,t,s){e&&(e.dataset[t]=s)}static setAttr(e,t,s){e&&e.setAttribute(t,s)}static setAttrFromEle(e,t,s,i){const o={};s.forEach(t=>{o[t]=e.getAttribute(t)}),s.forEach(e=>{const s=o[e];(s||-1!==i.indexOf(e)&&""===s)&&t.setAttribute(e,s)})}static setStyle(e,t,s){e&&(e.style[t]=s)}static setStyles(e,t){e&&t&&Object.keys(t).forEach(s=>{e.style[s]=t[s]})}static setAria(e,t,s){if(!e)return;let i=t;"role"!==i&&(i=`aria-${i}`),e.setAttribute(i,s)}static getElements(e){return e?void 0===e.forEach?[e]:e:[]}static getElementsBySelector(e="",t=void 0){let s;const i=void 0!==t?t:document;return""!==e&&(s=i.querySelectorAll(e)),void 0!==s?Array.from(s):[]}static addEvent(e,i,o,n){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{s.getElements(e).forEach(e=>{e.addEventListener(t,o,{capture:n})})})}static dispatchEvent(e,t,i=!1){if(!e)return;const o=s.getElements(e);setTimeout(()=>{o.forEach(e=>{e.dispatchEvent(new CustomEvent(t,{bubbles:i}))})},0)}static getAttributesText(e){let t="";return e?(Object.entries(e).forEach(([e,s])=>{void 0!==s&&(t+=` ${e}="${s}" `)}),t):t}static convertPropToDataAttr(e){return e?`data-${e}`.replace(/([A-Z])/g,"-$1").toLowerCase():""}static changeTabIndex(e,t){e?s.getElements(e).forEach(e=>{e.tabIndex=t}):console.log(e,"Invalid element provided.")}static removeEvent(e,t,i){e&&s.getElements(e).forEach(e=>{e.removeEventListener(t,i)})}}const i={13:"onEnterPress",38:"onUpArrowPress",40:"onDownArrowPress",46:"onBackspaceOrDeletePress",8:"onBackspaceOrDeletePress"},o=["autofocus","disabled","multiple","required"],n=["autofocus","class","disabled","id","multiple","name","placeholder","required"];let r;const a=["additionalClasses","additionalDropboxClasses","additionalDropboxContainerClasses","additionalToggleButtonClasses","aliasKey","allOptionsSelectedText","allowNewOption","alwaysShowSelectedOptionsCount","alwaysShowSelectedOptionsLabel","ariaLabelledby","ariaLabelText","ariaLabelClearButtonText","ariaLabelTagClearButtonText","ariaLabelSearchClearButtonText","autoSelectFirstOption","clearButtonText","descriptionKey","disableAllOptionsSelectedText","disableOptionGroupCheckbox","disableSelectAll","disableValidation","dropboxWidth","dropboxWrapper","emptyValue","enableSecureText","focusSelectedOptionOnOpen","hasOptionDescription","hideClearButton","hideValueTooltipOnSelectAll","keepAlwaysOpen","labelKey","markSearchResults","maxValues","maxWidth","minValues","moreText","noOfDisplayValues","noOptionsText","noSearchResultsText","optionHeight","optionSelectedText","optionsCount","optionsSelectedText","popupDropboxBreakpoint","popupPosition","position","search","searchByStartsWith","searchDelay","searchFormLabel","searchGroup","searchNormalize","searchPlaceholderText","selectAllOnlyVisible","selectAllText","setValueAsArray","showDropboxAsPopup","showOptionsOnlyOnSearch","showSelectedOptionsFirst","showValueAsTags","silentInitialValueSet","textDirection","tooltipAlignment","tooltipFontSize","tooltipMaxWidth","updatePositionThrottle","useGroupValue","valueKey","zIndex"];class l{constructor(e){try{this.createSecureTextElements(),this.setProps(e),this.setDisabledOptions(e.disabledOptions),this.setOptions(e.options),this.render()}catch(e){console.warn("Couldn't initiate Virtual Select"),console.error(e)}}render(){if(!this.$ele)return;const{uniqueId:e}=this;let t="vscomp-wrapper",i="vscomp-toggle-button";const o=this.showValueAsTags?"":this.getTooltipAttrText(this.placeholder,!0,!0),n=this.getTooltipAttrText(this.clearButtonText),r=this.ariaLabelledby?`aria-labelledby="${this.ariaLabelledby}"`:"",a=this.ariaLabelText?`aria-label="${this.ariaLabelText}"`:"",l=this.ariaLabelClearButtonText?`aria-label="${this.ariaLabelClearButtonText}"`:"";let p=!1;this.additionalClasses&&(t+=` ${this.additionalClasses}`),this.additionalToggleButtonClasses&&(i+=` ${this.additionalToggleButtonClasses}`),this.multiple&&(t+=" multiple",this.disableSelectAll||(t+=" has-select-all")),this.hideClearButton||(t+=" has-clear-button"),this.keepAlwaysOpen?(t+=" keep-always-open",p=!0):t+=" closed",this.showAsPopup&&(t+=" show-as-popup"),this.hasSearch&&(t+=" has-search-input"),this.showValueAsTags&&(t+=" show-value-as-tags"),this.textDirection&&(t+=` text-direction-${this.textDirection}`),this.popupPosition&&(t+=` popup-position-${this.popupPosition.toLowerCase()}`);const h=`
\n \n
\n
\n ${this.placeholder}\n
\n
\n
\n \n
\n
\n\n ${this.renderDropbox({wrapperClasses:t})}\n
`;this.$ele.innerHTML=h,this.$body=document.querySelector("body"),this.$wrapper=this.$ele.querySelector(".vscomp-wrapper"),this.hasDropboxWrapper?(this.$allWrappers=[this.$wrapper,this.$dropboxWrapper],this.$dropboxContainer=this.$dropboxWrapper.querySelector(".vscomp-dropbox-container"),s.addClass(this.$dropboxContainer,"pop-comp-wrapper")):(this.$allWrappers=[this.$wrapper],this.$dropboxContainer=this.$wrapper.querySelector(".vscomp-dropbox-container")),this.$toggleButton=this.$ele.querySelector(".vscomp-toggle-button"),this.$clearButton=this.$ele.querySelector(".vscomp-clear-button"),this.$valueText=this.$ele.querySelector(".vscomp-value"),this.$hiddenInput=this.$ele.querySelector(".vscomp-hidden-input"),this.$dropbox=this.$dropboxContainer.querySelector(".vscomp-dropbox"),this.$dropboxCloseButton=this.$dropboxContainer.querySelector(".vscomp-dropbox-close-button"),this.$dropboxContainerBottom=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-bottom"),this.$dropboxContainerTop=this.$dropboxContainer.querySelector(".vscomp-dropbox-container-top"),this.$search=this.$dropboxContainer.querySelector(".vscomp-search-wrapper"),this.$optionsContainer=this.$dropboxContainer.querySelector(".vscomp-options-container"),this.$optionsList=this.$dropboxContainer.querySelector(".vscomp-options-list"),this.$options=this.$dropboxContainer.querySelector(".vscomp-options"),this.$noOptions=this.$dropboxContainer.querySelector(".vscomp-no-options"),this.$noSearchResults=this.$dropboxContainer.querySelector(".vscomp-no-search-results"),this.afterRenderWrapper()}renderDropbox({wrapperClasses:e}){const t="self"!==this.dropboxWrapper?document.querySelector(this.dropboxWrapper):null;let i="vscomp-dropbox";this.additionalDropboxClasses&&(i+=` ${this.additionalDropboxClasses}`);let o="vscomp-dropbox-container";this.additionalDropboxContainerClasses&&(o+=` ${this.additionalDropboxContainerClasses}`);const n=`
\n \n
\n
\n\n
\n
\n\n
\n
\n
\n
\n\n
\n
${this.noOptionsText}
\n
${this.noSearchResultsText}
\n\n \n
\n \n
`;if(t){const i=document.createElement("div");return this.$dropboxWrapper=i,this.hasDropboxWrapper=!0,i.innerHTML=n,t.appendChild(i),s.addClass(i,`vscomp-dropbox-wrapper ${e}`),this.keepAlwaysOpen||(s.setAttr(i,"tabindex","-1"),s.setAria(i,"hidden",!0)),""}return this.hasDropboxWrapper=!1,n}renderOptions(){this.calculateAriaMetadata();let e="";const s=this.getVisibleOptions();let i="",o="";const n=!(!this.markSearchResults||!this.searchValue);let r;const{labelRenderer:a,disableOptionGroupCheckbox:l,uniqueId:p,searchGroup:h}=this,c="function"==typeof a,{convertToBoolean:u}=t;let d="";if(n&&(r=new RegExp(`(${t.regexEscape(this.searchValue)})(?!([^<]+)?>)`,"gi")),this.multiple&&(i=''),this.allowNewOption){const e=this.getTooltipAttrText("New Option");o=``}s.forEach(t=>{const{index:s}=t;let v,b="vscomp-option";const f=this.getTooltipAttrText("",!0,!0);let m=i,g="",O="",y="",x="",S="-1";const $=u(t.isSelected);let w="";if(t.classNames&&(b+=` ${t.classNames}`),t.isFocused&&(S="0",b+=" focused"),t.isDisabled&&(b+=" disabled",w='aria-disabled="true"'),t.isGroupTitle&&(d=t.label,b+=" group-title",l&&(m="")),$&&(b+=" selected"),t.isGroupOption){let e="";b+=" group-option",y=`data-group-index="${t.groupIndex}"`,t.customData?(d=void 0!==t.customData.group_name?`${t.customData.group_name}, `:"",e=void 0!==t.customData.description?` ${t.customData.description},`:"",x=`aria-label="${d} ${t.label}, ${e}"`):x=`aria-label="${d}, ${t.label}"`}v=c?a(t):t.label,t.description&&(O=`
${t.description}
`),t.isCurrentNew?(b+=" current-new",g+=o):!n||t.isGroupTitle&&!h||(v=v.replace(r,"$1"));let C="";this.ariaSetSize>0&&(C=`aria-setsize="${this.ariaSetSize}"`,t.filteredIndex&&(C+=` aria-posinset="${t.filteredIndex}"`)),e+=`
\n ${m}\n \n ${v}\n \n ${O}\n ${g}\n
`}),d="",this.$options.innerHTML=e,this.$visibleOptions=this.$options.querySelectorAll(".vscomp-option"),this.afterRenderOptions()}renderSearch(){if(!this.hasSearchContainer)return;let e="",t="";if(this.multiple&&!this.disableSelectAll&&(e=`\n \n ${this.selectAllText}\n `),this.hasSearch){const e=this.ariaLabelSearchClearButtonText?`aria-label="${this.ariaLabelSearchClearButtonText}"`:"";t=`\n \n ×`}const s=`
\n ${e}\n ${t}\n
`;this.$search.innerHTML=s,this.$searchInput=this.$dropboxContainer.querySelector(".vscomp-search-input"),this.$searchClear=this.$dropboxContainer.querySelector(".vscomp-search-clear"),this.$toggleAllButton=this.$dropboxContainer.querySelector(".vscomp-toggle-all-button"),this.$toggleAllCheckbox=this.$dropboxContainer.querySelector(".vscomp-toggle-all-checkbox"),this.addEvent(this.$searchInput,"input","onSearch"),this.addEvent(this.$searchInput,"change","preventPropagation"),this.addEvent(this.$searchClear,"click keydown","onSearchClear"),this.addEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.addEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.addEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus")}addEvents(){this.addEvent(document,"click","onDocumentClick",!0),this.addEvent(this.$allWrappers,"keydown","onKeyDown"),this.addEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.addEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.addEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.addEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.addEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.addEvent(this.$options,"click","onOptionsClick"),this.addEvent(this.$options,"mouseover","onOptionsMouseOver"),this.addEvent(this.$options,"touchmove","onOptionsTouchMove"),this.addMutationObserver()}addEvent(e,i,o,n=!1){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`;let r=this.events[i];r||(r=this[o].bind(this),this.events[i]=r),s.addEvent(e,t,r,n)})}removeEvents(){this.removeEvent(document,"click","onDocumentClick"),this.removeEvent(this.$allWrappers,"keydown","onKeyDown"),this.removeEvent(this.$toggleButton,"click keydown","onToggleButtonPress"),this.removeEvent(this.$clearButton,"click keydown","onClearButtonClick"),this.removeEvent(this.$dropboxContainer,"click","onDropboxContainerClick"),this.removeEvent(this.$dropboxCloseButton,"click","onDropboxCloseButtonClick"),this.removeEvent(this.$optionsContainer,"scroll","onOptionsScroll"),this.removeEvent(this.$options,"click","onOptionsClick"),this.removeEvent(this.$options,"mouseover","onOptionsMouseOver"),this.removeEvent(this.$options,"touchmove","onOptionsTouchMove"),this.$searchInput&&(this.removeEvent(this.$searchInput,"input","onSearch"),this.removeEvent(this.$searchInput,"change","preventPropagation"),this.$searchClear&&(this.removeEvent(this.$searchClear,"click","onSearchClear"),this.removeEvent(this.$searchClear,"keydown","onSearchClear"))),this.$toggleAllButton&&this.removeEvent(this.$toggleAllButton,"click","onToggleAllOptions"),this.$dropboxContainerBottom&&this.removeEvent(this.$dropboxContainerBottom,"focus","onDropboxContainerTopOrBottomFocus"),this.$dropboxContainerTop&&this.removeEvent(this.$dropboxContainerTop,"focus","onDropboxContainerTopOrBottomFocus"),this.removeMutationObserver()}removeEvent(e,i,o){e&&t.removeArrayEmpty(i.split(" ")).forEach(t=>{const i=`${o}-${t}`,n=this.events[i];n&&s.removeEvent(e,t,n)})}onDocumentClick(e){const t=e.target.closest(".vscomp-wrapper");if(!t)return void l.openInstances.forEach(e=>{const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox()});const s=t.parentElement.virtualSelect;s&&s!==this&&this.isOpened()&&!this.keepAlwaysOpen&&(this.shouldFocusWrapperOnClose=!1,this.closeDropbox())}onKeyDown(e){const t=e.which||e.keyCode,s=i[t];if(document.activeElement!==this.$searchInput||e.shiftKey||9!==t||this.multiple||(e.preventDefault(),this.focusFirstVisibleOption()),document.activeElement!==this.$toggleAllButton||13!==t){if(27===t||"Escape"===e.key){const e=this.showAsPopup?this.$wrapper:this.$dropboxWrapper;if(e&&(document.activeElement===e||e.contains(document.activeElement))&&!this.keepAlwaysOpen)return void this.closeDropbox()}s&&this[s](e)}else this.toggleAllOptions()}onEnterPress(e){e.preventDefault(),this.isOpened()?this.selectFocusedOption():!1===this.$ele.disabled&&this.openDropbox()}onDownArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"next"}):this.openDropbox())}onUpArrowPress(e){document.activeElement!==this.$searchInput&&(e.preventDefault(),this.isOpened()?this.focusOption({direction:"previous"}):this.openDropbox())}onBackspaceOrDeletePress(e){e.target===this.$wrapper&&(e.preventDefault(),this.selectedValues.length>0&&this.reset())}onToggleButtonPress(e){if("keydown"===e.type){if("Enter"!==e.code&&"Space"!==e.code)return;e.preventDefault()}const t=e.target;if(t.closest(".vscomp-value-tag-clear-button"))return e.stopPropagation(),void this.removeValue(t.closest(".vscomp-value-tag"));t.closest(".toggle-button-child")||this.toggleDropbox()}onClearButtonClick(e){"click"===e.type?this.reset():"keydown"!==e.type||"Enter"!==e.code&&"Space"!==e.code||(e.stopPropagation(),this.reset())}onOptionsScroll(){this.setVisibleOptions(!0)}onOptionsClick(e){const t=e.target.closest(".vscomp-option");t&&!s.hasClass(t,"disabled")&&(s.hasClass(t,"group-title")?this.onGroupTitleClick(t):this.selectOption(t,{event:e}))}onGroupTitleClick(e){if(!e||!this.multiple||this.disableOptionGroupCheckbox)return;const t=!s.hasClass(e,"selected");this.toggleGroupTitleCheckbox(e,t),this.toggleGroupOptions(e,t)}onDropboxContainerClick(e){e.target.closest(".vscomp-dropbox")||this.closeDropbox()}onDropboxCloseButtonClick(){this.closeDropbox()}onOptionsMouseOver(e){const t=e.target.closest(".vscomp-option");t&&this.isOpened()&&(s.hasClass(t,"disabled")||s.hasClass(t,"group-title")?this.removeOptionFocus():this.focusOption({$option:t}))}onOptionsTouchMove(){this.removeOptionFocus()}onSearch(e){e.stopPropagation(),this.setSearchValue(e.target.value,!0)}preventPropagation(e){e.stopPropagation()}onSearchClear(e){e.stopPropagation(),"Enter"!==e.code&&"Space"!==e.code&&"click"!==e.type||(this.setSearchValue(""),this.focusSearchInput())}onToggleAllOptions(){this.toggleAllOptions()}onDropboxContainerTopOrBottomFocus(){this.closeDropbox()}onResize(){this.setOptionsContainerHeight(!0)}addMutationObserver(){if(!this.hasDropboxWrapper)return;const e=this.$ele;this.mutationObserver=new MutationObserver(t=>{let s=!1,i=!1;t.forEach(t=>{s||(s=[...t.addedNodes].some(t=>!(t!==e&&!t.contains(e)))),i||(i=[...t.removedNodes].some(t=>!(t!==e&&!t.contains(e))))}),i&&!s&&this.destroy()}),this.mutationObserver.observe(document.querySelector("body"),{childList:!0,subtree:!0})}removeMutationObserver(){this.hasDropboxWrapper&&this.mutationObserver.disconnect()}beforeValueSet(e){this.toggleAllOptionsClass(!e&&void 0)}beforeSelectNewValue(e){const t=this.getNewOption();if(t){const e=t.index;this.newValues.push(t.value),this.setOptionProp(e,"isCurrentNew",!1),this.setOptionProp(e,"isNew",!0)}else e&&(this.setNewOption(e),this.toggleSelectedProp(this.lastOptionIndex,!0));setTimeout(()=>{this.setSearchValue(""),this.focusSearchInput()},0)}afterRenderWrapper(){s.addClass(this.$ele,"vscomp-ele"),this.renderSearch(),this.setEleStyles(),this.setDropboxStyles(),this.setVisibleOptionsCount(),this.setOptionsContainerHeight(),this.addEvents(),this.setEleProps(),this.keepAlwaysOpen||this.showAsPopup||this.initDropboxPopover(),this.initialSelectedValue?this.setValueMethod(this.initialSelectedValue,this.silentInitialValueSet):this.autoSelectFirstOption&&this.visibleOptions.length&&this.setValueMethod(this.visibleOptions[0].value,this.silentInitialValueSet),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),this.initialDisabled&&this.disable(),this.autofocus&&this.focus()}afterRenderOptions(){const e=this.getVisibleOptions(),t=!this.options.length&&!this.hasServerSearch,i=!t&&!e.length;(!this.allowNewOption||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(s.toggleClass(this.$allWrappers,"has-no-search-results",i),i?(s.setAttr(this.$noSearchResults,"tabindex","0"),s.setAttr(this.$noSearchResults,"aria-hidden","false")):(s.setAttr(this.$noSearchResults,"tabindex","-1"),s.setAttr(this.$noSearchResults,"aria-hidden","true"))),s.toggleClass(this.$allWrappers,"has-no-options",t),t?(s.setAttr(this.$noOptions,"tabindex","0"),s.setAttr(this.$noOptions,"aria-hidden","false")):(s.setAttr(this.$noOptions,"tabindex","-1"),s.setAttr(this.$noOptions,"aria-hidden","true")),this.setOptionAttr(),this.setOptionsPosition(),this.setOptionsTooltip(),document.activeElement!==this.$searchInput&&setTimeout(()=>{const e=s.getElementsBySelector(".focused",this.$dropboxContainer)[0];void 0!==e&&e.focus({preventScroll:!0})},20)}afterSetOptionsContainerHeight(e){e&&this.showAsPopup&&this.setVisibleOptions()}afterSetSearchValue(){this.hasServerSearch?(clearTimeout(this.serverSearchTimeout),this.serverSearchTimeout=setTimeout(()=>{this.serverSearch()},this.searchDelay)):this.setVisibleOptionsCount(),this.selectAllOnlyVisible&&this.toggleAllOptionsClass(),this.focusOption({focusFirst:!0})}afterSetVisibleOptionsCount(){this.scrollToTop(),this.setOptionsHeight(),this.setVisibleOptions(),this.updatePosition()}afterValueSet(){this.scrollToTop(),this.setSearchValue(""),this.renderOptions()}afterSetOptions(e){e&&this.setSelectedProp(),this.setOptionsHeight(),this.setVisibleOptions(),this.showOptionsOnlyOnSearch&&this.setSearchValue("",!1,!0),e||this.reset()}setProps(e){const s=this.setDefaultProps(e);this.setPropsFromElementAttr(s);const{convertToBoolean:i}=t;this.$ele=s.ele,this.dropboxWrapper=s.dropboxWrapper,this.valueKey=s.valueKey,this.labelKey=s.labelKey,this.descriptionKey=s.descriptionKey,this.aliasKey=s.aliasKey,this.optionHeightText=s.optionHeight,this.optionHeight=parseFloat(this.optionHeightText),this.multiple=i(s.multiple),this.hasSearch=i(s.search),this.searchByStartsWith=i(s.searchByStartsWith),this.searchGroup=i(s.searchGroup),this.hideClearButton=i(s.hideClearButton),this.autoSelectFirstOption=i(s.autoSelectFirstOption),this.hasOptionDescription=i(s.hasOptionDescription),this.silentInitialValueSet=i(s.silentInitialValueSet),this.allowNewOption=i(s.allowNewOption),this.markSearchResults=i(s.markSearchResults),this.showSelectedOptionsFirst=i(s.showSelectedOptionsFirst),this.disableSelectAll=i(s.disableSelectAll),this.keepAlwaysOpen=i(s.keepAlwaysOpen),this.showDropboxAsPopup=i(s.showDropboxAsPopup),this.hideValueTooltipOnSelectAll=i(s.hideValueTooltipOnSelectAll),this.showOptionsOnlyOnSearch=i(s.showOptionsOnlyOnSearch),this.selectAllOnlyVisible=i(s.selectAllOnlyVisible),this.alwaysShowSelectedOptionsCount=i(s.alwaysShowSelectedOptionsCount),this.alwaysShowSelectedOptionsLabel=i(s.alwaysShowSelectedOptionsLabel),this.disableAllOptionsSelectedText=i(s.disableAllOptionsSelectedText),this.showValueAsTags=i(s.showValueAsTags),this.disableOptionGroupCheckbox=i(s.disableOptionGroupCheckbox),this.enableSecureText=i(s.enableSecureText),this.setValueAsArray=i(s.setValueAsArray),this.disableValidation=i(s.disableValidation),this.initialDisabled=i(s.disabled),this.required=i(s.required),this.autofocus=i(s.autofocus),this.useGroupValue=i(s.useGroupValue),this.focusSelectedOptionOnOpen=i(s.focusSelectedOptionOnOpen),this.noOptionsText=s.noOptionsText,this.noSearchResultsText=s.noSearchResultsText,this.selectAllText=s.selectAllText,this.searchNormalize=s.searchNormalize,this.searchPlaceholderText=s.searchPlaceholderText,this.searchFormLabel=s.searchFormLabel,this.optionsSelectedText=s.optionsSelectedText,this.optionSelectedText=s.optionSelectedText,this.allOptionsSelectedText=s.allOptionsSelectedText,this.clearButtonText=s.clearButtonText,this.moreText=s.moreText,this.placeholder=s.placeholder,this.position=s.position,this.textDirection=s.textDirection,this.dropboxWidth=s.dropboxWidth,this.tooltipFontSize=s.tooltipFontSize,this.tooltipAlignment=s.tooltipAlignment,this.tooltipMaxWidth=s.tooltipMaxWidth,this.updatePositionThrottle=s.updatePositionThrottle,this.noOfDisplayValues=parseInt(s.noOfDisplayValues),this.zIndex=parseInt(s.zIndex),this.maxValues=parseInt(s.maxValues),this.minValues=parseInt(s.minValues),this.name=this.secureText(s.name),this.additionalClasses=s.additionalClasses,this.additionalDropboxClasses=s.additionalDropboxClasses,this.additionalDropboxContainerClasses=s.additionalDropboxContainerClasses,this.additionalToggleButtonClasses=s.additionalToggleButtonClasses,this.popupDropboxBreakpoint=s.popupDropboxBreakpoint,this.popupPosition=s.popupPosition,this.onServerSearch=s.onServerSearch,this.labelRenderer=s.labelRenderer,this.selectedLabelRenderer=s.selectedLabelRenderer,this.initialSelectedValue=0===s.selectedValue?"0":s.selectedValue,this.emptyValue=s.emptyValue,this.ariaLabelText=s.ariaLabelText,this.ariaLabelledby=s.ariaLabelledby,this.ariaLabelClearButtonText=s.ariaLabelClearButtonText,this.ariaLabelTagClearButtonText=s.ariaLabelTagClearButtonText,this.ariaLabelSearchClearButtonText=s.ariaLabelSearchClearButtonText,this.maxWidth=s.maxWidth,this.searchDelay=s.searchDelay,this.showDuration=parseInt(s.showDuration),this.hideDuration=parseInt(s.hideDuration),this.selectedValues=[],this.selectedOptions=[],this.newValues=[],this.events={},this.tooltipEnterDelay=200,this.searchValue="",this.searchValueOriginal="",this.isAllSelected=!1,(void 0===s.search&&this.multiple||this.allowNewOption||this.showOptionsOnlyOnSearch)&&(this.hasSearch=!0),this.hasServerSearch="function"==typeof this.onServerSearch,(this.maxValues||this.hasServerSearch||this.showOptionsOnlyOnSearch)&&(this.disableSelectAll=!0,this.disableOptionGroupCheckbox=!0),this.keepAlwaysOpen&&(this.dropboxWrapper="self"),this.showAsPopup=this.showDropboxAsPopup&&!this.keepAlwaysOpen&&window.innerWidth<=parseFloat(this.popupDropboxBreakpoint),this.hasSearchContainer=this.hasSearch||this.multiple&&!this.disableSelectAll,this.optionsCount=this.getOptionsCount(s.optionsCount),this.halfOptionsCount=Math.ceil(this.optionsCount/2),this.optionsHeight=this.getOptionsHeight(),this.uniqueId=this.getUniqueId(),this.shouldFocusWrapperOnClose=!0,this.ariaSetSize=0}setDefaultProps(e){const t={dropboxWrapper:"self",valueKey:"value",labelKey:"label",descriptionKey:"description",aliasKey:"alias",ariaLabelText:"Options list",ariaLabelClearButtonText:"Clear button",ariaLabelTagClearButtonText:"Remove option",ariaLabelSearchClearButtonText:"Clear search input",optionsCount:5,noOfDisplayValues:50,optionHeight:"40px",noOptionsText:"No options found",noSearchResultsText:"No results found",selectAllText:"Select All",searchNormalize:!1,searchPlaceholderText:"Search...",searchFormLabel:"Search",clearButtonText:"Clear",moreText:"more...",optionsSelectedText:"options selected",optionSelectedText:"option selected",allOptionsSelectedText:"All",placeholder:"Select",position:"bottom left",zIndex:e.keepAlwaysOpen?1:2,tooltipFontSize:"14px",tooltipAlignment:"center",tooltipMaxWidth:"300px",updatePositionThrottle:100,name:"",additionalClasses:"",additionalDropboxClasses:"",additionalDropboxContainerClasses:"",additionalToggleButtonClasses:"",maxValues:0,showDropboxAsPopup:!0,popupDropboxBreakpoint:"576px",popupPosition:"center",hideValueTooltipOnSelectAll:!0,emptyValue:"",searchDelay:300,focusSelectedOptionOnOpen:!0,showDuration:300,hideDuration:200};return e.hasOptionDescription&&(t.optionsCount=4,t.optionHeight="50px"),Object.assign(t,e)}setPropsFromElementAttr(e){const t=e.ele;Object.keys(r).forEach(s=>{let i=t.getAttribute(s);-1===o.indexOf(s)||""!==i&&"true"!==i||(i=!0),i&&(e[r[s]]=i)})}setEleProps(){const{$ele:e}=this;e.virtualSelect=this,e.value=this.multiple?[]:"",e.name=this.name,e.disabled=!1,e.required=this.required,e.autofocus=this.autofocus,e.multiple=this.multiple,e.form=e.closest("form"),e.reset=l.reset,e.setValue=l.setValueMethod,e.setOptions=l.setOptionsMethod,e.setDisabledOptions=l.setDisabledOptionsMethod,e.setEnabledOptions=l.setEnabledOptionsMethod,e.toggleSelectAll=l.toggleSelectAll,e.isAllSelected=l.isAllSelected,e.addOption=l.addOptionMethod,e.getNewValue=l.getNewValueMethod,e.getDisplayValue=l.getDisplayValueMethod,e.getSelectedOptions=l.getSelectedOptionsMethod,e.getDisabledOptions=l.getDisabledOptionsMethod,e.open=l.openMethod,e.close=l.closeMethod,e.focus=l.focusMethod,e.enable=l.enableMethod,e.disable=l.disableMethod,e.destroy=l.destroyMethod,e.validate=l.validateMethod,e.toggleRequired=l.toggleRequiredMethod,this.hasDropboxWrapper&&(this.$dropboxWrapper.virtualSelect=this)}setValueMethod(e,s){const i={},o={};let n=[];const r=this.multiple;let a=t.normalizeValues(e);if(a){if(Array.isArray(a)||(a=[a]),r){const{maxValues:e}=this;e&&a.length>e&&a.splice(e)}else a.length>1&&(a=[a[0]]);this.useGroupValue&&(a=this.setGroupOptionsValue(a)),a.forEach((e,t)=>{i[e]=!0,o[e]=t}),this.allowNewOption&&a&&this.setNewOptionsFromValue(a)}this.options.forEach(e=>{const s=t.normalizeValues(e.value);!0!==i[s]||e.isDisabled||e.isGroupTitle?e.isSelected=!1:(e.isSelected=!0,n.push(e.value))}),r?(this.hasOptionGroup&&this.setGroupsSelectedProp(),n.sort((e,s)=>o[t.normalizeValues(e)]-o[t.normalizeValues(s)])):[n]=n,this.beforeValueSet(),this.setValue(n,{disableEvent:s}),this.afterValueSet()}setGroupOptionsValue(e){const t=[],s={},i={};return e.forEach(e=>{i[e]=!0}),this.options.forEach(e=>{const{value:o}=e,n=!0===i[o];e.isGroupTitle?n&&(s[e.index]=!0):(n||s[e.groupIndex])&&t.push(o)}),t}setGroupsSelectedProp(){const e=this.isAllGroupOptionsSelected.bind(this);this.options.forEach(t=>{t.isGroupTitle&&(t.isSelected=e(t.index))})}setOptionsMethod(e,t){this.setOptions(e),this.afterSetOptions(t)}setDisabledOptionsMethod(e,t=!1){this.setDisabledOptions(e,!0),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setDisabledOptions(e,t=!1){let s=[];if(e)if(!0===e)t&&this.options.forEach(e=>(e.isDisabled=!0,s.push(e.value),e));else{s=e.map(e=>e.toString());const i={};s.forEach(e=>{i[e]=!0}),t&&this.options.forEach(e=>(e.isDisabled=!0===i[e.value],e))}else t&&this.options.forEach(e=>(e.isDisabled=!1,e));this.disabledOptions=s}setEnabledOptionsMethod(e,t=!1){this.setEnabledOptions(e),t||(this.setValueMethod(null),this.toggleAllOptionsClass()),this.setVisibleOptions()}setEnabledOptions(e){if(void 0===e)return;const t=[];if(!0===e)this.options.forEach(e=>(e.isDisabled=!1,e));else{const s={};e.forEach(e=>{s[e]=!0}),this.options.forEach(e=>{const i=!0!==s[e.value];return e.isDisabled=i,i&&t.push(e.value),e})}this.disabledOptions=t}setOptions(e=[]){const s=[],i=this.disabledOptions.length,{valueKey:o,labelKey:n,descriptionKey:r,aliasKey:a,hasOptionDescription:l}=this,{getString:p,convertToBoolean:h}=t,c=this.secureText.bind(this),u=this.getAlias.bind(this);let d=0,v=!1;const b={};let f=!1;this.disabledOptions.forEach(e=>{b[e]=!0});const m=e=>{"object"!=typeof e&&(e={[o]:e,[n]:e});const g=c(p(e[o])),O=c(p(e[n])),y=e.options,x=!!y,S={index:d,value:g,valueNormalized:g.toLowerCase(),label:O,labelNormalized:this.searchNormalize&&""!==O.trim()?t.normalizeString(O).toLowerCase():O.toLowerCase(),alias:u(e[a]),isVisible:h(e.isVisible,!0),isNew:e.isNew||!1,isGroupTitle:x,classNames:e.classNames};if(f||""!==g||(f=!0),i&&(S.isDisabled=!0===b[g]),e.isGroupOption&&(S.isGroupOption=!0,S.groupIndex=e.groupIndex),l){const s=c(p(e[r]));S.description=s,S.descriptionNormalized=this.searchNormalize&&""!==s.trim()?t.normalizeString(s).toLowerCase():s.toLowerCase()}if(e.customData&&(S.customData=e.customData),s.push(S),d+=1,x){const e=S.index;v=!0,y.forEach(t=>{t.isGroupOption=!0,t.groupIndex=e,m(t)})}};Array.isArray(e)&&e.forEach(m);const g=s.length,{$ele:O}=this;O.options=s,O.length=g,this.options=s,this.visibleOptionsCount=g,this.lastOptionIndex=g-1,this.newValues=[],this.hasOptionGroup=v,this.hasEmptyValueOption=f,this.setSortedOptions()}setServerOptions(e=[]){this.setOptionsMethod(e,!0);const{selectedOptions:t}=this,i=this.options;let o=!1;if(t.length){const e={};o=!0,i.forEach(t=>{e[t.value]=!0}),t.forEach(t=>{!0!==e[t.value]&&(t.isVisible=!1,i.push(t))}),this.setOptionsMethod(i,!0)}this.allowNewOption&&this.searchValue&&(i.some(e=>e.label.toLowerCase()===this.searchValue)||(o=!0,this.setNewOption())),o?(this.setVisibleOptionsCount(),this.multiple&&this.toggleAllOptionsClass(),this.setValueText()):this.updatePosition(),this.setVisibleOptionsCount(),s.removeClass(this.$allWrappers,"server-searching")}setSelectedOptions(){this.selectedOptions=this.options.filter(e=>e.isSelected)}setSortedOptions(){let e=[...this.options];this.showSelectedOptionsFirst&&this.selectedValues.length&&(e=this.hasOptionGroup?this.sortOptionsGroup(e):this.sortOptions(e)),this.sortedOptions=e}setVisibleOptions(){let e=[...this.sortedOptions];const t=2*this.optionsCount,s=this.getVisibleStartIndex(),i=this.getNewOption(),o=s+t-1;let n=0;i&&(i.visibleIndex=n,n+=1),e=e.filter(e=>{let t=!1;return e.isVisible&&!e.isCurrentNew&&(t=n>=s&&n<=o,e.visibleIndex=n,n+=1),t}),i&&(e=[i,...e]),this.visibleOptions=e,this.visibleOptionsCount=e.length,this.renderOptions()}setOptionsPosition(e){const t=parseInt((e||this.getVisibleStartIndex())*this.optionHeight);this.$options.style.transform=`translate3d(0, ${t}px, 0)`,s.setData(this.$options,"top",t)}setOptionsTooltip(){const e=this.getVisibleOptions(),{hasOptionDescription:t}=this;e.forEach(e=>{const i=this.$dropboxContainer.querySelector(`.vscomp-option[data-index="${e.index}"]`);s.setData(i.querySelector(".vscomp-option-text"),"tooltip",e.label),t&&s.setData(i.querySelector(".vscomp-option-description"),"tooltip",e.description)})}setValue(e,{disableEvent:i=!1,disableValidation:o=!1}={}){const n=t.normalizeValues(e);this.hasEmptyValueOption&&""===n||n?Array.isArray(n)?this.selectedValues=[...n]:this.selectedValues=[n]:this.selectedValues=[];const r=this.getValue();this.$ele.value=r,this.$hiddenInput.value=this.getInputValue(r),this.isMaxValuesSelected=!!(this.maxValues&&this.maxValues<=this.selectedValues.length),this.toggleAllOptionsClass(),this.setValueText();const a=t.isNotEmpty(this.selectedValues);s.toggleClass(this.$allWrappers,"has-value",a),s.toggleClass(this.$allWrappers,"max-value-selected",this.isMaxValuesSelected),s.setAttr(this.$clearButton,"tabindex",a?"0":"-1"),s.setAria(this.$clearButton,"hidden",!1===a),o||this.validate(),i||s.dispatchEvent(this.$ele,"change",!0)}setValueText(){const{multiple:e,selectedValues:i,noOfDisplayValues:o,showValueAsTags:n,$valueText:r,selectedLabelRenderer:a}=this,l=[];let p=[];const h=i.length;let c=0;const u=this.isAllSelected&&!this.hasServerSearch&&!this.disableAllOptionsSelectedText&&!n;if(u&&this.hideValueTooltipOnSelectAll)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else{this.getSelectedOptions({fullDetails:!0,keepSelectionOrder:!0}).some(e=>{if(e.isCurrentNew)return!1;if(c>=o)return!0;let{label:s}=e;if("function"==typeof a&&(s=a(e)),l.push(s),c+=1,n){const i=t.willTextOverflow(r.parentElement,s)?this.getTooltipAttrText(s,!1,!0):"";let o="";this.ariaLabelTagClearButtonText&&(o=`aria-label="${s.replace(/<[^>]+>/gi,"").trim()}, ${this.ariaLabelTagClearButtonText}"`);const n=`\n ${s}\n \n \n \n `;p.push(n)}else p.push(s);return!1});const i=h-o;i>0&&p.push(`+ ${i} ${this.moreText}`);const d=l.join(", ");if(""===d)r.innerHTML=this.placeholder;else if(r.innerHTML=d,e){const{maxValues:e}=this;if(this.alwaysShowSelectedOptionsCount||s.hasEllipsis(r)||e||n){let t=`${h}`;if(e&&(t+=` / ${e}`),u)r.innerHTML=`${this.allOptionsSelectedText} (${h})`;else if(n)r.innerHTML=p.join(""),this.$valueTags=r.querySelectorAll(".vscomp-value-tag"),this.setValueTagAttr();else if(!this.alwaysShowSelectedOptionsLabel){const e=1===h?this.optionSelectedText:this.optionsSelectedText;r.innerHTML=`${t} ${e}`}}else p=[]}}let d="";0===h?d=this.placeholder:n||(d=p.join(", ")),n||s.setData(r,"tooltip",d),e&&(n?this.updatePosition():s.setData(r,"tooltipEllipsisOnly",0===h))}setSearchValue(e,t=!1,i=!1){if(e===this.searchValueOriginal&&!i)return;t||(this.$searchInput.value=e);const o=e.replace(/\\/g,"").toLowerCase().trim();this.searchValue=o,this.searchValueOriginal=e,s.toggleClass(this.$allWrappers,"has-search-value",e),s.setAttr(this.$searchClear,"tabindex",""!==e?"0":"-1"),s.setAria(this.$searchClear,"hidden",""===e),this.afterSetSearchValue()}setVisibleOptionsCount(){let e,s=0,i=!1;const{searchGroup:o,showOptionsOnlyOnSearch:n,searchByStartsWith:r}=this;let{searchValue:a}=this;a=this.searchNormalize&&""!==a.trim()?t.normalizeString(a):a;const l=this.isOptionVisible.bind(this);this.hasOptionGroup&&(e=this.getVisibleOptionGroupsMapping(a)),this.options.forEach(t=>{if(t.isCurrentNew)return;let p;n&&!a?(t.isVisible=!1,p={isVisible:!1,hasExactOption:!1}):p=l({data:t,searchValue:a,hasExactOption:i,visibleOptionGroupsMapping:e,searchGroup:o,searchByStartsWith:r}),p.isVisible&&(s+=1),i||(i=p.hasExactOption)}),this.allowNewOption&&(a&&!i?(this.setNewOption(),s+=1):this.removeNewOption()),this.visibleOptionsCount=s,this.afterSetVisibleOptionsCount()}calculateAriaMetadata(){let e=0,t=0;if((this.sortedOptions&&this.sortedOptions.length?this.sortedOptions:this.options).forEach(s=>{if(s.isCurrentNew)s.filteredIndex=void 0;else if(!0===s.isVisible){const i=s.isGroupTitle&&this.multiple&&!this.disableOptionGroupCheckbox;!s.isGroupTitle||i?(t+=1,e+=1,s.filteredIndex=t):s.filteredIndex=void 0}else s.filteredIndex=void 0}),this.allowNewOption){const s=this.getNewOption();s&&!0===s.isVisible?(t+=1,e+=1,s.filteredIndex=t):s&&(s.filteredIndex=void 0)}this.ariaSetSize=e}setOptionProp(e,t,s){this.options[e]&&(this.options[e][t]=s)}setOptionsHeight(){this.$optionsList.style.height=this.optionHeight*this.visibleOptionsCount+"px"}setOptionsContainerHeight(e){let t;e?this.showAsPopup&&(this.optionsCount=this.getOptionsCount(),this.halfOptionsCount=Math.ceil(this.optionsCount/2),t=this.getOptionsHeight(),this.optionsHeight=t):(t=this.optionsHeight,this.keepAlwaysOpen&&(s.setStyle(this.$noOptions,"height",t),s.setStyle(this.$noSearchResults,"height",t))),s.setStyle(this.$optionsContainer,"max-height",t),this.afterSetOptionsContainerHeight(e)}setNewOption(e){const t=e||this.searchValueOriginal.trim();if(!t)return;const s=this.getNewOption();if(s){const e=s.index;this.setOptionProp(e,"value",this.secureText(t)),this.setOptionProp(e,"label",this.secureText(t))}else{const s={value:t,label:t};e?(s.isNew=!0,this.newValues.push(t)):s.isCurrentNew=!0,this.addOption(s)}}setSelectedProp(){const e={};this.selectedValues.forEach(t=>{e[t]=!0}),this.options.forEach(t=>{!0===e[t.value]&&(t.isSelected=!0)})}setNewOptionsFromValue(e){if(!e)return;const t=this.setNewOption.bind(this),s={};this.options.forEach(e=>{s[e.value]=!0}),e.forEach(e=>{e&&!0!==s[e]&&t(e)})}setDropboxWrapperWidth(){if(this.showAsPopup)return;const e=this.dropboxWidth||`${this.$wrapper.offsetWidth}px`;s.setStyle(this.$dropboxContainer,"max-width",e)}setEleStyles(){const{maxWidth:e}=this,t={};e&&(t["max-width"]=e),s.setStyles(this.$ele,t)}setDropboxStyles(){const{dropboxWidth:e}=this,t={},i={"z-index":this.zIndex};e&&(this.showAsPopup?t["max-width"]=e:i.width=e),s.setStyles(this.$dropboxContainer,i),s.setStyles(this.$dropbox,t)}setOptionAttr(){const{$visibleOptions:e}=this,{options:t}=this,i=`${this.optionHeight}px`,{setStyle:o,getData:n,setData:r}=s;e&&e.length&&e.forEach(e=>{const s=t[n(e,"index")];o(e,"height",i),r(e,"value",s.value)})}setValueTagAttr(){const{$valueTags:e}=this;if(!e||!e.length)return;const{getData:t,setData:i}=s,{options:o}=this;e.forEach(e=>{const s=t(e,"index");if(void 0!==s){const t=o[s];i(e,"value",t.value)}})}setScrollTop(){const{selectedValues:e}=this;if(this.showSelectedOptionsFirst||!this.focusSelectedOptionOnOpen||0===e.length)return;const t={};let s;e.forEach(e=>{t[e]=!0}),this.options.some(e=>!!t[e.value]&&(s=e.visibleIndex,!0)),s&&(this.$optionsContainer.scrollTop=this.optionHeight*s)}getVisibleOptions(){return this.visibleOptions||[]}getValue(){let e;return e=this.multiple?this.useGroupValue?this.getGroupValue():this.selectedValues:this.selectedValues[0]||"",t.normalizeValues(e)}getGroupValue(){const e=[],t={};return this.options.forEach(s=>{if(!s.isSelected)return;const{value:i}=s;s.isGroupTitle?i&&(t[s.index]=!0,e.push(i)):!0!==t[s.groupIndex]&&e.push(i)}),e}getInputValue(e){let t=e;return t&&t.length?this.setValueAsArray&&this.multiple&&(t=JSON.stringify(t)):t=this.emptyValue,t}getFirstVisibleOptionIndex(){return Math.ceil(this.$optionsContainer.scrollTop/this.optionHeight)}getVisibleStartIndex(){let e=this.getFirstVisibleOptionIndex()-this.halfOptionsCount;return e<0&&(e=0),e}getTooltipAttrText(e,i=!1,o=!1){const n={"data-tooltip":(t.containsHTML(e)?t.replaceDoubleQuotesWithHTML(e):e)||"","data-tooltip-enter-delay":this.tooltipEnterDelay,"data-tooltip-z-index":this.zIndex,"data-tooltip-font-size":this.tooltipFontSize,"data-tooltip-alignment":this.tooltipAlignment,"data-tooltip-max-width":this.tooltipMaxWidth,"data-tooltip-ellipsis-only":i,"data-tooltip-allow-html":o};return s.getAttributesText(n)}getOptionObj(e){if(!e)return;const{getString:s}=t,i=this.secureText.bind(this),o=i(s(e.value)),n=i(s(e.label)),r=i(s(e.description));return{index:e.index,value:o,valueNormalized:o.toLowerCase(),label:n,labelNormalized:this.searchNormalize&&""!==n.trim()?t.normalizeString(n).toLowerCase():n.toLowerCase(),description:r,descriptionNormalized:this.searchNormalize&&""!==r.trim()?t.normalizeString(r).toLowerCase():r.toLowerCase(),alias:this.getAlias(e.alias),isCurrentNew:e.isCurrentNew||!1,isNew:e.isNew||!1,isVisible:!0}}getNewOption(){const e=this.options[this.lastOptionIndex];if(e&&e.isCurrentNew)return e}getOptionIndex(e){let t;return this.options.some(s=>s.value===e&&(t=s.index,!0)),t}getNewValue(){const e={};this.newValues.forEach(t=>{e[t]=!0});const t=this.selectedValues.filter(t=>!0===e[t]);return this.multiple?t:t[0]}getAlias(e){let t=e;return t&&(t=Array.isArray(t)?t.join(","):t.toString().trim(),t=t.toLowerCase()),t||""}getDisplayValue(){const e=[];return this.options.forEach(t=>{t.isSelected&&e.push(t.label)}),this.multiple?e:e[0]||""}getSelectedOptions({fullDetails:e=!1,keepSelectionOrder:t=!1}={}){const{valueKey:s,labelKey:i,selectedValues:o}=this,n=[];if(this.options.forEach(t=>{if(t.isSelected&&!t.isGroupTitle)if(e)n.push(t);else{const e={[s]:t.value,[i]:t.label};t.isNew&&(e.isNew=!0),t.customData&&(e.customData=t.customData),n.push(e)}}),t){const e={};o.forEach((t,s)=>{e[t]=s}),n.sort((t,s)=>e[t.value]-e[s.value])}return this.multiple||e?n:n[0]}getDisabledOptions(){const{valueKey:e,labelKey:t,disabledOptions:s}=this,i={},o=[];return s.forEach(e=>{i[e]=!0}),this.options.forEach(({value:s,label:n})=>{i[s]&&o.push({[e]:s,[t]:n})}),o}getVisibleOptionGroupsMapping(e){let{options:t}=this;const s={},i=this.isOptionVisible.bind(this);return t=this.structureOptionGroup(t),t.forEach(t=>{s[t.index]=t.options.some(t=>i({data:t,searchValue:e}).isVisible)}),s}getOptionsCount(e){let t;if(this.showAsPopup){let e=80*window.innerHeight/100-48;this.hasSearchContainer&&(e-=40),t=Math.floor(e/this.optionHeight)}else t=parseInt(e);return t}getOptionsHeight(){return this.optionsCount*this.optionHeight+"px"}getSibling(e,t){const i="next"===t?"nextElementSibling":"previousElementSibling";let o=e;do{o&&(o=o[i])}while(s.hasClass(o,"disabled")||s.hasClass(o,"group-title"));return o}getUniqueId(){const e=t.getRandomInt(1e4);return document.querySelector(`#vscomp-ele-wrapper-${e}`)?this.getUniqueId():e}initDropboxPopover(){const e={ele:this.$ele,target:this.$dropboxContainer,position:this.position,zIndex:this.zIndex,margin:4,transitionDistance:30,hideArrowIcon:!0,disableManualAction:!0,disableUpdatePosition:!this.hasDropboxWrapper,updatePositionThrottle:this.updatePositionThrottle,showDuration:this.showDuration,hideDuration:this.hideDuration,afterShow:this.afterShowPopper.bind(this),afterHide:this.afterHidePopper.bind(this)};this.dropboxPopover=new PopoverComponent(e)}openDropbox(e){l.lastInteractedInstance=this;let t="";e||(t=this.$dropboxContainer.style.transition,this.$dropboxContainer.style.transition="none"),this.isSilentOpen=e,l.openInstances.forEach(e=>{if(e!==this){const t=e;t.shouldFocusWrapperOnClose=!1,t.closeDropbox(!0)}}),l.openInstances.add(this),s.setAttr(this.$dropboxWrapper,"tabindex","0"),s.setAria(this.$dropboxWrapper,"hidden",!1),s.setAttr(this.$dropboxContainerTop,"tabindex","0"),s.setAria(this.$dropboxContainerTop,"hidden",!1),s.setAttr(this.$dropboxContainerBottom,"tabindex","0"),s.setAria(this.$dropboxContainerBottom,"hidden",!1),e?s.setStyle(this.$dropboxContainer,"display","inline-flex"):(s.dispatchEvent(this.$ele,"beforeOpen"),s.setAria(this.$wrapper,"expanded",!0)),this.setDropboxWrapperWidth(),s.removeClass(this.$allWrappers,"closed"),s.changeTabIndex(this.$allWrappers,0),e||(this.$dropboxContainer.offsetHeight,this.$dropboxContainer.style.transition=t),this.dropboxPopover&&!e?this.dropboxPopover.show():this.afterShowPopper()}afterShowPopper(){const e=this.isSilentOpen;this.isSilentOpen=!1,e||(this.moveSelectedOptionsFirst(),this.setScrollTop(),s.addClass(this.$allWrappers,"focused"),this.showAsPopup?(s.addClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!0):this.focusElementOnOpen(),s.dispatchEvent(this.$ele,"afterOpen"))}closeDropbox(e){if(this.isSilentClose=e,l.openInstances.delete(this),!1===this.isOpened())return;if(this.keepAlwaysOpen)return void this.removeOptionFocus();const t=document.activeElement,i=t&&this.$wrapper.contains(t)||this.hasDropboxWrapper&&t&&this.$dropboxWrapper.contains(t);this.shouldFocusWrapperOnClose&&l.lastInteractedInstance===this&&!e&&(null===t||t===document.body||i)&&this.$wrapper.focus(),e?s.setStyle(this.$dropboxContainer,"display",""):(s.dispatchEvent(this.$ele,"beforeClose"),s.setAria(this.$wrapper,"expanded",!1),s.setAria(this.$wrapper,"activedescendant",""),s.setAria(this.$dropboxContainer,"activedescendant","")),this.dropboxPopover&&!e?(this.dropboxPopover.hide(),s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)):this.afterHidePopper(),this.setSearchValue("")}afterHidePopper(){const e=this.isSilentClose;this.isSilentClose=!1,s.removeClass(this.$allWrappers,"focused"),this.removeOptionFocus(),!e&&this.isPopupActive&&(s.removeClass(this.$body,"vscomp-popup-active"),this.isPopupActive=!1),s.addClass(this.$allWrappers,"closed"),e||s.dispatchEvent(this.$ele,"afterClose"),this.shouldFocusWrapperOnClose=!0,s.setAttr(this.$dropboxWrapper,"tabindex","-1"),s.setAria(this.$dropboxWrapper,"hidden",!0),s.setAttr(this.$dropboxContainerTop,"tabindex","-1"),s.setAria(this.$dropboxContainerTop,"hidden",!0),s.setAttr(this.$dropboxContainerBottom,"tabindex","-1"),s.setAria(this.$dropboxContainerBottom,"hidden",!0)}moveSelectedOptionsFirst(){this.$optionsContainer.scrollTop&&this.selectedValues.length||this.setVisibleOptions(),this.showSelectedOptionsFirst&&(this.setSortedOptions(),this.scrollToTop(),this.setVisibleOptions())}toggleDropbox(){l.lastInteractedInstance=this,this.isOpened()?this.closeDropbox():this.openDropbox()}updatePosition(){this.dropboxPopover&&this.isOpened()&&this.$ele.updatePosition()}isOpened(){return!s.hasClass(this.$wrapper,"closed")}focusSearchInput(){const e=this.$searchInput;e&&e.focus()}focusElementOnOpen(){const e=this.$searchInput,t=!this.options.length&&!this.hasServerSearch;if(e)t&&!this.allowNewOption?(s.setAttr(e,"disabled",""),this.$noOptions.focus()):(e.removeAttribute("disabled"),e.focus());else{const e=this.$dropbox.querySelector('[tabindex="0"]');void 0!==s.getData(e,"index")?this.focusOption({direction:"next"}):e?e.focus():this.focusFirstVisibleOption()}}focusFirstVisibleOption(){let e=this.$optionsContainer.querySelector(`[data-index='${this.getFirstVisibleOptionIndex()}']`);e?(s.hasClass(e,"group-title")&&(e=this.getSibling(e,"next")),s.setAttr(e,"tabindex","0"),this.$optionsContainer.scrollTop=this.optionHeight*this.getFirstVisibleOptionIndex(),this.focusOption({focusFirst:!0}),e.focus()):(e=this.$dropbox.querySelector('[tabindex="0"]'),e&&e.focus())}focusOption({direction:e,$option:t,focusFirst:i}={}){const o=this.$dropboxContainer.querySelector(".vscomp-option.focused");let n;if(t)n=t;else if(!o||i){const e=this.getFirstVisibleOptionIndex();n=this.$dropboxContainer.querySelector(`.vscomp-option[data-visible-index="${e}"]`),(s.hasClass(n,"disabled")||s.hasClass(n,"group-title"))&&(n=this.getSibling(n,"next"))}else n=this.getSibling(o,e);n&&n!==o&&(o&&this.toggleOptionFocusedState(o,!1),this.toggleOptionFocusedState(n,!0),this.toggleFocusedProp(s.getData(n,"index"),!0),this.moveFocusedOptionToView(n))}moveFocusedOptionToView(e){const t=e||this.$dropboxContainer.querySelector(".vscomp-option.focused");if(!t)return;let i;const o=this.$optionsContainer.getBoundingClientRect(),n=t.getBoundingClientRect(),r=o.top,a=o.bottom,l=o.height,p=n.top,h=n.bottom,c=n.height,u=t.offsetTop,d=s.getData(this.$options,"top","number");r>p?i=u+d:a{if(e.isDisabled||e.isGroupTitle||!e.isVisible||e.isSelected)return;const{index:t}=e;if(t>o&&t{e(parseInt(t))})}setTimeout(()=>{this.renderOptions()},0)}toggleAllOptions(e){if(!this.multiple||this.disableSelectAll)return;const t="boolean"==typeof isSelected?e:!s.hasClass(this.$toggleAllCheckbox,"checked"),i=[],{selectAllOnlyVisible:o}=this;this.options.forEach(e=>{const s=e;if(s.isDisabled||s.isCurrentNew)return;const{isVisible:n,isSelected:r}=s;!t&&(!o||n||!r)||t&&o&&!n&&!r?s.isSelected=!1:(s.isSelected=!0,s.isGroupTitle||i.push(s.value))}),this.toggleAllOptionsClass(t),this.setValue(i),this.renderOptions()}toggleAllOptionsClass(e){if(!this.multiple)return;let t=!1;"boolean"==typeof e||(e=this.isAllOptionsSelected()),!e&&this.selectAllOnlyVisible&&""!==this.searchValue&&(this.visibleOptionsCount>0||""===this.searchValue)&&(t=this.isAllOptionsSelected(!0)),s.toggleClass(this.$toggleAllCheckbox,"checked",e||t),this.isAllSelected=e}isAllOptionsSelected(e){let t=!1;return this.options.length&&this.selectedValues.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&(!e||t.isVisible))),t}isAllGroupOptionsSelected(e){let t=!1;return this.options.length&&(t=!this.options.some(t=>!t.isSelected&&!t.isDisabled&&!t.isGroupTitle&&t.groupIndex===e)),t}toggleGroupOptionsParent(e,t){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;let i=s.getData(e,"groupIndex");void 0!==i&&(i=parseInt(i));const o=this.$options.querySelector(`.vscomp-option[data-index="${i}"]`),n="boolean"==typeof t?t:this.isAllGroupOptionsSelected(i);this.toggleGroupTitleCheckbox(o,n),this.toggleGroupTitleProp(i,n)}toggleGroupTitleProp(e,t){const s="boolean"==typeof t?t:this.isAllGroupOptionsSelected(e);this.toggleSelectedProp(e,s)}toggleGroupOptions(e,i){if(!this.hasOptionGroup||this.disableOptionGroupCheckbox||!e)return;const o=s.getData(e,"index","number"),{selectedValues:n,selectAllOnlyVisible:r}=this,a={},{removeItemFromArray:l}=t;n.forEach(e=>{a[e]=!0}),this.options.forEach(e=>{if(e.isDisabled||e.groupIndex!==o)return;const{value:t}=e;!i||r&&!e.isVisible?(e.isSelected=!1,a[t]&&l(n,t)):(e.isSelected=!0,a[t]||n.push(t))}),this.toggleAllOptionsClass(!!i&&null),this.setValue(n),setTimeout(()=>{this.renderOptions()},0)}toggleGroupTitleCheckbox(e,t){if(!e)return;const i=s.getData(e,"index","number");this.toggleSelectedProp(i,t),this.toggleOptionSelectedState(e,t)}toggleFocusedProp(e,t=!1){this.focusedOptionIndex&&this.setOptionProp(this.focusedOptionIndex,"isFocused",!1),this.setOptionProp(e,"isFocused",t),this.focusedOptionIndex=e}toggleSelectedProp(e,t=!1){this.setOptionProp(e,"isSelected",t)}scrollToTop(){const{scrollTop:e}=this.$optionsContainer;e>0&&(this.$optionsContainer.scrollTop=0)}reset(e=!1,t=!1){this.options.forEach(e=>{e.isSelected=!1}),this.beforeValueSet(!0),this.setValue(null,{disableEvent:t,disableValidation:e}),this.afterValueSet(),e&&s.removeClass(this.$allWrappers,"has-error"),s.dispatchEvent(this.$ele,"reset")}addOption(e,t){if(!e)return;this.lastOptionIndex+=1;const s=this.getOptionObj({...e,index:this.lastOptionIndex});this.options.push(s),this.sortedOptions.push(s),t&&(this.visibleOptionsCount+=1,this.afterSetOptions())}removeOption(e){(e||0===e)&&(this.options.splice(e,1),this.lastOptionIndex-=1)}removeNewOption(){const e=this.getNewOption();e&&this.removeOption(e.index)}sortOptions(e){return e.sort((e,t)=>{const s=e.isSelected||e.isAnySelected,i=t.isSelected||t.isAnySelected;return s||i?s&&(!i||e.index{const s=e.options;e.isAnySelected=s.some(e=>e.isSelected),e.isAnySelected&&t(s)}),t(s),this.destructureOptionGroup(s)}isOptionVisible({data:e,searchValue:s,hasExactOption:i,visibleOptionGroupsMapping:o,searchGroup:n,searchByStartsWith:r}){const a=null!=e.valueNormalized?e.valueNormalized:e.value.toLowerCase();let l=e.labelNormalized;if(null==l){const s=(e.label||"").trim();l=this.searchNormalize&&""!==s?t.normalizeString(s).toLowerCase():s.toLowerCase()}const{description:p,alias:h}=e;let{descriptionNormalized:c}=e;if(null==c){const e=p||"";c=this.searchNormalize&&""!==e.trim()?t.normalizeString(e).toLowerCase():e.toLowerCase()}let u=r?l.startsWith(s):l.includes(s);return!e.isGroupTitle||n&&u||(u=o[e.index]),r||!h||u||(u=h.includes(s)),r||!c||u||(u=c.includes(s)),e.isVisible=u,i||(i=l===s||a===s),{isVisible:u,hasExactOption:i}}structureOptionGroup(e){const t=[],s={};return e.forEach(e=>{if(e.isGroupTitle){const i=[];e.options=i,s[e.index]=i,t.push(e)}}),e.forEach(e=>{e.isGroupOption&&s[e.groupIndex].push(e)}),t}destructureOptionGroup(e){let t=[];return e.forEach(e=>{t.push(e),t=t.concat(e.options)}),t}serverSearch(){s.removeClass(this.$allWrappers,"has-no-search-results"),s.addClass(this.$allWrappers,"server-searching"),this.setSelectedOptions(),this.onServerSearch(this.searchValue,this)}removeValue(e){const{selectedValues:i}=this,o=s.getData(e,"value");t.removeItemFromArray(i,o),this.setValueMethod(i)}focus(){this.$wrapper.focus()}enable(){this.$ele.disabled=!1,this.$ele.removeAttribute("disabled"),this.$hiddenInput.removeAttribute("disabled"),s.setAria(this.$wrapper,"disabled",!1),s.changeTabIndex(this.$wrapper,0)}disable(){this.$ele.disabled=!0,this.$ele.setAttribute("disabled",""),this.$hiddenInput.setAttribute("disabled",""),s.setAria(this.$wrapper,"disabled",!0),s.changeTabIndex(this.$wrapper,-1),this.$wrapper.blur()}validate(){if(this.disableValidation)return!0;let e=!1;const{selectedValues:i,minValues:o}=this;return this.required&&(t.isEmpty(i)||this.multiple&&o&&i.length{t.virtualSelect?i.push(t.virtualSelect):(e.ele=t,"SELECT"===t.tagName&&l.setPropsFromSelect(e),i.push(new l(e)))}),s?i[0]:i}static getAttrProps(){const{convertPropToDataAttr:e}=s,t={};return n.forEach(e=>{t[e]=e}),a.forEach(s=>{t[e(s)]=s}),t}static setPropsFromSelect(e){const t=e.ele,i=[],n=[],a=e=>{const t=[];return Array.from(e.children).forEach(e=>{const{value:s}=e,o={value:s};"OPTGROUP"===e.tagName?(o.label=e.getAttribute("label"),o.options=a(e)):o.label=e.innerHTML,t.push(o),e.disabled&&i.push(s),e.selected&&n.push(s)}),t},l=a(t),p=document.createElement("div");s.setAttrFromEle(t,p,Object.keys(r),o),t.parentNode.insertBefore(p,t),t.remove(),e.ele=p,e.options=l,e.disabledOptions=i,e.selectedValue=n}static onFormReset(e){const t=e.target.closest("form");t&&t.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.reset(!0)})}static onFormSubmit(e){l.validate(e.target.closest("form"))||e.preventDefault()}static validate(e){if(!e)return!0;let t=!1;return e.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{const s=e.parentElement.virtualSelect.validate();t||s||(t=!0)}),!t}static reset(e=!1,t=!1){this.virtualSelect.reset(e,t)}static setValueMethod(...e){this.virtualSelect.setValueMethod(...e)}static setOptionsMethod(...e){this.virtualSelect.setOptionsMethod(...e)}static setDisabledOptionsMethod(...e){this.virtualSelect.setDisabledOptionsMethod(...e)}static setEnabledOptionsMethod(...e){this.virtualSelect.setEnabledOptionsMethod(...e)}static toggleSelectAll(e){this.virtualSelect.toggleAllOptions(e)}static isAllSelected(){return this.virtualSelect.isAllSelected}static addOptionMethod(e){this.virtualSelect.addOption(e,!0)}static getNewValueMethod(){return this.virtualSelect.getNewValue()}static getDisplayValueMethod(){return this.virtualSelect.getDisplayValue()}static getSelectedOptionsMethod(e){return this.virtualSelect.getSelectedOptions(e)}static getDisabledOptionsMethod(){return this.virtualSelect.getDisabledOptions()}static openMethod(){return this.virtualSelect.openDropbox()}static closeMethod(){return this.virtualSelect.closeDropbox()}static focusMethod(){return this.virtualSelect.focus()}static enableMethod(){return this.virtualSelect.enable()}static disableMethod(){return this.virtualSelect.disable()}static destroyMethod(){return this.virtualSelect.destroy()}static validateMethod(){return this.virtualSelect.validate()}static toggleRequiredMethod(e){return this.virtualSelect.toggleRequired(e)}static onResizeMethod(){document.querySelectorAll(".vscomp-ele-wrapper").forEach(e=>{e.parentElement.virtualSelect.onResize()})}}document.addEventListener("reset",l.onFormReset),document.addEventListener("submit",l.onFormSubmit),window.addEventListener("resize",l.onResizeMethod),r=l.getAttrProps(),window.VirtualSelect=l,l.openInstances=new Set,l.lastInteractedInstance=null,"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}(),function(){"use strict";function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,s){if(e){if("string"==typeof e)return t(e,s);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,s):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,i=new Array(t);ss-o-t.width?"left":"right",vertical:n>i-n-t.height?"top":"bottom"}}},{key:"getAbsoluteCoords",value:function(e){if(e){var t=e.getBoundingClientRect(),s=window.pageXOffset,i=window.pageYOffset;return{width:t.width,height:t.height,top:t.top+i,right:t.right+s,bottom:t.bottom+i,left:t.left+s}}}},{key:"getCoords",value:function(e){return e?e.getBoundingClientRect():{}}},{key:"getData",value:function(e,t,s){if(e){var i=e?e.dataset[t]:"";return"number"===s?i=parseFloat(i)||0:"true"===i?i=!0:"false"===i&&(i=!1),i}}},{key:"setData",value:function(e,t,s){e&&(e.dataset[t]=s)}},{key:"setStyle",value:function(e,t,s){e&&(e.style[t]=s)}},{key:"show",value:function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"block";t.setStyle(e,"display",s)}},{key:"hide",value:function(e){t.setStyle(e,"display","none")}},{key:"getHideableParent",value:function(e){for(var t,s=e.parentElement;s;){var i=getComputedStyle(s).overflow;if(-1!==i.indexOf("scroll")||-1!==i.indexOf("auto")){t=s;break}s=s.parentElement}return t}}],s&&function(e,t){for(var s=0;sO?O-b:M:w+h>L&&("right"===E?n="left":w=L+by?y-u:P:C+c>I&&("bottom"===E?n="top":C=I+uh-j&&(G=h-j):"left"!==E&&"right"!==E||((H=m/2+g-R)c-j&&(H=c-j)),s.setStyle(this.$arrowEle,"transform","translate3d(".concat(parseInt(G),"px, ").concat(parseInt(H),"px, 0) ").concat(K))}s.hide(this.$popperEle)}},{key:"resetPosition",value:function(){s.setStyle(this.$popperEle,"transform","none"),this.setPosition()}},{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.resetPosition,o=t.data;clearTimeout(this.exitDelayTimeout),clearTimeout(this.hideDurationTimeout),i&&this.resetPosition(),this.enterDelayTimeout=setTimeout(function(){var t=s.getData(e.$popperEle,"left"),i=s.getData(e.$popperEle,"top"),n="translate3d(".concat(parseInt(t),"px, ").concat(parseInt(i),"px, 0)"),r=e.showDuration;s.show(e.$popperEle,"inline-flex"),s.getCoords(e.$popperEle),s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",1),e.showDurationTimeout=setTimeout(function(){"function"==typeof e.afterShowCallback&&e.afterShowCallback(o)},r)},this.enterDelay)}},{key:"hide",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).data;clearTimeout(this.enterDelayTimeout),clearTimeout(this.showDurationTimeout),this.exitDelayTimeout=setTimeout(function(){if(e.$popperEle){var i=parseInt(s.getData(e.$popperEle,"fromLeft")),o=parseInt(s.getData(e.$popperEle,"fromTop")),n="translate3d(".concat(i,"px, ").concat(o,"px, 0)"),r=e.hideDuration;s.setStyle(e.$popperEle,"transitionDuration",r+"ms"),s.setStyle(e.$popperEle,"transform",n),s.setStyle(e.$popperEle,"opacity",0),e.hideDurationTimeout=setTimeout(function(){s.hide(e.$popperEle),"function"==typeof e.afterHideCallback&&e.afterHideCallback(t)},r)}},this.exitDelay)}},{key:"updatePosition",value:function(){s.setStyle(this.$popperEle,"transitionDuration","0ms"),this.resetPosition();var e=parseInt(s.getData(this.$popperEle,"left")),t=parseInt(s.getData(this.$popperEle,"top"));s.show(this.$popperEle,"inline-flex"),s.setStyle(this.$popperEle,"transform","translate3d(".concat(e,"px, ").concat(t,"px, 0)"))}}],t&&function(e,t){for(var s=0;s1&&void 0!==arguments[1]&&arguments[1]}},{key:"removeArrayEmpty",value:function(e){return Array.isArray(e)&&e.length?e.filter(function(e){return!!e}):[]}},{key:"throttle",value:function(e,t){var s,i=0;return function(){for(var o=arguments.length,n=new Array(o),r=0;re.length)&&(t=e.length);for(var s=0,i=new Array(t);s'),e=this.$popover.querySelector(".pop-comp-arrow")),this.$arrowEle=e}}},{key:"destroy",value:function(){this.removeEvents()}}])&&c(t.prototype,s),o&&c(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,s,o}();d=f.getAttrProps(),window.PopoverComponent=f}(); \ No newline at end of file diff --git a/docs/examples.md b/docs/examples.md index 6272c70..0e15978 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -18,6 +18,7 @@ - [Maximum values](#maximum-values) - [Label with description](#label-with-description) - [Description search normalize](#description-search-normalize) +- [Multi-language search normalize](#multi-language-search-normalize) - [Show dropbox as popup](#show-dropbox-as-popup) - [Server search](#server-search) - [Show options only on search](#show-options-only-on-search) @@ -262,9 +263,7 @@ VirtualSelect.init({ ## Description search normalize
searchNormalize: false - -
- +

searchNormalize: true ```js @@ -292,6 +291,160 @@ VirtualSelect.init({ }); ``` +## Multi-language search normalize + +A single dropdown can contain options across many writing systems — Latin (with diacritics, including German, Norwegian, Swedish, and Finnish), Greek, Cyrillic, Vietnamese, Chinese, Japanese, Korean, Arabic, and Thai. With `searchNormalize: true`, the search input and option labels/descriptions are normalized via Unicode NFD and then stripped of every character that is not a Unicode letter (`\p{L}`), number (`\p{N}`), or underscore. In practice this means combining marks (`\p{M}`) are removed (enabling diacritic-insensitive matching), and so are punctuation and whitespace (so `co-op` matches `coop` and `Viet Nam` matches `VietNam`). + +Examples to try with `searchNormalize: true`: +- Latin (French/Spanish): `creme` finds `Crème brûlée`, `nino` finds `Niño` +- German: `Munchen` finds `München`, `Koln` finds `Köln`, `Madchen` finds `Mädchen` +- Norwegian: `Alesund` finds `Ålesund` (note: `ø`, `æ` are atomic and **not** stripped — `Tromso` does **not** find `Tromsø`) +- Swedish: `Goteborg` finds `Göteborg`, `Malmo` finds `Malmö` +- Finnish: `Jyvaskyla` finds `Jyväskylä` +- Greek: `Ενα` finds `Ένα` +- Cyrillic: `Ежик` finds `Ёжик` +- Vietnamese: `Viet Nam` finds `Việt Nam`, `Ha Noi` finds `Hà Nội` +- Arabic: `مرحبا` finds `مُرَحَّباً` (tashkeel stripped) +- Korean: searching `한국어` matches `한국어` (NFD decomposes Hangul syllables to jamo; both sides are normalized symmetrically) +- Chinese / Japanese kanji & katakana: characters have no combining marks, so they are matched as-is (previously broken under the old regex) +- Intra-word punctuation: `coop` finds `co-op`, `email` finds `e-mail` + +Because punctuation and whitespace are stripped, multi-word labels collapse into a single token: `"Foo Bar"` and `"FooBar"` are indistinguishable under `searchNormalize: true`. If you need exact matching on punctuation or word boundaries, use `searchNormalize: false`. + +With `searchNormalize: false`, matching remains case-insensitive and substring-based, but no normalization is applied. This means partial queries can still match, but accents/diacritics and other equivalent normalized forms are not folded. + +
Multi-language - searchNormalize: true + +
+
+ +
Multi-language - searchNormalize: false + +```js +const multiLanguageOptions = [ + // Latin (French / Spanish) + { label: 'Crème brûlée', value: 'creme-brulee', description: 'French dessert' }, + { label: 'Niño', value: 'nino', description: 'Spanish word for child' }, + // German + { label: 'München', value: 'munchen', description: 'Stadt in Deutschland' }, + { label: 'Mädchen', value: 'madchen', description: 'Junges weibliches Kind' }, + { label: 'Größe', value: 'grosse', description: 'Maß für die Ausdehnung' }, + // Norwegian + { label: 'Ålesund', value: 'alesund', description: 'By på vestlandskysten' }, + { label: 'Bjørn', value: 'bjorn', description: 'Stort pattedyr' }, + // Swedish + { label: 'Göteborg', value: 'goteborg', description: 'Stad på Sveriges västkust' }, + { label: 'Malmö', value: 'malmo', description: 'Stad i södra Sverige' }, + // Finnish + { label: 'Jyväskylä', value: 'jyvaskyla', description: 'Kaupunki Keski-Suomessa' }, + { label: 'Hämeenlinna', value: 'hameenlinna', description: 'Kaupunki Kanta-Hämeessä' }, + // Greek + { label: 'Ένα', value: 'ena', description: 'Πρώτο στοιχείο' }, + { label: 'Αθήνα', value: 'athina', description: 'Πρωτεύουσα της Ελλάδας' }, + // Cyrillic + { label: 'Ёжик', value: 'yozhik', description: 'Колючий зверёк' }, + { label: 'Москва', value: 'moskva', description: 'Столица России' }, + // Vietnamese + { label: 'Việt Nam', value: 'vietnam', description: 'Quốc gia Đông Nam Á' }, + { label: 'Hà Nội', value: 'hanoi', description: 'Thủ đô của Việt Nam' }, + // Chinese + { label: '北京', value: 'beijing', description: '中国的首都' }, + { label: '你好', value: 'nihao', description: '问候语' }, + // Japanese + { label: '東京', value: 'tokyo', description: '日本の首都' }, + { label: 'カタカナ', value: 'katakana', description: '日本の文字' }, + // Korean + { label: '서울', value: 'seoul', description: '한국의 수도' }, + { label: '한국어', value: 'hangugeo', description: '한국의 언어' }, + // Arabic + { label: 'مُرَحَّباً', value: 'marhaba', description: 'تحية' }, + // Thai + { label: 'กรุงเทพ', value: 'bangkok', description: 'เมืองหลวงของประเทศไทย' }, +]; + +VirtualSelect.init({ + ele: '#multi-language-search-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + searchNormalize: true, +}); + +VirtualSelect.init({ + ele: '#multi-language-search-no-normalize-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + searchNormalize: false, +}); +``` + +### Multi-language with values as tags + +Multi-select variant — chosen options render as removable tags. Search normalization works the same way across all scripts. + +
Tags - searchNormalize: true + +
+
+ +
Tags - searchNormalize: false + +```js +VirtualSelect.init({ + ele: '#multi-language-tags-search-select', + options: multiLanguageOptions, + multiple: true, + search: true, + hasOptionDescription: true, + showValueAsTags: true, + searchNormalize: true, +}); + +VirtualSelect.init({ + ele: '#multi-language-tags-search-no-normalize-select', + options: multiLanguageOptions, + multiple: true, + search: true, + hasOptionDescription: true, + showValueAsTags: true, + searchNormalize: false, +}); +``` + +### Multi-language as popup + +Popup variant — the dropbox renders as a popup (using `popupDropboxBreakpoint: '3000px'` for demo so the popup is visible on desktop too). Diacritic-insensitive search behaves identically inside the popup. + +
Popup - searchNormalize: true + +
+
+ +
Popup - searchNormalize: false + +```js +VirtualSelect.init({ + ele: '#multi-language-popup-search-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + popupDropboxBreakpoint: '3000px', + searchNormalize: true, +}); + +VirtualSelect.init({ + ele: '#multi-language-popup-search-no-normalize-select', + options: multiLanguageOptions, + search: true, + hasOptionDescription: true, + popupDropboxBreakpoint: '3000px', + searchNormalize: false, +}); +``` + +> **Note on Thai and Japanese hiragana**: stripping combining marks affects Thai vowel signs (e.g. `สวัสดี` → `สวสด`) and Japanese hiragana voicing marks (e.g. `が` → `か`). This enables fuzzy matching but loses some semantic precision. Use `searchNormalize: false` if exact-match behavior is required for those scripts. + ## Show dropbox as popup Show dropbox as popup on small screens like mobile. diff --git a/package-lock.json b/package-lock.json index ee5af19..5840ba5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,52 +1,53 @@ { "name": "virtual-select-plugin", - "version": "1.1.4", + "version": "1.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "virtual-select-plugin", - "version": "1.1.4", + "version": "1.1.5", "license": "ISC", "dependencies": { "tooltip-plugin": "^1.0.16" }, "devDependencies": { - "@babel/core": "^7.28.3", - "@babel/preset-env": "^7.28.3", - "autoprefixer": "^10.4.21", - "babel-loader": "^10.0.0", - "css-loader": "^7.1.2", - "cypress": "^14.5.4", - "cypress-real-events": "^1.14.0", + "@babel/core": "^7.29.0", + "@babel/preset-env": "^7.29.2", + "autoprefixer": "^10.5.0", + "babel-loader": "^10.1.1", + "css-loader": "^7.1.4", + "cypress": "^15.14.1", + "cypress-real-events": "^1.15.0", "docsify-cli": "^4.4.4", "eslint": "^8.57.1", "eslint-config-airbnb-base": "^15.0.0", "eslint-import-resolver-webpack": "^0.13.10", "eslint-plugin-import": "^2.32.0", "eslint-plugin-sonarjs": "^3.0.4", - "filemanager-webpack-plugin": "^9.0.1", + "filemanager-webpack-plugin": "^10.0.1", "mini-css-extract-plugin": "^2.9.4", "popover-plugin": "^1.0.13", - "postcss-loader": "^8.1.1", - "sass": "^1.90.0", - "sass-loader": "^16.0.5", - "stylelint": "^16.23.1", + "postcss-loader": "^8.2.1", + "sass": "^1.99.0", + "sass-loader": "^16.0.7", + "stylelint": "^16.26.1", "stylelint-config-sass-guidelines": "^12.1.0", - "typescript": "^5.9.2", + "ts-api-utils": "^2.5.0", + "typescript": "^5.9.3", "unminified-webpack-plugin": "^3.0.0", - "webpack": "^5.101.3", - "webpack-cli": "^6.0.1" + "webpack": "^5.106.2", + "webpack-cli": "^7.0.2" } }, "node_modules/@babel/code-frame": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", - "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", + "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" }, @@ -55,9 +56,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.5.tgz", - "integrity": "sha512-6uFXyCayocRbqhZOB+6XcuZbkMNimwfVGFji8CTZnCzOHVGvDqzvitu1re2AU5LROliz7eQPhB8CpAMvnx9EjA==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz", + "integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==", "dev": true, "license": "MIT", "engines": { @@ -65,22 +66,22 @@ } }, "node_modules/@babel/core": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz", - "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", + "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.5", - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-module-transforms": "^7.28.3", - "@babel/helpers": "^7.28.4", - "@babel/parser": "^7.28.5", - "@babel/template": "^7.27.2", - "@babel/traverse": "^7.28.5", - "@babel/types": "^7.28.5", + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helpers": "^7.28.6", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/traverse": "^7.29.0", + "@babel/types": "^7.29.0", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", @@ -97,14 +98,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.5.tgz", - "integrity": "sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==", + "version": "7.29.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.1.tgz", + "integrity": "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.28.5", - "@babel/types": "^7.28.5", + "@babel/parser": "^7.29.0", + "@babel/types": "^7.29.0", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -127,13 +128,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.27.2", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", - "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz", + "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.27.2", + "@babel/compat-data": "^7.28.6", "@babel/helper-validator-option": "^7.27.1", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", @@ -144,18 +145,18 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.28.5.tgz", - "integrity": "sha512-q3WC4JfdODypvxArsJQROfupPBq9+lMwjKq7C33GhbFYJsufD0yd/ziwD+hJucLeWsnFPWZjsU2DNFqBPE7jwQ==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.28.6.tgz", + "integrity": "sha512-dTOdvsjnG3xNT9Y0AUg1wAl38y+4Rl4sf9caSQZOXdNqVn+H+HbbJ4IyyHaIqNR6SW9oJpA/RuRjsjCw2IdIow==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.27.3", "@babel/helper-member-expression-to-functions": "^7.28.5", "@babel/helper-optimise-call-expression": "^7.27.1", - "@babel/helper-replace-supers": "^7.27.1", + "@babel/helper-replace-supers": "^7.28.6", "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", - "@babel/traverse": "^7.28.5", + "@babel/traverse": "^7.28.6", "semver": "^6.3.1" }, "engines": { @@ -184,17 +185,17 @@ } }, "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.5.tgz", - "integrity": "sha512-uJnGFcPsWQK8fvjgGP5LZUZZsYGIoPeRjSF5PGwrelYgq7Q15/Ft9NGFp1zglwgIv//W0uG4BevRuSJRyylZPg==", + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.8.tgz", + "integrity": "sha512-47UwBLPpQi1NoWzLuHNjRoHlYXMwIJoBf7MFou6viC/sIHWYygpvr0B6IAyh5sBdA2nr2LPIRww8lfaUVQINBA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-plugin-utils": "^7.27.1", - "debug": "^4.4.1", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", + "debug": "^4.4.3", "lodash.debounce": "^4.0.8", - "resolve": "^1.22.10" + "resolve": "^1.22.11" }, "peerDependencies": { "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" @@ -225,29 +226,29 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", - "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz", + "integrity": "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.27.1", - "@babel/types": "^7.27.1" + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.28.3", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.3.tgz", - "integrity": "sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz", + "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.27.1", - "@babel/helper-validator-identifier": "^7.27.1", - "@babel/traverse": "^7.28.3" + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-validator-identifier": "^7.28.5", + "@babel/traverse": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -270,9 +271,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", - "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz", + "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==", "dev": true, "license": "MIT", "engines": { @@ -298,15 +299,15 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.27.1.tgz", - "integrity": "sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.28.6.tgz", + "integrity": "sha512-mq8e+laIk94/yFec3DxSjCRD2Z0TAjhVbEJY3UQrlwVo15Lmt7C2wAUbK4bjnTs4APkwsYLTahXRraQXhb1WCg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-member-expression-to-functions": "^7.28.5", "@babel/helper-optimise-call-expression": "^7.27.1", - "@babel/traverse": "^7.27.1" + "@babel/traverse": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -360,42 +361,42 @@ } }, "node_modules/@babel/helper-wrap-function": { - "version": "7.28.3", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.28.3.tgz", - "integrity": "sha512-zdf983tNfLZFletc0RRXYrHrucBEg95NIFMkn6K9dbeMYnsgHaSBGcQqdsCSStG2PYwRre0Qc2NNSCXbG+xc6g==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.28.6.tgz", + "integrity": "sha512-z+PwLziMNBeSQJonizz2AGnndLsP2DeGHIxDAn+wdHOGuo4Fo1x1HBPPXeE9TAOPHNNWQKCSlA2VZyYyyibDnQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.27.2", - "@babel/traverse": "^7.28.3", - "@babel/types": "^7.28.2" + "@babel/template": "^7.28.6", + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.4.tgz", - "integrity": "sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w==", + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.2.tgz", + "integrity": "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.4" + "@babel/template": "^7.28.6", + "@babel/types": "^7.29.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", - "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz", + "integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.28.5" + "@babel/types": "^7.29.0" }, "bin": { "parser": "bin/babel-parser.js" @@ -472,14 +473,14 @@ } }, "node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": { - "version": "7.28.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.28.3.tgz", - "integrity": "sha512-b6YTX108evsvE4YgWyQ921ZAFFQm3Bn+CA3+ZXlNVnPhx+UfsVURoPjfGAPCjBgrqo30yX/C2nZGX96DxvR9Iw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.28.6.tgz", + "integrity": "sha512-a0aBScVTlNaiUe35UtfxAN7A/tehvvG4/ByO6+46VPKTRSlfnAFsgKy0FUh+qAkQrDTmhDkT+IBOKlOoMUxQ0g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", - "@babel/traverse": "^7.28.3" + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/traverse": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -502,13 +503,13 @@ } }, "node_modules/@babel/plugin-syntax-import-assertions": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.27.1.tgz", - "integrity": "sha512-UT/Jrhw57xg4ILHLFnzFpPDlMbcdEicaAtjPQpbj9wa8T4r5KVWCimHcL/460g8Ht0DMxDyjsLgiWSkVjnwPFg==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.28.6.tgz", + "integrity": "sha512-pSJUpFHdx9z5nqTSirOCMtYVP2wFgoWhP0p3g8ONK/4IHhLIBd0B9NYqAvIUAhq+OkhO4VM1tENCt0cjlsNShw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -518,13 +519,13 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz", - "integrity": "sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.28.6.tgz", + "integrity": "sha512-jiLC0ma9XkQT3TKJ9uYvlakm66Pamywo+qwL+oL8HJOvc6TWdZXVfhqJr8CCzbSGUAbDOzlGHJC1U+vRfLQDvw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -567,15 +568,15 @@ } }, "node_modules/@babel/plugin-transform-async-generator-functions": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.28.0.tgz", - "integrity": "sha512-BEOdvX4+M765icNPZeidyADIvQ1m1gmunXufXxvRESy/jNNyfovIqUyE7MVgGBjWktCoJlzvFA1To2O4ymIO3Q==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.29.0.tgz", + "integrity": "sha512-va0VdWro4zlBr2JsXC+ofCPB2iG12wPtVGTWFx2WLDOM3nYQZZIGP82qku2eW/JR83sD+k2k+CsNtyEbUqhU6w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-remap-async-to-generator": "^7.27.1", - "@babel/traverse": "^7.28.0" + "@babel/traverse": "^7.29.0" }, "engines": { "node": ">=6.9.0" @@ -585,14 +586,14 @@ } }, "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.27.1.tgz", - "integrity": "sha512-NREkZsZVJS4xmTr8qzE5y8AfIPqsdQfRuUiLRTEzb7Qii8iFWCyDKaUV2c0rCuh4ljDZ98ALHP/PetiBV2nddA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.28.6.tgz", + "integrity": "sha512-ilTRcmbuXjsMmcZ3HASTe4caH5Tpo93PkTxF9oG2VZsSWsahydmcEHhix9Ik122RcTnZnUzPbmux4wh1swfv7g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-remap-async-to-generator": "^7.27.1" }, "engines": { @@ -619,13 +620,13 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.28.5.tgz", - "integrity": "sha512-45DmULpySVvmq9Pj3X9B+62Xe+DJGov27QravQJU1LLcapR6/10i+gYVAucGGJpHBp5mYxIMK4nDAT/QDLr47g==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.28.6.tgz", + "integrity": "sha512-tt/7wOtBmwHPNMPu7ax4pdPz6shjFrmHDghvNC+FG9Qvj7D6mJcoRQIF5dy4njmxR941l6rgtvfSB2zX3VlUIw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -635,14 +636,14 @@ } }, "node_modules/@babel/plugin-transform-class-properties": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.27.1.tgz", - "integrity": "sha512-D0VcalChDMtuRvJIu3U/fwWjf8ZMykz5iZsg77Nuj821vCKI3zCyRLwRdWbsuJ/uRwZhZ002QtCqIkwC/ZkvbA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.28.6.tgz", + "integrity": "sha512-dY2wS3I2G7D697VHndN91TJr8/AAfXQNt5ynCTI/MpxMsSzHp+52uNivYT5wCPax3whc47DR8Ba7cmlQMg24bw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-class-features-plugin": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -652,14 +653,14 @@ } }, "node_modules/@babel/plugin-transform-class-static-block": { - "version": "7.28.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.28.3.tgz", - "integrity": "sha512-LtPXlBbRoc4Njl/oh1CeD/3jC+atytbnf/UqLoqTDcEYGUPj022+rvfkbDYieUrSj3CaV4yHDByPE+T2HwfsJg==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.28.6.tgz", + "integrity": "sha512-rfQ++ghVwTWTqQ7w8qyDxL1XGihjBss4CmTgGRCTAC9RIbhVpyp4fOeZtta0Lbf+dTNIVJer6ych2ibHwkZqsQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.28.3", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-class-features-plugin": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -669,18 +670,18 @@ } }, "node_modules/@babel/plugin-transform-classes": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.28.4.tgz", - "integrity": "sha512-cFOlhIYPBv/iBoc+KS3M6et2XPtbT2HiCRfBXWtfpc9OAyostldxIf9YAYB6ypURBBbx+Qv6nyrLzASfJe+hBA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.28.6.tgz", + "integrity": "sha512-EF5KONAqC5zAqT783iMGuM2ZtmEBy+mJMOKl2BCvPZ2lVrwvXnB6o+OBWCS+CoeCCpVRF2sA2RBKUxvT8tQT5Q==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.27.3", - "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-compilation-targets": "^7.28.6", "@babel/helper-globals": "^7.28.0", - "@babel/helper-plugin-utils": "^7.27.1", - "@babel/helper-replace-supers": "^7.27.1", - "@babel/traverse": "^7.28.4" + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/helper-replace-supers": "^7.28.6", + "@babel/traverse": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -690,14 +691,14 @@ } }, "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.27.1.tgz", - "integrity": "sha512-lj9PGWvMTVksbWiDT2tW68zGS/cyo4AkZ/QTp0sQT0mjPopCmrSkzxeXkznjqBxzDI6TclZhOJbBmbBLjuOZUw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.28.6.tgz", + "integrity": "sha512-bcc3k0ijhHbc2lEfpFHgx7eYw9KNXqOerKWfzbxEHUGKnS3sz9C4CNL9OiFN1297bDNfUiSO7DaLzbvHQQQ1BQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", - "@babel/template": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/template": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -724,14 +725,14 @@ } }, "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.27.1.tgz", - "integrity": "sha512-gEbkDVGRvjj7+T1ivxrfgygpT7GUd4vmODtYpbs0gZATdkX8/iSnOtZSxiZnsgm1YjTgjI6VKBGSJJevkrclzw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.28.6.tgz", + "integrity": "sha512-SljjowuNKB7q5Oayv4FoPzeB74g3QgLt8IVJw9ADvWy3QnUb/01aw8I4AVv8wYnPvQz2GDDZ/g3GhcNyDBI4Bg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -757,14 +758,14 @@ } }, "node_modules/@babel/plugin-transform-duplicate-named-capturing-groups-regex": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.27.1.tgz", - "integrity": "sha512-hkGcueTEzuhB30B3eJCbCYeCaaEQOmQR0AdvzpD4LoN0GXMWzzGSuRrxR2xTnCrvNbVwK9N6/jQ92GSLfiZWoQ==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.29.0.tgz", + "integrity": "sha512-zBPcW2lFGxdiD8PUnPwJjag2J9otbcLQzvbiOzDxpYXyCuYX9agOwMPGn1prVH0a4qzhCKu24rlH4c1f7yA8rw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -790,14 +791,14 @@ } }, "node_modules/@babel/plugin-transform-explicit-resource-management": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-explicit-resource-management/-/plugin-transform-explicit-resource-management-7.28.0.tgz", - "integrity": "sha512-K8nhUcn3f6iB+P3gwCv/no7OdzOZQcKchW6N389V6PD8NUWKZHzndOd9sPDVbMoBsbmjMqlB4L9fm+fEFNVlwQ==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-explicit-resource-management/-/plugin-transform-explicit-resource-management-7.28.6.tgz", + "integrity": "sha512-Iao5Konzx2b6g7EPqTy40UZbcdXE126tTxVFr/nAIj+WItNxjKSYTEw3RC+A2/ZetmdJsgueL1KhaMCQHkLPIg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", - "@babel/plugin-transform-destructuring": "^7.28.0" + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/plugin-transform-destructuring": "^7.28.5" }, "engines": { "node": ">=6.9.0" @@ -807,13 +808,13 @@ } }, "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.28.5.tgz", - "integrity": "sha512-D4WIMaFtwa2NizOp+dnoFjRez/ClKiC2BqqImwKd1X28nqBtZEyCYJ2ozQrrzlxAFrcrjxo39S6khe9RNDlGzw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.28.6.tgz", + "integrity": "sha512-WitabqiGjV/vJ0aPOLSFfNY1u9U3R7W36B03r5I2KoNix+a3sOhJ3pKFB3R5It9/UiK78NiO0KE9P21cMhlPkw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -874,13 +875,13 @@ } }, "node_modules/@babel/plugin-transform-json-strings": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.27.1.tgz", - "integrity": "sha512-6WVLVJiTjqcQauBhn1LkICsR2H+zm62I3h9faTDKt1qP4jn2o72tSvqMwtGFKGTpojce0gJs+76eZ2uCHRZh0Q==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.28.6.tgz", + "integrity": "sha512-Nr+hEN+0geQkzhbdgQVPoqr47lZbm+5fCUmO70722xJZd0Mvb59+33QLImGj6F+DkK3xgDi1YVysP8whD6FQAw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -906,13 +907,13 @@ } }, "node_modules/@babel/plugin-transform-logical-assignment-operators": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.28.5.tgz", - "integrity": "sha512-axUuqnUTBuXyHGcJEVVh9pORaN6wC5bYfE7FGzPiaWa3syib9m7g+/IT/4VgCOe2Upef43PHzeAvcrVek6QuuA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.28.6.tgz", + "integrity": "sha512-+anKKair6gpi8VsM/95kmomGNMD0eLz1NQ8+Pfw5sAwWH9fGYXT50E55ZpV0pHUHWf6IUTWPM+f/7AAff+wr9A==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -955,14 +956,14 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.27.1.tgz", - "integrity": "sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.28.6.tgz", + "integrity": "sha512-jppVbf8IV9iWWwWTQIxJMAJCWBuuKx71475wHwYytrRGQ2CWiDvYlADQno3tcYpS/T2UUWFQp3nVtYfK/YBQrA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -972,16 +973,16 @@ } }, "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.28.5.tgz", - "integrity": "sha512-vn5Jma98LCOeBy/KpeQhXcV2WZgaRUtjwQmjoBuLNlOmkg0fB5pdvYVeWRYI69wWKwK2cD1QbMiUQnoujWvrew==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.29.0.tgz", + "integrity": "sha512-PrujnVFbOdUpw4UHiVwKvKRLMMic8+eC0CuNlxjsyZUiBjhFdPsewdXCkveh2KqBA9/waD0W1b4hXSOBQJezpQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.28.3", - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-validator-identifier": "^7.28.5", - "@babel/traverse": "^7.28.5" + "@babel/traverse": "^7.29.0" }, "engines": { "node": ">=6.9.0" @@ -1008,14 +1009,14 @@ } }, "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.27.1.tgz", - "integrity": "sha512-SstR5JYy8ddZvD6MhV0tM/j16Qds4mIpJTOd1Yu9J9pJjH93bxHECF7pgtc28XvkzTD6Pxcm/0Z73Hvk7kb3Ng==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.29.0.tgz", + "integrity": "sha512-1CZQA5KNAD6ZYQLPw7oi5ewtDNxH/2vuCh+6SmvgDfhumForvs8a1o9n0UrEoBD8HU4djO2yWngTQlXl1NDVEQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1041,13 +1042,13 @@ } }, "node_modules/@babel/plugin-transform-nullish-coalescing-operator": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.27.1.tgz", - "integrity": "sha512-aGZh6xMo6q9vq1JGcw58lZ1Z0+i0xB2x0XaauNIUXd6O1xXc3RwoWEBlsTQrY4KQ9Jf0s5rgD6SiNkaUdJegTA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.28.6.tgz", + "integrity": "sha512-3wKbRgmzYbw24mDJXT7N+ADXw8BC/imU9yo9c9X9NKaLF1fW+e5H1U5QjMUBe4Qo4Ox/o++IyUkl1sVCLgevKg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1057,13 +1058,13 @@ } }, "node_modules/@babel/plugin-transform-numeric-separator": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.27.1.tgz", - "integrity": "sha512-fdPKAcujuvEChxDBJ5c+0BTaS6revLV7CJL08e4m3de8qJfNIuCc2nc7XJYOjBoTMJeqSmwXJ0ypE14RCjLwaw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.28.6.tgz", + "integrity": "sha512-SJR8hPynj8outz+SlStQSwvziMN4+Bq99it4tMIf5/Caq+3iOc0JtKyse8puvyXkk3eFRIA5ID/XfunGgO5i6w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1073,17 +1074,17 @@ } }, "node_modules/@babel/plugin-transform-object-rest-spread": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.4.tgz", - "integrity": "sha512-373KA2HQzKhQCYiRVIRr+3MjpCObqzDlyrM6u4I201wL8Mp2wHf7uB8GhDwis03k2ti8Zr65Zyyqs1xOxUF/Ew==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.6.tgz", + "integrity": "sha512-5rh+JR4JBC4pGkXLAcYdLHZjXudVxWMXbB6u6+E9lRL5TrGVbHt1TjxGbZ8CkmYw9zjkB7jutzOROArsqtncEA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-plugin-utils": "^7.27.1", - "@babel/plugin-transform-destructuring": "^7.28.0", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/plugin-transform-destructuring": "^7.28.5", "@babel/plugin-transform-parameters": "^7.27.7", - "@babel/traverse": "^7.28.4" + "@babel/traverse": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1110,13 +1111,13 @@ } }, "node_modules/@babel/plugin-transform-optional-catch-binding": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.27.1.tgz", - "integrity": "sha512-txEAEKzYrHEX4xSZN4kJ+OfKXFVSWKB2ZxM9dpcE3wT7smwkNmXo5ORRlVzMVdJbD+Q8ILTgSD7959uj+3Dm3Q==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.28.6.tgz", + "integrity": "sha512-R8ja/Pyrv0OGAvAXQhSTmWyPJPml+0TMqXlO5w+AsMEiwb2fg3WkOvob7UxFSL3OIttFSGSRFKQsOhJ/X6HQdQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1126,13 +1127,13 @@ } }, "node_modules/@babel/plugin-transform-optional-chaining": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.28.5.tgz", - "integrity": "sha512-N6fut9IZlPnjPwgiQkXNhb+cT8wQKFlJNqcZkWlcTqkcqx6/kU4ynGmLFoa4LViBSirn05YAwk+sQBbPfxtYzQ==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.28.6.tgz", + "integrity": "sha512-A4zobikRGJTsX9uqVFdafzGkqD30t26ck2LmOzAuLL8b2x6k3TIqRiT2xVvA9fNmFeTX484VpsdgmKNA0bS23w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" }, "engines": { @@ -1159,14 +1160,14 @@ } }, "node_modules/@babel/plugin-transform-private-methods": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.27.1.tgz", - "integrity": "sha512-10FVt+X55AjRAYI9BrdISN9/AQWHqldOeZDUoLyif1Kn05a56xVBXb8ZouL8pZ9jem8QpXaOt8TS7RHUIS+GPA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.28.6.tgz", + "integrity": "sha512-piiuapX9CRv7+0st8lmuUlRSmX6mBcVeNQ1b4AYzJxfCMuBfB0vBXDiGSmm03pKJw1v6cZ8KSeM+oUnM6yAExg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-class-features-plugin": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1176,15 +1177,15 @@ } }, "node_modules/@babel/plugin-transform-private-property-in-object": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.27.1.tgz", - "integrity": "sha512-5J+IhqTi1XPa0DXF83jYOaARrX+41gOewWbkPyjMNRDqgOCqdffGh8L3f/Ek5utaEBZExjSAzcyjmV9SSAWObQ==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.28.6.tgz", + "integrity": "sha512-b97jvNSOb5+ehyQmBpmhOCiUC5oVK4PMnpRvO7+ymFBoqYjeDHIU9jnrNUuwHOiL9RpGDoKBpSViarV+BU+eVA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.27.1", - "@babel/helper-create-class-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-create-class-features-plugin": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1210,13 +1211,13 @@ } }, "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.28.4.tgz", - "integrity": "sha512-+ZEdQlBoRg9m2NnzvEeLgtvBMO4tkFBw5SQIUgLICgTrumLoU7lr+Oghi6km2PFj+dbUt2u1oby2w3BDO9YQnA==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.29.0.tgz", + "integrity": "sha512-FijqlqMA7DmRdg/aINBSs04y8XNTYw/lr1gJ2WsmBnnaNw1iS43EPkJW+zK7z65auG3AWRFXWj+NcTQwYptUog==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1226,14 +1227,14 @@ } }, "node_modules/@babel/plugin-transform-regexp-modifiers": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regexp-modifiers/-/plugin-transform-regexp-modifiers-7.27.1.tgz", - "integrity": "sha512-TtEciroaiODtXvLZv4rmfMhkCv8jx3wgKpL68PuiPh2M4fvz5jhsA7697N1gMvkvr/JTF13DrFYyEbY9U7cVPA==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regexp-modifiers/-/plugin-transform-regexp-modifiers-7.28.6.tgz", + "integrity": "sha512-QGWAepm9qxpaIs7UM9FvUSnCGlb8Ua1RhyM4/veAxLwt3gMat/LSGrZixyuj4I6+Kn9iwvqCyPTtbdxanYoWYg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1275,13 +1276,13 @@ } }, "node_modules/@babel/plugin-transform-spread": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.27.1.tgz", - "integrity": "sha512-kpb3HUqaILBJcRFVhFUs6Trdd4mkrzcGXss+6/mxUd273PfbWqSDHRzMT2234gIg2QYfAjvXLSquP1xECSg09Q==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.28.6.tgz", + "integrity": "sha512-9U4QObUC0FtJl05AsUcodau/RWDytrU6uKgkxu09mLR9HLDAtUMoPuuskm5huQsoktmsYpI+bGmq+iapDcriKA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" }, "engines": { @@ -1356,14 +1357,14 @@ } }, "node_modules/@babel/plugin-transform-unicode-property-regex": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.27.1.tgz", - "integrity": "sha512-uW20S39PnaTImxp39O5qFlHLS9LJEmANjMG7SxIhap8rCHqu0Ik+tLEPX5DKmHn6CsWQ7j3lix2tFOa5YtL12Q==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.28.6.tgz", + "integrity": "sha512-4Wlbdl/sIZjzi/8St0evF0gEZrgOswVO6aOzqxh1kDZOl9WmLrHq2HtGhnOJZmHZYKP8WZ1MDLCt5DAWwRo57A==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1390,14 +1391,14 @@ } }, "node_modules/@babel/plugin-transform-unicode-sets-regex": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.27.1.tgz", - "integrity": "sha512-EtkOujbc4cgvb0mlpQefi4NTPBzhSIevblFevACNLUspmrALgmEBdL/XfnyyITfd8fKBZrZys92zOWcik7j9Tw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.28.6.tgz", + "integrity": "sha512-/wHc/paTUmsDYN7SZkpWxogTOBNnlx7nBQYfy6JJlCT7G3mVhltk3e++N7zV0XfgGsrqBxd4rJQt9H16I21Y1Q==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.27.1", - "@babel/helper-plugin-utils": "^7.27.1" + "@babel/helper-create-regexp-features-plugin": "^7.28.5", + "@babel/helper-plugin-utils": "^7.28.6" }, "engines": { "node": ">=6.9.0" @@ -1407,81 +1408,81 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.28.5.tgz", - "integrity": "sha512-S36mOoi1Sb6Fz98fBfE+UZSpYw5mJm0NUHtIKrOuNcqeFauy1J6dIvXm2KRVKobOSaGq4t/hBXdN4HGU3wL9Wg==", + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.29.2.tgz", + "integrity": "sha512-DYD23veRYGvBFhcTY1iUvJnDNpuqNd/BzBwCvzOTKUnJjKg5kpUBh3/u9585Agdkgj+QuygG7jLfOPWMa2KVNw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.28.5", - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-plugin-utils": "^7.27.1", + "@babel/compat-data": "^7.29.0", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", "@babel/helper-validator-option": "^7.27.1", "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.28.5", "@babel/plugin-bugfix-safari-class-field-initializer-scope": "^7.27.1", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.27.1", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.27.1", - "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.28.3", + "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.28.6", "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", - "@babel/plugin-syntax-import-assertions": "^7.27.1", - "@babel/plugin-syntax-import-attributes": "^7.27.1", + "@babel/plugin-syntax-import-assertions": "^7.28.6", + "@babel/plugin-syntax-import-attributes": "^7.28.6", "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6", "@babel/plugin-transform-arrow-functions": "^7.27.1", - "@babel/plugin-transform-async-generator-functions": "^7.28.0", - "@babel/plugin-transform-async-to-generator": "^7.27.1", + "@babel/plugin-transform-async-generator-functions": "^7.29.0", + "@babel/plugin-transform-async-to-generator": "^7.28.6", "@babel/plugin-transform-block-scoped-functions": "^7.27.1", - "@babel/plugin-transform-block-scoping": "^7.28.5", - "@babel/plugin-transform-class-properties": "^7.27.1", - "@babel/plugin-transform-class-static-block": "^7.28.3", - "@babel/plugin-transform-classes": "^7.28.4", - "@babel/plugin-transform-computed-properties": "^7.27.1", + "@babel/plugin-transform-block-scoping": "^7.28.6", + "@babel/plugin-transform-class-properties": "^7.28.6", + "@babel/plugin-transform-class-static-block": "^7.28.6", + "@babel/plugin-transform-classes": "^7.28.6", + "@babel/plugin-transform-computed-properties": "^7.28.6", "@babel/plugin-transform-destructuring": "^7.28.5", - "@babel/plugin-transform-dotall-regex": "^7.27.1", + "@babel/plugin-transform-dotall-regex": "^7.28.6", "@babel/plugin-transform-duplicate-keys": "^7.27.1", - "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.27.1", + "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.29.0", "@babel/plugin-transform-dynamic-import": "^7.27.1", - "@babel/plugin-transform-explicit-resource-management": "^7.28.0", - "@babel/plugin-transform-exponentiation-operator": "^7.28.5", + "@babel/plugin-transform-explicit-resource-management": "^7.28.6", + "@babel/plugin-transform-exponentiation-operator": "^7.28.6", "@babel/plugin-transform-export-namespace-from": "^7.27.1", "@babel/plugin-transform-for-of": "^7.27.1", "@babel/plugin-transform-function-name": "^7.27.1", - "@babel/plugin-transform-json-strings": "^7.27.1", + "@babel/plugin-transform-json-strings": "^7.28.6", "@babel/plugin-transform-literals": "^7.27.1", - "@babel/plugin-transform-logical-assignment-operators": "^7.28.5", + "@babel/plugin-transform-logical-assignment-operators": "^7.28.6", "@babel/plugin-transform-member-expression-literals": "^7.27.1", "@babel/plugin-transform-modules-amd": "^7.27.1", - "@babel/plugin-transform-modules-commonjs": "^7.27.1", - "@babel/plugin-transform-modules-systemjs": "^7.28.5", + "@babel/plugin-transform-modules-commonjs": "^7.28.6", + "@babel/plugin-transform-modules-systemjs": "^7.29.0", "@babel/plugin-transform-modules-umd": "^7.27.1", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.27.1", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.29.0", "@babel/plugin-transform-new-target": "^7.27.1", - "@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1", - "@babel/plugin-transform-numeric-separator": "^7.27.1", - "@babel/plugin-transform-object-rest-spread": "^7.28.4", + "@babel/plugin-transform-nullish-coalescing-operator": "^7.28.6", + "@babel/plugin-transform-numeric-separator": "^7.28.6", + "@babel/plugin-transform-object-rest-spread": "^7.28.6", "@babel/plugin-transform-object-super": "^7.27.1", - "@babel/plugin-transform-optional-catch-binding": "^7.27.1", - "@babel/plugin-transform-optional-chaining": "^7.28.5", + "@babel/plugin-transform-optional-catch-binding": "^7.28.6", + "@babel/plugin-transform-optional-chaining": "^7.28.6", "@babel/plugin-transform-parameters": "^7.27.7", - "@babel/plugin-transform-private-methods": "^7.27.1", - "@babel/plugin-transform-private-property-in-object": "^7.27.1", + "@babel/plugin-transform-private-methods": "^7.28.6", + "@babel/plugin-transform-private-property-in-object": "^7.28.6", "@babel/plugin-transform-property-literals": "^7.27.1", - "@babel/plugin-transform-regenerator": "^7.28.4", - "@babel/plugin-transform-regexp-modifiers": "^7.27.1", + "@babel/plugin-transform-regenerator": "^7.29.0", + "@babel/plugin-transform-regexp-modifiers": "^7.28.6", "@babel/plugin-transform-reserved-words": "^7.27.1", "@babel/plugin-transform-shorthand-properties": "^7.27.1", - "@babel/plugin-transform-spread": "^7.27.1", + "@babel/plugin-transform-spread": "^7.28.6", "@babel/plugin-transform-sticky-regex": "^7.27.1", "@babel/plugin-transform-template-literals": "^7.27.1", "@babel/plugin-transform-typeof-symbol": "^7.27.1", "@babel/plugin-transform-unicode-escapes": "^7.27.1", - "@babel/plugin-transform-unicode-property-regex": "^7.27.1", + "@babel/plugin-transform-unicode-property-regex": "^7.28.6", "@babel/plugin-transform-unicode-regex": "^7.27.1", - "@babel/plugin-transform-unicode-sets-regex": "^7.27.1", + "@babel/plugin-transform-unicode-sets-regex": "^7.28.6", "@babel/preset-modules": "0.1.6-no-external-plugins", - "babel-plugin-polyfill-corejs2": "^0.4.14", - "babel-plugin-polyfill-corejs3": "^0.13.0", - "babel-plugin-polyfill-regenerator": "^0.6.5", - "core-js-compat": "^3.43.0", + "babel-plugin-polyfill-corejs2": "^0.4.15", + "babel-plugin-polyfill-corejs3": "^0.14.0", + "babel-plugin-polyfill-regenerator": "^0.6.6", + "core-js-compat": "^3.48.0", "semver": "^6.3.1" }, "engines": { @@ -1507,33 +1508,33 @@ } }, "node_modules/@babel/template": { - "version": "7.27.2", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", - "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", + "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/parser": "^7.27.2", - "@babel/types": "^7.27.1" + "@babel/code-frame": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.5.tgz", - "integrity": "sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.0.tgz", + "integrity": "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.5", + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", "@babel/helper-globals": "^7.28.0", - "@babel/parser": "^7.28.5", - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.5", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/types": "^7.29.0", "debug": "^4.3.1" }, "engines": { @@ -1541,9 +1542,9 @@ } }, "node_modules/@babel/types": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.5.tgz", - "integrity": "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==", + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", "dev": true, "license": "MIT", "dependencies": { @@ -1555,39 +1556,39 @@ } }, "node_modules/@cacheable/memory": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.0.6.tgz", - "integrity": "sha512-7e8SScMocHxcAb8YhtkbMhGG+EKLRIficb1F5sjvhSYsWTZGxvg4KIDp8kgxnV2PUJ3ddPe6J9QESjKvBWRDkg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.0.8.tgz", + "integrity": "sha512-FvEb29x5wVwu/Kf93IWwsOOEuhHh6dYCJF3vcKLzXc0KXIW181AOzv6ceT4ZpBHDvAfG60eqb+ekmrnLHIy+jw==", "dev": true, "license": "MIT", "dependencies": { - "@cacheable/utils": "^2.3.2", - "@keyv/bigmap": "^1.3.0", - "hookified": "^1.13.0", - "keyv": "^5.5.4" + "@cacheable/utils": "^2.4.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" } }, "node_modules/@cacheable/memory/node_modules/@keyv/bigmap": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.0.tgz", - "integrity": "sha512-KT01GjzV6AQD5+IYrcpoYLkCu1Jod3nau1Z7EsEuViO3TZGRacSbO9MfHmbJ1WaOXFtWLxPVj169cn2WNKPkIg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", "dev": true, "license": "MIT", "dependencies": { - "hashery": "^1.2.0", - "hookified": "^1.13.0" + "hashery": "^1.4.0", + "hookified": "^1.15.0" }, "engines": { "node": ">= 18" }, "peerDependencies": { - "keyv": "^5.5.4" + "keyv": "^5.6.0" } }, "node_modules/@cacheable/memory/node_modules/keyv": { - "version": "5.5.5", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.5.tgz", - "integrity": "sha512-FA5LmZVF1VziNc0bIdCSA1IoSVnDCqE8HJIZZv2/W8YmoAM50+tnUgJR/gQZwEeIMleuIOnRnHA/UaZRNeV4iQ==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", "dev": true, "license": "MIT", "peer": true, @@ -1596,20 +1597,20 @@ } }, "node_modules/@cacheable/utils": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.3.2.tgz", - "integrity": "sha512-8kGE2P+HjfY8FglaOiW+y8qxcaQAfAhVML+i66XJR3YX5FtyDqn6Txctr3K2FrbxLKixRRYYBWMbuGciOhYNDg==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.4.1.tgz", + "integrity": "sha512-eiFgzCbIneyMlLOmNG4g9xzF7Hv3Mga4LjxjcSC/ues6VYq2+gUbQI8JqNuw/ZM8tJIeIaBGpswAsqV2V7ApgA==", "dev": true, "license": "MIT", "dependencies": { - "hashery": "^1.2.0", - "keyv": "^5.5.4" + "hashery": "^1.5.1", + "keyv": "^5.6.0" } }, "node_modules/@cacheable/utils/node_modules/keyv": { - "version": "5.5.5", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.5.tgz", - "integrity": "sha512-FA5LmZVF1VziNc0bIdCSA1IoSVnDCqE8HJIZZv2/W8YmoAM50+tnUgJR/gQZwEeIMleuIOnRnHA/UaZRNeV4iQ==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", "dev": true, "license": "MIT", "dependencies": { @@ -1641,9 +1642,9 @@ } }, "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.0.21", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.0.21.tgz", - "integrity": "sha512-plP8N8zKfEZ26figX4Nvajx8DuzfuRpLTqglQ5d0chfnt35Qt3X+m6ASZ+rG0D0kxe/upDVNwSIVJP5n4FuNfw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.3.tgz", + "integrity": "sha512-SH60bMfrRCJF3morcdk57WklujF4Jr/EsQUzqkarfHXEFcAR1gg7fS/chAE922Sehgzc1/+Tz5H3Ypa1HiEKrg==", "dev": true, "funding": [ { @@ -1656,8 +1657,13 @@ } ], "license": "MIT-0", - "engines": { - "node": ">=18" + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } } }, "node_modules/@csstools/css-tokenizer": { @@ -1729,9 +1735,9 @@ } }, "node_modules/@cypress/request": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@cypress/request/-/request-3.0.9.tgz", - "integrity": "sha512-I3l7FdGRXluAS44/0NguwWlO83J18p0vlr2FYHrJkWdNYhgVoiYo61IXPqaOsL+vNxU1ZqMACzItGK3/KKDsdw==", + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@cypress/request/-/request-3.0.10.tgz", + "integrity": "sha512-hauBrOdvu08vOsagkZ/Aju5XuiZx6ldsLfByg1htFeldhex+PeMrYauANzFsMJeAA0+dyPLbDoX2OYuvVoLDkQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1748,7 +1754,7 @@ "json-stringify-safe": "~5.0.1", "mime-types": "~2.1.19", "performance-now": "^2.1.0", - "qs": "6.14.0", + "qs": "~6.14.1", "safe-buffer": "^5.1.2", "tough-cookie": "^5.0.0", "tunnel-agent": "^0.6.0", @@ -1780,9 +1786,9 @@ } }, "node_modules/@discoveryjs/json-ext": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz", - "integrity": "sha512-4B4OijXeVNOPZlYA2oEwWOTkzyltLao+xbotHQeqN++Rv27Y6s818+n2Qkp8q+Fxhn0t/5lA5X1Mxktud8eayQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-1.0.0.tgz", + "integrity": "sha512-dDlz3W405VMFO4w5kIP9DOmELBcvFQGmLoKSdIRstBDubKFYwaNHV1NnlzMCQpXQFGWVALmeMORAuiLx18AvZQ==", "dev": true, "license": "MIT", "engines": { @@ -1801,9 +1807,9 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz", - "integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==", + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1901,6 +1907,29 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz", + "integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -1958,13 +1987,13 @@ } }, "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", - "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, "license": "MIT", "dependencies": { - "ansi-regex": "^6.0.1" + "ansi-regex": "^6.2.2" }, "engines": { "node": ">=12" @@ -2080,18 +2109,18 @@ } }, "node_modules/@parcel/watcher": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", - "integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", + "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==", "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, "dependencies": { - "detect-libc": "^1.0.3", + "detect-libc": "^2.0.3", "is-glob": "^4.0.3", - "micromatch": "^4.0.5", - "node-addon-api": "^7.0.0" + "node-addon-api": "^7.0.0", + "picomatch": "^4.0.3" }, "engines": { "node": ">= 10.0.0" @@ -2101,25 +2130,25 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "@parcel/watcher-android-arm64": "2.5.1", - "@parcel/watcher-darwin-arm64": "2.5.1", - "@parcel/watcher-darwin-x64": "2.5.1", - "@parcel/watcher-freebsd-x64": "2.5.1", - "@parcel/watcher-linux-arm-glibc": "2.5.1", - "@parcel/watcher-linux-arm-musl": "2.5.1", - "@parcel/watcher-linux-arm64-glibc": "2.5.1", - "@parcel/watcher-linux-arm64-musl": "2.5.1", - "@parcel/watcher-linux-x64-glibc": "2.5.1", - "@parcel/watcher-linux-x64-musl": "2.5.1", - "@parcel/watcher-win32-arm64": "2.5.1", - "@parcel/watcher-win32-ia32": "2.5.1", - "@parcel/watcher-win32-x64": "2.5.1" + "@parcel/watcher-android-arm64": "2.5.6", + "@parcel/watcher-darwin-arm64": "2.5.6", + "@parcel/watcher-darwin-x64": "2.5.6", + "@parcel/watcher-freebsd-x64": "2.5.6", + "@parcel/watcher-linux-arm-glibc": "2.5.6", + "@parcel/watcher-linux-arm-musl": "2.5.6", + "@parcel/watcher-linux-arm64-glibc": "2.5.6", + "@parcel/watcher-linux-arm64-musl": "2.5.6", + "@parcel/watcher-linux-x64-glibc": "2.5.6", + "@parcel/watcher-linux-x64-musl": "2.5.6", + "@parcel/watcher-win32-arm64": "2.5.6", + "@parcel/watcher-win32-ia32": "2.5.6", + "@parcel/watcher-win32-x64": "2.5.6" } }, "node_modules/@parcel/watcher-android-arm64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz", - "integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.6.tgz", + "integrity": "sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==", "cpu": [ "arm64" ], @@ -2138,9 +2167,9 @@ } }, "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz", - "integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.6.tgz", + "integrity": "sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==", "cpu": [ "arm64" ], @@ -2159,9 +2188,9 @@ } }, "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz", - "integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.6.tgz", + "integrity": "sha512-HgvOf3W9dhithcwOWX9uDZyn1lW9R+7tPZ4sug+NGrGIo4Rk1hAXLEbcH1TQSqxts0NYXXlOWqVpvS1SFS4fRg==", "cpu": [ "x64" ], @@ -2180,9 +2209,9 @@ } }, "node_modules/@parcel/watcher-freebsd-x64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz", - "integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.6.tgz", + "integrity": "sha512-vJVi8yd/qzJxEKHkeemh7w3YAn6RJCtYlE4HPMoVnCpIXEzSrxErBW5SJBgKLbXU3WdIpkjBTeUNtyBVn8TRng==", "cpu": [ "x64" ], @@ -2201,9 +2230,9 @@ } }, "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz", - "integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.6.tgz", + "integrity": "sha512-9JiYfB6h6BgV50CCfasfLf/uvOcJskMSwcdH1PHH9rvS1IrNy8zad6IUVPVUfmXr+u+Km9IxcfMLzgdOudz9EQ==", "cpu": [ "arm" ], @@ -2222,9 +2251,9 @@ } }, "node_modules/@parcel/watcher-linux-arm-musl": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz", - "integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.6.tgz", + "integrity": "sha512-Ve3gUCG57nuUUSyjBq/MAM0CzArtuIOxsBdQ+ftz6ho8n7s1i9E1Nmk/xmP323r2YL0SONs1EuwqBp2u1k5fxg==", "cpu": [ "arm" ], @@ -2243,9 +2272,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz", - "integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.6.tgz", + "integrity": "sha512-f2g/DT3NhGPdBmMWYoxixqYr3v/UXcmLOYy16Bx0TM20Tchduwr4EaCbmxh1321TABqPGDpS8D/ggOTaljijOA==", "cpu": [ "arm64" ], @@ -2264,9 +2293,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz", - "integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.6.tgz", + "integrity": "sha512-qb6naMDGlbCwdhLj6hgoVKJl2odL34z2sqkC7Z6kzir8b5W65WYDpLB6R06KabvZdgoHI/zxke4b3zR0wAbDTA==", "cpu": [ "arm64" ], @@ -2285,9 +2314,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz", - "integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.6.tgz", + "integrity": "sha512-kbT5wvNQlx7NaGjzPFu8nVIW1rWqV780O7ZtkjuWaPUgpv2NMFpjYERVi0UYj1msZNyCzGlaCWEtzc+exjMGbQ==", "cpu": [ "x64" ], @@ -2306,9 +2335,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz", - "integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.6.tgz", + "integrity": "sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==", "cpu": [ "x64" ], @@ -2327,9 +2356,9 @@ } }, "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz", - "integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.6.tgz", + "integrity": "sha512-3ukyebjc6eGlw9yRt678DxVF7rjXatWiHvTXqphZLvo7aC5NdEgFufVwjFfY51ijYEWpXbqF5jtrK275z52D4Q==", "cpu": [ "arm64" ], @@ -2348,9 +2377,9 @@ } }, "node_modules/@parcel/watcher-win32-ia32": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz", - "integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.6.tgz", + "integrity": "sha512-k35yLp1ZMwwee3Ez/pxBi5cf4AoBKYXj00CZ80jUz5h8prpiaQsiRPKQMxoLstNuqe2vR4RNPEAEcjEFzhEz/g==", "cpu": [ "ia32" ], @@ -2369,9 +2398,9 @@ } }, "node_modules/@parcel/watcher-win32-x64": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz", - "integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==", + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.6.tgz", + "integrity": "sha512-hbQlYcCq5dlAX9Qx+kFb0FHue6vbjlf0FrNzSKdYK2APUf7tGfGxQCk2ihEREmbR6ZMc0MVAD5RIX/41gpUzTw==", "cpu": [ "x64" ], @@ -2389,6 +2418,20 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@parcel/watcher/node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -2505,9 +2548,9 @@ } }, "node_modules/@types/archiver": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@types/archiver/-/archiver-6.0.4.tgz", - "integrity": "sha512-ULdQpARQ3sz9WH4nb98mJDYA0ft2A8C4f4fovvUcFwINa1cgGjY36JCAYuP5YypRq4mco1lJp1/7jEMS2oR0Hg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/archiver/-/archiver-7.0.0.tgz", + "integrity": "sha512-/3vwGwx9n+mCQdYZ2IKGGHEFL30I96UgBlk8EtRDDFQ9uxM1l4O5Ci6r00EMAkiDaTqD9DQ6nVrWRICnBPtzzg==", "dev": true, "license": "MIT", "dependencies": { @@ -2586,13 +2629,13 @@ } }, "node_modules/@types/node": { - "version": "25.0.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.3.tgz", - "integrity": "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==", + "version": "25.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.6.0.tgz", + "integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.16.0" + "undici-types": "~7.19.0" } }, "node_modules/@types/normalize-path": { @@ -2626,6 +2669,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/tmp": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.6.tgz", + "integrity": "sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/yauzl": { "version": "2.10.3", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", @@ -2805,53 +2855,6 @@ "@xtuc/long": "4.2.2" } }, - "node_modules/@webpack-cli/configtest": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-3.0.1.tgz", - "integrity": "sha512-u8d0pJ5YFgneF/GuvEiDA61Tf1VDomHHYMjv/wc9XzYj7nopltpG96nXN5dJRstxZhcNpV1g+nT6CydO7pHbjA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.12.0" - }, - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - } - }, - "node_modules/@webpack-cli/info": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-3.0.1.tgz", - "integrity": "sha512-coEmDzc2u/ffMvuW9aCjoRzNSPDl/XLuhPdlFRpT9tZHmJ/039az33CE7uH+8s0uL1j5ZNtfdv0HkfaKRBGJsQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.12.0" - }, - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - } - }, - "node_modules/@webpack-cli/serve": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-3.0.1.tgz", - "integrity": "sha512-sbgw03xQaCLiT6gcY/6u3qBDn01CWw/nbaXl3gTdTFuJJ75Gffv3E3DBpgvY2fkkrdS1fpjaXNOmJlnbtKauKg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.12.0" - }, - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - }, - "peerDependenciesMeta": { - "webpack-dev-server": { - "optional": true - } - } - }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -2880,9 +2883,9 @@ } }, "node_modules/acorn": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", - "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", + "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", "peer": true, @@ -2931,9 +2934,9 @@ } }, "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", "dependencies": { @@ -2966,9 +2969,9 @@ } }, "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "dev": true, "license": "MIT", "dependencies": { @@ -3341,9 +3344,9 @@ } }, "node_modules/autoprefixer": { - "version": "10.4.23", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.23.tgz", - "integrity": "sha512-YYTXSFulfwytnjAPlw8QHncHJmlvFKtczb8InXaAx9Q0LbfDnfEYDE55omerIJKihhmU61Ft+cAOSzQVaBUmeA==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.0.tgz", + "integrity": "sha512-FMhOoZV4+qR6aTUALKX2rEqGG+oyATvwBt9IIzVR5rMa2HRWPkxf+P+PAJLD1I/H5/II+HuZcBJYEFBpq39ong==", "dev": true, "funding": [ { @@ -3361,8 +3364,8 @@ ], "license": "MIT", "dependencies": { - "browserslist": "^4.28.1", - "caniuse-lite": "^1.0.30001760", + "browserslist": "^4.28.2", + "caniuse-lite": "^1.0.30001787", "fraction.js": "^5.3.4", "picocolors": "^1.1.1", "postcss-value-parser": "^4.2.0" @@ -3411,9 +3414,9 @@ "license": "MIT" }, "node_modules/b4a": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.7.3.tgz", - "integrity": "sha512-5Q2mfq2WfGuFp3uS//0s6baOJLMoVduPYVeNmDYxu5OUA1/cBfvr2RIS7vi62LdNj/urk1hfmj867I3qt6uZ7Q==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.0.tgz", + "integrity": "sha512-qRuSmNSkGQaHwNbM7J78Wwy+ghLEYF1zNrSeMxj4Kgw6y33O3mXcQ6Ie9fRvfU/YnxWkOchPXbaLb73TkIsfdg==", "dev": true, "license": "Apache-2.0", "peerDependencies": { @@ -3426,9 +3429,9 @@ } }, "node_modules/babel-loader": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-10.0.0.tgz", - "integrity": "sha512-z8jt+EdS61AMw22nSfoNJAZ0vrtmhPRVi6ghL3rCeRZI8cdNYFiV5xeV3HbE7rlZZNmGH8BVccwWt8/ED0QOHA==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-10.1.1.tgz", + "integrity": "sha512-JwKSzk2kjIe7mgPK+/lyZ2QAaJcpahNAdM+hgR2HI8D0OJVkdj8Rl6J3kaLYki9pwF7P2iWnD8qVv80Lq1ABtg==", "dev": true, "license": "MIT", "dependencies": { @@ -3438,19 +3441,28 @@ "node": "^18.20.0 || ^20.10.0 || >=22.0.0" }, "peerDependencies": { - "@babel/core": "^7.12.0", + "@babel/core": "^7.12.0 || ^8.0.0-beta.1", + "@rspack/core": "^1.0.0 || ^2.0.0-0", "webpack": ">=5.61.0" + }, + "peerDependenciesMeta": { + "@rspack/core": { + "optional": true + }, + "webpack": { + "optional": true + } } }, "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.4.14", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.14.tgz", - "integrity": "sha512-Co2Y9wX854ts6U8gAAPXfn0GmAyctHuK8n0Yhfjd6t30g7yvKjspvvOo9yG+z52PZRgFErt7Ka2pYnXCjLKEpg==", + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.17.tgz", + "integrity": "sha512-aTyf30K/rqAsNwN76zYrdtx8obu0E4KoUME29B1xj+B3WxgvWkp943vYQ+z8Mv3lw9xHXMHpvSPOBxzAkIa94w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.27.7", - "@babel/helper-define-polyfill-provider": "^0.6.5", + "@babel/compat-data": "^7.28.6", + "@babel/helper-define-polyfill-provider": "^0.6.8", "semver": "^6.3.1" }, "peerDependencies": { @@ -3458,27 +3470,27 @@ } }, "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.13.0.tgz", - "integrity": "sha512-U+GNwMdSFgzVmfhNm8GJUX88AadB3uo9KpJqS3FaqNIPKgySuvMb+bHPsOmmuWyIcuqZj/pzt1RUIUZns4y2+A==", + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.14.2.tgz", + "integrity": "sha512-coWpDLJ410R781Npmn/SIBZEsAetR4xVi0SxLMXPaMO4lSf1MwnkGYMtkFxew0Dn8B3/CpbpYxN0JCgg8mn67g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.5", - "core-js-compat": "^3.43.0" + "@babel/helper-define-polyfill-provider": "^0.6.8", + "core-js-compat": "^3.48.0" }, "peerDependencies": { "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.5.tgz", - "integrity": "sha512-ISqQ2frbiNU9vIJkzg7dlPpznPZ4jOiUQ1uSmB0fEHeowtN3COYRsXr/xexn64NpU13P06jc/L5TgiJXOgrbEg==", + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.8.tgz", + "integrity": "sha512-M762rNHfSF1EV3SLtnCJXFoQbbIIz0OyRwnCmV0KPC7qosSfCO0QLTSuJX3ayAebubhE6oYBAYPrBA5ljowaZg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.5" + "@babel/helper-define-polyfill-provider": "^0.6.8" }, "peerDependencies": { "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" @@ -3497,6 +3509,7 @@ "integrity": "sha512-riJjyv1/mHLIPX4RwiK+oW9/4c3TEUeORHKefKAKnZ5kyslbN+HXowtbaVEqt4IMUB7OXlfixcs6gsFeo/jhiQ==", "dev": true, "license": "Apache-2.0", + "peer": true, "peerDependencies": { "bare-abort-controller": "*" }, @@ -3506,6 +3519,88 @@ } } }, + "node_modules/bare-fs": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.7.1.tgz", + "integrity": "sha512-WDRsyVN52eAx/lBamKD6uyw8H4228h/x0sGGGegOamM2cd7Pag88GfMQalobXI+HaEUxpCkbKQUDOQqt9wawRw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.5.4", + "bare-path": "^3.0.0", + "bare-stream": "^2.6.4", + "bare-url": "^2.2.2", + "fast-fifo": "^1.3.2" + }, + "engines": { + "bare": ">=1.16.0" + }, + "peerDependencies": { + "bare-buffer": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + } + } + }, + "node_modules/bare-os": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.9.0.tgz", + "integrity": "sha512-JTjuZyNIDpw+GytMO4a6TK1VXdVKKJr6DRxEHasyuYyShV2deuiHJK/ahGZlebc+SG0/wJCB9XK8gprBGDFi/Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "bare": ">=1.14.0" + } + }, + "node_modules/bare-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.0.0.tgz", + "integrity": "sha512-tyfW2cQcB5NN8Saijrhqn0Zh7AnFNsnczRcuWODH0eYAXBsJ5gVxAUuNr7tsHSC6IZ77cA0SitzT+s47kot8Mw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-os": "^3.0.1" + } + }, + "node_modules/bare-stream": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.0.tgz", + "integrity": "sha512-3zAJRZMDFGjdn+RVnNpF9kuELw+0Fl3lpndM4NcEOhb9zwtSo/deETfuIwMSE5BXanA0FrN1qVjffGwAg2Y7EA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "streamx": "^2.25.0", + "teex": "^1.0.1" + }, + "peerDependencies": { + "bare-abort-controller": "*", + "bare-buffer": "*", + "bare-events": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + }, + "bare-buffer": { + "optional": true + }, + "bare-events": { + "optional": true + } + } + }, + "node_modules/bare-url": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.4.2.tgz", + "integrity": "sha512-/9a2j4ac6ckpmAHvod/ob7x439OAHst/drc2Clnq+reRYd/ovddwcF4LfoxHyNk5AuGBnPg+HqFjmE/Zpq6v0A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-path": "^3.0.0" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -3528,13 +3623,16 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.9.10", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.10.tgz", - "integrity": "sha512-2VIKvDx8Z1a9rTB2eCkdPE5nSe28XnA+qivGnWHoB40hMMt/h1hSz0960Zqsn6ZyxWXUie0EBdElKv8may20AA==", + "version": "2.10.21", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.21.tgz", + "integrity": "sha512-Q+rUQ7Uz8AHM7DEaNdwvfFCTq7a43lNTzuS94eiWqwyxfV/wJv+oUivef51T91mmRY4d4A1u9rcSvkeufCVXlA==", "dev": true, "license": "Apache-2.0", "bin": { - "baseline-browser-mapping": "dist/cli.js" + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" } }, "node_modules/bcrypt-pbkdf": { @@ -3635,9 +3733,9 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", "dev": true, "license": "MIT", "dependencies": { @@ -3659,9 +3757,9 @@ } }, "node_modules/browserslist": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", - "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz", + "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==", "dev": true, "funding": [ { @@ -3680,11 +3778,11 @@ "license": "MIT", "peer": true, "dependencies": { - "baseline-browser-mapping": "^2.9.0", - "caniuse-lite": "^1.0.30001759", - "electron-to-chromium": "^1.5.263", - "node-releases": "^2.0.27", - "update-browserslist-db": "^1.2.0" + "baseline-browser-mapping": "^2.10.12", + "caniuse-lite": "^1.0.30001782", + "electron-to-chromium": "^1.5.328", + "node-releases": "^2.0.36", + "update-browserslist-db": "^1.2.3" }, "bin": { "browserslist": "cli.js" @@ -3759,17 +3857,17 @@ } }, "node_modules/cacheable": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.3.1.tgz", - "integrity": "sha512-yr+FSHWn1ZUou5LkULX/S+jhfgfnLbuKQjE40tyEd4fxGZVMbBL5ifno0J0OauykS8UiCSgHi+DV/YD+rjFxFg==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.3.4.tgz", + "integrity": "sha512-djgxybDbw9fL/ZWMI3+CE8ZilNxcwFkVtDc1gJ+IlOSSWkSMPQabhV/XCHTQ6pwwN6aivXPZ43omTooZiX06Ew==", "dev": true, "license": "MIT", "dependencies": { - "@cacheable/memory": "^2.0.6", - "@cacheable/utils": "^2.3.2", - "hookified": "^1.14.0", - "keyv": "^5.5.5", - "qified": "^0.5.3" + "@cacheable/memory": "^2.0.8", + "@cacheable/utils": "^2.4.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.9.0" } }, "node_modules/cacheable-request": { @@ -3819,9 +3917,9 @@ } }, "node_modules/cacheable/node_modules/keyv": { - "version": "5.5.5", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.5.tgz", - "integrity": "sha512-FA5LmZVF1VziNc0bIdCSA1IoSVnDCqE8HJIZZv2/W8YmoAM50+tnUgJR/gQZwEeIMleuIOnRnHA/UaZRNeV4iQ==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", "dev": true, "license": "MIT", "dependencies": { @@ -3839,15 +3937,15 @@ } }, "node_modules/call-bind": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", - "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", "dev": true, "license": "MIT", "dependencies": { - "call-bind-apply-helpers": "^1.0.0", - "es-define-property": "^1.0.0", - "get-intrinsic": "^1.2.4", + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", "set-function-length": "^1.2.2" }, "engines": { @@ -3909,9 +4007,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001761", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz", - "integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==", + "version": "1.0.30001790", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001790.tgz", + "integrity": "sha512-bOoxfJPyYo+ds6W0YfptaCWbFnJYjh2Y1Eow5lRv+vI2u8ganPZqNm1JwNh0t2ELQCqIWg4B3dWEusgAmsoyOw==", "dev": true, "funding": [ { @@ -3966,16 +4064,6 @@ "node": ">=8" } }, - "node_modules/check-more-types": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/check-more-types/-/check-more-types-2.24.0.tgz", - "integrity": "sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -4025,9 +4113,9 @@ } }, "node_modules/ci-info": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", - "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", + "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", "dev": true, "funding": [ { @@ -4378,13 +4466,13 @@ "license": "MIT" }, "node_modules/core-js-compat": { - "version": "3.47.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.47.0.tgz", - "integrity": "sha512-IGfuznZ/n7Kp9+nypamBhvwdwLsW6KC8IOaURw2doAK5e98AG3acVLdh0woOnEqCfUtS+Vu882JE4k/DAm3ItQ==", + "version": "3.49.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.49.0.tgz", + "integrity": "sha512-VQXt1jr9cBz03b331DFDCCP90b3fanciLkgiOoy8SBHy06gNf+vQ1A3WFLqG7I8TipYIKeYK9wxd0tUrvHcOZA==", "dev": true, "license": "MIT", "dependencies": { - "browserslist": "^4.28.0" + "browserslist": "^4.28.1" }, "funding": { "type": "opencollective", @@ -4399,9 +4487,9 @@ "license": "MIT" }, "node_modules/cosmiconfig": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz", - "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.1.tgz", + "integrity": "sha512-hr4ihw+DBqcvrsEDioRO31Z17x71pUYoNe/4h6Z0wB72p7MU7/9gH8Q3s12NFhHPfYBBOV3qyfUxmr/Yn3shnQ==", "dev": true, "license": "MIT", "dependencies": { @@ -4494,30 +4582,30 @@ } }, "node_modules/css-functions-list": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/css-functions-list/-/css-functions-list-3.2.3.tgz", - "integrity": "sha512-IQOkD3hbR5KrN93MtcYuad6YPuTSUhntLHDuLEbFWE+ff2/XSZNdZG+LcbbIW5AXKg/WFIfYItIzVoHngHXZzA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/css-functions-list/-/css-functions-list-3.3.3.tgz", + "integrity": "sha512-8HFEBPKhOpJPEPu70wJJetjKta86Gw9+CCyCnB3sui2qQfOvRyqBy4IKLKKAwdMpWb2lHXWk9Wb4Z6AmaUT1Pg==", "dev": true, "license": "MIT", "engines": { - "node": ">=12 || >=16" + "node": ">=12" } }, "node_modules/css-loader": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-7.1.2.tgz", - "integrity": "sha512-6WvYYn7l/XEGN8Xu2vWFt9nVzrCn39vKyTEFf/ExEyoksJjjSZV/0/35XPlMbpnr6VGhZIUg5yJrL8tGfes/FA==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-7.1.4.tgz", + "integrity": "sha512-vv3J9tlOl04WjiMvHQI/9tmIrCxVrj6PFbHemBB1iihpeRbi/I4h033eoFIhwxBBqLhI0KYFS7yvynBFhIZfTw==", "dev": true, "license": "MIT", "dependencies": { "icss-utils": "^5.1.0", - "postcss": "^8.4.33", + "postcss": "^8.4.40", "postcss-modules-extract-imports": "^3.1.0", "postcss-modules-local-by-default": "^4.0.5", "postcss-modules-scope": "^3.2.0", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", - "semver": "^7.5.4" + "semver": "^7.6.3" }, "engines": { "node": ">= 18.12.0" @@ -4527,7 +4615,7 @@ "url": "https://opencollective.com/webpack" }, "peerDependencies": { - "@rspack/core": "0.x || 1.x", + "@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0", "webpack": "^5.27.0" }, "peerDependenciesMeta": { @@ -4540,9 +4628,9 @@ } }, "node_modules/css-loader/node_modules/semver": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", - "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", "dev": true, "license": "ISC", "bin": { @@ -4553,14 +4641,15 @@ } }, "node_modules/css-tree": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.1.0.tgz", - "integrity": "sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { - "mdn-data": "2.12.2", - "source-map-js": "^1.0.1" + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" @@ -4580,24 +4669,25 @@ } }, "node_modules/cypress": { - "version": "14.5.4", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-14.5.4.tgz", - "integrity": "sha512-0Dhm4qc9VatOcI1GiFGVt8osgpPdqJLHzRwcAB5MSD/CAAts3oybvPUPawHyvJZUd8osADqZe/xzMsZ8sDTjXw==", + "version": "15.14.1", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-15.14.1.tgz", + "integrity": "sha512-AkuiHNSnmm0a+h/horcvbjmY6dWpCe1Ebp1R0LjMP5I6pjMaNA50Mw1YP/d07pLHJ/sV8FZoGecUWFCJ/Nifpw==", "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { - "@cypress/request": "^3.0.9", + "@cypress/request": "^3.0.10", "@cypress/xvfb": "^1.2.4", "@types/sinonjs__fake-timers": "8.1.1", "@types/sizzle": "^2.3.2", + "@types/tmp": "^0.2.3", "arch": "^2.2.0", "blob-util": "^2.0.2", "bluebird": "^3.7.2", "buffer": "^5.7.1", "cachedir": "^2.3.0", "chalk": "^4.1.0", - "check-more-types": "^2.24.0", "ci-info": "^4.1.0", "cli-cursor": "^3.1.0", "cli-table3": "0.6.1", @@ -4612,12 +4702,10 @@ "extract-zip": "2.0.1", "figures": "^3.2.0", "fs-extra": "^9.1.0", - "getos": "^3.2.1", "hasha": "5.2.2", "is-installed-globally": "~0.4.0", - "lazy-ass": "^1.6.0", "listr2": "^3.8.3", - "lodash": "^4.17.21", + "lodash": "^4.17.23", "log-symbols": "^4.0.0", "minimist": "^1.2.8", "ospath": "^1.2.2", @@ -4625,10 +4713,11 @@ "process": "^0.11.10", "proxy-from-env": "1.0.0", "request-progress": "^3.0.0", - "semver": "^7.7.1", "supports-color": "^8.1.1", - "tmp": "~0.2.3", + "systeminformation": "^5.31.1", + "tmp": "~0.2.4", "tree-kill": "1.2.2", + "tslib": "1.14.1", "untildify": "^4.0.0", "yauzl": "^2.10.0" }, @@ -4636,7 +4725,7 @@ "cypress": "bin/cypress" }, "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + "node": "^20.1.0 || ^22.0.0 || >=24.0.0" } }, "node_modules/cypress-real-events": { @@ -4649,19 +4738,6 @@ "cypress": "^4.x || ^5.x || ^6.x || ^7.x || ^8.x || ^9.x || ^10.x || ^11.x || ^12.x || ^13.x || ^14.x || ^15.x" } }, - "node_modules/cypress/node_modules/semver": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", - "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -4730,9 +4806,9 @@ } }, "node_modules/dayjs": { - "version": "1.11.19", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", - "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "version": "1.11.20", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.20.tgz", + "integrity": "sha512-YbwwqR/uYpeoP4pu043q+LTDLFBLApUP6VxRihdfNTqu4ubqMlGDLd6ErXhEgsyvY0K6nCs7nggYumAN+9uEuQ==", "dev": true, "license": "MIT" }, @@ -4904,17 +4980,14 @@ } }, "node_modules/detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", "dev": true, "license": "Apache-2.0", "optional": true, - "bin": { - "detect-libc": "bin/detect-libc.js" - }, "engines": { - "node": ">=0.10" + "node": ">=8" } }, "node_modules/dir-glob": { @@ -5191,9 +5264,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.267", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.267.tgz", - "integrity": "sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==", + "version": "1.5.344", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.344.tgz", + "integrity": "sha512-4MxfbmNDm+KPh066EZy+eUnkcDPcZ35wNmOWzFuh/ijvHsve6kbLTLURy88uCNK5FbpN+yk2nQY6BYh1GEt+wg==", "dev": true, "license": "ISC" }, @@ -5287,9 +5360,9 @@ } }, "node_modules/es-abstract": { - "version": "1.24.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", - "integrity": "sha512-zHXBLhP+QehSSbsS9Pt23Gg964240DPd6QCf8WpkqEXxQ7fhdZzYsocOr5u7apWonsS5EjZDmTF+/slGMyasvw==", + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.2.tgz", + "integrity": "sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==", "dev": true, "license": "MIT", "dependencies": { @@ -5561,15 +5634,15 @@ } }, "node_modules/eslint-import-resolver-node": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", - "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.10.tgz", + "integrity": "sha512-tRrKqFyCaKict5hOd244sL6EQFNycnMQnBe+j8uqGNXYzsImGbGUU4ibtoaBmv5FLwJwcFJNeg1GeVjQfbMrDQ==", "dev": true, "license": "MIT", "dependencies": { "debug": "^3.2.7", - "is-core-module": "^2.13.0", - "resolve": "^1.22.4" + "is-core-module": "^2.16.1", + "resolve": "^2.0.0-next.6" } }, "node_modules/eslint-import-resolver-node/node_modules/debug": { @@ -5582,10 +5655,34 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-import-resolver-node/node_modules/resolve": { + "version": "2.0.0-next.6", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.6.tgz", + "integrity": "sha512-3JmVl5hMGtJ3kMmB3zi3DL25KfkCEyy3Tw7Gmw7z5w8M9WlwoPFnIvwChzu1+cF3iaK3sp18hhPz8ANeimdJfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", + "node-exports-info": "^1.6.0", + "object-keys": "^1.1.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/eslint-import-resolver-webpack": { - "version": "0.13.10", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.13.10.tgz", - "integrity": "sha512-ciVTEg7sA56wRMR772PyjcBRmyBMLS46xgzQZqt6cWBEKc7cK65ZSSLCTLVRu2gGtKyXUb5stwf4xxLBfERLFA==", + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.13.11.tgz", + "integrity": "sha512-RGFDrCHSmCKGuaoI1zmZT028weIFIEyfSy0nAwzp5rplutWDC+BBjvZS2l4bEgSOfjc+ILkSLxeszkslyNO6fQ==", "dev": true, "license": "MIT", "dependencies": { @@ -5594,10 +5691,10 @@ "find-root": "^1.1.0", "hasown": "^2.0.2", "interpret": "^1.4.0", - "is-core-module": "^2.15.1", - "is-regex": "^1.2.0", - "lodash": "^4.17.21", - "resolve": "^2.0.0-next.5", + "is-core-module": "^2.16.1", + "is-regex": "^1.2.1", + "lodash": "^4.18.1", + "resolve": "^2.0.0-next.6", "semver": "^5.7.2" }, "engines": { @@ -5619,19 +5716,25 @@ } }, "node_modules/eslint-import-resolver-webpack/node_modules/resolve": { - "version": "2.0.0-next.5", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.5.tgz", - "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", + "version": "2.0.0-next.6", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.6.tgz", + "integrity": "sha512-3JmVl5hMGtJ3kMmB3zi3DL25KfkCEyy3Tw7Gmw7z5w8M9WlwoPFnIvwChzu1+cF3iaK3sp18hhPz8ANeimdJfA==", "dev": true, "license": "MIT", "dependencies": { - "is-core-module": "^2.13.0", + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", + "node-exports-info": "^1.6.0", + "object-keys": "^1.1.1", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, "bin": { "resolve": "bin/resolve" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5733,67 +5836,47 @@ } }, "node_modules/eslint-plugin-sonarjs": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-3.0.5.tgz", - "integrity": "sha512-dI62Ff3zMezUToi161hs2i1HX1ie8Ia2hO0jtNBfdgRBicAG4ydy2WPt0rMTrAe3ZrlqhpAO3w1jcQEdneYoFA==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-3.0.7.tgz", + "integrity": "sha512-62jB20krIPvcwBLAyG3VVKa2ce2j2lL1yCb8Y0ylMRR/dLvCCTiQx8gQbXb+G81k1alPZ2/I3muZinqWQdBbzw==", "dev": true, "license": "LGPL-3.0-only", "dependencies": { - "@eslint-community/regexpp": "4.12.1", + "@eslint-community/regexpp": "4.12.2", "builtin-modules": "3.3.0", "bytes": "3.1.2", "functional-red-black-tree": "1.0.1", "jsx-ast-utils-x": "0.1.0", "lodash.merge": "4.6.2", - "minimatch": "9.0.5", + "minimatch": "10.1.2", "scslre": "0.3.0", - "semver": "7.7.2", + "semver": "7.7.4", "typescript": ">=5" }, "peerDependencies": { "eslint": "^8.0.0 || ^9.0.0" } }, - "node_modules/eslint-plugin-sonarjs/node_modules/@eslint-community/regexpp": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", - "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/eslint-plugin-sonarjs/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/eslint-plugin-sonarjs/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.2.tgz", + "integrity": "sha512-fu656aJ0n2kcXwsnwnv9g24tkU5uSmOlTjd6WyyaKm2Z+h1qmY6bAjrcaIxF/BslFqbZ8UBtbJi7KgQOZD2PTw==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^2.0.1" + "@isaacs/brace-expansion": "^5.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/eslint-plugin-sonarjs/node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", "dev": true, "license": "ISC", "bin": { @@ -5852,9 +5935,9 @@ } }, "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -6105,9 +6188,9 @@ } }, "node_modules/fastq": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", - "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", "dev": true, "license": "ISC", "dependencies": { @@ -6125,9 +6208,9 @@ } }, "node_modules/figlet": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.9.4.tgz", - "integrity": "sha512-uN6QE+TrzTAHC1IWTyrc4FfGo2KH/82J8Jl1tyKB7+z5DBit/m3D++Iu5lg91qJMnQQ3vpJrj5gxcK/pk4R9tQ==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.11.0.tgz", + "integrity": "sha512-EEx3OS/l2bFqcUNN2NM9FPJp8vAMrgbCxsbl2hbcJNNxOEwVe3mEzrhan7TbJQViZa8mMqhihlbCaqD+LyYKTQ==", "dev": true, "license": "MIT", "dependencies": { @@ -6141,9 +6224,9 @@ } }, "node_modules/figlet/node_modules/commander": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz", - "integrity": "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", "dev": true, "license": "MIT", "engines": { @@ -6190,9 +6273,9 @@ } }, "node_modules/filemanager-webpack-plugin": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/filemanager-webpack-plugin/-/filemanager-webpack-plugin-9.0.1.tgz", - "integrity": "sha512-eNvWK6GrC9roBc1LkB/SzixXCApxs0fbKEo99BDrZmLfC9LCWxzg8B4dzoYKLdXvi19Fc6aWOApnBa8DfZIxVQ==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/filemanager-webpack-plugin/-/filemanager-webpack-plugin-10.0.1.tgz", + "integrity": "sha512-bUgOJvvccx4Grinxg6Jn66ewYNuuKy2QTDcCuA2Qx4QA3UjkpTnUxQ3FsBGZ7DGoDcliE3g5s5oUodHeYoJ7uQ==", "dev": true, "funding": [ { @@ -6202,29 +6285,29 @@ ], "license": "MIT", "dependencies": { - "@types/archiver": "^6.0.3", + "@types/archiver": "^7.0.0", "@types/fs-extra": "^11.0.4", "@types/is-glob": "^4.0.4", "@types/normalize-path": "^3.0.2", "archiver": "^7.0.1", - "del": "^8.0.0", + "del": "^8.0.1", "fast-glob": "^3.3.3", - "fs-extra": "^11.3.0", + "fs-extra": "^11.3.4", "is-glob": "^4.0.3", "normalize-path": "^3.0.0", - "schema-utils": "^4.3.2" + "schema-utils": "^4.3.3" }, "engines": { - "node": ">=20.0.0" + "node": ">=22.14.0" }, "peerDependencies": { "webpack": "^5.0.0" } }, "node_modules/filemanager-webpack-plugin/node_modules/fs-extra": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz", - "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", + "version": "11.3.4", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.4.tgz", + "integrity": "sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA==", "dev": true, "license": "MIT", "dependencies": { @@ -6335,9 +6418,9 @@ } }, "node_modules/flatted": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", - "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz", + "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==", "dev": true, "license": "ISC" }, @@ -6640,16 +6723,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/getos": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/getos/-/getos-3.2.1.tgz", - "integrity": "sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "async": "^3.2.0" - } - }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -6664,6 +6737,7 @@ "version": "10.5.0", "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dev": true, "license": "ISC", "dependencies": { @@ -6702,9 +6776,9 @@ "license": "BSD-2-Clause" }, "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", "dev": true, "license": "MIT", "dependencies": { @@ -6712,13 +6786,13 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^2.0.1" + "brace-expansion": "^2.0.2" }, "engines": { "node": ">=16 || 14 >=14.17" @@ -7067,22 +7141,22 @@ } }, "node_modules/hashery": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.3.0.tgz", - "integrity": "sha512-fWltioiy5zsSAs9ouEnvhsVJeAXRybGCNNv0lvzpzNOSDbULXRy7ivFWwCCv4I5Am6kSo75hmbsCduOoc2/K4w==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", "dev": true, "license": "MIT", "dependencies": { - "hookified": "^1.13.0" + "hookified": "^1.15.0" }, "engines": { "node": ">=20" } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", "dev": true, "license": "MIT", "dependencies": { @@ -7093,9 +7167,9 @@ } }, "node_modules/hookified": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.14.0.tgz", - "integrity": "sha512-pi1ynXIMFx/uIIwpWJ/5CEtOHLGtnUB0WhGeeYT+fKcQ+WCQbm3/rrkAXnpfph++PgepNqPdTC2WTj8A6k6zoQ==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", "dev": true, "license": "MIT" }, @@ -7220,9 +7294,9 @@ } }, "node_modules/immutable": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.4.tgz", - "integrity": "sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==", + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.5.tgz", + "integrity": "sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==", "dev": true, "license": "MIT" }, @@ -8077,9 +8151,9 @@ } }, "node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", "dev": true, "license": "MIT", "dependencies": { @@ -8155,16 +8229,6 @@ "node": ">=8" } }, - "node_modules/lazy-ass": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/lazy-ass/-/lazy-ass-1.6.0.tgz", - "integrity": "sha512-cc8oEVoctTvsFZ/Oje/kGnHbpWHYBe8IAJe4C0QNc3t8uM/0Y8+erSz/7Y1ALuXTEZTMvxXwO6YbX1ey3ujiZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "> 0.8" - } - }, "node_modules/lazystream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz", @@ -8328,9 +8392,9 @@ "license": "MIT" }, "node_modules/loader-runner": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.1.tgz", - "integrity": "sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.2.tgz", + "integrity": "sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==", "dev": true, "license": "MIT", "engines": { @@ -8358,9 +8422,9 @@ } }, "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "dev": true, "license": "MIT" }, @@ -8532,9 +8596,9 @@ } }, "node_modules/mdn-data": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.12.2.tgz", - "integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==", + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", "dev": true, "license": "CC0-1.0" }, @@ -8663,9 +8727,9 @@ } }, "node_modules/mini-css-extract-plugin": { - "version": "2.9.4", - "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.9.4.tgz", - "integrity": "sha512-ZWYT7ln73Hptxqxk2DxPU9MmapXRhxkJD6tkSR04dnQxm8BGu2hzgKLugK5yySD97u/8yy7Ma7E76k9ZdvtjkQ==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.10.2.tgz", + "integrity": "sha512-AOSS0IdEB95ayVkxn5oGzNQwqAi2J0Jb/kKm43t7H73s8+f5873g0yuj0PNvK4dO75mu5DHg4nlgp4k6Kga8eg==", "dev": true, "license": "MIT", "dependencies": { @@ -8684,9 +8748,9 @@ } }, "node_modules/mini-css-extract-plugin/node_modules/tapable": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", - "integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", "dev": true, "license": "MIT", "engines": { @@ -8698,9 +8762,9 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -8721,11 +8785,11 @@ } }, "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "engines": { "node": ">=16 || 14 >=14.17" } @@ -8785,6 +8849,25 @@ "license": "MIT", "optional": true }, + "node_modules/node-exports-info": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/node-exports-info/-/node-exports-info-1.6.0.tgz", + "integrity": "sha512-pyFS63ptit/P5WqUkt+UUfe+4oevH+bFeIiPPdfb0pFeYEu/1ELnJu5l+5EcTKYL5M7zaAa7S8ddywgXypqKCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "array.prototype.flatmap": "^1.3.3", + "es-errors": "^1.3.0", + "object.entries": "^1.1.9", + "semver": "^6.3.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -8807,9 +8890,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.27", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", - "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", + "version": "2.0.38", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.38.tgz", + "integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==", "dev": true, "license": "MIT" }, @@ -9345,9 +9428,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "dev": true, "license": "MIT", "engines": { @@ -9454,9 +9537,9 @@ } }, "node_modules/postcss": { - "version": "8.5.6", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", - "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.10.tgz", + "integrity": "sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==", "dev": true, "funding": [ { @@ -9484,9 +9567,9 @@ } }, "node_modules/postcss-loader": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-8.2.0.tgz", - "integrity": "sha512-tHX+RkpsXVcc7st4dSdDGliI+r4aAQDuv+v3vFYHixb6YgjreG5AG4SEB0kDK8u2s6htqEEpKlkhSBUTvWKYnA==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-8.2.1.tgz", + "integrity": "sha512-k98jtRzthjj3f76MYTs9JTpRqV1RaaMhEU0Lpw9OTmQZQdppg4B30VZ74BojuBHt3F4KyubHJoXCMUeM8Bqeow==", "dev": true, "license": "MIT", "dependencies": { @@ -9502,7 +9585,7 @@ "url": "https://opencollective.com/webpack" }, "peerDependencies": { - "@rspack/core": "0.x || 1.x", + "@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0", "postcss": "^7.0.0 || ^8.0.1", "webpack": "^5.0.0" }, @@ -9516,9 +9599,9 @@ } }, "node_modules/postcss-loader/node_modules/semver": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", - "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", "dev": true, "license": "ISC", "bin": { @@ -9762,9 +9845,9 @@ "license": "MIT" }, "node_modules/pump": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", - "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", "dev": true, "license": "MIT", "dependencies": { @@ -9796,22 +9879,29 @@ } }, "node_modules/qified": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/qified/-/qified-0.5.3.tgz", - "integrity": "sha512-kXuQdQTB6oN3KhI6V4acnBSZx8D2I4xzZvn9+wFLLFCoBNQY/sFnCW6c43OL7pOQ2HvGV4lnWIXNmgfp7cTWhQ==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.9.1.tgz", + "integrity": "sha512-n7mar4T0xQ+39dE2vGTAlbxUEpndwPANH0kDef1/MYsB8Bba9wshkybIRx74qgcvKQPEWErf9AqAdYjhzY2Ilg==", "dev": true, "license": "MIT", "dependencies": { - "hookified": "^1.13.0" + "hookified": "^2.1.1" }, "engines": { "node": ">=20" } }, + "node_modules/qified/node_modules/hookified": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.1.1.tgz", + "integrity": "sha512-AHb76R16GB5EsPBE2J7Ko5kiEyXwviB9P5SMrAKcuAu4vJPZttViAbj9+tZeaQE5zjDme+1vcHP78Yj/WoAveA==", + "dev": true, + "license": "MIT" + }, "node_modules/qs": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", - "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -9845,16 +9935,6 @@ ], "license": "MIT" }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -9951,9 +10031,9 @@ } }, "node_modules/readdir-glob/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", "dev": true, "license": "MIT", "dependencies": { @@ -9961,9 +10041,9 @@ } }, "node_modules/readdir-glob/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", "dev": true, "license": "ISC", "dependencies": { @@ -10142,9 +10222,9 @@ "license": "MIT" }, "node_modules/regjsparser": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.0.tgz", - "integrity": "sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==", + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.1.tgz", + "integrity": "sha512-dLsljMd9sqwRkby8zhO1gSg3PnJIBFid8f4CQj/sXx+7cKx+E7u0PKhZ+U4wmhx7EfmtvnA318oVaIkAB1lRJw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -10192,12 +10272,13 @@ "license": "ISC" }, "node_modules/resolve": { - "version": "1.22.11", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", - "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "version": "1.22.12", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", + "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==", "dev": true, "license": "MIT", "dependencies": { + "es-errors": "^1.3.0", "is-core-module": "^2.16.1", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" @@ -10315,7 +10396,7 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dev": true, "license": "ISC", "dependencies": { @@ -10367,16 +10448,23 @@ "tslib": "^2.1.0" } }, + "node_modules/rxjs/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, "node_modules/safe-array-concat": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz", - "integrity": "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.4.tgz", + "integrity": "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==", "dev": true, "license": "MIT", "dependencies": { - "call-bind": "^1.0.8", - "call-bound": "^1.0.2", - "get-intrinsic": "^1.2.6", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", "has-symbols": "^1.1.0", "isarray": "^2.0.5" }, @@ -10451,14 +10539,14 @@ "license": "MIT" }, "node_modules/sass": { - "version": "1.97.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.97.0.tgz", - "integrity": "sha512-KR0igP1z4avUJetEuIeOdDlwaUDvkH8wSx7FdSjyYBS3dpyX3TzHfAMO0G1Q4/3cdjcmi3r7idh+KCmKqS+KeQ==", + "version": "1.99.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.99.0.tgz", + "integrity": "sha512-kgW13M54DUB7IsIRM5LvJkNlpH+WhMpooUcaWGFARkF1Tc82v9mIWkCbCYf+MBvpIUBSeSOTilpZjEPr2VYE6Q==", "dev": true, "license": "MIT", "dependencies": { "chokidar": "^4.0.0", - "immutable": "^5.0.2", + "immutable": "^5.1.5", "source-map-js": ">=0.6.2 <2.0.0" }, "bin": { @@ -10472,9 +10560,9 @@ } }, "node_modules/sass-loader": { - "version": "16.0.6", - "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.6.tgz", - "integrity": "sha512-sglGzId5gmlfxNs4gK2U3h7HlVRfx278YK6Ono5lwzuvi1jxig80YiuHkaDBVsYIKFhx8wN7XSCI0M2IDS/3qA==", + "version": "16.0.7", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.7.tgz", + "integrity": "sha512-w6q+fRHourZ+e+xA1kcsF27iGM6jdB8teexYCfdUw0sYgcDNeZESnDNT9sUmmPm3ooziwUJXGwZJSTF3kOdBfA==", "dev": true, "license": "MIT", "dependencies": { @@ -10488,7 +10576,7 @@ "url": "https://opencollective.com/webpack" }, "peerDependencies": { - "@rspack/core": "0.x || 1.x", + "@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0", "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", "sass": "^1.3.0", "sass-embedded": "*", @@ -10563,9 +10651,9 @@ } }, "node_modules/schema-utils/node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "dev": true, "license": "MIT", "peer": true, @@ -10713,16 +10801,6 @@ "node": ">= 0.8" } }, - "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/serve-static": { "version": "1.16.3", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", @@ -10869,14 +10947,14 @@ } }, "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" + "object-inspect": "^1.13.4" }, "engines": { "node": ">= 0.4" @@ -11041,9 +11119,9 @@ } }, "node_modules/streamx": { - "version": "2.23.0", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.23.0.tgz", - "integrity": "sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg==", + "version": "2.25.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.25.0.tgz", + "integrity": "sha512-0nQuG6jf1w+wddNEEXCF4nTg3LtufWINB5eFEN+5TNZW7KWJp6x87+JFL43vaAUPyCfH1wID+mNVyW6OHtFamg==", "dev": true, "license": "MIT", "dependencies": { @@ -11317,9 +11395,9 @@ } }, "node_modules/stylelint-scss": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/stylelint-scss/-/stylelint-scss-6.13.0.tgz", - "integrity": "sha512-kZPwFUJkfup2gP1enlrS2h9U5+T5wFoqzJ1n/56AlpwSj28kmFe7ww/QFydvPsg5gLjWchAwWWBLtterynZrOw==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/stylelint-scss/-/stylelint-scss-6.14.0.tgz", + "integrity": "sha512-ZKmHMZolxeuYsnB+PCYrTpFce0/QWX9i9gh0hPXzp73WjuIMqUpzdQaBCrKoLWh6XtCFSaNDErkMPqdjy1/8aA==", "dev": true, "license": "MIT", "dependencies": { @@ -11339,13 +11417,6 @@ "stylelint": "^16.8.2" } }, - "node_modules/stylelint-scss/node_modules/mdn-data": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.25.0.tgz", - "integrity": "sha512-T2LPsjgUE/tgMmRXREVmwsux89DwWfNjiynOeXuLd2mX6jphGQ2YE3Ukz7LQ2VOFKiVZU/Ee1GqzHiipZCjymw==", - "dev": true, - "license": "CC0-1.0" - }, "node_modules/stylelint/node_modules/balanced-match": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-2.0.0.tgz", @@ -11354,25 +11425,25 @@ "license": "MIT" }, "node_modules/stylelint/node_modules/file-entry-cache": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.1.tgz", - "integrity": "sha512-TPVFSDE7q91Dlk1xpFLvFllf8r0HyOMOlnWy7Z2HBku5H3KhIeOGInexrIeg2D64DosVB/JXkrrk6N/7Wriq4A==", + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.2.tgz", + "integrity": "sha512-N2WFfK12gmrK1c1GXOqiAJ1tc5YE+R53zvQ+t5P8S5XhnmKYVB5eZEiLNZKDSmoG8wqqbF9EXYBBW/nef19log==", "dev": true, "license": "MIT", "dependencies": { - "flat-cache": "^6.1.19" + "flat-cache": "^6.1.20" } }, "node_modules/stylelint/node_modules/flat-cache": { - "version": "6.1.19", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.19.tgz", - "integrity": "sha512-l/K33newPTZMTGAnnzaiqSl6NnH7Namh8jBNjrgjprWxGmZUuxx/sJNIRaijOh3n7q7ESbhNZC+pvVZMFdeU4A==", + "version": "6.1.22", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.22.tgz", + "integrity": "sha512-N2dnzVJIphnNsjHcrxGW7DePckJ6haPrSFqpsBUhHYgwtKGVq4JrBGielEGD2fCVnsGm1zlBVZ8wGhkyuetgug==", "dev": true, "license": "MIT", "dependencies": { - "cacheable": "^2.2.0", - "flatted": "^3.3.3", - "hookified": "^1.13.0" + "cacheable": "^2.3.4", + "flatted": "^3.4.2", + "hookified": "^1.15.0" } }, "node_modules/stylelint/node_modules/globby": { @@ -11501,6 +11572,33 @@ "integrity": "sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==", "dev": true }, + "node_modules/systeminformation": { + "version": "5.31.5", + "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.31.5.tgz", + "integrity": "sha512-5SyLdip4/3alxD4Kh+63bUQTJmu7YMfYQTC+koZy7X73HgNqZSD2P4wOZQWtUncvPvcEmnfIjCoygN4MRoEejQ==", + "dev": true, + "license": "MIT", + "os": [ + "darwin", + "linux", + "win32", + "freebsd", + "openbsd", + "netbsd", + "sunos", + "android" + ], + "bin": { + "systeminformation": "lib/cli.js" + }, + "engines": { + "node": ">=8.0.0" + }, + "funding": { + "type": "Buy me a coffee", + "url": "https://www.buymeacoffee.com/systeminfo" + } + }, "node_modules/table": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/table/-/table-6.9.0.tgz", @@ -11519,9 +11617,9 @@ } }, "node_modules/table/node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "dev": true, "license": "MIT", "dependencies": { @@ -11571,17 +11669,28 @@ } }, "node_modules/tar-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", - "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.8.tgz", + "integrity": "sha512-U6QpVRyCGHva435KoNWy9PRoi2IFYCgtEhq9nmrPPpbRacPs9IH4aJ3gbrFC8dPcXvdSZ4XXfXT5Fshbp2MtlQ==", "dev": true, "license": "MIT", "dependencies": { "b4a": "^1.6.4", + "bare-fs": "^4.5.5", "fast-fifo": "^1.2.0", "streamx": "^2.15.0" } }, + "node_modules/teex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz", + "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "streamx": "^2.12.5" + } + }, "node_modules/term-size": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", @@ -11596,9 +11705,9 @@ } }, "node_modules/terser": { - "version": "5.44.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz", - "integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==", + "version": "5.46.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.2.tgz", + "integrity": "sha512-uxfo9fPcSgLDYob/w1FuL0c99MWiJDnv+5qXSQc5+Ki5NjVNsYi66INnMFBjf6uFz6OnX12piJQPF4IpjJTNTw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -11615,16 +11724,15 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.16", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.16.tgz", - "integrity": "sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-UYhptBwhWvfIjKd/UuFo6D8uq9xpGLDK+z8EDsj/zWhrTaH34cKEbrkMKfV5YWqGBvAYA3tlzZbs2R+qYrbQJA==", "dev": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "jest-worker": "^27.4.5", "schema-utils": "^4.3.0", - "serialize-javascript": "^6.0.2", "terser": "^5.31.1" }, "engines": { @@ -11657,9 +11765,9 @@ "license": "MIT" }, "node_modules/text-decoder": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", - "integrity": "sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz", + "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -11799,6 +11907,19 @@ "tree-kill": "cli.js" } }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -11826,9 +11947,9 @@ } }, "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true, "license": "0BSD" }, @@ -11979,6 +12100,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -12007,9 +12129,9 @@ } }, "node_modules/undici-types": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", - "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "version": "7.19.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.19.2.tgz", + "integrity": "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==", "dev": true, "license": "MIT" }, @@ -12318,9 +12440,9 @@ } }, "node_modules/watchpack": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz", - "integrity": "sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.5.1.tgz", + "integrity": "sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==", "dev": true, "license": "MIT", "dependencies": { @@ -12339,9 +12461,9 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.104.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.104.1.tgz", - "integrity": "sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==", + "version": "5.106.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.106.2.tgz", + "integrity": "sha512-wGN3qcrBQIFmQ/c0AiOAQBvrZ5lmY8vbbMv4Mxfgzqd/B6+9pXtLo73WuS1dSGXM5QYY3hZnIbvx+K1xxe6FyA==", "dev": true, "license": "MIT", "peer": true, @@ -12352,25 +12474,24 @@ "@webassemblyjs/ast": "^1.14.1", "@webassemblyjs/wasm-edit": "^1.14.1", "@webassemblyjs/wasm-parser": "^1.14.1", - "acorn": "^8.15.0", + "acorn": "^8.16.0", "acorn-import-phases": "^1.0.3", "browserslist": "^4.28.1", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.4", + "enhanced-resolve": "^5.20.0", "es-module-lexer": "^2.0.0", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.2.11", - "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.3.1", - "mime-types": "^2.1.27", + "mime-db": "^1.54.0", "neo-async": "^2.6.2", "schema-utils": "^4.3.3", "tapable": "^2.3.0", - "terser-webpack-plugin": "^5.3.16", - "watchpack": "^2.4.4", - "webpack-sources": "^3.3.3" + "terser-webpack-plugin": "^5.3.17", + "watchpack": "^2.5.1", + "webpack-sources": "^3.3.4" }, "bin": { "webpack": "bin/webpack.js" @@ -12389,20 +12510,15 @@ } }, "node_modules/webpack-cli": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-6.0.1.tgz", - "integrity": "sha512-MfwFQ6SfwinsUVi0rNJm7rHZ31GyTcpVE5pgVA3hwFRb7COD4TzjUUwhGWKfO50+xdc2MQPuEBBJoqIMGt3JDw==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-7.0.2.tgz", + "integrity": "sha512-dB0R4T+C/8YuvM+fabdvil6QE44/ChDXikV5lOOkrUeCkW5hTJv2pGLE3keh+D5hjYw8icBaJkZzpFoaHV4T+g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "@discoveryjs/json-ext": "^0.6.1", - "@webpack-cli/configtest": "^3.0.1", - "@webpack-cli/info": "^3.0.1", - "@webpack-cli/serve": "^3.0.1", - "colorette": "^2.0.14", - "commander": "^12.1.0", - "cross-spawn": "^7.0.3", + "@discoveryjs/json-ext": "^1.0.0", + "commander": "^14.0.3", + "cross-spawn": "^7.0.6", "envinfo": "^7.14.0", "fastest-levenshtein": "^1.0.12", "import-local": "^3.0.2", @@ -12414,14 +12530,16 @@ "webpack-cli": "bin/cli.js" }, "engines": { - "node": ">=18.12.0" + "node": ">=20.9.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/webpack" }, "peerDependencies": { - "webpack": "^5.82.0" + "webpack": "^5.101.0", + "webpack-bundle-analyzer": "^4.0.0 || ^5.0.0", + "webpack-dev-server": "^5.0.0" }, "peerDependenciesMeta": { "webpack-bundle-analyzer": { @@ -12433,13 +12551,13 @@ } }, "node_modules/webpack-cli/node_modules/commander": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", - "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", "dev": true, "license": "MIT", "engines": { - "node": ">=18" + "node": ">=20" } }, "node_modules/webpack-cli/node_modules/interpret": { @@ -12468,9 +12586,9 @@ } }, "node_modules/webpack-sources": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.3.3.tgz", - "integrity": "sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.4.0.tgz", + "integrity": "sha512-gHwIe1cgBvvfLeu1Yz/dcFpmHfKDVxxyqI+kzqmuxZED81z2ChxpyqPaWcNqigPywhaEke7AjSGga+kxY55gjQ==", "dev": true, "license": "MIT", "engines": { @@ -12478,14 +12596,14 @@ } }, "node_modules/webpack/node_modules/enhanced-resolve": { - "version": "5.18.4", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.4.tgz", - "integrity": "sha512-LgQMM4WXU3QI+SYgEc2liRgznaD5ojbmY3sb8LxyguVkIg5FxdpTkvk72te2R38/TGKxH634oLxXRGY6d7AP+Q==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.0.tgz", + "integrity": "sha512-otxSQPw4lkOZWkHpB3zaEQs6gWYEsmX4xQF68ElXC/TWvGxGMSGOvoNbaLXm6/cS/fSfHtsEdw90y20PCd+sCA==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" + "tapable": "^2.3.3" }, "engines": { "node": ">=10.13.0" @@ -12515,10 +12633,20 @@ "node": ">=4.0" } }, + "node_modules/webpack/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/webpack/node_modules/tapable": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", - "integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", "dev": true, "license": "MIT", "engines": { @@ -12631,9 +12759,9 @@ "license": "ISC" }, "node_modules/which-typed-array": { - "version": "1.1.19", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", - "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.20.tgz", + "integrity": "sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==", "dev": true, "license": "MIT", "dependencies": { @@ -12771,13 +12899,13 @@ } }, "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", - "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, "license": "MIT", "dependencies": { - "ansi-regex": "^6.0.1" + "ansi-regex": "^6.2.2" }, "engines": { "node": ">=12" diff --git a/package.json b/package.json index 7e22d84..ccfd87e 100644 --- a/package.json +++ b/package.json @@ -20,34 +20,41 @@ "virtual scroll" ], "license": "ISC", + "browserslist": [ + ">= 0.5%", + "not ie 11", + "not op_mini all", + "not dead" + ], "dependencies": { "tooltip-plugin": "^1.0.16" }, "devDependencies": { - "@babel/core": "^7.28.3", - "@babel/preset-env": "^7.28.3", - "autoprefixer": "^10.4.21", - "babel-loader": "^10.0.0", - "css-loader": "^7.1.2", - "cypress": "^14.5.4", - "cypress-real-events": "^1.14.0", + "@babel/core": "^7.29.0", + "@babel/preset-env": "^7.29.2", + "autoprefixer": "^10.5.0", + "babel-loader": "^10.1.1", + "css-loader": "^7.1.4", + "cypress": "^15.14.1", + "cypress-real-events": "^1.15.0", "docsify-cli": "^4.4.4", "eslint": "^8.57.1", "eslint-config-airbnb-base": "^15.0.0", "eslint-import-resolver-webpack": "^0.13.10", "eslint-plugin-import": "^2.32.0", "eslint-plugin-sonarjs": "^3.0.4", - "filemanager-webpack-plugin": "^9.0.1", + "filemanager-webpack-plugin": "^10.0.1", "mini-css-extract-plugin": "^2.9.4", "popover-plugin": "^1.0.13", - "postcss-loader": "^8.1.1", - "sass": "^1.90.0", - "sass-loader": "^16.0.5", - "stylelint": "^16.23.1", + "postcss-loader": "^8.2.1", + "sass": "^1.99.0", + "sass-loader": "^16.0.7", + "stylelint": "^16.26.1", "stylelint-config-sass-guidelines": "^12.1.0", - "typescript": "^5.9.2", + "ts-api-utils": "^2.5.0", + "typescript": "^5.9.3", "unminified-webpack-plugin": "^3.0.0", - "webpack": "^5.101.3", - "webpack-cli": "^6.0.1" + "webpack": "^5.106.2", + "webpack-cli": "^7.0.2" } } diff --git a/src/utils/utils.js b/src/utils/utils.js index 8b1355c..d7fc8e6 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,3 +1,5 @@ +const NON_WORD_CHARS_REGEX = /[^\p{L}\p{N}_]/gu; + export class Utils { /** * @param {any} text @@ -151,13 +153,29 @@ export class Utils { } /** + * Normalizes a string for diacritic-insensitive search. Decomposes the input + * via NFD, then strips every character that is not a Unicode letter + * (\p{L}), number (\p{N}), or underscore. As a side effect this removes + * combining marks (so "München" matches "Munchen", "Việt Nam" matches + * "Viet Nam", "Ёжик" matches "Ежик") as well as punctuation and whitespace + * (so "co-op" matches "coop" and "Foo Bar" collapses into "FooBar"). + * Base letters and numbers from many scripts (Latin, Greek, Cyrillic, CJK, + * etc.) are preserved, but scripts that rely on combining marks are NOT + * fully preserved — every Unicode combining mark is removed, which affects + * Thai vowel signs, Devanagari matras, hiragana/katakana voicing marks + * (dakuten/handakuten), etc. This produces fuzzier matching for those + * scripts; use `searchNormalize: false` if exact-match behavior is + * required. + * + * Note: a few atomic letters do not decompose under NFD (e.g. "ø", "æ", "ß") + * and are kept as-is — a search for "Bjorn" will not match "Bjørn". + * * @param {string} text * @return {string} * @memberof Utils */ static normalizeString(text) { - const NON_WORD_REGEX = /[^\w]/g; - return text.normalize('NFD').replace(NON_WORD_REGEX, ''); + return text.normalize('NFD').replace(NON_WORD_CHARS_REGEX, ''); } /**