@tabworthy/components 0.8.3 → 0.8.5

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.
@@ -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
  }
@@ -10815,7 +10818,9 @@ const TabworthyDates = class {
10815
10818
  else {
10816
10819
  (_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
10817
10820
  // Convert ISO date to specified format
10818
- const formattedDate = moment.hooks(newValue).format(this.format);
10821
+ const formattedDate = newValue
10822
+ ? moment.hooks(newValue).format(this.format)
10823
+ : "";
10819
10824
  this.inputRef.value = formattedDate;
10820
10825
  this.internalValue = formattedDate;
10821
10826
  this.errorState = false;
@@ -10824,9 +10829,13 @@ const TabworthyDates = class {
10824
10829
  }
10825
10830
  this.announceDateChange(this.internalValue);
10826
10831
  }
10832
+ this.value = this.internalValue;
10827
10833
  this.selectDate.emit(this.internalValue);
10828
10834
  }
10829
10835
  announceDateChange(newValue) {
10836
+ if (!newValue || (Array.isArray(newValue) && newValue.length === 0)) {
10837
+ return;
10838
+ }
10830
10839
  const newValueInIsoFormat = Array.isArray(newValue)
10831
10840
  ? newValue.map((date) => moment.hooks(date, this.format).toISOString())
10832
10841
  : moment.hooks(newValue, this.format).toISOString();
@@ -10866,10 +10875,7 @@ const TabworthyDates = class {
10866
10875
  ? `${this.elementClassName}__${element}`
10867
10876
  : this.elementClassName;
10868
10877
  }
10869
- syncFromValueProp(value = this.value) {
10870
- if (!value)
10871
- return;
10872
- // store
10878
+ syncFromValueProp(value) {
10873
10879
  this.internalValue = value;
10874
10880
  // update calendar (expects Date or Date[])
10875
10881
  if (this.pickerRef) {
@@ -10883,23 +10889,31 @@ const TabworthyDates = class {
10883
10889
  this.pickerRef.value = dates.length ? dates : null;
10884
10890
  }
10885
10891
  else {
10886
- const parsedDate = moment.hooks(this.value, this.format, true);
10887
- if (parsedDate.isValid()) {
10888
- 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;
10889
10900
  }
10890
10901
  }
10891
10902
  }
10903
+ if (!value) {
10904
+ this.inputRef.value = "";
10905
+ }
10892
10906
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
10893
- if (this.inputRef) {
10907
+ if (this.inputRef && value) {
10894
10908
  this.formatInput(!!this.shouldInputFormat(), false);
10895
10909
  }
10896
10910
  }
10897
10911
  render() {
10898
10912
  var _a;
10899
- return (index$1.h(index$1.Host, { key: 'd424c911d4fd2d05222249b401e9b704430e6f29' }, index$1.h("label", { key: 'd14130a7b0b02e7124f7c7e9ec0642620da7aab6', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: 'c4f5397785326f323772f46a8cfb6d868f5ff230' }), index$1.h("div", { key: '9f52005781b9a54426ee3c094727b8890681a4d5', class: this.getClassName("input-container") }, index$1.h("input", { key: 'e67af61ef75a592acadcfbd14da4527b84b08417', 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: '180697843c3ae05f69acb3d43ab227cfbcdc16f2' }, index$1.h("label", { key: '1134bf0bd018c2f0c65beb8337bbff9e345a50de', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: '73469d03cd691e6c7ac41bef60ab99b8eb498b2e' }), index$1.h("div", { key: '3fc51e7291ec6458d7cb6807cb67f0c6852e6f08', class: this.getClassName("input-container") }, index$1.h("input", { key: '041ccffdc7911349b03f5f9764285b08af0495c1', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
10900
10914
  [this.getClassName("input")]: true,
10901
10915
  [this.inputClass]: !!this.inputClass
10902
- }, 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: 'dd9421438de95497d2e7037cfc927bb0f27cd3c0', 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: 'b8a3278a07bc1ddc36eac5a0c9808595c4bcdde5', 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: '8429dbfd6cc12eee026a9b2cb1d5eefc1837b260', 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: '1d1e63573957850ac97b2a26642aead2a660b150', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
10903
10917
  if (!this.pickerRef)
10904
10918
  return;
10905
10919
  this.pickerRef.modalIsOpen = true;
@@ -10907,11 +10921,11 @@ const TabworthyDates = class {
10907
10921
  if (!this.pickerRef)
10908
10922
  return;
10909
10923
  this.pickerRef.modalIsOpen = false;
10910
- }, inline: this.inline }, index$1.h("tabworthy-dates-calendar", { key: '29dc57f6a1951091476de39c8861b43d83242007', 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: '67bde6b757985896a954944e4cbd984e86d157df', 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 &&
10911
10925
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
10912
- this.chronoSupportedLocale && (index$1.h("div", { key: '1bb09b44a219648203d803c76d17a9b41b0278bf', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10926
+ this.chronoSupportedLocale && (index$1.h("div", { key: '436491da4225bde4b5b1a8ebca90bd873d947db4', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10913
10927
  return (index$1.h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
10914
- }))), this.errorState && (index$1.h("div", { key: '92d843bf6d0234568bf41a0fd2fdf281cb48487f', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10928
+ }))), this.errorState && (index$1.h("div", { key: 'd01c5419b306c0ea01e8c86f6a3c067ba03cff24', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10915
10929
  }
10916
10930
  get el() { return index$1.getElement(this); }
10917
10931
  static get watchers() { return {
@@ -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
  }
@@ -342,7 +345,9 @@ export class TabworthyDates {
342
345
  else {
343
346
  (_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
344
347
  // Convert ISO date to specified format
345
- const formattedDate = moment(newValue).format(this.format);
348
+ const formattedDate = newValue
349
+ ? moment(newValue).format(this.format)
350
+ : "";
346
351
  this.inputRef.value = formattedDate;
347
352
  this.internalValue = formattedDate;
348
353
  this.errorState = false;
@@ -351,9 +356,13 @@ export class TabworthyDates {
351
356
  }
352
357
  this.announceDateChange(this.internalValue);
353
358
  }
359
+ this.value = this.internalValue;
354
360
  this.selectDate.emit(this.internalValue);
355
361
  }
356
362
  announceDateChange(newValue) {
363
+ if (!newValue || (Array.isArray(newValue) && newValue.length === 0)) {
364
+ return;
365
+ }
357
366
  const newValueInIsoFormat = Array.isArray(newValue)
358
367
  ? newValue.map((date) => moment(date, this.format).toISOString())
359
368
  : moment(newValue, this.format).toISOString();
@@ -393,10 +402,7 @@ export class TabworthyDates {
393
402
  ? `${this.elementClassName}__${element}`
394
403
  : this.elementClassName;
395
404
  }
396
- syncFromValueProp(value = this.value) {
397
- if (!value)
398
- return;
399
- // store
405
+ syncFromValueProp(value) {
400
406
  this.internalValue = value;
401
407
  // update calendar (expects Date or Date[])
402
408
  if (this.pickerRef) {
@@ -410,23 +416,31 @@ export class TabworthyDates {
410
416
  this.pickerRef.value = dates.length ? dates : null;
411
417
  }
412
418
  else {
413
- const parsedDate = moment(this.value, this.format, true);
414
- if (parsedDate.isValid()) {
415
- 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;
416
427
  }
417
428
  }
418
429
  }
430
+ if (!value) {
431
+ this.inputRef.value = "";
432
+ }
419
433
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
420
- if (this.inputRef) {
434
+ if (this.inputRef && value) {
421
435
  this.formatInput(!!this.shouldInputFormat(), false);
422
436
  }
423
437
  }
424
438
  render() {
425
439
  var _a;
426
- return (h(Host, { key: 'd424c911d4fd2d05222249b401e9b704430e6f29' }, h("label", { key: 'd14130a7b0b02e7124f7c7e9ec0642620da7aab6', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: 'c4f5397785326f323772f46a8cfb6d868f5ff230' }), h("div", { key: '9f52005781b9a54426ee3c094727b8890681a4d5', class: this.getClassName("input-container") }, h("input", { key: 'e67af61ef75a592acadcfbd14da4527b84b08417', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
440
+ return (h(Host, { key: '180697843c3ae05f69acb3d43ab227cfbcdc16f2' }, h("label", { key: '1134bf0bd018c2f0c65beb8337bbff9e345a50de', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: '73469d03cd691e6c7ac41bef60ab99b8eb498b2e' }), h("div", { key: '3fc51e7291ec6458d7cb6807cb67f0c6852e6f08', class: this.getClassName("input-container") }, h("input", { key: '041ccffdc7911349b03f5f9764285b08af0495c1', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
427
441
  [this.getClassName("input")]: true,
428
442
  [this.inputClass]: !!this.inputClass
429
- }, 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: 'dd9421438de95497d2e7037cfc927bb0f27cd3c0', 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: 'b8a3278a07bc1ddc36eac5a0c9808595c4bcdde5', 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: '8429dbfd6cc12eee026a9b2cb1d5eefc1837b260', 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: '1d1e63573957850ac97b2a26642aead2a660b150', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
430
444
  if (!this.pickerRef)
431
445
  return;
432
446
  this.pickerRef.modalIsOpen = true;
@@ -434,11 +448,11 @@ export class TabworthyDates {
434
448
  if (!this.pickerRef)
435
449
  return;
436
450
  this.pickerRef.modalIsOpen = false;
437
- }, inline: this.inline }, h("tabworthy-dates-calendar", { key: '29dc57f6a1951091476de39c8861b43d83242007', 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: '67bde6b757985896a954944e4cbd984e86d157df', 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 &&
438
452
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
439
- this.chronoSupportedLocale && (h("div", { key: '1bb09b44a219648203d803c76d17a9b41b0278bf', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
453
+ this.chronoSupportedLocale && (h("div", { key: '436491da4225bde4b5b1a8ebca90bd873d947db4', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
440
454
  return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
441
- }))), this.errorState && (h("div", { key: '92d843bf6d0234568bf41a0fd2fdf281cb48487f', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
455
+ }))), this.errorState && (h("div", { key: 'd01c5419b306c0ea01e8c86f6a3c067ba03cff24', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
442
456
  }
443
457
  static get is() { return "tabworthy-dates"; }
444
458
  static get encapsulation() { return "scoped"; }