/** * Type helper for onChange callbacks that can handle string-only callbacks * when the value might be string | undefined */ type ControlledStateCallback = T extends string | undefined ? ((value: string) => void) | ((value: T) => void) : (value: T) => void; /** * Custom hook to manage controlled/uncontrolled state pattern * Handles both controlled mode (when value and onChange are provided) * and uncontrolled mode (when using internal state) * * @param controlledValue The externally controlled value * @param defaultValue Default value for uncontrolled mode * @param onChange Callback for when value changes in controlled mode * @returns Object with value, setValue function, and isControlled flag */ export default function useControlledState(controlledValue: T | undefined, defaultValue: V, onChange?: ControlledStateCallback): { value: T; setValue: (newValue: T) => void; isControlled: boolean; }; export {};