@momentum-ui/web-components 3.0.0-beta.5 → 3.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/2547.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
"use strict";(self["momentum-web-components-[id]"]=self["momentum-web-components-[id]"]||[]).push([[2547],{4928:(t,e,i)=>{i(20109),i(61200);var s,o=i(90195),l=i(3001),n=i(31890),r=i(66677),h=i(4313),a=i(87161),d=i(70429),p=i(85125),u=i(20291),c=i(58175),m=i(10318),b=i(97103),g=i(79270),f=function(t,e,i,s){var o,l=arguments.length,n=l<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var r=t.length-1;r>=0;r--)(o=t[r])&&(n=(l<3?o(n):l>3?o(e,i,n):o(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},x=function(t,e,i,s){return new(i||(i=Promise))(function(o,l){function n(t){try{h(s.next(t))}catch(t){l(t)}}function r(t){try{h(s.throw(t))}catch(t){l(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,r)}h((s=s.apply(t,e||[])).next())})};!function(t){class e{determineMessageType(t){return t.reduce((t,e)=>"error"===e?t:e.type,"")}filterMessagesByType(t,e){return t.reduce((t,i)=>i.type===e?t.concat(i.message):t,[])}}t.MessageController=e;let i=class extends((0,l.yC)(a.LitElement)){constructor(){super(...arguments),this._focusedIndex=-1,this._focusedGroupIndex=-1,this.label="Options",this.options=[],this.customOptions=[],this.placeholder="",this.isMulti=!1,this.useVirtualScroll=!1,this.disabled=!1,this.ordered=!1,this.expanded=!1,this.groupExpandedList=[],this.searchItem=!1,this.compact=!1,this.noClearIcon=!1,this.selectWhenInFocus=!1,this.selectedOptions=[],this.visibleOptions=8,this.optionId="",this.optionValue="",this.isCustomContent=!1,this.searchable=!1,this.shape="none",this.value=[],this.inputValue="",this.allowCustomValue=!1,this.autofocus=!1,this.resultsTextLocalization="No Results",this.optionsTextLocalization="No Options",this.trimSpace=!1,this.invalid=!1,this.invalidText="",this.ariaLabel="",this.searchResultAriaLabel="",this.ariaLabelForComboBox="",this.clearAriaLabel="Clear",this.arrowAriaLabel="Expand",this.clearIconHeight="auto",this.allTextLocalization="All",this.selectAllTextLocalization="Select All",this.selectedTextLocalization="Selected",this.allowSelectAll=!1,this.showCustomError=!1,this.showLoader=!1,this.showSelectedCount=!1,this.popupChevronAriaHidden="true",this.newMomentum=!1,this.showFilterIcon=!1,this.preventFilter=!1,this.isDropdownArrow=!1,this.comboboxId="",this.helpText="",this.messageArr=[],this.htmlId="",this.readOnly=!1,this.messageController=new e,this.isOptGroup=!1,this.isSelectAllChecked=!1,this.multiSelectedIndex=-1,this.multiSelected=[],this.customContent=[],this.notifySelectedChange=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("change-selected",{composed:!0,bubbles:!0,detail:t}))},0),this.handleGroupFilter=t=>{const e=t.filter(t=>{if("string"!=typeof t&&"true"===t.isLabel)return t.groupName});return this.searchItem=!0,this.groupExpandedList=e.map(t=>{if("string"!=typeof t)return t.groupName}),t.filter(e=>"string"==typeof e||"true"!==e.isLabel||!!t.find(t=>{if("string"!=typeof e&&"string"!=typeof t)return e.groupName===t.groupName&&"false"===t.isLabel}))},this.notifyInputValueChanged=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("combobox-input",{composed:!0,bubbles:!0,detail:{value:t}})),this.notifySearchResultCount(),this.focusedGroupIndex=0,requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})},250),this.handleOutsideClick=t=>{let e=!1;const i=t.composedPath();i.length&&(e=!!i.find(t=>t===this),e||(this.setVisualListbox(!1),this.unselectedAllMultiTag()))},this.renderItem=(t,e)=>{const i=this.allowSelectAll?e+2:e+1,s=this.allowSelectAll?this.options.length+1:this.options.length,o=this.checkForVirtualScroll()?`, ${i} of ${s}`:"";return a.html`
|
|
2
|
-
<div
|
|
3
|
-
id=${this.getOptionId(t)}
|
|
4
|
-
title="${this.getOptionValue(t)}"
|
|
5
|
-
part="combobox-option"
|
|
6
|
-
class="md-combobox-option"
|
|
7
|
-
aria-posinset=${i}
|
|
8
|
-
aria-setsize=${s}
|
|
9
|
-
role=${this.isMulti?"checkbox":"listitem"}
|
|
10
|
-
aria-label="${this.isCustomContent?this.getOptionId(t):this.getOptionValue(t)}${o}"
|
|
11
|
-
tabindex="-1"
|
|
12
|
-
@click=${this.handleListClick}
|
|
13
|
-
aria-checked=${(0,u.ifDefined)(this.isMulti?this.isOptionChecked.call(this,t):void 0)}
|
|
14
|
-
>
|
|
15
|
-
${this.isMulti?a.html`
|
|
16
|
-
<span class="select-option" aria-hidden="true">
|
|
17
|
-
<md-icon name="check-bold" size="14" iconSet="momentumDesign"></md-icon>
|
|
18
|
-
</span>
|
|
19
|
-
`:a.nothing}
|
|
20
|
-
<span part="label" class="select-label" aria-hidden="true">
|
|
21
|
-
${this.isCustomContent?this.getCustomContent(t):this.highlightingSearchedText(t)}
|
|
22
|
-
</span>
|
|
23
|
-
</div>
|
|
24
|
-
`}}get focusedIndex(){return this._focusedIndex}set focusedIndex(t){this.updateFocusedIndex(t)}updateFocusedIndex(t){var e,i,s,o;const l=this._focusedIndex;if(this.checkForVirtualScroll()){let l;l=this.allowSelectAll?0===t?"selectAll":this.getOptionId(this.filteredOptions[t-1]):this.getOptionId(this.filteredOptions[t]);const n=this.lists?null===(e=[...this.lists])||void 0===e?void 0:e.find(t=>0!==t.offsetHeight&&t.id===l):"";this.lists&&[...this.lists].forEach(t=>{t.toggleAttribute("focused",!1)}),n&&(null==n||n.toggleAttribute("focused",!0));const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("lit-virtualizer");r&&(-1===t?null===(s=r.element(t))||void 0===s||s.scrollIntoView({block:"start"}):null===(o=r.element(t))||void 0===o||o.scrollIntoView({block:"center"}))}else if(this.lists){const e=this.lists[l];e&&e.toggleAttribute("focused",!1);const i=this.lists[t];i&&i.toggleAttribute("focused",!0)}this._focusedIndex=t,this.requestUpdate("focusedIndex",l)}get focusedGroupIndex(){return this._focusedGroupIndex}set focusedGroupIndex(t){const e=this._focusedGroupIndex;if(this.labels&&0!==this.labels.length){const i=this.labels[e];i&&i.toggleAttribute("focused",!1);const s=this.labels[t];s&&(s.toggleAttribute("focused",!0),s.focus())}this._focusedGroupIndex=t,this.requestUpdate("focusedGroupIndex",e)}get messageType(){return this.messageArr.length>0?this.messageController.determineMessageType(this.messageArr):null}get messages(){return this.messageType?this.messageController.filterMessagesByType(this.messageArr,this.messageType):null}notifySearchResultCount(){if(this.searchResultAriaLabel){const t=/{{.*?}}/g;this.ariaLabelForComboBox=this.searchResultAriaLabel.replace(t,this.filteredOptions.length.toString())}else this.ariaLabel?this.ariaLabelForComboBox=`${this.ariaLabel}, ${this.filteredOptions.length} results found.`:this.ariaLabelForComboBox=`ComboBox Element, ${this.filteredOptions.length} results found.`}firstUpdated(t){this.ariaLabelForComboBox=this.ariaLabel?this.ariaLabel:"ComboBox Element",super.firstUpdated(t),this.isCustomContent&&(this.optionId="id",this.optionValue="value",this.setOptionCustomContent()),this.setInitialValue()}updated(t){super.updated(t),t.has("expanded")&&(this.expanded?(this.resizeListbox(),this.checkSelectedOptions()):this.unCheckAllOptions()),t.has("focusedIndex")&&this.focusedIndex>=0&&(this.checkForVirtualScroll()||this.scrollToOption()),t.has("value")&&0===this.selectedOptions.length&&this.setInitialValue(),t.has("options")&&this.expanded&&this.checkForVirtualScroll()&&this.updateOnNextFrame(()=>{this.resizeListbox()}),t.has("customOptions")&&this.isCustomContent&&(this.setOptionCustomContent(),this.resizeListbox()),t.has("showCustomError")&&this.resizeListbox(),t.has("showLoader")&&this.resizeListbox(),t.has("searchItem")&&this.resizeListbox()}handleFocusIn(t){var e;this.disabled&&!this.readOnly||(this.noClearIcon&&(requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}),this.selectWhenInFocus&&this.input.select()),null===(e=super.handleFocusIn)||void 0===e||e.call(this,t)),this.dispatchEvent(new CustomEvent("combobox-focus-in",{composed:!0,bubbles:!0}))}handleFocusOut(t){var e;null===(e=super.handleFocusOut)||void 0===e||e.call(this,t),this.dispatchEvent(new CustomEvent("combobox-focus-out",{composed:!0,bubbles:!0}))}findFilteredOption(t){return this.isOptionObject(t)?this.filteredOptions.findIndex(e=>this.getOptionId(e)===this.getOptionId(t)&&this.getOptionValue(e)===this.getOptionValue(t)):this.filteredOptions.indexOf(t)}setInitialValue(){var t;if(this.value.length)if(this.isMulti)this.value.forEach(t=>{-1!==this.findFilteredOption(t)&&this.setSelectedOption(t)});else{const e=this.value[0],i=this.findFilteredOption(e);-1!==i&&(this.setSelectedOption(e),this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedIndex=i,this.focusedGroupIndex=-1)}}isOptionObject(t){return"object"==typeof t&&null!==t}setOptionCustomContent(){if(this.isOptGroup){const t=[...this.querySelectorAll("optgroup")],e=[];for(const i of t){const t=i.getAttribute("label"),s=[...i.querySelectorAll("[slot]")];e.push({isLabel:"true",[this.optionValue]:t,groupName:t});for(const i of s){const s=i.getAttribute("aria-label"),o=i.getAttribute("display-value"),l=i.getAttribute("slot");s&&o&&e.push({[this.optionId]:s,[this.optionValue]:o,isLabel:"false",groupName:t,slot:l})}}this.options=e}else this.customContent=[...this.querySelectorAll("[slot]")],this.customContent&&this.customContent.length?this.options=this.customContent.map(t=>{const e=t.getAttribute("aria-label"),i=t.getAttribute("display-value");if(e&&i)return{[this.optionId]:e,[this.optionValue]:i}}):this.options=[]}getOptionValue(t){return this.isOptionObject(t)?t[this.optionValue]:t}getOptionGroupName(t){return null==t?void 0:t.groupName}getOptionId(t){return this.isOptionObject(t)?t[this.optionId]:t}getFocusedItem(t){if(t>=0)return this.filteredOptions[t]}setupEvents(){document.addEventListener("click",this.handleOutsideClick),this.addEventListener("remove-all-selected",this.removeAllSelected),this.addEventListener("selected-changed",this.selectedChange)}teardownEvents(){document.removeEventListener("click",this.handleOutsideClick),this.removeEventListener("remove-all-selected",this.removeAllSelected),this.removeEventListener("selected-changed",this.selectedChange)}setVisualListbox(t){this.expanded=t}setGroupList(t){this.groupExpandedList.includes(t)?(this.groupExpandedList.splice(this.groupExpandedList.indexOf(t),1),this.groupExpandedList=[...this.groupExpandedList]):this.searchItem?this.groupExpandedList.push(t):this.groupExpandedList=[t]}findSelectedOption(t){return this.optionId&&t?this.selectedOptions.findIndex(e=>e&&e[this.optionId]===t[this.optionId]):this.selectedOptions.indexOf(t)}findOptionIndex(t){const e=t.composedPath();if(this.checkForVirtualScroll()){let t="";return[...this.lists].forEach(i=>{e.includes(i)&&(t=i.id)}),this.filteredOptions.findIndex(e=>this.getOptionId(e)===t)}return[...this.lists].findIndex(t=>e.includes(t))}checkSelectedOptions(){if(this.checkForVirtualScroll()){const t=this.selectedOptions.map(t=>this.getOptionId(t)),e=[...this.lists].filter(t=>"selectAll"!==t.id);null==e||e.forEach(e=>{t.includes(e.id)?(this.isMulti&&(null==e||e.setAttribute("aria-checked","true")),null==e||e.setAttribute("aria-selected","true")):this.isMulti&&(null==e||e.setAttribute("aria-checked","false"))})}}unCheckAllOptions(){var t;this.checkForVirtualScroll()&&this.isMulti&&(null===(t=[...this.lists])||void 0===t||t.forEach(t=>{"selectAll"!==(null==t?void 0:t.id)&&(null==t||t.setAttribute("aria-checked","false"))}))}setSelectedOption(t){this.isMulti||(this.selectedOptions=[]);const e=this.findSelectedOption(t);if(-1!==e){const t=this.selectedOptions[e];this.selectedOptions.splice(e,1),this.notifySelectedChange({value:t,selected:this.selectedOptions})}else this.selectedOptions.push(t),this.notifySelectedChange({value:t,selected:this.selectedOptions});this.checkSelectedOptions(),this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()),this.requestUpdate()}filterOptions(t){if(this.preventFilter)return this.searchItem=!1,this.options;if(t&&t.length){const e=this.options.filter(e=>this.isOptGroup&&"string"!=typeof e&&"true"===e.isLabel?e:(this.isCustomContent?this.getOptionId(e):this.getOptionValue(e)).toLowerCase().includes(t.toLowerCase()));return this.isOptGroup?this.handleGroupFilter(e):e}return this.searchItem=!1,this.options}getListBoxVerticalPadding(){if(this.listBox){const t=window.getComputedStyle(this.listBox,null),e=parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom"));if(!isNaN(e))return e+2}return 10}resizeListbox(){this.updateOnNextFrame(()=>{var t;let e=0,i=0,s=0;const o=this.getListBoxVerticalPadding();if(this.lists){const t=this.checkForVirtualScroll()?[...this.lists].filter(t=>0!==t.offsetHeight):[...this.lists];e=t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0),s=this.checkForVirtualScroll()&&this.allowSelectAll?t.slice(1,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0):t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)}if(this.labels&&(i=[...this.labels].slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)),this.listBox&&(this.listBox.style.maxHeight=`${e+i+o}px`),this.virtualizer&&(this.virtualizer.style.height=`${s+o}px`),this.showCustomError||this.showLoader){const e=null===(t=this.listBox)||void 0===t?void 0:t.querySelector("[slot]");this.listBox&&e&&(this.listBox.style.height=`${e.clientHeight+o}px`,this.listBox.style.maxHeight=`${e.clientHeight+o}px`)}})}setInputValue(t=""){this.input.value=t}updateOnNextFrame(t){requestAnimationFrame(t)}unCheckedAllOptions(){this.isMulti&&(this.lists.forEach((t,e)=>this.unCheckedOption(e)),this.isSelectAllChecked=!1)}unCheckedOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","false"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}checkAllOptions(){this.isMulti&&this.lists.forEach((t,e)=>this.checkOption(e))}checkOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","true"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}isSelectAllSelected(){return this.selectedOptions.length===this.options.length}setFocusOnHost(t){this.setFocus&&this.setFocus(t)}isOptionFocused(t){return this.focusedIndex===t}getAriaState(t){return this.isOptionFocused(t)}scrollToOption(){var t,e;let i=0;const{top:s,bottom:o}=this.listBox.getBoundingClientRect(),l=this.lists[this.focusedIndex],n=null===(t=this.lists[this.focusedIndex+1]||l)||void 0===t?void 0:t.getBoundingClientRect(),r=null===(e=this.lists[this.focusedIndex-1]||l)||void 0===e?void 0:e.getBoundingClientRect();(null==n?void 0:n.bottom)>o?i=n.bottom-o+2:(null==r?void 0:r.top)<s&&(i=r.top-s-2),this.updateOnNextFrame(()=>{this.listBox.scrollTop+=i})}getCustomContentName(t){const e=this.options.indexOf(t);if(this.isOptGroup){const t=this.options[e];if(t&&"string"!=typeof t)return t.slot}else if(-1!==e)return this.customContent[e].slot}setInputSelectionRange(t,e){this.input.setSelectionRange(t,e)}isOptionChecked(t){return-1!==this.findSelectedOption(t)?"true":"false"}getInputSelection(){return this.input.selectionStart}canMultiSelect(){return 0===this.getInputSelection()&&0!==this.selectedOptions.length&&this.isMulti}removeMultiTag(){this.selected&&this.multiSelected.forEach(t=>{const e=this.selected[t];e&&e.hasAttribute("selected")&&this.removeSelected(this.selectedOptions[t])})}unselectedAllMultiTag(){this.selected&&this.selected.forEach(t=>t.removeAttribute("selected")),this.multiSelectedIndex=-1}findLastMultiSelected(){return this.selected[this.multiSelectedIndex]}toggleMultiSelectedTag(t,e){t&&t.toggleAttribute("selected",e)}selectMultiTag(t){if(this.canMultiSelect()){if(!t){this.multiSelected=[];const t=this.findLastMultiSelected();this.toggleMultiSelectedTag(t,!1)}this.multiSelectedIndex<=0?this.multiSelectedIndex=this.selectedOptions.length-1:this.multiSelectedIndex--,this.multiSelected.push(this.multiSelectedIndex);const e=this.findLastMultiSelected();this.toggleMultiSelectedTag(e,!0)}}handleListClick(t){return x(this,void 0,void 0,function*(){this.dispatchEvent(new CustomEvent("selected-changed",{detail:{event:t}})),yield this.updateComplete,this.isMulti?this.setVisualListbox(!0):this.setVisualListbox(!1),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})})}handleSelectAll(){return x(this,void 0,void 0,function*(){this.isSelectAllChecked=!this.isSelectAllChecked,this.isSelectAllChecked?(this.selectedOptions=[...this.options],this.checkAllOptions()):(this.selectedOptions=[],this.unCheckedAllOptions()),yield this.updateComplete,this.setVisualListbox(!0),this.notifySelectedChange({selected:this.selectedOptions})})}handleInputKeyUp(t){switch(t.code){case o.Uz.Escape:break;case o.Uz.Backspace:this.setFocusOnHost(!0),this.setVisualListbox(!0),this.resizeListbox(),this.removeMultiTag();break;case o.Uz.ArrowLeft:this.isMulti&&(t.shiftKey?this.selectMultiTag(!0):this.selectMultiTag(!1));break;default:this.isMulti&&this.unselectedAllMultiTag()}}handleInput(t){const e=t.target.value;this.inputValue=e.trim(),this.notifyInputValueChanged(e.trim())}removeAllSelected(){var t;this.focusedIndex=-1,this.focusedGroupIndex=-1,this.selectedOptions=[],this.inputValue="",this.setInputValue(),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,""),this.setVisualListbox(!1),this.unCheckedAllOptions(),this.setSelectedAttribute(void 0),this.updateOnNextFrame(()=>{this.input.focus()}),this.notifySelectedChange({selected:this.selectedOptions})}removeSelected(t){const e=this.findSelectedOption(t),i=this.filteredOptions.indexOf(t);-1!==i&&this.unCheckedOption(i),-1!==e&&(this.selectedOptions.splice(e,1),this.requestUpdate()),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})}selectedChange(t){var e;const{event:i}=t.detail;let s=this.findOptionIndex(i);if(-1!==s){this.focusedIndex=this.allowSelectAll&&this.checkForVirtualScroll()?s+1:s,this.isMulti&&this.allowSelectAll&&!this.checkForVirtualScroll()&&(s-=1);const t=this.getFocusedItem(s);this.setSelectedAttribute(t),t&&(this.setSelectedOption(t),this.isMulti?this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()):(this.setInputValue(this.getOptionValue(t)),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(t))))}}setSelectedAttribute(t){var e;let i="";t&&(i=this.getOptionId(t)),null===(e=this.lists)||void 0===e||e.forEach((t,e)=>{(null==t?void 0:t.id)===i?null==t||t.setAttribute("selected","true"):null==t||t.setAttribute("selected","false")})}shouldChangeButton(){const t=this.input&&this.input.value.length>0&&!this.noClearIcon||this.isMulti&&this.selectedOptions.length&&!this.noClearIcon;return t&&document.dispatchEvent(new CustomEvent("on-widget-update")),t}setCustomValue(){this.optionId||this.optionValue||(this.options=[...this.options,this.inputValue],this.setSelectedOption(this.inputValue),this.isMulti||this.updateOnNextFrame(()=>{var t;this.focusedIndex=this.filteredOptions.length-1;const e=this.getFocusedItem(this.focusedIndex);e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))}),this.dispatchEvent(new CustomEvent("custom-value-add",{composed:!0,bubbles:!0,detail:{value:this.inputValue}}))),this.inputValue=""}handleGroupFocus(){this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.filteredGroupOptions.length>0&&-1===this.focusedGroupIndex&&(this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===this.groupExpandedList[0])),this.updateOnNextFrame(()=>{-1===this.focusedGroupIndex||!this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length-1||this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length?this.focusedGroupIndex=0:this.focusedGroupIndex++}),this.focusedIndex=-1}handleInputKeyDown(t){var e,i;switch(t.code){case o.Uz.Backspace:this.focusedIndex=-1;break;case o.Uz.Tab:case o.Uz.Enter:if(this.setFocusOnHost(!0),this.expanded&&this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);this.allowCustomValue&&this.input&&this.input.value.length&&-1===this.findFilteredOption(this.inputValue)?this.setCustomValue():(e&&(this.setSelectedAttribute(e),this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll())}),this.setVisualListbox(!1),t.code===o.Uz.Tab&&this.isMulti)return;break;case o.Uz.ArrowDown:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedGroupIndex=-1)});break;case o.Uz.ArrowLeft:case o.Uz.ArrowRight:t.stopPropagation();break;case o.Uz.Escape:this.setFocusOnHost(!0),this.expanded?(t.stopPropagation(),this.setVisualListbox(!1)):(this.setInputValue(),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,""),this.focusedIndex=-1,this.focusedGroupIndex=-1,this.removeAllSelected(),this.setSelectedAttribute(void 0));break;case o.Uz.Home:this.setInputSelectionRange(0,0);break;case o.Uz.End:{const{length:t}=this.inputValue;this.setInputSelectionRange(t,t)}break;case o.Uz.Space:if(this.isMulti&&this.expanded){t.preventDefault();const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.setSelectedAttribute(e),this.showSelectedCount||(this.setInputValue(),null===(i=this.input)||void 0===i||i.setAttribute(o.iw.AriaActivedescendant,""))),0===this.focusedIndex&&this.allowSelectAll&&this.handleSelectAll()}this.expanded=!0}}handleGroupLabelKeyDown(t,e){switch(t.code){case o.Uz.Tab:this.handleGroupFocus();break;case o.Uz.Enter:case o.Uz.Space:-1!==this.focusedGroupIndex?this.toggleGroupListBox(t,e.value):(this.setFocusOnHost(!0),this.setVisualListbox(!1),this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll()}));break;case o.Uz.ArrowDown:if(0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))});break;case o.Uz.Escape:this.focusedGroupIndex=-1,this.setVisualListbox(!1),this.setFocusOnHost(!0),this.input.focus();break;default:this.setVisualListbox(!0)}}toggleVisualListBox(t){var e,i;if(!this.readOnly){if(t.target.classList.contains("md-combobox-listbox"))t.target.focus();else if("md-icon"===t.target.localName){const s=null===(i=null===(e=t.target.parentElement)||void 0===e?void 0:e.parentElement)||void 0===i?void 0:i.parentElement;if(s){const t=s.querySelector(".md-combobox-listbox");(0,b.setTimeout)(()=>{t.focus()},10)}}this.expanded?this.setVisualListbox(!1):(this.dispatchEvent(new CustomEvent("combobox-on-expand",{composed:!0,bubbles:!0})),this.notifySearchResultCount(),this.setVisualListbox(!0)),this.input.focus(),this.setGroupList(""),this.focusedGroupIndex=-1}}toggleGroupListBox(t,e){t.stopPropagation(),this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===e),this.setGroupList(e),this.resizeListbox()}handleRemoveAll(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-all-selected"))}connectedCallback(){super.connectedCallback(),this.setupEvents(),this.querySelector("optgroup")&&(this.isOptGroup=!0)}disconnectedCallback(){super.disconnectedCallback(),this.teardownEvents()}static get styles(){return[h.A,g.A]}get listItemOptionMap(){return{"md-combobox-multiselect":this.isMulti,compact:this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}get filteredOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t&&this.groupExpandedList.includes(this.getOptionGroupName(t))?"false"===t.isLabel:void 0))}get filteredGroupOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t?"true"===t.isLabel:void 0))}get comboBoxTemplateClassMap(){return{[`md-combobox--${this.shape}`]:!!this.shape,"md-combobox-searchable":this.searchable,"md-combobox-has-leading-icon":this.searchable||this.showFilterIcon,"md-new-combobox":this.newMomentum,[`md-${this.messageType}`]:!!this.messageType,"md-combobox-readonly":this.readOnly,"md-combobox-compact":this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}searchIconTemplate(){return this.leadingIconTemplate("search-bold","search-icon")}filterIconTemplate(){return this.leadingIconTemplate("filter-bold","filter-icon")}leadingIconTemplate(t,e){return a.html`
|
|
1
|
+
"use strict";(self["momentum-web-components-[id]"]=self["momentum-web-components-[id]"]||[]).push([[2547],{4928:(t,e,i)=>{i(20109),i(61200);var s,o=i(90195),l=i(3001),n=i(31890),r=i(66677),h=i(4313),a=i(87161),d=i(70429),p=i(85125),u=i(20291),c=i(58175),m=i(10318),b=i(97103),g=i(79270),f=function(t,e,i,s){var o,l=arguments.length,n=l<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var r=t.length-1;r>=0;r--)(o=t[r])&&(n=(l<3?o(n):l>3?o(e,i,n):o(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},x=function(t,e,i,s){return new(i||(i=Promise))(function(o,l){function n(t){try{h(s.next(t))}catch(t){l(t)}}function r(t){try{h(s.throw(t))}catch(t){l(t)}}function h(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,r)}h((s=s.apply(t,e||[])).next())})};!function(t){class e{determineMessageType(t){return t.reduce((t,e)=>"error"===e?t:e.type,"")}filterMessagesByType(t,e){return t.reduce((t,i)=>i.type===e?t.concat(i.message):t,[])}}t.MessageController=e;let i=class extends((0,l.yC)(a.LitElement)){constructor(){super(...arguments),this._focusedIndex=-1,this._focusedGroupIndex=-1,this.label="Options",this.options=[],this.customOptions=[],this.placeholder="",this.isMulti=!1,this.useVirtualScroll=!1,this.disabled=!1,this.ordered=!1,this.expanded=!1,this.groupExpandedList=[],this.searchItem=!1,this.compact=!1,this.noClearIcon=!1,this.selectWhenInFocus=!1,this.selectedOptions=[],this.visibleOptions=8,this.optionId="",this.optionValue="",this.isCustomContent=!1,this.searchable=!1,this.shape="none",this.value=[],this.inputValue="",this.allowCustomValue=!1,this.autofocus=!1,this.resultsTextLocalization="No Results",this.optionsTextLocalization="No Options",this.trimSpace=!1,this.invalid=!1,this.invalidText="",this.ariaLabel="",this.searchResultAriaLabel="",this.ariaLabelForComboBox="",this.clearAriaLabel="Clear",this.arrowAriaLabel="Expand",this.clearIconHeight="auto",this.allTextLocalization="All",this.selectAllTextLocalization="Select All",this.selectedTextLocalization="Selected",this.allowSelectAll=!1,this.showCustomError=!1,this.showLoader=!1,this.showSelectedCount=!1,this.popupChevronAriaHidden="true",this.newMomentum=!1,this.showFilterIcon=!1,this.preventFilter=!1,this.isDropdownArrow=!1,this.comboboxId="",this.helpText="",this.messageArr=[],this.htmlId="",this.readOnly=!1,this.messageController=new e,this.isOptGroup=!1,this.isSelectAllChecked=!1,this.multiSelectedIndex=-1,this.multiSelected=[],this.customContent=[],this.notifySelectedChange=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("change-selected",{composed:!0,bubbles:!0,detail:t}))},0),this.handleGroupFilter=t=>{const e=t.filter(t=>{if("string"!=typeof t&&"true"===t.isLabel)return t.groupName});return this.searchItem=!0,this.groupExpandedList=e.map(t=>{if("string"!=typeof t)return t.groupName}),t.filter(e=>"string"==typeof e||"true"!==e.isLabel||!!t.find(t=>{if("string"!=typeof e&&"string"!=typeof t)return e.groupName===t.groupName&&"false"===t.isLabel}))},this.notifyInputValueChanged=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("combobox-input",{composed:!0,bubbles:!0,detail:{value:t}})),this.notifySearchResultCount(),this.focusedGroupIndex=0,requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})},250),this.handleOutsideClick=t=>{let e=!1;const i=t.composedPath();i.length&&(e=!!i.find(t=>t===this),e||(this.setVisualListbox(!1),this.unselectedAllMultiTag()))}}get focusedIndex(){return this._focusedIndex}set focusedIndex(t){this.updateFocusedIndex(t)}updateFocusedIndex(t){var e,i,s,o;const l=this._focusedIndex;if(this.checkForVirtualScroll()){let l;l=this.allowSelectAll?0===t?"selectAll":this.getOptionId(this.filteredOptions[t-1]):this.getOptionId(this.filteredOptions[t]);const n=this.lists?null===(e=[...this.lists])||void 0===e?void 0:e.find(t=>0!==t.offsetHeight&&t.id===l):"";this.lists&&[...this.lists].forEach(t=>{t.toggleAttribute("focused",!1)}),n&&(null==n||n.toggleAttribute("focused",!0));const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("lit-virtualizer");r&&(-1===t?null===(s=r.element(t))||void 0===s||s.scrollIntoView({block:"start"}):null===(o=r.element(t))||void 0===o||o.scrollIntoView({block:"center"}))}else if(this.lists){const e=this.lists[l];e&&e.toggleAttribute("focused",!1);const i=this.lists[t];i&&i.toggleAttribute("focused",!0)}this._focusedIndex=t,this.requestUpdate("focusedIndex",l)}get focusedGroupIndex(){return this._focusedGroupIndex}set focusedGroupIndex(t){const e=this._focusedGroupIndex;if(this.labels&&0!==this.labels.length){const i=this.labels[e];i&&i.toggleAttribute("focused",!1);const s=this.labels[t];s&&(s.toggleAttribute("focused",!0),s.focus())}this._focusedGroupIndex=t,this.requestUpdate("focusedGroupIndex",e)}get messageType(){return this.messageArr.length>0?this.messageController.determineMessageType(this.messageArr):null}get messages(){return this.messageType?this.messageController.filterMessagesByType(this.messageArr,this.messageType):null}notifySearchResultCount(){if(this.searchResultAriaLabel){const t=/{{.*?}}/g;this.ariaLabelForComboBox=this.searchResultAriaLabel.replace(t,this.filteredOptions.length.toString())}else this.ariaLabel?this.ariaLabelForComboBox=`${this.ariaLabel}, ${this.filteredOptions.length} results found.`:this.ariaLabelForComboBox=`ComboBox Element, ${this.filteredOptions.length} results found.`}firstUpdated(t){this.ariaLabelForComboBox=this.ariaLabel?this.ariaLabel:"ComboBox Element",super.firstUpdated(t),this.isCustomContent&&(this.optionId="id",this.optionValue="value",this.setOptionCustomContent()),this.setInitialValue()}updated(t){super.updated(t),t.has("expanded")&&(this.expanded?(this.resizeListbox(),this.checkSelectedOptions()):this.unCheckAllOptions()),t.has("focusedIndex")&&this.focusedIndex>=0&&(this.checkForVirtualScroll()||this.scrollToOption()),t.has("value")&&0===this.selectedOptions.length&&this.setInitialValue(),t.has("options")&&this.expanded&&this.checkForVirtualScroll()&&this.updateOnNextFrame(()=>{this.resizeListbox()}),t.has("customOptions")&&this.isCustomContent&&(this.setOptionCustomContent(),this.resizeListbox()),t.has("showCustomError")&&this.resizeListbox(),t.has("showLoader")&&this.resizeListbox(),t.has("searchItem")&&this.resizeListbox()}handleFocusIn(t){var e;this.disabled&&!this.readOnly||(this.noClearIcon&&(requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}),this.selectWhenInFocus&&this.input.select()),null===(e=super.handleFocusIn)||void 0===e||e.call(this,t)),this.dispatchEvent(new CustomEvent("combobox-focus-in",{composed:!0,bubbles:!0}))}handleFocusOut(t){var e;null===(e=super.handleFocusOut)||void 0===e||e.call(this,t),this.dispatchEvent(new CustomEvent("combobox-focus-out",{composed:!0,bubbles:!0}))}findFilteredOption(t){return this.isOptionObject(t)?this.filteredOptions.findIndex(e=>this.getOptionId(e)===this.getOptionId(t)&&this.getOptionValue(e)===this.getOptionValue(t)):this.filteredOptions.indexOf(t)}setInitialValue(){var t;if(this.value.length)if(this.isMulti)this.value.forEach(t=>{-1!==this.findFilteredOption(t)&&this.setSelectedOption(t)});else{const e=this.value[0],i=this.findFilteredOption(e);-1!==i&&(this.setSelectedOption(e),this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedIndex=i,this.focusedGroupIndex=-1)}}isOptionObject(t){return"object"==typeof t&&null!==t}setOptionCustomContent(){if(this.isOptGroup){const t=[...this.querySelectorAll("optgroup")],e=[];for(const i of t){const t=i.getAttribute("label"),s=[...i.querySelectorAll("[slot]")];e.push({isLabel:"true",[this.optionValue]:t,groupName:t});for(const i of s){const s=i.getAttribute("aria-label"),o=i.getAttribute("display-value"),l=i.getAttribute("slot");s&&o&&e.push({[this.optionId]:s,[this.optionValue]:o,isLabel:"false",groupName:t,slot:l})}}this.options=e}else this.customContent=[...this.querySelectorAll("[slot]")],this.customContent&&this.customContent.length?this.options=this.customContent.map(t=>{const e=t.getAttribute("aria-label"),i=t.getAttribute("display-value");if(e&&i)return{[this.optionId]:e,[this.optionValue]:i}}):this.options=[]}getOptionValue(t){return this.isOptionObject(t)?t[this.optionValue]:t}getOptionGroupName(t){return null==t?void 0:t.groupName}getOptionId(t){return this.isOptionObject(t)?t[this.optionId]:t}getFocusedItem(t){if(t>=0)return this.filteredOptions[t]}setupEvents(){document.addEventListener("click",this.handleOutsideClick),this.addEventListener("remove-all-selected",this.removeAllSelected),this.addEventListener("selected-changed",this.selectedChange)}teardownEvents(){document.removeEventListener("click",this.handleOutsideClick),this.removeEventListener("remove-all-selected",this.removeAllSelected),this.removeEventListener("selected-changed",this.selectedChange)}setVisualListbox(t){this.expanded=t}setGroupList(t){this.groupExpandedList.includes(t)?(this.groupExpandedList.splice(this.groupExpandedList.indexOf(t),1),this.groupExpandedList=[...this.groupExpandedList]):this.searchItem?this.groupExpandedList.push(t):this.groupExpandedList=[t]}findSelectedOption(t){return this.optionId&&t?this.selectedOptions.findIndex(e=>e&&e[this.optionId]===t[this.optionId]):this.selectedOptions.indexOf(t)}findOptionIndex(t){const e=t.composedPath();if(this.checkForVirtualScroll()){let t="";return[...this.lists].forEach(i=>{e.includes(i)&&(t=i.id)}),this.filteredOptions.findIndex(e=>this.getOptionId(e)===t)}return[...this.lists].findIndex(t=>e.includes(t))}checkSelectedOptions(){if(this.checkForVirtualScroll()){const t=this.selectedOptions.map(t=>this.getOptionId(t)),e=[...this.lists].filter(t=>"selectAll"!==t.id);null==e||e.forEach(e=>{t.includes(e.id)?(this.isMulti&&(null==e||e.setAttribute("aria-checked","true")),null==e||e.setAttribute("aria-selected","true")):this.isMulti&&(null==e||e.setAttribute("aria-checked","false"))})}}unCheckAllOptions(){var t;this.checkForVirtualScroll()&&this.isMulti&&(null===(t=[...this.lists])||void 0===t||t.forEach(t=>{"selectAll"!==(null==t?void 0:t.id)&&(null==t||t.setAttribute("aria-checked","false"))}))}setSelectedOption(t){this.isMulti||(this.selectedOptions=[]);const e=this.findSelectedOption(t);if(-1!==e){const t=this.selectedOptions[e];this.selectedOptions.splice(e,1),this.notifySelectedChange({value:t,selected:this.selectedOptions})}else this.selectedOptions.push(t),this.notifySelectedChange({value:t,selected:this.selectedOptions});this.checkSelectedOptions(),this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()),this.requestUpdate()}filterOptions(t){if(this.preventFilter)return this.searchItem=!1,this.options;if(t&&t.length){const e=this.options.filter(e=>this.isOptGroup&&"string"!=typeof e&&"true"===e.isLabel?e:(this.isCustomContent?this.getOptionId(e):this.getOptionValue(e)).toLowerCase().includes(t.toLowerCase()));return this.isOptGroup?this.handleGroupFilter(e):e}return this.searchItem=!1,this.options}getListBoxVerticalPadding(){if(this.listBox){const t=window.getComputedStyle(this.listBox,null),e=parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom"));if(!isNaN(e))return e+2}return 10}resizeListbox(){this.updateOnNextFrame(()=>{var t;let e=0,i=0,s=0;const o=this.getListBoxVerticalPadding();if(this.lists){const t=this.checkForVirtualScroll()?[...this.lists].filter(t=>0!==t.offsetHeight):[...this.lists];e=t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0),s=this.checkForVirtualScroll()&&this.allowSelectAll?t.slice(1,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0):t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)}if(this.labels&&(i=[...this.labels].slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)),this.listBox&&(this.listBox.style.maxHeight=`${e+i+o}px`),this.virtualizer&&(this.virtualizer.style.height=`${s+o}px`),this.showCustomError||this.showLoader){const e=null===(t=this.listBox)||void 0===t?void 0:t.querySelector("[slot]");this.listBox&&e&&(this.listBox.style.height=`${e.clientHeight+o}px`,this.listBox.style.maxHeight=`${e.clientHeight+o}px`)}})}setInputValue(t=""){this.input.value=t}updateOnNextFrame(t){requestAnimationFrame(t)}unCheckedAllOptions(){this.isMulti&&(this.lists.forEach((t,e)=>this.unCheckedOption(e)),this.isSelectAllChecked=!1)}unCheckedOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","false"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}checkAllOptions(){this.isMulti&&this.lists.forEach((t,e)=>this.checkOption(e))}checkOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","true"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}isSelectAllSelected(){return this.selectedOptions.length===this.options.length}setFocusOnHost(t){this.setFocus&&this.setFocus(t)}isOptionFocused(t){return this.focusedIndex===t}getAriaState(t){return this.isOptionFocused(t)}scrollToOption(){var t,e;let i=0;const{top:s,bottom:o}=this.listBox.getBoundingClientRect(),l=this.lists[this.focusedIndex],n=null===(t=this.lists[this.focusedIndex+1]||l)||void 0===t?void 0:t.getBoundingClientRect(),r=null===(e=this.lists[this.focusedIndex-1]||l)||void 0===e?void 0:e.getBoundingClientRect();(null==n?void 0:n.bottom)>o?i=n.bottom-o+2:(null==r?void 0:r.top)<s&&(i=r.top-s-2),this.updateOnNextFrame(()=>{this.listBox.scrollTop+=i})}getCustomContentName(t){const e=this.options.indexOf(t);if(this.isOptGroup){const t=this.options[e];if(t&&"string"!=typeof t)return t.slot}else if(-1!==e)return this.customContent[e].slot}setInputSelectionRange(t,e){this.input.setSelectionRange(t,e)}isOptionChecked(t){return-1!==this.findSelectedOption(t)?"true":"false"}getInputSelection(){return this.input.selectionStart}canMultiSelect(){return 0===this.getInputSelection()&&0!==this.selectedOptions.length&&this.isMulti}removeMultiTag(){this.selected&&this.multiSelected.forEach(t=>{const e=this.selected[t];e&&e.hasAttribute("selected")&&this.removeSelected(this.selectedOptions[t])})}unselectedAllMultiTag(){this.selected&&this.selected.forEach(t=>t.removeAttribute("selected")),this.multiSelectedIndex=-1}findLastMultiSelected(){return this.selected[this.multiSelectedIndex]}toggleMultiSelectedTag(t,e){t&&t.toggleAttribute("selected",e)}selectMultiTag(t){if(this.canMultiSelect()){if(!t){this.multiSelected=[];const t=this.findLastMultiSelected();this.toggleMultiSelectedTag(t,!1)}this.multiSelectedIndex<=0?this.multiSelectedIndex=this.selectedOptions.length-1:this.multiSelectedIndex--,this.multiSelected.push(this.multiSelectedIndex);const e=this.findLastMultiSelected();this.toggleMultiSelectedTag(e,!0)}}handleListClick(t){return x(this,void 0,void 0,function*(){this.dispatchEvent(new CustomEvent("selected-changed",{detail:{event:t}})),yield this.updateComplete,this.isMulti?this.setVisualListbox(!0):this.setVisualListbox(!1),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})})}handleSelectAll(){return x(this,void 0,void 0,function*(){this.isSelectAllChecked=!this.isSelectAllChecked,this.isSelectAllChecked?(this.selectedOptions=[...this.options],this.checkAllOptions()):(this.selectedOptions=[],this.unCheckedAllOptions()),yield this.updateComplete,this.setVisualListbox(!0),this.notifySelectedChange({selected:this.selectedOptions})})}handleInputKeyUp(t){switch(t.code){case o.Uz.Escape:break;case o.Uz.Backspace:this.setFocusOnHost(!0),this.setVisualListbox(!0),this.resizeListbox(),this.removeMultiTag();break;case o.Uz.ArrowLeft:this.isMulti&&(t.shiftKey?this.selectMultiTag(!0):this.selectMultiTag(!1));break;default:this.isMulti&&this.unselectedAllMultiTag()}}handleInput(t){const e=t.target.value;this.inputValue=e.trim(),this.notifyInputValueChanged(e.trim())}removeAllSelected(){var t;this.focusedIndex=-1,this.focusedGroupIndex=-1,this.selectedOptions=[],this.inputValue="",this.setInputValue(),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,""),this.setVisualListbox(!1),this.unCheckedAllOptions(),this.setSelectedAttribute(void 0),this.updateOnNextFrame(()=>{this.input.focus()}),this.notifySelectedChange({selected:this.selectedOptions})}removeSelected(t){const e=this.findSelectedOption(t),i=this.filteredOptions.indexOf(t);-1!==i&&this.unCheckedOption(i),-1!==e&&(this.selectedOptions.splice(e,1),this.requestUpdate()),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})}selectedChange(t){var e;const{event:i}=t.detail;let s=this.findOptionIndex(i);if(-1!==s){this.focusedIndex=this.allowSelectAll&&this.checkForVirtualScroll()?s+1:s,this.isMulti&&this.allowSelectAll&&!this.checkForVirtualScroll()&&(s-=1);const t=this.getFocusedItem(s);this.setSelectedAttribute(t),t&&(this.setSelectedOption(t),this.isMulti?this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()):(this.setInputValue(this.getOptionValue(t)),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(t))))}}setSelectedAttribute(t){var e;let i="";t&&(i=this.getOptionId(t)),null===(e=this.lists)||void 0===e||e.forEach((t,e)=>{(null==t?void 0:t.id)===i?null==t||t.setAttribute("selected","true"):null==t||t.setAttribute("selected","false")})}shouldChangeButton(){const t=this.input&&this.input.value.length>0&&!this.noClearIcon||this.isMulti&&this.selectedOptions.length&&!this.noClearIcon;return t&&document.dispatchEvent(new CustomEvent("on-widget-update")),t}setCustomValue(){this.optionId||this.optionValue||(this.options=[...this.options,this.inputValue],this.setSelectedOption(this.inputValue),this.isMulti||this.updateOnNextFrame(()=>{var t;this.focusedIndex=this.filteredOptions.length-1;const e=this.getFocusedItem(this.focusedIndex);e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))}),this.dispatchEvent(new CustomEvent("custom-value-add",{composed:!0,bubbles:!0,detail:{value:this.inputValue}}))),this.inputValue=""}handleGroupFocus(){this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.filteredGroupOptions.length>0&&-1===this.focusedGroupIndex&&(this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===this.groupExpandedList[0])),this.updateOnNextFrame(()=>{-1===this.focusedGroupIndex||!this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length-1||this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length?this.focusedGroupIndex=0:this.focusedGroupIndex++}),this.focusedIndex=-1}handleInputKeyDown(t){var e,i;switch(t.code){case o.Uz.Backspace:this.focusedIndex=-1;break;case o.Uz.Tab:case o.Uz.Enter:if(this.setFocusOnHost(!0),this.expanded&&this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);this.allowCustomValue&&this.input&&this.input.value.length&&-1===this.findFilteredOption(this.inputValue)?this.setCustomValue():(e&&(this.setSelectedAttribute(e),this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll())}),this.setVisualListbox(!1),t.code===o.Uz.Tab&&this.isMulti)return;break;case o.Uz.ArrowDown:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedGroupIndex=-1)});break;case o.Uz.ArrowLeft:case o.Uz.ArrowRight:t.stopPropagation();break;case o.Uz.Escape:this.setFocusOnHost(!0),this.expanded?(t.stopPropagation(),this.setVisualListbox(!1)):(this.setInputValue(),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,""),this.focusedIndex=-1,this.focusedGroupIndex=-1,this.removeAllSelected(),this.setSelectedAttribute(void 0));break;case o.Uz.Home:this.setInputSelectionRange(0,0);break;case o.Uz.End:{const{length:t}=this.inputValue;this.setInputSelectionRange(t,t)}break;case o.Uz.Space:if(this.isMulti&&this.expanded){t.preventDefault();const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.setSelectedAttribute(e),this.showSelectedCount||(this.setInputValue(),null===(i=this.input)||void 0===i||i.setAttribute(o.iw.AriaActivedescendant,""))),0===this.focusedIndex&&this.allowSelectAll&&this.handleSelectAll()}this.expanded=!0}}handleGroupLabelKeyDown(t,e){switch(t.code){case o.Uz.Tab:this.handleGroupFocus();break;case o.Uz.Enter:case o.Uz.Space:-1!==this.focusedGroupIndex?this.toggleGroupListBox(t,e.value):(this.setFocusOnHost(!0),this.setVisualListbox(!1),this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll()}));break;case o.Uz.ArrowDown:if(0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))});break;case o.Uz.Escape:this.focusedGroupIndex=-1,this.setVisualListbox(!1),this.setFocusOnHost(!0),this.input.focus();break;default:this.setVisualListbox(!0)}}toggleVisualListBox(t){var e,i;if(!this.readOnly){if(t.target.classList.contains("md-combobox-listbox"))t.target.focus();else if("md-icon"===t.target.localName){const s=null===(i=null===(e=t.target.parentElement)||void 0===e?void 0:e.parentElement)||void 0===i?void 0:i.parentElement;if(s){const t=s.querySelector(".md-combobox-listbox");(0,b.setTimeout)(()=>{t.focus()},10)}}this.expanded?this.setVisualListbox(!1):(this.dispatchEvent(new CustomEvent("combobox-on-expand",{composed:!0,bubbles:!0})),this.notifySearchResultCount(),this.setVisualListbox(!0)),this.input.focus(),this.setGroupList(""),this.focusedGroupIndex=-1}}toggleGroupListBox(t,e){t.stopPropagation(),this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===e),this.setGroupList(e),this.resizeListbox()}handleRemoveAll(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-all-selected"))}connectedCallback(){super.connectedCallback(),this.setupEvents(),this.querySelector("optgroup")&&(this.isOptGroup=!0)}disconnectedCallback(){super.disconnectedCallback(),this.teardownEvents()}static get styles(){return[h.A,g.A]}get listItemOptionMap(){return{"md-combobox-multiselect":this.isMulti,compact:this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}get filteredOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t&&this.groupExpandedList.includes(this.getOptionGroupName(t))?"false"===t.isLabel:void 0))}get filteredGroupOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t?"true"===t.isLabel:void 0))}get comboBoxTemplateClassMap(){return{[`md-combobox--${this.shape}`]:!!this.shape,"md-combobox-searchable":this.searchable,"md-combobox-has-leading-icon":this.searchable||this.showFilterIcon,"md-new-combobox":this.newMomentum,[`md-${this.messageType}`]:!!this.messageType,"md-combobox-readonly":this.readOnly,"md-combobox-compact":this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}searchIconTemplate(){return this.leadingIconTemplate("search-bold","search-icon")}filterIconTemplate(){return this.leadingIconTemplate("filter-bold","filter-icon")}leadingIconTemplate(t,e){return a.html`
|
|
25
2
|
<md-icon
|
|
26
3
|
name=${t}
|
|
27
4
|
class=${e}
|
|
@@ -125,7 +102,30 @@
|
|
|
125
102
|
<span part="group-label">${t.value}</span>
|
|
126
103
|
${this.groupArrowButtonTemplate(t.value)}
|
|
127
104
|
</div>
|
|
128
|
-
`}renderWithoutVirtualScroll(){return(0,c.repeat)(this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue),t=>this.getOptionId(t),(t,e)=>"string"!=typeof t&&this.isOptGroup&&"true"===t.isLabel?this.renderGroupLabelHeader(t,e):!this.isOptGroup||this.groupExpandedList.includes(this.getOptionGroupName(t))?this.renderItem(t,e):void 0)}highlightingSearchedText(t){return(0,r.ws)(this.getOptionValue(t),this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).map(({text:t,matching:e})=>e?a.html` <span class="highlight-text" part="select-label">${t}</span> `:a.html` <span class="selected-label-text" part="select-label">${t}</span> `)}addStyle(){const t=!this.expanded||this.options.length&&0===this.filteredOptions.length&&this.inputValue&&this.allowCustomValue;return this.checkForVirtualScroll()?(0,m.styleMap)({visibility:t?"hidden":"visible","z-index":t?"-1":"99",overflow:"hidden"}):(0,m.styleMap)({display:t?"none":"block","z-index":"99",overflow:"auto"})}
|
|
105
|
+
`}renderWithoutVirtualScroll(){return(0,c.repeat)(this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue),t=>this.getOptionId(t),(t,e)=>"string"!=typeof t&&this.isOptGroup&&"true"===t.isLabel?this.renderGroupLabelHeader(t,e):!this.isOptGroup||this.groupExpandedList.includes(this.getOptionGroupName(t))?this.renderItem(t,e):void 0)}highlightingSearchedText(t){return(0,r.ws)(this.getOptionValue(t),this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).map(({text:t,matching:e})=>e?a.html` <span class="highlight-text" part="select-label">${t}</span> `:a.html` <span class="selected-label-text" part="select-label">${t}</span> `)}addStyle(){const t=!this.expanded||this.options.length&&0===this.filteredOptions.length&&this.inputValue&&this.allowCustomValue;return this.checkForVirtualScroll()?(0,m.styleMap)({visibility:t?"hidden":"visible","z-index":t?"-1":"99",overflow:"hidden"}):(0,m.styleMap)({display:t?"none":"block","z-index":"99",overflow:"auto"})}renderItem(t,e){const i=this.allowSelectAll?e+2:e+1,s=this.allowSelectAll?this.options.length+1:this.options.length,o=this.checkForVirtualScroll()?`, ${i} of ${s}`:"";return a.html`
|
|
106
|
+
<div
|
|
107
|
+
id=${this.getOptionId(t)}
|
|
108
|
+
title="${this.getOptionValue(t)}"
|
|
109
|
+
part="combobox-option"
|
|
110
|
+
class="md-combobox-option"
|
|
111
|
+
aria-posinset=${i}
|
|
112
|
+
aria-setsize=${s}
|
|
113
|
+
role=${this.isMulti?"checkbox":"listitem"}
|
|
114
|
+
aria-label="${this.isCustomContent?this.getOptionId(t):this.getOptionValue(t)}${o}"
|
|
115
|
+
tabindex="-1"
|
|
116
|
+
@click=${t=>this.handleListClick(t)}
|
|
117
|
+
aria-checked=${(0,u.ifDefined)(this.isMulti?this.isOptionChecked.call(this,t):void 0)}
|
|
118
|
+
>
|
|
119
|
+
${this.isMulti?a.html`
|
|
120
|
+
<span class="select-option" aria-hidden="true">
|
|
121
|
+
<md-icon name="check-bold" size="14" iconSet="momentumDesign"></md-icon>
|
|
122
|
+
</span>
|
|
123
|
+
`:a.nothing}
|
|
124
|
+
<span part="label" class="select-label" aria-hidden="true">
|
|
125
|
+
${this.isCustomContent?this.getCustomContent(t):this.highlightingSearchedText(t)}
|
|
126
|
+
</span>
|
|
127
|
+
</div>
|
|
128
|
+
`}inputTitle(){return this.isMulti?this.selectedOptions.length>0?`${this.selectedOptions.length} ${this.selectedTextLocalization}`:this.placeholder:this.selectedOptions.length>0?this.getOptionValue(this.selectedOptions[0]):this.placeholder}helpTextTemplate(){return this.helpText?a.html`
|
|
129
129
|
<md-help-text
|
|
130
130
|
class="help-text ${(0,p.classMap)({disabled:this.disabled,newMomentum:this.newMomentum})}"
|
|
131
131
|
.message=${this.helpText}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
!function(t
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("lit"),require("lit/decorators.js"),require("@lit-labs/virtualizer"));else if("function"==typeof define&&define.amd)define(["lit","lit/decorators.js","@lit-labs/virtualizer"],t);else{var i="object"==typeof exports?t(require("lit"),require("lit/decorators.js"),require("@lit-labs/virtualizer")):t(e.lit,e["lit/decorators.js"],e["@lit-labs/virtualizer"]);for(var s in i)("object"==typeof exports?exports:e)[s]=i[s]}}(self,(e,t,i)=>(()=>{"use strict";var s,r={28307:(e,t,i)=>{i.r(t),i.d(t,{AdvanceList:()=>s});var s,r=i(90195),l=i(31890),d=i(32972),a=i(4313),o=(i(83048),i(87161)),n=i(70429),h=i(89312),c=function(e,t,i,s){var r,l=arguments.length,d=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(d=(l<3?r(d):l>3?r(t,i,d):r(t,i))||d);return l>3&&d&&Object.defineProperty(t,i,d),d};!function(e){e.prefixId="item-";let t=class extends((0,d.y)(o.LitElement)){constructor(){super(...arguments),this.items=[],this.isLoading=!1,this.isMulti=!1,this.groupOnMultiSelect=!1,this.value=[],this.ariaRoleList="listbox",this.ariaRoleListItem="option",this.ariaLabelList="",this.isError=!1,this.containerHeight="292px",this.lastSelectedIdByOrder="",this.selectAllItems=!1,this.focusReset=!1,this.disabledItems=[],this.totalRecords=0,this.isNonSelectable=!1,this.scrollIndex=-1,this.activeId="",this.selectedItemsIds=[],this.isUserNavigated=!1,this.handleKeyDown=t=>{var i,s,l;const{ArrowDown:d,ArrowUp:a,Tab:o,Space:n,Enter:h}=r.Uz,{code:c}=t,p=c===d,u=c===a,v=c===o,m=c===n,b=c===h;if(p||u){if(t.preventDefault(),this.isUserNavigated=!0,""===this.activeId&&this.value.length>0&&""!==this.value[0])return void(this.activeId=this.value[0]);if(""===this.activeId&&!u&&this.items.length>0)return void(this.activeId=this.items[0].id);const e=this.items.findIndex(e=>e.id===this.activeId);p?e<this.items.length-1&&!this.isNextElemenentStatusIndicator(e)&&(this.scrollIndex=e+1,this.activeId=this.items[this.scrollIndex].id,null===(i=this.virtualizer)||void 0===i||i.scrollToIndex(this.scrollIndex,"start")):e>0&&(this.scrollIndex=e-1,this.activeId=this.items[this.scrollIndex].id,null===(s=this.virtualizer)||void 0===s||s.scrollToIndex(this.scrollIndex,"start"))}else if(v)""===this.activeId&&this.value.length>0&&(this.activeId=this.value[0]);else if((m||b)&&(t.preventDefault(),this.activeId)){const t=null===(l=this.shadowRoot)||void 0===l?void 0:l.querySelector(`#${e.prefixId}${this.activeId}`);t&&("true"===t.getAttribute("aria-disabled")||t.hasAttribute("disabled")||this.updateItemSelection(t))}},this.handleRangeChange=e=>{const{last:t}=e;this.updateSelectedState(),this.items.length<this.totalRecords&&t>=this.items.length-1&&!this.isLoading&&!this.isError&&this.dispatchEvent(new CustomEvent("load-more",{bubbles:!0,composed:!0})),this.isUserNavigated=!1},this.renderItem=(t,i)=>{if(!t)return o.html`<div class="default-wrapper-error">Invalid item</div>`;if(!t.id)return console.warn(`AdvanceList.renderItem: item missing id at index ${i}`,t),o.html`<div class="default-wrapper-error">Item missing ID</div>`;try{return"status-indicator"===t.id?o.html`
|
|
2
|
+
<div class="default-wrapper-status-indicator" id="status-indicator">${t.template(t,i)}</div>
|
|
3
|
+
`:o.html`
|
|
4
|
+
<div
|
|
5
|
+
class="default-wrapper ${t.id} ${this.isNonSelectable?"non-selectable":""}"
|
|
6
|
+
part="advance-list-item-wrapper"
|
|
7
|
+
aria-setsize="${this.totalRecords}"
|
|
8
|
+
aria-posinset="${i+1}"
|
|
9
|
+
role="${this.ariaRoleListItem}"
|
|
10
|
+
aria-label=${t.name||"Unknown item"}
|
|
11
|
+
id="${e.prefixId}${t.id}"
|
|
12
|
+
data-index="${i}"
|
|
13
|
+
>
|
|
14
|
+
${t.template(t,i)}
|
|
15
|
+
</div>
|
|
16
|
+
`}catch(e){return console.error(`AdvanceList.renderItem: Error rendering item ${t.id} at index ${i}:`,e,t),o.html`<div class="default-wrapper-error">Error rendering item</div>`}}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick)}static get styles(){return[a.A,h.A]}getStyles(){return o.html`
|
|
17
17
|
<style>
|
|
18
18
|
:host .virtual-scroll {
|
|
19
19
|
height: ${this.containerHeight};
|
|
20
20
|
}
|
|
21
21
|
</style>
|
|
22
|
-
`}disconnectedCallback(){var
|
|
22
|
+
`}disconnectedCallback(){var e;super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),null===(e=this.listContainer)||void 0===e||e.removeEventListener("keydown",this.handleKeyDown)}firstUpdated(e){var t;super.firstUpdated(e),null===(t=this.listContainer)||void 0===t||t.addEventListener("keydown",this.handleKeyDown)}willUpdate(e){var t;null===(t=super.willUpdate)||void 0===t||t.call(this,e),e.has("value")&&(void 0!==e.get("value")||this.value.length>0)&&(this.selectedItemsIds=this.value),e.has("selectAllItems")&&this.selectAllItems&&(this.selectedItemsIds=this.items.filter(e=>e&&e.id&&!this.disabledItems.includes(e.id)).map(e=>e.id)),e.has("focusReset")&&this.focusReset&&(this.activeId="")}updated(e){super.updated(e),e.has("value")&&(void 0!==e.get("value")||this.value.length>0)&&this.updateSelectedState(),e.has("selectAllItems")&&this.selectAllItems&&(this.updateSelectedState(),this.notifySelectedChange())}setCheckboxAttributes(e,t){var i,s,r,l;!e||(null===(i=t.firstElementChild)||void 0===i?void 0:i.hasAttribute("disabled"))&&"true"===(null===(s=t.firstElementChild)||void 0===s?void 0:s.getAttribute("aria-disabled"))?null===(l=t.querySelector("md-checkbox"))||void 0===l||l.removeAttribute("checked"):null===(r=t.querySelector("md-checkbox"))||void 0===r||r.setAttribute("checked","true")}updateWrapperAttributes(e,t){this.isMulti?this.setCheckboxAttributes(t,e):e.classList.toggle("selected",t),e.setAttribute("selected",t.toString()),e.setAttribute("aria-selected",t.toString()),e.setAttribute("tabindex",t?"0":"-1")}updateSelectedState(){var t;Array.from((null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll(".default-wrapper"))||[]).forEach(t=>{var i,s;const r=this.selectedItemsIds.some(i=>t.id===`${e.prefixId}${i}`);this.updateWrapperAttributes(t,r),this.groupOnMultiSelect&&this.value.length>0&&this.items.length!==this.value.length&&t.id===`${e.prefixId}${this.lastSelectedIdByOrder}`?t.classList.add("selected-border-bottom"):t.classList.remove("selected-border-bottom"),t.id===`${e.prefixId}${this.activeId}`?(t.setAttribute("tabindex","0"),t.focus()):t.setAttribute("tabindex","-1"),""==this.activeId&&t.id===`${e.prefixId}${this.value[0]}`&&t.setAttribute("tabindex","0"),(null===(i=t.firstElementChild)||void 0===i?void 0:i.hasAttribute("disabled"))||"true"===(null===(s=t.firstElementChild)||void 0===s?void 0:s.getAttribute("aria-disabled"))?(t.setAttribute("disabled",""),t.setAttribute("aria-disabled","true")):(t.removeAttribute("disabled"),t.removeAttribute("aria-disabled"))})}findClickedItem(e){var t;const i=Array.from((null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelectorAll(".default-wrapper"))||[]),s=e.composedPath(),r=i.find(e=>s.includes(e));if(r)return(null==r?void 0:r.hasAttribute("disabled"))||"true"===(null==r?void 0:r.getAttribute("aria-disabled"))?0:r}isNextElemenentStatusIndicator(e){return(this.isLoading||this.isError)&&e===this.items.length-2}updateItemForMultiSelect(e){const t=this.selectedItemsIds.indexOf(e);-1===t?(this.selectedItemsIds.push(this.activeId),this.selectedItemsIds.length===this.items.length-this.disabledItems.length&&(this.selectAllItems=!0)):(this.selectedItemsIds.splice(t,1),this.selectAllItems=!1)}updateItemSelection(e){e&&(this.activeId=e.id.substring(e.id.indexOf("-")+1),this.isMulti?this.updateItemForMultiSelect(this.activeId):this.selectedItemsIds=[this.activeId],this.updateSelectedState(),this.notifySelectedChange())}handleClick(e){e.preventDefault(),this.isUserNavigated=!1;const t=this.findClickedItem(e);t&&(this.scrollIndex=parseInt(t.getAttribute("index")||"0"),this.updateItemSelection(t))}notifySelectedChange(){this.dispatchEvent(new CustomEvent("list-item-change",{detail:{selected:this.selectedItemsIds},bubbles:!0,composed:!0}))}getActiveDescendant(){return this.activeId?`${e.prefixId}${this.activeId}`:this.value?`${e.prefixId}${this.value[0]}`:""}render(){return o.html`
|
|
23
23
|
${this.getStyles()}
|
|
24
24
|
<div
|
|
25
25
|
class="md-advance-list-wrapper virtual-scroll"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
>
|
|
33
33
|
<lit-virtualizer
|
|
34
34
|
.items=${this.items}
|
|
35
|
-
.renderItem=${(t
|
|
35
|
+
.renderItem=${(e,t)=>this.renderItem(e,t)}
|
|
36
36
|
></lit-virtualizer>
|
|
37
37
|
</div>
|
|
38
|
-
`}};c([(0,n.property)({type:Array})],
|
|
38
|
+
`}};c([(0,n.property)({type:Array})],t.prototype,"items",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"isLoading",void 0),c([(0,n.property)({type:Boolean,attribute:"is-multi"})],t.prototype,"isMulti",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"groupOnMultiSelect",void 0),c([(0,n.property)({type:Array})],t.prototype,"value",void 0),c([(0,n.property)({type:String})],t.prototype,"ariaRoleList",void 0),c([(0,n.property)({type:String})],t.prototype,"ariaRoleListItem",void 0),c([(0,n.property)({type:String})],t.prototype,"ariaLabelList",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"isError",void 0),c([(0,n.property)({type:String})],t.prototype,"containerHeight",void 0),c([(0,n.property)({type:String})],t.prototype,"lastSelectedIdByOrder",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"selectAllItems",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"focusReset",void 0),c([(0,n.property)({type:Array})],t.prototype,"disabledItems",void 0),c([(0,n.property)({type:Number})],t.prototype,"totalRecords",void 0),c([(0,n.property)({type:Boolean})],t.prototype,"isNonSelectable",void 0),c([(0,n.query)(".virtual-scroll")],t.prototype,"listContainer",void 0),c([(0,n.query)("lit-virtualizer")],t.prototype,"virtualizer",void 0),c([(0,n.state)()],t.prototype,"scrollIndex",void 0),c([(0,n.state)()],t.prototype,"activeId",void 0),c([(0,n.state)()],t.prototype,"selectedItemsIds",void 0),c([(0,n.state)()],t.prototype,"isUserNavigated",void 0),t=c([(0,l.w)("md-advance-list")],t),e.ELEMENT=t}(s||(s={}))},70429:e=>{e.exports=t},83048:e=>{e.exports=i},87161:t=>{t.exports=e}},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var i=l[e]={exports:{}};return r[e](i,i.exports,d),i.exports}d.m=r,s=[],d.O=(e,t,i,r)=>{if(!t){var l=1/0;for(h=0;h<s.length;h++){for(var[t,i,r]=s[h],a=!0,o=0;o<t.length;o++)(!1&r||l>=r)&&Object.keys(d.O).every(e=>d.O[e](t[o]))?t.splice(o--,1):(a=!1,r<l&&(l=r));if(a){s.splice(h--,1);var n=i();void 0!==n&&(e=n)}}return e}r=r||0;for(var h=s.length;h>0&&s[h-1][2]>r;h--)s[h]=s[h-1];s[h]=[t,i,r]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},d.d=(e,t)=>{for(var i in t)d.o(t,i)&&!d.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={3079:0};d.O.j=t=>0===e[t];var t=(t,i)=>{var s,r,[l,a,o]=i,n=0;if(l.some(t=>0!==e[t])){for(s in a)d.o(a,s)&&(d.m[s]=a[s]);if(o)var h=o(d)}for(t&&t(i);n<l.length;n++)r=l[n],d.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return d.O(h)},i=self["momentum-web-components-[id]"]=self["momentum-web-components-[id]"]||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var a=d.O(void 0,[1890,4313,2576,8210,1270,9312],()=>d(28307));return d.O(a)})());
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("lit/directives/repeat.js"));else if("function"==typeof define&&define.amd)define(["lit","lit/decorators.js","lit/directives/class-map.js","lit/directives/style-map.js","lit/directives/if-defined.js","@momentum-ui/icons/data/momentumUiIconsNames.json","@momentum-ui/utils/lib/getColorValue","mobx","lit/directives/repeat.js"],e);else{var i="object"==typeof exports?e(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("lit/directives/repeat.js")):e(t.lit,t["lit/decorators.js"],t["lit/directives/class-map.js"],t["lit/directives/style-map.js"],t["lit/directives/if-defined.js"],t["@momentum-ui/icons/data/momentumUiIconsNames.json"],t["@momentum-ui/utils/lib/getColorValue"],t.mobx,t["lit/directives/repeat.js"]);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(self,(t,e,i,s,o,l,n,r,a)=>(()=>{"use strict";var h,d={4928:(t,e,i)=>{i.r(e),i.d(e,{ComboBox:()=>s}),i(20109),i(61200);var s,o=i(90195),l=i(3001),n=i(31890),r=i(66677),a=i(4313),h=i(87161),d=i(70429),p=i(85125),u=i(20291),c=i(58175),m=i(10318),b=i(97103),g=i(79270),f=function(t,e,i,s){var o,l=arguments.length,n=l<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var r=t.length-1;r>=0;r--)(o=t[r])&&(n=(l<3?o(n):l>3?o(e,i,n):o(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},x=function(t,e,i,s){return new(i||(i=Promise))(function(o,l){function n(t){try{a(s.next(t))}catch(t){l(t)}}function r(t){try{a(s.throw(t))}catch(t){l(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,r)}a((s=s.apply(t,e||[])).next())})};!function(t){class e{determineMessageType(t){return t.reduce((t,e)=>"error"===e?t:e.type,"")}filterMessagesByType(t,e){return t.reduce((t,i)=>i.type===e?t.concat(i.message):t,[])}}t.MessageController=e;let i=class extends((0,l.yC)(h.LitElement)){constructor(){super(...arguments),this._focusedIndex=-1,this._focusedGroupIndex=-1,this.label="Options",this.options=[],this.customOptions=[],this.placeholder="",this.isMulti=!1,this.useVirtualScroll=!1,this.disabled=!1,this.ordered=!1,this.expanded=!1,this.groupExpandedList=[],this.searchItem=!1,this.compact=!1,this.noClearIcon=!1,this.selectWhenInFocus=!1,this.selectedOptions=[],this.visibleOptions=8,this.optionId="",this.optionValue="",this.isCustomContent=!1,this.searchable=!1,this.shape="none",this.value=[],this.inputValue="",this.allowCustomValue=!1,this.autofocus=!1,this.resultsTextLocalization="No Results",this.optionsTextLocalization="No Options",this.trimSpace=!1,this.invalid=!1,this.invalidText="",this.ariaLabel="",this.searchResultAriaLabel="",this.ariaLabelForComboBox="",this.clearAriaLabel="Clear",this.arrowAriaLabel="Expand",this.clearIconHeight="auto",this.allTextLocalization="All",this.selectAllTextLocalization="Select All",this.selectedTextLocalization="Selected",this.allowSelectAll=!1,this.showCustomError=!1,this.showLoader=!1,this.showSelectedCount=!1,this.popupChevronAriaHidden="true",this.newMomentum=!1,this.showFilterIcon=!1,this.preventFilter=!1,this.isDropdownArrow=!1,this.comboboxId="",this.helpText="",this.messageArr=[],this.htmlId="",this.readOnly=!1,this.messageController=new e,this.isOptGroup=!1,this.isSelectAllChecked=!1,this.multiSelectedIndex=-1,this.multiSelected=[],this.customContent=[],this.notifySelectedChange=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("change-selected",{composed:!0,bubbles:!0,detail:t}))},0),this.handleGroupFilter=t=>{const e=t.filter(t=>{if("string"!=typeof t&&"true"===t.isLabel)return t.groupName});return this.searchItem=!0,this.groupExpandedList=e.map(t=>{if("string"!=typeof t)return t.groupName}),t.filter(e=>"string"==typeof e||"true"!==e.isLabel||!!t.find(t=>{if("string"!=typeof e&&"string"!=typeof t)return e.groupName===t.groupName&&"false"===t.isLabel}))},this.notifyInputValueChanged=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("combobox-input",{composed:!0,bubbles:!0,detail:{value:t}})),this.notifySearchResultCount(),this.focusedGroupIndex=0,requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})},250),this.handleOutsideClick=t=>{let e=!1;const i=t.composedPath();i.length&&(e=!!i.find(t=>t===this),e||(this.setVisualListbox(!1),this.unselectedAllMultiTag()))},this.renderItem=(t,e)=>{const i=this.allowSelectAll?e+2:e+1,s=this.allowSelectAll?this.options.length+1:this.options.length,o=this.checkForVirtualScroll()?`, ${i} of ${s}`:"";return h.html`
|
|
2
|
-
<div
|
|
3
|
-
id=${this.getOptionId(t)}
|
|
4
|
-
title="${this.getOptionValue(t)}"
|
|
5
|
-
part="combobox-option"
|
|
6
|
-
class="md-combobox-option"
|
|
7
|
-
aria-posinset=${i}
|
|
8
|
-
aria-setsize=${s}
|
|
9
|
-
role=${this.isMulti?"checkbox":"listitem"}
|
|
10
|
-
aria-label="${this.isCustomContent?this.getOptionId(t):this.getOptionValue(t)}${o}"
|
|
11
|
-
tabindex="-1"
|
|
12
|
-
@click=${this.handleListClick}
|
|
13
|
-
aria-checked=${(0,u.ifDefined)(this.isMulti?this.isOptionChecked.call(this,t):void 0)}
|
|
14
|
-
>
|
|
15
|
-
${this.isMulti?h.html`
|
|
16
|
-
<span class="select-option" aria-hidden="true">
|
|
17
|
-
<md-icon name="check-bold" size="14" iconSet="momentumDesign"></md-icon>
|
|
18
|
-
</span>
|
|
19
|
-
`:h.nothing}
|
|
20
|
-
<span part="label" class="select-label" aria-hidden="true">
|
|
21
|
-
${this.isCustomContent?this.getCustomContent(t):this.highlightingSearchedText(t)}
|
|
22
|
-
</span>
|
|
23
|
-
</div>
|
|
24
|
-
`}}get focusedIndex(){return this._focusedIndex}set focusedIndex(t){this.updateFocusedIndex(t)}updateFocusedIndex(t){var e,i,s,o;const l=this._focusedIndex;if(this.checkForVirtualScroll()){let l;l=this.allowSelectAll?0===t?"selectAll":this.getOptionId(this.filteredOptions[t-1]):this.getOptionId(this.filteredOptions[t]);const n=this.lists?null===(e=[...this.lists])||void 0===e?void 0:e.find(t=>0!==t.offsetHeight&&t.id===l):"";this.lists&&[...this.lists].forEach(t=>{t.toggleAttribute("focused",!1)}),n&&(null==n||n.toggleAttribute("focused",!0));const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("lit-virtualizer");r&&(-1===t?null===(s=r.element(t))||void 0===s||s.scrollIntoView({block:"start"}):null===(o=r.element(t))||void 0===o||o.scrollIntoView({block:"center"}))}else if(this.lists){const e=this.lists[l];e&&e.toggleAttribute("focused",!1);const i=this.lists[t];i&&i.toggleAttribute("focused",!0)}this._focusedIndex=t,this.requestUpdate("focusedIndex",l)}get focusedGroupIndex(){return this._focusedGroupIndex}set focusedGroupIndex(t){const e=this._focusedGroupIndex;if(this.labels&&0!==this.labels.length){const i=this.labels[e];i&&i.toggleAttribute("focused",!1);const s=this.labels[t];s&&(s.toggleAttribute("focused",!0),s.focus())}this._focusedGroupIndex=t,this.requestUpdate("focusedGroupIndex",e)}get messageType(){return this.messageArr.length>0?this.messageController.determineMessageType(this.messageArr):null}get messages(){return this.messageType?this.messageController.filterMessagesByType(this.messageArr,this.messageType):null}notifySearchResultCount(){if(this.searchResultAriaLabel){const t=/{{.*?}}/g;this.ariaLabelForComboBox=this.searchResultAriaLabel.replace(t,this.filteredOptions.length.toString())}else this.ariaLabel?this.ariaLabelForComboBox=`${this.ariaLabel}, ${this.filteredOptions.length} results found.`:this.ariaLabelForComboBox=`ComboBox Element, ${this.filteredOptions.length} results found.`}firstUpdated(t){this.ariaLabelForComboBox=this.ariaLabel?this.ariaLabel:"ComboBox Element",super.firstUpdated(t),this.isCustomContent&&(this.optionId="id",this.optionValue="value",this.setOptionCustomContent()),this.setInitialValue()}updated(t){super.updated(t),t.has("expanded")&&(this.expanded?(this.resizeListbox(),this.checkSelectedOptions()):this.unCheckAllOptions()),t.has("focusedIndex")&&this.focusedIndex>=0&&(this.checkForVirtualScroll()||this.scrollToOption()),t.has("value")&&0===this.selectedOptions.length&&this.setInitialValue(),t.has("options")&&this.expanded&&this.checkForVirtualScroll()&&this.updateOnNextFrame(()=>{this.resizeListbox()}),t.has("customOptions")&&this.isCustomContent&&(this.setOptionCustomContent(),this.resizeListbox()),t.has("showCustomError")&&this.resizeListbox(),t.has("showLoader")&&this.resizeListbox(),t.has("searchItem")&&this.resizeListbox()}handleFocusIn(t){var e;this.disabled&&!this.readOnly||(this.noClearIcon&&(requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}),this.selectWhenInFocus&&this.input.select()),null===(e=super.handleFocusIn)||void 0===e||e.call(this,t)),this.dispatchEvent(new CustomEvent("combobox-focus-in",{composed:!0,bubbles:!0}))}handleFocusOut(t){var e;null===(e=super.handleFocusOut)||void 0===e||e.call(this,t),this.dispatchEvent(new CustomEvent("combobox-focus-out",{composed:!0,bubbles:!0}))}findFilteredOption(t){return this.isOptionObject(t)?this.filteredOptions.findIndex(e=>this.getOptionId(e)===this.getOptionId(t)&&this.getOptionValue(e)===this.getOptionValue(t)):this.filteredOptions.indexOf(t)}setInitialValue(){var t;if(this.value.length)if(this.isMulti)this.value.forEach(t=>{-1!==this.findFilteredOption(t)&&this.setSelectedOption(t)});else{const e=this.value[0],i=this.findFilteredOption(e);-1!==i&&(this.setSelectedOption(e),this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedIndex=i,this.focusedGroupIndex=-1)}}isOptionObject(t){return"object"==typeof t&&null!==t}setOptionCustomContent(){if(this.isOptGroup){const t=[...this.querySelectorAll("optgroup")],e=[];for(const i of t){const t=i.getAttribute("label"),s=[...i.querySelectorAll("[slot]")];e.push({isLabel:"true",[this.optionValue]:t,groupName:t});for(const i of s){const s=i.getAttribute("aria-label"),o=i.getAttribute("display-value"),l=i.getAttribute("slot");s&&o&&e.push({[this.optionId]:s,[this.optionValue]:o,isLabel:"false",groupName:t,slot:l})}}this.options=e}else this.customContent=[...this.querySelectorAll("[slot]")],this.customContent&&this.customContent.length?this.options=this.customContent.map(t=>{const e=t.getAttribute("aria-label"),i=t.getAttribute("display-value");if(e&&i)return{[this.optionId]:e,[this.optionValue]:i}}):this.options=[]}getOptionValue(t){return this.isOptionObject(t)?t[this.optionValue]:t}getOptionGroupName(t){return null==t?void 0:t.groupName}getOptionId(t){return this.isOptionObject(t)?t[this.optionId]:t}getFocusedItem(t){if(t>=0)return this.filteredOptions[t]}setupEvents(){document.addEventListener("click",this.handleOutsideClick),this.addEventListener("remove-all-selected",this.removeAllSelected),this.addEventListener("selected-changed",this.selectedChange)}teardownEvents(){document.removeEventListener("click",this.handleOutsideClick),this.removeEventListener("remove-all-selected",this.removeAllSelected),this.removeEventListener("selected-changed",this.selectedChange)}setVisualListbox(t){this.expanded=t}setGroupList(t){this.groupExpandedList.includes(t)?(this.groupExpandedList.splice(this.groupExpandedList.indexOf(t),1),this.groupExpandedList=[...this.groupExpandedList]):this.searchItem?this.groupExpandedList.push(t):this.groupExpandedList=[t]}findSelectedOption(t){return this.optionId&&t?this.selectedOptions.findIndex(e=>e&&e[this.optionId]===t[this.optionId]):this.selectedOptions.indexOf(t)}findOptionIndex(t){const e=t.composedPath();if(this.checkForVirtualScroll()){let t="";return[...this.lists].forEach(i=>{e.includes(i)&&(t=i.id)}),this.filteredOptions.findIndex(e=>this.getOptionId(e)===t)}return[...this.lists].findIndex(t=>e.includes(t))}checkSelectedOptions(){if(this.checkForVirtualScroll()){const t=this.selectedOptions.map(t=>this.getOptionId(t)),e=[...this.lists].filter(t=>"selectAll"!==t.id);null==e||e.forEach(e=>{t.includes(e.id)?(this.isMulti&&(null==e||e.setAttribute("aria-checked","true")),null==e||e.setAttribute("aria-selected","true")):this.isMulti&&(null==e||e.setAttribute("aria-checked","false"))})}}unCheckAllOptions(){var t;this.checkForVirtualScroll()&&this.isMulti&&(null===(t=[...this.lists])||void 0===t||t.forEach(t=>{"selectAll"!==(null==t?void 0:t.id)&&(null==t||t.setAttribute("aria-checked","false"))}))}setSelectedOption(t){this.isMulti||(this.selectedOptions=[]);const e=this.findSelectedOption(t);if(-1!==e){const t=this.selectedOptions[e];this.selectedOptions.splice(e,1),this.notifySelectedChange({value:t,selected:this.selectedOptions})}else this.selectedOptions.push(t),this.notifySelectedChange({value:t,selected:this.selectedOptions});this.checkSelectedOptions(),this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()),this.requestUpdate()}filterOptions(t){if(this.preventFilter)return this.searchItem=!1,this.options;if(t&&t.length){const e=this.options.filter(e=>this.isOptGroup&&"string"!=typeof e&&"true"===e.isLabel?e:(this.isCustomContent?this.getOptionId(e):this.getOptionValue(e)).toLowerCase().includes(t.toLowerCase()));return this.isOptGroup?this.handleGroupFilter(e):e}return this.searchItem=!1,this.options}getListBoxVerticalPadding(){if(this.listBox){const t=window.getComputedStyle(this.listBox,null),e=parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom"));if(!isNaN(e))return e+2}return 10}resizeListbox(){this.updateOnNextFrame(()=>{var t;let e=0,i=0,s=0;const o=this.getListBoxVerticalPadding();if(this.lists){const t=this.checkForVirtualScroll()?[...this.lists].filter(t=>0!==t.offsetHeight):[...this.lists];e=t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0),s=this.checkForVirtualScroll()&&this.allowSelectAll?t.slice(1,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0):t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)}if(this.labels&&(i=[...this.labels].slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)),this.listBox&&(this.listBox.style.maxHeight=`${e+i+o}px`),this.virtualizer&&(this.virtualizer.style.height=`${s+o}px`),this.showCustomError||this.showLoader){const e=null===(t=this.listBox)||void 0===t?void 0:t.querySelector("[slot]");this.listBox&&e&&(this.listBox.style.height=`${e.clientHeight+o}px`,this.listBox.style.maxHeight=`${e.clientHeight+o}px`)}})}setInputValue(t=""){this.input.value=t}updateOnNextFrame(t){requestAnimationFrame(t)}unCheckedAllOptions(){this.isMulti&&(this.lists.forEach((t,e)=>this.unCheckedOption(e)),this.isSelectAllChecked=!1)}unCheckedOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","false"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}checkAllOptions(){this.isMulti&&this.lists.forEach((t,e)=>this.checkOption(e))}checkOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","true"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}isSelectAllSelected(){return this.selectedOptions.length===this.options.length}setFocusOnHost(t){this.setFocus&&this.setFocus(t)}isOptionFocused(t){return this.focusedIndex===t}getAriaState(t){return this.isOptionFocused(t)}scrollToOption(){var t,e;let i=0;const{top:s,bottom:o}=this.listBox.getBoundingClientRect(),l=this.lists[this.focusedIndex],n=null===(t=this.lists[this.focusedIndex+1]||l)||void 0===t?void 0:t.getBoundingClientRect(),r=null===(e=this.lists[this.focusedIndex-1]||l)||void 0===e?void 0:e.getBoundingClientRect();(null==n?void 0:n.bottom)>o?i=n.bottom-o+2:(null==r?void 0:r.top)<s&&(i=r.top-s-2),this.updateOnNextFrame(()=>{this.listBox.scrollTop+=i})}getCustomContentName(t){const e=this.options.indexOf(t);if(this.isOptGroup){const t=this.options[e];if(t&&"string"!=typeof t)return t.slot}else if(-1!==e)return this.customContent[e].slot}setInputSelectionRange(t,e){this.input.setSelectionRange(t,e)}isOptionChecked(t){return-1!==this.findSelectedOption(t)?"true":"false"}getInputSelection(){return this.input.selectionStart}canMultiSelect(){return 0===this.getInputSelection()&&0!==this.selectedOptions.length&&this.isMulti}removeMultiTag(){this.selected&&this.multiSelected.forEach(t=>{const e=this.selected[t];e&&e.hasAttribute("selected")&&this.removeSelected(this.selectedOptions[t])})}unselectedAllMultiTag(){this.selected&&this.selected.forEach(t=>t.removeAttribute("selected")),this.multiSelectedIndex=-1}findLastMultiSelected(){return this.selected[this.multiSelectedIndex]}toggleMultiSelectedTag(t,e){t&&t.toggleAttribute("selected",e)}selectMultiTag(t){if(this.canMultiSelect()){if(!t){this.multiSelected=[];const t=this.findLastMultiSelected();this.toggleMultiSelectedTag(t,!1)}this.multiSelectedIndex<=0?this.multiSelectedIndex=this.selectedOptions.length-1:this.multiSelectedIndex--,this.multiSelected.push(this.multiSelectedIndex);const e=this.findLastMultiSelected();this.toggleMultiSelectedTag(e,!0)}}handleListClick(t){return x(this,void 0,void 0,function*(){this.dispatchEvent(new CustomEvent("selected-changed",{detail:{event:t}})),yield this.updateComplete,this.isMulti?this.setVisualListbox(!0):this.setVisualListbox(!1),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})})}handleSelectAll(){return x(this,void 0,void 0,function*(){this.isSelectAllChecked=!this.isSelectAllChecked,this.isSelectAllChecked?(this.selectedOptions=[...this.options],this.checkAllOptions()):(this.selectedOptions=[],this.unCheckedAllOptions()),yield this.updateComplete,this.setVisualListbox(!0),this.notifySelectedChange({selected:this.selectedOptions})})}handleInputKeyUp(t){switch(t.code){case o.Uz.Escape:break;case o.Uz.Backspace:this.setFocusOnHost(!0),this.setVisualListbox(!0),this.resizeListbox(),this.removeMultiTag();break;case o.Uz.ArrowLeft:this.isMulti&&(t.shiftKey?this.selectMultiTag(!0):this.selectMultiTag(!1));break;default:this.isMulti&&this.unselectedAllMultiTag()}}handleInput(t){const e=t.target.value;this.inputValue=e.trim(),this.notifyInputValueChanged(e.trim())}removeAllSelected(){var t;this.focusedIndex=-1,this.focusedGroupIndex=-1,this.selectedOptions=[],this.inputValue="",this.setInputValue(),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,""),this.setVisualListbox(!1),this.unCheckedAllOptions(),this.setSelectedAttribute(void 0),this.updateOnNextFrame(()=>{this.input.focus()}),this.notifySelectedChange({selected:this.selectedOptions})}removeSelected(t){const e=this.findSelectedOption(t),i=this.filteredOptions.indexOf(t);-1!==i&&this.unCheckedOption(i),-1!==e&&(this.selectedOptions.splice(e,1),this.requestUpdate()),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})}selectedChange(t){var e;const{event:i}=t.detail;let s=this.findOptionIndex(i);if(-1!==s){this.focusedIndex=this.allowSelectAll&&this.checkForVirtualScroll()?s+1:s,this.isMulti&&this.allowSelectAll&&!this.checkForVirtualScroll()&&(s-=1);const t=this.getFocusedItem(s);this.setSelectedAttribute(t),t&&(this.setSelectedOption(t),this.isMulti?this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()):(this.setInputValue(this.getOptionValue(t)),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(t))))}}setSelectedAttribute(t){var e;let i="";t&&(i=this.getOptionId(t)),null===(e=this.lists)||void 0===e||e.forEach((t,e)=>{(null==t?void 0:t.id)===i?null==t||t.setAttribute("selected","true"):null==t||t.setAttribute("selected","false")})}shouldChangeButton(){const t=this.input&&this.input.value.length>0&&!this.noClearIcon||this.isMulti&&this.selectedOptions.length&&!this.noClearIcon;return t&&document.dispatchEvent(new CustomEvent("on-widget-update")),t}setCustomValue(){this.optionId||this.optionValue||(this.options=[...this.options,this.inputValue],this.setSelectedOption(this.inputValue),this.isMulti||this.updateOnNextFrame(()=>{var t;this.focusedIndex=this.filteredOptions.length-1;const e=this.getFocusedItem(this.focusedIndex);e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))}),this.dispatchEvent(new CustomEvent("custom-value-add",{composed:!0,bubbles:!0,detail:{value:this.inputValue}}))),this.inputValue=""}handleGroupFocus(){this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.filteredGroupOptions.length>0&&-1===this.focusedGroupIndex&&(this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===this.groupExpandedList[0])),this.updateOnNextFrame(()=>{-1===this.focusedGroupIndex||!this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length-1||this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length?this.focusedGroupIndex=0:this.focusedGroupIndex++}),this.focusedIndex=-1}handleInputKeyDown(t){var e,i;switch(t.code){case o.Uz.Backspace:this.focusedIndex=-1;break;case o.Uz.Tab:case o.Uz.Enter:if(this.setFocusOnHost(!0),this.expanded&&this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);this.allowCustomValue&&this.input&&this.input.value.length&&-1===this.findFilteredOption(this.inputValue)?this.setCustomValue():(e&&(this.setSelectedAttribute(e),this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll())}),this.setVisualListbox(!1),t.code===o.Uz.Tab&&this.isMulti)return;break;case o.Uz.ArrowDown:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedGroupIndex=-1)});break;case o.Uz.ArrowLeft:case o.Uz.ArrowRight:t.stopPropagation();break;case o.Uz.Escape:this.setFocusOnHost(!0),this.expanded?(t.stopPropagation(),this.setVisualListbox(!1)):(this.setInputValue(),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,""),this.focusedIndex=-1,this.focusedGroupIndex=-1,this.removeAllSelected(),this.setSelectedAttribute(void 0));break;case o.Uz.Home:this.setInputSelectionRange(0,0);break;case o.Uz.End:{const{length:t}=this.inputValue;this.setInputSelectionRange(t,t)}break;case o.Uz.Space:if(this.isMulti&&this.expanded){t.preventDefault();const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.setSelectedAttribute(e),this.showSelectedCount||(this.setInputValue(),null===(i=this.input)||void 0===i||i.setAttribute(o.iw.AriaActivedescendant,""))),0===this.focusedIndex&&this.allowSelectAll&&this.handleSelectAll()}this.expanded=!0}}handleGroupLabelKeyDown(t,e){switch(t.code){case o.Uz.Tab:this.handleGroupFocus();break;case o.Uz.Enter:case o.Uz.Space:-1!==this.focusedGroupIndex?this.toggleGroupListBox(t,e.value):(this.setFocusOnHost(!0),this.setVisualListbox(!1),this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll()}));break;case o.Uz.ArrowDown:if(0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))});break;case o.Uz.Escape:this.focusedGroupIndex=-1,this.setVisualListbox(!1),this.setFocusOnHost(!0),this.input.focus();break;default:this.setVisualListbox(!0)}}toggleVisualListBox(t){var e,i;if(!this.readOnly){if(t.target.classList.contains("md-combobox-listbox"))t.target.focus();else if("md-icon"===t.target.localName){const s=null===(i=null===(e=t.target.parentElement)||void 0===e?void 0:e.parentElement)||void 0===i?void 0:i.parentElement;if(s){const t=s.querySelector(".md-combobox-listbox");(0,b.setTimeout)(()=>{t.focus()},10)}}this.expanded?this.setVisualListbox(!1):(this.dispatchEvent(new CustomEvent("combobox-on-expand",{composed:!0,bubbles:!0})),this.notifySearchResultCount(),this.setVisualListbox(!0)),this.input.focus(),this.setGroupList(""),this.focusedGroupIndex=-1}}toggleGroupListBox(t,e){t.stopPropagation(),this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===e),this.setGroupList(e),this.resizeListbox()}handleRemoveAll(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-all-selected"))}connectedCallback(){super.connectedCallback(),this.setupEvents(),this.querySelector("optgroup")&&(this.isOptGroup=!0)}disconnectedCallback(){super.disconnectedCallback(),this.teardownEvents()}static get styles(){return[a.A,g.A]}get listItemOptionMap(){return{"md-combobox-multiselect":this.isMulti,compact:this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}get filteredOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t&&this.groupExpandedList.includes(this.getOptionGroupName(t))?"false"===t.isLabel:void 0))}get filteredGroupOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t?"true"===t.isLabel:void 0))}get comboBoxTemplateClassMap(){return{[`md-combobox--${this.shape}`]:!!this.shape,"md-combobox-searchable":this.searchable,"md-combobox-has-leading-icon":this.searchable||this.showFilterIcon,"md-new-combobox":this.newMomentum,[`md-${this.messageType}`]:!!this.messageType,"md-combobox-readonly":this.readOnly,"md-combobox-compact":this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}searchIconTemplate(){return this.leadingIconTemplate("search-bold","search-icon")}filterIconTemplate(){return this.leadingIconTemplate("filter-bold","filter-icon")}leadingIconTemplate(t,e){return h.html`
|
|
1
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("lit/directives/repeat.js"));else if("function"==typeof define&&define.amd)define(["lit","lit/decorators.js","lit/directives/class-map.js","lit/directives/style-map.js","lit/directives/if-defined.js","@momentum-ui/icons/data/momentumUiIconsNames.json","@momentum-ui/utils/lib/getColorValue","mobx","lit/directives/repeat.js"],e);else{var i="object"==typeof exports?e(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("lit/directives/repeat.js")):e(t.lit,t["lit/decorators.js"],t["lit/directives/class-map.js"],t["lit/directives/style-map.js"],t["lit/directives/if-defined.js"],t["@momentum-ui/icons/data/momentumUiIconsNames.json"],t["@momentum-ui/utils/lib/getColorValue"],t.mobx,t["lit/directives/repeat.js"]);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(self,(t,e,i,s,o,l,n,r,a)=>(()=>{"use strict";var h,d={4928:(t,e,i)=>{i.r(e),i.d(e,{ComboBox:()=>s}),i(20109),i(61200);var s,o=i(90195),l=i(3001),n=i(31890),r=i(66677),a=i(4313),h=i(87161),d=i(70429),p=i(85125),u=i(20291),c=i(58175),m=i(10318),b=i(97103),g=i(79270),f=function(t,e,i,s){var o,l=arguments.length,n=l<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var r=t.length-1;r>=0;r--)(o=t[r])&&(n=(l<3?o(n):l>3?o(e,i,n):o(e,i))||n);return l>3&&n&&Object.defineProperty(e,i,n),n},x=function(t,e,i,s){return new(i||(i=Promise))(function(o,l){function n(t){try{a(s.next(t))}catch(t){l(t)}}function r(t){try{a(s.throw(t))}catch(t){l(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,r)}a((s=s.apply(t,e||[])).next())})};!function(t){class e{determineMessageType(t){return t.reduce((t,e)=>"error"===e?t:e.type,"")}filterMessagesByType(t,e){return t.reduce((t,i)=>i.type===e?t.concat(i.message):t,[])}}t.MessageController=e;let i=class extends((0,l.yC)(h.LitElement)){constructor(){super(...arguments),this._focusedIndex=-1,this._focusedGroupIndex=-1,this.label="Options",this.options=[],this.customOptions=[],this.placeholder="",this.isMulti=!1,this.useVirtualScroll=!1,this.disabled=!1,this.ordered=!1,this.expanded=!1,this.groupExpandedList=[],this.searchItem=!1,this.compact=!1,this.noClearIcon=!1,this.selectWhenInFocus=!1,this.selectedOptions=[],this.visibleOptions=8,this.optionId="",this.optionValue="",this.isCustomContent=!1,this.searchable=!1,this.shape="none",this.value=[],this.inputValue="",this.allowCustomValue=!1,this.autofocus=!1,this.resultsTextLocalization="No Results",this.optionsTextLocalization="No Options",this.trimSpace=!1,this.invalid=!1,this.invalidText="",this.ariaLabel="",this.searchResultAriaLabel="",this.ariaLabelForComboBox="",this.clearAriaLabel="Clear",this.arrowAriaLabel="Expand",this.clearIconHeight="auto",this.allTextLocalization="All",this.selectAllTextLocalization="Select All",this.selectedTextLocalization="Selected",this.allowSelectAll=!1,this.showCustomError=!1,this.showLoader=!1,this.showSelectedCount=!1,this.popupChevronAriaHidden="true",this.newMomentum=!1,this.showFilterIcon=!1,this.preventFilter=!1,this.isDropdownArrow=!1,this.comboboxId="",this.helpText="",this.messageArr=[],this.htmlId="",this.readOnly=!1,this.messageController=new e,this.isOptGroup=!1,this.isSelectAllChecked=!1,this.multiSelectedIndex=-1,this.multiSelected=[],this.customContent=[],this.notifySelectedChange=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("change-selected",{composed:!0,bubbles:!0,detail:t}))},0),this.handleGroupFilter=t=>{const e=t.filter(t=>{if("string"!=typeof t&&"true"===t.isLabel)return t.groupName});return this.searchItem=!0,this.groupExpandedList=e.map(t=>{if("string"!=typeof t)return t.groupName}),t.filter(e=>"string"==typeof e||"true"!==e.isLabel||!!t.find(t=>{if("string"!=typeof e&&"string"!=typeof t)return e.groupName===t.groupName&&"false"===t.isLabel}))},this.notifyInputValueChanged=(0,r.sg)(t=>{this.dispatchEvent(new CustomEvent("combobox-input",{composed:!0,bubbles:!0,detail:{value:t}})),this.notifySearchResultCount(),this.focusedGroupIndex=0,requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})},250),this.handleOutsideClick=t=>{let e=!1;const i=t.composedPath();i.length&&(e=!!i.find(t=>t===this),e||(this.setVisualListbox(!1),this.unselectedAllMultiTag()))}}get focusedIndex(){return this._focusedIndex}set focusedIndex(t){this.updateFocusedIndex(t)}updateFocusedIndex(t){var e,i,s,o;const l=this._focusedIndex;if(this.checkForVirtualScroll()){let l;l=this.allowSelectAll?0===t?"selectAll":this.getOptionId(this.filteredOptions[t-1]):this.getOptionId(this.filteredOptions[t]);const n=this.lists?null===(e=[...this.lists])||void 0===e?void 0:e.find(t=>0!==t.offsetHeight&&t.id===l):"";this.lists&&[...this.lists].forEach(t=>{t.toggleAttribute("focused",!1)}),n&&(null==n||n.toggleAttribute("focused",!0));const r=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelector("lit-virtualizer");r&&(-1===t?null===(s=r.element(t))||void 0===s||s.scrollIntoView({block:"start"}):null===(o=r.element(t))||void 0===o||o.scrollIntoView({block:"center"}))}else if(this.lists){const e=this.lists[l];e&&e.toggleAttribute("focused",!1);const i=this.lists[t];i&&i.toggleAttribute("focused",!0)}this._focusedIndex=t,this.requestUpdate("focusedIndex",l)}get focusedGroupIndex(){return this._focusedGroupIndex}set focusedGroupIndex(t){const e=this._focusedGroupIndex;if(this.labels&&0!==this.labels.length){const i=this.labels[e];i&&i.toggleAttribute("focused",!1);const s=this.labels[t];s&&(s.toggleAttribute("focused",!0),s.focus())}this._focusedGroupIndex=t,this.requestUpdate("focusedGroupIndex",e)}get messageType(){return this.messageArr.length>0?this.messageController.determineMessageType(this.messageArr):null}get messages(){return this.messageType?this.messageController.filterMessagesByType(this.messageArr,this.messageType):null}notifySearchResultCount(){if(this.searchResultAriaLabel){const t=/{{.*?}}/g;this.ariaLabelForComboBox=this.searchResultAriaLabel.replace(t,this.filteredOptions.length.toString())}else this.ariaLabel?this.ariaLabelForComboBox=`${this.ariaLabel}, ${this.filteredOptions.length} results found.`:this.ariaLabelForComboBox=`ComboBox Element, ${this.filteredOptions.length} results found.`}firstUpdated(t){this.ariaLabelForComboBox=this.ariaLabel?this.ariaLabel:"ComboBox Element",super.firstUpdated(t),this.isCustomContent&&(this.optionId="id",this.optionValue="value",this.setOptionCustomContent()),this.setInitialValue()}updated(t){super.updated(t),t.has("expanded")&&(this.expanded?(this.resizeListbox(),this.checkSelectedOptions()):this.unCheckAllOptions()),t.has("focusedIndex")&&this.focusedIndex>=0&&(this.checkForVirtualScroll()||this.scrollToOption()),t.has("value")&&0===this.selectedOptions.length&&this.setInitialValue(),t.has("options")&&this.expanded&&this.checkForVirtualScroll()&&this.updateOnNextFrame(()=>{this.resizeListbox()}),t.has("customOptions")&&this.isCustomContent&&(this.setOptionCustomContent(),this.resizeListbox()),t.has("showCustomError")&&this.resizeListbox(),t.has("showLoader")&&this.resizeListbox(),t.has("searchItem")&&this.resizeListbox()}handleFocusIn(t){var e;this.disabled&&!this.readOnly||(this.noClearIcon&&(requestAnimationFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}),this.selectWhenInFocus&&this.input.select()),null===(e=super.handleFocusIn)||void 0===e||e.call(this,t)),this.dispatchEvent(new CustomEvent("combobox-focus-in",{composed:!0,bubbles:!0}))}handleFocusOut(t){var e;null===(e=super.handleFocusOut)||void 0===e||e.call(this,t),this.dispatchEvent(new CustomEvent("combobox-focus-out",{composed:!0,bubbles:!0}))}findFilteredOption(t){return this.isOptionObject(t)?this.filteredOptions.findIndex(e=>this.getOptionId(e)===this.getOptionId(t)&&this.getOptionValue(e)===this.getOptionValue(t)):this.filteredOptions.indexOf(t)}setInitialValue(){var t;if(this.value.length)if(this.isMulti)this.value.forEach(t=>{-1!==this.findFilteredOption(t)&&this.setSelectedOption(t)});else{const e=this.value[0],i=this.findFilteredOption(e);-1!==i&&(this.setSelectedOption(e),this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedIndex=i,this.focusedGroupIndex=-1)}}isOptionObject(t){return"object"==typeof t&&null!==t}setOptionCustomContent(){if(this.isOptGroup){const t=[...this.querySelectorAll("optgroup")],e=[];for(const i of t){const t=i.getAttribute("label"),s=[...i.querySelectorAll("[slot]")];e.push({isLabel:"true",[this.optionValue]:t,groupName:t});for(const i of s){const s=i.getAttribute("aria-label"),o=i.getAttribute("display-value"),l=i.getAttribute("slot");s&&o&&e.push({[this.optionId]:s,[this.optionValue]:o,isLabel:"false",groupName:t,slot:l})}}this.options=e}else this.customContent=[...this.querySelectorAll("[slot]")],this.customContent&&this.customContent.length?this.options=this.customContent.map(t=>{const e=t.getAttribute("aria-label"),i=t.getAttribute("display-value");if(e&&i)return{[this.optionId]:e,[this.optionValue]:i}}):this.options=[]}getOptionValue(t){return this.isOptionObject(t)?t[this.optionValue]:t}getOptionGroupName(t){return null==t?void 0:t.groupName}getOptionId(t){return this.isOptionObject(t)?t[this.optionId]:t}getFocusedItem(t){if(t>=0)return this.filteredOptions[t]}setupEvents(){document.addEventListener("click",this.handleOutsideClick),this.addEventListener("remove-all-selected",this.removeAllSelected),this.addEventListener("selected-changed",this.selectedChange)}teardownEvents(){document.removeEventListener("click",this.handleOutsideClick),this.removeEventListener("remove-all-selected",this.removeAllSelected),this.removeEventListener("selected-changed",this.selectedChange)}setVisualListbox(t){this.expanded=t}setGroupList(t){this.groupExpandedList.includes(t)?(this.groupExpandedList.splice(this.groupExpandedList.indexOf(t),1),this.groupExpandedList=[...this.groupExpandedList]):this.searchItem?this.groupExpandedList.push(t):this.groupExpandedList=[t]}findSelectedOption(t){return this.optionId&&t?this.selectedOptions.findIndex(e=>e&&e[this.optionId]===t[this.optionId]):this.selectedOptions.indexOf(t)}findOptionIndex(t){const e=t.composedPath();if(this.checkForVirtualScroll()){let t="";return[...this.lists].forEach(i=>{e.includes(i)&&(t=i.id)}),this.filteredOptions.findIndex(e=>this.getOptionId(e)===t)}return[...this.lists].findIndex(t=>e.includes(t))}checkSelectedOptions(){if(this.checkForVirtualScroll()){const t=this.selectedOptions.map(t=>this.getOptionId(t)),e=[...this.lists].filter(t=>"selectAll"!==t.id);null==e||e.forEach(e=>{t.includes(e.id)?(this.isMulti&&(null==e||e.setAttribute("aria-checked","true")),null==e||e.setAttribute("aria-selected","true")):this.isMulti&&(null==e||e.setAttribute("aria-checked","false"))})}}unCheckAllOptions(){var t;this.checkForVirtualScroll()&&this.isMulti&&(null===(t=[...this.lists])||void 0===t||t.forEach(t=>{"selectAll"!==(null==t?void 0:t.id)&&(null==t||t.setAttribute("aria-checked","false"))}))}setSelectedOption(t){this.isMulti||(this.selectedOptions=[]);const e=this.findSelectedOption(t);if(-1!==e){const t=this.selectedOptions[e];this.selectedOptions.splice(e,1),this.notifySelectedChange({value:t,selected:this.selectedOptions})}else this.selectedOptions.push(t),this.notifySelectedChange({value:t,selected:this.selectedOptions});this.checkSelectedOptions(),this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()),this.requestUpdate()}filterOptions(t){if(this.preventFilter)return this.searchItem=!1,this.options;if(t&&t.length){const e=this.options.filter(e=>this.isOptGroup&&"string"!=typeof e&&"true"===e.isLabel?e:(this.isCustomContent?this.getOptionId(e):this.getOptionValue(e)).toLowerCase().includes(t.toLowerCase()));return this.isOptGroup?this.handleGroupFilter(e):e}return this.searchItem=!1,this.options}getListBoxVerticalPadding(){if(this.listBox){const t=window.getComputedStyle(this.listBox,null),e=parseInt(t.getPropertyValue("padding-top"))+parseInt(t.getPropertyValue("padding-bottom"));if(!isNaN(e))return e+2}return 10}resizeListbox(){this.updateOnNextFrame(()=>{var t;let e=0,i=0,s=0;const o=this.getListBoxVerticalPadding();if(this.lists){const t=this.checkForVirtualScroll()?[...this.lists].filter(t=>0!==t.offsetHeight):[...this.lists];e=t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0),s=this.checkForVirtualScroll()&&this.allowSelectAll?t.slice(1,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0):t.slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)}if(this.labels&&(i=[...this.labels].slice(0,this.visibleOptions).reduce((t,e)=>t+e.offsetHeight,0)),this.listBox&&(this.listBox.style.maxHeight=`${e+i+o}px`),this.virtualizer&&(this.virtualizer.style.height=`${s+o}px`),this.showCustomError||this.showLoader){const e=null===(t=this.listBox)||void 0===t?void 0:t.querySelector("[slot]");this.listBox&&e&&(this.listBox.style.height=`${e.clientHeight+o}px`,this.listBox.style.maxHeight=`${e.clientHeight+o}px`)}})}setInputValue(t=""){this.input.value=t}updateOnNextFrame(t){requestAnimationFrame(t)}unCheckedAllOptions(){this.isMulti&&(this.lists.forEach((t,e)=>this.unCheckedOption(e)),this.isSelectAllChecked=!1)}unCheckedOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","false"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}checkAllOptions(){this.isMulti&&this.lists.forEach((t,e)=>this.checkOption(e))}checkOption(t){this.isMulti&&(this.lists[t].setAttribute("aria-checked","true"),this.notifySelectedChange({value:this.filteredOptions[t],selected:this.selectedOptions}))}isSelectAllSelected(){return this.selectedOptions.length===this.options.length}setFocusOnHost(t){this.setFocus&&this.setFocus(t)}isOptionFocused(t){return this.focusedIndex===t}getAriaState(t){return this.isOptionFocused(t)}scrollToOption(){var t,e;let i=0;const{top:s,bottom:o}=this.listBox.getBoundingClientRect(),l=this.lists[this.focusedIndex],n=null===(t=this.lists[this.focusedIndex+1]||l)||void 0===t?void 0:t.getBoundingClientRect(),r=null===(e=this.lists[this.focusedIndex-1]||l)||void 0===e?void 0:e.getBoundingClientRect();(null==n?void 0:n.bottom)>o?i=n.bottom-o+2:(null==r?void 0:r.top)<s&&(i=r.top-s-2),this.updateOnNextFrame(()=>{this.listBox.scrollTop+=i})}getCustomContentName(t){const e=this.options.indexOf(t);if(this.isOptGroup){const t=this.options[e];if(t&&"string"!=typeof t)return t.slot}else if(-1!==e)return this.customContent[e].slot}setInputSelectionRange(t,e){this.input.setSelectionRange(t,e)}isOptionChecked(t){return-1!==this.findSelectedOption(t)?"true":"false"}getInputSelection(){return this.input.selectionStart}canMultiSelect(){return 0===this.getInputSelection()&&0!==this.selectedOptions.length&&this.isMulti}removeMultiTag(){this.selected&&this.multiSelected.forEach(t=>{const e=this.selected[t];e&&e.hasAttribute("selected")&&this.removeSelected(this.selectedOptions[t])})}unselectedAllMultiTag(){this.selected&&this.selected.forEach(t=>t.removeAttribute("selected")),this.multiSelectedIndex=-1}findLastMultiSelected(){return this.selected[this.multiSelectedIndex]}toggleMultiSelectedTag(t,e){t&&t.toggleAttribute("selected",e)}selectMultiTag(t){if(this.canMultiSelect()){if(!t){this.multiSelected=[];const t=this.findLastMultiSelected();this.toggleMultiSelectedTag(t,!1)}this.multiSelectedIndex<=0?this.multiSelectedIndex=this.selectedOptions.length-1:this.multiSelectedIndex--,this.multiSelected.push(this.multiSelectedIndex);const e=this.findLastMultiSelected();this.toggleMultiSelectedTag(e,!0)}}handleListClick(t){return x(this,void 0,void 0,function*(){this.dispatchEvent(new CustomEvent("selected-changed",{detail:{event:t}})),yield this.updateComplete,this.isMulti?this.setVisualListbox(!0):this.setVisualListbox(!1),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})})}handleSelectAll(){return x(this,void 0,void 0,function*(){this.isSelectAllChecked=!this.isSelectAllChecked,this.isSelectAllChecked?(this.selectedOptions=[...this.options],this.checkAllOptions()):(this.selectedOptions=[],this.unCheckedAllOptions()),yield this.updateComplete,this.setVisualListbox(!0),this.notifySelectedChange({selected:this.selectedOptions})})}handleInputKeyUp(t){switch(t.code){case o.Uz.Escape:break;case o.Uz.Backspace:this.setFocusOnHost(!0),this.setVisualListbox(!0),this.resizeListbox(),this.removeMultiTag();break;case o.Uz.ArrowLeft:this.isMulti&&(t.shiftKey?this.selectMultiTag(!0):this.selectMultiTag(!1));break;default:this.isMulti&&this.unselectedAllMultiTag()}}handleInput(t){const e=t.target.value;this.inputValue=e.trim(),this.notifyInputValueChanged(e.trim())}removeAllSelected(){var t;this.focusedIndex=-1,this.focusedGroupIndex=-1,this.selectedOptions=[],this.inputValue="",this.setInputValue(),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,""),this.setVisualListbox(!1),this.unCheckedAllOptions(),this.setSelectedAttribute(void 0),this.updateOnNextFrame(()=>{this.input.focus()}),this.notifySelectedChange({selected:this.selectedOptions})}removeSelected(t){const e=this.findSelectedOption(t),i=this.filteredOptions.indexOf(t);-1!==i&&this.unCheckedOption(i),-1!==e&&(this.selectedOptions.splice(e,1),this.requestUpdate()),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1})}selectedChange(t){var e;const{event:i}=t.detail;let s=this.findOptionIndex(i);if(-1!==s){this.focusedIndex=this.allowSelectAll&&this.checkForVirtualScroll()?s+1:s,this.isMulti&&this.allowSelectAll&&!this.checkForVirtualScroll()&&(s-=1);const t=this.getFocusedItem(s);this.setSelectedAttribute(t),t&&(this.setSelectedOption(t),this.isMulti?this.isMulti&&this.allowSelectAll&&(this.isSelectAllChecked=this.isSelectAllSelected()):(this.setInputValue(this.getOptionValue(t)),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(t))))}}setSelectedAttribute(t){var e;let i="";t&&(i=this.getOptionId(t)),null===(e=this.lists)||void 0===e||e.forEach((t,e)=>{(null==t?void 0:t.id)===i?null==t||t.setAttribute("selected","true"):null==t||t.setAttribute("selected","false")})}shouldChangeButton(){const t=this.input&&this.input.value.length>0&&!this.noClearIcon||this.isMulti&&this.selectedOptions.length&&!this.noClearIcon;return t&&document.dispatchEvent(new CustomEvent("on-widget-update")),t}setCustomValue(){this.optionId||this.optionValue||(this.options=[...this.options,this.inputValue],this.setSelectedOption(this.inputValue),this.isMulti||this.updateOnNextFrame(()=>{var t;this.focusedIndex=this.filteredOptions.length-1;const e=this.getFocusedItem(this.focusedIndex);e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))}),this.dispatchEvent(new CustomEvent("custom-value-add",{composed:!0,bubbles:!0,detail:{value:this.inputValue}}))),this.inputValue=""}handleGroupFocus(){this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.filteredGroupOptions.length>0&&-1===this.focusedGroupIndex&&(this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===this.groupExpandedList[0])),this.updateOnNextFrame(()=>{-1===this.focusedGroupIndex||!this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length-1||this.allowSelectAll&&this.focusedGroupIndex>=this.filteredGroupOptions.length?this.focusedGroupIndex=0:this.focusedGroupIndex++}),this.focusedIndex=-1}handleInputKeyDown(t){var e,i;switch(t.code){case o.Uz.Backspace:this.focusedIndex=-1;break;case o.Uz.Tab:case o.Uz.Enter:if(this.setFocusOnHost(!0),this.expanded&&this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);this.allowCustomValue&&this.input&&this.input.value.length&&-1===this.findFilteredOption(this.inputValue)?this.setCustomValue():(e&&(this.setSelectedAttribute(e),this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll())}),this.setVisualListbox(!1),t.code===o.Uz.Tab&&this.isMulti)return;break;case o.Uz.ArrowDown:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return void this.handleGroupFocus();this.setFocusOnHost(!1),this.expanded||this.setVisualListbox(!0),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.focusedGroupIndex=-1)});break;case o.Uz.ArrowLeft:case o.Uz.ArrowRight:t.stopPropagation();break;case o.Uz.Escape:this.setFocusOnHost(!0),this.expanded?(t.stopPropagation(),this.setVisualListbox(!1)):(this.setInputValue(),null===(e=this.input)||void 0===e||e.setAttribute(o.iw.AriaActivedescendant,""),this.focusedIndex=-1,this.focusedGroupIndex=-1,this.removeAllSelected(),this.setSelectedAttribute(void 0));break;case o.Uz.Home:this.setInputSelectionRange(0,0);break;case o.Uz.End:{const{length:t}=this.inputValue;this.setInputSelectionRange(t,t)}break;case o.Uz.Space:if(this.isMulti&&this.expanded){t.preventDefault();const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.setSelectedAttribute(e),this.showSelectedCount||(this.setInputValue(),null===(i=this.input)||void 0===i||i.setAttribute(o.iw.AriaActivedescendant,""))),0===this.focusedIndex&&this.allowSelectAll&&this.handleSelectAll()}this.expanded=!0}}handleGroupLabelKeyDown(t,e){switch(t.code){case o.Uz.Tab:this.handleGroupFocus();break;case o.Uz.Enter:case o.Uz.Space:-1!==this.focusedGroupIndex?this.toggleGroupListBox(t,e.value):(this.setFocusOnHost(!0),this.setVisualListbox(!1),this.updateOnNextFrame(()=>{var t;const e=this.getFocusedItem(this.allowSelectAll?this.focusedIndex-1:this.focusedIndex);e&&(this.setSelectedOption(e),this.showSelectedCount||(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)),this.updateOnNextFrame(()=>{this.input.focus(),this.focusedGroupIndex=-1}))),this.isMulti&&this.allowSelectAll&&0===this.focusedIndex&&this.handleSelectAll()}));break;case o.Uz.ArrowDown:if(0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;-1===this.focusedIndex||!this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length-1||this.allowSelectAll&&this.focusedIndex>=this.filteredOptions.length?this.focusedIndex=0:this.focusedIndex++;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],!this.showSelectedCount&&e&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e))),this.focusedGroupIndex=-1});break;case o.Uz.ArrowUp:if(this.isOptGroup&&0===this.filteredOptions.length)return;this.setFocusOnHost(!1),this.updateOnNextFrame(()=>{var t;this.focusedIndex<=0?this.focusedIndex=this.allowSelectAll?this.filteredOptions.length:this.filteredOptions.length-1:this.focusedIndex--;const e=this.getFocusedItem(this.focusedIndex);this.groupExpandedList=[this.getOptionGroupName(e)],e&&!this.showSelectedCount&&(this.setInputValue(this.getOptionValue(e)),null===(t=this.input)||void 0===t||t.setAttribute(o.iw.AriaActivedescendant,this.getOptionId(e)))});break;case o.Uz.Escape:this.focusedGroupIndex=-1,this.setVisualListbox(!1),this.setFocusOnHost(!0),this.input.focus();break;default:this.setVisualListbox(!0)}}toggleVisualListBox(t){var e,i;if(!this.readOnly){if(t.target.classList.contains("md-combobox-listbox"))t.target.focus();else if("md-icon"===t.target.localName){const s=null===(i=null===(e=t.target.parentElement)||void 0===e?void 0:e.parentElement)||void 0===i?void 0:i.parentElement;if(s){const t=s.querySelector(".md-combobox-listbox");(0,b.setTimeout)(()=>{t.focus()},10)}}this.expanded?this.setVisualListbox(!1):(this.dispatchEvent(new CustomEvent("combobox-on-expand",{composed:!0,bubbles:!0})),this.notifySearchResultCount(),this.setVisualListbox(!0)),this.input.focus(),this.setGroupList(""),this.focusedGroupIndex=-1}}toggleGroupListBox(t,e){t.stopPropagation(),this.focusedGroupIndex=this.filteredGroupOptions.findIndex(t=>"string"!=typeof t&&t.groupName===e),this.setGroupList(e),this.resizeListbox()}handleRemoveAll(t){t.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-all-selected"))}connectedCallback(){super.connectedCallback(),this.setupEvents(),this.querySelector("optgroup")&&(this.isOptGroup=!0)}disconnectedCallback(){super.disconnectedCallback(),this.teardownEvents()}static get styles(){return[a.A,g.A]}get listItemOptionMap(){return{"md-combobox-multiselect":this.isMulti,compact:this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}get filteredOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t&&this.groupExpandedList.includes(this.getOptionGroupName(t))?"false"===t.isLabel:void 0))}get filteredGroupOptions(){return this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).filter(t=>!this.isOptGroup||("string"!=typeof t?"true"===t.isLabel:void 0))}get comboBoxTemplateClassMap(){return{[`md-combobox--${this.shape}`]:!!this.shape,"md-combobox-searchable":this.searchable,"md-combobox-has-leading-icon":this.searchable||this.showFilterIcon,"md-new-combobox":this.newMomentum,[`md-${this.messageType}`]:!!this.messageType,"md-combobox-readonly":this.readOnly,"md-combobox-compact":this.compact,"md-combobox-dropdown-arrow":this.isDropdownArrow}}searchIconTemplate(){return this.leadingIconTemplate("search-bold","search-icon")}filterIconTemplate(){return this.leadingIconTemplate("filter-bold","filter-icon")}leadingIconTemplate(t,e){return h.html`
|
|
25
2
|
<md-icon
|
|
26
3
|
name=${t}
|
|
27
4
|
class=${e}
|
|
@@ -125,7 +102,30 @@
|
|
|
125
102
|
<span part="group-label">${t.value}</span>
|
|
126
103
|
${this.groupArrowButtonTemplate(t.value)}
|
|
127
104
|
</div>
|
|
128
|
-
`}renderWithoutVirtualScroll(){return(0,c.repeat)(this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue),t=>this.getOptionId(t),(t,e)=>"string"!=typeof t&&this.isOptGroup&&"true"===t.isLabel?this.renderGroupLabelHeader(t,e):!this.isOptGroup||this.groupExpandedList.includes(this.getOptionGroupName(t))?this.renderItem(t,e):void 0)}highlightingSearchedText(t){return(0,r.ws)(this.getOptionValue(t),this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).map(({text:t,matching:e})=>e?h.html` <span class="highlight-text" part="select-label">${t}</span> `:h.html` <span class="selected-label-text" part="select-label">${t}</span> `)}addStyle(){const t=!this.expanded||this.options.length&&0===this.filteredOptions.length&&this.inputValue&&this.allowCustomValue;return this.checkForVirtualScroll()?(0,m.styleMap)({visibility:t?"hidden":"visible","z-index":t?"-1":"99",overflow:"hidden"}):(0,m.styleMap)({display:t?"none":"block","z-index":"99",overflow:"auto"})}
|
|
105
|
+
`}renderWithoutVirtualScroll(){return(0,c.repeat)(this.filterOptions(this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue),t=>this.getOptionId(t),(t,e)=>"string"!=typeof t&&this.isOptGroup&&"true"===t.isLabel?this.renderGroupLabelHeader(t,e):!this.isOptGroup||this.groupExpandedList.includes(this.getOptionGroupName(t))?this.renderItem(t,e):void 0)}highlightingSearchedText(t){return(0,r.ws)(this.getOptionValue(t),this.trimSpace?this.inputValue.replace(/\s+/g,""):this.inputValue).map(({text:t,matching:e})=>e?h.html` <span class="highlight-text" part="select-label">${t}</span> `:h.html` <span class="selected-label-text" part="select-label">${t}</span> `)}addStyle(){const t=!this.expanded||this.options.length&&0===this.filteredOptions.length&&this.inputValue&&this.allowCustomValue;return this.checkForVirtualScroll()?(0,m.styleMap)({visibility:t?"hidden":"visible","z-index":t?"-1":"99",overflow:"hidden"}):(0,m.styleMap)({display:t?"none":"block","z-index":"99",overflow:"auto"})}renderItem(t,e){const i=this.allowSelectAll?e+2:e+1,s=this.allowSelectAll?this.options.length+1:this.options.length,o=this.checkForVirtualScroll()?`, ${i} of ${s}`:"";return h.html`
|
|
106
|
+
<div
|
|
107
|
+
id=${this.getOptionId(t)}
|
|
108
|
+
title="${this.getOptionValue(t)}"
|
|
109
|
+
part="combobox-option"
|
|
110
|
+
class="md-combobox-option"
|
|
111
|
+
aria-posinset=${i}
|
|
112
|
+
aria-setsize=${s}
|
|
113
|
+
role=${this.isMulti?"checkbox":"listitem"}
|
|
114
|
+
aria-label="${this.isCustomContent?this.getOptionId(t):this.getOptionValue(t)}${o}"
|
|
115
|
+
tabindex="-1"
|
|
116
|
+
@click=${t=>this.handleListClick(t)}
|
|
117
|
+
aria-checked=${(0,u.ifDefined)(this.isMulti?this.isOptionChecked.call(this,t):void 0)}
|
|
118
|
+
>
|
|
119
|
+
${this.isMulti?h.html`
|
|
120
|
+
<span class="select-option" aria-hidden="true">
|
|
121
|
+
<md-icon name="check-bold" size="14" iconSet="momentumDesign"></md-icon>
|
|
122
|
+
</span>
|
|
123
|
+
`:h.nothing}
|
|
124
|
+
<span part="label" class="select-label" aria-hidden="true">
|
|
125
|
+
${this.isCustomContent?this.getCustomContent(t):this.highlightingSearchedText(t)}
|
|
126
|
+
</span>
|
|
127
|
+
</div>
|
|
128
|
+
`}inputTitle(){return this.isMulti?this.selectedOptions.length>0?`${this.selectedOptions.length} ${this.selectedTextLocalization}`:this.placeholder:this.selectedOptions.length>0?this.getOptionValue(this.selectedOptions[0]):this.placeholder}helpTextTemplate(){return this.helpText?h.html`
|
|
129
129
|
<md-help-text
|
|
130
130
|
class="help-text ${(0,p.classMap)({disabled:this.disabled,newMomentum:this.newMomentum})}"
|
|
131
131
|
.message=${this.helpText}
|