@momentum-design/components 0.133.9 → 0.133.10

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.
@@ -7003,7 +7003,7 @@
7003
7003
  --mdc-timepicker-text-color: var(--mds-color-theme-text-primary-disabled);
7004
7004
  color: var(--mds-color-theme-text-primary-disabled);
7005
7005
  }
7006
- `,My=[HS,...yt(!0)];var Rt=class extends ce(re(Zt)){constructor(){super(...arguments);this.timeFormat=$e.TIME_FORMAT;this.interval=$e.INTERVAL;this.placement=Mt.BOTTOM_START;this.strategy=Et.STRATEGY;this.disableFlip=$e.DISABLE_FLIP;this.localeHoursLabel="";this.localeMinutesLabel="";this.localePeriodLabel="";this.localeHoursPlaceholder="";this.localeMinutesPlaceholder="";this.localePeriodPlaceholder="";this.localeAmLabel="";this.localePmLabel="";this.localeShowTimePickerLabel="";this.localeTimeOptionsLabel="";this.localeSpinbuttonDescription="";this.displayPopover=!1;this.internalHours="";this.internalMinutes="";this.internalPeriod="AM";this.focusedOptionIndex=-1;this.pendingDigits=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.parseValueToInternal(),this.syncFormValue()}).catch(t=>{this.onerror&&this.onerror(t)})}disconnectedCallback(){super.disconnectedCallback(),this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout)}willUpdate(t){super.willUpdate(t),t.has("value")&&!this.displayPopover&&(this.parseValueToInternal(),this.syncFormValue()),(t.has("disabled")||t.has("softDisabled")||t.has("readonly"))&&(this.disabled||this.softDisabled||this.readonly)&&(this.displayPopover=!1)}updated(t){super.updated(t),t.has("displayPopover")&&this.displayPopover&&this.focusMenuItemOnOpen()}focusMenuItemOnOpen(){let t=this.getTimeOptions(),e=this.internalToValue(),o=t.findIndex(l=>l.value===e);this.focusedOptionIndex=o>=0?o:0,this.updateComplete.then(()=>{this.focusCurrentMenuItem()}).catch(()=>{})}focusCurrentMenuItem(){var o;let t=(o=this.shadowRoot)==null?void 0:o.querySelector(`#${gm}`);if(!t)return;let e=t.querySelectorAll("mdc-option");e[this.focusedOptionIndex]&&e[this.focusedOptionIndex].focus()}formResetCallback(){this.value="",this.internalHours="",this.internalMinutes="",this.internalPeriod="AM",this.syncFormValue(),this.requestUpdate()}formStateRestoreCallback(t){this.value=t,this.parseValueToInternal()}parseValueToInternal(){if(!this.value){this.internalHours="",this.internalMinutes="",this.internalPeriod="AM";return}let t=this.value.match(/^(\d{1,2}):(\d{2})$/);if(!t)return;let e=parseInt(t[1],10),o=parseInt(t[2],10);e<0||e>23||o<0||o>59||(this.internalMinutes=String(o).padStart(2,"0"),this.timeFormat===_o.TWELVE_HOUR?e===0?(this.internalPeriod="AM",this.internalHours="12"):e<12?(this.internalPeriod="AM",this.internalHours=String(e).padStart(2,"0")):e===12?(this.internalPeriod="PM",this.internalHours="12"):(this.internalPeriod="PM",this.internalHours=String(e-12).padStart(2,"0")):this.internalHours=String(e).padStart(2,"0"))}internalToValue(){if(!this.internalHours||!this.internalMinutes)return"";let t=parseInt(this.internalHours,10);return this.timeFormat===_o.TWELVE_HOUR&&(this.internalPeriod==="AM"?t=t===12?0:t:t=t===12?12:t+12),`${String(t).padStart(2,"0")}:${this.internalMinutes}`}syncFormValue(){let t=this.internalToValue();this.internals.setFormValue(t||this.value)}commitValue(){let t=this.internalToValue();t&&t!==this.value&&(this.value=t,this.syncFormValue(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value},composed:!0,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},composed:!0,bubbles:!0})))}getTimeOptions(){let t=[],e=Math.max(1,Math.min(this.interval,60));for(let o=0;o<24*60;o+=e){let l=Math.floor(o/60),c=o%60,f=`${String(l).padStart(2,"0")}:${String(c).padStart(2,"0")}`,y;if(this.timeFormat===_o.TWELVE_HOUR){let W=l<12?this.localeAmLabel:this.localePmLabel,Q=l%12;Q===0&&(Q=12);let Z=c===0?"00":String(c);y=`${Q}:${Z} ${W}`}else y=`${l}:${String(c).padStart(2,"0")}`;let A=!this.min||f>=this.min,F=!this.max||f<=this.max;A&&F&&t.push({label:y,value:f})}return t}handleOptionClick(t){var e;this.value=t,this.parseValueToInternal(),this.displayPopover=!1,this.syncFormValue(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value},composed:!0,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},composed:!0,bubbles:!0})),(e=this.dropdownButton)==null||e.focus()}handleDropdownClick(t){this.disabled||this.softDisabled||this.readonly||(this.displayPopover=!this.displayPopover,t.stopPropagation())}handleSpinbuttonAreaClick(t){var o,l;this.disabled||this.softDisabled||this.readonly||t.target.getAttribute("role")==="spinbutton"||((o=this.hoursInput)==null||o.focus(),(l=this.hoursInput)==null||l.select())}handleBaseKeydown(t){var e;this.disabled||this.softDisabled||this.readonly||t.key===Ct.ESCAPE&&this.displayPopover&&(this.displayPopover=!1,(e=this.dropdownButton)==null||e.focus(),t.preventDefault(),t.stopPropagation())}handleListboxKeydown(t){var l;let e=this.getTimeOptions(),o=e.length;if(o!==0)switch(t.key){case Ct.ARROW_DOWN:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex=(this.focusedOptionIndex+1)%o,this.focusCurrentMenuItem();break}case Ct.ARROW_UP:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex=(this.focusedOptionIndex-1+o)%o,this.focusCurrentMenuItem();break}case Ct.ENTER:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex>=0&&this.focusedOptionIndex<o&&this.handleOptionClick(e[this.focusedOptionIndex].value);break}case Ct.ESCAPE:{t.preventDefault(),t.stopPropagation(),this.displayPopover=!1,(l=this.dropdownButton)==null||l.focus();break}default:break}}handleHoursKeydown(t){this.handleSpinbuttonKeydown(t,"hours")}handleMinutesKeydown(t){this.handleSpinbuttonKeydown(t,"minutes")}handlePeriodKeydown(t){var e,o;switch(t.key){case Ct.ARROW_UP:case Ct.ARROW_DOWN:t.preventDefault(),this.internalPeriod=this.internalPeriod==="AM"?"PM":"AM",this.commitValue(),this.requestUpdate();break;case Ct.TAB:break;case Ct.ARROW_LEFT:t.preventDefault(),(e=this.minutesInput)==null||e.focus(),(o=this.minutesInput)==null||o.select();break;default:{t.preventDefault();let l=this.localeAmLabel.charAt(0).toLowerCase(),c=this.localePmLabel.charAt(0).toLowerCase(),f=t.key.toLowerCase();f===l?(this.internalPeriod="AM",this.commitValue(),this.requestUpdate()):f===c&&(this.internalPeriod="PM",this.commitValue(),this.requestUpdate());break}}}handleSpinbuttonKeydown(t,e){var A,F,W,Q,Z,et;let o=this.timeFormat===_o.TWELVE_HOUR,l,c;e==="hours"?(l=o?$e.MIN_HOUR_12:$e.MIN_HOUR_24,c=o?$e.MAX_HOUR_12:$e.MAX_HOUR_24):(l=$e.MIN_MINUTE,c=$e.MAX_MINUTE);let f=e==="hours"?this.internalHours:this.internalMinutes,y=f?parseInt(f,10):l;switch(t.key){case Ct.ARROW_UP:{t.preventDefault(),y=y>=c?l:y+1,this.setSpinbuttonValue(e,y),this.commitValue();break}case Ct.ARROW_DOWN:{t.preventDefault(),y=y<=l?c:y-1,this.setSpinbuttonValue(e,y),this.commitValue();break}case Ct.ARROW_RIGHT:{t.preventDefault(),e==="hours"?((A=this.minutesInput)==null||A.focus(),(F=this.minutesInput)==null||F.select()):o&&((W=this.periodInput)==null||W.focus(),(Q=this.periodInput)==null||Q.select());break}case Ct.ARROW_LEFT:{t.preventDefault(),e==="minutes"&&((Z=this.hoursInput)==null||Z.focus(),(et=this.hoursInput)==null||et.select());break}case Ct.TAB:break;default:{/^\d$/.test(t.key)?(t.preventDefault(),this.handleDigitInput(t.key,e,l,c)):t.preventDefault();break}}}handleDigitInput(t,e,o,l){if(this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout),this.pendingDigits+=t,this.pendingDigits.length>=2){let c=parseInt(this.pendingDigits,10);c>l&&(c=l),c<o&&(c=o),this.setSpinbuttonValue(e,c),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)}else{let c=parseInt(this.pendingDigits,10),f=Math.floor(l/10);if(c>f){let y=c;y>l&&(y=l),y<o&&(y=o),this.setSpinbuttonValue(e,y),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)}else this.setSpinbuttonValue(e,c),this.pendingDigitTimeout=setTimeout(()=>{let y=c;y<o&&(y=o),this.setSpinbuttonValue(e,y),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)},1e3)}}setSpinbuttonValue(t,e){let o=String(e).padStart(2,"0");t==="hours"?this.internalHours=o:this.internalMinutes=o,this.requestUpdate()}advanceToNextField(t){t==="hours"?this.updateComplete.then(()=>{var e,o;(e=this.minutesInput)==null||e.focus(),(o=this.minutesInput)==null||o.select()}).catch(()=>{}):this.timeFormat===_o.TWELVE_HOUR&&this.updateComplete.then(()=>{var e,o;(e=this.periodInput)==null||e.focus(),(o=this.periodInput)==null||o.select()}).catch(()=>{})}handleSpinbuttonFocus(t){t.target.select(),this.pendingDigits="",this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout)}get displayPeriod(){return this.internalPeriod==="AM"?this.localeAmLabel:this.localePmLabel}get hoursPlaceholder(){return this.localeHoursPlaceholder}get minutesPlaceholder(){return this.localeMinutesPlaceholder}get periodPlaceholder(){return this.localePeriodPlaceholder}renderTimeOptions(){let t=this.getTimeOptions(),e=this.internalToValue();return t.map(o=>S`
7006
+ `,My=[HS,...yt(!0)];var Rt=class extends ce(re(Zt)){constructor(){super(...arguments);this.timeFormat=$e.TIME_FORMAT;this.interval=$e.INTERVAL;this.placement=Mt.BOTTOM_START;this.strategy=Et.STRATEGY;this.disableFlip=$e.DISABLE_FLIP;this.localeHoursLabel="";this.localeMinutesLabel="";this.localePeriodLabel="";this.localeHoursPlaceholder="";this.localeMinutesPlaceholder="";this.localePeriodPlaceholder="";this.localeAmLabel="";this.localePmLabel="";this.localeShowTimePickerLabel="";this.localeTimeOptionsLabel="";this.localeSpinbuttonDescription="";this.displayPopover=!1;this.internalHours="";this.internalMinutes="";this.internalPeriod="AM";this.focusedOptionIndex=-1;this.pendingDigits=""}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.parseValueToInternal(),this.syncFormValue()}).catch(t=>{this.onerror&&this.onerror(t)})}disconnectedCallback(){super.disconnectedCallback(),this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout)}willUpdate(t){super.willUpdate(t),t.has("value")&&!this.displayPopover&&(this.parseValueToInternal(),this.syncFormValue()),(t.has("disabled")||t.has("softDisabled")||t.has("readonly"))&&(this.disabled||this.softDisabled||this.readonly)&&(this.displayPopover=!1)}updated(t){super.updated(t),t.has("displayPopover")&&this.displayPopover&&this.focusMenuItemOnOpen()}focusMenuItemOnOpen(){let t=this.getTimeOptions(),e=this.internalToValue(),o=t.findIndex(l=>l.value===e);this.focusedOptionIndex=o>=0?o:0,this.updateComplete.then(()=>{this.focusCurrentMenuItem()}).catch(()=>{})}focusCurrentMenuItem(){var o;let t=(o=this.shadowRoot)==null?void 0:o.querySelector(`#${gm}`);if(!t)return;let e=t.querySelectorAll("mdc-option");e[this.focusedOptionIndex]&&e[this.focusedOptionIndex].focus()}formResetCallback(){this.value="",this.internalHours="",this.internalMinutes="",this.internalPeriod="AM",this.syncFormValue(),this.requestUpdate()}formStateRestoreCallback(t){this.value=t,this.parseValueToInternal()}parseValueToInternal(){if(!this.value){this.internalHours="",this.internalMinutes="",this.internalPeriod="AM";return}let t=this.value.match(/^(\d{1,2}):(\d{2})$/);if(!t)return;let e=parseInt(t[1],10),o=parseInt(t[2],10);e<0||e>23||o<0||o>59||(this.internalMinutes=String(o).padStart(2,"0"),this.timeFormat===_o.TWELVE_HOUR?e===0?(this.internalPeriod="AM",this.internalHours="12"):e<12?(this.internalPeriod="AM",this.internalHours=String(e).padStart(2,"0")):e===12?(this.internalPeriod="PM",this.internalHours="12"):(this.internalPeriod="PM",this.internalHours=String(e-12).padStart(2,"0")):this.internalHours=String(e).padStart(2,"0"))}internalToValue(){if(!this.internalHours||!this.internalMinutes)return"";let t=parseInt(this.internalHours,10);return this.timeFormat===_o.TWELVE_HOUR&&(this.internalPeriod==="AM"?t=t===12?0:t:t=t===12?12:t+12),`${String(t).padStart(2,"0")}:${this.internalMinutes}`}syncFormValue(){let t=this.internalToValue();this.internals.setFormValue(t||this.value)}commitValue(){let t=this.internalToValue();t&&t!==this.value&&(this.value=t,this.syncFormValue(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value},composed:!0,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},composed:!0,bubbles:!0})))}getTimeOptions(){let t=[],e=Math.max(1,Math.min(this.interval,60));for(let o=0;o<24*60;o+=e){let l=Math.floor(o/60),c=o%60,f=`${String(l).padStart(2,"0")}:${String(c).padStart(2,"0")}`,y;if(this.timeFormat===_o.TWELVE_HOUR){let W=l<12?this.localeAmLabel:this.localePmLabel,Q=l%12;Q===0&&(Q=12);let Z=String(c).padStart(2,"0");y=`${Q}:${Z} ${W}`}else y=`${l}:${String(c).padStart(2,"0")}`;let A=!this.min||f>=this.min,F=!this.max||f<=this.max;A&&F&&t.push({label:y,value:f})}return t}handleOptionClick(t){var e;this.value=t,this.parseValueToInternal(),this.displayPopover=!1,this.syncFormValue(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value},composed:!0,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},composed:!0,bubbles:!0})),(e=this.dropdownButton)==null||e.focus()}handleDropdownClick(t){this.disabled||this.softDisabled||this.readonly||(this.displayPopover=!this.displayPopover,t.stopPropagation())}handleSpinbuttonAreaClick(t){var o,l;this.disabled||this.softDisabled||this.readonly||t.target.getAttribute("role")==="spinbutton"||((o=this.hoursInput)==null||o.focus(),(l=this.hoursInput)==null||l.select())}handleBaseKeydown(t){var e;this.disabled||this.softDisabled||this.readonly||t.key===Ct.ESCAPE&&this.displayPopover&&(this.displayPopover=!1,(e=this.dropdownButton)==null||e.focus(),t.preventDefault(),t.stopPropagation())}handleListboxKeydown(t){var l;let e=this.getTimeOptions(),o=e.length;if(o!==0)switch(t.key){case Ct.ARROW_DOWN:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex=(this.focusedOptionIndex+1)%o,this.focusCurrentMenuItem();break}case Ct.ARROW_UP:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex=(this.focusedOptionIndex-1+o)%o,this.focusCurrentMenuItem();break}case Ct.ENTER:{t.preventDefault(),t.stopPropagation(),this.focusedOptionIndex>=0&&this.focusedOptionIndex<o&&this.handleOptionClick(e[this.focusedOptionIndex].value);break}case Ct.ESCAPE:{t.preventDefault(),t.stopPropagation(),this.displayPopover=!1,(l=this.dropdownButton)==null||l.focus();break}default:break}}handleHoursKeydown(t){this.handleSpinbuttonKeydown(t,"hours")}handleMinutesKeydown(t){this.handleSpinbuttonKeydown(t,"minutes")}handlePeriodKeydown(t){var e,o;switch(t.key){case Ct.ARROW_UP:case Ct.ARROW_DOWN:t.preventDefault(),this.internalPeriod=this.internalPeriod==="AM"?"PM":"AM",this.commitValue(),this.requestUpdate();break;case Ct.TAB:break;case Ct.ARROW_LEFT:t.preventDefault(),(e=this.minutesInput)==null||e.focus(),(o=this.minutesInput)==null||o.select();break;default:{t.preventDefault();let l=this.localeAmLabel.charAt(0).toLowerCase(),c=this.localePmLabel.charAt(0).toLowerCase(),f=t.key.toLowerCase();f===l?(this.internalPeriod="AM",this.commitValue(),this.requestUpdate()):f===c&&(this.internalPeriod="PM",this.commitValue(),this.requestUpdate());break}}}handleSpinbuttonKeydown(t,e){var A,F,W,Q,Z,et;let o=this.timeFormat===_o.TWELVE_HOUR,l,c;e==="hours"?(l=o?$e.MIN_HOUR_12:$e.MIN_HOUR_24,c=o?$e.MAX_HOUR_12:$e.MAX_HOUR_24):(l=$e.MIN_MINUTE,c=$e.MAX_MINUTE);let f=e==="hours"?this.internalHours:this.internalMinutes,y=f?parseInt(f,10):l;switch(t.key){case Ct.ARROW_UP:{t.preventDefault(),y=y>=c?l:y+1,this.setSpinbuttonValue(e,y),this.commitValue();break}case Ct.ARROW_DOWN:{t.preventDefault(),y=y<=l?c:y-1,this.setSpinbuttonValue(e,y),this.commitValue();break}case Ct.ARROW_RIGHT:{t.preventDefault(),e==="hours"?((A=this.minutesInput)==null||A.focus(),(F=this.minutesInput)==null||F.select()):o&&((W=this.periodInput)==null||W.focus(),(Q=this.periodInput)==null||Q.select());break}case Ct.ARROW_LEFT:{t.preventDefault(),e==="minutes"&&((Z=this.hoursInput)==null||Z.focus(),(et=this.hoursInput)==null||et.select());break}case Ct.TAB:break;default:{/^\d$/.test(t.key)?(t.preventDefault(),this.handleDigitInput(t.key,e,l,c)):t.preventDefault();break}}}handleDigitInput(t,e,o,l){if(this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout),this.pendingDigits+=t,this.pendingDigits.length>=2){let c=parseInt(this.pendingDigits,10);c>l&&(c=l),c<o&&(c=o),this.setSpinbuttonValue(e,c),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)}else{let c=parseInt(this.pendingDigits,10),f=Math.floor(l/10);if(c>f){let y=c;y>l&&(y=l),y<o&&(y=o),this.setSpinbuttonValue(e,y),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)}else this.setSpinbuttonValue(e,c),this.pendingDigitTimeout=setTimeout(()=>{let y=c;y<o&&(y=o),this.setSpinbuttonValue(e,y),this.pendingDigits="",this.commitValue(),this.advanceToNextField(e)},1e3)}}setSpinbuttonValue(t,e){let o=String(e).padStart(2,"0");t==="hours"?this.internalHours=o:this.internalMinutes=o,this.requestUpdate()}advanceToNextField(t){t==="hours"?this.updateComplete.then(()=>{var e,o;(e=this.minutesInput)==null||e.focus(),(o=this.minutesInput)==null||o.select()}).catch(()=>{}):this.timeFormat===_o.TWELVE_HOUR&&this.updateComplete.then(()=>{var e,o;(e=this.periodInput)==null||e.focus(),(o=this.periodInput)==null||o.select()}).catch(()=>{})}handleSpinbuttonFocus(t){t.target.select(),this.pendingDigits="",this.pendingDigitTimeout&&clearTimeout(this.pendingDigitTimeout)}get displayPeriod(){return this.internalPeriod==="AM"?this.localeAmLabel:this.localePmLabel}get hoursPlaceholder(){return this.localeHoursPlaceholder}get minutesPlaceholder(){return this.localeMinutesPlaceholder}get periodPlaceholder(){return this.localePeriodPlaceholder}renderTimeOptions(){let t=this.getTimeOptions(),e=this.internalToValue();return t.map(o=>S`
7007
7007
  <mdc-option
7008
7008
  label="${o.label}"
7009
7009
  ?selected="${o.value===e}"