import type { ControlSize } from "../../Theme/tokens/primitives/controlSizes"; /** `false` or a non-empty string rejects `tag` (the string is shown as the message); `true` or `undefined` accepts. */ export type TagValidator = (tag: string, tags: readonly string[]) => boolean | string | undefined; /** Free-text chips: Enter or comma adds, Backspace on an empty input removes the last; `ref` is the text ``. */ export type TagInputProps = { /** The committed tags, in order. Controlled: the field never edits it itself. */ value: string[]; /** Called with the next list after an add or a remove. */ onChange: (tags: string[]) => void; /** Runs on each trimmed entry before it is added; a rejected entry stays in the input with its message. */ validate?: TagValidator; /** Cap on tags; adding past it is rejected with a message. */ maxTags?: number; /** Allows the same tag twice. Defaults to false, compared case-insensitively. */ allowDuplicates?: boolean; /** Also commits the typed text when focus leaves the input. Defaults to false. */ addOnBlur?: boolean; /** DOM id of the text input; the label's `for` and the message ids derive from it. Generated when omitted. */ id?: string; /** Submits each tag as its own hidden input with this name; the half-typed text is never submitted. */ name?: string; /** Visible label above the field, tied to the input via `for`; also required for the info icon. */ label?: string; /** Names the input when there is no visible `label`. */ "aria-label"?: string; /** Shown only while there are no tags. */ placeholder?: string; /** Label asterisk plus native `required` on the input. */ isRequired?: boolean; /** Shows an info icon beside the label; needs both `label` and `informationMessage`. */ isInformation?: boolean; /** Tooltip text of the info icon; has no effect unless `isInformation` and `label` are set. */ informationMessage?: string; /** Dims the chips, disables the input and drops the remove buttons. */ isDisabled?: boolean; /** Keeps the input focusable but drops typing and the remove buttons. */ isReadOnly?: boolean; /** Error border and `aria-invalid`; swaps `helperText` for `errorMessage`. A rejected entry sets this too. */ error?: boolean; /** Shown while `error` is true; a rejected entry's own message wins until the input changes. */ errorMessage?: string; /** Shown under the field when there is no error; linked via `aria-describedby`. */ helperText?: string; /** Field height on the control scale: xs 32, sm 38, md 40, lg 48px; grows a row at a time. Defaults to `sm`. */ size?: ControlSize; /** Overrides the field's own messages and announcements; omit a key to keep its English default. */ labels?: Partial<{ /** Rejection when `maxTags` is reached. */ maxTags: (max: number) => string; /** Rejection for a repeated entry. */ duplicate: (entry: string) => string; /** Rejection when `validate` returns `false`; a returned string is shown as is. */ invalid: (entry: string) => string; /** Live-region announcement after entries are added. */ added: (entries: string[]) => string; /** Live-region announcement after a tag is removed. */ removed: (entry: string) => string; /** Accessible name of each chip's remove button. */ remove: (entry: string) => string; }>; /** Width of the whole field; defaults to "100%". */ width?: string | number; };