UNPKG

1.39 kBTypeScriptView Raw
1import { PropInjector } from '@material-ui/types';
2import { Theme } from './createTheme';
3import {
4 CreateCSSProperties,
5 CSSProperties,
6 ClassNameMap,
7 StyledComponentProps,
8 WithStylesOptions,
9 StyleRules as ActualStyleRules,
10 StyleRulesCallback,
11 Styles,
12 ClassKeyOfStyles,
13 BaseCSSProperties,
14} from '@material-ui/styles/withStyles';
15
16export {
17 CreateCSSProperties,
18 CSSProperties,
19 ClassNameMap,
20 StyledComponentProps,
21 Styles,
22 WithStylesOptions,
23 StyleRulesCallback,
24 BaseCSSProperties,
25};
26
27/**
28 * Adapter for `StyleRules` from `@material-ui/styles` for backwards compatibility.
29 * Order of generic arguments is just reversed.
30 *
31 * TODO: to normalize in v5
32 */
33export type StyleRules<
34 ClassKey extends string = string,
35 Props extends object = {}
36> = ActualStyleRules<Props, ClassKey>;
37
38export type WithStyles<
39 StylesOrClassKey extends string | Styles<any, any, any> = string,
40 IncludeTheme extends boolean | undefined = false
41> = (IncludeTheme extends true ? { theme: Theme } : {}) & {
42 classes: ClassNameMap<ClassKeyOfStyles<StylesOrClassKey>>;
43};
44
45export default function withStyles<
46 ClassKey extends string,
47 Options extends WithStylesOptions<Theme> = {},
48 Props extends object = {}
49>(
50 style: Styles<Theme, Props, ClassKey>,
51 options?: Options
52): PropInjector<WithStyles<ClassKey, Options['withTheme']>, StyledComponentProps<ClassKey> & Props>;