@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,881 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-BusoZVTR.js';
2
+ import { g as getISODateString, r as removeTimezoneOffset, a as getNextMonth, b as getNextYear, c as getPreviousMonth, d as getPreviousYear, e as dateIsWithinBounds, f as getPreviousDay, h as getNextDay, s as subDays, i as addDays, j as getFirstOfMonth, k as getLastOfMonth, l as getWeekDays, m as getDaysOfMonth, n as dateIsWithinLowerBounds, o as dateIsWithinUpperBounds, p as getYear, q as getMonth, t as monthIsDisabled, u as getMonths, v as isSameDay, w as isDateInRange } from './utils-BVHu5CWV.js';
3
+
4
+ const tabworthyDatesCalendarCss = () => `.visually-hidden.sc-tabworthy-dates-calendar{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%)}`;
5
+
6
+ const defaultLabels = {
7
+ clearButton: "Clear value",
8
+ monthSelect: "Select month",
9
+ nextMonthButton: "Next month",
10
+ nextYearButton: "Next year",
11
+ picker: "Choose date",
12
+ previousMonthButton: "Previous month",
13
+ previousYearButton: "Previous year",
14
+ todayButton: "Show today",
15
+ yearSelect: "Select year",
16
+ keyboardHint: "Keyboard commands",
17
+ selected: "Selected date",
18
+ chooseAsStartDate: "choose as start date",
19
+ chooseAsEndDate: "choose as end date"
20
+ };
21
+ const InclusiveDatesCalendar = class {
22
+ constructor(hostRef) {
23
+ registerInstance(this, hostRef);
24
+ this.selectDate = createEvent(this, "selectDate");
25
+ this.changeMonth = createEvent(this, "changeMonth");
26
+ this.changeYear = createEvent(this, "changeYear");
27
+ this.disabled = false;
28
+ this.modalIsOpen = false;
29
+ this.disableDate = () => false;
30
+ this.elementClassName = "tabworthy-dates-calendar";
31
+ this.firstDayOfWeek = 0;
32
+ this.range = false;
33
+ this.labels = defaultLabels;
34
+ this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
35
+ this.inline = false;
36
+ this.showClearButton = false;
37
+ this.showMonthStepper = true;
38
+ this.showTodayButton = true;
39
+ this.showYearStepper = false;
40
+ this.showKeyboardHint = false;
41
+ this.showHiddenTitle = true;
42
+ this.startDate = getISODateString(new Date());
43
+ this.init = () => {
44
+ this.currentDate = this.startDate
45
+ ? removeTimezoneOffset(new Date(this.startDate))
46
+ : new Date();
47
+ this.updateWeekdays();
48
+ };
49
+ this.nextMonth = () => {
50
+ this.updateCurrentDate(getNextMonth(this.currentDate));
51
+ };
52
+ this.nextYear = () => {
53
+ this.updateCurrentDate(getNextYear(this.currentDate));
54
+ };
55
+ this.previousMonth = () => {
56
+ this.updateCurrentDate(getPreviousMonth(this.currentDate));
57
+ };
58
+ this.previousYear = () => {
59
+ this.updateCurrentDate(getPreviousYear(this.currentDate));
60
+ };
61
+ this.showToday = () => {
62
+ this.updateCurrentDate(new Date(), true);
63
+ };
64
+ this.clear = () => {
65
+ var _a;
66
+ this.value = undefined;
67
+ (_a = this.selectDate) === null || _a === void 0 ? void 0 : _a.emit(undefined);
68
+ };
69
+ this.onClick = (event) => {
70
+ if (this.disabled) {
71
+ return;
72
+ }
73
+ const target = event.target.closest("[data-date]");
74
+ if (!Boolean(target)) {
75
+ return;
76
+ }
77
+ const date = removeTimezoneOffset(new Date(target.dataset.date));
78
+ this.updateCurrentDate(date);
79
+ this.onSelectDate(date);
80
+ };
81
+ this.onMonthSelect = (event) => {
82
+ const month = +event.target.value - 1;
83
+ const date = new Date(this.currentDate);
84
+ if (!dateIsWithinBounds(date, this.minDate, this.maxDate))
85
+ return;
86
+ date.setMonth(month);
87
+ this.updateCurrentDate(date);
88
+ };
89
+ this.onYearSelect = (event) => {
90
+ var _a;
91
+ const year = +event.target.value;
92
+ const date = new Date(this.currentDate);
93
+ if (!dateIsWithinBounds(date, this.minDate, this.maxDate))
94
+ return;
95
+ date.setFullYear(year);
96
+ (_a = this.changeYear) === null || _a === void 0 ? void 0 : _a.emit({ year });
97
+ this.updateCurrentDate(date);
98
+ };
99
+ this.onKeyDown = (event) => {
100
+ if (this.disabled) {
101
+ return;
102
+ }
103
+ if (event.code === "ArrowLeft") {
104
+ event.preventDefault();
105
+ this.updateCurrentDate(getPreviousDay(this.currentDate), true);
106
+ }
107
+ else if (event.code === "ArrowRight") {
108
+ event.preventDefault();
109
+ this.updateCurrentDate(getNextDay(this.currentDate), true);
110
+ }
111
+ else if (event.code === "ArrowUp") {
112
+ event.preventDefault();
113
+ this.updateCurrentDate(subDays(this.currentDate, 7), true);
114
+ }
115
+ else if (event.code === "ArrowDown") {
116
+ event.preventDefault();
117
+ this.updateCurrentDate(addDays(this.currentDate, 7), true);
118
+ }
119
+ else if (event.code === "PageUp") {
120
+ event.preventDefault();
121
+ if (event.shiftKey) {
122
+ this.updateCurrentDate(getPreviousYear(this.currentDate), true);
123
+ }
124
+ else {
125
+ this.updateCurrentDate(getPreviousMonth(this.currentDate), true);
126
+ }
127
+ }
128
+ else if (event.code === "PageDown") {
129
+ event.preventDefault();
130
+ if (event.shiftKey) {
131
+ this.updateCurrentDate(getNextYear(this.currentDate), true);
132
+ }
133
+ else {
134
+ this.updateCurrentDate(getNextMonth(this.currentDate), true);
135
+ }
136
+ }
137
+ else if (event.code === "Home") {
138
+ event.preventDefault();
139
+ this.updateCurrentDate(getFirstOfMonth(this.currentDate), true);
140
+ }
141
+ else if (event.code === "End") {
142
+ event.preventDefault();
143
+ this.updateCurrentDate(getLastOfMonth(this.currentDate), true);
144
+ }
145
+ else if (event.code === "Space" || event.code === "Enter") {
146
+ event.preventDefault();
147
+ this.onSelectDate(this.currentDate);
148
+ }
149
+ };
150
+ this.onMouseEnter = (event) => {
151
+ var _a;
152
+ if (this.disabled) {
153
+ return;
154
+ }
155
+ const date = removeTimezoneOffset(new Date((_a = event.target.closest("td")) === null || _a === void 0 ? void 0 : _a.dataset.date));
156
+ this.hoveredDate = date;
157
+ };
158
+ this.onMouseLeave = () => {
159
+ this.hoveredDate = undefined;
160
+ };
161
+ }
162
+ componentWillLoad() {
163
+ this.init();
164
+ }
165
+ watchModalIsOpen() {
166
+ if (this.modalIsOpen === true) {
167
+ this.moveFocusOnModalOpen = true;
168
+ }
169
+ }
170
+ watchFirstDayOfWeek() {
171
+ this.updateWeekdays();
172
+ }
173
+ watchLocale() {
174
+ if (!Boolean(this.locale)) {
175
+ this.locale = (navigator === null || navigator === void 0 ? void 0 : navigator.language) || "en-US";
176
+ }
177
+ this.updateWeekdays();
178
+ }
179
+ watchRange() {
180
+ var _a;
181
+ this.value = undefined;
182
+ (_a = this.selectDate) === null || _a === void 0 ? void 0 : _a.emit(undefined);
183
+ }
184
+ watchStartDate() {
185
+ this.currentDate = this.startDate
186
+ ? removeTimezoneOffset(new Date(this.startDate))
187
+ : new Date();
188
+ }
189
+ watchValue() {
190
+ if (Boolean(this.value)) {
191
+ if (Array.isArray(this.value) && this.value.length >= 1) {
192
+ this.currentDate = this.value[0];
193
+ }
194
+ else if (this.value instanceof Date) {
195
+ this.currentDate = this.value;
196
+ }
197
+ }
198
+ }
199
+ componentDidRender() {
200
+ if (this.moveFocusAfterMonthChanged) {
201
+ this.focusDate(this.currentDate);
202
+ this.moveFocusAfterMonthChanged = false;
203
+ }
204
+ if (this.moveFocusOnModalOpen) {
205
+ // Timeout added to stop VoiceOver from crashing Safari when openin the calendar. TODO: Investigate a neater solution
206
+ setTimeout(() => {
207
+ this.focusDate(this.currentDate);
208
+ this.moveFocusOnModalOpen = false;
209
+ }, 100);
210
+ }
211
+ }
212
+ updateWeekdays() {
213
+ this.weekdays = getWeekDays(this.firstDayOfWeek, this.locale);
214
+ }
215
+ getClassName(element) {
216
+ return Boolean(element)
217
+ ? `${this.elementClassName}__${element}`
218
+ : this.elementClassName;
219
+ }
220
+ getCalendarRows() {
221
+ const daysOfMonth = getDaysOfMonth(this.currentDate, true, this.firstDayOfWeek === 0 ? 7 : this.firstDayOfWeek);
222
+ const calendarRows = [];
223
+ for (let i = 0; i < daysOfMonth.length; i += 7) {
224
+ const row = daysOfMonth.slice(i, i + 7);
225
+ calendarRows.push(row);
226
+ }
227
+ return calendarRows;
228
+ }
229
+ getTitle() {
230
+ if (!Boolean(this.currentDate)) {
231
+ return;
232
+ }
233
+ return Intl.DateTimeFormat(this.locale, {
234
+ month: "long",
235
+ year: "numeric"
236
+ }).format(this.currentDate);
237
+ }
238
+ focusDate(date) {
239
+ var _a;
240
+ date && ((_a = this.el
241
+ .querySelector(`[data-date="${getISODateString(date)}"]`)) === null || _a === void 0 ? void 0 : _a.focus());
242
+ }
243
+ updateCurrentDate(date, moveFocus) {
244
+ var _a, _b;
245
+ const month = date.getMonth();
246
+ const year = date.getFullYear();
247
+ if (!dateIsWithinLowerBounds(date, this.minDate))
248
+ date = new Date(this.minDate);
249
+ if (!dateIsWithinUpperBounds(date, this.maxDate))
250
+ date = new Date(this.maxDate);
251
+ const monthChanged = month !== ((_a = this.currentDate) === null || _a === void 0 ? void 0 : _a.getMonth()) ||
252
+ year !== this.currentDate.getFullYear();
253
+ if (monthChanged) {
254
+ (_b = this.changeMonth) === null || _b === void 0 ? void 0 : _b.emit({ month: getMonth(date), year: getYear(date) });
255
+ if (moveFocus) {
256
+ this.moveFocusAfterMonthChanged = true;
257
+ }
258
+ }
259
+ this.currentDate = date;
260
+ if (moveFocus) {
261
+ this.focusDate(this.currentDate);
262
+ }
263
+ }
264
+ onSelectDate(date) {
265
+ var _a, _b, _c, _d;
266
+ if (this.disableDate(date) ||
267
+ !dateIsWithinBounds(date, this.minDate, this.maxDate)) {
268
+ return;
269
+ }
270
+ if (this.isRangeValue(this.value)) {
271
+ const newValue = ((_a = this.value) === null || _a === void 0 ? void 0 : _a[0]) === undefined || this.value.length === 2
272
+ ? [date]
273
+ : [this.value[0], date];
274
+ if (newValue.length === 2 && newValue[0] > newValue[1]) {
275
+ newValue.reverse();
276
+ }
277
+ const isoValue = newValue[1] === undefined
278
+ ? [getISODateString(newValue[0])]
279
+ : [getISODateString(newValue[0]), getISODateString(newValue[1])];
280
+ this.value = newValue;
281
+ (_b = this.selectDate) === null || _b === void 0 ? void 0 : _b.emit(isoValue);
282
+ }
283
+ else {
284
+ if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.getTime()) === date.getTime()) {
285
+ return;
286
+ }
287
+ this.value = date;
288
+ (_d = this.selectDate) === null || _d === void 0 ? void 0 : _d.emit(getISODateString(date));
289
+ }
290
+ }
291
+ isRangeValue(_value) {
292
+ return !!this.range;
293
+ }
294
+ render() {
295
+ var _a;
296
+ const showFooter = this.showTodayButton || this.showClearButton || this.showKeyboardHint;
297
+ const disabled = {
298
+ year: {
299
+ prev: this.disabled || (!!this.minDate && new Date(this.minDate).getFullYear() > getPreviousYear(this.currentDate).getFullYear()),
300
+ next: this.disabled || (!!this.maxDate && new Date(this.maxDate).getFullYear() < getNextYear(this.currentDate).getFullYear())
301
+ },
302
+ month: {
303
+ prev: this.disabled ||
304
+ monthIsDisabled(getPreviousMonth(this.currentDate).getMonth(), getPreviousMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate),
305
+ next: this.disabled ||
306
+ monthIsDisabled(getNextMonth(this.currentDate).getMonth(), getNextMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate)
307
+ }
308
+ };
309
+ return (h(Host, { key: '79018439c3f99dc228ac0d429763d1e86fe9bb03' }, h("div", { key: '8863cf5d0de75a1f358723440f11b70128d7c739', class: {
310
+ [`${this.getClassName()}-wrapper`]: true,
311
+ [`${this.getClassName()}-wrapper--inline`]: this.inline
312
+ } }, h("div", { key: 'b47630e94a50c0bb74da62f1d9e9931ed06e15ab', class: {
313
+ [this.getClassName()]: true,
314
+ [`${this.getClassName()}--disabled`]: this.disabled,
315
+ } }, 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) => {
316
+ return (h("option", { key: month, selected: this.currentDate.getMonth() === index, value: index + 1, disabled: monthIsDisabled(index, this.currentDate.getFullYear(), this.minDate, this.maxDate) }, month));
317
+ })), 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) => {
318
+ const rowKey = `row-${calendarRow[0].getMonth()}-${calendarRow[0].getDate()}`;
319
+ return (h("tr", { class: this.getClassName("calendar-row"), key: rowKey }, calendarRow.map((day) => {
320
+ var _a, _b, _c;
321
+ const isCurrent = isSameDay(day, this.currentDate);
322
+ const isOverflowing = day.getMonth() !== ((_a = this.currentDate) === null || _a === void 0 ? void 0 : _a.getMonth());
323
+ const isSelected = Array.isArray(this.value)
324
+ ? isSameDay(day, this.value[0]) ||
325
+ (this.value[1] &&
326
+ dateIsWithinBounds(day, getISODateString(this.value[0]), getISODateString(this.value[1])))
327
+ : isSameDay(day, this.value);
328
+ const isDisabled = this.disableDate(day) ||
329
+ !dateIsWithinBounds(day, this.minDate, this.maxDate);
330
+ const isInRange = !this.isRangeValue(this.value)
331
+ ? false
332
+ : isDateInRange(day, {
333
+ from: (_b = this.value) === null || _b === void 0 ? void 0 : _b[0],
334
+ to: ((_c = this.value) === null || _c === void 0 ? void 0 : _c[1]) ||
335
+ this.hoveredDate ||
336
+ this.currentDate
337
+ }) && !isDisabled;
338
+ const isToday = isSameDay(day, new Date());
339
+ const cellKey = `cell-${day.getMonth()}-${day.getDate()}`;
340
+ const getScreenReaderText = () => {
341
+ if (this.range) {
342
+ let suffix = !this.value
343
+ ? `, ${this.labels.chooseAsStartDate}.`
344
+ : "";
345
+ if (Array.isArray(this.value)) {
346
+ suffix = {
347
+ 1: `, ${this.labels.chooseAsEndDate}.`,
348
+ 2: `, ${this.labels.chooseAsStartDate}.`
349
+ }[this.value.length];
350
+ }
351
+ return `${isSelected ? `${this.labels.selected}, ` : ""}${Intl.DateTimeFormat(this.locale, {
352
+ day: "numeric",
353
+ month: "long",
354
+ year: "numeric"
355
+ }).format(day)}${suffix}`;
356
+ }
357
+ else {
358
+ return `${isSelected ? `${this.labels.selected}, ` : ""}${Intl.DateTimeFormat(this.locale, {
359
+ day: "numeric",
360
+ month: "long",
361
+ year: "numeric"
362
+ }).format(day)}`;
363
+ }
364
+ };
365
+ const className = {
366
+ [this.getClassName("date")]: true,
367
+ [this.getClassName("date--current")]: isCurrent,
368
+ [this.getClassName("date--disabled")]: isDisabled,
369
+ [this.getClassName("date--overflowing")]: isOverflowing,
370
+ [this.getClassName("date--today")]: isToday,
371
+ [this.getClassName("date--selected")]: isSelected,
372
+ [this.getClassName("date--in-range")]: isInRange
373
+ };
374
+ const Tag = isSelected
375
+ ? "strong"
376
+ : isToday
377
+ ? "em"
378
+ : "span";
379
+ 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
380
+ ? 0
381
+ : -1 }, h(Tag, { "aria-hidden": "true" }, day.getDate()), h("span", { class: "visually-hidden" }, getScreenReaderText())));
382
+ })));
383
+ })))), 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 &&
384
+ !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" }))));
385
+ }
386
+ get el() { return getElement(this); }
387
+ static get watchers() { return {
388
+ "modalIsOpen": [{
389
+ "watchModalIsOpen": 0
390
+ }],
391
+ "firstDayOfWeek": [{
392
+ "watchFirstDayOfWeek": 0
393
+ }],
394
+ "locale": [{
395
+ "watchLocale": 0
396
+ }],
397
+ "range": [{
398
+ "watchRange": 0
399
+ }],
400
+ "startDate": [{
401
+ "watchStartDate": 0
402
+ }],
403
+ "value": [{
404
+ "watchValue": 0
405
+ }]
406
+ }; }
407
+ };
408
+ InclusiveDatesCalendar.style = tabworthyDatesCalendarCss();
409
+
410
+ /**
411
+ * Traverses the slots of the open shadowroots and returns all children matching the query.
412
+ * @param {ShadowRoot | HTMLElement} root
413
+ * @param skipNode
414
+ * @param isMatch
415
+ * @param {number} maxDepth
416
+ * @param {number} depth
417
+ * @returns {HTMLElement[]}
418
+ */
419
+ function queryShadowRoot(root, skipNode, isMatch, maxDepth = 20, depth = 0) {
420
+ let matches = [];
421
+ // If the depth is above the max depth, abort the searching here.
422
+ if (depth >= maxDepth) {
423
+ return matches;
424
+ }
425
+ // Traverses a slot element
426
+ const traverseSlot = ($slot) => {
427
+ // Only check nodes that are of the type Node.ELEMENT_NODE
428
+ // Read more here https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
429
+ const assignedNodes = $slot.assignedNodes().filter(node => node.nodeType === 1);
430
+ if (assignedNodes.length > 0) {
431
+ return queryShadowRoot(assignedNodes[0].parentElement, skipNode, isMatch, maxDepth, depth + 1);
432
+ }
433
+ return [];
434
+ };
435
+ // Go through each child and continue the traversing if necessary
436
+ // Even though the typing says that children can't be undefined, Edge 15 sometimes gives an undefined value.
437
+ // Therefore we fallback to an empty array if it is undefined.
438
+ const children = Array.from(root.children || []);
439
+ for (const $child of children) {
440
+ // Check if the node and its descendants should be skipped
441
+ if (skipNode($child)) {
442
+ continue;
443
+ }
444
+ // If the child matches we always add it
445
+ if (isMatch($child)) {
446
+ matches.push($child);
447
+ }
448
+ if ($child.shadowRoot != null) {
449
+ matches.push(...queryShadowRoot($child.shadowRoot, skipNode, isMatch, maxDepth, depth + 1));
450
+ }
451
+ else if ($child.tagName === "SLOT") {
452
+ matches.push(...traverseSlot($child));
453
+ }
454
+ else {
455
+ matches.push(...queryShadowRoot($child, skipNode, isMatch, maxDepth, depth + 1));
456
+ }
457
+ }
458
+ return matches;
459
+ }
460
+
461
+ /**
462
+ * Returns whether the element is hidden.
463
+ * @param $elem
464
+ */
465
+ function isHidden($elem) {
466
+ return $elem.hasAttribute("hidden")
467
+ || ($elem.hasAttribute("aria-hidden") && $elem.getAttribute("aria-hidden") !== "false")
468
+ // A quick and dirty way to check whether the element is hidden.
469
+ // For a more fine-grained check we could use "window.getComputedStyle" but we don't because of bad performance.
470
+ // If the element has visibility set to "hidden" or "collapse", display set to "none" or opacity set to "0" through CSS
471
+ // we won't be able to catch it here. We accept it due to the huge performance benefits.
472
+ || $elem.style.display === `none`
473
+ || $elem.style.opacity === `0`
474
+ || $elem.style.visibility === `hidden`
475
+ || $elem.style.visibility === `collapse`;
476
+ // If offsetParent is null we can assume that the element is hidden
477
+ // https://stackoverflow.com/questions/306305/what-would-make-offsetparent-null
478
+ //|| $elem.offsetParent == null;
479
+ }
480
+ /**
481
+ * Returns whether the element is disabled.
482
+ * @param $elem
483
+ */
484
+ function isDisabled($elem) {
485
+ return $elem.hasAttribute("disabled")
486
+ || ($elem.hasAttribute("aria-disabled") && $elem.getAttribute("aria-disabled") !== "false");
487
+ }
488
+ /**
489
+ * Determines whether an element is focusable.
490
+ * Read more here: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus/1600194#1600194
491
+ * Or here: https://stackoverflow.com/questions/18261595/how-to-check-if-a-dom-element-is-focusable
492
+ * @param $elem
493
+ */
494
+ function isFocusable($elem) {
495
+ // Discard elements that are removed from the tab order.
496
+ if ($elem.getAttribute("tabindex") === "-1" || isHidden($elem) || isDisabled($elem)) {
497
+ return false;
498
+ }
499
+ return (
500
+ // At this point we know that the element can have focus (eg. won't be -1) if the tabindex attribute exists
501
+ $elem.hasAttribute("tabindex")
502
+ // Anchor tags or area tags with a href set
503
+ || ($elem instanceof HTMLAnchorElement || $elem instanceof HTMLAreaElement) && $elem.hasAttribute("href")
504
+ // Form elements which are not disabled
505
+ || ($elem instanceof HTMLButtonElement
506
+ || $elem instanceof HTMLInputElement
507
+ || $elem instanceof HTMLTextAreaElement
508
+ || $elem instanceof HTMLSelectElement)
509
+ // IFrames
510
+ || $elem instanceof HTMLIFrameElement);
511
+ }
512
+
513
+ const timeouts = new Map();
514
+ /**
515
+ * Debounces a callback.
516
+ * @param cb
517
+ * @param ms
518
+ * @param id
519
+ */
520
+ function debounce(cb, ms, id) {
521
+ // Clear current timeout for id
522
+ const timeout = timeouts.get(id);
523
+ if (timeout != null) {
524
+ window.clearTimeout(timeout);
525
+ }
526
+ // Set new timeout
527
+ timeouts.set(id, window.setTimeout(() => {
528
+ cb();
529
+ timeouts.delete(id);
530
+ }, ms));
531
+ }
532
+
533
+ /**
534
+ * Template for the focus trap.
535
+ */
536
+ const template = document.createElement("template");
537
+ template.innerHTML = `
538
+ <div id="start"></div>
539
+ <div id="backup"></div>
540
+ <slot></slot>
541
+ <div id="end"></div>
542
+ `;
543
+ /**
544
+ * Focus trap web component.
545
+ * @customElement focus-trap
546
+ * @slot - Default content.
547
+ */
548
+ class FocusTrap extends HTMLElement {
549
+ /**
550
+ * Attaches the shadow root.
551
+ */
552
+ constructor() {
553
+ super();
554
+ // The debounce id is used to distinguish this focus trap from others when debouncing
555
+ this.debounceId = Math.random().toString();
556
+ this._focused = false;
557
+ const shadow = this.attachShadow({ mode: "open" });
558
+ shadow.appendChild(template.content.cloneNode(true));
559
+ this.$backup = shadow.querySelector("#backup");
560
+ this.$start = shadow.querySelector("#start");
561
+ this.$end = shadow.querySelector("#end");
562
+ this.focusLastElement = this.focusLastElement.bind(this);
563
+ this.focusFirstElement = this.focusFirstElement.bind(this);
564
+ this.onFocusIn = this.onFocusIn.bind(this);
565
+ this.onFocusOut = this.onFocusOut.bind(this);
566
+ }
567
+ // Whenever one of these attributes changes we need to render the template again.
568
+ static get observedAttributes() {
569
+ return [
570
+ "inactive"
571
+ ];
572
+ }
573
+ /**
574
+ * Determines whether the focus trap is active or not.
575
+ * @attr
576
+ */
577
+ get inactive() {
578
+ return this.hasAttribute("inactive");
579
+ }
580
+ set inactive(value) {
581
+ value ? this.setAttribute("inactive", "") : this.removeAttribute("inactive");
582
+ }
583
+ /**
584
+ * Returns whether the element currently has focus.
585
+ */
586
+ get focused() {
587
+ return this._focused;
588
+ }
589
+ /**
590
+ * Hooks up the element.
591
+ */
592
+ connectedCallback() {
593
+ this.$start.addEventListener("focus", this.focusLastElement);
594
+ this.$end.addEventListener("focus", this.focusFirstElement);
595
+ // Focus out is called every time the user tabs around inside the element
596
+ this.addEventListener("focusin", this.onFocusIn);
597
+ this.addEventListener("focusout", this.onFocusOut);
598
+ this.render();
599
+ }
600
+ /**
601
+ * Tears down the element.
602
+ */
603
+ disconnectedCallback() {
604
+ this.$start.removeEventListener("focus", this.focusLastElement);
605
+ this.$end.removeEventListener("focus", this.focusFirstElement);
606
+ this.removeEventListener("focusin", this.onFocusIn);
607
+ this.removeEventListener("focusout", this.onFocusOut);
608
+ }
609
+ /**
610
+ * When the attributes changes we need to re-render the template.
611
+ */
612
+ attributeChangedCallback() {
613
+ this.render();
614
+ }
615
+ /**
616
+ * Focuses the first focusable element in the focus trap.
617
+ */
618
+ focusFirstElement() {
619
+ this.trapFocus();
620
+ }
621
+ /**
622
+ * Focuses the last focusable element in the focus trap.
623
+ */
624
+ focusLastElement() {
625
+ this.trapFocus(true);
626
+ }
627
+ /**
628
+ * Returns a list of the focusable children found within the element.
629
+ */
630
+ getFocusableElements() {
631
+ return queryShadowRoot(this, isHidden, isFocusable);
632
+ }
633
+ /**
634
+ * Focuses on either the last or first focusable element.
635
+ * @param {boolean} trapToEnd
636
+ */
637
+ trapFocus(trapToEnd) {
638
+ if (this.inactive)
639
+ return;
640
+ let focusableChildren = this.getFocusableElements();
641
+ if (focusableChildren.length > 0) {
642
+ if (trapToEnd) {
643
+ focusableChildren[focusableChildren.length - 1].focus();
644
+ }
645
+ else {
646
+ focusableChildren[0].focus();
647
+ }
648
+ this.$backup.setAttribute("tabindex", "-1");
649
+ }
650
+ else {
651
+ // If there are no focusable children we need to focus on the backup
652
+ // to trap the focus. This is a useful behavior if the focus trap is
653
+ // for example used in a dialog and we don't want the user to tab
654
+ // outside the dialog even though there are no focusable children
655
+ // in the dialog.
656
+ this.$backup.setAttribute("tabindex", "0");
657
+ this.$backup.focus();
658
+ }
659
+ }
660
+ /**
661
+ * When the element gains focus this function is called.
662
+ */
663
+ onFocusIn() {
664
+ this.updateFocused(true);
665
+ }
666
+ /**
667
+ * When the element looses its focus this function is called.
668
+ */
669
+ onFocusOut() {
670
+ this.updateFocused(false);
671
+ }
672
+ /**
673
+ * Updates the focused property and updates the view.
674
+ * The update is debounced because the focusin and focusout out
675
+ * might fire multiple times in a row. We only want to render
676
+ * the element once, therefore waiting until the focus is "stable".
677
+ * @param value
678
+ */
679
+ updateFocused(value) {
680
+ debounce(() => {
681
+ if (this.focused !== value) {
682
+ this._focused = value;
683
+ this.render();
684
+ }
685
+ }, 0, this.debounceId);
686
+ }
687
+ /**
688
+ * Updates the template.
689
+ */
690
+ render() {
691
+ this.$start.setAttribute("tabindex", !this.focused || this.inactive ? `-1` : `0`);
692
+ this.$end.setAttribute("tabindex", !this.focused || this.inactive ? `-1` : `0`);
693
+ this.focused ? this.setAttribute("focused", "") : this.removeAttribute("focused");
694
+ }
695
+ }
696
+ window.customElements.define("focus-trap", FocusTrap);
697
+
698
+ var getDefaultParent = function (originalTarget) {
699
+ if (typeof document === 'undefined') {
700
+ return null;
701
+ }
702
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
703
+ return sampleTarget.ownerDocument.body;
704
+ };
705
+ var counterMap = new WeakMap();
706
+ var uncontrolledNodes = new WeakMap();
707
+ var markerMap = {};
708
+ var lockCount = 0;
709
+ var unwrapHost = function (node) {
710
+ return node && (node.host || unwrapHost(node.parentNode));
711
+ };
712
+ var correctTargets = function (parent, targets) {
713
+ return targets.map(function (target) {
714
+ if (parent.contains(target)) {
715
+ return target;
716
+ }
717
+ var correctedTarget = unwrapHost(target);
718
+ if (correctedTarget && parent.contains(correctedTarget)) {
719
+ return correctedTarget;
720
+ }
721
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
722
+ return null;
723
+ }).filter(function (x) { return Boolean(x); });
724
+ };
725
+ /**
726
+ * Marks everything except given node(or nodes) as aria-hidden
727
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
728
+ * @param [parentNode] - top element, defaults to document.body
729
+ * @param {String} [markerName] - a special attribute to mark every node
730
+ * @param {String} [controlAttribute] - html Attribute to control
731
+ * @return {Undo} undo command
732
+ */
733
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
734
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
735
+ if (!markerMap[markerName]) {
736
+ markerMap[markerName] = new WeakMap();
737
+ }
738
+ var markerCounter = markerMap[markerName];
739
+ var hiddenNodes = [];
740
+ var elementsToKeep = new Set();
741
+ var elementsToStop = new Set(targets);
742
+ var keep = function (el) {
743
+ if (!el || elementsToKeep.has(el)) {
744
+ return;
745
+ }
746
+ elementsToKeep.add(el);
747
+ keep(el.parentNode);
748
+ };
749
+ targets.forEach(keep);
750
+ var deep = function (parent) {
751
+ if (!parent || elementsToStop.has(parent)) {
752
+ return;
753
+ }
754
+ Array.prototype.forEach.call(parent.children, function (node) {
755
+ if (elementsToKeep.has(node)) {
756
+ deep(node);
757
+ }
758
+ else {
759
+ var attr = node.getAttribute(controlAttribute);
760
+ var alreadyHidden = attr !== null && attr !== 'false';
761
+ var counterValue = (counterMap.get(node) || 0) + 1;
762
+ var markerValue = (markerCounter.get(node) || 0) + 1;
763
+ counterMap.set(node, counterValue);
764
+ markerCounter.set(node, markerValue);
765
+ hiddenNodes.push(node);
766
+ if (counterValue === 1 && alreadyHidden) {
767
+ uncontrolledNodes.set(node, true);
768
+ }
769
+ if (markerValue === 1) {
770
+ node.setAttribute(markerName, 'true');
771
+ }
772
+ if (!alreadyHidden) {
773
+ node.setAttribute(controlAttribute, 'true');
774
+ }
775
+ }
776
+ });
777
+ };
778
+ deep(parentNode);
779
+ elementsToKeep.clear();
780
+ lockCount++;
781
+ return function () {
782
+ hiddenNodes.forEach(function (node) {
783
+ var counterValue = counterMap.get(node) - 1;
784
+ var markerValue = markerCounter.get(node) - 1;
785
+ counterMap.set(node, counterValue);
786
+ markerCounter.set(node, markerValue);
787
+ if (!counterValue) {
788
+ if (!uncontrolledNodes.has(node)) {
789
+ node.removeAttribute(controlAttribute);
790
+ }
791
+ uncontrolledNodes.delete(node);
792
+ }
793
+ if (!markerValue) {
794
+ node.removeAttribute(markerName);
795
+ }
796
+ });
797
+ lockCount--;
798
+ if (!lockCount) {
799
+ // clear
800
+ counterMap = new WeakMap();
801
+ counterMap = new WeakMap();
802
+ uncontrolledNodes = new WeakMap();
803
+ markerMap = {};
804
+ }
805
+ };
806
+ };
807
+ /**
808
+ * Marks everything except given node(or nodes) as aria-hidden
809
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
810
+ * @param [parentNode] - top element, defaults to document.body
811
+ * @param {String} [markerName] - a special attribute to mark every node
812
+ * @return {Undo} undo command
813
+ */
814
+ var hideOthers = function (originalTarget, parentNode, markerName) {
815
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
816
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
817
+ var activeParentNode = getDefaultParent(originalTarget);
818
+ if (!activeParentNode) {
819
+ return function () { return null; };
820
+ }
821
+ // we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
822
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
823
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
824
+ };
825
+
826
+ const tabworthyDatesModalCss = () => `:host::part(body){position:absolute;width:-moz-fit-content;width:fit-content;z-index:1200;margin-top:0.5rem}:host::part(backdrop){}:host::part(content){}`;
827
+
828
+ const InclusiveDatesModal = class {
829
+ constructor(hostRef) {
830
+ registerInstance(this, hostRef);
831
+ this.opened = createEvent(this, "opened");
832
+ this.closed = createEvent(this, "closed");
833
+ this.inline = false;
834
+ this.closing = false;
835
+ this.showing = this.inline || false;
836
+ this.onKeyDown = (event) => {
837
+ if (event.code === "Escape") {
838
+ this.close();
839
+ }
840
+ };
841
+ }
842
+ /**
843
+ * Open the dialog.
844
+ */
845
+ async open() {
846
+ if (this.inline)
847
+ return;
848
+ this.showing = true;
849
+ this.undo = hideOthers(this.el);
850
+ this.opened.emit(undefined);
851
+ }
852
+ /**
853
+ * Close the dialog.
854
+ */
855
+ async close() {
856
+ if (this.inline)
857
+ return;
858
+ this.showing = false;
859
+ this.closed.emit(undefined);
860
+ this.undo();
861
+ if (this.triggerElement)
862
+ this.triggerElement.focus();
863
+ }
864
+ async getState() {
865
+ return this.showing;
866
+ }
867
+ async setTriggerElement(element) {
868
+ this.triggerElement = element;
869
+ }
870
+ handleClick(event) {
871
+ if (this.showing && !this.el.contains(event.target)) {
872
+ this.close();
873
+ }
874
+ }
875
+ render() {
876
+ return (h(Host, { key: 'dd44f82a23c471268369362e7f0899d197b6686a', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (h("div", { key: '6c5d845e75737c366defff2434f51ca345a172f3', part: "body", onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: '56beecf073b790849d2761b3ac135641612744e1' }, h("div", { key: '85aca24946135337732f404ac164553f4374c9ec', part: "content" }, h("slot", { key: 'cb7b7c57ed1012256e3e045f64b40ce8c5d8dd8b' }))))), this.inline && (h("div", { key: '0a6d50757d0c77f1cc781dfe7676a4b3f8e74c22', part: "content" }, h("slot", { key: '17e71b147f00061c3f3f4deb3b66abb465714f8a' })))));
877
+ }
878
+ };
879
+ InclusiveDatesModal.style = tabworthyDatesModalCss();
880
+
881
+ export { InclusiveDatesCalendar as tabworthy_dates_calendar, InclusiveDatesModal as tabworthy_dates_modal };