@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.
@@ -10603,6 +10603,7 @@ const TabworthyDates = class {
10603
10603
  if (this.pickerRef) {
10604
10604
  this.pickerRef.value = null;
10605
10605
  }
10606
+ this.value = this.internalValue;
10606
10607
  return this.selectDate.emit(this.internalValue);
10607
10608
  }
10608
10609
  const parsedRange = await chronoParseRange(value, {
@@ -10637,6 +10638,7 @@ const TabworthyDates = class {
10637
10638
  if (this.pickerRef) {
10638
10639
  this.pickerRef.value = null;
10639
10640
  }
10641
+ this.value = this.internalValue;
10640
10642
  return this.selectDate.emit(this.internalValue);
10641
10643
  }
10642
10644
  const parsedDate = await chronoParseDate(value, {
@@ -10704,7 +10706,7 @@ const TabworthyDates = class {
10704
10706
  return !!this.inputShouldFormat;
10705
10707
  }
10706
10708
  componentDidLoad() {
10707
- this.syncFromValueProp();
10709
+ this.syncFromValueProp(this.value);
10708
10710
  this.componentReady.emit();
10709
10711
  if (!this.id) {
10710
10712
  console.error('tabworthy-dates: The "id" prop is required for accessibility');
@@ -10749,6 +10751,7 @@ const TabworthyDates = class {
10749
10751
  this.pickerRef.value = newValue;
10750
10752
  }
10751
10753
  this.errorState = false;
10754
+ this.value = this.internalValue;
10752
10755
  this.selectDate.emit(this.internalValue);
10753
10756
  this.announceDateChange(this.internalValue);
10754
10757
  }
@@ -10813,7 +10816,9 @@ const TabworthyDates = class {
10813
10816
  else {
10814
10817
  (_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
10815
10818
  // Convert ISO date to specified format
10816
- const formattedDate = hooks(newValue).format(this.format);
10819
+ const formattedDate = newValue
10820
+ ? hooks(newValue).format(this.format)
10821
+ : "";
10817
10822
  this.inputRef.value = formattedDate;
10818
10823
  this.internalValue = formattedDate;
10819
10824
  this.errorState = false;
@@ -10822,9 +10827,13 @@ const TabworthyDates = class {
10822
10827
  }
10823
10828
  this.announceDateChange(this.internalValue);
10824
10829
  }
10830
+ this.value = this.internalValue;
10825
10831
  this.selectDate.emit(this.internalValue);
10826
10832
  }
10827
10833
  announceDateChange(newValue) {
10834
+ if (!newValue || (Array.isArray(newValue) && newValue.length === 0)) {
10835
+ return;
10836
+ }
10828
10837
  const newValueInIsoFormat = Array.isArray(newValue)
10829
10838
  ? newValue.map((date) => hooks(date, this.format).toISOString())
10830
10839
  : hooks(newValue, this.format).toISOString();
@@ -10864,10 +10873,7 @@ const TabworthyDates = class {
10864
10873
  ? `${this.elementClassName}__${element}`
10865
10874
  : this.elementClassName;
10866
10875
  }
10867
- syncFromValueProp(value = this.value) {
10868
- if (!value)
10869
- return;
10870
- // store
10876
+ syncFromValueProp(value) {
10871
10877
  this.internalValue = value;
10872
10878
  // update calendar (expects Date or Date[])
10873
10879
  if (this.pickerRef) {
@@ -10881,23 +10887,31 @@ const TabworthyDates = class {
10881
10887
  this.pickerRef.value = dates.length ? dates : null;
10882
10888
  }
10883
10889
  else {
10884
- const parsedDate = hooks(this.value, this.format, true);
10885
- if (parsedDate.isValid()) {
10886
- this.pickerRef.value = parsedDate.toDate();
10890
+ if (value) {
10891
+ const parsedDate = hooks(value, this.format, true);
10892
+ if (parsedDate.isValid()) {
10893
+ this.pickerRef.value = parsedDate.toDate();
10894
+ }
10895
+ }
10896
+ else {
10897
+ this.pickerRef.value = null;
10887
10898
  }
10888
10899
  }
10889
10900
  }
10901
+ if (!value) {
10902
+ this.inputRef.value = "";
10903
+ }
10890
10904
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
10891
- if (this.inputRef) {
10905
+ if (this.inputRef && value) {
10892
10906
  this.formatInput(!!this.shouldInputFormat(), false);
10893
10907
  }
10894
10908
  }
10895
10909
  render() {
10896
10910
  var _a;
10897
- 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: {
10911
+ 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: {
10898
10912
  [this.getClassName("input")]: true,
10899
10913
  [this.inputClass]: !!this.inputClass
10900
- }, 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: () => {
10914
+ }, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '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: () => {
10901
10915
  if (!this.pickerRef)
10902
10916
  return;
10903
10917
  this.pickerRef.modalIsOpen = true;
@@ -10905,11 +10919,11 @@ const TabworthyDates = class {
10905
10919
  if (!this.pickerRef)
10906
10920
  return;
10907
10921
  this.pickerRef.modalIsOpen = false;
10908
- }, 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 &&
10922
+ }, 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 &&
10909
10923
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
10910
- this.chronoSupportedLocale && (h("div", { key: '1bb09b44a219648203d803c76d17a9b41b0278bf', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10924
+ this.chronoSupportedLocale && (h("div", { key: '436491da4225bde4b5b1a8ebca90bd873d947db4', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
10911
10925
  return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
10912
- }))), this.errorState && (h("div", { key: '92d843bf6d0234568bf41a0fd2fdf281cb48487f', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10926
+ }))), this.errorState && (h("div", { key: 'd01c5419b306c0ea01e8c86f6a3c067ba03cff24', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
10913
10927
  }
10914
10928
  get el() { return getElement(this); }
10915
10929
  static get watchers() { return {