| 532 | } |
| 533 | |
| 534 | _updateValueState() { |
| 535 | const isWithinRange = (this.min === undefined || this._parseNumber(this.input.value) >= this.min) |
| 536 | && (this.max === undefined || this._parseNumber(this.input.value) <= this.max); |
| 537 | const isValueWithCorrectPrecision = this._isValueWithCorrectPrecision; |
| 538 | const previousValueState = this.valueState; |
| 539 | const isValid = isWithinRange && isValueWithCorrectPrecision; |
| 540 | |
| 541 | this.valueState = isValid ? ValueState.None : ValueState.Negative; |
| 542 | |
| 543 | const eventPrevented = !this.fireDecoratorEvent("value-state-change", { |
| 544 | valueState: this.valueState, |
| 545 | valid: isValid, |
| 546 | }); |
| 547 | |
| 548 | if (eventPrevented) { |
| 549 | this.valueState = previousValueState; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | _preciseValue(value: number) { |
| 554 | const pow = 10 ** this.valuePrecision; |