@tabworthy/components 0.12.3 → 0.13.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 (44) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/tabworthy-components.cjs.js +1 -1
  3. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +39 -15
  4. package/dist/cjs/tabworthy-dates.cjs.entry.js +52 -12
  5. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +82 -10
  6. package/dist/cjs/tabworthy-times.cjs.entry.js +109 -4
  7. package/dist/cjs/{utils-y5Vtky2t.js → utils-DGbdK8VF.js} +29 -8
  8. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +148 -12
  9. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +39 -15
  10. package/dist/collection/components/tabworthy-times/tabworthy-times.js +262 -3
  11. package/dist/collection/components/tabworthy-times-picker/tabworthy-times-picker.js +128 -10
  12. package/dist/components/p-BzY8iIVW.js +1 -0
  13. package/dist/components/p-C_uZGgcG.js +1 -0
  14. package/dist/components/tabworthy-dates-calendar.js +1 -1
  15. package/dist/components/tabworthy-dates.js +1 -1
  16. package/dist/components/tabworthy-times-picker.js +1 -1
  17. package/dist/components/tabworthy-times.js +1 -1
  18. package/dist/esm/loader.js +1 -1
  19. package/dist/esm/tabworthy-components.js +1 -1
  20. package/dist/esm/tabworthy-dates-calendar_2.entry.js +39 -15
  21. package/dist/esm/tabworthy-dates.entry.js +52 -12
  22. package/dist/esm/tabworthy-times-picker.entry.js +82 -10
  23. package/dist/esm/tabworthy-times.entry.js +109 -4
  24. package/dist/esm/{utils-BVHu5CWV.js → utils-CoFOnMSw.js} +29 -9
  25. package/dist/shared/utils/utils.js +28 -8
  26. package/dist/tabworthy-components/p-69334c34.entry.js +1 -0
  27. package/dist/tabworthy-components/p-71f5c261.entry.js +1 -0
  28. package/dist/tabworthy-components/p-7cd6ccc1.entry.js +1 -0
  29. package/dist/tabworthy-components/{p-BVHu5CWV.js → p-CoFOnMSw.js} +1 -1
  30. package/dist/tabworthy-components/p-ed3c60d6.entry.js +1 -0
  31. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
  32. package/dist/themes/light.css +1 -1
  33. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +11 -0
  34. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +15 -1
  35. package/dist/types/components/tabworthy-times-picker/tabworthy-times-picker.d.ts +15 -0
  36. package/dist/types/components.d.ts +47 -4
  37. package/dist/types/home/runner/work/tabworthy-components/tabworthy-components/.stencil/shared/utils/utils.d.ts +6 -0
  38. package/package.json +1 -1
  39. package/dist/components/p-BTQaxOHo.js +0 -1
  40. package/dist/components/p-CkD8Cvl_.js +0 -1
  41. package/dist/tabworthy-components/p-04240a8d.entry.js +0 -1
  42. package/dist/tabworthy-components/p-1743bf7a.entry.js +0 -1
  43. package/dist/tabworthy-components/p-744ffef9.entry.js +0 -1
  44. package/dist/tabworthy-components/p-8ccc0de2.entry.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { h, Host } from "@stencil/core";
2
- import { addDays, dateIsWithinLowerBounds, dateIsWithinUpperBounds, getDaysOfMonth, getFirstOfMonth, getISODateString, getLastOfMonth, getMonth, getMonths, getNextDay, getNextMonth, getNextYear, getPreviousDay, getPreviousMonth, getPreviousYear, getWeekDays, getYear, isDateInRange, isSameDay, monthIsDisabled, removeTimezoneOffset, subDays } from "../../../../shared/utils/utils";
2
+ import { addDays, dateIsWithinLowerBounds, dateIsWithinUpperBounds, getDaysOfMonth, getFirstOfMonth, getISODateString, getLastOfMonth, getMonth, getMonths, getNextDay, getNextMonth, getNextYear, getPreviousDay, getPreviousMonth, getPreviousYear, getWeekDays, getYear, isDateInRange, isSameDay, monthIsDisabled, parseDateString, removeTimezoneOffset, subDays } from "../../../../shared/utils/utils";
3
3
  import { dateIsWithinBounds } from "../../../../shared/utils/utils";
