@vimeo/iris
Version:
Vimeo Design System
21 lines (20 loc) • 849 B
TypeScript
/// <reference types="react" />
import { CharacterCountState, UserAction } from './useCharacterCount.state';
export interface UseCharacterCountInit {
value?: string;
/** Max number of characters allowed */
maxCharacters?: number;
/** Shows warning color when threshold is met */
warningThreshold?: number;
}
export interface UseCharacterCount {
state: CharacterCountState;
dispatch: React.Dispatch<UserAction>;
handleChange: (value: string) => void;
clean: () => void;
}
/**
* Based on withCharacterCount, this provides handlers for a character count message to create a controlled component.
* Helpful to use in conjuction with custom inputs that need more control of input messages
*/
export declare function useCharacterCount({ maxCharacters, warningThreshold, }: UseCharacterCountInit): UseCharacterCount;