Skip to content

Commit 25062b2

Browse files
committed
Refactor away events
1 parent 9c1d96f commit 25062b2

File tree

4 files changed

+146
-476
lines changed

4 files changed

+146
-476
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
export const NumberInputActionTypes = {
2-
blur: 'numberInput:blur',
2+
clamp: 'numberInput:clamp',
33
inputChange: 'numberInput:inputChange',
4-
keyDown: 'numberInput:keyDown',
54
increment: 'numberInput:increment',
65
decrement: 'numberInput:decrement',
6+
decrementToMin: 'numberInput:decrementToMin',
7+
incrementToMax: 'numberInput:incrementToMax',
78
} as const;
89

9-
interface NumberInputBlurAction {
10-
type: typeof NumberInputActionTypes.blur;
11-
event: React.FocusEvent;
10+
interface NumberInputClampAction {
11+
type: typeof NumberInputActionTypes.clamp;
12+
inputValue: string;
1213
}
1314

1415
interface NumberInputInputChangeAction {
1516
type: typeof NumberInputActionTypes.inputChange;
16-
event: React.ChangeEvent;
17-
}
18-
19-
interface NumberInputKeyDownAction {
20-
type: typeof NumberInputActionTypes.keyDown;
21-
event: React.KeyboardEvent;
22-
key: string;
17+
inputValue: string;
2318
}
2419

2520
interface NumberInputIncrementAction {
2621
type: typeof NumberInputActionTypes.increment;
27-
// triggering a button with the keyboard fires a PointerEvent
28-
event: React.PointerEvent;
22+
shiftKey: boolean;
2923
}
3024

3125
interface NumberInputDecrementAction {
3226
type: typeof NumberInputActionTypes.decrement;
33-
// triggering a button with the keyboard fires a PointerEvent
34-
event: React.PointerEvent;
27+
shiftKey: boolean;
28+
}
29+
30+
interface NumberInputIncrementToMaxAction {
31+
type: typeof NumberInputActionTypes.incrementToMax;
32+
}
33+
34+
interface NumberInputDecrementToMinAction {
35+
type: typeof NumberInputActionTypes.decrementToMin;
3536
}
3637

3738
export type NumberInputAction =
38-
| NumberInputBlurAction
39+
| NumberInputClampAction
3940
| NumberInputInputChangeAction
40-
| NumberInputKeyDownAction
4141
| NumberInputIncrementAction
42-
| NumberInputDecrementAction;
42+
| NumberInputDecrementAction
43+
| NumberInputIncrementToMaxAction
44+
| NumberInputDecrementToMinAction;

0 commit comments

Comments
 (0)