4
4
  const defaultLabels = {
5
5
  clearButton: "Clear value",
@@ -43,16 +43,34 @@ export class TabworthyDatesCalendar {
43
43
  this.updateWeekdays();
44
44
  };
45
45
  this.nextMonth = () => {
46
- this.updateCurrentDate(getNextMonth(this.currentDate));
46
+ const next = getNextMonth(this.currentDate);
47
+ if (this.disabled ||
48
+ monthIsDisabled(next.getMonth(), next.getFullYear(), this.minDate, this.maxDate))
49
+ return;
50
+ this.updateCurrentDate(next);
47
51
  };
48
52
  this.nextYear = () => {
49
- this.updateCurrentDate(getNextYear(this.currentDate), false, true);
53
+ const next = getNextYear(this.currentDate);
54
+ if (this.disabled ||
55
+ (this.maxDate &&
56
+ parseDateString(this.maxDate).getFullYear() < next.getFullYear()))
57
+ return;
58
+ this.updateCurrentDate(next, false, true);
50
59
  };
51
60
  this.previousMonth = () => {
52
- this.updateCurrentDate(getPreviousMonth(this.currentDate));
61
+ const prev = getPreviousMonth(this.currentDate);
62
+ if (this.disabled ||
63
+ monthIsDisabled(prev.getMonth(), prev.getFullYear(), this.minDate, this.maxDate))
64
+ return;
65
+ this.updateCurrentDate(prev);
53
66
  };
54
67
  this.previousYear = () => {
55
- this.updateCurrentDate(getPreviousYear(this.currentDate), false, true);
68
+ const prev = getPreviousYear(this.currentDate);
69
+ if (this.disabled ||
70
+ (this.minDate &&
71
+ parseDateString(this.minDate).getFullYear() > prev.getFullYear()))
72
+ return;
73
+ this.updateCurrentDate(prev, false, true);
56
74
  };
57
75
  this.showToday = () => {
58
76
  this.updateCurrentDate(new Date(), true);
@@ -256,9 +274,9 @@ export class TabworthyDatesCalendar {
256
274
  const month = date.getMonth();
257
275
  const year = date.getFullYear();
258
276
  if (!dateIsWithinLowerBounds(date, this.minDate))
259
- date = new Date(this.minDate);
277
+ date = parseDateString(this.minDate);
260
278
  if (!dateIsWithinUpperBounds(date, this.maxDate))
261
- date = new Date(this.maxDate);
279
+ date = parseDateString(this.maxDate);
262
280
  const monthChanged = month !== ((_a = this.currentDate) === null || _a === void 0 ? void 0 : _a.getMonth()) ||
263
281
  year !== this.currentDate.getFullYear();
264
282
  if (monthChanged) {
@@ -315,11 +333,11 @@ export class TabworthyDatesCalendar {
315
333
  year: {
316
334
  prev: this.disabled ||
317
335
  (!!this.minDate &&
318
- new Date(this.minDate).getFullYear() >
336
+ parseDateString(this.minDate).getFullYear() >
319
337
  getPreviousYear(this.currentDate).getFullYear()),
320
338
  next: this.disabled ||
321
339
  (!!this.maxDate &&
322
- new Date(this.maxDate).getFullYear() <
340
+ parseDateString(this.maxDate).getFullYear() <
323
341
  getNextYear(this.currentDate).getFullYear())
324
342
  },
325
343
  month: {
@@ -329,15 +347,15 @@ export class TabworthyDatesCalendar {
329
347
  monthIsDisabled(getNextMonth(this.currentDate).getMonth(), getNextMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate)
330
348
  }
331
349
  };
332
- return (h(Host, { key: '1bda8d7a489d87cf27ecbcd978accf5363f32804' }, h("div", { key: '7118660fbbdfac4a73a1ace99d96d4ac32a4b137', class: {
350
+ return (h(Host, { key: '60e2a56f8a1aadceb57d7f445098060293a0f937' }, h("div", { key: '12fd35c03b0c34e4ad88e4e491fcc685de5f09b2', class: {
333
351
  [`${this.getClassName()}-wrapper`]: true,
334
352
  [`${this.getClassName()}-wrapper--inline`]: this.inline
335
- } }, h("div", { key: '41b62826cdff428aef8ad89844a50873f8853b5e', class: {
353
+ } }, h("div", { key: 'ad36d1e260a7a89110c53fc86e339eb5a259a4fc', class: {
336
354
  [this.getClassName()]: true,
337
355
  [`${this.getClassName()}--disabled`]: this.disabled
338
- } }, h("div", { key: '7a9ee67778c6f48e65d88defc1ff620e995d75bc', class: this.getClassName("header") }, this.showHiddenTitle && (h("span", { key: '404e50ab0f24235d6678af7c12f6b3cdd491e347', "aria-atomic": "true", "aria-live": "polite", class: "visually-hidden" }, this.getTitle())), this.showYearStepper && (h("button", { key: '88552edc01ae9c4a7d8225c2aab078d2123bf9f6', "aria-label": this.labels.previousYearButton, class: this.getClassName("previous-year-button"), "aria-disabled": disabled.year.prev, innerHTML: this.previousYearButtonContent || undefined, onClick: this.previousYear, type: "button" }, h("svg", { key: '5daef016748f562ddf3866557774c87016887fc6', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: '5b73b6ec2b5abcae4d2e5cd833b5de441938e533', points: "11 17 6 12 11 7" }), h("polyline", { key: '05e146e1c233c39403147e7af61948798db7c0f7', points: "18 17 13 12 18 7" })))), this.showMonthStepper && (h("button", { key: '6145f62f073563e9136ad454f4e9633e99b8d8a9', "aria-label": this.labels.previousMonthButton, class: this.getClassName("previous-month-button"), "aria-disabled": disabled.month.prev, innerHTML: this.previousMonthButtonContent || undefined, onClick: this.previousMonth, type: "button" }, h("svg", { key: '8ae9cc385a6fdbdd915a2717246752c7f2f17b01', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: '9395192e65c1e550547220850b29a117569a79e2', points: "15 18 9 12 15 6" })))), h("span", { key: '3b282148e95b8b1facde4a2ab370c6088b72bccd', class: this.getClassName("current-month") }, h("select", { key: 'f782b9d803abd5eb1add6c869b3ac302a717780d', "aria-label": this.labels.monthSelect, class: this.getClassName("month-select"), "aria-disabled": this.disabled, name: "month", onChange: this.onMonthSelect }, getMonths(this.locale).map((month, index) => {
356
+ } }, h("div", { key: '181b9ed0a6a9d6073d67f270d6b14efc28f6a6b2', class: this.getClassName("header") }, this.showHiddenTitle && (h("span", { key: '580656924dc3ba028458591399791423797d58d7', "aria-atomic": "true", "aria-live": "polite", class: "visually-hidden" }, this.getTitle())), this.showYearStepper && (h("button", { key: '7822100c140418bc3cb65ae39a32a3ebc1f53bc2', "aria-label": this.labels.previousYearButton, class: this.getClassName("previous-year-button"), "aria-disabled": disabled.year.prev, innerHTML: this.previousYearButtonContent || undefined, onClick: this.previousYear, type: "button" }, h("svg", { key: '9408d89cf59c268c3e44801297f1a7776a594539', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: 'b9108784891de5eb7acef5c14425e90c25fc514a', points: "11 17 6 12 11 7" }), h("polyline", { key: 'a2fbabe46f6a0584d5c4b54296b9db13e979c818', points: "18 17 13 12 18 7" })))), this.showMonthStepper && (h("button", { key: '8e515d4fa9fde9f0e16fc2ff5629049039df09e0', "aria-label": this.labels.previousMonthButton, class: this.getClassName("previous-month-button"), "aria-disabled": disabled.month.prev, innerHTML: this.previousMonthButtonContent || undefined, onClick: this.previousMonth, type: "button" }, h("svg", { key: '5248668ca2f843102193fb57beb8a3a4b4edbb96', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: '021c514ec8fb801fd0d3dbf250fc8d55b9c9ef08', points: "15 18 9 12 15 6" })))), h("span", { key: '8fab6b75376e1399b6ea07e3545ddcfa3eb120d8', class: this.getClassName("current-month") }, h("select", { key: '01f8fbd5a76c91b0bf121c2589af72860abe2a22', "aria-label": this.labels.monthSelect, class: this.getClassName("month-select"), "aria-disabled": this.disabled, name: "month", onChange: this.onMonthSelect }, getMonths(this.locale).map((month, index) => {
339
357
  return (h("option", { key: month, selected: this.currentDate.getMonth() === index, value: index + 1, disabled: monthIsDisabled(index, this.currentDate.getFullYear(), this.minDate, this.maxDate) }, month));
340
- })), h("input", { key: 'dcd8a96a130513d1cf34d900d6f8c09ce974ba15', "aria-label": this.labels.yearSelect, class: this.getClassName("year-select"), "aria-disabled": this.disabled, max: this.maxDate ? this.maxDate.slice(0, 4) : 9999, min: this.minDate ? this.minDate.slice(0, 4) : 1, name: "year", onChange: this.onYearSelect, type: "number", value: this.currentDate.getFullYear() })), this.showMonthStepper && (h("button", { key: '7de261689d242a0116e85f3c5fda265f49eaaf13', "aria-label": this.labels.nextMonthButton, class: this.getClassName("next-month-button"), "aria-disabled": disabled.month.next, innerHTML: this.nextMonthButtonContent || undefined, onClick: this.nextMonth, type: "button" }, h("svg", { key: '2033c731d98fd53088857a92bdd35e5e977137d7', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: 'dc88e8e5e4f79d5ae0b62ea51f6ba52d5e26ce9f', points: "9 18 15 12 9 6" })))), this.showYearStepper && (h("button", { key: 'e25bcd81e34e0e162954b2ab67876c148f50f5d4', "aria-label": this.labels.nextYearButton, class: this.getClassName("next-year-button"), "aria-disabled": disabled.year.next, innerHTML: this.nextYearButtonContent || undefined, onClick: this.nextYear, type: "button" }, h("svg", { key: '70df81cfd06bcb1e6571933b7a43a5071522159b', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: 'f8242866ca29743b19055d1ac53fcc8e84d68a35', points: "13 17 18 12 13 7" }), h("polyline", { key: '6bda80ff2eba82dac0d36e287976130e6b16113c', points: "6 17 11 12 6 7" }))))), h("div", { key: '6d5b0085437827c1db975f12dc5fe5927c7ba62f', class: this.getClassName("body") }, h("table", { key: '61975eac4e06c3a416fcb9503eef9c7a386a6b54', class: this.getClassName("calendar"), onKeyDown: this.onKeyDown, role: "grid", "aria-label": this.getTitle() }, h("thead", { key: 'fd259bd5ba6e12ff39dad5a31133913d17fdf276', class: this.getClassName("calendar-header") }, h("tr", { key: '410c84eabac58cf6139dd6c886b4803772abceb5', class: this.getClassName("weekday-row") }, (_a = this.weekdays) === null || _a === void 0 ? void 0 : _a.map((weekday) => (h("th", { role: "columnheader", abbr: weekday[1], class: this.getClassName("weekday"), key: weekday[0], scope: "col" }, h("span", { "aria-hidden": "true" }, weekday[0]), h("span", { class: "visually-hidden" }, weekday[1])))))), h("tbody", { key: '330d3b922d474b42edf0764556d2f2643b5b639d' }, this.getCalendarRows().map((calendarRow) => {
358
+ })), h("input", { key: 'cb126814e09a6ae81ce8a6db10152decef97d66a', "aria-label": this.labels.yearSelect, class: this.getClassName("year-select"), "aria-disabled": this.disabled, max: this.maxDate ? this.maxDate.slice(0, 4) : 9999, min: this.minDate ? this.minDate.slice(0, 4) : 1, name: "year", onChange: this.onYearSelect, type: "number", value: this.currentDate.getFullYear() })), this.showMonthStepper && (h("button", { key: '9ad3e382b769ada1ecb746a55c37c54d0c6b06e1', "aria-label": this.labels.nextMonthButton, class: this.getClassName("next-month-button"), "aria-disabled": disabled.month.next, innerHTML: this.nextMonthButtonContent || undefined, onClick: this.nextMonth, type: "button" }, h("svg", { key: '7ecdf33b13950c8972b5b3a66bd086f700967fad', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: '78768373bb23d06e8babd79a77fb0a899ea5e942', points: "9 18 15 12 9 6" })))), this.showYearStepper && (h("button", { key: 'ab920b5dbdf0bf6000c58718d0d3a0e9a31bbebd', "aria-label": this.labels.nextYearButton, class: this.getClassName("next-year-button"), "aria-disabled": disabled.year.next, innerHTML: this.nextYearButtonContent || undefined, onClick: this.nextYear, type: "button" }, h("svg", { key: '7f5c83e6333e6c33984961722c855f2609e0999e', fill: "none", height: "24", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "24" }, h("polyline", { key: 'dd3eed1b08d0373a089beb91eb9cb6b62b477b3b', points: "13 17 18 12 13 7" }), h("polyline", { key: 'fa989db37ceaf95817aef623770b895b3c10d0b4', points: "6 17 11 12 6 7" }))))), h("div", { key: '5b41060ca782df39e19ba35ec71d4425ae5c3a2a', class: this.getClassName("body") }, h("table", { key: '357337fd3a5f05cc204982682c99f99c46dd4b29', class: this.getClassName("calendar"), onKeyDown: this.onKeyDown, role: "grid", "aria-label": this.getTitle() }, h("thead", { key: '8fa7ecfada004b39dd406eb9079de3eab66fe298', class: this.getClassName("calendar-header") }, h("tr", { key: '364f6021007700c2da60082fca32e4896e071ccd', class: this.getClassName("weekday-row") }, (_a = this.weekdays) === null || _a === void 0 ? void 0 : _a.map((weekday) => (h("th", { role: "columnheader", abbr: weekday[1], class: this.getClassName("weekday"), key: weekday[0], scope: "col" }, h("span", { "aria-hidden": "true" }, weekday[0]), h("span", { class: "visually-hidden" }, weekday[1])))))), h("tbody", { key: 'e0269bd5bfe1310a8950635441edc472e3a5f413' }, this.getCalendarRows().map((calendarRow) => {
341
359
  const rowKey = `row-${calendarRow[0].getMonth()}-${calendarRow[0].getDate()}`;
342
360
  return (h("tr", { class: this.getClassName("calendar-row"), key: rowKey }, calendarRow.map((day) => {
343
361
  var _a, _b, _c;
@@ -404,8 +422,14 @@ export class TabworthyDatesCalendar {
404
422
  ? 0
405
423
  : -1 }, h(Tag, { "aria-hidden": "true" }, day.getDate()), h("span", { class: "visually-hidden" }, getScreenReaderText())));
406
424
  })));
407
- })))), showFooter && (h("div", { key: '88362c2e1731e8813ad9c5da3b34f6afe16f2036', class: this.getClassName("footer") }, h("div", { key: 'e93a0b8fff1be09855ab87db159cb186b9339a39', class: this.getClassName("footer-buttons") }, this.showTodayButton && (h("button", { key: 'a5b88ad46182dc5367987bd78cb02e98cd63aaef', class: this.getClassName("today-button"), disabled: this.disabled, innerHTML: this.todayButtonContent || undefined, onClick: this.showToday, type: "button" }, this.labels.todayButton)), this.showClearButton && (h("button", { key: '3929f2d213399b656057010ccdbead8020b04c2d', class: this.getClassName("clear-button"), disabled: this.disabled, innerHTML: this.clearButtonContent || undefined, onClick: this.clear, type: "button" }, this.labels.clearButton)), this.showCloseButton && (h("button", { key: '800308eb41769813d9191bec7537385255039a80', class: this.getClassName("close-button"), disabled: this.disabled, innerHTML: this.closeButtonContent || undefined, onClick: this.close, type: "button" }, this.labels.closeButton))), this.showKeyboardHint &&
408
- !window.matchMedia("(pointer: coarse)").matches && (h("button", { key: '0b478f25499d1aec350b35bb9777c6ec03d7fea3', type: "button", onClick: () => alert("Todo: Add Keyboard helper!"), class: this.getClassName("keyboard-hint") }, h("svg", { key: '14840cb62c1a222a347e40f6d1ab043842377a49', xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "0 0 48 48", fill: "currentColor" }, h("path", { key: 'd73008de603c67c20e335845ce42d6eff3cf2fc6', d: "M7 38q-1.2 0-2.1-.925Q4 36.15 4 35V13q0-1.2.9-2.1.9-.9 2.1-.9h34q1.2 0 2.1.9.9.9.9 2.1v22q0 1.15-.9 2.075Q42.2 38 41 38Zm0-3h34V13H7v22Zm8-3.25h18v-3H15Zm-4.85-6.25h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm-24.7-6.25h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3ZM7 35V13v22Z" })), this.labels.keyboardHint))))), h("slot", { key: '4616ab014b3db34b2d42958aefdbc7795829bbba', name: "after-calendar" }))));
425
+ })))), showFooter && (h("div", { key: '4d18b821b06e4eb7fd2f1a1210fcab01d3acdd00', class: this.getClassName("footer") }, h("div", { key: 'fec534b0bff03bfe3e15a8842abbcca9b57e9a1c', class: this.getClassName("footer-buttons") }, this.showTodayButton && (h("button", { key: '0d8aed7413f313c2ab6aa9a634093de1d46cd7ce', "aria-label": this.todayButtonContent
426
+ ? this.labels.todayButton
427
+ : undefined, class: this.getClassName("today-button"), disabled: this.disabled, innerHTML: this.todayButtonContent || undefined, onClick: this.showToday, type: "button" }, !this.todayButtonContent && this.labels.todayButton)), this.showClearButton && (h("button", { key: '176c535cb85d6b95d40324a55aa11e1bc2faaa61', "aria-label": this.clearButtonContent
428
+ ? this.labels.clearButton
429
+ : undefined, class: this.getClassName("clear-button"), disabled: this.disabled, innerHTML: this.clearButtonContent || undefined, onClick: this.clear, type: "button" }, !this.clearButtonContent && this.labels.clearButton)), this.showCloseButton && (h("button", { key: 'cea15baf92edabea6841510459c6b05ebfaf81fa', "aria-label": this.closeButtonContent
430
+ ? this.labels.closeButton
431
+ : undefined, class: this.getClassName("close-button"), disabled: this.disabled, innerHTML: this.closeButtonContent || undefined, onClick: this.close, type: "button" }, !this.closeButtonContent && this.labels.closeButton))), this.showKeyboardHint &&
432
+ !window.matchMedia("(pointer: coarse)").matches && (h("button", { key: '51a48353fbb94243d93047141e26b8c8ef5545b2', type: "button", onClick: () => alert("Todo: Add Keyboard helper!"), class: this.getClassName("keyboard-hint") }, h("svg", { key: '2991aa978689e3a0bd4c795a8629451e252ccf41', xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "0 0 48 48", fill: "currentColor" }, h("path", { key: 'b84c3846f234a79e8c78eae3118aa2a9f24b8377', d: "M7 38q-1.2 0-2.1-.925Q4 36.15 4 35V13q0-1.2.9-2.1.9-.9 2.1-.9h34q1.2 0 2.1.9.9.9.9 2.1v22q0 1.15-.9 2.075Q42.2 38 41 38Zm0-3h34V13H7v22Zm8-3.25h18v-3H15Zm-4.85-6.25h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm-24.7-6.25h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3Zm6.2 0h3v-3h-3Zm6.15 0h3v-3h-3ZM7 35V13v22Z" })), this.labels.keyboardHint))))), h("slot", { key: '86e8fb8907bf11951461baaf41f92b29ce0cc413', name: "after-calendar" }))));
409
433
  }
