@tabworthy/components 0.12.0 → 0.12.2

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.
@@ -35,7 +35,6 @@ const defaultLabels = {
35
35
  disabledDateError: `Please choose an available date`,
36
36
  to: "to",
37
37
  startDate: "Start date",
38
- yearSelect: "Select year",
39
38
  timeLabel: "Time"
40
39
  };
41
40
  const TabworthyTimes = class {
@@ -152,6 +151,16 @@ const TabworthyTimes = class {
152
151
  };
153
152
  this.handleInputChange = (event) => {
154
153
  const value = event.target.value;
154
+ // Handle empty input
155
+ if (value.length === 0) {
156
+ this.errorState = false;
157
+ this.internalValue = "";
158
+ if (this.pickerRef) {
159
+ this.pickerRef.value = null;
160
+ }
161
+ this.value = this.internalValue;
162
+ return this.selectDateTime.emit(this.internalValue);
163
+ }
155
164
  // Try to parse the input value using the component's format first (strict mode)
156
165
  // This prevents dayjs from misinterpreting date formats (e.g., DD/MM/YYYY as MM/DD/YYYY)
157
166
  let parsed = customParseFormat.dayjs(value, this.format, true);
@@ -160,10 +169,17 @@ const TabworthyTimes = class {
160
169
  parsed = customParseFormat.dayjs(value);
161
170
  }
162
171
  if (parsed.isValid()) {
172
+ this.errorState = false;
163
173
  this.selectedHours = parsed.hour();
164
174
  this.selectedMinutes = parsed.minute();
175
+ this.selectedSeconds = parsed.second();
165
176
  this.updateValue(parsed.toDate());
166
177
  }
178
+ else {
179
+ // Set error state for invalid/garbage input
180
+ this.errorState = true;
181
+ this.errorMessage = this.timesLabels.invalidDateError;
182
+ }
167
183
  };
168
184
  }
