@omnia/velcron 7.0.509-dev → 7.0.511-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 { useVelcronTheming } 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?: typeof useVelcronTheming;
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.509-dev",
4
+ "version": "7.0.511-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -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>(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,30 @@
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;
7
- }
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;
3
+ exports.defineVelcronStore = void 0;
4
+ const __1 = require("..");
5
+ const defineVelcronStore = (definition) => {
6
+ definition.state = __1.ReactivitySystem.makeReactive(definition.state);
7
+ return {
8
+ state: definition.state,
9
+ get: definition.getters(definition.state),
10
+ actions: definition.actions(definition.state)
11
+ };
12
+ };
13
+ exports.defineVelcronStore = defineVelcronStore;
14
+ // export const testStore = defineVelcronStore({
15
+ // state: {
16
+ // hepp: ""
17
+ // },
18
+ // getters(state) {
19
+ // return {
20
+ // get hepp() { return state.hepp; }
21
+ // };
22
+ // },
23
+ // actions(state) {
24
+ // return {
25
+ // testMutate() {
26
+ // state.hepp = "hepp";
27
+ // }
28
+ // };
29
+ // }
30
+ // });
@@ -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 useVelcronTheming: {
3
+ state: {
4
+ currentTheme: ThemeDefinitionV2;
5
+ activeSchema: string;
12
6
  };
13
- }
7
+ get: {
8
+ typography(name: string): TypographyType;
9
+ colorFromActiveSchema(name: string): string;
10
+ activeColorSchema(): ColorSchema;
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.useVelcronTheming = 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.useVelcronTheming = (0, VelcronStore_1.defineVelcronStore)({
7
+ state: {
8
+ currentTheme: {},
9
+ activeSchema: ""
10
+ },
11
+ getters(state) {
12
+ const local = {
13
+ activeColorSchema() {
14
+ if (state.activeSchema === __1.ColorSchemaTypes.primary) {
15
+ return state.currentTheme?.primary;
16
+ }
17
+ else if (state.activeSchema === __1.ColorSchemaTypes.secondary) {
18
+ return state.currentTheme?.secondary;
19
+ }
20
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent1) {
21
+ return state.currentTheme?.accent1;
22
+ }
23
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent2) {
24
+ return state.currentTheme?.accent2;
25
+ }
26
+ else if (state.activeSchema === __1.ColorSchemaTypes.accent3) {
27
+ return state.currentTheme?.accent3;
28
+ }
29
+ else if (state.activeSchema === __1.ColorSchemaTypes.background) {
30
+ return state.currentTheme?.background;
31
+ }
32
+ else if (state.activeSchema === __1.ColorSchemaTypes.neutral) {
33
+ return state.currentTheme?.neutral;
34
+ }
35
+ else if (state.activeSchema === __1.ColorSchemaTypes.error) {
36
+ return state.currentTheme?.error;
37
+ }
38
+ return state.currentTheme?.background;
14
39
  }
15
- else if (name === __1.TypographyTypes.h2) {
16
- return this.currentTheme.typography.h2;
17
- }
18
- else if (name === __1.TypographyTypes.h3) {
19
- return this.currentTheme.typography.h3;
20
- }
21
- else if (name === __1.TypographyTypes.caption) {
22
- return this.currentTheme.typography.caption;
23
- }
24
- else if (name === __1.TypographyTypes.link) {
25
- return this.currentTheme.typography.link;
26
- }
27
- else if (name === __1.TypographyTypes.text) {
28
- return this.currentTheme.typography.text;
29
- }
30
- return this.currentTheme.typography.text;
31
- };
32
- this.activeColorSchema = () => {
33
- if (this.activeSchemaState === __1.ColorSchemaTypes.primary) {
34
- return this.currentTheme.primary;
35
- }
36
- else if (this.activeSchemaState === __1.ColorSchemaTypes.secondary) {
37
- return this.currentTheme.secondary;
38
- }
39
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent1) {
40
- return this.currentTheme.accent1;
41
- }
42
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent2) {
43
- return this.currentTheme.accent2;
44
- }
45
- else if (this.activeSchemaState === __1.ColorSchemaTypes.accent3) {
46
- return this.currentTheme.accent3;
47
- }
48
- else if (this.activeSchemaState === __1.ColorSchemaTypes.background) {
49
- return this.currentTheme.background;
50
- }
51
- else if (this.activeSchemaState === __1.ColorSchemaTypes.neutral) {
52
- return this.currentTheme.neutral;
53
- }
54
- else if (this.activeSchemaState === __1.ColorSchemaTypes.error) {
55
- return this.currentTheme.error;
56
- }
57
- return this.currentTheme.background;
58
40
  };
