@vaadin/date-picker 25.3.0-dev.3a3c2d7d2a → 25.3.0-rc1
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/custom-elements.json +556 -205
- package/package.json +13 -13
- package/src/styles/vaadin-date-picker-overlay-content-base-styles.js +0 -3
- package/src/styles/vaadin-month-calendar-base-styles.js +3 -0
- package/src/vaadin-date-metadata-controller.d.ts +94 -0
- package/src/vaadin-date-metadata-controller.js +268 -0
- package/src/vaadin-date-picker-helper.d.ts +144 -13
- package/src/vaadin-date-picker-helper.js +119 -15
- package/src/vaadin-date-picker-mixin.d.ts +87 -15
- package/src/vaadin-date-picker-mixin.js +129 -121
- package/src/vaadin-date-picker-overlay-content-mixin.js +144 -163
- package/src/vaadin-date-picker-overlay-content.js +1 -0
- package/src/vaadin-date-picker-overlay.js +1 -0
- package/src/vaadin-date-picker-year.js +4 -1
- package/src/vaadin-date-picker.d.ts +73 -7
- package/src/vaadin-date-picker.js +67 -9
- package/src/vaadin-infinite-scroller.js +21 -6
- package/src/vaadin-month-calendar-mixin.js +43 -59
- package/src/vaadin-month-calendar.js +5 -0
- package/web-types.json +37 -21
- package/web-types.lit.json +18 -11
- package/src/vaadin-disabled-dates-controller.d.ts +0 -66
- package/src/vaadin-disabled-dates-controller.js +0 -241
|
@@ -5,10 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
|
+
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
8
9
|
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
9
10
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
10
11
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createDate,
|
|
14
|
+
dateAfterXMonths,
|
|
15
|
+
dateAllowed,
|
|
16
|
+
dateEquals,
|
|
17
|
+
dateSelectable,
|
|
18
|
+
firstOfMonth,
|
|
19
|
+
getClosestDate,
|
|
20
|
+
lastOfMonth,
|
|
21
|
+
monthDate,
|
|
22
|
+
monthIndex,
|
|
23
|
+
} from './vaadin-date-picker-helper.js';
|
|
12
24
|
|
|
13
25
|
export const DatePickerOverlayContentMixin = (superClass) =>
|
|
14
26
|
class DatePickerOverlayContentMixin extends superClass {
|
|
@@ -106,19 +118,10 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
106
118
|
type: Function,
|
|
107
119
|
},
|
|
108
120
|
|
|
109
|
-
/**
|
|
110
|
-
* A batch function that is consulted for a range of dates the calendar is about to render
|
|
111
|
-
* and returns, or resolves with, an array of `DatePickerDate` objects to disable.
|
|
112
|
-
*
|
|
113
|
-
* @type {function(DatePickerDateRange): Array<DatePickerDate> | Promise<Array<DatePickerDate>> | undefined}
|
|
114
|
-
*/
|
|
115
|
-
disabledDatesProvider: {
|
|
116
|
-
type: Function,
|
|
117
|
-
},
|
|
118
|
-
|
|
119
121
|
/**
|
|
120
122
|
* Reflected while data is being loaded, so the overlay can show a loading spinner.
|
|
121
|
-
* Currently set while the
|
|
123
|
+
* Currently set while the date metadata provider is resolving.
|
|
124
|
+
* @protected
|
|
122
125
|
*/
|
|
123
126
|
loading: {
|
|
124
127
|
type: Boolean,
|
|
@@ -126,17 +129,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
126
129
|
reflectToAttribute: true,
|
|
127
130
|
},
|
|
128
131
|
|
|
129
|
-
/**
|
|
130
|
-
* Bumped whenever the disabled dates controller's cache or loading state changes, to
|
|
131
|
-
* re-run `__updateCalendars` and push the new state to the rendered months.
|
|
132
|
-
* @private
|
|
133
|
-
*/
|
|
134
|
-
_disabledDatesVersion: {
|
|
135
|
-
type: Number,
|
|
136
|
-
value: 0,
|
|
137
|
-
attribute: false,
|
|
138
|
-
},
|
|
139
|
-
|
|
140
132
|
enteredDate: {
|
|
141
133
|
type: Date,
|
|
142
134
|
sync: true,
|
|
@@ -155,6 +147,18 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
155
147
|
type: Object,
|
|
156
148
|
},
|
|
157
149
|
|
|
150
|
+
/**
|
|
151
|
+
* The date-picker's date metadata controller, assigned by the host. Declared as a property,
|
|
152
|
+
* and a dependency of `__updateCalendarsConfig` below, so that the calendars are handed it
|
|
153
|
+
* and subscribed whenever it arrives, rather than relying on the host assigning it before
|
|
154
|
+
* the properties that happen to trigger that observer.
|
|
155
|
+
* @protected
|
|
156
|
+
*/
|
|
157
|
+
_dateMetadataController: {
|
|
158
|
+
type: Object,
|
|
159
|
+
sync: true,
|
|
160
|
+
},
|
|
161
|
+
|
|
158
162
|
calendars: {
|
|
159
163
|
type: Array,
|
|
160
164
|
value: () => [],
|
|
@@ -169,14 +173,47 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
169
173
|
|
|
170
174
|
static get observers() {
|
|
171
175
|
return [
|
|
172
|
-
'
|
|
173
|
-
'
|
|
176
|
+
'__updateCalendarsConfig(calendars, i18n, minDate, maxDate, showWeekNumbers, isDateDisabled, _theme, _dateMetadataController)',
|
|
177
|
+
'__updateCalendarsState(calendars, selectedDate, focusedDate, enteredDate, _ignoreTaps)',
|
|
174
178
|
'__updateCancelButton(_cancelButton, i18n)',
|
|
175
|
-
'__updateTodayButton(_todayButton, i18n, minDate, maxDate, isDateDisabled, _disabledDatesVersion)',
|
|
176
179
|
'__updateYears(years, selectedDate, _theme)',
|
|
177
180
|
];
|
|
178
181
|
}
|
|
179
182
|
|
|
183
|
+
/** @protected */
|
|
184
|
+
disconnectedCallback() {
|
|
185
|
+
super.disconnectedCallback();
|
|
186
|
+
|
|
187
|
+
this.cancelLoadVisibleDateMetadata();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** @protected */
|
|
191
|
+
updated(props) {
|
|
192
|
+
super.updated(props);
|
|
193
|
+
|
|
194
|
+
if (props.has('loading')) {
|
|
195
|
+
setOrRemoveAttribute(this, 'aria-busy', this.loading);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (props.has('i18n')) {
|
|
199
|
+
setOrRemoveAttribute(this, 'aria-label', this.i18n?.dialogAccessibleName);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (props.has('calendars') || props.has('_dateMetadataController')) {
|
|
203
|
+
this.loadVisibleDateMetadata();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (
|
|
207
|
+
props.has('_todayButton') ||
|
|
208
|
+
props.has('i18n') ||
|
|
209
|
+
props.has('minDate') ||
|
|
210
|
+
props.has('maxDate') ||
|
|
211
|
+
props.has('isDateDisabled')
|
|
212
|
+
) {
|
|
213
|
+
this.updateTodayButton();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
180
217
|
/**
|
|
181
218
|
* Whether to scroll to a sub-month position when scrolling to a date.
|
|
182
219
|
* This is active if the month scroller is not large enough to fit a
|
|
@@ -231,6 +268,8 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
231
268
|
|
|
232
269
|
reset() {
|
|
233
270
|
this._closeYearScroller();
|
|
271
|
+
this._monthScroller?.reset();
|
|
272
|
+
this._yearScroller?.reset();
|
|
234
273
|
}
|
|
235
274
|
|
|
236
275
|
/**
|
|
@@ -323,39 +362,60 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
323
362
|
}
|
|
324
363
|
}
|
|
325
364
|
|
|
326
|
-
/**
|
|
327
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Applies the today button's label and whether today can be selected.
|
|
367
|
+
*/
|
|
368
|
+
updateTodayButton() {
|
|
369
|
+
const todayButton = this._todayButton;
|
|
328
370
|
if (todayButton) {
|
|
329
|
-
todayButton.textContent = i18n?.today;
|
|
330
|
-
todayButton.disabled = !this._isTodayAllowed(
|
|
371
|
+
todayButton.textContent = this.i18n?.today;
|
|
372
|
+
todayButton.disabled = !this._isTodayAllowed();
|
|
331
373
|
}
|
|
332
374
|
}
|
|
333
375
|
|
|
334
|
-
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Requests the date metadata for the months currently rendered. Months already loaded or in flight
|
|
378
|
+
* are skipped.
|
|
379
|
+
*/
|
|
380
|
+
loadVisibleDateMetadata() {
|
|
381
|
+
const controller = this._dateMetadataController;
|
|
382
|
+
if (!controller) {
|
|
383
|
+
return;
|
|
342
384
|
}
|
|
385
|
+
// Reduced to month indexes so the outermost months can be picked with plain arithmetic.
|
|
386
|
+
const indexes = (this.calendars ?? [])
|
|
387
|
+
.map((calendar) => calendar.month)
|
|
388
|
+
.filter(Boolean)
|
|
389
|
+
.map((month) => monthIndex(month));
|
|
390
|
+
if (indexes.length === 0) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
controller.ensureRangeLoaded(monthDate(Math.min(...indexes)), monthDate(Math.max(...indexes)));
|
|
343
394
|
}
|
|
344
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Drops a date metadata load that navigating has scheduled but that has not run yet.
|
|
398
|
+
*/
|
|
399
|
+
cancelLoadVisibleDateMetadata() {
|
|
400
|
+
this._loadDateMetadataDebouncer?.cancel();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Config that changes rarely (locale, allowed range, week numbers, theme).
|
|
405
|
+
* Split from the interaction state below so a keyboard/selection update
|
|
406
|
+
* does not re-assign every config property on every calendar.
|
|
407
|
+
* @private
|
|
408
|
+
*/
|
|
345
409
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
346
|
-
|
|
410
|
+
__updateCalendarsConfig(
|
|
347
411
|
calendars,
|
|
348
412
|
i18n,
|
|
349
413
|
minDate,
|
|
350
414
|
maxDate,
|
|
351
|
-
selectedDate,
|
|
352
|
-
focusedDate,
|
|
353
415
|
showWeekNumbers,
|
|
354
|
-
ignoreTaps,
|
|
355
|
-
theme,
|
|
356
416
|
isDateDisabled,
|
|
357
|
-
|
|
358
|
-
|
|
417
|
+
theme,
|
|
418
|
+
dateMetadataController,
|
|
359
419
|
) {
|
|
360
420
|
if (calendars?.length) {
|
|
361
421
|
calendars.forEach((calendar) => {
|
|
@@ -363,60 +423,40 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
363
423
|
calendar.minDate = minDate;
|
|
364
424
|
calendar.maxDate = maxDate;
|
|
365
425
|
calendar.isDateDisabled = isDateDisabled;
|
|
366
|
-
calendar.
|
|
367
|
-
|
|
368
|
-
calendar
|
|
369
|
-
calendar.selectedDate = selectedDate;
|
|
426
|
+
calendar._dateMetadataController = dateMetadataController;
|
|
427
|
+
// Subscribe to controller updates (subscribing again is a no-op).
|
|
428
|
+
dateMetadataController?.subscribe(calendar);
|
|
370
429
|
calendar.showWeekNumbers = showWeekNumbers;
|
|
371
|
-
calendar.ignoreTaps = ignoreTaps;
|
|
372
|
-
calendar.enteredDate = enteredDate;
|
|
373
430
|
|
|
374
|
-
|
|
375
|
-
calendar.setAttribute('theme', theme);
|
|
376
|
-
} else {
|
|
377
|
-
calendar.removeAttribute('theme');
|
|
378
|
-
}
|
|
431
|
+
setOrRemoveAttribute(calendar, 'theme', theme);
|
|
379
432
|
});
|
|
380
|
-
|
|
381
|
-
this.__ensureVisibleDisabledDatesLoaded();
|
|
382
433
|
}
|
|
383
434
|
}
|
|
384
435
|
|
|
385
436
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* already loaded or in flight, so one request covers the whole visible range.
|
|
437
|
+
* Debounced variant used while navigating, so a continuous scroll triggers one load once it
|
|
438
|
+
* settles instead of a request per intermediate position.
|
|
389
439
|
* @private
|
|
390
440
|
*/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
const indexes = this.calendars
|
|
397
|
-
.map((calendar) => calendar.month)
|
|
398
|
-
.filter(Boolean)
|
|
399
|
-
.map((month) => month.getFullYear() * 12 + month.getMonth());
|
|
400
|
-
if (indexes.length === 0) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
const min = Math.min(...indexes);
|
|
404
|
-
const max = Math.max(...indexes);
|
|
405
|
-
controller.ensureRangeLoaded(
|
|
406
|
-
new Date(Math.floor(min / 12), min % 12, 1),
|
|
407
|
-
new Date(Math.floor(max / 12), max % 12, 1),
|
|
441
|
+
__scheduleLoadVisibleDateMetadata() {
|
|
442
|
+
this._loadDateMetadataDebouncer = Debouncer.debounce(this._loadDateMetadataDebouncer, timeOut.after(200), () =>
|
|
443
|
+
this.loadVisibleDateMetadata(),
|
|
408
444
|
);
|
|
409
445
|
}
|
|
410
446
|
|
|
411
447
|
/**
|
|
412
|
-
*
|
|
413
|
-
* settles instead of a request per intermediate position.
|
|
448
|
+
* Interaction state that changes often (focus, selection, entered date, taps).
|
|
414
449
|
* @private
|
|
415
450
|
*/
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
451
|
+
__updateCalendarsState(calendars, selectedDate, focusedDate, enteredDate, ignoreTaps) {
|
|
452
|
+
if (calendars?.length) {
|
|
453
|
+
calendars.forEach((calendar) => {
|
|
454
|
+
calendar.focusedDate = focusedDate;
|
|
455
|
+
calendar.selectedDate = selectedDate;
|
|
456
|
+
calendar.enteredDate = enteredDate;
|
|
457
|
+
calendar.ignoreTaps = ignoreTaps;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
420
460
|
}
|
|
421
461
|
|
|
422
462
|
/** @private */
|
|
@@ -425,11 +465,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
425
465
|
years.forEach((year) => {
|
|
426
466
|
year.selectedDate = selectedDate;
|
|
427
467
|
|
|
428
|
-
|
|
429
|
-
year.setAttribute('theme', theme);
|
|
430
|
-
} else {
|
|
431
|
-
year.removeAttribute('theme');
|
|
432
|
-
}
|
|
468
|
+
setOrRemoveAttribute(year, 'theme', theme);
|
|
433
469
|
});
|
|
434
470
|
}
|
|
435
471
|
}
|
|
@@ -439,12 +475,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
439
475
|
* @protected
|
|
440
476
|
*/
|
|
441
477
|
_selectDate(dateToSelect) {
|
|
442
|
-
if (!this.
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
// Block dates disabled by the provider, or in a month whose provider result has not loaded
|
|
446
|
-
// yet, so they cannot be selected via keyboard or the today button either.
|
|
447
|
-
if (this._disabledDatesController?.isDateBlocked(dateToSelect)) {
|
|
478
|
+
if (!this._dateSelectable(dateToSelect)) {
|
|
448
479
|
return false;
|
|
449
480
|
}
|
|
450
481
|
this.selectedDate = dateToSelect;
|
|
@@ -510,11 +541,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
510
541
|
* @private
|
|
511
542
|
*/
|
|
512
543
|
_calculateWeekScrollOffset(date) {
|
|
513
|
-
|
|
514
|
-
const temp = new Date(0, 0);
|
|
515
|
-
temp.setFullYear(date.getFullYear());
|
|
516
|
-
temp.setMonth(date.getMonth());
|
|
517
|
-
temp.setDate(1);
|
|
544
|
+
const temp = firstOfMonth(date);
|
|
518
545
|
// Determine week (=row index) of date within the month
|
|
519
546
|
let week = 0;
|
|
520
547
|
while (temp.getDate() < date.getDate()) {
|
|
@@ -542,17 +569,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
542
569
|
const monthPosition = this._monthScroller.position;
|
|
543
570
|
this._visibleMonthIndex = Math.floor(monthPosition);
|
|
544
571
|
this._yearScroller.position = (monthPosition + this._originDate.getMonth()) / 12;
|
|
545
|
-
|
|
546
|
-
// single place to keep the disabled dates loaded for the newly visible months. Debounced
|
|
547
|
-
// so a continuous scroll only triggers one load once it settles.
|
|
548
|
-
this.__scheduleVisibleDisabledDatesLoad();
|
|
572
|
+
this.__scheduleLoadVisibleDateMetadata();
|
|
549
573
|
}
|
|
550
574
|
|
|
551
575
|
/** @private */
|
|
552
576
|
_repositionMonthScroller() {
|
|
553
577
|
this._monthScroller.position = this._yearScroller.position * 12 - this._originDate.getMonth();
|
|
554
578
|
this._visibleMonthIndex = Math.floor(this._monthScroller.position);
|
|
555
|
-
this.
|
|
579
|
+
this.__scheduleLoadVisibleDateMetadata();
|
|
556
580
|
}
|
|
557
581
|
|
|
558
582
|
/** @private */
|
|
@@ -719,8 +743,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
719
743
|
|
|
720
744
|
/** @private */
|
|
721
745
|
_differenceInMonths(date1, date2) {
|
|
722
|
-
|
|
723
|
-
return months - date2.getMonth() + date1.getMonth();
|
|
746
|
+
return monthIndex(date1) - monthIndex(date2);
|
|
724
747
|
}
|
|
725
748
|
|
|
726
749
|
/** @private */
|
|
@@ -926,33 +949,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
926
949
|
this.focusDate(getClosestDate(focus, [this.minDate, this.maxDate]));
|
|
927
950
|
}
|
|
928
951
|
|
|
929
|
-
/**
|
|
930
|
-
* Returns the nearest date to the given one that can actually be selected: inside min/max, not
|
|
931
|
-
* disabled by `isDateDisabled`, and not disabled by a resolved `disabledDatesProvider`. Scans a
|
|
932
|
-
* year in both directions and returns `undefined` if none is found, so the caller can leave the
|
|
933
|
-
* focus untouched.
|
|
934
|
-
* @private
|
|
935
|
-
*/
|
|
936
|
-
__closestSelectableDate(date) {
|
|
937
|
-
const controller = this._disabledDatesController;
|
|
938
|
-
const isSelectable = (candidate) =>
|
|
939
|
-
this._dateAllowed(candidate) && !(controller?.provider && controller.isDateDisabled(candidate));
|
|
940
|
-
|
|
941
|
-
if (isSelectable(date)) {
|
|
942
|
-
return date;
|
|
943
|
-
}
|
|
944
|
-
for (let offset = 1; offset <= 366; offset++) {
|
|
945
|
-
for (const direction of [1, -1]) {
|
|
946
|
-
const candidate = new Date(date);
|
|
947
|
-
candidate.setDate(candidate.getDate() + offset * direction);
|
|
948
|
-
if (isSelectable(candidate)) {
|
|
949
|
-
return candidate;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
return undefined;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
952
|
/** @private */
|
|
957
953
|
_focusAllowedDate(dateToFocus, diff, keepMonth) {
|
|
958
954
|
// For this check we do consider the isDateDisabled function because disabled dates are allowed to be focused, just not outside min/max
|
|
@@ -975,13 +971,11 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
975
971
|
|
|
976
972
|
/** @private */
|
|
977
973
|
_getDateDiff(months, days) {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
return date;
|
|
974
|
+
return createDate(
|
|
975
|
+
this.focusedDate.getFullYear(),
|
|
976
|
+
this.focusedDate.getMonth() + months,
|
|
977
|
+
days ? this.focusedDate.getDate() + days : 1,
|
|
978
|
+
);
|
|
985
979
|
}
|
|
986
980
|
|
|
987
981
|
/** @private */
|
|
@@ -1011,16 +1005,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
1011
1005
|
|
|
1012
1006
|
/** @private */
|
|
1013
1007
|
_moveFocusInsideMonth(focusedDate, property) {
|
|
1014
|
-
const dateToFocus =
|
|
1015
|
-
dateToFocus.setFullYear(focusedDate.getFullYear());
|
|
1016
|
-
|
|
1017
|
-
if (property === 'minDate') {
|
|
1018
|
-
dateToFocus.setMonth(focusedDate.getMonth());
|
|
1019
|
-
dateToFocus.setDate(1);
|
|
1020
|
-
} else {
|
|
1021
|
-
dateToFocus.setMonth(focusedDate.getMonth() + 1);
|
|
1022
|
-
dateToFocus.setDate(0);
|
|
1023
|
-
}
|
|
1008
|
+
const dateToFocus = property === 'minDate' ? firstOfMonth(focusedDate) : lastOfMonth(focusedDate);
|
|
1024
1009
|
|
|
1025
1010
|
if (this._dateAllowed(dateToFocus)) {
|
|
1026
1011
|
this.focusDate(dateToFocus);
|
|
@@ -1039,22 +1024,18 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
1039
1024
|
}
|
|
1040
1025
|
|
|
1041
1026
|
/** @private */
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
return
|
|
1027
|
+
_dateSelectable(date) {
|
|
1028
|
+
return dateSelectable(date, this.minDate, this.maxDate, this.isDateDisabled, this._dateMetadataController);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** @private */
|
|
1032
|
+
_isTodayAllowed() {
|
|
1033
|
+
return this._dateSelectable(this._getTodayMidnight());
|
|
1049
1034
|
}
|
|
1050
1035
|
|
|
1051
1036
|
/** @private */
|
|
1052
1037
|
_getTodayMidnight() {
|
|
1053
1038
|
const today = new Date();
|
|
1054
|
-
|
|
1055
|
-
todayMidnight.setFullYear(today.getFullYear());
|
|
1056
|
-
todayMidnight.setMonth(today.getMonth());
|
|
1057
|
-
todayMidnight.setDate(today.getDate());
|
|
1058
|
-
return todayMidnight;
|
|
1039
|
+
return createDate(today.getFullYear(), today.getMonth(), today.getDate());
|
|
1059
1040
|
}
|
|
1060
1041
|
};
|
|
@@ -19,6 +19,7 @@ import { overlayContentStyles } from './styles/vaadin-date-picker-overlay-conten
|
|
|
19
19
|
import { DatePickerOverlayContentMixin } from './vaadin-date-picker-overlay-content-mixin.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
22
23
|
* @customElement vaadin-date-picker-overlay-content
|
|
23
24
|
* @extends HTMLElement
|
|
24
25
|
* @private
|
|
@@ -16,6 +16,7 @@ import { DatePickerOverlayMixin } from './vaadin-date-picker-overlay-mixin.js';
|
|
|
16
16
|
/**
|
|
17
17
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
18
18
|
*
|
|
19
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
19
20
|
* @customElement vaadin-date-picker-overlay
|
|
20
21
|
* @extends HTMLElement
|
|
21
22
|
* @private
|
|
@@ -13,11 +13,12 @@ import { datePickerYearStyles } from './styles/vaadin-date-picker-year-base-styl
|
|
|
13
13
|
/**
|
|
14
14
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
15
15
|
*
|
|
16
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
16
17
|
* @customElement vaadin-date-picker-year
|
|
17
18
|
* @extends HTMLElement
|
|
18
19
|
* @private
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
class DatePickerYear extends ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))) {
|
|
21
22
|
static get is() {
|
|
22
23
|
return 'vaadin-date-picker-year';
|
|
23
24
|
}
|
|
@@ -63,3 +64,5 @@ export class DatePickerYear extends ThemableMixin(PolylitMixin(LumoInjectionMixi
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
defineCustomElement(DatePickerYear);
|
|
67
|
+
|
|
68
|
+
export { DatePickerYear };
|
|
@@ -7,7 +7,13 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
|
7
7
|
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
DatePickerDate,
|
|
12
|
+
DatePickerDateMetadata,
|
|
13
|
+
DatePickerDateMetadataProvider,
|
|
14
|
+
DatePickerDateRange,
|
|
15
|
+
DatePickerI18n,
|
|
16
|
+
} from './vaadin-date-picker-mixin.js';
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Fired when the user commits a value change.
|
|
@@ -72,12 +78,6 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
72
78
|
*
|
|
73
79
|
* ### Styling
|
|
74
80
|
*
|
|
75
|
-
* The following custom properties are available for styling:
|
|
76
|
-
*
|
|
77
|
-
* Custom property | Description | Default
|
|
78
|
-
* -------------------------------|----------------------------|---------
|
|
79
|
-
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
80
|
-
*
|
|
81
81
|
* The following shadow DOM parts are available for styling:
|
|
82
82
|
*
|
|
83
83
|
* Part name | Description
|
|
@@ -111,6 +111,69 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
111
111
|
* `opened` | Set when the overlay is opened
|
|
112
112
|
* `week-numbers` | Set when week numbers are shown in the calendar
|
|
113
113
|
*
|
|
114
|
+
* The following custom CSS properties are available for styling:
|
|
115
|
+
*
|
|
116
|
+
* Custom CSS property |
|
|
117
|
+
* :----------------------------------------------------------|
|
|
118
|
+
* | `--vaadin-date-picker-date-border-radius` |
|
|
119
|
+
* | `--vaadin-date-picker-date-disabled-color` |
|
|
120
|
+
* | `--vaadin-date-picker-date-height` |
|
|
121
|
+
* | `--vaadin-date-picker-date-selected-background` |
|
|
122
|
+
* | `--vaadin-date-picker-date-selected-color` |
|
|
123
|
+
* | `--vaadin-date-picker-date-today-color` |
|
|
124
|
+
* | `--vaadin-date-picker-date-width` |
|
|
125
|
+
* | `--vaadin-date-picker-month-header-color` |
|
|
126
|
+
* | `--vaadin-date-picker-month-header-font-size` |
|
|
127
|
+
* | `--vaadin-date-picker-month-header-font-weight` |
|
|
128
|
+
* | `--vaadin-date-picker-month-padding` |
|
|
129
|
+
* | `--vaadin-date-picker-overlay-max-height` |
|
|
130
|
+
* | `--vaadin-date-picker-overlay-width` |
|
|
131
|
+
* | `--vaadin-date-picker-toolbar-padding` |
|
|
132
|
+
* | `--vaadin-date-picker-week-divider-color` |
|
|
133
|
+
* | `--vaadin-date-picker-week-number-color` |
|
|
134
|
+
* | `--vaadin-date-picker-week-number-font-size` |
|
|
135
|
+
* | `--vaadin-date-picker-weekday-color` |
|
|
136
|
+
* | `--vaadin-date-picker-weekday-font-size` |
|
|
137
|
+
* | `--vaadin-date-picker-weekday-font-weight` |
|
|
138
|
+
* | `--vaadin-date-picker-year-scroller-background` |
|
|
139
|
+
* | `--vaadin-date-picker-year-scroller-border-color` |
|
|
140
|
+
* | `--vaadin-date-picker-year-scroller-current-year-color` |
|
|
141
|
+
* | `--vaadin-date-picker-year-scroller-width` |
|
|
142
|
+
* | `--vaadin-field-default-width` |
|
|
143
|
+
* | `--vaadin-input-field-background` |
|
|
144
|
+
* | `--vaadin-input-field-border-color` |
|
|
145
|
+
* | `--vaadin-input-field-border-radius` |
|
|
146
|
+
* | `--vaadin-input-field-border-width` |
|
|
147
|
+
* | `--vaadin-input-field-bottom-end-radius` |
|
|
148
|
+
* | `--vaadin-input-field-bottom-start-radius` |
|
|
149
|
+
* | `--vaadin-input-field-button-text-color` |
|
|
150
|
+
* | `--vaadin-input-field-container-gap` |
|
|
151
|
+
* | `--vaadin-input-field-disabled-background` |
|
|
152
|
+
* | `--vaadin-input-field-disabled-text-color` |
|
|
153
|
+
* | `--vaadin-input-field-error-color` |
|
|
154
|
+
* | `--vaadin-input-field-error-font-size` |
|
|
155
|
+
* | `--vaadin-input-field-error-font-weight` |
|
|
156
|
+
* | `--vaadin-input-field-error-line-height` |
|
|
157
|
+
* | `--vaadin-input-field-gap` |
|
|
158
|
+
* | `--vaadin-input-field-helper-color` |
|
|
159
|
+
* | `--vaadin-input-field-helper-font-size` |
|
|
160
|
+
* | `--vaadin-input-field-helper-font-weight` |
|
|
161
|
+
* | `--vaadin-input-field-helper-line-height` |
|
|
162
|
+
* | `--vaadin-input-field-label-color` |
|
|
163
|
+
* | `--vaadin-input-field-label-font-size` |
|
|
164
|
+
* | `--vaadin-input-field-label-font-weight` |
|
|
165
|
+
* | `--vaadin-input-field-label-line-height` |
|
|
166
|
+
* | `--vaadin-input-field-padding` |
|
|
167
|
+
* | `--vaadin-input-field-placeholder-color` |
|
|
168
|
+
* | `--vaadin-input-field-required-indicator` |
|
|
169
|
+
* | `--vaadin-input-field-required-indicator-color` |
|
|
170
|
+
* | `--vaadin-input-field-top-end-radius` |
|
|
171
|
+
* | `--vaadin-input-field-top-start-radius` |
|
|
172
|
+
* | `--vaadin-input-field-value-color` |
|
|
173
|
+
* | `--vaadin-input-field-value-font-size` |
|
|
174
|
+
* | `--vaadin-input-field-value-font-weight` |
|
|
175
|
+
* | `--vaadin-input-field-value-line-height` |
|
|
176
|
+
*
|
|
114
177
|
* ### Internal components
|
|
115
178
|
*
|
|
116
179
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
@@ -128,6 +191,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
128
191
|
* ----------------------|--------------------
|
|
129
192
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
130
193
|
* `toolbar` | Toolbar with slotted buttons
|
|
194
|
+
* `loader` | Loading spinner shown while the date metadata provider is resolving
|
|
131
195
|
*
|
|
132
196
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
133
197
|
*
|
|
@@ -136,6 +200,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
136
200
|
* `desktop` | Set when the overlay content is in desktop mode
|
|
137
201
|
* `fullscreen` | Set when the overlay content is in fullscreen mode
|
|
138
202
|
* `years-visible` | Set when the year scroller is visible in fullscreen mode
|
|
203
|
+
* `loading` | Set while the date metadata provider is resolving
|
|
139
204
|
*
|
|
140
205
|
* In order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:
|
|
141
206
|
*
|
|
@@ -148,6 +213,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
148
213
|
* `week-number` | Week number element
|
|
149
214
|
* `date` | Date element
|
|
150
215
|
* `disabled` | Disabled date element
|
|
216
|
+
* `loading` | Date element in a month whose metadata is currently being fetched
|
|
151
217
|
* `focused` | Focused date element
|
|
152
218
|
* `selected` | Selected date element
|
|
153
219
|
* `today` | Date element corresponding to the current day
|