@vaadin/date-picker 25.3.0-dev.3a3c2d7d2a → 25.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +556 -205
- package/package.json +13 -13
- package/src/styles/vaadin-date-picker-overlay-content-base-styles.js +0 -3
- package/src/styles/vaadin-month-calendar-base-styles.js +3 -0
- package/src/vaadin-date-metadata-controller.d.ts +94 -0
- package/src/vaadin-date-metadata-controller.js +268 -0
- package/src/vaadin-date-picker-helper.d.ts +144 -13
- package/src/vaadin-date-picker-helper.js +119 -15
- package/src/vaadin-date-picker-mixin.d.ts +87 -15
- package/src/vaadin-date-picker-mixin.js +129 -121
- package/src/vaadin-date-picker-overlay-content-mixin.js +144 -163
- package/src/vaadin-date-picker-overlay-content.js +1 -0
- package/src/vaadin-date-picker-overlay.js +1 -0
- package/src/vaadin-date-picker-year.js +4 -1
- package/src/vaadin-date-picker.d.ts +73 -7
- package/src/vaadin-date-picker.js +67 -9
- package/src/vaadin-infinite-scroller.js +21 -6
- package/src/vaadin-month-calendar-mixin.js +43 -59
- package/src/vaadin-month-calendar.js +5 -0
- package/web-types.json +37 -21
- package/web-types.lit.json +18 -11
- package/src/vaadin-disabled-dates-controller.d.ts +0 -66
- package/src/vaadin-disabled-dates-controller.js +0 -241
|
@@ -36,12 +36,6 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
36
36
|
*
|
|
37
37
|
* ### Styling
|
|
38
38
|
*
|
|
39
|
-
* The following custom properties are available for styling:
|
|
40
|
-
*
|
|
41
|
-
* Custom property | Description | Default
|
|
42
|
-
* -------------------------------|----------------------------|---------
|
|
43
|
-
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
44
|
-
*
|
|
45
39
|
* The following shadow DOM parts are available for styling:
|
|
46
40
|
*
|
|
47
41
|
* Part name | Description
|
|
@@ -75,6 +69,69 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
75
69
|
* `opened` | Set when the overlay is opened
|
|
76
70
|
* `week-numbers` | Set when week numbers are shown in the calendar
|
|
77
71
|
*
|
|
72
|
+
* The following custom CSS properties are available for styling:
|
|
73
|
+
*
|
|
74
|
+
* Custom CSS property |
|
|
75
|
+
* :----------------------------------------------------------|
|
|
76
|
+
* | `--vaadin-date-picker-date-border-radius` |
|
|
77
|
+
* | `--vaadin-date-picker-date-disabled-color` |
|
|
78
|
+
* | `--vaadin-date-picker-date-height` |
|
|
79
|
+
* | `--vaadin-date-picker-date-selected-background` |
|
|
80
|
+
* | `--vaadin-date-picker-date-selected-color` |
|
|
81
|
+
* | `--vaadin-date-picker-date-today-color` |
|
|
82
|
+
* | `--vaadin-date-picker-date-width` |
|
|
83
|
+
* | `--vaadin-date-picker-month-header-color` |
|
|
84
|
+
* | `--vaadin-date-picker-month-header-font-size` |
|
|
85
|
+
* | `--vaadin-date-picker-month-header-font-weight` |
|
|
86
|
+
* | `--vaadin-date-picker-month-padding` |
|
|
87
|
+
* | `--vaadin-date-picker-overlay-max-height` |
|
|
88
|
+
* | `--vaadin-date-picker-overlay-width` |
|
|
89
|
+
* | `--vaadin-date-picker-toolbar-padding` |
|
|
90
|
+
* | `--vaadin-date-picker-week-divider-color` |
|
|
91
|
+
* | `--vaadin-date-picker-week-number-color` |
|
|
92
|
+
* | `--vaadin-date-picker-week-number-font-size` |
|
|
93
|
+
* | `--vaadin-date-picker-weekday-color` |
|
|
94
|
+
* | `--vaadin-date-picker-weekday-font-size` |
|
|
95
|
+
* | `--vaadin-date-picker-weekday-font-weight` |
|
|
96
|
+
* | `--vaadin-date-picker-year-scroller-background` |
|
|
97
|
+
* | `--vaadin-date-picker-year-scroller-border-color` |
|
|
98
|
+
* | `--vaadin-date-picker-year-scroller-current-year-color` |
|
|
99
|
+
* | `--vaadin-date-picker-year-scroller-width` |
|
|
100
|
+
* | `--vaadin-field-default-width` |
|
|
101
|
+
* | `--vaadin-input-field-background` |
|
|
102
|
+
* | `--vaadin-input-field-border-color` |
|
|
103
|
+
* | `--vaadin-input-field-border-radius` |
|
|
104
|
+
* | `--vaadin-input-field-border-width` |
|
|
105
|
+
* | `--vaadin-input-field-bottom-end-radius` |
|
|
106
|
+
* | `--vaadin-input-field-bottom-start-radius` |
|
|
107
|
+
* | `--vaadin-input-field-button-text-color` |
|
|
108
|
+
* | `--vaadin-input-field-container-gap` |
|
|
109
|
+
* | `--vaadin-input-field-disabled-background` |
|
|
110
|
+
* | `--vaadin-input-field-disabled-text-color` |
|
|
111
|
+
* | `--vaadin-input-field-error-color` |
|
|
112
|
+
* | `--vaadin-input-field-error-font-size` |
|
|
113
|
+
* | `--vaadin-input-field-error-font-weight` |
|
|
114
|
+
* | `--vaadin-input-field-error-line-height` |
|
|
115
|
+
* | `--vaadin-input-field-gap` |
|
|
116
|
+
* | `--vaadin-input-field-helper-color` |
|
|
117
|
+
* | `--vaadin-input-field-helper-font-size` |
|
|
118
|
+
* | `--vaadin-input-field-helper-font-weight` |
|
|
119
|
+
* | `--vaadin-input-field-helper-line-height` |
|
|
120
|
+
* | `--vaadin-input-field-label-color` |
|
|
121
|
+
* | `--vaadin-input-field-label-font-size` |
|
|
122
|
+
* | `--vaadin-input-field-label-font-weight` |
|
|
123
|
+
* | `--vaadin-input-field-label-line-height` |
|
|
124
|
+
* | `--vaadin-input-field-padding` |
|
|
125
|
+
* | `--vaadin-input-field-placeholder-color` |
|
|
126
|
+
* | `--vaadin-input-field-required-indicator` |
|
|
127
|
+
* | `--vaadin-input-field-required-indicator-color` |
|
|
128
|
+
* | `--vaadin-input-field-top-end-radius` |
|
|
129
|
+
* | `--vaadin-input-field-top-start-radius` |
|
|
130
|
+
* | `--vaadin-input-field-value-color` |
|
|
131
|
+
* | `--vaadin-input-field-value-font-size` |
|
|
132
|
+
* | `--vaadin-input-field-value-font-weight` |
|
|
133
|
+
* | `--vaadin-input-field-value-line-height` |
|
|
134
|
+
*
|
|
78
135
|
* ### Internal components
|
|
79
136
|
*
|
|
80
137
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
@@ -92,7 +149,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
92
149
|
* ----------------------|--------------------
|
|
93
150
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
94
151
|
* `toolbar` | Toolbar with slotted buttons
|
|
95
|
-
* `loader` | Loading spinner shown while
|
|
152
|
+
* `loader` | Loading spinner shown while the date metadata provider is resolving
|
|
96
153
|
*
|
|
97
154
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
98
155
|
*
|
|
@@ -101,7 +158,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
101
158
|
* `desktop` | Set when the overlay content is in desktop mode
|
|
102
159
|
* `fullscreen` | Set when the overlay content is in fullscreen mode
|
|
103
160
|
* `years-visible` | Set when the year scroller is visible in fullscreen mode
|
|
104
|
-
* `loading` | Set while
|
|
161
|
+
* `loading` | Set while the date metadata provider is resolving
|
|
105
162
|
*
|
|
106
163
|
* In order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:
|
|
107
164
|
*
|
|
@@ -114,7 +171,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
114
171
|
* `week-number` | Week number element
|
|
115
172
|
* `date` | Date element
|
|
116
173
|
* `disabled` | Disabled date element
|
|
117
|
-
* `
|
|
174
|
+
* `loading` | Date element in a month whose metadata is currently being fetched
|
|
118
175
|
* `focused` | Focused date element
|
|
119
176
|
* `selected` | Selected date element
|
|
120
177
|
* `today` | Date element corresponding to the current day
|
|
@@ -153,6 +210,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
153
210
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
154
211
|
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
155
212
|
*
|
|
213
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
156
214
|
* @customElement vaadin-date-picker
|
|
157
215
|
* @extends HTMLElement
|
|
158
216
|
*/
|
|
@@ -20,6 +20,8 @@ template.innerHTML = `
|
|
|
20
20
|
position: relative;
|
|
21
21
|
height: 100%;
|
|
22
22
|
overflow: auto;
|
|
23
|
+
/* Prevent browser scroll anchoring from overriding the virtual scroll position. */
|
|
24
|
+
overflow-anchor: none;
|
|
23
25
|
outline: none;
|
|
24
26
|
overflow-x: hidden;
|
|
25
27
|
scrollbar-width: none;
|
|
@@ -35,6 +37,10 @@ template.innerHTML = `
|
|
|
35
37
|
box-sizing: border-box;
|
|
36
38
|
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
::slotted(div) {
|
|
42
|
+
height: var(--vaadin-infinite-scroller-item-height);
|
|
43
|
+
}
|
|
38
44
|
</style>
|
|
39
45
|
|
|
40
46
|
<div id="scroller" tabindex="-1">
|
|
@@ -147,7 +153,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
147
153
|
this.$.scroller.scrollTop = this.itemHeight * (index - this._firstIndex) + this._buffers[0].translateY;
|
|
148
154
|
} else {
|
|
149
155
|
this._initialIndex = ~~index;
|
|
150
|
-
this.
|
|
156
|
+
this.reset();
|
|
151
157
|
this._scrollDisabled = true;
|
|
152
158
|
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
153
159
|
this._scrollDisabled = false;
|
|
@@ -233,7 +239,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
233
239
|
});
|
|
234
240
|
|
|
235
241
|
if (!this._buffers[0].translateY) {
|
|
236
|
-
this.
|
|
242
|
+
this.reset();
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
this._initDone = true;
|
|
@@ -260,7 +266,7 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
260
266
|
if (scrollTop < this._bufferHeight || scrollTop > this._initialScroll * 2 - this._bufferHeight) {
|
|
261
267
|
// Scrolled near the end/beginning of the scrollable area -> reset.
|
|
262
268
|
this._initialIndex = ~~this.position;
|
|
263
|
-
this.
|
|
269
|
+
this.reset();
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
// Check if we scrolled enough to translate the buffer positions.
|
|
@@ -286,8 +292,18 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
286
292
|
});
|
|
287
293
|
}
|
|
288
294
|
|
|
289
|
-
/**
|
|
290
|
-
|
|
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
|
+
|
|
291
307
|
this._scrollDisabled = true;
|
|
292
308
|
this.$.scroller.scrollTop = this._initialScroll;
|
|
293
309
|
this._buffers[0].translateY = this._initialScroll - this._bufferHeight;
|
|
@@ -312,7 +328,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
312
328
|
this._buffers.forEach((buffer) => {
|
|
313
329
|
for (let i = 0; i < this.bufferSize; i++) {
|
|
314
330
|
const itemWrapper = document.createElement('div');
|
|
315
|
-
itemWrapper.style.height = `${this.itemHeight}px`;
|
|
316
331
|
itemWrapper.instance = {};
|
|
317
332
|
|
|
318
333
|
const slotName = `vaadin-infinite-scroller-item-content-${generateUniqueId()}`;
|
|
@@ -4,8 +4,17 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
|
+
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
8
|
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
dateAllowed,
|
|
11
|
+
dateEquals,
|
|
12
|
+
dateSelectable,
|
|
13
|
+
firstOfMonth,
|
|
14
|
+
getISOWeekNumber,
|
|
15
|
+
lastOfMonth,
|
|
16
|
+
normalizeDate,
|
|
17
|
+
} from './vaadin-date-picker-helper.js';
|
|
9
18
|
|
|
10
19
|
export const MonthCalendarMixin = (superClass) =>
|
|
11
20
|
class MonthCalendarMixinClass extends FocusMixin(superClass) {
|
|
@@ -88,25 +97,15 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
88
97
|
},
|
|
89
98
|
|
|
90
99
|
/**
|
|
91
|
-
* The
|
|
92
|
-
* `
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
95
|
-
* @private
|
|
100
|
+
* The date-picker's controller resolving the metadata returned by its
|
|
101
|
+
* `dateMetadataProvider`. Assigned by the overlay content, which also subscribes this
|
|
102
|
+
* calendar to it.
|
|
103
|
+
* @protected
|
|
96
104
|
*/
|
|
97
|
-
|
|
105
|
+
_dateMetadataController: {
|
|
98
106
|
type: Object,
|
|
99
107
|
attribute: false,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Bumped by the overlay content whenever the controller's cache or loading state changes,
|
|
104
|
-
* to trigger a re-render of this month.
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
|
-
__disabledDatesVersion: {
|
|
108
|
-
type: Number,
|
|
109
|
-
attribute: false,
|
|
108
|
+
sync: true,
|
|
110
109
|
},
|
|
111
110
|
|
|
112
111
|
enteredDate: {
|
|
@@ -122,8 +121,7 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
122
121
|
/** @protected */
|
|
123
122
|
_days: {
|
|
124
123
|
type: Array,
|
|
125
|
-
computed:
|
|
126
|
-
'__computeDays(month, i18n, minDate, maxDate, isDateDisabled, disabledDatesController, __disabledDatesVersion)',
|
|
124
|
+
computed: '__computeDays(month, i18n, minDate, maxDate, isDateDisabled)',
|
|
127
125
|
},
|
|
128
126
|
|
|
129
127
|
/** @protected */
|
|
@@ -171,17 +169,8 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
171
169
|
* @protected
|
|
172
170
|
*/
|
|
173
171
|
__computeDisabled(month, minDate, maxDate) {
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
firstDate.setFullYear(month.getFullYear());
|
|
177
|
-
firstDate.setMonth(month.getMonth());
|
|
178
|
-
firstDate.setDate(1);
|
|
179
|
-
|
|
180
|
-
// Last day of the month
|
|
181
|
-
const lastDate = new Date(0, 0);
|
|
182
|
-
lastDate.setFullYear(month.getFullYear());
|
|
183
|
-
lastDate.setMonth(month.getMonth() + 1);
|
|
184
|
-
lastDate.setDate(0);
|
|
172
|
+
const firstDate = firstOfMonth(month);
|
|
173
|
+
const lastDate = lastOfMonth(month);
|
|
185
174
|
|
|
186
175
|
if (
|
|
187
176
|
minDate &&
|
|
@@ -248,11 +237,8 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
248
237
|
|
|
249
238
|
/** @private */
|
|
250
239
|
__focusedDateChanged(focusedDate, days) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} else {
|
|
254
|
-
this.setAttribute('aria-hidden', 'true');
|
|
255
|
-
}
|
|
240
|
+
const hasFocusedDate = Array.isArray(days) && days.some((date) => dateEquals(date, focusedDate));
|
|
241
|
+
setOrRemoveAttribute(this, 'aria-hidden', !hasFocusedDate);
|
|
256
242
|
}
|
|
257
243
|
|
|
258
244
|
/** @protected */
|
|
@@ -276,11 +262,7 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
276
262
|
if (month === undefined || i18n === undefined) {
|
|
277
263
|
return [];
|
|
278
264
|
}
|
|
279
|
-
|
|
280
|
-
const date = new Date(0, 0);
|
|
281
|
-
date.setFullYear(month.getFullYear());
|
|
282
|
-
date.setMonth(month.getMonth());
|
|
283
|
-
date.setDate(1);
|
|
265
|
+
const date = firstOfMonth(month);
|
|
284
266
|
|
|
285
267
|
// Rewind to first day of the week.
|
|
286
268
|
while (date.getDay() !== i18n.firstDayOfWeek) {
|
|
@@ -353,11 +335,7 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
353
335
|
|
|
354
336
|
/** @private */
|
|
355
337
|
_showWeekNumbersChanged(showWeekNumbers, i18n) {
|
|
356
|
-
|
|
357
|
-
this.setAttribute('week-numbers', '');
|
|
358
|
-
} else {
|
|
359
|
-
this.removeAttribute('week-numbers');
|
|
360
|
-
}
|
|
338
|
+
this.toggleAttribute('week-numbers', this.__computeShowWeekSeparator(showWeekNumbers, i18n));
|
|
361
339
|
}
|
|
362
340
|
|
|
363
341
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
@@ -368,8 +346,8 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
368
346
|
result.push('disabled');
|
|
369
347
|
}
|
|
370
348
|
|
|
371
|
-
if (date && this.
|
|
372
|
-
result.push('
|
|
349
|
+
if (date && this.__isMonthPending()) {
|
|
350
|
+
result.push('loading');
|
|
373
351
|
}
|
|
374
352
|
|
|
375
353
|
if (dateEquals(date, focusedDate) && (hasFocus || dateEquals(date, enteredDate))) {
|
|
@@ -392,6 +370,12 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
392
370
|
result.push('future');
|
|
393
371
|
}
|
|
394
372
|
|
|
373
|
+
// Only a string can name parts, so anything else the provider set is ignored.
|
|
374
|
+
const customParts = date && this._dateMetadataController?.getMetadata(date)?.part;
|
|
375
|
+
if (customParts && typeof customParts === 'string') {
|
|
376
|
+
result.push(customParts);
|
|
377
|
+
}
|
|
378
|
+
|
|
395
379
|
return result.join(' ');
|
|
396
380
|
}
|
|
397
381
|
|
|
@@ -406,28 +390,28 @@ export const MonthCalendarMixin = (superClass) =>
|
|
|
406
390
|
}
|
|
407
391
|
|
|
408
392
|
/**
|
|
409
|
-
* Whether the
|
|
410
|
-
*
|
|
393
|
+
* Whether the displayed month is currently being fetched, which is the same state the overlay
|
|
394
|
+
* reports with its spinner. A month that has not been asked about yet is not pending: nothing is
|
|
395
|
+
* loading, so there is nothing to report.
|
|
411
396
|
* @private
|
|
412
397
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
return !!controller?.provider && this.month !== undefined && !controller.isMonthLoaded(this.month);
|
|
398
|
+
__isMonthPending() {
|
|
399
|
+
return !!this._dateMetadataController?.isMonthPending(this.month);
|
|
416
400
|
}
|
|
417
401
|
|
|
418
402
|
/** @private */
|
|
419
403
|
__isDayDisabled(date, minDate, maxDate, isDateDisabled) {
|
|
420
|
-
|
|
421
|
-
return true;
|
|
422
|
-
}
|
|
423
|
-
// A date is blocked while its month is pending (whole month non-selectable) or once the
|
|
424
|
-
// resolved provider result marks it disabled.
|
|
425
|
-
return !!this.disabledDatesController?.isDateBlocked(date);
|
|
404
|
+
return !dateSelectable(date, minDate, maxDate, isDateDisabled, this._dateMetadataController);
|
|
426
405
|
}
|
|
427
406
|
|
|
428
407
|
/** @private */
|
|
429
408
|
__computeDayAriaDisabled(date, min, max, isDateDisabled) {
|
|
430
|
-
if (date === undefined
|
|
409
|
+
if (date === undefined) {
|
|
410
|
+
return 'false';
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const hasProvider = !!this._dateMetadataController?.provider;
|
|
414
|
+
if (!hasProvider && min === undefined && max === undefined && isDateDisabled === undefined) {
|
|
431
415
|
return 'false';
|
|
432
416
|
}
|
|
433
417
|
|
|
@@ -12,6 +12,7 @@ import { monthCalendarStyles } from './styles/vaadin-month-calendar-base-styles.
|
|
|
12
12
|
import { MonthCalendarMixin } from './vaadin-month-calendar-mixin.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
15
16
|
* @customElement vaadin-month-calendar
|
|
16
17
|
* @extends HTMLElement
|
|
17
18
|
* @private
|
|
@@ -25,6 +26,10 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LumoIn
|
|
|
25
26
|
return monthCalendarStyles;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
static get lumoInjector() {
|
|
30
|
+
return { ...super.lumoInjector, includeBaseStyles: true };
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
/** @protected */
|
|
29
34
|
render() {
|
|
30
35
|
const weekDayNames = this.__computeWeekDayNames(this.i18n, this.showWeekNumbers);
|
package/web-types.json
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "25.3.0
|
|
4
|
+
"version": "25.3.0",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-date-picker",
|
|
11
|
-
"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
|
|
11
|
+
"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 shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|----------------\n`label` | The label element\n`input-field` | The element that wraps prefix, value and buttons\n`field-button` | Set on both clear and toggle buttons\n`clear-button` | The clear button\n`error-message` | The error message element\n`helper-text` | The helper text element wrapper\n`required-indicator` | The `required` state indicator element\n`toggle-button` | The toggle button\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------------|---------------------------------\n`disabled` | Set when the element is disabled\n`has-value` | Set when the element has a value\n`has-label` | Set when the element has a label\n`has-helper` | Set when the element has helper text or slot\n`has-error-message` | Set when the element has an error message\n`has-tooltip` | Set when the element has a slotted tooltip\n`invalid` | Set when the element is invalid\n`focused` | Set when the element is focused\n`focus-ring` | Set when the element is keyboard focused\n`readonly` | Set when the element is readonly\n`opened` | Set when the overlay is opened\n`week-numbers` | Set when week numbers are shown in the calendar\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:----------------------------------------------------------|\n| `--vaadin-date-picker-date-border-radius` |\n| `--vaadin-date-picker-date-disabled-color` |\n| `--vaadin-date-picker-date-height` |\n| `--vaadin-date-picker-date-selected-background` |\n| `--vaadin-date-picker-date-selected-color` |\n| `--vaadin-date-picker-date-today-color` |\n| `--vaadin-date-picker-date-width` |\n| `--vaadin-date-picker-month-header-color` |\n| `--vaadin-date-picker-month-header-font-size` |\n| `--vaadin-date-picker-month-header-font-weight` |\n| `--vaadin-date-picker-month-padding` |\n| `--vaadin-date-picker-overlay-max-height` |\n| `--vaadin-date-picker-overlay-width` |\n| `--vaadin-date-picker-toolbar-padding` |\n| `--vaadin-date-picker-week-divider-color` |\n| `--vaadin-date-picker-week-number-color` |\n| `--vaadin-date-picker-week-number-font-size` |\n| `--vaadin-date-picker-weekday-color` |\n| `--vaadin-date-picker-weekday-font-size` |\n| `--vaadin-date-picker-weekday-font-weight` |\n| `--vaadin-date-picker-year-scroller-background` |\n| `--vaadin-date-picker-year-scroller-border-color` |\n| `--vaadin-date-picker-year-scroller-current-year-color` |\n| `--vaadin-date-picker-year-scroller-width` |\n| `--vaadin-field-default-width` |\n| `--vaadin-input-field-background` |\n| `--vaadin-input-field-border-color` |\n| `--vaadin-input-field-border-radius` |\n| `--vaadin-input-field-border-width` |\n| `--vaadin-input-field-bottom-end-radius` |\n| `--vaadin-input-field-bottom-start-radius` |\n| `--vaadin-input-field-button-text-color` |\n| `--vaadin-input-field-container-gap` |\n| `--vaadin-input-field-disabled-background` |\n| `--vaadin-input-field-disabled-text-color` |\n| `--vaadin-input-field-error-color` |\n| `--vaadin-input-field-error-font-size` |\n| `--vaadin-input-field-error-font-weight` |\n| `--vaadin-input-field-error-line-height` |\n| `--vaadin-input-field-gap` |\n| `--vaadin-input-field-helper-color` |\n| `--vaadin-input-field-helper-font-size` |\n| `--vaadin-input-field-helper-font-weight` |\n| `--vaadin-input-field-helper-line-height` |\n| `--vaadin-input-field-label-color` |\n| `--vaadin-input-field-label-font-size` |\n| `--vaadin-input-field-label-font-weight` |\n| `--vaadin-input-field-label-line-height` |\n| `--vaadin-input-field-padding` |\n| `--vaadin-input-field-placeholder-color` |\n| `--vaadin-input-field-required-indicator` |\n| `--vaadin-input-field-required-indicator-color` |\n| `--vaadin-input-field-top-end-radius` |\n| `--vaadin-input-field-top-start-radius` |\n| `--vaadin-input-field-value-color` |\n| `--vaadin-input-field-value-font-size` |\n| `--vaadin-input-field-value-font-weight` |\n| `--vaadin-input-field-value-line-height` |\n\n### Internal components\n\nIn addition to `<vaadin-date-picker>` itself, the following internal\ncomponents are themable:\n\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\nIn order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Toolbar with slotted buttons\n`loader` | Loading spinner shown while the date metadata provider is resolving\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`loading` | Set while the date metadata provider is resolving\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`loading` | Date element in a month whose metadata is currently being fetched\n`focused` | Focused date element\n`selected` | Selected date element\n`today` | Date element corresponding to the current day\n`past` | Date element corresponding to the date in the past\n`future` | Date element corresponding to the date in the future\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\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",
|
|
12
12
|
"attributes": [
|
|
13
|
+
{
|
|
14
|
+
"name": "accessible-description-ref",
|
|
15
|
+
"description": "A space-separated list of IDs referencing the elements that\ndescribe the component for screen reader users. The referenced\nelements are announced in addition to the helper text and\nthe error message.",
|
|
16
|
+
"value": {
|
|
17
|
+
"type": [
|
|
18
|
+
"string"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
13
22
|
{
|
|
14
23
|
"name": "accessible-name",
|
|
15
|
-
"description": "String used to label the component
|
|
24
|
+
"description": "String used to label the component for screen reader users.",
|
|
16
25
|
"value": {
|
|
17
26
|
"type": [
|
|
18
27
|
"string"
|
|
@@ -21,7 +30,7 @@
|
|
|
21
30
|
},
|
|
22
31
|
{
|
|
23
32
|
"name": "accessible-name-ref",
|
|
24
|
-
"description": "
|
|
33
|
+
"description": "A space-separated list of IDs referencing the elements that\nlabel the component for screen reader users.",
|
|
25
34
|
"value": {
|
|
26
35
|
"type": [
|
|
27
36
|
"string"
|
|
@@ -66,7 +75,7 @@
|
|
|
66
75
|
},
|
|
67
76
|
{
|
|
68
77
|
"name": "clear-button-visible",
|
|
69
|
-
"description": "Set to true to display the clear icon which clears the input.\
|
|
78
|
+
"description": "Set to true to display the clear icon which clears the input.\nThis also enables clearing the input when pressing Esc key.",
|
|
70
79
|
"value": {
|
|
71
80
|
"type": [
|
|
72
81
|
"boolean"
|
|
@@ -213,9 +222,7 @@
|
|
|
213
222
|
"description": "The theme variants to apply to the component.",
|
|
214
223
|
"value": {
|
|
215
224
|
"type": [
|
|
216
|
-
"string"
|
|
217
|
-
"null",
|
|
218
|
-
"undefined"
|
|
225
|
+
"string"
|
|
219
226
|
]
|
|
220
227
|
}
|
|
221
228
|
},
|
|
@@ -240,9 +247,18 @@
|
|
|
240
247
|
],
|
|
241
248
|
"js": {
|
|
242
249
|
"properties": [
|
|
250
|
+
{
|
|
251
|
+
"name": "accessibleDescriptionRef",
|
|
252
|
+
"description": "A space-separated list of IDs referencing the elements that\ndescribe the component for screen reader users. The referenced\nelements are announced in addition to the helper text and\nthe error message.",
|
|
253
|
+
"value": {
|
|
254
|
+
"type": [
|
|
255
|
+
"string"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
},
|
|
243
259
|
{
|
|
244
260
|
"name": "accessibleName",
|
|
245
|
-
"description": "String used to label the component
|
|
261
|
+
"description": "String used to label the component for screen reader users.",
|
|
246
262
|
"value": {
|
|
247
263
|
"type": [
|
|
248
264
|
"string"
|
|
@@ -251,7 +267,7 @@
|
|
|
251
267
|
},
|
|
252
268
|
{
|
|
253
269
|
"name": "accessibleNameRef",
|
|
254
|
-
"description": "
|
|
270
|
+
"description": "A space-separated list of IDs referencing the elements that\nlabel the component for screen reader users.",
|
|
255
271
|
"value": {
|
|
256
272
|
"type": [
|
|
257
273
|
"string"
|
|
@@ -296,7 +312,7 @@
|
|
|
296
312
|
},
|
|
297
313
|
{
|
|
298
314
|
"name": "clearButtonVisible",
|
|
299
|
-
"description": "Set to true to display the clear icon which clears the input.\
|
|
315
|
+
"description": "Set to true to display the clear icon which clears the input.\nThis also enables clearing the input when pressing Esc key.",
|
|
300
316
|
"value": {
|
|
301
317
|
"type": [
|
|
302
318
|
"boolean"
|
|
@@ -304,22 +320,22 @@
|
|
|
304
320
|
}
|
|
305
321
|
},
|
|
306
322
|
{
|
|
307
|
-
"name": "
|
|
308
|
-
"description": "
|
|
323
|
+
"name": "dateMetadataProvider",
|
|
324
|
+
"description": "A function that provides metadata for the dates the calendar is about to render: whether they\nare disabled, and CSS `part` names for styling from outside using the `::part()` selector.\nUnlike `isDateDisabled`, which is called once per date, the metadata provider is called for\na range of dates at a time, and again as the calendar renders further dates.\n\nIt receives a `DatePickerDateRange` and returns an array of `DatePickerDateMetadata` objects\nfor the dates in that range that have metadata. It can return a `Promise` to load the metadata\nasynchronously, and `null` or `undefined` when no date in the range has metadata.\n\nThe returned array has the following structure:\n\n```js\n[\n // The date is an ISO 8601 string.\n { date: '2026-01-01', disabled: true },\n\n // Adds a custom part name to the date.\n { date: '2026-01-02', part: 'busy' },\n]\n```\n\nA date is disabled if its metadata marks it disabled, or `isDateDisabled` returns `true`, or\nit is outside `min` and `max`. Disabled dates are not selectable, and typing a disabled date in\nthe field makes it invalid. The provider does not affect which date is focused when opening the\noverlay. Use `initialPosition` property to provide a selectable date.\n\nWhile a returned `Promise` is pending, the dates it covers are not disabled yet and render with\nthe `loading` part. If the function throws or rejects, corresponding dates are requested again\nthe next time the user navigates.\n\nThe provider is used for validation also when the overlay is closed. Date is considered valid\nwhile the provider is pending, and is re-validated again after the metadata is loaded.\n\nKeep a stable reference to the function: assigning a new one clears the cache and re-fetches\nvisible range. Call `clearCache()` to re-fetch when the data behind the same function changed.",
|
|
309
325
|
"value": {
|
|
310
326
|
"type": [
|
|
311
|
-
"
|
|
327
|
+
"DatePickerDateMetadataProvider",
|
|
328
|
+
"null",
|
|
329
|
+
"undefined"
|
|
312
330
|
]
|
|
313
331
|
}
|
|
314
332
|
},
|
|
315
333
|
{
|
|
316
|
-
"name": "
|
|
317
|
-
"description": "
|
|
334
|
+
"name": "disabled",
|
|
335
|
+
"description": "If true, the user cannot interact with this element.",
|
|
318
336
|
"value": {
|
|
319
337
|
"type": [
|
|
320
|
-
"
|
|
321
|
-
"Promise<Array<DatePickerDate>>",
|
|
322
|
-
"undefined"
|
|
338
|
+
"boolean"
|
|
323
339
|
]
|
|
324
340
|
}
|
|
325
341
|
},
|
|
@@ -343,7 +359,7 @@
|
|
|
343
359
|
},
|
|
344
360
|
{
|
|
345
361
|
"name": "i18n",
|
|
346
|
-
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n```js\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 // 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```",
|
|
362
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n```js\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 // Translation of the Today shortcut button text.\n today: 'Today',\n\n // Translation of the Cancel button text.\n cancel: 'Cancel',\n\n // Accessible name of the overlay content, announced by screen readers\n // when the overlay opens.\n dialogAccessibleName: 'Calendar',\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```",
|
|
347
363
|
"value": {
|
|
348
364
|
"type": [
|
|
349
365
|
"Object"
|
|
@@ -370,7 +386,7 @@
|
|
|
370
386
|
},
|
|
371
387
|
{
|
|
372
388
|
"name": "isDateDisabled",
|
|
373
|
-
"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.",
|
|
389
|
+
"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.\n\nThe function is called once per date and has to answer synchronously. Use\n`dateMetadataProvider` when the answer has to be loaded first, or when dates also need\ncustom part names. A date is disabled when either of the two disables it.",
|
|
374
390
|
"value": {
|
|
375
391
|
"type": [
|
|
376
392
|
"function DatePickerDate: boolean",
|