-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Expand file tree
/
Copy pathStepContent.spec.tsx
More file actions
69 lines (65 loc) · 1.92 KB
/
StepContent.spec.tsx
File metadata and controls
69 lines (65 loc) · 1.92 KB
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
import { expectType } from '@mui/types';
import { mergeSlotProps } from '@mui/material/utils';
import StepContent, { StepContentProps } from '@mui/material/StepContent';
import Fade from '@mui/material/Fade';
import Collapse from '@mui/material/Collapse';
import Grow from '@mui/material/Grow';
import Slide from '@mui/material/Slide';
import Zoom from '@mui/material/Zoom';
// slotProps.transition should reject unknown props
<StepContent
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
>
Step Content
</StepContent>;
<StepContent slots={{ transition: Fade }}>Step Content</StepContent>;
<StepContent slots={{ transition: Collapse }}>Step Content</StepContent>;
<StepContent slots={{ transition: Grow }}>Step Content</StepContent>;
<StepContent slots={{ transition: Slide }}>Step Content</StepContent>;
<StepContent slots={{ transition: Zoom }}>Step Content</StepContent>;
function Custom(props: StepContentProps) {
const { slotProps, ...other } = props;
return (
<StepContent
slotProps={{
...slotProps,
transition: (ownerState) => {
const transitionProps =
typeof slotProps?.transition === 'function'
? slotProps.transition(ownerState)
: slotProps?.transition;
return {
...transitionProps,
onExited: (node) => {
transitionProps?.onExited?.(node);
},
};
},
}}
{...other}
>
test
</StepContent>
);
}
function Custom2(props: StepContentProps) {
const { slotProps, ...other } = props;
return (
<StepContent
slotProps={{
...slotProps,
transition: mergeSlotProps(slotProps?.transition, {
onExited: (node) => {
expectType<HTMLElement, typeof node>(node);
},
}),
}}
{...other}
>
test
</StepContent>
);
}