(value: string, normalizeValue: boolean, eventsNames: Array<"input" | "change" | "value-changed">)
| 643 | } |
| 644 | |
| 645 | _updateValueAndFireEvents(value: string, normalizeValue: boolean, eventsNames: Array<"input" | "change" | "value-changed">) { |
| 646 | const isInputEvent = eventsNames.includes("input"); |
| 647 | const valid = this.isValidValue(value); |
| 648 | |
| 649 | let normalizedValue = value; |
| 650 | // Only normalize if valid - if invalid, keep raw value |
| 651 | if (value !== undefined && valid && normalizeValue && !isInputEvent) { |
| 652 | normalizedValue = this.normalizeValue(value); // transform valid values (in any format) to the correct format |
| 653 | } |
| 654 | |
| 655 | // Store the previous value to check if it actually changed |
| 656 | const previousValue = this.value; |
| 657 | |
| 658 | // During input events (live typing), only update tempValue, not the public value property |
| 659 | if (!isInputEvent) { |
| 660 | this.value = ""; // Do not remove! DurationPicker (an external component extending TimePicker) use case |
| 661 | this.value = normalizedValue; |
| 662 | } |
| 663 | |
| 664 | // Always sync tempValue for the picker |
| 665 | this.tempValue = isInputEvent ? value : normalizedValue; |
| 666 | this._updateValueState(); // Change the value state to Error/None, but only if needed (must be called before early return) |
| 667 | |
| 668 | if (previousValue === this.value) { |
| 669 | return; |
| 670 | } |
| 671 | |
| 672 | eventsNames.forEach(eventName => { |
| 673 | this.fireDecoratorEvent(eventName, { value, valid }); |
| 674 | }); |
| 675 | } |
| 676 | |
| 677 | _updateValueState() { |
| 678 | // During live typing, validate against displayFormat (what user types), otherwise validate against valueFormat (stored value) |
no test coverage detected