1
1
import * as React from 'react' ;
2
2
import { TransitionActions } from 'react-transition-group/Transition' ;
3
3
import { SvgIconProps } from '@material-ui/core/SvgIcon' ;
4
- import { SnackbarProps } from '@material-ui/core/Snackbar' ;
4
+ import { SnackbarProps , SnackbarClassKey } from '@material-ui/core/Snackbar' ;
5
5
6
6
type Omit < T , K extends keyof T > = Pick < T , Exclude < keyof T , K > >
7
7
8
8
export type VariantType = 'default' | 'error' | 'success' | 'warning' | 'info' ;
9
9
10
- export interface OptionsObject extends Omit < SnackbarProps , 'open' | 'message' > {
10
+ export interface OptionsObject extends Omit < SnackbarProps , 'open' | 'message' > {
11
11
variant ?: VariantType ;
12
12
onClickAction ?: Function ;
13
13
}
14
14
15
+ type NotistackClassKey = 'variantSuccess'
16
+ | 'variantError'
17
+ | 'variantInfo'
18
+ | 'variantWarning' ;
19
+
20
+ // class keys for both MUI and notistack
21
+ export type CombinedClassKey = NotistackClassKey | SnackbarClassKey ;
22
+
15
23
export interface InjectedNotistackProps {
16
24
onPresentSnackbar : ( variant : VariantType , message : string ) => void ;
17
25
enqueueSnackbar : ( message : string , options ?: OptionsObject ) => void ;
@@ -20,8 +28,12 @@ export interface InjectedNotistackProps {
20
28
export function withSnackbar < P extends InjectedNotistackProps > ( component : React . ComponentType < P > ) :
21
29
React . ComponentClass < Omit < P , keyof InjectedNotistackProps > > & { WrappedComponent : React . ComponentType < P > } ;
22
30
31
+ export type ClassNameMap < ClassKey extends string = string > = Record < ClassKey , string > ;
23
32
24
- export interface SnackbarProviderProps extends Omit < SnackbarProps , 'open' | 'message' > {
33
+ /** all MUI props, including class keys for notistack and MUI with additional notistack props */
34
+ export interface SnackbarProviderProps
35
+ extends Omit < SnackbarProps , 'open' | 'message' | 'classes' > {
36
+ classes ?: Partial < ClassNameMap < CombinedClassKey > > ;
25
37
maxSnack : number ;
26
38
iconVariant ?: React . ComponentType < SvgIconProps > ;
27
39
hideIconVariant ?: boolean ;
0 commit comments