@omnia/velcron 7.0.514-dev → 7.0.515-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.
- package/models/VelcronDefinitions.d.ts +7 -3
- package/package.json +1 -1
- package/parser/VelcronRenderers.d.ts +27 -1
- package/parser/VelcronRenderers.js +29 -10
- package/parser/VelcronStyles.js +4 -3
- package/stores/VelcronStore.d.ts +6 -6
- package/stores/VelcronStore.js +14 -2
- package/stores/VelcronTheming.d.ts +7 -7
- package/stores/VelcronTheming.js +21 -28
|
@@ -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 { useVelcronThemingStore } from "..";
|
|
5
|
+
import { ColorSchema, useVelcronThemingStore } from "..";
|
|
6
6
|
export interface ResolvedComponentRenderer {
|
|
7
7
|
component: unknown;
|
|
8
8
|
definition: VelcronDefinition;
|
|
@@ -33,6 +33,8 @@ export interface VelcronRenderContext {
|
|
|
33
33
|
rootContext: DynamicViewModel;
|
|
34
34
|
currentContext: DynamicViewModel;
|
|
35
35
|
theming?: ReturnType<typeof useVelcronThemingStore>;
|
|
36
|
+
colorSchemaName?: string;
|
|
37
|
+
colorSchema?: ColorSchema;
|
|
36
38
|
actions?: {
|
|
37
39
|
[name: string]: [];
|
|
38
40
|
};
|
|
@@ -91,6 +93,9 @@ export interface VelcronDefinitionBase {
|
|
|
91
93
|
*/
|
|
92
94
|
key?: string;
|
|
93
95
|
}
|
|
96
|
+
export interface VelcronCustomThemeSettings {
|
|
97
|
+
colorSchema?: string;
|
|
98
|
+
}
|
|
94
99
|
export interface VelcronDefinition extends VelcronDefinitionBase {
|
|
95
100
|
body?: Array<VelcronDefinition>;
|
|
96
101
|
style?: VelcronStyling;
|
|
@@ -202,7 +207,7 @@ export interface VelcronIconDefinition extends VelcronDefinition {
|
|
|
202
207
|
size?: number;
|
|
203
208
|
events?: VelcronOnPressEvent;
|
|
204
209
|
}
|
|
205
|
-
export interface VelcronFlexViewDefinition extends VelcronDefinition {
|
|
210
|
+
export interface VelcronFlexViewDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
|
|
206
211
|
type: "FlexView";
|
|
207
212
|
column?: boolean;
|
|
208
213
|
body: Array<VelcronDefinition>;
|
|
@@ -212,7 +217,6 @@ export interface VelcronFlexViewDefinition extends VelcronDefinition {
|
|
|
212
217
|
grow?: number;
|
|
213
218
|
border?: VelcronBorder;
|
|
214
219
|
borderRadius?: VelcronDimensions;
|
|
215
|
-
colorSchema?: string;
|
|
216
220
|
width: string;
|
|
217
221
|
}
|
|
218
222
|
export interface VelcronDimensions {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuiltInComponentRenderers, DynamicViewModel, ResolvedComponentRenderer, VelcronDefinition, VelcronRenderContext } from "../models";
|
|
1
|
+
import { BuiltInComponentRenderers, DynamicViewModel, ResolvedComponentRenderer, VelcronCustomComponentDefinition, VelcronDefinition, VelcronRenderContext } from "../models";
|
|
2
2
|
export declare class VelcronRenderers {
|
|
3
3
|
private static components;
|
|
4
4
|
static registerComponent(type: string, component: any): void;
|
|
@@ -6,5 +6,31 @@ export declare class VelcronRenderers {
|
|
|
6
6
|
static hasComponent(type: string): any;
|
|
7
7
|
static registerComponents(components: BuiltInComponentRenderers): void;
|
|
8
8
|
static getComponent(definition: VelcronDefinition, renderContext: VelcronRenderContext): ResolvedComponentRenderer;
|
|
9
|
+
static definitionContainsCustomColorSchema(definition: VelcronDefinition): boolean;
|
|
10
|
+
static createNewRendererContext(currentRenderCtx: VelcronRenderContext, definition: VelcronDefinition, newViewModel?: DynamicViewModel): {
|
|
11
|
+
rootContext: object;
|
|
12
|
+
theming: {
|
|
13
|
+
state: {
|
|
14
|
+
currentTheme: import("@omnia/fx-models").ThemeDefinitionV2;
|
|
15
|
+
};
|
|
16
|
+
get: {
|
|
17
|
+
colorSchema: (schema: string) => import("@omnia/fx-models").ColorSchema;
|
|
18
|
+
typography: (name: string) => import("@omnia/fx-models").TypographyType;
|
|
19
|
+
color: (schemaName: string, colorType: string) => string;
|
|
20
|
+
};
|
|
21
|
+
actions: {
|
|
22
|
+
setTheme(newTheme: import("@omnia/fx-models").ThemeDefinitionV2): void;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
currentContext: object;
|
|
26
|
+
actions: {
|
|
27
|
+
[name: string]: [];
|
|
28
|
+
};
|
|
29
|
+
components: VelcronCustomComponentDefinition[];
|
|
30
|
+
hooks: import("../models").VelcronRenderContextHooks;
|
|
31
|
+
computed: {
|
|
32
|
+
[name: string]: [];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
9
35
|
static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?: DynamicViewModel): VelcronRenderContext;
|
|
10
36
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VelcronRenderers = void 0;
|
|
4
4
|
const VelcronLogger_1 = require("./VelcronLogger");
|
|
5
5
|
const VelcronData_1 = require("./VelcronData");
|
|
6
|
+
const stores_1 = require("../stores");
|
|
6
7
|
class VelcronRenderers {
|
|
7
8
|
static registerComponent(type, component) {
|
|
8
9
|
type = type.toLowerCase();
|
|
@@ -59,19 +60,37 @@ class VelcronRenderers {
|
|
|
59
60
|
}
|
|
60
61
|
return result;
|
|
61
62
|
}
|
|
63
|
+
static definitionContainsCustomColorSchema(definition) {
|
|
64
|
+
return (definition.colorSchema && definition.colorSchema !== "");
|
|
65
|
+
}
|
|
66
|
+
static createNewRendererContext(currentRenderCtx, definition, newViewModel) {
|
|
67
|
+
const result = {
|
|
68
|
+
rootContext: currentRenderCtx.rootContext,
|
|
69
|
+
theming: currentRenderCtx.theming,
|
|
70
|
+
currentContext: newViewModel ? newViewModel : currentRenderCtx.currentContext,
|
|
71
|
+
actions: currentRenderCtx.actions,
|
|
72
|
+
components: currentRenderCtx.components,
|
|
73
|
+
hooks: currentRenderCtx.hooks,
|
|
74
|
+
computed: currentRenderCtx.computed,
|
|
75
|
+
};
|
|
76
|
+
if (VelcronRenderers.definitionContainsCustomColorSchema(definition)) {
|
|
77
|
+
const schema = VelcronData_1.VelcronData.dataBind(result, definition.colorSchema);
|
|
78
|
+
result.colorSchemaName = stores_1.ReactivitySystem.makeReactive(schema);
|
|
79
|
+
result.colorSchema = result.theming.get.colorSchema(result.colorSchemaName);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
result.colorSchemaName = currentRenderCtx.colorSchemaName;
|
|
83
|
+
result.colorSchema = currentRenderCtx.colorSchema;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
62
87
|
static ensureRenderContext(rendererInfo, definition, currentRenderCtx, newViewModel) {
|
|
63
88
|
//Ensure we have the correct render context passing properties etc to sub components
|
|
64
89
|
let result = currentRenderCtx;
|
|
65
|
-
if (rendererInfo.customComponent
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
currentContext: newViewModel ? newViewModel : currentRenderCtx.currentContext,
|
|
70
|
-
actions: currentRenderCtx.actions,
|
|
71
|
-
components: currentRenderCtx.components,
|
|
72
|
-
hooks: currentRenderCtx.hooks,
|
|
73
|
-
computed: currentRenderCtx.computed
|
|
74
|
-
};
|
|
90
|
+
if (rendererInfo.customComponent
|
|
91
|
+
|| newViewModel ||
|
|
92
|
+
VelcronRenderers.definitionContainsCustomColorSchema(definition)) {
|
|
93
|
+
result = VelcronRenderers.createNewRendererContext(currentRenderCtx, definition, newViewModel);
|
|
75
94
|
if (rendererInfo.customComponent) {
|
|
76
95
|
//Fetch the custom component definition
|
|
77
96
|
const customDef = rendererInfo.definition;
|
package/parser/VelcronStyles.js
CHANGED
|
@@ -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.get.
|
|
25
|
+
styleBase["color"] = renderCtx.theming.get.color(renderCtx.colorSchemaName, textDefinition.color);
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
styleBase["color"] = renderCtx.
|
|
28
|
+
styleBase["color"] = renderCtx.colorSchema.onBase.color;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
else if (definition.type === VelcronConstants_1.VelcronConstants.components.flexView) {
|
|
@@ -53,7 +53,8 @@ class VelcronStyles {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (flexViewDefinition.colorSchema && flexViewDefinition.colorSchema != "") {
|
|
56
|
-
styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
|
|
56
|
+
//styleBase["backgroundColor"] = renderCtx.theming.get.activeColorSchema().base.color;
|
|
57
|
+
styleBase["backgroundColor"] = renderCtx.colorSchema.base.color;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
return VelcronStyles.styleProvider(styleBase, definition, renderCtx);
|
package/stores/VelcronStore.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export declare const defineVelcronStore: <
|
|
1
|
+
export declare const defineVelcronStore: <TSetup extends {
|
|
2
2
|
state: object;
|
|
3
3
|
privateState?: object;
|
|
4
4
|
}, TGetters, TActions>(name: string, definition: {
|
|
5
|
-
|
|
6
|
-
getters
|
|
7
|
-
actions
|
|
8
|
-
}) => () => {
|
|
9
|
-
state:
|
|
5
|
+
setup: () => TSetup;
|
|
6
|
+
getters?: (state: TSetup["state"], privateState?: TSetup["privateState"]) => TGetters;
|
|
7
|
+
actions?: (state: TSetup["state"], privateState?: TSetup["privateState"]) => TActions;
|
|
8
|
+
}) => (newStateWithName?: string) => {
|
|
9
|
+
state: TSetup["state"];
|
|
10
10
|
get: TGetters;
|
|
11
11
|
actions: TActions;
|
|
12
12
|
};
|
package/stores/VelcronStore.js
CHANGED
|
@@ -4,9 +4,12 @@ exports.defineVelcronStore = void 0;
|
|
|
4
4
|
const ReactivitySystem_1 = require("./ReactivitySystem");
|
|
5
5
|
const stateMap = new Map();
|
|
6
6
|
const defineVelcronStore = (name, definition) => {
|
|
7
|
-
const result = () => {
|
|
7
|
+
const result = (newStateWithName) => {
|
|
8
|
+
if (newStateWithName && newStateWithName !== "" && newStateWithName !== name) {
|
|
9
|
+
name = newStateWithName;
|
|
10
|
+
}
|
|
8
11
|
if (!stateMap.has(name)) {
|
|
9
|
-
stateMap.set(name, ReactivitySystem_1.ReactivitySystem.makeReactive(definition.
|
|
12
|
+
stateMap.set(name, ReactivitySystem_1.ReactivitySystem.makeReactive(definition.setup()));
|
|
10
13
|
}
|
|
11
14
|
const reactiveState = stateMap.get(name);
|
|
12
15
|
return {
|
|
@@ -18,3 +21,12 @@ const defineVelcronStore = (name, definition) => {
|
|
|
18
21
|
return result;
|
|
19
22
|
};
|
|
20
23
|
exports.defineVelcronStore = defineVelcronStore;
|
|
24
|
+
const pelle = (0, exports.defineVelcronStore)("pelle", {
|
|
25
|
+
setup() {
|
|
26
|
+
return {
|
|
27
|
+
state: {
|
|
28
|
+
test: "Hello"
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useVelcronThemingStore: () => {
|
|
3
|
-
state:
|
|
1
|
+
import { ThemeDefinitionV2, TypographyType } from "..";
|
|
2
|
+
export declare const useVelcronThemingStore: (newStateWithName?: string) => {
|
|
3
|
+
state: {
|
|
4
|
+
currentTheme: ThemeDefinitionV2;
|
|
5
|
+
};
|
|
4
6
|
get: {
|
|
5
|
-
|
|
6
|
-
colorSchema: (schema: string) => ColorSchema;
|
|
7
|
+
colorSchema: (schema: string) => import("..").ColorSchema;
|
|
7
8
|
typography: (name: string) => TypographyType;
|
|
8
|
-
|
|
9
|
+
color: (schemaName: string, colorType: string) => string;
|
|
9
10
|
};
|
|
10
11
|
actions: {
|
|
11
|
-
setActiveSchema(name: string): void;
|
|
12
12
|
setTheme(newTheme: ThemeDefinitionV2): void;
|
|
13
13
|
};
|
|
14
14
|
};
|
package/stores/VelcronTheming.js
CHANGED
|
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useVelcronThemingStore = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const VelcronStore_1 = require("./VelcronStore");
|
|
6
|
-
let activeSchemaType = "";
|
|
7
6
|
exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("VelcronTheming", {
|
|
8
|
-
|
|
7
|
+
setup() {
|
|
9
8
|
return {
|
|
10
9
|
state: {
|
|
11
10
|
currentTheme: {}
|
|
@@ -40,9 +39,6 @@ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("Velcron
|
|
|
40
39
|
}
|
|
41
40
|
return state.currentTheme?.background;
|
|
42
41
|
};
|
|
43
|
-
const activeColorSchema = () => {
|
|
44
|
-
return colorSchema(activeSchemaType);
|
|
45
|
-
};
|
|
46
42
|
const typography = (name) => {
|
|
47
43
|
if (name === __1.TypographyTypes.h1) {
|
|
48
44
|
return state.currentTheme.typography.h1;
|
|
@@ -64,45 +60,42 @@ exports.useVelcronThemingStore = (0, VelcronStore_1.defineVelcronStore)("Velcron
|
|
|
64
60
|
}
|
|
65
61
|
return state.currentTheme.typography.text;
|
|
66
62
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
const color = (schemaName, colorType) => {
|
|
64
|
+
const mappedColorSchema = colorSchema(schemaName);
|
|
65
|
+
if (colorType === __1.ColorTypes.base) {
|
|
66
|
+
return mappedColorSchema.base.color;
|
|
70
67
|
}
|
|
71
|
-
else if (
|
|
72
|
-
return
|
|
68
|
+
else if (colorType === __1.ColorTypes.baseTone) {
|
|
69
|
+
return mappedColorSchema.base.colorToned;
|
|
73
70
|
}
|
|
74
|
-
else if (
|
|
75
|
-
return
|
|
71
|
+
else if (colorType === __1.ColorTypes.onBase) {
|
|
72
|
+
return mappedColorSchema.onBase.color;
|
|
76
73
|
}
|
|
77
|
-
else if (
|
|
78
|
-
return
|
|
74
|
+
else if (colorType === __1.ColorTypes.onBaseTone) {
|
|
75
|
+
return mappedColorSchema.onBase.colorToned;
|
|
79
76
|
}
|
|
80
|
-
else if (
|
|
81
|
-
return
|
|
77
|
+
else if (colorType === __1.ColorTypes.container) {
|
|
78
|
+
return mappedColorSchema.container.color;
|
|
82
79
|
}
|
|
83
|
-
else if (
|
|
84
|
-
return
|
|
80
|
+
else if (colorType === __1.ColorTypes.containerTone) {
|
|
81
|
+
return mappedColorSchema.container.colorToned;
|
|
85
82
|
}
|
|
86
|
-
else if (
|
|
87
|
-
return
|
|
83
|
+
else if (colorType === __1.ColorTypes.onContainer) {
|
|
84
|
+
return mappedColorSchema.onContainer.color;
|
|
88
85
|
}
|
|
89
|
-
else if (
|
|
90
|
-
return
|
|
86
|
+
else if (colorType === __1.ColorTypes.onContainerTone) {
|
|
87
|
+
return mappedColorSchema.onContainer.colorToned;
|
|
91
88
|
}
|
|
92
|
-
return
|
|
89
|
+
return colorType;
|
|
93
90
|
};
|
|
94
91
|
return {
|
|
95
|
-
activeColorSchema,
|
|
96
92
|
colorSchema,
|
|
97
93
|
typography,
|
|
98
|
-
|
|
94
|
+
color
|
|
99
95
|
};
|
|
100
96
|
},
|
|
101
97
|
actions(state) {
|
|
102
98
|
return {
|
|
103
|
-
setActiveSchema(name) {
|
|
104
|
-
activeSchemaType = name;
|
|
105
|
-
},
|
|
106
99
|
setTheme(newTheme) {
|
|
107
100
|
state.currentTheme = newTheme;
|
|
108
101
|
}
|