UNPKG

4.29 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { Theme } from '../styles';
4import { InternalStandardProps as StandardProps } from '..';
5import { FabProps } from '../Fab';
6import { TransitionProps } from '../transitions';
7import { SpeedDialClasses } from './speedDialClasses';
8import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
9
10export type CloseReason = 'toggle' | 'blur' | 'mouseLeave' | 'escapeKeyDown';
11export type OpenReason = 'toggle' | 'focus' | 'mouseEnter';
12
13export interface SpeedDialSlots {
14 /**
15 * The component that renders the transition.
16 * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
17 * @default {}
18 */
19 transition: React.JSXElementConstructor<
20 TransitionProps & { children: React.ReactElement<unknown, any> }
21 >;
22}
23
24export type SpeedDialSlotsAndSlotProps = CreateSlotsAndSlotProps<
25 SpeedDialSlots,
26 {
27 transition: SlotProps<React.JSXElementConstructor<TransitionProps>, {}, SpeedDialOwnerState>;
28 }
29>;
30
31export interface SpeedDialProps
32 extends Omit<
33 StandardProps<React.HTMLAttributes<HTMLDivElement>, 'children'>,
34 'slots' | 'slotProps'
35 >,
36 SpeedDialSlotsAndSlotProps {
37 /**
38 * SpeedDialActions to display when the SpeedDial is `open`.
39 */
40 children?: React.ReactNode;
41 /**
42 * Override or extend the styles applied to the component.
43 */
44 classes?: Partial<SpeedDialClasses>;
45 /**
46 * The aria-label of the button element.
47 * Also used to provide the `id` for the `SpeedDial` element and its children.
48 */
49 ariaLabel: string;
50 /**
51 * The direction the actions open relative to the floating action button.
52 * @default 'up'
53 */
54 direction?: 'up' | 'down' | 'left' | 'right';
55 /**
56 * If `true`, the SpeedDial is hidden.
57 * @default false
58 */
59 hidden?: boolean;
60 /**
61 * Props applied to the [`Fab`](https://mui.com/material-ui/api/fab/) element.
62 * @default {}
63 */
64 FabProps?: Partial<FabProps>;
65 /**
66 * The icon to display in the SpeedDial Fab. The `SpeedDialIcon` component
67 * provides a default Icon with animation.
68 */
69 icon?: React.ReactNode;
70 /**
71 * Callback fired when the component requests to be closed.
72 *
73 * @param {object} event The event source of the callback.
74 * @param {string} reason Can be: `"toggle"`, `"blur"`, `"mouseLeave"`, `"escapeKeyDown"`.
75 */
76 onClose?: (event: React.SyntheticEvent<{}>, reason: CloseReason) => void;
77 /**
78 * Callback fired when the component requests to be open.
79 *
80 * @param {object} event The event source of the callback.
81 * @param {string} reason Can be: `"toggle"`, `"focus"`, `"mouseEnter"`.
82 */
83 onOpen?: (event: React.SyntheticEvent<{}>, reason: OpenReason) => void;
84 /**
85 * If `true`, the component is shown.
86 */
87 open?: boolean;
88 /**
89 * The icon to display in the SpeedDial Fab when the SpeedDial is open.
90 */
91 openIcon?: React.ReactNode;
92 /**
93 * The system prop that allows defining system overrides as well as additional CSS styles.
94 */
95 sx?: SxProps<Theme>;
96 /**
97 * The component used for the transition.
98 * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
99 * @default Zoom
100 */
101 TransitionComponent?: React.JSXElementConstructor<TransitionProps>;
102 /**
103 * The duration for the transition, in milliseconds.
104 * You may specify a single timeout for all transitions, or individually with an object.
105 * @default {
106 * enter: theme.transitions.duration.enteringScreen,
107 * exit: theme.transitions.duration.leavingScreen,
108 * }
109 */
110 transitionDuration?: TransitionProps['timeout'];
111 /**
112 * Props applied to the transition element.
113 * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
114 */
115 TransitionProps?: TransitionProps;
116}
117
118export interface SpeedDialOwnerState extends SpeedDialProps {}
119
120/**
121 *
122 * Demos:
123 *
124 * - [Speed Dial](https://mui.com/material-ui/react-speed-dial/)
125 *
126 * API:
127 *
128 * - [SpeedDial API](https://mui.com/material-ui/api/speed-dial/)
129 */
130export default function SpeedDial(props: SpeedDialProps): React.JSX.Element;