@vaadin/vaadin-time-picker 3.0.0-alpha1 → 3.1.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/@types/interfaces.d.ts +13 -0
- package/README.md +49 -16
- package/package.json +25 -61
- package/src/vaadin-time-picker-text-field.js +40 -36
- package/src/vaadin-time-picker.d.ts +59 -30
- package/src/vaadin-time-picker.js +142 -116
- package/theme/lumo/vaadin-time-picker-styles.js +12 -10
- package/theme/lumo/vaadin-time-picker-text-field-styles.js +18 -15
- package/theme/material/vaadin-time-picker-styles.js +12 -10
- package/vaadin-time-picker.d.ts +14 -1
- package/src/interfaces.d.ts +0 -31
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface TimePickerTime {
|
|
2
|
+
hours: string | number;
|
|
3
|
+
minutes: string | number;
|
|
4
|
+
seconds?: string | number;
|
|
5
|
+
milliseconds?: string | number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TimePickerI18n {
|
|
9
|
+
parseTime: (time: string) => TimePickerTime | undefined;
|
|
10
|
+
formatTime: (time: TimePickerTime) => string;
|
|
11
|
+
clear: string;
|
|
12
|
+
selector: string;
|
|
13
|
+
}
|
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# <vaadin-time-picker>
|
|
2
2
|
|
|
3
|
+
> ⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the [`vaadin/web-components`](https://github.com/vaadin/web-components/tree/master/packages/vaadin-time-picker) monorepository.
|
|
4
|
+
> This repository contains the source code and releases of `<vaadin-time-picker>` for the Vaadin versions 10 to 19.
|
|
5
|
+
|
|
3
6
|
[<vaadin-time-picker>](https://vaadin.com/components/vaadin-time-picker) is a [Web Component](http://webcomponents.org) providing a time-selection field, part of the [Vaadin components](https://vaadin.com/components).
|
|
4
7
|
|
|
5
8
|
[Live Demo ↗](https://cdn.vaadin.com/vaadin-time-picker/1.0.0/demo/)
|
|
@@ -8,12 +11,20 @@
|
|
|
8
11
|
|
|
9
12
|
[](https://www.npmjs.com/package/@vaadin/vaadin-time-picker)
|
|
10
13
|
[](https://www.webcomponents.org/element/vaadin/vaadin-time-picker)
|
|
11
|
-
[](https://travis-ci.org/vaadin/vaadin-time-picker)
|
|
12
|
-
[](https://coveralls.io/github/vaadin/vaadin-time-picker?branch=master)
|
|
13
|
-
[](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
14
14
|
[](https://vaadin.com/directory/component/vaadinvaadin-time-picker)
|
|
15
|
-
[](https://vaad.in/chat)
|
|
16
16
|
|
|
17
|
+
<!--
|
|
18
|
+
```
|
|
19
|
+
<custom-element-demo>
|
|
20
|
+
<template>
|
|
21
|
+
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
|
|
22
|
+
<link rel="import" href="vaadin-time-picker.html">
|
|
23
|
+
<next-code-block></next-code-block>
|
|
24
|
+
</template>
|
|
25
|
+
</custom-element-demo>
|
|
26
|
+
```
|
|
27
|
+
-->
|
|
17
28
|
```html
|
|
18
29
|
<vaadin-time-picker label="Delivery Time"></vaadin-time-picker>
|
|
19
30
|
```
|
|
@@ -22,6 +33,29 @@
|
|
|
22
33
|
|
|
23
34
|
## Installation
|
|
24
35
|
|
|
36
|
+
The Vaadin components are distributed as Bower and npm packages.
|
|
37
|
+
Please note that the version range is the same, as the API has not changed.
|
|
38
|
+
You should not mix Bower and npm versions in the same application, though.
|
|
39
|
+
|
|
40
|
+
Unlike the official Polymer Elements, the converted Polymer 3 compatible Vaadin components
|
|
41
|
+
are only published on npm, not pushed to GitHub repositories.
|
|
42
|
+
|
|
43
|
+
### Polymer 2 and HTML Imports compatible version
|
|
44
|
+
|
|
45
|
+
Install `vaadin-time-picker`:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
bower i vaadin/vaadin-time-picker --save
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Once installed, import it in your application:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<link rel="import" href="bower_components/vaadin-time-picker/vaadin-time-picker.html">
|
|
55
|
+
```
|
|
56
|
+
### Polymer 3 and ES Modules compatible version
|
|
57
|
+
|
|
58
|
+
|
|
25
59
|
Install `vaadin-time-picker`:
|
|
26
60
|
|
|
27
61
|
```sh
|
|
@@ -44,33 +78,32 @@ To use the Material theme, import the correspondent file from the `theme/materia
|
|
|
44
78
|
|
|
45
79
|
- The component with the Lumo theme:
|
|
46
80
|
|
|
47
|
-
`theme/lumo/vaadin-time-picker.
|
|
81
|
+
`theme/lumo/vaadin-time-picker.html`
|
|
48
82
|
|
|
49
83
|
- The component with the Material theme:
|
|
50
84
|
|
|
51
|
-
`theme/material/vaadin-time-picker.
|
|
85
|
+
`theme/material/vaadin-time-picker.html`
|
|
52
86
|
|
|
53
|
-
- Alias for `theme/lumo/vaadin-time-picker.
|
|
87
|
+
- Alias for `theme/lumo/vaadin-time-picker.html`:
|
|
54
88
|
|
|
55
|
-
`vaadin-time-picker.
|
|
89
|
+
`vaadin-time-picker.html`
|
|
56
90
|
|
|
57
|
-
## Running
|
|
91
|
+
## Running demos and tests in a browser
|
|
58
92
|
|
|
59
93
|
1. Fork the `vaadin-time-picker` repository and clone it locally.
|
|
60
94
|
|
|
61
|
-
1. Make sure you have [
|
|
62
|
-
|
|
63
|
-
1. Make sure you have [npm](https://www.npmjs.com/) installed.
|
|
95
|
+
1. Make sure you have [npm](https://www.npmjs.com/) and [Bower](https://bower.io) installed.
|
|
64
96
|
|
|
65
|
-
1. When in the `vaadin-time-picker` directory, run `npm install` to install dependencies.
|
|
97
|
+
1. When in the `vaadin-time-picker` directory, run `npm install` and then `bower install` to install dependencies.
|
|
66
98
|
|
|
67
99
|
1. Make sure you have [polymer-cli](https://www.npmjs.com/package/polymer-cli) installed globally: `npm i -g polymer-cli`.
|
|
68
100
|
|
|
69
101
|
1. Run `npm start`, browser will automatically open the component API documentation.
|
|
70
102
|
|
|
71
|
-
1. You can also open
|
|
103
|
+
1. You can also open demo or in-browser tests by adding **demo** or **test** to the URL, for example:
|
|
72
104
|
|
|
73
|
-
- http://127.0.0.1:3000/
|
|
105
|
+
- http://127.0.0.1:3000/components/vaadin-time-picker/demo
|
|
106
|
+
- http://127.0.0.1:3000/components/vaadin-time-picker/test
|
|
74
107
|
|
|
75
108
|
|
|
76
109
|
## Running tests from the command line
|
|
@@ -80,7 +113,7 @@ To use the Material theme, import the correspondent file from the `theme/materia
|
|
|
80
113
|
|
|
81
114
|
## Following the coding style
|
|
82
115
|
|
|
83
|
-
We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `npm run lint`, which will automatically lint all `.js` files.
|
|
116
|
+
We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `npm run lint`, which will automatically lint all `.js` files as well as JavaScript snippets inside `.html` files.
|
|
84
117
|
|
|
85
118
|
## Big Thanks
|
|
86
119
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@vaadin/vaadin-time-picker",
|
|
3
|
-
"version": "3.0.0-alpha1",
|
|
4
2
|
"description": "vaadin-time-picker",
|
|
5
|
-
"main": "vaadin-time-picker.js",
|
|
6
|
-
"module": "vaadin-time-picker.js",
|
|
7
3
|
"keywords": [
|
|
8
4
|
"Vaadin",
|
|
9
5
|
"vaadin-time-picker",
|
|
@@ -12,83 +8,51 @@
|
|
|
12
8
|
"polymer"
|
|
13
9
|
],
|
|
14
10
|
"repository": "vaadin/vaadin-time-picker",
|
|
11
|
+
"homepage": "https://vaadin.com/components",
|
|
12
|
+
"name": "@vaadin/vaadin-time-picker",
|
|
13
|
+
"version": "3.1.0",
|
|
14
|
+
"main": "vaadin-time-picker.js",
|
|
15
15
|
"author": "Vaadin Ltd",
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/vaadin/vaadin-time-picker/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://vaadin.com/components",
|
|
21
20
|
"files": [
|
|
22
21
|
"vaadin-*.d.ts",
|
|
23
22
|
"vaadin-*.js",
|
|
23
|
+
"@types",
|
|
24
24
|
"src",
|
|
25
25
|
"theme"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"lint": "npm run lint:js && npm run lint:css && npm run lint:types",
|
|
33
|
-
"lint:css": "stylelint src/*.js theme/**/*-styles.js",
|
|
34
|
-
"lint:js": "eslint src theme test",
|
|
35
|
-
"lint:types": "tsc",
|
|
36
|
-
"prestart": "npm run analyze",
|
|
37
|
-
"preversion": "magi update-version",
|
|
38
|
-
"screenshots": "hermione test/visual/test.js --update-refs",
|
|
39
|
-
"serve:dist": "web-dev-server --app-index dist/index.html --open",
|
|
40
|
-
"start": "web-dev-server --node-resolve --open",
|
|
41
|
-
"test": "web-test-runner test/*.test.js --coverage",
|
|
42
|
-
"test:sauce": "TEST_ENV=sauce npm test",
|
|
43
|
-
"test:visual": "hermione test/visual/test.js"
|
|
44
|
-
},
|
|
45
|
-
"husky": {
|
|
46
|
-
"hooks": {
|
|
47
|
-
"pre-commit": "lint-staged"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"lint-staged": {
|
|
51
|
-
"*.js": [
|
|
52
|
-
"eslint --fix",
|
|
53
|
-
"prettier --write"
|
|
54
|
-
]
|
|
27
|
+
"resolutions": {
|
|
28
|
+
"inherits": "2.0.3",
|
|
29
|
+
"samsam": "1.1.3",
|
|
30
|
+
"supports-color": "3.1.2",
|
|
31
|
+
"type-detect": "1.0.0"
|
|
55
32
|
},
|
|
56
33
|
"dependencies": {
|
|
57
34
|
"@polymer/polymer": "^3.0.0",
|
|
58
|
-
"@
|
|
35
|
+
"@polymer/iron-a11y-keys-behavior": "^3.0.0",
|
|
36
|
+
"@vaadin/vaadin-themable-mixin": "^1.6.1",
|
|
59
37
|
"@vaadin/vaadin-element-mixin": "^2.4.1",
|
|
60
|
-
"@vaadin/vaadin-lumo-styles": "^1.6.
|
|
38
|
+
"@vaadin/vaadin-lumo-styles": "^1.6.0",
|
|
61
39
|
"@vaadin/vaadin-material-styles": "^1.3.2",
|
|
62
|
-
"@vaadin/vaadin-text-field": "^
|
|
63
|
-
"@vaadin/vaadin-combo-box": "^
|
|
40
|
+
"@vaadin/vaadin-text-field": "^2.10.0",
|
|
41
|
+
"@vaadin/vaadin-combo-box": "^5.5.2",
|
|
64
42
|
"@vaadin/vaadin-control-state-mixin": "^2.2.2"
|
|
65
43
|
},
|
|
66
44
|
"devDependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"
|
|
69
|
-
"@open-wc/testing-helpers": "^1.8.0",
|
|
45
|
+
"@web-padawan/gen-typescript-declarations": "^1.6.2",
|
|
46
|
+
"web-component-tester": "6.9.2",
|
|
70
47
|
"@polymer/iron-component-page": "^4.0.0",
|
|
71
48
|
"@polymer/iron-test-helpers": "^3.0.0",
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"hermione-esm": "^0.4.0",
|
|
81
|
-
"hermione-sauce": "^0.1.0",
|
|
82
|
-
"husky": "^4.3.0",
|
|
83
|
-
"lint-staged": "^10.5.1",
|
|
84
|
-
"magi-cli": "^0.28.0",
|
|
85
|
-
"prettier": "^2.1.2",
|
|
86
|
-
"rimraf": "^3.0.2",
|
|
87
|
-
"rollup": "^2.34.1",
|
|
88
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
89
|
-
"sinon": "^9.2.0",
|
|
90
|
-
"stylelint": "^13.7.1",
|
|
91
|
-
"stylelint-config-vaadin": "^0.2.6",
|
|
92
|
-
"typescript": "^4.0.5"
|
|
49
|
+
"@webcomponents/webcomponentsjs": "^2.0.0",
|
|
50
|
+
"wct-browser-legacy": "^1.0.1",
|
|
51
|
+
"@vaadin/vaadin-demo-helpers": "^3.1.0",
|
|
52
|
+
"@polymer/iron-form": "^3.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"generate-typings": "gen-typescript-declarations --outDir . --verify",
|
|
56
|
+
"test": "wct --npm"
|
|
93
57
|
}
|
|
94
58
|
}
|
|
@@ -1,47 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2018 Vaadin Ltd.
|
|
4
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
6
|
import { TextFieldElement } from '@vaadin/vaadin-text-field/src/vaadin-text-field.js';
|
|
7
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
'vaadin-time-picker-text-field',
|
|
11
|
-
css`
|
|
12
|
-
:host([dir='rtl']) [part='input-field'] {
|
|
13
|
-
direction: ltr;
|
|
14
|
-
}
|
|
8
|
+
const $_documentContainer = document.createElement('template');
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
$_documentContainer.innerHTML = `<dom-module id="vaadin-time-picker-text-field-styles" theme-for="vaadin-time-picker-text-field">
|
|
11
|
+
<template>
|
|
12
|
+
<style>
|
|
13
|
+
:host([dir="rtl"]) [part="input-field"] {
|
|
14
|
+
direction: ltr;
|
|
15
|
+
}
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
:host([dir="rtl"]) [part="value"]::placeholder {
|
|
18
|
+
direction: rtl;
|
|
19
|
+
text-align: left;
|
|
20
|
+
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
`,
|
|
32
|
-
{ moduleId: 'vaadin-time-picker-text-field-styles' }
|
|
33
|
-
);
|
|
22
|
+
:host([dir="rtl"]) [part="input-field"] ::slotted(input)::placeholder {
|
|
23
|
+
direction: rtl;
|
|
24
|
+
text-align: left;
|
|
25
|
+
}
|
|
34
26
|
|
|
27
|
+
:host([dir="rtl"]) [part="value"]:-ms-input-placeholder,
|
|
28
|
+
:host([dir="rtl"]) [part="input-field"] ::slotted(input):-ms-input-placeholder {
|
|
29
|
+
direction: rtl;
|
|
30
|
+
text-align: left;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
</template>
|
|
34
|
+
</dom-module>`;
|
|
35
|
+
|
|
36
|
+
document.head.appendChild($_documentContainer.content);
|
|
35
37
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
* The text-field element.
|
|
39
|
+
*
|
|
40
|
+
* ### Styling
|
|
41
|
+
*
|
|
42
|
+
* See [`<vaadin-text-field>` documentation](https://github.com/vaadin/vaadin-text-field/blob/master/src/vaadin-text-field.html)
|
|
43
|
+
* for `<vaadin-time-picker-text-field>` parts and available slots (prefix, suffix etc.)
|
|
44
|
+
*
|
|
45
|
+
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)
|
|
46
|
+
*
|
|
47
|
+
* @extends PolymerElement
|
|
48
|
+
*/
|
|
45
49
|
class TimePickerTextFieldElement extends TextFieldElement {
|
|
46
50
|
static get is() {
|
|
47
51
|
return 'vaadin-time-picker-text-field';
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file was automatically generated by
|
|
5
|
+
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
|
6
|
+
*
|
|
7
|
+
* To modify these typings, edit the source file(s):
|
|
8
|
+
* src/vaadin-time-picker.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
|
13
|
+
// tslint:disable:no-any describes the API as best we are able today
|
|
4
14
|
|
|
5
|
-
import {
|
|
15
|
+
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
|
6
16
|
|
|
7
|
-
import {
|
|
17
|
+
import {ThemableMixin} from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
18
|
+
|
|
19
|
+
import {ElementMixin} from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
|
|
20
|
+
|
|
21
|
+
import {IronA11yKeysBehavior} from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
|
|
22
|
+
|
|
23
|
+
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
|
24
|
+
|
|
25
|
+
import {ControlStateMixin} from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';
|
|
8
26
|
|
|
9
27
|
/**
|
|
10
28
|
* `<vaadin-time-picker>` is a Web Component providing a time-selection field.
|
|
@@ -51,7 +69,12 @@ import { TimePickerEventMap, TimePickerI18n, TimePickerTime } from './interfaces
|
|
|
51
69
|
* Note: the `theme` attribute value set on `<vaadin-time-picker>` is
|
|
52
70
|
* propagated to the internal themable components listed above.
|
|
53
71
|
*/
|
|
54
|
-
declare class TimePickerElement extends
|
|
72
|
+
declare class TimePickerElement extends
|
|
73
|
+
ElementMixin(
|
|
74
|
+
ControlStateMixin(
|
|
75
|
+
ThemableMixin(
|
|
76
|
+
PolymerElement))) {
|
|
77
|
+
|
|
55
78
|
/**
|
|
56
79
|
* Focusable element used by vaadin-control-state-mixin
|
|
57
80
|
*/
|
|
@@ -65,7 +88,7 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
65
88
|
/**
|
|
66
89
|
* The name of this element.
|
|
67
90
|
*/
|
|
68
|
-
name: string
|
|
91
|
+
name: string|null|undefined;
|
|
69
92
|
|
|
70
93
|
/**
|
|
71
94
|
* The time value for this element.
|
|
@@ -80,7 +103,7 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
80
103
|
/**
|
|
81
104
|
* The label for this element.
|
|
82
105
|
*/
|
|
83
|
-
label: string
|
|
106
|
+
label: string|null|undefined;
|
|
84
107
|
|
|
85
108
|
/**
|
|
86
109
|
* Set to true to mark the input as required.
|
|
@@ -91,24 +114,24 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
91
114
|
* Set to true to prevent the user from entering invalid input.
|
|
92
115
|
* @attr {boolean} prevent-invalid-input
|
|
93
116
|
*/
|
|
94
|
-
preventInvalidInput: boolean
|
|
117
|
+
preventInvalidInput: boolean|null|undefined;
|
|
95
118
|
|
|
96
119
|
/**
|
|
97
120
|
* A pattern to validate the `input` with.
|
|
98
121
|
*/
|
|
99
|
-
pattern: string
|
|
122
|
+
pattern: string|null|undefined;
|
|
100
123
|
|
|
101
124
|
/**
|
|
102
125
|
* The error message to display when the input is invalid.
|
|
103
126
|
* @attr {string} error-message
|
|
104
127
|
*/
|
|
105
|
-
errorMessage: string
|
|
128
|
+
errorMessage: string|null|undefined;
|
|
106
129
|
|
|
107
130
|
/**
|
|
108
131
|
* String used for the helper text.
|
|
109
132
|
* @attr {string} helper-text
|
|
110
133
|
*/
|
|
111
|
-
helperText: string
|
|
134
|
+
helperText: string|null|undefined;
|
|
112
135
|
|
|
113
136
|
/**
|
|
114
137
|
* A placeholder string in addition to the label.
|
|
@@ -145,6 +168,11 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
145
168
|
*/
|
|
146
169
|
max: string;
|
|
147
170
|
|
|
171
|
+
/**
|
|
172
|
+
* When true, the input element has a non-empty value entered by the user.
|
|
173
|
+
*/
|
|
174
|
+
_hasInputValue: boolean|null|undefined;
|
|
175
|
+
|
|
148
176
|
/**
|
|
149
177
|
* Specifies the number of valid intervals in a day used for
|
|
150
178
|
* configuring the items displayed in the selection box.
|
|
@@ -161,7 +189,7 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
161
189
|
* fragments (i.e. 5760 seconds which equals 1 hour 36 minutes), but it is
|
|
162
190
|
* not recommended to use it for better UX experience.
|
|
163
191
|
*/
|
|
164
|
-
step: number
|
|
192
|
+
step: number|null|undefined;
|
|
165
193
|
|
|
166
194
|
/**
|
|
167
195
|
* Set to true to display the clear icon which clears the input.
|
|
@@ -173,7 +201,7 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
173
201
|
* Set true to prevent the overlay from opening automatically.
|
|
174
202
|
* @attr {boolean} auto-open-disabled
|
|
175
203
|
*/
|
|
176
|
-
autoOpenDisabled: boolean
|
|
204
|
+
autoOpenDisabled: boolean|null|undefined;
|
|
177
205
|
|
|
178
206
|
/**
|
|
179
207
|
* The object used to localize this component.
|
|
@@ -206,13 +234,21 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
206
234
|
* }
|
|
207
235
|
*/
|
|
208
236
|
i18n: TimePickerI18n;
|
|
237
|
+
ready(): void;
|
|
238
|
+
_getInputElement(): any;
|
|
239
|
+
_setInvalid(invalid: boolean): void;
|
|
209
240
|
|
|
210
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Override this method to define whether the given `invalid` state should be set.
|
|
243
|
+
*/
|
|
244
|
+
_shouldSetInvalid(_invalid: boolean): boolean;
|
|
211
245
|
|
|
212
246
|
/**
|
|
213
|
-
*
|
|
247
|
+
* Validates the field and sets the `invalid` property based on the result.
|
|
214
248
|
*
|
|
215
|
-
*
|
|
249
|
+
* The method fires a `validated` event with the result of the validation.
|
|
250
|
+
*
|
|
251
|
+
* @returns True if the value is valid.
|
|
216
252
|
*/
|
|
217
253
|
validate(): boolean;
|
|
218
254
|
|
|
@@ -232,24 +268,17 @@ declare class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableM
|
|
|
232
268
|
* @returns True if the value is valid
|
|
233
269
|
*/
|
|
234
270
|
checkValidity(): boolean;
|
|
235
|
-
|
|
236
|
-
addEventListener<K extends keyof TimePickerEventMap>(
|
|
237
|
-
type: K,
|
|
238
|
-
listener: (this: TimePickerElement, ev: TimePickerEventMap[K]) => void,
|
|
239
|
-
options?: boolean | AddEventListenerOptions
|
|
240
|
-
): void;
|
|
241
|
-
|
|
242
|
-
removeEventListener<K extends keyof TimePickerEventMap>(
|
|
243
|
-
type: K,
|
|
244
|
-
listener: (this: TimePickerElement, ev: TimePickerEventMap[K]) => void,
|
|
245
|
-
options?: boolean | EventListenerOptions
|
|
246
|
-
): void;
|
|
247
271
|
}
|
|
248
272
|
|
|
249
273
|
declare global {
|
|
274
|
+
|
|
250
275
|
interface HTMLElementTagNameMap {
|
|
251
|
-
|
|
276
|
+
"vaadin-time-picker": TimePickerElement;
|
|
252
277
|
}
|
|
253
278
|
}
|
|
254
279
|
|
|
255
|
-
export {
|
|
280
|
+
export {TimePickerElement};
|
|
281
|
+
|
|
282
|
+
import {TimePickerI18n} from '../@types/interfaces';
|
|
283
|
+
|
|
284
|
+
import {TimePickerTime} from '../@types/interfaces';
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { PolymerElement
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2018 Vaadin Ltd.
|
|
4
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
|
|
7
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
|
|
9
|
-
import { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';
|
|
10
10
|
import '@vaadin/vaadin-combo-box/src/vaadin-combo-box-light.js';
|
|
11
|
+
import { IronA11yKeysBehavior } from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior.js';
|
|
11
12
|
import './vaadin-time-picker-text-field.js';
|
|
13
|
+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
14
|
+
import { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* `<vaadin-time-picker>` is a Web Component providing a time-selection field.
|
|
@@ -55,85 +58,53 @@ import './vaadin-time-picker-text-field.js';
|
|
|
55
58
|
* Note: the `theme` attribute value set on `<vaadin-time-picker>` is
|
|
56
59
|
* propagated to the internal themable components listed above.
|
|
57
60
|
*
|
|
58
|
-
* @extends
|
|
61
|
+
* @extends PolymerElement
|
|
59
62
|
* @mixes ElementMixin
|
|
60
63
|
* @mixes ControlStateMixin
|
|
61
64
|
* @mixes ThemableMixin
|
|
65
|
+
* @demo demo/index.html
|
|
62
66
|
*/
|
|
63
|
-
class TimePickerElement extends
|
|
67
|
+
class TimePickerElement extends
|
|
68
|
+
ElementMixin(
|
|
69
|
+
ControlStateMixin(
|
|
70
|
+
ThemableMixin(PolymerElement))) {
|
|
64
71
|
static get template() {
|
|
65
72
|
return html`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
<style>
|
|
74
|
+
:host {
|
|
75
|
+
display: inline-block;
|
|
76
|
+
}
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
:host([hidden]) {
|
|
79
|
+
display: none !important;
|
|
80
|
+
}
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
[part~="toggle-button"] {
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
item
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<template> [[item.label]] </template>
|
|
95
|
-
<vaadin-time-picker-text-field
|
|
96
|
-
class="input"
|
|
97
|
-
name="[[name]]"
|
|
98
|
-
invalid="[[invalid]]"
|
|
99
|
-
autocomplete="off"
|
|
100
|
-
label="[[label]]"
|
|
101
|
-
required="[[required]]"
|
|
102
|
-
disabled="[[disabled]]"
|
|
103
|
-
prevent-invalid-input="[[preventInvalidInput]]"
|
|
104
|
-
pattern="[[pattern]]"
|
|
105
|
-
error-message="[[errorMessage]]"
|
|
106
|
-
autofocus="[[autofocus]]"
|
|
107
|
-
placeholder="[[placeholder]]"
|
|
108
|
-
readonly="[[readonly]]"
|
|
109
|
-
role="application"
|
|
110
|
-
aria-live="assertive"
|
|
111
|
-
min$="[[min]]"
|
|
112
|
-
max$="[[max]]"
|
|
113
|
-
aria-label$="[[label]]"
|
|
114
|
-
clear-button-visible="[[clearButtonVisible]]"
|
|
115
|
-
i18n="[[i18n]]"
|
|
116
|
-
helper-text="[[helperText]]"
|
|
117
|
-
theme$="[[theme]]"
|
|
118
|
-
>
|
|
119
|
-
<slot name="helper" slot="helper">[[helperText]]</slot>
|
|
120
|
-
<span
|
|
121
|
-
slot="suffix"
|
|
122
|
-
part="toggle-button"
|
|
123
|
-
class="toggle-button"
|
|
124
|
-
role="button"
|
|
125
|
-
aria-label$="[[i18n.selector]]"
|
|
126
|
-
></span>
|
|
127
|
-
</vaadin-time-picker-text-field>
|
|
128
|
-
</vaadin-combo-box-light>
|
|
129
|
-
`;
|
|
86
|
+
.input {
|
|
87
|
+
width: 100%;
|
|
88
|
+
min-width: 0;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
91
|
+
<vaadin-combo-box-light allow-custom-value="" item-label-path="value" filtered-items="[[__dropdownItems]]" disabled="[[disabled]]" readonly="[[readonly]]" auto-open-disabled="[[autoOpenDisabled]]" dir="ltr" theme\$="[[theme]]" on-has-input-value-changed="__onComboBoxHasInputValueChanged">
|
|
92
|
+
<template>
|
|
93
|
+
[[item.label]]
|
|
94
|
+
</template>
|
|
95
|
+
<vaadin-time-picker-text-field class="input" name="[[name]]" invalid="[[invalid]]" autocomplete="off" label="[[label]]" required="[[required]]" disabled="[[disabled]]" prevent-invalid-input="[[preventInvalidInput]]" pattern="[[pattern]]" error-message="[[errorMessage]]" autofocus="[[autofocus]]" placeholder="[[placeholder]]" readonly="[[readonly]]" role="application" aria-live="assertive" min\$="[[min]]" max\$="[[max]]" aria-label\$="[[label]]" clear-button-visible="[[clearButtonVisible]]" i18n="[[i18n]]" helper-text="[[helperText]]" theme\$="[[theme]]">
|
|
96
|
+
<slot name="helper" slot="helper">[[helperText]]</slot>
|
|
97
|
+
<span slot="suffix" part="toggle-button" class="toggle-button" role="button" aria-label\$="[[i18n.selector]]"></span>
|
|
98
|
+
</vaadin-time-picker-text-field>
|
|
99
|
+
</vaadin-combo-box-light>
|
|
100
|
+
`;
|
|
130
101
|
}
|
|
131
102
|
|
|
132
103
|
static get is() {
|
|
133
104
|
return 'vaadin-time-picker';
|
|
134
105
|
}
|
|
135
106
|
static get version() {
|
|
136
|
-
return '3.
|
|
107
|
+
return '3.1.0';
|
|
137
108
|
}
|
|
138
109
|
|
|
139
110
|
static get properties() {
|
|
@@ -260,7 +231,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
260
231
|
*/
|
|
261
232
|
min: {
|
|
262
233
|
type: String,
|
|
263
|
-
value: '00:00:00.000'
|
|
234
|
+
value: '00:00:00.000',
|
|
264
235
|
},
|
|
265
236
|
|
|
266
237
|
/**
|
|
@@ -274,7 +245,17 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
274
245
|
*/
|
|
275
246
|
max: {
|
|
276
247
|
type: String,
|
|
277
|
-
value: '23:59:59.999'
|
|
248
|
+
value: '23:59:59.999',
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* When true, the input element has a non-empty value entered by the user.
|
|
253
|
+
* @protected
|
|
254
|
+
*/
|
|
255
|
+
_hasInputValue: {
|
|
256
|
+
type: Boolean,
|
|
257
|
+
value: false,
|
|
258
|
+
observer: '_hasInputValueChanged',
|
|
278
259
|
},
|
|
279
260
|
|
|
280
261
|
/**
|
|
@@ -362,19 +343,17 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
362
343
|
// Always display hour and minute
|
|
363
344
|
let timeString = `${pad(time.hours)}:${pad(time.minutes)}`;
|
|
364
345
|
// Adding second and millisecond depends on resolution
|
|
365
|
-
time.seconds !== undefined && (timeString += `:${pad(time.seconds)}`);
|
|
366
|
-
time.milliseconds !== undefined && (timeString += `.${pad(time.milliseconds, '000')}`);
|
|
346
|
+
(time.seconds !== undefined) && (timeString += `:${pad(time.seconds)}`);
|
|
347
|
+
(time.milliseconds !== undefined) && (timeString += `.${pad(time.milliseconds, '000')}`);
|
|
367
348
|
return timeString;
|
|
368
349
|
},
|
|
369
|
-
parseTime:
|
|
350
|
+
parseTime: text => {
|
|
370
351
|
// Parsing with RegExp to ensure correct format
|
|
371
352
|
const MATCH_HOURS = '(\\d|[0-1]\\d|2[0-3])';
|
|
372
353
|
const MATCH_MINUTES = '(\\d|[0-5]\\d)';
|
|
373
354
|
const MATCH_SECONDS = MATCH_MINUTES;
|
|
374
355
|
const MATCH_MILLISECONDS = '(\\d{1,3})';
|
|
375
|
-
const re = new RegExp(
|
|
376
|
-
`^${MATCH_HOURS}(?::${MATCH_MINUTES}(?::${MATCH_SECONDS}(?:\\.${MATCH_MILLISECONDS})?)?)?$`
|
|
377
|
-
);
|
|
356
|
+
const re = new RegExp(`^${MATCH_HOURS}(?::${MATCH_MINUTES}(?::${MATCH_SECONDS}(?:\\.${MATCH_MILLISECONDS})?)?)?$`);
|
|
378
357
|
const parts = re.exec(text);
|
|
379
358
|
if (parts) {
|
|
380
359
|
// Allows setting the milliseconds with hundreds and tens precision
|
|
@@ -383,7 +362,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
383
362
|
parts[4] += '0';
|
|
384
363
|
}
|
|
385
364
|
}
|
|
386
|
-
return {
|
|
365
|
+
return {hours: parts[1], minutes: parts[2], seconds: parts[3], milliseconds: parts[4]};
|
|
387
366
|
}
|
|
388
367
|
},
|
|
389
368
|
selector: 'Time selector',
|
|
@@ -395,7 +374,9 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
395
374
|
}
|
|
396
375
|
|
|
397
376
|
static get observers() {
|
|
398
|
-
return [
|
|
377
|
+
return [
|
|
378
|
+
'__updateDropdownItems(i18n.*, min, max, step)'
|
|
379
|
+
];
|
|
399
380
|
}
|
|
400
381
|
|
|
401
382
|
/** @protected */
|
|
@@ -407,14 +388,14 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
407
388
|
|
|
408
389
|
// Not using declarative because we receive an event before text-element shadow is ready,
|
|
409
390
|
// thus querySelector in textField.focusElement raises an undefined exception on validate
|
|
410
|
-
this.__dropdownElement.addEventListener('value-changed',
|
|
391
|
+
this.__dropdownElement.addEventListener('value-changed', e => this.__onInputChange(e));
|
|
411
392
|
this.__inputElement.addEventListener('keydown', this.__onKeyDown.bind(this));
|
|
412
393
|
|
|
413
394
|
// Validation listeners
|
|
414
|
-
this.__dropdownElement.addEventListener('change',
|
|
415
|
-
this.__inputElement.addEventListener('blur',
|
|
395
|
+
this.__dropdownElement.addEventListener('change', e => this.validate());
|
|
396
|
+
this.__inputElement.addEventListener('blur', e => this.validate());
|
|
416
397
|
|
|
417
|
-
this.__dropdownElement.addEventListener('change',
|
|
398
|
+
this.__dropdownElement.addEventListener('change', e => {
|
|
418
399
|
// `vaadin-combo-box-light` forwards 'change' event from text-field.
|
|
419
400
|
// So we need to filter out in order to avoid duplicates.
|
|
420
401
|
if (e.composedPath()[0] !== this.__inputElement) {
|
|
@@ -423,23 +404,35 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
423
404
|
});
|
|
424
405
|
}
|
|
425
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Observer to notify about the change of private property.
|
|
409
|
+
*
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
_hasInputValueChanged(hasValue, oldHasValue) {
|
|
413
|
+
if (hasValue || oldHasValue) {
|
|
414
|
+
this.dispatchEvent(new CustomEvent('has-input-value-changed'));
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
426
418
|
/** @private */
|
|
427
419
|
__validDayDivisor(step) {
|
|
428
420
|
// valid if undefined, or exact divides a day, or has millisecond resolution
|
|
429
|
-
return !step ||
|
|
421
|
+
return !step || 24 * 3600 % step === 0 || (step < 1 && step % 1 * 1000 % 1 === 0);
|
|
430
422
|
}
|
|
431
423
|
|
|
432
424
|
/** @private */
|
|
433
425
|
__onKeyDown(e) {
|
|
426
|
+
|
|
434
427
|
if (this.readonly || this.disabled || this.__dropdownItems.length) {
|
|
435
428
|
return;
|
|
436
429
|
}
|
|
437
430
|
|
|
438
|
-
const stepResolution =
|
|
431
|
+
const stepResolution = this.__validDayDivisor(this.step) && this.step || 60;
|
|
439
432
|
|
|
440
|
-
if (e
|
|
433
|
+
if (IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'down')) {
|
|
441
434
|
this.__onArrowPressWithStep(-stepResolution);
|
|
442
|
-
} else if (e
|
|
435
|
+
} else if (IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'up')) {
|
|
443
436
|
this.__onArrowPressWithStep(stepResolution);
|
|
444
437
|
}
|
|
445
438
|
}
|
|
@@ -454,7 +447,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
454
447
|
|
|
455
448
|
/** @private */
|
|
456
449
|
__dispatchChange() {
|
|
457
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
450
|
+
this.dispatchEvent(new CustomEvent('change', {bubbles: true}));
|
|
458
451
|
}
|
|
459
452
|
|
|
460
453
|
/**
|
|
@@ -462,10 +455,10 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
462
455
|
* @private
|
|
463
456
|
*/
|
|
464
457
|
__getMsec(obj) {
|
|
465
|
-
let result = (
|
|
466
|
-
result += (
|
|
467
|
-
result += (
|
|
468
|
-
result += (obj && parseInt(obj.milliseconds)
|
|
458
|
+
let result = (obj && obj.hours || 0) * 60 * 60 * 1000;
|
|
459
|
+
result += (obj && obj.minutes || 0) * 60 * 1000;
|
|
460
|
+
result += (obj && obj.seconds || 0) * 1000;
|
|
461
|
+
result += (obj && parseInt(obj.milliseconds) || 0);
|
|
469
462
|
|
|
470
463
|
return result;
|
|
471
464
|
}
|
|
@@ -475,10 +468,10 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
475
468
|
* @private
|
|
476
469
|
*/
|
|
477
470
|
__getSec(obj) {
|
|
478
|
-
let result = (
|
|
479
|
-
result += (
|
|
480
|
-
result += (obj && obj.seconds
|
|
481
|
-
result += (obj && obj.milliseconds / 1000
|
|
471
|
+
let result = (obj && obj.hours || 0) * 60 * 60;
|
|
472
|
+
result += (obj && obj.minutes || 0) * 60;
|
|
473
|
+
result += (obj && obj.seconds || 0);
|
|
474
|
+
result += (obj && obj.milliseconds / 1000 || 0);
|
|
482
475
|
|
|
483
476
|
return result;
|
|
484
477
|
}
|
|
@@ -512,7 +505,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
512
505
|
var ss = Math.floor(msec / 1000);
|
|
513
506
|
msec -= ss * 1000;
|
|
514
507
|
|
|
515
|
-
return {
|
|
508
|
+
return {hours: (hh < 24) ? hh : 0, minutes: mm, seconds: ss, milliseconds: msec};
|
|
516
509
|
}
|
|
517
510
|
|
|
518
511
|
/** @private */
|
|
@@ -554,7 +547,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
554
547
|
const timeObj = this.__validateTime(this.__addStep(time * 1000, step));
|
|
555
548
|
time += step;
|
|
556
549
|
const formatted = this.i18n.formatTime(timeObj);
|
|
557
|
-
generatedList.push({
|
|
550
|
+
generatedList.push({label: formatted, value: formatted});
|
|
558
551
|
}
|
|
559
552
|
|
|
560
553
|
return generatedList;
|
|
@@ -578,7 +571,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
578
571
|
|
|
579
572
|
/** @private */
|
|
580
573
|
__valueChanged(value, oldValue) {
|
|
581
|
-
const parsedObj =
|
|
574
|
+
const parsedObj = this.__memoValue = this.__parseISO(value);
|
|
582
575
|
const newValue = this.__formatISO(parsedObj) || '';
|
|
583
576
|
|
|
584
577
|
if (this.value !== '' && this.value !== null && !parsedObj) {
|
|
@@ -591,7 +584,7 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
591
584
|
}
|
|
592
585
|
|
|
593
586
|
/** @private */
|
|
594
|
-
__onInputChange() {
|
|
587
|
+
__onInputChange(e) {
|
|
595
588
|
const parsedObj = this.i18n.parseTime(this.__dropdownElement.value);
|
|
596
589
|
const newValue = this.i18n.formatTime(parsedObj) || '';
|
|
597
590
|
|
|
@@ -644,7 +637,6 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
644
637
|
// Accept milliseconds
|
|
645
638
|
return 4;
|
|
646
639
|
}
|
|
647
|
-
return undefined;
|
|
648
640
|
}
|
|
649
641
|
|
|
650
642
|
/** @private */
|
|
@@ -671,7 +663,8 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
671
663
|
|
|
672
664
|
/** @private */
|
|
673
665
|
get __dropdownElement() {
|
|
674
|
-
return this.__memoDropdown ||
|
|
666
|
+
return this.__memoDropdown ||
|
|
667
|
+
(this.__memoDropdown = this.shadowRoot.querySelector('vaadin-combo-box-light'));
|
|
675
668
|
}
|
|
676
669
|
|
|
677
670
|
/**
|
|
@@ -684,12 +677,47 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
684
677
|
}
|
|
685
678
|
|
|
686
679
|
/**
|
|
687
|
-
*
|
|
680
|
+
* Synchronizes the `_hasInputValue` property with the internal combo-box's one.
|
|
681
|
+
*
|
|
682
|
+
* @private
|
|
683
|
+
*/
|
|
684
|
+
__onComboBoxHasInputValueChanged() {
|
|
685
|
+
this._hasInputValue = this.__dropdownElement._hasInputValue;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* @param {boolean} invalid
|
|
690
|
+
* @protected
|
|
691
|
+
*/
|
|
692
|
+
_setInvalid(invalid) {
|
|
693
|
+
if (this._shouldSetInvalid(invalid)) {
|
|
694
|
+
this.invalid = invalid;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Override this method to define whether the given `invalid` state should be set.
|
|
700
|
+
*
|
|
701
|
+
* @param {boolean} _invalid
|
|
702
|
+
* @return {boolean}
|
|
703
|
+
* @protected
|
|
704
|
+
*/
|
|
705
|
+
_shouldSetInvalid(_invalid) {
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Validates the field and sets the `invalid` property based on the result.
|
|
711
|
+
*
|
|
712
|
+
* The method fires a `validated` event with the result of the validation.
|
|
688
713
|
*
|
|
689
|
-
* @return {boolean} True if the value is valid
|
|
714
|
+
* @return {boolean} True if the value is valid.
|
|
690
715
|
*/
|
|
691
716
|
validate() {
|
|
692
|
-
|
|
717
|
+
const isValid = this.checkValidity();
|
|
718
|
+
this._setInvalid(!isValid);
|
|
719
|
+
this.dispatchEvent(new CustomEvent('validated', {detail: {valid: isValid}}));
|
|
720
|
+
return isValid;
|
|
693
721
|
}
|
|
694
722
|
|
|
695
723
|
/**
|
|
@@ -703,10 +731,8 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
703
731
|
const parsedMin = this.i18n.parseTime(this.min);
|
|
704
732
|
const parsedMax = this.i18n.parseTime(this.max);
|
|
705
733
|
|
|
706
|
-
return (
|
|
707
|
-
(!this.__getMsec(
|
|
708
|
-
(!this.__getMsec(parsedMax) || this.__getMsec(time) <= this.__getMsec(parsedMax))
|
|
709
|
-
);
|
|
734
|
+
return (!this.__getMsec(parsedMin) || this.__getMsec(time) >= this.__getMsec(parsedMin)) &&
|
|
735
|
+
(!this.__getMsec(parsedMax) || this.__getMsec(time) <= this.__getMsec(parsedMax));
|
|
710
736
|
}
|
|
711
737
|
|
|
712
738
|
/**
|
|
@@ -717,17 +743,17 @@ class TimePickerElement extends ElementMixin(ControlStateMixin(ThemableMixin(Pol
|
|
|
717
743
|
* @return {boolean} True if the value is valid
|
|
718
744
|
*/
|
|
719
745
|
checkValidity() {
|
|
720
|
-
return !!(
|
|
721
|
-
this.__inputElement.focusElement.checkValidity() &&
|
|
746
|
+
return !!(this.__inputElement.focusElement.checkValidity() &&
|
|
722
747
|
(!this.value || this._timeAllowed(this.i18n.parseTime(this.value))) &&
|
|
723
|
-
(!this.__dropdownElement.value || this.i18n.parseTime(this.__dropdownElement.value))
|
|
724
|
-
);
|
|
748
|
+
(!this.__dropdownElement.value || this.i18n.parseTime(this.__dropdownElement.value)));
|
|
725
749
|
}
|
|
726
750
|
|
|
727
751
|
/**
|
|
728
|
-
* Fired
|
|
752
|
+
* Fired whenever the field is validated.
|
|
729
753
|
*
|
|
730
|
-
* @event
|
|
754
|
+
* @event validated
|
|
755
|
+
* @param {Object} detail
|
|
756
|
+
* @param {boolean} detail.valid the result of the validation.
|
|
731
757
|
*/
|
|
732
758
|
}
|
|
733
759
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import '@vaadin/vaadin-combo-box/theme/lumo/vaadin-combo-box-light.js';
|
|
2
2
|
import '@vaadin/vaadin-lumo-styles/mixins/field-button.js';
|
|
3
3
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
4
|
-
import {
|
|
4
|
+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const $_documentContainer = html`<dom-module id="lumo-time-picker" theme-for="vaadin-time-picker">
|
|
7
|
+
<template>
|
|
8
|
+
<style include="lumo-field-button">
|
|
9
|
+
[part~="toggle-button"]::before {
|
|
10
|
+
content: var(--lumo-icons-clock);
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
</template>
|
|
14
|
+
</dom-module>`;
|
|
15
|
+
|
|
16
|
+
document.head.appendChild($_documentContainer.content);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import '@vaadin/vaadin-text-field/theme/lumo/vaadin-text-field.js';
|
|
2
|
-
import {
|
|
2
|
+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const $_documentContainer = html`<dom-module id="lumo-time-picker-text-field" theme-for="vaadin-time-picker-text-field">
|
|
5
|
+
<template>
|
|
6
|
+
<style>
|
|
7
|
+
:not(*):placeholder-shown, /* to prevent broken styles on IE */
|
|
8
|
+
:host([dir="rtl"]) [part="value"]:placeholder-shown,
|
|
9
|
+
:host([dir="rtl"]) [part="input-field"] ::slotted(input:placeholder-shown) {
|
|
10
|
+
--_lumo-text-field-overflow-mask-image: none;
|
|
11
|
+
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
:host([dir="rtl"]) [part="value"],
|
|
14
|
+
:host([dir="rtl"]) [part="input-field"] ::slotted(input) {
|
|
15
|
+
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em);
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
</template>
|
|
19
|
+
</dom-module>`;
|
|
20
|
+
|
|
21
|
+
document.head.appendChild($_documentContainer.content);
|
|
@@ -2,14 +2,16 @@ import '@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light.js';
|
|
|
2
2
|
import '@vaadin/vaadin-text-field/theme/material/vaadin-text-field.js';
|
|
3
3
|
import '@vaadin/vaadin-material-styles/mixins/field-button.js';
|
|
4
4
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
5
|
-
import {
|
|
5
|
+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const $_documentContainer = html`<dom-module id="material-time-picker" theme-for="vaadin-time-picker">
|
|
8
|
+
<template>
|
|
9
|
+
<style include="material-field-button">
|
|
10
|
+
[part~="toggle-button"]::before {
|
|
11
|
+
content: var(--material-icons-clock);
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
</template>
|
|
15
|
+
</dom-module>`;
|
|
16
|
+
|
|
17
|
+
document.head.appendChild($_documentContainer.content);
|
package/vaadin-time-picker.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DO NOT EDIT
|
|
3
|
+
*
|
|
4
|
+
* This file was automatically generated by
|
|
5
|
+
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
|
|
6
|
+
*
|
|
7
|
+
* To modify these typings, edit the source file(s):
|
|
8
|
+
* vaadin-time-picker.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// tslint:disable:variable-name Describing an API that's defined elsewhere.
|
|
13
|
+
|
|
1
14
|
export * from './src/vaadin-time-picker.js';
|
|
2
|
-
export * from '
|
|
15
|
+
export * from './@types/interfaces';
|
package/src/interfaces.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface TimePickerTime {
|
|
2
|
-
hours: string | number;
|
|
3
|
-
minutes: string | number;
|
|
4
|
-
seconds?: string | number;
|
|
5
|
-
milliseconds?: string | number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface TimePickerI18n {
|
|
9
|
-
parseTime: (time: string) => TimePickerTime | undefined;
|
|
10
|
-
formatTime: (time: TimePickerTime) => string;
|
|
11
|
-
clear: string;
|
|
12
|
-
selector: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fired when the `invalid` property changes.
|
|
17
|
-
*/
|
|
18
|
-
export type TimePickerInvalidChanged = CustomEvent<{ value: boolean; path: 'invalid' }>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Fired when the `value` property changes.
|
|
22
|
-
*/
|
|
23
|
-
export type TimePickerValueChanged = CustomEvent<{ value: string; path: 'value' }>;
|
|
24
|
-
|
|
25
|
-
export interface TimePickerElementEventMap {
|
|
26
|
-
'invalid-changed': TimePickerInvalidChanged;
|
|
27
|
-
|
|
28
|
-
'value-changed': TimePickerValueChanged;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface TimePickerEventMap extends HTMLElementEventMap, TimePickerElementEventMap {}
|