@vaadin/time-picker 22.0.0-alpha7
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/LICENSE +190 -0
- package/README.md +61 -0
- package/package.json +50 -0
- package/src/interfaces.d.ts +31 -0
- package/src/vaadin-time-picker-combo-box.js +105 -0
- package/src/vaadin-time-picker-dropdown.js +38 -0
- package/src/vaadin-time-picker-item.js +37 -0
- package/src/vaadin-time-picker-overlay.js +31 -0
- package/src/vaadin-time-picker-scroller.js +20 -0
- package/src/vaadin-time-picker.d.ts +186 -0
- package/src/vaadin-time-picker.js +684 -0
- package/theme/lumo/vaadin-time-picker-styles.js +24 -0
- package/theme/lumo/vaadin-time-picker.js +9 -0
- package/theme/material/vaadin-time-picker-styles.js +16 -0
- package/theme/material/vaadin-time-picker.js +9 -0
- package/vaadin-time-picker.d.ts +2 -0
- package/vaadin-time-picker.js +2 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
|
+
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
8
|
+
import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
9
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
+
import { TimePickerEventMap, TimePickerI18n } from './interfaces';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `<vaadin-time-picker>` is a Web Component providing a time-selection field.
|
|
14
|
+
*
|
|
15
|
+
* ```html
|
|
16
|
+
* <vaadin-time-picker></vaadin-time-picker>
|
|
17
|
+
* ```
|
|
18
|
+
* ```js
|
|
19
|
+
* timePicker.value = '14:30';
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* When the selected `value` is changed, a `value-changed` event is triggered.
|
|
23
|
+
*
|
|
24
|
+
* ### Styling
|
|
25
|
+
*
|
|
26
|
+
* The following custom properties are available for styling:
|
|
27
|
+
*
|
|
28
|
+
* Custom property | Description | Default
|
|
29
|
+
* ------------------------------------------|----------------------------|---------
|
|
30
|
+
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
31
|
+
* `--vaadin-time-picker-overlay-max-height` | Max height of the overlay | `65vh`
|
|
32
|
+
*
|
|
33
|
+
* The following shadow DOM parts are available for styling:
|
|
34
|
+
*
|
|
35
|
+
* Part name | Description
|
|
36
|
+
* ----------------|----------------
|
|
37
|
+
* `clear-button` | The clear button
|
|
38
|
+
* `input-field` | Input element wrapper
|
|
39
|
+
* `toggle-button` | The toggle button
|
|
40
|
+
* `label` | The label element
|
|
41
|
+
* `error-message` | The error message element
|
|
42
|
+
* `helper-text` | The helper text element wrapper
|
|
43
|
+
*
|
|
44
|
+
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
45
|
+
*
|
|
46
|
+
* The following state attributes are available for styling:
|
|
47
|
+
*
|
|
48
|
+
* Attribute | Description | Part name
|
|
49
|
+
* -------------|------------------------------------------|------------
|
|
50
|
+
* `disabled` | Set to a disabled time picker | :host
|
|
51
|
+
* `readonly` | Set to a read only time picker | :host
|
|
52
|
+
* `invalid` | Set when the element is invalid | :host
|
|
53
|
+
* `focused` | Set when the element is focused | :host
|
|
54
|
+
* `focus-ring` | Set when the element is keyboard focused | :host
|
|
55
|
+
*
|
|
56
|
+
* ### Internal components
|
|
57
|
+
*
|
|
58
|
+
* In addition to `<vaadin-time-picker>` itself, the following internal
|
|
59
|
+
* components are themable:
|
|
60
|
+
*
|
|
61
|
+
* - `<vaadin-time-picker-combo-box>` - has the same API as [`<vaadin-combo-box-light>`](#/elements/vaadin-combo-box-light).
|
|
62
|
+
*
|
|
63
|
+
* Note: the `theme` attribute value set on `<vaadin-time-picker>` is
|
|
64
|
+
* propagated to the internal components listed above.
|
|
65
|
+
*
|
|
66
|
+
* @fires {Event} change - Fired when the user commits a value change.
|
|
67
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
68
|
+
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
69
|
+
*/
|
|
70
|
+
declare class TimePicker extends PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
|
|
71
|
+
/**
|
|
72
|
+
* The time value for this element.
|
|
73
|
+
*
|
|
74
|
+
* Supported time formats are in ISO 8601:
|
|
75
|
+
* - `hh:mm` (default)
|
|
76
|
+
* - `hh:mm:ss`
|
|
77
|
+
* - `hh:mm:ss.fff`
|
|
78
|
+
*/
|
|
79
|
+
value: string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Minimum time allowed.
|
|
83
|
+
*
|
|
84
|
+
* Supported time formats are in ISO 8601:
|
|
85
|
+
* - `hh:mm`
|
|
86
|
+
* - `hh:mm:ss`
|
|
87
|
+
* - `hh:mm:ss.fff`
|
|
88
|
+
*/
|
|
89
|
+
min: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Maximum time allowed.
|
|
93
|
+
*
|
|
94
|
+
* Supported time formats are in ISO 8601:
|
|
95
|
+
* - `hh:mm`
|
|
96
|
+
* - `hh:mm:ss`
|
|
97
|
+
* - `hh:mm:ss.fff`
|
|
98
|
+
*/
|
|
99
|
+
max: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Specifies the number of valid intervals in a day used for
|
|
103
|
+
* configuring the items displayed in the selection box.
|
|
104
|
+
*
|
|
105
|
+
* It also configures the precision of the value string. By default
|
|
106
|
+
* the component formats values as `hh:mm` but setting a step value
|
|
107
|
+
* lower than one minute or one second, format resolution changes to
|
|
108
|
+
* `hh:mm:ss` and `hh:mm:ss.fff` respectively.
|
|
109
|
+
*
|
|
110
|
+
* Unit must be set in seconds, and for correctly configuring intervals
|
|
111
|
+
* in the dropdown, it need to evenly divide a day.
|
|
112
|
+
*
|
|
113
|
+
* Note: it is possible to define step that is dividing an hour in inexact
|
|
114
|
+
* fragments (i.e. 5760 seconds which equals 1 hour 36 minutes), but it is
|
|
115
|
+
* not recommended to use it for better UX experience.
|
|
116
|
+
*/
|
|
117
|
+
step: number | null | undefined;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Set true to prevent the overlay from opening automatically.
|
|
121
|
+
* @attr {boolean} auto-open-disabled
|
|
122
|
+
*/
|
|
123
|
+
autoOpenDisabled: boolean | null | undefined;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The object used to localize this component.
|
|
127
|
+
* To change the default localization, replace the entire
|
|
128
|
+
* _i18n_ object or just the property you want to modify.
|
|
129
|
+
*
|
|
130
|
+
* The object has the following JSON structure:
|
|
131
|
+
*
|
|
132
|
+
* ```
|
|
133
|
+
* {
|
|
134
|
+
* // A function to format given `Object` as
|
|
135
|
+
* // time string. Object is in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
|
|
136
|
+
* formatTime: (time) => {
|
|
137
|
+
* // returns a string representation of the given
|
|
138
|
+
* // object in `hh` / 'hh:mm' / 'hh:mm:ss' / 'hh:mm:ss.fff' - formats
|
|
139
|
+
* },
|
|
140
|
+
*
|
|
141
|
+
* // A function to parse the given text to an `Object` in the format
|
|
142
|
+
* // `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`.
|
|
143
|
+
* // Must properly parse (at least) text
|
|
144
|
+
* // formatted by `formatTime`.
|
|
145
|
+
* parseTime: text => {
|
|
146
|
+
* // Parses a string in object/string that can be formatted by`formatTime`.
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* Both `formatTime` and `parseTime` need to be implemented
|
|
152
|
+
* to ensure the component works properly.
|
|
153
|
+
*/
|
|
154
|
+
i18n: TimePickerI18n;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Returns true if `value` is valid, and sets the `invalid` flag appropriately.
|
|
158
|
+
*/
|
|
159
|
+
validate(): boolean;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns true if the current input value satisfies all constraints (if any).
|
|
163
|
+
* You can override this method for custom validations.
|
|
164
|
+
*/
|
|
165
|
+
checkValidity(): boolean;
|
|
166
|
+
|
|
167
|
+
addEventListener<K extends keyof TimePickerEventMap>(
|
|
168
|
+
type: K,
|
|
169
|
+
listener: (this: TimePicker, ev: TimePickerEventMap[K]) => void,
|
|
170
|
+
options?: boolean | AddEventListenerOptions
|
|
171
|
+
): void;
|
|
172
|
+
|
|
173
|
+
removeEventListener<K extends keyof TimePickerEventMap>(
|
|
174
|
+
type: K,
|
|
175
|
+
listener: (this: TimePicker, ev: TimePickerEventMap[K]) => void,
|
|
176
|
+
options?: boolean | EventListenerOptions
|
|
177
|
+
): void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare global {
|
|
181
|
+
interface HTMLElementTagNameMap {
|
|
182
|
+
'vaadin-time-picker': TimePicker;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { TimePicker };
|