@tabworthy/components 0.8.5 → 0.8.6
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/tabworthy-dates.cjs.entry.js +6 -6
- package/dist/cjs/tabworthy-times.cjs.entry.js +11 -3
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +7 -7
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +11 -3
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/tabworthy-dates.entry.js +6 -6
- package/dist/esm/tabworthy-times.entry.js +11 -3
- package/dist/tabworthy-components/{p-4de237aa.entry.js → p-224503da.entry.js} +1 -1
- package/dist/tabworthy-components/p-dcb3ea8d.entry.js +1 -0
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/dist/themes/light.css +1 -1
- package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +1 -0
- package/dist/types/components.d.ts +2 -2
- package/package.json +8 -6
- package/dist/tabworthy-components/p-141bd515.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as s,c as e,h as i,d as a,t as h}from"./p-Kr35QPhi.js";import{h as r}from"./p-Mki5YqAR.js";import{g as o,r as
|
|
1
|
+
import{p as t,H as s,c as e,h as i,d as a,t as h}from"./p-Kr35QPhi.js";import{h as r}from"./p-Mki5YqAR.js";import{g as o,r as n,c as d}from"./p-DT8TK_a8.js";import{d as l}from"./p-CGobNAdR.js";import{d as c}from"./p-Bnmroodq.js";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"},u=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectDateTime=e(this,"selectDateTime",7),this.changeYear=e(this,"changeYear",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=o(new Date),this.referenceDate=o(new Date),this.useTwelveHourFormat=!0,this.timesLabels=b,this.inline=!1,this.hasError=!1,this.showYearStepper=!1,this.showMonthStepper=!0,this.showClearButton=!0,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=12,this.selectedMinutes=0,this.errorState=this.hasError,this.disabledState=this.disabled,this.errorMessage="",this.handlePickerSelection=async t=>{const s=t.split(",");if(this.range&&2===s.length){const t=n(new Date(s[0])),e=n(new Date(s[1]));this.updateValue([t,e]),this.pickerRef&&(this.pickerRef.value=[t,e])}else{const t=n(new Date(s[0]));this.updateValue(t),this.pickerRef&&(this.pickerRef.value=t)}},this.handleTimeChange=t=>{this.selectedHours=t.detail.hours,this.selectedMinutes=t.detail.minutes,this.selectedDate&&this.updateValue(this.selectedDate)},this.handleCalendarButtonClick=async()=>{this.modalRef&&(await this.modalRef.setTriggerElement(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=r(t.target.value);s.isValid()&&(this.selectedHours=s.hours(),this.selectedMinutes=s.minutes(),this.updateValue(s.toDate()))}}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=r(t,this.format);s.isValid()&&(this.selectedDate=s.toDate(),this.selectedHours=s.hours(),this.selectedMinutes=s.minutes())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const s=t.map((t=>{const s=r(t);return s.hours(this.selectedHours),s.minutes(this.selectedMinutes),s.seconds(0),s.format(this.format)}));this.internalValue=s,this.value=s,this.selectDateTime.emit(s)}else{const s=r(t);s.hours(this.selectedHours),s.minutes(this.selectedMinutes),s.seconds(0);const e=s.format(this.format);this.internalValue=e,this.value=e,this.selectedDate=t,this.selectDateTime.emit(e)}this.errorState=!1,this.shouldInputFormat()&&this.formatInput()}formatInput(){if(this.internalValue)if(Array.isArray(this.internalValue)){const t=this.internalValue.map((t=>r(t,this.format).format("lll"))).join(` ${this.timesLabels.to} `);this.inputRef.value=t}else this.inputRef.value=r(this.internalValue,this.format).format("lll")}getClassName(t){return`${this.elementClassName}__${t}`}toDate(t){return t?Array.isArray(t)?t.map((t=>r(t,this.format).toDate())):r(t,this.format).toDate():null}async clearValue(){this.internalValue=null,this.value=void 0,this.selectedDate=void 0,this.inputRef.value="",this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return i(a,{key:"82b7e3ac499f9b8bea87955bfe55bbe645aa9d5a",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"19a9a6cf34bccd49e6d079a4d9d7d5f3e527f1c7",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),i("div",{key:"20a4dae28141bb9d3d124653df0f8f3a152a2ee8",class:this.getClassName("input-container")},i("input",{key:"64779c1b8d59ecff3c9ddcbe0e67025e9bcbd325",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:"503fb34dfa3b5328c1dfae06647601729d0c634d",type:"button",ref:t=>this.calendarButtonRef=t,onClick:this.handleCalendarButtonClick,class:this.getClassName("calendar-button"),disabled:this.disabledState},this.calendarButtonContent?i("span",{innerHTML:this.calendarButtonContent}):this.timesLabels.openCalendar)),i("tabworthy-dates-modal",{key:"915841d3053aae0e856b19ae24dafc8870c3d746",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},i("div",{key:"b7ead351553fa42af52be2ab8e461b49d6f63b56",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"9397be905159540b8645428d7624c4c6f2dd5133",range:this.range,locale:this.locale,onSelectDate:t=>this.handlePickerSelection(t.detail),onChangeMonth:t=>this.handleChangedMonths(t.detail),onChangeYear:t=>this.handleYearChange(t.detail),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,showTodayButton:this.showTodayButton,disableDate:this.disableDate,minDate:this.minDate,maxDate:this.maxDate,inline:this.inline,value:this.value?this.toDate(this.value):void 0},i("div",{key:"6aa58750a3a13fc3e1ddadee0a9c4631220bb399",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"17943c66cef11e8a4335cb0c0711d5ae327076e9",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"f356db7d523202ee5a72089cf57cf072787c32ee",hours:this.selectedHours,minutes:this.selectedMinutes,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState,onTimeChanged:this.handleTimeChange}))))),this.errorState&&i("div",{key:"db47877aa13a91f6441dfd371cc7da70375aa1ea",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"],timesLabels:[16],datesCalendarLabels:[16],inline:[4],hasError:[1028,"has-error"],showYearStepper:[4,"show-year-stepper"],showMonthStepper:[4,"show-month-stepper"],showClearButton:[4,"show-clear-button"],showTodayButton:[4,"show-today-button"],calendarButtonContent:[1,"calendar-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"],internalValue:[32],selectedDate:[32],selectedHours:[32],selectedMinutes:[32],errorState:[32],disabledState:[32],clearValue:[64]},void 0,{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}]),m=u,f=function(){"undefined"!=typeof customElements&&["tabworthy-times","tabworthy-dates-calendar","tabworthy-dates-modal","tabworthy-times-picker"].forEach((t=>{switch(t){case"tabworthy-times":customElements.get(h(t))||customElements.define(h(t),u);break;case"tabworthy-dates-calendar":customElements.get(h(t))||d();break;case"tabworthy-dates-modal":customElements.get(h(t))||l();break;case"tabworthy-times-picker":customElements.get(h(t))||c()}}))};export{m as TabworthyTimes,f as defineCustomElement}
|
|
@@ -10497,7 +10497,7 @@ const TabworthyDates = class {
|
|
|
10497
10497
|
// A placeholder for the text field
|
|
10498
10498
|
this.placeholder = this.range
|
|
10499
10499
|
? `Try "June 8 to 12"`
|
|
10500
|
-
: `Try "
|
|
10500
|
+
: `Try "tomorrow" or "in ten days"`;
|
|
10501
10501
|
// Locale used for internal translations and date parsing
|
|
10502
10502
|
this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
|
|
10503
10503
|
// If the datepicker is disabled
|
|
@@ -10908,10 +10908,10 @@ const TabworthyDates = class {
|
|
|
10908
10908
|
}
|
|
10909
10909
|
render() {
|
|
10910
10910
|
var _a;
|
|
10911
|
-
return (h(Host, { key: '
|
|
10911
|
+
return (h(Host, { key: 'e88b264159dd97824a678fd47e735daa7d6e7937' }, h("label", { key: 'bd130dbe90559f0f02760c0cd98069121208ead8', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: 'e32218a5fd45461d589d10f7ed24b4512475f5e7' }), h("div", { key: '6a17c542843f1cbe42a17a6c437422773f17da5c', class: this.getClassName("input-container") }, h("input", { key: '72688ef25cd185f1c64e385602af5ac758eef488', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
|
|
10912
10912
|
[this.getClassName("input")]: true,
|
|
10913
10913
|
[this.inputClass]: !!this.inputClass
|
|
10914
|
-
}, 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", { key: '
|
|
10914
|
+
}, 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", { key: '89acd9aa82cb8c10b7f73e351620babfc13bc96f', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '3a853a44a3637007547aba3f55d41f8c4f4ce363', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
10915
10915
|
if (!this.pickerRef)
|
|
10916
10916
|
return;
|
|
10917
10917
|
this.pickerRef.modalIsOpen = true;
|
|
@@ -10919,11 +10919,11 @@ const TabworthyDates = class {
|
|
|
10919
10919
|
if (!this.pickerRef)
|
|
10920
10920
|
return;
|
|
10921
10921
|
this.pickerRef.modalIsOpen = false;
|
|
10922
|
-
}, inline: this.inline }, h("tabworthy-dates-calendar", { key: '
|
|
10922
|
+
}, inline: this.inline }, h("tabworthy-dates-calendar", { key: '12900a935aebd37116e805a0528966ab3bbff699', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), labels: this.datesCalendarLabels ? this.datesCalendarLabels : undefined, 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, showKeyboardHint: this.showKeyboardHint, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline })), this.showQuickButtons &&
|
|
10923
10923
|
((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
10924
|
-
this.chronoSupportedLocale && (h("div", { key: '
|
|
10924
|
+
this.chronoSupportedLocale && (h("div", { key: 'db492a4c33d882a7f056dd66d669cd639894a714', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
|
|
10925
10925
|
return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
|
|
10926
|
-
}))), this.errorState && (h("div", { key: '
|
|
10926
|
+
}))), this.errorState && (h("div", { key: '8a4a4d89be39da4438beda996b2f1f3b785d9010', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
10927
10927
|
}
|
|
10928
10928
|
get el() { return getElement(this); }
|
|
10929
10929
|
static get watchers() { return {
|
|
@@ -215,6 +215,14 @@ const InclusiveTimes = class {
|
|
|
215
215
|
getClassName(suffix) {
|
|
216
216
|
return `${this.elementClassName}__${suffix}`;
|
|
217
217
|
}
|
|
218
|
+
toDate(dateString) {
|
|
219
|
+
if (!dateString)
|
|
220
|
+
return null;
|
|
221
|
+
const date = Array.isArray(dateString)
|
|
222
|
+
? dateString.map((d) => hooks(d, this.format).toDate())
|
|
223
|
+
: hooks(dateString, this.format).toDate();
|
|
224
|
+
return date;
|
|
225
|
+
}
|
|
218
226
|
async clearValue() {
|
|
219
227
|
this.internalValue = null;
|
|
220
228
|
this.value = undefined;
|
|
@@ -227,10 +235,10 @@ const InclusiveTimes = class {
|
|
|
227
235
|
}
|
|
228
236
|
render() {
|
|
229
237
|
var _a;
|
|
230
|
-
return (h(Host, { key: '
|
|
238
|
+
return (h(Host, { key: '82b7e3ac499f9b8bea87955bfe55bbe645aa9d5a', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '19a9a6cf34bccd49e6d079a4d9d7d5f3e527f1c7', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '20a4dae28141bb9d3d124653df0f8f3a152a2ee8', class: this.getClassName("input-container") }, h("input", { key: '64779c1b8d59ecff3c9ddcbe0e67025e9bcbd325', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
231
239
|
[this.getClassName("input")]: true,
|
|
232
240
|
[this.inputClass]: !!this.inputClass
|
|
233
|
-
}, 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: '
|
|
241
|
+
}, 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: '503fb34dfa3b5328c1dfae06647601729d0c634d', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '915841d3053aae0e856b19ae24dafc8870c3d746', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
234
242
|
if (this.pickerRef) {
|
|
235
243
|
this.pickerRef.modalIsOpen = true;
|
|
236
244
|
}
|
|
@@ -238,7 +246,7 @@ const InclusiveTimes = class {
|
|
|
238
246
|
if (this.pickerRef) {
|
|
239
247
|
this.pickerRef.modalIsOpen = false;
|
|
240
248
|
}
|
|
241
|
-
}, inline: this.inline }, h("div", { key: '
|
|
249
|
+
}, inline: this.inline }, h("div", { key: 'b7ead351553fa42af52be2ab8e461b49d6f63b56', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '9397be905159540b8645428d7624c4c6f2dd5133', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), 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, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline, value: this.value ? this.toDate(this.value) : undefined }, h("div", { key: '6aa58750a3a13fc3e1ddadee0a9c4631220bb399', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '17943c66cef11e8a4335cb0c0711d5ae327076e9', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'f356db7d523202ee5a72089cf57cf072787c32ee', hours: this.selectedHours, minutes: this.selectedMinutes, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (h("div", { key: 'db47877aa13a91f6441dfd371cc7da70375aa1ea', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
242
250
|
}
|
|
243
251
|
get el() { return getElement(this); }
|
|
244
252
|
static get watchers() { return {
|