@momentum-design/components 0.133.35 → 0.133.37
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/browser/index.js +3 -2
- package/dist/browser/index.js.map +2 -2
- package/dist/components/input/input.component.d.ts +1 -1
- package/dist/components/input/input.component.js +7 -1
- package/dist/components/menupopover/menupopover.component.js +4 -2
- package/dist/components/menupopover/menupopover.styles.js +1 -0
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -4103,7 +4103,7 @@
|
|
|
4103
4103
|
opacity: 0;
|
|
4104
4104
|
pointer-events: none;
|
|
4105
4105
|
}
|
|
4106
|
-
`,...Et(!0)],mb=C0;var ge=class extends Nt(Ve(pe(ie(dr)))){constructor(){super(...arguments);this.placeholder="";this.trailingButton=!1;this.autocapitalize=Kd.OFF;this.autocomplete=aa.OFF;this.clearAriaLabel="";this.dataAriaDescribedby=null}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.inputElement&&(this.setInputValidity(),this.internals.setFormValue(this.inputElement.value))}).catch(t=>{this.onerror&&this.onerror(t)})}firstUpdated(t){this.inputElement&&this.autoFocusOnMount&&(this.elementToAutoFocus=this.inputElement),super.firstUpdated(t)}formResetCallback(){this.value="",this.inputElement.value="",this.setInputValidity(),this.requestUpdate()}formStateRestoreCallback(t){this.value=t}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="validation-message"&&this.updateComplete.then(()=>{this.setInputValidity()}).catch(l=>{this.onerror&&this.onerror(l)})}setInputValidity(){this.inputElement.setCustomValidity(""),!this.inputElement.validity.valid&&this.validationMessage&&this.inputElement.setCustomValidity(this.validationMessage),this.setValidity()}updateValue(){this.value=this.inputElement.value,this.internals.setFormValue(this.inputElement.value)}onInput(){this.updateValue(),this.setInputValidity(),this.checkValidity()}onChange(t){this.updateValue(),this.setInputValidity();let e=t.constructor;this.dispatchEvent(new e(t.type,t))}handleKeyDown(t){var e;this.getActionForKeyEvent(t)===W.ENTER&&this.getKeyboardNavMode()===ee.DEFAULT&&((e=this.form)==null||e.requestSubmit())}renderLeadingIcon(){return this.leadingIcon?S`
|
|
4106
|
+
`,...Et(!0)],mb=C0;var ge=class extends Nt(Ve(pe(ie(dr)))){constructor(){super(...arguments);this.placeholder="";this.trailingButton=!1;this.autocapitalize=Kd.OFF;this.autocomplete=aa.OFF;this.clearAriaLabel="";this.dataAriaDescribedby=null}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.inputElement&&(this.setInputValidity(),this.internals.setFormValue(this.inputElement.value))}).catch(t=>{this.onerror&&this.onerror(t)})}firstUpdated(t){this.inputElement&&this.autoFocusOnMount&&(this.elementToAutoFocus=this.inputElement),super.firstUpdated(t)}formResetCallback(){this.value="",this.inputElement.value="",this.setInputValidity(),this.requestUpdate()}formStateRestoreCallback(t){this.value=t}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="validation-message"&&this.updateComplete.then(()=>{this.setInputValidity()}).catch(l=>{this.onerror&&this.onerror(l)})}setInputValidity(){this.inputElement.setCustomValidity(""),!this.inputElement.validity.valid&&this.validationMessage&&this.inputElement.setCustomValidity(this.validationMessage),this.setValidity()}updateValue(){this.value=this.inputElement.value,this.internals.setFormValue(this.inputElement.value)}onInput(t){if(this.updateValue(),this.setInputValidity(),this.checkValidity(),!t.composed){let e=t.constructor;this.dispatchEvent(new e(t.type,t))}}onChange(t){this.updateValue(),this.setInputValidity();let e=t.constructor;this.dispatchEvent(new e(t.type,t))}handleKeyDown(t){var e;this.getActionForKeyEvent(t)===W.ENTER&&this.getKeyboardNavMode()===ee.DEFAULT&&((e=this.form)==null||e.requestSubmit())}renderLeadingIcon(){return this.leadingIcon?S`
|
|
4107
4107
|
<mdc-icon
|
|
4108
4108
|
part="leading-icon"
|
|
4109
4109
|
name=${this.leadingIcon}
|
|
@@ -4898,12 +4898,13 @@
|
|
|
4898
4898
|
`}};pa.styles=[...Lr.styles,...Bb],h([u({type:Boolean,reflect:!0})],pa.prototype,"checked",2),h([u({type:String,reflect:!0})],pa.prototype,"indicator",2);var Rp=pa;Rp.register(Qd);var eS=Rp;var Io=B.constructTagName("navmenuitem"),Hb={DOT:_r.DOT,COUNTER:_r.COUNTER},Ub={RIGHT_ARROW:"arrow-right-bold"},Dp={MAX_COUNTER:99,TEXT_TYPE:ot.BODY_MIDSIZE_REGULAR,TAG_NAME:ut.SPAN,SIZE:Uo[24],VARIANT:cr.FLEXIBLE,CANNOT_ACTIVATE:!1};var rS=H`
|
|
4899
4899
|
:host::part(popover-content) {
|
|
4900
4900
|
padding: 0.75rem 0.5rem;
|
|
4901
|
+
scroll-padding-block: 0.25rem;
|
|
4901
4902
|
}
|
|
4902
4903
|
|
|
4903
4904
|
::slotted(mdc-divider) {
|
|
4904
4905
|
margin-block: 0.25rem;
|
|
4905
4906
|
}
|
|
4906
|
-
`,Gb=[rS];var Bn=a=>{var t;if(!a)return!1;let o=(t=a.getAttribute("role"))==null?void 0:t.toLowerCase();return o===et.MENUITEM||o===et.MENUITEMCHECKBOX||o===et.MENUITEMRADIO},Pp=a=>{var o;return((o=a==null?void 0:a.tagName)==null?void 0:o.toLowerCase())===be};var Hn=class extends nr{constructor(){super();this.placement=Ip.PLACEMENT;this.menuItems=[];this.menuItemsWithSubMenus=[];this.onOutsidePopoverClick=t=>{if(!this.depthManager.isHostOnTop())return;let e=t.composedPath(),i=this.contains(t.target)||e.includes(this.triggerElement)||e.includes(this),l=this.backdropElement?e.includes(this.backdropElement):!1;(!i||l)&&(this.closeAllMenuPopovers(),l&&t.stopPropagation())};this.togglePopoverVisible=t=>{var e;(e=this.triggerElement)!=null&&e.hasAttribute("soft-disabled")||(t.composedPath().find(i=>i.tagName===this.tagName)===this&&this.handleMouseClick(t),this.isEventFromTrigger(t)&&(this.visible?this.hide():this.show()))};this.handleItemCreation=t=>{let e=t.target;Bn(e)&&(t.stopImmediatePropagation(),e.addEventListener("destroyed",this.handleItemChangeEvent),e.addEventListener("disabled",this.handleItemChangeEvent))};this.handleItemChangeEvent=t=>{t.stopImmediatePropagation(),t.target&&t.type==="destroyed"&&(t.target.removeEventListener("destroyed",this.handleItemChangeEvent),t.target.removeEventListener("disabled",this.handleItemChangeEvent)),this.resetMenuNavigation()};this.resetMenuNavigation=()=>{this.collectMenuItems(),this.menuItems.find(e=>e.getAttribute("tabindex")==="0")||this.resetTabIndexes(0)};this.handleKeyDown=t=>{let e=!1;this.collectMenuItems();let i=t.target,l=this.getCurrentIndex(i);if(l===-1)return;switch(this.resetTabIndexes(l),this.getActionForKeyEvent(t,!0)){case W.HOME:{this.resetTabIndexAndSetFocus(0,l),e=!0;break}case W.END:{this.resetTabIndexAndSetFocus(this.menuItems.length-1,l),e=!0;break}case W.DOWN:{let f=l+1===this.menuItems.length?0:l+1;this.resetTabIndexAndSetFocus(f,l),e=!0;break}case W.UP:{let f=l-1===-1?this.menuItems.length-1:l-1;this.resetTabIndexAndSetFocus(f,l),e=!0;break}case W.RIGHT:{let f=this.getSubMenuPopoverOfTarget(i);f&&(f.show(),e=!0);break}case W.LEFT:{Pp(this.parentElement)&&(this.hide(),this.resetTabIndexAndSetFocus(0,l),e=!0);break}case W.ESCAPE:{this.depthManager.isHostOnTop()&&(this.resetTabIndexAndSetFocus(0,l),e=!0);break}case W.ENTER:{!this.getSubMenuPopoverOfTarget(i)&&!i.hasAttribute("soft-disabled")&&(this.closeAllMenuPopovers(),this.fireMenuItemAction(i),e=!0);break}case W.SPACE:{e=!0;break}default:break}e&&(this.keyDownEventHandled(),t.stopPropagation(),t.preventDefault())};this.handleKeyUp=t=>{let e=!1,i=t.target;switch(this.getActionForKeyEvent(t)){case W.SPACE:{!i.matches(`${Qd}, ${Zd}`)&&!i.hasAttribute("soft-disabled")&&(this.getSubMenuPopoverOfTarget(i)||(this.closeAllMenuPopovers(),this.fireMenuItemAction(i),e=!0));break}default:break}e&&(t.stopPropagation(),t.preventDefault())};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.addEventListener("created",this.handleItemCreation)}getSubMenuPopoverOfTarget(t){var i,l;let e=t.getAttribute("id");return e?(l=(i=this.parentElement)==null?void 0:i.querySelector)==null?void 0:l.call(i,`${be}[triggerid="${e}"]`):null}collectMenuItems(){var i;let t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=(t==null?void 0:t.assignedElements({flatten:!0}))||[];this.menuItems=e.map(l=>l.tagName.toLowerCase()===zi?Array.from(l.children).filter(c=>Bn(c)):Bn(l)?l:[]).flat().filter(l=>!!l&&!l.hasAttribute("disabled")),this.menuItemsWithSubMenus=this.menuItems.filter(l=>this.getSubMenuPopoverOfTarget(l))}getOpenSubMenusOfItems(t){let e=[];return!t||t.length===0||t.forEach(i=>{let l=this.getSubMenuPopoverOfTarget(i);l&&l.visible&&e.push(l)}),e}connectedCallback(){super.connectedCallback(),this.role=et.MENU,this.ariaOrientation=Ip.ORIENTATION,this.backdrop=!1,this.color=Qo.TONAL,this.disableAriaExpanded=!1,this.focusBackToTrigger=!0,this.focusTrap=!0,this.hideOnEscape=!0,this.hideOnOutsideClick=!0,this.interactive=!0,this.showArrow=!1,this.closeButton=!1,this.closeButtonAriaLabel=null}async isOpenUpdated(t,e){return t===e||!this.triggerElement?Promise.resolve():(e&&(this.backdrop=![Pn,Io].includes(this.triggerElement.tagName.toLowerCase())),e===!1&&this.menuItemsWithSubMenus.forEach(i=>{let l=this.getSubMenuPopoverOfTarget(i);l&&l.hide()}),this.resetMenuNavigation(),super.isOpenUpdated(t,e))}async firstUpdated(t){await super.firstUpdated(t),this.collectMenuItems(),this.resetTabIndexes(0)}resetTabIndexes(t){this.menuItems.length>0&&(this.menuItems.forEach(e=>e.setAttribute("tabindex","-1")),this.menuItems[t].setAttribute("tabindex","0"),this.menuItems[t].focus())}getCurrentIndex(t){return this.menuItems.findIndex(e=>e===t)}resetTabIndexAndSetFocus(t,e){t!==e&&(this.menuItems[e].setAttribute("tabindex","-1"),this.menuItems[t].setAttribute("tabindex","0"),this.menuItems[t].focus())}closeAllMenuPopovers(t){this.depthManager.popUntil(e=>e!==t&&Pp(e))}closeOtherSubMenusOnSameLevel(t){let e=this.menuItemsWithSubMenus.filter(l=>l!==t);this.getOpenSubMenusOfItems(e).forEach(l=>{l.hide()})}fireMenuItemAction(t){t.matches(Pn)&&t.dispatchEvent(new Event("action",{bubbles:!0,composed:!0}))}handleMouseClick(t){let e=t.target;if(!(!Bn(e)||!t.isTrusted||e.hasAttribute("soft-disabled"))){if(this.getSubMenuPopoverOfTarget(e)){this.closeOtherSubMenusOnSameLevel(e);return}this.closeAllMenuPopovers(),this.fireMenuItemAction(e)}}};Hn.styles=[...nr.styles,...Gb],h([u({type:String,reflect:!0})],Hn.prototype,"placement",2);var Fp=Hn;Fp.register(be);var iS=Fp;var tc=class{constructor(o,t){this.variant=o,this.expanded=t}hasSiblingWithTriggerId(o){var i,l;let t=o==null?void 0:o.getAttribute("id");return t?Array.from((l=(i=o==null?void 0:o.parentElement)==null?void 0:i.children)!=null?l:[]).some(c=>c!==o&&c.tagName.toLowerCase()===be&&c.getAttribute("triggerid")===t):!1}getParentNavMenuItems(o){if(!o)return[];let t=[],e=o;for(;e;){let i=e==null?void 0:e.closest(be);if(!i)break;let l=i.getAttribute("triggerid");if(!l)break;let c=document.getElementById(l);if(c&&c.tagName.toLowerCase()===Io)t.push(c),e=c;else break}return t}setCurrentActiveNavMenuItem(o){var l;let t=((l=this.currentActiveNavMenuItem)==null?void 0:l.navId)===(o==null?void 0:o.navId),e=(o==null?void 0:o.cannotActivate)||this.hasSiblingWithTriggerId(o)||(o==null?void 0:o.softDisabled);if(t||e||(this.currentActiveNavMenuItem&&(this.currentActiveNavMenuItem.removeAttribute("aria-current"),this.currentActiveNavMenuItem.removeAttribute("active"),this.getParentNavMenuItems(this.currentActiveNavMenuItem).forEach(f=>{f.hasActiveChild=!1,f.removeAttribute("active")})),!o))return;this.currentActiveNavMenuItem=o,o!=null&&o.disableAriaCurrent||o.setAttribute("aria-current","page"),o.setAttribute("active",""),this.getParentNavMenuItems(o).forEach(c=>{c.hasActiveChild=!0,c.setAttribute("active","")})}};tc.context=xo;var ec=tc;var oS=H`
|
|
4907
|
+
`,Gb=[rS];var Bn=a=>{var t;if(!a)return!1;let o=(t=a.getAttribute("role"))==null?void 0:t.toLowerCase();return o===et.MENUITEM||o===et.MENUITEMCHECKBOX||o===et.MENUITEMRADIO},Pp=a=>{var o;return((o=a==null?void 0:a.tagName)==null?void 0:o.toLowerCase())===be};var Hn=class extends nr{constructor(){super();this.placement=Ip.PLACEMENT;this.menuItems=[];this.menuItemsWithSubMenus=[];this.onOutsidePopoverClick=t=>{if(!this.depthManager.isHostOnTop())return;let e=t.composedPath(),i=this.contains(t.target)||e.includes(this.triggerElement)||e.includes(this),l=this.backdropElement?e.includes(this.backdropElement):!1;(!i||l)&&(this.closeAllMenuPopovers(),l&&t.stopPropagation())};this.togglePopoverVisible=t=>{var e;(e=this.triggerElement)!=null&&e.hasAttribute("soft-disabled")||(t.composedPath().find(i=>i.tagName===this.tagName)===this&&this.handleMouseClick(t),this.isEventFromTrigger(t)&&(this.visible?this.hide():this.show()))};this.handleItemCreation=t=>{let e=t.target;Bn(e)&&(t.stopImmediatePropagation(),e.addEventListener("destroyed",this.handleItemChangeEvent),e.addEventListener("disabled",this.handleItemChangeEvent))};this.handleItemChangeEvent=t=>{t.stopImmediatePropagation(),t.target&&t.type==="destroyed"&&(t.target.removeEventListener("destroyed",this.handleItemChangeEvent),t.target.removeEventListener("disabled",this.handleItemChangeEvent)),this.resetMenuNavigation()};this.resetMenuNavigation=()=>{this.collectMenuItems(),this.menuItems.find(e=>e.getAttribute("tabindex")==="0")||this.resetTabIndexes(0)};this.handleKeyDown=t=>{let e=!1;this.collectMenuItems();let i=t.target,l=this.getCurrentIndex(i);if(l===-1)return;switch(this.resetTabIndexes(l),this.getActionForKeyEvent(t,!0)){case W.HOME:{this.resetTabIndexAndSetFocus(0,l),e=!0;break}case W.END:{this.resetTabIndexAndSetFocus(this.menuItems.length-1,l),e=!0;break}case W.DOWN:{let f=l+1===this.menuItems.length?0:l+1;this.resetTabIndexAndSetFocus(f,l),e=!0;break}case W.UP:{let f=l-1===-1?this.menuItems.length-1:l-1;this.resetTabIndexAndSetFocus(f,l),e=!0;break}case W.RIGHT:{let f=this.getSubMenuPopoverOfTarget(i);f&&(f.show(),e=!0);break}case W.LEFT:{Pp(this.parentElement)&&(this.hide(),this.resetTabIndexAndSetFocus(0,l),e=!0);break}case W.ESCAPE:{this.depthManager.isHostOnTop()&&(this.resetTabIndexAndSetFocus(0,l),e=!0);break}case W.ENTER:{!this.getSubMenuPopoverOfTarget(i)&&!i.hasAttribute("soft-disabled")&&(this.closeAllMenuPopovers(),this.fireMenuItemAction(i),e=!0);break}case W.SPACE:{e=!0;break}default:break}e&&(this.keyDownEventHandled(),t.stopPropagation(),t.preventDefault())};this.handleKeyUp=t=>{let e=!1,i=t.target;switch(this.getActionForKeyEvent(t)){case W.SPACE:{!i.matches(`${Qd}, ${Zd}`)&&!i.hasAttribute("soft-disabled")&&(this.getSubMenuPopoverOfTarget(i)||(this.closeAllMenuPopovers(),this.fireMenuItemAction(i),e=!0));break}default:break}e&&(t.stopPropagation(),t.preventDefault())};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.addEventListener("created",this.handleItemCreation)}getSubMenuPopoverOfTarget(t){var i,l;let e=t.getAttribute("id");return e?(l=(i=this.parentElement)==null?void 0:i.querySelector)==null?void 0:l.call(i,`${be}[triggerid="${e}"]`):null}collectMenuItems(){var i;let t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=(t==null?void 0:t.assignedElements({flatten:!0}))||[];this.menuItems=e.map(l=>l.tagName.toLowerCase()===zi?Array.from(l.children).filter(c=>Bn(c)):Bn(l)?l:[]).flat().filter(l=>!!l&&!l.hasAttribute("disabled")),this.menuItemsWithSubMenus=this.menuItems.filter(l=>this.getSubMenuPopoverOfTarget(l))}getOpenSubMenusOfItems(t){let e=[];return!t||t.length===0||t.forEach(i=>{let l=this.getSubMenuPopoverOfTarget(i);l&&l.visible&&e.push(l)}),e}connectedCallback(){super.connectedCallback(),this.role=et.MENU,this.ariaOrientation=Ip.ORIENTATION,this.backdrop=!1,this.color=Qo.TONAL,this.disableAriaExpanded=!1,this.focusBackToTrigger=!0,this.focusTrap=!0,this.hideOnEscape=!0,this.hideOnOutsideClick=!0,this.interactive=!0,this.showArrow=!1,this.closeButton=!1,this.closeButtonAriaLabel=null}async isOpenUpdated(t,e){return t===e||!this.triggerElement?Promise.resolve():(e&&(this.backdrop=![Pn,Io].includes(this.triggerElement.tagName.toLowerCase())),e===!1&&this.menuItemsWithSubMenus.forEach(i=>{let l=this.getSubMenuPopoverOfTarget(i);l&&l.hide()}),this.resetMenuNavigation(),super.isOpenUpdated(t,e))}async firstUpdated(t){await super.firstUpdated(t),this.collectMenuItems(),this.resetTabIndexes(0)}resetTabIndexes(t){this.menuItems.length>0&&(this.menuItems.forEach(e=>e.setAttribute("tabindex","-1")),this.menuItems[t].setAttribute("tabindex","0"),this.menuItems[t].focus({preventScroll:!0}),this.menuItems[t].scrollIntoView({block:"nearest"}))}getCurrentIndex(t){return this.menuItems.findIndex(e=>e===t)}resetTabIndexAndSetFocus(t,e){t!==e&&(this.menuItems[e].setAttribute("tabindex","-1"),this.menuItems[t].setAttribute("tabindex","0"),this.menuItems[t].focus({preventScroll:!0}),this.menuItems[t].scrollIntoView({block:"nearest"}))}closeAllMenuPopovers(t){this.depthManager.popUntil(e=>e!==t&&Pp(e))}closeOtherSubMenusOnSameLevel(t){let e=this.menuItemsWithSubMenus.filter(l=>l!==t);this.getOpenSubMenusOfItems(e).forEach(l=>{l.hide()})}fireMenuItemAction(t){t.matches(Pn)&&t.dispatchEvent(new Event("action",{bubbles:!0,composed:!0}))}handleMouseClick(t){let e=t.target;if(!(!Bn(e)||!t.isTrusted||e.hasAttribute("soft-disabled"))){if(this.getSubMenuPopoverOfTarget(e)){this.closeOtherSubMenusOnSameLevel(e);return}this.closeAllMenuPopovers(),this.fireMenuItemAction(e)}}};Hn.styles=[...nr.styles,...Gb],h([u({type:String,reflect:!0})],Hn.prototype,"placement",2);var Fp=Hn;Fp.register(be);var iS=Fp;var tc=class{constructor(o,t){this.variant=o,this.expanded=t}hasSiblingWithTriggerId(o){var i,l;let t=o==null?void 0:o.getAttribute("id");return t?Array.from((l=(i=o==null?void 0:o.parentElement)==null?void 0:i.children)!=null?l:[]).some(c=>c!==o&&c.tagName.toLowerCase()===be&&c.getAttribute("triggerid")===t):!1}getParentNavMenuItems(o){if(!o)return[];let t=[],e=o;for(;e;){let i=e==null?void 0:e.closest(be);if(!i)break;let l=i.getAttribute("triggerid");if(!l)break;let c=document.getElementById(l);if(c&&c.tagName.toLowerCase()===Io)t.push(c),e=c;else break}return t}setCurrentActiveNavMenuItem(o){var l;let t=((l=this.currentActiveNavMenuItem)==null?void 0:l.navId)===(o==null?void 0:o.navId),e=(o==null?void 0:o.cannotActivate)||this.hasSiblingWithTriggerId(o)||(o==null?void 0:o.softDisabled);if(t||e||(this.currentActiveNavMenuItem&&(this.currentActiveNavMenuItem.removeAttribute("aria-current"),this.currentActiveNavMenuItem.removeAttribute("active"),this.getParentNavMenuItems(this.currentActiveNavMenuItem).forEach(f=>{f.hasActiveChild=!1,f.removeAttribute("active")})),!o))return;this.currentActiveNavMenuItem=o,o!=null&&o.disableAriaCurrent||o.setAttribute("aria-current","page"),o.setAttribute("active",""),this.getParentNavMenuItems(o).forEach(c=>{c.hasActiveChild=!0,c.setAttribute("active","")})}};tc.context=xo;var ec=tc;var oS=H`
|
|
4907
4908
|
:host {
|
|
4908
4909
|
--mdc-sidenavigation-expanded-width: 14.5rem;
|
|
4909
4910
|
--mdc-sidenavigation-expanded-left-padding: 1rem;
|