@vaadin/date-picker 25.3.0-dev.1fa5a51482 → 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 +391 -79
- 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 +54 -35
- package/src/vaadin-date-metadata-controller.js +170 -156
- 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 +71 -31
- package/src/vaadin-date-picker-mixin.js +116 -136
- package/src/vaadin-date-picker-overlay-content-mixin.js +143 -163
- package/src/vaadin-date-picker-year.js +3 -1
- package/src/vaadin-date-picker.d.ts +67 -11
- package/src/vaadin-date-picker.js +66 -13
- package/src/vaadin-infinite-scroller.js +19 -6
- package/src/vaadin-month-calendar-mixin.js +41 -64
- package/src/vaadin-month-calendar.js +4 -0
- package/web-types.json +29 -11
- package/web-types.lit.json +14 -7
|
@@ -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,20 +118,10 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
106
118
|
type: Function,
|
|
107
119
|
},
|
|
108
120
|
|
|
109
|
-
/**
|
|
110
|
-
* A batch function that fetches metadata (disabled state, custom part names, ...) for a
|
|
111
|
-
* range of dates the calendar is about to render. Returns, or resolves with, an array of
|
|
112
|
-
* `DatePickerDateMetadata` objects.
|
|
113
|
-
*
|
|
114
|
-
* @type {function(DatePickerDateRange): Array<DatePickerDateMetadata> | Promise<Array<DatePickerDateMetadata>> | undefined}
|
|
115
|
-
*/
|
|
116
|
-
dateMetadataProvider: {
|
|
117
|
-
type: Function,
|
|
118
|
-
},
|
|
119
|
-
|
|
120
121
|
/**
|
|
121
122
|
* Reflected while data is being loaded, so the overlay can show a loading spinner.
|
|
122
123
|
* Currently set while the date metadata provider is resolving.
|
|
124
|
+
* @protected
|
|
123
125
|
*/
|
|
124
126
|
loading: {
|
|
125
127
|
type: Boolean,
|
|
@@ -127,17 +129,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
127
129
|
reflectToAttribute: true,
|
|
128
130
|
},
|
|
129
131
|
|
|
130
|
-
/**
|
|
131
|
-
* Bumped whenever the disabled dates controller's cache or loading state changes, to
|
|
132
|
-
* re-run `__updateCalendars` and push the new state to the rendered months.
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
_dateMetadataVersion: {
|
|
136
|
-
type: Number,
|
|
137
|
-
value: 0,
|
|
138
|
-
attribute: false,
|
|
139
|
-
},
|
|
140
|
-
|
|
141
132
|
enteredDate: {
|
|
142
133
|
type: Date,
|
|
143
134
|
sync: true,
|
|
@@ -156,6 +147,18 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
156
147
|
type: Object,
|
|
157
148
|
},
|
|
158
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
|
+
|
|
159
162
|
calendars: {
|
|
160
163
|
type: Array,
|
|
161
164
|
value: () => [],
|
|
@@ -170,14 +173,47 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
170
173
|
|
|
171
174
|
static get observers() {
|
|
172
175
|
return [
|
|
173
|
-
'
|
|
174
|
-
'
|
|
176
|
+
'__updateCalendarsConfig(calendars, i18n, minDate, maxDate, showWeekNumbers, isDateDisabled, _theme, _dateMetadataController)',
|
|
177
|
+
'__updateCalendarsState(calendars, selectedDate, focusedDate, enteredDate, _ignoreTaps)',
|
|
175
178
|
'__updateCancelButton(_cancelButton, i18n)',
|
|
176
|
-
'__updateTodayButton(_todayButton, i18n, minDate, maxDate, isDateDisabled, _dateMetadataVersion)',
|
|
177
179
|
'__updateYears(years, selectedDate, _theme)',
|
|
178
180
|
];
|
|
179
181
|
}
|
|
180
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
|
+
|
|
181
217
|
/**
|
|
182
218
|
* Whether to scroll to a sub-month position when scrolling to a date.
|
|
183
219
|
* This is active if the month scroller is not large enough to fit a
|
|
@@ -232,6 +268,8 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
232
268
|
|
|
233
269
|
reset() {
|
|
234
270
|
this._closeYearScroller();
|
|
271
|
+
this._monthScroller?.reset();
|
|
272
|
+
this._yearScroller?.reset();
|
|
235
273
|
}
|
|
236
274
|
|
|
237
275
|
/**
|
|
@@ -324,39 +362,60 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
324
362
|
}
|
|
325
363
|
}
|
|
326
364
|
|
|
327
|
-
/**
|
|
328
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Applies the today button's label and whether today can be selected.
|
|
367
|
+
*/
|
|
368
|
+
updateTodayButton() {
|
|
369
|
+
const todayButton = this._todayButton;
|
|
329
370
|
if (todayButton) {
|
|
330
|
-
todayButton.textContent = i18n?.today;
|
|
331
|
-
todayButton.disabled = !this._isTodayAllowed(
|
|
371
|
+
todayButton.textContent = this.i18n?.today;
|
|
372
|
+
todayButton.disabled = !this._isTodayAllowed();
|
|
332
373
|
}
|
|
333
374
|
}
|
|
334
375
|
|
|
335
|
-
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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;
|
|
343
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)));
|
|
344
394
|
}
|
|
345
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
|
+
*/
|
|
346
409
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
347
|
-
|
|
410
|
+
__updateCalendarsConfig(
|
|
348
411
|
calendars,
|
|
349
412
|
i18n,
|
|
350
413
|
minDate,
|
|
351
414
|
maxDate,
|
|
352
|
-
selectedDate,
|
|
353
|
-
focusedDate,
|
|
354
415
|
showWeekNumbers,
|
|
355
|
-
ignoreTaps,
|
|
356
|
-
theme,
|
|
357
416
|
isDateDisabled,
|
|
358
|
-
|
|
359
|
-
|
|
417
|
+
theme,
|
|
418
|
+
dateMetadataController,
|
|
360
419
|
) {
|
|
361
420
|
if (calendars?.length) {
|
|
362
421
|
calendars.forEach((calendar) => {
|
|
@@ -364,60 +423,40 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
364
423
|
calendar.minDate = minDate;
|
|
365
424
|
calendar.maxDate = maxDate;
|
|
366
425
|
calendar.isDateDisabled = isDateDisabled;
|
|
367
|
-
calendar.
|
|
368
|
-
|
|
369
|
-
calendar
|
|
370
|
-
calendar.selectedDate = selectedDate;
|
|
426
|
+
calendar._dateMetadataController = dateMetadataController;
|
|
427
|
+
// Subscribe to controller updates (subscribing again is a no-op).
|
|
428
|
+
dateMetadataController?.subscribe(calendar);
|
|
371
429
|
calendar.showWeekNumbers = showWeekNumbers;
|
|
372
|
-
calendar.ignoreTaps = ignoreTaps;
|
|
373
|
-
calendar.enteredDate = enteredDate;
|
|
374
430
|
|
|
375
|
-
|
|
376
|
-
calendar.setAttribute('theme', theme);
|
|
377
|
-
} else {
|
|
378
|
-
calendar.removeAttribute('theme');
|
|
379
|
-
}
|
|
431
|
+
setOrRemoveAttribute(calendar, 'theme', theme);
|
|
380
432
|
});
|
|
381
|
-
|
|
382
|
-
this.__ensureVisibleDateMetadataLoaded();
|
|
383
433
|
}
|
|
384
434
|
}
|
|
385
435
|
|
|
386
436
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* 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.
|
|
390
439
|
* @private
|
|
391
440
|
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
const indexes = this.calendars
|
|
398
|
-
.map((calendar) => calendar.month)
|
|
399
|
-
.filter(Boolean)
|
|
400
|
-
.map((month) => month.getFullYear() * 12 + month.getMonth());
|
|
401
|
-
if (indexes.length === 0) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
const min = Math.min(...indexes);
|
|
405
|
-
const max = Math.max(...indexes);
|
|
406
|
-
controller.ensureRangeLoaded(
|
|
407
|
-
new Date(Math.floor(min / 12), min % 12, 1),
|
|
408
|
-
new Date(Math.floor(max / 12), max % 12, 1),
|
|
441
|
+
__scheduleLoadVisibleDateMetadata() {
|
|
442
|
+
this._loadDateMetadataDebouncer = Debouncer.debounce(this._loadDateMetadataDebouncer, timeOut.after(200), () =>
|
|
443
|
+
this.loadVisibleDateMetadata(),
|
|
409
444
|
);
|
|
410
445
|
}
|
|
411
446
|
|
|
412
447
|
/**
|
|
413
|
-
*
|
|
414
|
-
* settles instead of a request per intermediate position.
|
|
448
|
+
* Interaction state that changes often (focus, selection, entered date, taps).
|
|
415
449
|
* @private
|
|
416
450
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
+
}
|
|
421
460
|
}
|
|
422
461
|
|
|
423
462
|
/** @private */
|
|
@@ -426,11 +465,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
426
465
|
years.forEach((year) => {
|
|
427
466
|
year.selectedDate = selectedDate;
|
|
428
467
|
|
|
429
|
-
|
|
430
|
-
year.setAttribute('theme', theme);
|
|
431
|
-
} else {
|
|
432
|
-
year.removeAttribute('theme');
|
|
433
|
-
}
|
|
468
|
+
setOrRemoveAttribute(year, 'theme', theme);
|
|
434
469
|
});
|
|
435
470
|
}
|
|
436
471
|
}
|
|
@@ -440,12 +475,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
440
475
|
* @protected
|
|
441
476
|
*/
|
|
442
477
|
_selectDate(dateToSelect) {
|
|
443
|
-
if (!this.
|
|
444
|
-
return false;
|
|
445
|
-
}
|
|
446
|
-
// Block dates disabled by the provider, or in a month whose provider result has not loaded
|
|
447
|
-
// yet, so they cannot be selected via keyboard or the today button either.
|
|
448
|
-
if (this._dateMetadataController?.isDateBlocked(dateToSelect)) {
|
|
478
|
+
if (!this._dateSelectable(dateToSelect)) {
|
|
449
479
|
return false;
|
|
450
480
|
}
|
|
451
481
|
this.selectedDate = dateToSelect;
|
|
@@ -511,11 +541,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
511
541
|
* @private
|
|
512
542
|
*/
|
|
513
543
|
_calculateWeekScrollOffset(date) {
|
|
514
|
-
|
|
515
|
-
const temp = new Date(0, 0);
|
|
516
|
-
temp.setFullYear(date.getFullYear());
|
|
517
|
-
temp.setMonth(date.getMonth());
|
|
518
|
-
temp.setDate(1);
|
|
544
|
+
const temp = firstOfMonth(date);
|
|
519
545
|
// Determine week (=row index) of date within the month
|
|
520
546
|
let week = 0;
|
|
521
547
|
while (temp.getDate() < date.getDate()) {
|
|
@@ -543,17 +569,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
543
569
|
const monthPosition = this._monthScroller.position;
|
|
544
570
|
this._visibleMonthIndex = Math.floor(monthPosition);
|
|
545
571
|
this._yearScroller.position = (monthPosition + this._originDate.getMonth()) / 12;
|
|
546
|
-
|
|
547
|
-
// single place to keep the disabled dates loaded for the newly visible months. Debounced
|
|
548
|
-
// so a continuous scroll only triggers one load once it settles.
|
|
549
|
-
this.__scheduleVisibleDateMetadataLoad();
|
|
572
|
+
this.__scheduleLoadVisibleDateMetadata();
|
|
550
573
|
}
|
|
551
574
|
|
|
552
575
|
/** @private */
|
|
553
576
|
_repositionMonthScroller() {
|
|
554
577
|
this._monthScroller.position = this._yearScroller.position * 12 - this._originDate.getMonth();
|
|
555
578
|
this._visibleMonthIndex = Math.floor(this._monthScroller.position);
|
|
556
|
-
this.
|
|
579
|
+
this.__scheduleLoadVisibleDateMetadata();
|
|
557
580
|
}
|
|
558
581
|
|
|
559
582
|
/** @private */
|
|
@@ -720,8 +743,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
720
743
|
|
|
721
744
|
/** @private */
|
|
722
745
|
_differenceInMonths(date1, date2) {
|
|
723
|
-
|
|
724
|
-
return months - date2.getMonth() + date1.getMonth();
|
|
746
|
+
return monthIndex(date1) - monthIndex(date2);
|
|
725
747
|
}
|
|
726
748
|
|
|
727
749
|
/** @private */
|
|
@@ -927,33 +949,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
927
949
|
this.focusDate(getClosestDate(focus, [this.minDate, this.maxDate]));
|
|
928
950
|
}
|
|
929
951
|
|
|
930
|
-
/**
|
|
931
|
-
* Returns the nearest date to the given one that can actually be selected: inside min/max, not
|
|
932
|
-
* disabled by `isDateDisabled`, and not disabled by a resolved `dateMetadataProvider`. Scans a
|
|
933
|
-
* year in both directions and returns `undefined` if none is found, so the caller can leave the
|
|
934
|
-
* focus untouched.
|
|
935
|
-
* @private
|
|
936
|
-
*/
|
|
937
|
-
__closestSelectableDate(date) {
|
|
938
|
-
const controller = this._dateMetadataController;
|
|
939
|
-
const isSelectable = (candidate) =>
|
|
940
|
-
this._dateAllowed(candidate) && !(controller?.provider && controller.isDateDisabled(candidate));
|
|
941
|
-
|
|
942
|
-
if (isSelectable(date)) {
|
|
943
|
-
return date;
|
|
944
|
-
}
|
|
945
|
-
for (let offset = 1; offset <= 366; offset++) {
|
|
946
|
-
for (const direction of [1, -1]) {
|
|
947
|
-
const candidate = new Date(date);
|
|
948
|
-
candidate.setDate(candidate.getDate() + offset * direction);
|
|
949
|
-
if (isSelectable(candidate)) {
|
|
950
|
-
return candidate;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
return undefined;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
952
|
/** @private */
|
|
958
953
|
_focusAllowedDate(dateToFocus, diff, keepMonth) {
|
|
959
954
|
// For this check we do consider the isDateDisabled function because disabled dates are allowed to be focused, just not outside min/max
|
|
@@ -976,13 +971,11 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
976
971
|
|
|
977
972
|
/** @private */
|
|
978
973
|
_getDateDiff(months, days) {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
return date;
|
|
974
|
+
return createDate(
|
|
975
|
+
this.focusedDate.getFullYear(),
|
|
976
|
+
this.focusedDate.getMonth() + months,
|
|
977
|
+
days ? this.focusedDate.getDate() + days : 1,
|
|
978
|
+
);
|
|
986
979
|
}
|
|
987
980
|
|
|
988
981
|
/** @private */
|
|
@@ -1012,16 +1005,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
1012
1005
|
|
|
1013
1006
|
/** @private */
|
|
1014
1007
|
_moveFocusInsideMonth(focusedDate, property) {
|
|
1015
|
-
const dateToFocus =
|
|
1016
|
-
dateToFocus.setFullYear(focusedDate.getFullYear());
|
|
1017
|
-
|
|
1018
|
-
if (property === 'minDate') {
|
|
1019
|
-
dateToFocus.setMonth(focusedDate.getMonth());
|
|
1020
|
-
dateToFocus.setDate(1);
|
|
1021
|
-
} else {
|
|
1022
|
-
dateToFocus.setMonth(focusedDate.getMonth() + 1);
|
|
1023
|
-
dateToFocus.setDate(0);
|
|
1024
|
-
}
|
|
1008
|
+
const dateToFocus = property === 'minDate' ? firstOfMonth(focusedDate) : lastOfMonth(focusedDate);
|
|
1025
1009
|
|
|
1026
1010
|
if (this._dateAllowed(dateToFocus)) {
|
|
1027
1011
|
this.focusDate(dateToFocus);
|
|
@@ -1040,22 +1024,18 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
1040
1024
|
}
|
|
1041
1025
|
|
|
1042
1026
|
/** @private */
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
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());
|
|
1050
1034
|
}
|
|
1051
1035
|
|
|
1052
1036
|
/** @private */
|
|
1053
1037
|
_getTodayMidnight() {
|
|
1054
1038
|
const today = new Date();
|
|
1055
|
-
|
|
1056
|
-
todayMidnight.setFullYear(today.getFullYear());
|
|
1057
|
-
todayMidnight.setMonth(today.getMonth());
|
|
1058
|
-
todayMidnight.setDate(today.getDate());
|
|
1059
|
-
return todayMidnight;
|
|
1039
|
+
return createDate(today.getFullYear(), today.getMonth(), today.getDate());
|
|
1060
1040
|
}
|
|
1061
1041
|
};
|
|
@@ -18,7 +18,7 @@ import { datePickerYearStyles } from './styles/vaadin-date-picker-year-base-styl
|
|
|
18
18
|
* @extends HTMLElement
|
|
19
19
|
* @private
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
class DatePickerYear extends ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))) {
|
|
22
22
|
static get is() {
|
|
23
23
|
return 'vaadin-date-picker-year';
|
|
24
24
|
}
|
|
@@ -64,3 +64,5 @@ export class DatePickerYear extends ThemableMixin(PolylitMixin(LumoInjectionMixi
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
defineCustomElement(DatePickerYear);
|
|
67
|
+
|
|
68
|
+
export { DatePickerYear };
|
|
@@ -10,6 +10,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
10
10
|
export {
|
|
11
11
|
DatePickerDate,
|
|
12
12
|
DatePickerDateMetadata,
|
|
13
|
+
DatePickerDateMetadataProvider,
|
|
13
14
|
DatePickerDateRange,
|
|
14
15
|
DatePickerI18n,
|
|
15
16
|
} from './vaadin-date-picker-mixin.js';
|
|
@@ -77,12 +78,6 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
77
78
|
*
|
|
78
79
|
* ### Styling
|
|
79
80
|
*
|
|
80
|
-
* The following custom properties are available for styling:
|
|
81
|
-
*
|
|
82
|
-
* Custom property | Description | Default
|
|
83
|
-
* -------------------------------|----------------------------|---------
|
|
84
|
-
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
85
|
-
*
|
|
86
81
|
* The following shadow DOM parts are available for styling:
|
|
87
82
|
*
|
|
88
83
|
* Part name | Description
|
|
@@ -116,6 +111,69 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
116
111
|
* `opened` | Set when the overlay is opened
|
|
117
112
|
* `week-numbers` | Set when week numbers are shown in the calendar
|
|
118
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
|
+
*
|
|
119
177
|
* ### Internal components
|
|
120
178
|
*
|
|
121
179
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
@@ -133,6 +191,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
133
191
|
* ----------------------|--------------------
|
|
134
192
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
135
193
|
* `toolbar` | Toolbar with slotted buttons
|
|
194
|
+
* `loader` | Loading spinner shown while the date metadata provider is resolving
|
|
136
195
|
*
|
|
137
196
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
138
197
|
*
|
|
@@ -141,6 +200,7 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
141
200
|
* `desktop` | Set when the overlay content is in desktop mode
|
|
142
201
|
* `fullscreen` | Set when the overlay content is in fullscreen mode
|
|
143
202
|
* `years-visible` | Set when the year scroller is visible in fullscreen mode
|
|
203
|
+
* `loading` | Set while the date metadata provider is resolving
|
|
144
204
|
*
|
|
145
205
|
* In order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:
|
|
146
206
|
*
|
|
@@ -153,17 +213,13 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
153
213
|
* `week-number` | Week number element
|
|
154
214
|
* `date` | Date element
|
|
155
215
|
* `disabled` | Disabled date element
|
|
156
|
-
* `
|
|
216
|
+
* `loading` | Date element in a month whose metadata is currently being fetched
|
|
157
217
|
* `focused` | Focused date element
|
|
158
218
|
* `selected` | Selected date element
|
|
159
219
|
* `today` | Date element corresponding to the current day
|
|
160
220
|
* `past` | Date element corresponding to the date in the past
|
|
161
221
|
* `future` | Date element corresponding to the date in the future
|
|
162
222
|
*
|
|
163
|
-
* Custom part names returned per date by `dateMetadataProvider` (the `part` metadata field) are
|
|
164
|
-
* also added to the matching date elements, so specific dates can be styled with
|
|
165
|
-
* `vaadin-month-calendar::part(<name>)`.
|
|
166
|
-
*
|
|
167
223
|
* In order to style year scroller elements, use `<vaadin-date-picker-year>` shadow DOM parts:
|
|
168
224
|
*
|
|
169
225
|
* Part name | Description
|