@tabworthy/components 0.13.0 → 0.13.1
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.cjs.entry.js +10 -0
- package/dist/cjs/tabworthy-times.cjs.entry.js +45 -7
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +10 -0
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +45 -7
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/tabworthy-dates.entry.js +10 -0
- package/dist/esm/tabworthy-times.entry.js +45 -7
- package/dist/tabworthy-components/{p-71f5c261.entry.js → p-4eedf24e.entry.js} +1 -1
- package/dist/tabworthy-components/p-b6a5d970.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-times/tabworthy-times.d.ts +5 -0
- package/package.json +1 -1
- package/dist/tabworthy-components/p-ed3c60d6.entry.js +0 -1
|
@@ -10666,6 +10666,16 @@ const TabworthyDates = class {
|
|
|
10666
10666
|
this.value = this.internalValue;
|
|
10667
10667
|
return this.selectDate.emit(this.internalValue);
|
|
10668
10668
|
}
|
|
10669
|
+
// Try strict format parsing first to avoid DD/MM vs MM/DD ambiguity
|
|
10670
|
+
const strictParsed = customParseFormat.dayjs(value, this.format, true);
|
|
10671
|
+
if (strictParsed.isValid()) {
|
|
10672
|
+
const date = strictParsed.toDate();
|
|
10673
|
+
if (!this.isPickedDateValid(date))
|
|
10674
|
+
return;
|
|
10675
|
+
this.updateValue(date);
|
|
10676
|
+
this.formatInput(true, false);
|
|
10677
|
+
return;
|
|
10678
|
+
}
|
|
10669
10679
|
const parsedDate = await chronoParseDate(value, {
|
|
10670
10680
|
locale: this.locale.slice(0, 2),
|
|
10671
10681
|
minDate: this.minDate,
|
|
@@ -116,9 +116,12 @@ const TabworthyTimes = class {
|
|
|
116
116
|
const date = utils.removeTimezoneOffset(new Date(dates[0]));
|
|
117
117
|
if (!this.isDateValid(date))
|
|
118
118
|
return;
|
|
119
|
+
// Clamp time to boundary constraints when selecting a boundary day
|
|
120
|
+
this.clampTimeToBounds(date);
|
|
119
121
|
this.updateValue(date);
|
|
120
|
-
//
|
|
122
|
+
// Reset then set calendar value so re-clicking the same date still emits
|
|
121
123
|
if (this.pickerRef) {
|
|
124
|
+
this.pickerRef.value = undefined;
|
|
122
125
|
this.pickerRef.value = date;
|
|
123
126
|
}
|
|
124
127
|
}
|
|
@@ -261,6 +264,41 @@ const TabworthyTimes = class {
|
|
|
261
264
|
return true;
|
|
262
265
|
return false;
|
|
263
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* When selecting a date on a boundary day, adjust the time to the first
|
|
269
|
+
* available time if the current selection falls outside the allowed range.
|
|
270
|
+
*/
|
|
271
|
+
clampTimeToBounds(date) {
|
|
272
|
+
const sel = customParseFormat.dayjs(date);
|
|
273
|
+
if (this.minDate) {
|
|
274
|
+
const min = customParseFormat.dayjs(this.minDate);
|
|
275
|
+
if (min.isValid() && sel.isSame(min, "day")) {
|
|
276
|
+
const curTotal = this.selectedHours * 3600 +
|
|
277
|
+
this.selectedMinutes * 60 +
|
|
278
|
+
this.selectedSeconds;
|
|
279
|
+
const minTotal = min.hour() * 3600 + min.minute() * 60 + min.second();
|
|
280
|
+
if (curTotal < minTotal) {
|
|
281
|
+
this.selectedHours = min.hour();
|
|
282
|
+
this.selectedMinutes = min.minute();
|
|
283
|
+
this.selectedSeconds = min.second();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (this.maxDate) {
|
|
288
|
+
const max = customParseFormat.dayjs(this.maxDate);
|
|
289
|
+
if (max.isValid() && sel.isSame(max, "day")) {
|
|
290
|
+
const curTotal = this.selectedHours * 3600 +
|
|
291
|
+
this.selectedMinutes * 60 +
|
|
292
|
+
this.selectedSeconds;
|
|
293
|
+
const maxTotal = max.hour() * 3600 + max.minute() * 60 + max.second();
|
|
294
|
+
if (curTotal > maxTotal) {
|
|
295
|
+
this.selectedHours = max.hour();
|
|
296
|
+
this.selectedMinutes = max.minute();
|
|
297
|
+
this.selectedSeconds = max.second();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
264
302
|
shouldInputFormat() {
|
|
265
303
|
if (typeof this.inputShouldFormat === "string") {
|
|
266
304
|
return this.inputShouldFormat === "true";
|
|
@@ -337,13 +375,13 @@ const TabworthyTimes = class {
|
|
|
337
375
|
const parsed = customParseFormat.dayjs(date);
|
|
338
376
|
if (!parsed.isValid())
|
|
339
377
|
return false;
|
|
340
|
-
if (this.minDate && parsed.isBefore(customParseFormat.dayjs(this.minDate))) {
|
|
378
|
+
if (this.minDate && parsed.isBefore(customParseFormat.dayjs(this.minDate), "day")) {
|
|
341
379
|
this.errorState = true;
|
|
342
380
|
this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
|
|
343
381
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
344
382
|
return false;
|
|
345
383
|
}
|
|
346
|
-
if (this.maxDate && parsed.isAfter(customParseFormat.dayjs(this.maxDate))) {
|
|
384
|
+
if (this.maxDate && parsed.isAfter(customParseFormat.dayjs(this.maxDate), "day")) {
|
|
347
385
|
this.errorState = true;
|
|
348
386
|
this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
|
|
349
387
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
@@ -397,12 +435,12 @@ const TabworthyTimes = class {
|
|
|
397
435
|
}
|
|
398
436
|
render() {
|
|
399
437
|
var _a;
|
|
400
|
-
return (index.h(index.Host, { key: '
|
|
438
|
+
return (index.h(index.Host, { key: '6c3049b02eda2e976f14616027cfb3fd1a0b0100', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: 'eb9ecc8c81d04338a5935ad414c6cd544a01bb58', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: '8906972aec0b8c7b24cc3f2d07212c3f6c2d8f56', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: 'bca908ac7aa2710569fa86be5c7c6643d7f73574', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
401
439
|
[this.getClassName("input")]: true,
|
|
402
440
|
[this.inputClass]: !!this.inputClass
|
|
403
|
-
}, 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 && (index.h("button", { key: '
|
|
441
|
+
}, 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 && (index.h("button", { key: 'c0d27ab5207fb62606e017bea14c93bc44daebb9', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
404
442
|
? this.timesLabels.openCalendar
|
|
405
|
-
: undefined }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: '
|
|
443
|
+
: undefined }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: '1e6761504cd55a9fd380902861aeec0e7e655d47', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
406
444
|
if (this.pickerRef) {
|
|
407
445
|
this.pickerRef.modalIsOpen = true;
|
|
408
446
|
}
|
|
@@ -410,7 +448,7 @@ const TabworthyTimes = class {
|
|
|
410
448
|
if (this.pickerRef) {
|
|
411
449
|
this.pickerRef.modalIsOpen = false;
|
|
412
450
|
}
|
|
413
|
-
}, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '
|
|
451
|
+
}, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '14966bd22b73a14fcb54bf118543e6aedf6e291f', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: 'aef55f7ee2cb19eb68bf8db51dd3e111e4f0dbff', 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 }, index.h("div", { key: 'f89b6d83e9ef68bd98eb6e08ea3aec00c2b6dd86', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '2ae84e5817c25641ab56ff096f164355524abfdf', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '55bfe07297efd0c60d47d6049572f502311abf15', 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 && (index.h("div", { key: '97dbda7bc8725c8964a627e37e9236e9bf699ee0', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
414
452
|
}
|
|
415
453
|
get el() { return index.getElement(this); }
|
|
416
454
|
static get watchers() { return {
|
|
@@ -197,6 +197,16 @@ export class TabworthyDates {
|
|
|
197
197
|
this.value = this.internalValue;
|
|
198
198
|
return this.selectDate.emit(this.internalValue);
|
|
199
199
|
}
|
|
200
|
+
// Try strict format parsing first to avoid DD/MM vs MM/DD ambiguity
|
|
201
|
+
const strictParsed = dayjs(value, this.format, true);
|
|
202
|
+
if (strictParsed.isValid()) {
|
|
203
|
+
const date = strictParsed.toDate();
|
|
204
|
+
if (!this.isPickedDateValid(date))
|
|
205
|
+
return;
|
|
206
|
+
this.updateValue(date);
|
|
207
|
+
this.formatInput(true, false);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
200
210
|
const parsedDate = await chronoParseDate(value, {
|
|
201
211
|
locale: this.locale.slice(0, 2),
|
|
202
212
|
minDate: this.minDate,
|
|
@@ -92,9 +92,12 @@ export class TabworthyTimes {
|
|
|
92
92
|
const date = removeTimezoneOffset(new Date(dates[0]));
|
|
93
93
|
if (!this.isDateValid(date))
|
|
94
94
|
return;
|
|
95
|
+
// Clamp time to boundary constraints when selecting a boundary day
|
|
96
|
+
this.clampTimeToBounds(date);
|
|
95
97
|
this.updateValue(date);
|
|
96
|
-
//
|
|
98
|
+
// Reset then set calendar value so re-clicking the same date still emits
|
|
97
99
|
if (this.pickerRef) {
|
|
100
|
+
this.pickerRef.value = undefined;
|
|
98
101
|
this.pickerRef.value = date;
|
|
99
102
|
}
|
|
100
103
|
}
|
|
@@ -237,6 +240,41 @@ export class TabworthyTimes {
|
|
|
237
240
|
return true;
|
|
238
241
|
return false;
|
|
239
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* When selecting a date on a boundary day, adjust the time to the first
|
|
245
|
+
* available time if the current selection falls outside the allowed range.
|
|
246
|
+
*/
|
|
247
|
+
clampTimeToBounds(date) {
|
|
248
|
+
const sel = dayjs(date);
|
|
249
|
+
if (this.minDate) {
|
|
250
|
+
const min = dayjs(this.minDate);
|
|
251
|
+
if (min.isValid() && sel.isSame(min, "day")) {
|
|
252
|
+
const curTotal = this.selectedHours * 3600 +
|
|
253
|
+
this.selectedMinutes * 60 +
|
|
254
|
+
this.selectedSeconds;
|
|
255
|
+
const minTotal = min.hour() * 3600 + min.minute() * 60 + min.second();
|
|
256
|
+
if (curTotal < minTotal) {
|
|
257
|
+
this.selectedHours = min.hour();
|
|
258
|
+
this.selectedMinutes = min.minute();
|
|
259
|
+
this.selectedSeconds = min.second();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (this.maxDate) {
|
|
264
|
+
const max = dayjs(this.maxDate);
|
|
265
|
+
if (max.isValid() && sel.isSame(max, "day")) {
|
|
266
|
+
const curTotal = this.selectedHours * 3600 +
|
|
267
|
+
this.selectedMinutes * 60 +
|
|
268
|
+
this.selectedSeconds;
|
|
269
|
+
const maxTotal = max.hour() * 3600 + max.minute() * 60 + max.second();
|
|
270
|
+
if (curTotal > maxTotal) {
|
|
271
|
+
this.selectedHours = max.hour();
|
|
272
|
+
this.selectedMinutes = max.minute();
|
|
273
|
+
this.selectedSeconds = max.second();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
240
278
|
shouldInputFormat() {
|
|
241
279
|
if (typeof this.inputShouldFormat === "string") {
|
|
242
280
|
return this.inputShouldFormat === "true";
|
|
@@ -313,13 +351,13 @@ export class TabworthyTimes {
|
|
|
313
351
|
const parsed = dayjs(date);
|
|
314
352
|
if (!parsed.isValid())
|
|
315
353
|
return false;
|
|
316
|
-
if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
|
|
354
|
+
if (this.minDate && parsed.isBefore(dayjs(this.minDate), "day")) {
|
|
317
355
|
this.errorState = true;
|
|
318
356
|
this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
|
|
319
357
|
this.emitErrorChange("minDate", this.errorMessage);
|
|
320
358
|
return false;
|
|
321
359
|
}
|
|
322
|
-
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
|
|
360
|
+
if (this.maxDate && parsed.isAfter(dayjs(this.maxDate), "day")) {
|
|
323
361
|
this.errorState = true;
|
|
324
362
|
this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
|
|
325
363
|
this.emitErrorChange("maxDate", this.errorMessage);
|
|
@@ -373,12 +411,12 @@ export class TabworthyTimes {
|
|
|
373
411
|
}
|
|
374
412
|
render() {
|
|
375
413
|
var _a;
|
|
376
|
-
return (h(Host, { key: '
|
|
414
|
+
return (h(Host, { key: '6c3049b02eda2e976f14616027cfb3fd1a0b0100', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'eb9ecc8c81d04338a5935ad414c6cd544a01bb58', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '8906972aec0b8c7b24cc3f2d07212c3f6c2d8f56', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'bca908ac7aa2710569fa86be5c7c6643d7f73574', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
377
415
|
[this.getClassName("input")]: true,
|
|
378
416
|
[this.inputClass]: !!this.inputClass
|
|
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: '
|
|
417
|
+
}, 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: 'c0d27ab5207fb62606e017bea14c93bc44daebb9', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
|
|
380
418
|
? this.timesLabels.openCalendar
|
|
381
|
-
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '
|
|
419
|
+
: undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '1e6761504cd55a9fd380902861aeec0e7e655d47', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
382
420
|
if (this.pickerRef) {
|
|
383
421
|
this.pickerRef.modalIsOpen = true;
|
|
384
422
|
}
|
|
@@ -386,7 +424,7 @@ export class TabworthyTimes {
|
|
|
386
424
|
if (this.pickerRef) {
|
|
387
425
|
this.pickerRef.modalIsOpen = false;
|
|
388
426
|
}
|
|
389
|
-
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '
|
|
427
|
+
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '14966bd22b73a14fcb54bf118543e6aedf6e291f', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'aef55f7ee2cb19eb68bf8db51dd3e111e4f0dbff', 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: 'f89b6d83e9ef68bd98eb6e08ea3aec00c2b6dd86', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '2ae84e5817c25641ab56ff096f164355524abfdf', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '55bfe07297efd0c60d47d6049572f502311abf15', 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: '97dbda7bc8725c8964a627e37e9236e9bf699ee0', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
390
428
|
}
|
|
391
429
|
static get is() { return "tabworthy-times"; }
|
|
392
430
|
static get encapsulation() { return "scoped"; }
|