zova-module-a-style 5.0.8 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/bean/store.theme.ts +6 -2
- package/src/types.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-style",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"title": "a-style",
|
|
5
5
|
"zovaModule": {
|
|
6
6
|
"capabilities": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"tsc:publish": "npm run clean && tsc -b",
|
|
35
35
|
"prepublishOnly": "npm run tsc:publish"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "1c586ea11b3ca5eba665522e25adcb26b4eecd12"
|
|
38
38
|
}
|
package/src/bean/store.theme.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BeanBase, Cast, IBeanRecord, Store } from 'zova';
|
|
2
2
|
import { ScopeModule } from '../resource/this.js';
|
|
3
|
-
import { ThemeBase } from '../types.js';
|
|
3
|
+
import { ThemeBase, ThemeHandler } from '../types.js';
|
|
4
4
|
|
|
5
5
|
export type ThemeDarkMode = 'auto' | boolean;
|
|
6
6
|
|
|
@@ -39,9 +39,13 @@ export class StoreTheme extends BeanBase<ScopeModule> {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async applyTheme() {
|
|
42
|
-
const theme = (await this.bean._getBean(this.name, true)) as ThemeBase;
|
|
42
|
+
const theme = (await this.bean._getBean(this.name as any, true)) as ThemeBase;
|
|
43
43
|
const res = await theme.apply({ name: this.name, dark: this.dark });
|
|
44
44
|
this.token = Cast(res).token;
|
|
45
|
+
if (res.handler) {
|
|
46
|
+
const themeHandler = (await this.bean._getBean(res.handler, true)) as unknown as ThemeHandler;
|
|
47
|
+
await themeHandler.apply(res);
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
async setTheme(name?: keyof IBeanRecord) {
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { style } from 'typestyle';
|
|
2
2
|
import 'zova';
|
|
3
3
|
import { StoreTheme } from './bean/store.theme.js';
|
|
4
|
+
import { IBeanRecord } from 'zova';
|
|
4
5
|
declare module 'zova' {
|
|
5
6
|
export interface BeanBase {
|
|
6
7
|
$style: typeof style;
|
|
@@ -13,8 +14,14 @@ export interface ThemeApplyParams {
|
|
|
13
14
|
dark: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export interface ThemeApplyResult {
|
|
17
|
+
export interface ThemeApplyResult {
|
|
18
|
+
handler?: keyof IBeanRecord;
|
|
19
|
+
}
|
|
17
20
|
|
|
18
21
|
export interface ThemeBase {
|
|
19
22
|
apply({ name, dark }: ThemeApplyParams): Promise<ThemeApplyResult>;
|
|
20
23
|
}
|
|
24
|
+
|
|
25
|
+
export interface ThemeHandler {
|
|
26
|
+
apply(result: ThemeApplyResult): Promise<void>;
|
|
27
|
+
}
|