(value: string, normalizeValue: boolean, events: Array<"change" | "value-changed" | "input">, updateValue: boolean = true)
| 580 | } |
| 581 | |
| 582 | _updateValueAndFireEvents(value: string, normalizeValue: boolean, events: Array<"change" | "value-changed" | "input">, updateValue: boolean = true) { |
| 583 | const valid = this._checkValueValidity(value); |
| 584 | this.isLiveUpdate = !updateValue; |
| 585 | if ((valid && normalizeValue) || !this.isLiveUpdate) { // in case that value is not valid we format it in change event |
| 586 | value = this.getDisplayValueFromValue(value); |
| 587 | value = this.normalizeDisplayValue(value); // transform valid values (in any format) to the correct format |
| 588 | } |
| 589 | |
| 590 | let executeEvent = true; |
| 591 | this.liveValue = value; |
| 592 | const previousValue = this.value; |
| 593 | |
| 594 | if (updateValue) { |
| 595 | this._dateTimeInput.value = value; |
| 596 | this.value = this.getValueFromDisplayValue(value); |
| 597 | this._updateValueState(); |
| 598 | } |
| 599 | |
| 600 | events.forEach(e => { |
| 601 | if (!this.fireDecoratorEvent(e, { value: this.value, valid })) { |
| 602 | executeEvent = false; |
| 603 | } |
| 604 | }); |
| 605 | |
| 606 | if (!executeEvent && updateValue) { |
| 607 | if (this.value !== previousValue && this.value !== this._dateTimeInput.value) { |
| 608 | return; // If the value was changed in the change event, do not revert it |
| 609 | } |
| 610 | |
| 611 | this._dateTimeInput.value = previousValue; |
| 612 | |
| 613 | this.value = previousValue; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | _updateValueState() { |
| 618 | const valid = this._checkValueValidity(this.value); |
no test coverage detected