@tabworthy/components 0.2.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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  4. package/dist/cjs/index-C15oswCE.js +2148 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +13 -0
  7. package/dist/cjs/moment-CdViwxPQ.js +5681 -0
  8. package/dist/cjs/tabworthy-components.cjs.js +25 -0
  9. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +884 -0
  10. package/dist/cjs/tabworthy-dates.cjs.entry.js +10906 -0
  11. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +181 -0
  12. package/dist/cjs/tabworthy-times.cjs.entry.js +242 -0
  13. package/dist/cjs/utils-y5Vtky2t.js +214 -0
  14. package/dist/collection/collection-manifest.json +16 -0
  15. package/dist/collection/components/tabworthy-dates/tabworthy-dates.css +10 -0
  16. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +1197 -0
  17. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.css +10 -0
  18. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +986 -0
  19. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.css +14 -0
  20. package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +237 -0
  21. package/dist/collection/components/tabworthy-times/tabworthy-times.js +832 -0
  22. package/dist/collection/components/tabworthy-times-picker/tabworthy-times-picker.js +356 -0
  23. package/dist/collection/index.js +1 -0
  24. package/dist/components/index.d.ts +35 -0
  25. package/dist/components/index.js +1 -0
  26. package/dist/components/moment.js +8 -0
  27. package/dist/components/tabworthy-dates-calendar.d.ts +11 -0
  28. package/dist/components/tabworthy-dates-calendar.js +1 -0
  29. package/dist/components/tabworthy-dates-calendar2.js +1 -0
  30. package/dist/components/tabworthy-dates-modal.d.ts +11 -0
  31. package/dist/components/tabworthy-dates-modal.js +1 -0
  32. package/dist/components/tabworthy-dates-modal2.js +1 -0
  33. package/dist/components/tabworthy-dates.d.ts +11 -0
  34. package/dist/components/tabworthy-dates.js +1 -0
  35. package/dist/components/tabworthy-times-picker.d.ts +11 -0
  36. package/dist/components/tabworthy-times-picker.js +1 -0
  37. package/dist/components/tabworthy-times-picker2.js +1 -0
  38. package/dist/components/tabworthy-times.d.ts +11 -0
  39. package/dist/components/tabworthy-times.js +1 -0
  40. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  41. package/dist/esm/index-BusoZVTR.js +2139 -0
  42. package/dist/esm/index.js +1 -0
  43. package/dist/esm/loader.js +11 -0
  44. package/dist/esm/moment-Mki5YqAR.js +5679 -0
  45. package/dist/esm/tabworthy-components.js +21 -0
  46. package/dist/esm/tabworthy-dates-calendar_2.entry.js +881 -0
  47. package/dist/esm/tabworthy-dates.entry.js +10904 -0
  48. package/dist/esm/tabworthy-times-picker.entry.js +179 -0
  49. package/dist/esm/tabworthy-times.entry.js +240 -0
  50. package/dist/esm/utils-BVHu5CWV.js +188 -0
  51. package/dist/index.cjs.js +1 -0
  52. package/dist/index.js +1 -0
  53. package/dist/loader/cdn.js +1 -0
  54. package/dist/loader/index.cjs.js +1 -0
  55. package/dist/loader/index.d.ts +24 -0
  56. package/dist/loader/index.es2017.js +1 -0
  57. package/dist/loader/index.js +2 -0
  58. package/dist/shared/utils/chrono-parser/chrono-parser.js +146 -0
  59. package/dist/shared/utils/chrono-parser/chrono-parser.type.js +1 -0
  60. package/dist/shared/utils/utils.js +186 -0
  61. package/dist/tabworthy-components/index.esm.js +0 -0
  62. package/dist/tabworthy-components/p-170bc6ca.entry.js +1 -0
  63. package/dist/tabworthy-components/p-3ce9a767.entry.js +1 -0
  64. package/dist/tabworthy-components/p-77bd1bd4.entry.js +1 -0
  65. package/dist/tabworthy-components/p-BVHu5CWV.js +1 -0
  66. package/dist/tabworthy-components/p-BusoZVTR.js +2 -0
  67. package/dist/tabworthy-components/p-DQuL1Twl.js +1 -0
  68. package/dist/tabworthy-components/p-Mki5YqAR.js +8 -0
  69. package/dist/tabworthy-components/p-ebbb4c46.entry.js +1 -0
  70. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -0
  71. package/dist/themes/dark.css +1 -0
  72. package/dist/themes/light.css +1 -0
  73. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/chrono-parser/chrono-parser.d.ts +3 -0
  74. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/chrono-parser/chrono-parser.type.d.ts +40 -0
  75. package/dist/types/Users/damirbogdanov_1/work/tabworthy-components/.stencil/shared/utils/utils.d.ts +28 -0
  76. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +80 -0
  77. package/dist/types/components/tabworthy-dates-calendar/tabworthy-dates-calendar.d.ts +89 -0
  78. package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +29 -0
  79. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +65 -0
  80. package/dist/types/components/tabworthy-times-picker/tabworthy-times-picker.d.ts +46 -0
  81. package/dist/types/components.d.ts +879 -0
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/stencil-public-runtime.d.ts +1858 -0
  84. package/package.json +132 -0
