@tabworthy/components 0.13.0 → 0.14.0
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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/tabworthy-components.cjs.js +1 -1
- package/dist/cjs/tabworthy-dates.cjs.entry.js +16 -0
- package/dist/cjs/tabworthy-times.cjs.entry.js +51 -7
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +41 -0
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +76 -7
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tabworthy-components.js +1 -1
- package/dist/esm/tabworthy-dates.entry.js +16 -0
- package/dist/esm/tabworthy-times.entry.js +51 -7
- package/dist/tabworthy-components/p-792d275e.entry.js +1 -0
- package/dist/tabworthy-components/{p-71f5c261.entry.js → p-af49d0fc.entry.js} +1 -1
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/dist/themes/light.css +1 -1
- package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +1 -0
- package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +6 -0
- package/dist/types/components.d.ts +2 -0
- package/package.json +1 -1
- package/dist/tabworthy-components/p-ed3c60d6.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as s,c as e,h as i,d as h,t as a}from"./p-BiJ0HZVY.js";import{g as n,d as o,c as r}from"./p-DkyM-7xr.js";import{g as d,r as l,c}from"./p-BzY8iIVW.js";import{d as u}from"./p-CMIEIvTW.js";import{d as m}from"./p-C_uZGgcG.js";var f,b={exports:{}},p=n(f?b.exports:(f=1,b.exports=function(){var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(s,e,i){var h=e.prototype,a=h.format;i.en.formats=t,h.format=function(s){void 0===s&&(s="YYYY-MM-DDTHH:mm:ssZ");var e=this.$locale().formats,i=function(s,e){return s.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(s,i,h){var a=h&&h.toUpperCase();return i||e[h]||t[h]||e[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,e){return s||e.slice(1)}))}))}(s,void 0===e?{}:e);return a.call(this,i)}}}()));o.extend(r),o.extend(p);const y={selected:"selected",openCalendar:"Choose time",calendar:"date and time picker",invalidDateError:"We could not find a matching date",minDateError:"Please fill in a date after ",maxDateError:"Please fill in a date before ",rangeOutOfBoundsError:"Please enter a valid range of dates",disabledDateError:"Please choose an available date",to:"to",startDate:"Start date",timeLabel:"Time"},v=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectDateTime=e(this,"selectDateTime",7),this.changeYear=e(this,"changeYear",7),this.errorChange=e(this,"errorChange",7),this.componentReady=e(this,"componentReady",7),this.range=!1,this.label="Choose a date and time",this.placeholder="",this.locale=(null===navigator||void 0===navigator?void 0:navigator.language)||"en-US",this.disabled=!1,this.startDate=d(new Date),this.referenceDate=d(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=y,this.inline=!1,this.hasError=!1,this.showYearStepper=!1,this.showMonthStepper=!0,this.showClearButton=!0,this.showCloseButton=!1,this.showTodayButton=!0,this.disableDate=()=>!1,this.elementClassName="tabworthy-times",this.firstDayOfWeek=1,this.format="YYYY-MM-DDTHH:mm:ss",this.inputShouldFormat=!0,this.disableFreeformInput=!1,this.inputClass="",this.selectedHours=(new Date).getHours(),this.selectedMinutes=(new Date).getMinutes(),this.selectedSeconds=(new Date).getSeconds(),this.errorState=this.hasError,this.disabledState=this.disabled,this.errorMessage="",this.handlePickerSelection=async t=>{if(!t)return this.clearValue();const s=t.split(",");if(this.range&&2===s.length){const t=l(new Date(s[0])),e=l(new Date(s[1]));if(!this.isDateValid(t)||!this.isDateValid(e))return;this.updateValue([t,e]),this.pickerRef&&(this.pickerRef.value=[t,e])}else{const t=l(new Date(s[0]));if(!this.isDateValid(t))return;this.updateValue(t),this.pickerRef&&(this.pickerRef.value=t)}},this.handleTimeChange=t=>{this.selectedHours=t.detail.hours,this.selectedMinutes=t.detail.minutes,void 0!==t.detail.seconds&&(this.selectedSeconds=t.detail.seconds),this.selectedDate&&this.updateValue(this.selectedDate)},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(this.inputContainerRef),await this.modalRef.open())},this.handleYearChange=t=>{this.changeYear&&this.changeYear.emit(t)},this.handleChangedMonths=()=>{},this.handleInputBlur=()=>{this.shouldInputFormat()&&this.formatInput()},this.handleInputChange=t=>{const s=t.target.value;if(0===s.length)return this.errorState=!1,this.internalValue="",this.pickerRef&&(this.pickerRef.value=null),this.value=this.internalValue,this.selectDateTime.emit(this.internalValue);let e=o(s,this.format,!0);if(e.isValid()||(e=o(s)),e.isValid()){if(this.minDate&&e.isBefore(o(this.minDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,void this.emitErrorChange("minDate",this.errorMessage);if(this.maxDate&&e.isAfter(o(this.maxDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,void this.emitErrorChange("maxDate",this.errorMessage);if(this.disableDate(e.toDate()))return this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,void this.emitErrorChange("disabledDate",this.errorMessage);this.errorState=!1,this.selectedHours=e.hour(),this.selectedMinutes=e.minute(),this.selectedSeconds=e.second(),this.updateValue(e.toDate())}else this.errorState=!0,this.errorMessage=this.timesLabels.invalidDateError,this.emitErrorChange("invalid",this.errorMessage)}}emitErrorChange(t,s){this.errorChange.emit({reason:t,message:s})}formatBoundaryDate(t){const s=o(t);if(!s.isValid())return t;if(!t.includes("T")&&!t.includes(" "))return Intl.DateTimeFormat(this.locale,{day:"numeric",month:"short",year:"numeric"}).format(s.toDate());const e=Object.assign({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"},this.showSeconds?{second:"numeric"}:{});return Intl.DateTimeFormat(this.locale,e).format(s.toDate())}getEffectiveMinTime(){if(!this.minDate||!this.selectedDate)return;const t=o(this.minDate),s=o(this.selectedDate);return t.isValid()&&s.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}getEffectiveMaxTime(){if(!this.maxDate||!this.selectedDate)return;const t=o(this.maxDate),s=o(this.selectedDate);return t.isValid()&&s.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}isDateOutOfBounds(){if(!this.selectedDate)return!1;const t=o(this.selectedDate);return!(!this.minDate||!t.isBefore(o(this.minDate),"day"))||!(!this.maxDate||!t.isAfter(o(this.maxDate),"day"))}shouldInputFormat(){return"string"==typeof this.inputShouldFormat?"true"===this.inputShouldFormat:!!this.inputShouldFormat}watchValue(t){this.syncFromValueProp()}watchDisabled(t){this.disabledState=t}watchHasError(t){this.errorState=t}componentDidLoad(){this.syncFromValueProp(),this.componentReady.emit(),this.id||console.error('tabworthy-times: The "id" prop is required for accessibility')}syncFromValueProp(){if(this.value){this.internalValue=this.value;const t=Array.isArray(this.value)?this.value[0]:this.value;if(t){const s=o(t,this.format);s.isValid()&&(this.selectedDate=s.toDate(),this.selectedHours=s.hour(),this.selectedMinutes=s.minute(),this.selectedSeconds=s.second())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const s=t.map((t=>o(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format)));this.internalValue=s,this.value=s,this.selectDateTime.emit(s)}else{const s=o(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format);this.internalValue=s,this.value=s,this.selectedDate=t,this.selectDateTime.emit(s)}this.errorState=!1,this.shouldInputFormat()&&this.formatInput()}isDateValid(t){const s=o(t);return!(!s.isValid()||(this.minDate&&s.isBefore(o(this.minDate))?(this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,this.emitErrorChange("minDate",this.errorMessage),1):this.maxDate&&s.isAfter(o(this.maxDate))?(this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,this.emitErrorChange("maxDate",this.errorMessage),1):this.disableDate(t)&&(this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,this.emitErrorChange("disabledDate",this.errorMessage),1)))}formatInput(){if(this.internalValue)if(Array.isArray(this.internalValue)){const t=this.internalValue.map((t=>o(t,this.format).format("lll"))).join(` ${this.timesLabels.to} `);this.inputRef.value=t}else this.inputRef.value=o(this.internalValue,this.format).format("lll")}getClassName(t){return`${this.elementClassName}__${t}`}toDate(t){return t?Array.isArray(t)?t.map((t=>o(t,this.format).toDate())):o(t,this.format).toDate():null}async clearValue(){this.internalValue=null,this.value=void 0,this.selectedDate=void 0,this.inputRef&&(this.inputRef.value=""),this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return i(h,{key:"d258bd87c60aa773bd178e1e74eeb32934d8f068",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"5e7a53cb36c350794af9fed2371c89823726ee2f",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),i("div",{key:"986905f117271cfb82a1f8415d55536a590ac2bc",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},i("input",{key:"9ad436c1e0c8a427c1665db16913cddf93d94fed",id:this.id+"-input",ref:t=>this.inputRef=t,type:"text",class:{[this.getClassName("input")]:!0,[this.inputClass]:!!this.inputClass},placeholder:this.placeholder,disabled:this.disabledState||this.disableFreeformInput,value:null===(t=this.internalValue)||void 0===t?void 0:""+t,onBlur:this.handleInputBlur,onChange:this.handleInputChange,"aria-describedby":this.errorState?this.id+"-error":void 0,"aria-invalid":this.errorState}),!this.inline&&i("button",{key:"d537e6f3251bada7ad50bbe1ca2c562737205897",type:"button",onClick:this.handleCalendarButtonClick,class:this.getClassName("calendar-button"),disabled:this.disabledState,"aria-label":this.calendarButtonContent?this.timesLabels.openCalendar:void 0},this.calendarButtonContent?i("span",{innerHTML:this.calendarButtonContent}):this.timesLabels.openCalendar)),i("tabworthy-dates-modal",{key:"241700195e1d028f8d8b6b55af7de3aee09163ea",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},i("div",{key:"b99aa129e4d1d600971bc4d21b2c6a4316ff64cf",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"6ac11c01936e2155c023d286d912ba87e0ed3415",range:this.range,locale:this.locale,onSelectDate:t=>this.handlePickerSelection(t.detail),onChangeMonth:t=>this.handleChangedMonths(t.detail),onChangeYear:t=>this.handleYearChange(t.detail),onRequestClose:()=>{var t;return null===(t=this.modalRef)||void 0===t?void 0:t.close()},labels:this.datesCalendarLabels,ref:t=>this.pickerRef=t,startDate:this.startDate,firstDayOfWeek:this.firstDayOfWeek,showHiddenTitle:!0,disabled:this.disabledState,showMonthStepper:this.showMonthStepper,showYearStepper:this.showYearStepper,showClearButton:this.showClearButton,showCloseButton:this.showCloseButton,showTodayButton:this.showTodayButton,disableDate:this.disableDate,minDate:this.minDate,maxDate:this.maxDate,inline:this.inline,value:this.value?this.toDate(this.value):void 0,nextMonthButtonContent:this.nextMonthButtonContent,nextYearButtonContent:this.nextYearButtonContent,previousMonthButtonContent:this.previousMonthButtonContent,previousYearButtonContent:this.previousYearButtonContent,todayButtonContent:this.todayButtonContent,clearButtonContent:this.clearButtonContent,closeButtonContent:this.closeButtonContent},i("div",{key:"7eead2c25334abce43fe7371436a52b0970e648b",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"06ac45a5eaaaa56d39825f941b0951f99c4b28e9",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"ba4187a2a369cff58ca0ecf3a60abfeff3ba9ca3",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState||this.isDateOutOfBounds(),onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels,minTime:this.getEffectiveMinTime(),maxTime:this.getEffectiveMaxTime()}))))),this.errorState&&i("div",{key:"c187d0bd982a5184aa796ffe8be4ed91c340230d",class:this.getClassName("input-error"),id:this.id?this.id+"-error":void 0,role:"status"},this.errorMessage))}get el(){return this}static get watchers(){return{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}}},[2,"tabworthy-times",{id:[513],value:[1025],range:[4],label:[1],placeholder:[1],locale:[1],disabled:[4],minDate:[1,"min-date"],maxDate:[1,"max-date"],startDate:[1,"start-date"],referenceDate:[1,"reference-date"],useTwelveHourFormat:[4,"use-twelve-hour-format"],showSeconds:[4,"show-seconds"],timesLabels:[16],datesCalendarLabels:[16],timesPickerLabels:[16],inline:[4],hasError:[1028,"has-error"],showYearStepper:[4,"show-year-stepper"],showMonthStepper:[4,"show-month-stepper"],showClearButton:[4,"show-clear-button"],showCloseButton:[4,"show-close-button"],showTodayButton:[4,"show-today-button"],calendarButtonContent:[1,"calendar-button-content"],nextMonthButtonContent:[1,"next-month-button-content"],nextYearButtonContent:[1,"next-year-button-content"],previousMonthButtonContent:[1,"previous-month-button-content"],previousYearButtonContent:[1,"previous-year-button-content"],todayButtonContent:[1,"today-button-content"],clearButtonContent:[1,"clear-button-content"],closeButtonContent:[1,"close-button-content"],disableDate:[16],elementClassName:[1,"element-class-name"],firstDayOfWeek:[2,"first-day-of-week"],format:[1],inputShouldFormat:[8,"input-should-format"],disableFreeformInput:[4,"disable-freeform-input"],inputClass:[1,"input-class"],appendTo:[1,"append-to"],internalValue:[32],selectedDate:[32],selectedHours:[32],selectedMinutes:[32],selectedSeconds:[32],errorState:[32],disabledState:[32],clearValue:[64]},void 0,{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}]),w=v,D=function(){"undefined"!=typeof customElements&&["tabworthy-times","tabworthy-dates-calendar","tabworthy-dates-modal","tabworthy-times-picker"].forEach((t=>{switch(t){case"tabworthy-times":customElements.get(a(t))||customElements.define(a(t),v);break;case"tabworthy-dates-calendar":customElements.get(a(t))||c();break;case"tabworthy-dates-modal":customElements.get(a(t))||u();break;case"tabworthy-times-picker":customElements.get(a(t))||m()}}))};export{w as TabworthyTimes,D as defineCustomElement}
|
|
1
|
+
import{p as t,H as s,c as i,h as e,d as h,t as a}from"./p-BiJ0HZVY.js";import{g as n,d as o,c as r}from"./p-DkyM-7xr.js";import{g as d,r as c,c as l}from"./p-BzY8iIVW.js";import{d as u}from"./p-CMIEIvTW.js";import{d as m}from"./p-C_uZGgcG.js";var b,f={exports:{}},p=n(b?f.exports:(b=1,f.exports=function(){var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(s,i,e){var h=i.prototype,a=h.format;e.en.formats=t,h.format=function(s){void 0===s&&(s="YYYY-MM-DDTHH:mm:ssZ");var i=this.$locale().formats,e=function(s,i){return s.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(s,e,h){var a=h&&h.toUpperCase();return e||i[h]||t[h]||i[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,i){return s||i.slice(1)}))}))}(s,void 0===i?{}:i);return a.call(this,e)}}}()));o.extend(r),o.extend(p);const y={selected:"selected",openCalendar:"Choose time",calendar:"date and time picker",invalidDateError:"We could not find a matching date",minDateError:"Please fill in a date after ",maxDateError:"Please fill in a date before ",rangeOutOfBoundsError:"Please enter a valid range of dates",disabledDateError:"Please choose an available date",to:"to",startDate:"Start date",timeLabel:"Time"},v=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectDateTime=i(this,"selectDateTime",7),this.changeYear=i(this,"changeYear",7),this.errorChange=i(this,"errorChange",7),this.componentReady=i(this,"componentReady",7),this.range=!1,this.label="Choose a date and time",this.placeholder="",this.locale=(null===navigator||void 0===navigator?void 0:navigator.language)||"en-US",this.disabled=!1,this.startDate=d(new Date),this.referenceDate=d(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=y,this.inline=!1,this.hasError=!1,this.showYearStepper=!1,this.showMonthStepper=!0,this.showClearButton=!0,this.showCloseButton=!1,this.showTodayButton=!0,this.disableDate=()=>!1,this.elementClassName="tabworthy-times",this.firstDayOfWeek=1,this.format="YYYY-MM-DDTHH:mm:ss",this.inputShouldFormat=!0,this.disableFreeformInput=!1,this.inputClass="",this.selectedHours=(new Date).getHours(),this.selectedMinutes=(new Date).getMinutes(),this.selectedSeconds=(new Date).getSeconds(),this.errorState=this.hasError,this.disabledState=this.disabled,this.errorMessage="",this.handlePickerSelection=async t=>{if(!t)return this.clearValue();const s=t.split(",");if(this.range&&2===s.length){const t=c(new Date(s[0])),i=c(new Date(s[1]));if(!this.isDateValid(t)||!this.isDateValid(i))return;this.updateValue([t,i]),this.pickerRef&&(this.pickerRef.value=[t,i])}else{const t=c(new Date(s[0]));if(!this.isDateValid(t))return;this.clampTimeToBounds(t),this.updateValue(t),this.pickerRef&&(this.pickerRef.value=void 0,this.pickerRef.value=t)}},this.handleTimeChange=t=>{this.selectedHours=t.detail.hours,this.selectedMinutes=t.detail.minutes,void 0!==t.detail.seconds&&(this.selectedSeconds=t.detail.seconds),this.selectedDate&&this.updateValue(this.selectedDate)},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(this.inputContainerRef),await this.modalRef.open())},this.handleYearChange=t=>{this.changeYear&&this.changeYear.emit(t)},this.handleChangedMonths=()=>{},this.handleInputBlur=()=>{this.shouldInputFormat()&&this.formatInput()},this.handleInputChange=t=>{const s=t.target.value;if(0===s.length)return this.errorState=!1,this.internalValue="",this.pickerRef&&(this.pickerRef.value=null),this.value=this.internalValue,this.selectDateTime.emit(this.internalValue);let i=o(s,this.format,!0);if(i.isValid()||(i=o(s)),i.isValid()){if(this.minDate&&i.isBefore(o(this.minDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,void this.emitErrorChange("minDate",this.errorMessage);if(this.maxDate&&i.isAfter(o(this.maxDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,void this.emitErrorChange("maxDate",this.errorMessage);if(this.disableDate(i.toDate()))return this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,void this.emitErrorChange("disabledDate",this.errorMessage);this.errorState=!1,this.selectedHours=i.hour(),this.selectedMinutes=i.minute(),this.selectedSeconds=i.second(),this.updateValue(i.toDate())}else this.errorState=!0,this.errorMessage=this.timesLabels.invalidDateError,this.emitErrorChange("invalid",this.errorMessage)}}emitErrorChange(t,s){this.errorChange.emit({reason:t,message:s})}formatBoundaryDate(t){const s=o(t);if(!s.isValid())return t;if(!t.includes("T")&&!t.includes(" "))return Intl.DateTimeFormat(this.locale,{day:"numeric",month:"short",year:"numeric"}).format(s.toDate());const i=Object.assign({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"},this.showSeconds?{second:"numeric"}:{});return Intl.DateTimeFormat(this.locale,i).format(s.toDate())}getEffectiveMinTime(){if(!this.minDate||!this.selectedDate)return;const t=o(this.minDate),s=o(this.selectedDate);return t.isValid()&&s.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}getEffectiveMaxTime(){if(!this.maxDate||!this.selectedDate)return;const t=o(this.maxDate),s=o(this.selectedDate);return t.isValid()&&s.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}isDateOutOfBounds(){if(!this.selectedDate)return!1;const t=o(this.selectedDate);return!(!this.minDate||!t.isBefore(o(this.minDate),"day"))||!(!this.maxDate||!t.isAfter(o(this.maxDate),"day"))}clampTimeToBounds(t){const s=o(t);if(this.minDate){const t=o(this.minDate);t.isValid()&&s.isSame(t,"day")&&3600*this.selectedHours+60*this.selectedMinutes+this.selectedSeconds<3600*t.hour()+60*t.minute()+t.second()&&(this.selectedHours=t.hour(),this.selectedMinutes=t.minute(),this.selectedSeconds=t.second())}if(this.maxDate){const t=o(this.maxDate);t.isValid()&&s.isSame(t,"day")&&3600*this.selectedHours+60*this.selectedMinutes+this.selectedSeconds>3600*t.hour()+60*t.minute()+t.second()&&(this.selectedHours=t.hour(),this.selectedMinutes=t.minute(),this.selectedSeconds=t.second())}}shouldInputFormat(){return"string"==typeof this.inputShouldFormat?"true"===this.inputShouldFormat:!!this.inputShouldFormat}watchValue(t){this.syncFromValueProp()}watchDisabled(t){this.disabledState=t}watchHasError(t){this.errorState=t}componentDidLoad(){this.syncFromValueProp(),this.componentReady.emit(),this.id||console.error('tabworthy-times: The "id" prop is required for accessibility')}syncFromValueProp(){if(this.value){this.internalValue=this.value;const t=Array.isArray(this.value)?this.value[0]:this.value;if(t){const s=o(t,this.format);s.isValid()&&(this.selectedDate=s.toDate(),this.selectedHours=s.hour(),this.selectedMinutes=s.minute(),this.selectedSeconds=s.second())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const s=t.map((t=>o(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format)));this.internalValue=s,this.value=s,this.selectDateTime.emit(s)}else{const s=o(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format);this.internalValue=s,this.value=s,this.selectedDate=t,this.selectDateTime.emit(s)}this.errorState=!1,this.shouldInputFormat()&&this.formatInput()}isDateValid(t){const s=o(t);return!(!s.isValid()||(this.minDate&&s.isBefore(o(this.minDate),"day")?(this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,this.emitErrorChange("minDate",this.errorMessage),1):this.maxDate&&s.isAfter(o(this.maxDate),"day")?(this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,this.emitErrorChange("maxDate",this.errorMessage),1):this.disableDate(t)&&(this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,this.emitErrorChange("disabledDate",this.errorMessage),1)))}formatInput(){if(this.internalValue)if(Array.isArray(this.internalValue)){const t=this.internalValue.map((t=>o(t,this.format).format("lll"))).join(` ${this.timesLabels.to} `);this.inputRef.value=t}else this.inputRef.value=o(this.internalValue,this.format).format("lll")}getClassName(t){return`${this.elementClassName}__${t}`}toDate(t){return t?Array.isArray(t)?t.map((t=>o(t,this.format).toDate())):o(t,this.format).toDate():null}async revertInput(t,s=!1){s&&(this.errorState=!1),this.value=t,this.syncFromValueProp()}async clearValue(){this.internalValue=null,this.value=void 0,this.selectedDate=void 0,this.inputRef&&(this.inputRef.value=""),this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return e(h,{key:"315801393d1528c6e6ba98b9e1c51187e40f62f5",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},e("label",{key:"c0ff6094ad4f9a2c12c1f041cd75996a792f2b1c",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),e("div",{key:"ede6bcbbd1874acc47360facc5220a0b7fef358c",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},e("input",{key:"4dcbd71cdd54fca3bb3ae26d4982c49fa32db8d6",id:this.id+"-input",ref:t=>this.inputRef=t,type:"text",class:{[this.getClassName("input")]:!0,[this.inputClass]:!!this.inputClass},placeholder:this.placeholder,disabled:this.disabledState||this.disableFreeformInput,value:null===(t=this.internalValue)||void 0===t?void 0:""+t,onBlur:this.handleInputBlur,onChange:this.handleInputChange,"aria-describedby":this.errorState?this.id+"-error":void 0,"aria-invalid":this.errorState}),!this.inline&&e("button",{key:"f486c98770077cd7ff39d2a56cafaf3d8c80a36c",type:"button",onClick:this.handleCalendarButtonClick,class:this.getClassName("calendar-button"),disabled:this.disabledState,"aria-label":this.calendarButtonContent?this.timesLabels.openCalendar:void 0},this.calendarButtonContent?e("span",{innerHTML:this.calendarButtonContent}):this.timesLabels.openCalendar)),e("tabworthy-dates-modal",{key:"b1cd3cbcea01f7147fe33abf11d62d35c50cbdb6",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},e("div",{key:"cec6685037168dd633037a6d723823572d9db5e5",class:this.getClassName("picker-container")},e("tabworthy-dates-calendar",{key:"0dec8076bb3aee853979d6de95bd07a7095b717a",range:this.range,locale:this.locale,onSelectDate:t=>this.handlePickerSelection(t.detail),onChangeMonth:t=>this.handleChangedMonths(t.detail),onChangeYear:t=>this.handleYearChange(t.detail),onRequestClose:()=>{var t;return null===(t=this.modalRef)||void 0===t?void 0:t.close()},labels:this.datesCalendarLabels,ref:t=>this.pickerRef=t,startDate:this.startDate,firstDayOfWeek:this.firstDayOfWeek,showHiddenTitle:!0,disabled:this.disabledState,showMonthStepper:this.showMonthStepper,showYearStepper:this.showYearStepper,showClearButton:this.showClearButton,showCloseButton:this.showCloseButton,showTodayButton:this.showTodayButton,disableDate:this.disableDate,minDate:this.minDate,maxDate:this.maxDate,inline:this.inline,value:this.value?this.toDate(this.value):void 0,nextMonthButtonContent:this.nextMonthButtonContent,nextYearButtonContent:this.nextYearButtonContent,previousMonthButtonContent:this.previousMonthButtonContent,previousYearButtonContent:this.previousYearButtonContent,todayButtonContent:this.todayButtonContent,clearButtonContent:this.clearButtonContent,closeButtonContent:this.closeButtonContent},e("div",{key:"f69a1b84ebceaf5d0c359190bec9ae11189d75e0",slot:"after-calendar",class:this.getClassName("time-section")},e("hr",{key:"6b9e5ae7c1f5aaa447da7b1b393c9bd75043dac2",class:this.getClassName("divider")}),e("tabworthy-times-picker",{key:"406f5ac12c09d0fddc0ebe3330961b783c2d7366",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState||this.isDateOutOfBounds(),onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels,minTime:this.getEffectiveMinTime(),maxTime:this.getEffectiveMaxTime()}))))),this.errorState&&e("div",{key:"ddc92f2c8d936a3a38f61d841860b17cd9c06283",class:this.getClassName("input-error"),id:this.id?this.id+"-error":void 0,role:"status"},this.errorMessage))}get el(){return this}static get watchers(){return{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}}},[2,"tabworthy-times",{id:[513],value:[1025],range:[4],label:[1],placeholder:[1],locale:[1],disabled:[4],minDate:[1,"min-date"],maxDate:[1,"max-date"],startDate:[1,"start-date"],referenceDate:[1,"reference-date"],useTwelveHourFormat:[4,"use-twelve-hour-format"],showSeconds:[4,"show-seconds"],timesLabels:[16],datesCalendarLabels:[16],timesPickerLabels:[16],inline:[4],hasError:[1028,"has-error"],showYearStepper:[4,"show-year-stepper"],showMonthStepper:[4,"show-month-stepper"],showClearButton:[4,"show-clear-button"],showCloseButton:[4,"show-close-button"],showTodayButton:[4,"show-today-button"],calendarButtonContent:[1,"calendar-button-content"],nextMonthButtonContent:[1,"next-month-button-content"],nextYearButtonContent:[1,"next-year-button-content"],previousMonthButtonContent:[1,"previous-month-button-content"],previousYearButtonContent:[1,"previous-year-button-content"],todayButtonContent:[1,"today-button-content"],clearButtonContent:[1,"clear-button-content"],closeButtonContent:[1,"close-button-content"],disableDate:[16],elementClassName:[1,"element-class-name"],firstDayOfWeek:[2,"first-day-of-week"],format:[1],inputShouldFormat:[8,"input-should-format"],disableFreeformInput:[4,"disable-freeform-input"],inputClass:[1,"input-class"],appendTo:[1,"append-to"],internalValue:[32],selectedDate:[32],selectedHours:[32],selectedMinutes:[32],selectedSeconds:[32],errorState:[32],disabledState:[32],revertInput:[64],clearValue:[64]},void 0,{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}]),w=v,D=function(){"undefined"!=typeof customElements&&["tabworthy-times","tabworthy-dates-calendar","tabworthy-dates-modal","tabworthy-times-picker"].forEach((t=>{switch(t){case"tabworthy-times":customElements.get(a(t))||customElements.define(a(t),v);break;case"tabworthy-dates-calendar":customElements.get(a(t))||l();break;case"tabworthy-dates-modal":customElements.get(a(t))||u();break;case"tabworthy-times-picker":customElements.get(a(t))||m()}}))};export{w as TabworthyTimes,D as defineCustomElement}
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-DQuL1Twl.js';
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["tabworthy-times-picker",[[2,"tabworthy-times-picker",{"hours":[1026],"minutes":[1026],"seconds":[1026],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"labels":[16],"labelsSrOnly":[4,"labels-sr-only"],"disabled":[4],"elementClassName":[1,"element-class-name"],"minTime":[16],"maxTime":[16],"internalHours":[32],"internalMinutes":[32],"internalSeconds":[32],"period":[32]},null,{"hours":[{"watchHours":0}],"minutes":[{"watchMinutes":0}],"seconds":[{"watchSeconds":0}]}]]],["tabworthy-dates-calendar_2",[[262,"tabworthy-dates-calendar",{"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disabled":[4],"modalIsOpen":[4,"modal-is-open"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"range":[4],"labels":[16],"locale":[1],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"inline":[4],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showMonthStepper":[4,"show-month-stepper"],"showTodayButton":[4,"show-today-button"],"showYearStepper":[4,"show-year-stepper"],"showKeyboardHint":[4,"show-keyboard-hint"],"showHiddenTitle":[4,"show-hidden-title"],"startDate":[1,"start-date"],"todayButtonContent":[1,"today-button-content"],"value":[1040],"currentDate":[32],"hoveredDate":[32],"weekdays":[32]},null,{"modalIsOpen":[{"watchModalIsOpen":0}],"firstDayOfWeek":[{"watchFirstDayOfWeek":0}],"locale":[{"watchLocale":0}],"range":[{"watchRange":0}],"startDate":[{"watchStartDate":0}],"value":[{"watchValue":0}]}],[257,"tabworthy-dates-modal",{"label":[1],"inline":[4],"placement":[1],"offset":[16],"appendTo":[1,"append-to"],"closing":[32],"showing":[32],"positioned":[32],"open":[64],"close":[64],"getState":[64],"setTriggerElement":[64],"updatePosition":[64]},[[10,"click","handleClick"]],{"showing":[{"watchShowing":0}]}]]],["tabworthy-times",[[2,"tabworthy-times",{"id":[513],"value":[1025],"range":[4],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"timesLabels":[16],"datesCalendarLabels":[16],"timesPickerLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"calendarButtonContent":[1,"calendar-button-content"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"inputShouldFormat":[8,"input-should-format"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"selectedDate":[32],"selectedHours":[32],"selectedMinutes":[32],"selectedSeconds":[32],"errorState":[32],"disabledState":[32],"clearValue":[64]},null,{"value":[{"watchValue":0}],"disabled":[{"watchDisabled":0}],"hasError":[{"watchHasError":0}]}]]],["tabworthy-dates",[[2,"tabworthy-dates",{"id":[513],"value":[1025],"range":[4],"yearOnly":[4,"year-only"],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useStrictDateParsing":[4,"use-strict-date-parsing"],"datesLabels":[16],"datesCalendarLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"inputShouldFormat":[8,"input-should-format"],"showKeyboardHint":[4,"show-keyboard-hint"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"quickButtons":[16],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"calendarButtonContent":[1,"calendar-button-content"],"showQuickButtons":[4,"show-quick-buttons"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"errorState":[32],"disabledState":[32],"parseDate":[64]},null,{"disabled":[{"watchDisabled":0}],"value":[{"watchValue":0}]}]]]], options);
|
|
8
|
+
return bootstrapLazy([["tabworthy-times-picker",[[2,"tabworthy-times-picker",{"hours":[1026],"minutes":[1026],"seconds":[1026],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"labels":[16],"labelsSrOnly":[4,"labels-sr-only"],"disabled":[4],"elementClassName":[1,"element-class-name"],"minTime":[16],"maxTime":[16],"internalHours":[32],"internalMinutes":[32],"internalSeconds":[32],"period":[32]},null,{"hours":[{"watchHours":0}],"minutes":[{"watchMinutes":0}],"seconds":[{"watchSeconds":0}]}]]],["tabworthy-dates-calendar_2",[[262,"tabworthy-dates-calendar",{"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disabled":[4],"modalIsOpen":[4,"modal-is-open"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"range":[4],"labels":[16],"locale":[1],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"inline":[4],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showMonthStepper":[4,"show-month-stepper"],"showTodayButton":[4,"show-today-button"],"showYearStepper":[4,"show-year-stepper"],"showKeyboardHint":[4,"show-keyboard-hint"],"showHiddenTitle":[4,"show-hidden-title"],"startDate":[1,"start-date"],"todayButtonContent":[1,"today-button-content"],"value":[1040],"currentDate":[32],"hoveredDate":[32],"weekdays":[32]},null,{"modalIsOpen":[{"watchModalIsOpen":0}],"firstDayOfWeek":[{"watchFirstDayOfWeek":0}],"locale":[{"watchLocale":0}],"range":[{"watchRange":0}],"startDate":[{"watchStartDate":0}],"value":[{"watchValue":0}]}],[257,"tabworthy-dates-modal",{"label":[1],"inline":[4],"placement":[1],"offset":[16],"appendTo":[1,"append-to"],"closing":[32],"showing":[32],"positioned":[32],"open":[64],"close":[64],"getState":[64],"setTriggerElement":[64],"updatePosition":[64]},[[10,"click","handleClick"]],{"showing":[{"watchShowing":0}]}]]],["tabworthy-times",[[2,"tabworthy-times",{"id":[513],"value":[1025],"range":[4],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"timesLabels":[16],"datesCalendarLabels":[16],"timesPickerLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"calendarButtonContent":[1,"calendar-button-content"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"inputShouldFormat":[8,"input-should-format"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"selectedDate":[32],"selectedHours":[32],"selectedMinutes":[32],"selectedSeconds":[32],"errorState":[32],"disabledState":[32],"revertInput":[64],"clearValue":[64]},null,{"value":[{"watchValue":0}],"disabled":[{"watchDisabled":0}],"hasError":[{"watchHasError":0}]}]]],["tabworthy-dates",[[2,"tabworthy-dates",{"id":[513],"value":[1025],"range":[4],"yearOnly":[4,"year-only"],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useStrictDateParsing":[4,"use-strict-date-parsing"],"datesLabels":[16],"datesCalendarLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"inputShouldFormat":[8,"input-should-format"],"showKeyboardHint":[4,"show-keyboard-hint"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"quickButtons":[16],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"calendarButtonContent":[1,"calendar-button-content"],"showQuickButtons":[4,"show-quick-buttons"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"errorState":[32],"disabledState":[32],"parseDate":[64],"revertInput":[64]},null,{"disabled":[{"watchDisabled":0}],"value":[{"watchValue":0}]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -17,5 +17,5 @@ var patchBrowser = () => {
|
|
|
17
17
|
|
|
18
18
|
patchBrowser().then(async (options) => {
|
|
19
19
|
await globalScripts();
|
|
20
|
-
return bootstrapLazy([["tabworthy-times-picker",[[2,"tabworthy-times-picker",{"hours":[1026],"minutes":[1026],"seconds":[1026],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"labels":[16],"labelsSrOnly":[4,"labels-sr-only"],"disabled":[4],"elementClassName":[1,"element-class-name"],"minTime":[16],"maxTime":[16],"internalHours":[32],"internalMinutes":[32],"internalSeconds":[32],"period":[32]},null,{"hours":[{"watchHours":0}],"minutes":[{"watchMinutes":0}],"seconds":[{"watchSeconds":0}]}]]],["tabworthy-dates-calendar_2",[[262,"tabworthy-dates-calendar",{"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disabled":[4],"modalIsOpen":[4,"modal-is-open"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"range":[4],"labels":[16],"locale":[1],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"inline":[4],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showMonthStepper":[4,"show-month-stepper"],"showTodayButton":[4,"show-today-button"],"showYearStepper":[4,"show-year-stepper"],"showKeyboardHint":[4,"show-keyboard-hint"],"showHiddenTitle":[4,"show-hidden-title"],"startDate":[1,"start-date"],"todayButtonContent":[1,"today-button-content"],"value":[1040],"currentDate":[32],"hoveredDate":[32],"weekdays":[32]},null,{"modalIsOpen":[{"watchModalIsOpen":0}],"firstDayOfWeek":[{"watchFirstDayOfWeek":0}],"locale":[{"watchLocale":0}],"range":[{"watchRange":0}],"startDate":[{"watchStartDate":0}],"value":[{"watchValue":0}]}],[257,"tabworthy-dates-modal",{"label":[1],"inline":[4],"placement":[1],"offset":[16],"appendTo":[1,"append-to"],"closing":[32],"showing":[32],"positioned":[32],"open":[64],"close":[64],"getState":[64],"setTriggerElement":[64],"updatePosition":[64]},[[10,"click","handleClick"]],{"showing":[{"watchShowing":0}]}]]],["tabworthy-times",[[2,"tabworthy-times",{"id":[513],"value":[1025],"range":[4],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"timesLabels":[16],"datesCalendarLabels":[16],"timesPickerLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"calendarButtonContent":[1,"calendar-button-content"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"inputShouldFormat":[8,"input-should-format"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"selectedDate":[32],"selectedHours":[32],"selectedMinutes":[32],"selectedSeconds":[32],"errorState":[32],"disabledState":[32],"clearValue":[64]},null,{"value":[{"watchValue":0}],"disabled":[{"watchDisabled":0}],"hasError":[{"watchHasError":0}]}]]],["tabworthy-dates",[[2,"tabworthy-dates",{"id":[513],"value":[1025],"range":[4],"yearOnly":[4,"year-only"],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useStrictDateParsing":[4,"use-strict-date-parsing"],"datesLabels":[16],"datesCalendarLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"inputShouldFormat":[8,"input-should-format"],"showKeyboardHint":[4,"show-keyboard-hint"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"quickButtons":[16],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"calendarButtonContent":[1,"calendar-button-content"],"showQuickButtons":[4,"show-quick-buttons"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"errorState":[32],"disabledState":[32],"parseDate":[64]},null,{"disabled":[{"watchDisabled":0}],"value":[{"watchValue":0}]}]]]], options);
|
|
20
|
+
return bootstrapLazy([["tabworthy-times-picker",[[2,"tabworthy-times-picker",{"hours":[1026],"minutes":[1026],"seconds":[1026],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"labels":[16],"labelsSrOnly":[4,"labels-sr-only"],"disabled":[4],"elementClassName":[1,"element-class-name"],"minTime":[16],"maxTime":[16],"internalHours":[32],"internalMinutes":[32],"internalSeconds":[32],"period":[32]},null,{"hours":[{"watchHours":0}],"minutes":[{"watchMinutes":0}],"seconds":[{"watchSeconds":0}]}]]],["tabworthy-dates-calendar_2",[[262,"tabworthy-dates-calendar",{"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disabled":[4],"modalIsOpen":[4,"modal-is-open"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"range":[4],"labels":[16],"locale":[1],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"inline":[4],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showMonthStepper":[4,"show-month-stepper"],"showTodayButton":[4,"show-today-button"],"showYearStepper":[4,"show-year-stepper"],"showKeyboardHint":[4,"show-keyboard-hint"],"showHiddenTitle":[4,"show-hidden-title"],"startDate":[1,"start-date"],"todayButtonContent":[1,"today-button-content"],"value":[1040],"currentDate":[32],"hoveredDate":[32],"weekdays":[32]},null,{"modalIsOpen":[{"watchModalIsOpen":0}],"firstDayOfWeek":[{"watchFirstDayOfWeek":0}],"locale":[{"watchLocale":0}],"range":[{"watchRange":0}],"startDate":[{"watchStartDate":0}],"value":[{"watchValue":0}]}],[257,"tabworthy-dates-modal",{"label":[1],"inline":[4],"placement":[1],"offset":[16],"appendTo":[1,"append-to"],"closing":[32],"showing":[32],"positioned":[32],"open":[64],"close":[64],"getState":[64],"setTriggerElement":[64],"updatePosition":[64]},[[10,"click","handleClick"]],{"showing":[{"watchShowing":0}]}]]],["tabworthy-times",[[2,"tabworthy-times",{"id":[513],"value":[1025],"range":[4],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useTwelveHourFormat":[4,"use-twelve-hour-format"],"showSeconds":[4,"show-seconds"],"timesLabels":[16],"datesCalendarLabels":[16],"timesPickerLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"calendarButtonContent":[1,"calendar-button-content"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"inputShouldFormat":[8,"input-should-format"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"selectedDate":[32],"selectedHours":[32],"selectedMinutes":[32],"selectedSeconds":[32],"errorState":[32],"disabledState":[32],"revertInput":[64],"clearValue":[64]},null,{"value":[{"watchValue":0}],"disabled":[{"watchDisabled":0}],"hasError":[{"watchHasError":0}]}]]],["tabworthy-dates",[[2,"tabworthy-dates",{"id":[513],"value":[1025],"range":[4],"yearOnly":[4,"year-only"],"label":[1],"placeholder":[1],"locale":[1],"disabled":[4],"minDate":[1,"min-date"],"maxDate":[1,"max-date"],"startDate":[1,"start-date"],"referenceDate":[1,"reference-date"],"useStrictDateParsing":[4,"use-strict-date-parsing"],"datesLabels":[16],"datesCalendarLabels":[16],"inline":[4],"hasError":[1028,"has-error"],"nextMonthButtonContent":[1,"next-month-button-content"],"nextYearButtonContent":[1,"next-year-button-content"],"previousMonthButtonContent":[1,"previous-month-button-content"],"previousYearButtonContent":[1,"previous-year-button-content"],"showYearStepper":[4,"show-year-stepper"],"showMonthStepper":[4,"show-month-stepper"],"showClearButton":[4,"show-clear-button"],"showCloseButton":[4,"show-close-button"],"showTodayButton":[4,"show-today-button"],"inputShouldFormat":[8,"input-should-format"],"showKeyboardHint":[4,"show-keyboard-hint"],"disableDate":[16],"elementClassName":[1,"element-class-name"],"firstDayOfWeek":[2,"first-day-of-week"],"format":[1],"quickButtons":[16],"todayButtonContent":[1,"today-button-content"],"clearButtonContent":[1,"clear-button-content"],"closeButtonContent":[1,"close-button-content"],"calendarButtonContent":[1,"calendar-button-content"],"showQuickButtons":[4,"show-quick-buttons"],"disableFreeformInput":[4,"disable-freeform-input"],"inputClass":[1,"input-class"],"appendTo":[1,"append-to"],"internalValue":[32],"errorState":[32],"disabledState":[32],"parseDate":[64],"revertInput":[64]},null,{"disabled":[{"watchDisabled":0}],"value":[{"watchValue":0}]}]]]], options);
|
|
21
21
|
});
|
|
@@ -10664,6 +10664,16 @@ const TabworthyDates = class {
|
|
|
10664
10664
|
this.value = this.internalValue;
|
|
10665
10665
|
return this.selectDate.emit(this.internalValue);
|
|
10666
10666
|
}
|
|
10667
|
+
// Try strict format parsing first to avoid DD/MM vs MM/DD ambiguity
|
|
10668
|
+
const strictParsed = dayjs$1(value, this.format, true);
|
|
10669
|
+
if (strictParsed.isValid()) {
|
|
10670
|
+
const date = strictParsed.toDate();
|
|
10671
|
+
if (!this.isPickedDateValid(date))
|
|
10672
|
+
return;
|
|
10673
|
+
this.updateValue(date);
|
|
10674
|
+
this.formatInput(true, false);
|
|
10675
|
+
return;
|
|
10676
|
+
}
|
|
10667
10677
|
const parsedDate = await chronoParseDate(value, {
|
|
10668
10678
|
locale: this.locale.slice(0, 2),
|
|
10669
10679
|
minDate: this.minDate,
|
|
@@ -10756,6 +10766,12 @@ const TabworthyDates = class {
|
|
|
10756
10766
|
reason: parsedDate && parsedDate.reason ? parsedDate.reason : undefined
|
|
10757
10767
|
};
|
|
10758
10768
|
}
|
|
10769
|
+
async revertInput(newValue, clearError = false) {
|
|
10770
|
+
if (clearError)
|
|
10771
|
+
this.errorState = false;
|
|
10772
|
+
this.value = newValue;
|
|
10773
|
+
this.syncFromValueProp(newValue);
|
|
10774
|
+
}
|
|
10759
10775
|
// @ts-ignore
|
|
10760
10776
|
isRangeValue(value) {
|
|
10761
10777
|
if (Array.isArray(value) &&
|
|
@@ -114,9 +114,12 @@ const TabworthyTimes = class {
|
|
|
114
114
|
const date = removeTimezoneOffset(new Date(dates[0]));
|
|
115
115
|
if (!this.isDateValid(date))
|
|
116
116
|
return;
|
|
117
|
+
// Clamp time to boundary constraints when selecting a boundary day
|
|
118
|
+
this.clampTimeToBounds(date);
|
|
117
119
|
this.updateValue(date);
|
|
118
|
-
//
|
|
120
|
+
// Reset then set calendar value so re-clicking the same date still emits
|
|
119
121
|
if (this.pickerRef) {
|
|
122
|
+
this.pickerRef.value = undefined;
|
|
120
123
|
this.pickerRef.value = date;
|
|
121
124
|
}
|
|
122
125
|
}
|
|
@@ -259,6 +262,41 @@ const TabworthyTimes = class {
|
|
|
259
262
|
return true;
|
|
260
263
|
return false;
|
|
261
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* When selecting a date on a boundary day, adjust the time to the first
|
|
267
|
+
* available time if the current selection falls outside the allowed range.
|
|
268
|
+
*/
|
|
269
|
+
clampTimeToBounds(date) {
|
|
270
|
+
const sel = dayjs(date);
|
|
271
|
+
if (this.minDate) {
|
|
272
|
+
const min = dayjs(this.minDate);
|
|
273
|
+
if (min.isValid() && sel.isSame(min, "day")) {
|
|
274
|
+
const curTotal = this.selectedHours * 3600 +
|
|
275
|
+
this.selectedMinutes * 60 +
|
|
276
|
+
this.selectedSeconds;
|
|
277
|
+
const minTotal = min.hour() * 3600 + min.minute() * 60 + min.second();
|
|
278
|
+
if (curTotal < minTotal) {
|
|
279
|
+
this.selectedHours = min.hour();
|
|
280
|
+
this.selectedMinutes = min.minute();
|
|
281
|
+
this.selectedSeconds = min.second();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (this.maxDate) {
|
|
286
|
+
const max = dayjs(this.maxDate);
|
|
287
|
+
if (max.isValid() && sel.isSame(max, "day")) {
|
|
288
|
+
const curTotal = this.selectedHours * 3600 +
|
|
289
|
+
this.selectedMinutes * 60 +
|
|
290
|
+
this.selectedSeconds;
|
|
291
|
+
const maxTotal = max.hour() * 3600 + max.minute() * 60 + max.second();
|
|
292
|
+
if (curTotal > maxTotal) {
|
|
293
|
+
this.selectedHours = max.hour();
|
|
294
|
+
this.selectedMinutes = max.minute();
|
|
295
|
+
this.selectedSeconds = max.second();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
262
300
|
shouldInputFormat() {
|
|
263
301
|
if (typeof this.inputShouldFormat === "string") {
|
|
264
302
|
return this.inputShouldFormat === "true";
|
|
@@ -335,13 +373,13 @@ const TabworthyTimes = class {
|
|
|
335
373
|
const parsed = dayjs(date);
|
|
336
374
|
if (!parsed.isValid())
|
|
337
375
|
return false;
|
|
338
|
-
if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
|
|
376
|
+
if (this.minDate && parsed.isBefore(dayjs(this.minDate), "day")) {
|
|
339
377
|
this.errorState = true;
|
|
340
378
|
this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
|
|
341
379
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
342
380
|
return false;
|
|
343
381
|
}
|
|
344
|
-
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
|
|
382
|
+
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate), "day")) {
|
|
345
383
|
this.errorState = true;
|
|
346
384
|
this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
|
|
347
385
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
@@ -381,6 +419,12 @@ const TabworthyTimes = class {
|
|
|
381
419
|
: dayjs(dateString, this.format).toDate();
|
|
382
420
|
return date;
|
|
383
421
|
}
|
|
422
|
+
async revertInput(newValue, clearError = false) {
|
|
423
|
+
if (clearError)
|
|
424
|
+
this.errorState = false;
|
|
425
|
+
this.value = newValue;
|
|
426
|
+
this.syncFromValueProp();
|
|
427
|
+
}
|
|
384
428
|
async clearValue() {
|
|
385
429
|
this.internalValue = null;
|
|
386
430
|
this.value = undefined;
|
|
@@ -395,12 +439,12 @@ const TabworthyTimes = class {
|
|
|
395
439
|
}
|
|
396
440
|
render() {
|
|
397
441
|
var _a;
|
|
398
|
-
return (h(Host, { key: '
|
|
442
|
+
return (h(Host, { key: '315801393d1528c6e6ba98b9e1c51187e40f62f5', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'c0ff6094ad4f9a2c12c1f041cd75996a792f2b1c', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'ede6bcbbd1874acc47360facc5220a0b7fef358c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: '4dcbd71cdd54fca3bb3ae26d4982c49fa32db8d6', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
399
443
|
[this.getClassName("input")]: true,
|
|
400
444
|
[this.inputClass]: !!this.inputClass
|
|
401
|
-
}, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '
|
|
445
|
+
}, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: 'f486c98770077cd7ff39d2a56cafaf3d8c80a36c', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
402
446
|
? this.timesLabels.openCalendar
|
|
403
|
-
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '
|
|
447
|
+
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: 'b1cd3cbcea01f7147fe33abf11d62d35c50cbdb6', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
404
448
|
if (this.pickerRef) {
|
|
405
449
|
this.pickerRef.modalIsOpen = true;
|
|
406
450
|
}
|
|
@@ -408,7 +452,7 @@ const TabworthyTimes = class {
|
|
|
408
452
|
if (this.pickerRef) {
|
|
409
453
|
this.pickerRef.modalIsOpen = false;
|
|
410
454
|
}
|
|
411
|
-
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '
|
|
455
|
+
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: 'cec6685037168dd633037a6d723823572d9db5e5', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '0dec8076bb3aee853979d6de95bd07a7095b717a', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline, value: this.value ? this.toDate(this.value) : undefined, nextMonthButtonContent: this.nextMonthButtonContent, nextYearButtonContent: this.nextYearButtonContent, previousMonthButtonContent: this.previousMonthButtonContent, previousYearButtonContent: this.previousYearButtonContent, todayButtonContent: this.todayButtonContent, clearButtonContent: this.clearButtonContent, closeButtonContent: this.closeButtonContent }, h("div", { key: 'f69a1b84ebceaf5d0c359190bec9ae11189d75e0', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '6b9e5ae7c1f5aaa447da7b1b393c9bd75043dac2', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '406f5ac12c09d0fddc0ebe3330961b783c2d7366', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime() }))))), this.errorState && (h("div", { key: 'ddc92f2c8d936a3a38f61d841860b17cd9c06283', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
412
456
|
}
|
|
413
457
|
get el() { return getElement(this); }
|
|
414
458
|
static get watchers() { return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as s,H as h,g as e}from"./p-CwtZ_Lud.js";import{g as a,d as n,c as r}from"./p-DkyM-7xr.js";import{g as o,r as d}from"./p-CoFOnMSw.js";var c,l,u={exports:{}},f=a(c?u.exports:(c=1,u.exports=(l={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},function(t,i,s){var h=i.prototype,e=h.format;s.en.formats=l,h.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var i=this.$locale().formats,s=function(t,i){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,s,h){var e=h&&h.toUpperCase();return s||i[h]||l[h]||i[e].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,i,s){return i||s.slice(1)}))}))}(t,void 0===i?{}:i);return e.call(this,s)}})));n.extend(r),n.extend(f);const m={selected:"selected",openCalendar:"Choose time",calendar:"date and time picker",invalidDateError:"We could not find a matching date",minDateError:"Please fill in a date after ",maxDateError:"Please fill in a date before ",rangeOutOfBoundsError:"Please enter a valid range of dates",disabledDateError:"Please choose an available date",to:"to",startDate:"Start date",timeLabel:"Time"},b=class{constructor(s){t(this,s),this.selectDateTime=i(this,"selectDateTime",7),this.changeYear=i(this,"changeYear",7),this.errorChange=i(this,"errorChange",7),this.componentReady=i(this,"componentReady",7),this.range=!1,this.label="Choose a date and time",this.placeholder="",this.locale=(null===navigator||void 0===navigator?void 0:navigator.language)||"en-US",this.disabled=!1,this.startDate=o(new Date),this.referenceDate=o(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=m,this.inline=!1,this.hasError=!1,this.showYearStepper=!1,this.showMonthStepper=!0,this.showClearButton=!0,this.showCloseButton=!1,this.showTodayButton=!0,this.disableDate=()=>!1,this.elementClassName="tabworthy-times",this.firstDayOfWeek=1,this.format="YYYY-MM-DDTHH:mm:ss",this.inputShouldFormat=!0,this.disableFreeformInput=!1,this.inputClass="",this.selectedHours=(new Date).getHours(),this.selectedMinutes=(new Date).getMinutes(),this.selectedSeconds=(new Date).getSeconds(),this.errorState=this.hasError,this.disabledState=this.disabled,this.errorMessage="",this.handlePickerSelection=async t=>{if(!t)return this.clearValue();const i=t.split(",");if(this.range&&2===i.length){const t=d(new Date(i[0])),s=d(new Date(i[1]));if(!this.isDateValid(t)||!this.isDateValid(s))return;this.updateValue([t,s]),this.pickerRef&&(this.pickerRef.value=[t,s])}else{const t=d(new Date(i[0]));if(!this.isDateValid(t))return;this.clampTimeToBounds(t),this.updateValue(t),this.pickerRef&&(this.pickerRef.value=void 0,this.pickerRef.value=t)}},this.handleTimeChange=t=>{this.selectedHours=t.detail.hours,this.selectedMinutes=t.detail.minutes,void 0!==t.detail.seconds&&(this.selectedSeconds=t.detail.seconds),this.selectedDate&&this.updateValue(this.selectedDate)},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(this.inputContainerRef),await this.modalRef.open())},this.handleYearChange=t=>{this.changeYear&&this.changeYear.emit(t)},this.handleChangedMonths=()=>{},this.handleInputBlur=()=>{this.shouldInputFormat()&&this.formatInput()},this.handleInputChange=t=>{const i=t.target.value;if(0===i.length)return this.errorState=!1,this.internalValue="",this.pickerRef&&(this.pickerRef.value=null),this.value=this.internalValue,this.selectDateTime.emit(this.internalValue);let s=n(i,this.format,!0);if(s.isValid()||(s=n(i)),s.isValid()){if(this.minDate&&s.isBefore(n(this.minDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,void this.emitErrorChange("minDate",this.errorMessage);if(this.maxDate&&s.isAfter(n(this.maxDate)))return this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,void this.emitErrorChange("maxDate",this.errorMessage);if(this.disableDate(s.toDate()))return this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,void this.emitErrorChange("disabledDate",this.errorMessage);this.errorState=!1,this.selectedHours=s.hour(),this.selectedMinutes=s.minute(),this.selectedSeconds=s.second(),this.updateValue(s.toDate())}else this.errorState=!0,this.errorMessage=this.timesLabels.invalidDateError,this.emitErrorChange("invalid",this.errorMessage)}}emitErrorChange(t,i){this.errorChange.emit({reason:t,message:i})}formatBoundaryDate(t){const i=n(t);if(!i.isValid())return t;if(!t.includes("T")&&!t.includes(" "))return Intl.DateTimeFormat(this.locale,{day:"numeric",month:"short",year:"numeric"}).format(i.toDate());const s=Object.assign({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"},this.showSeconds?{second:"numeric"}:{});return Intl.DateTimeFormat(this.locale,s).format(i.toDate())}getEffectiveMinTime(){if(!this.minDate||!this.selectedDate)return;const t=n(this.minDate),i=n(this.selectedDate);return t.isValid()&&i.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}getEffectiveMaxTime(){if(!this.maxDate||!this.selectedDate)return;const t=n(this.maxDate),i=n(this.selectedDate);return t.isValid()&&i.isSame(t,"day")?{hours:t.hour(),minutes:t.minute(),seconds:t.second()}:void 0}isDateOutOfBounds(){if(!this.selectedDate)return!1;const t=n(this.selectedDate);return!(!this.minDate||!t.isBefore(n(this.minDate),"day"))||!(!this.maxDate||!t.isAfter(n(this.maxDate),"day"))}clampTimeToBounds(t){const i=n(t);if(this.minDate){const t=n(this.minDate);t.isValid()&&i.isSame(t,"day")&&3600*this.selectedHours+60*this.selectedMinutes+this.selectedSeconds<3600*t.hour()+60*t.minute()+t.second()&&(this.selectedHours=t.hour(),this.selectedMinutes=t.minute(),this.selectedSeconds=t.second())}if(this.maxDate){const t=n(this.maxDate);t.isValid()&&i.isSame(t,"day")&&3600*this.selectedHours+60*this.selectedMinutes+this.selectedSeconds>3600*t.hour()+60*t.minute()+t.second()&&(this.selectedHours=t.hour(),this.selectedMinutes=t.minute(),this.selectedSeconds=t.second())}}shouldInputFormat(){return"string"==typeof this.inputShouldFormat?"true"===this.inputShouldFormat:!!this.inputShouldFormat}watchValue(t){this.syncFromValueProp()}watchDisabled(t){this.disabledState=t}watchHasError(t){this.errorState=t}componentDidLoad(){this.syncFromValueProp(),this.componentReady.emit(),this.id||console.error('tabworthy-times: The "id" prop is required for accessibility')}syncFromValueProp(){if(this.value){this.internalValue=this.value;const t=Array.isArray(this.value)?this.value[0]:this.value;if(t){const i=n(t,this.format);i.isValid()&&(this.selectedDate=i.toDate(),this.selectedHours=i.hour(),this.selectedMinutes=i.minute(),this.selectedSeconds=i.second())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const i=t.map((t=>n(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format)));this.internalValue=i,this.value=i,this.selectDateTime.emit(i)}else{const i=n(t).hour(this.selectedHours).minute(this.selectedMinutes).second(this.selectedSeconds).format(this.format);this.internalValue=i,this.value=i,this.selectedDate=t,this.selectDateTime.emit(i)}this.errorState=!1,this.shouldInputFormat()&&this.formatInput()}isDateValid(t){const i=n(t);return!(!i.isValid()||(this.minDate&&i.isBefore(n(this.minDate),"day")?(this.errorState=!0,this.errorMessage=`${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`,this.emitErrorChange("minDate",this.errorMessage),1):this.maxDate&&i.isAfter(n(this.maxDate),"day")?(this.errorState=!0,this.errorMessage=`${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`,this.emitErrorChange("maxDate",this.errorMessage),1):this.disableDate(t)&&(this.errorState=!0,this.errorMessage=this.timesLabels.disabledDateError,this.emitErrorChange("disabledDate",this.errorMessage),1)))}formatInput(){if(this.internalValue)if(Array.isArray(this.internalValue)){const t=this.internalValue.map((t=>n(t,this.format).format("lll"))).join(` ${this.timesLabels.to} `);this.inputRef.value=t}else this.inputRef.value=n(this.internalValue,this.format).format("lll")}getClassName(t){return`${this.elementClassName}__${t}`}toDate(t){return t?Array.isArray(t)?t.map((t=>n(t,this.format).toDate())):n(t,this.format).toDate():null}async revertInput(t,i=!1){i&&(this.errorState=!1),this.value=t,this.syncFromValueProp()}async clearValue(){this.internalValue=null,this.value=void 0,this.selectedDate=void 0,this.inputRef&&(this.inputRef.value=""),this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return s(h,{key:"315801393d1528c6e6ba98b9e1c51187e40f62f5",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},s("label",{key:"c0ff6094ad4f9a2c12c1f041cd75996a792f2b1c",htmlFor:`${this.id}-input`,class:this.getClassName("label")},this.label),s("div",{key:"ede6bcbbd1874acc47360facc5220a0b7fef358c",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},s("input",{key:"4dcbd71cdd54fca3bb3ae26d4982c49fa32db8d6",id:`${this.id}-input`,ref:t=>this.inputRef=t,type:"text",class:{[this.getClassName("input")]:!0,[this.inputClass]:!!this.inputClass},placeholder:this.placeholder,disabled:this.disabledState||this.disableFreeformInput,value:null===(t=this.internalValue)||void 0===t?void 0:t.toString(),onBlur:this.handleInputBlur,onChange:this.handleInputChange,"aria-describedby":this.errorState?`${this.id}-error`:void 0,"aria-invalid":this.errorState}),!this.inline&&s("button",{key:"f486c98770077cd7ff39d2a56cafaf3d8c80a36c",type:"button",onClick:this.handleCalendarButtonClick,class:this.getClassName("calendar-button"),disabled:this.disabledState,"aria-label":this.calendarButtonContent?this.timesLabels.openCalendar:void 0},this.calendarButtonContent?s("span",{innerHTML:this.calendarButtonContent}):this.timesLabels.openCalendar)),s("tabworthy-dates-modal",{key:"b1cd3cbcea01f7147fe33abf11d62d35c50cbdb6",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},s("div",{key:"cec6685037168dd633037a6d723823572d9db5e5",class:this.getClassName("picker-container")},s("tabworthy-dates-calendar",{key:"0dec8076bb3aee853979d6de95bd07a7095b717a",range:this.range,locale:this.locale,onSelectDate:t=>this.handlePickerSelection(t.detail),onChangeMonth:t=>this.handleChangedMonths(t.detail),onChangeYear:t=>this.handleYearChange(t.detail),onRequestClose:()=>{var t;return null===(t=this.modalRef)||void 0===t?void 0:t.close()},labels:this.datesCalendarLabels,ref:t=>this.pickerRef=t,startDate:this.startDate,firstDayOfWeek:this.firstDayOfWeek,showHiddenTitle:!0,disabled:this.disabledState,showMonthStepper:this.showMonthStepper,showYearStepper:this.showYearStepper,showClearButton:this.showClearButton,showCloseButton:this.showCloseButton,showTodayButton:this.showTodayButton,disableDate:this.disableDate,minDate:this.minDate,maxDate:this.maxDate,inline:this.inline,value:this.value?this.toDate(this.value):void 0,nextMonthButtonContent:this.nextMonthButtonContent,nextYearButtonContent:this.nextYearButtonContent,previousMonthButtonContent:this.previousMonthButtonContent,previousYearButtonContent:this.previousYearButtonContent,todayButtonContent:this.todayButtonContent,clearButtonContent:this.clearButtonContent,closeButtonContent:this.closeButtonContent},s("div",{key:"f69a1b84ebceaf5d0c359190bec9ae11189d75e0",slot:"after-calendar",class:this.getClassName("time-section")},s("hr",{key:"6b9e5ae7c1f5aaa447da7b1b393c9bd75043dac2",class:this.getClassName("divider")}),s("tabworthy-times-picker",{key:"406f5ac12c09d0fddc0ebe3330961b783c2d7366",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState||this.isDateOutOfBounds(),onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels,minTime:this.getEffectiveMinTime(),maxTime:this.getEffectiveMaxTime()}))))),this.errorState&&s("div",{key:"ddc92f2c8d936a3a38f61d841860b17cd9c06283",class:this.getClassName("input-error"),id:this.id?`${this.id}-error`:void 0,role:"status"},this.errorMessage))}get el(){return e(this)}static get watchers(){return{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}}};export{b as tabworthy_times}
|