/** * Manages a boolean state with convenient toggle and set functions. * Simplifies the common pattern of toggling boolean values. * * @param initialValue - The initial boolean value (default: false) * @returns A tuple containing [value, toggle, setValue] * * @example * ```tsx * function Modal() { * const [isOpen, toggle, setIsOpen] = useToggle(false); * * return ( *
* * * * {isOpen && setIsOpen(false)} />} *
* ); * } * ``` * * @example * ```tsx * function Accordion({ title, children }: AccordionProps) { * const [isExpanded, toggleExpanded] = useToggle(false); * * return ( *
* * {isExpanded &&
{children}
} *
* ); * } * ``` * * @example * ```tsx * function PasswordInput() { * const [showPassword, toggleShowPassword, setShowPassword] = useToggle(false); * const [password, setPassword] = useState(''); * * return ( *
* setPassword(e.target.value)} * /> * * *
* ); * } * ``` */ export declare function useToggle(initialValue?: boolean): [boolean, () => void, (value: boolean) => void]; /** * Alternative version with more descriptive return object instead of tuple. * Useful when you prefer named properties over array destructuring. * * @param initialValue - The initial boolean value (default: false) * @returns Object with value, toggle, setTrue, setFalse, and setValue functions * * @example * ```tsx * function Sidebar() { * const sidebar = useToggleObject(true); * * return ( *
* * * * {sidebar.value && } *
* ); * } * ``` * * @example * ```tsx * function LoadingButton() { * const loading = useToggleObject(false); * * const handleClick = async () => { * loading.setTrue(); * try { * await performAction(); * } finally { * loading.setFalse(); * } * }; * * return ( * * ); * } * ``` */ export declare function useToggleObject(initialValue?: boolean): { value: boolean; toggle: () => void; setTrue: () => void; setFalse: () => void; setValue: (value: boolean) => void; }; /** * Advanced version with conditional toggle based on a predicate function. * Only toggles if the predicate returns true. * * @param initialValue - The initial boolean value * @param predicate - Function that determines if toggle should occur * @returns Tuple with [value, conditionalToggle, setValue] * * @example * ```tsx * function ConditionalFeature() { * const [hasPermission, setHasPermission] = useState(true); * const [isEnabled, toggle, setEnabled] = useConditionalToggle( * false, * () => hasPermission * ); * * return ( *
* * *

Feature is {isEnabled ? 'enabled' : 'disabled'}

*
* ); * } * ``` */ export declare function useConditionalToggle(initialValue: boolean | undefined, predicate: () => boolean): [boolean, () => void, (value: boolean) => void]; //# sourceMappingURL=useToggle.d.ts.map