@mui/x-date-pickers
Version:
The community edition of the MUI X Date and Time Picker components.
96 lines • 3.77 kB
TypeScript
import type * as React from 'react';
import type { FormControlProps } from '@mui/material/FormControl';
import type { FormHelperTextProps } from '@mui/material/FormHelperText';
import type { InputLabelProps } from '@mui/material/InputLabel';
import type { TextFieldVariants } from '@mui/material/TextField';
import type { WithDataAttributes } from '@mui/utils/types';
import type { PickersInputBaseProps, PickersInputPropsUsedByField } from "./PickersInputBase/PickersInputBase.types.js";
import type { PickersInputProps } from "./PickersInput/index.js";
import type { PickersOutlinedInputProps } from "./PickersOutlinedInput/index.js";
import type { PickersFilledInputProps } from "./PickersFilledInput/index.js";
export interface PickersTextFieldSlots {
/**
* The component used for the root slot.
* @default FormControl
*/
root?: React.ElementType;
/**
* The component used for the input slot.
* Defaults to one of `PickersInput`, `PickersFilledInput`, `PickersOutlinedInput` based on `variant`.
* @default PickersOutlinedInput
*/
input?: React.ElementType;
/**
* The component used for the input label slot.
* @default InputLabel
*/
inputLabel?: React.ElementType;
/**
* The component rendered as the underlying hidden `<input>` element.
* @default PickersInputBaseInput
*/
htmlInput?: React.ElementType;
/**
* The component used for the form helper text slot.
* @default FormHelperText
*/
formHelperText?: React.ElementType;
}
export interface PickersTextFieldSlotProps<InputPropsType extends PickersInputBaseProps> {
root?: WithDataAttributes<Partial<FormControlProps>>;
input?: WithDataAttributes<Partial<InputPropsType>>;
inputLabel?: WithDataAttributes<Partial<InputLabelProps>>;
htmlInput?: WithDataAttributes<React.ComponentPropsWithRef<'input'>>;
formHelperText?: WithDataAttributes<Partial<FormHelperTextProps>>;
}
export interface PickersTextFieldSlotsAndSlotProps<InputPropsType extends PickersInputBaseProps> {
/**
* The components used for each slot inside.
* @default {}
*/
slots?: PickersTextFieldSlots;
/**
* The props used for each component slot.
* @default {}
*/
slotProps?: PickersTextFieldSlotProps<InputPropsType>;
}
interface PickersTextFieldPropsUsedByField {
onFocus: React.FocusEventHandler<HTMLDivElement>;
onBlur: React.FocusEventHandler<HTMLDivElement>;
disabled: boolean;
/**
* If `true`, the `input` will indicate an error.
* @default false
*/
error: boolean;
}
export interface PickersBaseTextFieldProps extends PickersInputPropsUsedByField, PickersTextFieldPropsUsedByField, Omit<FormControlProps, keyof PickersInputPropsUsedByField | keyof PickersTextFieldPropsUsedByField | 'slots' | 'slotProps'> {
/**
* The helper text content.
*/
helperText?: React.ReactNode;
}
export interface PickersStandardTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersInputProps> {
/**
* The variant to use.
* @default 'outlined'
*/
variant?: 'standard';
}
export interface PickersOutlinedTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersOutlinedInputProps> {
/**
* The variant to use.
* @default 'outlined'
*/
variant?: 'outlined';
}
export interface PickersFilledTextFieldProps extends PickersBaseTextFieldProps, PickersTextFieldSlotsAndSlotProps<PickersFilledInputProps> {
/**
* The variant to use.
* @default 'outlined'
*/
variant?: 'filled';
}
export type PickersTextFieldProps<Variant extends TextFieldVariants = TextFieldVariants> = Variant extends 'filled' ? PickersFilledTextFieldProps : Variant extends 'standard' ? PickersStandardTextFieldProps : PickersOutlinedTextFieldProps;
export {};