@vaadin/date-picker 24.8.4 → 25.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/README.md +0 -23
- package/package.json +15 -15
- package/src/styles/vaadin-date-picker-base-styles.d.ts +8 -0
- package/src/styles/vaadin-date-picker-base-styles.js +30 -0
- package/src/styles/vaadin-date-picker-core-styles.d.ts +8 -0
- package/src/styles/vaadin-date-picker-overlay-base-styles.js +48 -0
- package/src/styles/vaadin-date-picker-overlay-content-base-styles.js +107 -0
- package/src/styles/vaadin-date-picker-overlay-content-core-styles.js +54 -0
- package/src/styles/vaadin-date-picker-year-base-styles.js +26 -0
- package/src/styles/vaadin-date-picker-year-core-styles.js +13 -0
- package/src/styles/vaadin-month-calendar-base-styles.js +140 -0
- package/src/vaadin-date-picker-helper.d.ts +5 -0
- package/src/vaadin-date-picker-mixin.js +34 -45
- package/src/vaadin-date-picker-month-scroller.js +2 -6
- package/src/vaadin-date-picker-overlay-content-mixin.js +5 -135
- package/src/vaadin-date-picker-overlay-content.js +28 -31
- package/src/vaadin-date-picker-overlay.js +27 -11
- package/src/vaadin-date-picker-year-scroller.js +3 -4
- package/src/vaadin-date-picker-year.js +39 -11
- package/src/vaadin-date-picker.d.ts +11 -14
- package/src/vaadin-date-picker.js +73 -54
- package/src/vaadin-infinite-scroller.js +1 -22
- package/src/vaadin-month-calendar.js +69 -47
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +19 -46
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +0 -1
- package/web-types.json +2 -369
- package/web-types.lit.json +2 -156
- package/src/vaadin-date-picker-light.d.ts +0 -112
- package/src/vaadin-date-picker-light.js +0 -136
- package/src/vaadin-date-picker-overlay-content-styles.js +0 -68
- package/src/vaadin-date-picker-year-mixin.js +0 -35
- package/src/vaadin-lit-date-picker-overlay-content.js +0 -70
- package/src/vaadin-lit-date-picker-overlay.js +0 -46
- package/src/vaadin-lit-date-picker-year.js +0 -41
- package/src/vaadin-lit-date-picker.js +0 -172
- package/src/vaadin-lit-month-calendar.js +0 -98
- package/theme/lumo/vaadin-date-picker-light.d.ts +0 -4
- package/theme/lumo/vaadin-date-picker-light.js +0 -4
- package/theme/lumo/vaadin-lit-date-picker.d.ts +0 -5
- package/theme/lumo/vaadin-lit-date-picker.js +0 -5
- package/theme/material/vaadin-date-picker-light.d.ts +0 -4
- package/theme/material/vaadin-date-picker-light.js +0 -4
- package/theme/material/vaadin-date-picker-overlay-content-styles.d.ts +0 -6
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +0 -132
- package/theme/material/vaadin-date-picker-overlay-styles.d.ts +0 -1
- package/theme/material/vaadin-date-picker-overlay-styles.js +0 -47
- package/theme/material/vaadin-date-picker-styles.d.ts +0 -3
- package/theme/material/vaadin-date-picker-styles.js +0 -22
- package/theme/material/vaadin-date-picker-year-styles.d.ts +0 -1
- package/theme/material/vaadin-date-picker-year-styles.js +0 -28
- package/theme/material/vaadin-date-picker.d.ts +0 -5
- package/theme/material/vaadin-date-picker.js +0 -5
- package/theme/material/vaadin-lit-date-picker.d.ts +0 -5
- package/theme/material/vaadin-lit-date-picker.js +0 -5
- package/theme/material/vaadin-month-calendar-styles.d.ts +0 -2
- package/theme/material/vaadin-month-calendar-styles.js +0 -120
- package/vaadin-date-picker-light.d.ts +0 -1
- package/vaadin-date-picker-light.js +0 -2
- package/vaadin-lit-date-picker.d.ts +0 -1
- package/vaadin-lit-date-picker.js +0 -2
- /package/src/{vaadin-date-picker-styles.js → styles/vaadin-date-picker-core-styles.js} +0 -0
- /package/src/{vaadin-date-picker-overlay-styles.js → styles/vaadin-date-picker-overlay-core-styles.js} +0 -0
- /package/src/{vaadin-month-calendar-styles.js → styles/vaadin-month-calendar-core-styles.js} +0 -0
|
@@ -83,18 +83,19 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
83
83
|
*
|
|
84
84
|
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
85
85
|
*
|
|
86
|
-
* Part name
|
|
87
|
-
*
|
|
88
|
-
* `toggle-button`
|
|
86
|
+
* Part name | Description
|
|
87
|
+
* -----------------|--------------------
|
|
88
|
+
* `toggle-button` | Toggle button
|
|
89
|
+
* `backdrop` | Backdrop of the overlay
|
|
90
|
+
* `overlay` | The overlay container
|
|
91
|
+
* `content` | The overlay content
|
|
89
92
|
*
|
|
90
93
|
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
91
94
|
*
|
|
92
|
-
* Attribute
|
|
93
|
-
*
|
|
94
|
-
* `opened`
|
|
95
|
-
*
|
|
96
|
-
* If you want to replace the default `<input>` and its container with a custom implementation to get full control
|
|
97
|
-
* over the input field, consider using the [`<vaadin-date-picker-light>`](#/elements/vaadin-date-picker-light) element.
|
|
95
|
+
* Attribute | Description
|
|
96
|
+
* ---------------|----------------------------------------------
|
|
97
|
+
* `opened` | Set when the date selector overlay is opened
|
|
98
|
+
* `week-numbers` | Set when week numbers are shown in the calendar
|
|
98
99
|
*
|
|
99
100
|
* ### Internal components
|
|
100
101
|
*
|
|
@@ -113,12 +114,8 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
113
114
|
*
|
|
114
115
|
* Part name | Description
|
|
115
116
|
* ----------------------|--------------------
|
|
116
|
-
* `overlay-header` | Fullscreen mode header
|
|
117
|
-
* `label` | Fullscreen mode value/label
|
|
118
|
-
* `clear-button` | Fullscreen mode clear button
|
|
119
|
-
* `toggle-button` | Fullscreen mode toggle button
|
|
120
117
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
121
|
-
* `toolbar` |
|
|
118
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
122
119
|
*
|
|
123
120
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
124
121
|
*
|
|
@@ -6,19 +6,20 @@
|
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
7
7
|
import './vaadin-date-picker-overlay.js';
|
|
8
8
|
import './vaadin-date-picker-overlay-content.js';
|
|
9
|
-
import { html,
|
|
9
|
+
import { html, LitElement } from 'lit';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
12
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
13
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
14
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
15
|
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
14
16
|
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
15
17
|
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
16
18
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
17
|
-
import {
|
|
19
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
20
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
21
|
+
import { datePickerStyles } from './styles/vaadin-date-picker-core-styles.js';
|
|
18
22
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
19
|
-
import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
20
|
-
|
|
21
|
-
registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { moduleId: 'vaadin-date-picker-styles' });
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* `<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.
|
|
@@ -46,18 +47,19 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
46
47
|
*
|
|
47
48
|
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
48
49
|
*
|
|
49
|
-
* Part name
|
|
50
|
-
*
|
|
51
|
-
* `toggle-button`
|
|
50
|
+
* Part name | Description
|
|
51
|
+
* -----------------|--------------------
|
|
52
|
+
* `toggle-button` | Toggle button
|
|
53
|
+
* `backdrop` | Backdrop of the overlay
|
|
54
|
+
* `overlay` | The overlay container
|
|
55
|
+
* `content` | The overlay content
|
|
52
56
|
*
|
|
53
57
|
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
54
58
|
*
|
|
55
|
-
* Attribute
|
|
56
|
-
*
|
|
57
|
-
* `opened`
|
|
58
|
-
*
|
|
59
|
-
* If you want to replace the default `<input>` and its container with a custom implementation to get full control
|
|
60
|
-
* over the input field, consider using the [`<vaadin-date-picker-light>`](#/elements/vaadin-date-picker-light) element.
|
|
59
|
+
* Attribute | Description
|
|
60
|
+
* ---------------|----------------------------------------------
|
|
61
|
+
* `opened` | Set when the date selector overlay is opened
|
|
62
|
+
* `week-numbers` | Set when week numbers are shown in the calendar
|
|
61
63
|
*
|
|
62
64
|
* ### Internal components
|
|
63
65
|
*
|
|
@@ -76,12 +78,8 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
76
78
|
*
|
|
77
79
|
* Part name | Description
|
|
78
80
|
* ----------------------|--------------------
|
|
79
|
-
* `overlay-header` | Fullscreen mode header
|
|
80
|
-
* `label` | Fullscreen mode value/label
|
|
81
|
-
* `clear-button` | Fullscreen mode clear button
|
|
82
|
-
* `toggle-button` | Fullscreen mode toggle button
|
|
83
81
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
84
|
-
* `toolbar` |
|
|
82
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
85
83
|
*
|
|
86
84
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
87
85
|
*
|
|
@@ -150,30 +148,56 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
150
148
|
* @mixes InputControlMixin
|
|
151
149
|
* @mixes DatePickerMixin
|
|
152
150
|
*/
|
|
153
|
-
class DatePicker extends DatePickerMixin(
|
|
151
|
+
class DatePicker extends DatePickerMixin(
|
|
152
|
+
InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
153
|
+
) {
|
|
154
154
|
static get is() {
|
|
155
155
|
return 'vaadin-date-picker';
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
static get
|
|
158
|
+
static get styles() {
|
|
159
|
+
return [inputFieldShared, datePickerStyles];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static get properties() {
|
|
163
|
+
return {
|
|
164
|
+
/** @private */
|
|
165
|
+
_positionTarget: {
|
|
166
|
+
type: Object,
|
|
167
|
+
sync: true,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
174
|
+
* @protected
|
|
175
|
+
* @return {!HTMLElement}
|
|
176
|
+
*/
|
|
177
|
+
get clearElement() {
|
|
178
|
+
return this.$.clearButton;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** @protected */
|
|
182
|
+
render() {
|
|
159
183
|
return html`
|
|
160
184
|
<div class="vaadin-date-picker-container">
|
|
161
185
|
<div part="label">
|
|
162
186
|
<slot name="label"></slot>
|
|
163
|
-
<span part="required-indicator" aria-hidden="true"
|
|
187
|
+
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
164
188
|
</div>
|
|
165
189
|
|
|
166
190
|
<vaadin-input-container
|
|
167
191
|
part="input-field"
|
|
168
|
-
readonly="
|
|
169
|
-
disabled="
|
|
170
|
-
invalid="
|
|
171
|
-
theme
|
|
192
|
+
.readonly="${this.readonly}"
|
|
193
|
+
.disabled="${this.disabled}"
|
|
194
|
+
.invalid="${this.invalid}"
|
|
195
|
+
theme="${ifDefined(this._theme)}"
|
|
172
196
|
>
|
|
173
197
|
<slot name="prefix" slot="prefix"></slot>
|
|
174
198
|
<slot name="input"></slot>
|
|
175
199
|
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
176
|
-
<div part="toggle-button" slot="suffix" aria-hidden="true"
|
|
200
|
+
<div part="toggle-button" slot="suffix" aria-hidden="true" @click="${this._toggle}"></div>
|
|
177
201
|
</vaadin-input-container>
|
|
178
202
|
|
|
179
203
|
<div part="helper-text">
|
|
@@ -187,29 +211,28 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
187
211
|
|
|
188
212
|
<vaadin-date-picker-overlay
|
|
189
213
|
id="overlay"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
214
|
+
.owner="${this}"
|
|
215
|
+
?fullscreen="${this._fullscreen}"
|
|
216
|
+
theme="${ifDefined(this._theme)}"
|
|
217
|
+
.opened="${this.opened}"
|
|
218
|
+
@opened-changed="${this._onOpenedChanged}"
|
|
219
|
+
@vaadin-overlay-escape-press="${this._onOverlayEscapePress}"
|
|
220
|
+
@vaadin-overlay-open="${this._onOverlayOpened}"
|
|
221
|
+
@vaadin-overlay-close="${this._onVaadinOverlayClose}"
|
|
222
|
+
@vaadin-overlay-closing="${this._onOverlayClosed}"
|
|
196
223
|
restore-focus-on-close
|
|
197
|
-
|
|
198
|
-
|
|
224
|
+
no-vertical-overlap
|
|
225
|
+
exportparts="backdrop, overlay, content"
|
|
226
|
+
.restoreFocusNode="${this.inputElement}"
|
|
227
|
+
.positionTarget="${this._positionTarget}"
|
|
228
|
+
>
|
|
229
|
+
<slot name="overlay"></slot>
|
|
230
|
+
</vaadin-date-picker-overlay>
|
|
199
231
|
|
|
200
232
|
<slot name="tooltip"></slot>
|
|
201
233
|
`;
|
|
202
234
|
}
|
|
203
235
|
|
|
204
|
-
/**
|
|
205
|
-
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
206
|
-
* @protected
|
|
207
|
-
* @return {!HTMLElement}
|
|
208
|
-
*/
|
|
209
|
-
get clearElement() {
|
|
210
|
-
return this.$.clearButton;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
236
|
/** @protected */
|
|
214
237
|
ready() {
|
|
215
238
|
super.ready();
|
|
@@ -239,10 +262,15 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
239
262
|
this._tooltipController.setAriaTarget(this.inputElement);
|
|
240
263
|
this._tooltipController.setShouldShow((target) => !target.opened);
|
|
241
264
|
|
|
265
|
+
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
266
|
+
|
|
242
267
|
const toggleButton = this.shadowRoot.querySelector('[part="toggle-button"]');
|
|
243
268
|
toggleButton.addEventListener('mousedown', (e) => e.preventDefault());
|
|
269
|
+
}
|
|
244
270
|
|
|
245
|
-
|
|
271
|
+
/** @private */
|
|
272
|
+
_onOpenedChanged(event) {
|
|
273
|
+
this.opened = event.detail.value;
|
|
246
274
|
}
|
|
247
275
|
|
|
248
276
|
/** @private */
|
|
@@ -262,15 +290,6 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
262
290
|
this.open();
|
|
263
291
|
}
|
|
264
292
|
}
|
|
265
|
-
|
|
266
|
-
// Workaround https://github.com/vaadin/web-components/issues/2855
|
|
267
|
-
/** @protected */
|
|
268
|
-
_openedChanged(opened) {
|
|
269
|
-
super._openedChanged(opened);
|
|
270
|
-
|
|
271
|
-
this.$.overlay.positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
272
|
-
this.$.overlay.noVerticalOverlap = true;
|
|
273
|
-
}
|
|
274
293
|
}
|
|
275
294
|
|
|
276
295
|
defineCustomElement(DatePicker);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { flush } from '@polymer/polymer/lib/utils/flush.js';
|
|
7
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
8
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
8
|
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
@@ -22,13 +21,8 @@ template.innerHTML = `
|
|
|
22
21
|
height: 100%;
|
|
23
22
|
overflow: auto;
|
|
24
23
|
outline: none;
|
|
25
|
-
margin-right: -40px;
|
|
26
|
-
-webkit-overflow-scrolling: touch;
|
|
27
24
|
overflow-x: hidden;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#scroller.notouchscroll {
|
|
31
|
-
-webkit-overflow-scrolling: auto;
|
|
25
|
+
scrollbar-width: none;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
#scroller::-webkit-scrollbar {
|
|
@@ -39,7 +33,6 @@ template.innerHTML = `
|
|
|
39
33
|
position: absolute;
|
|
40
34
|
width: var(--vaadin-infinite-scroller-buffer-width, 100%);
|
|
41
35
|
box-sizing: border-box;
|
|
42
|
-
padding-right: 40px;
|
|
43
36
|
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
44
37
|
}
|
|
45
38
|
</style>
|
|
@@ -159,17 +152,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
159
152
|
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
160
153
|
this._scrollDisabled = false;
|
|
161
154
|
}
|
|
162
|
-
|
|
163
|
-
if (this._mayHaveMomentum) {
|
|
164
|
-
// Stop the possible iOS Safari momentum with -webkit-overflow-scrolling: auto;
|
|
165
|
-
this.$.scroller.classList.add('notouchscroll');
|
|
166
|
-
this._mayHaveMomentum = false;
|
|
167
|
-
|
|
168
|
-
setTimeout(() => {
|
|
169
|
-
// Restore -webkit-overflow-scrolling: touch; after a small delay.
|
|
170
|
-
this.$.scroller.classList.remove('notouchscroll');
|
|
171
|
-
}, 10);
|
|
172
|
-
}
|
|
173
155
|
}
|
|
174
156
|
|
|
175
157
|
/** @protected */
|
|
@@ -220,8 +202,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
220
202
|
this._updateClones();
|
|
221
203
|
this._debouncerUpdateClones.cancel();
|
|
222
204
|
}
|
|
223
|
-
|
|
224
|
-
flush();
|
|
225
205
|
}
|
|
226
206
|
|
|
227
207
|
/**
|
|
@@ -295,7 +275,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
295
275
|
|
|
296
276
|
if (!this._preventScrollEvent) {
|
|
297
277
|
this.dispatchEvent(new CustomEvent('custom-scroll', { bubbles: false, composed: true }));
|
|
298
|
-
this._mayHaveMomentum = true;
|
|
299
278
|
}
|
|
300
279
|
this._preventScrollEvent = false;
|
|
301
280
|
|
|
@@ -3,76 +3,98 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import '
|
|
7
|
-
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
8
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
|
-
import {
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
10
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import { monthCalendarStyles } from './styles/vaadin-month-calendar-core-styles.js';
|
|
10
12
|
import { MonthCalendarMixin } from './vaadin-month-calendar-mixin.js';
|
|
11
|
-
import { monthCalendarStyles } from './vaadin-month-calendar-styles.js';
|
|
12
|
-
|
|
13
|
-
registerStyles('vaadin-month-calendar', monthCalendarStyles, {
|
|
14
|
-
moduleId: 'vaadin-month-calendar-styles',
|
|
15
|
-
});
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* @customElement
|
|
19
16
|
* @extends HTMLElement
|
|
20
17
|
* @private
|
|
21
18
|
*/
|
|
22
|
-
class MonthCalendar extends MonthCalendarMixin(ThemableMixin(
|
|
23
|
-
static get
|
|
19
|
+
class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
20
|
+
static get is() {
|
|
21
|
+
return 'vaadin-month-calendar';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static get styles() {
|
|
25
|
+
return monthCalendarStyles;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @protected */
|
|
29
|
+
render() {
|
|
30
|
+
const weekDayNames = this.__computeWeekDayNames(this.i18n, this.showWeekNumbers);
|
|
31
|
+
const weeks = this._weeks;
|
|
32
|
+
const hideWeekSeparator = !this.__computeShowWeekSeparator(this.showWeekNumbers, this.i18n);
|
|
33
|
+
|
|
24
34
|
return html`
|
|
25
|
-
<div part="month-header" id="month-header" aria-hidden="true"
|
|
35
|
+
<div part="month-header" id="month-header" aria-hidden="true">${this._getTitle(this.month, this.i18n)}</div>
|
|
26
36
|
<table
|
|
27
37
|
id="monthGrid"
|
|
28
38
|
role="grid"
|
|
29
39
|
aria-labelledby="month-header"
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
@touchend="${this._preventDefault}"
|
|
41
|
+
@touchstart="${this._onMonthGridTouchStart}"
|
|
32
42
|
>
|
|
33
43
|
<thead id="weekdays-container">
|
|
34
44
|
<tr role="row" part="weekdays">
|
|
35
|
-
<th part="weekday" aria-hidden="true" hidden
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
<th part="weekday" aria-hidden="true" ?hidden="${hideWeekSeparator}"></th>
|
|
46
|
+
${weekDayNames.map(
|
|
47
|
+
(item) => html`
|
|
48
|
+
<th role="columnheader" part="weekday" scope="col" abbr="${item.weekDay}" aria-hidden="true">
|
|
49
|
+
${item.weekDayShort}
|
|
50
|
+
</th>
|
|
51
|
+
`,
|
|
52
|
+
)}
|
|
41
53
|
</tr>
|
|
42
54
|
</thead>
|
|
43
55
|
<tbody id="days-container">
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
part="week-number"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
${weeks.map(
|
|
57
|
+
(week) => html`
|
|
58
|
+
<tr role="row">
|
|
59
|
+
<td part="week-number" aria-hidden="true" ?hidden="${hideWeekSeparator}">
|
|
60
|
+
${this.__computeWeekNumber(week)}
|
|
61
|
+
</td>
|
|
62
|
+
${week.map((date) => {
|
|
63
|
+
return html`
|
|
64
|
+
<td
|
|
65
|
+
role="gridcell"
|
|
66
|
+
part="${this.__computeDatePart(
|
|
67
|
+
date,
|
|
68
|
+
this.focusedDate,
|
|
69
|
+
this.selectedDate,
|
|
70
|
+
this.minDate,
|
|
71
|
+
this.maxDate,
|
|
72
|
+
this.isDateDisabled,
|
|
73
|
+
this.enteredDate,
|
|
74
|
+
this.__hasFocus,
|
|
75
|
+
)}"
|
|
76
|
+
.date="${date}"
|
|
77
|
+
?disabled="${this.__isDayDisabled(date, this.minDate, this.maxDate, this.isDateDisabled)}"
|
|
78
|
+
tabindex="${this.__computeDayTabIndex(date, this.focusedDate)}"
|
|
79
|
+
aria-selected="${this.__computeDayAriaSelected(date, this.selectedDate)}"
|
|
80
|
+
aria-disabled="${this.__computeDayAriaDisabled(
|
|
81
|
+
date,
|
|
82
|
+
this.minDate,
|
|
83
|
+
this.maxDate,
|
|
84
|
+
this.isDateDisabled,
|
|
85
|
+
)}"
|
|
86
|
+
aria-label="${this.__computeDayAriaLabel(date)}"
|
|
87
|
+
>${this._getDate(date)}</td
|
|
88
|
+
>
|
|
89
|
+
`;
|
|
90
|
+
})}
|
|
91
|
+
</tr>
|
|
92
|
+
`,
|
|
93
|
+
)}
|
|
68
94
|
</tbody>
|
|
69
95
|
</table>
|
|
70
96
|
`;
|
|
71
97
|
}
|
|
72
|
-
|
|
73
|
-
static get is() {
|
|
74
|
-
return 'vaadin-month-calendar';
|
|
75
|
-
}
|
|
76
98
|
}
|
|
77
99
|
|
|
78
100
|
defineCustomElement(MonthCalendar);
|
|
@@ -20,6 +20,10 @@ registerStyles(
|
|
|
20
20
|
cursor: default;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
:host([dir='rtl']) {
|
|
24
|
+
background-position: top left;
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
::slotted([slot='months']) {
|
|
24
28
|
/* Month calendar height:
|
|
25
29
|
header height + margin-bottom
|
|
@@ -36,39 +40,26 @@ registerStyles(
|
|
|
36
40
|
+ var(--lumo-space-s)
|
|
37
41
|
);
|
|
38
42
|
--vaadin-infinite-scroller-buffer-offset: 10%;
|
|
39
|
-
-webkit-mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
40
43
|
mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
41
44
|
position: relative;
|
|
42
|
-
margin-right: 57px;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
::slotted([slot='years']) {
|
|
46
48
|
/* TODO get rid of fixed magic number */
|
|
47
|
-
--vaadin-infinite-scroller-buffer-width:
|
|
49
|
+
--vaadin-infinite-scroller-buffer-width: 57px;
|
|
48
50
|
width: 57px;
|
|
49
|
-
height: auto;
|
|
50
|
-
top: 0;
|
|
51
|
-
bottom: 0;
|
|
52
51
|
font-size: var(--lumo-font-size-s);
|
|
53
52
|
box-shadow: inset 2px 0 4px 0 var(--lumo-shade-5pct);
|
|
54
|
-
-webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
|
|
55
53
|
mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
|
|
56
54
|
cursor: var(--lumo-clickable-cursor);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
::slotted([slot='years']
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* TODO unsupported selector */
|
|
64
|
-
#scrollers {
|
|
65
|
-
position: static;
|
|
66
|
-
display: block;
|
|
57
|
+
:host([dir='rtl']) ::slotted([slot='years']) {
|
|
58
|
+
box-shadow: inset -2px 0 4px 0 var(--lumo-shade-5pct);
|
|
67
59
|
}
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
right: auto;
|
|
61
|
+
::slotted([slot='years']:hover) {
|
|
62
|
+
--_lumo-date-picker-year-opacity: 1;
|
|
72
63
|
}
|
|
73
64
|
|
|
74
65
|
/* Year scroller position indicator */
|
|
@@ -84,10 +75,14 @@ registerStyles(
|
|
|
84
75
|
z-index: 1;
|
|
85
76
|
}
|
|
86
77
|
|
|
78
|
+
:host([dir='rtl']) ::slotted([slot='years'])::before {
|
|
79
|
+
right: 0;
|
|
80
|
+
transform: translate(75%, -50%) rotate(45deg);
|
|
81
|
+
}
|
|
82
|
+
|
|
87
83
|
[part='toolbar'] {
|
|
88
84
|
padding: var(--lumo-space-s);
|
|
89
85
|
border-bottom-left-radius: var(--lumo-border-radius-l);
|
|
90
|
-
margin-right: 57px;
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
[part='toolbar'] ::slotted(vaadin-button) {
|
|
@@ -97,24 +92,8 @@ registerStyles(
|
|
|
97
92
|
/* Narrow viewport mode (fullscreen) */
|
|
98
93
|
|
|
99
94
|
:host([fullscreen]) [part='toolbar'] {
|
|
100
|
-
order: -1;
|
|
101
95
|
background-color: var(--lumo-base-color);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
:host([fullscreen]) [part='overlay-header'] {
|
|
105
|
-
order: -2;
|
|
106
|
-
height: var(--lumo-size-m);
|
|
107
|
-
padding: var(--lumo-space-s);
|
|
108
|
-
position: absolute;
|
|
109
|
-
left: 0;
|
|
110
|
-
right: 0;
|
|
111
|
-
justify-content: center;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
:host([fullscreen]) [part='toggle-button'],
|
|
115
|
-
:host([fullscreen]) [part='clear-button'],
|
|
116
|
-
[part='overlay-header'] [part='label'] {
|
|
117
|
-
display: none;
|
|
96
|
+
margin-inline-end: 57px;
|
|
118
97
|
}
|
|
119
98
|
|
|
120
99
|
/* Very narrow screen (year scroller initially hidden) */
|
|
@@ -122,10 +101,9 @@ registerStyles(
|
|
|
122
101
|
[part='years-toggle-button'] {
|
|
123
102
|
display: flex;
|
|
124
103
|
align-items: center;
|
|
125
|
-
height: var(--lumo-size-
|
|
104
|
+
height: var(--lumo-size-m);
|
|
126
105
|
padding: 0 0.5em;
|
|
127
106
|
border-radius: var(--lumo-border-radius-m);
|
|
128
|
-
z-index: 3;
|
|
129
107
|
color: var(--lumo-primary-text-color);
|
|
130
108
|
font-weight: 500;
|
|
131
109
|
-webkit-font-smoothing: antialiased;
|
|
@@ -143,21 +121,16 @@ registerStyles(
|
|
|
143
121
|
background-image: none;
|
|
144
122
|
}
|
|
145
123
|
|
|
146
|
-
[part='toolbar']
|
|
147
|
-
|
|
148
|
-
margin-right: 0;
|
|
124
|
+
:host([fullscreen]) [part='toolbar'] {
|
|
125
|
+
margin-inline-end: 0;
|
|
149
126
|
}
|
|
150
127
|
|
|
151
128
|
/* TODO make date-picker adapt to the width of the years part */
|
|
152
129
|
::slotted([slot='years']) {
|
|
153
|
-
--vaadin-infinite-scroller-buffer-width:
|
|
130
|
+
--vaadin-infinite-scroller-buffer-width: 50px;
|
|
154
131
|
width: 50px;
|
|
155
132
|
background-color: var(--lumo-shade-5pct);
|
|
156
133
|
}
|
|
157
|
-
|
|
158
|
-
:host([years-visible]) ::slotted([slot='months']) {
|
|
159
|
-
padding-left: 50px;
|
|
160
|
-
}
|
|
161
134
|
}
|
|
162
135
|
`,
|
|
163
136
|
{ moduleId: 'lumo-date-picker-overlay-content' },
|