UNPKG

1.27 kBTypeScriptView Raw
1import { Omit } from '@material-ui/types';
2import {
3 CreateCSSProperties,
4 StyledComponentProps,
5 WithStylesOptions,
6} from '@material-ui/styles/withStyles';
7import { Theme as DefaultTheme } from './createTheme';
8import * as React from 'react';
9
10// These definitions are almost identical to the ones in @material-ui/styles/styled
11// Only difference is that ComponentCreator has a default theme type
12// If you need to change these types, update the ones in @material-ui/styles as well
13
14/**
15 * @internal
16 */
17export type ComponentCreator<Component extends React.ElementType> = <
18 Theme = DefaultTheme,
19 Props extends {} = {}
20>(
21 styles:
22 | CreateCSSProperties<Props>
23 | ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
24 options?: WithStylesOptions<Theme>
25) => React.ComponentType<
26 Omit<
27 JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
28 'classes' | 'className'
29 > &
30 StyledComponentProps<'root'> & { className?: string } & (Props extends { theme: Theme }
31 ? Omit<Props, 'theme'> & { theme?: Theme }
32 : Props)
33>;
34
35export interface StyledProps {
36 className: string;
37}
38
39export default function styled<Component extends React.ElementType>(
40 Component: Component
41): ComponentCreator<Component>;