|
1 | | -// /* eslint-disable sort-imports */ |
2 | | -// import { extend, getIgnoreCase } from './tools/helper'; |
3 | | -// import darkTheme from './themes/DARK'; |
4 | | -// import brightTheme from './themes/BRIGHT'; |
5 | | -// import arcoTheme from './themes/ARCO'; |
6 | | -// import defaultTheme from './themes/DEFAULT'; |
7 | | -// import materialDesignTheme from './themes/SIMPLIFY'; |
8 | | -// import { themes as plugins } from './plugins/themes'; |
9 | | -// import { TableTheme } from './themes/theme'; |
10 | | -// import type { ITableThemeDefine } from './ts-types'; |
11 | | -// export const DARK = new TableTheme(darkTheme, darkTheme); |
12 | | -// export const BRIGHT = new TableTheme(brightTheme, brightTheme); |
13 | | -// export const ARCO = new TableTheme(arcoTheme, arcoTheme); |
14 | | -// export const DEFAULT = new TableTheme(defaultTheme, defaultTheme); |
15 | | -// export const SIMPLIFY = new TableTheme(materialDesignTheme, materialDesignTheme); |
| 1 | +/* eslint-disable sort-imports */ |
| 2 | +import { extend, getIgnoreCase } from './tools/helper'; |
| 3 | +import { TableTheme } from './themes/theme-define'; |
| 4 | +import ganttSimplifyTheme from './themes/SIMPLIFY'; |
| 5 | +import arcoTheme from './themes/ARCO'; |
| 6 | +import darkTheme from './themes/DARK'; |
| 7 | +import defaultTheme from './themes/DEFAULT'; |
| 8 | +import brightTheme from './themes/BRIGHT'; |
16 | 9 |
|
17 | | -// const builtin: { [key: string]: TableTheme } = { |
18 | | -// DEFAULT, |
19 | | -// SIMPLIFY, |
20 | | -// ARCO, |
21 | | -// DARK, |
22 | | -// BRIGHT |
23 | | -// }; |
24 | | -// // let defTheme = DEFAULT; |
25 | | -// export const theme = { TableTheme }; |
26 | | -// export function of(value: ITableThemeDefine | string | undefined | null): TableTheme | null { |
27 | | -// if (!value) { |
28 | | -// return null; |
29 | | -// } |
30 | | -// if (typeof value === 'string') { |
31 | | -// const t = getIgnoreCase(get(), value); |
32 | | -// if (t) { |
33 | | -// if (t instanceof TableTheme) { |
34 | | -// return t; |
35 | | -// } |
36 | | -// return new TableTheme(t, t); |
37 | | -// } |
38 | | -// return null; |
39 | | -// } |
40 | | -// if (value instanceof TableTheme) { |
41 | | -// return value; |
42 | | -// } |
43 | | -// return new TableTheme(value, value); |
44 | | -// } |
| 10 | +export const SIMPLIFY = new TableTheme(ganttSimplifyTheme, ganttSimplifyTheme); |
| 11 | +export const ARCO = new TableTheme(arcoTheme, arcoTheme); |
| 12 | +export const DARK = new TableTheme(darkTheme, darkTheme); |
| 13 | +export const DEFAULT = new TableTheme(defaultTheme, defaultTheme); |
| 14 | +export const BRIGHT = new TableTheme(brightTheme, brightTheme); |
45 | 15 |
|
46 | | -// export function get(): { [key: string]: TableTheme } { |
47 | | -// return extend(builtin, plugins); |
48 | | -// } |
49 | | -// export { ITableThemeDefine }; |
50 | | -// export default { |
51 | | -// DARK, |
52 | | -// BRIGHT, |
53 | | -// ARCO, |
54 | | -// DEFAULT, |
55 | | -// SIMPLIFY, |
56 | | -// theme, |
57 | | -// of, |
58 | | -// get |
59 | | -// }; |
| 16 | +const builtin: { [key: string]: TableTheme } = { |
| 17 | + SIMPLIFY, |
| 18 | + ARCO, |
| 19 | + DARK, |
| 20 | + DEFAULT, |
| 21 | + BRIGHT |
| 22 | +}; |
| 23 | + |
| 24 | +export const theme = { TableTheme }; |
| 25 | + |
| 26 | +export function of(value: any | string | undefined | null): TableTheme | null { |
| 27 | + if (!value) { |
| 28 | + return null; |
| 29 | + } |
| 30 | + if (typeof value === 'string') { |
| 31 | + const t = getIgnoreCase(get(), value); |
| 32 | + if (t) { |
| 33 | + if (t instanceof TableTheme) { |
| 34 | + return t; |
| 35 | + } |
| 36 | + return new TableTheme(t, t); |
| 37 | + } |
| 38 | + return null; |
| 39 | + } |
| 40 | + if (value instanceof TableTheme) { |
| 41 | + return value; |
| 42 | + } |
| 43 | + return new TableTheme(value, value); |
| 44 | +} |
| 45 | + |
| 46 | +export function get(): { [key: string]: TableTheme } { |
| 47 | + // 这里可以扩展插件主题 |
| 48 | + return extend(builtin, {}); |
| 49 | +} |
| 50 | + |
| 51 | +export default { |
| 52 | + SIMPLIFY, |
| 53 | + theme, |
| 54 | + of, |
| 55 | + get |
| 56 | +}; |
0 commit comments