@@ -0,0 +1,986 @@
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";
3
+ import { dateIsWithinBounds } from "../../../../shared/utils/utils";
4
+ const defaultLabels = {
5
+ clearButton: "Clear value",
6
+ monthSelect: "Select month",
7
+ nextMonthButton: "Next month",
8
+ nextYearButton: "Next year",
9
+ picker: "Choose date",
10
+ previousMonthButton: "Previous month",
11
+ previousYearButton: "Previous year",
12
+ todayButton: "Show today",
13
+ yearSelect: "Select year",
14
+ keyboardHint: "Keyboard commands",
15
+ selected: "Selected date",
16
+ chooseAsStartDate: "choose as start date",
17
+ chooseAsEndDate: "choose as end date"
18
+ };
19
+ export class InclusiveDatesCalendar {
20
+ constructor() {
21
+ this.disabled = false;
22
+ this.modalIsOpen = false;
23
+ this.disableDate = () => false;
24
+ this.elementClassName = "tabworthy-dates-calendar";
25
+ this.firstDayOfWeek = 0;
26
+ this.range = false;
27
+ this.labels = defaultLabels;
28
+ this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
29
+ this.inline = false;
30
+ this.showClearButton = false;
31
+ this.showMonthStepper = true;
32
+ this.showTodayButton = true;
33
+ this.showYearStepper = false;
34
+ this.showKeyboardHint = false;
35
+ this.showHiddenTitle = true;
36
+ this.startDate = getISODateString(new Date());
37
+ this.init = () => {
38
+ this.currentDate = this.startDate
39
+ ? removeTimezoneOffset(new Date(this.startDate))
40
+ : new Date();
41
+ this.updateWeekdays();
42
+ };
43
+ this.nextMonth = () => {
44
+ this.updateCurrentDate(getNextMonth(this.currentDate));
45
+ };
46
+ this.nextYear = () => {
47
+ this.updateCurrentDate(getNextYear(this.currentDate));
48
+ };
49
+ this.previousMonth = () => {
50
+ this.updateCurrentDate(getPreviousMonth(this.currentDate));
51
+ };
52
+ this.previousYear = () => {
53
+ this.updateCurrentDate(getPreviousYear(this.currentDate));
54
+ };
55
+ this.showToday = () => {
56
+ this.updateCurrentDate(new Date(), true);
57
+ };
58
+ this.clear = () => {
59
+ var _a;
60
+ this.value = undefined;
61
+ (_a = this.selectDate) === null || _a === void 0 ? void 0 : _a.emit(undefined);
62
+ };
63
+ this.onClick = (event) => {
64
+ if (this.disabled) {
65
+ return;
66
+ }
67
+ const target = event.target.closest("[data-date]");
68
+ if (!Boolean(target)) {
69
+ return;
70
+ }
71
+ const date = removeTimezoneOffset(new Date(target.dataset.date));
72
+ this.updateCurrentDate(date);
73
+ this.onSelectDate(date);
74
+ };
75
+ this.onMonthSelect = (event) => {
76
+ const month = +event.target.value - 1;
77
+ const date = new Date(this.currentDate);
78
+ if (!dateIsWithinBounds(date, this.minDate, this.maxDate))
79
+ return;
80
+ date.setMonth(month);
81
+ this.updateCurrentDate(date);
82
+ };
83
+ this.onYearSelect = (event) => {
84
+ var _a;
85
+ const year = +event.target.value;
86
+ const date = new Date(this.currentDate);
87
+ if (!dateIsWithinBounds(date, this.minDate, this.maxDate))
88
+ return;
89
+ date.setFullYear(year);
90
+ (_a = this.changeYear) === null || _a === void 0 ? void 0 : _a.emit({ year });
91
+ this.updateCurrentDate(date);
92
+ };
93
+ this.onKeyDown = (event) => {
94
+ if (this.disabled) {
95
+ return;
96
+ }
97
+ if (event.code === "ArrowLeft") {
98
+ event.preventDefault();
99
+ this.updateCurrentDate(getPreviousDay(this.currentDate), true);
100
+ }
101
+ else if (event.code === "ArrowRight") {
102
+ event.preventDefault();
103
+ this.updateCurrentDate(getNextDay(this.currentDate), true);
104
+ }
105
+ else if (event.code === "ArrowUp") {
106
+ event.preventDefault();
107
+ this.updateCurrentDate(subDays(this.currentDate, 7), true);
108
+ }
109
+ else if (event.code === "ArrowDown") {
110
+ event.preventDefault();
111
+ this.updateCurrentDate(addDays(this.currentDate, 7), true);
112
+ }
113
+ else if (event.code === "PageUp") {
114
+ event.preventDefault();
115
+ if (event.shiftKey) {
116
+ this.updateCurrentDate(getPreviousYear(this.currentDate), true);
117
+ }
118
+ else {
119
+ this.updateCurrentDate(getPreviousMonth(this.currentDate), true);
120
+ }
121
+ }
122
+ else if (event.code === "PageDown") {
123
+ event.preventDefault();
124
+ if (event.shiftKey) {
125
+ this.updateCurrentDate(getNextYear(this.currentDate), true);
126
+ }
127
+ else {
128
+ this.updateCurrentDate(getNextMonth(this.currentDate), true);
129
+ }
130
+ }
131
+ else if (event.code === "Home") {
132
+ event.preventDefault();
133
+ this.updateCurrentDate(getFirstOfMonth(this.currentDate), true);
134
+ }
135
+ else if (event.code === "End") {
136
+ event.preventDefault();
137
+ this.updateCurrentDate(getLastOfMonth(this.currentDate), true);
138
+ }
139
+ else if (event.code === "Space" || event.code === "Enter") {
140
+ event.preventDefault();
141
+ this.onSelectDate(this.currentDate);
142
+ }
143
+ };
144
+ this.onMouseEnter = (event) => {
145
+ var _a;
146
+ if (this.disabled) {
147
+ return;
148
+ }
149
+ const date = removeTimezoneOffset(new Date((_a = event.target.closest("td")) === null || _a === void 0 ? void 0 : _a.dataset.date));
150
+ this.hoveredDate = date;
151
+ };
152
+ this.onMouseLeave = () => {
153
+ this.hoveredDate = undefined;
154
+ };
155
+ }
156
+ componentWillLoad() {
157
+ this.init();
158
+ }
159
+ watchModalIsOpen() {
160
+ if (this.modalIsOpen === true) {
161
+ this.moveFocusOnModalOpen = true;
162
+ }
163
+ }
164
+ watchFirstDayOfWeek() {
165
+ this.updateWeekdays();
166
+ }
167
+ watchLocale() {
168
+ if (!Boolean(this.locale)) {
169
+ this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
170
+ }
171
+ this.updateWeekdays();
172
+ }
173
+ watchRange() {
174
+ var _a;
175
+ this.value = undefined;
176
+ (_a = this.selectDate) === null || _a === void 0 ? void 0 : _a.emit(undefined);
177
+ }
178
+ watchStartDate() {
179
+ this.currentDate = this.startDate
180
+ ? removeTimezoneOffset(new Date(this.startDate))
181
+ : new Date();
182
+ }
183
+ watchValue() {
184
+ if (Boolean(this.value)) {
185
+ if (Array.isArray(this.value) && this.value.length >= 1) {
186
+ this.currentDate = this.value[0];
187
+ }
188
+ else if (this.value instanceof Date) {
189
+ this.currentDate = this.value;
190
+ }
191
+ }
192
+ }
193
+ componentDidRender() {
194
+ if (this.moveFocusAfterMonthChanged) {
195
+ this.focusDate(this.currentDate);
196
+ this.moveFocusAfterMonthChanged = false;
197
+ }
198
+ if (this.moveFocusOnModalOpen) {
199
+ // Timeout added to stop VoiceOver from crashing Safari when openin the calendar. TODO: Investigate a neater solution
200
+ setTimeout(() => {
201
+ this.focusDate(this.currentDate);
202
+ this.moveFocusOnModalOpen = false;
203
+ }, 100);
204
+ }
205
+ }
206
+ updateWeekdays() {
207
+ this.weekdays = getWeekDays(this.firstDayOfWeek, this.locale);
208
+ }
209
+ getClassName(element) {
210
+ return Boolean(element)
211
+ ? `${this.elementClassName}__${element}`
212
+ : this.elementClassName;
213
+ }
214
+ getCalendarRows() {
215
+ const daysOfMonth = getDaysOfMonth(this.currentDate, true, this.firstDayOfWeek === 0 ? 7 : this.firstDayOfWeek);
216
+ const calendarRows = [];
217
+ for (let i = 0; i < daysOfMonth.length; i += 7) {
218
+ const row = daysOfMonth.slice(i, i + 7);
219
+ calendarRows.push(row);
220
+ }
221
+ return calendarRows;
222
+ }
223
+ getTitle() {
224
+ if (!Boolean(this.currentDate)) {
225
+ return;
226
+ }
227
+ return Intl.DateTimeFormat(this.locale, {
228
+ month: "long",
229
+ year: "numeric"
230
+ }).format(this.currentDate);
231
+ }
232
+ focusDate(date) {
233
+ var _a;
234
+ date && ((_a = this.el
235
+ .querySelector(`[data-date="${getISODateString(date)}"]`)) === null || _a === void 0 ? void 0 : _a.focus());
236
+ }
237
+ updateCurrentDate(date, moveFocus) {
238
+ var _a, _b;
239
+ const month = date.getMonth();
240
+ const year = date.getFullYear();
241
+ if (!dateIsWithinLowerBounds(date, this.minDate))
242
+ date = new Date(this.minDate);
243
+ if (!dateIsWithinUpperBounds(date, this.maxDate))
244
+ date = new Date(this.maxDate);
245
+ const monthChanged = month !== ((_a = this.currentDate) === null || _a === void 0 ? void 0 : _a.getMonth()) ||
246
+ year !== this.currentDate.getFullYear();
247
+ if (monthChanged) {
248
+ (_b = this.changeMonth) === null || _b === void 0 ? void 0 : _b.emit({ month: getMonth(date), year: getYear(date) });
249
+ if (moveFocus) {
250
+ this.moveFocusAfterMonthChanged = true;
251
+ }
252
+ }
253
+ this.currentDate = date;
254
+ if (moveFocus) {
255
+ this.focusDate(this.currentDate);
256
+ }
257
+ }
258
+ onSelectDate(date) {
259
+ var _a, _b, _c, _d;
260
+ if (this.disableDate(date) ||
261
+ !dateIsWithinBounds(date, this.minDate, this.maxDate)) {
262
+ return;
263
+ }
264
+ if (this.isRangeValue(this.value)) {
265
+ const newValue = ((_a = this.value) === null || _a === void 0 ? void 0 : _a[0]) === undefined || this.value.length === 2
266
+ ? [date]
267
+ : [this.value[0], date];
268
+ if (newValue.length === 2 && newValue[0] > newValue[1]) {
269
+ newValue.reverse();
270
+ }
271
+ const isoValue = newValue[1] === undefined
272
+ ? [getISODateString(newValue[0])]
273
+ : [getISODateString(newValue[0]), getISODateString(newValue[1])];
274
+ this.value = newValue;
275
+ (_b = this.selectDate) === null || _b === void 0 ? void 0 : _b.emit(isoValue);
276
+ }
277
+ else {
278
+ if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.getTime()) === date.getTime()) {
279
+ return;
280
+ }
281
+ this.value = date;
282
+ (_d = this.selectDate) === null || _d === void 0 ? void 0 : _d.emit(getISODateString(date));
283
+ }
284
+ }
285
+ isRangeValue(_value) {
286
+ return !!this.range;
287
+ }
288
+ render() {
289
+ var _a;
290
+ const showFooter = this.showTodayButton || this.showClearButton || this.showKeyboardHint;
291
+ const disabled = {
292
+ year: {
293
+ prev: this.disabled || (!!this.minDate && new Date(this.minDate).getFullYear() > getPreviousYear(this.currentDate).getFullYear()),
294
+ next: this.disabled || (!!this.maxDate && new Date(this.maxDate).getFullYear() < getNextYear(this.currentDate).getFullYear())
295
+ },
296
+ month: {
297
+ prev: this.disabled ||
298
+ monthIsDisabled(getPreviousMonth(this.currentDate).getMonth(), getPreviousMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate),
299
+ next: this.disabled ||
300
+ monthIsDisabled(getNextMonth(this.currentDate).getMonth(), getNextMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate)
301
+ }
302
+ };
303
+ return (h(Host, { key: '79018439c3f99dc228ac0d429763d1e86fe9bb03' }, h("div", { key: '8863cf5d0de75a1f358723440f11b70128d7c739', class: {
304
+ [`${this.getClassName()}-wrapper`]: true,
305
+ [`${this.getClassName()}-wrapper--inline`]: this.inline
306
+ } }, h("div", { key: 'b47630e94a50c0bb74da62f1d9e9931ed06e15ab', class: {
307
+ [this.getClassName()]: true,
308
+ [`${this.getClassName()}--disabled`]: this.disabled,
309
+ } }, h("div", { key: '594429a8b241c0024edde2e4adb211935e3579fd', class: this.getClassName("header") }, this.showHiddenTitle && (h("span", { key: '3258ebc3b0a325f0f21af5126fa31c5cb0197ebb', "aria-atomic": "true", "aria-live": "polite", class: "visually-hidden" }, this.getTitle())), this.showYearStepper && (h("button", { key: '0f7d853b969a89b76b5794d9b8c5e03f7ece778b', "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: '1d4da9d54e875a85e22beae6f608de9ec0495a03', 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: '0fd84be75c074c61a0d839694e5e1b8e7efa480e', points: "11 17 6 12 11 7" }), h("polyline", { key: '4b1c8d3e29718cabc669d9194af749ffc2cac7aa', points: "18 17 13 12 18 7" })))), this.showMonthStepper && (h("button", { key: '27402a2f431d68487775e4fbe548804755c569cc', "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: 'b503e9f1d393c1a245da483b25edb14f473aac7d', 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: '37241e518f64e1a7aba4153d0222649e62671ed4', points: "15 18 9 12 15 6" })))), h("span", { key: '3e87bb8129d4d7b1db718ee87f5164dec158fb1a', class: this.getClassName("current-month") }, h("select", { key: 'ae6c5128f2dc9ec17bd4d4c0090df4a62743b09c', "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) => {
310
+ return (h("option", { key: month, selected: this.currentDate.getMonth() === index, value: index + 1, disabled: monthIsDisabled(index, this.currentDate.getFullYear(), this.minDate, this.maxDate) }, month));
311
+ })), h("input", { key: '733a5e0025571c54fc27616c200bfbf07de436cc', "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: 'eaa9e5e613835a9108f17991ba4743020cfa3146', "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: '5729113b90336e0e8d2ade0a24952d186e12867c', 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: 'a6cc05a5b83eb6f162654782466a43bd98ada883', points: "9 18 15 12 9 6" })))), this.showYearStepper && (h("button", { key: '6a8556ddc516e5c9a06fd9d71cfa939de48e9bbe', "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: '17e51e43e8a378fb73e1d51c8a75bb8e890af433', 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: 'bdf9cf173de2dc96beaf2bc615aea901899e5907', points: "13 17 18 12 13 7" }), h("polyline", { key: '638e86d7b823782b2331c2569531def9f267dce9', points: "6 17 11 12 6 7" }))))), h("div", { key: '8fbe9e86646e09853205865351f3aa298877c43a', class: this.getClassName("body") }, h("table", { key: 'bf374b391788b26485362a368a10c009b42a9d84', class: this.getClassName("calendar"), onKeyDown: this.onKeyDown, role: "grid", "aria-label": this.getTitle() }, h("thead", { key: '7cb065ee0fa4bd944c79a130b107d59e8e622b89', class: this.getClassName("calendar-header") }, h("tr", { key: '30b196641286a6f9adb3d37167172858a34f2933', 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: '922edf01c35e7512654d8661348301d275c67647' }, this.getCalendarRows().map((calendarRow) => {
312
+ const rowKey = `row-${calendarRow[0].getMonth()}-${calendarRow[0].getDate()}`;
313
+ return (h("tr", { class: this.getClassName("calendar-row"), key: rowKey }, calendarRow.map((day) => {
314
+ var _a, _b, _c;
315
+ const isCurrent = isSameDay(day, this.currentDate);
316
+ const isOverflowing = day.getMonth() !== ((_a = this.currentDate) === null || _a === void 0 ? void 0 : _a.getMonth());
317
+ const isSelected = Array.isArray(this.value)
318
+ ? isSameDay(day, this.value[0]) ||
319
+ (this.value[1] &&
320
+ dateIsWithinBounds(day, getISODateString(this.value[0]), getISODateString(this.value[1])))
321
+ : isSameDay(day, this.value);
322
+ const isDisabled = this.disableDate(day) ||
323
+ !dateIsWithinBounds(day, this.minDate, this.maxDate);
324
+ const isInRange = !this.isRangeValue(this.value)
325
+ ? false
326
+ : isDateInRange(day, {
327
+ from: (_b = this.value) === null || _b === void 0 ? void 0 : _b[0],
328
+ to: ((_c = this.value) === null || _c === void 0 ? void 0 : _c[1]) ||
329
+ this.hoveredDate ||
330
+ this.currentDate
331
+ }) && !isDisabled;
332
+ const isToday = isSameDay(day, new Date());
333
+ const cellKey = `cell-${day.getMonth()}-${day.getDate()}`;
334
+ const getScreenReaderText = () => {
335
+ if (this.range) {
336
+ let suffix = !this.value
337
+ ? `, ${this.labels.chooseAsStartDate}.`
338
+ : "";
339
+ if (Array.isArray(this.value)) {
340
+ suffix = {
341
+ 1: `, ${this.labels.chooseAsEndDate}.`,
342
+ 2: `, ${this.labels.chooseAsStartDate}.`
343
+ }[this.value.length];
344
+ }
345
+ return `${isSelected ? `${this.labels.selected}, ` : ""}${Intl.DateTimeFormat(this.locale, {
346
+ day: "numeric",
347
+ month: "long",
348
+ year: "numeric"
349
+ }).format(day)}${suffix}`;
350
+ }
351
+ else {
352
+ return `${isSelected ? `${this.labels.selected}, ` : ""}${Intl.DateTimeFormat(this.locale, {
353
+ day: "numeric",
354
+ month: "long",
355
+ year: "numeric"
356
+ }).format(day)}`;
357
+ }
358
+ };
359
+ const className = {
360
+ [this.getClassName("date")]: true,
361
+ [this.getClassName("date--current")]: isCurrent,
362
+ [this.getClassName("date--disabled")]: isDisabled,
363
+ [this.getClassName("date--overflowing")]: isOverflowing,
364
+ [this.getClassName("date--today")]: isToday,
365
+ [this.getClassName("date--selected")]: isSelected,
366
+ [this.getClassName("date--in-range")]: isInRange
367
+ };
368
+ const Tag = isSelected
369
+ ? "strong"
370
+ : isToday
371
+ ? "em"
372
+ : "span";
373
+ return (h("td", { "aria-disabled": String(isDisabled), "aria-selected": isSelected ? "true" : undefined, class: className, "data-date": getISODateString(day), key: cellKey, onClick: this.onClick, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave, role: "gridcell", tabIndex: isSameDay(day, this.currentDate) && !this.disabled
374
+ ? 0
375
+ : -1 }, h(Tag, { "aria-hidden": "true" }, day.getDate()), h("span", { class: "visually-hidden" }, getScreenReaderText())));
376
+ })));
377
+ })))), showFooter && (h("div", { key: '0a189fdb44b39bddc7a26c7bd3e4a889307fee39', class: this.getClassName("footer") }, h("div", { key: 'fbdf81d3a93afa19cdedba1423d2c64ab4e1fbcb', class: this.getClassName("footer-buttons") }, this.showTodayButton && (h("button", { key: '4faad216c53bda804e8b660d758e30e0bf538940', 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: '84ad553438da2c701c0ec75328eac36d01b3daa3', class: this.getClassName("clear-button"), disabled: this.disabled, innerHTML: this.clearButtonContent || undefined, onClick: this.clear, type: "button" }, this.labels.clearButton))), this.showKeyboardHint &&
378
+ !window.matchMedia("(pointer: coarse)").matches && (h("button", { key: 'f63c1d1c802173072424a098ab52fffe35df7f56', type: "button", onClick: () => alert("Todo: Add Keyboard helper!"), class: this.getClassName("keyboard-hint") }, h("svg", { key: '790b14010416be81d39a52549a5677116e436a63', xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "0 0 48 48", fill: "currentColor" }, h("path", { key: '83a801f97bf0a2fbd33f728cd00c5dfab75eb213', 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: '1b6c88f7c9e4e6fa7109b99ef774af1ee8de24ea', name: "after-calendar" }))));
379
+ }
380
+ static get is() { return "tabworthy-dates-calendar"; }
381
+ static get encapsulation() { return "scoped"; }
382
+ static get originalStyleUrls() {
383
+ return {
384
+ "$": ["tabworthy-dates-calendar.css"]
385
+ };
386
+ }
387
+ static get styleUrls() {
388
+ return {
389
+ "$": ["tabworthy-dates-calendar.css"]
390
+ };
391
+ }
392
+ static get properties() {
393
+ return {
394
+ "clearButtonContent": {
395
+ "type": "string",
396
+ "mutable": false,
397
+ "complexType": {
398
+ "original": "string",
399
+ "resolved": "string",
400
+ "references": {}
401
+ },
402
+ "required": false,
403
+ "optional": true,
404
+ "docs": {
405
+ "tags": [],
406
+ "text": ""
407
+ },
408
+ "getter": false,
409
+ "setter": false,
410
+ "reflect": false,
411
+ "attribute": "clear-button-content"
412
+ },
413
+ "disabled": {
414
+ "type": "boolean",
415
+ "mutable": false,
416
+ "complexType": {
417
+ "original": "boolean",
418
+ "resolved": "boolean",
419
+ "references": {}
420
+ },
421
+ "required": false,
422
+ "optional": false,
423
+ "docs": {
424
+ "tags": [],
425
+ "text": ""
426
+ },
427
+ "getter": false,
428
+ "setter": false,
429
+ "reflect": false,
430
+ "attribute": "disabled",
431
+ "defaultValue": "false"
432
+ },
433
+ "modalIsOpen": {
434
+ "type": "boolean",
435
+ "mutable": false,
436
+ "complexType": {
437
+ "original": "boolean",
438
+ "resolved": "boolean",
439
+ "references": {}
440
+ },
441
+ "required": false,
442
+ "optional": true,
443
+ "docs": {
444
+ "tags": [],
445
+ "text": ""
446
+ },
447
+ "getter": false,
448
+ "setter": false,
449
+ "reflect": false,
450
+ "attribute": "modal-is-open",
451
+ "defaultValue": "false"
452
+ },
453
+ "disableDate": {
454
+ "type": "unknown",
455
+ "mutable": false,
456
+ "complexType": {
457
+ "original": "(date: Date) => boolean",
458
+ "resolved": "(date: Date) => boolean",
459
+ "references": {
460
+ "Date": {
461
+ "location": "global",
462
+ "id": "global::Date"
463
+ }
464
+ }
465
+ },
466
+ "required": false,
467
+ "optional": false,
468
+ "docs": {
469
+ "tags": [],
470
+ "text": ""
471
+ },
472
+ "getter": false,
473
+ "setter": false,
474
+ "defaultValue": "() => false"
475
+ },
476
+ "elementClassName": {
477
+ "type": "string",
478
+ "mutable": false,
479
+ "complexType": {
480
+ "original": "string",
481
+ "resolved": "string",
482
+ "references": {}
483
+ },
484
+ "required": false,
485
+ "optional": false,
486
+ "docs": {
487
+ "tags": [],
488
+ "text": ""
489
+ },
490
+ "getter": false,
491
+ "setter": false,
492
+ "reflect": false,
493
+ "attribute": "element-class-name",
494
+ "defaultValue": "\"tabworthy-dates-calendar\""
495
+ },
496
+ "firstDayOfWeek": {
497
+ "type": "number",
498
+ "mutable": false,
499
+ "complexType": {
500
+ "original": "number",
501
+ "resolved": "number",
502
+ "references": {}
503
+ },
504
+ "required": false,
505
+ "optional": false,
506
+ "docs": {
507
+ "tags": [],
508
+ "text": ""
509
+ },
510
+ "getter": false,
511
+ "setter": false,
512
+ "reflect": false,
513
+ "attribute": "first-day-of-week",
514
+ "defaultValue": "0"
515
+ },
516
+ "range": {
517
+ "type": "boolean",
518
+ "mutable": false,
519
+ "complexType": {
520
+ "original": "boolean",
521
+ "resolved": "boolean",
522
+ "references": {}
523
+ },
524
+ "required": false,
525
+ "optional": true,
526
+ "docs": {
527
+ "tags": [],
528
+ "text": ""
529
+ },
530
+ "getter": false,
531
+ "setter": false,
532
+ "reflect": false,
533
+ "attribute": "range",
534
+ "defaultValue": "false"
535
+ },
536
+ "labels": {
537
+ "type": "unknown",
538
+ "mutable": false,
539
+ "complexType": {
540
+ "original": "DatesCalendarLabels",
541
+ "resolved": "{ clearButton: string; monthSelect: string; nextMonthButton: string; nextYearButton: string; picker: string; previousMonthButton: string; previousYearButton: string; todayButton: string; yearSelect: string; keyboardHint: string; selected: string; chooseAsStartDate: string; chooseAsEndDate: string; }",
542
+ "references": {
543
+ "DatesCalendarLabels": {
544
+ "location": "local",
545
+ "path": "/Users/damirbogdanov_1/work/tabworthy-components/src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx",
546
+ "id": "src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx::DatesCalendarLabels"
547
+ }
548
+ }
549
+ },
550
+ "required": false,
551
+ "optional": false,
552
+ "docs": {
553
+ "tags": [],
554
+ "text": ""
555
+ },
556
+ "getter": false,
557
+ "setter": false,
558
+ "defaultValue": "defaultLabels"
559
+ },
560
+ "locale": {
561
+ "type": "string",
562
+ "mutable": false,
563
+ "complexType": {
564
+ "original": "string",
565
+ "resolved": "string",
566
+ "references": {}
567
+ },
568
+ "required": false,
569
+ "optional": true,
570
+ "docs": {
571
+ "tags": [],
572
+ "text": ""
573
+ },
574
+ "getter": false,
575
+ "setter": false,
576
+ "reflect": false,
577
+ "attribute": "locale",
578
+ "defaultValue": "navigator?.language || \"en-US\""
579
+ },
580
+ "nextMonthButtonContent": {
581
+ "type": "string",
582
+ "mutable": false,
583
+ "complexType": {
584
+ "original": "string",
585
+ "resolved": "string",
586
+ "references": {}
587
+ },
588
+ "required": false,
589
+ "optional": true,
590
+ "docs": {
591
+ "tags": [],
592
+ "text": ""
593
+ },
594
+ "getter": false,
595
+ "setter": false,
596
+ "reflect": false,
597
+ "attribute": "next-month-button-content"
598
+ },
599
+ "nextYearButtonContent": {
600
+ "type": "string",
601
+ "mutable": false,
602
+ "complexType": {
603
+ "original": "string",
604
+ "resolved": "string",
605
+ "references": {}
606
+ },
607
+ "required": false,
608
+ "optional": true,
609
+ "docs": {
610
+ "tags": [],
611
+ "text": ""
612
+ },
613
+ "getter": false,
614
+ "setter": false,
615
+ "reflect": false,
616
+ "attribute": "next-year-button-content"
617
+ },
618
+ "previousMonthButtonContent": {
619
+ "type": "string",
620
+ "mutable": false,
621
+ "complexType": {
622
+ "original": "string",
623
+ "resolved": "string",
624
+ "references": {}
625
+ },
626
+ "required": false,
627
+ "optional": true,
628
+ "docs": {
629
+ "tags": [],
630
+ "text": ""
631
+ },
632
+ "getter": false,
633
+ "setter": false,
634
+ "reflect": false,
635
+ "attribute": "previous-month-button-content"
636
+ },
637
+ "previousYearButtonContent": {
638
+ "type": "string",
639
+ "mutable": false,
640
+ "complexType": {
641
+ "original": "string",
642
+ "resolved": "string",
643
+ "references": {}
644
+ },
645
+ "required": false,
646
+ "optional": true,
647
+ "docs": {
648
+ "tags": [],
649
+ "text": ""
650
+ },
651
+ "getter": false,
652
+ "setter": false,
653
+ "reflect": false,
654
+ "attribute": "previous-year-button-content"
655
+ },
656
+ "minDate": {
657
+ "type": "string",
658
+ "mutable": false,
659
+ "complexType": {
660
+ "original": "string",
661
+ "resolved": "string",
662
+ "references": {}
663
+ },
664
+ "required": false,
665
+ "optional": true,
666
+ "docs": {
667
+ "tags": [],
668
+ "text": ""
669
+ },
670
+ "getter": false,
671
+ "setter": false,
672
+ "reflect": false,
673
+ "attribute": "min-date"
674
+ },
675
+ "maxDate": {
676
+ "type": "string",
677
+ "mutable": false,
678
+ "complexType": {
679
+ "original": "string",
680
+ "resolved": "string",
681
+ "references": {}
682
+ },
683
+ "required": false,
684
+ "optional": true,
685
+ "docs": {
686
+ "tags": [],
687
+ "text": ""
688
+ },
689
+ "getter": false,
690
+ "setter": false,
691
+ "reflect": false,
692
+ "attribute": "max-date"
693
+ },
694
+ "inline": {
695
+ "type": "boolean",
696
+ "mutable": false,
697
+ "complexType": {
698
+ "original": "boolean",
699
+ "resolved": "boolean",
700
+ "references": {}
701
+ },
702
+ "required": false,
703
+ "optional": false,
704
+ "docs": {
705
+ "tags": [],
706
+ "text": ""
707
+ },
708
+ "getter": false,
709
+ "setter": false,
710
+ "reflect": false,
711
+ "attribute": "inline",
712
+ "defaultValue": "false"
713
+ },
714
+ "showClearButton": {
715
+ "type": "boolean",
716
+ "mutable": false,
717
+ "complexType": {
718
+ "original": "boolean",
719
+ "resolved": "boolean",
720
+ "references": {}
721
+ },
722
+ "required": false,
723
+ "optional": true,
724
+ "docs": {
725
+ "tags": [],
726
+ "text": ""
727
+ },
728
+ "getter": false,
729
+ "setter": false,
730
+ "reflect": false,
731
+ "attribute": "show-clear-button",
732
+ "defaultValue": "false"
733
+ },
734
+ "showMonthStepper": {
735
+ "type": "boolean",
736
+ "mutable": false,
737
+ "complexType": {
738
+ "original": "boolean",
739
+ "resolved": "boolean",
740
+ "references": {}
741
+ },
742
+ "required": false,
743
+ "optional": true,
744
+ "docs": {
745
+ "tags": [],
746
+ "text": ""
747
+ },
748
+ "getter": false,
749
+ "setter": false,
750
+ "reflect": false,
751
+ "attribute": "show-month-stepper",
752
+ "defaultValue": "true"
753
+ },
754
+ "showTodayButton": {
755
+ "type": "boolean",
756
+ "mutable": false,
757
+ "complexType": {
758
+ "original": "boolean",
759
+ "resolved": "boolean",
760
+ "references": {}
761
+ },
762
+ "required": false,
763
+ "optional": true,
764
+ "docs": {
765
+ "tags": [],
766
+ "text": ""
767
+ },
768
+ "getter": false,
769
+ "setter": false,
770
+ "reflect": false,
771
+ "attribute": "show-today-button",
772
+ "defaultValue": "true"
773
+ },
774
+ "showYearStepper": {
775
+ "type": "boolean",
776
+ "mutable": false,
777
+ "complexType": {
778
+ "original": "boolean",
779
+ "resolved": "boolean",
780
+ "references": {}
781
+ },
782
+ "required": false,
783
+ "optional": true,
784
+ "docs": {
785
+ "tags": [],
786
+ "text": ""
787
+ },
788
+ "getter": false,
789
+ "setter": false,
790
+ "reflect": false,
791
+ "attribute": "show-year-stepper",
792
+ "defaultValue": "false"
793
+ },
794
+ "showKeyboardHint": {
795
+ "type": "boolean",
796
+ "mutable": false,
797
+ "complexType": {
798
+ "original": "boolean",
799
+ "resolved": "boolean",
800
+ "references": {}
801
+ },
802
+ "required": false,
803
+ "optional": true,
804
+ "docs": {
805
+ "tags": [],
806
+ "text": ""
807
+ },
808
+ "getter": false,
809
+ "setter": false,
810
+ "reflect": false,
811
+ "attribute": "show-keyboard-hint",
812
+ "defaultValue": "false"
813
+ },
814
+ "showHiddenTitle": {
815
+ "type": "boolean",
816
+ "mutable": false,
817
+ "complexType": {
818
+ "original": "boolean",
819
+ "resolved": "boolean",
820
+ "references": {}
821
+ },
822
+ "required": false,
823
+ "optional": true,
824
+ "docs": {
825
+ "tags": [],
826
+ "text": ""
827
+ },
828
+ "getter": false,
829
+ "setter": false,
830
+ "reflect": false,
831
+ "attribute": "show-hidden-title",
832
+ "defaultValue": "true"
833
+ },
834
+ "startDate": {
835
+ "type": "string",
836
+ "mutable": false,
837
+ "complexType": {
838
+ "original": "string",
839
+ "resolved": "string",
840
+ "references": {}
841
+ },
842
+ "required": false,
843
+ "optional": true,
844
+ "docs": {
845
+ "tags": [],
846
+ "text": ""
847
+ },
848
+ "getter": false,
849
+ "setter": false,
850
+ "reflect": false,
851
+ "attribute": "start-date",
852
+ "defaultValue": "getISODateString(new Date())"
853
+ },
854
+ "todayButtonContent": {
855
+ "type": "string",
856
+ "mutable": false,
857
+ "complexType": {
858
+ "original": "string",
859
+ "resolved": "string",
860
+ "references": {}
861
+ },
862
+ "required": false,
863
+ "optional": true,
864
+ "docs": {
865
+ "tags": [],
866
+ "text": ""
867
+ },
868
+ "getter": false,
869
+ "setter": false,
870
+ "reflect": false,
871
+ "attribute": "today-button-content"
872
+ },
873
+ "value": {
874
+ "type": "unknown",
875
+ "mutable": true,
876
+ "complexType": {
877
+ "original": "Date | Date[] | null",
878
+ "resolved": "Date | Date[]",
879
+ "references": {
880
+ "Date": {
881
+ "location": "global",
882
+ "id": "global::Date"
883
+ }
884
+ }
885
+ },
886
+ "required": false,
887
+ "optional": true,
888
+ "docs": {
889
+ "tags": [],
890
+ "text": ""
891
+ },
892
+ "getter": false,
893
+ "setter": false
894
+ }
895
+ };
896
+ }
897
+ static get states() {
898
+ return {
899
+ "currentDate": {},
900
+ "hoveredDate": {},
901
+ "weekdays": {}
902
+ };
903
+ }
904
+ static get events() {
905
+ return [{
906
+ "method": "selectDate",
907
+ "name": "selectDate",
908
+ "bubbles": true,
909
+ "cancelable": true,
910
+ "composed": true,
911
+ "docs": {
912
+ "tags": [],
913
+ "text": ""
914
+ },
915
+ "complexType": {
916
+ "original": "string | string[] | undefined",
917
+ "resolved": "string | string[]",
918
+ "references": {}
919
+ }
920
+ }, {
921
+ "method": "changeMonth",
922
+ "name": "changeMonth",
923
+ "bubbles": true,
924
+ "cancelable": true,
925
+ "composed": true,
926
+ "docs": {
927
+ "tags": [],
928
+ "text": ""
929
+ },
930
+ "complexType": {
931
+ "original": "MonthChangedEventDetails",
932
+ "resolved": "MonthChangedEventDetails",
933
+ "references": {
934
+ "MonthChangedEventDetails": {
935
+ "location": "local",
936
+ "path": "/Users/damirbogdanov_1/work/tabworthy-components/src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx",
937
+ "id": "src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx::MonthChangedEventDetails"
938
+ }
939
+ }
940
+ }
941
+ }, {
942
+ "method": "changeYear",
943
+ "name": "changeYear",
944
+ "bubbles": true,
945
+ "cancelable": true,
946
+ "composed": true,
947
+ "docs": {
948
+ "tags": [],
949
+ "text": ""
950
+ },
951
+ "complexType": {
952
+ "original": "YearChangedEventDetails",
953
+ "resolved": "YearChangedEventDetails",
954
+ "references": {
955
+ "YearChangedEventDetails": {
956
+ "location": "local",
957
+ "path": "/Users/damirbogdanov_1/work/tabworthy-components/src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx",
958
+ "id": "src/components/tabworthy-dates-calendar/tabworthy-dates-calendar.tsx::YearChangedEventDetails"
959
+ }
960
+ }
961
+ }
962
+ }];
963
+ }
964
+ static get elementRef() { return "el"; }
965
+ static get watchers() {
966
+ return [{
967
+ "propName": "modalIsOpen",
968
+ "methodName": "watchModalIsOpen"
969
+ }, {
970
+ "propName": "firstDayOfWeek",
971
+ "methodName": "watchFirstDayOfWeek"
972
+ }, {
973
+ "propName": "locale",
974
+ "methodName": "watchLocale"
975
+ }, {
976
+ "propName": "range",
977
+ "methodName": "watchRange"
978
+ }, {
979
+ "propName": "startDate",
980
+ "methodName": "watchStartDate"
981
+ }, {
982
+ "propName": "value",
983
+ "methodName": "watchValue"
984
+ }];
985
+ }
986
+ }