@vaadin/date-picker 25.3.0-alpha12 → 25.3.0-alpha14
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-alpha14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "25.3.0-
|
|
39
|
-
"@vaadin/button": "25.3.0-
|
|
40
|
-
"@vaadin/component-base": "25.3.0-
|
|
41
|
-
"@vaadin/field-base": "25.3.0-
|
|
42
|
-
"@vaadin/input-container": "25.3.0-
|
|
43
|
-
"@vaadin/overlay": "25.3.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
38
|
+
"@vaadin/a11y-base": "25.3.0-alpha14",
|
|
39
|
+
"@vaadin/button": "25.3.0-alpha14",
|
|
40
|
+
"@vaadin/component-base": "25.3.0-alpha14",
|
|
41
|
+
"@vaadin/field-base": "25.3.0-alpha14",
|
|
42
|
+
"@vaadin/input-container": "25.3.0-alpha14",
|
|
43
|
+
"@vaadin/overlay": "25.3.0-alpha14",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-alpha14",
|
|
45
45
|
"lit": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vaadin/aura": "25.3.0-
|
|
49
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
50
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
48
|
+
"@vaadin/aura": "25.3.0-alpha14",
|
|
49
|
+
"@vaadin/chai-plugins": "25.3.0-alpha14",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.3.0-alpha14",
|
|
51
51
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-alpha14",
|
|
53
53
|
"sinon": "^22.0.0"
|
|
54
54
|
},
|
|
55
55
|
"customElements": "custom-elements.json",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"web-types.json",
|
|
58
58
|
"web-types.lit.json"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "10a01ae7a1e278af50eda7255dbb68dafc0e4caf"
|
|
61
61
|
}
|
|
@@ -6,19 +6,85 @@
|
|
|
6
6
|
import type { DateMetadataController } from './vaadin-date-metadata-controller.js';
|
|
7
7
|
import type { DatePickerDate } from './vaadin-date-picker-mixin.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Create a date at midnight in local time. Unlike `new Date(year, month, day)`,
|
|
11
|
+
* this supports years below 100, which the constructor maps into the 20th
|
|
12
|
+
* century. The month is assigned before the day so that the initial day of month
|
|
13
|
+
* (1) always exists in the target month.
|
|
14
|
+
*
|
|
15
|
+
* @param month Zero-based month, may be out of range to shift the year
|
|
16
|
+
* @param day May be `0` to select the last day of the previous month
|
|
17
|
+
*/
|
|
18
|
+
declare function createDate(year: number, month: number, day: number): Date;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the first day of the month the given date is in.
|
|
22
|
+
*/
|
|
23
|
+
declare function firstOfMonth(date: Date): Date;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the last day of the month the given date is in.
|
|
27
|
+
*/
|
|
28
|
+
declare function lastOfMonth(date: Date): Date;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the index of a month, counted from January of year 0. Reduces a month to a single
|
|
32
|
+
* integer, so a lookup builds no key and two months are adjacent when their indexes are.
|
|
33
|
+
*
|
|
34
|
+
* @param month Zero-based month
|
|
35
|
+
*/
|
|
36
|
+
declare function monthIndexOf(year: number, month: number): number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get the index of the month the given date is in.
|
|
40
|
+
*/
|
|
41
|
+
declare function monthIndex(date: Date): number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the first day of the month with the given index, inverting `monthIndexOf`. Counting from
|
|
45
|
+
* January of year 0 also inverts negative indexes, since `createDate` normalizes a month outside
|
|
46
|
+
* 0-11 into the year.
|
|
47
|
+
*/
|
|
48
|
+
declare function monthDate(index: number): Date;
|
|
49
|
+
|
|
9
50
|
/**
|
|
10
51
|
* Get ISO 8601 week number for the given date.
|
|
11
52
|
*
|
|
12
53
|
* @returns Week number
|
|
13
54
|
*/
|
|
14
|
-
declare function getISOWeekNumber(
|
|
55
|
+
declare function getISOWeekNumber(date: Date): number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new object with the same date, but sets the hours, minutes, seconds and milliseconds to 0.
|
|
59
|
+
*
|
|
60
|
+
* @param date in system timezone
|
|
61
|
+
* @returns The same date with time elements set to 0, in system timezone.
|
|
62
|
+
*/
|
|
63
|
+
declare function normalizeDate(date: Date): Date;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new object with the same date, but sets the hours, minutes, seconds and milliseconds to 0.
|
|
67
|
+
*
|
|
68
|
+
* Uses UTC date components to allow handling date instances independently of
|
|
69
|
+
* the system time-zone.
|
|
70
|
+
*
|
|
71
|
+
* @param date in UTC timezone
|
|
72
|
+
* @returns The same date with time elements set to 0, in UTC timezone.
|
|
73
|
+
*/
|
|
74
|
+
declare function normalizeUTCDate(date: Date): Date;
|
|
15
75
|
|
|
16
76
|
/**
|
|
17
77
|
* Check if two dates are equal.
|
|
18
78
|
*
|
|
19
79
|
* @returns True if the given date objects refer to the same date
|
|
20
80
|
*/
|
|
21
|
-
declare function dateEquals(date1: Date | null, date2: Date | null): boolean;
|
|
81
|
+
declare function dateEquals(date1: Date | null, date2: Date | null, normalizer?: (date: Date) => Date): boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Extracts the basic component parts of a date (day, month and year)
|
|
85
|
+
* to the expected format.
|
|
86
|
+
*/
|
|
87
|
+
declare function extractDateParts(date: Date): { day: number; month: number; year: number };
|
|
22
88
|
|
|
23
89
|
/**
|
|
24
90
|
* Check if the given date is in the range of allowed dates.
|
|
@@ -55,37 +121,85 @@ declare function dateSelectable(
|
|
|
55
121
|
declare function getClosestDate(date: Date, dates: Date[]): Date;
|
|
56
122
|
|
|
57
123
|
/**
|
|
58
|
-
*
|
|
59
|
-
* to the expected format.
|
|
124
|
+
* Get difference in months between today and given months value.
|
|
60
125
|
*/
|
|
61
|
-
declare function
|
|
126
|
+
declare function dateAfterXMonths(months: number): Date;
|
|
62
127
|
|
|
63
128
|
/**
|
|
64
|
-
*
|
|
129
|
+
* Calculate the year of the date based on the provided reference date.
|
|
130
|
+
* Gets a two-digit year and returns a full year.
|
|
131
|
+
*
|
|
132
|
+
* @param year Should be in the range of [0, 99]
|
|
133
|
+
* @returns Adjusted year value
|
|
65
134
|
*/
|
|
66
|
-
declare function
|
|
135
|
+
declare function getAdjustedYear(referenceDate: Date, year: number, month?: number, day?: number): number;
|
|
67
136
|
|
|
68
137
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
138
|
+
* Parse date string of one of the following date formats:
|
|
139
|
+
* - ISO 8601 `"YYYY-MM-DD"`
|
|
140
|
+
* - Extended ISO 8601 with a signed year, e.g. `"+012026-MM-DD"` or `"-0001-MM-DD"`
|
|
141
|
+
*
|
|
142
|
+
* A date that does not exist, such as `"2026-02-30"`, is not parsed. Building it would carry the
|
|
143
|
+
* surplus into the next month or year and answer with a date that was never asked for.
|
|
144
|
+
*
|
|
145
|
+
* @param str Date string to parse
|
|
146
|
+
* @returns Parsed date in system timezone, or `undefined` when the string is not a date
|
|
71
147
|
*/
|
|
72
|
-
declare function
|
|
148
|
+
declare function parseDate(str: string): Date | undefined;
|
|
73
149
|
|
|
74
150
|
/**
|
|
75
151
|
* Parse date string of one of the following date formats:
|
|
76
152
|
* - ISO 8601 `"YYYY-MM-DD"`
|
|
77
|
-
* -
|
|
153
|
+
* - Extended ISO 8601 with a signed year, e.g. `"+012026-MM-DD"` or `"-0001-MM-DD"`
|
|
154
|
+
*
|
|
155
|
+
* Uses UTC date components to allow handling date instances independently of
|
|
156
|
+
* the system time-zone.
|
|
157
|
+
*
|
|
158
|
+
* A date that does not exist, such as `"2026-02-30"`, is not parsed, as in `parseDate`.
|
|
159
|
+
*
|
|
160
|
+
* @param str Date string to parse
|
|
161
|
+
* @returns Parsed date in UTC timezone, or `undefined` when the string is not a date
|
|
162
|
+
*/
|
|
163
|
+
declare function parseUTCDate(str: string): Date | undefined;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Format a date instance in ISO 8601 (`"YYYY-MM-DD"`) or 6-digit extended ISO
|
|
167
|
+
* 8601 (`"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`) format.
|
|
168
|
+
*
|
|
169
|
+
* @param date in system timezone
|
|
78
170
|
*/
|
|
79
|
-
declare function
|
|
171
|
+
declare function formatISODate(date: Date): string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Format a date instance in ISO 8601 (`"YYYY-MM-DD"`) or 6-digit extended ISO
|
|
175
|
+
* 8601 (`"+YYYYYY-MM-DD"`, `"-YYYYYY-MM-DD"`) format.
|
|
176
|
+
*
|
|
177
|
+
* Uses UTC date components to allow handling date instances independently of
|
|
178
|
+
* the system time-zone.
|
|
179
|
+
*
|
|
180
|
+
* @param date in UTC timezone
|
|
181
|
+
*/
|
|
182
|
+
declare function formatUTCISODate(date: Date): string;
|
|
80
183
|
|
|
81
184
|
export {
|
|
185
|
+
createDate,
|
|
186
|
+
firstOfMonth,
|
|
187
|
+
lastOfMonth,
|
|
188
|
+
monthIndexOf,
|
|
189
|
+
monthIndex,
|
|
190
|
+
monthDate,
|
|
82
191
|
getISOWeekNumber,
|
|
192
|
+
normalizeDate,
|
|
193
|
+
normalizeUTCDate,
|
|
83
194
|
dateEquals,
|
|
195
|
+
extractDateParts,
|
|
84
196
|
dateAllowed,
|
|
85
197
|
dateSelectable,
|
|
86
198
|
getClosestDate,
|
|
87
|
-
extractDateParts,
|
|
88
199
|
dateAfterXMonths,
|
|
89
200
|
getAdjustedYear,
|
|
90
201
|
parseDate,
|
|
202
|
+
parseUTCDate,
|
|
203
|
+
formatISODate,
|
|
204
|
+
formatUTCISODate,
|
|
91
205
|
};
|
|
@@ -459,7 +459,10 @@ export const DatePickerMixin = (subclass) =>
|
|
|
459
459
|
super._onFocus(event);
|
|
460
460
|
|
|
461
461
|
if (this._noInput && !isKeyboardActive()) {
|
|
462
|
+
// Blur to hide the virtual keyboard, but do not validate.
|
|
463
|
+
this.__ignoreInternalBlur = true;
|
|
462
464
|
event.target.blur();
|
|
465
|
+
this.__ignoreInternalBlur = false;
|
|
463
466
|
}
|
|
464
467
|
}
|
|
465
468
|
|
|
@@ -470,6 +473,10 @@ export const DatePickerMixin = (subclass) =>
|
|
|
470
473
|
_onBlur(event) {
|
|
471
474
|
super._onBlur(event);
|
|
472
475
|
|
|
476
|
+
if (this.__ignoreInternalBlur) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
473
480
|
if (!this.opened) {
|
|
474
481
|
this.__commitParsedOrFocusedDate();
|
|
475
482
|
|
|
@@ -37,6 +37,10 @@ template.innerHTML = `
|
|
|
37
37
|
box-sizing: border-box;
|
|
38
38
|
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
::slotted(div) {
|
|
42
|
+
height: var(--vaadin-infinite-scroller-item-height);
|
|
43
|
+
}
|
|
40
44
|
</style>
|
|
41
45
|
|
|
42
46
|
<div id="scroller" tabindex="-1">
|
|
@@ -149,7 +153,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
149
153
|
this.$.scroller.scrollTop = this.itemHeight * (index - this._firstIndex) + this._buffers[0].translateY;
|
|
150
154
|
} else {
|
|
151
155
|
this._initialIndex = ~~index;
|
|
152
|
-
this.
|
|
156
|
+
this.reset();
|
|
153
157
|
this._scrollDisabled = true;
|
|
154
158
|
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
155
159
|
this._scrollDisabled = false;
|
|
@@ -235,7 +239,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
235
239
|
});
|
|
236
240
|
|
|
237
241
|
if (!this._buffers[0].translateY) {
|
|
238
|
-
this.
|
|
242
|
+
this.reset();
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
this._initDone = true;
|
|
@@ -262,7 +266,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
262
266
|
if (scrollTop < this._bufferHeight || scrollTop > this._initialScroll * 2 - this._bufferHeight) {
|
|
263
267
|
// Scrolled near the end/beginning of the scrollable area -> reset.
|
|
264
268
|
this._initialIndex = ~~this.position;
|
|
265
|
-
this.
|
|
269
|
+
this.reset();
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
// Check if we scrolled enough to translate the buffer positions.
|
|
@@ -288,8 +292,18 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
288
292
|
});
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
/**
|
|
292
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Resets the scroller to the last starting index, and re-measures the
|
|
297
|
+
* item height in case the computed value of the CSS custom property
|
|
298
|
+
* has changed.
|
|
299
|
+
*/
|
|
300
|
+
reset() {
|
|
301
|
+
if (!this._activated || !this.isConnected) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
this._itemHeightVal = null;
|
|
306
|
+
|
|
293
307
|
this._scrollDisabled = true;
|
|
294
308
|
this.$.scroller.scrollTop = this._initialScroll;
|
|
295
309
|
this._buffers[0].translateY = this._initialScroll - this._bufferHeight;
|
|
@@ -314,7 +328,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
314
328
|
this._buffers.forEach((buffer) => {
|
|
315
329
|
for (let i = 0; i < this.bufferSize; i++) {
|
|
316
330
|
const itemWrapper = document.createElement('div');
|
|
317
|
-
itemWrapper.style.height = `${this.itemHeight}px`;
|
|
318
331
|
itemWrapper.instance = {};
|
|
319
332
|
|
|
320
333
|
const slotName = `vaadin-infinite-scroller-item-content-${generateUniqueId()}`;
|
package/web-types.json
CHANGED
package/web-types.lit.json
CHANGED