@tabworthy/components 0.15.1 → 1.0.0

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.
Files changed (31) hide show
  1. package/dist/cjs/{customParseFormat-l09KVyWD.js → date-error-CCtoCDtq.js} +3 -0
  2. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +11 -6
  3. package/dist/cjs/tabworthy-dates.cjs.entry.js +30 -28
  4. package/dist/cjs/tabworthy-times.cjs.entry.js +42 -42
  5. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +14 -11
  6. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +16 -7
  7. package/dist/collection/components/tabworthy-times/tabworthy-times.js +10 -9
  8. package/dist/collection/utils/date-error.js +1 -0
  9. package/dist/{tabworthy-components/p-DkyM-7xr.js → components/p-DCgn1Avj.js} +1 -1
  10. package/dist/components/{p-DXCumu2Y.js → p-Denq9zJN.js} +1 -1
  11. package/dist/components/tabworthy-dates-modal.js +1 -1
  12. package/dist/components/tabworthy-dates.js +1 -1
  13. package/dist/components/tabworthy-times.js +1 -1
  14. package/dist/esm/{customParseFormat-DkyM-7xr.js → date-error-DCgn1Avj.js} +3 -1
  15. package/dist/esm/tabworthy-dates-calendar_2.entry.js +11 -6
  16. package/dist/esm/tabworthy-dates.entry.js +14 -12
  17. package/dist/esm/tabworthy-times.entry.js +10 -10
  18. package/dist/tabworthy-components/p-6749b25f.entry.js +1 -0
  19. package/dist/tabworthy-components/p-8c2b9340.entry.js +1 -0
  20. package/dist/tabworthy-components/{p-66c929f1.entry.js → p-98ba1248.entry.js} +1 -1
  21. package/dist/{components/p-DkyM-7xr.js → tabworthy-components/p-DCgn1Avj.js} +1 -1
  22. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
  23. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +5 -2
  24. package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +2 -1
  25. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +1 -0
  26. package/dist/types/components.d.ts +1 -1
  27. package/dist/types/index.d.ts +1 -0
  28. package/dist/types/utils/date-error.d.ts +2 -0
  29. package/package.json +3 -2
  30. package/dist/tabworthy-components/p-3e890a9c.entry.js +0 -1
  31. package/dist/tabworthy-components/p-af49d0fc.entry.js +0 -1
