@momentum-design/components 0.133.33 → 0.133.34
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
CHANGED
|
@@ -5671,7 +5671,7 @@
|
|
|
5671
5671
|
outline: 0.125rem solid var(--mds-color-theme-focus-default-0);
|
|
5672
5672
|
}
|
|
5673
5673
|
}
|
|
5674
|
-
`,...Et(!0,"parent-to-child")],ay=yS;var Gn=class extends Lt(Nt(Ve(pe(Qt)))){constructor(){super();this.checked=!1;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}connectedCallback(){super.connectedCallback(),this.role=et.RADIO,this.shouldRenderLabel=!1,this.helpTextType=void 0,this.toggletipPlacement=void 0,this.toggletipStrategy=void 0,this.updateAriaLabel()}firstUpdated(t){this.updateTabIndex(),this.autoFocusOnMount&&(this.elementToAutoFocus=this),super.firstUpdated(t)}getAllRadiosWithinSameGroup(){return Array.from(
|
|
5674
|
+
`,...Et(!0,"parent-to-child")],ay=yS;var Gn=class extends Lt(Nt(Ve(pe(Qt)))){constructor(){super();this.checked=!1;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}connectedCallback(){super.connectedCallback(),this.role=et.RADIO,this.shouldRenderLabel=!1,this.helpTextType=void 0,this.toggletipPlacement=void 0,this.toggletipStrategy=void 0,this.updateAriaLabel()}firstUpdated(t){this.updateTabIndex(),this.autoFocusOnMount&&(this.elementToAutoFocus=this),super.firstUpdated(t)}getAllRadiosWithinSameGroup(){let t=this.getRootNode();return Array.from(t.querySelectorAll(`mdc-radio[name="${this.name}"]`))}formResetCallback(){this.getAllRadiosWithinSameGroup().forEach(e=>{e.checked=!1}),this.updateComplete.then(()=>{this.setActualFormValue()}).catch(e=>{this.onerror&&this.onerror(e)})}formStateRestoreCallback(t){this.value===t&&t!==""&&(this.checked=!0)}setComponentValidity(t){t?this.internals.setValidity({}):this.required&&!this.checked&&this.setValidity(),this.updateTabIndex()}setGroupValidity(t,e){this.updateComplete.then(()=>{t.forEach(i=>i.setComponentValidity(e))}).catch(i=>{var l;return(l=this.onerror)==null?void 0:l.call(this,i)})}setActualFormValue(){let t=this.getAllRadiosWithinSameGroup();if(this.checked)this.setGroupValidity(t,!0),this.internals.setFormValue(this.value||"on");else{let e=t.some(c=>c.required),i=t.some(c=>c.checked),l=e&&!i;this.setGroupValidity(t,!l),this.internals.setFormValue(null)}}handleChange(t=!1){if(this.checked||this.disabled||this.readonly||this.softDisabled)return;this.getAllRadiosWithinSameGroup().forEach(i=>{i.checked=!1}),this.checked=!0,t&&super.click(),this.emitCheckedChangeEvent()}click(){this.handleChange(!0)}updateRadio(t,e){let i=t[e];i.focus(),i.handleChange()}handleClick(){this.handleChange()}emitCheckedChangeEvent(){this.checked&&(this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleKeyDown(t){var f;if(this.disabled)return;let e=this.getActionForKeyEvent(t);(this.readonly||this.softDisabled)&&e===W.SPACE&&t.preventDefault();let l=this.getAllRadiosWithinSameGroup().filter(b=>!b.disabled),c=l.indexOf(this);if(this.getKeyboardNavMode()===ee.SPATIAL){e===W.ENTER&&(this.updateRadio(l,c),this.keyDownEventHandled()),this.updateTabIndex();return}if(e===W.DOWN||e===W.RIGHT){let b=(c+1)%l.length;this.updateRadio(l,b)}else if(e===W.UP||e===W.LEFT){let b=(c-1+l.length)%l.length;this.updateRadio(l,b)}else e===W.SPACE&&this.updateRadio(l,c);this.updateTabIndex(),e===W.ENTER&&((f=this.form)==null||f.requestSubmit())}updateTabIndex(){let t=this.getKeyboardNavMode()===ee.SPATIAL,e=this.getAllRadiosWithinSameGroup(),i=e.find(c=>c.checked),l=e.find(c=>!c.disabled);e.forEach(c=>{c.tabIndex=-1,(t||c===i||!i&&c===l)&&(c.tabIndex=0)})}update(t){super.update(t),t.has("checked")&&(this.ariaChecked=this.checked.toString(),this.setActualFormValue()),t.has("label")&&this.updateAriaLabel()}updateAriaLabel(){!this.ariaLabel&&this.ariaLabel!==this.label&&(this.ariaLabel=this.label||"")}setValidity(){this.required&&!this.checked&&this.validationMessage&&this.internals.setValidity({valueMissing:!0,customError:!0},this.validationMessage,this),this.internals.setValidity({})}handleIndicatorSlotChange(t){let i=t.target.assignedNodes({flatten:!0}).filter(l=>l.nodeType===Node.ELEMENT_NODE);this.classList.toggle("mdc-focus-ring",i.length>0)}render(){return S`
|
|
5675
5675
|
<slot name="indicator" @slotchange=${this.handleIndicatorSlotChange}>
|
|
5676
5676
|
<mdc-staticradio
|
|
5677
5677
|
part="radio-indicator"
|