UNPKG

3.11 kBTypeScriptView Raw
1export interface IThemingInstruction {
2 theme?: string;
3 defaultValue?: string;
4 rawString?: string;
5}
6export declare type ThemableArray = IThemingInstruction[];
7export interface ITheme {
8 [key: string]: string;
9}
10/**
11 * In sync mode, styles are registered as style elements synchronously with loadStyles() call.
12 * In async mode, styles are buffered and registered as batch in async timer for performance purpose.
13 */
14export declare const enum Mode {
15 sync = 0,
16 async = 1
17}
18/**
19 * Themable styles and non-themable styles are tracked separately
20 * Specify ClearStyleOptions when calling clearStyles API to specify which group of registered styles should be cleared.
21 */
22export declare const enum ClearStyleOptions {
23 /** only themable styles will be cleared */
24 onlyThemable = 1,
25 /** only non-themable styles will be cleared */
26 onlyNonThemable = 2,
27 /** both themable and non-themable styles will be cleared */
28 all = 3
29}
30/**
31 * Loads a set of style text. If it is registered too early, we will register it when the window.load
32 * event is fired.
33 * @param {string | ThemableArray} styles Themable style text to register.
34 * @param {boolean} loadAsync When true, always load styles in async mode, irrespective of current sync mode.
35 */
36export declare function loadStyles(styles: string | ThemableArray, loadAsync?: boolean): void;
37/**
38 * Allows for customizable loadStyles logic. e.g. for server side rendering application
39 * @param {(processedStyles: string, rawStyles?: string | ThemableArray) => void}
40 * a loadStyles callback that gets called when styles are loaded or reloaded
41 */
42export declare function configureLoadStyles(loadStylesFn: ((processedStyles: string, rawStyles?: string | ThemableArray) => void) | undefined): void;
43/**
44 * Configure run mode of load-themable-styles
45 * @param mode load-themable-styles run mode, async or sync
46 */
47export declare function configureRunMode(mode: Mode): void;
48/**
49 * external code can call flush to synchronously force processing of currently buffered styles
50 */
51export declare function flush(): void;
52/**
53 * Registers a set theme tokens to find and replace. If styles were already registered, they will be
54 * replaced.
55 * @param {theme} theme JSON object of theme tokens to values.
56 */
57export declare function loadTheme(theme: ITheme | undefined): void;
58/**
59 * Clear already registered style elements and style records in theme_State object
60 * @param option - specify which group of registered styles should be cleared.
61 * Default to be both themable and non-themable styles will be cleared
62 */
63export declare function clearStyles(option?: ClearStyleOptions): void;
64/**
65 * Find theme tokens and replaces them with provided theme values.
66 * @param {string} styles Tokenized styles to fix.
67 */
68export declare function detokenize(styles: string | undefined): string | undefined;
69/**
70 * Split tokenized CSS into an array of strings and theme specification objects
71 * @param {string} styles Tokenized styles to split.
72 */
73export declare function splitStyles(styles: string): ThemableArray;
74//# sourceMappingURL=index.d.ts.map
\No newline at end of file