@@ -40,6 +40,9 @@ function requireCustomParseFormat () {
40
40
  var customParseFormatExports = requireCustomParseFormat();
41
41
  var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
42
42
 
43
+ const formatDateError = (label, date) => typeof label === "function" ? label(date) : `${label} ${date}`;
44
+
43
45
  exports.customParseFormat = customParseFormat;
44
46
  exports.dayjs = dayjs;
47
+ exports.formatDateError = formatDateError;
45
48
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -2817,14 +2817,18 @@ const TabworthyDatesModal = class {
2817
2817
  * Close the dialog.
2818
2818
  */
2819
2819
  async close() {
2820
- var _a;
2820
+ var _a, _b;
2821
2821
  if (this.inline)
2822
2822
  return;
2823
+ const activeElement = document.activeElement;
2824
+ const focusMovedOutside = !!activeElement &&
2825
+ activeElement !== document.body &&
2826
+ !this.hostElement.contains(activeElement);
2823
2827
  this.showing = false;
2824
2828
  this.closed.emit(undefined);
2825
2829
  (_a = this.undo) === null || _a === void 0 ? void 0 : _a.call(this);
2826
- if (this.triggerElement)
2827
- this.triggerElement.focus();
2830
+ if (!focusMovedOutside)
2831
+ (_b = this.focusReturnElement) === null || _b === void 0 ? void 0 : _b.focus();
2828
2832
  }
2829
2833
  disconnectedCallback() {
2830
2834
  // Skip cleanup if we're in the middle of portal operations
@@ -2836,8 +2840,9 @@ const TabworthyDatesModal = class {
2836
2840
  async getState() {
2837
2841
  return this.showing;
2838
2842
  }
2839
- async setTriggerElement(element) {
2843
+ async setTriggerElement(element, focusElement = element) {
2840
2844
  this.triggerElement = element;
2845
+ this.focusReturnElement = focusElement;
2841
2846
  }
2842
2847
  /** Force update the popper position */
2843
2848
  async updatePosition() {
@@ -2859,7 +2864,7 @@ const TabworthyDatesModal = class {
2859
2864
  }
2860
2865
  }
2861
2866
  render() {
2862
- return (index.h(index.Host, { key: '2c9c3ade4eb4964dbb5ba86bd196240851dbb996', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (index.h("div", { key: '961c2d9e34d7ddadb512f8652f14ed4ed4ec6ce5', part: "body", ref: (r) => {
2867
+ return (index.h(index.Host, { key: '8f2128e3b9ed31547aaa4a1eb1f9fe1c2c554834', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (index.h("div", { key: 'd3c8a2b9d11bdd1147ded6256417c0bdda9274b5', part: "body", ref: (r) => {
2863
2868
  if (r) {
2864
2869
  this.bodyRef = r;
2865
2870
  // Setup portal and create popper when ref is set
@@ -2876,7 +2881,7 @@ const TabworthyDatesModal = class {
2876
2881
  });
2877
2882
  }
2878
2883
  }
2879
- }, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, index.h("focus-trap", { key: '719a3e82aab59326d1aa069b237d158d2311cd62' }, index.h("div", { key: 'b33e1aabdb7477409d97f757bf7121697979d50c', part: "content" }, index.h("slot", { key: 'c7e85552f37b930e298484c0040c138fdccb8ea7' }))))), this.inline && (index.h("div", { key: '59e0333fb0e980c17e0a1da041e6bc492d025bd8', part: "content" }, index.h("slot", { key: 'd52759f124c038fbde4b510ae1df8c3a1bdad25e' })))));
2884
+ }, style: { visibility: this.positioned ? "visible" : "hidden" }, onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, index.h("focus-trap", { key: '3c36e0e81b87ef9364ff8288e200c4462626bfea' }, index.h("div", { key: '111ba3d8fea2f0f4afdb63506fa43d1b8467c14d', part: "content" }, index.h("slot", { key: '6ec34c827f3c4cf1a5f30d9e571826f73cc66157' }))))), this.inline && (index.h("div", { key: '49970743a4f726fd02b18ba485ba0753acc4d0ec', part: "content" }, index.h("slot", { key: '6d0e2cd6bdc51f63fbab138c93f9c99cc3b1291d' })))));
2880
2885
  }
2881
2886
  get hostElement() { return index.getElement(this); }
2882
2887
  static get watchers() { return {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index$1 = require('./index-B1s0tI-Z.js');
4
- var customParseFormat = require('./customParseFormat-l09KVyWD.js');
4
+ var dateError = require('./date-error-CCtoCDtq.js');
5
5
  var utils = require('./utils-DGbdK8VF.js');
6
6
 
7
7
  function _mergeNamespaces(n, m) {
@@ -10312,7 +10312,7 @@ function requireDist () {
10312
10312
  }
10313
10313
 
10314
10314
  var distExports = requireDist();
10315
- var index = /*@__PURE__*/customParseFormat.getDefaultExportFromCjs(distExports);
10315
+ var index = /*@__PURE__*/dateError.getDefaultExportFromCjs(distExports);
10316
10316
 
10317
10317
  var chrono = /*#__PURE__*/_mergeNamespaces({
10318
10318
  __proto__: null,
@@ -10468,7 +10468,7 @@ const chronoParseRange = async (dateString, options) => {
10468
10468
 
10469
10469
  const tabworthyDatesCss = () => `.visually-hidden.sc-tabworthy-dates{position:absolute;overflow:hidden;width:1px;height:1px;white-space:nowrap;clip:rect(0 0 0 0);-webkit-clip-path:inset(50%);clip-path:inset(50%)}`;
10470
10470
 
10471
- customParseFormat.dayjs.extend(customParseFormat.customParseFormat);
10471
+ dateError.dayjs.extend(dateError.customParseFormat);
10472
10472
  const defaultLabels = {
10473
10473
  selected: "selected",
10474
10474
  openCalendar: "Open calendar",
@@ -10557,7 +10557,7 @@ const TabworthyDates = class {
10557
10557
  await customElements.whenDefined("tabworthy-dates-modal");
10558
10558
  // Use input container as trigger for proper dropdown alignment
10559
10559
  this.inputContainerRef &&
10560
- (await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef)));
10560
+ (await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef, this.calendarButtonRef)));
10561
10561
  if ((await ((_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.getState())) === false)
10562
10562
  await ((_c = this.modalRef) === null || _c === void 0 ? void 0 : _c.open());
10563
10563
  else if ((await ((_d = this.modalRef) === null || _d === void 0 ? void 0 : _d.getState())) === true)
@@ -10614,7 +10614,7 @@ const TabworthyDates = class {
10614
10614
  : 9999;
10615
10615
  if (year < minYear || year > maxYear)
10616
10616
  return;
10617
- const newValue = customParseFormat.dayjs().year(year).startOf("year").format(this.format);
10617
+ const newValue = dateError.dayjs().year(year).startOf("year").format(this.format);
10618
10618
  this.internalValue = newValue;
10619
10619
  this.value = newValue;
10620
10620
  (_a = this.changeYear) === null || _a === void 0 ? void 0 : _a.emit({ year });
@@ -10667,7 +10667,7 @@ const TabworthyDates = class {
10667
10667
  return this.selectDate.emit(this.internalValue);
10668
10668
  }
10669
10669
  // Try strict format parsing first to avoid DD/MM vs MM/DD ambiguity
10670
- const strictParsed = customParseFormat.dayjs(value, this.format, true);
10670
+ const strictParsed = dateError.dayjs(value, this.format, true);
10671
10671
  if (strictParsed.isValid()) {
10672
10672
  const date = strictParsed.toDate();
10673
10673
  if (!this.isPickedDateValid(date))
@@ -10707,18 +10707,13 @@ const TabworthyDates = class {
10707
10707
  minDate === null || minDate === void 0 ? void 0 : minDate.setDate(minDate.getDate() - 1);
10708
10708
  }
10709
10709
  if (!!parsedDate.reason) {
10710
- const formatLocalizedDate = (date) => Intl.DateTimeFormat(this.locale, {
10711
- day: "numeric",
10712
- month: "short",
10713
- year: "numeric"
10714
- }).format(date);
10715
10710
  this.errorMessage = parsedDate.reason;
10716
10711
  this.errorMessage = {
10717
10712
  minDate: minDate
10718
- ? `${this.datesLabels.minDateError} ${formatLocalizedDate(minDate)}`
10713
+ ? dateError.formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(minDate))
10719
10714
  : "",
10720
10715
  maxDate: maxDate
10721
- ? `${this.datesLabels.maxDateError} ${formatLocalizedDate(maxDate)}`
10716
+ ? dateError.formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(maxDate))
10722
10717
  : "",
10723
10718
  invalid: this.datesLabels.invalidDateError
10724
10719
  }[parsedDate.reason];
@@ -10763,7 +10758,7 @@ const TabworthyDates = class {
10763
10758
  }
10764
10759
  return {
10765
10760
  value: parsedDate && parsedDate.value instanceof Date
10766
- ? customParseFormat.dayjs(parsedDate.value).format(this.format)
10761
+ ? dateError.dayjs(parsedDate.value).format(this.format)
10767
10762
  : undefined,
10768
10763
  reason: parsedDate && parsedDate.reason ? parsedDate.reason : undefined
10769
10764
  };
@@ -10784,11 +10779,11 @@ const TabworthyDates = class {
10784
10779
  updateValue(newValue) {
10785
10780
  // Range
10786
10781
  if (Array.isArray(newValue)) {
10787
- this.internalValue = newValue.map((date) => customParseFormat.dayjs(date).format(this.format));
10782
+ this.internalValue = newValue.map((date) => dateError.dayjs(date).format(this.format));
10788
10783
  }
10789
10784
  // Single
10790
10785
  else {
10791
- this.internalValue = customParseFormat.dayjs(newValue).format(this.format);
10786
+ this.internalValue = dateError.dayjs(newValue).format(this.format);
10792
10787
  }
10793
10788
  if (this.pickerRef) {
10794
10789
  this.pickerRef.value = newValue;
@@ -10801,6 +10796,13 @@ const TabworthyDates = class {
10801
10796
  emitErrorChange(reason, message) {
10802
10797
  this.errorChange.emit({ reason, message });
10803
10798
  }
10799
+ formatBoundaryDate(date) {
10800
+ return Intl.DateTimeFormat(this.locale, {
10801
+ day: "numeric",
10802
+ month: "short",
10803
+ year: "numeric"
10804
+ }).format(date);
10805
+ }
10804
10806
  formatInput(enabled, useInputValue = true) {
10805
10807
  if (this.shouldInputFormat() === false || enabled === false) {
10806
10808
  if (this.internalValue) {
@@ -10820,7 +10822,7 @@ const TabworthyDates = class {
10820
10822
  return; // Range date is invalid, leave the text field as is
10821
10823
  let output = "";
10822
10824
  this.internalValue.forEach((value, index) => {
10823
- const parsedDate = customParseFormat.dayjs(useInputValue ? this.inputRef.value : value, this.format, true);
10825
+ const parsedDate = dateError.dayjs(useInputValue ? this.inputRef.value : value, this.format, true);
10824
10826
  const dateToFormat = parsedDate.isValid()
10825
10827
  ? parsedDate.toDate()
10826
10828
  : utils.removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : value));
@@ -10833,7 +10835,7 @@ const TabworthyDates = class {
10833
10835
  this.inputRef.value = output;
10834
10836
  }
10835
10837
  else {
10836
- const parsedDate = customParseFormat.dayjs(useInputValue ? this.inputRef.value : this.internalValue, this.format, true);
10838
+ const parsedDate = dateError.dayjs(useInputValue ? this.inputRef.value : this.internalValue, this.format, true);
10837
10839
  const dateToFormat = parsedDate.isValid()
10838
10840
  ? parsedDate.toDate()
10839
10841
  : utils.removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : this.internalValue));
@@ -10847,19 +10849,19 @@ const TabworthyDates = class {
10847
10849
  }
10848
10850
  }
10849
10851
  isPickedDateValid(dateString) {
10850
- const parsed = customParseFormat.dayjs(dateString);
10852
+ const parsed = dateError.dayjs(dateString);
10851
10853
  if (!parsed.isValid())
10852
10854
  return false;
10853
10855
  const isoDate = typeof dateString === "string" ? dateString : parsed.format("YYYY-MM-DD");
10854
10856
  if (this.minDate && isoDate < this.minDate) {
10855
10857
  this.errorState = true;
10856
- this.errorMessage = `${this.datesLabels.minDateError} ${this.minDate}`;
10858
+ this.errorMessage = dateError.formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(utils.parseDateString(this.minDate)));
10857
10859
  this.emitErrorChange("minDate", this.errorMessage);
10858
10860
  return false;
10859
10861
  }
10860
10862
  if (this.maxDate && isoDate > this.maxDate) {
10861
10863
  this.errorState = true;
10862
- this.errorMessage = `${this.datesLabels.maxDateError} ${this.maxDate}`;
10864
+ this.errorMessage = dateError.formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(utils.parseDateString(this.maxDate)));
10863
10865
  this.emitErrorChange("maxDate", this.errorMessage);
10864
10866
  return false;
10865
10867
  }
@@ -10880,7 +10882,7 @@ const TabworthyDates = class {
10880
10882
  if (newValue.length === 2)
10881
10883
  (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close();
10882
10884
  // Convert ISO dates to specified format
10883
- this.internalValue = newValue.map((date) => customParseFormat.dayjs(date).format(this.format));
10885
+ this.internalValue = newValue.map((date) => dateError.dayjs(date).format(this.format));
10884
10886
  this.errorState = false;
10885
10887
  if (document.activeElement !== this.inputRef) {
10886
10888
  this.formatInput(true, false);
@@ -10894,7 +10896,7 @@ const TabworthyDates = class {
10894
10896
  (_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
10895
10897
  // Convert ISO date to specified format
10896
10898
  const formattedDate = newValue
10897
- ? customParseFormat.dayjs(newValue).format(this.format)
10899
+ ? dateError.dayjs(newValue).format(this.format)
10898
10900
  : "";
10899
10901
  this.inputRef.value = formattedDate;
10900
10902
  this.internalValue = formattedDate;
@@ -10912,8 +10914,8 @@ const TabworthyDates = class {
10912
10914
  return;
10913
10915
  }
10914
10916
  const newValueInIsoFormat = Array.isArray(newValue)
10915
- ? newValue.map((date) => customParseFormat.dayjs(date, this.format).toISOString())
10916
- : customParseFormat.dayjs(newValue, this.format).toISOString();
10917
+ ? newValue.map((date) => dateError.dayjs(date, this.format).toISOString())
10918
+ : dateError.dayjs(newValue, this.format).toISOString();
10917
10919
  let content = "";
10918
10920
  if (Array.isArray(newValueInIsoFormat)) {
10919
10921
  if (newValueInIsoFormat.length === 1) {
@@ -10956,7 +10958,7 @@ const TabworthyDates = class {
10956
10958
  if (this.pickerRef) {
10957
10959
  if (Array.isArray(value)) {
10958
10960
  const dates = value.reduce((acc, v) => {
10959
- const d = customParseFormat.dayjs(v, this.format, true);
10961
+ const d = dateError.dayjs(v, this.format, true);
10960
10962
  if (d.isValid())
10961
10963
  acc.push(d.toDate());
10962
10964
  return acc;
@@ -10965,7 +10967,7 @@ const TabworthyDates = class {
10965
10967
  }
10966
10968
  else {
10967
10969
  if (value) {
10968
- const parsedDate = customParseFormat.dayjs(value, this.format, true);
10970
+ const parsedDate = dateError.dayjs(value, this.format, true);
10969
10971
  if (parsedDate.isValid()) {
10970
10972
  this.pickerRef.value = parsedDate.toDate();
10971
10973
  }
@@ -10999,7 +11001,7 @@ const TabworthyDates = class {
10999
11001
  return (index$1.h(index$1.Host, null, index$1.h("label", { htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", null), index$1.h("div", { class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index$1.h("input", { disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
11000
11002
  [this.getClassName("input")]: true,
11001
11003
  [this.inputClass]: !!this.inputClass
11002
- }, 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", { type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
11004
+ }, 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", { type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
11003
11005
  ? this.datesLabels.openCalendar
11004
11006
  : undefined }, this.calendarButtonContent ? (index$1.h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), index$1.h("tabworthy-dates-modal", { label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
11005
11007
  if (!this.pickerRef)
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-B1s0tI-Z.js');
4
- var customParseFormat = require('./customParseFormat-l09KVyWD.js');
4
+ var dateError = require('./date-error-CCtoCDtq.js');
5
5
  var utils = require('./utils-DGbdK8VF.js');
6
6
 
7
7
  var localizedFormat$2 = {exports: {}};
@@ -20,10 +20,10 @@ function requireLocalizedFormat () {
20
20
  }
21
21
 
22
22
  var localizedFormatExports = requireLocalizedFormat();
23
- var localizedFormat = /*@__PURE__*/customParseFormat.getDefaultExportFromCjs(localizedFormatExports);
23
+ var localizedFormat = /*@__PURE__*/dateError.getDefaultExportFromCjs(localizedFormatExports);
24
24
 
25
- customParseFormat.dayjs.extend(customParseFormat.customParseFormat);
26
- customParseFormat.dayjs.extend(localizedFormat);
25
+ dateError.dayjs.extend(dateError.customParseFormat);
26
+ dateError.dayjs.extend(localizedFormat);
27
27
  const defaultLabels = {
28
28
  selected: "selected",
29
29
  openCalendar: "Choose time",
@@ -145,7 +145,7 @@ const TabworthyTimes = class {
145
145
  this.handleCalendarButtonClick = async () => {
146
146
  if (this.modalRef) {
147
147
  // Use input container as trigger for proper dropdown alignment
148
- await this.modalRef.setTriggerElement(this.inputContainerRef);
148
+ await this.modalRef.setTriggerElement(this.inputContainerRef, this.calendarButtonRef);
149
149
  await this.modalRef.open();
150
150
  }
151
151
  };
@@ -176,22 +176,22 @@ const TabworthyTimes = class {
176
176
  }
177
177
  // Try to parse the input value using the component's format first (strict mode)
178
178
  // This prevents dayjs from misinterpreting date formats (e.g., DD/MM/YYYY as MM/DD/YYYY)
179
- let parsed = customParseFormat.dayjs(value, this.format, true);
179
+ let parsed = dateError.dayjs(value, this.format, true);
180
180
  // Fall back to loose parsing if strict format doesn't match
181
181
  if (!parsed.isValid()) {
182
- parsed = customParseFormat.dayjs(value);
182
+ parsed = dateError.dayjs(value);
183
183
  }
184
184
  if (parsed.isValid()) {
185
185
  // Check minDate/maxDate bounds (supports both date-only and datetime strings)
186
- if (this.minDate && parsed.isBefore(customParseFormat.dayjs(this.minDate))) {
186
+ if (this.minDate && parsed.isBefore(dateError.dayjs(this.minDate))) {
187
187
  this.errorState = true;
188
- this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
188
+ this.errorMessage = dateError.formatDateError(this.timesLabels.minDateError, this.formatBoundaryDate(this.minDate));
189
189
  this.emitErrorChange("minDate", this.errorMessage);
190
190
  return;
191
191
  }
192
- if (this.maxDate && parsed.isAfter(customParseFormat.dayjs(this.maxDate))) {
192
+ if (this.maxDate && parsed.isAfter(dateError.dayjs(this.maxDate))) {
193
193
  this.errorState = true;
194
- this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
194
+ this.errorMessage = dateError.formatDateError(this.timesLabels.maxDateError, this.formatBoundaryDate(this.maxDate));
195
195
  this.emitErrorChange("maxDate", this.errorMessage);
196
196
  return;
197
197
  }
@@ -219,7 +219,7 @@ const TabworthyTimes = class {
219
219
  this.errorChange.emit({ reason, message });
220
220
  }
221
221
  formatBoundaryDate(dateString) {
222
- const parsed = customParseFormat.dayjs(dateString);
222
+ const parsed = dateError.dayjs(dateString);
223
223
  if (!parsed.isValid())
224
224
  return dateString;
225
225
  const hasTime = dateString.includes("T") || dateString.includes(" ");
@@ -236,8 +236,8 @@ const TabworthyTimes = class {
236
236
  getEffectiveMinTime() {
237
237
  if (!this.minDate || !this.selectedDate)
238
238
  return undefined;
239
- const min = customParseFormat.dayjs(this.minDate);
240
- const sel = customParseFormat.dayjs(this.selectedDate);
239
+ const min = dateError.dayjs(this.minDate);
240
+ const sel = dateError.dayjs(this.selectedDate);
241
241
  if (!min.isValid() || !sel.isSame(min, "day"))
242
242
  return undefined;
243
243
  return {
@@ -249,8 +249,8 @@ const TabworthyTimes = class {
249
249
  getEffectiveMaxTime() {
250
250
  if (!this.maxDate || !this.selectedDate)
251
251
  return undefined;
252
- const max = customParseFormat.dayjs(this.maxDate);
253
- const sel = customParseFormat.dayjs(this.selectedDate);
252
+ const max = dateError.dayjs(this.maxDate);
253
+ const sel = dateError.dayjs(this.selectedDate);
254
254
  if (!max.isValid() || !sel.isSame(max, "day"))
255
255
  return undefined;
256
256
  return {
@@ -262,10 +262,10 @@ const TabworthyTimes = class {
262
262
  isDateOutOfBounds() {
263
263
  if (!this.selectedDate)
264
264
  return false;
265
- const sel = customParseFormat.dayjs(this.selectedDate);
266
- if (this.minDate && sel.isBefore(customParseFormat.dayjs(this.minDate), "day"))
265
+ const sel = dateError.dayjs(this.selectedDate);
266
+ if (this.minDate && sel.isBefore(dateError.dayjs(this.minDate), "day"))
267
267
  return true;
268
- if (this.maxDate && sel.isAfter(customParseFormat.dayjs(this.maxDate), "day"))
268
+ if (this.maxDate && sel.isAfter(dateError.dayjs(this.maxDate), "day"))
269
269
  return true;
270
270
  return false;
271
271
  }
@@ -274,9 +274,9 @@ const TabworthyTimes = class {
274
274
  * available time if the current selection falls outside the allowed range.
275
275
  */
276
276
  clampTimeToBounds(date) {
277
- const sel = customParseFormat.dayjs(date);
277
+ const sel = dateError.dayjs(date);
278
278
  if (this.minDate) {
279
- const min = customParseFormat.dayjs(this.minDate);
279
+ const min = dateError.dayjs(this.minDate);
280
280
  if (min.isValid() && sel.isSame(min, "day")) {
281
281
  const curTotal = this.selectedHours * 3600 +
282
282
  this.selectedMinutes * 60 +
@@ -290,7 +290,7 @@ const TabworthyTimes = class {
290
290
  }
291
291
  }
292
292
  if (this.maxDate) {
293
- const max = customParseFormat.dayjs(this.maxDate);
293
+ const max = dateError.dayjs(this.maxDate);
294
294
  if (max.isValid() && sel.isSame(max, "day")) {
295
295
  const curTotal = this.selectedHours * 3600 +
296
296
  this.selectedMinutes * 60 +
@@ -313,7 +313,7 @@ const TabworthyTimes = class {
313
313
  getDateForTimeOnlyValue() {
314
314
  if (this.selectedDate)
315
315
  return this.selectedDate;
316
- const referenceDate = customParseFormat.dayjs(this.referenceDate);
316
+ const referenceDate = dateError.dayjs(this.referenceDate);
317
317
  if (referenceDate.isValid())
318
318
  return referenceDate.toDate();
319
319
  return new Date();
@@ -340,7 +340,7 @@ const TabworthyTimes = class {
340
340
  // Parse the first datetime value to set time picker
341
341
  const firstValue = Array.isArray(this.value) ? this.value[0] : this.value;
342
342
  if (firstValue) {
343
- const parsed = customParseFormat.dayjs(firstValue, this.format);
343
+ const parsed = dateError.dayjs(firstValue, this.format);
344
344
  if (parsed.isValid()) {
345
345
  this.selectedDate = parsed.toDate();
346
346
  this.selectedHours = parsed.hour();
@@ -356,7 +356,7 @@ const TabworthyTimes = class {
356
356
  if (this.pickerRef) {
357
357
  if (Array.isArray(this.value)) {
358
358
  const dates = this.value.reduce((acc, v) => {
359
- const d = customParseFormat.dayjs(v, this.format, true);
359
+ const d = dateError.dayjs(v, this.format, true);
360
360
  if (d.isValid())
361
361
  acc.push(d.toDate());
362
362
  return acc;
@@ -364,7 +364,7 @@ const TabworthyTimes = class {
364
364
  this.pickerRef.value = dates.length ? dates : null;
365
365
  }
366
366
  else if (this.value) {
367
- const parsedDate = customParseFormat.dayjs(this.value, this.format, true);
367
+ const parsedDate = dateError.dayjs(this.value, this.format, true);
368
368
  if (parsedDate.isValid()) {
369
369
  this.pickerRef.value = parsedDate.toDate();
370
370
  }
@@ -391,7 +391,7 @@ const TabworthyTimes = class {
391
391
  if (Array.isArray(date)) {
392
392
  // Range mode
393
393
  const formattedDates = date.map((d) => {
394
- const m = customParseFormat.dayjs(d)
394
+ const m = dateError.dayjs(d)
395
395
  .hour(this.selectedHours)
396
396
  .minute(this.selectedMinutes)
397
397
  .second(this.selectedSeconds);
@@ -403,7 +403,7 @@ const TabworthyTimes = class {
403
403
  }
404
404
  else {
405
405
  // Single date mode
406
- const m = customParseFormat.dayjs(date)
406
+ const m = dateError.dayjs(date)
407
407
  .hour(this.selectedHours)
408
408
  .minute(this.selectedMinutes)
409
409
  .second(this.selectedSeconds);
@@ -419,18 +419,18 @@ const TabworthyTimes = class {
419
419
  }
420
420
  }
421
421
  isDateValid(date) {
422
- const parsed = customParseFormat.dayjs(date);
422
+ const parsed = dateError.dayjs(date);
423
423
  if (!parsed.isValid())
424
424
  return false;
425
- if (this.minDate && parsed.isBefore(customParseFormat.dayjs(this.minDate), "day")) {
425
+ if (this.minDate && parsed.isBefore(dateError.dayjs(this.minDate), "day")) {
426
426
  this.errorState = true;
427
- this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
427
+ this.errorMessage = dateError.formatDateError(this.timesLabels.minDateError, this.formatBoundaryDate(this.minDate));
428
428
  this.emitErrorChange("minDate", this.errorMessage);
429
429
  return false;
430
430
  }
431
- if (this.maxDate && parsed.isAfter(customParseFormat.dayjs(this.maxDate), "day")) {
431
+ if (this.maxDate && parsed.isAfter(dateError.dayjs(this.maxDate), "day")) {
432
432
  this.errorState = true;
433
- this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
433
+ this.errorMessage = dateError.formatDateError(this.timesLabels.maxDateError, this.formatBoundaryDate(this.maxDate));
434
434
  this.emitErrorChange("maxDate", this.errorMessage);
435
435
  return false;
436
436
  }
@@ -448,16 +448,16 @@ const TabworthyTimes = class {
448
448
  if (Array.isArray(this.internalValue)) {
449
449
  // Format range
450
450
  const formatted = this.internalValue
451
- .map((v) => customParseFormat.dayjs(v, this.format).format("lll"))
451
+ .map((v) => dateError.dayjs(v, this.format).format("lll"))
452
452
  .join(` ${this.timesLabels.to} `);
453
453
  this.inputRef.value = formatted;
454
454
  }
455
455
  else if (this.timeOnly) {
456
- this.inputRef.value = customParseFormat.dayjs(this.internalValue, this.format).format(this.showSeconds ? "LTS" : "LT");
456
+ this.inputRef.value = dateError.dayjs(this.internalValue, this.format).format(this.showSeconds ? "LTS" : "LT");
457
457
  }
458
458
  else {
459
459
  // Format single datetime
460
- this.inputRef.value = customParseFormat.dayjs(this.internalValue, this.format).format("lll");
460
+ this.inputRef.value = dateError.dayjs(this.internalValue, this.format).format("lll");
461
461
  }
462
462
  }
463
463
  getClassName(suffix) {
@@ -467,8 +467,8 @@ const TabworthyTimes = class {
467
467
  if (!dateString)
468
468
  return null;
469
469
  const date = Array.isArray(dateString)
470
- ? dateString.map((d) => customParseFormat.dayjs(d, this.format).toDate())
471
- : customParseFormat.dayjs(dateString, this.format).toDate();
470
+ ? dateString.map((d) => dateError.dayjs(d, this.format).toDate())
471
+ : dateError.dayjs(dateString, this.format).toDate();
472
472
  return date;
473
473
  }
474
474
  async revertInput(newValue, clearError = false) {
@@ -491,12 +491,12 @@ const TabworthyTimes = class {
491
491
  }
492
492
  render() {
493
493
  var _a;
494
- return (index.h(index.Host, { key: 'ab639b86fb2e2afe854a1253a2caab53a82f9cc0', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState, "time-only": this.timeOnly }, index.h("label", { key: '55dd4b279bc847151a5f3cb50f98bddb62c2965c', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: '5aa75daa3ee2d7de8f8385d5871dd732ce6c5d3c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: '49912db4c96619e20e818b494d553aad293920a8', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
494
+ return (index.h(index.Host, { key: 'eb40f4186e17019d6c0e7f59cd6c34ee65550fd8', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState, "time-only": this.timeOnly }, index.h("label", { key: '6d1f0deae328d66331350247da217c428910ddfb', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: 'd7721562f0eeb5be4f6b68ff8e1c01c4ed08fe1b', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: '1e4b4bd45f63aa5357505f58edde39739a51a124', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
495
495
  [this.getClassName("input")]: true,
496
496
  [this.inputClass]: !!this.inputClass
497
- }, 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: 'f22378a0ad106f560ed0d1e02e3b22b43e725289', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
497
+ }, 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: 'c5789e7d45619291c38895ba184c6ec74d73c584', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
498
498
  ? this.timesLabels.openCalendar
499
- : undefined }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: 'c0f14cf67c2da5a3c4917b388949458e410009e8', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
499
+ : undefined }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: 'af58b555642816b299cf50394148ed17c427db21', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
500
500
  if (this.pickerRef) {
501
501
  this.pickerRef.modalIsOpen = true;
502
502
  }
@@ -510,7 +510,7 @@ const TabworthyTimes = class {
510
510
  if (this.timePickerRef) {
511
511
  this.timePickerRef.modalIsOpen = false;
512
512
  }
513
- }, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: 'c7051d360cfba74d9e0b3a8702683da2f79c013c', class: this.getClassName("picker-container") }, !this.timeOnly && (index.h("tabworthy-dates-calendar", { key: 'c9c72c072116568cd6ca0ce99de136940876e3b0', 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, nextMonthButtonContent: this.nextMonthButtonContent, nextYearButtonContent: this.nextYearButtonContent, previousMonthButtonContent: this.previousMonthButtonContent, previousYearButtonContent: this.previousYearButtonContent, todayButtonContent: this.todayButtonContent, clearButtonContent: this.clearButtonContent, closeButtonContent: this.closeButtonContent }, index.h("div", { key: '325945a90d36cb39ef23db27f99fd6224984b735', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: 'ff305cef7f526fb05dd3f193ea4093f0064fc813', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: 'ad163d7fa0c3282312b848a758bfcc8b08a663ad', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime(), ref: (el) => (this.timePickerRef = el) })))), this.timeOnly && (index.h("div", { key: 'c19252f05b91934af956c5ed9453185e591c4f71', class: this.getClassName("time-section") }, index.h("tabworthy-times-picker", { key: 'd8456d201c430625d2181a7da76f0ec5a471aec4', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime(), ref: (el) => (this.timePickerRef = el) }))))), this.errorState && (index.h("div", { key: '0968907cbf6971aa00a486184394fe7d342ee237', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
513
+ }, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '1bc48335f50777efd746a2737ac6acc60a72dec3', class: this.getClassName("picker-container") }, !this.timeOnly && (index.h("tabworthy-dates-calendar", { key: 'd0bdb6e18676f0019be5fd939a19075927b10fa4', 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, nextMonthButtonContent: this.nextMonthButtonContent, nextYearButtonContent: this.nextYearButtonContent, previousMonthButtonContent: this.previousMonthButtonContent, previousYearButtonContent: this.previousYearButtonContent, todayButtonContent: this.todayButtonContent, clearButtonContent: this.clearButtonContent, closeButtonContent: this.closeButtonContent }, index.h("div", { key: '042f5fa7e60b67858ea7f92ca80792953b38d0a1', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '7262873201e1294e6116fea1f429c71e37bf06c2', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '46a179fd9ce95d53e144d0b03a77311e4daa3c10', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime(), ref: (el) => (this.timePickerRef = el) })))), this.timeOnly && (index.h("div", { key: 'eaedaf5a7157dbdc99a947b6eb3e55f696556371', class: this.getClassName("time-section") }, index.h("tabworthy-times-picker", { key: '504ea7e3069134e695d09ef48834b947de629b5e', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime(), ref: (el) => (this.timePickerRef = el) }))))), this.errorState && (index.h("div", { key: '961823a7550b5439d2768f80317422b057758de3', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
514
514
  }
515
515
  get el() { return index.getElement(this); }
516
516
  static get watchers() { return {
@@ -5,6 +5,7 @@ import customParseFormat from "dayjs/plugin/customParseFormat";
5
5
  dayjs.extend(customParseFormat);
6
6
  import { getISODateString, parseDateString, removeTimezoneOffset } from "../../../../shared/utils/utils";
7
7
  import { chronoParseDate, chronoParseRange } from "../../../../shared/utils/chrono-parser/chrono-parser";
8
+ import { formatDateError } from "../../utils/date-error";
8
9
  const defaultLabels = {
9
10
  selected: "selected",
10
11
  openCalendar: "Open calendar",
@@ -88,7 +89,7 @@ export class TabworthyDates {
88
89
  await customElements.whenDefined("tabworthy-dates-modal");
89
90
  // Use input container as trigger for proper dropdown alignment
90
91
  this.inputContainerRef &&
91
- (await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef)));
92
+ (await ((_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.setTriggerElement(this.inputContainerRef, this.calendarButtonRef)));
92
93
  if ((await ((_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.getState())) === false)
93
94
  await ((_c = this.modalRef) === null || _c === void 0 ? void 0 : _c.open());
94
95
  else if ((await ((_d = this.modalRef) === null || _d === void 0 ? void 0 : _d.getState())) === true)
@@ -238,18 +239,13 @@ export class TabworthyDates {
238
239
  minDate === null || minDate === void 0 ? void 0 : minDate.setDate(minDate.getDate() - 1);
239
240
  }
240
241
  if (!!parsedDate.reason) {
241
- const formatLocalizedDate = (date) => Intl.DateTimeFormat(this.locale, {
242
- day: "numeric",
243
- month: "short",
244
- year: "numeric"
245
- }).format(date);
246
242
  this.errorMessage = parsedDate.reason;
247
243
  this.errorMessage = {
248
244
  minDate: minDate
249
- ? `${this.datesLabels.minDateError} ${formatLocalizedDate(minDate)}`
245
+ ? formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(minDate))
250
246
  : "",
251
247
  maxDate: maxDate
252
- ? `${this.datesLabels.maxDateError} ${formatLocalizedDate(maxDate)}`
248
+ ? formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(maxDate))
253
249
  : "",
254
250
  invalid: this.datesLabels.invalidDateError
255
251
  }[parsedDate.reason];
@@ -332,6 +328,13 @@ export class TabworthyDates {
332
328
  emitErrorChange(reason, message) {
333
329
  this.errorChange.emit({ reason, message });
334
330
  }
331
+ formatBoundaryDate(date) {
332
+ return Intl.DateTimeFormat(this.locale, {
333
+ day: "numeric",
334
+ month: "short",
335
+ year: "numeric"
336
+ }).format(date);
337
+ }
335
338
  formatInput(enabled, useInputValue = true) {
336
339
  if (this.shouldInputFormat() === false || enabled === false) {
337
340
  if (this.internalValue) {
@@ -384,13 +387,13 @@ export class TabworthyDates {
384
387
  const isoDate = typeof dateString === "string" ? dateString : parsed.format("YYYY-MM-DD");
385
388
  if (this.minDate && isoDate < this.minDate) {
386
389
  this.errorState = true;
387
- this.errorMessage = `${this.datesLabels.minDateError} ${this.minDate}`;
390
+ this.errorMessage = formatDateError(this.datesLabels.minDateError, this.formatBoundaryDate(parseDateString(this.minDate)));
388
391
  this.emitErrorChange("minDate", this.errorMessage);
389
392
  return false;
390
393
  }
391
394
  if (this.maxDate && isoDate > this.maxDate) {
392
395
  this.errorState = true;
393
- this.errorMessage = `${this.datesLabels.maxDateError} ${this.maxDate}`;
396
+ this.errorMessage = formatDateError(this.datesLabels.maxDateError, this.formatBoundaryDate(parseDateString(this.maxDate)));
394
397
  this.emitErrorChange("maxDate", this.errorMessage);
395
398
  return false;
396
399
  }
@@ -530,7 +533,7 @@ export class TabworthyDates {
530
533
  return (h(Host, null, h("label", { htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", null), h("div", { class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
531
534
  [this.getClassName("input")]: true,
532
535
  [this.inputClass]: !!this.inputClass
533
- }, 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", { type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
536
+ }, 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", { type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
534
537
  ? this.datesLabels.openCalendar
535
538
  : undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), h("tabworthy-dates-modal", { label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
536
539
  if (!this.pickerRef)