@vaadin/date-time-picker 24.8.0-alpha9 → 25.0.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -23
- package/package.json +13 -16
- package/src/vaadin-date-time-picker-mixin.d.ts +1 -3
- package/src/vaadin-date-time-picker-mixin.js +113 -11
- package/src/vaadin-date-time-picker.d.ts +23 -0
- package/src/vaadin-date-time-picker.js +42 -14
- package/web-types.json +5 -5
- package/web-types.lit.json +4 -4
- package/src/vaadin-lit-date-time-picker.d.ts +0 -1
- package/src/vaadin-lit-date-time-picker.js +0 -86
- package/theme/lumo/vaadin-lit-date-time-picker.d.ts +0 -4
- package/theme/lumo/vaadin-lit-date-time-picker.js +0 -4
- package/theme/material/vaadin-date-time-picker-styles.d.ts +0 -1
- package/theme/material/vaadin-date-time-picker-styles.js +0 -8
- package/theme/material/vaadin-date-time-picker.d.ts +0 -4
- package/theme/material/vaadin-date-time-picker.js +0 -4
- package/theme/material/vaadin-lit-date-time-picker.d.ts +0 -4
- package/theme/material/vaadin-lit-date-time-picker.js +0 -4
- package/vaadin-lit-date-time-picker.d.ts +0 -1
- package/vaadin-lit-date-time-picker.js +0 -2
package/README.md
CHANGED
|
@@ -24,29 +24,6 @@ Once installed, import the component in your application:
|
|
|
24
24
|
import '@vaadin/date-time-picker';
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
## Themes
|
|
28
|
-
|
|
29
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
30
|
-
The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/date-time-picker/vaadin-date-time-picker.js) of the package uses the Lumo theme.
|
|
31
|
-
|
|
32
|
-
To use the Material theme, import the component from the `theme/material` folder:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
import '@vaadin/date-time-picker/theme/material/vaadin-date-time-picker.js';
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
You can also import the Lumo version of the component explicitly:
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
import '@vaadin/date-time-picker/theme/lumo/vaadin-date-time-picker.js';
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import '@vaadin/date-time-picker/src/vaadin-date-time-picker.js';
|
|
48
|
-
```
|
|
49
|
-
|
|
50
27
|
## Contributing
|
|
51
28
|
|
|
52
29
|
Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-time-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,26 +31,23 @@
|
|
|
31
31
|
"Vaadin",
|
|
32
32
|
"vaadin-date-time-picker",
|
|
33
33
|
"web-components",
|
|
34
|
-
"web-component"
|
|
35
|
-
"polymer"
|
|
34
|
+
"web-component"
|
|
36
35
|
],
|
|
37
36
|
"dependencies": {
|
|
38
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@
|
|
40
|
-
"@vaadin/
|
|
41
|
-
"@vaadin/
|
|
42
|
-
"@vaadin/
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/
|
|
45
|
-
"@vaadin/
|
|
46
|
-
"@vaadin/vaadin-
|
|
47
|
-
"@vaadin/vaadin-material-styles": "24.8.0-alpha9",
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha9",
|
|
38
|
+
"@vaadin/a11y-base": "25.0.0-alpha1",
|
|
39
|
+
"@vaadin/component-base": "25.0.0-alpha1",
|
|
40
|
+
"@vaadin/custom-field": "25.0.0-alpha1",
|
|
41
|
+
"@vaadin/date-picker": "25.0.0-alpha1",
|
|
42
|
+
"@vaadin/field-base": "25.0.0-alpha1",
|
|
43
|
+
"@vaadin/time-picker": "25.0.0-alpha1",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha1",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha1",
|
|
49
46
|
"lit": "^3.0.0"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
|
-
"@vaadin/chai-plugins": "
|
|
53
|
-
"@vaadin/test-runner-commands": "
|
|
49
|
+
"@vaadin/chai-plugins": "25.0.0-alpha1",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha1",
|
|
54
51
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
55
52
|
"sinon": "^18.0.0"
|
|
56
53
|
},
|
|
@@ -58,5 +55,5 @@
|
|
|
58
55
|
"web-types.json",
|
|
59
56
|
"web-types.lit.json"
|
|
60
57
|
],
|
|
61
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "b8c22a4a0c64156210d0daac96b43ae4e5526d49"
|
|
62
59
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
8
8
|
import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
9
|
-
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
9
|
import type { DatePickerI18n } from '@vaadin/date-picker/src/vaadin-date-picker.js';
|
|
11
10
|
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
12
11
|
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
@@ -36,8 +35,7 @@ export interface DateTimePickerI18n extends DatePickerI18n, TimePickerI18n {
|
|
|
36
35
|
*/
|
|
37
36
|
export declare function DateTimePickerMixin<T extends Constructor<HTMLElement>>(
|
|
38
37
|
base: T,
|
|
39
|
-
): Constructor<
|
|
40
|
-
Constructor<DateTimePickerMixinClass> &
|
|
38
|
+
): Constructor<DateTimePickerMixinClass> &
|
|
41
39
|
Constructor<DisabledMixinClass> &
|
|
42
40
|
Constructor<FieldMixinClass> &
|
|
43
41
|
Constructor<FocusMixinClass> &
|
|
@@ -305,6 +305,7 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
305
305
|
// Default value for "max" property of vaadin-time-picker (for removing constraint)
|
|
306
306
|
this.__defaultTimeMaxValue = '23:59:59.999';
|
|
307
307
|
|
|
308
|
+
this.__onGlobalClick = this.__onGlobalClick.bind(this);
|
|
308
309
|
this.__changeEventHandler = this.__changeEventHandler.bind(this);
|
|
309
310
|
this.__valueChangedEventHandler = this.__valueChangedEventHandler.bind(this);
|
|
310
311
|
this.__openedChangedEventHandler = this.__openedChangedEventHandler.bind(this);
|
|
@@ -315,12 +316,38 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
315
316
|
return [this.__datePicker, this.__timePicker];
|
|
316
317
|
}
|
|
317
318
|
|
|
319
|
+
/** @private */
|
|
320
|
+
get __filledPickers() {
|
|
321
|
+
return this.__pickers.filter((picker) => picker.value || picker.__unparsableValue);
|
|
322
|
+
}
|
|
323
|
+
|
|
318
324
|
/** @private */
|
|
319
325
|
get __formattedValue() {
|
|
320
326
|
const values = this.__pickers.map((picker) => picker.value);
|
|
321
327
|
return values.every(Boolean) ? values.join('T') : '';
|
|
322
328
|
}
|
|
323
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Values:
|
|
332
|
+
* - ""
|
|
333
|
+
* - "fooT"
|
|
334
|
+
* - "Tbar"
|
|
335
|
+
* - "fooTbar"
|
|
336
|
+
* - "T12:00"
|
|
337
|
+
* - "fooT12:00"
|
|
338
|
+
* - "2024-01-01T"
|
|
339
|
+
* - "2024-01-01Tbar"
|
|
340
|
+
*
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
get __unparsableValue() {
|
|
344
|
+
if (this.__filledPickers.length > 0 && !this.__pickers.every((picker) => picker.value)) {
|
|
345
|
+
return this.__pickers.map((picker) => picker.value || picker.__unparsableValue).join('T');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return '';
|
|
349
|
+
}
|
|
350
|
+
|
|
324
351
|
/** @protected */
|
|
325
352
|
ready() {
|
|
326
353
|
super.ready();
|
|
@@ -347,12 +374,49 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
347
374
|
this.ariaTarget = this;
|
|
348
375
|
}
|
|
349
376
|
|
|
377
|
+
/** @protected */
|
|
378
|
+
connectedCallback() {
|
|
379
|
+
super.connectedCallback();
|
|
380
|
+
document.addEventListener('click', this.__onGlobalClick, true);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** @protected */
|
|
384
|
+
disconnectedCallback() {
|
|
385
|
+
super.disconnectedCallback();
|
|
386
|
+
document.removeEventListener('click', this.__onGlobalClick, true);
|
|
387
|
+
}
|
|
388
|
+
|
|
350
389
|
focus() {
|
|
351
390
|
if (this.__datePicker) {
|
|
352
391
|
this.__datePicker.focus();
|
|
353
392
|
}
|
|
354
393
|
}
|
|
355
394
|
|
|
395
|
+
/** @private */
|
|
396
|
+
__onGlobalClick(event) {
|
|
397
|
+
const isOpened = this.__datePicker.opened || this.__timePicker.opened;
|
|
398
|
+
if (!isOpened) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const isOutsideClick = event.composedPath().every((node) => {
|
|
403
|
+
return ![
|
|
404
|
+
this.__datePicker,
|
|
405
|
+
this.__datePicker.$.overlay,
|
|
406
|
+
this.__timePicker,
|
|
407
|
+
this.__timePicker.$.comboBox.$.overlay,
|
|
408
|
+
].includes(node);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
if (isOutsideClick) {
|
|
412
|
+
this.__outsideClickInProgress = true;
|
|
413
|
+
|
|
414
|
+
setTimeout(() => {
|
|
415
|
+
this.__outsideClickInProgress = false;
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
356
420
|
/**
|
|
357
421
|
* Override method inherited from `FocusMixin` to validate on blur.
|
|
358
422
|
* @param {boolean} focused
|
|
@@ -365,7 +429,7 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
365
429
|
// Do not validate when focusout is caused by document
|
|
366
430
|
// losing focus, which happens on browser tab switch.
|
|
367
431
|
if (!focused && document.hasFocus()) {
|
|
368
|
-
this.
|
|
432
|
+
this.__commitPendingValueChange();
|
|
369
433
|
}
|
|
370
434
|
}
|
|
371
435
|
|
|
@@ -379,12 +443,12 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
379
443
|
*/
|
|
380
444
|
_shouldRemoveFocus(event) {
|
|
381
445
|
const target = event.relatedTarget;
|
|
382
|
-
const overlayContent = this.__datePicker._overlayContent;
|
|
383
446
|
|
|
384
447
|
if (
|
|
448
|
+
this.__datePicker.opened ||
|
|
449
|
+
this.__timePicker.opened ||
|
|
385
450
|
this.__datePicker.contains(target) ||
|
|
386
|
-
this.__timePicker.contains(target)
|
|
387
|
-
(overlayContent && overlayContent.contains(target))
|
|
451
|
+
this.__timePicker.contains(target)
|
|
388
452
|
) {
|
|
389
453
|
return false;
|
|
390
454
|
}
|
|
@@ -408,22 +472,35 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
408
472
|
__changeEventHandler(event) {
|
|
409
473
|
event.stopPropagation();
|
|
410
474
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
475
|
+
const isAlreadyInvalid = this.invalid;
|
|
476
|
+
const filledPickers = this.__filledPickers;
|
|
477
|
+
if (filledPickers.length === 1 && filledPickers[0].checkValidity() && !isAlreadyInvalid) {
|
|
478
|
+
// Skip if (a) only one picker is filled, (b) its value is valid by itself, and (c) the user
|
|
479
|
+
// is still interacting with the field. This is to give the user a chance to finish the input
|
|
480
|
+
// before giving him feedback. However, if the field is already in the invalid state due to
|
|
481
|
+
// a previous error, proceed to committing the value to get the error message updated.
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (this.__hasPendingValueChange) {
|
|
486
|
+
this.__commitPendingValueChange();
|
|
414
487
|
}
|
|
415
|
-
this.__dispatchChangeForValue = undefined;
|
|
416
488
|
}
|
|
417
489
|
|
|
418
490
|
/** @private */
|
|
419
491
|
__openedChangedEventHandler() {
|
|
420
492
|
const opened = this.__datePicker.opened || this.__timePicker.opened;
|
|
421
493
|
this.style.pointerEvents = opened ? 'auto' : '';
|
|
494
|
+
|
|
495
|
+
if (!opened && this.__outsideClickInProgress) {
|
|
496
|
+
this.__commitPendingValueChange();
|
|
497
|
+
}
|
|
422
498
|
}
|
|
423
499
|
|
|
424
500
|
/** @private */
|
|
425
501
|
__addInputListeners(node) {
|
|
426
502
|
node.addEventListener('change', this.__changeEventHandler);
|
|
503
|
+
node.addEventListener('unparsable-change', this.__changeEventHandler);
|
|
427
504
|
node.addEventListener('value-changed', this.__valueChangedEventHandler);
|
|
428
505
|
node.addEventListener('opened-changed', this.__openedChangedEventHandler);
|
|
429
506
|
}
|
|
@@ -431,6 +508,7 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
431
508
|
/** @private */
|
|
432
509
|
__removeInputListeners(node) {
|
|
433
510
|
node.removeEventListener('change', this.__changeEventHandler);
|
|
511
|
+
node.removeEventListener('unparsable-change', this.__changeEventHandler);
|
|
434
512
|
node.removeEventListener('value-changed', this.__valueChangedEventHandler);
|
|
435
513
|
node.removeEventListener('opened-changed', this.__openedChangedEventHandler);
|
|
436
514
|
}
|
|
@@ -724,8 +802,27 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
724
802
|
*/
|
|
725
803
|
checkValidity() {
|
|
726
804
|
const hasInvalidPickers = this.__pickers.some((picker) => !picker.checkValidity());
|
|
805
|
+
const hasOnlyOneFilledPicker = this.__filledPickers.length === 1;
|
|
727
806
|
const hasEmptyRequiredPickers = this.required && this.__pickers.some((picker) => !picker.value);
|
|
728
|
-
return !hasInvalidPickers && !hasEmptyRequiredPickers;
|
|
807
|
+
return !hasInvalidPickers && !hasEmptyRequiredPickers && !hasOnlyOneFilledPicker;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** @private */
|
|
811
|
+
__commitPendingValueChange() {
|
|
812
|
+
this._requestValidation();
|
|
813
|
+
if (this.__committedValue !== this.value) {
|
|
814
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
|
815
|
+
} else if (this.__committedUnparsableValue !== this.__unparsableValue) {
|
|
816
|
+
this.dispatchEvent(new CustomEvent('unparsable-change'));
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
this.__committedValue = this.value;
|
|
820
|
+
this.__committedUnparsableValue = this.__unparsableValue;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** @private */
|
|
824
|
+
get __hasPendingValueChange() {
|
|
825
|
+
return this.__committedValue !== this.value || this.__committedUnparsableValue !== this.__unparsableValue;
|
|
729
826
|
}
|
|
730
827
|
|
|
731
828
|
/**
|
|
@@ -769,8 +866,9 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
769
866
|
__valueChanged(value, oldValue) {
|
|
770
867
|
this.__handleDateTimeChange('value', '__selectedDateTime', value, oldValue);
|
|
771
868
|
|
|
772
|
-
if (
|
|
773
|
-
this.
|
|
869
|
+
if (!this.__keepCommittedValue) {
|
|
870
|
+
this.__committedValue = value;
|
|
871
|
+
this.__committedUnparsableValue = '';
|
|
774
872
|
}
|
|
775
873
|
|
|
776
874
|
this.toggleAttribute('has-value', !!value);
|
|
@@ -839,8 +937,12 @@ export const DateTimePickerMixin = (superClass) =>
|
|
|
839
937
|
}
|
|
840
938
|
|
|
841
939
|
this.__ignoreInputValueChange = true;
|
|
940
|
+
this.__keepCommittedValue = true;
|
|
941
|
+
|
|
842
942
|
this.__updateTimePickerMinMax();
|
|
843
943
|
this.value = this.__formattedValue;
|
|
944
|
+
|
|
945
|
+
this.__keepCommittedValue = false;
|
|
844
946
|
this.__ignoreInputValueChange = false;
|
|
845
947
|
}
|
|
846
948
|
|
|
@@ -93,7 +93,30 @@ export interface DateTimePickerEventMap extends DateTimePickerCustomEventMap, HT
|
|
|
93
93
|
*
|
|
94
94
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
95
95
|
*
|
|
96
|
+
* ### Change events
|
|
97
|
+
*
|
|
98
|
+
* Depending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,
|
|
99
|
+
* the component can fire either a `change` event or an `unparsable-change` event:
|
|
100
|
+
*
|
|
101
|
+
* Value change | Event
|
|
102
|
+
* :------------------------|:------------------
|
|
103
|
+
* empty => parsable | change
|
|
104
|
+
* empty => unparsable | unparsable-change
|
|
105
|
+
* parsable => empty | change
|
|
106
|
+
* parsable => parsable | change
|
|
107
|
+
* parsable => unparsable | change
|
|
108
|
+
* unparsable => empty | unparsable-change
|
|
109
|
+
* unparsable => parsable | change
|
|
110
|
+
* unparsable => unparsable | unparsable-change
|
|
111
|
+
* incomplete => empty | unparsable-change
|
|
112
|
+
* incomplete => parsable | change
|
|
113
|
+
* incomplete => unparsable | unparsable-change
|
|
114
|
+
* empty => incomplete | unparsable-change
|
|
115
|
+
* parsable => incomplete | change
|
|
116
|
+
* unparsable => incomplete | unparsable-change
|
|
117
|
+
*
|
|
96
118
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
119
|
+
* @fires {Event} unparsable-change - Fired when the user commits an unparsable or incomplete value change and there is no change event.
|
|
97
120
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
98
121
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
99
122
|
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
@@ -5,15 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/date-picker/src/vaadin-date-picker.js';
|
|
7
7
|
import '@vaadin/time-picker/src/vaadin-time-picker.js';
|
|
8
|
-
import { html,
|
|
8
|
+
import { css, html, LitElement } from 'lit';
|
|
9
9
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
12
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
12
|
-
import {
|
|
13
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
14
|
import { DateTimePickerMixin } from './vaadin-date-time-picker-mixin.js';
|
|
14
15
|
|
|
15
|
-
registerStyles('vaadin-date-time-picker', inputFieldShared, { moduleId: 'vaadin-date-time-picker' });
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* `<vaadin-date-time-picker>` is a Web Component providing a date time selection field.
|
|
19
18
|
*
|
|
@@ -64,7 +63,30 @@ registerStyles('vaadin-date-time-picker', inputFieldShared, { moduleId: 'vaadin-
|
|
|
64
63
|
*
|
|
65
64
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
66
65
|
*
|
|
66
|
+
* ### Change events
|
|
67
|
+
*
|
|
68
|
+
* Depending on the nature of the value change that the user attempts to commit e.g. by pressing Enter,
|
|
69
|
+
* the component can fire either a `change` event or an `unparsable-change` event:
|
|
70
|
+
*
|
|
71
|
+
* Value change | Event
|
|
72
|
+
* :------------------------|:------------------
|
|
73
|
+
* empty => parsable | change
|
|
74
|
+
* empty => unparsable | unparsable-change
|
|
75
|
+
* parsable => empty | change
|
|
76
|
+
* parsable => parsable | change
|
|
77
|
+
* parsable => unparsable | change
|
|
78
|
+
* unparsable => empty | unparsable-change
|
|
79
|
+
* unparsable => parsable | change
|
|
80
|
+
* unparsable => unparsable | unparsable-change
|
|
81
|
+
* incomplete => empty | unparsable-change
|
|
82
|
+
* incomplete => parsable | change
|
|
83
|
+
* incomplete => unparsable | unparsable-change
|
|
84
|
+
* empty => incomplete | unparsable-change
|
|
85
|
+
* parsable => incomplete | change
|
|
86
|
+
* unparsable => incomplete | unparsable-change
|
|
87
|
+
*
|
|
67
88
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
89
|
+
* @fires {Event} unparsable-change - Fired when the user commits an unparsable or incomplete value change and there is no change event.
|
|
68
90
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
69
91
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
70
92
|
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
@@ -75,10 +97,15 @@ registerStyles('vaadin-date-time-picker', inputFieldShared, { moduleId: 'vaadin-
|
|
|
75
97
|
* @mixes ThemableMixin
|
|
76
98
|
* @mixes DateTimePickerMixin
|
|
77
99
|
*/
|
|
78
|
-
class DateTimePicker extends DateTimePickerMixin(ThemableMixin(ElementMixin(
|
|
79
|
-
static get
|
|
80
|
-
return
|
|
81
|
-
|
|
100
|
+
class DateTimePicker extends DateTimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) {
|
|
101
|
+
static get is() {
|
|
102
|
+
return 'vaadin-date-time-picker';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static get styles() {
|
|
106
|
+
return [
|
|
107
|
+
inputFieldShared,
|
|
108
|
+
css`
|
|
82
109
|
.vaadin-date-time-picker-container {
|
|
83
110
|
--vaadin-field-default-width: auto;
|
|
84
111
|
}
|
|
@@ -97,10 +124,15 @@ class DateTimePicker extends DateTimePickerMixin(ThemableMixin(ElementMixin(Poly
|
|
|
97
124
|
min-width: 0;
|
|
98
125
|
flex: 1 1.65 auto;
|
|
99
126
|
}
|
|
100
|
-
|
|
127
|
+
`,
|
|
128
|
+
];
|
|
129
|
+
}
|
|
101
130
|
|
|
131
|
+
/** @protected */
|
|
132
|
+
render() {
|
|
133
|
+
return html`
|
|
102
134
|
<div class="vaadin-date-time-picker-container">
|
|
103
|
-
<div part="label"
|
|
135
|
+
<div part="label" @click="${this.focus}">
|
|
104
136
|
<slot name="label"></slot>
|
|
105
137
|
<span part="required-indicator" aria-hidden="true"></span>
|
|
106
138
|
</div>
|
|
@@ -122,10 +154,6 @@ class DateTimePicker extends DateTimePickerMixin(ThemableMixin(ElementMixin(Poly
|
|
|
122
154
|
<slot name="tooltip"></slot>
|
|
123
155
|
`;
|
|
124
156
|
}
|
|
125
|
-
|
|
126
|
-
static get is() {
|
|
127
|
-
return 'vaadin-date-time-picker';
|
|
128
|
-
}
|
|
129
157
|
}
|
|
130
158
|
|
|
131
159
|
defineCustomElement(DateTimePicker);
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/date-time-picker",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-date-time-picker",
|
|
11
|
-
"description": "`<vaadin-date-time-picker>` is a Web Component providing a date time selection field.\n\n```html\n<vaadin-date-time-picker value=\"2019-09-16T15:00\"></vaadin-date-time-picker>\n```\n```js\ndateTimePicker.value = '2019-09-16T15:00';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|----------------\n`label` | The slotted label element wrapper\n`helper-text` | The slotted helper text element wrapper\n`error-message` | The slotted error message element wrapper\n`required-indicator` | The `required` state indicator element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n--------------------|-------------------------------------------|------------\n`disabled` | Set when the element is disabled | :host\n`focused` | Set when the element is focused | :host\n`focus-ring` | Set when the element is keyboard focused | :host\n`readonly` | Set when the element is readonly | :host\n`invalid` | Set when the element is invalid | :host\n`has-label` | Set when the element has a label | :host\n`has-value` | Set when the element has a value | :host\n`has-helper` | Set when the element has helper text | :host\n`has-error-message` | Set when the element has an error message | :host\n\n### Internal components\n\nThe following components are created by `<vaadin-date-time-picker>` and placed in light DOM:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "`<vaadin-date-time-picker>` is a Web Component providing a date time selection field.\n\n```html\n<vaadin-date-time-picker value=\"2019-09-16T15:00\"></vaadin-date-time-picker>\n```\n```js\ndateTimePicker.value = '2019-09-16T15:00';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|----------------\n`label` | The slotted label element wrapper\n`helper-text` | The slotted helper text element wrapper\n`error-message` | The slotted error message element wrapper\n`required-indicator` | The `required` state indicator element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n--------------------|-------------------------------------------|------------\n`disabled` | Set when the element is disabled | :host\n`focused` | Set when the element is focused | :host\n`focus-ring` | Set when the element is keyboard focused | :host\n`readonly` | Set when the element is readonly | :host\n`invalid` | Set when the element is invalid | :host\n`has-label` | Set when the element has a label | :host\n`has-value` | Set when the element has a value | :host\n`has-helper` | Set when the element has helper text | :host\n`has-error-message` | Set when the element has an error message | :host\n\n### Internal components\n\nThe following components are created by `<vaadin-date-time-picker>` and placed in light DOM:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker).\n- [`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker).\n\nNote: the `theme` attribute value set on `<vaadin-date-time-picker>` is\npropagated to these components.\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\nincomplete => empty | unparsable-change\nincomplete => parsable | change\nincomplete => unparsable | unparsable-change\nempty => incomplete | unparsable-change\nparsable => incomplete | change\nunparsable => incomplete | unparsable-change",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
},
|
|
236
236
|
{
|
|
237
237
|
"name": "overlay-class",
|
|
238
|
-
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
238
|
+
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker#property-overlayClass)\n- [`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker#property-overlayClass)",
|
|
239
239
|
"value": {
|
|
240
240
|
"type": [
|
|
241
241
|
"string",
|
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
},
|
|
484
484
|
{
|
|
485
485
|
"name": "i18n",
|
|
486
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object or just the properties you want to modify.\n\nThe object is a combination of the i18n properties supported by\n[`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
486
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object or just the properties you want to modify.\n\nThe object is a combination of the i18n properties supported by\n[`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker) and\n[`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker).",
|
|
487
487
|
"value": {
|
|
488
488
|
"type": [
|
|
489
489
|
"DateTimePickerI18n"
|
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
},
|
|
493
493
|
{
|
|
494
494
|
"name": "overlayClass",
|
|
495
|
-
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
495
|
+
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker#property-overlayClass)\n- [`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker#property-overlayClass)",
|
|
496
496
|
"value": {
|
|
497
497
|
"type": [
|
|
498
498
|
"string",
|
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-time-picker",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-date-time-picker",
|
|
19
|
-
"description": "`<vaadin-date-time-picker>` is a Web Component providing a date time selection field.\n\n```html\n<vaadin-date-time-picker value=\"2019-09-16T15:00\"></vaadin-date-time-picker>\n```\n```js\ndateTimePicker.value = '2019-09-16T15:00';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|----------------\n`label` | The slotted label element wrapper\n`helper-text` | The slotted helper text element wrapper\n`error-message` | The slotted error message element wrapper\n`required-indicator` | The `required` state indicator element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n--------------------|-------------------------------------------|------------\n`disabled` | Set when the element is disabled | :host\n`focused` | Set when the element is focused | :host\n`focus-ring` | Set when the element is keyboard focused | :host\n`readonly` | Set when the element is readonly | :host\n`invalid` | Set when the element is invalid | :host\n`has-label` | Set when the element has a label | :host\n`has-value` | Set when the element has a value | :host\n`has-helper` | Set when the element has helper text | :host\n`has-error-message` | Set when the element has an error message | :host\n\n### Internal components\n\nThe following components are created by `<vaadin-date-time-picker>` and placed in light DOM:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
19
|
+
"description": "`<vaadin-date-time-picker>` is a Web Component providing a date time selection field.\n\n```html\n<vaadin-date-time-picker value=\"2019-09-16T15:00\"></vaadin-date-time-picker>\n```\n```js\ndateTimePicker.value = '2019-09-16T15:00';\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|----------------\n`label` | The slotted label element wrapper\n`helper-text` | The slotted helper text element wrapper\n`error-message` | The slotted error message element wrapper\n`required-indicator` | The `required` state indicator element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n--------------------|-------------------------------------------|------------\n`disabled` | Set when the element is disabled | :host\n`focused` | Set when the element is focused | :host\n`focus-ring` | Set when the element is keyboard focused | :host\n`readonly` | Set when the element is readonly | :host\n`invalid` | Set when the element is invalid | :host\n`has-label` | Set when the element has a label | :host\n`has-value` | Set when the element has a value | :host\n`has-helper` | Set when the element has helper text | :host\n`has-error-message` | Set when the element has an error message | :host\n\n### Internal components\n\nThe following components are created by `<vaadin-date-time-picker>` and placed in light DOM:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker).\n- [`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker).\n\nNote: the `theme` attribute value set on `<vaadin-date-time-picker>` is\npropagated to these components.\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\nincomplete => empty | unparsable-change\nincomplete => parsable | change\nincomplete => unparsable | unparsable-change\nempty => incomplete | unparsable-change\nparsable => incomplete | change\nunparsable => incomplete | unparsable-change",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -168,14 +168,14 @@
|
|
|
168
168
|
},
|
|
169
169
|
{
|
|
170
170
|
"name": ".i18n",
|
|
171
|
-
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object or just the properties you want to modify.\n\nThe object is a combination of the i18n properties supported by\n[`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
171
|
+
"description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object or just the properties you want to modify.\n\nThe object is a combination of the i18n properties supported by\n[`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker) and\n[`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker).",
|
|
172
172
|
"value": {
|
|
173
173
|
"kind": "expression"
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
177
|
"name": ".overlayClass",
|
|
178
|
-
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
178
|
+
"description": "A space-delimited list of CSS class names to set on the overlay elements\nof the internal components controlled by the `<vaadin-date-time-picker>`:\n\n- [`<vaadin-date-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-date-picker#property-overlayClass)\n- [`<vaadin-time-picker>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-time-picker#property-overlayClass)",
|
|
179
179
|
"value": {
|
|
180
180
|
"kind": "expression"
|
|
181
181
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vaadin-date-time-picker.js';
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import '@vaadin/date-picker/src/vaadin-lit-date-picker.js';
|
|
7
|
-
import '@vaadin/time-picker/src/vaadin-lit-time-picker.js';
|
|
8
|
-
import { css, html, LitElement } from 'lit';
|
|
9
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
|
-
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
13
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
-
import { DateTimePickerMixin } from './vaadin-date-time-picker-mixin.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* LitElement based version of `<vaadin-date-time-picker>` web component.
|
|
18
|
-
*
|
|
19
|
-
* ## Disclaimer
|
|
20
|
-
*
|
|
21
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
22
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
23
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
24
|
-
*/
|
|
25
|
-
class DateTimePicker extends DateTimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) {
|
|
26
|
-
static get is() {
|
|
27
|
-
return 'vaadin-date-time-picker';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static get styles() {
|
|
31
|
-
return [
|
|
32
|
-
inputFieldShared,
|
|
33
|
-
css`
|
|
34
|
-
.vaadin-date-time-picker-container {
|
|
35
|
-
--vaadin-field-default-width: auto;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.slots {
|
|
39
|
-
display: flex;
|
|
40
|
-
--vaadin-field-default-width: 12em;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.slots ::slotted([slot='date-picker']) {
|
|
44
|
-
min-width: 0;
|
|
45
|
-
flex: 1 1 auto;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.slots ::slotted([slot='time-picker']) {
|
|
49
|
-
min-width: 0;
|
|
50
|
-
flex: 1 1.65 auto;
|
|
51
|
-
}
|
|
52
|
-
`,
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** @protected */
|
|
57
|
-
render() {
|
|
58
|
-
return html`
|
|
59
|
-
<div class="vaadin-date-time-picker-container">
|
|
60
|
-
<div part="label" @click="${this.focus}">
|
|
61
|
-
<slot name="label"></slot>
|
|
62
|
-
<span part="required-indicator" aria-hidden="true"></span>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<div class="slots">
|
|
66
|
-
<slot name="date-picker" id="dateSlot"></slot>
|
|
67
|
-
<slot name="time-picker" id="timeSlot"></slot>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div part="helper-text">
|
|
71
|
-
<slot name="helper"></slot>
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<div part="error-message">
|
|
75
|
-
<slot name="error-message"></slot>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<slot name="tooltip"></slot>
|
|
80
|
-
`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
defineCustomElement(DateTimePicker);
|
|
85
|
-
|
|
86
|
-
export { DateTimePicker };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { customField } from '@vaadin/custom-field/theme/material/vaadin-custom-field-styles.js';
|
|
2
|
-
import { helper } from '@vaadin/vaadin-material-styles/mixins/helper.js';
|
|
3
|
-
import { requiredField } from '@vaadin/vaadin-material-styles/mixins/required-field.js';
|
|
4
|
-
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
|
-
|
|
6
|
-
registerStyles('vaadin-date-time-picker', [requiredField, helper, customField], {
|
|
7
|
-
moduleId: 'material-date-time-picker',
|
|
8
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/vaadin-date-time-picker.js';
|