@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.
- package/dist/esm/common/numberInput/numberInput.mjs +1 -1
- package/dist/esm/common/numberInput/numberInput.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/types/package/common/numberInput/numberInput.d.ts +8 -0
- package/docs/NumberInput.md +6 -1
- package/package.json +1 -1
|
@@ -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;
|
package/docs/NumberInput.md
CHANGED
|
@@ -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` |
|
|
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` |
|