import * as React from 'react'; export type RequiredBy = Omit & Required>; /** * type MyType = { * a: string * b: never * } * * OmitNever --> { a: string } */ type OmitNever = Pick< T, { [Prop in keyof T]: [T[Prop]] extends [never] ? never : Prop; }[keyof T] >; /** * type Type1 = { a: string; b: number } * type Type2 = { b: boolean; c: string } * * Override --> { * a: string * b: boolean * c: string * } */ type Override = Omit & U; type MarkInvalidVariantAsNever = { [Key in keyof T]: T[Key] extends true ? T[Key] : T[Key] extends Record ? T[Key] : never; }; type GetWhitelistedVariants = OmitNever, U>>>; export interface TransitionDuration { enter?: number; exit?: number; } export type TransitionStatus = 'entering' | 'entered' | 'exiting' | 'exited' | 'unmounted'; export interface TransitionComponentProps extends Omit { children: (status: TransitionStatus, childProps: Record) => React.ReactNode; nodeRef: React.RefObject; } /** * @category Shared */ export interface TransitionHandlerProps { /** * Callback fired before the transition is entering. */ onEnter: (node: HTMLElement, isAppearing: boolean, key: SnackbarKey) => void; /** * Callback fired when the transition has entered. */ onEntered: (node: HTMLElement, isAppearing: boolean, key: SnackbarKey) => void; /** * Callback fired before the transition is exiting. */ onExit: (node: HTMLElement, key: SnackbarKey) => void; /** * Callback fired when the transition has exited. */ onExited: (node: HTMLElement, key: SnackbarKey) => void; } export type SlideTransitionDirection = 'down' | 'left' | 'right' | 'up'; export interface TransitionProps { appear?: boolean; /** * Show the component; triggers the enter or exit states */ in?: boolean; /** * The duration of the transition, in milliseconds */ timeout?: number | TransitionDuration; /** * Enable or disable enter transitions. */ enter?: boolean; /** * Enable or disable exit transitions. */ exit?: boolean; /** * By default the child component is mounted immediately along with the * parent Transition component. If you want to "lazy mount" the component on * the first `in={true}` you can set `mountOnEnter`. After the first enter * transition the component will stay mounted, even on "exited", unless you * also specify `unmountOnExit`. */ mountOnEnter?: boolean; /** * By default the child component stays mounted after it reaches the * 'exited' state. Set `unmountOnExit` if you'd prefer to unmount the * component after it finishes exiting. */ unmountOnExit?: boolean; /** * Can be used to apply a custom `transitionTimingFunction` (e.g. your own easing), * `transitionDuration` and `transitionDelay`. */ style?: React.CSSProperties; /** * The direction in which a snackbar slides into the screen. * Only applicable if `TransitionComponent` is Slide */ direction?: SlideTransitionDirection; children: React.ReactNode; /** * Callback fired before the transition is entering. */ onEnter?: (node: HTMLElement, isAppearing: boolean) => void; /** * Callback fired when the transition has entered. */ onEntered?: (node: HTMLElement, isAppearing: boolean) => void; /** * Callback fired when the transition is entering. */ onEntering?: (node: HTMLElement, isAppearing: boolean) => void; /** * Callback fired before the transition is exiting. */ onExit?: (node: HTMLElement) => void; /** * Callback fired when the transition has exited. */ onExited?: (node: HTMLElement) => void; /** * Callback fired when the transition is existing. */ onExiting?: (node: HTMLElement) => void; addEndListener?: (node: HTMLElement | HTMLDivElement, callback: () => void) => void; } export type ClassNameMap = Record; // eslint-disable-next-line @typescript-eslint/no-empty-interface interface VariantOverrides {} type VariantMap = GetWhitelistedVariants; type BaseVariant = 'default' | 'error' | 'success' | 'warning' | 'info'; export type VariantType = keyof VariantMap; export type SnackbarKey = string | number; export type CloseReason = 'timeout' | 'maxsnack' | 'instructed'; export type SnackbarMessage = string | React.ReactNode; export type SnackbarAction = React.ReactNode | ((key: SnackbarKey) => React.ReactNode); export type SnackbarContentCallback = | React.ReactNode | ((key: SnackbarKey, message?: SnackbarMessage) => React.ReactNode); export type SnackbarClassKey = | 'root' | 'anchorOriginTopCenter' | 'anchorOriginBottomCenter' | 'anchorOriginTopRight' | 'anchorOriginBottomRight' | 'anchorOriginTopLeft' | 'anchorOriginBottomLeft'; export type ContainerClassKey = | 'containerRoot' | 'containerAnchorOriginTopCenter' | 'containerAnchorOriginBottomCenter' | 'containerAnchorOriginTopRight' | 'containerAnchorOriginBottomRight' | 'containerAnchorOriginTopLeft' | 'containerAnchorOriginBottomLeft'; export type CombinedClassKey = ContainerClassKey | SnackbarClassKey; export interface SnackbarOrigin { vertical: 'top' | 'bottom'; horizontal: 'left' | 'center' | 'right'; } export type SnackbarContentProps = React.HTMLAttributes; /** * @category Shared */ export interface SharedProps extends Partial { className?: string; style?: React.CSSProperties; /** * The anchor of the `Snackbar`. * @default { horizontal: left, vertical: bottom } */ anchorOrigin?: SnackbarOrigin; /** * The number of milliseconds to wait before automatically calling the * `onClose` function. By default snackbars get closed after 5000 milliseconds. * Set autoHideDuration to 'null' if you don't want snackbars to automatically close. * Alternatively pass `persist: true` in the options parameter of enqueueSnackbar. * @default 5000 */ autoHideDuration?: number | null; /** * If `true`, the `autoHideDuration` timer will expire even if the window is not focused. * @default false */ disableWindowBlurListener?: boolean; /** * The component used for the transition. See how you can use a different transition: * https://notistack.com/examples/advanced/custom-transition * @default Slide */ TransitionComponent?: React.JSXElementConstructor }>; /** * The duration for the transition, in milliseconds. * * You may specify a single timeout for both enter and exit transitions: * ```js * timeout={500} * ``` * or individually: * ```js * timeout={{ enter: 300, exit: 500 }} * ``` * @default { enter: 225, exit: 195 } */ transitionDuration?: TransitionProps['timeout']; /** * Properties applied to Transition component */ TransitionProps?: Partial; /** * Used to easily display different variant of snackbars. When passed to `SnackbarProvider` * all snackbars inherit the `variant`, unless you override it in `enqueueSnackbar` options. * @default default */ variant?: V; /** * Ignores displaying multiple snackbars with the same `message` * @default false */ preventDuplicate?: boolean; /** * Callback used for getting action(s). actions are mostly buttons displayed in Snackbar. * @param {string|number} key key of a snackbar */ action?: SnackbarAction; /** * Hides iconVariant if set to `true`