import { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";
export type NumberInputTranslationId = "increment" | "decrement";
type $RestProps = SvelteHTMLElements["input"];
type $Props = {
/**
* Set the size of the input.
* Inherits the parent `Form` size when unset.
* Also accepts Carbon v11's `"md"` (the 40px default, which overrides a
* `Form` size) and `"lg"` (`"xl"`).
*/
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
/**
* Specify the input value.
* Use `null` to denote "no value".
* Kept when the owning form resets; with `allowEmpty`, follows the field
* instead.
* @default null
*/
value?: null | number;
/**
* Specify the step increment
* @default 1
*/
step?: number;
/**
* Specify the maximum value.
*/
max?: number | undefined;
/**
* Specify the minimum value.
*/
min?: number | undefined;
/**
* Provide the value stepping should begin at when the input is empty.
*/
stepStartValue?: number | undefined;
/**
* Set to `true` for the input to be read-only
* @default false
*/
readonly?: boolean;
/**
* Set to `true` to use the fluid variant.
* Inherited from the parent `FluidForm` context,
* so it does not need to be set when used inside `FluidForm`.
* @default false
*/
fluid?: boolean;
/**
* Set to `true` to allow for an empty value
* @default false
*/
allowEmpty?: boolean;
/**
* Set to `true` to preserve decimal input formatting.
* When enabled, uses type="text" with inputmode="decimal" instead of type="number".
* @example
* ```svelte
*
*
* ```
* @default false
*/
allowDecimal?: boolean;
/**
* Specify a BCP 47 locale for number formatting.
* When set, forces type="text" with inputmode="decimal"
* and formats the display value using Intl.NumberFormat.
* @example
* ```svelte
*
*
* ```
*/
locale?: string | undefined;
/**
* Specify Intl.NumberFormat options when `locale` is set.
* @example
* ```svelte
*
* ```
*/
formatOptions?: Intl.NumberFormatOptions | undefined;
/**
* Set to `true` to disable the input
* @default false
*/
disabled?: boolean;
/**
* Set to `true` to hide the input stepper buttons
* @default false
*/
hideSteppers?: boolean;
/**
* Set to `true` to prevent the scroll wheel from changing the input value
* @default false
*/
disableWheel?: boolean;
/**
* Set to `true` to change the value by dragging the label left or right.
* Dragging toward the inline end raises the value: right, or left under
* `dir="rtl"`. Every 4 pixels of travel moves one `step`; hold Shift to
* move 10 steps.
* Typing, arrow keys, and the steppers work as usual.
* @default false
*/
scrubbable?: boolean;
/**
* Set to `true` to select the input's text when it receives focus
* @default false
*/
selectTextOnFocus?: boolean;
/**
* Custom validation function.
* Receives the current raw input string and locale.
* Return `true` to force valid, `false` to force invalid,
* or `undefined` to defer to built-in validation.
* @example
* ```svelte
* Number(raw) % 2 === 0} invalidText="Must be even" />
* ```
*/
validate?: ((value: string, locale: string | undefined) => boolean | undefined) | undefined;
/**
* Set to `true` to indicate an invalid state
* @default false
*/
invalid?: boolean;
/**
* Specify the invalid state text
* @default ""
*/
invalidText?: string;
/**
* Set to `true` to indicate a warning state
* @default false
*/
warn?: boolean;
/**
* Specify the warning state text
* @default ""
*/
warnText?: string;
/**
* Specify the helper text
* @default ""
*/
helperText?: string;
/**
* Specify the label text
* @default ""
*/
labelText?: string;
/**
* Set to `true` to visually hide the label text
* @default false
*/
hideLabel?: boolean;
/**
* Override the default translation ids.
* @default (id) => defaultTranslations[id]
*/
translateWithId?: (id: NumberInputTranslationId) => string;
/**
* Set an id for the input element
* @default uniqueId()
*/
id?: string;
/**
* Specify a name attribute for the input.
* With `locale` or `allowDecimal`, the form submits the numeric value
* (for example `1234.5`), not the formatted display text.
*/
name?: string | undefined;
/**
* Obtain a reference to the input HTML element.
* @default null
*/
ref?: null | HTMLInputElement;
decorator?: (this: void) => void;
labelChildren?: (this: void) => void;
[key: `data-${string}`]: unknown;
};
export type NumberInputProps = Omit<$RestProps, keyof $Props> & $Props;
export default class NumberInput extends SvelteComponentTyped<
NumberInputProps,
{
blur: CustomEvent<{ event: FocusEvent, value: null | number }>;
"blur:stepper": CustomEvent<{ event: FocusEvent, value: null | number, direction: "up" | "down" }>;
change: CustomEvent;
click: WindowEventMap["click"];
"click:stepper": CustomEvent<{ value: null | number, direction: "up" | "down" }>;
focus: WindowEventMap["focus"];
input: CustomEvent;
keydown: WindowEventMap["keydown"];
keyup: WindowEventMap["keyup"];
mouseenter: WindowEventMap["mouseenter"];
mouseleave: WindowEventMap["mouseleave"];
mouseover: WindowEventMap["mouseover"];
paste: WindowEventMap["paste"];
},
{
decorator: Record;
labelChildren: Record;
}
> {
/**
* Default translation ids.
*/
translationIds: {
increment: "increment";
decrement: "decrement"
};
}