1 | export type SnackbarCloseReason = 'timeout' | 'clickaway' | 'escapeKeyDown';
|
2 | export interface UseSnackbarParameters {
|
3 | /**
|
4 | * The number of milliseconds to wait before automatically calling the
|
5 | * `onClose` function. `onClose` should then set the state of the `open`
|
6 | * prop to hide the Snackbar. This behavior is disabled by default with
|
7 | * the `null` value.
|
8 | * @default null
|
9 | */
|
10 | autoHideDuration?: number | null;
|
11 | /**
|
12 | * If `true`, the `autoHideDuration` timer will expire even if the window is not focused.
|
13 | * @default false
|
14 | */
|
15 | disableWindowBlurListener?: boolean;
|
16 | /**
|
17 | * Callback fired when the component requests to be closed.
|
18 | * Typically `onClose` is used to set state in the parent component,
|
19 | * which is used to control the `Snackbar` `open` prop.
|
20 | * The `reason` parameter can optionally be used to control the response to `onClose`,
|
21 | * for example ignoring `clickaway`.
|
22 | *
|
23 | * @param {React.SyntheticEvent<any> | Event} event The event source of the callback.
|
24 | * @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`, or `"escapeKeyDown"`.
|
25 | */
|
26 | onClose?: (event: React.SyntheticEvent<any> | Event | null, reason: SnackbarCloseReason) => void;
|
27 | /**
|
28 | * If `true`, the component is shown.
|
29 | */
|
30 | open?: boolean;
|
31 | /**
|
32 | * The number of milliseconds to wait before dismissing after user interaction.
|
33 | * If `autoHideDuration` prop isn't specified, it does nothing.
|
34 | * If `autoHideDuration` prop is specified but `resumeHideDuration` isn't,
|
35 | * we default to `autoHideDuration / 2` ms.
|
36 | */
|
37 | resumeHideDuration?: number;
|
38 | }
|
39 | export type UseSnackbarRootSlotProps<ExternalProps = {}> = ExternalProps & UseSnackbarRootSlotOwnProps;
|
40 | export interface UseSnackbarRootSlotOwnProps {
|
41 | onBlur: React.FocusEventHandler;
|
42 | onFocus: React.FocusEventHandler;
|
43 | onMouseEnter: React.MouseEventHandler;
|
44 | onMouseLeave: React.MouseEventHandler;
|
45 | ref?: React.RefCallback<Element>;
|
46 | role: React.AriaRole;
|
47 | }
|
48 | export interface UseSnackbarReturnValue {
|
49 | /**
|
50 | * Resolver for the root slot's props.
|
51 | * @param externalProps props for the root slot
|
52 | * @returns props that should be spread on the root slot
|
53 | */
|
54 | getRootProps: <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseSnackbarRootSlotProps<ExternalProps>;
|
55 | /**
|
56 | * Callback fired when a "click away" event is detected.
|
57 | */
|
58 | onClickAway: (event: React.SyntheticEvent<any> | Event) => void;
|
59 | }
|