import { type ChangeEvent, type ComponentProps, type MouseEvent, type ReactNode } from 'react'; /** * Unstyled Carbon `TextInput` / `PasswordInput`, the behaviour without a single class: the `Input`, a * `PasswordToggle` that shows or hides a password (Carbon PasswordInput; name it with what a press does next, so no * `aria-pressed`), and a `mask` that formats the value as the user types (USWDS, as ``): `0` a digit, * `a` a letter, `*` either; any other character is a separator added for the user (`\` makes a pattern character * one). A masked edit is reformatted in place with the caret kept (not while composing); a value set by the app * (raw or formatted) shows formatted; `Input`'s `onChange` gets the value without separators as its second argument, * after the field settled. The keyboard is the mask's (`inputMode` numeric for digits only). * * State shows as data attributes to style on: `data-visible` on `Input` and `PasswordToggle` (the password shows), * `data-disabled` on both. * * ```tsx * const [visible, setVisible] = useState(false); // or read it inside Root: useTextInputContext().visible * * * * {visible ? 'Hide password' : 'Show password'} * * ``` */ type FieldValue = ComponentProps<'input'>['value']; export interface RootProps { /** The input's type; `password` hides the text until `PasswordToggle` shows it. */ type?: ComponentProps<'input'>['type']; value?: FieldValue; defaultValue?: FieldValue; /** The format to type into (see above). */ mask?: string; disabled?: boolean; /** Whether the password shows (controlled). */ visible?: boolean; defaultVisible?: boolean; /** Each press of `PasswordToggle`; `visible` is the new state. */ onVisibleChange?: (visible: boolean, event: MouseEvent) => void; children?: ReactNode; } interface TextInputContextValue { type: ComponentProps<'input'>['type']; /** The value as shown (formatted by the mask). */ value: FieldValue; defaultValue: FieldValue; mask: string | undefined; disabled: boolean; /** The password shows. */ visible: boolean; /** Shows or hides the password. */ toggleVisible: (event: MouseEvent) => void; /** Reformats the input after the browser's edit; returns what was typed, without separators. */ edit: (event: ChangeEvent) => string; } /** The state of the enclosing `TextInput.Root` (visible, the shown value …). */ export declare function useTextInputContext(part?: string): TextInputContextValue; /** Holds the shown value, the mask and whether the password shows; renders only its children. */ export declare function Root({ type, value, defaultValue, mask, disabled, visible: visibleProp, defaultVisible, onVisibleChange, children }: Readonly): import("react").JSX.Element; export interface InputProps extends Omit, 'type' | 'value' | 'defaultValue' | 'disabled' | 'onChange'> { /** The input's change, after the mask reformatted it; `raw` is the value without the separators (the value itself without a mask). */ onChange?: (event: ChangeEvent, raw: string) => void; } /** The ``: a password while hidden; a masked edit reformats in place before your `onChange` sees it. */ export declare function Input(props: Readonly): import("react").JSX.Element; /** Shows or hides the password (off while the field is disabled); give it the name of what a press does next. */ export declare function PasswordToggle(props: Readonly, 'type'>>): import("react").JSX.Element; export {};