zova-module-a-style 5.0.14 → 5.0.16
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 → bean.theme.ts} +6 -5
- package/src/config/config.ts +1 -0
- package/src/monkey.ts +10 -10
- package/src/resource/beans.ts +3 -3
- package/src/types.ts +2 -2
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.16",
|
|
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": "e59fa627f7bdd1f308c4bd5ae36c45ec4a2648b2"
|
|
38
38
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BeanBase, Cast, IBeanRecord
|
|
1
|
+
import { Bean, BeanBase, Cast, IBeanRecord } from 'zova';
|
|
2
2
|
import { ScopeModule } from '../resource/this.js';
|
|
3
3
|
import { ThemeBase, ThemeHandler } from '../types.js';
|
|
4
4
|
|
|
5
5
|
export type ThemeDarkMode = 'auto' | boolean;
|
|
6
6
|
|
|
7
|
-
@
|
|
8
|
-
export class
|
|
7
|
+
@Bean({ containerScope: 'app' })
|
|
8
|
+
export class BeanTheme extends BeanBase<ScopeModule> {
|
|
9
9
|
private _name: string;
|
|
10
10
|
public get name(): string {
|
|
11
11
|
return this._name;
|
|
@@ -42,8 +42,9 @@ export class StoreTheme extends BeanBase<ScopeModule> {
|
|
|
42
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
|
-
|
|
46
|
-
|
|
45
|
+
const handler = res.handler ?? this.scope.config.defaultThemeHandler;
|
|
46
|
+
if (handler) {
|
|
47
|
+
const themeHandler = (await this.bean._getBean(handler, true)) as unknown as ThemeHandler;
|
|
47
48
|
await themeHandler.apply({ name: this.name, dark: this.dark, token: this.token } as any);
|
|
48
49
|
}
|
|
49
50
|
}
|
package/src/config/config.ts
CHANGED
package/src/monkey.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { style } from 'typestyle';
|
|
2
2
|
import { BeanBase, BeanContainer, BeanSimple, IMonkeySystem, SymbolModuleName, useComputed } from 'zova';
|
|
3
3
|
import { ScopeModule, __ThisModule__ } from './resource/this.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BeanTheme } from './bean/bean.theme.js';
|
|
5
5
|
|
|
6
6
|
export class Monkey extends BeanSimple implements IMonkeySystem {
|
|
7
|
-
private
|
|
8
|
-
private
|
|
7
|
+
private _beanTheme: BeanTheme;
|
|
8
|
+
private _beanStyleDefault: any;
|
|
9
9
|
|
|
10
|
-
async appInitialize(
|
|
10
|
+
async appInitialize(_bean: BeanContainer) {}
|
|
11
|
+
async appInitialized(bean: BeanContainer) {
|
|
11
12
|
// theme
|
|
12
|
-
this.
|
|
13
|
+
this._beanTheme = await bean._getBean(BeanTheme, true);
|
|
13
14
|
// style default
|
|
14
15
|
const scope: ScopeModule = await bean.getScope(__ThisModule__);
|
|
15
|
-
this.
|
|
16
|
+
this._beanStyleDefault = await bean._getBean(scope.config.defaultStyle, true);
|
|
16
17
|
}
|
|
17
|
-
async appInitialized(_bean: BeanContainer) {}
|
|
18
18
|
async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
|
|
19
19
|
const self = this;
|
|
20
20
|
bean.defineProperty(beanInstance, '$style', {
|
|
@@ -30,21 +30,21 @@ export class Monkey extends BeanSimple implements IMonkeySystem {
|
|
|
30
30
|
enumerable: false,
|
|
31
31
|
configurable: true,
|
|
32
32
|
get() {
|
|
33
|
-
return self.
|
|
33
|
+
return self._beanStyleDefault;
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
bean.defineProperty(beanInstance, '$theme', {
|
|
37
37
|
enumerable: false,
|
|
38
38
|
configurable: true,
|
|
39
39
|
get() {
|
|
40
|
-
return self.
|
|
40
|
+
return self._beanTheme;
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
bean.defineProperty(beanInstance, '$token', {
|
|
44
44
|
enumerable: false,
|
|
45
45
|
configurable: true,
|
|
46
46
|
get() {
|
|
47
|
-
return useComputed(() => self.
|
|
47
|
+
return useComputed(() => self._beanTheme.token);
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
}
|
package/src/resource/beans.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from '../bean/
|
|
2
|
-
import {
|
|
1
|
+
export * from '../bean/bean.theme.js';
|
|
2
|
+
import { BeanTheme } from '../bean/bean.theme.js';
|
|
3
3
|
import 'zova';
|
|
4
4
|
declare module 'zova' {
|
|
5
5
|
export interface IBeanRecord {
|
|
6
|
-
'a-style.
|
|
6
|
+
'a-style.bean.theme': BeanTheme;
|
|
7
7
|
}
|
|
8
8
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { style } from 'typestyle';
|
|
2
2
|
import 'zova';
|
|
3
|
-
import {
|
|
3
|
+
import { BeanTheme } from './bean/bean.theme.js';
|
|
4
4
|
import { IBeanRecord } from 'zova';
|
|
5
5
|
declare module 'zova' {
|
|
6
6
|
export interface BeanBase {
|
|
7
7
|
$style: typeof style;
|
|
8
|
-
$theme:
|
|
8
|
+
$theme: BeanTheme;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|