@tabworthy/components 0.8.4 → 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
  }
@@ -10824,6 +10827,7 @@ const TabworthyDates = class {
10824
10827
  }
10825
10828
  this.announceDateChange(this.internalValue);
10826
10829
  }
10830
+ this.value = this.internalValue;
10827
10831
  this.selectDate.emit(this.internalValue);
10828
10832
  }
10829
10833
  announceDateChange(newValue) {
@@ -10869,10 +10873,7 @@ const TabworthyDates = class {
10869
10873
  ? `${this.elementClassName}__${element}`
10870
10874
  : this.elementClassName;
10871
10875
  }
10872
- syncFromValueProp(value = this.value) {
10873
- if (!value)
10874
- return;
10875
- // store
10876
+ syncFromValueProp(value) {
10876
10877
  this.internalValue = value;
10877
10878
  // update calendar (expects Date or Date[])
10878
10879
  if (this.pickerRef) {
@@ -10886,23 +10887,31 @@ const TabworthyDates = class {
10886
10887
  this.pickerRef.value = dates.length ? dates : null;
10887
10888
  }
10888
10889
  else {
10889
- const parsedDate = hooks(this.value, this.format, true);
10890
- if (parsedDate.isValid()) {
10891
- 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;
10892
10898
  }
10893
10899
  }
10894
10900
  }
10901
+ if (!value) {
10902
+ this.inputRef.value = "";
10903
+ }
10895
10904
  // update text input (useInputValue=false so it formats from internalValue, not from input's current text)
10896
- if (this.inputRef) {
10905
+ if (this.inputRef && value) {
10897
10906
  this.formatInput(!!this.shouldInputFormat(), false);
10898
10907
  }
10899
10908
  }
10900
10909
  render() {
10901
10910
  var _a;
10902
- 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: {
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: {
10903
10912
  [this.getClassName("input")]: true,
10904
10913
  [this.inputClass]: !!this.inputClass
10905
- }, 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: () => {
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: () => {
10906
10915
  if (!this.pickerRef)
10907
10916
  return;
10908
10917
  this.pickerRef.modalIsOpen = true;
@@ -10910,11 +10919,11 @@ const TabworthyDates = class {
10910
10919
  if (!this.pickerRef)
10911
10920
  return;
10912
10921
  this.pickerRef.modalIsOpen = false;
10913
- }, 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 &&
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 &&
10914
10923
  ((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
10915
- this.chronoSupportedLocale && (h("div", { key: '3130ee18874ab44cb4de0b9c47289ea4de4f51b8', 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) => {
10916
10925
  return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
10917
- }))), this.errorState && (h("div", { key: '62a9c3115a69430c8a6b1f646612c250c527449b', 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))));
10918
10927
  }
10919
10928
  get el() { return getElement(this); }
10920
10929
  static get watchers() { return {