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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-style",
3
- "version": "5.0.14",
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": "6e879538e3d741f0c87136ad404eb0fe90c2bd7f"
37
+ "gitHead": "e59fa627f7bdd1f308c4bd5ae36c45ec4a2648b2"
38
38
  }
@@ -1,11 +1,11 @@
1
- import { BeanBase, Cast, IBeanRecord, Store } from 'zova';
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
- @Store()
8
- export class StoreTheme extends BeanBase<ScopeModule> {
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
- if (res.handler) {
46
- const themeHandler = (await this.bean._getBean(res.handler, true)) as unknown as ThemeHandler;
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
  }
@@ -4,5 +4,6 @@ export const config = (_app: ZovaApplication) => {
4
4
  return {
5
5
  defaultStyle: 'home-style.style.default' as keyof IBeanRecord,
6
6
  defaultTheme: 'home-theme.theme.default' as keyof IBeanRecord,
7
+ defaultThemeHandler: '' as keyof IBeanRecord,
7
8
  };
8
9
  };
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 { StoreTheme } from './bean/store.theme.js';
4
+ import { BeanTheme } from './bean/bean.theme.js';
5
5
 
6
6
  export class Monkey extends BeanSimple implements IMonkeySystem {
7
- private _storeTheme: StoreTheme;
8
- private _storeStyleDefault: any;
7
+ private _beanTheme: BeanTheme;
8
+ private _beanStyleDefault: any;
9
9
 
10
- async appInitialize(bean: BeanContainer) {
10
+ async appInitialize(_bean: BeanContainer) {}
11
+ async appInitialized(bean: BeanContainer) {
11
12
  // theme
12
- this._storeTheme = await bean._getBean(StoreTheme, true);
13
+ this._beanTheme = await bean._getBean(BeanTheme, true);
13
14
  // style default
14
15
  const scope: ScopeModule = await bean.getScope(__ThisModule__);
15
- this._storeStyleDefault = await bean._getBean(scope.config.defaultStyle, true);
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._storeStyleDefault;
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._storeTheme;
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._storeTheme.token);
47
+ return useComputed(() => self._beanTheme.token);
48
48
  },
49
49
  });
50
50
  }
@@ -1,8 +1,8 @@
1
- export * from '../bean/store.theme.js';
2
- import { StoreTheme } from '../bean/store.theme.js';
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.store.theme': StoreTheme;
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 { StoreTheme } from './bean/store.theme.js';
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: StoreTheme;
8
+ $theme: BeanTheme;
9
9
  }
10
10
  }
11
11