import { type PropertyValues } from 'lit'; import { UiElement } from '../shared/element.js'; import '../tooltip/tooltip.js'; export type TextInputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number'; /** Heights: sm 32px · md 40px · lg 48px (Carbon touch target). */ export type TextInputSize = 'sm' | 'md' | 'lg'; /** * Carbon-style text input (Carbon `TextInput`). * * Label, helper / warning / error text live in the same shadow root as the ``, * so `for` / `aria-describedby` references resolve. Form-associated: takes * part in `
` submit, reset, and native constraint validation. * * Errors appear after the user leaves the field (or tries to submit), never * while they are still typing. `warn` shows a non-blocking warning. * `type="password"` adds a show/hide toggle (Carbon PasswordInput): its icon tooltip, below and lined up with its end, * is also its name — `show-password-label` while hidden, `hide-password-label` while shown — and each press fires * `ui-toggle` (Carbon `onTogglePasswordVisibility`). * `inline` (Carbon `inline`) puts the label before the field and the helper / error text after it, in one row * centred: each side at most 142px, 8px from the field (not while fluid). * `max-count` shows a character counter; going over doesn't cut the text off (users can * paste and then trim) — it becomes an error and screen readers hear when the limit is near * or exceeded. * * `prefix-text` / `suffix-text` put a currency or a unit inside the field (฿, kg), and `mask` * formats the value as the user types (`0-0000-00000-00-0`) — neither has a Carbon counterpart * (Carbon puts both in the label or helper text); they follow USWDS. * * State on the host for styling: `data-show-error` while the error shows, `data-show-warn` while the * warning shows, `data-password-visible` while the password is shown as text. * * @cssstate show-error - While its error message shows (also `[data-show-error]`) * @cssstate show-warn - While its warning message shows (also `[data-show-warn]`) * @cssstate password-visible - While the password is shown as text (also `[data-password-visible]`) * @fires input - Native input event (already composed, so it reaches the host) * @fires change - Re-dispatched from the native input (native change is not composed) * @fires ui-toggle - detail: { visible } when the password toggle shows or hides the password (Carbon `onTogglePasswordVisibility`) * @slot label - Label content with markup; the `label` attribute is the plain-text fallback * @slot helper-text - Helper text with markup (links, bold); overrides `helper-text` * @slot warn-text - Warning text shown while `warn`; overrides `warn-text` * @slot invalid-text - Error text shown while invalid; overrides `invalid-text` * @csspart base - The field box around the input * @csspart label - The label * @csspart input - The native input * @csspart prefix - The text before the value * @csspart suffix - The text after the value * @csspart password-toggle - The show / hide password button * @csspart password-tooltip - The `` around it (its name) * @csspart counter - The character counter * @csspart status-icon - The error / warning icon * @csspart helper-text - The helper line * @csspart warning-text - The warning line * @csspart warn-text - Same line as `warning-text` (named after the `warn-text` attribute / slot) * @csspart error-text - The error line * @csspart invalid-text - Same line as `error-text` (named after the `invalid-text` attribute / slot) * @cssprop --ui-field-border - Border on every side of the box (default none: Carbon's underline only; Kanok: a 1px outline) * @cssprop --ui-field-disabled-border-color - Border colour when disabled (default: the underline transparent) * @cssprop --ui-field-readonly-border-color - Border colour when read-only (default: a hairline underline) * @cssprop --ui-field-radius - Corner radius of the box (default 0; Kanok: 6px) * @cssprop --ui-field-background - Fill of the box (default `--ui-surface-1`; Kanok: transparent) * @cssprop --ui-label-font - Font of the label (default `--ui-font-caption`; Kanok: 14px semibold) * @cssprop --ui-label-color - Colour of the label (default `--ui-ink-muted`; Kanok: `--ui-ink`) * @cssprop --ui-field-readonly-background - The box's fill when read-only (default transparent; Kanok: a faint ink tint, so read-only reads as set and never weaker than disabled) * @cssprop --ui-fluid-background / --ui-fluid-gap - A fluid box's fill and the space under it (default the layer's fill, 0: boxes that touch; Kanok: transparent, 8px) * @cssprop --ui-icon-control-radius - Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round) */ export declare class UiTextInput extends UiElement { static hostStates: readonly string[]; static readonly formAssociated = true; static readonly shadowRootOptions: ShadowRootInit; static readonly styles: import("lit").CSSResult[]; /** Visible label text; the `label` slot replaces it when markup is needed. */ label: string; private readonly localize; /** Keep the label for screen readers but don't show it. */ hideLabel: boolean; /** Helper text under the field, shown while there is no error or warning. */ helperText: string; /** Message shown when invalid. Falls back to the browser's validation message. */ invalidText: string; /** Force the error state (e.g. a server-side error). */ invalid: boolean; /** Non-blocking warning; shown when there is no error. */ warn: boolean; /** Text of the warning shown while `warn`. */ warnText: string; value: string; /** Reflected: form-associated elements submit under the `name` attribute. */ name: string; type: TextInputType; /** Field height: sm 32px, md 40px, lg 48px (tokens `--ui-field-height-*`). */ size: TextInputSize; placeholder: string; autocomplete: string; /** Passed to the text box: the virtual keyboard to show (`numeric`, `decimal`, `email`, `tel`, `url`, `search`…). */ inputmode: string; /** Passed to the text box: the label of the virtual keyboard's Enter key (`search`, `send`, `next`, `done`…). */ enterkeyhint: string; pattern: string; /** Text inside the field before the value, e.g. a currency (`฿`). Part of the field's description for screen readers. */ prefixText: string; /** Text inside the field after the value, e.g. a unit (`kg`). Part of the field's description for screen readers. */ suffixText: string; /** * Formats the value as the user types: `0` a digit, `a` a letter, `*` either; any other * character is a separator added for the user (`\` makes a pattern character one). * E.g. `0-0000-00000-00-0` (Thai citizen ID), `000-000-0000`. `value` and the form get the * formatted text, `rawValue` what was typed. Put the format in the helper text too (Carbon). */ mask: string; minlength?: number; maxlength?: number; /** Soft limit with a visible counter (unlike maxlength, extra text isn't blocked). */ maxCount?: number; /** Error when over `max-count`; `{max}` is replaced with the limit. */ tooLongText: string; /** Announced once when the remaining characters drop to 10% or less. */ nearLimitText: string; /** Disables the control; a disabled `
` ancestor does the same. */ disabled: boolean; /** Shows and submits the value but blocks changes. */ readonly: boolean; /** Carbon `FluidTextInput`: the label inside a 64px box, an error / warning inside it. `` sets it for every field inside. */ fluid: boolean; /** Blocks form submission while the field is empty. */ required: boolean; /** The password toggle's name and tooltip while the password is hidden (Carbon `showPasswordLabel`; default: the translation's "Show password"). */ showPasswordLabel: string; /** The password toggle's name and tooltip while the password shows (Carbon `hidePasswordLabel`; default: the translation's "Hide password"). */ hidePasswordLabel: string; /** Carbon `inline`: the label before the field, the helper / error text after it (ignored while fluid). */ inline: boolean; private touched; /** Disabled, reset defaults, validation on submit and the name given from outside (shared by the form fields). */ private readonly formControl; private passwordVisible; private readonly input; /** Message from `setCustomValidity()`; '' = none. */ private customValidityMessage; /** Like `.setCustomValidity()`: a non-empty message makes the field invalid (and is shown as its error once touched) until cleared with ''. */ setCustomValidity(message: string): void; private readonly inputId; private defaultValue; /** Enter in the text box submits the form, like a native input. */ private readonly onEnterKey; protected willUpdate(changed: PropertyValues): void; /** The characters typed, without the mask's separators (`value` when there is no mask). */ get rawValue(): string; connectedCallback(): void; disconnectedCallback(): void; get validity(): ValidityState; get validationMessage(): string; get form(): HTMLFormElement | null; /** Whether the field takes part in constraint validation (not while disabled), as natively. */ get willValidate(): boolean; /** The `