UNPKG

password-manager-autofill-utilities

Version:

TypeScript utilities to control password manager autofill behavior across different password managers

110 lines 4.11 kB
import { PasswordManagerConfig, FormElementProps } from '../types'; /** * Get password manager attributes for use in React components * This function can be used in React hooks when React is available * @param config - Password manager configuration * @returns HTML attributes to spread onto form elements * * @example * // In a React component: * function MyInput() { * const attrs = getPasswordManagerControlAttributes({ * behavior: PasswordManagerBehavior.IGNORE * }); * return <input {...attrs} />; * } */ export declare function getPasswordManagerControlAttributes(config: PasswordManagerConfig): FormElementProps; /** * Get password manager prevention attributes for use in React components * Convenience function for the most common use case * @returns HTML attributes to prevent password manager autofill * * @example * // In a React component: * function MyInput() { * const preventionProps = getPasswordManagerPreventionAttributes(); * return <input {...preventionProps} />; * } */ export declare function getPasswordManagerPreventionAttributes(): FormElementProps; /** * Create configuration object for password manager control HOCs * This can be used with custom HOC implementations * @param config - Password manager configuration * @returns Configuration object with attributes * * @example * const controlConfig = createPasswordManagerControlConfig({ * behavior: PasswordManagerBehavior.IGNORE * }); * // Use controlConfig.attributes in your HOC implementation */ export declare function createPasswordManagerControlConfig(config: PasswordManagerConfig): { config: PasswordManagerConfig; attributes: FormElementProps; }; /** * Create configuration object for password manager prevention HOCs * Convenience function for the most common use case * @returns Configuration object with prevention attributes */ export declare function createPasswordManagerPreventionConfig(): { config: PasswordManagerConfig; attributes: FormElementProps; }; /** * Merge props with password manager attributes * Utility function for React component prop merging * @param existingProps - Existing component props * @param config - Password manager configuration * @returns Merged props with password manager attributes * * @example * function MyInput(props) { * const mergedProps = mergePropsWithPasswordManagerControl(props, { * behavior: PasswordManagerBehavior.IGNORE * }); * return <input {...mergedProps} />; * } */ export declare function mergePropsWithPasswordManagerControl<T extends Record<string, unknown>>(existingProps: T, config: PasswordManagerConfig): T & FormElementProps; /** * Merge props with password manager prevention attributes * Convenience function for the most common use case * @param existingProps - Existing component props * @returns Merged props with password manager prevention attributes * * @example * function MyInput(props) { * const mergedProps = mergePropsWithPasswordManagerPrevention(props); * return <input {...mergedProps} />; * } */ export declare function mergePropsWithPasswordManagerPrevention<T extends Record<string, unknown>>(existingProps: T): T & FormElementProps; /** * React hook for controlling password manager behavior * @param config - Password manager configuration * @returns HTML attributes to spread onto form elements * * @example * function MyInput() { * const attrs = usePasswordManagerControl({ * behavior: PasswordManagerBehavior.IGNORE * }); * return <input {...attrs} type="text" />; * } */ export declare function usePasswordManagerControl(config: PasswordManagerConfig): FormElementProps; /** * React hook for the common use case of preventing password manager autofill * @returns HTML attributes to prevent password manager autofill * * @example * function MyInput() { * const preventionProps = usePasswordManagerPrevention(); * return <input {...preventionProps} type="text" />; * } */ export declare function usePasswordManagerPrevention(): FormElementProps; //# sourceMappingURL=reactUtils.d.ts.map