@omnia/velcron 7.0.510-dev → 7.0.512-dev

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.
@@ -12,3 +12,4 @@ export * from "./Realtime";
12
12
  export * from "./OmniaSharedBootstrapData";
13
13
  export * from "./StringExtensions";
14
14
  export * from "./theming";
15
+ export * from "./reactivity";
@@ -16,3 +16,4 @@ tslib_1.__exportStar(require("./Realtime"), exports);
16
16
  tslib_1.__exportStar(require("./OmniaSharedBootstrapData"), exports);
17
17
  tslib_1.__exportStar(require("./StringExtensions"), exports);
18
18
  tslib_1.__exportStar(require("./theming"), exports);
19
+ tslib_1.__exportStar(require("./reactivity"), exports);
@@ -0,0 +1,5 @@
1
+ export declare class ReactivitySystem {
2
+ static makeReactive: (obj: any) => unknown;
3
+ static hasReactivityProvider: boolean;
4
+ static registerProvider(fn: (obj: any) => unknown): void;
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactivitySystem = void 0;
4
+ class ReactivitySystem {
5
+ static registerProvider(fn) {
6
+ ReactivitySystem.makeReactive = fn;
7
+ ReactivitySystem.hasReactivityProvider = true;
8
+ }
9
+ }
10
+ exports.ReactivitySystem = ReactivitySystem;
11
+ ReactivitySystem.hasReactivityProvider = false;
@@ -0,0 +1 @@
1
+ export * from "./DefineReactivity";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./DefineReactivity"), exports);
@@ -2,7 +2,7 @@ import { VelcronComponentDescriptor } from "./VelcronDescriptors";
2
2
  import { VelcronEvent, VelcronOnChangedEvent, VelcronOnClosedEvent, VelcronOnCloseRequestedEvent, VelcronOnLoadEvent, VelcronOnPressEvent } from "./VelcronEvents";
3
3
  import { VelcroncomponentArrayType, VelcronPrimitiveType } from "./VelcronTypes";
4
4
  import { AssignOperators, VelcronHorizontalAlignments, VelcronIconTypes, VelcronActionTypes, VerticalAlignments } from "./Enums";
5
- import { VelcronTheming } from "..";
5
+ import { useVelcronThemingStore } from "..";
6
6
  export interface ResolvedComponentRenderer {
7
7
  component: unknown;
8
8
  definition: VelcronDefinition;
@@ -32,7 +32,7 @@ export interface VelcronRenderContext {
32
32
  id?: string;
33
33
  rootContext: DynamicViewModel;
34
34
  currentContext: DynamicViewModel;
35
- theming?: VelcronTheming;
35
+ theming?: ReturnType<typeof useVelcronThemingStore>;
36
36
  actions?: {
37
37
  [name: string]: [];
38
38
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "7.0.510-dev",
4
+ "version": "7.0.512-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,7 +1,7 @@
1
1
  import { VelcronDefinition, VelcronRenderContext } from "../models";
2
2
  import { VelcronUnitProvider } from "../models/VelcronUnitProvider";
3
3
  export declare class VelcronStyles {
4
- static styleProvider: (baseStyles: object, definition: VelcronDefinition, renderCtx: VelcronRenderContext) => object | string;
4
+ static styleProvider: (baseStyles: object, definition: VelcronDefinition, renderCtx: VelcronRenderContext) => any;
5
5
  static unitProvider: VelcronUnitProvider;
6
6
  static registerStyleProvider(fn: (styleBase: object, definition: VelcronDefinition, renderCtx: VelcronRenderContext) => object | string, unitProvider: VelcronUnitProvider): void;
7
7
  static create(definition: VelcronDefinition, renderCtx: VelcronRenderContext): object | string;
@@ -22,10 +22,10 @@ class VelcronStyles {
22
22
  else if (definition.type === VelcronConstants_1.VelcronConstants.components.text) {
23
23
  const textDefinition = definition;
24
24
  if (textDefinition.color) {
25
- styleBase["color"] = renderCtx.theming.getColorFromActiveSchema(textDefinition.color);
25
+ styleBase["color"] = renderCtx.theming.get.colorFromActiveSchema(textDefinition.color);
26
26
  }
27
27
  else {
28
- styleBase["color"] = renderCtx.theming.activeColorSchema().onBase.color;
28
+ styleBase["color"] = renderCtx.theming.get.activeColorSchema().onBase.color;
29
29
  }
30
30
  }
31
31
  else if (definition.type === VelcronConstants_1.VelcronConstants.components.flexView) {
@@ -53,7 +53,7 @@ class VelcronStyles {
53
53
  }
54
54
  }
55
55
  if (flexViewDefinition.colorSchema && flexViewDefinition.colorSchema != "") {
56
- styleBase["backgroundColor"] = renderCtx.theming.activeColorSchema().base.color;
56
+ styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
57
57
  }
58
58
  }
59
59
  return VelcronStyles.styleProvider(styleBase, definition, renderCtx);
@@ -1,12 +1,9 @@
1
- export declare class VelcronStore {
2
- static reactivityProvider: (obj: any) => unknown;
3
- static registerReactivityProvider(fn: (obj: any) => unknown): void;
4
- state<T>(obj: T): T;
5
- mutation(fn: () => void): void;
6
- }
7
- export declare class TestStore extends VelcronStore {
8
- test: {
9
- title: string;
10
- };
11
- increment: (text: string) => string;
12
- }
1
+ export declare const defineVelcronStore: <TState, TGetters, TActions>(name: string, definition: {
2
+ state: TState;
3
+ getters: (state: TState) => TGetters;
4
+ actions: (state: TState) => TActions;
5
+ }) => () => {
6
+ state: TState;
7
+ get: TGetters;
8
+ actions: TActions;
9
+ };
@@ -1,26 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestStore = exports.VelcronStore = void 0;
4
- class VelcronStore {
5
- static registerReactivityProvider(fn) {
6
- VelcronStore.reactivityProvider = fn;
3
+ exports.defineVelcronStore = void 0;
4
+ const __1 = require("..");
5
+ const stateMap = new Map();
6
+ const defineVelcronStore = (name, definition) => {
7
+ if (!stateMap.has(name)) {
8
+ stateMap.set(name, __1.ReactivitySystem.makeReactive(definition.state));
7
9
  }
8
- state(obj) {
9
- if (!VelcronStore.reactivityProvider) {
10
- throw new Error("Reactivity creator not set");
11
- }
12
- return VelcronStore.reactivityProvider(obj);
13
- }
14
- mutation(fn) {
15
- fn();
16
- }
17
- }
18
- exports.VelcronStore = VelcronStore;
19
- class TestStore extends VelcronStore {
20
- constructor() {
21
- super(...arguments);
22
- this.test = this.state({ title: "Hello" });
23
- this.increment = (text) => this.test.title = text;
24
- }
25
- }
26
- exports.TestStore = TestStore;
10
+ const reactiveState = stateMap.get(name);
11
+ const result = () => {
12
+ return {
13
+ state: reactiveState,
14
+ get: definition.getters(reactiveState),
15
+ actions: definition.actions(reactiveState)
16
+ };
17
+ };
18
+ return result;
19
+ };
20
+ exports.defineVelcronStore = defineVelcronStore;
21
+ // export const testStore = defineVelcronStore({
22
+ // state: {
23
+ // hepp: ""
24
+ // },
25
+ // getters(state) {
26
+ // return {
27
+ // get hepp() { return state.hepp; }
28
+ // };
29
+ // },
30
+ // actions(state) {
31
+ // return {
32
+ // testMutate() {
33
+ // state.hepp = "hepp";
34
+ // }
35
+ // };
36
+ // }
37
+ // });
@@ -1,13 +1,16 @@
1
1
  import { ColorSchema, ThemeDefinitionV2, TypographyType } from "..";
2
- import { VelcronStore } from "./VelcronStore";
3
- export declare class VelcronTheming extends VelcronStore {
4
- currentTheme: ThemeDefinitionV2;
5
- private activeSchemaState;
6
- typography: (name: string) => TypographyType;
7
- activeColorSchema: () => ColorSchema;
8
- getColorFromActiveSchema: (name: any) => string;
9
- mutations: {
10
- setActiveSchema: (name: string) => void;
11
- setTheme: (newTheme: ThemeDefinitionV2) => void;
2
+ export declare const useVelcronThemingStore: () => {
3
+ state: {
4
+ currentTheme: ThemeDefinitionV2;
5
+ activeSchema: string;
12
6
  };
13
- }
7
+ get: {
8
+ activeColorSchema: () => ColorSchema;
9
+ typography: (name: string) => TypographyType;
10
+ colorFromActiveSchema: (name: string) => string;
11
+ };
12
+ actions: {
13
+ setActiveSchema(name: string): void;
14
+ setTheme(newTheme: ThemeDefinitionV2): void;
15
+ };
16
+ };
@@ -1,96 +1,190 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VelcronTheming = void 0;
3
+ exports.useVelcronThemingStore = void 0;
4
4
  const __1 = require("..");
5
5
  const VelcronStore_1 = require("./VelcronStore");
6
- class VelcronTheming extends VelcronStore_1.VelcronStore {
7
- constructor() {
8
- super(...arguments);
9
- this.currentTheme = this.state({});
10
- this.activeSchemaState = this.state("");
11
- this.typography = (name) => {
12
- if (name === __1.TypographyTypes.h1) {
13
- return this.currentTheme.typography.h1;
6
+ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("VelcronTheming", {
7
+ state: {
8
+ currentTheme: {},
9
+ activeSchema: ""
10
+ },
11
+ getters(state) {
12
+ const activeColorSchema = () => {
13
+ if (state.activeSchema === __1.ColorSchemaTypes.primary) {
14
+ return state.currentTheme?.primary;
14
15
  }
15
- else if (name === __1.TypographyTypes.h2) {
16
- return this.currentTheme.typography.h2;
16
+ else if (state.activeSchema === __1.ColorSchemaTypes.secondary) {
17
+ return state.currentTheme?.secondary;
17
18
  }
18
- else if (name === __1.TypographyTypes.h3) {
19
- return this.currentTheme.typography.h3;
19
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent1) {
20
+ return state.currentTheme?.accent1;
20
21
  }
21
- else if (name === __1.TypographyTypes.caption) {
22
- return this.currentTheme.typography.caption;
22
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent2) {
23
+ return state.currentTheme?.accent2;
23
24
  }
24
- else if (name === __1.TypographyTypes.link) {
25
- return this.currentTheme.typography.link;
25
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent3) {
26
+ return state.currentTheme?.accent3;
26
27
  }
27
- else if (name === __1.TypographyTypes.text) {
28
- return this.currentTheme.typography.text;
28
+ else if (state.activeSchema === __1.ColorSchemaTypes.background) {
29
+ return state.currentTheme?.background;
29
30
  }
30
- return this.currentTheme.typography.text;
31
- };
32
- this.activeColorSchema = () => {
33
- if (this.activeSchemaState === __1.ColorSchemaTypes.primary) {
34
- return this.currentTheme.primary;
31
+ else if (state.activeSchema === __1.ColorSchemaTypes.neutral) {
32
+ return state.currentTheme?.neutral;
35
33
  }
36
- else if (this.activeSchemaState === __1.ColorSchemaTypes.secondary) {
37
- return this.currentTheme.secondary;
34
+ else if (state.activeSchema === __1.ColorSchemaTypes.error) {
35
+ return state.currentTheme?.error;
38
36
  }
39
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent1) {
40
- return this.currentTheme.accent1;
37
+ return state.currentTheme?.background;
38
+ };
39
+ const typography = (name) => {
40
+ if (name === __1.TypographyTypes.h1) {
41
+ return state.currentTheme.typography.h1;
41
42
  }
42
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent2) {
43
- return this.currentTheme.accent2;
43
+ else if (name === __1.TypographyTypes.h2) {
44
+ return state.currentTheme.typography.h2;
44
45
  }
45
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent3) {
46
- return this.currentTheme.accent3;
46
+ else if (name === __1.TypographyTypes.h3) {
47
+ return state.currentTheme.typography.h3;
47
48
  }
48
- else if (this.activeSchemaState === __1.ColorSchemaTypes.background) {
49
- return this.currentTheme.background;
49
+ else if (name === __1.TypographyTypes.caption) {
50
+ return state.currentTheme.typography.caption;
50
51
  }
51
- else if (this.activeSchemaState === __1.ColorSchemaTypes.neutral) {
52
- return this.currentTheme.neutral;
52
+ else if (name === __1.TypographyTypes.link) {
53
+ return state.currentTheme.typography.link;
53
54
  }
54
- else if (this.activeSchemaState === __1.ColorSchemaTypes.error) {
55
- return this.currentTheme.error;
55
+ else if (name === __1.TypographyTypes.text) {
56
+ return state.currentTheme.typography.text;
56
57
  }
57
- return this.currentTheme.background;
58
+ return state.currentTheme.typography.text;
58
59
  };
59
- this.getColorFromActiveSchema = (name) => {
60
+ const colorFromActiveSchema = (name) => {
60
61
  if (name === __1.ColorTypes.base) {
61
- return this.activeColorSchema().base.color;
62
+ return activeColorSchema().base.color;
62
63
  }
63
64
  else if (name === __1.ColorTypes.baseTone) {
64
- return this.activeColorSchema().base.colorToned;
65
+ return activeColorSchema().base.colorToned;
65
66
  }
66
67
  else if (name === __1.ColorTypes.onBase) {
67
- return this.activeColorSchema().onBase.color;
68
+ return activeColorSchema().onBase.color;
68
69
  }
69
70
  else if (name === __1.ColorTypes.onBaseTone) {
70
- return this.activeColorSchema().onBase.colorToned;
71
+ return activeColorSchema().onBase.colorToned;
71
72
  }
72
73
  else if (name === __1.ColorTypes.container) {
73
- return this.activeColorSchema().container.color;
74
+ return activeColorSchema().container.color;
74
75
  }
75
76
  else if (name === __1.ColorTypes.containerTone) {
76
- return this.activeColorSchema().container.colorToned;
77
+ return activeColorSchema().container.colorToned;
77
78
  }
78
79
  else if (name === __1.ColorTypes.onContainer) {
79
- return this.activeColorSchema().onContainer.color;
80
+ return activeColorSchema().onContainer.color;
80
81
  }
81
82
  else if (name === __1.ColorTypes.onContainerTone) {
82
- return this.activeColorSchema().onContainer.colorToned;
83
+ return activeColorSchema().onContainer.colorToned;
83
84
  }
84
85
  return name;
85
86
  };
86
- this.mutations = {
87
- setActiveSchema: (name) => {
88
- this.activeSchemaState = name;
87
+ return {
88
+ activeColorSchema,
89
+ typography,
90
+ colorFromActiveSchema
91
+ };
92
+ },
93
+ actions(state) {
94
+ return {
95
+ setActiveSchema(name) {
96
+ state.activeSchema = name;
89
97
  },
90
- setTheme: (newTheme) => {
91
- this.currentTheme = newTheme;
98
+ setTheme(newTheme) {
99
+ state.currentTheme = newTheme;
92
100
  }
93
101
  };
94
102
  }
95
- }
96
- exports.VelcronTheming = VelcronTheming;
103
+ });
104
+ // export class VelcronTheming extends VelcronStore {
105
+ // // public currentTheme = this.state({} as ThemeDefinitionV2);
106
+ // // private activeSchemaState = this.state("" as string);
107
+ // typography = (name: string): TypographyType => {
108
+ // if (name === TypographyTypes.h1) {
109
+ // return this.currentTheme.typography.h1;
110
+ // }
111
+ // else if (name === TypographyTypes.h2) {
112
+ // return this.currentTheme.typography.h2;
113
+ // }
114
+ // else if (name === TypographyTypes.h3) {
115
+ // return this.currentTheme.typography.h3;
116
+ // }
117
+ // else if (name === TypographyTypes.caption) {
118
+ // return this.currentTheme.typography.caption;
119
+ // }
120
+ // else if (name === TypographyTypes.link) {
121
+ // return this.currentTheme.typography.link;
122
+ // }
123
+ // else if (name === TypographyTypes.text) {
124
+ // return this.currentTheme.typography.text;
125
+ // }
126
+ // return this.currentTheme.typography.text;
127
+ // };
128
+ // activeColorSchema = (): ColorSchema => {
129
+ // if (this.activeSchemaState === ColorSchemaTypes.primary) {
130
+ // return this.currentTheme.primary;
131
+ // }
132
+ // else if (this.activeSchemaState === ColorSchemaTypes.secondary) {
133
+ // return this.currentTheme.secondary;
134
+ // }
135
+ // else if (this.activeSchemaState === ColorSchemaTypes.accent1) {
136
+ // return this.currentTheme.accent1;
137
+ // }
138
+ // else if (this.activeSchemaState === ColorSchemaTypes.accent2) {
139
+ // return this.currentTheme.accent2;
140
+ // }
141
+ // else if (this.activeSchemaState=== ColorSchemaTypes.accent3) {
142
+ // return this.currentTheme.accent3;
143
+ // }
144
+ // else if (this.activeSchemaState === ColorSchemaTypes.background) {
145
+ // return this.currentTheme.background;
146
+ // }
147
+ // else if (this.activeSchemaState === ColorSchemaTypes.neutral) {
148
+ // return this.currentTheme.neutral;
149
+ // }
150
+ // else if (this.activeSchemaState === ColorSchemaTypes.error) {
151
+ // return this.currentTheme.error;
152
+ // }
153
+ // return this.currentTheme.background;
154
+ // };
155
+ // getColorFromActiveSchema = (name):string => {
156
+ // if (name === ColorTypes.base) {
157
+ // return this.activeColorSchema().base.color;
158
+ // }
159
+ // else if (name === ColorTypes.baseTone) {
160
+ // return this.activeColorSchema().base.colorToned;
161
+ // }
162
+ // else if (name === ColorTypes.onBase) {
163
+ // return this.activeColorSchema().onBase.color;
164
+ // }
165
+ // else if (name === ColorTypes.onBaseTone) {
166
+ // return this.activeColorSchema().onBase.colorToned;
167
+ // }
168
+ // else if (name === ColorTypes.container) {
169
+ // return this.activeColorSchema().container.color;
170
+ // }
171
+ // else if (name === ColorTypes.containerTone) {
172
+ // return this.activeColorSchema().container.colorToned;
173
+ // }
174
+ // else if (name === ColorTypes.onContainer) {
175
+ // return this.activeColorSchema().onContainer.color;
176
+ // }
177
+ // else if (name === ColorTypes.onContainerTone) {
178
+ // return this.activeColorSchema().onContainer.colorToned;
179
+ // }
180
+ // return name;
181
+ // };
182
+ // mutations = {
183
+ // setActiveSchema: (name: string) => {
184
+ // this.activeSchemaState = name;
185
+ // },
186
+ // setTheme: (newTheme: ThemeDefinitionV2) => {
187
+ // this.currentTheme = newTheme;
188
+ // }
189
+ // };
190
+ // }