@vaadin/date-picker 24.3.0-alpha10 → 24.3.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 +11 -15
- package/src/vaadin-date-picker-year-mixin.js +35 -0
- package/src/vaadin-date-picker-year.js +3 -23
- package/src/vaadin-lit-date-picker-overlay-content.js +70 -0
- package/src/vaadin-lit-date-picker-overlay.js +64 -0
- package/src/vaadin-lit-date-picker-year.js +41 -0
- package/src/vaadin-lit-date-picker.js +162 -0
- package/src/vaadin-lit-month-calendar.js +117 -0
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/lumo/vaadin-lit-date-picker.js +5 -0
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/material/vaadin-lit-date-picker.js +5 -0
- package/vaadin-lit-date-picker-light.d.ts +1 -0
- package/vaadin-lit-date-picker-light.js +2 -0
- package/vaadin-lit-date-picker.d.ts +1 -0
- package/vaadin-lit-date-picker.js +2 -0
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "24.3.0-
|
|
3
|
+
"version": "24.3.0-alpha11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
-
"!src/vaadin-lit-date-picker-overlay-content.js",
|
|
25
|
-
"!src/vaadin-lit-date-picker-overlay.js",
|
|
26
|
-
"!src/vaadin-lit-date-picker.js",
|
|
27
|
-
"!src/vaadin-lit-month-calendar.js",
|
|
28
24
|
"theme",
|
|
29
25
|
"vaadin-*.d.ts",
|
|
30
26
|
"vaadin-*.js",
|
|
@@ -40,15 +36,15 @@
|
|
|
40
36
|
"dependencies": {
|
|
41
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
42
38
|
"@polymer/polymer": "^3.2.0",
|
|
43
|
-
"@vaadin/a11y-base": "24.3.0-
|
|
44
|
-
"@vaadin/button": "24.3.0-
|
|
45
|
-
"@vaadin/component-base": "24.3.0-
|
|
46
|
-
"@vaadin/field-base": "24.3.0-
|
|
47
|
-
"@vaadin/input-container": "24.3.0-
|
|
48
|
-
"@vaadin/overlay": "24.3.0-
|
|
49
|
-
"@vaadin/vaadin-lumo-styles": "24.3.0-
|
|
50
|
-
"@vaadin/vaadin-material-styles": "24.3.0-
|
|
51
|
-
"@vaadin/vaadin-themable-mixin": "24.3.0-
|
|
39
|
+
"@vaadin/a11y-base": "24.3.0-alpha11",
|
|
40
|
+
"@vaadin/button": "24.3.0-alpha11",
|
|
41
|
+
"@vaadin/component-base": "24.3.0-alpha11",
|
|
42
|
+
"@vaadin/field-base": "24.3.0-alpha11",
|
|
43
|
+
"@vaadin/input-container": "24.3.0-alpha11",
|
|
44
|
+
"@vaadin/overlay": "24.3.0-alpha11",
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "24.3.0-alpha11",
|
|
46
|
+
"@vaadin/vaadin-material-styles": "24.3.0-alpha11",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "24.3.0-alpha11"
|
|
52
48
|
},
|
|
53
49
|
"devDependencies": {
|
|
54
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -59,5 +55,5 @@
|
|
|
59
55
|
"web-types.json",
|
|
60
56
|
"web-types.lit.json"
|
|
61
57
|
],
|
|
62
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "123cf569a1b6ef6f4ef5fe8e60cb8d988699b98c"
|
|
63
59
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @polymerMixin
|
|
9
|
+
*/
|
|
10
|
+
export const DatePickerYearMixin = (superClass) =>
|
|
11
|
+
class DatePickerYearMixin extends superClass {
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
year: {
|
|
15
|
+
type: String,
|
|
16
|
+
sync: true,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
selectedDate: {
|
|
20
|
+
type: Object,
|
|
21
|
+
sync: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static get observers() {
|
|
27
|
+
return ['__updateSelected(year, selectedDate)'];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @private */
|
|
31
|
+
__updateSelected(year, selectedDate) {
|
|
32
|
+
this.toggleAttribute('selected', selectedDate && selectedDate.getFullYear() === year);
|
|
33
|
+
this.toggleAttribute('current', year === new Date().getFullYear());
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import { DatePickerYearMixin } from './vaadin-date-picker-year-mixin.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
@@ -13,9 +14,10 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
13
14
|
* @customElement
|
|
14
15
|
* @extends HTMLElement
|
|
15
16
|
* @mixes ThemableMixin
|
|
17
|
+
* @mixes DatePickerYearMixin
|
|
16
18
|
* @private
|
|
17
19
|
*/
|
|
18
|
-
export class DatePickerYear extends ThemableMixin(PolymerElement) {
|
|
20
|
+
export class DatePickerYear extends ThemableMixin(DatePickerYearMixin(PolymerElement)) {
|
|
19
21
|
static get is() {
|
|
20
22
|
return 'vaadin-date-picker-year';
|
|
21
23
|
}
|
|
@@ -32,28 +34,6 @@ export class DatePickerYear extends ThemableMixin(PolymerElement) {
|
|
|
32
34
|
<div part="year-separator" aria-hidden="true"></div>
|
|
33
35
|
`;
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
static get properties() {
|
|
37
|
-
return {
|
|
38
|
-
year: {
|
|
39
|
-
type: String,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
selectedDate: {
|
|
43
|
-
type: Object,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static get observers() {
|
|
49
|
-
return ['__updateSelected(year, selectedDate)'];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @private */
|
|
53
|
-
__updateSelected(year, selectedDate) {
|
|
54
|
-
this.toggleAttribute('selected', selectedDate && selectedDate.getFullYear() === year);
|
|
55
|
-
this.toggleAttribute('current', year === new Date().getFullYear());
|
|
56
|
-
}
|
|
57
37
|
}
|
|
58
38
|
|
|
59
39
|
defineCustomElement(DatePickerYear);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/button/src/vaadin-lit-button.js';
|
|
7
|
+
import './vaadin-date-picker-month-scroller.js';
|
|
8
|
+
import './vaadin-date-picker-year-scroller.js';
|
|
9
|
+
import './vaadin-lit-date-picker-year.js';
|
|
10
|
+
import './vaadin-lit-month-calendar.js';
|
|
11
|
+
import { html, LitElement } from 'lit';
|
|
12
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
14
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
15
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
+
import { DatePickerOverlayContentMixin } from './vaadin-date-picker-overlay-content-mixin.js';
|
|
17
|
+
import { overlayContentStyles } from './vaadin-date-picker-overlay-content-styles.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @extends HTMLElement
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
class DatePickerOverlayContent extends DatePickerOverlayContentMixin(
|
|
24
|
+
ThemableMixin(DirMixin(PolylitMixin(LitElement))),
|
|
25
|
+
) {
|
|
26
|
+
static get is() {
|
|
27
|
+
return 'vaadin-date-picker-overlay-content';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get styles() {
|
|
31
|
+
return overlayContentStyles;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @protected */
|
|
35
|
+
render() {
|
|
36
|
+
return html`
|
|
37
|
+
<div part="overlay-header" @touchend="${this._preventDefault}" aria-hidden="true">
|
|
38
|
+
<div part="label">${this._formatDisplayed(this.selectedDate, this.i18n, this.label)}</div>
|
|
39
|
+
<div part="clear-button" ?hidden="${!this.selectedDate}"></div>
|
|
40
|
+
<div part="toggle-button"></div>
|
|
41
|
+
|
|
42
|
+
<div part="years-toggle-button" ?hidden="${this._desktopMode}" aria-hidden="true">
|
|
43
|
+
${this._yearAfterXMonths(this._visibleMonthIndex)}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div id="scrollers">
|
|
48
|
+
<slot name="months"></slot>
|
|
49
|
+
<slot name="years"></slot>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div @touchend="${this._preventDefault}" role="toolbar" part="toolbar">
|
|
53
|
+
<slot name="today-button"></slot>
|
|
54
|
+
<slot name="cancel-button"></slot>
|
|
55
|
+
</div>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @protected */
|
|
60
|
+
firstUpdated() {
|
|
61
|
+
super.firstUpdated();
|
|
62
|
+
|
|
63
|
+
this.setAttribute('role', 'dialog');
|
|
64
|
+
|
|
65
|
+
this._addListeners();
|
|
66
|
+
this._initControllers();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
defineCustomElement(DatePickerOverlayContent);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
11
|
+
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
12
|
+
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
13
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
+
import { datePickerOverlayStyles } from './vaadin-date-picker-overlay-styles.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
18
|
+
*
|
|
19
|
+
* @extends HTMLElement
|
|
20
|
+
* @mixes PositionMixin
|
|
21
|
+
* @mixes OverlayMixin
|
|
22
|
+
* @mixes DirMixin
|
|
23
|
+
* @mixes ThemableMixin
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
class DatePickerOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement))))) {
|
|
27
|
+
static get is() {
|
|
28
|
+
return 'vaadin-date-picker-overlay';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return [overlayStyles, datePickerOverlayStyles];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static get properties() {
|
|
36
|
+
return {
|
|
37
|
+
/**
|
|
38
|
+
* When true, the overlay is visible and attached to body.
|
|
39
|
+
* This property config is overridden to set `sync: true`.
|
|
40
|
+
*/
|
|
41
|
+
opened: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
notify: true,
|
|
44
|
+
observer: '_openedChanged',
|
|
45
|
+
reflectToAttribute: true,
|
|
46
|
+
sync: true,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @protected */
|
|
52
|
+
render() {
|
|
53
|
+
return html`
|
|
54
|
+
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
55
|
+
<div part="overlay" id="overlay">
|
|
56
|
+
<div part="content" id="content">
|
|
57
|
+
<slot></slot>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
defineCustomElement(DatePickerOverlay);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
+
import { DatePickerYearMixin } from './vaadin-date-picker-year-mixin.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @extends HTMLElement
|
|
14
|
+
* @mixes ThemableMixin
|
|
15
|
+
* @mixes DatePickerYearMixin
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export class DatePickerYear extends ThemableMixin(DatePickerYearMixin(PolylitMixin(LitElement))) {
|
|
19
|
+
static get is() {
|
|
20
|
+
return 'vaadin-date-picker-year';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get styles() {
|
|
24
|
+
return css`
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @protected */
|
|
33
|
+
render() {
|
|
34
|
+
return html`
|
|
35
|
+
<div part="year-number">${this.year}</div>
|
|
36
|
+
<div part="year-separator" aria-hidden="true"></div>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
defineCustomElement(DatePickerYear);
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/input-container/src/vaadin-lit-input-container.js';
|
|
7
|
+
import './vaadin-lit-date-picker-overlay.js';
|
|
8
|
+
import './vaadin-lit-date-picker-overlay-content.js';
|
|
9
|
+
import { html, LitElement } from 'lit';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
13
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
14
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
15
|
+
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
16
|
+
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
17
|
+
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
18
|
+
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
19
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
20
|
+
import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
21
|
+
import { datePickerStyles } from './vaadin-date-picker-styles.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* LitElement based version of `<vaadin-date-picker>` web component.
|
|
25
|
+
*
|
|
26
|
+
* ## Disclaimer
|
|
27
|
+
*
|
|
28
|
+
* This component is an experiment not intended for publishing to npm.
|
|
29
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
30
|
+
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
31
|
+
*/
|
|
32
|
+
class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement))))) {
|
|
33
|
+
static get is() {
|
|
34
|
+
return 'vaadin-date-picker';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static get styles() {
|
|
38
|
+
return [inputFieldShared, datePickerStyles];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get properties() {
|
|
42
|
+
return {
|
|
43
|
+
/** @private */
|
|
44
|
+
_positionTarget: {
|
|
45
|
+
type: Object,
|
|
46
|
+
sync: true,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
53
|
+
* @protected
|
|
54
|
+
* @return {!HTMLElement}
|
|
55
|
+
*/
|
|
56
|
+
get clearElement() {
|
|
57
|
+
return this.$.clearButton;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @protected */
|
|
61
|
+
render() {
|
|
62
|
+
return html`
|
|
63
|
+
<div class="vaadin-date-picker-container">
|
|
64
|
+
<div part="label">
|
|
65
|
+
<slot name="label"></slot>
|
|
66
|
+
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<vaadin-input-container
|
|
70
|
+
part="input-field"
|
|
71
|
+
.readonly="${this.readonly}"
|
|
72
|
+
.disabled="${this.disabled}"
|
|
73
|
+
.invalid="${this.invalid}"
|
|
74
|
+
theme="${ifDefined(this._theme)}"
|
|
75
|
+
>
|
|
76
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
77
|
+
<slot name="input"></slot>
|
|
78
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
79
|
+
<div part="toggle-button" slot="suffix" aria-hidden="true" @click="${this._toggle}"></div>
|
|
80
|
+
</vaadin-input-container>
|
|
81
|
+
|
|
82
|
+
<div part="helper-text">
|
|
83
|
+
<slot name="helper"></slot>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div part="error-message">
|
|
87
|
+
<slot name="error-message"></slot>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<vaadin-date-picker-overlay
|
|
92
|
+
id="overlay"
|
|
93
|
+
?fullscreen="${this._fullscreen}"
|
|
94
|
+
theme="${ifDefined(this._theme)}"
|
|
95
|
+
.opened="${this.opened}"
|
|
96
|
+
@opened-changed="${this._onOpenedChanged}"
|
|
97
|
+
@vaadin-overlay-escape-press="${this._onOverlayEscapePress}"
|
|
98
|
+
@vaadin-overlay-open="${this._onOverlayOpened}"
|
|
99
|
+
@vaadin-overlay-close="${this._onVaadinOverlayClose}"
|
|
100
|
+
@vaadin-overlay-closing="${this._onOverlayClosed}"
|
|
101
|
+
restore-focus-on-close
|
|
102
|
+
no-vertical-overlap
|
|
103
|
+
.restoreFocusNode="${this.inputElement}"
|
|
104
|
+
.positionTarget="${this._positionTarget}"
|
|
105
|
+
></vaadin-date-picker-overlay>
|
|
106
|
+
|
|
107
|
+
<slot name="tooltip"></slot>
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @protected */
|
|
112
|
+
firstUpdated() {
|
|
113
|
+
super.firstUpdated();
|
|
114
|
+
|
|
115
|
+
this.addController(
|
|
116
|
+
new InputController(this, (input) => {
|
|
117
|
+
this._setInputElement(input);
|
|
118
|
+
this._setFocusElement(input);
|
|
119
|
+
this.stateTarget = input;
|
|
120
|
+
this.ariaTarget = input;
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
124
|
+
|
|
125
|
+
this._tooltipController = new TooltipController(this);
|
|
126
|
+
this.addController(this._tooltipController);
|
|
127
|
+
this._tooltipController.setPosition('top');
|
|
128
|
+
this._tooltipController.setAriaTarget(this.inputElement);
|
|
129
|
+
this._tooltipController.setShouldShow((target) => !target.opened);
|
|
130
|
+
|
|
131
|
+
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
132
|
+
|
|
133
|
+
const toggleButton = this.shadowRoot.querySelector('[part="toggle-button"]');
|
|
134
|
+
toggleButton.addEventListener('mousedown', (e) => e.preventDefault());
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @private */
|
|
138
|
+
_onOpenedChanged(event) {
|
|
139
|
+
this.opened = event.detail.value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @private */
|
|
143
|
+
_onVaadinOverlayClose(e) {
|
|
144
|
+
if (e.detail.sourceEvent && e.detail.sourceEvent.composedPath().includes(this)) {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** @private */
|
|
150
|
+
_toggle(e) {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
if (this.$.overlay.opened) {
|
|
153
|
+
this.close();
|
|
154
|
+
} else {
|
|
155
|
+
this.open();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
defineCustomElement(DatePicker);
|
|
161
|
+
|
|
162
|
+
export { DatePicker };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
+
import { dateAllowed, dateEquals } from './vaadin-date-picker-helper.js';
|
|
11
|
+
import { MonthCalendarMixin } from './vaadin-month-calendar-mixin.js';
|
|
12
|
+
import { monthCalendarStyles } from './vaadin-month-calendar-styles.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @extends HTMLElement
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
19
|
+
static get is() {
|
|
20
|
+
return 'vaadin-month-calendar';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get styles() {
|
|
24
|
+
return monthCalendarStyles;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @protected */
|
|
28
|
+
render() {
|
|
29
|
+
const weekDayNames = this._getWeekDayNames(this.i18n, this.showWeekNumbers);
|
|
30
|
+
const weeks = this._weeks;
|
|
31
|
+
const hideWeekSeparator = !this._showWeekNumbers;
|
|
32
|
+
|
|
33
|
+
return html`
|
|
34
|
+
<div part="month-header" id="month-header" aria-hidden="true">${this._getTitle(this.month, this.i18n)}</div>
|
|
35
|
+
<table
|
|
36
|
+
id="monthGrid"
|
|
37
|
+
role="grid"
|
|
38
|
+
aria-labelledby="month-header"
|
|
39
|
+
@touchend="${this._preventDefault}"
|
|
40
|
+
@touchstart="${this._onMonthGridTouchStart}"
|
|
41
|
+
>
|
|
42
|
+
<thead id="weekdays-container">
|
|
43
|
+
<tr role="row" part="weekdays">
|
|
44
|
+
<th part="weekday" aria-hidden="true" ?hidden="${hideWeekSeparator}"></th>
|
|
45
|
+
${weekDayNames.map(
|
|
46
|
+
(item) => html`
|
|
47
|
+
<th role="columnheader" part="weekday" scope="col" abbr="${item.weekDay}" aria-hidden="true">
|
|
48
|
+
${item.weekDayShort}
|
|
49
|
+
</th>
|
|
50
|
+
`,
|
|
51
|
+
)}
|
|
52
|
+
</tr>
|
|
53
|
+
</thead>
|
|
54
|
+
<tbody id="days-container">
|
|
55
|
+
${weeks.map(
|
|
56
|
+
(week) => html`
|
|
57
|
+
<tr role="row">
|
|
58
|
+
<td part="week-number" aria-hidden="true" ?hidden="${hideWeekSeparator}">
|
|
59
|
+
${this.__getWeekNumber(week)}
|
|
60
|
+
</td>
|
|
61
|
+
${week.map((date) => {
|
|
62
|
+
const isFocused = dateEquals(date, this.focusedDate);
|
|
63
|
+
const isSelected = dateEquals(date, this.selectedDate);
|
|
64
|
+
const isDisabled = !dateAllowed(date, this.minDate, this.maxDate);
|
|
65
|
+
|
|
66
|
+
const parts = [
|
|
67
|
+
'date',
|
|
68
|
+
isDisabled && 'disabled',
|
|
69
|
+
isFocused && 'focused',
|
|
70
|
+
isSelected && 'selected',
|
|
71
|
+
this._isToday(date) && 'today',
|
|
72
|
+
].filter(Boolean);
|
|
73
|
+
|
|
74
|
+
return html`
|
|
75
|
+
<td
|
|
76
|
+
role="gridcell"
|
|
77
|
+
part="${parts.join(' ')}"
|
|
78
|
+
.date="${date}"
|
|
79
|
+
?disabled="${isDisabled}"
|
|
80
|
+
tabindex="${isFocused ? '0' : '-1'}"
|
|
81
|
+
aria-selected="${isSelected ? 'true' : 'false'}"
|
|
82
|
+
aria-disabled="${isDisabled ? 'true' : 'false'}"
|
|
83
|
+
aria-label="${this.__getDayAriaLabel(date)}"
|
|
84
|
+
>${this._getDate(date)}</td
|
|
85
|
+
>
|
|
86
|
+
`;
|
|
87
|
+
})}
|
|
88
|
+
</tr>
|
|
89
|
+
`,
|
|
90
|
+
)}
|
|
91
|
+
</tbody>
|
|
92
|
+
</table>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** @protected */
|
|
97
|
+
willUpdate(props) {
|
|
98
|
+
// Calculate these properties in `willUpdate()` instead of marking
|
|
99
|
+
// them as `computed` to avoid extra update because of `sync: true`
|
|
100
|
+
if (props.has('month') || props.has('i18n')) {
|
|
101
|
+
this._days = this._getDays(this.month, this.i18n);
|
|
102
|
+
this._weeks = this._getWeeks(this._days);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (props.has('month') || props.has('minDate') || props.has('maxDate')) {
|
|
106
|
+
this.disabled = this._isDisabled(this.month, this.minDate, this.maxDate);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (props.has('showWeekNumbers') || props.has('i18n')) {
|
|
110
|
+
// Currently only supported for locales that start the week on Monday.
|
|
111
|
+
this._showWeekNumbers = this.showWeekNumbers && this.i18n && this.i18n.firstDayOfWeek === 1;
|
|
112
|
+
this.toggleAttribute('week-numbers', this._showWeekNumbers);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
defineCustomElement(MonthCalendar);
|
|
@@ -3,7 +3,7 @@ import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
|
3
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
4
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
5
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
-
import '@vaadin/button/theme/lumo/vaadin-button.js';
|
|
6
|
+
import '@vaadin/button/theme/lumo/vaadin-button-styles.js';
|
|
7
7
|
import './vaadin-date-picker-year-styles.js';
|
|
8
8
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@ import '@vaadin/vaadin-material-styles/color.js';
|
|
|
2
2
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
3
3
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
4
|
import '@vaadin/vaadin-material-styles/shadow.js';
|
|
5
|
-
import '@vaadin/button/theme/material/vaadin-button.js';
|
|
5
|
+
import '@vaadin/button/theme/material/vaadin-button-styles.js';
|
|
6
6
|
import './vaadin-date-picker-year-styles.js';
|
|
7
7
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
8
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/vaadin-date-picker-light.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/vaadin-date-picker.js';
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "24.3.0-
|
|
4
|
+
"version": "24.3.0-alpha11",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
336
|
"name": "vaadin-date-picker",
|
|
337
|
-
"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/24.3.0-
|
|
337
|
+
"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/24.3.0-alpha11/#/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\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-date-picker-light>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha11/#/elements/vaadin-date-picker-light) element.\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/24.3.0-alpha11/#/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/24.3.0-alpha11/#/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`overlay-header` | Fullscreen mode header\n`label` | Fullscreen mode value/label\n`clear-button` | Fullscreen mode clear button\n`toggle-button` | Fullscreen mode toggle button\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Footer bar 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\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",
|
|
338
338
|
"attributes": [
|
|
339
339
|
{
|
|
340
340
|
"name": "disabled",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-picker",
|
|
4
|
-
"version": "24.3.0-
|
|
4
|
+
"version": "24.3.0-alpha11",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"name": "vaadin-date-picker",
|
|
159
|
-
"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/24.3.0-
|
|
159
|
+
"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/24.3.0-alpha11/#/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\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-date-picker-light>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-alpha11/#/elements/vaadin-date-picker-light) element.\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/24.3.0-alpha11/#/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/24.3.0-alpha11/#/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`overlay-header` | Fullscreen mode header\n`label` | Fullscreen mode value/label\n`clear-button` | Fullscreen mode clear button\n`toggle-button` | Fullscreen mode toggle button\n`years-toggle-button` | Fullscreen mode years scroller toggle\n`toolbar` | Footer bar 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\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",
|
|
160
160
|
"extension": true,
|
|
161
161
|
"attributes": [
|
|
162
162
|
{
|