@vaadin/date-picker 22.0.0-alpha9 → 22.0.0
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 +26 -29
- package/package.json +14 -14
- package/src/vaadin-date-picker-light.js +13 -5
- package/src/vaadin-date-picker-mixin.d.ts +18 -13
- package/src/vaadin-date-picker-mixin.js +16 -26
- package/src/vaadin-date-picker-overlay-content.js +37 -36
- package/src/vaadin-date-picker-overlay.js +1 -1
- package/src/vaadin-date-picker-styles.js +1 -1
- package/src/vaadin-date-picker.d.ts +53 -48
- package/src/vaadin-date-picker.js +71 -56
- package/src/vaadin-infinite-scroller.js +3 -3
- package/src/vaadin-month-calendar.js +1 -1
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/lumo/vaadin-date-picker-styles.js +1 -1
- package/theme/lumo/vaadin-month-calendar-styles.js +1 -1
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/material/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/material/vaadin-date-picker-styles.js +1 -1
- package/theme/material/vaadin-month-calendar-styles.js +1 -1
package/README.md
CHANGED
|
@@ -1,58 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vaadin/date-picker
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
|
5
|
-
[API documentation ↗](https://vaadin.com/components/vaadin-date-picker/html-api)
|
|
3
|
+
A web component that allows to enter a date by typing or by selecting from a calendar overlay.
|
|
6
4
|
|
|
7
|
-
[
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/date-picker)
|
|
8
6
|
|
|
9
7
|
[](https://www.npmjs.com/package/@vaadin/date-picker)
|
|
10
|
-
[](https://vaadin.com/directory/component/vaadinvaadin-date-picker)
|
|
11
8
|
[](https://discord.gg/PHmkCKC)
|
|
12
9
|
|
|
13
10
|
```html
|
|
14
|
-
<vaadin-date-picker label="Label"
|
|
11
|
+
<vaadin-date-picker label="Label" value="2018-12-03" clear-button-visible></vaadin-date-picker>
|
|
15
12
|
```
|
|
16
13
|
|
|
17
|
-
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/date-picker/screenshot.png" width="
|
|
14
|
+
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/date-picker/screenshot.png" width="343" alt="Screenshot of vaadin-date-picker">](https://vaadin.com/docs/latest/ds/components/date-picker)
|
|
18
15
|
|
|
19
16
|
## Installation
|
|
20
17
|
|
|
21
|
-
Install
|
|
18
|
+
Install the component:
|
|
22
19
|
|
|
23
20
|
```sh
|
|
24
|
-
npm i @vaadin/date-picker
|
|
21
|
+
npm i @vaadin/date-picker
|
|
25
22
|
```
|
|
26
23
|
|
|
27
|
-
Once installed, import
|
|
24
|
+
Once installed, import the component in your application:
|
|
28
25
|
|
|
29
26
|
```js
|
|
30
|
-
import '@vaadin/date-picker
|
|
27
|
+
import '@vaadin/date-picker';
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
##
|
|
30
|
+
## Themes
|
|
34
31
|
|
|
35
|
-
Vaadin components
|
|
32
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
33
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/date-picker/vaadin-date-picker.js) of the package uses the Lumo theme.
|
|
36
34
|
|
|
37
|
-
To use the Material theme, import the
|
|
35
|
+
To use the Material theme, import the component from the `theme/material` folder:
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`theme/lumo/vaadin-date-picker.js`
|
|
44
|
-
`theme/lumo/vaadin-date-picker-light.js`
|
|
37
|
+
```js
|
|
38
|
+
import '@vaadin/date-picker/theme/material/vaadin-date-picker.js';
|
|
39
|
+
```
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
You can also import the Lumo version of the component explicitly:
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
```js
|
|
44
|
+
import '@vaadin/date-picker/theme/lumo/vaadin-date-picker.js';
|
|
45
|
+
```
|
|
50
46
|
|
|
51
|
-
-
|
|
52
|
-
`theme/lumo/vaadin-date-picker-light.js`:
|
|
47
|
+
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
```js
|
|
50
|
+
import '@vaadin/date-picker/src/vaadin-date-picker.js';
|
|
51
|
+
```
|
|
56
52
|
|
|
57
53
|
## Contributing
|
|
58
54
|
|
|
@@ -62,4 +58,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
|
|
|
62
58
|
|
|
63
59
|
Apache License 2.0
|
|
64
60
|
|
|
65
|
-
Vaadin collects development time
|
|
61
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
62
|
+
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "22.0.0
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,25 +31,25 @@
|
|
|
31
31
|
"web-component"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
34
35
|
"@polymer/iron-a11y-announcer": "^3.0.0",
|
|
35
|
-
"@polymer/iron-a11y-keys-behavior": "^3.0.0",
|
|
36
36
|
"@polymer/iron-media-query": "^3.0.0",
|
|
37
37
|
"@polymer/polymer": "^3.2.0",
|
|
38
|
-
"@vaadin/button": "22.0.0
|
|
39
|
-
"@vaadin/component-base": "22.0.0
|
|
40
|
-
"@vaadin/field-base": "22.0.0
|
|
41
|
-
"@vaadin/input-container": "22.0.0
|
|
42
|
-
"@vaadin/vaadin-lumo-styles": "22.0.0
|
|
43
|
-
"@vaadin/vaadin-material-styles": "22.0.0
|
|
44
|
-
"@vaadin/vaadin-overlay": "22.0.0
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "22.0.0
|
|
38
|
+
"@vaadin/button": "^22.0.0",
|
|
39
|
+
"@vaadin/component-base": "^22.0.0",
|
|
40
|
+
"@vaadin/field-base": "^22.0.0",
|
|
41
|
+
"@vaadin/input-container": "^22.0.0",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.0",
|
|
43
|
+
"@vaadin/vaadin-material-styles": "^22.0.0",
|
|
44
|
+
"@vaadin/vaadin-overlay": "^22.0.0",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/dialog": "22.0.0
|
|
50
|
-
"@vaadin/polymer-legacy-adapter": "22.0.0
|
|
51
|
-
"@vaadin/testing-helpers": "^0.3.
|
|
49
|
+
"@vaadin/dialog": "^22.0.0",
|
|
50
|
+
"@vaadin/polymer-legacy-adapter": "^22.0.0",
|
|
51
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
52
52
|
"sinon": "^9.2.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b668e9b1a975227fbe34beb70d1cd5b03dce2348"
|
|
55
55
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
8
6
|
import '@polymer/iron-media-query/iron-media-query.js';
|
|
9
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
7
|
import './vaadin-date-picker-overlay.js';
|
|
11
8
|
import './vaadin-date-picker-overlay-content.js';
|
|
9
|
+
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
10
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
11
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
12
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -72,10 +72,9 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
|
|
|
72
72
|
id="overlay"
|
|
73
73
|
fullscreen$="[[_fullscreen]]"
|
|
74
74
|
opened="{{opened}}"
|
|
75
|
-
position-target="[[inputElement]]"
|
|
76
|
-
no-vertical-overlap
|
|
77
75
|
on-vaadin-overlay-open="_onOverlayOpened"
|
|
78
76
|
on-vaadin-overlay-close="_onOverlayClosed"
|
|
77
|
+
on-vaadin-overlay-outside-click="focus"
|
|
79
78
|
theme$="[[__getOverlayTheme(theme, _overlayInitialized)]]"
|
|
80
79
|
>
|
|
81
80
|
<template>
|
|
@@ -149,6 +148,15 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
|
|
|
149
148
|
get _inputValue() {
|
|
150
149
|
return this.inputElement && this.inputElement[dashToCamelCase(this.attrForValue)];
|
|
151
150
|
}
|
|
151
|
+
|
|
152
|
+
// Workaround https://github.com/vaadin/web-components/issues/2855
|
|
153
|
+
/** @protected */
|
|
154
|
+
_openedChanged(opened) {
|
|
155
|
+
super._openedChanged(opened);
|
|
156
|
+
|
|
157
|
+
this.$.overlay.positionTarget = this.inputElement;
|
|
158
|
+
this.$.overlay.noVerticalOverlap = true;
|
|
159
|
+
}
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
customElements.define(DatePickerLight.is, DatePickerLight);
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* Copyright (c) 2021 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 {
|
|
8
|
-
import {
|
|
6
|
+
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
9
|
+
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
10
|
+
import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
11
|
+
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
9
12
|
|
|
10
13
|
export interface DatePickerDate {
|
|
11
14
|
day: number;
|
|
@@ -28,15 +31,19 @@ export interface DatePickerI18n {
|
|
|
28
31
|
formatTitle: (monthName: string, fullYear: number) => string;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
declare function DatePickerMixin<T extends
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
export declare function DatePickerMixin<T extends Constructor<HTMLElement>>(
|
|
35
|
+
base: T
|
|
36
|
+
): T &
|
|
37
|
+
Constructor<DatePickerMixinClass> &
|
|
38
|
+
Constructor<DelegateFocusMixinClass> &
|
|
39
|
+
Constructor<DisabledMixinClass> &
|
|
40
|
+
Constructor<FocusMixinClass> &
|
|
41
|
+
Constructor<InputMixinClass> &
|
|
42
|
+
Constructor<KeyboardMixinClass>;
|
|
43
|
+
|
|
44
|
+
export declare class DatePickerMixinClass {
|
|
38
45
|
/**
|
|
39
|
-
*
|
|
46
|
+
* Selected date.
|
|
40
47
|
*
|
|
41
48
|
* Supported date formats:
|
|
42
49
|
* - ISO 8601 `"YYYY-MM-DD"` (default)
|
|
@@ -194,5 +201,3 @@ interface DatePickerMixin extends DelegateFocusMixin, InputMixin, KeyboardMixin
|
|
|
194
201
|
*/
|
|
195
202
|
checkValidity(): boolean;
|
|
196
203
|
}
|
|
197
|
-
|
|
198
|
-
export { DatePickerMixinConstructor, DatePickerMixin };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { IronA11yKeysBehavior } from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
|
|
7
6
|
import { addListener } from '@polymer/polymer/lib/utils/gestures.js';
|
|
7
|
+
import { isIOS } from '@vaadin/component-base/src/browser-utils.js';
|
|
8
8
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
9
|
import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
10
10
|
import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
|
|
@@ -33,7 +33,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
33
33
|
_focusedDate: Date,
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Selected date.
|
|
37
37
|
*
|
|
38
38
|
* Supported date formats:
|
|
39
39
|
* - ISO 8601 `"YYYY-MM-DD"` (default)
|
|
@@ -308,7 +308,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
308
308
|
/** @private */
|
|
309
309
|
_ios: {
|
|
310
310
|
type: Boolean,
|
|
311
|
-
value:
|
|
311
|
+
value: isIOS
|
|
312
312
|
},
|
|
313
313
|
|
|
314
314
|
/** @private */
|
|
@@ -465,7 +465,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
465
465
|
|
|
466
466
|
// Keep focus attribute in focusElement for styling
|
|
467
467
|
this._overlayContent.addEventListener('focus', () => {
|
|
468
|
-
this.
|
|
468
|
+
this._setFocused(true);
|
|
469
469
|
});
|
|
470
470
|
|
|
471
471
|
this.$.overlay.addEventListener('vaadin-overlay-close', this._onVaadinOverlayClose.bind(this));
|
|
@@ -581,7 +581,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
/** @
|
|
584
|
+
/** @protected */
|
|
585
585
|
_openedChanged(opened) {
|
|
586
586
|
if (opened && !this._overlayInitialized) {
|
|
587
587
|
this._initOverlay();
|
|
@@ -778,6 +778,11 @@ export const DatePickerMixin = (subclass) =>
|
|
|
778
778
|
if (!this.value) {
|
|
779
779
|
this.validate();
|
|
780
780
|
}
|
|
781
|
+
|
|
782
|
+
// If the input isn't focused when overlay closes (fullscreen mode), clear focused state
|
|
783
|
+
if (this.getRootNode().activeElement !== this.inputElement) {
|
|
784
|
+
this._setFocused(false);
|
|
785
|
+
}
|
|
781
786
|
}
|
|
782
787
|
|
|
783
788
|
/** @private */
|
|
@@ -819,21 +824,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
819
824
|
}
|
|
820
825
|
}
|
|
821
826
|
|
|
822
|
-
/**
|
|
823
|
-
* Keyboard Navigation
|
|
824
|
-
* @private
|
|
825
|
-
*/
|
|
826
|
-
_eventKey(e) {
|
|
827
|
-
const keys = ['down', 'up', 'enter', 'esc', 'tab'];
|
|
828
|
-
|
|
829
|
-
for (let i = 0; i < keys.length; i++) {
|
|
830
|
-
const k = keys[i];
|
|
831
|
-
if (IronA11yKeysBehavior.keyboardEventMatchesKeys(e, k)) {
|
|
832
|
-
return k;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
827
|
/** @private */
|
|
838
828
|
_isValidDate(d) {
|
|
839
829
|
return d && !isNaN(d.getTime());
|
|
@@ -888,9 +878,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
888
878
|
}
|
|
889
879
|
}
|
|
890
880
|
|
|
891
|
-
switch (
|
|
892
|
-
case '
|
|
893
|
-
case '
|
|
881
|
+
switch (e.key) {
|
|
882
|
+
case 'ArrowDown':
|
|
883
|
+
case 'ArrowUp':
|
|
894
884
|
// prevent scrolling the page with arrows
|
|
895
885
|
e.preventDefault();
|
|
896
886
|
|
|
@@ -903,7 +893,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
903
893
|
}
|
|
904
894
|
|
|
905
895
|
break;
|
|
906
|
-
case '
|
|
896
|
+
case 'Enter': {
|
|
907
897
|
const parsedDate = this._getParsedDate();
|
|
908
898
|
const isValidDate = this._isValidDate(parsedDate);
|
|
909
899
|
if (this.opened) {
|
|
@@ -924,7 +914,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
924
914
|
}
|
|
925
915
|
break;
|
|
926
916
|
}
|
|
927
|
-
case '
|
|
917
|
+
case 'Escape':
|
|
928
918
|
if (this.opened) {
|
|
929
919
|
this._focusedDate = this._selectedDate;
|
|
930
920
|
this._close();
|
|
@@ -941,7 +931,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
941
931
|
this._selectParsedOrFocusedDate();
|
|
942
932
|
}
|
|
943
933
|
break;
|
|
944
|
-
case '
|
|
934
|
+
case 'Tab':
|
|
945
935
|
if (this.opened) {
|
|
946
936
|
e.preventDefault();
|
|
947
937
|
//Clear the selection range (remains visible on IE)
|
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
8
|
-
import { addListener, setTouchAction } from '@polymer/polymer/lib/utils/gestures.js';
|
|
9
|
-
import { IronA11yKeysBehavior } from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
|
|
10
|
-
import { IronA11yAnnouncer } from '@polymer/iron-a11y-announcer/iron-a11y-announcer.js';
|
|
11
6
|
import '@polymer/iron-media-query/iron-media-query.js';
|
|
12
7
|
import '@vaadin/button/src/vaadin-button.js';
|
|
8
|
+
import './vaadin-month-calendar.js';
|
|
9
|
+
import './vaadin-infinite-scroller.js';
|
|
10
|
+
import { IronA11yAnnouncer } from '@polymer/iron-a11y-announcer/iron-a11y-announcer.js';
|
|
11
|
+
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
12
|
+
import { addListener, setTouchAction } from '@polymer/polymer/lib/utils/gestures.js';
|
|
13
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
13
14
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
14
15
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
15
16
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
16
17
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
17
|
-
import './vaadin-
|
|
18
|
-
import './vaadin-infinite-scroller.js';
|
|
19
|
-
import { dateEquals, getClosestDate, getISOWeekNumber, extractDateParts } from './vaadin-date-picker-helper.js';
|
|
18
|
+
import { dateEquals, extractDateParts, getClosestDate, getISOWeekNumber } from './vaadin-date-picker-helper.js';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* @extends HTMLElement
|
|
@@ -704,20 +703,6 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(GestureEventListen
|
|
|
704
703
|
e.preventDefault();
|
|
705
704
|
}
|
|
706
705
|
|
|
707
|
-
/**
|
|
708
|
-
* Keyboard Navigation
|
|
709
|
-
*/
|
|
710
|
-
_eventKey(e) {
|
|
711
|
-
var keys = ['down', 'up', 'right', 'left', 'enter', 'space', 'home', 'end', 'pageup', 'pagedown', 'tab', 'esc'];
|
|
712
|
-
|
|
713
|
-
for (var i = 0; i < keys.length; i++) {
|
|
714
|
-
var k = keys[i];
|
|
715
|
-
if (IronA11yKeysBehavior.keyboardEventMatchesKeys(e, k)) {
|
|
716
|
-
return k;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
706
|
_onKeydown(e) {
|
|
722
707
|
var focus = this._currentlyFocusedDate();
|
|
723
708
|
|
|
@@ -727,8 +712,24 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(GestureEventListen
|
|
|
727
712
|
const isCancel = e.composedPath().indexOf(this.$.cancelButton) >= 0;
|
|
728
713
|
const isScroller = !isToday && !isCancel;
|
|
729
714
|
|
|
730
|
-
|
|
731
|
-
|
|
715
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
|
716
|
+
const navigationKeys = [
|
|
717
|
+
' ',
|
|
718
|
+
'ArrowDown',
|
|
719
|
+
'ArrowUp',
|
|
720
|
+
'ArrowRight',
|
|
721
|
+
'ArrowLeft',
|
|
722
|
+
'Enter',
|
|
723
|
+
'End',
|
|
724
|
+
'Escape',
|
|
725
|
+
'Home',
|
|
726
|
+
'PageUp',
|
|
727
|
+
'PageDown',
|
|
728
|
+
'Tab'
|
|
729
|
+
];
|
|
730
|
+
|
|
731
|
+
const eventKey = e.key;
|
|
732
|
+
if (eventKey === 'Tab') {
|
|
732
733
|
// We handle tabs here and don't want to bubble up.
|
|
733
734
|
e.stopPropagation();
|
|
734
735
|
|
|
@@ -751,36 +752,36 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(GestureEventListen
|
|
|
751
752
|
// set to false.
|
|
752
753
|
this._focused = false;
|
|
753
754
|
}
|
|
754
|
-
} else if (eventKey) {
|
|
755
|
+
} else if (navigationKeys.includes(eventKey)) {
|
|
755
756
|
e.preventDefault();
|
|
756
757
|
e.stopPropagation();
|
|
757
758
|
switch (eventKey) {
|
|
758
|
-
case '
|
|
759
|
+
case 'ArrowDown':
|
|
759
760
|
this._moveFocusByDays(7);
|
|
760
761
|
this.focus();
|
|
761
762
|
break;
|
|
762
|
-
case '
|
|
763
|
+
case 'ArrowUp':
|
|
763
764
|
this._moveFocusByDays(-7);
|
|
764
765
|
this.focus();
|
|
765
766
|
break;
|
|
766
|
-
case '
|
|
767
|
+
case 'ArrowRight':
|
|
767
768
|
if (isScroller) {
|
|
768
769
|
this._moveFocusByDays(this.__isRTL ? -1 : 1);
|
|
769
770
|
}
|
|
770
771
|
break;
|
|
771
|
-
case '
|
|
772
|
+
case 'ArrowLeft':
|
|
772
773
|
if (isScroller) {
|
|
773
774
|
this._moveFocusByDays(this.__isRTL ? 1 : -1);
|
|
774
775
|
}
|
|
775
776
|
break;
|
|
776
|
-
case '
|
|
777
|
+
case 'Enter':
|
|
777
778
|
if (isScroller || isCancel) {
|
|
778
779
|
this._close();
|
|
779
780
|
} else if (isToday) {
|
|
780
781
|
this._onTodayTap();
|
|
781
782
|
}
|
|
782
783
|
break;
|
|
783
|
-
case '
|
|
784
|
+
case ' ':
|
|
784
785
|
if (isCancel) {
|
|
785
786
|
this._close();
|
|
786
787
|
} else if (isToday) {
|
|
@@ -795,19 +796,19 @@ class DatePickerOverlayContent extends ThemableMixin(DirMixin(GestureEventListen
|
|
|
795
796
|
}
|
|
796
797
|
}
|
|
797
798
|
break;
|
|
798
|
-
case '
|
|
799
|
+
case 'Home':
|
|
799
800
|
this._moveFocusInsideMonth(focus, 'minDate');
|
|
800
801
|
break;
|
|
801
|
-
case '
|
|
802
|
+
case 'End':
|
|
802
803
|
this._moveFocusInsideMonth(focus, 'maxDate');
|
|
803
804
|
break;
|
|
804
|
-
case '
|
|
805
|
+
case 'PageDown':
|
|
805
806
|
this._moveFocusByMonths(e.shiftKey ? 12 : 1);
|
|
806
807
|
break;
|
|
807
|
-
case '
|
|
808
|
+
case 'PageUp':
|
|
808
809
|
this._moveFocusByMonths(e.shiftKey ? -12 : -1);
|
|
809
810
|
break;
|
|
810
|
-
case '
|
|
811
|
+
case 'Escape':
|
|
811
812
|
this._cancel();
|
|
812
813
|
break;
|
|
813
814
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { DisableUpgradeMixin } from '@polymer/polymer/lib/mixins/disable-upgrade-mixin.js';
|
|
7
7
|
import { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
8
8
|
import { PositionMixin } from '@vaadin/vaadin-overlay/src/vaadin-overlay-position-mixin.js';
|
|
9
|
-
import { registerStyles } from '@vaadin/vaadin-themable-mixin/
|
|
9
|
+
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
import { datePickerOverlayStyles } from './vaadin-date-picker-styles.js';
|
|
11
11
|
|
|
12
12
|
registerStyles('vaadin-date-picker-overlay', datePickerOverlayStyles, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { css } from '@vaadin/vaadin-themable-mixin/
|
|
6
|
+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
export const datePickerStyles = css`
|
|
9
9
|
:host([dir='rtl']) [part='input-field'] {
|
|
@@ -35,16 +35,17 @@ export interface DatePickerCustomEventMap {
|
|
|
35
35
|
export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCustomEventMap {}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* `<vaadin-date-picker>` is a date
|
|
39
|
-
*
|
|
38
|
+
* `<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.
|
|
39
|
+
*
|
|
40
40
|
* ```html
|
|
41
41
|
* <vaadin-date-picker label="Birthday"></vaadin-date-picker>
|
|
42
42
|
* ```
|
|
43
|
+
*
|
|
43
44
|
* ```js
|
|
44
45
|
* datePicker.value = '2016-03-02';
|
|
45
46
|
* ```
|
|
46
|
-
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
47
47
|
*
|
|
48
|
+
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
48
49
|
*
|
|
49
50
|
* ### Styling
|
|
50
51
|
*
|
|
@@ -54,71 +55,77 @@ export interface DatePickerEventMap extends HTMLElementEventMap, DatePickerCusto
|
|
|
54
55
|
* -------------------------------|----------------------------|---------
|
|
55
56
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
56
57
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* Part name | Description | Theme for Element
|
|
60
|
-
* ----------------|----------------|----------------
|
|
61
|
-
* `input-field` | Input element | vaadin-date-picker
|
|
62
|
-
* `clear-button` | Clear button | vaadin-date-picker
|
|
63
|
-
* `toggle-button` | Toggle button | vaadin-date-picker
|
|
64
|
-
* `overlay-content` | The overlay element | vaadin-date-picker
|
|
65
|
-
* `overlay-header` | Fullscreen mode header | vaadin-date-picker-overlay-content
|
|
66
|
-
* `label` | Fullscreen mode value/label | vaadin-date-picker-overlay-content
|
|
67
|
-
* `clear-button` | Fullscreen mode clear button | vaadin-date-picker-overlay-content
|
|
68
|
-
* `toggle-button` | Fullscreen mode toggle button | vaadin-date-picker-overlay-content
|
|
69
|
-
* `years-toggle-button` | Fullscreen mode years scroller toggle | vaadin-date-picker-overlay-content
|
|
70
|
-
* `months` | Months scroller | vaadin-date-picker-overlay-content
|
|
71
|
-
* `years` | Years scroller | vaadin-date-picker-overlay-content
|
|
72
|
-
* `toolbar` | Footer bar with buttons | vaadin-date-picker-overlay-content
|
|
73
|
-
* `today-button` | Today button | vaadin-date-picker-overlay-content
|
|
74
|
-
* `cancel-button` | Cancel button | vaadin-date-picker-overlay-content
|
|
75
|
-
* `month` | Month calendar | vaadin-date-picker-overlay-content
|
|
76
|
-
* `year-number` | Year number | vaadin-date-picker-overlay-content
|
|
77
|
-
* `year-separator` | Year separator | vaadin-date-picker-overlay-content
|
|
78
|
-
* `month-header` | Month title | vaadin-month-calendar
|
|
79
|
-
* `weekdays` | Weekday container | vaadin-month-calendar
|
|
80
|
-
* `weekday` | Weekday element | vaadin-month-calendar
|
|
81
|
-
* `week-numbers` | Week numbers container | vaadin-month-calendar
|
|
82
|
-
* `week-number` | Week number element | vaadin-month-calendar
|
|
83
|
-
* `date` | Date element | vaadin-month-calendar
|
|
58
|
+
* `<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
59
|
+
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
84
60
|
*
|
|
85
|
-
*
|
|
61
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
62
|
+
*
|
|
63
|
+
* Part name | Description
|
|
64
|
+
* ----------------------|--------------------
|
|
65
|
+
* `toggle-button` | Toggle button
|
|
66
|
+
* `overlay-content` | The overlay element
|
|
86
67
|
*
|
|
87
|
-
*
|
|
68
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
88
69
|
*
|
|
89
|
-
* Attribute
|
|
90
|
-
*
|
|
91
|
-
* `
|
|
92
|
-
* `
|
|
93
|
-
* `
|
|
94
|
-
* `disabled` | Set when the element is disabled | :host
|
|
95
|
-
* `today` | Set on the date corresponding to the current day | date
|
|
96
|
-
* `focused` | Set on the focused date | date
|
|
97
|
-
* `disabled` | Set on the date out of the allowed range | date
|
|
98
|
-
* `selected` | Set on the selected date | date
|
|
70
|
+
* Attribute | Description | Part name
|
|
71
|
+
* -----------|--------------------------------------------------|-----------
|
|
72
|
+
* `opened` | Set when the date selector overlay is opened | :host
|
|
73
|
+
* `today` | Set on the date corresponding to the current day | date
|
|
74
|
+
* `selected` | Set on the selected date | date
|
|
99
75
|
*
|
|
100
|
-
* If you want to replace the default input
|
|
101
|
-
* [`<vaadin-date-picker-light>`](
|
|
76
|
+
* If you want to replace the default `<input>` and its container with a custom implementation to get full control
|
|
77
|
+
* over the input field, consider using the [`<vaadin-date-picker-light>`](#/elements/vaadin-date-picker-light) element.
|
|
102
78
|
*
|
|
103
79
|
* ### Internal components
|
|
104
80
|
*
|
|
105
81
|
* In addition to `<vaadin-date-picker>` itself, the following internal
|
|
106
82
|
* components are themable:
|
|
107
83
|
*
|
|
108
|
-
|
|
109
84
|
* - `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
110
85
|
* - `<vaadin-date-picker-overlay-content>`
|
|
111
86
|
* - `<vaadin-month-calendar>`
|
|
87
|
+
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
88
|
+
*
|
|
89
|
+
* In order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:
|
|
90
|
+
*
|
|
91
|
+
* Part name | Description
|
|
92
|
+
* ----------------------|--------------------
|
|
93
|
+
* `overlay-header` | Fullscreen mode header
|
|
94
|
+
* `label` | Fullscreen mode value/label
|
|
95
|
+
* `clear-button` | Fullscreen mode clear button
|
|
96
|
+
* `toggle-button` | Fullscreen mode toggle button
|
|
97
|
+
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
98
|
+
* `months` | Months scroller
|
|
99
|
+
* `years` | Years scroller
|
|
100
|
+
* `toolbar` | Footer bar with buttons
|
|
101
|
+
* `today-button` | Today button
|
|
102
|
+
* `cancel-button` | Cancel button
|
|
103
|
+
* `month` | Month calendar
|
|
104
|
+
* `year-number` | Year number
|
|
105
|
+
* `year-separator` | Year separator
|
|
106
|
+
*
|
|
107
|
+
* In order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:
|
|
108
|
+
*
|
|
109
|
+
* Part name | Description
|
|
110
|
+
* ----------------------|--------------------
|
|
111
|
+
* `month-header` | Month title
|
|
112
|
+
* `weekdays` | Weekday container
|
|
113
|
+
* `weekday` | Weekday element
|
|
114
|
+
* `week-numbers` | Week numbers container
|
|
115
|
+
* `week-number` | Week number element
|
|
116
|
+
* `date` | Date element
|
|
112
117
|
*
|
|
113
118
|
* Note: the `theme` attribute value set on `<vaadin-date-picker>` is
|
|
114
119
|
* propagated to the internal components listed above.
|
|
115
120
|
*
|
|
121
|
+
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
122
|
+
*
|
|
116
123
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
117
124
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
118
125
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
119
126
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
120
127
|
*/
|
|
121
|
-
declare class DatePicker extends HTMLElement {
|
|
128
|
+
declare class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
|
|
122
129
|
addEventListener<K extends keyof DatePickerEventMap>(
|
|
123
130
|
type: K,
|
|
124
131
|
listener: (this: DatePicker, ev: DatePickerEventMap[K]) => void,
|
|
@@ -132,8 +139,6 @@ declare class DatePicker extends HTMLElement {
|
|
|
132
139
|
): void;
|
|
133
140
|
}
|
|
134
141
|
|
|
135
|
-
interface DatePicker extends DatePickerMixin, ElementMixin, InputControlMixin, ThemableMixin {}
|
|
136
|
-
|
|
137
142
|
declare global {
|
|
138
143
|
interface HTMLElementTagNameMap {
|
|
139
144
|
'vaadin-date-picker': DatePicker;
|
|
@@ -3,35 +3,35 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
8
6
|
import '@polymer/iron-media-query/iron-media-query.js';
|
|
7
|
+
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
8
|
+
import './vaadin-date-picker-overlay.js';
|
|
9
|
+
import './vaadin-date-picker-overlay-content.js';
|
|
10
|
+
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
11
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
12
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
10
|
-
import { AriaLabelController } from '@vaadin/field-base/src/aria-label-controller.js';
|
|
11
|
-
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
12
13
|
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
14
|
+
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
15
|
+
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
13
16
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
14
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
-
import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
16
|
-
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
17
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
17
18
|
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
18
19
|
import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
19
|
-
import './vaadin-date-picker-overlay.js';
|
|
20
|
-
import './vaadin-date-picker-overlay-content.js';
|
|
21
20
|
|
|
22
21
|
registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { moduleId: 'vaadin-date-picker-styles' });
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
* `<vaadin-date-picker>` is a date
|
|
26
|
-
*
|
|
24
|
+
* `<vaadin-date-picker>` is an input field that allows to enter a date by typing or by selecting from a calendar overlay.
|
|
25
|
+
*
|
|
27
26
|
* ```html
|
|
28
27
|
* <vaadin-date-picker label="Birthday"></vaadin-date-picker>
|
|
29
28
|
* ```
|
|
29
|
+
*
|
|
30
30
|
* ```js
|
|
31
31
|
* datePicker.value = '2016-03-02';
|
|
32
32
|
* ```
|
|
33
|
-
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
34
33
|
*
|
|
34
|
+
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
35
35
|
*
|
|
36
36
|
* ### Styling
|
|
37
37
|
*
|
|
@@ -41,51 +41,26 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
41
41
|
* -------------------------------|----------------------------|---------
|
|
42
42
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* Part name | Description | Theme for Element
|
|
47
|
-
* ----------------|----------------|----------------
|
|
48
|
-
* `input-field` | Input element | vaadin-date-picker
|
|
49
|
-
* `clear-button` | Clear button | vaadin-date-picker
|
|
50
|
-
* `toggle-button` | Toggle button | vaadin-date-picker
|
|
51
|
-
* `overlay-content` | The overlay element | vaadin-date-picker
|
|
52
|
-
* `overlay-header` | Fullscreen mode header | vaadin-date-picker-overlay-content
|
|
53
|
-
* `label` | Fullscreen mode value/label | vaadin-date-picker-overlay-content
|
|
54
|
-
* `clear-button` | Fullscreen mode clear button | vaadin-date-picker-overlay-content
|
|
55
|
-
* `toggle-button` | Fullscreen mode toggle button | vaadin-date-picker-overlay-content
|
|
56
|
-
* `years-toggle-button` | Fullscreen mode years scroller toggle | vaadin-date-picker-overlay-content
|
|
57
|
-
* `months` | Months scroller | vaadin-date-picker-overlay-content
|
|
58
|
-
* `years` | Years scroller | vaadin-date-picker-overlay-content
|
|
59
|
-
* `toolbar` | Footer bar with buttons | vaadin-date-picker-overlay-content
|
|
60
|
-
* `today-button` | Today button | vaadin-date-picker-overlay-content
|
|
61
|
-
* `cancel-button` | Cancel button | vaadin-date-picker-overlay-content
|
|
62
|
-
* `month` | Month calendar | vaadin-date-picker-overlay-content
|
|
63
|
-
* `year-number` | Year number | vaadin-date-picker-overlay-content
|
|
64
|
-
* `year-separator` | Year separator | vaadin-date-picker-overlay-content
|
|
65
|
-
* `month-header` | Month title | vaadin-month-calendar
|
|
66
|
-
* `weekdays` | Weekday container | vaadin-month-calendar
|
|
67
|
-
* `weekday` | Weekday element | vaadin-month-calendar
|
|
68
|
-
* `week-numbers` | Week numbers container | vaadin-month-calendar
|
|
69
|
-
* `week-number` | Week number element | vaadin-month-calendar
|
|
70
|
-
* `date` | Date element | vaadin-month-calendar
|
|
44
|
+
* `<vaadin-date-picker>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
45
|
+
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
71
46
|
*
|
|
72
|
-
*
|
|
47
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
73
48
|
*
|
|
74
|
-
*
|
|
49
|
+
* Part name | Description
|
|
50
|
+
* ----------------------|--------------------
|
|
51
|
+
* `toggle-button` | Toggle button
|
|
52
|
+
* `overlay-content` | The overlay element
|
|
75
53
|
*
|
|
76
|
-
*
|
|
77
|
-
* -------------|-------------|------------
|
|
78
|
-
* `invalid` | Set when the element is invalid | :host
|
|
79
|
-
* `opened` | Set when the date selector overlay is opened | :host
|
|
80
|
-
* `readonly` | Set when the element is readonly | :host
|
|
81
|
-
* `disabled` | Set when the element is disabled | :host
|
|
82
|
-
* `today` | Set on the date corresponding to the current day | date
|
|
83
|
-
* `focused` | Set on the focused date | date
|
|
84
|
-
* `disabled` | Set on the date out of the allowed range | date
|
|
85
|
-
* `selected` | Set on the selected date | date
|
|
54
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
86
55
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
56
|
+
* Attribute | Description | Part name
|
|
57
|
+
* -----------|--------------------------------------------------|-----------
|
|
58
|
+
* `opened` | Set when the date selector overlay is opened | :host
|
|
59
|
+
* `today` | Set on the date corresponding to the current day | date
|
|
60
|
+
* `selected` | Set on the selected date | date
|
|
61
|
+
*
|
|
62
|
+
* If you want to replace the default `<input>` and its container with a custom implementation to get full control
|
|
63
|
+
* over the input field, consider using the [`<vaadin-date-picker-light>`](#/elements/vaadin-date-picker-light) element.
|
|
89
64
|
*
|
|
90
65
|
* ### Internal components
|
|
91
66
|
*
|
|
@@ -95,10 +70,42 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
95
70
|
* - `<vaadin-date-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
96
71
|
* - `<vaadin-date-picker-overlay-content>`
|
|
97
72
|
* - `<vaadin-month-calendar>`
|
|
73
|
+
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
74
|
+
*
|
|
75
|
+
* In order to style the overlay content, use `<vaadin-date-picker-overlay-content>` shadow DOM parts:
|
|
76
|
+
*
|
|
77
|
+
* Part name | Description
|
|
78
|
+
* ----------------------|--------------------
|
|
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
|
+
* `years-toggle-button` | Fullscreen mode years scroller toggle
|
|
84
|
+
* `months` | Months scroller
|
|
85
|
+
* `years` | Years scroller
|
|
86
|
+
* `toolbar` | Footer bar with buttons
|
|
87
|
+
* `today-button` | Today button
|
|
88
|
+
* `cancel-button` | Cancel button
|
|
89
|
+
* `month` | Month calendar
|
|
90
|
+
* `year-number` | Year number
|
|
91
|
+
* `year-separator` | Year separator
|
|
92
|
+
*
|
|
93
|
+
* In order to style the month calendar, use `<vaadin-month-calendar>` shadow DOM parts:
|
|
94
|
+
*
|
|
95
|
+
* Part name | Description
|
|
96
|
+
* ----------------------|--------------------
|
|
97
|
+
* `month-header` | Month title
|
|
98
|
+
* `weekdays` | Weekday container
|
|
99
|
+
* `weekday` | Weekday element
|
|
100
|
+
* `week-numbers` | Week numbers container
|
|
101
|
+
* `week-number` | Week number element
|
|
102
|
+
* `date` | Date element
|
|
98
103
|
*
|
|
99
104
|
* Note: the `theme` attribute value set on `<vaadin-date-picker>` is
|
|
100
105
|
* propagated to the internal components listed above.
|
|
101
106
|
*
|
|
107
|
+
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
108
|
+
*
|
|
102
109
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
103
110
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
104
111
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
@@ -156,9 +163,9 @@ class DatePicker extends DatePickerMixin(
|
|
|
156
163
|
id="overlay"
|
|
157
164
|
fullscreen$="[[_fullscreen]]"
|
|
158
165
|
theme$="[[__getOverlayTheme(theme, _overlayInitialized)]]"
|
|
159
|
-
no-vertical-overlap
|
|
160
166
|
on-vaadin-overlay-open="_onOverlayOpened"
|
|
161
167
|
on-vaadin-overlay-close="_onOverlayClosed"
|
|
168
|
+
on-vaadin-overlay-outside-click="focus"
|
|
162
169
|
disable-upgrade
|
|
163
170
|
>
|
|
164
171
|
<template>
|
|
@@ -206,8 +213,7 @@ class DatePicker extends DatePickerMixin(
|
|
|
206
213
|
this.ariaTarget = input;
|
|
207
214
|
})
|
|
208
215
|
);
|
|
209
|
-
this.addController(new
|
|
210
|
-
this.$.overlay.positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
216
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelNode));
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
/** @private */
|
|
@@ -227,6 +233,15 @@ class DatePicker extends DatePickerMixin(
|
|
|
227
233
|
e.stopPropagation();
|
|
228
234
|
this[this._overlayInitialized && this.$.overlay.opened ? 'close' : 'open']();
|
|
229
235
|
}
|
|
236
|
+
|
|
237
|
+
// Workaround https://github.com/vaadin/web-components/issues/2855
|
|
238
|
+
/** @protected */
|
|
239
|
+
_openedChanged(opened) {
|
|
240
|
+
super._openedChanged(opened);
|
|
241
|
+
|
|
242
|
+
this.$.overlay.positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
243
|
+
this.$.overlay.noVerticalOverlap = true;
|
|
244
|
+
}
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
customElements.define(DatePicker.is, DatePicker);
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
|
-
import { templatize } from '@polymer/polymer/lib/utils/templatize.js';
|
|
8
6
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
7
|
+
import { templatize } from '@polymer/polymer/lib/utils/templatize.js';
|
|
8
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
9
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
10
|
+
import { isFirefox } from '@vaadin/component-base/src/browser-utils.js';
|
|
10
11
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -137,7 +138,6 @@ class InfiniteScroller extends PolymerElement {
|
|
|
137
138
|
|
|
138
139
|
// Firefox interprets elements with overflow:auto as focusable
|
|
139
140
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1069739
|
|
140
|
-
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
141
141
|
if (isFirefox) {
|
|
142
142
|
this.$.scroller.tabIndex = -1;
|
|
143
143
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
6
|
import '@polymer/polymer/lib/elements/dom-repeat.js';
|
|
8
7
|
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
8
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
import { dateAllowed, dateEquals, getISOWeekNumber } from './vaadin-date-picker-helper.js';
|
|
11
11
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
4
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
5
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
6
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
7
6
|
import '@vaadin/button/theme/lumo/vaadin-button.js';
|
|
7
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
8
|
|
|
9
9
|
registerStyles(
|
|
10
10
|
'vaadin-date-picker-overlay-content',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
3
2
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
3
|
import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
|
|
4
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
5
|
|
|
6
6
|
const datePickerOverlay = css`
|
|
7
7
|
[part='overlay'] {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
3
2
|
import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-shared.js';
|
|
3
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
4
|
|
|
5
5
|
const datePicker = css`
|
|
6
6
|
:host {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
4
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
5
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
6
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
registerStyles(
|
|
9
9
|
'vaadin-month-calendar',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
4
3
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
5
4
|
import '@vaadin/vaadin-material-styles/shadow.js';
|
|
6
5
|
import '@vaadin/button/theme/material/vaadin-button.js';
|
|
6
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
registerStyles(
|
|
9
9
|
'vaadin-date-picker-overlay-content',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import { overlay } from '@vaadin/vaadin-material-styles/mixins/overlay.js';
|
|
2
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
3
3
|
|
|
4
4
|
const datePickerOverlay = css`
|
|
5
5
|
:host([fullscreen]) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
4
3
|
import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-field-shared.js';
|
|
4
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
5
|
|
|
6
6
|
const datePicker = css`
|
|
7
7
|
:host {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
3
2
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
3
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
4
|
|
|
5
5
|
registerStyles(
|
|
6
6
|
'vaadin-month-calendar',
|