UNPKG

2.99 kBTypeScriptView Raw
1import * as React from 'react';
2import {
3 StyleObject,
4 StyletronComponent,
5 WithStyleFn as StyletronWithStyleFn,
6 StyledFn as StyletronStyledFn,
7} from 'styletron-react';
8import {Override, Overrides} from './overrides';
9import {Locale} from './locale';
10import {Theme, ThemePrimitives} from './theme';
11
12type UseStyletronFn<Theme> = () => [(arg: StyleObject) => string, Theme];
13export function createThemedUseStyletron<Theme>(): UseStyletronFn<Theme>;
14export const useStyletron: UseStyletronFn<Theme>;
15
16export function createTheme<P extends object>(
17 primitives: Partial<ThemePrimitives>,
18 overrides?: P,
19): Theme & P;
20export function createLightTheme<P extends object>(
21 primitives: Partial<ThemePrimitives>,
22 overrides?: P,
23): Theme & P;
24export function createDarkTheme<P extends object>(
25 primitives: Partial<ThemePrimitives>,
26 overrides?: P,
27): Theme & P;
28export function mergeOverrides<T>(
29 target?: Overrides<T>,
30 source?: Overrides<T>,
31): Overrides<T>;
32export function styled<
33 P extends object,
34 C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
35 T = Theme
36>(
37 component: C,
38 styledFn: StyleObject | ((props: {$theme: T} & P) => StyleObject),
39): StyletronComponent<
40 Pick<
41 React.ComponentProps<C>,
42 Exclude<keyof React.ComponentProps<C>, {className: string}>
43 > &
44 P
45>;
46
47export const LightTheme: Theme;
48export const LightThemeMove: Theme;
49export const lightThemePrimitives: ThemePrimitives;
50export const DarkTheme: Theme;
51export const DarkThemeMove: Theme;
52export const darkThemePrimitives: ThemePrimitives;
53
54export interface BaseProviderOverrides {
55 AppContainer?: Override<any>;
56 LayersContainer?: Override<any>;
57}
58
59export interface BaseProviderProps {
60 children: React.ReactNode;
61 theme: Theme;
62 overrides?: BaseProviderOverrides;
63 zIndex?: number;
64}
65export const BaseProvider: React.FC<BaseProviderProps>;
66
67export interface LocaleProviderProps {
68 locale: Partial<Locale>;
69 children?: React.ReactNode;
70}
71export const LocaleProvider: React.FC<LocaleProviderProps>;
72
73export interface ThemeProviderProps {
74 theme: Theme;
75 children?: React.ReactNode;
76}
77export const ThemeProvider: React.FC<ThemeProviderProps>;
78
79export interface StyledFn<T> extends StyletronStyledFn {
80 <
81 C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
82 P extends object
83 >(
84 component: C,
85 style: (props: {$theme: T} & P) => StyleObject,
86 ): StyletronComponent<
87 Pick<
88 React.ComponentProps<C>,
89 Exclude<keyof React.ComponentProps<C>, {className: string}>
90 > &
91 P
92 >;
93}
94
95export function createThemedStyled<Theme>(): StyledFn<Theme>;
96
97export interface WithStyleFn<T = Theme> extends StyletronWithStyleFn {
98 <C extends StyletronComponent<any>, P extends object, T1 = T>(
99 component: C,
100 style: (props: P & {$theme: T1}) => StyleObject,
101 ): StyletronComponent<React.ComponentProps<C> & P>;
102}
103
104export const withStyle: WithStyleFn;
105
106export function createThemedWithStyle<Theme>(): WithStyleFn<Theme>;