@vaadin/time-picker 25.0.0-alpha1 → 25.0.0-alpha10
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 +15 -13
- package/src/styles/vaadin-time-picker-base-styles.d.ts +8 -0
- package/src/styles/vaadin-time-picker-base-styles.js +27 -0
- package/src/styles/vaadin-time-picker-core-styles.d.ts +8 -0
- package/src/styles/vaadin-time-picker-core-styles.js +26 -0
- package/src/styles/vaadin-time-picker-overlay-base-styles.js +22 -0
- package/src/styles/vaadin-time-picker-overlay-core-styles.js +18 -0
- package/src/styles/vaadin-time-picker-scroller-base-styles.js +8 -0
- package/src/styles/vaadin-time-picker-scroller-core-styles.js +27 -0
- package/src/vaadin-time-picker-item.js +7 -11
- package/src/vaadin-time-picker-mixin.d.ts +4 -28
- package/src/vaadin-time-picker-mixin.js +158 -84
- package/src/vaadin-time-picker-overlay.js +5 -16
- package/src/vaadin-time-picker-scroller.js +3 -24
- package/src/vaadin-time-picker.d.ts +5 -4
- package/src/vaadin-time-picker.js +36 -61
- package/web-types.json +108 -112
- package/web-types.lit.json +33 -33
- package/src/vaadin-time-picker-combo-box.js +0 -92
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { ComboBoxBaseMixin } from '@vaadin/combo-box/src/vaadin-combo-box-base-mixin.js';
|
|
6
7
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
7
8
|
import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
8
9
|
import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
@@ -22,11 +23,12 @@ const MAX_ALLOWED_TIME = '23:59:59.999';
|
|
|
22
23
|
* A mixin providing common time-picker functionality.
|
|
23
24
|
*
|
|
24
25
|
* @polymerMixin
|
|
26
|
+
* @mixes ComboBoxBaseMixin
|
|
25
27
|
* @mixes InputControlMixin
|
|
26
28
|
* @mixes PatternMixin
|
|
27
29
|
*/
|
|
28
30
|
export const TimePickerMixin = (superClass) =>
|
|
29
|
-
class TimePickerMixinClass extends PatternMixin(InputControlMixin(superClass)) {
|
|
31
|
+
class TimePickerMixinClass extends PatternMixin(ComboBoxBaseMixin(InputControlMixin(superClass))) {
|
|
30
32
|
static get properties() {
|
|
31
33
|
return {
|
|
32
34
|
/**
|
|
@@ -45,17 +47,6 @@ export const TimePickerMixin = (superClass) =>
|
|
|
45
47
|
sync: true,
|
|
46
48
|
},
|
|
47
49
|
|
|
48
|
-
/**
|
|
49
|
-
* True if the dropdown is open, false otherwise.
|
|
50
|
-
*/
|
|
51
|
-
opened: {
|
|
52
|
-
type: Boolean,
|
|
53
|
-
notify: true,
|
|
54
|
-
value: false,
|
|
55
|
-
reflectToAttribute: true,
|
|
56
|
-
sync: true,
|
|
57
|
-
},
|
|
58
|
-
|
|
59
50
|
/**
|
|
60
51
|
* Minimum time allowed.
|
|
61
52
|
*
|
|
@@ -107,24 +98,6 @@ export const TimePickerMixin = (superClass) =>
|
|
|
107
98
|
sync: true,
|
|
108
99
|
},
|
|
109
100
|
|
|
110
|
-
/**
|
|
111
|
-
* Set true to prevent the overlay from opening automatically.
|
|
112
|
-
* @attr {boolean} auto-open-disabled
|
|
113
|
-
*/
|
|
114
|
-
autoOpenDisabled: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
sync: true,
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* A space-delimited list of CSS class names to set on the overlay element.
|
|
121
|
-
*
|
|
122
|
-
* @attr {string} overlay-class
|
|
123
|
-
*/
|
|
124
|
-
overlayClass: {
|
|
125
|
-
type: String,
|
|
126
|
-
},
|
|
127
|
-
|
|
128
101
|
/**
|
|
129
102
|
* The object used to localize this component.
|
|
130
103
|
* To change the default localization, replace the entire
|
|
@@ -169,12 +142,6 @@ export const TimePickerMixin = (superClass) =>
|
|
|
169
142
|
observer: '__comboBoxValueChanged',
|
|
170
143
|
},
|
|
171
144
|
|
|
172
|
-
/** @private */
|
|
173
|
-
__dropdownItems: {
|
|
174
|
-
type: Array,
|
|
175
|
-
sync: true,
|
|
176
|
-
},
|
|
177
|
-
|
|
178
145
|
/** @private */
|
|
179
146
|
_inputContainer: {
|
|
180
147
|
type: Object,
|
|
@@ -184,7 +151,9 @@ export const TimePickerMixin = (superClass) =>
|
|
|
184
151
|
|
|
185
152
|
static get observers() {
|
|
186
153
|
return [
|
|
187
|
-
'
|
|
154
|
+
'_openedOrItemsChanged(opened, _dropdownItems)',
|
|
155
|
+
'_updateScroller(opened, _dropdownItems, _focusedIndex, _theme)',
|
|
156
|
+
'__updateAriaAttributes(_dropdownItems, opened, inputElement)',
|
|
188
157
|
'__updateDropdownItems(i18n, min, max, step)',
|
|
189
158
|
];
|
|
190
159
|
}
|
|
@@ -193,6 +162,15 @@ export const TimePickerMixin = (superClass) =>
|
|
|
193
162
|
return [...super.constraints, 'min', 'max'];
|
|
194
163
|
}
|
|
195
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Tag name prefix used by `ComboBoxBaseMixin` for scroller and items.
|
|
167
|
+
* @protected
|
|
168
|
+
* @return {string}
|
|
169
|
+
*/
|
|
170
|
+
get _tagNamePrefix() {
|
|
171
|
+
return 'vaadin-time-picker';
|
|
172
|
+
}
|
|
173
|
+
|
|
196
174
|
/**
|
|
197
175
|
* Used by `ClearButtonMixin` as a reference to the clear button element.
|
|
198
176
|
* @protected
|
|
@@ -239,6 +217,7 @@ export const TimePickerMixin = (superClass) =>
|
|
|
239
217
|
);
|
|
240
218
|
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
241
219
|
this._inputContainer = this.shadowRoot.querySelector('[part~="input-field"]');
|
|
220
|
+
this._toggleElement = this.$.toggleButton;
|
|
242
221
|
|
|
243
222
|
this._tooltipController = new TooltipController(this);
|
|
244
223
|
this._tooltipController.setShouldShow((timePicker) => !timePicker.opened);
|
|
@@ -247,47 +226,136 @@ export const TimePickerMixin = (superClass) =>
|
|
|
247
226
|
this.addController(this._tooltipController);
|
|
248
227
|
}
|
|
249
228
|
|
|
229
|
+
/** @protected */
|
|
230
|
+
updated(props) {
|
|
231
|
+
super.updated(props);
|
|
232
|
+
|
|
233
|
+
// Update selected item in the scroller
|
|
234
|
+
if (props.has('_comboBoxValue') && this._dropdownItems) {
|
|
235
|
+
this._scroller.selectedItem = this._dropdownItems.find((item) => item.value === this._comboBoxValue);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
250
239
|
/**
|
|
251
|
-
*
|
|
240
|
+
* Returns true if the current input value satisfies all constraints (if any).
|
|
241
|
+
* You can override this method for custom validations.
|
|
242
|
+
*
|
|
243
|
+
* @return {boolean} True if the value is valid
|
|
244
|
+
*/
|
|
245
|
+
checkValidity() {
|
|
246
|
+
return !!(
|
|
247
|
+
this.inputElement.checkValidity() &&
|
|
248
|
+
(!this.value || this._timeAllowed(this.i18n.parseTime(this.value))) &&
|
|
249
|
+
(!this._comboBoxValue || this.i18n.parseTime(this._comboBoxValue))
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Override method from `ComboBoxBaseMixin` to handle item label path.
|
|
252
255
|
* @protected
|
|
253
256
|
* @override
|
|
254
257
|
*/
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
_getItemLabel(item) {
|
|
259
|
+
return item ? item.label : '';
|
|
260
|
+
}
|
|
257
261
|
|
|
258
|
-
|
|
259
|
-
|
|
262
|
+
/** @private */
|
|
263
|
+
_updateScroller(opened, items, focusedIndex, theme) {
|
|
264
|
+
if (opened) {
|
|
265
|
+
this._scroller.style.maxHeight =
|
|
266
|
+
getComputedStyle(this).getPropertyValue(`--${this._tagNamePrefix}-overlay-max-height`) || '65vh';
|
|
260
267
|
}
|
|
268
|
+
|
|
269
|
+
this._scroller.setProperties({
|
|
270
|
+
items: opened ? items : [],
|
|
271
|
+
opened,
|
|
272
|
+
focusedIndex,
|
|
273
|
+
theme,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** @private */
|
|
278
|
+
_openedOrItemsChanged(opened, items) {
|
|
279
|
+
// Close the overlay if there are no items to display.
|
|
280
|
+
this._overlayOpened = opened && !!(items && items.length);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Override method from `ComboBoxBaseMixin` to commit value on overlay closing.
|
|
285
|
+
* @protected
|
|
286
|
+
* @override
|
|
287
|
+
*/
|
|
288
|
+
_onClosed() {
|
|
289
|
+
this._commitValue();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Override method from `ComboBoxBaseMixin` to handle Escape pres..
|
|
294
|
+
* @protected
|
|
295
|
+
* @override
|
|
296
|
+
*/
|
|
297
|
+
_onEscapeCancel() {
|
|
298
|
+
this._inputElementValue = this._comboBoxValue;
|
|
299
|
+
this._closeOrCommit();
|
|
261
300
|
}
|
|
262
301
|
|
|
263
302
|
/**
|
|
264
|
-
*
|
|
303
|
+
* Override method from `ComboBoxBaseMixin` to implement clearing logic.
|
|
304
|
+
* @protected
|
|
305
|
+
* @override
|
|
306
|
+
*/
|
|
307
|
+
_onClearAction() {
|
|
308
|
+
this._comboBoxValue = '';
|
|
309
|
+
this._inputElementValue = '';
|
|
310
|
+
|
|
311
|
+
this.__commitValueChange();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Override method from `ComboBoxBaseMixin` to implement value commit logic.
|
|
316
|
+
* @protected
|
|
317
|
+
* @override
|
|
265
318
|
*/
|
|
266
|
-
|
|
267
|
-
if (
|
|
268
|
-
|
|
319
|
+
_commitValue() {
|
|
320
|
+
if (this._focusedIndex > -1) {
|
|
321
|
+
// Commit value based on focused index
|
|
322
|
+
const focusedItem = this._dropdownItems[this._focusedIndex];
|
|
323
|
+
const itemValue = this._getItemLabel(focusedItem);
|
|
324
|
+
this._inputElementValue = itemValue;
|
|
325
|
+
this._comboBoxValue = itemValue;
|
|
326
|
+
this._focusedIndex = -1;
|
|
327
|
+
} else if (this._inputElementValue === '' || this._inputElementValue === undefined) {
|
|
328
|
+
this._comboBoxValue = '';
|
|
329
|
+
} else {
|
|
330
|
+
this._comboBoxValue = this._inputElementValue;
|
|
269
331
|
}
|
|
332
|
+
|
|
333
|
+
this.__commitValueChange();
|
|
334
|
+
|
|
335
|
+
this._clearSelectionRange();
|
|
270
336
|
}
|
|
271
337
|
|
|
272
338
|
/**
|
|
273
|
-
*
|
|
339
|
+
* Override method from `ComboBoxBaseMixin` to handle loading.
|
|
340
|
+
* @protected
|
|
341
|
+
* @override
|
|
274
342
|
*/
|
|
275
|
-
|
|
276
|
-
this.opened
|
|
343
|
+
_closeOrCommit() {
|
|
344
|
+
if (!this.opened) {
|
|
345
|
+
this._commitValue();
|
|
346
|
+
} else {
|
|
347
|
+
this.close();
|
|
348
|
+
}
|
|
277
349
|
}
|
|
278
350
|
|
|
279
351
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* @return {boolean} True if the value is valid
|
|
352
|
+
* Override method from `ComboBoxBaseMixin` to handle reverting value.
|
|
353
|
+
* @protected
|
|
354
|
+
* @override
|
|
284
355
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
(!this.value || this._timeAllowed(this.i18n.parseTime(this.value))) &&
|
|
289
|
-
(!this._comboBoxValue || this.i18n.parseTime(this._comboBoxValue))
|
|
290
|
-
);
|
|
356
|
+
_revertInputValue() {
|
|
357
|
+
this._inputElementValue = this._comboBoxValue;
|
|
358
|
+
this._clearSelectionRange();
|
|
291
359
|
}
|
|
292
360
|
|
|
293
361
|
/**
|
|
@@ -321,7 +389,7 @@ export const TimePickerMixin = (superClass) =>
|
|
|
321
389
|
_onKeyDown(e) {
|
|
322
390
|
super._onKeyDown(e);
|
|
323
391
|
|
|
324
|
-
if (this.readonly || this.disabled || this.
|
|
392
|
+
if (this.readonly || this.disabled || this._dropdownItems.length) {
|
|
325
393
|
return;
|
|
326
394
|
}
|
|
327
395
|
|
|
@@ -334,17 +402,6 @@ export const TimePickerMixin = (superClass) =>
|
|
|
334
402
|
}
|
|
335
403
|
}
|
|
336
404
|
|
|
337
|
-
/**
|
|
338
|
-
* Override an event listener from `KeyboardMixin`.
|
|
339
|
-
* Do not call `super` in order to override clear
|
|
340
|
-
* button logic defined in `InputControlMixin`.
|
|
341
|
-
* @param {Event} event
|
|
342
|
-
* @protected
|
|
343
|
-
*/
|
|
344
|
-
_onEscape() {
|
|
345
|
-
// Do nothing, the internal combo-box handles Escape.
|
|
346
|
-
}
|
|
347
|
-
|
|
348
405
|
/** @private */
|
|
349
406
|
__onArrowPressWithStep(step) {
|
|
350
407
|
const objWithStep = this.__addStep(this.__getMsec(this.__memoValue), step, true);
|
|
@@ -458,7 +515,7 @@ export const TimePickerMixin = (superClass) =>
|
|
|
458
515
|
const maxTimeObj = validateTime(parseISOTime(max || MAX_ALLOWED_TIME), step);
|
|
459
516
|
const maxSec = this.__getSec(maxTimeObj);
|
|
460
517
|
|
|
461
|
-
this.
|
|
518
|
+
this._dropdownItems = this.__generateDropdownList(minSec, maxSec, step);
|
|
462
519
|
|
|
463
520
|
if (step !== this.__oldStep) {
|
|
464
521
|
this.__oldStep = step;
|
|
@@ -574,12 +631,6 @@ export const TimePickerMixin = (superClass) =>
|
|
|
574
631
|
}
|
|
575
632
|
}
|
|
576
633
|
|
|
577
|
-
/** @private */
|
|
578
|
-
__onComboBoxChange(event) {
|
|
579
|
-
event.stopPropagation();
|
|
580
|
-
this.__commitValueChange();
|
|
581
|
-
}
|
|
582
|
-
|
|
583
634
|
/** @private */
|
|
584
635
|
__updateValue(obj) {
|
|
585
636
|
const timeString = formatISOTime(validateTime(obj, this.step)) || '';
|
|
@@ -594,6 +645,7 @@ export const TimePickerMixin = (superClass) =>
|
|
|
594
645
|
/** @private */
|
|
595
646
|
__updateInputValue(obj) {
|
|
596
647
|
const timeString = this.i18n.formatTime(validateTime(obj, this.step)) || '';
|
|
648
|
+
this._inputElementValue = timeString;
|
|
597
649
|
this._comboBoxValue = timeString;
|
|
598
650
|
}
|
|
599
651
|
|
|
@@ -615,22 +667,44 @@ export const TimePickerMixin = (superClass) =>
|
|
|
615
667
|
}
|
|
616
668
|
|
|
617
669
|
/**
|
|
618
|
-
* Override method
|
|
670
|
+
* Override method from `ComboBoxBaseMixin` to deselect
|
|
671
|
+
* dropdown item by requesting content update on clear.
|
|
672
|
+
* @param {Event} event
|
|
619
673
|
* @protected
|
|
620
674
|
*/
|
|
621
|
-
_onClearButtonClick() {
|
|
675
|
+
_onClearButtonClick(event) {
|
|
676
|
+
event.stopPropagation();
|
|
677
|
+
super._onClearButtonClick(event);
|
|
678
|
+
|
|
679
|
+
if (this.opened) {
|
|
680
|
+
this._scroller.requestContentUpdate();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
622
683
|
|
|
623
684
|
/**
|
|
624
|
-
*
|
|
685
|
+
* @param {Event} event
|
|
625
686
|
* @protected
|
|
626
687
|
*/
|
|
627
|
-
|
|
688
|
+
_onHostClick(event) {
|
|
689
|
+
const path = event.composedPath();
|
|
690
|
+
|
|
691
|
+
// Open dropdown only when clicking on the label or input field
|
|
692
|
+
if (path.includes(this._labelNode) || path.includes(this._inputContainer)) {
|
|
693
|
+
super._onHostClick(event);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
628
696
|
|
|
629
697
|
/**
|
|
630
|
-
* Override
|
|
698
|
+
* Override an event listener from `InputMixin`.
|
|
699
|
+
* @param {!Event} event
|
|
631
700
|
* @protected
|
|
701
|
+
* @override
|
|
632
702
|
*/
|
|
633
|
-
|
|
703
|
+
_onChange(event) {
|
|
704
|
+
// Suppress the native change event fired on the native input.
|
|
705
|
+
// We use `__commitValueChange` to fire a custom event.
|
|
706
|
+
event.stopPropagation();
|
|
707
|
+
}
|
|
634
708
|
|
|
635
709
|
/**
|
|
636
710
|
* Fired when the user commits a value change.
|
|
@@ -3,26 +3,16 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { ComboBoxOverlayMixin } from '@vaadin/combo-box/src/vaadin-combo-box-overlay-mixin.js';
|
|
8
8
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
9
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
10
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
|
|
11
12
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
12
|
-
import {
|
|
13
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
13
14
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
-
|
|
15
|
-
const timePickerOverlayStyles = css`
|
|
16
|
-
#overlay {
|
|
17
|
-
width: var(--vaadin-time-picker-overlay-width, var(--_vaadin-time-picker-overlay-default-width, auto));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[part='content'] {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
height: 100%;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
15
|
+
import { timePickerOverlayStyles } from './styles/vaadin-time-picker-overlay-core-styles.js';
|
|
26
16
|
|
|
27
17
|
/**
|
|
28
18
|
* An element used internally by `<vaadin-time-picker>`. Not intended to be used separately.
|
|
@@ -35,7 +25,7 @@ const timePickerOverlayStyles = css`
|
|
|
35
25
|
* @private
|
|
36
26
|
*/
|
|
37
27
|
export class TimePickerOverlay extends ComboBoxOverlayMixin(
|
|
38
|
-
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
28
|
+
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
39
29
|
) {
|
|
40
30
|
static get is() {
|
|
41
31
|
return 'vaadin-time-picker-overlay';
|
|
@@ -48,7 +38,6 @@ export class TimePickerOverlay extends ComboBoxOverlayMixin(
|
|
|
48
38
|
/** @protected */
|
|
49
39
|
render() {
|
|
50
40
|
return html`
|
|
51
|
-
<div id="backdrop" part="backdrop" hidden></div>
|
|
52
41
|
<div part="overlay" id="overlay">
|
|
53
42
|
<div part="content" id="content">
|
|
54
43
|
<slot></slot>
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { ComboBoxScrollerMixin } from '@vaadin/combo-box/src/vaadin-combo-box-scroller-mixin.js';
|
|
8
8
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { timePickerScrollerStyles } from './styles/vaadin-time-picker-scroller-core-styles.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* An element used internally by `<vaadin-time-picker>`. Not intended to be used separately.
|
|
@@ -22,29 +23,7 @@ export class TimePickerScroller extends ComboBoxScrollerMixin(PolylitMixin(LitEl
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
static get styles() {
|
|
25
|
-
return
|
|
26
|
-
:host {
|
|
27
|
-
display: block;
|
|
28
|
-
min-height: 1px;
|
|
29
|
-
overflow: auto;
|
|
30
|
-
|
|
31
|
-
/* Fixes item background from getting on top of scrollbars on Safari */
|
|
32
|
-
transform: translate3d(0, 0, 0);
|
|
33
|
-
|
|
34
|
-
/* Enable momentum scrolling on iOS */
|
|
35
|
-
-webkit-overflow-scrolling: touch;
|
|
36
|
-
|
|
37
|
-
/* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
|
|
38
|
-
box-shadow: 0 0 0 white;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
#selector {
|
|
42
|
-
border-width: var(--_vaadin-time-picker-items-container-border-width);
|
|
43
|
-
border-style: var(--_vaadin-time-picker-items-container-border-style);
|
|
44
|
-
border-color: var(--_vaadin-time-picker-items-container-border-color, transparent);
|
|
45
|
-
position: relative;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
26
|
+
return timePickerScrollerStyles;
|
|
48
27
|
}
|
|
49
28
|
|
|
50
29
|
/** @protected */
|
|
@@ -78,9 +78,11 @@ export interface TimePickerEventMap extends HTMLElementEventMap, TimePickerCusto
|
|
|
78
78
|
*
|
|
79
79
|
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
80
80
|
*
|
|
81
|
-
* Part name
|
|
82
|
-
*
|
|
83
|
-
* `toggle-button`
|
|
81
|
+
* Part name | Description
|
|
82
|
+
* -----------------|----------------
|
|
83
|
+
* `toggle-button` | The toggle button
|
|
84
|
+
* `overlay` | The overlay container
|
|
85
|
+
* `content` | The overlay content
|
|
84
86
|
*
|
|
85
87
|
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
86
88
|
*
|
|
@@ -93,7 +95,6 @@ export interface TimePickerEventMap extends HTMLElementEventMap, TimePickerCusto
|
|
|
93
95
|
* In addition to `<vaadin-time-picker>` itself, the following internal
|
|
94
96
|
* components are themable:
|
|
95
97
|
*
|
|
96
|
-
* - `<vaadin-time-picker-combo-box>` - an internal version of [`<vaadin-combo-box>`](#/elements/vaadin-combo-box).
|
|
97
98
|
* - `<vaadin-time-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
98
99
|
* - `<vaadin-time-picker-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
99
100
|
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
@@ -4,14 +4,18 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
7
|
-
import './vaadin-time-picker-
|
|
8
|
-
import
|
|
7
|
+
import './vaadin-time-picker-item.js';
|
|
8
|
+
import './vaadin-time-picker-overlay.js';
|
|
9
|
+
import './vaadin-time-picker-scroller.js';
|
|
10
|
+
import { html, LitElement } from 'lit';
|
|
9
11
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
12
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
13
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
14
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
15
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
16
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
14
17
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
18
|
+
import { timePickerStyles } from './styles/vaadin-time-picker-core-styles.js';
|
|
15
19
|
import { TimePickerMixin } from './vaadin-time-picker-mixin.js';
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -41,9 +45,11 @@ import { TimePickerMixin } from './vaadin-time-picker-mixin.js';
|
|
|
41
45
|
*
|
|
42
46
|
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
43
47
|
*
|
|
44
|
-
* Part name
|
|
45
|
-
*
|
|
46
|
-
* `toggle-button`
|
|
48
|
+
* Part name | Description
|
|
49
|
+
* -----------------|----------------
|
|
50
|
+
* `toggle-button` | The toggle button
|
|
51
|
+
* `overlay` | The overlay container
|
|
52
|
+
* `content` | The overlay content
|
|
47
53
|
*
|
|
48
54
|
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
49
55
|
*
|
|
@@ -56,7 +62,6 @@ import { TimePickerMixin } from './vaadin-time-picker-mixin.js';
|
|
|
56
62
|
* In addition to `<vaadin-time-picker>` itself, the following internal
|
|
57
63
|
* components are themable:
|
|
58
64
|
*
|
|
59
|
-
* - `<vaadin-time-picker-combo-box>` - an internal version of [`<vaadin-combo-box>`](#/elements/vaadin-combo-box).
|
|
60
65
|
* - `<vaadin-time-picker-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
61
66
|
* - `<vaadin-time-picker-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
62
67
|
* - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
|
|
@@ -94,30 +99,13 @@ import { TimePickerMixin } from './vaadin-time-picker-mixin.js';
|
|
|
94
99
|
* @mixes ThemableMixin
|
|
95
100
|
* @mixes TimePickerMixin
|
|
96
101
|
*/
|
|
97
|
-
class TimePicker extends TimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) {
|
|
102
|
+
class TimePicker extends TimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
98
103
|
static get is() {
|
|
99
104
|
return 'vaadin-time-picker';
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
static get styles() {
|
|
103
|
-
return [
|
|
104
|
-
inputFieldShared,
|
|
105
|
-
css`
|
|
106
|
-
/* See https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
107
|
-
:host([dir='rtl']) [part='input-field'] {
|
|
108
|
-
direction: ltr;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
:host([dir='rtl']) [part='input-field'] ::slotted(input)::placeholder {
|
|
112
|
-
direction: rtl;
|
|
113
|
-
text-align: left;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
[part~='toggle-button'] {
|
|
117
|
-
cursor: pointer;
|
|
118
|
-
}
|
|
119
|
-
`,
|
|
120
|
-
];
|
|
108
|
+
return [inputFieldShared, timePickerStyles];
|
|
121
109
|
}
|
|
122
110
|
|
|
123
111
|
/** @protected */
|
|
@@ -129,35 +117,18 @@ class TimePicker extends TimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin
|
|
|
129
117
|
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
130
118
|
</div>
|
|
131
119
|
|
|
132
|
-
<vaadin-
|
|
133
|
-
|
|
134
|
-
.filteredItems="${this.__dropdownItems}"
|
|
135
|
-
.value="${this._comboBoxValue}"
|
|
136
|
-
.opened="${this.opened}"
|
|
137
|
-
.disabled="${this.disabled}"
|
|
120
|
+
<vaadin-input-container
|
|
121
|
+
part="input-field"
|
|
138
122
|
.readonly="${this.readonly}"
|
|
139
|
-
.
|
|
140
|
-
.
|
|
141
|
-
.overlayClass="${this.overlayClass}"
|
|
142
|
-
.positionTarget="${this._inputContainer}"
|
|
123
|
+
.disabled="${this.disabled}"
|
|
124
|
+
.invalid="${this.invalid}"
|
|
143
125
|
theme="${ifDefined(this._theme)}"
|
|
144
|
-
@value-changed="${this.__onComboBoxValueChanged}"
|
|
145
|
-
@opened-changed="${this.__onComboBoxOpenedChanged}"
|
|
146
|
-
@change="${this.__onComboBoxChange}"
|
|
147
126
|
>
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
theme="${ifDefined(this._theme)}"
|
|
154
|
-
>
|
|
155
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
156
|
-
<slot name="input"></slot>
|
|
157
|
-
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
158
|
-
<div id="toggleButton" class="toggle-button" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
159
|
-
</vaadin-input-container>
|
|
160
|
-
</vaadin-time-picker-combo-box>
|
|
127
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
128
|
+
<slot name="input"></slot>
|
|
129
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
130
|
+
<div id="toggleButton" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
131
|
+
</vaadin-input-container>
|
|
161
132
|
|
|
162
133
|
<div part="helper-text">
|
|
163
134
|
<slot name="helper"></slot>
|
|
@@ -167,18 +138,22 @@ class TimePicker extends TimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin
|
|
|
167
138
|
<slot name="error-message"></slot>
|
|
168
139
|
</div>
|
|
169
140
|
</div>
|
|
170
|
-
<slot name="tooltip"></slot>
|
|
171
|
-
`;
|
|
172
|
-
}
|
|
173
141
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
142
|
+
<vaadin-time-picker-overlay
|
|
143
|
+
id="overlay"
|
|
144
|
+
dir="ltr"
|
|
145
|
+
.owner="${this}"
|
|
146
|
+
.opened="${this._overlayOpened}"
|
|
147
|
+
theme="${ifDefined(this._theme)}"
|
|
148
|
+
.positionTarget="${this._inputContainer}"
|
|
149
|
+
no-vertical-overlap
|
|
150
|
+
exportparts="overlay, content"
|
|
151
|
+
>
|
|
152
|
+
<slot name="overlay"></slot>
|
|
153
|
+
</vaadin-time-picker-overlay>
|
|
178
154
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this._comboBoxValue = event.detail.value;
|
|
155
|
+
<slot name="tooltip"></slot>
|
|
156
|
+
`;
|
|
182
157
|
}
|
|
183
158
|
}
|
|
184
159
|
|