@vaadin/date-time-picker 23.0.0-alpha1 → 23.0.0-alpha2
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 +10 -10
- package/src/vaadin-date-time-picker.js +87 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-time-picker",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@polymer/polymer": "^3.0.0",
|
|
36
|
-
"@vaadin/component-base": "23.0.0-
|
|
37
|
-
"@vaadin/custom-field": "23.0.0-
|
|
38
|
-
"@vaadin/date-picker": "23.0.0-
|
|
39
|
-
"@vaadin/field-base": "23.0.0-
|
|
40
|
-
"@vaadin/time-picker": "23.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
36
|
+
"@vaadin/component-base": "23.0.0-alpha2",
|
|
37
|
+
"@vaadin/custom-field": "23.0.0-alpha2",
|
|
38
|
+
"@vaadin/date-picker": "23.0.0-alpha2",
|
|
39
|
+
"@vaadin/field-base": "23.0.0-alpha2",
|
|
40
|
+
"@vaadin/time-picker": "23.0.0-alpha2",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha2",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@esm-bundle/chai": "^4.3.4",
|
|
47
47
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
48
48
|
"sinon": "^9.2.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
|
|
51
51
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-date-time-picker-date-picker.js';
|
|
7
7
|
import './vaadin-date-time-picker-time-picker.js';
|
|
8
|
+
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
8
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
10
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
10
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
@@ -25,14 +26,14 @@ registerStyles('vaadin-date-time-picker', inputFieldShared, { moduleId: 'vaadin-
|
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
// Find a property definition from the prototype chain of a Polymer element class
|
|
28
|
-
|
|
29
|
+
function getPropertyFromPrototype(clazz, prop) {
|
|
29
30
|
while (clazz) {
|
|
30
31
|
if (clazz.properties && clazz.properties[prop]) {
|
|
31
32
|
return clazz.properties[prop];
|
|
32
33
|
}
|
|
33
|
-
clazz = clazz
|
|
34
|
+
clazz = Object.getPrototypeOf(clazz);
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
+
}
|
|
36
37
|
|
|
37
38
|
const datePickerClass = customElements.get('vaadin-date-time-picker-date-picker');
|
|
38
39
|
const timePickerClass = customElements.get('vaadin-date-time-picker-time-picker');
|
|
@@ -326,7 +327,25 @@ class DateTimePicker extends FieldMixin(SlotMixin(DisabledMixin(ThemableMixin(El
|
|
|
326
327
|
*/
|
|
327
328
|
i18n: {
|
|
328
329
|
type: Object,
|
|
329
|
-
value: () =>
|
|
330
|
+
value: () => ({ ...datePickerI18nDefaults, ...timePickerI18nDefaults })
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The current slotted date picker.
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
__datePicker: {
|
|
338
|
+
type: HTMLElement,
|
|
339
|
+
observer: '__datePickerChanged'
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The current slotted time picker.
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
__timePicker: {
|
|
347
|
+
type: HTMLElement,
|
|
348
|
+
observer: '__timePickerChanged'
|
|
330
349
|
}
|
|
331
350
|
};
|
|
332
351
|
}
|
|
@@ -378,6 +397,10 @@ class DateTimePicker extends FieldMixin(SlotMixin(DisabledMixin(ThemableMixin(El
|
|
|
378
397
|
|
|
379
398
|
this.__changeEventHandler = this.__changeEventHandler.bind(this);
|
|
380
399
|
this.__valueChangedEventHandler = this.__valueChangedEventHandler.bind(this);
|
|
400
|
+
|
|
401
|
+
this._observer = new FlattenedNodesObserver(this, (info) => {
|
|
402
|
+
this.__onDomChange(info.addedNodes);
|
|
403
|
+
});
|
|
381
404
|
}
|
|
382
405
|
|
|
383
406
|
/** @protected */
|
|
@@ -390,11 +413,8 @@ class DateTimePicker extends FieldMixin(SlotMixin(DisabledMixin(ThemableMixin(El
|
|
|
390
413
|
}
|
|
391
414
|
});
|
|
392
415
|
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
|
|
396
|
-
this.$.dateSlot.addEventListener('slotchange', this.__datePickerChanged.bind(this));
|
|
397
|
-
this.$.timeSlot.addEventListener('slotchange', this.__timePickerChanged.bind(this));
|
|
416
|
+
this.__datePicker = this._getDirectSlotChild('date-picker');
|
|
417
|
+
this.__timePicker = this._getDirectSlotChild('time-picker');
|
|
398
418
|
|
|
399
419
|
if (this.autofocus && !this.disabled) {
|
|
400
420
|
window.requestAnimationFrame(() => this.focus());
|
|
@@ -449,87 +469,98 @@ class DateTimePicker extends FieldMixin(SlotMixin(DisabledMixin(ThemableMixin(El
|
|
|
449
469
|
}
|
|
450
470
|
|
|
451
471
|
/** @private */
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
472
|
+
__onDomChange(addedNodes) {
|
|
473
|
+
addedNodes
|
|
474
|
+
.filter((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
475
|
+
.forEach((node) => {
|
|
476
|
+
const slotAttributeValue = node.getAttribute('slot');
|
|
477
|
+
|
|
478
|
+
if (slotAttributeValue === 'date-picker') {
|
|
479
|
+
this.__datePicker = node;
|
|
480
|
+
} else if (slotAttributeValue === 'time-picker') {
|
|
481
|
+
this.__timePicker = node;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** @private */
|
|
487
|
+
__datePickerChanged(newDatePicker, existingDatePicker) {
|
|
488
|
+
if (!newDatePicker) {
|
|
455
489
|
return;
|
|
456
490
|
}
|
|
457
|
-
if (
|
|
491
|
+
if (existingDatePicker) {
|
|
458
492
|
// Remove an existing date picker
|
|
459
|
-
this.__removeInputListeners(
|
|
460
|
-
|
|
493
|
+
this.__removeInputListeners(existingDatePicker);
|
|
494
|
+
existingDatePicker.remove();
|
|
461
495
|
}
|
|
462
496
|
|
|
463
|
-
this.__addInputListeners(
|
|
464
|
-
this.__datePicker = datePicker;
|
|
497
|
+
this.__addInputListeners(newDatePicker);
|
|
465
498
|
|
|
466
|
-
if (
|
|
499
|
+
if (newDatePicker.__defaultPicker) {
|
|
467
500
|
// Synchronize properties to default date picker
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.__syncI18n(
|
|
501
|
+
newDatePicker.placeholder = this.datePlaceholder;
|
|
502
|
+
newDatePicker.invalid = this.invalid;
|
|
503
|
+
newDatePicker.initialPosition = this.initialPosition;
|
|
504
|
+
newDatePicker.showWeekNumbers = this.showWeekNumbers;
|
|
505
|
+
this.__syncI18n(newDatePicker, this, datePickerI18nProps);
|
|
473
506
|
} else {
|
|
474
507
|
// Synchronize properties from slotted date picker
|
|
475
|
-
this.datePlaceholder =
|
|
476
|
-
this.initialPosition =
|
|
477
|
-
this.showWeekNumbers =
|
|
478
|
-
this.__syncI18n(this,
|
|
508
|
+
this.datePlaceholder = newDatePicker.placeholder;
|
|
509
|
+
this.initialPosition = newDatePicker.initialPosition;
|
|
510
|
+
this.showWeekNumbers = newDatePicker.showWeekNumbers;
|
|
511
|
+
this.__syncI18n(this, newDatePicker, datePickerI18nProps);
|
|
479
512
|
}
|
|
480
513
|
|
|
481
514
|
// min and max are always synchronized from date time picker (host) to inner fields because time picker
|
|
482
515
|
// min and max need to be dynamically set depending on currently selected date instead of simple propagation
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
516
|
+
newDatePicker.min = this.__formatDateISO(this.__minDateTime, this.__defaultDateMinMaxValue);
|
|
517
|
+
newDatePicker.max = this.__formatDateISO(this.__maxDateTime, this.__defaultDateMinMaxValue);
|
|
518
|
+
newDatePicker.required = this.required;
|
|
519
|
+
newDatePicker.disabled = this.disabled;
|
|
520
|
+
newDatePicker.readonly = this.readonly;
|
|
521
|
+
newDatePicker.autoOpenDisabled = this.autoOpenDisabled;
|
|
489
522
|
|
|
490
523
|
// Disable default internal validation for the component
|
|
491
|
-
|
|
492
|
-
|
|
524
|
+
newDatePicker.validate = () => {};
|
|
525
|
+
newDatePicker._validateInput = () => {};
|
|
493
526
|
}
|
|
494
527
|
|
|
495
528
|
/** @private */
|
|
496
|
-
__timePickerChanged() {
|
|
497
|
-
|
|
498
|
-
if (this.__timePicker === timePicker || !timePicker) {
|
|
529
|
+
__timePickerChanged(newTimePicker, existingTimePicker) {
|
|
530
|
+
if (!newTimePicker) {
|
|
499
531
|
return;
|
|
500
532
|
}
|
|
501
|
-
if (
|
|
533
|
+
if (existingTimePicker) {
|
|
502
534
|
// Remove an existing time picker
|
|
503
|
-
this.__removeInputListeners(
|
|
504
|
-
|
|
535
|
+
this.__removeInputListeners(existingTimePicker);
|
|
536
|
+
existingTimePicker.remove();
|
|
505
537
|
}
|
|
506
538
|
|
|
507
|
-
this.__addInputListeners(
|
|
508
|
-
this.__timePicker = timePicker;
|
|
539
|
+
this.__addInputListeners(newTimePicker);
|
|
509
540
|
|
|
510
|
-
if (
|
|
541
|
+
if (newTimePicker.__defaultPicker) {
|
|
511
542
|
// Synchronize properties to default time picker
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
this.__syncI18n(
|
|
543
|
+
newTimePicker.placeholder = this.timePlaceholder;
|
|
544
|
+
newTimePicker.step = this.step;
|
|
545
|
+
newTimePicker.invalid = this.invalid;
|
|
546
|
+
this.__syncI18n(newTimePicker, this, timePickerI18nProps);
|
|
516
547
|
} else {
|
|
517
548
|
// Synchronize properties from slotted time picker
|
|
518
|
-
this.timePlaceholder =
|
|
519
|
-
this.step =
|
|
520
|
-
this.__syncI18n(this,
|
|
549
|
+
this.timePlaceholder = newTimePicker.placeholder;
|
|
550
|
+
this.step = newTimePicker.step;
|
|
551
|
+
this.__syncI18n(this, newTimePicker, timePickerI18nProps);
|
|
521
552
|
}
|
|
522
553
|
|
|
523
554
|
// min and max are always synchronized from parent to slotted because time picker min and max
|
|
524
555
|
// need to be dynamically set depending on currently selected date instead of simple propagation
|
|
525
556
|
this.__updateTimePickerMinMax();
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
557
|
+
newTimePicker.required = this.required;
|
|
558
|
+
newTimePicker.disabled = this.disabled;
|
|
559
|
+
newTimePicker.readonly = this.readonly;
|
|
560
|
+
newTimePicker.autoOpenDisabled = this.autoOpenDisabled;
|
|
530
561
|
|
|
531
562
|
// Disable default internal validation for the component
|
|
532
|
-
|
|
563
|
+
newTimePicker.validate = () => {};
|
|
533
564
|
}
|
|
534
565
|
|
|
535
566
|
/** @private */
|
|
@@ -561,12 +592,10 @@ class DateTimePicker extends FieldMixin(SlotMixin(DisabledMixin(ThemableMixin(El
|
|
|
561
592
|
|
|
562
593
|
/** @private */
|
|
563
594
|
__i18nChanged(changeRecord) {
|
|
564
|
-
this.__datePickerChanged();
|
|
565
595
|
if (this.__datePicker) {
|
|
566
596
|
this.__datePicker.set(changeRecord.path, changeRecord.value);
|
|
567
597
|
}
|
|
568
598
|
|
|
569
|
-
this.__timePickerChanged();
|
|
570
599
|
if (this.__timePicker) {
|
|
571
600
|
this.__timePicker.set(changeRecord.path, changeRecord.value);
|
|
572
601
|
}
|