import { type ComponentProps, type ReactNode, type RefObject } from 'react'; import { type LocaleNumberFormat } from '../core/number-format.js'; /** * Unstyled Carbon `NumberInput` (Base UI calls it NumberField), the behaviour of the styled one * without a single class: an `Input` with `Decrement` / `Increment` buttons (out of the Tab order: * ↑ / ↓ step from the field). A step clamps to `min` / `max` and rounds to the precision of the * value or `step`; from an empty field it starts at `stepStartValue`, else ±1, else `min` (core * `stepNumber`). A button turns off at its end of the range. The value is plain number text * (`''` when empty). * * `type="text"` formats the number for `locale` with `formatOptions` (`Intl.NumberFormat`: * currency, percent, units…): free text while typing, reformatted on blur, while the value stays a * plain number (`1234.5` for `฿1,234.50`); `HiddenInput` submits it. The browser's invalid bubble * never shows: an invalid field is marked `touched` (and focused when it is the form's first) for * your own message. An uncontrolled field goes back to `defaultValue` with its form. * * State shows as data attributes to style on: `data-disabled`, `data-readonly` and `data-touched` * on `Input` (the field was left, stepped, or a submit found it invalid); `data-disabled` on the buttons. * * ```tsx * * * * − * + * * ``` */ export interface RootProps { /** The value as plain number text (`''` = empty); a number is accepted too. */ value?: string | number; defaultValue?: string | number; /** The new value (plain number text, `''` when empty) after typing, a step, or a blur that rounded it. */ onValueChange?: (value: string) => void; min?: number; max?: number; /** Step of the buttons and ↑ / ↓; with `type="number"` also the allowed precision. */ step?: number; /** Where a step starts from an empty field (Carbon `stepStartValue`); 0 = ±1, or `min` when only a minimum is set. */ stepStartValue?: number; type?: 'number' | 'text'; /** BCP 47 locale of `type="text"` (default: ``, else the browser's). */ locale?: string; /** `Intl.NumberFormat` options of `type="text"`. */ formatOptions?: Intl.NumberFormatOptions; disabled?: boolean; readOnly?: boolean; /** Submitted name: on the `Input` itself, or (`type="text"`) on `HiddenInput`. */ name?: string; children?: ReactNode; } export interface NumberInputContextValue { /** Plain number text; `''` when empty. */ value: string; /** The value as a number (NaN while empty). */ number: number; /** What the field shows: the typed text, or (`type="text"`) the formatted value. */ shownText: string; /** `type="text"`'s formatter; null for `type="number"`. */ format: LocaleNumberFormat | null; textMode: boolean; /** Empty (what it shows). */ isEmpty: boolean; /** `type="text"`: text that doesn't read as a number. */ badText: boolean; /** Left, stepped, or found invalid by a submit. */ touched: boolean; min: number | undefined; max: number | undefined; step: number; name: string | undefined; disabled: boolean; readOnly: boolean; interactive: boolean; atMin: boolean; atMax: boolean; /** One step up or down (does nothing unless interactive). */ stepBy: (direction: 1 | -1) => void; /** The parts' handlers. */ typeText: (text: string) => void; leave: () => void; markTouched: () => void; input: RefObject; } /** The state of the enclosing `NumberInput.Root` (value, limits, touched …). */ export declare function useNumberInputContext(part?: string): NumberInputContextValue; export declare function Root({ value: valueProp, defaultValue, onValueChange, min, max, step, stepStartValue, type, locale: localeProp, formatOptions, disabled, readOnly, name, children }: Readonly): import("react").JSX.Element; export interface InputProps extends Omit, 'type' | 'value' | 'defaultValue' | 'min' | 'max' | 'step' | 'name'> { /** Ignore the mouse wheel while focused (Carbon `disableWheel`). */ disableWheel?: boolean; } /** The field: ↑ / ↓ step (unless your `onKeyDown` prevents it); `onBlur` runs after the value settles (`type="text"` reformats). */ export declare function Input({ disableWheel, ref, ...rest }: Readonly): import("react").JSX.Element; type StepButtonProps = Omit, 'type'>; /** One step down. */ export declare function Decrement(props: Readonly): import("react").JSX.Element; /** One step up. */ export declare function Increment(props: Readonly): import("react").JSX.Element; /** `type="text"` with a `name`: submits the plain value (nothing while disabled). Renders nothing otherwise (`Input` carries the name). */ export declare function HiddenInput(props: Readonly, 'type' | 'value' | 'name'>>): import("react").JSX.Element | null; export {};