59
- this.getColorFromActiveSchema = (name) => {
60
- if (name === __1.ColorTypes.base) {
61
- return this.activeColorSchema().base.color;
62
- }
63
- else if (name === __1.ColorTypes.baseTone) {
64
- return this.activeColorSchema().base.colorToned;
65
- }
66
- else if (name === __1.ColorTypes.onBase) {
67
- return this.activeColorSchema().onBase.color;
68
- }
69
- else if (name === __1.ColorTypes.onBaseTone) {
70
- return this.activeColorSchema().onBase.colorToned;
71
- }
72
- else if (name === __1.ColorTypes.container) {
73
- return this.activeColorSchema().container.color;
74
- }
75
- else if (name === __1.ColorTypes.containerTone) {
76
- return this.activeColorSchema().container.colorToned;
77
- }
78
- else if (name === __1.ColorTypes.onContainer) {
79
- return this.activeColorSchema().onContainer.color;
80
- }
81
- else if (name === __1.ColorTypes.onContainerTone) {
82
- return this.activeColorSchema().onContainer.colorToned;
41
+ return {
42
+ ...local,
43
+ typography(name) {
44
+ if (name === __1.TypographyTypes.h1) {
45
+ return state.currentTheme.typography.h1;
46
+ }
47
+ else if (name === __1.TypographyTypes.h2) {
48
+ return state.currentTheme.typography.h2;
49
+ }
50
+ else if (name === __1.TypographyTypes.h3) {
51
+ return state.currentTheme.typography.h3;
52
+ }
53
+ else if (name === __1.TypographyTypes.caption) {
54
+ return state.currentTheme.typography.caption;
55
+ }
56
+ else if (name === __1.TypographyTypes.link) {
57
+ return state.currentTheme.typography.link;
58
+ }
59
+ else if (name === __1.TypographyTypes.text) {
60
+ return state.currentTheme.typography.text;
61
+ }
62
+ return state.currentTheme.typography.text;
63
+ },
64
+ colorFromActiveSchema(name) {
65
+ if (name === __1.ColorTypes.base) {
66
+ return local.activeColorSchema().base.color;
67
+ }
68
+ else if (name === __1.ColorTypes.baseTone) {
69
+ return local.activeColorSchema().base.colorToned;
70
+ }
71
+ else if (name === __1.ColorTypes.onBase) {
72
+ return local.activeColorSchema().onBase.color;
73
+ }
74
+ else if (name === __1.ColorTypes.onBaseTone) {
75
+ return local.activeColorSchema().onBase.colorToned;
76
+ }
77
+ else if (name === __1.ColorTypes.container) {
78
+ return local.activeColorSchema().container.color;
79
+ }
80
+ else if (name === __1.ColorTypes.containerTone) {
81
+ return local.activeColorSchema().container.colorToned;
82
+ }
83
+ else if (name === __1.ColorTypes.onContainer) {
84
+ return local.activeColorSchema().onContainer.color;
85
+ }
86
+ else if (name === __1.ColorTypes.onContainerTone) {
87
+ return local.activeColorSchema().onContainer.colorToned;
88
+ }
89
+ return name;
83
90
  }
84
- return name;
85
91
  };
86
- this.mutations = {
87
- setActiveSchema: (name) => {
88
- this.activeSchemaState = name;
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
+ // }