@ahrowe/ui 0.5.1 → 0.5.2

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.
@@ -14,6 +14,14 @@ export interface NumberInputProps extends Omit<NumericFormatProps, 'onValueChang
14
14
  prefix?: string;
15
15
  suffix?: string;
16
16
  decimalScale?: number;
17
+ /**
18
+ * Whether to pad the value to exactly `decimalScale` decimals. Default `true`
19
+ * (e.g. with `decimalScale={2}`, `12` displays as `12.00`). Set `false` to make
20
+ * `decimalScale` an upper limit only — the user may type fewer decimals and they
21
+ * are kept as-is (`12` stays `12`, `12.1` stays `12.1`), while anything beyond
22
+ * `decimalScale` is still truncated.
23
+ */
24
+ fixedDecimalScale?: boolean;
17
25
  placeholder?: string;
18
26
  sign?: '+' | '-';
19
27
  showArrows?: boolean;
@@ -31,6 +31,10 @@ const priceValidator = new FormValidator<number | undefined>(undefined, [Validat
31
31
 
32
32
  // Percentage
33
33
  <NumberInput label="Discount" suffix="%" decimalScale={1} max={100} />
34
+
35
+ // Max decimals without padding — cap at 2 decimals, but keep what the user typed
36
+ // (12 stays "12", 12.1 stays "12.1"; 12.111 is truncated to "12.11")
37
+ <NumberInput label="Amount" decimalScale={2} fixedDecimalScale={false} />
34
38
  ```
35
39
 
36
40
  **Key props:**
@@ -43,7 +47,8 @@ const priceValidator = new FormValidator<number | undefined>(undefined, [Validat
43
47
  | `formValidator` | `FormValidator` | Connects to validation |
44
48
  | `prefix` | `string` | Text before number (e.g. `'€'`) |
45
49
  | `suffix` | `string` | Text after number (e.g. `'%'`) |
46
- | `decimalScale` | `number` | Number of decimal places |
50
+ | `decimalScale` | `number` | Maximum number of decimal places |
51
+ | `fixedDecimalScale` | `boolean` | Pad to exactly `decimalScale` decimals (default `true`). Set `false` to treat `decimalScale` as a cap only — fewer decimals are kept as typed, `12` stays `12` |
47
52
  | `decimalSeparator` | `string` | Decimal character |
48
53
  | `thousandSeparator` | `string \| boolean` | Thousand grouping character |
49
54
  | `allowNegative` | `boolean` | Default: `false` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahrowe/ui",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },