@gechiui/components
Version:
UI components for GeChiUI.
44 lines • 2.45 kB
TypeScript
import type { SyntheticEvent } from 'react';
/**
* Internal dependencies
*/
import { InputState, StateReducer } from './state';
import * as actions from './actions';
/**
* Composes multiple stateReducers into a single stateReducer, building
* the pipeline to control the flow for state and actions.
*
* @param fns State reducers.
* @return The single composed stateReducer.
*/
export declare const composeStateReducers: (...fns: StateReducer[]) => StateReducer;
/**
* A custom hook that connects and external stateReducer with an internal
* reducer. This hook manages the internal state of InputControl.
* However, by connecting an external stateReducer function, other
* components can react to actions as well as modify state before it is
* applied.
*
* This technique uses the "stateReducer" design pattern:
* https://kentcdodds.com/blog/the-state-reducer-pattern/
*
* @param stateReducer An external state reducer.
* @param initialState The initial state for the reducer.
* @return State, dispatch, and a collection of actions.
*/
export declare function useInputControlStateReducer(stateReducer?: StateReducer, initialState?: Partial<InputState>): {
readonly change: (nextValue: actions.ChangeEventAction['payload']['value'], event: actions.ChangeEventAction['payload']['event']) => void;
readonly commit: (nextValue: actions.ChangeEventAction['payload']['value'], event: actions.ChangeEventAction['payload']['event']) => void;
readonly dispatch: import("react").Dispatch<actions.InputAction>;
readonly drag: (payload: actions.DragEventAction['payload']) => void;
readonly dragEnd: (payload: actions.DragEventAction['payload']) => void;
readonly dragStart: (payload: actions.DragEventAction['payload']) => void;
readonly invalidate: (error: unknown, event: SyntheticEvent) => void;
readonly pressDown: (event: actions.KeyEventAction['payload']['event']) => void;
readonly pressEnter: (event: actions.KeyEventAction['payload']['event']) => void;
readonly pressUp: (event: actions.KeyEventAction['payload']['event']) => void;
readonly reset: (nextValue: actions.ChangeEventAction['payload']['value'], event: actions.ChangeEventAction['payload']['event']) => void;
readonly state: InputState;
readonly update: (nextValue: actions.ChangeEventAction['payload']['value'], event: actions.ChangeEventAction['payload']['event']) => void;
};
//# sourceMappingURL=reducer.d.ts.map