import { type PropertyValues } from 'lit'; import { UiElement } from '../shared/element.js'; export type NumberInputSize = 'sm' | 'md' | 'lg'; export type NumberInputType = 'number' | 'text'; /** * Carbon-style number input (`NumberInput`): a native `type="number"` field with the browser * spinner replaced by Carbon's two 40px stepper buttons (− then +, divided by hairlines) at the * end of the field. ↑ / ↓ step as well. The value is kept as text so the field can be empty. * * Validation follows Carbon: out of `min` / `max` is invalid, so is an empty field unless * `allow-empty` (both via native constraint validation, so forms block submit). Steppers clamp * to the range and round to the precision of the value or `step`, whichever has more decimals; * from an empty field they start at `step-start-value`, else ±1, else `min` (Carbon). * * `type="text"` formats the number for a locale (Carbon `type="text"` + `locale` + * `formatOptions`): thousands separators, currency, percent, units, accounting brackets, all * from `Intl.NumberFormat` options in `format-options`. The text is free while typing and is * reformatted on blur; `value` (and the submitted form value) stays a plain number, e.g. * `1234.5` for `฿1,234.50`, and a percent style gives the fraction (`0.5` for `50%`), as `Intl`. * Two deliberate differences from cds-number-input: `value` stays a plain number after blur * (Carbon's getter returns the formatted text; its event detail and Carbon React give the number), * and an empty `locale` follows the page language instead of `en-US`. * * `prefix-text` / `suffix-text` put text inside the field before / after the value — a unit or a * currency that stays in view while typing and is not part of `value` (`kg`, `บาท/เดือน`, `฿`), as * ``. No Carbon counterpart (Carbon writes a unit into the text with `type="text"` + * `format-options` `{ style: 'unit' }`, which works here too). * * State on the host for styling: `data-show-error` while the error shows, `data-show-warn` while the * warning shows. * * @cssstate show-error - While its error message shows (also `[data-show-error]`) * @cssstate show-warn - While its warning message shows (also `[data-show-warn]`) * @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` * @fires change - After a committed change (blur / Enter / stepper; with `type="text"`, on blur when the number changed) * @fires input - On every keystroke or stepper click * @csspart base - The field box * @csspart label - The label * @csspart input - The native input * @csspart prefix - The text before the value * @csspart suffix - The text after the value * @csspart controls - The stepper group * @csspart decrement-button - The − button * @csspart increment-button - The + button * @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 UiNumberInput 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; /** Error text shown while `invalid` or while the field fails validation. */ invalidText: string; /** Forces the error state, e.g. after server-side validation. */ invalid: boolean; /** Non-blocking warning; shown when there is no error. */ warn: boolean; /** Text of the warning shown while `warn`. */ warnText: string; /** The field text; `valueAsNumber` gives the parsed number (NaN while empty or invalid). */ value: string; /** Reflected: form-associated elements submit under the `name` attribute. */ name: string; placeholder: string; /** Text inside the field before the value, e.g. a currency (`฿`); not part of `value`. Part of the field's description for screen readers. */ prefixText: string; /** Text inside the field after the value, e.g. a unit (`kg`); not part of `value`. Part of the field's description for screen readers. */ suffixText: string; min?: number; max?: number; /** Step of the ± buttons and ↑ / ↓; with `type="number"` also the allowed precision. */ step: number; /** Where the steppers start from an empty field (Carbon `stepStartValue`); 0 = Carbon's rule: ±1, or `min` when only a minimum is set. */ stepStartValue: number; /** `number`: a native number field. `text`: a text field formatted for `locale` with `format-options` (Carbon `type="text"`). */ type: NumberInputType; /** BCP 47 locale of the formatting with `type="text"`; empty = the page language (`lang` on the element, an ancestor or ``), as `ui-date-picker`. */ locale: string; /** `Intl.NumberFormat` options with `type="text"`, e.g. `{"style":"currency","currency":"THB"}` or `{"maximumFractionDigits":2}`. */ formatOptions: Intl.NumberFormatOptions; /** An empty field is valid (Carbon `allowEmpty`); otherwise empty counts as missing. */ allowEmpty: boolean; /** Remove the − / + buttons (keyboard stepping still works). */ hideSteppers: boolean; /** Ignore mouse-wheel changes while focused (Carbon `disableWheel`). */ disableWheel: boolean; /** Field height: sm 32px, md 40px, lg 48px (tokens `--ui-field-height-*`). */ size: NumberInputSize; /** Disables the control; a disabled `
` ancestor does the same. */ disabled: boolean; /** Shows and submits the value but blocks changes. */ readonly: boolean; /** Carbon `FluidNumberInput`: 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; /** Accessible name of the − button. */ decrementLabel: string; /** Accessible name of the + button. */ incrementLabel: string; private touched; /** Disabled, reset defaults, validation on submit and the name given from outside (shared by the form fields). */ private readonly formControl; /** The text shown with `type="text"`: as typed while focused, formatted otherwise. */ private text; 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 readonly slots; private defaultValue; /** `value` as last derived from typing, so willUpdate doesn't reformat what the user is typing. */ private typedValue?; /** `value` at the last commit (focus, blur, stepper): blur fires `change` when it differs. */ private committedValue; /** Locale + options the text was last formatted with. */ private formatKey; /** The parsed value, NaN while empty or not a number. */ get valueAsNumber(): number; /** Enter in the text box submits the form, like a native input. */ private readonly onEnterKey; connectedCallback(): void; disconnectedCallback(): void; /** Follows the prefix / suffix widths so the value never runs under them. */ private readonly affixSizes; 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 `