@momentum-design/components 0.87.0 → 0.87.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4264,7 +4264,7 @@
4264
4264
  :host([help-text-type='warning'])::part(base-container) {
4265
4265
  border-color: var(--mdc-select-warning-border-color);
4266
4266
  }
4267
- `,zu=[xy,...St(!0)];var ye=class extends Ne(Wt(ve)){constructor(){super(...arguments);this.readonly=!1;this.height="auto";this.baseIconName=Kn.ARROW_DOWN;this.selectedValue="";this.displayPopover=!1;this.activeDescendant=""}connectedCallback(){super.connectedCallback(),this.value=void 0}getAllValidOptions(){var e;return((e=this.optionsList)==null?void 0:e.map(s=>s.tagName.toLowerCase()===ia?s:s.tagName.toLowerCase()===jn?Array.from(s.children).filter(n=>n.tagName.toLowerCase()===ia):[]).flat())||[]}handlePopoverOpen(){this.displayPopover=!0,this.baseIconName=Kn.ARROW_UP,this.updateActivedescendant()}handlePopoverClose(){this.displayPopover=!1,this.baseIconName=Kn.ARROW_DOWN}updateTabIndexForAllOptions(e){var n;let s=!1;this.getAllValidOptions().forEach(h=>{h===e?(this.setSelectedValue(h),s=!0,h.setAttribute("selected",""),h.setAttribute("tabindex","0")):(h==null||h.setAttribute("tabindex","-1"),h==null||h.removeAttribute("selected"))}),s||(n=this.getAllValidOptions()[0])==null||n.setAttribute("tabindex","0")}handleOptionsClick(e){this.updateTabIndexForAllOptions(e.target)}setSelectedValue(e){var s,n,h,m;this.selectedValueText=(n=(s=e==null?void 0:e.getAttribute("label"))!=null?s:e==null?void 0:e.textContent)!=null?n:"",this.selectedIcon=e==null?void 0:e.getAttribute("prefix-icon"),this.selectedValue=(m=(h=e==null?void 0:e.getAttribute("value"))!=null?h:e==null?void 0:e.textContent)!=null?m:"",this.internals.setFormValue(this.selectedValue),this.manageRequired(),this.dispatchChange(this.selectedValue)}manageRequired(){!this.selectedValue&&this.required?(this.validationMessage?this.inputElement.setCustomValidity(this.validationMessage):this.inputElement.setCustomValidity(""),this.setValidity()):this.internals.setValidity({})}formResetCallback(){this.selectedValue="",this.selectedValueText=void 0,this.selectedIcon=null,this.internals.setFormValue(this.selectedValue),this.updateTabIndexForAllOptions()}formStateRestoreCallback(e){this.selectedValue=e,this.selectedValueText=e}dispatchChange(e){e&&this.dispatchEvent(new CustomEvent("change",{detail:{value:e},composed:!0,bubbles:!0}))}handlePopoverOnOpen(e){var s;switch(e.key){case dt.TAB:{let n=this.getAllValidOptions().findIndex(h=>h===e.target);this.setFocusAndTabIndex(n),e.preventDefault();break}case dt.SPACE:this.updateTabIndexForAllOptions(e.target),this.closePopover(),e.preventDefault();break;case dt.ENTER:this.updateTabIndexForAllOptions(e.target),this.closePopover(),e.preventDefault(),(s=this.form)==null||s.requestSubmit();break;case dt.HOME:this.setFocusAndTabIndex(0),e.preventDefault();break;case dt.END:this.setFocusAndTabIndex(this.getAllValidOptions().length-1),e.preventDefault();break;case dt.ARROW_DOWN:case dt.ARROW_UP:case dt.PAGE_DOWN:case dt.PAGE_UP:this.handleOptionsNavigation(e),e.preventDefault();break;default:break}}handlePopoverOnClose(e){switch(e.key){case dt.ARROW_DOWN:case dt.ARROW_UP:case dt.ENTER:case dt.SPACE:this.openPopover(),e.preventDefault();break;case dt.HOME:this.openPopover(),this.setFocusAndTabIndex(0),e.preventDefault();break;case dt.END:this.openPopover(),this.setFocusAndTabIndex(this.getAllValidOptions().length-1),e.preventDefault();break;default:break}}handleOptionsNavigation(e){let s=this.getAllValidOptions(),n=s.findIndex(m=>m===e.target),h=this.getNewIndexBasedOnKey(e.key,n,s.length);h!==-1&&(this.setFocusAndTabIndex(h),e.preventDefault())}getNewIndexBasedOnKey(e,s,n){return e===dt.ARROW_DOWN&&s!==n-1?s+1:e===dt.ARROW_UP&&s>0?s-1:e===dt.PAGE_DOWN?s+10>n?n-1:s+10:e===dt.PAGE_UP?s-10<0?0:s-10:-1}updateActivedescendant(e){var n,h,m,T,L;let s=this.getAllValidOptions();if(e){let $=s.findIndex(W=>W===e);this.activeDescendant=(h=(n=s[$])==null?void 0:n.id)!=null?h:""}else{let $=s.find(W=>W.getAttribute("tabindex")==="0");this.activeDescendant=(L=(T=$==null?void 0:$.id)!=null?T:(m=s[0])==null?void 0:m.id)!=null?L:""}}resetActivedescendant(){this.activeDescendant=""}setFocusAndTabIndex(e){var h;let s=this.getAllValidOptions(),n=s[e];n&&(n.focus(),s.forEach((m,T)=>{let L=e===T?"0":"-1";m==null||m.setAttribute("tabindex",L)}),this.activeDescendant=(h=n.id)!=null?h:"")}openPopover(){var h,m;this.displayPopover=!0;let e=this.getAllValidOptions(),s=e.find(T=>T.hasAttribute("selected")),n=e.find(T=>T.getAttribute("tabindex")==="0");this.activeDescendant=(m=(h=s||n||e[0])==null?void 0:h.id)!=null?m:""}closePopover(){this.displayPopover=!1,this.resetActivedescendant()}firstUpdated(){let e=this.getAllValidOptions(),s=e.findIndex(n=>n==null?void 0:n.hasAttribute("selected"));s!==-1?(this.setSelectedValue(e[s]),this.updateTabIndexForAllOptions(e[s])):this.placeholder?this.placeholder&&this.manageRequired():(this.setSelectedValue(e[0]),this.updateTabIndexForAllOptions())}getNativeSelect(){return O`
4267
+ `,zu=[xy,...St(!0)];var ye=class extends Ne(Wt(ve)){constructor(){super(...arguments);this.readonly=!1;this.height="auto";this.baseIconName=Kn.ARROW_DOWN;this.selectedValue="";this.displayPopover=!1;this.activeDescendant=""}getAllValidOptions(){var e;return((e=this.optionsList)==null?void 0:e.map(s=>s.tagName.toLowerCase()===ia?s:s.tagName.toLowerCase()===jn?Array.from(s.children).filter(n=>n.tagName.toLowerCase()===ia):[]).flat())||[]}handlePopoverOpen(){this.displayPopover=!0,this.baseIconName=Kn.ARROW_UP,this.updateActivedescendant()}handlePopoverClose(){this.displayPopover=!1,this.baseIconName=Kn.ARROW_DOWN}updateTabIndexForAllOptions(e){var n;let s=!1;this.getAllValidOptions().forEach(h=>{h===e?(this.setSelectedValue(h),s=!0,h.setAttribute("selected",""),h.setAttribute("tabindex","0")):(h==null||h.setAttribute("tabindex","-1"),h==null||h.removeAttribute("selected"))}),s||(n=this.getAllValidOptions()[0])==null||n.setAttribute("tabindex","0")}handleOptionsClick(e){this.updateTabIndexForAllOptions(e.target)}setSelectedValue(e){var s,n,h,m;this.selectedValueText=(n=(s=e==null?void 0:e.getAttribute("label"))!=null?s:e==null?void 0:e.textContent)!=null?n:"",this.selectedIcon=e==null?void 0:e.getAttribute("prefix-icon"),this.selectedValue=(m=(h=e==null?void 0:e.getAttribute("value"))!=null?h:e==null?void 0:e.textContent)!=null?m:"",this.value=this.selectedValue,this.internals.setFormValue(this.selectedValue),this.manageRequired(),this.dispatchInput(this.selectedValue),this.dispatchChange(this.selectedValue)}manageRequired(){!this.selectedValue&&this.required?(this.validationMessage?this.inputElement.setCustomValidity(this.validationMessage):this.inputElement.setCustomValidity(""),this.setValidity()):this.internals.setValidity({})}formResetCallback(){this.selectedValue="",this.selectedValueText=void 0,this.selectedIcon=null,this.internals.setFormValue(this.selectedValue),this.updateTabIndexForAllOptions()}formStateRestoreCallback(e){this.selectedValue=e,this.selectedValueText=e}dispatchChange(e){e&&this.dispatchEvent(new CustomEvent("change",{detail:{value:e},composed:!0,bubbles:!0}))}dispatchInput(e){e&&this.dispatchEvent(new CustomEvent("input",{detail:{value:e},composed:!0,bubbles:!0}))}handlePopoverOnOpen(e){var s;switch(e.key){case dt.TAB:{let n=this.getAllValidOptions().findIndex(h=>h===e.target);this.setFocusAndTabIndex(n),e.preventDefault();break}case dt.SPACE:this.closePopover(),e.preventDefault();break;case dt.ENTER:this.closePopover(),e.preventDefault(),(s=this.form)==null||s.requestSubmit();break;case dt.HOME:this.setFocusAndTabIndex(0),e.preventDefault();break;case dt.END:this.setFocusAndTabIndex(this.getAllValidOptions().length-1),e.preventDefault();break;case dt.ARROW_DOWN:case dt.ARROW_UP:case dt.PAGE_DOWN:case dt.PAGE_UP:this.handleOptionsNavigation(e),e.preventDefault();break;default:break}}handlePopoverOnClose(e){switch(e.key){case dt.ARROW_DOWN:case dt.ARROW_UP:case dt.ENTER:case dt.SPACE:this.openPopover(),e.preventDefault();break;case dt.HOME:this.openPopover(),this.setFocusAndTabIndex(0),e.preventDefault();break;case dt.END:this.openPopover(),this.setFocusAndTabIndex(this.getAllValidOptions().length-1),e.preventDefault();break;default:break}}handleOptionsNavigation(e){let s=this.getAllValidOptions(),n=s.findIndex(m=>m===e.target),h=this.getNewIndexBasedOnKey(e.key,n,s.length);h!==-1&&(this.setFocusAndTabIndex(h),e.preventDefault())}getNewIndexBasedOnKey(e,s,n){return e===dt.ARROW_DOWN&&s!==n-1?s+1:e===dt.ARROW_UP&&s>0?s-1:e===dt.PAGE_DOWN?s+10>n?n-1:s+10:e===dt.PAGE_UP?s-10<0?0:s-10:-1}updateActivedescendant(e){var n,h,m,T,L;let s=this.getAllValidOptions();if(e){let $=s.findIndex(W=>W===e);this.activeDescendant=(h=(n=s[$])==null?void 0:n.id)!=null?h:""}else{let $=s.find(W=>W.getAttribute("tabindex")==="0");this.activeDescendant=(L=(T=$==null?void 0:$.id)!=null?T:(m=s[0])==null?void 0:m.id)!=null?L:""}}resetActivedescendant(){this.activeDescendant=""}setFocusAndTabIndex(e){var h;let s=this.getAllValidOptions(),n=s[e];n&&(n.focus(),s.forEach((m,T)=>{let L=e===T?"0":"-1";m==null||m.setAttribute("tabindex",L)}),this.activeDescendant=(h=n.id)!=null?h:"")}openPopover(){var h,m;this.displayPopover=!0;let e=this.getAllValidOptions(),s=e.find(T=>T.hasAttribute("selected")),n=e.find(T=>T.getAttribute("tabindex")==="0");this.activeDescendant=(m=(h=s||n||e[0])==null?void 0:h.id)!=null?m:""}closePopover(){this.displayPopover=!1,this.resetActivedescendant()}firstUpdated(){let e=this.getAllValidOptions(),s=e.findIndex(n=>n==null?void 0:n.hasAttribute("selected"));s!==-1?(this.setSelectedValue(e[s]),this.updateTabIndexForAllOptions(e[s])):this.placeholder?this.placeholder&&this.manageRequired():(this.setSelectedValue(e[0]),this.updateTabIndexForAllOptions())}getNativeSelect(){return O`
4268
4268
  <select
4269
4269
  part="native-select"
4270
4270
  id="${this.id}"