numeric-input-react 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/README.md +27 -2
  2. package/package.json +5 -1
package/README.md CHANGED
@@ -7,6 +7,7 @@ A React component for handling numeric input with advanced features including de
7
7
  - ✅ **Decimal number support** - Allow or disallow decimal points
8
8
  - ✅ **Negative number support** - Optional negative number input
9
9
  - ✅ **Thousands separator** - Customizable separator for number formatting
10
+ - ✅ **Min/Max value validation** - Set minimum and maximum value constraints
10
11
  - ✅ **Full-width character conversion** - Automatically converts full-width Japanese characters (0-9, ., ,, -) to half-width equivalents
11
12
  - ✅ **IME composition handling** - Properly handles IME input methods
12
13
  - ✅ **Leading zero handling** - Smart handling of leading zeros
@@ -52,6 +53,8 @@ Extends all standard HTML input props (`ComponentProps<'input'>`) with the follo
52
53
  | `separator` | `string` | `undefined` | Thousands separator (e.g., `","` for comma, `" "` for space) |
53
54
  | `allowDecimal` | `boolean` | `false` | Whether to allow decimal point input |
54
55
  | `allowNegative` | `boolean` | `false` | Whether to allow negative numbers |
56
+ | `minValue` | `number` | `undefined` | Minimum allowed value. Values below this will be clamped to `minValue` |
57
+ | `maxValue` | `number` | `undefined` | Maximum allowed value. Values above this will be clamped to `maxValue` |
55
58
 
56
59
  ### NumericInputValue
57
60
 
@@ -108,6 +111,17 @@ type NumericInputValue = {
108
111
  />
109
112
  ```
110
113
 
114
+ ### With min/max value constraints
115
+
116
+ ```tsx
117
+ <NumericInput
118
+ minValue={0}
119
+ maxValue={100}
120
+ onValueChange={(val) => console.log(val.value)}
121
+ placeholder="Enter number (0-100)"
122
+ />
123
+ ```
124
+
111
125
  ### Full example with all features
112
126
 
113
127
  ```tsx
@@ -125,7 +139,9 @@ function PriceInput() {
125
139
  allowDecimal={true}
126
140
  allowNegative={false}
127
141
  separator=","
128
- placeholder="Enter price"
142
+ minValue={0}
143
+ maxValue={1000000}
144
+ placeholder="Enter price (0 - 1,000,000)"
129
145
  className="price-input"
130
146
  />
131
147
  <p>Value: {price.value}</p>
@@ -152,6 +168,15 @@ function PriceInput() {
152
168
  - If `allowNegative` is `false`, negative signs are removed
153
169
  - Multiple negative signs are normalized to a single sign at the start
154
170
 
171
+ ### Min/Max Value Validation
172
+ - Values are automatically clamped to the `minValue` and `maxValue` range when the input is complete
173
+ - Intermediate values (e.g., values ending with `.` or during typing) are allowed temporarily for better UX
174
+ - Values are validated and clamped when:
175
+ - The input value is complete (not ending with decimal point)
176
+ - The input loses focus (on blur)
177
+ - If a value exceeds the maximum, it will be clamped to `maxValue`
178
+ - If a value is below the minimum, it will be clamped to `minValue`
179
+
155
180
  ### Full-width Character Conversion
156
181
  The component automatically converts full-width Japanese characters to half-width:
157
182
  - `0-9` → `0-9`
@@ -167,7 +192,7 @@ The component properly handles IME (Input Method Editor) composition events, ens
167
192
  The library is written in TypeScript and includes full type definitions:
168
193
 
169
194
  ```typescript
170
- import { NumericInput, type NumericInputProps } from 'numeric-input-react'
195
+ import { NumericInput, type NumericInputProps, type NumericInputValue } from 'numeric-input-react'
171
196
  ```
172
197
 
173
198
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "numeric-input-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A React component for handling numeric input with decimal support, negative numbers, thousands separators, and IME composition handling",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,6 +28,10 @@
28
28
  ],
29
29
  "author": "",
30
30
  "license": "ISC",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/khachoangpt/numeric-input-react.git"
34
+ },
31
35
  "type": "module",
32
36
  "dependencies": {
33
37
  "react": "^19.2.3"