@tabworthy/components 0.15.1 → 1.0.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/{customParseFormat-l09KVyWD.js → date-error-CCtoCDtq.js} +3 -0
- package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +11 -6
- package/dist/cjs/tabworthy-dates.cjs.entry.js +30 -28
- package/dist/cjs/tabworthy-times.cjs.entry.js +42 -42
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +14 -11
- package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +16 -7
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +10 -9
- package/dist/collection/utils/date-error.js +1 -0
- package/dist/{tabworthy-components/p-DkyM-7xr.js → components/p-DCgn1Avj.js} +1 -1
- package/dist/components/{p-DXCumu2Y.js → p-Denq9zJN.js} +1 -1
- package/dist/components/tabworthy-dates-modal.js +1 -1
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/{customParseFormat-DkyM-7xr.js → date-error-DCgn1Avj.js} +3 -1
- package/dist/esm/tabworthy-dates-calendar_2.entry.js +11 -6
- package/dist/esm/tabworthy-dates.entry.js +14 -12
- package/dist/esm/tabworthy-times.entry.js +10 -10
- package/dist/tabworthy-components/p-6749b25f.entry.js +1 -0
- package/dist/tabworthy-components/p-8c2b9340.entry.js +1 -0
- package/dist/tabworthy-components/{p-66c929f1.entry.js → p-98ba1248.entry.js} +1 -1
- package/dist/{components/p-DkyM-7xr.js → tabworthy-components/p-DCgn1Avj.js} +1 -1
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +5 -2
- package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +2 -1
- package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +1 -0
- package/dist/types/components.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/date-error.d.ts +2 -0
- package/package.json +3 -2
- package/dist/tabworthy-components/p-3e890a9c.entry.js +0 -1
- package/dist/tabworthy-components/p-af49d0fc.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
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 l,c}from"./p-C_Pq_S0e.js";import{d as u}from"./p-DXCumu2Y.js";import{d as m}from"./p-BvcvP308.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,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.timeOnly=!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])),i=l(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=l(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.timeOnly&&this.updateValue(this.getDateForTimeOnlyValue())},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}getDateForTimeOnlyValue(){if(this.selectedDate)return this.selectedDate;const t=o(this.referenceDate);return t.isValid()?t.toDate():new Date}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.internalValue=this.value||null,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.selectedDate=void 0;if(this.pickerRef)if(Array.isArray(this.value)){const t=this.value.reduce(((t,s)=>{const i=o(s,this.format,!0);return i.isValid()&&t.push(i.toDate()),t}),[]);this.pickerRef.value=t.length?t:null}else if(this.value){const t=o(this.value,this.format,!0);t.isValid()&&(this.pickerRef.value=t.toDate())}else this.pickerRef.value=null;this.inputRef&&(this.value?this.shouldInputFormat()?this.formatInput():this.inputRef.value=""+this.internalValue:this.inputRef.value="")}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=this.timeOnly?o(this.internalValue,this.format).format(this.showSeconds?"LTS":"LT"):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:"ab639b86fb2e2afe854a1253a2caab53a82f9cc0",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState,"time-only":this.timeOnly},e("label",{key:"55dd4b279bc847151a5f3cb50f98bddb62c2965c",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),e("div",{key:"5aa75daa3ee2d7de8f8385d5871dd732ce6c5d3c",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},e("input",{key:"49912db4c96619e20e818b494d553aad293920a8",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:"f22378a0ad106f560ed0d1e02e3b22b43e725289",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:"c0f14cf67c2da5a3c4917b388949458e410009e8",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0),this.timeOnly&&this.timePickerRef&&(this.timePickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1),this.timePickerRef&&(this.timePickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},e("div",{key:"c7051d360cfba74d9e0b3a8702683da2f79c013c",class:this.getClassName("picker-container")},!this.timeOnly&&e("tabworthy-dates-calendar",{key:"c9c72c072116568cd6ca0ce99de136940876e3b0",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:"325945a90d36cb39ef23db27f99fd6224984b735",slot:"after-calendar",class:this.getClassName("time-section")},e("hr",{key:"ff305cef7f526fb05dd3f193ea4093f0064fc813",class:this.getClassName("divider")}),e("tabworthy-times-picker",{key:"ad163d7fa0c3282312b848a758bfcc8b08a663ad",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(),ref:t=>this.timePickerRef=t}))),this.timeOnly&&e("div",{key:"c19252f05b91934af956c5ed9453185e591c4f71",class:this.getClassName("time-section")},e("tabworthy-times-picker",{key:"d8456d201c430625d2181a7da76f0ec5a471aec4",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(),ref:t=>this.timePickerRef=t})))),this.errorState&&e("div",{key:"0968907cbf6971aa00a486184394fe7d342ee237",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],timeOnly:[4,"time-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"],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))||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,f as d}from"./p-DCgn1Avj.js";import{g as l,r as c,c as u}from"./p-C_Pq_S0e.js";import{d as m}from"./p-Denq9zJN.js";import{d as f}from"./p-BvcvP308.js";var b,p={exports:{}},y=n(b?p.exports:(b=1,p.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(y);const v={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"},w=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.timeOnly=!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=l(new Date),this.referenceDate=l(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=v,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.timeOnly&&this.updateValue(this.getDateForTimeOnlyValue())},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(this.inputContainerRef,this.calendarButtonRef),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=d(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=d(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}getDateForTimeOnlyValue(){if(this.selectedDate)return this.selectedDate;const t=o(this.referenceDate);return t.isValid()?t.toDate():new Date}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.internalValue=this.value||null,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.selectedDate=void 0;if(this.pickerRef)if(Array.isArray(this.value)){const t=this.value.reduce(((t,s)=>{const i=o(s,this.format,!0);return i.isValid()&&t.push(i.toDate()),t}),[]);this.pickerRef.value=t.length?t:null}else if(this.value){const t=o(this.value,this.format,!0);t.isValid()&&(this.pickerRef.value=t.toDate())}else this.pickerRef.value=null;this.inputRef&&(this.value?this.shouldInputFormat()?this.formatInput():this.inputRef.value=""+this.internalValue:this.inputRef.value="")}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=d(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=d(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=this.timeOnly?o(this.internalValue,this.format).format(this.showSeconds?"LTS":"LT"):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:"eb40f4186e17019d6c0e7f59cd6c34ee65550fd8",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState,"time-only":this.timeOnly},e("label",{key:"6d1f0deae328d66331350247da217c428910ddfb",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),e("div",{key:"d7721562f0eeb5be4f6b68ff8e1c01c4ed08fe1b",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},e("input",{key:"1e4b4bd45f63aa5357505f58edde39739a51a124",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:"c5789e7d45619291c38895ba184c6ec74d73c584",type:"button",ref:t=>this.calendarButtonRef=t,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:"af58b555642816b299cf50394148ed17c427db21",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0),this.timeOnly&&this.timePickerRef&&(this.timePickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1),this.timePickerRef&&(this.timePickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},e("div",{key:"1bc48335f50777efd746a2737ac6acc60a72dec3",class:this.getClassName("picker-container")},!this.timeOnly&&e("tabworthy-dates-calendar",{key:"d0bdb6e18676f0019be5fd939a19075927b10fa4",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:"042f5fa7e60b67858ea7f92ca80792953b38d0a1",slot:"after-calendar",class:this.getClassName("time-section")},e("hr",{key:"7262873201e1294e6116fea1f429c71e37bf06c2",class:this.getClassName("divider")}),e("tabworthy-times-picker",{key:"46a179fd9ce95d53e144d0b03a77311e4daa3c10",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(),ref:t=>this.timePickerRef=t}))),this.timeOnly&&e("div",{key:"eaedaf5a7157dbdc99a947b6eb3e55f696556371",class:this.getClassName("time-section")},e("tabworthy-times-picker",{key:"504ea7e3069134e695d09ef48834b947de629b5e",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(),ref:t=>this.timePickerRef=t})))),this.errorState&&e("div",{key:"961823a7550b5439d2768f80317422b057758de3",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],timeOnly:[4,"time-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"],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}]}]),D=w,C=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),w);break;case"tabworthy-dates-calendar":customElements.get(a(t))||u();break;case"tabworthy-dates-modal":customElements.get(a(t))||m();break;case"tabworthy-times-picker":customElements.get(a(t))||f()}}))};export{D as TabworthyTimes,C as defineCustomElement}
|
|
@@ -38,4 +38,6 @@ function requireCustomParseFormat () {
|
|
|
38
38
|
var customParseFormatExports = requireCustomParseFormat();
|
|
39
39
|
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const formatDateError = (label, date) => typeof label === "function" ? label(date) : `${label} ${date}`;
|
|
42
|
+
|
|
43
|
+
export { customParseFormat as c, dayjs as d, formatDateError as f, getDefaultExportFromCjs as g };
|
|
@@ -2815,14 +2815,18 @@ const TabworthyDatesModal = class {
|
|
|
2815
2815
|
* Close the dialog.
|
|
2816
2816
|
*/
|
|
2817
2817
|
async close() {
|
|
2818
|
-
var _a;
|
|
2818
|
+
var _a, _b;
|
|
2819
2819
|
if (this.inline)
|
|
2820
2820
|
return;
|
|
2821
|
+
const activeElement = document.activeElement;
|
|
2822
|
+
const focusMovedOutside = !!activeElement &&
|
|
2823
|
+
activeElement !== document.body &&
|
|
2824
|
+
!this.hostElement.contains(activeElement);
|
|
2821
2825
|
this.showing = false;
|
|
2822
2826
|
this.closed.emit(undefined);
|
|
2823
2827
|
(_a = this.undo) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2824
|
-
if (
|
|
2825
|
-
this.
|
|
2828
|
+
if (!focusMovedOutside)
|
|
2829
|
+
(_b = this.focusReturnElement) === null || _b === void 0 ? void 0 : _b.focus();
|
|
2826
2830
|
}
|
|
2827
2831
|
disconnectedCallback() {
|
|
2828
2832
|
// Skip cleanup if we're in the middle of portal operations
|
|
@@ -2834,8 +2838,9 @@ const TabworthyDatesModal = class {
|
|
|
2834
2838
|
async getState() {
|
|
2835
2839
|
return this.showing;
|
|
2836
2840
|
}
|
|
2837
|
-
async setTriggerElement(element) {
|
|
2841
|
+
async setTriggerElement(element, focusElement = element) {
|
|
2838
2842
|
this.triggerElement = element;
|
|
2843
|
+
this.focusReturnElement = focusElement;
|
|
2839
2844
|
}
|
|
2840
2845
|
/** Force update the popper position */
|
|
2841
2846
|
async updatePosition() {
|
|
@@ -2857,7 +2862,7 @@ const TabworthyDatesModal = class {
|
|
|
2857
2862
|
}
|
|
2858
2863
|
}
|
|
2859
2864
|
render() {
|
|
2860
|
-
return (h(Host, { key: '
|
|
2865
|
+
return (h(Host, { key: '8f2128e3b9ed31547aaa4a1eb1f9fe1c2c554834', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (h("div", { key: 'd3c8a2b9d11bdd1147ded6256417c0bdda9274b5', part: "body", ref: (r) => {
|
|
2861
2866
|
if (r) {
|
|
2862
2867
|
this.bodyRef = r;
|
|
2863
2868
|
// Setup portal and create popper when ref is set
|
|
@@ -2874,7 +2879,7 @@ const TabworthyDatesModal = class {
|
|
|
2874
2879
|
});
|
|
2875
2880
|
}
|
|
2876
2881
|
}
|
|
2877
|
-
}, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: '
|
|
2882
|
+
}, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: '3c36e0e81b87ef9364ff8288e200c4462626bfea' }, h("div", { key: '111ba3d8fea2f0f4afdb63506fa43d1b8467c14d', part: "content" }, h("slot", { key: '6ec34c827f3c4cf1a5f30d9e571826f73cc66157' }))))), this.inline && (h("div", { key: '49970743a4f726fd02b18ba485ba0753acc4d0ec', part: "content" }, h("slot", { key: '6d0e2cd6bdc51f63fbab138c93f9c99cc3b1291d' })))));
|
|
2878
2883
|
}
|
|
2879
2884
|
get hostElement() { return getElement(this); }
|
|
2880
2885
|
static get watchers() { return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CwtZ_Lud.js';
|
|
2
|
-
import { g as getDefaultExportFromCjs, d as dayjs$1, c as customParseFormat } from './
|
|
2
|
+
import { g as getDefaultExportFromCjs, d as dayjs$1, c as customParseFormat, f as formatDateError } from './date-error-DCgn1Avj.js';
|
|
3
3
|
import { r as removeTimezoneOffset, y as extractDates, z as isValidISODate, e as dateIsWithinBounds, o as dateIsWithinLowerBounds, q as dateIsWithinUpperBounds, g as getISODateString, p as parseDateString } from './utils-CoFOnMSw.js';
|
|
4
4
|
|
|
5
5
|
function _mergeNamespaces(n, m) {
|
|
@@ -10555,7 +10555,7 @@ const TabworthyDates = class {
|
|
|
10555
10555
|
await customElements.whenDefined("tabworthy-dates-modal");
|
|
10556
10556
|
// Use input container as trigger for proper dropdown alignment
|
|
10557
10557
|
this.inputContainerRef &&
|
|
10558
|
-
(await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef)));
|
|
10558
|
+
(await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef, this.calendarButtonRef)));
|
|
10559
10559
|
if ((await ((_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.getState())) === false)
|
|
10560
10560
|
await ((_c = this.modalRef) === null || _c === void 0 ? void 0 : _c.open());
|
|
10561
10561
|
else if ((await ((_d = this.modalRef) === null || _d === void 0 ? void 0 : _d.getState())) === true)
|
|
@@ -10705,18 +10705,13 @@ const TabworthyDates = class {
|
|
|
10705
10705
|
minDate === null || minDate === void 0 ? void 0 : minDate.setDate(minDate.getDate() - 1);
|
|
10706
10706
|
}
|
|
10707
10707
|
if (!!parsedDate.reason) {
|
|
10708
|
-
const formatLocalizedDate = (date) => Intl.DateTimeFormat(this.locale, {
|
|
10709
|
-
day: "numeric",
|
|
10710
|
-
month: "short",
|
|
10711
|
-
year: "numeric"
|
|
10712
|
-
}).format(date);
|
|
10713
10708
|
this.errorMessage = parsedDate.reason;
|
|
10714
10709
|
this.errorMessage = {
|
|
10715
10710
|
minDate: minDate
|
|
10716
|
-
?
|
|
10711
|
+
? formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(minDate))
|
|
10717
10712
|
: "",
|
|
10718
10713
|
maxDate: maxDate
|
|
10719
|
-
?
|
|
10714
|
+
? formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(maxDate))
|
|
10720
10715
|
: "",
|
|
10721
10716
|
invalid: this.datesLabels.invalidDateError
|
|
10722
10717
|
}[parsedDate.reason];
|
|
@@ -10799,6 +10794,13 @@ const TabworthyDates = class {
|
|
|
10799
10794
|
emitErrorChange(reason, message) {
|
|
10800
10795
|
this.errorChange.emit({ reason, message });
|
|
10801
10796
|
}
|
|
10797
|
+
formatBoundaryDate(date) {
|
|
10798
|
+
return Intl.DateTimeFormat(this.locale, {
|
|
10799
|
+
day: "numeric",
|
|
10800
|
+
month: "short",
|
|
10801
|
+
year: "numeric"
|
|
10802
|
+
}).format(date);
|
|
10803
|
+
}
|
|
10802
10804
|
formatInput(enabled, useInputValue = true) {
|
|
10803
10805
|
if (this.shouldInputFormat() === false || enabled === false) {
|
|
10804
10806
|
if (this.internalValue) {
|
|
@@ -10851,13 +10853,13 @@ const TabworthyDates = class {
|
|
|
10851
10853
|
const isoDate = typeof dateString === "string" ? dateString : parsed.format("YYYY-MM-DD");
|
|
10852
10854
|
if (this.minDate && isoDate < this.minDate) {
|
|
10853
10855
|
this.errorState = true;
|
|
10854
|
-
this.errorMessage =
|
|
10856
|
+
this.errorMessage = formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(parseDateString(this.minDate)));
|
|
10855
10857
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
10856
10858
|
return false;
|
|
10857
10859
|
}
|
|
10858
10860
|
if (this.maxDate && isoDate > this.maxDate) {
|
|
10859
10861
|
this.errorState = true;
|
|
10860
|
-
this.errorMessage =
|
|
10862
|
+
this.errorMessage = formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(parseDateString(this.maxDate)));
|
|
10861
10863
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
10862
10864
|
return false;
|
|
10863
10865
|
}
|
|
@@ -10997,7 +10999,7 @@ const TabworthyDates = class {
|
|
|
10997
10999
|
return (h(Host, null, h("label", { htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", null), h("div", { class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
|
|
10998
11000
|
[this.getClassName("input")]: true,
|
|
10999
11001
|
[this.inputClass]: !!this.inputClass
|
|
11000
|
-
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
11002
|
+
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
11001
11003
|
? this.datesLabels.openCalendar
|
|
11002
11004
|
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), h("tabworthy-dates-modal", { label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
11003
11005
|
if (!this.pickerRef)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CwtZ_Lud.js';
|
|
2
|
-
import { g as getDefaultExportFromCjs, d as dayjs, c as customParseFormat } from './
|
|
2
|
+
import { g as getDefaultExportFromCjs, d as dayjs, c as customParseFormat, f as formatDateError } from './date-error-DCgn1Avj.js';
|
|
3
3
|
import { g as getISODateString, r as removeTimezoneOffset } from './utils-CoFOnMSw.js';
|
|
4
4
|
|
|
5
5
|
var localizedFormat$2 = {exports: {}};
|
|
@@ -143,7 +143,7 @@ const TabworthyTimes = class {
|
|
|
143
143
|
this.handleCalendarButtonClick = async () => {
|
|
144
144
|
if (this.modalRef) {
|
|
145
145
|
// Use input container as trigger for proper dropdown alignment
|
|
146
|
-
await this.modalRef.setTriggerElement(this.inputContainerRef);
|
|
146
|
+
await this.modalRef.setTriggerElement(this.inputContainerRef, this.calendarButtonRef);
|
|
147
147
|
await this.modalRef.open();
|
|
148
148
|
}
|
|
149
149
|
};
|
|
@@ -183,13 +183,13 @@ const TabworthyTimes = class {
|
|
|
183
183
|
// Check minDate/maxDate bounds (supports both date-only and datetime strings)
|
|
184
184
|
if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
|
|
185
185
|
this.errorState = true;
|
|
186
|
-
this.errorMessage =
|
|
186
|
+
this.errorMessage = formatDateError(this.timesLabels.minDateError, this.formatBoundaryDate(this.minDate));
|
|
187
187
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
|
|
191
191
|
this.errorState = true;
|
|
192
|
-
this.errorMessage =
|
|
192
|
+
this.errorMessage = formatDateError(this.timesLabels.maxDateError, this.formatBoundaryDate(this.maxDate));
|
|
193
193
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
@@ -422,13 +422,13 @@ const TabworthyTimes = class {
|
|
|
422
422
|
return false;
|
|
423
423
|
if (this.minDate && parsed.isBefore(dayjs(this.minDate), "day")) {
|
|
424
424
|
this.errorState = true;
|
|
425
|
-
this.errorMessage =
|
|
425
|
+
this.errorMessage = formatDateError(this.timesLabels.minDateError, this.formatBoundaryDate(this.minDate));
|
|
426
426
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
427
427
|
return false;
|
|
428
428
|
}
|
|
429
429
|
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate), "day")) {
|
|
430
430
|
this.errorState = true;
|
|
431
|
-
this.errorMessage =
|
|
431
|
+
this.errorMessage = formatDateError(this.timesLabels.maxDateError, this.formatBoundaryDate(this.maxDate));
|
|
432
432
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
433
433
|
return false;
|
|
434
434
|
}
|
|
@@ -489,12 +489,12 @@ const TabworthyTimes = class {
|
|
|
489
489
|
}
|
|
490
490
|
render() {
|
|
491
491
|
var _a;
|
|
492
|
-
return (h(Host, { key: '
|
|
492
|
+
return (h(Host, { key: 'eb40f4186e17019d6c0e7f59cd6c34ee65550fd8', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState, "time-only": this.timeOnly }, h("label", { key: '6d1f0deae328d66331350247da217c428910ddfb', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'd7721562f0eeb5be4f6b68ff8e1c01c4ed08fe1b', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: '1e4b4bd45f63aa5357505f58edde39739a51a124', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
493
493
|
[this.getClassName("input")]: true,
|
|
494
494
|
[this.inputClass]: !!this.inputClass
|
|
495
|
-
}, 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: '
|
|
495
|
+
}, 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: 'c5789e7d45619291c38895ba184c6ec74d73c584', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
496
496
|
? this.timesLabels.openCalendar
|
|
497
|
-
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '
|
|
497
|
+
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: 'af58b555642816b299cf50394148ed17c427db21', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
498
498
|
if (this.pickerRef) {
|
|
499
499
|
this.pickerRef.modalIsOpen = true;
|
|
500
500
|
}
|
|
@@ -508,7 +508,7 @@ const TabworthyTimes = class {
|
|
|
508
508
|
if (this.timePickerRef) {
|
|
509
509
|
this.timePickerRef.modalIsOpen = false;
|
|
510
510
|
}
|
|
511
|
-
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '
|
|
511
|
+
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '1bc48335f50777efd746a2737ac6acc60a72dec3', class: this.getClassName("picker-container") }, !this.timeOnly && (h("tabworthy-dates-calendar", { key: 'd0bdb6e18676f0019be5fd939a19075927b10fa4', 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: '042f5fa7e60b67858ea7f92ca80792953b38d0a1', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '7262873201e1294e6116fea1f429c71e37bf06c2', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '46a179fd9ce95d53e144d0b03a77311e4daa3c10', 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(), ref: (el) => (this.timePickerRef = el) })))), this.timeOnly && (h("div", { key: 'eaedaf5a7157dbdc99a947b6eb3e55f696556371', class: this.getClassName("time-section") }, h("tabworthy-times-picker", { key: '504ea7e3069134e695d09ef48834b947de629b5e', 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(), ref: (el) => (this.timePickerRef = el) }))))), this.errorState && (h("div", { key: '961823a7550b5439d2768f80317422b057758de3', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
512
512
|
}
|
|
513
513
|
get el() { return getElement(this); }
|
|
514
514
|
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,f as o}from"./p-DCgn1Avj.js";import{g as d,r as l}from"./p-CoFOnMSw.js";var c,u,f={exports:{}},m=a(c?f.exports:(c=1,f.exports=(u={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=u,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]||u[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(m);const b={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"},y=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.timeOnly=!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=b,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=l(new Date(i[0])),s=l(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=l(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.timeOnly&&this.updateValue(this.getDateForTimeOnlyValue())},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(this.inputContainerRef,this.calendarButtonRef),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=o(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=o(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}getDateForTimeOnlyValue(){if(this.selectedDate)return this.selectedDate;const t=n(this.referenceDate);return t.isValid()?t.toDate():new Date}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.internalValue=this.value||null,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.selectedDate=void 0;if(this.pickerRef)if(Array.isArray(this.value)){const t=this.value.reduce(((t,i)=>{const s=n(i,this.format,!0);return s.isValid()&&t.push(s.toDate()),t}),[]);this.pickerRef.value=t.length?t:null}else if(this.value){const t=n(this.value,this.format,!0);t.isValid()&&(this.pickerRef.value=t.toDate())}else this.pickerRef.value=null;this.inputRef&&(this.value?this.shouldInputFormat()?this.formatInput():this.inputRef.value=this.internalValue.toString():this.inputRef.value="")}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=o(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=o(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=this.timeOnly?n(this.internalValue,this.format).format(this.showSeconds?"LTS":"LT"):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:"eb40f4186e17019d6c0e7f59cd6c34ee65550fd8",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState,"time-only":this.timeOnly},s("label",{key:"6d1f0deae328d66331350247da217c428910ddfb",htmlFor:`${this.id}-input`,class:this.getClassName("label")},this.label),s("div",{key:"d7721562f0eeb5be4f6b68ff8e1c01c4ed08fe1b",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},s("input",{key:"1e4b4bd45f63aa5357505f58edde39739a51a124",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:"c5789e7d45619291c38895ba184c6ec74d73c584",type:"button",ref:t=>this.calendarButtonRef=t,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:"af58b555642816b299cf50394148ed17c427db21",label:this.timesLabels.calendar,ref:t=>this.modalRef=t,onOpened:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!0),this.timeOnly&&this.timePickerRef&&(this.timePickerRef.modalIsOpen=!0)},onClosed:()=>{this.pickerRef&&(this.pickerRef.modalIsOpen=!1),this.timePickerRef&&(this.timePickerRef.modalIsOpen=!1)},inline:this.inline,appendTo:this.appendTo},s("div",{key:"1bc48335f50777efd746a2737ac6acc60a72dec3",class:this.getClassName("picker-container")},!this.timeOnly&&s("tabworthy-dates-calendar",{key:"d0bdb6e18676f0019be5fd939a19075927b10fa4",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:"042f5fa7e60b67858ea7f92ca80792953b38d0a1",slot:"after-calendar",class:this.getClassName("time-section")},s("hr",{key:"7262873201e1294e6116fea1f429c71e37bf06c2",class:this.getClassName("divider")}),s("tabworthy-times-picker",{key:"46a179fd9ce95d53e144d0b03a77311e4daa3c10",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(),ref:t=>this.timePickerRef=t}))),this.timeOnly&&s("div",{key:"eaedaf5a7157dbdc99a947b6eb3e55f696556371",class:this.getClassName("time-section")},s("tabworthy-times-picker",{key:"504ea7e3069134e695d09ef48834b947de629b5e",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(),ref:t=>this.timePickerRef=t})))),this.errorState&&s("div",{key:"961823a7550b5439d2768f80317422b057758de3",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{y as tabworthy_times}
|