@vaadin/date-picker 24.2.0-alpha5 → 24.2.0-alpha7
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 +15 -11
- package/src/vaadin-date-picker-mixin.js +50 -25
- package/src/vaadin-date-picker-month-scroller.js +6 -19
- package/src/vaadin-date-picker-overlay-content-mixin.js +1032 -0
- package/src/vaadin-date-picker-overlay-content-styles.js +68 -0
- package/src/vaadin-date-picker-overlay-content.js +14 -1012
- package/src/vaadin-date-picker-overlay-styles.js +23 -0
- package/src/vaadin-date-picker-overlay.js +7 -19
- package/src/vaadin-date-picker-styles.js +21 -0
- package/src/vaadin-date-picker-year-scroller.js +6 -20
- package/src/vaadin-date-picker.js +2 -16
- package/src/vaadin-infinite-scroller.js +118 -117
- package/src/vaadin-month-calendar-mixin.js +303 -0
- package/src/vaadin-month-calendar-styles.js +64 -0
- package/src/vaadin-month-calendar.js +27 -319
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const datePickerOverlayStyles = css`
|
|
9
|
+
[part='overlay'] {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[part~='content'] {
|
|
15
|
+
flex: auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@media (forced-colors: active) {
|
|
19
|
+
[part='overlay'] {
|
|
20
|
+
outline: 3px solid;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
@@ -8,24 +8,8 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
|
8
8
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
9
9
|
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
10
10
|
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const datePickerOverlayStyles = css`
|
|
14
|
-
[part='overlay'] {
|
|
15
|
-
display: flex;
|
|
16
|
-
flex: auto;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
[part~='content'] {
|
|
20
|
-
flex: auto;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@media (forced-colors: active) {
|
|
24
|
-
[part='overlay'] {
|
|
25
|
-
outline: 3px solid;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
11
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
import { datePickerOverlayStyles } from './vaadin-date-picker-overlay-styles.js';
|
|
29
13
|
|
|
30
14
|
registerStyles('vaadin-date-picker-overlay', [overlayStyles, datePickerOverlayStyles], {
|
|
31
15
|
moduleId: 'vaadin-date-picker-overlay-styles',
|
|
@@ -34,7 +18,11 @@ registerStyles('vaadin-date-picker-overlay', [overlayStyles, datePickerOverlaySt
|
|
|
34
18
|
/**
|
|
35
19
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
36
20
|
*
|
|
37
|
-
* @extends
|
|
21
|
+
* @extends HTMLElement
|
|
22
|
+
* @mixes PositionMixin
|
|
23
|
+
* @mixes OverlayMixin
|
|
24
|
+
* @mixes DirMixin
|
|
25
|
+
* @mixes ThemableMixin
|
|
38
26
|
* @private
|
|
39
27
|
*/
|
|
40
28
|
class DatePickerOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(PolymerElement)))) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const datePickerStyles = css`
|
|
9
|
+
:host([opened]) {
|
|
10
|
+
pointer-events: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([dir='rtl']) [part='input-field'] {
|
|
14
|
+
direction: ltr;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([dir='rtl']) [part='input-field'] ::slotted(input)::placeholder {
|
|
18
|
+
direction: rtl;
|
|
19
|
+
text-align: left;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
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
|
-
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
7
6
|
import { InfiniteScroller } from './vaadin-infinite-scroller.js';
|
|
8
7
|
|
|
9
|
-
const stylesTemplate =
|
|
8
|
+
const stylesTemplate = document.createElement('template');
|
|
9
|
+
stylesTemplate.innerHTML = `
|
|
10
10
|
<style>
|
|
11
11
|
:host {
|
|
12
12
|
--vaadin-infinite-scroller-item-height: 80px;
|
|
@@ -42,13 +42,10 @@ const stylesTemplate = html`
|
|
|
42
42
|
</style>
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
|
-
let memoizedTemplate;
|
|
46
|
-
|
|
47
45
|
/**
|
|
48
46
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
49
47
|
*
|
|
50
48
|
* @extends InfiniteScroller
|
|
51
|
-
* @mixes ThemableMixin
|
|
52
49
|
* @private
|
|
53
50
|
*/
|
|
54
51
|
class DatePickerYearScroller extends InfiniteScroller {
|
|
@@ -56,22 +53,11 @@ class DatePickerYearScroller extends InfiniteScroller {
|
|
|
56
53
|
return 'vaadin-date-picker-year-scroller';
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
memoizedTemplate = super.template.cloneNode(true);
|
|
62
|
-
memoizedTemplate.content.appendChild(stylesTemplate.content.cloneNode(true));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return memoizedTemplate;
|
|
66
|
-
}
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
bufferSize: {
|
|
71
|
-
type: Number,
|
|
72
|
-
value: 12,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
59
|
+
this.bufferSize = 12;
|
|
60
|
+
this.shadowRoot.appendChild(stylesTemplate.content.cloneNode(true));
|
|
75
61
|
}
|
|
76
62
|
|
|
77
63
|
/**
|
|
@@ -15,8 +15,9 @@ import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-c
|
|
|
15
15
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
16
16
|
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
17
17
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
18
|
+
import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
18
19
|
|
|
19
|
-
registerStyles('vaadin-date-picker', inputFieldShared, { moduleId: 'vaadin-date-picker-styles' });
|
|
20
|
+
registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { moduleId: 'vaadin-date-picker-styles' });
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* `<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.
|
|
@@ -135,21 +136,6 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
135
136
|
|
|
136
137
|
static get template() {
|
|
137
138
|
return html`
|
|
138
|
-
<style>
|
|
139
|
-
:host([opened]) {
|
|
140
|
-
pointer-events: auto;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
:host([dir='rtl']) [part='input-field'] {
|
|
144
|
-
direction: ltr;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
:host([dir='rtl']) [part='input-field'] ::slotted(input)::placeholder {
|
|
148
|
-
direction: rtl;
|
|
149
|
-
text-align: left;
|
|
150
|
-
}
|
|
151
|
-
</style>
|
|
152
|
-
|
|
153
139
|
<div class="vaadin-date-picker-container">
|
|
154
140
|
<div part="label">
|
|
155
141
|
<slot name="label"></slot>
|
|
@@ -3,119 +3,118 @@
|
|
|
3
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
|
-
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
7
|
-
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
9
7
|
import { isFirefox } from '@vaadin/component-base/src/browser-utils.js';
|
|
10
8
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
11
9
|
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
:host {
|
|
22
|
-
display: block;
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
height: 500px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
#scroller {
|
|
28
|
-
position: relative;
|
|
29
|
-
height: 100%;
|
|
30
|
-
overflow: auto;
|
|
31
|
-
outline: none;
|
|
32
|
-
margin-right: -40px;
|
|
33
|
-
-webkit-overflow-scrolling: touch;
|
|
34
|
-
overflow-x: hidden;
|
|
35
|
-
}
|
|
11
|
+
const template = document.createElement('template');
|
|
12
|
+
template.innerHTML = `
|
|
13
|
+
<style>
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
height: 500px;
|
|
18
|
+
}
|
|
36
19
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
#scroller {
|
|
21
|
+
position: relative;
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow: auto;
|
|
24
|
+
outline: none;
|
|
25
|
+
margin-right: -40px;
|
|
26
|
+
-webkit-overflow-scrolling: touch;
|
|
27
|
+
overflow-x: hidden;
|
|
28
|
+
}
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
#scroller.notouchscroll {
|
|
31
|
+
-webkit-overflow-scrolling: auto;
|
|
32
|
+
}
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
box-sizing: border-box;
|
|
49
|
-
padding-right: 40px;
|
|
50
|
-
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
51
|
-
animation: fadein 0.2s;
|
|
52
|
-
}
|
|
34
|
+
#scroller::-webkit-scrollbar {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</style>
|
|
63
|
-
|
|
64
|
-
<div id="scroller" on-scroll="_scroll">
|
|
65
|
-
<div class="buffer"></div>
|
|
66
|
-
<div class="buffer"></div>
|
|
67
|
-
<div id="fullHeight"></div>
|
|
68
|
-
</div>
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
38
|
+
.buffer {
|
|
39
|
+
position: absolute;
|
|
40
|
+
width: var(--vaadin-infinite-scroller-buffer-width, 100%);
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
padding-right: 40px;
|
|
43
|
+
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
44
|
+
animation: fadein 0.2s;
|
|
45
|
+
}
|
|
71
46
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
type: Number,
|
|
82
|
-
value: 20,
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The amount of initial scroll top. Needed in order for the
|
|
87
|
-
* user to be able to scroll backwards.
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
_initialScroll: {
|
|
91
|
-
value: 500000,
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The index/position mapped at _initialScroll point.
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
_initialIndex: {
|
|
99
|
-
value: 0,
|
|
100
|
-
},
|
|
47
|
+
@keyframes fadein {
|
|
48
|
+
from {
|
|
49
|
+
opacity: 0;
|
|
50
|
+
}
|
|
51
|
+
to {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
101
56
|
|
|
102
|
-
|
|
103
|
-
|
|
57
|
+
<div id="scroller">
|
|
58
|
+
<div class="buffer"></div>
|
|
59
|
+
<div class="buffer"></div>
|
|
60
|
+
<div id="fullHeight"></div>
|
|
61
|
+
</div>
|
|
62
|
+
`;
|
|
104
63
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
64
|
+
/**
|
|
65
|
+
* @extends HTMLElement
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
export class InfiniteScroller extends HTMLElement {
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
|
|
72
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
73
|
+
root.appendChild(template.content.cloneNode(true));
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Count of individual items in each buffer.
|
|
77
|
+
* The scroller has 2 buffers altogether so bufferSize of 20
|
|
78
|
+
* will result in 40 buffered DOM items in total.
|
|
79
|
+
* Changing after initialization not supported.
|
|
80
|
+
* @type {number}
|
|
81
|
+
*/
|
|
82
|
+
this.bufferSize = 20;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The amount of initial scroll top. Needed in order for the
|
|
86
|
+
* user to be able to scroll backwards.
|
|
87
|
+
* @type {number}
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
this._initialScroll = 500000;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The index/position mapped at _initialScroll point.
|
|
94
|
+
* @type {number}
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
this._initialIndex = 0;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
this._activated = false;
|
|
104
|
+
}
|
|
110
105
|
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
/**
|
|
107
|
+
* @return {boolean}
|
|
108
|
+
*/
|
|
109
|
+
get active() {
|
|
110
|
+
return this._activated;
|
|
111
|
+
}
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
113
|
+
set active(active) {
|
|
114
|
+
if (active && !this._activated) {
|
|
115
|
+
this._createPool();
|
|
116
|
+
this._activated = true;
|
|
117
|
+
}
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
/**
|
|
@@ -184,17 +183,27 @@ export class InfiniteScroller extends PolymerElement {
|
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
/** @protected */
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
connectedCallback() {
|
|
187
|
+
if (!this._ready) {
|
|
188
|
+
this._ready = true;
|
|
189
|
+
|
|
190
|
+
this.$ = {};
|
|
191
|
+
this.shadowRoot.querySelectorAll('[id]').forEach((node) => {
|
|
192
|
+
this.$[node.id] = node;
|
|
193
|
+
});
|
|
189
194
|
|
|
190
|
-
|
|
195
|
+
this.$.scroller.addEventListener('scroll', () => this._scroll());
|
|
191
196
|
|
|
192
|
-
|
|
197
|
+
/** @private */
|
|
198
|
+
this._buffers = [...this.shadowRoot.querySelectorAll('.buffer')];
|
|
199
|
+
|
|
200
|
+
this.$.fullHeight.style.height = `${this._initialScroll * 2}px`;
|
|
193
201
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
// Firefox interprets elements with overflow:auto as focusable
|
|
203
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1069739
|
|
204
|
+
if (isFirefox) {
|
|
205
|
+
this.$.scroller.tabIndex = -1;
|
|
206
|
+
}
|
|
198
207
|
}
|
|
199
208
|
}
|
|
200
209
|
|
|
@@ -228,14 +237,6 @@ export class InfiniteScroller extends PolymerElement {
|
|
|
228
237
|
// To be implemented.
|
|
229
238
|
}
|
|
230
239
|
|
|
231
|
-
/** @private */
|
|
232
|
-
_activated(active) {
|
|
233
|
-
if (active && !this._initialized) {
|
|
234
|
-
this._createPool();
|
|
235
|
-
this._initialized = true;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
240
|
/** @private */
|
|
240
241
|
_finishInit() {
|
|
241
242
|
if (!this._initDone) {
|
|
@@ -347,7 +348,7 @@ export class InfiniteScroller extends PolymerElement {
|
|
|
347
348
|
}
|
|
348
349
|
});
|
|
349
350
|
|
|
350
|
-
|
|
351
|
+
requestAnimationFrame(() => {
|
|
351
352
|
this._finishInit();
|
|
352
353
|
});
|
|
353
354
|
}
|
|
@@ -364,7 +365,7 @@ export class InfiniteScroller extends PolymerElement {
|
|
|
364
365
|
itemWrapper.appendChild(itemWrapper.instance);
|
|
365
366
|
|
|
366
367
|
Object.keys(tmpInstance).forEach((prop) => {
|
|
367
|
-
itemWrapper.instance
|
|
368
|
+
itemWrapper.instance[prop] = tmpInstance[prop];
|
|
368
369
|
});
|
|
369
370
|
}
|
|
370
371
|
|