@vaadin/date-picker 25.0.0-alpha1 → 25.0.0-alpha11
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 +13 -14
- package/src/styles/vaadin-date-picker-base-styles.d.ts +8 -0
- package/src/{vaadin-date-picker-styles.js → styles/vaadin-date-picker-base-styles.js} +9 -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-year-base-styles.js +26 -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 +45 -31
- package/src/vaadin-date-picker-month-scroller.js +2 -6
- package/src/vaadin-date-picker-overlay-content-mixin.js +5 -132
- package/src/vaadin-date-picker-overlay-content.js +13 -17
- package/src/vaadin-date-picker-overlay.js +17 -3
- package/src/vaadin-date-picker-year-scroller.js +3 -4
- package/src/vaadin-date-picker-year.js +32 -9
- package/src/vaadin-date-picker.d.ts +11 -16
- package/src/vaadin-date-picker.js +23 -20
- package/src/vaadin-infinite-scroller.js +1 -19
- package/src/vaadin-month-calendar.js +3 -2
- package/vaadin-date-picker.js +1 -1
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
- package/src/vaadin-date-picker-overlay-content-styles.js +0 -68
- package/src/vaadin-date-picker-overlay-styles.js +0 -23
- package/src/vaadin-date-picker-year-mixin.js +0 -35
- package/src/vaadin-month-calendar-styles.js +0 -64
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.d.ts +0 -7
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +0 -164
- package/theme/lumo/vaadin-date-picker-overlay-styles.d.ts +0 -2
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +0 -55
- package/theme/lumo/vaadin-date-picker-styles.d.ts +0 -2
- package/theme/lumo/vaadin-date-picker-styles.js +0 -30
- package/theme/lumo/vaadin-date-picker-year-styles.d.ts +0 -1
- package/theme/lumo/vaadin-date-picker-year-styles.js +0 -32
- package/theme/lumo/vaadin-date-picker.d.ts +0 -5
- package/theme/lumo/vaadin-date-picker.js +0 -5
- package/theme/lumo/vaadin-month-calendar-styles.d.ts +0 -5
- package/theme/lumo/vaadin-month-calendar-styles.js +0 -158
|
@@ -5,16 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
|
-
import { addListener
|
|
8
|
+
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
9
9
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
10
10
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
11
|
-
import {
|
|
12
|
-
dateAfterXMonths,
|
|
13
|
-
dateAllowed,
|
|
14
|
-
dateEquals,
|
|
15
|
-
extractDateParts,
|
|
16
|
-
getClosestDate,
|
|
17
|
-
} from './vaadin-date-picker-helper.js';
|
|
11
|
+
import { dateAfterXMonths, dateAllowed, dateEquals, getClosestDate } from './vaadin-date-picker-helper.js';
|
|
18
12
|
|
|
19
13
|
/**
|
|
20
14
|
* @polymerMixin
|
|
@@ -75,14 +69,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
75
69
|
value: '(min-width: 375px)',
|
|
76
70
|
},
|
|
77
71
|
|
|
78
|
-
_translateX: {
|
|
79
|
-
observer: '_translateXChanged',
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
_yearScrollerWidth: {
|
|
83
|
-
value: 50,
|
|
84
|
-
},
|
|
85
|
-
|
|
86
72
|
i18n: {
|
|
87
73
|
type: Object,
|
|
88
74
|
},
|
|
@@ -178,20 +164,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
178
164
|
return this.calendars.map((calendar) => calendar.focusableDateElement).find(Boolean);
|
|
179
165
|
}
|
|
180
166
|
|
|
181
|
-
/** @protected */
|
|
182
|
-
_addListeners() {
|
|
183
|
-
setTouchAction(this.$.scrollers, 'pan-y');
|
|
184
|
-
|
|
185
|
-
addListener(this.$.scrollers, 'track', this._track.bind(this));
|
|
186
|
-
addListener(this.shadowRoot.querySelector('[part="clear-button"]'), 'tap', this._clear.bind(this));
|
|
187
|
-
addListener(this.shadowRoot.querySelector('[part="toggle-button"]'), 'tap', this._cancel.bind(this));
|
|
188
|
-
addListener(
|
|
189
|
-
this.shadowRoot.querySelector('[part="years-toggle-button"]'),
|
|
190
|
-
'tap',
|
|
191
|
-
this._toggleYearScroller.bind(this),
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
167
|
/** @protected */
|
|
196
168
|
_initControllers() {
|
|
197
169
|
this.addController(
|
|
@@ -206,7 +178,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
206
178
|
initializer: (btn) => {
|
|
207
179
|
btn.setAttribute('theme', 'tertiary');
|
|
208
180
|
btn.addEventListener('keydown', (e) => this.__onTodayButtonKeyDown(e));
|
|
209
|
-
|
|
181
|
+
btn.addEventListener('click', this._onTodayTap.bind(this));
|
|
210
182
|
this._todayButton = btn;
|
|
211
183
|
},
|
|
212
184
|
}),
|
|
@@ -218,7 +190,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
218
190
|
initializer: (btn) => {
|
|
219
191
|
btn.setAttribute('theme', 'tertiary');
|
|
220
192
|
btn.addEventListener('keydown', (e) => this.__onCancelButtonKeyDown(e));
|
|
221
|
-
|
|
193
|
+
btn.addEventListener('click', this._cancel.bind(this));
|
|
222
194
|
this._cancelButton = btn;
|
|
223
195
|
},
|
|
224
196
|
}),
|
|
@@ -230,7 +202,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
230
202
|
|
|
231
203
|
reset() {
|
|
232
204
|
this._closeYearScroller();
|
|
233
|
-
this._toggleAnimateClass(true);
|
|
234
205
|
}
|
|
235
206
|
|
|
236
207
|
/**
|
|
@@ -527,14 +498,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
527
498
|
});
|
|
528
499
|
}
|
|
529
500
|
|
|
530
|
-
/** @protected */
|
|
531
|
-
_formatDisplayed(date, i18n, label) {
|
|
532
|
-
if (date && i18n && typeof i18n.formatDate === 'function') {
|
|
533
|
-
return i18n.formatDate(extractDateParts(date));
|
|
534
|
-
}
|
|
535
|
-
return label;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
501
|
/** @private */
|
|
539
502
|
_onTodayTap() {
|
|
540
503
|
const today = this._getTodayMidnight();
|
|
@@ -647,99 +610,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
647
610
|
window.requestAnimationFrame(smoothScroll);
|
|
648
611
|
}
|
|
649
612
|
|
|
650
|
-
/** @private */
|
|
651
|
-
_limit(value, range) {
|
|
652
|
-
return Math.min(range.max, Math.max(range.min, value));
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/** @private */
|
|
656
|
-
_handleTrack(e) {
|
|
657
|
-
// Check if horizontal movement threshold (dx) not exceeded or
|
|
658
|
-
// scrolling fast vertically (ddy).
|
|
659
|
-
if (Math.abs(e.detail.dx) < 10 || Math.abs(e.detail.ddy) > 10) {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// If we're flinging quickly -> start animating already.
|
|
664
|
-
if (Math.abs(e.detail.ddx) > this._yearScrollerWidth / 3) {
|
|
665
|
-
this._toggleAnimateClass(true);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
const newTranslateX = this._translateX + e.detail.ddx;
|
|
669
|
-
this._translateX = this._limit(newTranslateX, {
|
|
670
|
-
min: 0,
|
|
671
|
-
max: this._yearScrollerWidth,
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/** @private */
|
|
676
|
-
_track(e) {
|
|
677
|
-
if (this._desktopMode) {
|
|
678
|
-
// No need to track for swipe gestures on desktop.
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
switch (e.detail.state) {
|
|
683
|
-
case 'start':
|
|
684
|
-
this._toggleAnimateClass(false);
|
|
685
|
-
break;
|
|
686
|
-
case 'track':
|
|
687
|
-
this._handleTrack(e);
|
|
688
|
-
break;
|
|
689
|
-
case 'end':
|
|
690
|
-
this._toggleAnimateClass(true);
|
|
691
|
-
if (this._translateX >= this._yearScrollerWidth / 2) {
|
|
692
|
-
this._closeYearScroller();
|
|
693
|
-
} else {
|
|
694
|
-
this._openYearScroller();
|
|
695
|
-
}
|
|
696
|
-
break;
|
|
697
|
-
default:
|
|
698
|
-
break;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/** @private */
|
|
703
|
-
_toggleAnimateClass(enable) {
|
|
704
|
-
if (enable) {
|
|
705
|
-
this.classList.add('animate');
|
|
706
|
-
} else {
|
|
707
|
-
this.classList.remove('animate');
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
613
|
/** @private */
|
|
712
614
|
_toggleYearScroller() {
|
|
713
|
-
|
|
714
|
-
this._closeYearScroller();
|
|
715
|
-
} else {
|
|
716
|
-
this._openYearScroller();
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
/** @private */
|
|
721
|
-
_openYearScroller() {
|
|
722
|
-
this._translateX = 0;
|
|
723
|
-
this.setAttribute('years-visible', '');
|
|
615
|
+
this.toggleAttribute('years-visible');
|
|
724
616
|
}
|
|
725
617
|
|
|
726
618
|
/** @private */
|
|
727
619
|
_closeYearScroller() {
|
|
728
620
|
this.removeAttribute('years-visible');
|
|
729
|
-
this._translateX = this._yearScrollerWidth;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/** @private */
|
|
733
|
-
_isYearScrollerVisible() {
|
|
734
|
-
return this._translateX < this._yearScrollerWidth / 2;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
/** @private */
|
|
738
|
-
_translateXChanged(x) {
|
|
739
|
-
if (!this._desktopMode) {
|
|
740
|
-
this._monthScroller.style.transform = `translateX(${x - this._yearScrollerWidth}px)`;
|
|
741
|
-
this._yearScroller.style.transform = `translateX(${x}px)`;
|
|
742
|
-
}
|
|
743
621
|
}
|
|
744
622
|
|
|
745
623
|
/** @private */
|
|
@@ -769,11 +647,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
|
|
|
769
647
|
this._close();
|
|
770
648
|
}
|
|
771
649
|
|
|
772
|
-
/** @protected */
|
|
773
|
-
_preventDefault(e) {
|
|
774
|
-
e.preventDefault();
|
|
775
|
-
}
|
|
776
|
-
|
|
777
650
|
/** @private */
|
|
778
651
|
__toggleDate(date) {
|
|
779
652
|
if (dateEquals(date, this.selectedDate)) {
|
|
@@ -12,9 +12,10 @@ import { html, LitElement } from 'lit';
|
|
|
12
12
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
13
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
14
14
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
15
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
15
16
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
17
|
+
import { overlayContentStyles } from './styles/vaadin-date-picker-overlay-content-base-styles.js';
|
|
16
18
|
import { DatePickerOverlayContentMixin } from './vaadin-date-picker-overlay-content-mixin.js';
|
|
17
|
-
import { overlayContentStyles } from './vaadin-date-picker-overlay-content-styles.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @customElement
|
|
@@ -22,7 +23,7 @@ import { overlayContentStyles } from './vaadin-date-picker-overlay-content-style
|
|
|
22
23
|
* @private
|
|
23
24
|
*/
|
|
24
25
|
class DatePickerOverlayContent extends DatePickerOverlayContentMixin(
|
|
25
|
-
ThemableMixin(DirMixin(PolylitMixin(LitElement))),
|
|
26
|
+
ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement)))),
|
|
26
27
|
) {
|
|
27
28
|
static get is() {
|
|
28
29
|
return 'vaadin-date-picker-overlay-content';
|
|
@@ -35,23 +36,19 @@ class DatePickerOverlayContent extends DatePickerOverlayContentMixin(
|
|
|
35
36
|
/** @protected */
|
|
36
37
|
render() {
|
|
37
38
|
return html`
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
<div part="clear-button" ?hidden="${!this.selectedDate}"></div>
|
|
41
|
-
<div part="toggle-button"></div>
|
|
39
|
+
<slot name="months"></slot>
|
|
40
|
+
<slot name="years"></slot>
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
<div role="toolbar" part="toolbar">
|
|
43
|
+
<slot name="today-button"></slot>
|
|
44
|
+
<div
|
|
45
|
+
part="years-toggle-button"
|
|
46
|
+
?hidden="${this._desktopMode}"
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
@click="${this._toggleYearScroller}"
|
|
49
|
+
>
|
|
44
50
|
${this._yearAfterXMonths(this._visibleMonthIndex)}
|
|
45
51
|
</div>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<div id="scrollers">
|
|
49
|
-
<slot name="months"></slot>
|
|
50
|
-
<slot name="years"></slot>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<div @touchend="${this._preventDefault}" role="toolbar" part="toolbar">
|
|
54
|
-
<slot name="today-button"></slot>
|
|
55
52
|
<slot name="cancel-button"></slot>
|
|
56
53
|
</div>
|
|
57
54
|
`;
|
|
@@ -63,7 +60,6 @@ class DatePickerOverlayContent extends DatePickerOverlayContentMixin(
|
|
|
63
60
|
|
|
64
61
|
this.setAttribute('role', 'dialog');
|
|
65
62
|
|
|
66
|
-
this._addListeners();
|
|
67
63
|
this._initControllers();
|
|
68
64
|
}
|
|
69
65
|
}
|
|
@@ -7,10 +7,11 @@ import { html, LitElement } from 'lit';
|
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
10
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
|
|
11
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
11
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { datePickerOverlayStyles } from './styles/vaadin-date-picker-overlay-base-styles.js';
|
|
12
14
|
import { DatePickerOverlayMixin } from './vaadin-date-picker-overlay-mixin.js';
|
|
13
|
-
import { datePickerOverlayStyles } from './vaadin-date-picker-overlay-styles.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
@@ -22,7 +23,9 @@ import { datePickerOverlayStyles } from './vaadin-date-picker-overlay-styles.js'
|
|
|
22
23
|
* @mixes ThemableMixin
|
|
23
24
|
* @private
|
|
24
25
|
*/
|
|
25
|
-
class DatePickerOverlay extends DatePickerOverlayMixin(
|
|
26
|
+
class DatePickerOverlay extends DatePickerOverlayMixin(
|
|
27
|
+
DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))),
|
|
28
|
+
) {
|
|
26
29
|
static get is() {
|
|
27
30
|
return 'vaadin-date-picker-overlay';
|
|
28
31
|
}
|
|
@@ -42,6 +45,17 @@ class DatePickerOverlay extends DatePickerOverlayMixin(DirMixin(ThemableMixin(Po
|
|
|
42
45
|
</div>
|
|
43
46
|
`;
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Override method from `OverlayFocusMixin` to specify content root
|
|
51
|
+
* used to detect whether focus should be restored on overlay close.
|
|
52
|
+
*
|
|
53
|
+
* @protected
|
|
54
|
+
* @override
|
|
55
|
+
*/
|
|
56
|
+
get _contentRoot() {
|
|
57
|
+
return this.owner._overlayContent;
|
|
58
|
+
}
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
defineCustomElement(DatePickerOverlay);
|
|
@@ -13,10 +13,9 @@ stylesTemplate.innerHTML = `
|
|
|
13
13
|
--vaadin-infinite-scroller-item-height: 80px;
|
|
14
14
|
width: 50px;
|
|
15
15
|
display: block;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
transform: translateX(100%);
|
|
16
|
+
position: relative;
|
|
17
|
+
grid-area: years;
|
|
18
|
+
height: auto;
|
|
20
19
|
-webkit-tap-highlight-color: transparent;
|
|
21
20
|
-webkit-user-select: none;
|
|
22
21
|
user-select: none;
|
|
@@ -3,11 +3,12 @@
|
|
|
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 {
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
9
10
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
-
import {
|
|
11
|
+
import { datePickerYearStyles } from './styles/vaadin-date-picker-year-base-styles.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
@@ -18,18 +19,27 @@ import { DatePickerYearMixin } from './vaadin-date-picker-year-mixin.js';
|
|
|
18
19
|
* @mixes DatePickerYearMixin
|
|
19
20
|
* @private
|
|
20
21
|
*/
|
|
21
|
-
export class DatePickerYear extends ThemableMixin(
|
|
22
|
+
export class DatePickerYear extends ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))) {
|
|
22
23
|
static get is() {
|
|
23
24
|
return 'vaadin-date-picker-year';
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
static get styles() {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return datePickerYearStyles;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get properties() {
|
|
32
|
+
return {
|
|
33
|
+
year: {
|
|
34
|
+
type: String,
|
|
35
|
+
sync: true,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
selectedDate: {
|
|
39
|
+
type: Object,
|
|
40
|
+
sync: true,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
/** @protected */
|
|
@@ -39,6 +49,19 @@ export class DatePickerYear extends ThemableMixin(DatePickerYearMixin(PolylitMix
|
|
|
39
49
|
<div part="year-separator" aria-hidden="true"></div>
|
|
40
50
|
`;
|
|
41
51
|
}
|
|
52
|
+
|
|
53
|
+
/** @protected */
|
|
54
|
+
updated(props) {
|
|
55
|
+
super.updated(props);
|
|
56
|
+
|
|
57
|
+
if (props.has('year')) {
|
|
58
|
+
this.toggleAttribute('current', this.year === new Date().getFullYear());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (props.has('year') || props.has('selectedDate')) {
|
|
62
|
+
this.toggleAttribute('selected', this.selectedDate && this.selectedDate.getFullYear() === this.year);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
defineCustomElement(DatePickerYear);
|
|
@@ -83,39 +83,37 @@ 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
|
+
* 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
|
|
95
99
|
*
|
|
96
100
|
* ### Internal components
|
|
97
101
|
*
|
|
98
102
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
99
103
|
* components are themable:
|
|
100
104
|
*
|
|
101
|
-
* - `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
102
105
|
* - `<vaadin-date-picker-overlay-content>`
|
|
103
106
|
* - `<vaadin-date-picker-month-scroller>`
|
|
104
107
|
* - `<vaadin-date-picker-year-scroller>`
|
|
105
108
|
* - `<vaadin-date-picker-year>`
|
|
106
109
|
* - `<vaadin-month-calendar>`
|
|
107
|
-
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
108
110
|
*
|
|
109
111
|
* In order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:
|
|
110
112
|
*
|
|
111
113
|
* Part name | Description
|
|
112
114
|
* ----------------------|--------------------
|
|
113
|
-
* `overlay-header` | Fullscreen mode header
|
|
114
|
-
* `label` | Fullscreen mode value/label
|
|
115
|
-
* `clear-button` | Fullscreen mode clear button
|
|
116
|
-
* `toggle-button` | Fullscreen mode toggle button
|
|
117
115
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
118
|
-
* `toolbar` |
|
|
116
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
119
117
|
*
|
|
120
118
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
121
119
|
*
|
|
@@ -149,9 +147,6 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
149
147
|
* `year-number` | Year number
|
|
150
148
|
* `year-separator` | Year separator
|
|
151
149
|
*
|
|
152
|
-
* Note: the `theme` attribute value set on `<vaadin-date-picker>` is
|
|
153
|
-
* propagated to the internal components listed above.
|
|
154
|
-
*
|
|
155
150
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
156
151
|
*
|
|
157
152
|
* ### Change events
|
|
@@ -16,9 +16,10 @@ import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js
|
|
|
16
16
|
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
17
17
|
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
18
18
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
19
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
19
20
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
21
|
+
import { datePickerStyles } from './styles/vaadin-date-picker-base-styles.js';
|
|
20
22
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
21
|
-
import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
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,39 +47,37 @@ import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
|
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`
|
|
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
|
|
58
63
|
*
|
|
59
64
|
* ### Internal components
|
|
60
65
|
*
|
|
61
66
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
62
67
|
* components are themable:
|
|
63
68
|
*
|
|
64
|
-
* - `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
65
69
|
* - `<vaadin-date-picker-overlay-content>`
|
|
66
70
|
* - `<vaadin-date-picker-month-scroller>`
|
|
67
71
|
* - `<vaadin-date-picker-year-scroller>`
|
|
68
72
|
* - `<vaadin-date-picker-year>`
|
|
69
73
|
* - `<vaadin-month-calendar>`
|
|
70
|
-
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
71
74
|
*
|
|
72
75
|
* In order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:
|
|
73
76
|
*
|
|
74
77
|
* Part name | Description
|
|
75
78
|
* ----------------------|--------------------
|
|
76
|
-
* `overlay-header` | Fullscreen mode header
|
|
77
|
-
* `label` | Fullscreen mode value/label
|
|
78
|
-
* `clear-button` | Fullscreen mode clear button
|
|
79
|
-
* `toggle-button` | Fullscreen mode toggle button
|
|
80
79
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
81
|
-
* `toolbar` |
|
|
80
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
82
81
|
*
|
|
83
82
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
84
83
|
*
|
|
@@ -112,9 +111,6 @@ import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
|
112
111
|
* `year-number` | Year number
|
|
113
112
|
* `year-separator` | Year separator
|
|
114
113
|
*
|
|
115
|
-
* Note: the `theme` attribute value set on `<vaadin-date-picker>` is
|
|
116
|
-
* propagated to the internal components listed above.
|
|
117
|
-
*
|
|
118
114
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
119
115
|
*
|
|
120
116
|
* ### Change events
|
|
@@ -147,7 +143,9 @@ import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
|
147
143
|
* @mixes InputControlMixin
|
|
148
144
|
* @mixes DatePickerMixin
|
|
149
145
|
*/
|
|
150
|
-
class DatePicker extends DatePickerMixin(
|
|
146
|
+
class DatePicker extends DatePickerMixin(
|
|
147
|
+
InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
148
|
+
) {
|
|
151
149
|
static get is() {
|
|
152
150
|
return 'vaadin-date-picker';
|
|
153
151
|
}
|
|
@@ -208,6 +206,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
208
206
|
|
|
209
207
|
<vaadin-date-picker-overlay
|
|
210
208
|
id="overlay"
|
|
209
|
+
.owner="${this}"
|
|
211
210
|
?fullscreen="${this._fullscreen}"
|
|
212
211
|
theme="${ifDefined(this._theme)}"
|
|
213
212
|
.opened="${this.opened}"
|
|
@@ -218,9 +217,12 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
218
217
|
@vaadin-overlay-closing="${this._onOverlayClosed}"
|
|
219
218
|
restore-focus-on-close
|
|
220
219
|
no-vertical-overlap
|
|
220
|
+
exportparts="backdrop, overlay, content"
|
|
221
221
|
.restoreFocusNode="${this.inputElement}"
|
|
222
222
|
.positionTarget="${this._positionTarget}"
|
|
223
|
-
|
|
223
|
+
>
|
|
224
|
+
<slot name="overlay"></slot>
|
|
225
|
+
</vaadin-date-picker-overlay>
|
|
224
226
|
|
|
225
227
|
<slot name="tooltip"></slot>
|
|
226
228
|
`;
|
|
@@ -269,7 +271,8 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
269
271
|
/** @private */
|
|
270
272
|
_onVaadinOverlayClose(e) {
|
|
271
273
|
// Prevent closing the overlay on label element click
|
|
272
|
-
|
|
274
|
+
const event = e.detail.sourceEvent;
|
|
275
|
+
if (event && event.composedPath().includes(this) && !event.composedPath().includes(this._overlayElement)) {
|
|
273
276
|
e.preventDefault();
|
|
274
277
|
}
|
|
275
278
|
}
|
|
@@ -21,13 +21,8 @@ template.innerHTML = `
|
|
|
21
21
|
height: 100%;
|
|
22
22
|
overflow: auto;
|
|
23
23
|
outline: none;
|
|
24
|
-
margin-right: -40px;
|
|
25
|
-
-webkit-overflow-scrolling: touch;
|
|
26
24
|
overflow-x: hidden;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#scroller.notouchscroll {
|
|
30
|
-
-webkit-overflow-scrolling: auto;
|
|
25
|
+
scrollbar-width: none;
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
#scroller::-webkit-scrollbar {
|
|
@@ -38,7 +33,6 @@ template.innerHTML = `
|
|
|
38
33
|
position: absolute;
|
|
39
34
|
width: var(--vaadin-infinite-scroller-buffer-width, 100%);
|
|
40
35
|
box-sizing: border-box;
|
|
41
|
-
padding-right: 40px;
|
|
42
36
|
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
43
37
|
}
|
|
44
38
|
</style>
|
|
@@ -158,17 +152,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
158
152
|
this.$.scroller.scrollTop += (index % 1) * this.itemHeight;
|
|
159
153
|
this._scrollDisabled = false;
|
|
160
154
|
}
|
|
161
|
-
|
|
162
|
-
if (this._mayHaveMomentum) {
|
|
163
|
-
// Stop the possible iOS Safari momentum with -webkit-overflow-scrolling: auto;
|
|
164
|
-
this.$.scroller.classList.add('notouchscroll');
|
|
165
|
-
this._mayHaveMomentum = false;
|
|
166
|
-
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
// Restore -webkit-overflow-scrolling: touch; after a small delay.
|
|
169
|
-
this.$.scroller.classList.remove('notouchscroll');
|
|
170
|
-
}, 10);
|
|
171
|
-
}
|
|
172
155
|
}
|
|
173
156
|
|
|
174
157
|
/** @protected */
|
|
@@ -292,7 +275,6 @@ export class InfiniteScroller extends HTMLElement {
|
|
|
292
275
|
|
|
293
276
|
if (!this._preventScrollEvent) {
|
|
294
277
|
this.dispatchEvent(new CustomEvent('custom-scroll', { bubbles: false, composed: true }));
|
|
295
|
-
this._mayHaveMomentum = true;
|
|
296
278
|
}
|
|
297
279
|
this._preventScrollEvent = false;
|
|
298
280
|
|
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
9
10
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import { monthCalendarStyles } from './styles/vaadin-month-calendar-base-styles.js';
|
|
10
12
|
import { MonthCalendarMixin } from './vaadin-month-calendar-mixin.js';
|
|
11
|
-
import { monthCalendarStyles } from './vaadin-month-calendar-styles.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @customElement
|
|
15
16
|
* @extends HTMLElement
|
|
16
17
|
* @private
|
|
17
18
|
*/
|
|
18
|
-
class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
19
|
+
class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
19
20
|
static get is() {
|
|
20
21
|
return 'vaadin-month-calendar';
|
|
21
22
|
}
|
package/vaadin-date-picker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './src/vaadin-date-picker.js';
|
|
2
2
|
export * from './src/vaadin-date-picker.js';
|