-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
DateField.types.ts
92 lines (86 loc) · 2.7 KB
/
DateField.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import * as React from 'react';
import { SlotComponentProps } from '@mui/base/utils';
import TextField from '@mui/material/TextField';
import {
ExportedUseClearableFieldProps,
UseClearableFieldSlots,
UseClearableFieldSlotProps,
} from '../hooks/useClearableField';
import {
DateValidationError,
FieldSection,
PickerValidDate,
BuiltInFieldTextFieldProps,
} from '../models';
import { UseFieldInternalProps } from '../internals/hooks/useField';
import { MakeOptional } from '../internals/models/helpers';
import {
BaseDateValidationProps,
DayValidationProps,
MonthValidationProps,
YearValidationProps,
} from '../internals/models/validation';
export interface UseDateFieldProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean,
> extends MakeOptional<
UseFieldInternalProps<
TDate | null,
TDate,
FieldSection,
TEnableAccessibleFieldDOMStructure,
DateValidationError
>,
'format'
>,
DayValidationProps<TDate>,
MonthValidationProps<TDate>,
YearValidationProps<TDate>,
BaseDateValidationProps<TDate>,
ExportedUseClearableFieldProps {}
export type UseDateFieldComponentProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean,
TChildProps extends {},
> = Omit<TChildProps, keyof UseDateFieldProps<TDate, TEnableAccessibleFieldDOMStructure>> &
UseDateFieldProps<TDate, TEnableAccessibleFieldDOMStructure>;
export type DateFieldProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean = false,
> = UseDateFieldComponentProps<
TDate,
TEnableAccessibleFieldDOMStructure,
BuiltInFieldTextFieldProps<TEnableAccessibleFieldDOMStructure>
> & {
/**
* Overridable component slots.
* @default {}
*/
slots?: DateFieldSlots;
/**
* The props used for each component slot.
* @default {}
*/
slotProps?: DateFieldSlotProps<TDate, TEnableAccessibleFieldDOMStructure>;
};
export type DateFieldOwnerState<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean,
> = DateFieldProps<TDate, TEnableAccessibleFieldDOMStructure>;
export interface DateFieldSlots extends UseClearableFieldSlots {
/**
* Form control with an input to render the value.
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`.
*/
textField?: React.ElementType;
}
export interface DateFieldSlotProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean,
> extends UseClearableFieldSlotProps {
textField?: SlotComponentProps<
typeof TextField,
{},
DateFieldOwnerState<TDate, TEnableAccessibleFieldDOMStructure>
>;
}