Created
January 24, 2019 21:36
-
-
Save baetheus/3f0e6de36bfee7a353c8f402a56062c5 to your computer and use it in GitHub Desktop.
Potential Input State Interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface InputState<ValueType, MaskType> { | |
value: ValueType; | |
mask: MaskType; // TODO Decide on masking implementation | |
touched: boolean; | |
invalid: boolean; | |
focused: boolean; | |
disabled: boolean; | |
} | |
export enum InputEvents { | |
INIT, | |
BLUR, | |
CHANGE, | |
FOCUS, | |
// TODO Consider other input events | |
} | |
export interface InputAction { | |
type: InputEvents; | |
} | |
export interface InputStateReducer<ValueType, MaskType = ValueType> { | |
(state: InputState<ValueType, MaskType>, action: InputAction): InputState<ValueType, MaskType>; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment