@vaadin/date-picker 23.3.0-alpha3 → 23.3.0-alpha4
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 +10 -10
- package/src/vaadin-date-picker-helper.d.ts +17 -0
- package/src/vaadin-date-picker-helper.js +47 -0
- package/src/vaadin-date-picker-mixin.d.ts +11 -0
- package/src/vaadin-date-picker-mixin.js +30 -26
- package/src/vaadin-date-picker-overlay-content.js +70 -20
- package/src/vaadin-date-picker-overlay.js +4 -4
- package/src/vaadin-date-picker-styles.js +0 -5
- package/src/vaadin-infinite-scroller.js +41 -10
- package/src/vaadin-month-calendar.js +0 -6
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +2 -2
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +1 -5
- package/theme/material/vaadin-date-picker-overlay-styles.js +1 -1
- package/web-types.json +4 -4
- package/web-types.lit.json +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "23.3.0-
|
|
3
|
+
"version": "23.3.0-alpha4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.2.0",
|
|
39
|
-
"@vaadin/button": "23.3.0-
|
|
40
|
-
"@vaadin/component-base": "23.3.0-
|
|
41
|
-
"@vaadin/field-base": "23.3.0-
|
|
42
|
-
"@vaadin/input-container": "23.3.0-
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/vaadin-
|
|
45
|
-
"@vaadin/vaadin-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "23.3.0-
|
|
39
|
+
"@vaadin/button": "23.3.0-alpha4",
|
|
40
|
+
"@vaadin/component-base": "23.3.0-alpha4",
|
|
41
|
+
"@vaadin/field-base": "23.3.0-alpha4",
|
|
42
|
+
"@vaadin/input-container": "23.3.0-alpha4",
|
|
43
|
+
"@vaadin/overlay": "23.3.0-alpha4",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha4",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha4",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "da037c0aa36e4b2874f253967300f6ca1af27315"
|
|
58
58
|
}
|
|
@@ -41,3 +41,20 @@ export { extractDateParts };
|
|
|
41
41
|
* to the expected format.
|
|
42
42
|
*/
|
|
43
43
|
declare function extractDateParts(date: Date): { day: number; month: number; year: number };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Calculate the year of the date based on the provided reference date
|
|
47
|
+
* Gets a two-digit year and returns a full year.
|
|
48
|
+
*/
|
|
49
|
+
declare function getAdjustedYear(referenceDate: Date, year: number, month?: number, day?: number): Date;
|
|
50
|
+
|
|
51
|
+
export { getAdjustedYear };
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Parse date string of one of the following date formats:
|
|
55
|
+
* - ISO 8601 `"YYYY-MM-DD"`
|
|
56
|
+
* - 6-digit extended ISO 8601 `"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`
|
|
57
|
+
*/
|
|
58
|
+
declare function parseDate(str: string): Date;
|
|
59
|
+
|
|
60
|
+
export { parseDate };
|
|
@@ -103,3 +103,50 @@ export function extractDateParts(date) {
|
|
|
103
103
|
year: date.getFullYear(),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Calculate the year of the date based on the provided reference date.
|
|
109
|
+
* Gets a two-digit year and returns a full year.
|
|
110
|
+
* @param {!Date} referenceDate The date to act as basis in the calculation
|
|
111
|
+
* @param {!number} year Should be in the range of [0, 99]
|
|
112
|
+
* @param {number} month
|
|
113
|
+
* @param {number} day
|
|
114
|
+
* @return {!number} Adjusted year value
|
|
115
|
+
*/
|
|
116
|
+
export function getAdjustedYear(referenceDate, year, month = 0, day = 1) {
|
|
117
|
+
if (year > 99) {
|
|
118
|
+
throw new Error('The provided year cannot have more than 2 digits.');
|
|
119
|
+
}
|
|
120
|
+
if (year < 0) {
|
|
121
|
+
throw new Error('The provided year cannot be negative.');
|
|
122
|
+
}
|
|
123
|
+
// Year values up to 2 digits are parsed based on the reference date.
|
|
124
|
+
let adjustedYear = year + Math.floor(referenceDate.getFullYear() / 100) * 100;
|
|
125
|
+
if (referenceDate < new Date(adjustedYear - 50, month, day)) {
|
|
126
|
+
adjustedYear -= 100;
|
|
127
|
+
} else if (referenceDate > new Date(adjustedYear + 50, month, day)) {
|
|
128
|
+
adjustedYear += 100;
|
|
129
|
+
}
|
|
130
|
+
return adjustedYear;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Parse date string of one of the following date formats:
|
|
135
|
+
* - ISO 8601 `"YYYY-MM-DD"`
|
|
136
|
+
* - 6-digit extended ISO 8601 `"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`
|
|
137
|
+
* @param {!string} str Date string to parse
|
|
138
|
+
* @return {Date} Parsed date
|
|
139
|
+
*/
|
|
140
|
+
export function parseDate(str) {
|
|
141
|
+
// Parsing with RegExp to ensure correct format
|
|
142
|
+
const parts = /^([-+]\d{1}|\d{2,4}|[-+]\d{6})-(\d{1,2})-(\d{1,2})$/.exec(str);
|
|
143
|
+
if (!parts) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const date = new Date(0, 0); // Wrong date (1900-01-01), but with midnight in local time
|
|
148
|
+
date.setFullYear(parseInt(parts[1], 10));
|
|
149
|
+
date.setMonth(parseInt(parts[2], 10) - 1);
|
|
150
|
+
date.setDate(parseInt(parts[3], 10));
|
|
151
|
+
return date;
|
|
152
|
+
}
|
|
@@ -26,6 +26,7 @@ export interface DatePickerI18n {
|
|
|
26
26
|
calendar: string;
|
|
27
27
|
today: string;
|
|
28
28
|
cancel: string;
|
|
29
|
+
referenceDate: string;
|
|
29
30
|
parseDate(date: string): DatePickerDate | undefined;
|
|
30
31
|
formatDate(date: DatePickerDate): string;
|
|
31
32
|
formatTitle(monthName: string, fullYear: number): string;
|
|
@@ -134,6 +135,16 @@ export declare class DatePickerMixinClass {
|
|
|
134
135
|
* // Translation of the Cancel button text.
|
|
135
136
|
* cancel: 'Cancel',
|
|
136
137
|
*
|
|
138
|
+
* // Used for adjusting the year value when parsing dates with short years.
|
|
139
|
+
* // The year values between 0 and 99 are evaluated and adjusted.
|
|
140
|
+
* // Example: for a referenceDate of 1970-10-30;
|
|
141
|
+
* // dateToBeParsed: 40-10-30, result: 1940-10-30
|
|
142
|
+
* // dateToBeParsed: 80-10-30, result: 1980-10-30
|
|
143
|
+
* // dateToBeParsed: 10-10-30, result: 2010-10-30
|
|
144
|
+
* // Supported date format: ISO 8601 `"YYYY-MM-DD"` (default)
|
|
145
|
+
* // The default value is the current date.
|
|
146
|
+
* referenceDate: '',
|
|
147
|
+
*
|
|
137
148
|
* // A function to format given `Object` as
|
|
138
149
|
* // date string. Object is in the format `{ day: ..., month: ..., year: ... }`
|
|
139
150
|
* // Note: The argument month is 0-based. This means that January = 0 and December = 11.
|
|
@@ -10,7 +10,14 @@ import { MediaQueryController } from '@vaadin/component-base/src/media-query-con
|
|
|
10
10
|
import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
11
11
|
import { InputConstraintsMixin } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
12
12
|
import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
dateAllowed,
|
|
15
|
+
dateEquals,
|
|
16
|
+
extractDateParts,
|
|
17
|
+
getAdjustedYear,
|
|
18
|
+
getClosestDate,
|
|
19
|
+
parseDate,
|
|
20
|
+
} from './vaadin-date-picker-helper.js';
|
|
14
21
|
|
|
15
22
|
/**
|
|
16
23
|
* @polymerMixin
|
|
@@ -158,6 +165,16 @@ export const DatePickerMixin = (subclass) =>
|
|
|
158
165
|
* // Translation of the Cancel button text.
|
|
159
166
|
* cancel: 'Cancel',
|
|
160
167
|
*
|
|
168
|
+
* // Used for adjusting the year value when parsing dates with short years.
|
|
169
|
+
* // The year values between 0 and 99 are evaluated and adjusted.
|
|
170
|
+
* // Example: for a referenceDate of 1970-10-30;
|
|
171
|
+
* // dateToBeParsed: 40-10-30, result: 1940-10-30
|
|
172
|
+
* // dateToBeParsed: 80-10-30, result: 1980-10-30
|
|
173
|
+
* // dateToBeParsed: 10-10-30, result: 2010-10-30
|
|
174
|
+
* // Supported date format: ISO 8601 `"YYYY-MM-DD"` (default)
|
|
175
|
+
* // The default value is the current date.
|
|
176
|
+
* referenceDate: '',
|
|
177
|
+
*
|
|
161
178
|
* // A function to format given `Object` as
|
|
162
179
|
* // date string. Object is in the format `{ day: ..., month: ..., year: ... }`
|
|
163
180
|
* // Note: The argument month is 0-based. This means that January = 0 and December = 11.
|
|
@@ -211,11 +228,12 @@ export const DatePickerMixin = (subclass) =>
|
|
|
211
228
|
calendar: 'Calendar',
|
|
212
229
|
today: 'Today',
|
|
213
230
|
cancel: 'Cancel',
|
|
214
|
-
|
|
231
|
+
referenceDate: '',
|
|
232
|
+
formatDate(d) {
|
|
215
233
|
const yearStr = String(d.year).replace(/\d+/, (y) => '0000'.substr(y.length) + y);
|
|
216
234
|
return [d.month + 1, d.day, yearStr].join('/');
|
|
217
235
|
},
|
|
218
|
-
parseDate
|
|
236
|
+
parseDate(text) {
|
|
219
237
|
const parts = text.split('/');
|
|
220
238
|
const today = new Date();
|
|
221
239
|
let date,
|
|
@@ -223,12 +241,13 @@ export const DatePickerMixin = (subclass) =>
|
|
|
223
241
|
year = today.getFullYear();
|
|
224
242
|
|
|
225
243
|
if (parts.length === 3) {
|
|
244
|
+
month = parseInt(parts[0]) - 1;
|
|
245
|
+
date = parseInt(parts[1]);
|
|
226
246
|
year = parseInt(parts[2]);
|
|
227
247
|
if (parts[2].length < 3 && year >= 0) {
|
|
228
|
-
|
|
248
|
+
const usedReferenceDate = this.referenceDate ? parseDate(this.referenceDate) : new Date();
|
|
249
|
+
year = getAdjustedYear(usedReferenceDate, year, month, date);
|
|
229
250
|
}
|
|
230
|
-
month = parseInt(parts[0]) - 1;
|
|
231
|
-
date = parseInt(parts[1]);
|
|
232
251
|
} else if (parts.length === 2) {
|
|
233
252
|
month = parseInt(parts[0]) - 1;
|
|
234
253
|
date = parseInt(parts[1]);
|
|
@@ -607,21 +626,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
607
626
|
});
|
|
608
627
|
}
|
|
609
628
|
|
|
610
|
-
/** @private */
|
|
611
|
-
_parseDate(str) {
|
|
612
|
-
// Parsing with RegExp to ensure correct format
|
|
613
|
-
const parts = /^([-+]\d{1}|\d{2,4}|[-+]\d{6})-(\d{1,2})-(\d{1,2})$/.exec(str);
|
|
614
|
-
if (!parts) {
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
const date = new Date(0, 0); // Wrong date (1900-01-01), but with midnight in local time
|
|
619
|
-
date.setFullYear(parseInt(parts[1], 10));
|
|
620
|
-
date.setMonth(parseInt(parts[2], 10) - 1);
|
|
621
|
-
date.setDate(parseInt(parts[3], 10));
|
|
622
|
-
return date;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
629
|
/** @private */
|
|
626
630
|
// eslint-disable-next-line max-params
|
|
627
631
|
_isNoInput(inputElement, fullscreen, ios, i18n, opened, autoOpenDisabled) {
|
|
@@ -737,7 +741,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
737
741
|
* @override
|
|
738
742
|
*/
|
|
739
743
|
_valueChanged(value, oldValue) {
|
|
740
|
-
const newDate =
|
|
744
|
+
const newDate = parseDate(value);
|
|
741
745
|
|
|
742
746
|
if (value && !newDate) {
|
|
743
747
|
// The new value cannot be parsed, revert the old value.
|
|
@@ -764,7 +768,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
764
768
|
|
|
765
769
|
/** @protected */
|
|
766
770
|
_onOverlayOpened() {
|
|
767
|
-
const parsedInitialPosition =
|
|
771
|
+
const parsedInitialPosition = parseDate(this.initialPosition);
|
|
768
772
|
|
|
769
773
|
const initialPosition =
|
|
770
774
|
this._selectedDate || this._overlayContent.initialPosition || parsedInitialPosition || new Date();
|
|
@@ -1049,7 +1053,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1049
1053
|
/** @private */
|
|
1050
1054
|
_getParsedDate(inputValue = this._inputValue) {
|
|
1051
1055
|
const dateObject = this.i18n.parseDate && this.i18n.parseDate(inputValue);
|
|
1052
|
-
const parsedDate = dateObject &&
|
|
1056
|
+
const parsedDate = dateObject && parseDate(`${dateObject.year}-${dateObject.month + 1}-${dateObject.day}`);
|
|
1053
1057
|
return parsedDate;
|
|
1054
1058
|
}
|
|
1055
1059
|
|
|
@@ -1071,7 +1075,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1071
1075
|
|
|
1072
1076
|
/** @private */
|
|
1073
1077
|
_userInputValueChanged() {
|
|
1074
|
-
if (this.
|
|
1078
|
+
if (this._inputValue) {
|
|
1075
1079
|
const parsedDate = this._getParsedDate();
|
|
1076
1080
|
|
|
1077
1081
|
if (this._isValidDate(parsedDate)) {
|
|
@@ -1091,7 +1095,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1091
1095
|
|
|
1092
1096
|
/** @private */
|
|
1093
1097
|
__computeMinOrMaxDate(dateString) {
|
|
1094
|
-
return
|
|
1098
|
+
return parseDate(dateString);
|
|
1095
1099
|
}
|
|
1096
1100
|
|
|
1097
1101
|
/**
|
|
@@ -297,6 +297,18 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
297
297
|
return this.getAttribute('dir') === 'rtl';
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Whether to scroll to a sub-month position when scrolling to a date.
|
|
302
|
+
* This is active if the month scroller is not large enough to fit a
|
|
303
|
+
* full month. In that case we want to scroll to a position between
|
|
304
|
+
* two months in order to have the focused date in the visible area.
|
|
305
|
+
* @returns {boolean} whether to use sub-month scrolling
|
|
306
|
+
* @private
|
|
307
|
+
*/
|
|
308
|
+
get __useSubMonthScrolling() {
|
|
309
|
+
return this.$.monthScroller.clientHeight < this.$.monthScroller.itemHeight + this.$.monthScroller.bufferOffset;
|
|
310
|
+
}
|
|
311
|
+
|
|
300
312
|
get calendars() {
|
|
301
313
|
return [...this.shadowRoot.querySelectorAll('vaadin-month-calendar')];
|
|
302
314
|
}
|
|
@@ -354,7 +366,9 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
354
366
|
* Scrolls the list to the given Date.
|
|
355
367
|
*/
|
|
356
368
|
scrollToDate(date, animate) {
|
|
357
|
-
this.
|
|
369
|
+
const offset = this.__useSubMonthScrolling ? this._calculateWeekScrollOffset(date) : 0;
|
|
370
|
+
this._scrollToPosition(this._differenceInMonths(date, this._originDate) + offset, animate);
|
|
371
|
+
this.$.monthScroller.forceUpdate();
|
|
358
372
|
}
|
|
359
373
|
|
|
360
374
|
/**
|
|
@@ -386,23 +400,63 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
386
400
|
* Scrolls the month and year scrollers enough to reveal the given date.
|
|
387
401
|
*/
|
|
388
402
|
revealDate(date, animate = true) {
|
|
389
|
-
if (date) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
if (!date) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const diff = this._differenceInMonths(date, this._originDate);
|
|
407
|
+
// If scroll area does not fit the full month, then always scroll with an offset to
|
|
408
|
+
// approximately display the week of the date
|
|
409
|
+
if (this.__useSubMonthScrolling) {
|
|
410
|
+
const offset = this._calculateWeekScrollOffset(date);
|
|
411
|
+
this._scrollToPosition(diff + offset, animate);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Otherwise determine if we need to scroll to make the month of the date visible
|
|
416
|
+
const scrolledAboveViewport = this.$.monthScroller.position > diff;
|
|
417
|
+
|
|
418
|
+
const visibleArea = Math.max(
|
|
419
|
+
this.$.monthScroller.itemHeight,
|
|
420
|
+
this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2,
|
|
421
|
+
);
|
|
422
|
+
const visibleItems = visibleArea / this.$.monthScroller.itemHeight;
|
|
423
|
+
const scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
|
|
424
|
+
|
|
425
|
+
if (scrolledAboveViewport) {
|
|
426
|
+
this._scrollToPosition(diff, animate);
|
|
427
|
+
} else if (scrolledBelowViewport) {
|
|
428
|
+
this._scrollToPosition(diff - visibleItems + 1, animate);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Calculates an offset to be added to the month scroll position
|
|
434
|
+
* when using sub-month scrolling, in order ensure that the week
|
|
435
|
+
* that the date is in is visible even for small scroll areas.
|
|
436
|
+
* As the month scroller uses a month as minimal scroll unit
|
|
437
|
+
* (a value of `1` equals one month), we can not exactly identify
|
|
438
|
+
* the position of a specific week. This is a best effort
|
|
439
|
+
* implementation based on manual testing.
|
|
440
|
+
* @param date the date for which to calculate the offset
|
|
441
|
+
* @returns {number} the offset
|
|
442
|
+
* @private
|
|
443
|
+
*/
|
|
444
|
+
_calculateWeekScrollOffset(date) {
|
|
445
|
+
// Get first day of month
|
|
446
|
+
const temp = new Date(0, 0);
|
|
447
|
+
temp.setFullYear(date.getFullYear());
|
|
448
|
+
temp.setMonth(date.getMonth());
|
|
449
|
+
temp.setDate(1);
|
|
450
|
+
// Determine week (=row index) of date within the month
|
|
451
|
+
let week = 0;
|
|
452
|
+
while (temp.getDate() < date.getDate()) {
|
|
453
|
+
temp.setDate(temp.getDate() + 1);
|
|
454
|
+
if (temp.getDay() === this.i18n.firstDayOfWeek) {
|
|
455
|
+
week += 1;
|
|
404
456
|
}
|
|
405
457
|
}
|
|
458
|
+
// Calculate magic number that approximately keeps the week visible
|
|
459
|
+
return week / 6;
|
|
406
460
|
}
|
|
407
461
|
|
|
408
462
|
_initialPositionChanged(initialPosition) {
|
|
@@ -667,10 +721,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
667
721
|
return months - date2.getMonth() + date1.getMonth();
|
|
668
722
|
}
|
|
669
723
|
|
|
670
|
-
_differenceInYears(date1, date2) {
|
|
671
|
-
return this._differenceInMonths(date1, date2) / 12;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
724
|
_clear() {
|
|
675
725
|
this._selectDate('');
|
|
676
726
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { DisableUpgradeMixin } from '@polymer/polymer/lib/mixins/disable-upgrade-mixin.js';
|
|
7
|
-
import {
|
|
8
|
-
import { PositionMixin } from '@vaadin/
|
|
7
|
+
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
8
|
+
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
9
9
|
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
import { datePickerOverlayStyles } from './vaadin-date-picker-styles.js';
|
|
11
11
|
|
|
@@ -18,10 +18,10 @@ let memoizedTemplate;
|
|
|
18
18
|
/**
|
|
19
19
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
20
20
|
*
|
|
21
|
-
* @extends
|
|
21
|
+
* @extends Overlay
|
|
22
22
|
* @private
|
|
23
23
|
*/
|
|
24
|
-
class DatePickerOverlay extends DisableUpgradeMixin(PositionMixin(
|
|
24
|
+
class DatePickerOverlay extends DisableUpgradeMixin(PositionMixin(Overlay)) {
|
|
25
25
|
static get is() {
|
|
26
26
|
return 'vaadin-date-picker-overlay';
|
|
27
27
|
}
|
|
@@ -10,11 +10,6 @@ export const datePickerStyles = css`
|
|
|
10
10
|
direction: ltr;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
:host([dir='rtl']) [part='value']::placeholder {
|
|
14
|
-
direction: rtl;
|
|
15
|
-
text-align: left;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
:host([dir='rtl']) [part='input-field'] ::slotted(input)::placeholder {
|
|
19
14
|
direction: rtl;
|
|
20
15
|
text-align: left;
|
|
@@ -89,6 +89,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
89
89
|
/**
|
|
90
90
|
* The amount of initial scroll top. Needed in order for the
|
|
91
91
|
* user to be able to scroll backwards.
|
|
92
|
+
* @private
|
|
92
93
|
*/
|
|
93
94
|
_initialScroll: {
|
|
94
95
|
value: 500000,
|
|
@@ -96,17 +97,22 @@ class InfiniteScroller extends PolymerElement {
|
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* The index/position mapped at _initialScroll point.
|
|
100
|
+
* @private
|
|
99
101
|
*/
|
|
100
102
|
_initialIndex: {
|
|
101
103
|
value: 0,
|
|
102
104
|
},
|
|
103
105
|
|
|
106
|
+
/** @private */
|
|
104
107
|
_buffers: Array,
|
|
105
108
|
|
|
109
|
+
/** @private */
|
|
106
110
|
_preventScrollEvent: Boolean,
|
|
107
111
|
|
|
112
|
+
/** @private */
|
|
108
113
|
_mayHaveMomentum: Boolean,
|
|
109
114
|
|
|
115
|
+
/** @private */
|
|
110
116
|
_initialized: Boolean,
|
|
111
117
|
|
|
112
118
|
active: {
|
|
@@ -116,10 +122,11 @@ class InfiniteScroller extends PolymerElement {
|
|
|
116
122
|
};
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/** @protected */
|
|
119
126
|
ready() {
|
|
120
127
|
super.ready();
|
|
121
128
|
|
|
122
|
-
this._buffers =
|
|
129
|
+
this._buffers = [...this.shadowRoot.querySelectorAll('.buffer')];
|
|
123
130
|
|
|
124
131
|
this.$.fullHeight.style.height = `${this._initialScroll * 2}px`;
|
|
125
132
|
|
|
@@ -128,8 +135,8 @@ class InfiniteScroller extends PolymerElement {
|
|
|
128
135
|
forwardHostProp(prop, value) {
|
|
129
136
|
if (prop !== 'index') {
|
|
130
137
|
this._buffers.forEach((buffer) => {
|
|
131
|
-
[].forEach
|
|
132
|
-
|
|
138
|
+
[...buffer.children].forEach((slot) => {
|
|
139
|
+
slot._itemWrapper.instance[prop] = value;
|
|
133
140
|
});
|
|
134
141
|
});
|
|
135
142
|
}
|
|
@@ -143,6 +150,19 @@ class InfiniteScroller extends PolymerElement {
|
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Force the scroller to update clones after a reset, without
|
|
155
|
+
* waiting for the debouncer to resolve.
|
|
156
|
+
*/
|
|
157
|
+
forceUpdate() {
|
|
158
|
+
if (this._debouncerUpdateClones) {
|
|
159
|
+
this._buffers[0].updated = this._buffers[1].updated = false;
|
|
160
|
+
this._updateClones();
|
|
161
|
+
this._debouncerUpdateClones.cancel();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @private */
|
|
146
166
|
_activated(active) {
|
|
147
167
|
if (active && !this._initialized) {
|
|
148
168
|
this._createPool();
|
|
@@ -150,11 +170,14 @@ class InfiniteScroller extends PolymerElement {
|
|
|
150
170
|
}
|
|
151
171
|
}
|
|
152
172
|
|
|
173
|
+
/** @private */
|
|
153
174
|
_finishInit() {
|
|
154
175
|
if (!this._initDone) {
|
|
155
176
|
// Once the first set of items start fading in, stamp the rest
|
|
156
177
|
this._buffers.forEach((buffer) => {
|
|
157
|
-
[].forEach
|
|
178
|
+
[...buffer.children].forEach((slot) => {
|
|
179
|
+
this._ensureStampedInstance(slot._itemWrapper);
|
|
180
|
+
});
|
|
158
181
|
});
|
|
159
182
|
|
|
160
183
|
if (!this._buffers[0].translateY) {
|
|
@@ -165,6 +188,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
165
188
|
}
|
|
166
189
|
}
|
|
167
190
|
|
|
191
|
+
/** @private */
|
|
168
192
|
_translateBuffer(up) {
|
|
169
193
|
const index = up ? 1 : 0;
|
|
170
194
|
this._buffers[index].translateY = this._buffers[index ? 0 : 1].translateY + this._bufferHeight * (index ? -1 : 1);
|
|
@@ -173,6 +197,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
173
197
|
this._buffers.reverse();
|
|
174
198
|
}
|
|
175
199
|
|
|
200
|
+
/** @private */
|
|
176
201
|
_scroll() {
|
|
177
202
|
if (this._scrollDisabled) {
|
|
178
203
|
return;
|
|
@@ -269,10 +294,12 @@ class InfiniteScroller extends PolymerElement {
|
|
|
269
294
|
return this._itemHeightVal;
|
|
270
295
|
}
|
|
271
296
|
|
|
297
|
+
/** @private */
|
|
272
298
|
get _bufferHeight() {
|
|
273
299
|
return this.itemHeight * this.bufferSize;
|
|
274
300
|
}
|
|
275
301
|
|
|
302
|
+
/** @private */
|
|
276
303
|
_reset() {
|
|
277
304
|
this._scrollDisabled = true;
|
|
278
305
|
this.$.scroller.scrollTop = this._initialScroll;
|
|
@@ -292,6 +319,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
292
319
|
this._scrollDisabled = false;
|
|
293
320
|
}
|
|
294
321
|
|
|
322
|
+
/** @private */
|
|
295
323
|
_createPool() {
|
|
296
324
|
const container = this.getBoundingClientRect();
|
|
297
325
|
this._buffers.forEach((buffer) => {
|
|
@@ -303,10 +331,10 @@ class InfiniteScroller extends PolymerElement {
|
|
|
303
331
|
const contentId = (InfiniteScroller._contentIndex = InfiniteScroller._contentIndex + 1 || 0);
|
|
304
332
|
const slotName = `vaadin-infinite-scroller-item-content-${contentId}`;
|
|
305
333
|
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
buffer.appendChild(
|
|
334
|
+
const slot = document.createElement('slot');
|
|
335
|
+
slot.setAttribute('name', slotName);
|
|
336
|
+
slot._itemWrapper = itemWrapper;
|
|
337
|
+
buffer.appendChild(slot);
|
|
310
338
|
|
|
311
339
|
itemWrapper.setAttribute('slot', slotName);
|
|
312
340
|
this.appendChild(itemWrapper);
|
|
@@ -325,6 +353,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
325
353
|
}, 1);
|
|
326
354
|
}
|
|
327
355
|
|
|
356
|
+
/** @private */
|
|
328
357
|
_ensureStampedInstance(itemWrapper) {
|
|
329
358
|
if (itemWrapper.firstElementChild) {
|
|
330
359
|
return;
|
|
@@ -340,6 +369,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
340
369
|
});
|
|
341
370
|
}
|
|
342
371
|
|
|
372
|
+
/** @private */
|
|
343
373
|
_updateClones(viewPortOnly) {
|
|
344
374
|
this._firstIndex = ~~((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex;
|
|
345
375
|
|
|
@@ -348,8 +378,8 @@ class InfiniteScroller extends PolymerElement {
|
|
|
348
378
|
if (!buffer.updated) {
|
|
349
379
|
const firstIndex = this._firstIndex + this.bufferSize * bufferIndex;
|
|
350
380
|
|
|
351
|
-
[].forEach
|
|
352
|
-
const itemWrapper =
|
|
381
|
+
[...buffer.children].forEach((slot, index) => {
|
|
382
|
+
const itemWrapper = slot._itemWrapper;
|
|
353
383
|
if (!viewPortOnly || this._isVisible(itemWrapper, scrollerRect)) {
|
|
354
384
|
itemWrapper.instance.index = firstIndex + index;
|
|
355
385
|
}
|
|
@@ -359,6 +389,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
359
389
|
});
|
|
360
390
|
}
|
|
361
391
|
|
|
392
|
+
/** @private */
|
|
362
393
|
_isVisible(element, container) {
|
|
363
394
|
const rect = element.getBoundingClientRect();
|
|
364
395
|
return rect.bottom > container.top && rect.top < container.bottom;
|
|
@@ -428,12 +428,6 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
428
428
|
|
|
429
429
|
return '-1';
|
|
430
430
|
}
|
|
431
|
-
|
|
432
|
-
__getWeekNumbers(dates) {
|
|
433
|
-
return dates
|
|
434
|
-
.map((date) => this.__getWeekNumber(date, dates))
|
|
435
|
-
.filter((week, index, arr) => arr.indexOf(week) === index);
|
|
436
|
-
}
|
|
437
431
|
}
|
|
438
432
|
|
|
439
433
|
customElements.define(MonthCalendar.is, MonthCalendar);
|
|
@@ -36,7 +36,7 @@ registerStyles(
|
|
|
36
36
|
+ var(--lumo-size-m) * 6
|
|
37
37
|
+ var(--lumo-space-s)
|
|
38
38
|
);
|
|
39
|
-
--vaadin-infinite-scroller-buffer-offset:
|
|
39
|
+
--vaadin-infinite-scroller-buffer-offset: 10%;
|
|
40
40
|
-webkit-mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
41
41
|
mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
42
42
|
position: relative;
|
|
@@ -171,7 +171,7 @@ registerStyles(
|
|
|
171
171
|
color: var(--lumo-primary-contrast-color);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
/* TODO magic number (same as used for
|
|
174
|
+
/* TODO magic number (same as used for media-query in vaadin-date-picker-overlay-content) */
|
|
175
175
|
@media screen and (max-width: 374px) {
|
|
176
176
|
:host {
|
|
177
177
|
background-image: none;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
2
2
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
3
|
-
import '@vaadin/
|
|
3
|
+
import '@vaadin/overlay/theme/lumo/vaadin-overlay.js';
|
|
4
4
|
import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
|
|
5
5
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ registerStyles(
|
|
|
9
9
|
'vaadin-date-picker-overlay-content',
|
|
10
10
|
css`
|
|
11
11
|
:host {
|
|
12
|
+
background: var(--material-background-color);
|
|
12
13
|
font-family: var(--material-font-family);
|
|
13
14
|
font-size: var(--material-body-font-size);
|
|
14
15
|
-webkit-text-size-adjust: 100%;
|
|
@@ -113,11 +114,6 @@ registerStyles(
|
|
|
113
114
|
background: var(--material-background-color);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
:host([years-visible]) [part='years']::after {
|
|
117
|
-
top: calc(20px + 16px);
|
|
118
|
-
height: calc(100% - 20px - 16px);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
117
|
[part='year-number'] {
|
|
122
118
|
font-size: var(--material-small-font-size);
|
|
123
119
|
line-height: 10px; /* NOTE(platosha): chosen to align years to months */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '@vaadin/
|
|
1
|
+
import '@vaadin/overlay/theme/material/vaadin-overlay.js';
|
|
2
2
|
import { overlay } from '@vaadin/vaadin-material-styles/mixins/overlay.js';
|
|
3
3
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
4
|
|
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": "23.3.0-
|
|
4
|
+
"version": "23.3.0-alpha4",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "i18n",
|
|
164
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
164
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Used for adjusting the year value when parsing dates with short years.\n // The year values between 0 and 99 are evaluated and adjusted.\n // Example: for a referenceDate of 1970-10-30;\n // dateToBeParsed: 40-10-30, result: 1940-10-30\n // dateToBeParsed: 80-10-30, result: 1980-10-30\n // dateToBeParsed: 10-10-30, result: 2010-10-30\n // Supported date format: ISO 8601 `\"YYYY-MM-DD\"` (default)\n // The default value is the current date.\n referenceDate: '',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
165
165
|
"value": {
|
|
166
166
|
"type": [
|
|
167
167
|
"DatePickerI18n"
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
},
|
|
217
217
|
{
|
|
218
218
|
"name": "vaadin-date-picker",
|
|
219
|
-
"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/23.3.0-
|
|
219
|
+
"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/23.3.0-alpha4/#/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`overlay-content` | The overlay element\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`today` | Set on the date corresponding to the current day | date\n`selected` | Set on the selected date | date\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/23.3.0-alpha4/#/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/23.3.0-alpha4/#/elements/vaadin-overlay).\n- `<vaadin-date-picker-overlay-content>`\n- `<vaadin-month-calendar>`\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha4/#/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`months` | Months scroller\n`years` | Years scroller\n`toolbar` | Footer bar with buttons\n`today-button` | Today button\n`cancel-button` | Cancel button\n`month` | Month calendar\n`year-number` | Year number\n`year-separator` | Year separator\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\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/custom-theme/styling-components) documentation.",
|
|
220
220
|
"attributes": [
|
|
221
221
|
{
|
|
222
222
|
"name": "disabled",
|
|
@@ -668,7 +668,7 @@
|
|
|
668
668
|
},
|
|
669
669
|
{
|
|
670
670
|
"name": "i18n",
|
|
671
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
671
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Used for adjusting the year value when parsing dates with short years.\n // The year values between 0 and 99 are evaluated and adjusted.\n // Example: for a referenceDate of 1970-10-30;\n // dateToBeParsed: 40-10-30, result: 1940-10-30\n // dateToBeParsed: 80-10-30, result: 1980-10-30\n // dateToBeParsed: 10-10-30, result: 2010-10-30\n // Supported date format: ISO 8601 `\"YYYY-MM-DD\"` (default)\n // The default value is the current date.\n referenceDate: '',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
672
672
|
"value": {
|
|
673
673
|
"type": [
|
|
674
674
|
"DatePickerI18n"
|
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": "23.3.0-
|
|
4
|
+
"version": "23.3.0-alpha4",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": ".i18n",
|
|
59
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
59
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Used for adjusting the year value when parsing dates with short years.\n // The year values between 0 and 99 are evaluated and adjusted.\n // Example: for a referenceDate of 1970-10-30;\n // dateToBeParsed: 40-10-30, result: 1940-10-30\n // dateToBeParsed: 80-10-30, result: 1980-10-30\n // dateToBeParsed: 10-10-30, result: 2010-10-30\n // Supported date format: ISO 8601 `\"YYYY-MM-DD\"` (default)\n // The default value is the current date.\n referenceDate: '',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
60
60
|
"value": {
|
|
61
61
|
"kind": "expression"
|
|
62
62
|
}
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
"name": "vaadin-date-picker",
|
|
110
|
-
"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/23.3.0-
|
|
110
|
+
"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/23.3.0-alpha4/#/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`overlay-content` | The overlay element\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`today` | Set on the date corresponding to the current day | date\n`selected` | Set on the selected date | date\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/23.3.0-alpha4/#/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/23.3.0-alpha4/#/elements/vaadin-overlay).\n- `<vaadin-date-picker-overlay-content>`\n- `<vaadin-month-calendar>`\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha4/#/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`months` | Months scroller\n`years` | Years scroller\n`toolbar` | Footer bar with buttons\n`today-button` | Today button\n`cancel-button` | Cancel button\n`month` | Month calendar\n`year-number` | Year number\n`year-separator` | Year separator\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\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/custom-theme/styling-components) documentation.",
|
|
111
111
|
"extension": true,
|
|
112
112
|
"attributes": [
|
|
113
113
|
{
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
"name": ".i18n",
|
|
248
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
248
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\ndatePicker.i18n = { ...datePicker.i18n, {\n formatDate: date => { ... },\n parseDate: value => { ... },\n}};\n```\n\nThe object has the following JSON structure and default values:\n\n```\n{\n // An array with the full names of months starting\n // with January.\n monthNames: [\n 'January', 'February', 'March', 'April', 'May',\n 'June', 'July', 'August', 'September',\n 'October', 'November', 'December'\n ],\n\n // An array of weekday names starting with Sunday. Used\n // in screen reader announcements.\n weekdays: [\n 'Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday'\n ],\n\n // An array of short weekday names starting with Sunday.\n // Displayed in the calendar.\n weekdaysShort: [\n 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'\n ],\n\n // An integer indicating the first day of the week\n // (0 = Sunday, 1 = Monday, etc.).\n firstDayOfWeek: 0,\n\n // Used in screen reader announcements along with week\n // numbers, if they are displayed.\n week: 'Week',\n\n // Translation of the Calendar icon button title.\n calendar: 'Calendar',\n\n // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Used for adjusting the year value when parsing dates with short years.\n // The year values between 0 and 99 are evaluated and adjusted.\n // Example: for a referenceDate of 1970-10-30;\n // dateToBeParsed: 40-10-30, result: 1940-10-30\n // dateToBeParsed: 80-10-30, result: 1980-10-30\n // dateToBeParsed: 10-10-30, result: 2010-10-30\n // Supported date format: ISO 8601 `\"YYYY-MM-DD\"` (default)\n // The default value is the current date.\n referenceDate: '',\n\n // A function to format given `Object` as\n // date string. Object is in the format `{ day: ..., month: ..., year: ... }`\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n formatDate: d => {\n // returns a string representation of the given\n // object in 'MM/DD/YYYY' -format\n },\n\n // A function to parse the given text to an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n // Must properly parse (at least) text formatted by `formatDate`.\n // Setting the property to null will disable keyboard input feature.\n // Note: The argument month is 0-based. This means that January = 0 and December = 11.\n parseDate: text => {\n // Parses a string in 'MM/DD/YY', 'MM/DD' or 'DD' -format to\n // an `Object` in the format `{ day: ..., month: ..., year: ... }`.\n }\n\n // A function to format given `monthName` and\n // `fullYear` integer as calendar title string.\n formatTitle: (monthName, fullYear) => {\n return monthName + ' ' + fullYear;\n }\n}\n```",
|
|
249
249
|
"value": {
|
|
250
250
|
"kind": "expression"
|
|
251
251
|
}
|