@tabworthy/components 0.12.2 → 0.12.3
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.
- package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +16 -6
- package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +16 -6
- package/dist/components/p-CkD8Cvl_.js +1 -0
- package/dist/components/tabworthy-dates-calendar.js +1 -1
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/tabworthy-dates-calendar_2.entry.js +16 -6
- package/dist/tabworthy-components/p-8ccc0de2.entry.js +1 -0
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/package.json +1 -2
- package/dist/components/p-M03P4DAz.js +0 -1
- package/dist/tabworthy-components/p-df93e5d4.entry.js +0 -1
|
@@ -233,6 +233,16 @@ const TabworthyDatesCalendar = class {
|
|
|
233
233
|
const row = daysOfMonth.slice(i, i + 7);
|
|
234
234
|
calendarRows.push(row);
|
|
235
235
|
}
|
|
236
|
+
const lastRow = calendarRows[calendarRows.length - 1];
|
|
237
|
+
let lastDay = lastRow === null || lastRow === void 0 ? void 0 : lastRow[lastRow.length - 1];
|
|
238
|
+
while (calendarRows.length < 6 && lastDay) {
|
|
239
|
+
const row = [];
|
|
240
|
+
for (let i = 0; i < 7; i += 1) {
|
|
241
|
+
lastDay = utils.addDays(lastDay, 1);
|
|
242
|
+
row.push(lastDay);
|
|
243
|
+
}
|
|
244
|
+
calendarRows.push(row);
|
|
245
|
+
}
|
|
236
246
|
return calendarRows;
|
|
237
247
|
}
|
|
238
248
|
getTitle() {
|
|
@@ -328,15 +338,15 @@ const TabworthyDatesCalendar = class {
|
|
|
328
338
|
utils.monthIsDisabled(utils.getNextMonth(this.currentDate).getMonth(), utils.getNextMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate)
|
|
329
339
|
}
|
|
330
340
|
};
|
|
331
|
-
return (index.h(index.Host, { key: '
|
|
341
|
+
return (index.h(index.Host, { key: '1bda8d7a489d87cf27ecbcd978accf5363f32804' }, index.h("div", { key: '7118660fbbdfac4a73a1ace99d96d4ac32a4b137', class: {
|
|
332
342
|
[`${this.getClassName()}-wrapper`]: true,
|
|
333
343
|
[`${this.getClassName()}-wrapper--inline`]: this.inline
|
|
334
|
-
} }, index.h("div", { key: '
|
|
344
|
+
} }, index.h("div", { key: '41b62826cdff428aef8ad89844a50873f8853b5e', class: {
|
|
335
345
|
[this.getClassName()]: true,
|
|
336
346
|
[`${this.getClassName()}--disabled`]: this.disabled
|
|
337
|
-
} }, index.h("div", { key: '
|
|
347
|
+
} }, index.h("div", { key: '7a9ee67778c6f48e65d88defc1ff620e995d75bc', class: this.getClassName("header") }, this.showHiddenTitle && (index.h("span", { key: '404e50ab0f24235d6678af7c12f6b3cdd491e347', "aria-atomic": "true", "aria-live": "polite", class: "visually-hidden" }, this.getTitle())), this.showYearStepper && (index.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" }, index.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" }, index.h("polyline", { key: '5b73b6ec2b5abcae4d2e5cd833b5de441938e533', points: "11 17 6 12 11 7" }), index.h("polyline", { key: '05e146e1c233c39403147e7af61948798db7c0f7', points: "18 17 13 12 18 7" })))), this.showMonthStepper && (index.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" }, index.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" }, index.h("polyline", { key: '9395192e65c1e550547220850b29a117569a79e2', points: "15 18 9 12 15 6" })))), index.h("span", { key: '3b282148e95b8b1facde4a2ab370c6088b72bccd', class: this.getClassName("current-month") }, index.h("select", { key: 'f782b9d803abd5eb1add6c869b3ac302a717780d', "aria-label": this.labels.monthSelect, class: this.getClassName("month-select"), "aria-disabled": this.disabled, name: "month", onChange: this.onMonthSelect }, utils.getMonths(this.locale).map((month, index$1) => {
|
|
338
348
|
return (index.h("option", { key: month, selected: this.currentDate.getMonth() === index$1, value: index$1 + 1, disabled: utils.monthIsDisabled(index$1, this.currentDate.getFullYear(), this.minDate, this.maxDate) }, month));
|
|
339
|
-
})), index.h("input", { key: '
|
|
349
|
+
})), index.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 && (index.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" }, index.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" }, index.h("polyline", { key: 'dc88e8e5e4f79d5ae0b62ea51f6ba52d5e26ce9f', points: "9 18 15 12 9 6" })))), this.showYearStepper && (index.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" }, index.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" }, index.h("polyline", { key: 'f8242866ca29743b19055d1ac53fcc8e84d68a35', points: "13 17 18 12 13 7" }), index.h("polyline", { key: '6bda80ff2eba82dac0d36e287976130e6b16113c', points: "6 17 11 12 6 7" }))))), index.h("div", { key: '6d5b0085437827c1db975f12dc5fe5927c7ba62f', class: this.getClassName("body") }, index.h("table", { key: '61975eac4e06c3a416fcb9503eef9c7a386a6b54', class: this.getClassName("calendar"), onKeyDown: this.onKeyDown, role: "grid", "aria-label": this.getTitle() }, index.h("thead", { key: 'fd259bd5ba6e12ff39dad5a31133913d17fdf276', class: this.getClassName("calendar-header") }, index.h("tr", { key: '410c84eabac58cf6139dd6c886b4803772abceb5', class: this.getClassName("weekday-row") }, (_a = this.weekdays) === null || _a === void 0 ? void 0 : _a.map((weekday) => (index.h("th", { role: "columnheader", abbr: weekday[1], class: this.getClassName("weekday"), key: weekday[0], scope: "col" }, index.h("span", { "aria-hidden": "true" }, weekday[0]), index.h("span", { class: "visually-hidden" }, weekday[1])))))), index.h("tbody", { key: '330d3b922d474b42edf0764556d2f2643b5b639d' }, this.getCalendarRows().map((calendarRow) => {
|
|
340
350
|
const rowKey = `row-${calendarRow[0].getMonth()}-${calendarRow[0].getDate()}`;
|
|
341
351
|
return (index.h("tr", { class: this.getClassName("calendar-row"), key: rowKey }, calendarRow.map((day) => {
|
|
342
352
|
var _a, _b, _c;
|
|
@@ -403,8 +413,8 @@ const TabworthyDatesCalendar = class {
|
|
|
403
413
|
? 0
|
|
404
414
|
: -1 }, index.h(Tag, { "aria-hidden": "true" }, day.getDate()), index.h("span", { class: "visually-hidden" }, getScreenReaderText())));
|
|
405
415
|
})));
|
|
406
|
-
})))), showFooter && (index.h("div", { key: '
|
|
407
|
-
!window.matchMedia("(pointer: coarse)").matches && (index.h("button", { key: '
|
|
416
|
+
})))), showFooter && (index.h("div", { key: '88362c2e1731e8813ad9c5da3b34f6afe16f2036', class: this.getClassName("footer") }, index.h("div", { key: 'e93a0b8fff1be09855ab87db159cb186b9339a39', class: this.getClassName("footer-buttons") }, this.showTodayButton && (index.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 && (index.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 && (index.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 &&
|
|
417
|
+
!window.matchMedia("(pointer: coarse)").matches && (index.h("button", { key: '0b478f25499d1aec350b35bb9777c6ec03d7fea3', type: "button", onClick: () => alert("Todo: Add Keyboard helper!"), class: this.getClassName("keyboard-hint") }, index.h("svg", { key: '14840cb62c1a222a347e40f6d1ab043842377a49', xmlns: "http://www.w3.org/2000/svg", height: "1em", width: "1em", viewBox: "0 0 48 48", fill: "currentColor" }, index.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))))), index.h("slot", { key: '4616ab014b3db34b2d42958aefdbc7795829bbba', name: "after-calendar" }))));
|
|
408
418
|
}
|
|
409
419
|
get el() { return index.getElement(this); }
|
|
410
420
|
static get watchers() { return {
|
|
@@ -224,6 +224,16 @@ export class TabworthyDatesCalendar {
|
|
|
224
224
|
const row = daysOfMonth.slice(i, i + 7);
|
|
225
225
|
calendarRows.push(row);
|
|
226
226
|
}
|
|
227
|
+
const lastRow = calendarRows[calendarRows.length - 1];
|
|
228
|
+
let lastDay = lastRow === null || lastRow === void 0 ? void 0 : lastRow[lastRow.length - 1];
|
|
229
|
+
while (calendarRows.length < 6 && lastDay) {
|
|
230
|
+
const row = [];
|
|
231
|
+
for (let i = 0; i < 7; i += 1) {
|
|
232
|
+
lastDay = addDays(lastDay, 1);
|
|
233
|
+
row.push(lastDay);
|
|
234
|
+
}
|
|
235
|
+
calendarRows.push(row);
|
|
236
|
+
}
|
|
227
237
|
return calendarRows;
|
|
228
238
|
}
|
|
229
239
|
getTitle() {
|
|
@@ -319,15 +329,15 @@ export class TabworthyDatesCalendar {
|
|
|
319
329
|
monthIsDisabled(getNextMonth(this.currentDate).getMonth(), getNextMonth(this.currentDate).getFullYear(), this.minDate, this.maxDate)
|
|
320
330
|
}
|
|
321
331
|
};
|
|
322
|
-
return (h(Host, { key: '
|
|
332
|
+
return (h(Host, { key: '1bda8d7a489d87cf27ecbcd978accf5363f32804' }, h("div", { key: '7118660fbbdfac4a73a1ace99d96d4ac32a4b137', class: {
|
|
323
333
|
[`${this.getClassName()}-wrapper`]: true,
|
|
324
334
|
[`${this.getClassName()}-wrapper--inline`]: this.inline
|
|
325
|
-
} }, h("div", { key: '
|
|
335
|
+
} }, h("div", { key: '41b62826cdff428aef8ad89844a50873f8853b5e', class: {
|
|
326
336
|
[this.getClassName()]: true,
|
|
327
337
|
[`${this.getClassName()}--disabled`]: this.disabled
|
|
328
|
-
} }, h("div", { key: '
|
|
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) => {
|
|
329
339
|
return (h("option", { key: month, selected: this.currentDate.getMonth() === index, value: index + 1, disabled: monthIsDisabled(index, this.currentDate.getFullYear(), this.minDate, this.maxDate) }, month));
|
|
330
|
-
})), h("input", { key: '
|
|
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) => {
|
|
331
341
|
const rowKey = `row-${calendarRow[0].getMonth()}-${calendarRow[0].getDate()}`;
|
|
332
342
|
return (h("tr", { class: this.getClassName("calendar-row"), key: rowKey }, calendarRow.map((day) => {
|
|
333
343
|
var _a, _b, _c;
|
|
@@ -394,8 +404,8 @@ export class TabworthyDatesCalendar {
|
|
|
394
404
|
? 0
|
|
395
405
|
: -1 }, h(Tag, { "aria-hidden": "true" }, day.getDate()), h("span", { class: "visually-hidden" }, getScreenReaderText())));
|
|
396
406
|
})));
|
|
397
|
-
})))), showFooter && (h("div", { key: '
|
|
398
|
-
!window.matchMedia("(pointer: coarse)").matches && (h("button", { key: '
|
|
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" }))));
|
|
399
409
|
}
|
|
400
410
|
static get is() { return "tabworthy-dates-calendar"; }
|
|
401
411
|
static get encapsulation() { return "scoped"; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as t,H as e,c as i,h as s,d as a,t as n}from"./p-BiJ0HZVY.js";function h(t,e){const i=new Date(t);return i.setDate(i.getDate()+e),i}function o(t){return k(new Date(`${w(t)}-${String(c(t)).padStart(2,"0")}-01`))}function r(t){return function(t){if(t instanceof Date)return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}(t)}function d(t){const e=o(t);return e.setMonth(e.getMonth()+1),e.setDate(e.getDate()-1),e}function c(t){return t.getMonth()+1}function l(t){return h(t,1)}function u(t){const e=new Date(t);return e.setMonth(e.getMonth()+1),e}function b(t){const e=new Date(t);return e.setFullYear(e.getFullYear()+1),e}function f(t){return m(t,1)}function v(t){const e=new Date(t);return e.setMonth(e.getMonth()-1),e}function y(t){const e=new Date(t);return e.setFullYear(e.getFullYear()-1),e}function w(t){return t.getFullYear()}function p(t,e){return!(!t||!e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function k(t){const e=new Date(t);return e.setMinutes(e.getMinutes()+e.getTimezoneOffset()),e}function m(t,e){const i=new Date(t);return i.setDate(i.getDate()-e),i}function D(t,e){if(e){const i=k(new Date(e));return t>=i||p(i,t)}return!0}function g(t,e){if(e){const i=k(new Date(e));return t<=i||p(t,i)}return!0}function C(t,e,i){return D(t,e)&&g(t,i)}function B(t,e,i,s){const a=new Date(e,t,1);a.setDate(a.getDate()-1);const n=new Date(e,t+1,0);return n.setDate(a.getDate()+1),!C(a,i,s)&&!C(n,i,s)}function $(t){if(null==t.match(/^\d{4}-\d{2}-\d{2}$/))return!1;var e=new Date(t);return!isNaN(e.getTime())}function x(t){var e=t.match(/\d{4}-\d{2}-\d{2}/g);return null==e?void 0:e.slice(0,2)}const S={clearButton:"Clear value",closeButton:"Close",monthSelect:"Select month",nextMonthButton:"Next month",nextYearButton:"Next year",picker:"Choose date",previousMonthButton:"Previous month",previousYearButton:"Previous year",todayButton:"Show today",yearSelect:"Select year",keyboardHint:"Keyboard commands",selected:"Selected date",chooseAsStartDate:"choose as start date",chooseAsEndDate:"choose as end date"},M=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectDate=i(this,"selectDate",3),this.changeMonth=i(this,"changeMonth",3),this.changeYear=i(this,"changeYear",3),this.requestClose=i(this,"requestClose",3),this.disabled=!1,this.modalIsOpen=!1,this.disableDate=()=>!1,this.elementClassName="tabworthy-dates-calendar",this.firstDayOfWeek=0,this.range=!1,this.labels=S,this.locale=(null===navigator||void 0===navigator?void 0:navigator.language)||"en-US",this.inline=!1,this.showClearButton=!1,this.showCloseButton=!1,this.showMonthStepper=!0,this.showTodayButton=!0,this.showYearStepper=!1,this.showKeyboardHint=!1,this.showHiddenTitle=!0,this.startDate=r(new Date),this.init=()=>{this.currentDate=this.startDate?k(new Date(this.startDate)):new Date,this.updateWeekdays()},this.nextMonth=()=>{this.updateCurrentDate(u(this.currentDate))},this.nextYear=()=>{this.updateCurrentDate(b(this.currentDate),!1,!0)},this.previousMonth=()=>{this.updateCurrentDate(v(this.currentDate))},this.previousYear=()=>{this.updateCurrentDate(y(this.currentDate),!1,!0)},this.showToday=()=>{this.updateCurrentDate(new Date,!0)},this.clear=()=>{var t;this.value=void 0,null===(t=this.selectDate)||void 0===t||t.emit(void 0)},this.onClick=t=>{if(this.disabled)return;const e=t.target.closest("[data-date]");if(!Boolean(e))return;const i=k(new Date(e.dataset.date));this.updateCurrentDate(i),this.onSelectDate(i)},this.onMonthSelect=t=>{const e=+t.target.value-1,i=new Date(this.currentDate);C(i,this.minDate,this.maxDate)&&(i.setMonth(e),this.updateCurrentDate(i))},this.onYearSelect=t=>{var e;const i=+t.target.value,s=new Date(this.currentDate);C(s,this.minDate,this.maxDate)&&(s.setFullYear(i),null===(e=this.changeYear)||void 0===e||e.emit({year:i}),this.updateCurrentDate(s))},this.onKeyDown=t=>{this.disabled||("ArrowLeft"===t.code?(t.preventDefault(),this.updateCurrentDate(f(this.currentDate),!0)):"ArrowRight"===t.code?(t.preventDefault(),this.updateCurrentDate(l(this.currentDate),!0)):"ArrowUp"===t.code?(t.preventDefault(),this.updateCurrentDate(m(this.currentDate,7),!0)):"ArrowDown"===t.code?(t.preventDefault(),this.updateCurrentDate(h(this.currentDate,7),!0)):"PageUp"===t.code?(t.preventDefault(),this.updateCurrentDate(t.shiftKey?y(this.currentDate):v(this.currentDate),!0)):"PageDown"===t.code?(t.preventDefault(),this.updateCurrentDate(t.shiftKey?b(this.currentDate):u(this.currentDate),!0)):"Home"===t.code?(t.preventDefault(),this.updateCurrentDate(o(this.currentDate),!0)):"End"===t.code?(t.preventDefault(),this.updateCurrentDate(d(this.currentDate),!0)):"Space"!==t.code&&"Enter"!==t.code||(t.preventDefault(),this.onSelectDate(this.currentDate)))},this.onMouseEnter=t=>{var e;if(this.disabled)return;const i=k(new Date(null===(e=t.target.closest("td"))||void 0===e?void 0:e.dataset.date));this.hoveredDate=i},this.onMouseLeave=()=>{this.hoveredDate=void 0},this.close=()=>{var t;null===(t=this.requestClose)||void 0===t||t.emit()}}componentWillLoad(){this.init()}watchModalIsOpen(){!0===this.modalIsOpen&&(this.moveFocusOnModalOpen=!0)}watchFirstDayOfWeek(){this.updateWeekdays()}watchLocale(){Boolean(this.locale)||(this.locale=(null===navigator||void 0===navigator?void 0:navigator.language)||"en-US"),this.updateWeekdays()}watchRange(){var t;this.value=void 0,null===(t=this.selectDate)||void 0===t||t.emit(void 0)}watchStartDate(){this.currentDate=this.startDate?k(new Date(this.startDate)):new Date}watchValue(){Boolean(this.value)&&(Array.isArray(this.value)&&this.value.length>=1?this.currentDate=this.value[0]:this.value instanceof Date&&(this.currentDate=this.value))}componentDidRender(){this.moveFocusAfterMonthChanged&&(this.focusDate(this.currentDate),this.moveFocusAfterMonthChanged=!1),this.moveFocusOnModalOpen&&setTimeout((()=>{this.focusDate(this.currentDate),this.moveFocusOnModalOpen=!1}),100)}updateWeekdays(){var t,e;this.weekdays=(t=this.firstDayOfWeek,e=this.locale,new Array(7).fill(void 0).map(((e,i)=>(t+i)%7+1)).map((t=>{const i=new Date(2006,0,t);return[Intl.DateTimeFormat(e,{weekday:"short"}).format(i),Intl.DateTimeFormat(e,{weekday:"long"}).format(i)]})))}getClassName(t){return Boolean(t)?`${this.elementClassName}__${t}`:this.elementClassName}getCalendarRows(){const t=function(t,e,i){const s=[],a=o(t),n=0===a.getDay()?7:a.getDay(),h=d(t),r=0===h.getDay()?7:h.getDay(),c=1===i?7:i-1,u=[],b=[];{let t=(7-i+n)%7,e=f(a);for(;t>0;)u.push(e),e=f(e),t-=1;u.reverse();let s=(7-r+c)%7,o=l(h);for(;s>0;)b.push(o),o=l(o),s-=1}let v=a;for(;v.getMonth()===t.getMonth();)s.push(v),v=l(v);return[...u,...s,...b]}(this.currentDate,0,0===this.firstDayOfWeek?7:this.firstDayOfWeek),e=[];for(let i=0;i<t.length;i+=7){const s=t.slice(i,i+7);e.push(s)}const i=e[e.length-1];let s=null==i?void 0:i[i.length-1];for(;e.length<6&&s;){const t=[];for(let e=0;e<7;e+=1)s=h(s,1),t.push(s);e.push(t)}return e}getTitle(){if(Boolean(this.currentDate))return Intl.DateTimeFormat(this.locale,{month:"long",year:"numeric"}).format(this.currentDate)}focusDate(t){var e;t&&(null===(e=this.el.querySelector(`[data-date="${r(t)}"]`))||void 0===e||e.focus())}updateCurrentDate(t,e,i=!1){var s,a,n;const h=t.getMonth(),o=t.getFullYear();D(t,this.minDate)||(t=new Date(this.minDate)),g(t,this.maxDate)||(t=new Date(this.maxDate)),(h!==(null===(s=this.currentDate)||void 0===s?void 0:s.getMonth())||o!==this.currentDate.getFullYear())&&(null===(a=this.changeMonth)||void 0===a||a.emit({month:c(t),year:w(t)}),e&&(this.moveFocusAfterMonthChanged=!0)),this.currentDate=t,e&&this.focusDate(this.currentDate),i&&(null===(n=this.changeYear)||void 0===n||n.emit({year:w(t)}))}onSelectDate(t){var e,i,s,a;if(!this.disableDate(t)&&C(t,this.minDate,this.maxDate))if(this.isRangeValue(this.value)){const s=void 0===(null===(e=this.value)||void 0===e?void 0:e[0])||2===this.value.length?[t]:[this.value[0],t];2===s.length&&s[0]>s[1]&&s.reverse();const a=void 0===s[1]?[r(s[0])]:[r(s[0]),r(s[1])];this.value=s,null===(i=this.selectDate)||void 0===i||i.emit(a)}else{if((null===(s=this.value)||void 0===s?void 0:s.getTime())===t.getTime())return;this.value=t,null===(a=this.selectDate)||void 0===a||a.emit(r(t))}}isRangeValue(t){return!!this.range}render(){var t;const e=this.showTodayButton||this.showClearButton||this.showCloseButton||this.showKeyboardHint,i={year:{prev:this.disabled||!!this.minDate&&new Date(this.minDate).getFullYear()>y(this.currentDate).getFullYear(),next:this.disabled||!!this.maxDate&&new Date(this.maxDate).getFullYear()<b(this.currentDate).getFullYear()},month:{prev:this.disabled||B(v(this.currentDate).getMonth(),v(this.currentDate).getFullYear(),this.minDate,this.maxDate),next:this.disabled||B(u(this.currentDate).getMonth(),u(this.currentDate).getFullYear(),this.minDate,this.maxDate)}};return s(a,{key:"1bda8d7a489d87cf27ecbcd978accf5363f32804"},s("div",{key:"7118660fbbdfac4a73a1ace99d96d4ac32a4b137",class:{[`${this.getClassName()}-wrapper`]:!0,[`${this.getClassName()}-wrapper--inline`]:this.inline}},s("div",{key:"41b62826cdff428aef8ad89844a50873f8853b5e",class:{[this.getClassName()]:!0,[`${this.getClassName()}--disabled`]:this.disabled}},s("div",{key:"7a9ee67778c6f48e65d88defc1ff620e995d75bc",class:this.getClassName("header")},this.showHiddenTitle&&s("span",{key:"404e50ab0f24235d6678af7c12f6b3cdd491e347","aria-atomic":"true","aria-live":"polite",class:"visually-hidden"},this.getTitle()),this.showYearStepper&&s("button",{key:"88552edc01ae9c4a7d8225c2aab078d2123bf9f6","aria-label":this.labels.previousYearButton,class:this.getClassName("previous-year-button"),"aria-disabled":i.year.prev,innerHTML:this.previousYearButtonContent||void 0,onClick:this.previousYear,type:"button"},s("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"},s("polyline",{key:"5b73b6ec2b5abcae4d2e5cd833b5de441938e533",points:"11 17 6 12 11 7"}),s("polyline",{key:"05e146e1c233c39403147e7af61948798db7c0f7",points:"18 17 13 12 18 7"}))),this.showMonthStepper&&s("button",{key:"6145f62f073563e9136ad454f4e9633e99b8d8a9","aria-label":this.labels.previousMonthButton,class:this.getClassName("previous-month-button"),"aria-disabled":i.month.prev,innerHTML:this.previousMonthButtonContent||void 0,onClick:this.previousMonth,type:"button"},s("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"},s("polyline",{key:"9395192e65c1e550547220850b29a117569a79e2",points:"15 18 9 12 15 6"}))),s("span",{key:"3b282148e95b8b1facde4a2ab370c6088b72bccd",class:this.getClassName("current-month")},s("select",{key:"f782b9d803abd5eb1add6c869b3ac302a717780d","aria-label":this.labels.monthSelect,class:this.getClassName("month-select"),"aria-disabled":this.disabled,name:"month",onChange:this.onMonthSelect},(n=this.locale,new Array(12).fill(void 0).map(((t,e)=>{const i=k(new Date(`2006-${String(e+1).padStart(2,"0")}-01`));return Intl.DateTimeFormat(n,{month:"long"}).format(i)}))).map(((t,e)=>s("option",{key:t,selected:this.currentDate.getMonth()===e,value:e+1,disabled:B(e,this.currentDate.getFullYear(),this.minDate,this.maxDate)},t)))),s("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&&s("button",{key:"7de261689d242a0116e85f3c5fda265f49eaaf13","aria-label":this.labels.nextMonthButton,class:this.getClassName("next-month-button"),"aria-disabled":i.month.next,innerHTML:this.nextMonthButtonContent||void 0,onClick:this.nextMonth,type:"button"},s("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"},s("polyline",{key:"dc88e8e5e4f79d5ae0b62ea51f6ba52d5e26ce9f",points:"9 18 15 12 9 6"}))),this.showYearStepper&&s("button",{key:"e25bcd81e34e0e162954b2ab67876c148f50f5d4","aria-label":this.labels.nextYearButton,class:this.getClassName("next-year-button"),"aria-disabled":i.year.next,innerHTML:this.nextYearButtonContent||void 0,onClick:this.nextYear,type:"button"},s("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"},s("polyline",{key:"f8242866ca29743b19055d1ac53fcc8e84d68a35",points:"13 17 18 12 13 7"}),s("polyline",{key:"6bda80ff2eba82dac0d36e287976130e6b16113c",points:"6 17 11 12 6 7"})))),s("div",{key:"6d5b0085437827c1db975f12dc5fe5927c7ba62f",class:this.getClassName("body")},s("table",{key:"61975eac4e06c3a416fcb9503eef9c7a386a6b54",class:this.getClassName("calendar"),onKeyDown:this.onKeyDown,role:"grid","aria-label":this.getTitle()},s("thead",{key:"fd259bd5ba6e12ff39dad5a31133913d17fdf276",class:this.getClassName("calendar-header")},s("tr",{key:"410c84eabac58cf6139dd6c886b4803772abceb5",class:this.getClassName("weekday-row")},null===(t=this.weekdays)||void 0===t?void 0:t.map((t=>s("th",{role:"columnheader",abbr:t[1],class:this.getClassName("weekday"),key:t[0],scope:"col"},s("span",{"aria-hidden":"true"},t[0]),s("span",{class:"visually-hidden"},t[1])))))),s("tbody",{key:"330d3b922d474b42edf0764556d2f2643b5b639d"},this.getCalendarRows().map((t=>{const e=`row-${t[0].getMonth()}-${t[0].getDate()}`;return s("tr",{class:this.getClassName("calendar-row"),key:e},t.map((t=>{var e,i,a;const n=p(t,this.currentDate),h=t.getMonth()!==(null===(e=this.currentDate)||void 0===e?void 0:e.getMonth()),o=Array.isArray(this.value)?p(t,this.value[0])||this.value[1]&&C(t,r(this.value[0]),r(this.value[1])):p(t,this.value),d=this.disableDate(t)||!C(t,this.minDate,this.maxDate),c=!!this.isRangeValue(this.value)&&(u={from:null===(i=this.value)||void 0===i?void 0:i[0],to:(null===(a=this.value)||void 0===a?void 0:a[1])||this.hoveredDate||this.currentDate},!!((l=t)&&u&&u.from&&u.to)&&l>=(u.from<u.to?u.from:u.to)&&l<=(u.from<u.to?u.to:u.from)&&!d);var l,u;const b=p(t,new Date),f=`cell-${t.getMonth()}-${t.getDate()}`,v={[this.getClassName("date")]:!0,[this.getClassName("date--current")]:n,[this.getClassName("date--disabled")]:d,[this.getClassName("date--overflowing")]:h,[this.getClassName("date--today")]:b,[this.getClassName("date--selected")]:o,[this.getClassName("date--in-range")]:c},y=o?"strong":b?"em":"span";return s("td",{"aria-disabled":String(d),"aria-selected":o?"true":void 0,class:v,"data-date":r(t),key:f,onClick:this.onClick,onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,role:"gridcell",tabIndex:p(t,this.currentDate)&&!this.disabled?0:-1},s(y,{"aria-hidden":"true"},t.getDate()),s("span",{class:"visually-hidden"},(()=>{if(this.range){let e=this.value?"":`, ${this.labels.chooseAsStartDate}.`;return Array.isArray(this.value)&&(e={1:`, ${this.labels.chooseAsEndDate}.`,2:`, ${this.labels.chooseAsStartDate}.`}[this.value.length]),`${o?`${this.labels.selected}, `:""}${Intl.DateTimeFormat(this.locale,{day:"numeric",month:"long",year:"numeric"}).format(t)}${e}`}return`${o?`${this.labels.selected}, `:""}${Intl.DateTimeFormat(this.locale,{day:"numeric",month:"long",year:"numeric"}).format(t)}`})()))})))}))))),e&&s("div",{key:"88362c2e1731e8813ad9c5da3b34f6afe16f2036",class:this.getClassName("footer")},s("div",{key:"e93a0b8fff1be09855ab87db159cb186b9339a39",class:this.getClassName("footer-buttons")},this.showTodayButton&&s("button",{key:"a5b88ad46182dc5367987bd78cb02e98cd63aaef",class:this.getClassName("today-button"),disabled:this.disabled,innerHTML:this.todayButtonContent||void 0,onClick:this.showToday,type:"button"},this.labels.todayButton),this.showClearButton&&s("button",{key:"3929f2d213399b656057010ccdbead8020b04c2d",class:this.getClassName("clear-button"),disabled:this.disabled,innerHTML:this.clearButtonContent||void 0,onClick:this.clear,type:"button"},this.labels.clearButton),this.showCloseButton&&s("button",{key:"800308eb41769813d9191bec7537385255039a80",class:this.getClassName("close-button"),disabled:this.disabled,innerHTML:this.closeButtonContent||void 0,onClick:this.close,type:"button"},this.labels.closeButton)),this.showKeyboardHint&&!window.matchMedia("(pointer: coarse)").matches&&s("button",{key:"0b478f25499d1aec350b35bb9777c6ec03d7fea3",type:"button",onClick:()=>alert("Todo: Add Keyboard helper!"),class:this.getClassName("keyboard-hint")},s("svg",{key:"14840cb62c1a222a347e40f6d1ab043842377a49",xmlns:"http://www.w3.org/2000/svg",height:"1em",width:"1em",viewBox:"0 0 48 48",fill:"currentColor"},s("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))),s("slot",{key:"4616ab014b3db34b2d42958aefdbc7795829bbba",name:"after-calendar"})));var n}get el(){return this}static get watchers(){return{modalIsOpen:[{watchModalIsOpen:0}],firstDayOfWeek:[{watchFirstDayOfWeek:0}],locale:[{watchLocale:0}],range:[{watchRange:0}],startDate:[{watchStartDate:0}],value:[{watchValue:0}]}}static get style(){return".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%)}"}},[262,"tabworthy-dates-calendar",{clearButtonContent:[1,"clear-button-content"],closeButtonContent:[1,"close-button-content"],disabled:[4],modalIsOpen:[4,"modal-is-open"],disableDate:[16],elementClassName:[1,"element-class-name"],firstDayOfWeek:[2,"first-day-of-week"],range:[4],labels:[16],locale:[1],nextMonthButtonContent:[1,"next-month-button-content"],nextYearButtonContent:[1,"next-year-button-content"],previousMonthButtonContent:[1,"previous-month-button-content"],previousYearButtonContent:[1,"previous-year-button-content"],minDate:[1,"min-date"],maxDate:[1,"max-date"],inline:[4],showClearButton:[4,"show-clear-button"],showCloseButton:[4,"show-close-button"],showMonthStepper:[4,"show-month-stepper"],showTodayButton:[4,"show-today-button"],showYearStepper:[4,"show-year-stepper"],showKeyboardHint:[4,"show-keyboard-hint"],showHiddenTitle:[4,"show-hidden-title"],startDate:[1,"start-date"],todayButtonContent:[1,"today-button-content"],value:[1040],currentDate:[32],hoveredDate:[32],weekdays:[32]},void 0,{modalIsOpen:[{watchModalIsOpen:0}],firstDayOfWeek:[{watchFirstDayOfWeek:0}],locale:[{watchLocale:0}],range:[{watchRange:0}],startDate:[{watchStartDate:0}],value:[{watchValue:0}]}]);function Z(){"undefined"!=typeof customElements&&["tabworthy-dates-calendar"].forEach((t=>{"tabworthy-dates-calendar"===t&&(customElements.get(n(t))||customElements.define(n(t),M))}))}export{M as T,D as a,g as b,Z as c,C as d,x as e,r as g,$ as i,k as r}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as o,c as s}from"./p-
|
|
1
|
+
import{T as o,c as s}from"./p-CkD8Cvl_.js";const p=o,r=s;export{p as TabworthyDatesCalendar,r as defineCustomElement}
|