169
185
  shouldInputFormat() {
@@ -278,10 +294,10 @@ const TabworthyTimes = class {
278
294
  }
279
295
  render() {
280
296
  var _a;
281
- return (index.h(index.Host, { key: '16801875a7a022afd2db87e489ff69133e27773d', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: 'f0aa269a9677dbda54d31ea0fa32e69f6ef19114', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: 'a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: 'dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
297
+ return (index.h(index.Host, { key: '671702979dddb6a19cfa78a95df28a958af56df9', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: '7b23263f899b3a59d43f3f2922e9c98a0bc62524', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: '453d585bee8dd0262aadec8ba816cd22c51cffea', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: 'd2ec7de2b31f3c1a6b9acb4f57341530cb8431dc', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
282
298
  [this.getClassName("input")]: true,
283
299
  [this.inputClass]: !!this.inputClass
284
- }, 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 && (index.h("button", { key: 'c072cedad6d4567b3688e434a7173441b4a11026', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: '4a4e37ff7f76d51389153b52d281fdc1a8f861d5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
300
+ }, 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 && (index.h("button", { key: '77b42f53ad8a5e0d5d70ea41f999f95d61942a83', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: '3633f9e7839b8947da48f83ac3808156bea8515d', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
285
301
  if (this.pickerRef) {
286
302
  this.pickerRef.modalIsOpen = true;
287
303
  }
@@ -289,7 +305,7 @@ const TabworthyTimes = class {
289
305
  if (this.pickerRef) {
290
306
  this.pickerRef.modalIsOpen = false;
291
307
  }
292
- }, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '9b03ffb9df5a041d802647d66af53eafec187c7f', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: '0caab550470b253542d93e29ddadcde85fe7caad', 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 }, index.h("div", { key: '655aa9bb049f76dba44f18684fec6550ab8aac22', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: 'b695207bda87835f57240f72bea88dc57470c170', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: 'f17bf595f1df723dc04d87ef86a5f5a6152b506a', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (index.h("div", { key: '8bf64ca388076cd5f1ad73b763993dbc7736b08c', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
308
+ }, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '706e2fdcd7e4ecf77f5ee63f4c5ced7951593735', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: 'cb027f3fe4d2bf73abea9ec6511fe11305e28aba', 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 }, index.h("div", { key: '2287a25cdec6fc40c36833c250536f99cabe5cbf', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (index.h("div", { key: '4a568e01f57652308adb7a8c115ab6649fc591fc', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
293
309
  }
294
310
  get el() { return index.getElement(this); }
295
311
  static get watchers() { return {
@@ -16,7 +16,6 @@ const defaultLabels = {
16
16
  disabledDateError: `Please choose an available date`,
17
17
  to: "to",
18
18
  startDate: "Start date",
19
- yearSelect: "Select year",
20
19
  timeLabel: "Time"
21
20
  };
22
21
  export class TabworthyTimes {
@@ -129,6 +128,16 @@ export class TabworthyTimes {
129
128
  };
130
129
  this.handleInputChange = (event) => {
131
130
  const value = event.target.value;
131
+ // Handle empty input
132
+ if (value.length === 0) {
133
+ this.errorState = false;
134
+ this.internalValue = "";
135
+ if (this.pickerRef) {
136
+ this.pickerRef.value = null;
137
+ }
138
+ this.value = this.internalValue;
139
+ return this.selectDateTime.emit(this.internalValue);
140
+ }
132
141
  // Try to parse the input value using the component's format first (strict mode)
133
142
  // This prevents dayjs from misinterpreting date formats (e.g., DD/MM/YYYY as MM/DD/YYYY)
134
143
  let parsed = dayjs(value, this.format, true);
@@ -137,10 +146,17 @@ export class TabworthyTimes {
137
146
  parsed = dayjs(value);
138
147
  }
139
148
  if (parsed.isValid()) {
149
+ this.errorState = false;
140
150
  this.selectedHours = parsed.hour();
141
151
  this.selectedMinutes = parsed.minute();
152
+ this.selectedSeconds = parsed.second();
142
153
  this.updateValue(parsed.toDate());
143
154
  }
155
+ else {
156
+ // Set error state for invalid/garbage input
157
+ this.errorState = true;
158
+ this.errorMessage = this.timesLabels.invalidDateError;
159
+ }
144
160
  };
145
161
  }
146
162
  shouldInputFormat() {
@@ -255,10 +271,10 @@ export class TabworthyTimes {
255
271
  }
256
272
  render() {
257
273
  var _a;
258
- return (h(Host, { key: '16801875a7a022afd2db87e489ff69133e27773d', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'f0aa269a9677dbda54d31ea0fa32e69f6ef19114', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
274
+ return (h(Host, { key: '671702979dddb6a19cfa78a95df28a958af56df9', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '7b23263f899b3a59d43f3f2922e9c98a0bc62524', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '453d585bee8dd0262aadec8ba816cd22c51cffea', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'd2ec7de2b31f3c1a6b9acb4f57341530cb8431dc', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
259
275
  [this.getClassName("input")]: true,
260
276
  [this.inputClass]: !!this.inputClass
261
- }, 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: 'c072cedad6d4567b3688e434a7173441b4a11026', type: "button", 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: '4a4e37ff7f76d51389153b52d281fdc1a8f861d5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
277
+ }, 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: '77b42f53ad8a5e0d5d70ea41f999f95d61942a83', type: "button", 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: '3633f9e7839b8947da48f83ac3808156bea8515d', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
262
278
  if (this.pickerRef) {
263
279
  this.pickerRef.modalIsOpen = true;
264
280
  }
@@ -266,7 +282,7 @@ export class TabworthyTimes {
266
282
  if (this.pickerRef) {
267
283
  this.pickerRef.modalIsOpen = false;
268
284
  }
269
- }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '9b03ffb9df5a041d802647d66af53eafec187c7f', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '0caab550470b253542d93e29ddadcde85fe7caad', 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 }, h("div", { key: '655aa9bb049f76dba44f18684fec6550ab8aac22', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: 'b695207bda87835f57240f72bea88dc57470c170', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'f17bf595f1df723dc04d87ef86a5f5a6152b506a', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '8bf64ca388076cd5f1ad73b763993dbc7736b08c', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
285
+ }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '706e2fdcd7e4ecf77f5ee63f4c5ced7951593735', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'cb027f3fe4d2bf73abea9ec6511fe11305e28aba', 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 }, h("div", { key: '2287a25cdec6fc40c36833c250536f99cabe5cbf', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '4a568e01f57652308adb7a8c115ab6649fc591fc', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
270
286
  }
271
287
  static get is() { return "tabworthy-times"; }
272
288
  static get encapsulation() { return "scoped"; }
@@ -1 +1 @@
1
- import{p as t,H as s,c as e,h as i,d as a,t as h}from"./p-BiJ0HZVY.js";import{g as r,d as o,c as n}from"./p-DkyM-7xr.js";import{g as d,r as l,c}from"./p-M03P4DAz.js";import{d as u}from"./p-CMIEIvTW.js";import{d as b}from"./p-BTQaxOHo.js";var f,m={exports:{}},p=r(f?m.exports:(f=1,m.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 a=e.prototype,h=a.format;i.en.formats=t,a.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,a){var h=a&&a.toUpperCase();return i||e[a]||t[a]||e[h].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,e){return s||e.slice(1)}))}))}(s,void 0===e?{}:e);return h.call(this,i)}}}()));o.extend(n),o.extend(p);const w={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",yearSelect:"Select year",timeLabel:"Time"},y=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=d(new Date),this.referenceDate=d(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=w,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]));this.updateValue([t,e]),this.pickerRef&&(this.pickerRef.value=[t,e])}else{const t=l(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,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;let e=o(s,this.format,!0);e.isValid()||(e=o(s)),e.isValid()&&(this.selectedHours=e.hour(),this.selectedMinutes=e.minute(),this.updateValue(e.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=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()}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(a,{key:"16801875a7a022afd2db87e489ff69133e27773d",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"f0aa269a9677dbda54d31ea0fa32e69f6ef19114",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),i("div",{key:"a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},i("input",{key:"dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2",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:"c072cedad6d4567b3688e434a7173441b4a11026",type:"button",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:"4a4e37ff7f76d51389153b52d281fdc1a8f861d5",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:"9b03ffb9df5a041d802647d66af53eafec187c7f",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"0caab550470b253542d93e29ddadcde85fe7caad",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},i("div",{key:"655aa9bb049f76dba44f18684fec6550ab8aac22",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"b695207bda87835f57240f72bea88dc57470c170",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"f17bf595f1df723dc04d87ef86a5f5a6152b506a",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState,onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels}))))),this.errorState&&i("div",{key:"8bf64ca388076cd5f1ad73b763993dbc7736b08c",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"],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}]}]),D=y,v=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),y);break;case"tabworthy-dates-calendar":customElements.get(h(t))||c();break;case"tabworthy-dates-modal":customElements.get(h(t))||u();break;case"tabworthy-times-picker":customElements.get(h(t))||b()}}))};export{D as TabworthyTimes,v as defineCustomElement}
1
+ import{p as t,H as s,c as e,h as i,d as a,t as h}from"./p-BiJ0HZVY.js";import{g as r,d as o,c as n}from"./p-DkyM-7xr.js";import{g as d,r as l,c}from"./p-M03P4DAz.js";import{d as u}from"./p-CMIEIvTW.js";import{d as f}from"./p-BTQaxOHo.js";var m,b={exports:{}},p=r(m?b.exports:(m=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 a=e.prototype,h=a.format;i.en.formats=t,a.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,a){var h=a&&a.toUpperCase();return i||e[a]||t[a]||e[h].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,e){return s||e.slice(1)}))}))}(s,void 0===e?{}:e);return h.call(this,i)}}}()));o.extend(n),o.extend(p);const w={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=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=d(new Date),this.referenceDate=d(new Date),this.useTwelveHourFormat=!0,this.showSeconds=!1,this.timesLabels=w,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]));this.updateValue([t,e]),this.pickerRef&&(this.pickerRef.value=[t,e])}else{const t=l(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,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);e.isValid()||(e=o(s)),e.isValid()?(this.errorState=!1,this.selectedHours=e.hour(),this.selectedMinutes=e.minute(),this.selectedSeconds=e.second(),this.updateValue(e.toDate())):(this.errorState=!0,this.errorMessage=this.timesLabels.invalidDateError)}}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()}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(a,{key:"671702979dddb6a19cfa78a95df28a958af56df9",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"7b23263f899b3a59d43f3f2922e9c98a0bc62524",htmlFor:this.id+"-input",class:this.getClassName("label")},this.label),i("div",{key:"453d585bee8dd0262aadec8ba816cd22c51cffea",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},i("input",{key:"d2ec7de2b31f3c1a6b9acb4f57341530cb8431dc",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:"77b42f53ad8a5e0d5d70ea41f999f95d61942a83",type:"button",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:"3633f9e7839b8947da48f83ac3808156bea8515d",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:"706e2fdcd7e4ecf77f5ee63f4c5ced7951593735",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"cb027f3fe4d2bf73abea9ec6511fe11305e28aba",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},i("div",{key:"2287a25cdec6fc40c36833c250536f99cabe5cbf",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState,onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels}))))),this.errorState&&i("div",{key:"4a568e01f57652308adb7a8c115ab6649fc591fc",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"],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}]}]),D=y,v=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),y);break;case"tabworthy-dates-calendar":customElements.get(h(t))||c();break;case"tabworthy-dates-modal":customElements.get(h(t))||u();break;case"tabworthy-times-picker":customElements.get(h(t))||f()}}))};export{D as TabworthyTimes,v as defineCustomElement}
@@ -33,7 +33,6 @@ const defaultLabels = {
33
33
  disabledDateError: `Please choose an available date`,
34
34
  to: "to",
35
35
  startDate: "Start date",
36
- yearSelect: "Select year",
37
36
  timeLabel: "Time"
38
37
  };
39
38
  const TabworthyTimes = class {
@@ -150,6 +149,16 @@ const TabworthyTimes = class {
150
149
  };
151
150
  this.handleInputChange = (event) => {
152
151
  const value = event.target.value;
152
+ // Handle empty input
153
+ if (value.length === 0) {
154
+ this.errorState = false;
155
+ this.internalValue = "";
156
+ if (this.pickerRef) {
157
+ this.pickerRef.value = null;
158
+ }
159
+ this.value = this.internalValue;
160
+ return this.selectDateTime.emit(this.internalValue);
161
+ }
153
162
  // Try to parse the input value using the component's format first (strict mode)
154
163
  // This prevents dayjs from misinterpreting date formats (e.g., DD/MM/YYYY as MM/DD/YYYY)
155
164
  let parsed = dayjs(value, this.format, true);
@@ -158,10 +167,17 @@ const TabworthyTimes = class {
158
167
  parsed = dayjs(value);
159
168
  }
160
169
  if (parsed.isValid()) {
170
+ this.errorState = false;
161
171
  this.selectedHours = parsed.hour();
162
172
  this.selectedMinutes = parsed.minute();
173
+ this.selectedSeconds = parsed.second();
163
174
  this.updateValue(parsed.toDate());
164
175
  }
176
+ else {
177
+ // Set error state for invalid/garbage input
178
+ this.errorState = true;
179
+ this.errorMessage = this.timesLabels.invalidDateError;
180
+ }
165
181
  };
166
182
  }
167
183
  shouldInputFormat() {
@@ -276,10 +292,10 @@ const TabworthyTimes = class {
276
292
  }
277
293
  render() {
278
294
  var _a;
279
- return (h(Host, { key: '16801875a7a022afd2db87e489ff69133e27773d', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'f0aa269a9677dbda54d31ea0fa32e69f6ef19114', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
295
+ return (h(Host, { key: '671702979dddb6a19cfa78a95df28a958af56df9', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '7b23263f899b3a59d43f3f2922e9c98a0bc62524', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '453d585bee8dd0262aadec8ba816cd22c51cffea', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'd2ec7de2b31f3c1a6b9acb4f57341530cb8431dc', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
280
296
  [this.getClassName("input")]: true,
281
297
  [this.inputClass]: !!this.inputClass
282
- }, 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: 'c072cedad6d4567b3688e434a7173441b4a11026', type: "button", 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: '4a4e37ff7f76d51389153b52d281fdc1a8f861d5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
298
+ }, 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: '77b42f53ad8a5e0d5d70ea41f999f95d61942a83', type: "button", 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: '3633f9e7839b8947da48f83ac3808156bea8515d', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
283
299
  if (this.pickerRef) {
284
300
  this.pickerRef.modalIsOpen = true;
285
301
  }
@@ -287,7 +303,7 @@ const TabworthyTimes = class {
287
303
  if (this.pickerRef) {
288
304
  this.pickerRef.modalIsOpen = false;
289
305
  }
290
- }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '9b03ffb9df5a041d802647d66af53eafec187c7f', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '0caab550470b253542d93e29ddadcde85fe7caad', 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 }, h("div", { key: '655aa9bb049f76dba44f18684fec6550ab8aac22', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: 'b695207bda87835f57240f72bea88dc57470c170', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'f17bf595f1df723dc04d87ef86a5f5a6152b506a', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '8bf64ca388076cd5f1ad73b763993dbc7736b08c', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
306
+ }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '706e2fdcd7e4ecf77f5ee63f4c5ced7951593735', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'cb027f3fe4d2bf73abea9ec6511fe11305e28aba', 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 }, h("div", { key: '2287a25cdec6fc40c36833c250536f99cabe5cbf', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '4a568e01f57652308adb7a8c115ab6649fc591fc', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
291
307
  }
292
308
  get el() { return getElement(this); }
293
309
  static get watchers() { return {
@@ -0,0 +1 @@
1
+ import{r as t,c as s,h as i,H as h,g as e}from"./p-CwtZ_Lud.js";import{g as a,d as r,c as n}from"./p-DkyM-7xr.js";import{g as o,r as d}from"./p-BVHu5CWV.js";var l,c,f={exports:{}},u=a(l?f.exports:(l=1,f.exports=(c={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,s,i){var h=s.prototype,e=h.format;i.en.formats=c,h.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var s=this.$locale().formats,i=function(t,s){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,i,h){var e=h&&h.toUpperCase();return i||s[h]||c[h]||s[e].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,i){return s||i.slice(1)}))}))}(t,void 0===s?{}:s);return e.call(this,i)}})));r.extend(n),r.extend(u);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"},m=class{constructor(i){t(this,i),this.selectDateTime=s(this,"selectDateTime",7),this.changeYear=s(this,"changeYear",7),this.componentReady=s(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=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 s=t.split(",");if(this.range&&2===s.length){const t=d(new Date(s[0])),i=d(new Date(s[1]));this.updateValue([t,i]),this.pickerRef&&(this.pickerRef.value=[t,i])}else{const t=d(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,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=r(s,this.format,!0);i.isValid()||(i=r(s)),i.isValid()?(this.errorState=!1,this.selectedHours=i.hour(),this.selectedMinutes=i.minute(),this.selectedSeconds=i.second(),this.updateValue(i.toDate())):(this.errorState=!0,this.errorMessage=this.timesLabels.invalidDateError)}}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.hour(),this.selectedMinutes=s.minute(),this.selectedSeconds=s.second())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const s=t.map((t=>r(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=r(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()}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&&(this.inputRef.value=""),this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return i(h,{key:"671702979dddb6a19cfa78a95df28a958af56df9",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"7b23263f899b3a59d43f3f2922e9c98a0bc62524",htmlFor:`${this.id}-input`,class:this.getClassName("label")},this.label),i("div",{key:"453d585bee8dd0262aadec8ba816cd22c51cffea",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},i("input",{key:"d2ec7de2b31f3c1a6b9acb4f57341530cb8431dc",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&&i("button",{key:"77b42f53ad8a5e0d5d70ea41f999f95d61942a83",type:"button",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:"3633f9e7839b8947da48f83ac3808156bea8515d",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:"706e2fdcd7e4ecf77f5ee63f4c5ced7951593735",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"cb027f3fe4d2bf73abea9ec6511fe11305e28aba",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},i("div",{key:"2287a25cdec6fc40c36833c250536f99cabe5cbf",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState,onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels}))))),this.errorState&&i("div",{key:"4a568e01f57652308adb7a8c115ab6649fc591fc",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{m as tabworthy_times}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-CwtZ_Lud.js";export{s as setNonce}from"./p-CwtZ_Lud.js";import{g as a}from"./p-DQuL1Twl.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((async e=>(await a(),t([["p-1743bf7a",[[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"],internalHours:[32],internalMinutes:[32],internalSeconds:[32],period:[32]},null,{hours:[{watchHours:0}],minutes:[{watchMinutes:0}],seconds:[{watchSeconds:0}]}]]],["p-df93e5d4",[[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}]}]]],["p-bc07c40b",[[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"],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}]}]]],["p-744ffef9",[[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"],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"],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}]}]]]],e))));
1
+ import{p as e,b as t}from"./p-CwtZ_Lud.js";export{s as setNonce}from"./p-CwtZ_Lud.js";import{g as a}from"./p-DQuL1Twl.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((async e=>(await a(),t([["p-1743bf7a",[[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"],internalHours:[32],internalMinutes:[32],internalSeconds:[32],period:[32]},null,{hours:[{watchHours:0}],minutes:[{watchMinutes:0}],seconds:[{watchSeconds:0}]}]]],["p-df93e5d4",[[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}]}]]],["p-04240a8d",[[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"],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}]}]]],["p-744ffef9",[[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"],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"],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}]}]]]],e))));
@@ -2,7 +2,7 @@ import { EventEmitter } from "../../stencil-public-runtime";
2
2
  import { TimesPickerLabels } from "../tabworthy-times-picker/tabworthy-times-picker";
3
3
  import { DatesLabels } from "../tabworthy-dates/tabworthy-dates";
4
4
  import { DatesCalendarLabels, YearChangedEventDetails } from "../tabworthy-dates-calendar/tabworthy-dates-calendar";
5
- export interface TimesLabels extends Omit<DatesLabels, "quickSelection"> {
5
+ export interface TimesLabels extends Omit<DatesLabels, "quickSelection" | "yearSelect"> {
6
6
  timeLabel: string;
7
7
  }
8
8
  export declare class TabworthyTimes {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabworthy/components",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Small, accessible datepicker and datetimepicker Web Components with natural language date input.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- import{r as t,c as s,h as i,H as e,g as h}from"./p-CwtZ_Lud.js";import{g as a,d as r,c as d}from"./p-DkyM-7xr.js";import{g as n,r as o}from"./p-BVHu5CWV.js";var l,c,f={exports:{}},u=a(l?f.exports:(l=1,f.exports=(c={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,s,i){var e=s.prototype,h=e.format;i.en.formats=c,e.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var s=this.$locale().formats,i=function(t,s){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,i,e){var h=e&&e.toUpperCase();return i||s[e]||c[e]||s[h].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,s,i){return s||i.slice(1)}))}))}(t,void 0===s?{}:s);return h.call(this,i)}})));r.extend(d),r.extend(u);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",yearSelect:"Select year",timeLabel:"Time"},m=class{constructor(i){t(this,i),this.selectDateTime=s(this,"selectDateTime",7),this.changeYear=s(this,"changeYear",7),this.componentReady=s(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=n(new Date),this.referenceDate=n(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 s=t.split(",");if(this.range&&2===s.length){const t=o(new Date(s[0])),i=o(new Date(s[1]));this.updateValue([t,i]),this.pickerRef&&(this.pickerRef.value=[t,i])}else{const t=o(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,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;let i=r(s,this.format,!0);i.isValid()||(i=r(s)),i.isValid()&&(this.selectedHours=i.hour(),this.selectedMinutes=i.minute(),this.updateValue(i.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.hour(),this.selectedMinutes=s.minute(),this.selectedSeconds=s.second())}}else this.internalValue=null}updateValue(t){if(Array.isArray(t)){const s=t.map((t=>r(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=r(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()}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&&(this.inputRef.value=""),this.pickerRef&&(this.pickerRef.value=null),this.selectDateTime.emit(void 0)}render(){var t;return i(e,{key:"16801875a7a022afd2db87e489ff69133e27773d",class:this.elementClassName,"has-error":this.errorState,disabled:this.disabledState},i("label",{key:"f0aa269a9677dbda54d31ea0fa32e69f6ef19114",htmlFor:`${this.id}-input`,class:this.getClassName("label")},this.label),i("div",{key:"a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c",class:this.getClassName("input-container"),ref:t=>this.inputContainerRef=t},i("input",{key:"dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2",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&&i("button",{key:"c072cedad6d4567b3688e434a7173441b4a11026",type:"button",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:"4a4e37ff7f76d51389153b52d281fdc1a8f861d5",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:"9b03ffb9df5a041d802647d66af53eafec187c7f",class:this.getClassName("picker-container")},i("tabworthy-dates-calendar",{key:"0caab550470b253542d93e29ddadcde85fe7caad",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},i("div",{key:"655aa9bb049f76dba44f18684fec6550ab8aac22",slot:"after-calendar",class:this.getClassName("time-section")},i("hr",{key:"b695207bda87835f57240f72bea88dc57470c170",class:this.getClassName("divider")}),i("tabworthy-times-picker",{key:"f17bf595f1df723dc04d87ef86a5f5a6152b506a",hours:this.selectedHours,minutes:this.selectedMinutes,seconds:this.selectedSeconds,showSeconds:this.showSeconds,useTwelveHourFormat:this.useTwelveHourFormat,disabled:this.disabledState,onTimeChanged:this.handleTimeChange,labels:this.timesPickerLabels}))))),this.errorState&&i("div",{key:"8bf64ca388076cd5f1ad73b763993dbc7736b08c",class:this.getClassName("input-error"),id:this.id?`${this.id}-error`:void 0,role:"status"},this.errorMessage))}get el(){return h(this)}static get watchers(){return{value:[{watchValue:0}],disabled:[{watchDisabled:0}],hasError:[{watchHasError:0}]}}};export{m as tabworthy_times}