UNPKG

3.96 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Simplify } from '@mui/types';
3import { FormControlState } from '../FormControl';
4import { UseNumberInputParameters, UseNumberInputRootSlotProps, UseNumberInputIncrementButtonSlotProps, UseNumberInputDecrementButtonSlotProps } from '../unstable_useNumberInput/useNumberInput.types';
5import { PolymorphicProps, SlotComponentProps } from '../utils';
6export interface NumberInputRootSlotPropsOverrides {
7}
8export interface NumberInputInputSlotPropsOverrides {
9}
10export interface NumberInputStepperButtonSlotPropsOverrides {
11}
12export type NumberInputOwnProps = Omit<UseNumberInputParameters, 'error' | 'inputId' | 'inputRef'> & {
13 /**
14 * Trailing adornment for this input.
15 */
16 endAdornment?: React.ReactNode;
17 /**
18 * If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `baseui--error` class on the root element.
19 */
20 error?: boolean;
21 /**
22 * The id of the `input` element.
23 */
24 id?: string;
25 /**
26 * The short hint displayed in the `input` before the user enters a value.
27 */
28 placeholder?: React.InputHTMLAttributes<HTMLInputElement>['placeholder'];
29 /**
30 * The props used for each slot inside the NumberInput.
31 * @default {}
32 */
33 slotProps?: {
34 root?: SlotComponentProps<'div', NumberInputRootSlotPropsOverrides, NumberInputOwnerState>;
35 input?: SlotComponentProps<'input', NumberInputInputSlotPropsOverrides, NumberInputOwnerState>;
36 incrementButton?: SlotComponentProps<'button', NumberInputStepperButtonSlotPropsOverrides, NumberInputOwnerState>;
37 decrementButton?: SlotComponentProps<'button', NumberInputStepperButtonSlotPropsOverrides, NumberInputOwnerState>;
38 };
39 /**
40 * The components used for each slot inside the InputBase.
41 * Either a string to use a HTML element or a component.
42 * @default {}
43 */
44 slots?: NumberInputSlots;
45 /**
46 * Leading adornment for this input.
47 */
48 startAdornment?: React.ReactNode;
49};
50export interface NumberInputSlots {
51 /**
52 * The component that renders the root.
53 * @default 'div'
54 */
55 root?: React.ElementType;
56 /**
57 * The component that renders the input.
58 * @default 'input'
59 */
60 input?: React.ElementType;
61 /**
62 * The component that renders the increment button.
63 * @default 'button'
64 */
65 incrementButton?: React.ElementType;
66 /**
67 * The component that renders the decrement button.
68 * @default 'button'
69 */
70 decrementButton?: React.ElementType;
71}
72export interface NumberInputTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
73 props: AdditionalProps & NumberInputOwnProps;
74 defaultComponent: RootComponentType;
75}
76export type NumberInputProps<RootComponentType extends React.ElementType = NumberInputTypeMap['defaultComponent']> = PolymorphicProps<NumberInputTypeMap<{}, RootComponentType>, RootComponentType>;
77export type NumberInputOwnerState = Simplify<NumberInputOwnProps & {
78 formControlContext: FormControlState | undefined;
79 focused: boolean;
80 isIncrementDisabled: boolean;
81 isDecrementDisabled: boolean;
82}>;
83export type NumberInputRootSlotProps = Simplify<UseNumberInputRootSlotProps & {
84 ownerState: NumberInputOwnerState;
85 className?: string;
86 children?: React.ReactNode;
87 ref?: React.Ref<Element>;
88}>;
89export type NumberInputInputSlotProps = Simplify<Omit<UseNumberInputRootSlotProps, 'onClick'> & {
90 id: string | undefined;
91 ownerState: NumberInputOwnerState;
92 placeholder: string | undefined;
93 ref: React.Ref<HTMLInputElement>;
94}>;
95export type NumberInputIncrementButtonSlotProps = Simplify<UseNumberInputIncrementButtonSlotProps & {
96 ownerState: NumberInputOwnerState;
97}>;
98export type NumberInputDecrementButtonSlotProps = Simplify<UseNumberInputDecrementButtonSlotProps & {
99 ownerState: NumberInputOwnerState;
100}>;