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