createThemeFoundation.d.ts
9.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
import { OverridableStringUnion } from '@mui/types';
import { SxConfig, SxProps, CSSObject, ApplyStyles, Theme as SystemTheme, Shape as SystemShape, ShapeOptions as SystemShapeOptions } from '@mui/system';
import { ExtractTypographyTokens } from '@mui/system/cssVars';
import { Palette, PaletteOptions } from "./createPalette.js";
import { Shadows } from "./shadows.js";
import { Transitions } from "./createTransitions.js";
import { Mixins } from "./createMixins.js";
import { TypographyVariants } from "./createTypography.js";
import { ZIndex } from "./zIndex.js";
/**
* default MD color-schemes
*/
export type DefaultColorScheme = 'light' | 'dark';
/**
* The application can add more color-scheme by extending this interface via module augmentation
*
* Ex.
* declare module @mui/material/styles {
* interface ColorSchemeOverrides {
* foo: true;
* }
* }
*
* // SupportedColorScheme = 'light' | 'dark' | 'foo';
*/
export interface ColorSchemeOverrides {}
export type ExtendedColorScheme = OverridableStringUnion<never, ColorSchemeOverrides>;
/**
* All color-schemes that the application has
*/
export type SupportedColorScheme = DefaultColorScheme | ExtendedColorScheme;
export interface Opacity {
inputPlaceholder: number;
inputUnderline: number;
switchTrackDisabled: number;
switchTrack: number;
}
export type Overlays = [string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined, string | undefined];
export interface PaletteBackgroundChannel {
defaultChannel: string;
paperChannel: string;
}
export interface PaletteCommonChannel {
background: string;
backgroundChannel: string;
onBackground: string;
onBackgroundChannel: string;
}
export interface PaletteColorChannel {
mainChannel: string;
lightChannel: string;
darkChannel: string;
contrastTextChannel: string;
}
export interface PaletteActionChannel {
activeChannel: string;
selectedChannel: string;
}
export interface PaletteTextChannel {
primaryChannel: string;
secondaryChannel: string;
}
export interface PaletteAlert {
errorColor: string;
infoColor: string;
successColor: string;
warningColor: string;
errorFilledBg: string;
infoFilledBg: string;
successFilledBg: string;
warningFilledBg: string;
errorFilledColor: string;
infoFilledColor: string;
successFilledColor: string;
warningFilledColor: string;
errorStandardBg: string;
infoStandardBg: string;
successStandardBg: string;
warningStandardBg: string;
errorIconColor: string;
infoIconColor: string;
successIconColor: string;
warningIconColor: string;
}
export interface PaletteAppBar {
defaultBg: string;
darkBg: string;
darkColor: string;
}
export interface PaletteAvatar {
defaultBg: string;
}
export interface PaletteButton {
inheritContainedBg: string;
inheritContainedHoverBg: string;
}
export interface PaletteChip {
defaultBorder: string;
defaultAvatarColor: string;
defaultIconColor: string;
}
export interface PaletteFilledInput {
bg: string;
hoverBg: string;
disabledBg: string;
}
export interface PaletteLinearProgress {
primaryBg: string;
secondaryBg: string;
errorBg: string;
infoBg: string;
successBg: string;
warningBg: string;
}
export interface PaletteSkeleton {
bg: string;
}
export interface PaletteSlider {
primaryTrack: string;
secondaryTrack: string;
errorTrack: string;
infoTrack: string;
successTrack: string;
warningTrack: string;
}
export interface PaletteSnackbarContent {
bg: string;
color: string;
}
export interface PaletteSpeedDialAction {
fabHoverBg: string;
}
export interface PaletteStepConnector {
border: string;
}
export interface PaletteStepContent {
border: string;
}
export interface PaletteSwitch {
defaultColor: string;
defaultDisabledColor: string;
primaryDisabledColor: string;
secondaryDisabledColor: string;
errorDisabledColor: string;
infoDisabledColor: string;
successDisabledColor: string;
warningDisabledColor: string;
}
export interface PaletteTableCell {
border: string;
}
export interface PaletteTooltip {
bg: string;
}
export interface Shape extends SystemShape {}
export interface ShapeOptions extends SystemShapeOptions {}
export interface ColorSystemOptions {
palette?: PaletteOptions & {
background?: Partial<PaletteBackgroundChannel>;
common?: Partial<PaletteCommonChannel>;
primary?: Partial<PaletteColorChannel>;
secondary?: Partial<PaletteColorChannel>;
error?: Partial<PaletteColorChannel>;
info?: Partial<PaletteColorChannel>;
success?: Partial<PaletteColorChannel>;
text?: Partial<PaletteTextChannel>;
dividerChannel?: Partial<string>;
action?: Partial<PaletteActionChannel>;
Alert?: Partial<PaletteAlert>;
AppBar?: Partial<PaletteAppBar>;
Avatar?: Partial<PaletteAvatar>;
Button?: Partial<PaletteButton>;
Chip?: Partial<PaletteChip>;
FilledInput?: Partial<PaletteFilledInput>;
LinearProgress?: Partial<PaletteLinearProgress>;
Skeleton?: Partial<PaletteSkeleton>;
Slider?: Partial<PaletteSlider>;
SnackbarContent?: Partial<PaletteSnackbarContent>;
SpeedDialAction?: Partial<PaletteSpeedDialAction>;
StepConnector?: Partial<PaletteStepConnector>;
StepContent?: Partial<PaletteStepContent>;
Switch?: Partial<PaletteSwitch>;
TableCell?: Partial<PaletteTableCell>;
Tooltip?: Partial<PaletteTooltip>;
};
opacity?: Partial<Opacity>;
overlays?: Overlays;
}
export interface CssVarsPalette {
common: PaletteCommonChannel;
primary: PaletteColorChannel;
secondary: PaletteColorChannel;
error: PaletteColorChannel;
info: PaletteColorChannel;
success: PaletteColorChannel;
warning: PaletteColorChannel;
text: PaletteTextChannel;
background: PaletteBackgroundChannel;
dividerChannel: string;
action: PaletteActionChannel;
Alert: PaletteAlert;
AppBar: PaletteAppBar;
Avatar: PaletteAvatar;
Button: PaletteButton;
Chip: PaletteChip;
FilledInput: PaletteFilledInput;
LinearProgress: PaletteLinearProgress;
Skeleton: PaletteSkeleton;
Slider: PaletteSlider;
SnackbarContent: PaletteSnackbarContent;
SpeedDialAction: PaletteSpeedDialAction;
StepConnector: PaletteStepConnector;
StepContent: PaletteStepContent;
Switch: PaletteSwitch;
TableCell: PaletteTableCell;
Tooltip: PaletteTooltip;
}
export interface ColorSystem {
palette: Palette & CssVarsPalette;
opacity: Opacity;
overlays: Overlays;
}
export interface ThemeVars {
font: ExtractTypographyTokens<TypographyVariants>;
palette: Omit<ColorSystem['palette'], 'colorScheme' | 'mode' | 'contrastThreshold' | 'tonalOffset' | 'getContrastText' | 'augmentColor'>;
opacity: Opacity;
overlays: Overlays;
shadows: Shadows;
shape: Shape;
spacing: string;
zIndex: ZIndex;
}
type Split<T, K extends keyof T = keyof T> = K extends string | number ? { [k in K]: Exclude<T[K], undefined> } : never;
type ConcatDeep<T> = T extends Record<string | number, infer V> ? keyof T extends string | number ? V extends string | number ? keyof T : keyof V extends string | number ? `${keyof T}-${ConcatDeep<Split<V>>}` : never : never : never;
/**
* Does not work for these cases:
* - { borderRadius: string | number } // the value can't be a union
* - { shadows: [string, string, ..., string] } // the value can't be an array
*/
type NormalizeVars<T> = ConcatDeep<Split<T>>;
export {};
export interface ThemeCssVarOverrides {}
export type ThemeCssVar = OverridableStringUnion<NormalizeVars<Omit<ThemeVars, 'overlays' | 'shadows' | 'shape'>> | 'shape-borderRadius' | 'shadows-0' | 'shadows-1' | 'shadows-2' | 'shadows-3' | 'shadows-4' | 'shadows-5' | 'shadows-6' | 'shadows-7' | 'shadows-8' | 'shadows-9' | 'shadows-10' | 'shadows-11' | 'shadows-12' | 'shadows-13' | 'shadows-14' | 'shadows-15' | 'shadows-16' | 'shadows-17' | 'shadows-18' | 'shadows-19' | 'shadows-20' | 'shadows-21' | 'shadows-22' | 'shadows-23' | 'shadows-24' | 'overlays-0' | 'overlays-1' | 'overlays-2' | 'overlays-3' | 'overlays-4' | 'overlays-5' | 'overlays-6' | 'overlays-7' | 'overlays-8' | 'overlays-9' | 'overlays-10' | 'overlays-11' | 'overlays-12' | 'overlays-13' | 'overlays-14' | 'overlays-15' | 'overlays-16' | 'overlays-17' | 'overlays-18' | 'overlays-19' | 'overlays-20' | 'overlays-21' | 'overlays-22' | 'overlays-23' | 'overlays-24', ThemeCssVarOverrides>;
/**
* Theme properties generated by extendTheme and CssVarsProvider
*/
export interface CssVarsTheme extends ColorSystem {
colorSchemes: Partial<Record<SupportedColorScheme, ColorSystem>>;
rootSelector: string;
colorSchemeSelector: 'media' | 'class' | 'data' | string;
cssVarPrefix: string;
defaultColorScheme: SupportedColorScheme;
vars: ThemeVars;
getCssVar: (field: ThemeCssVar, ...vars: ThemeCssVar[]) => string;
getColorSchemeSelector: (colorScheme: SupportedColorScheme) => string;
generateThemeVars: () => ThemeVars;
generateStyleSheets: () => Array<Record<string, any>>;
generateSpacing: () => SystemTheme['spacing'];
spacing: SystemTheme['spacing'];
breakpoints: SystemTheme['breakpoints'];
shape: Shape;
typography: TypographyVariants;
transitions: Transitions;
shadows: Shadows;
mixins: Mixins;
zIndex: ZIndex;
direction: SystemTheme['direction'];
/**
* A function to determine if the key, value should be attached as CSS Variable
* `keys` is an array that represents the object path keys.
* Ex, if the theme is { foo: { bar: 'var(--test)' } }
* then, keys = ['foo', 'bar']
* value = 'var(--test)'
*/
shouldSkipGeneratingVar: (keys: string[], value: string | number) => boolean;
unstable_sxConfig: SxConfig;
unstable_sx: (props: SxProps<CssVarsTheme>) => CSSObject;
applyStyles: ApplyStyles<SupportedColorScheme>;
}