410
434
  static get is() { return "tabworthy-dates-calendar"; }
411
435
  static get encapsulation() { return "scoped"; }
@@ -80,6 +80,8 @@ export class TabworthyTimes {
80
80
  if (this.range && dates.length === 2) {
81
81
  const startDate = removeTimezoneOffset(new Date(dates[0]));
82
82
  const endDate = removeTimezoneOffset(new Date(dates[1]));
83
+ if (!this.isDateValid(startDate) || !this.isDateValid(endDate))
84
+ return;
83
85
  this.updateValue([startDate, endDate]);
84
86
  // Update calendar with selected dates
85
87
  if (this.pickerRef) {
@@ -88,6 +90,8 @@ export class TabworthyTimes {
88
90
  }
89
91
  else {
90
92
  const date = removeTimezoneOffset(new Date(dates[0]));
93
+ if (!this.isDateValid(date))
94
+ return;
91
95
  this.updateValue(date);
92
96
  // Update calendar with selected date
93
97
  if (this.pickerRef) {
@@ -146,6 +150,25 @@ export class TabworthyTimes {
146
150
  parsed = dayjs(value);
147
151
  }
148
152
  if (parsed.isValid()) {
153
+ // Check minDate/maxDate bounds (supports both date-only and datetime strings)
154
+ if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
155
+ this.errorState = true;
156
+ this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
157
+ this.emitErrorChange("minDate", this.errorMessage);
158
+ return;
159
+ }
160
+ if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
161
+ this.errorState = true;
162
+ this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
163
+ this.emitErrorChange("maxDate", this.errorMessage);
164
+ return;
165
+ }
166
+ if (this.disableDate(parsed.toDate())) {
167
+ this.errorState = true;
168
+ this.errorMessage = this.timesLabels.disabledDateError;
169
+ this.emitErrorChange("disabledDate", this.errorMessage);
170
+ return;
171
+ }
149
172
  this.errorState = false;
150
173
  this.selectedHours = parsed.hour();
151
174
  this.selectedMinutes = parsed.minute();
@@ -156,9 +179,64 @@ export class TabworthyTimes {
156
179
  // Set error state for invalid/garbage input
157
180
  this.errorState = true;
158
181
  this.errorMessage = this.timesLabels.invalidDateError;
182
+ this.emitErrorChange("invalid", this.errorMessage);
159
183
  }
160
184
  };
161
185
  }
186
+ emitErrorChange(reason, message) {
187
+ this.errorChange.emit({ reason, message });
188
+ }
189
+ formatBoundaryDate(dateString) {
190
+ const parsed = dayjs(dateString);
191
+ if (!parsed.isValid())
192
+ return dateString;
193
+ const hasTime = dateString.includes("T") || dateString.includes(" ");
194
+ if (!hasTime) {
195
+ return Intl.DateTimeFormat(this.locale, {
196
+ day: "numeric",
197
+ month: "short",
198
+ year: "numeric"
199
+ }).format(parsed.toDate());
200
+ }
201
+ const options = Object.assign({ day: "numeric", month: "short", year: "numeric", hour: "numeric", minute: "numeric" }, (this.showSeconds ? { second: "numeric" } : {}));
202
+ return Intl.DateTimeFormat(this.locale, options).format(parsed.toDate());
203
+ }
204
+ getEffectiveMinTime() {
205
+ if (!this.minDate || !this.selectedDate)
206
+ return undefined;
207
+ const min = dayjs(this.minDate);
208
+ const sel = dayjs(this.selectedDate);
209
+ if (!min.isValid() || !sel.isSame(min, "day"))
210
+ return undefined;
211
+ return {
212
+ hours: min.hour(),
213
+ minutes: min.minute(),
214
+ seconds: min.second()
215
+ };
216
+ }
217
+ getEffectiveMaxTime() {
218
+ if (!this.maxDate || !this.selectedDate)
219
+ return undefined;
220
+ const max = dayjs(this.maxDate);
221
+ const sel = dayjs(this.selectedDate);
222
+ if (!max.isValid() || !sel.isSame(max, "day"))
223
+ return undefined;
224
+ return {
225
+ hours: max.hour(),
226
+ minutes: max.minute(),
227
+ seconds: max.second()
228
+ };
229
+ }
230
+ isDateOutOfBounds() {
231
+ if (!this.selectedDate)
232
+ return false;
233
+ const sel = dayjs(this.selectedDate);
234
+ if (this.minDate && sel.isBefore(dayjs(this.minDate), "day"))
235
+ return true;
236
+ if (this.maxDate && sel.isAfter(dayjs(this.maxDate), "day"))
237
+ return true;
238
+ return false;
239
+ }
162
240
  shouldInputFormat() {
163
241
  if (typeof this.inputShouldFormat === "string") {
164
242
  return this.inputShouldFormat === "true";
@@ -231,6 +309,30 @@ export class TabworthyTimes {
231
309
  this.formatInput();
232
310
  }
233
311
  }
312
+ isDateValid(date) {
313
+ const parsed = dayjs(date);
314
+ if (!parsed.isValid())
315
+ return false;
316
+ if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
317
+ this.errorState = true;
318
+ this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
319
+ this.emitErrorChange("minDate", this.errorMessage);
320
+ return false;
321
+ }
322
+ if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
323
+ this.errorState = true;
324
+ this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
325
+ this.emitErrorChange("maxDate", this.errorMessage);
326
+ return false;
327
+ }
328
+ if (this.disableDate(date)) {
329
+ this.errorState = true;
330
+ this.errorMessage = this.timesLabels.disabledDateError;
331
+ this.emitErrorChange("disabledDate", this.errorMessage);
332
+ return false;
333
+ }
334
+ return true;
335
+ }
234
336
  formatInput() {
235
337
  if (!this.internalValue)
236
338
  return;
@@ -271,10 +373,12 @@ export class TabworthyTimes {
271
373
  }
272
374
  render() {
273
375
  var _a;
274
- return (h(Host, { key: '671702979dddb6a19cfa78a95df28a958af56df9', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '7b23263f899b3a59d43f3f2922e9c98a0bc62524', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '453d585bee8dd0262aadec8ba816cd22c51cffea', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'd2ec7de2b31f3c1a6b9acb4f57341530cb8431dc', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
376
+ return (h(Host, { key: 'd258bd87c60aa773bd178e1e74eeb32934d8f068', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '5e7a53cb36c350794af9fed2371c89823726ee2f', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '986905f117271cfb82a1f8415d55536a590ac2bc', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: '9ad436c1e0c8a427c1665db16913cddf93d94fed', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
275
377
  [this.getClassName("input")]: true,
276
378
  [this.inputClass]: !!this.inputClass
277
- }, 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: '77b42f53ad8a5e0d5d70ea41f999f95d61942a83', type: "button", 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: '3633f9e7839b8947da48f83ac3808156bea8515d', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
379
+ }, 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: 'd537e6f3251bada7ad50bbe1ca2c562737205897', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
380
+ ? this.timesLabels.openCalendar
381
+ : undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '241700195e1d028f8d8b6b55af7de3aee09163ea', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
278
382
  if (this.pickerRef) {
279
383
  this.pickerRef.modalIsOpen = true;
280
384
  }
@@ -282,7 +386,7 @@ export class TabworthyTimes {
282
386
  if (this.pickerRef) {
283
387
  this.pickerRef.modalIsOpen = false;
284
388
  }
285
- }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '706e2fdcd7e4ecf77f5ee63f4c5ced7951593735', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'cb027f3fe4d2bf73abea9ec6511fe11305e28aba', 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 }, h("div", { key: '2287a25cdec6fc40c36833c250536f99cabe5cbf', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '540cfd69b4ca3618ecd22f9d1ed3d240ed8eeee9', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '79e8c05c3ba4af1ef46a78c6d6fcb211dec7abd5', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '4a568e01f57652308adb7a8c115ab6649fc591fc', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
389
+ }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: 'b99aa129e4d1d600971bc4d21b2c6a4316ff64cf', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '6ac11c01936e2155c023d286d912ba87e0ed3415', 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 }, h("div", { key: '7eead2c25334abce43fe7371436a52b0970e648b', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '06ac45a5eaaaa56d39825f941b0951f99c4b28e9', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'ba4187a2a369cff58ca0ecf3a60abfeff3ba9ca3', 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() }))))), this.errorState && (h("div", { key: 'c187d0bd982a5184aa796ffe8be4ed91c340230d', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
286
390
  }
287
391
  static get is() { return "tabworthy-times"; }
288
392
  static get encapsulation() { return "scoped"; }
@@ -775,6 +879,139 @@ export class TabworthyTimes {
775
879
  "reflect": false,
776
880
  "attribute": "calendar-button-content"
777
881
  },
882
+ "nextMonthButtonContent": {
883
+ "type": "string",
884
+ "mutable": false,
885
+ "complexType": {
886
+ "original": "string",
887
+ "resolved": "string",
888
+ "references": {}
889
+ },
890
+ "required": false,
891
+ "optional": true,
892
+ "docs": {
893
+ "tags": [],
894
+ "text": ""
895
+ },
896
+ "getter": false,
897
+ "setter": false,
898
+ "reflect": false,
899
+ "attribute": "next-month-button-content"
900
+ },
901
+ "nextYearButtonContent": {
902
+ "type": "string",
903
+ "mutable": false,
904
+ "complexType": {
905
+ "original": "string",
906
+ "resolved": "string",
907
+ "references": {}
908
+ },
909
+ "required": false,
910
+ "optional": true,
911
+ "docs": {
912
+ "tags": [],
913
+ "text": ""
914
+ },
915
+ "getter": false,
916
+ "setter": false,
917
+ "reflect": false,
918
+ "attribute": "next-year-button-content"
919
+ },
920
+ "previousMonthButtonContent": {
921
+ "type": "string",
922
+ "mutable": false,
923
+ "complexType": {
924
+ "original": "string",
925
+ "resolved": "string",
926
+ "references": {}
927
+ },
928
+ "required": false,
929
+ "optional": true,
930
+ "docs": {
931
+ "tags": [],
932
+ "text": ""
933
+ },
934
+ "getter": false,
935
+ "setter": false,
936
+ "reflect": false,
937
+ "attribute": "previous-month-button-content"
938
+ },
939
+ "previousYearButtonContent": {
940
+ "type": "string",
941
+ "mutable": false,
942
+ "complexType": {
943
+ "original": "string",
944
+ "resolved": "string",
945
+ "references": {}
946
+ },
947
+ "required": false,
948
+ "optional": true,
949
+ "docs": {
950
+ "tags": [],
951
+ "text": ""
952
+ },
953
+ "getter": false,
954
+ "setter": false,
955
+ "reflect": false,
956
+ "attribute": "previous-year-button-content"
957
+ },
958
+ "todayButtonContent": {
959
+ "type": "string",
960
+ "mutable": false,
961
+ "complexType": {
962
+ "original": "string",
963
+ "resolved": "string",
964
+ "references": {}
965
+ },
966
+ "required": false,
967
+ "optional": true,
968
+ "docs": {
969
+ "tags": [],
970
+ "text": ""
971
+ },
972
+ "getter": false,
973
+ "setter": false,
974
+ "reflect": false,
975
+ "attribute": "today-button-content"
976
+ },
977
+ "clearButtonContent": {
978
+ "type": "string",
979
+ "mutable": false,
980
+ "complexType": {
981
+ "original": "string",
982
+ "resolved": "string",
983
+ "references": {}
984
+ },
985
+ "required": false,
986
+ "optional": true,
987
+ "docs": {
988
+ "tags": [],
989
+ "text": ""
990
+ },
991
+ "getter": false,
992
+ "setter": false,
993
+ "reflect": false,
994
+ "attribute": "clear-button-content"
995
+ },
996
+ "closeButtonContent": {
997
+ "type": "string",
998
+ "mutable": false,
999
+ "complexType": {
1000
+ "original": "string",
1001
+ "resolved": "string",
1002
+ "references": {}
1003
+ },
1004
+ "required": false,
1005
+ "optional": true,
1006
+ "docs": {
1007
+ "tags": [],
1008
+ "text": ""
1009
+ },
1010
+ "getter": false,
1011
+ "setter": false,
1012
+ "reflect": false,
1013
+ "attribute": "close-button-content"
1014
+ },
778
1015
  "disableDate": {
779
1016
  "type": "unknown",
780
1017
  "mutable": false,
@@ -993,6 +1230,28 @@ export class TabworthyTimes {
993
1230
  }
994
1231
  }
995
1232
  }
1233
+ }, {
1234
+ "method": "errorChange",
1235
+ "name": "errorChange",
1236
+ "bubbles": true,
1237
+ "cancelable": true,
1238
+ "composed": true,
1239
+ "docs": {
1240
+ "tags": [],
1241
+ "text": ""
1242
+ },
1243
+ "complexType": {
1244
+ "original": "ErrorChangeEventDetails",
1245
+ "resolved": "ErrorChangeEventDetails",
1246
+ "references": {
1247
+ "ErrorChangeEventDetails": {
1248
+ "location": "import",
1249
+ "path": "../tabworthy-dates/tabworthy-dates",
1250
+ "id": "src/components/tabworthy-dates/tabworthy-dates.tsx::ErrorChangeEventDetails",
1251
+ "referenceLocation": "ErrorChangeEventDetails"
1252
+ }
1253
+ }
1254
+ }
996
1255
  }, {
997
1256
  "method": "componentReady",
998
1257
  "name": "componentReady",