-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
/
Copy pathModalProps.ts
80 lines (73 loc) · 2.19 KB
/
ModalProps.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
import * as React from 'react';
import { ModalOwnProps as BaseModalOwnProps } from '@mui/base/Modal';
import { OverrideProps } from '@mui/types';
import { SxProps } from '../styles/types';
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
export type ModalSlot = 'root' | 'backdrop';
export interface ModalSlots {
/**
* The component that renders the root.
* @default 'div'
*/
root?: React.ElementType;
/**
* The component that renders the backdrop.
* @default 'div'
*/
backdrop?: React.ElementType;
}
export type ModalSlotsAndSlotProps = CreateSlotsAndSlotProps<
ModalSlots,
{
root: SlotProps<'div', {}, ModalOwnerState>;
backdrop: SlotProps<'div', {}, ModalOwnerState>;
}
>;
export type ModalOwnProps = Pick<
BaseModalOwnProps,
| 'children'
| 'container'
| 'scrollLockContainer'
| 'disableAutoFocus'
| 'disableEnforceFocus'
| 'disableEscapeKeyDown'
| 'disablePortal'
| 'disableRestoreFocus'
| 'disableScrollLock'
| 'hideBackdrop'
| 'keepMounted'
| 'open'
> & {
/**
* Callback fired when the component requests to be closed.
* The `reason` parameter can optionally be used to control the response to `onClose`.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"closeClick"`.
*/
onClose?: {
bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown' | 'closeClick'): void;
}['bivarianceHack'];
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps;
};
export interface ModalTypeMap<P = {}, D extends React.ElementType = 'div'> {
props: P & ModalOwnProps & ModalSlotsAndSlotProps;
defaultComponent: D;
}
export type ModalProps<
D extends React.ElementType = ModalTypeMap['defaultComponent'],
P = { component?: React.ElementType },
> = OverrideProps<ModalTypeMap<P, D>, D>;
export interface ModalOwnerState extends ModalProps {
disableAutoFocus: boolean;
disableEnforceFocus: boolean;
disableEscapeKeyDown: boolean;
disablePortal: boolean;
disableRestoreFocus: boolean;
disableScrollLock: boolean;
hideBackdrop: boolean;
keepMounted: boolean;
}