Skip to content

Commit e4e4e9a

Browse files
authored
[base-ui][NumberInput] Implement numberInputReducer (#38723)
1 parent 0563e82 commit e4e4e9a

File tree

8 files changed

+668
-13
lines changed

8 files changed

+668
-13
lines changed

docs/pages/base-ui/api/number-input.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"startAdornment": { "type": { "name": "node" } },
4343
"step": { "type": { "name": "number" } },
44-
"value": { "type": { "name": "any" } }
44+
"value": { "type": { "name": "number" } }
4545
},
4646
"name": "NumberInput",
4747
"imports": [

docs/pages/base-ui/api/use-number-input.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"required": { "type": { "name": "boolean", "description": "boolean" } },
4141
"shiftMultiplier": { "type": { "name": "number", "description": "number" } },
4242
"step": { "type": { "name": "number", "description": "number" } },
43-
"value": { "type": { "name": "unknown", "description": "unknown" } }
43+
"value": { "type": { "name": "number", "description": "number" } }
4444
},
4545
"returnValue": {
4646
"disabled": {

packages/mui-base/src/Unstable_NumberInput/NumberInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ NumberInput.propTypes /* remove-proptypes */ = {
307307
/**
308308
* The current value. Use when the component is controlled.
309309
*/
310-
value: PropTypes.any,
310+
value: PropTypes.number,
311311
} as any;
312312

313313
export { NumberInput };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
export const NumberInputActionTypes = {
2+
clamp: 'numberInput:clamp',
3+
inputChange: 'numberInput:inputChange',
4+
increment: 'numberInput:increment',
5+
decrement: 'numberInput:decrement',
6+
decrementToMin: 'numberInput:decrementToMin',
7+
incrementToMax: 'numberInput:incrementToMax',
8+
} as const;
9+
10+
interface NumberInputClampAction {
11+
type: typeof NumberInputActionTypes.clamp;
12+
inputValue: string;
13+
}
14+
15+
interface NumberInputInputChangeAction {
16+
type: typeof NumberInputActionTypes.inputChange;
17+
inputValue: string;
18+
}
19+
20+
interface NumberInputIncrementAction {
21+
type: typeof NumberInputActionTypes.increment;
22+
applyMultiplier: boolean;
23+
}
24+
25+
interface NumberInputDecrementAction {
26+
type: typeof NumberInputActionTypes.decrement;
27+
applyMultiplier: boolean;
28+
}
29+
30+
interface NumberInputIncrementToMaxAction {
31+
type: typeof NumberInputActionTypes.incrementToMax;
32+
}
33+
34+
interface NumberInputDecrementToMinAction {
35+
type: typeof NumberInputActionTypes.decrementToMin;
36+
}
37+
38+
export type NumberInputAction =
39+
| NumberInputClampAction
40+
| NumberInputInputChangeAction
41+
| NumberInputIncrementAction
42+
| NumberInputDecrementAction
43+
| NumberInputIncrementToMaxAction
44+
| NumberInputDecrementToMinAction;

0 commit comments

Comments
 (0)