@vaadin/date-picker 23.3.3 → 24.0.0-alpha10
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 +7 -0
- package/src/vaadin-date-picker-helper.js +16 -2
- package/src/vaadin-date-picker-light.d.ts +1 -7
- package/src/vaadin-date-picker-light.js +12 -50
- package/src/vaadin-date-picker-mixin.d.ts +4 -18
- package/src/vaadin-date-picker-mixin.js +121 -83
- package/src/vaadin-date-picker-month-scroller.js +74 -0
- package/src/vaadin-date-picker-overlay-content.js +268 -208
- package/src/vaadin-date-picker-overlay.js +19 -8
- package/src/vaadin-date-picker-year-scroller.js +104 -0
- package/src/vaadin-date-picker-year.js +57 -0
- package/src/vaadin-date-picker.d.ts +24 -12
- package/src/vaadin-date-picker.js +43 -39
- package/src/vaadin-infinite-scroller.js +98 -101
- package/src/vaadin-month-calendar.js +37 -14
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +13 -50
- package/theme/lumo/vaadin-date-picker-year-styles.js +32 -0
- package/theme/lumo/vaadin-month-calendar-styles.js +16 -16
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +10 -31
- package/theme/material/vaadin-date-picker-year-styles.js +28 -0
- package/theme/material/vaadin-month-calendar-styles.js +14 -14
- package/web-types.json +145 -5
- package/web-types.lit.json +61 -5
- package/src/vaadin-date-picker-styles.js +0 -28
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
7
|
-
import { templatize } from '@polymer/polymer/lib/utils/templatize.js';
|
|
8
7
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
8
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
10
9
|
import { isFirefox } from '@vaadin/component-base/src/browser-utils.js';
|
|
11
10
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
11
|
+
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @extends HTMLElement
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
|
-
class InfiniteScroller extends PolymerElement {
|
|
17
|
+
export class InfiniteScroller extends PolymerElement {
|
|
18
18
|
static get template() {
|
|
19
19
|
return html`
|
|
20
20
|
<style>
|
|
@@ -69,10 +69,6 @@ class InfiniteScroller extends PolymerElement {
|
|
|
69
69
|
`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
static get is() {
|
|
73
|
-
return 'vaadin-infinite-scroller';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
static get properties() {
|
|
77
73
|
return {
|
|
78
74
|
/**
|
|
@@ -122,6 +118,71 @@ class InfiniteScroller extends PolymerElement {
|
|
|
122
118
|
};
|
|
123
119
|
}
|
|
124
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @return {number}
|
|
123
|
+
*/
|
|
124
|
+
get bufferOffset() {
|
|
125
|
+
return this._buffers[0].offsetTop;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @return {number}
|
|
130
|
+
*/
|
|
131
|
+
get itemHeight() {
|
|
132
|
+
if (!this._itemHeightVal) {
|
|
133
|
+
const itemHeight = getComputedStyle(this).getPropertyValue('--vaadin-infinite-scroller-item-height');
|
|
134
|
+
// Use background-position temp inline style for unit conversion
|
|
135
|
+
const tmpStyleProp = 'background-position';
|
|
136
|
+
this.$.fullHeight.style.setProperty(tmpStyleProp, itemHeight);
|
|
137
|
+
const itemHeightPx = getComputedStyle(this.$.fullHeight).getPropertyValue(tmpStyleProp);
|
|
138
|
+
this.$.fullHeight.style.removeProperty(tmpStyleProp);
|
|
139
|
+
this._itemHeightVal = parseFloat(itemHeightPx);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return this._itemHeightVal;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** @private */
|
|
146
|
+
get _bufferHeight() {
|
|
147
|
+
return this.itemHeight * this.bufferSize;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @return {number}
|
|
152
|
+
*/
|
|
153
|
+
get position() {
|
|
154
|
+
return (this.$.scroller.scrollTop - this._buffers[0].translateY) / this.itemHeight + this._firstIndex;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Current scroller position as index. Can be a fractional number.
|
|
159
|
+
*
|
|
160
|
+
* @type {number}
|
|
161
|
+
*/
|
|
162
|
+
set position(index) {
|
|
163
|
+
this._preventScrollEvent = true;
|
|
164
|
+
if (index > this._firstIndex && index < this._firstIndex + this.bufferSize * 2) {
|
|
165
|
+
this.$.scroller.scrollTop = this.itemHeight * (index - this._firstIndex) + this._buffers[0].translateY;
|
|
166
|
+
} else {
|
|
167
|
+
this._initialIndex = ~~index;
|
|
168
|
+
this._reset();
|
|
169
|
+
this._scrollDisabled = true;
|
|
170
|
+
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
171
|
+
this._scrollDisabled = false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (this._mayHaveMomentum) {
|
|
175
|
+
// Stop the possible iOS Safari momentum with -webkit-overflow-scrolling: auto;
|
|
176
|
+
this.$.scroller.classList.add('notouchscroll');
|
|
177
|
+
this._mayHaveMomentum = false;
|
|
178
|
+
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
// Restore -webkit-overflow-scrolling: touch; after a small delay.
|
|
181
|
+
this.$.scroller.classList.remove('notouchscroll');
|
|
182
|
+
}, 10);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
125
186
|
/** @protected */
|
|
126
187
|
ready() {
|
|
127
188
|
super.ready();
|
|
@@ -130,19 +191,6 @@ class InfiniteScroller extends PolymerElement {
|
|
|
130
191
|
|
|
131
192
|
this.$.fullHeight.style.height = `${this._initialScroll * 2}px`;
|
|
132
193
|
|
|
133
|
-
const tpl = this.querySelector('template');
|
|
134
|
-
this._TemplateClass = templatize(tpl, this, {
|
|
135
|
-
forwardHostProp(prop, value) {
|
|
136
|
-
if (prop !== 'index') {
|
|
137
|
-
this._buffers.forEach((buffer) => {
|
|
138
|
-
[...buffer.children].forEach((slot) => {
|
|
139
|
-
slot._itemWrapper.instance[prop] = value;
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
194
|
// Firefox interprets elements with overflow:auto as focusable
|
|
147
195
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1069739
|
|
148
196
|
if (isFirefox) {
|
|
@@ -162,6 +210,24 @@ class InfiniteScroller extends PolymerElement {
|
|
|
162
210
|
}
|
|
163
211
|
}
|
|
164
212
|
|
|
213
|
+
/**
|
|
214
|
+
* @protected
|
|
215
|
+
* @override
|
|
216
|
+
*/
|
|
217
|
+
_createElement() {
|
|
218
|
+
// To be implemented.
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @param {HTMLElement} _element
|
|
223
|
+
* @param {number} _index
|
|
224
|
+
* @protected
|
|
225
|
+
* @override
|
|
226
|
+
*/
|
|
227
|
+
_updateElement(_element, _index) {
|
|
228
|
+
// To be implemented.
|
|
229
|
+
}
|
|
230
|
+
|
|
165
231
|
/** @private */
|
|
166
232
|
_activated(active) {
|
|
167
233
|
if (active && !this._initialized) {
|
|
@@ -185,6 +251,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
185
251
|
}
|
|
186
252
|
|
|
187
253
|
this._initDone = true;
|
|
254
|
+
this.dispatchEvent(new CustomEvent('init-done'));
|
|
188
255
|
}
|
|
189
256
|
}
|
|
190
257
|
|
|
@@ -234,71 +301,6 @@ class InfiniteScroller extends PolymerElement {
|
|
|
234
301
|
});
|
|
235
302
|
}
|
|
236
303
|
|
|
237
|
-
/**
|
|
238
|
-
* @return {number}
|
|
239
|
-
*/
|
|
240
|
-
get bufferOffset() {
|
|
241
|
-
return this._buffers[0].offsetTop;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @return {number}
|
|
246
|
-
*/
|
|
247
|
-
get position() {
|
|
248
|
-
return (this.$.scroller.scrollTop - this._buffers[0].translateY) / this.itemHeight + this._firstIndex;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Current scroller position as index. Can be a fractional number.
|
|
253
|
-
*
|
|
254
|
-
* @type {number}
|
|
255
|
-
*/
|
|
256
|
-
set position(index) {
|
|
257
|
-
this._preventScrollEvent = true;
|
|
258
|
-
if (index > this._firstIndex && index < this._firstIndex + this.bufferSize * 2) {
|
|
259
|
-
this.$.scroller.scrollTop = this.itemHeight * (index - this._firstIndex) + this._buffers[0].translateY;
|
|
260
|
-
} else {
|
|
261
|
-
this._initialIndex = ~~index;
|
|
262
|
-
this._reset();
|
|
263
|
-
this._scrollDisabled = true;
|
|
264
|
-
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
265
|
-
this._scrollDisabled = false;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (this._mayHaveMomentum) {
|
|
269
|
-
// Stop the possible iOS Safari momentum with -webkit-overflow-scrolling: auto;
|
|
270
|
-
this.$.scroller.classList.add('notouchscroll');
|
|
271
|
-
this._mayHaveMomentum = false;
|
|
272
|
-
|
|
273
|
-
setTimeout(() => {
|
|
274
|
-
// Restore -webkit-overflow-scrolling: touch; after a small delay.
|
|
275
|
-
this.$.scroller.classList.remove('notouchscroll');
|
|
276
|
-
}, 10);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @return {number}
|
|
282
|
-
*/
|
|
283
|
-
get itemHeight() {
|
|
284
|
-
if (!this._itemHeightVal) {
|
|
285
|
-
const itemHeight = getComputedStyle(this).getPropertyValue('--vaadin-infinite-scroller-item-height');
|
|
286
|
-
// Use background-position temp inline style for unit conversion
|
|
287
|
-
const tmpStyleProp = 'background-position';
|
|
288
|
-
this.$.fullHeight.style.setProperty(tmpStyleProp, itemHeight);
|
|
289
|
-
const itemHeightPx = getComputedStyle(this.$.fullHeight).getPropertyValue(tmpStyleProp);
|
|
290
|
-
this.$.fullHeight.style.removeProperty(tmpStyleProp);
|
|
291
|
-
this._itemHeightVal = parseFloat(itemHeightPx);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return this._itemHeightVal;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/** @private */
|
|
298
|
-
get _bufferHeight() {
|
|
299
|
-
return this.itemHeight * this.bufferSize;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
304
|
/** @private */
|
|
303
305
|
_reset() {
|
|
304
306
|
this._scrollDisabled = true;
|
|
@@ -328,8 +330,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
328
330
|
itemWrapper.style.height = `${this.itemHeight}px`;
|
|
329
331
|
itemWrapper.instance = {};
|
|
330
332
|
|
|
331
|
-
const
|
|
332
|
-
const slotName = `vaadin-infinite-scroller-item-content-${contentId}`;
|
|
333
|
+
const slotName = `vaadin-infinite-scroller-item-content-${generateUniqueId()}`;
|
|
333
334
|
|
|
334
335
|
const slot = document.createElement('slot');
|
|
335
336
|
slot.setAttribute('name', slotName);
|
|
@@ -339,18 +340,16 @@ class InfiniteScroller extends PolymerElement {
|
|
|
339
340
|
itemWrapper.setAttribute('slot', slotName);
|
|
340
341
|
this.appendChild(itemWrapper);
|
|
341
342
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
}, 1); // Wait for first reset
|
|
343
|
+
// Only stamp the visible instances first
|
|
344
|
+
if (this._isVisible(itemWrapper, container)) {
|
|
345
|
+
this._ensureStampedInstance(itemWrapper);
|
|
346
|
+
}
|
|
348
347
|
}
|
|
349
348
|
});
|
|
350
349
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
350
|
+
afterNextRender(this, () => {
|
|
351
|
+
this._finishInit();
|
|
352
|
+
});
|
|
354
353
|
}
|
|
355
354
|
|
|
356
355
|
/** @private */
|
|
@@ -361,8 +360,8 @@ class InfiniteScroller extends PolymerElement {
|
|
|
361
360
|
|
|
362
361
|
const tmpInstance = itemWrapper.instance;
|
|
363
362
|
|
|
364
|
-
itemWrapper.instance =
|
|
365
|
-
itemWrapper.appendChild(itemWrapper.instance
|
|
363
|
+
itemWrapper.instance = this._createElement();
|
|
364
|
+
itemWrapper.appendChild(itemWrapper.instance);
|
|
366
365
|
|
|
367
366
|
Object.keys(tmpInstance).forEach((prop) => {
|
|
368
367
|
itemWrapper.instance.set(prop, tmpInstance[prop]);
|
|
@@ -381,7 +380,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
381
380
|
[...buffer.children].forEach((slot, index) => {
|
|
382
381
|
const itemWrapper = slot._itemWrapper;
|
|
383
382
|
if (!viewPortOnly || this._isVisible(itemWrapper, scrollerRect)) {
|
|
384
|
-
itemWrapper.instance
|
|
383
|
+
this._updateElement(itemWrapper.instance, firstIndex + index);
|
|
385
384
|
}
|
|
386
385
|
});
|
|
387
386
|
buffer.updated = true;
|
|
@@ -395,5 +394,3 @@ class InfiniteScroller extends PolymerElement {
|
|
|
395
394
|
return rect.bottom > container.top && rect.top < container.bottom;
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
|
-
|
|
399
|
-
customElements.define(InfiniteScroller.is, InfiniteScroller);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@polymer/polymer/lib/elements/dom-repeat.js';
|
|
@@ -32,17 +32,21 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
32
32
|
display: flex;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
[part
|
|
35
|
+
[part~='date'] {
|
|
36
36
|
outline: none;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
[part~='disabled'] {
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
[part='week-number'][hidden],
|
|
40
44
|
[part='weekday'][hidden] {
|
|
41
45
|
display: none;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
[part='weekday'],
|
|
45
|
-
[part
|
|
49
|
+
[part~='date'] {
|
|
46
50
|
width: calc(100% / 7);
|
|
47
51
|
padding: 0;
|
|
48
52
|
font-weight: normal;
|
|
@@ -56,7 +60,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
:host([week-numbers]) [part='weekday']:not(:empty),
|
|
59
|
-
:host([week-numbers]) [part
|
|
63
|
+
:host([week-numbers]) [part~='date'] {
|
|
60
64
|
width: 12.5%;
|
|
61
65
|
}
|
|
62
66
|
</style>
|
|
@@ -99,12 +103,9 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
99
103
|
<template is="dom-repeat" items="[[week]]">
|
|
100
104
|
<td
|
|
101
105
|
role="gridcell"
|
|
102
|
-
part
|
|
106
|
+
part$="[[__getDatePart(item, focusedDate, selectedDate, minDate, maxDate)]]"
|
|
103
107
|
date="[[item]]"
|
|
104
|
-
today$="[[_isToday(item)]]"
|
|
105
|
-
focused$="[[__isDayFocused(item, focusedDate)]]"
|
|
106
108
|
tabindex$="[[__getDayTabindex(item, focusedDate)]]"
|
|
107
|
-
selected$="[[__isDaySelected(item, selectedDate)]]"
|
|
108
109
|
disabled$="[[__isDayDisabled(item, minDate, maxDate)]]"
|
|
109
110
|
aria-selected$="[[__getDayAriaSelected(item, selectedDate)]]"
|
|
110
111
|
aria-disabled$="[[__getDayAriaDisabled(item, minDate, maxDate)]]"
|
|
@@ -204,18 +205,18 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
204
205
|
];
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
get focusableDateElement() {
|
|
209
|
+
return [...this.shadowRoot.querySelectorAll('[part~=date]')].find((datePart) => {
|
|
210
|
+
return dateEquals(datePart.date, this.focusedDate);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
207
214
|
/** @protected */
|
|
208
215
|
ready() {
|
|
209
216
|
super.ready();
|
|
210
217
|
addListener(this.$.monthGrid, 'tap', this._handleTap.bind(this));
|
|
211
218
|
}
|
|
212
219
|
|
|
213
|
-
get focusableDateElement() {
|
|
214
|
-
return [...this.shadowRoot.querySelectorAll('[part=date]')].find((datePart) => {
|
|
215
|
-
return dateEquals(datePart.date, this.focusedDate);
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
220
|
/* Returns true if all the dates in the month are out of the allowed range */
|
|
220
221
|
_isDisabled(month, minDate, maxDate) {
|
|
221
222
|
// First day of the month
|
|
@@ -369,6 +370,28 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
369
370
|
e.preventDefault();
|
|
370
371
|
}
|
|
371
372
|
|
|
373
|
+
__getDatePart(date, focusedDate, selectedDate, minDate, maxDate) {
|
|
374
|
+
const result = ['date'];
|
|
375
|
+
|
|
376
|
+
if (this.__isDayDisabled(date, minDate, maxDate)) {
|
|
377
|
+
result.push('disabled');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (this.__isDayFocused(date, focusedDate)) {
|
|
381
|
+
result.push('focused');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (this.__isDaySelected(date, selectedDate)) {
|
|
385
|
+
result.push('selected');
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (this._isToday(date)) {
|
|
389
|
+
result.push('today');
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return result.join(' ');
|
|
393
|
+
}
|
|
394
|
+
|
|
372
395
|
__getWeekNumber(days) {
|
|
373
396
|
const date = days.reduce((acc, d) => {
|
|
374
397
|
return !acc && d ? d : acc;
|
|
@@ -4,6 +4,7 @@ import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
6
|
import '@vaadin/button/theme/lumo/vaadin-button.js';
|
|
7
|
+
import './vaadin-date-picker-year-styles.js';
|
|
7
8
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
|
|
9
10
|
registerStyles(
|
|
@@ -19,9 +20,7 @@ registerStyles(
|
|
|
19
20
|
cursor: default;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[part='months'] {
|
|
23
|
+
::slotted([slot='months']) {
|
|
25
24
|
/* Month calendar height:
|
|
26
25
|
header height + margin-bottom
|
|
27
26
|
+ weekdays height + margin-bottom
|
|
@@ -43,8 +42,7 @@ registerStyles(
|
|
|
43
42
|
margin-right: 57px;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
[part='years'] {
|
|
45
|
+
::slotted([slot='years']) {
|
|
48
46
|
/* TODO get rid of fixed magic number */
|
|
49
47
|
--vaadin-infinite-scroller-buffer-width: 97px;
|
|
50
48
|
width: 57px;
|
|
@@ -58,15 +56,8 @@ registerStyles(
|
|
|
58
56
|
cursor: var(--lumo-clickable-cursor);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
[
|
|
62
|
-
|
|
63
|
-
opacity: 0.7;
|
|
64
|
-
transition: 0.2s opacity;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[part='years']:hover [part='year-number'],
|
|
68
|
-
[part='years']:hover [part='year-separator'] {
|
|
69
|
-
opacity: 1;
|
|
59
|
+
::slotted([slot='years']:hover) {
|
|
60
|
+
--_lumo-date-picker-year-opacity: 1;
|
|
70
61
|
}
|
|
71
62
|
|
|
72
63
|
/* TODO unsupported selector */
|
|
@@ -75,14 +66,13 @@ registerStyles(
|
|
|
75
66
|
display: block;
|
|
76
67
|
}
|
|
77
68
|
|
|
78
|
-
/* TODO
|
|
79
|
-
|
|
80
|
-
#scrollers[desktop] [part='months'] {
|
|
69
|
+
/* TODO fix this in vaadin-date-picker that it adapts to the width of the year scroller */
|
|
70
|
+
:host([desktop]) ::slotted([slot='months']) {
|
|
81
71
|
right: auto;
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
/* Year scroller position indicator */
|
|
85
|
-
[
|
|
75
|
+
::slotted([slot='years'])::before {
|
|
86
76
|
border: none;
|
|
87
77
|
width: 1em;
|
|
88
78
|
height: 1em;
|
|
@@ -94,37 +84,13 @@ registerStyles(
|
|
|
94
84
|
z-index: 1;
|
|
95
85
|
}
|
|
96
86
|
|
|
97
|
-
[part='year-number'],
|
|
98
|
-
[part='year-separator'] {
|
|
99
|
-
display: flex;
|
|
100
|
-
align-items: center;
|
|
101
|
-
justify-content: center;
|
|
102
|
-
height: 50%;
|
|
103
|
-
transform: translateY(-50%);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
[part='years'] [part='year-separator']::after {
|
|
107
|
-
color: var(--lumo-disabled-text-color);
|
|
108
|
-
content: '•';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* Current year */
|
|
112
|
-
|
|
113
|
-
[part='years'] [part='year-number'][current] {
|
|
114
|
-
color: var(--lumo-primary-text-color);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* Toolbar (footer) */
|
|
118
|
-
|
|
119
87
|
[part='toolbar'] {
|
|
120
88
|
padding: var(--lumo-space-s);
|
|
121
89
|
border-bottom-left-radius: var(--lumo-border-radius-l);
|
|
122
90
|
margin-right: 57px;
|
|
123
91
|
}
|
|
124
92
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
[part='toolbar'] [part\$='button'] {
|
|
93
|
+
[part='toolbar'] ::slotted(vaadin-button) {
|
|
128
94
|
margin: 0;
|
|
129
95
|
}
|
|
130
96
|
|
|
@@ -177,22 +143,19 @@ registerStyles(
|
|
|
177
143
|
background-image: none;
|
|
178
144
|
}
|
|
179
145
|
|
|
180
|
-
[part='years'] {
|
|
181
|
-
background-color: var(--lumo-shade-5pct);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
146
|
[part='toolbar'],
|
|
185
|
-
[
|
|
147
|
+
::slotted([slot='months']) {
|
|
186
148
|
margin-right: 0;
|
|
187
149
|
}
|
|
188
150
|
|
|
189
151
|
/* TODO make date-picker adapt to the width of the years part */
|
|
190
|
-
[
|
|
152
|
+
::slotted([slot='years']) {
|
|
191
153
|
--vaadin-infinite-scroller-buffer-width: 90px;
|
|
192
154
|
width: 50px;
|
|
155
|
+
background-color: var(--lumo-shade-5pct);
|
|
193
156
|
}
|
|
194
157
|
|
|
195
|
-
:host([years-visible]) [
|
|
158
|
+
:host([years-visible]) ::slotted([slot='months']) {
|
|
196
159
|
padding-left: 50px;
|
|
197
160
|
}
|
|
198
161
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
2
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
3
|
+
|
|
4
|
+
registerStyles(
|
|
5
|
+
'vaadin-date-picker-year',
|
|
6
|
+
css`
|
|
7
|
+
:host([current]) [part='year-number'] {
|
|
8
|
+
color: var(--lumo-primary-text-color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host(:not([current])) [part='year-number'],
|
|
12
|
+
[part='year-separator'] {
|
|
13
|
+
opacity: var(--_lumo-date-picker-year-opacity, 0.7);
|
|
14
|
+
transition: 0.2s opacity;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part='year-number'],
|
|
18
|
+
[part='year-separator'] {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
height: 50%;
|
|
23
|
+
transform: translateY(-50%);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[part='year-separator']::after {
|
|
27
|
+
color: var(--lumo-disabled-text-color);
|
|
28
|
+
content: '•';
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
{ moduleId: 'lumo-date-picker-year' },
|
|
32
|
+
);
|
|
@@ -50,7 +50,7 @@ registerStyles(
|
|
|
50
50
|
|
|
51
51
|
/* Date and week number cells */
|
|
52
52
|
|
|
53
|
-
[part
|
|
53
|
+
[part~='date'],
|
|
54
54
|
[part='week-number'] {
|
|
55
55
|
box-sizing: border-box;
|
|
56
56
|
display: inline-flex;
|
|
@@ -60,28 +60,28 @@ registerStyles(
|
|
|
60
60
|
position: relative;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
[part
|
|
63
|
+
[part~='date'] {
|
|
64
64
|
transition: color 0.1s;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
[part
|
|
67
|
+
[part~='date']:not(:empty) {
|
|
68
68
|
cursor: var(--lumo-clickable-cursor);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
:host([week-numbers]) [part='weekday']:not(:empty),
|
|
72
|
-
:host([week-numbers]) [part
|
|
72
|
+
:host([week-numbers]) [part~='date'] {
|
|
73
73
|
width: calc((100% - var(--lumo-size-xs)) / 7);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/* Today date */
|
|
77
77
|
|
|
78
|
-
[part
|
|
78
|
+
[part~='date'][part~='today'] {
|
|
79
79
|
color: var(--lumo-primary-text-color);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/* Focused date */
|
|
83
83
|
|
|
84
|
-
[part
|
|
84
|
+
[part~='date']::before {
|
|
85
85
|
content: '';
|
|
86
86
|
position: absolute;
|
|
87
87
|
z-index: -1;
|
|
@@ -97,11 +97,11 @@ registerStyles(
|
|
|
97
97
|
border-radius: var(--lumo-border-radius-m);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
[part
|
|
100
|
+
[part~='date'][part~='focused']::before {
|
|
101
101
|
box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
:host(:not([focused])) [part
|
|
104
|
+
:host(:not([focused])) [part~='date'][part~='focused']::before {
|
|
105
105
|
animation: vaadin-date-picker-month-calendar-focus-date 1.4s infinite;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -111,33 +111,33 @@ registerStyles(
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
[part
|
|
114
|
+
[part~='date']:not(:empty):not([part~='disabled']):not([part~='selected']):hover::before {
|
|
115
115
|
background-color: var(--lumo-primary-color-10pct);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
[part
|
|
118
|
+
[part~='date'][part~='selected'] {
|
|
119
119
|
color: var(--lumo-primary-contrast-color);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
[part
|
|
122
|
+
[part~='date'][part~='selected']::before {
|
|
123
123
|
background-color: var(--lumo-primary-color);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
[part
|
|
126
|
+
[part~='date'][part~='disabled'] {
|
|
127
127
|
color: var(--lumo-disabled-text-color);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
@media (pointer: coarse) {
|
|
131
|
-
[part
|
|
132
|
-
[part
|
|
131
|
+
[part~='date']:hover:not([part~='selected'])::before,
|
|
132
|
+
[part~='focused']:not([part~='selected'])::before {
|
|
133
133
|
display: none;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
[part
|
|
136
|
+
[part~='date']:not(:empty):not([part~='disabled']):active::before {
|
|
137
137
|
display: block;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
[part
|
|
140
|
+
[part~='date'][part~='selected']::before {
|
|
141
141
|
box-shadow: none;
|
|
142
142
|
}
|
|
143
143
|
}
|