@omnia/velcron 7.0.501-dev → 7.0.502-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/package.json +1 -1
- package/parser/VelcronStyles.d.ts +3 -15
- package/parser/VelcronStyles.js +5 -123
- package/stores/VelcronStore.d.ts +2 -2
- package/stores/VelcronStore.js +4 -4
package/package.json
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { VelcronDefinition, VelcronRenderContext } from "../models";
|
|
2
|
-
export declare enum VelcronSizeUnits {
|
|
3
|
-
Pixels = 1,
|
|
4
|
-
Numbers = 2
|
|
5
|
-
}
|
|
6
|
-
export interface VelcronStyleSettings {
|
|
7
|
-
sizeUnit: VelcronSizeUnits;
|
|
8
|
-
}
|
|
9
2
|
export declare class VelcronStyles {
|
|
10
|
-
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
private static createStylesForImage;
|
|
14
|
-
private static createStylesForFlexbox;
|
|
15
|
-
private static createStylesForLayoutColumnComponent;
|
|
3
|
+
static styleProvider: (definition: VelcronDefinition, renderCtx: VelcronRenderContext) => object;
|
|
4
|
+
static registerStyleProvider(fn: (definition: VelcronDefinition, renderCtx: VelcronRenderContext) => object): void;
|
|
5
|
+
static create(definition: VelcronDefinition, renderCtx: VelcronRenderContext): object;
|
|
16
6
|
private static dataBindStyles;
|
|
17
|
-
private static setUnitForValue;
|
|
18
|
-
private static setup;
|
|
19
7
|
}
|
package/parser/VelcronStyles.js
CHANGED
|
@@ -1,124 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VelcronStyles =
|
|
3
|
+
exports.VelcronStyles = void 0;
|
|
4
4
|
const VelcronData_1 = require("./VelcronData");
|
|
5
|
-
const models_1 = require("../models");
|
|
6
|
-
const VelcronConstants_1 = require("./VelcronConstants");
|
|
7
|
-
var VelcronSizeUnits;
|
|
8
|
-
(function (VelcronSizeUnits) {
|
|
9
|
-
VelcronSizeUnits[VelcronSizeUnits["Pixels"] = 1] = "Pixels";
|
|
10
|
-
VelcronSizeUnits[VelcronSizeUnits["Numbers"] = 2] = "Numbers";
|
|
11
|
-
})(VelcronSizeUnits = exports.VelcronSizeUnits || (exports.VelcronSizeUnits = {}));
|
|
12
5
|
class VelcronStyles {
|
|
6
|
+
static registerStyleProvider(fn) {
|
|
7
|
+
VelcronStyles.styleProvider = fn;
|
|
8
|
+
}
|
|
13
9
|
static create(definition, renderCtx) {
|
|
14
|
-
let result =
|
|
15
|
-
if (definition.type === VelcronConstants_1.VelcronConstants.components.image) {
|
|
16
|
-
result = this.createStylesForImage(definition, result);
|
|
17
|
-
}
|
|
18
|
-
else if (definition.type === VelcronConstants_1.VelcronConstants.components.text) {
|
|
19
|
-
result = this.createStylesForText(definition, result);
|
|
20
|
-
}
|
|
21
|
-
else if (definition.type === VelcronConstants_1.VelcronConstants.components.flexView) {
|
|
22
|
-
//result = this.createStylesForSection(definition as VelcronFlexBoxDefinition, result);
|
|
23
|
-
result = this.createStylesForFlexbox(definition, result);
|
|
24
|
-
}
|
|
25
|
-
// else if (definition.type === VelcronConstants.components.flexPanel) {
|
|
26
|
-
// result = this.createStylesForColumn(definition as VelcronFlexBoxDefinition, result);
|
|
27
|
-
// }
|
|
10
|
+
let result = VelcronStyles.styleProvider(definition, renderCtx);
|
|
28
11
|
if (renderCtx) {
|
|
29
12
|
result = VelcronStyles.dataBindStyles(result, renderCtx);
|
|
30
13
|
}
|
|
31
14
|
return result;
|
|
32
15
|
}
|
|
33
|
-
static createStylesForText(textDefinition, styles) {
|
|
34
|
-
// const themeStore = useInject(ThemeStore);
|
|
35
|
-
// if (textDefinition.color && textDefinition.color != "") {
|
|
36
|
-
// styles["color"] = themeStore.getters.getColor(textDefinition.color);
|
|
37
|
-
// }
|
|
38
|
-
// else {
|
|
39
|
-
// styles["color"] = themeStore.getters.activeSchema().onBase.color;
|
|
40
|
-
// }
|
|
41
|
-
// const typography = themeStore.getters.typography(textDefinition.typography);
|
|
42
|
-
// styles["fontSize"] = this.setUnitForValue(typography.large.size);
|
|
43
|
-
// styles["font-weight"] = typography.large.weight;
|
|
44
|
-
// styles["line-height"] = this.setUnitForValue(typography.large.lineHeight);
|
|
45
|
-
return styles;
|
|
46
|
-
}
|
|
47
|
-
static createStylesForImage(imageDef, styles) {
|
|
48
|
-
if (!styles.width) {
|
|
49
|
-
styles.width = this.setUnitForValue(200);
|
|
50
|
-
}
|
|
51
|
-
if (!styles.height) {
|
|
52
|
-
styles.height = this.setUnitForValue(400);
|
|
53
|
-
}
|
|
54
|
-
styles.flex = "0 0 auto!important";
|
|
55
|
-
return styles;
|
|
56
|
-
}
|
|
57
|
-
// private static createStylesForSection(sectionDef: VelcronFlexBoxDefinition, styles: any) {
|
|
58
|
-
// styles.display = "flex";
|
|
59
|
-
// styles.width = "100%";
|
|
60
|
-
// styles["flex-direction"] = sectionDef.column ? "column" : "row";
|
|
61
|
-
// return styles;
|
|
62
|
-
// }
|
|
63
|
-
static createStylesForFlexbox(flexViewDefinition, styles) {
|
|
64
|
-
const flexGrow = flexViewDefinition.grow ? flexViewDefinition.grow : 1;
|
|
65
|
-
const flextShrink = flexGrow;
|
|
66
|
-
styles.display = "flex";
|
|
67
|
-
styles.flex = flexGrow;
|
|
68
|
-
styles["max-width"] = "100%";
|
|
69
|
-
styles["flex-direction"] = flexViewDefinition.column ? "column" : "row";
|
|
70
|
-
//Auto
|
|
71
|
-
if (flexViewDefinition.width && flexViewDefinition.width === models_1.VelcronSectionColumnWidthTypes.auto) {
|
|
72
|
-
styles["flex"] = `${flexGrow} ${flextShrink} auto`;
|
|
73
|
-
}
|
|
74
|
-
//Pixels
|
|
75
|
-
else if (flexViewDefinition.width && VelcronData_1.VelcronData.isString(flexViewDefinition.width) && flexViewDefinition.width.endsWith("px")) {
|
|
76
|
-
//width["flex"] = `${flexGrow} ${flextShrink} ${columnDef.width}`;
|
|
77
|
-
styles["max-width"] = this.setUnitForValue(flexViewDefinition.width);
|
|
78
|
-
}
|
|
79
|
-
//Percentage
|
|
80
|
-
else if (flexViewDefinition.width && (isNaN(flexViewDefinition.width) === false)) {
|
|
81
|
-
styles["flex"] = `${flexGrow} ${flextShrink} ${flexViewDefinition.width}%`;
|
|
82
|
-
}
|
|
83
|
-
// if (columnDef.horizontalAlignment && columnDef.horizontalAlignment !== VelcronHorizontalAlignments.left) {
|
|
84
|
-
// //Need to add this to make horizontalAlignment work for child div
|
|
85
|
-
// result["flex-direction"] = "column";
|
|
86
|
-
// }
|
|
87
|
-
if (flexViewDefinition.horizontalAlignment) {
|
|
88
|
-
//Need to add this to make horizontalAlignment work for child div
|
|
89
|
-
styles["justify-content"] = flexViewDefinition.horizontalAlignment;
|
|
90
|
-
}
|
|
91
|
-
if (flexViewDefinition.verticalAlignment) {
|
|
92
|
-
if (flexViewDefinition.verticalAlignment === models_1.VerticalAlignments.center) {
|
|
93
|
-
//result["flex-direction"] = "column";
|
|
94
|
-
styles["align-items"] = "center";
|
|
95
|
-
}
|
|
96
|
-
else if (flexViewDefinition.verticalAlignment === models_1.VerticalAlignments.bottom) {
|
|
97
|
-
//result["flex-direction"] = "column";
|
|
98
|
-
styles["align-items"] = "flex-end";
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// if (flexViewDefinition.colorSchema && flexViewDefinition.colorSchema != "") {
|
|
102
|
-
// const themeStore = useInject(ThemeStore);
|
|
103
|
-
// styles["background-color"] = themeStore.getters.activeSchema().base.color;
|
|
104
|
-
// }
|
|
105
|
-
//Color
|
|
106
|
-
//if(flexViewDefinition.co)
|
|
107
|
-
//const { theming } = useTheme();
|
|
108
|
-
return styles;
|
|
109
|
-
}
|
|
110
|
-
static createStylesForLayoutColumnComponent(layoutDef, columnDef, styles) {
|
|
111
|
-
styles.display = "flex";
|
|
112
|
-
if (columnDef.horizontalAlignment) {
|
|
113
|
-
if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.center) {
|
|
114
|
-
styles["justify-content"] = "center";
|
|
115
|
-
}
|
|
116
|
-
else if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.right) {
|
|
117
|
-
styles["justify-content"] = "flex-end";
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return styles;
|
|
121
|
-
}
|
|
122
16
|
static dataBindStyles(styles, renderCtx) {
|
|
123
17
|
Object.keys(styles).forEach((key) => {
|
|
124
18
|
const style = styles[key];
|
|
@@ -128,17 +22,5 @@ class VelcronStyles {
|
|
|
128
22
|
});
|
|
129
23
|
return styles;
|
|
130
24
|
}
|
|
131
|
-
static setUnitForValue(value) {
|
|
132
|
-
if (this.styleSettings.sizeUnit === VelcronSizeUnits.Pixels) {
|
|
133
|
-
return value + "px";
|
|
134
|
-
}
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
static setup(settings) {
|
|
138
|
-
this.styleSettings = settings;
|
|
139
|
-
}
|
|
140
25
|
}
|
|
141
26
|
exports.VelcronStyles = VelcronStyles;
|
|
142
|
-
VelcronStyles.styleSettings = {
|
|
143
|
-
sizeUnit: VelcronSizeUnits.Pixels
|
|
144
|
-
};
|
package/stores/VelcronStore.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class VelcronStore {
|
|
2
|
-
static
|
|
3
|
-
static
|
|
2
|
+
static reactivityProvider: (obj: any) => unknown;
|
|
3
|
+
static registerReactivityProvider(fn: (obj: any) => unknown): void;
|
|
4
4
|
state<T>(obj: T): T;
|
|
5
5
|
mutation(fn: () => void): void;
|
|
6
6
|
}
|
package/stores/VelcronStore.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestStore = exports.VelcronStore = void 0;
|
|
4
4
|
class VelcronStore {
|
|
5
|
-
static
|
|
6
|
-
VelcronStore.
|
|
5
|
+
static registerReactivityProvider(fn) {
|
|
6
|
+
VelcronStore.reactivityProvider = fn;
|
|
7
7
|
}
|
|
8
8
|
state(obj) {
|
|
9
|
-
if (!VelcronStore.
|
|
9
|
+
if (!VelcronStore.reactivityProvider) {
|
|
10
10
|
throw new Error("Reactivity creator not set");
|
|
11
11
|
}
|
|
12
|
-
return VelcronStore.
|
|
12
|
+
return VelcronStore.reactivityProvider(obj);
|
|
13
13
|
}
|
|
14
14
|
mutation(fn) {
|
|
15
15
|
fn();
|