@vaadin/date-picker 25.0.0-alpha3 → 25.0.0-alpha4
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 +14 -12
- package/src/styles/vaadin-date-picker-base-styles.d.ts +8 -0
- package/src/styles/vaadin-date-picker-base-styles.js +28 -0
- package/src/styles/vaadin-date-picker-core-styles.d.ts +8 -0
- package/src/styles/vaadin-date-picker-overlay-base-styles.js +54 -0
- package/src/styles/vaadin-date-picker-overlay-content-base-styles.js +109 -0
- package/src/styles/vaadin-date-picker-overlay-content-core-styles.js +54 -0
- package/src/styles/vaadin-date-picker-year-base-styles.js +28 -0
- package/src/styles/vaadin-date-picker-year-core-styles.js +13 -0
- package/src/styles/vaadin-month-calendar-base-styles.js +145 -0
- package/src/vaadin-date-picker-helper.d.ts +5 -0
- 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 +6 -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 +1 -5
- package/src/vaadin-date-picker.js +7 -7
- package/src/vaadin-infinite-scroller.js +1 -2
- package/src/vaadin-month-calendar.js +3 -2
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +19 -44
- 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-year-mixin.js +0 -35
- /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
|
@@ -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 { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-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-core-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
|
+
CSSInjectionMixin(ThemableMixin(DirMixin(PolylitMixin(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-core-styles.js';
|
|
11
|
+
import { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-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-core-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(CSSInjectionMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
28
|
+
) {
|
|
26
29
|
static get is() {
|
|
27
30
|
return 'vaadin-date-picker-overlay';
|
|
28
31
|
}
|
|
@@ -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 { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-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-core-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 CSSInjectionMixin(ThemableMixin(PolylitMixin(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);
|
|
@@ -110,12 +110,8 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
110
110
|
*
|
|
111
111
|
* Part name | Description
|
|
112
112
|
* ----------------------|--------------------
|
|
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
113
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
118
|
-
* `toolbar` |
|
|
114
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
119
115
|
*
|
|
120
116
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
121
117
|
*
|
|
@@ -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 { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-injection-mixin.js';
|
|
19
20
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
21
|
+
import { datePickerStyles } from './styles/vaadin-date-picker-core-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.
|
|
@@ -73,12 +74,8 @@ import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
|
73
74
|
*
|
|
74
75
|
* Part name | Description
|
|
75
76
|
* ----------------------|--------------------
|
|
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
77
|
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
81
|
-
* `toolbar` |
|
|
78
|
+
* `toolbar` | Toolbar with slotted buttons
|
|
82
79
|
*
|
|
83
80
|
* The following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:
|
|
84
81
|
*
|
|
@@ -147,7 +144,9 @@ import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
|
147
144
|
* @mixes InputControlMixin
|
|
148
145
|
* @mixes DatePickerMixin
|
|
149
146
|
*/
|
|
150
|
-
class DatePicker extends DatePickerMixin(
|
|
147
|
+
class DatePicker extends DatePickerMixin(
|
|
148
|
+
InputControlMixin(CSSInjectionMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement))))),
|
|
149
|
+
) {
|
|
151
150
|
static get is() {
|
|
152
151
|
return 'vaadin-date-picker';
|
|
153
152
|
}
|
|
@@ -209,6 +208,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
209
208
|
<vaadin-date-picker-overlay
|
|
210
209
|
id="overlay"
|
|
211
210
|
?fullscreen="${this._fullscreen}"
|
|
211
|
+
?week-numbers="${this.showWeekNumbers}"
|
|
212
212
|
theme="${ifDefined(this._theme)}"
|
|
213
213
|
.opened="${this.opened}"
|
|
214
214
|
@opened-changed="${this._onOpenedChanged}"
|
|
@@ -21,9 +21,9 @@ template.innerHTML = `
|
|
|
21
21
|
height: 100%;
|
|
22
22
|
overflow: auto;
|
|
23
23
|
outline: none;
|
|
24
|
-
margin-right: -40px;
|
|
25
24
|
-webkit-overflow-scrolling: touch;
|
|
26
25
|
overflow-x: hidden;
|
|
26
|
+
scrollbar-width: none;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
#scroller.notouchscroll {
|
|
@@ -38,7 +38,6 @@ template.innerHTML = `
|
|
|
38
38
|
position: absolute;
|
|
39
39
|
width: var(--vaadin-infinite-scroller-buffer-width, 100%);
|
|
40
40
|
box-sizing: border-box;
|
|
41
|
-
padding-right: 40px;
|
|
42
41
|
top: var(--vaadin-infinite-scroller-buffer-offset, 0);
|
|
43
42
|
}
|
|
44
43
|
</style>
|
|
@@ -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 { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-injection-mixin.js';
|
|
9
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
|
|
|
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(CSSInjectionMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
19
20
|
static get is() {
|
|
20
21
|
return 'vaadin-month-calendar';
|
|
21
22
|
}
|
|
@@ -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
|
|
@@ -39,16 +43,12 @@ registerStyles(
|
|
|
39
43
|
-webkit-mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
40
44
|
mask-image: linear-gradient(transparent, #000 10%, #000 85%, transparent);
|
|
41
45
|
position: relative;
|
|
42
|
-
margin-right: 57px;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
::slotted([slot='years']) {
|
|
46
49
|
/* TODO get rid of fixed magic number */
|
|
47
|
-
--vaadin-infinite-scroller-buffer-width:
|
|
50
|
+
--vaadin-infinite-scroller-buffer-width: 57px;
|
|
48
51
|
width: 57px;
|
|
49
|
-
height: auto;
|
|
50
|
-
top: 0;
|
|
51
|
-
bottom: 0;
|
|
52
52
|
font-size: var(--lumo-font-size-s);
|
|
53
53
|
box-shadow: inset 2px 0 4px 0 var(--lumo-shade-5pct);
|
|
54
54
|
-webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
|
|
@@ -56,19 +56,12 @@ registerStyles(
|
|
|
56
56
|
cursor: var(--lumo-clickable-cursor);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
::slotted([slot='years']
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* TODO unsupported selector */
|
|
64
|
-
#scrollers {
|
|
65
|
-
position: static;
|
|
66
|
-
display: block;
|
|
59
|
+
:host([dir='rtl']) ::slotted([slot='years']) {
|
|
60
|
+
box-shadow: inset -2px 0 4px 0 var(--lumo-shade-5pct);
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
right: auto;
|
|
63
|
+
::slotted([slot='years']:hover) {
|
|
64
|
+
--_lumo-date-picker-year-opacity: 1;
|
|
72
65
|
}
|
|
73
66
|
|
|
74
67
|
/* Year scroller position indicator */
|
|
@@ -84,10 +77,14 @@ registerStyles(
|
|
|
84
77
|
z-index: 1;
|
|
85
78
|
}
|
|
86
79
|
|
|
80
|
+
:host([dir='rtl']) ::slotted([slot='years'])::before {
|
|
81
|
+
right: 0;
|
|
82
|
+
transform: translate(75%, -50%) rotate(45deg);
|
|
83
|
+
}
|
|
84
|
+
|
|
87
85
|
[part='toolbar'] {
|
|
88
86
|
padding: var(--lumo-space-s);
|
|
89
87
|
border-bottom-left-radius: var(--lumo-border-radius-l);
|
|
90
|
-
margin-right: 57px;
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
[part='toolbar'] ::slotted(vaadin-button) {
|
|
@@ -97,24 +94,8 @@ registerStyles(
|
|
|
97
94
|
/* Narrow viewport mode (fullscreen) */
|
|
98
95
|
|
|
99
96
|
:host([fullscreen]) [part='toolbar'] {
|
|
100
|
-
order: -1;
|
|
101
97
|
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;
|
|
98
|
+
margin-inline-end: 57px;
|
|
118
99
|
}
|
|
119
100
|
|
|
120
101
|
/* Very narrow screen (year scroller initially hidden) */
|
|
@@ -122,10 +103,9 @@ registerStyles(
|
|
|
122
103
|
[part='years-toggle-button'] {
|
|
123
104
|
display: flex;
|
|
124
105
|
align-items: center;
|
|
125
|
-
height: var(--lumo-size-
|
|
106
|
+
height: var(--lumo-size-m);
|
|
126
107
|
padding: 0 0.5em;
|
|
127
108
|
border-radius: var(--lumo-border-radius-m);
|
|
128
|
-
z-index: 3;
|
|
129
109
|
color: var(--lumo-primary-text-color);
|
|
130
110
|
font-weight: 500;
|
|
131
111
|
-webkit-font-smoothing: antialiased;
|
|
@@ -143,21 +123,16 @@ registerStyles(
|
|
|
143
123
|
background-image: none;
|
|
144
124
|
}
|
|
145
125
|
|
|
146
|
-
[part='toolbar']
|
|
147
|
-
|
|
148
|
-
margin-right: 0;
|
|
126
|
+
:host([fullscreen]) [part='toolbar'] {
|
|
127
|
+
margin-inline-end: 0;
|
|
149
128
|
}
|
|
150
129
|
|
|
151
130
|
/* TODO make date-picker adapt to the width of the years part */
|
|
152
131
|
::slotted([slot='years']) {
|
|
153
|
-
--vaadin-infinite-scroller-buffer-width:
|
|
132
|
+
--vaadin-infinite-scroller-buffer-width: 50px;
|
|
154
133
|
width: 50px;
|
|
155
134
|
background-color: var(--lumo-shade-5pct);
|
|
156
135
|
}
|
|
157
|
-
|
|
158
|
-
:host([years-visible]) ::slotted([slot='months']) {
|
|
159
|
-
padding-left: 50px;
|
|
160
|
-
}
|
|
161
136
|
}
|
|
162
137
|
`,
|
|
163
138
|
{ moduleId: 'lumo-date-picker-overlay-content' },
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha4",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-date-picker",
|
|
11
|
-
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-
|
|
11
|
+
"description": "`<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.\n\n```html\n<vaadin-date-picker label=\"Birthday\"></vaadin-date-picker>\n```\n```js\ndatePicker.value = '2016-03-02';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n-------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n\n`<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha4/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------------|--------------------\n`toggle-button` | Toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n-----------|--------------------------------------------------|-----------\n`opened` | Set when the date selector overlay is opened | :host\n\n### Internal components\n\nIn addition to `<vaadin-date-picker>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha4/#/elements/vaadin-overlay).\n- `<vaadin-date-picker-overlay-content>`\n- `<vaadin-date-picker-month-scroller>`\n- `<vaadin-date-picker-year-scroller>`\n- `<vaadin-date-picker-year>`\n- `<vaadin-month-calendar>`\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha4/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nIn order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Toolbar with slotted buttons\n\nThe following state attributes are available on the `<vaadin-date-picker-overlay-content>` element:\n\nAttribute | Description\n----------------|-------------------------------------------------\n`desktop` | Set when the overlay content is in desktop mode\n`fullscreen` | Set when the overlay content is in fullscreen mode\n`years-visible` | Set when the year scroller is visible in fullscreen mode\n\nIn order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`month-header` | Month title\n`weekdays` | Weekday container\n`weekday` | Weekday element\n`week-numbers` | Week numbers container\n`week-number` | Week number element\n`date` | Date element\n`disabled` | Disabled date element\n`focused` | Focused date element\n`selected` | Selected date element\n`today` | Date element corresponding to the current day\n`past` | Date element corresponding to the date in the past\n`future` | Date element corresponding to the date in the future\n\nIn order to style year scroller elements, use `<vaadin-date-picker-year>` shadow DOM parts:\n\nPart name | Description\n----------------------|--------------------\n`year-number` | Year number\n`year-separator` | Year separator\n\nNote: the `theme` attribute value set on `<vaadin-date-picker>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Change events\n\nDepending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,\nthe component can fire either a `change` event or an `unparsable-change` event:\n\nValue change | Event\n:------------------------|:------------------\nempty => parsable | change\nempty => unparsable | unparsable-change\nparsable => empty | change\nparsable => parsable | change\nparsable => unparsable | change\nunparsable => empty | unparsable-change\nunparsable => parsable | change\nunparsable => unparsable | unparsable-change",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|