@vaadin/date-picker 24.4.0-alpha4 → 24.4.0-alpha6
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/package.json +11 -11
- package/src/vaadin-date-picker-helper.d.ts +6 -1
- package/src/vaadin-date-picker-helper.js +23 -16
- package/src/vaadin-date-picker-mixin.d.ts +7 -0
- package/src/vaadin-date-picker-mixin.js +31 -6
- package/src/vaadin-date-picker-overlay-content-mixin.js +38 -13
- package/src/vaadin-lit-month-calendar.js +1 -1
- package/src/vaadin-month-calendar-mixin.js +11 -0
- package/src/vaadin-month-calendar.js +11 -11
- package/theme/lumo/vaadin-date-picker-light.d.ts +4 -0
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.d.ts +7 -0
- package/theme/lumo/vaadin-date-picker-overlay-styles.d.ts +2 -0
- package/theme/lumo/vaadin-date-picker-styles.d.ts +2 -0
- package/theme/lumo/vaadin-date-picker-year-styles.d.ts +1 -0
- package/theme/lumo/vaadin-date-picker.d.ts +5 -0
- package/theme/lumo/vaadin-lit-date-picker.d.ts +5 -0
- package/theme/lumo/vaadin-month-calendar-styles.d.ts +5 -0
- package/theme/material/vaadin-date-picker-light.d.ts +4 -0
- package/theme/material/vaadin-date-picker-overlay-content-styles.d.ts +6 -0
- package/theme/material/vaadin-date-picker-overlay-styles.d.ts +1 -0
- package/theme/material/vaadin-date-picker-styles.d.ts +3 -0
- package/theme/material/vaadin-date-picker-year-styles.d.ts +1 -0
- package/theme/material/vaadin-date-picker.d.ts +5 -0
- package/theme/material/vaadin-lit-date-picker.d.ts +5 -0
- package/theme/material/vaadin-month-calendar-styles.d.ts +2 -0
- package/web-types.json +22 -2
- package/web-types.lit.json +16 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "24.4.0-
|
|
3
|
+
"version": "24.4.0-alpha6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.2.0",
|
|
39
|
-
"@vaadin/a11y-base": "24.4.0-
|
|
40
|
-
"@vaadin/button": "24.4.0-
|
|
41
|
-
"@vaadin/component-base": "24.4.0-
|
|
42
|
-
"@vaadin/field-base": "24.4.0-
|
|
43
|
-
"@vaadin/input-container": "24.4.0-
|
|
44
|
-
"@vaadin/overlay": "24.4.0-
|
|
45
|
-
"@vaadin/vaadin-lumo-styles": "24.4.0-
|
|
46
|
-
"@vaadin/vaadin-material-styles": "24.4.0-
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "24.4.0-
|
|
39
|
+
"@vaadin/a11y-base": "24.4.0-alpha6",
|
|
40
|
+
"@vaadin/button": "24.4.0-alpha6",
|
|
41
|
+
"@vaadin/component-base": "24.4.0-alpha6",
|
|
42
|
+
"@vaadin/field-base": "24.4.0-alpha6",
|
|
43
|
+
"@vaadin/input-container": "24.4.0-alpha6",
|
|
44
|
+
"@vaadin/overlay": "24.4.0-alpha6",
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "24.4.0-alpha6",
|
|
46
|
+
"@vaadin/vaadin-material-styles": "24.4.0-alpha6",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "24.4.0-alpha6",
|
|
48
48
|
"lit": "^3.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"web-types.json",
|
|
57
57
|
"web-types.lit.json"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "7d555ad342715966005883fafcd20001425a6d8c"
|
|
60
60
|
}
|
|
@@ -17,7 +17,12 @@ declare function dateEquals(date1: Date | null, date2: Date | null): boolean;
|
|
|
17
17
|
*
|
|
18
18
|
* @returns True if the date is in the range
|
|
19
19
|
*/
|
|
20
|
-
declare function dateAllowed(
|
|
20
|
+
declare function dateAllowed(
|
|
21
|
+
date: Date,
|
|
22
|
+
min: Date | null,
|
|
23
|
+
max: Date | null,
|
|
24
|
+
isDateDisabled: (DatePickerDate) => boolean | null,
|
|
25
|
+
): boolean;
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
28
|
* Get closest date from array of dates.
|
|
@@ -53,16 +53,37 @@ export function dateEquals(date1, date2) {
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Extracts the basic component parts of a date (day, month and year)
|
|
58
|
+
* to the expected format.
|
|
59
|
+
* @param {!Date} date
|
|
60
|
+
* @return {{day: number, month: number, year: number}}
|
|
61
|
+
*/
|
|
62
|
+
export function extractDateParts(date) {
|
|
63
|
+
return {
|
|
64
|
+
day: date.getDate(),
|
|
65
|
+
month: date.getMonth(),
|
|
66
|
+
year: date.getFullYear(),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
/**
|
|
57
71
|
* Check if the given date is in the range of allowed dates.
|
|
58
72
|
*
|
|
59
73
|
* @param {!Date} date The date to check
|
|
60
74
|
* @param {Date} min Range start
|
|
61
75
|
* @param {Date} max Range end
|
|
76
|
+
* @param {function(!DatePickerDate): boolean} isDateDisabled Callback to check if the date is disabled
|
|
62
77
|
* @return {boolean} True if the date is in the range
|
|
63
78
|
*/
|
|
64
|
-
export function dateAllowed(date, min, max) {
|
|
65
|
-
|
|
79
|
+
export function dateAllowed(date, min, max, isDateDisabled) {
|
|
80
|
+
let dateIsDisabled = false;
|
|
81
|
+
if (typeof isDateDisabled === 'function' && !!date) {
|
|
82
|
+
const dateToCheck = extractDateParts(date);
|
|
83
|
+
dateIsDisabled = isDateDisabled(dateToCheck);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (!min || date >= min) && (!max || date <= max) && !dateIsDisabled;
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
/**
|
|
@@ -90,20 +111,6 @@ export function getClosestDate(date, dates) {
|
|
|
90
111
|
});
|
|
91
112
|
}
|
|
92
113
|
|
|
93
|
-
/**
|
|
94
|
-
* Extracts the basic component parts of a date (day, month and year)
|
|
95
|
-
* to the expected format.
|
|
96
|
-
* @param {!Date} date
|
|
97
|
-
* @return {{day: number, month: number, year: number}}
|
|
98
|
-
*/
|
|
99
|
-
export function extractDateParts(date) {
|
|
100
|
-
return {
|
|
101
|
-
day: date.getDate(),
|
|
102
|
-
month: date.getMonth(),
|
|
103
|
-
year: date.getFullYear(),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
114
|
/**
|
|
108
115
|
* Get difference in months between today and given months value.
|
|
109
116
|
*
|
|
@@ -237,6 +237,13 @@ export declare class DatePickerMixinClass {
|
|
|
237
237
|
*/
|
|
238
238
|
max: string | undefined;
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* A function to be used to determine whether the user can select a given date.
|
|
242
|
+
* Receives a `DatePickerDate` object of the date to be selected and should return a
|
|
243
|
+
* boolean.
|
|
244
|
+
*/
|
|
245
|
+
isDateDisabled: (date: DatePickerDate) => boolean;
|
|
246
|
+
|
|
240
247
|
/**
|
|
241
248
|
* Opens the dropdown.
|
|
242
249
|
*/
|
|
@@ -302,6 +302,17 @@ export const DatePickerMixin = (subclass) =>
|
|
|
302
302
|
sync: true,
|
|
303
303
|
},
|
|
304
304
|
|
|
305
|
+
/**
|
|
306
|
+
* A function to be used to determine whether the user can select a given date.
|
|
307
|
+
* Receives a `DatePickerDate` object of the date to be selected and should return a
|
|
308
|
+
* boolean.
|
|
309
|
+
*
|
|
310
|
+
* @type {function(DatePickerDate): boolean | undefined}
|
|
311
|
+
*/
|
|
312
|
+
isDateDisabled: {
|
|
313
|
+
type: Function,
|
|
314
|
+
},
|
|
315
|
+
|
|
305
316
|
/**
|
|
306
317
|
* The earliest date that can be selected. All earlier dates will be disabled.
|
|
307
318
|
* @type {Date | undefined}
|
|
@@ -365,7 +376,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
365
376
|
return [
|
|
366
377
|
'_selectedDateChanged(_selectedDate, i18n)',
|
|
367
378
|
'_focusedDateChanged(_focusedDate, i18n)',
|
|
368
|
-
'__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers)',
|
|
379
|
+
'__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers, isDateDisabled)',
|
|
369
380
|
'__updateOverlayContentTheme(_overlayContent, _theme)',
|
|
370
381
|
'__updateOverlayContentFullScreen(_overlayContent, _fullscreen)',
|
|
371
382
|
];
|
|
@@ -601,7 +612,8 @@ export const DatePickerMixin = (subclass) =>
|
|
|
601
612
|
checkValidity() {
|
|
602
613
|
const inputValue = this._inputElementValue;
|
|
603
614
|
const inputValid = !inputValue || (!!this._selectedDate && inputValue === this.__formatDate(this._selectedDate));
|
|
604
|
-
const
|
|
615
|
+
const isDateValid =
|
|
616
|
+
!this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate, this.isDateDisabled);
|
|
605
617
|
|
|
606
618
|
let inputValidity = true;
|
|
607
619
|
if (this.inputElement) {
|
|
@@ -613,7 +625,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
613
625
|
}
|
|
614
626
|
}
|
|
615
627
|
|
|
616
|
-
return inputValid &&
|
|
628
|
+
return inputValid && isDateValid && inputValidity;
|
|
617
629
|
}
|
|
618
630
|
|
|
619
631
|
/**
|
|
@@ -852,7 +864,17 @@ export const DatePickerMixin = (subclass) =>
|
|
|
852
864
|
|
|
853
865
|
/** @private */
|
|
854
866
|
// eslint-disable-next-line max-params
|
|
855
|
-
__updateOverlayContent(
|
|
867
|
+
__updateOverlayContent(
|
|
868
|
+
overlayContent,
|
|
869
|
+
i18n,
|
|
870
|
+
label,
|
|
871
|
+
minDate,
|
|
872
|
+
maxDate,
|
|
873
|
+
focusedDate,
|
|
874
|
+
selectedDate,
|
|
875
|
+
showWeekNumbers,
|
|
876
|
+
isDateDisabled,
|
|
877
|
+
) {
|
|
856
878
|
if (overlayContent) {
|
|
857
879
|
overlayContent.i18n = i18n;
|
|
858
880
|
overlayContent.label = label;
|
|
@@ -861,6 +883,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
861
883
|
overlayContent.focusedDate = focusedDate;
|
|
862
884
|
overlayContent.selectedDate = selectedDate;
|
|
863
885
|
overlayContent.showWeekNumbers = showWeekNumbers;
|
|
886
|
+
overlayContent.isDateDisabled = isDateDisabled;
|
|
864
887
|
}
|
|
865
888
|
}
|
|
866
889
|
|
|
@@ -932,9 +955,11 @@ export const DatePickerMixin = (subclass) =>
|
|
|
932
955
|
const initialPosition =
|
|
933
956
|
this._selectedDate || this._overlayContent.initialPosition || parsedInitialPosition || new Date();
|
|
934
957
|
|
|
935
|
-
return parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate)
|
|
958
|
+
return parsedInitialPosition || dateAllowed(initialPosition, this._minDate, this._maxDate, this.isDateDisabled)
|
|
936
959
|
? initialPosition
|
|
937
|
-
:
|
|
960
|
+
: this._minDate || this._maxDate
|
|
961
|
+
? getClosestDate(initialPosition, [this._minDate, this._maxDate])
|
|
962
|
+
: new Date();
|
|
938
963
|
}
|
|
939
964
|
|
|
940
965
|
/**
|
|
@@ -10,7 +10,13 @@ import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
|
10
10
|
import { addListener, setTouchAction } from '@vaadin/component-base/src/gestures.js';
|
|
11
11
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
12
12
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
dateAfterXMonths,
|
|
15
|
+
dateAllowed,
|
|
16
|
+
dateEquals,
|
|
17
|
+
extractDateParts,
|
|
18
|
+
getClosestDate,
|
|
19
|
+
} from './vaadin-date-picker-helper.js';
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* @polymerMixin
|
|
@@ -107,6 +113,17 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
107
113
|
sync: true,
|
|
108
114
|
},
|
|
109
115
|
|
|
116
|
+
/**
|
|
117
|
+
* A function to be used to determine whether the user can select a given date.
|
|
118
|
+
* Receives a `DatePickerDate` object of the date to be selected and should return a
|
|
119
|
+
* boolean.
|
|
120
|
+
*
|
|
121
|
+
* @type {function(DatePickerDate): boolean | undefined}
|
|
122
|
+
*/
|
|
123
|
+
isDateDisabled: {
|
|
124
|
+
type: Function,
|
|
125
|
+
},
|
|
126
|
+
|
|
110
127
|
/**
|
|
111
128
|
* Input label
|
|
112
129
|
*/
|
|
@@ -134,9 +151,9 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
134
151
|
|
|
135
152
|
static get observers() {
|
|
136
153
|
return [
|
|
137
|
-
'__updateCalendars(calendars, i18n, minDate, maxDate, selectedDate, focusedDate, showWeekNumbers, _ignoreTaps, _theme)',
|
|
154
|
+
'__updateCalendars(calendars, i18n, minDate, maxDate, selectedDate, focusedDate, showWeekNumbers, _ignoreTaps, _theme, isDateDisabled)',
|
|
138
155
|
'__updateCancelButton(_cancelButton, i18n)',
|
|
139
|
-
'__updateTodayButton(_todayButton, i18n, minDate, maxDate)',
|
|
156
|
+
'__updateTodayButton(_todayButton, i18n, minDate, maxDate, isDateDisabled)',
|
|
140
157
|
'__updateYears(years, selectedDate, _theme)',
|
|
141
158
|
];
|
|
142
159
|
}
|
|
@@ -303,10 +320,10 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
303
320
|
}
|
|
304
321
|
|
|
305
322
|
/** @private */
|
|
306
|
-
__updateTodayButton(todayButton, i18n, minDate, maxDate) {
|
|
323
|
+
__updateTodayButton(todayButton, i18n, minDate, maxDate, isDateDisabled) {
|
|
307
324
|
if (todayButton) {
|
|
308
325
|
todayButton.textContent = i18n && i18n.today;
|
|
309
|
-
todayButton.disabled = !this._isTodayAllowed(minDate, maxDate);
|
|
326
|
+
todayButton.disabled = !this._isTodayAllowed(minDate, maxDate, isDateDisabled);
|
|
310
327
|
}
|
|
311
328
|
}
|
|
312
329
|
|
|
@@ -321,12 +338,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
321
338
|
showWeekNumbers,
|
|
322
339
|
ignoreTaps,
|
|
323
340
|
theme,
|
|
341
|
+
isDateDisabled,
|
|
324
342
|
) {
|
|
325
343
|
if (calendars && calendars.length) {
|
|
326
344
|
calendars.forEach((calendar) => {
|
|
327
345
|
calendar.i18n = i18n;
|
|
328
346
|
calendar.minDate = minDate;
|
|
329
347
|
calendar.maxDate = maxDate;
|
|
348
|
+
calendar.isDateDisabled = isDateDisabled;
|
|
330
349
|
calendar.focusedDate = focusedDate;
|
|
331
350
|
calendar.selectedDate = selectedDate;
|
|
332
351
|
calendar.showWeekNumbers = showWeekNumbers;
|
|
@@ -361,10 +380,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
361
380
|
* @protected
|
|
362
381
|
*/
|
|
363
382
|
_selectDate(dateToSelect) {
|
|
383
|
+
if (!this._dateAllowed(dateToSelect)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
364
386
|
this.selectedDate = dateToSelect;
|
|
365
387
|
this.dispatchEvent(
|
|
366
388
|
new CustomEvent('date-selected', { detail: { date: dateToSelect }, bubbles: true, composed: true }),
|
|
367
389
|
);
|
|
390
|
+
return true;
|
|
368
391
|
}
|
|
369
392
|
|
|
370
393
|
/** @private */
|
|
@@ -775,9 +798,10 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
775
798
|
handled = true;
|
|
776
799
|
break;
|
|
777
800
|
case 'Enter':
|
|
778
|
-
this._selectDate(this.focusedDate)
|
|
779
|
-
|
|
780
|
-
|
|
801
|
+
if (this._selectDate(this.focusedDate)) {
|
|
802
|
+
this._close();
|
|
803
|
+
handled = true;
|
|
804
|
+
}
|
|
781
805
|
break;
|
|
782
806
|
case ' ':
|
|
783
807
|
this.__toggleDate(this.focusedDate);
|
|
@@ -931,7 +955,8 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
931
955
|
|
|
932
956
|
/** @private */
|
|
933
957
|
_focusAllowedDate(dateToFocus, diff, keepMonth) {
|
|
934
|
-
|
|
958
|
+
// For this check we do consider the isDateDisabled function because disabled dates are allowed to be focused, just not outside min/max
|
|
959
|
+
if (this._dateAllowed(dateToFocus, undefined, undefined, () => false)) {
|
|
935
960
|
this.focusDate(dateToFocus, keepMonth);
|
|
936
961
|
} else if (this._dateAllowed(this.focusedDate)) {
|
|
937
962
|
// Move to min or max date
|
|
@@ -1009,18 +1034,18 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
1009
1034
|
}
|
|
1010
1035
|
|
|
1011
1036
|
/** @private */
|
|
1012
|
-
_dateAllowed(date, min = this.minDate, max = this.maxDate) {
|
|
1013
|
-
return (
|
|
1037
|
+
_dateAllowed(date, min = this.minDate, max = this.maxDate, isDateDisabled = this.isDateDisabled) {
|
|
1038
|
+
return dateAllowed(date, min, max, isDateDisabled);
|
|
1014
1039
|
}
|
|
1015
1040
|
|
|
1016
1041
|
/** @private */
|
|
1017
|
-
_isTodayAllowed(min, max) {
|
|
1042
|
+
_isTodayAllowed(min, max, isDateDisabled) {
|
|
1018
1043
|
const today = new Date();
|
|
1019
1044
|
const todayMidnight = new Date(0, 0);
|
|
1020
1045
|
todayMidnight.setFullYear(today.getFullYear());
|
|
1021
1046
|
todayMidnight.setMonth(today.getMonth());
|
|
1022
1047
|
todayMidnight.setDate(today.getDate());
|
|
1023
|
-
return this._dateAllowed(todayMidnight, min, max);
|
|
1048
|
+
return this._dateAllowed(todayMidnight, min, max, isDateDisabled);
|
|
1024
1049
|
}
|
|
1025
1050
|
|
|
1026
1051
|
/**
|
|
@@ -61,7 +61,7 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LitEle
|
|
|
61
61
|
${week.map((date) => {
|
|
62
62
|
const isFocused = dateEquals(date, this.focusedDate);
|
|
63
63
|
const isSelected = dateEquals(date, this.selectedDate);
|
|
64
|
-
const isDisabled = !dateAllowed(date, this.minDate, this.maxDate);
|
|
64
|
+
const isDisabled = !dateAllowed(date, this.minDate, this.maxDate, this.isDateDisabled);
|
|
65
65
|
|
|
66
66
|
const parts = [
|
|
67
67
|
'date',
|
|
@@ -80,6 +80,17 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
80
80
|
sync: true,
|
|
81
81
|
},
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A function to be used to determine whether the user can select a given date.
|
|
85
|
+
* Receives a `DatePickerDate` object of the date to be selected and should return a
|
|
86
|
+
* boolean.
|
|
87
|
+
* @type {Function | undefined}
|
|
88
|
+
*/
|
|
89
|
+
isDateDisabled: {
|
|
90
|
+
type: Function,
|
|
91
|
+
value: () => false,
|
|
92
|
+
},
|
|
93
|
+
|
|
83
94
|
disabled: {
|
|
84
95
|
type: Boolean,
|
|
85
96
|
reflectToAttribute: true,
|
|
@@ -50,12 +50,12 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolymerElement)) {
|
|
|
50
50
|
<template is="dom-repeat" items="[[week]]">
|
|
51
51
|
<td
|
|
52
52
|
role="gridcell"
|
|
53
|
-
part$="[[__getDatePart(item, focusedDate, selectedDate, minDate, maxDate)]]"
|
|
53
|
+
part$="[[__getDatePart(item, focusedDate, selectedDate, minDate, maxDate, isDateDisabled)]]"
|
|
54
54
|
date="[[item]]"
|
|
55
55
|
tabindex$="[[__getDayTabindex(item, focusedDate)]]"
|
|
56
|
-
disabled$="[[__isDayDisabled(item, minDate, maxDate)]]"
|
|
56
|
+
disabled$="[[__isDayDisabled(item, minDate, maxDate, isDateDisabled)]]"
|
|
57
57
|
aria-selected$="[[__getDayAriaSelected(item, selectedDate)]]"
|
|
58
|
-
aria-disabled$="[[__getDayAriaDisabled(item, minDate, maxDate)]]"
|
|
58
|
+
aria-disabled$="[[__getDayAriaDisabled(item, minDate, maxDate, isDateDisabled)]]"
|
|
59
59
|
aria-label$="[[__getDayAriaLabel(item)]]"
|
|
60
60
|
>[[_getDate(item)]]</td
|
|
61
61
|
>
|
|
@@ -76,7 +76,7 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolymerElement)) {
|
|
|
76
76
|
/** @protected */
|
|
77
77
|
_days: {
|
|
78
78
|
type: Array,
|
|
79
|
-
computed: '_getDays(month, i18n, minDate, maxDate)',
|
|
79
|
+
computed: '_getDays(month, i18n, minDate, maxDate, isDateDisabled)',
|
|
80
80
|
},
|
|
81
81
|
|
|
82
82
|
/** @protected */
|
|
@@ -107,10 +107,10 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolymerElement)) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/** @private */
|
|
110
|
-
__getDatePart(date, focusedDate, selectedDate, minDate, maxDate) {
|
|
110
|
+
__getDatePart(date, focusedDate, selectedDate, minDate, maxDate, isDateDisabled) {
|
|
111
111
|
const result = ['date'];
|
|
112
112
|
|
|
113
|
-
if (this.__isDayDisabled(date, minDate, maxDate)) {
|
|
113
|
+
if (this.__isDayDisabled(date, minDate, maxDate, isDateDisabled)) {
|
|
114
114
|
result.push('disabled');
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -147,17 +147,17 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolymerElement)) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/** @private */
|
|
150
|
-
__isDayDisabled(date, minDate, maxDate) {
|
|
151
|
-
return !dateAllowed(date, minDate, maxDate);
|
|
150
|
+
__isDayDisabled(date, minDate, maxDate, isDateDisabled) {
|
|
151
|
+
return !dateAllowed(date, minDate, maxDate, isDateDisabled);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/** @private */
|
|
155
|
-
__getDayAriaDisabled(date, min, max) {
|
|
156
|
-
if (date === undefined || min === undefined
|
|
155
|
+
__getDayAriaDisabled(date, min, max, isDateDisabled) {
|
|
156
|
+
if (date === undefined || (min === undefined && max === undefined && isDateDisabled === undefined)) {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
if (this.__isDayDisabled(date, min, max)) {
|
|
160
|
+
if (this.__isDayDisabled(date, min, max, isDateDisabled)) {
|
|
161
161
|
return 'true';
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
2
|
+
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
3
|
+
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
|
+
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
|
+
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
+
import '@vaadin/button/theme/lumo/vaadin-button-styles.js';
|
|
7
|
+
import './vaadin-date-picker-year-styles.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '@vaadin/vaadin-material-styles/color.js';
|
|
2
|
+
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
3
|
+
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
|
+
import '@vaadin/vaadin-material-styles/shadow.js';
|
|
5
|
+
import '@vaadin/button/theme/material/vaadin-button-styles.js';
|
|
6
|
+
import './vaadin-date-picker-year-styles.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@vaadin/vaadin-material-styles/typography.js';
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "24.4.0-
|
|
4
|
+
"version": "24.4.0-alpha6",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -298,6 +298,16 @@
|
|
|
298
298
|
]
|
|
299
299
|
}
|
|
300
300
|
},
|
|
301
|
+
{
|
|
302
|
+
"name": "isDateDisabled",
|
|
303
|
+
"description": "A function to be used to determine whether the user can select a given date.\nReceives a `DatePickerDate` object of the date to be selected and should return a\nboolean.",
|
|
304
|
+
"value": {
|
|
305
|
+
"type": [
|
|
306
|
+
"function DatePickerDate: boolean",
|
|
307
|
+
"undefined"
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
},
|
|
301
311
|
{
|
|
302
312
|
"name": "attrForValue",
|
|
303
313
|
"description": "Name of the two-way data-bindable property representing the\nvalue of the custom input field.",
|
|
@@ -334,7 +344,7 @@
|
|
|
334
344
|
},
|
|
335
345
|
{
|
|
336
346
|
"name": "vaadin-date-picker",
|
|
337
|
-
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-
|
|
347
|
+
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------------|--------------------\n`toggle-button` | Toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n-----------|--------------------------------------------------|-----------\n`opened` | Set when the date selector overlay is opened | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-date-picker-light>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-date-picker-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-date-picker>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-overlay).\n- `<vaadin-date-picker-overlay-content>`\n- `<vaadin-date-picker-month-scroller>`\n- `<vaadin-date-picker-year-scroller>`\n- `<vaadin-date-picker-year>`\n- `<vaadin-month-calendar>`\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nIn order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`overlay-header` | Fullscreen mode header\n`label` | Fullscreen mode value/label\n`clear-button` | Fullscreen mode clear button\n`toggle-button` | Fullscreen mode toggle button\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Footer bar with slotted buttons\n\nThe following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:\n\nAttribute | Description\n----------------|-------------------------------------------------\n`desktop` | Set when the overlay content is in desktop mode\n`fullscreen` | Set when the overlay content is in fullscreen mode\n`years-visible` | Set when the year scroller is visible in fullscreen mode\n\nIn order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`month-header` | Month title\n`weekdays` | Weekday container\n`weekday` | Weekday element\n`week-numbers` | Week numbers container\n`week-number` | Week number element\n`date` | Date element\n`disabled` | Disabled date element\n`focused` | Focused date element\n`selected` | Selected date element\n`today` | Date element corresponding to the current day\n\nIn order to style year scroller elements, use `<vaadin-date-picker-year>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`year-number` | Year number\n`year-separator` | Year separator\n\nNote: the `theme` attribute value set on `<vaadin-date-picker>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Change events\n\nDepending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,\nthe component can fire either a `change` event or an `unparsable-change` event:\n\nValue change | Event\n:------------------------|:------------------\nempty => parsable | change\nempty => unparsable | unparsable-change\nparsable => empty | change\nparsable => parsable | change\nparsable => unparsable | change\nunparsable => empty | unparsable-change\nunparsable => parsable | change\nunparsable => unparsable | unparsable-change",
|
|
338
348
|
"attributes": [
|
|
339
349
|
{
|
|
340
350
|
"name": "disabled",
|
|
@@ -878,6 +888,16 @@
|
|
|
878
888
|
"undefined"
|
|
879
889
|
]
|
|
880
890
|
}
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
"name": "isDateDisabled",
|
|
894
|
+
"description": "A function to be used to determine whether the user can select a given date.\nReceives a `DatePickerDate` object of the date to be selected and should return a\nboolean.",
|
|
895
|
+
"value": {
|
|
896
|
+
"type": [
|
|
897
|
+
"function DatePickerDate: boolean",
|
|
898
|
+
"undefined"
|
|
899
|
+
]
|
|
900
|
+
}
|
|
881
901
|
}
|
|
882
902
|
],
|
|
883
903
|
"events": [
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "24.4.0-
|
|
4
|
+
"version": "24.4.0-alpha6",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -68,6 +68,13 @@
|
|
|
68
68
|
"kind": "expression"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
+
{
|
|
72
|
+
"name": "?isDateDisabled",
|
|
73
|
+
"description": "A function to be used to determine whether the user can select a given date.\nReceives a `DatePickerDate` object of the date to be selected and should return a\nboolean.",
|
|
74
|
+
"value": {
|
|
75
|
+
"kind": "expression"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
71
78
|
{
|
|
72
79
|
"name": ".value",
|
|
73
80
|
"description": "Selected date.\n\nSupported date formats:\n- ISO 8601 `\"YYYY-MM-DD\"` (default)\n- 6-digit extended ISO 8601 `\"+YYYYYY-MM-DD\"`, `\"-YYYYYY-MM-DD\"`",
|
|
@@ -156,7 +163,7 @@
|
|
|
156
163
|
},
|
|
157
164
|
{
|
|
158
165
|
"name": "vaadin-date-picker",
|
|
159
|
-
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-
|
|
166
|
+
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------------|--------------------\n`toggle-button` | Toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n-----------|--------------------------------------------------|-----------\n`opened` | Set when the date selector overlay is opened | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-date-picker-light>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-date-picker-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-date-picker>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-overlay).\n- `<vaadin-date-picker-overlay-content>`\n- `<vaadin-date-picker-month-scroller>`\n- `<vaadin-date-picker-year-scroller>`\n- `<vaadin-date-picker-year>`\n- `<vaadin-month-calendar>`\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha6/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nIn order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`overlay-header` | Fullscreen mode header\n`label` | Fullscreen mode value/label\n`clear-button` | Fullscreen mode clear button\n`toggle-button` | Fullscreen mode toggle button\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Footer bar with slotted buttons\n\nThe following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:\n\nAttribute | Description\n----------------|-------------------------------------------------\n`desktop` | Set when the overlay content is in desktop mode\n`fullscreen` | Set when the overlay content is in fullscreen mode\n`years-visible` | Set when the year scroller is visible in fullscreen mode\n\nIn order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`month-header` | Month title\n`weekdays` | Weekday container\n`weekday` | Weekday element\n`week-numbers` | Week numbers container\n`week-number` | Week number element\n`date` | Date element\n`disabled` | Disabled date element\n`focused` | Focused date element\n`selected` | Selected date element\n`today` | Date element corresponding to the current day\n\nIn order to style year scroller elements, use `<vaadin-date-picker-year>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`year-number` | Year number\n`year-separator` | Year separator\n\nNote: the `theme` attribute value set on `<vaadin-date-picker>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Change events\n\nDepending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,\nthe component can fire either a `change` event or an `unparsable-change` event:\n\nValue change | Event\n:------------------------|:------------------\nempty => parsable | change\nempty => unparsable | unparsable-change\nparsable => empty | change\nparsable => parsable | change\nparsable => unparsable | change\nunparsable => empty | unparsable-change\nunparsable => parsable | change\nunparsable => unparsable | unparsable-change",
|
|
160
167
|
"extension": true,
|
|
161
168
|
"attributes": [
|
|
162
169
|
{
|
|
@@ -229,6 +236,13 @@
|
|
|
229
236
|
"kind": "expression"
|
|
230
237
|
}
|
|
231
238
|
},
|
|
239
|
+
{
|
|
240
|
+
"name": "?isDateDisabled",
|
|
241
|
+
"description": "A function to be used to determine whether the user can select a given date.\nReceives a `DatePickerDate` object of the date to be selected and should return a\nboolean.",
|
|
242
|
+
"value": {
|
|
243
|
+
"kind": "expression"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
232
246
|
{
|
|
233
247
|
"name": ".label",
|
|
234
248
|
"description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
|