@tabworthy/components 0.8.4 → 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.
@@ -10499,7 +10499,7 @@ const TabworthyDates = class {
10499
10499
  // A placeholder for the text field
10500
10500
  this.placeholder = this.range
10501
10501
  ? `Try "June 8 to 12"`
10502
- : `Try "tomorrrow" or "in ten days"`;
10502
+ : `Try "tomorrow" or "in ten days"`;
10503
10503
  // Locale used for internal translations and date parsing
10504
10504
  this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
10505
10505
  // If the datepicker is disabled
@@ -10605,6 +10605,7 @@ const TabworthyDates = class {
10605
10605
  if (this.pickerRef) {
10606
10606
  this.pickerRef.value = null;
10607
10607
  }
10608
+ this.value = this.internalValue;
10608
10609
  return this.selectDate.emit(this.internalValue);
10609
10610
  }
10610
10611
  const parsedRange = await chronoParseRange(value, {
@@ -10639,6 +10640,7 @@ const TabworthyDates = class {
10639
10640
  if (this.pickerRef) {
10640
10641
  this.pickerRef.value = null;
10641
10642
  }
10643
+ this.value = this.internalValue;
10642
10644
  return this.selectDate.emit(this.internalValue);
10643
10645
  }
10644
10646
  const parsedDate = await chronoParseDate(value, {
@@ -10706,7 +10708,7 @@ const TabworthyDates = class {
10706
10708
  return !!this.inputShouldFormat;
10707
10709
  }
10708
10710
  componentDidLoad() {
10709
- this.syncFromValueProp();
10711
+ this.syncFromValueProp(this.value);
10710
10712
  this.componentReady.emit();
10711
10713
  if (!this.id) {
10712
10714
  console.error('tabworthy-dates: The "id" prop is required for accessibility');
@@ -10751,6 +10753,7 @@ const TabworthyDates = class {
10751
10753
  this.pickerRef.value = newValue;
10752
10754
  }
10753
10755
  this.errorState = false;
10756
+ this.value = this.internalValue;
10754
10757
  this.selectDate.emit(this.internalValue);
10755
10758
  this.announceDateChange(this.internalValue);
10756
10759
  }
@@ -10826,6 +10829,7 @@ const TabworthyDates = class {
10826
10829
  }
10827
10830
  this.announceDateChange(this.internalValue);
10828
10831
  }
10832
+ this.value = this.internalValue;
10829
10833
  this.selectDate.emit(this.internalValue);
10830
10834
  }
10831
10835
  announceDateChange(newValue) {
@@ -10871,10 +10875,7 @@ const TabworthyDates = class {
10871
10875
  ? `${this.elementClassName}__${element}`
10872
10876
  : this.elementClassName;
10873
10877
  }
10874
- syncFromValueProp(value = this.value) {
10875
- if (!value)
10876
- return;
10877
- // store
10878
+ syncFromValueProp(value) {
10878
10879
  this.internalValue = value;
10879
10880
  // update calendar (expects Date or Date[])
10880
10881
  if (this.pickerRef) {
@@ -10888,23 +10889,31 @@ const TabworthyDates = class {
10888
10889
  this.pickerRef.value = dates.length ? dates : null;
10889
10890
  }
10890
10891
  else {
10891
- const parsedDate = moment.hooks(this.value, this.format, true);
10892
- if (parsedDate.isValid()) {
10893
- this.pickerRef.value = parsedDate.toDate();
10892
+ if (value) {
10893
+ const parsedDate = moment.hooks(value, this.format, true);
10894
+ if (parsedDate.isValid()) {
10895
+ this.pickerRef.value = parsedDate.toDate();
10896
+ }
10897
+ }
10898
+ else {
10899
+ this.pickerRef.value = null;
10894
10900
  }
10895
10901
  }
10896
10902
  }
10903
+ if (!value) {
10904
+ this.inputRef.value = "";
10905
+ }
10897
10906
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
10898
- if (this.inputRef) {
10907
+ if (this.inputRef && value) {
10899
10908
  this.formatInput(!!this.shouldInputFormat(), false);
10900
10909
  }
10901
10910
  }
10902
10911
  render() {
10903
10912
  var _a;
10904
- return (index$1.h(index$1.Host, { key: '16c9966e45f0084e805bb11cb1292a47869a2626' }, index$1.h("label", { key: '69d95cfdf481252fb684b8d071af97b26a10f466', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: '0b5c2fff7c26dbfe40d75f8f488ccf39e89b1ca3' }), index$1.h("div", { key: 'ecda94423965415e62da7a973ecf4b197104296f', class: this.getClassName("input-container") }, index$1.h("input", { key: '5c0e5276b82e69d68ebf14983918318fa2c33162', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
10913
+ return (index$1.h(index$1.Host, { key: 'e88b264159dd97824a678fd47e735daa7d6e7937' }, index$1.h("label", { key: 'bd130dbe90559f0f02760c0cd98069121208ead8', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: 'e32218a5fd45461d589d10f7ed24b4512475f5e7' }), index$1.h("div", { key: '6a17c542843f1cbe42a17a6c437422773f17da5c', class: this.getClassName("input-container") }, index$1.h("input", { key: '72688ef25cd185f1c64e385602af5ac758eef488', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
10905
10914
  [this.getClassName("input")]: true,
10906
10915
  [this.inputClass]: !!this.inputClass
10907
- }, 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 && (index$1.h("button", { key: 'b8652ae391a12962aac5eb620ecddf23fed9a47b', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index$1.h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), index$1.h("tabworthy-dates-modal", { key: '358993a42e0401f33f2bc602f83241c53a0f7ef9', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
10916
+ }, 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 && (index$1.h("button", { key: '89acd9aa82cb8c10b7f73e351620babfc13bc96f', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index$1.h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), index$1.h("tabworthy-dates-modal", { key: '3a853a44a3637007547aba3f55d41f8c4f4ce363', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
10908
10917
  if (!this.pickerRef)
10909
10918
  return;
10910
10919
  this.pickerRef.modalIsOpen = true;
@@ -10912,11 +10921,11 @@ const TabworthyDates = class {
10912
10921
  if (!this.pickerRef)
10913
10922
  return;
10914
10923
  this.pickerRef.modalIsOpen = false;
10915
- }, inline: this.inline }, index$1.h("tabworthy-dates-calendar", { key: 'a9a1376d1d0a0f8213d8be3426d333257cc60be7', 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 &&
10924
+ }, inline: this.inline }, index$1.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 &&
10916
10925
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
10917
- this.chronoSupportedLocale && (index$1.h("div", { key: '3130ee18874ab44cb4de0b9c47289ea4de4f51b8', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10926
+ this.chronoSupportedLocale && (index$1.h("div", { key: 'db492a4c33d882a7f056dd66d669cd639894a714', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10918
10927
  return (index$1.h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
10919
- }))), this.errorState && (index$1.h("div", { key: '62a9c3115a69430c8a6b1f646612c250c527449b', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10928
+ }))), this.errorState && (index$1.h("div", { key: '8a4a4d89be39da4438beda996b2f1f3b785d9010', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10920
10929
  }
10921
10930
  get el() { return index$1.getElement(this); }
10922
10931
  static get watchers() { return {
@@ -217,6 +217,14 @@ const InclusiveTimes = class {
217
217
  getClassName(suffix) {
218
218
  return `${this.elementClassName}__${suffix}`;
219
219
  }
220
+ toDate(dateString) {
221
+ if (!dateString)
222
+ return null;
223
+ const date = Array.isArray(dateString)
224
+ ? dateString.map((d) => moment.hooks(d, this.format).toDate())
225
+ : moment.hooks(dateString, this.format).toDate();
226
+ return date;
227
+ }
220
228
  async clearValue() {
221
229
  this.internalValue = null;
222
230
  this.value = undefined;
@@ -229,10 +237,10 @@ const InclusiveTimes = class {
229
237
  }
230
238
  render() {
231
239
  var _a;
232
- return (index.h(index.Host, { key: 'a2bfc28b058319e0e1c723483c0f98aae766a371', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: '072b5974746736864e482853198409c969dff6d7', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: 'bcc38045d990ce22960cdbfbbf43a218b05cdb12', class: this.getClassName("input-container") }, index.h("input", { key: 'e741093da1a37022ad73bd27fc2aecfaa39b5a6c', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
240
+ return (index.h(index.Host, { key: '82b7e3ac499f9b8bea87955bfe55bbe645aa9d5a', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: '19a9a6cf34bccd49e6d079a4d9d7d5f3e527f1c7', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: '20a4dae28141bb9d3d124653df0f8f3a152a2ee8', class: this.getClassName("input-container") }, index.h("input", { key: '64779c1b8d59ecff3c9ddcbe0e67025e9bcbd325', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
233
241
  [this.getClassName("input")]: true,
234
242
  [this.inputClass]: !!this.inputClass
235
- }, 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: '9c088d60d8ed20d6e385bd2467766091a0ffab60', type: "button", ref: (r) => (this.calendarButtonRef = r), 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: 'a2df562a114f9131b8a43d7f226d09b07cd21c63', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
243
+ }, 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: '503fb34dfa3b5328c1dfae06647601729d0c634d', type: "button", ref: (r) => (this.calendarButtonRef = r), 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: '915841d3053aae0e856b19ae24dafc8870c3d746', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
236
244
  if (this.pickerRef) {
237
245
  this.pickerRef.modalIsOpen = true;
238
246
  }
@@ -240,7 +248,7 @@ const InclusiveTimes = class {
240
248
  if (this.pickerRef) {
241
249
  this.pickerRef.modalIsOpen = false;
242
250
  }
243
- }, inline: this.inline }, index.h("div", { key: 'c02d2c09cbb10a99d65cdd37723dcb0b30c31800', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: 'ab24fcb28e457937f10d7914f0c65219fbd1aa7e', 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 }, index.h("div", { key: '1c2d6e1f290ef75840fd5ea33dd7debbe10d6cf4', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '34ed116961c27d81a4daf44c5c9325fad4b491fe', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '5862db463ee502572c6d04bc039ddf8a51455511', hours: this.selectedHours, minutes: this.selectedMinutes, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (index.h("div", { key: '2dccd8a4b09eed861c3e9c9ee9a02163ef2b0149', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
251
+ }, inline: this.inline }, index.h("div", { key: 'b7ead351553fa42af52be2ab8e461b49d6f63b56', class: this.getClassName("picker-container") }, index.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 }, index.h("div", { key: '6aa58750a3a13fc3e1ddadee0a9c4631220bb399', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '17943c66cef11e8a4335cb0c0711d5ae327076e9', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: 'f356db7d523202ee5a72089cf57cf072787c32ee', hours: this.selectedHours, minutes: this.selectedMinutes, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (index.h("div", { key: 'db47877aa13a91f6441dfd371cc7da70375aa1ea', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
244
252
  }
245
253
  get el() { return index.getElement(this); }
246
254
  static get watchers() { return {
@@ -26,7 +26,7 @@ export class TabworthyDates {
26
26
  // A placeholder for the text field
27
27
  this.placeholder = this.range
28
28
  ? `Try "June 8 to 12"`
29
- : `Try "tomorrrow" or "in ten days"`;
29
+ : `Try "tomorrow" or "in ten days"`;
30
30
  // Locale used for internal translations and date parsing
31
31
  this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
32
32
  // If the datepicker is disabled
@@ -132,6 +132,7 @@ export class TabworthyDates {
132
132
  if (this.pickerRef) {
133
133
  this.pickerRef.value = null;
134
134
  }
135
+ this.value = this.internalValue;
135
136
  return this.selectDate.emit(this.internalValue);
136
137
  }
137
138
  const parsedRange = await chronoParseRange(value, {
@@ -166,6 +167,7 @@ export class TabworthyDates {
166
167
  if (this.pickerRef) {
167
168
  this.pickerRef.value = null;
168
169
  }
170
+ this.value = this.internalValue;
169
171
  return this.selectDate.emit(this.internalValue);
170
172
  }
171
173
  const parsedDate = await chronoParseDate(value, {
@@ -233,7 +235,7 @@ export class TabworthyDates {
233
235
  return !!this.inputShouldFormat;
234
236
  }
235
237
  componentDidLoad() {
236
- this.syncFromValueProp();
238
+ this.syncFromValueProp(this.value);
237
239
  this.componentReady.emit();
238
240
  if (!this.id) {
239
241
  console.error('tabworthy-dates: The "id" prop is required for accessibility');
@@ -278,6 +280,7 @@ export class TabworthyDates {
278
280
  this.pickerRef.value = newValue;
279
281
  }
280
282
  this.errorState = false;
283
+ this.value = this.internalValue;
281
284
  this.selectDate.emit(this.internalValue);
282
285
  this.announceDateChange(this.internalValue);
283
286
  }
@@ -353,6 +356,7 @@ export class TabworthyDates {
353
356
  }
354
357
  this.announceDateChange(this.internalValue);
355
358
  }
359
+ this.value = this.internalValue;
356
360
  this.selectDate.emit(this.internalValue);
357
361
  }
358
362
  announceDateChange(newValue) {
@@ -398,10 +402,7 @@ export class TabworthyDates {
398
402
  ? `${this.elementClassName}__${element}`
399
403
  : this.elementClassName;
400
404
  }
401
- syncFromValueProp(value = this.value) {
402
- if (!value)
403
- return;
404
- // store
405
+ syncFromValueProp(value) {
405
406
  this.internalValue = value;
406
407
  // update calendar (expects Date or Date[])
407
408
  if (this.pickerRef) {
@@ -415,23 +416,31 @@ export class TabworthyDates {
415
416
  this.pickerRef.value = dates.length ? dates : null;
416
417
  }
417
418
  else {
418
- const parsedDate = moment(this.value, this.format, true);
419
- if (parsedDate.isValid()) {
420
- this.pickerRef.value = parsedDate.toDate();
419
+ if (value) {
420
+ const parsedDate = moment(value, this.format, true);
421
+ if (parsedDate.isValid()) {
422
+ this.pickerRef.value = parsedDate.toDate();
423
+ }
424
+ }
425
+ else {
426
+ this.pickerRef.value = null;
421
427
  }
422
428
  }
423
429
  }
430
+ if (!value) {
431
+ this.inputRef.value = "";
432
+ }
424
433
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
425
- if (this.inputRef) {
434
+ if (this.inputRef && value) {
426
435
  this.formatInput(!!this.shouldInputFormat(), false);
427
436
  }
428
437
  }
429
438
  render() {
430
439
  var _a;
431
- return (h(Host, { key: '16c9966e45f0084e805bb11cb1292a47869a2626' }, h("label", { key: '69d95cfdf481252fb684b8d071af97b26a10f466', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: '0b5c2fff7c26dbfe40d75f8f488ccf39e89b1ca3' }), h("div", { key: 'ecda94423965415e62da7a973ecf4b197104296f', class: this.getClassName("input-container") }, h("input", { key: '5c0e5276b82e69d68ebf14983918318fa2c33162', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
440
+ 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: {
432
441
  [this.getClassName("input")]: true,
433
442
  [this.inputClass]: !!this.inputClass
434
- }, 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: 'b8652ae391a12962aac5eb620ecddf23fed9a47b', 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: '358993a42e0401f33f2bc602f83241c53a0f7ef9', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
443
+ }, 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: () => {
435
444
  if (!this.pickerRef)
436
445
  return;
437
446
  this.pickerRef.modalIsOpen = true;
@@ -439,11 +448,11 @@ export class TabworthyDates {
439
448
  if (!this.pickerRef)
440
449
  return;
441
450
  this.pickerRef.modalIsOpen = false;
442
- }, inline: this.inline }, h("tabworthy-dates-calendar", { key: 'a9a1376d1d0a0f8213d8be3426d333257cc60be7', 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 &&
451
+ }, 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 &&
443
452
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
444
- this.chronoSupportedLocale && (h("div", { key: '3130ee18874ab44cb4de0b9c47289ea4de4f51b8', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
453
+ this.chronoSupportedLocale && (h("div", { key: 'db492a4c33d882a7f056dd66d669cd639894a714', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
445
454
  return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
446
- }))), this.errorState && (h("div", { key: '62a9c3115a69430c8a6b1f646612c250c527449b', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
455
+ }))), this.errorState && (h("div", { key: '8a4a4d89be39da4438beda996b2f1f3b785d9010', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
447
456
  }
448
457
  static get is() { return "tabworthy-dates"; }
449
458
  static get encapsulation() { return "scoped"; }
@@ -555,7 +564,7 @@ export class TabworthyDates {
555
564
  "setter": false,
556
565
  "reflect": false,
557
566
  "attribute": "placeholder",
558
- "defaultValue": "this.range\n ? `Try \"June 8 to 12\"`\n : `Try \"tomorrrow\" or \"in ten days\"`"
567
+ "defaultValue": "this.range\n ? `Try \"June 8 to 12\"`\n : `Try \"tomorrow\" or \"in ten days\"`"
559
568
  },
560
569
  "locale": {
561
570
  "type": "string",
@@ -210,6 +210,14 @@ export class InclusiveTimes {
210
210
  getClassName(suffix) {
211
211
  return `${this.elementClassName}__${suffix}`;
212
212
  }
213
+ toDate(dateString) {
214
+ if (!dateString)
215
+ return null;
216
+ const date = Array.isArray(dateString)
217
+ ? dateString.map((d) => moment(d, this.format).toDate())
218
+ : moment(dateString, this.format).toDate();
219
+ return date;
220
+ }
213
221
  async clearValue() {
214
222
  this.internalValue = null;
215
223
  this.value = undefined;
@@ -222,10 +230,10 @@ export class InclusiveTimes {
222
230
  }
223
231
  render() {
224
232
  var _a;
225
- return (h(Host, { key: 'a2bfc28b058319e0e1c723483c0f98aae766a371', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '072b5974746736864e482853198409c969dff6d7', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'bcc38045d990ce22960cdbfbbf43a218b05cdb12', class: this.getClassName("input-container") }, h("input", { key: 'e741093da1a37022ad73bd27fc2aecfaa39b5a6c', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
233
+ 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: {
226
234
  [this.getClassName("input")]: true,
227
235
  [this.inputClass]: !!this.inputClass
228
- }, 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: '9c088d60d8ed20d6e385bd2467766091a0ffab60', 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: 'a2df562a114f9131b8a43d7f226d09b07cd21c63', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
236
+ }, 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: () => {
229
237
  if (this.pickerRef) {
230
238
  this.pickerRef.modalIsOpen = true;
231
239
  }
@@ -233,7 +241,7 @@ export class InclusiveTimes {
233
241
  if (this.pickerRef) {
234
242
  this.pickerRef.modalIsOpen = false;
235
243
  }
236
- }, inline: this.inline }, h("div", { key: 'c02d2c09cbb10a99d65cdd37723dcb0b30c31800', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'ab24fcb28e457937f10d7914f0c65219fbd1aa7e', 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 }, h("div", { key: '1c2d6e1f290ef75840fd5ea33dd7debbe10d6cf4', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '34ed116961c27d81a4daf44c5c9325fad4b491fe', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '5862db463ee502572c6d04bc039ddf8a51455511', hours: this.selectedHours, minutes: this.selectedMinutes, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (h("div", { key: '2dccd8a4b09eed861c3e9c9ee9a02163ef2b0149', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
244
+ }, 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))));
237
245
  }
238
246
  static get is() { return "tabworthy-times"; }
239
247
  static get encapsulation() { return "scoped"; }