codexly-ui 0.13.4 → 0.13.5

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.
@@ -4583,13 +4583,25 @@ class ClxNumberComponent {
4583
4583
  this._onChange(v);
4584
4584
  this._onTouched();
4585
4585
  }
4586
+ /** Number of decimal places implied by step() (e.g. 0.1 -> 1, 0.01 -> 2, 1 -> 0) — used to round
4587
+ * after +/- so a fractional step doesn't accumulate binary floating-point noise (0.1 isn't
4588
+ * exactly representable, so 2.2 + 0.1 naively yields 2.3000000000000003, not 2.3). */
4589
+ _stepDecimals() {
4590
+ const str = this.step().toString();
4591
+ const dot = str.indexOf('.');
4592
+ return dot === -1 ? 0 : str.length - dot - 1;
4593
+ }
4594
+ _roundToStep(value) {
4595
+ const factor = 10 ** this._stepDecimals();
4596
+ return Math.round(value * factor) / factor;
4597
+ }
4586
4598
  _decrement() {
4587
- const next = this._value() - this.step();
4599
+ const next = this._roundToStep(this._value() - this.step());
4588
4600
  const clamped = this.min() !== null ? Math.max(next, this.min()) : next;
4589
4601
  this._applyValue(clamped);
4590
4602
  }
4591
4603
  _increment() {
4592
- const next = this._value() + this.step();
4604
+ const next = this._roundToStep(this._value() + this.step());
4593
4605
  const clamped = this.max() !== null ? Math.min(next, this.max()) : next;
4594
4606
  this._applyValue(clamped);
4595
4607
  }