@omnia/velcron 7.0.498-dev → 7.0.499-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 +15 -9
- package/models/VelcronDescriptors.d.ts +1 -0
- package/package.json +1 -1
- package/parser/VelcronConstants.d.ts +1 -1
- package/parser/VelcronConstants.js +1 -1
- package/parser/VelcronData.js +4 -1
- package/parser/VelcronStyles.d.ts +6 -5
- package/parser/VelcronStyles.js +68 -74
|
@@ -18,12 +18,13 @@ export interface BuiltInComponentRenderers {
|
|
|
18
18
|
"WebView": any;
|
|
19
19
|
"CustomComponent": any;
|
|
20
20
|
"Dialog": any;
|
|
21
|
-
"
|
|
21
|
+
"FlexView": any;
|
|
22
22
|
"Icon": any;
|
|
23
23
|
}
|
|
24
24
|
export type DynamicViewModel = object;
|
|
25
25
|
export interface OnItemRenderedHookResult {
|
|
26
|
-
cssClass
|
|
26
|
+
cssClass?: Object;
|
|
27
|
+
containerRenderer?: VelcronContainerRenderer;
|
|
27
28
|
}
|
|
28
29
|
export interface VelcronRenderContext {
|
|
29
30
|
id?: string;
|
|
@@ -47,6 +48,11 @@ export interface VelcronRenderContextHooks {
|
|
|
47
48
|
onItemSelected?: ((item: VelcronDefinition) => void);
|
|
48
49
|
onItemRendered?: ((item: VelcronDefinition) => OnItemRenderedHookResult);
|
|
49
50
|
}
|
|
51
|
+
export interface VelcronContainerRenderer {
|
|
52
|
+
definition: VelcronDefinition;
|
|
53
|
+
renderContext: VelcronRenderContext;
|
|
54
|
+
component: JSX.Element;
|
|
55
|
+
}
|
|
50
56
|
export interface VelcronAction extends VelcronRenderContext {
|
|
51
57
|
type: VelcronActionTypes;
|
|
52
58
|
}
|
|
@@ -160,7 +166,8 @@ export interface VelcronImageDefinition extends VelcronDefinition {
|
|
|
160
166
|
export interface VelcronButtonDefinition extends VelcronDefinition {
|
|
161
167
|
type: "Button";
|
|
162
168
|
text: string;
|
|
163
|
-
icon
|
|
169
|
+
icon?: VelcronIcon;
|
|
170
|
+
disabled?: boolean;
|
|
164
171
|
events?: VelcronOnPressEvent;
|
|
165
172
|
}
|
|
166
173
|
export interface VelcronTextInputDefinition extends VelcronDefinition {
|
|
@@ -191,15 +198,14 @@ export interface VelcronIconDefinition extends VelcronDefinition {
|
|
|
191
198
|
size?: number;
|
|
192
199
|
events?: VelcronOnPressEvent;
|
|
193
200
|
}
|
|
194
|
-
export interface
|
|
195
|
-
type: "
|
|
196
|
-
|
|
197
|
-
columnStyle?: object;
|
|
198
|
-
}
|
|
199
|
-
export interface VelcronSectionColumn extends VelcronDefinition {
|
|
201
|
+
export interface VelcronFlexViewDefinition extends VelcronDefinition {
|
|
202
|
+
type: "FlexView";
|
|
203
|
+
column?: boolean;
|
|
200
204
|
body: Array<VelcronDefinition>;
|
|
205
|
+
columnStyle?: object;
|
|
201
206
|
horizontalAlignment?: VelcronHorizontalAlignments;
|
|
202
207
|
verticalAlignment?: VerticalAlignments;
|
|
208
|
+
grow?: number;
|
|
203
209
|
width?: "auto" | "stretch" | number | string;
|
|
204
210
|
}
|
|
205
211
|
export interface VelcronSectionColumnWidth {
|
|
@@ -24,6 +24,7 @@ export interface VelcronComponentPropertyDescriptor {
|
|
|
24
24
|
editor?: VelcronComponentPropertyEditors;
|
|
25
25
|
required?: boolean;
|
|
26
26
|
defaultValue?: VelcronPrimitiveType | VelcroncomponentArrayType;
|
|
27
|
+
disableRemovePropertyOnEmptyOrFalse?: boolean;
|
|
27
28
|
}
|
|
28
29
|
export interface VelcronComponentArrayPropertyDescriptor extends VelcronComponentPropertyDescriptor {
|
|
29
30
|
type: VelcronDataTypes.componentArray;
|
package/package.json
CHANGED
package/parser/VelcronData.js
CHANGED
|
@@ -367,6 +367,9 @@ class VelcronData {
|
|
|
367
367
|
return result;
|
|
368
368
|
}
|
|
369
369
|
static evaluateBoolean(template, renderContext) {
|
|
370
|
+
if (VelcronData.isUndefined(template)) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
370
373
|
if (VelcronData.isBoolean(template)) {
|
|
371
374
|
return template;
|
|
372
375
|
}
|
|
@@ -418,7 +421,7 @@ class VelcronData {
|
|
|
418
421
|
return !isNaN(value);
|
|
419
422
|
}
|
|
420
423
|
static isUndefined(value) {
|
|
421
|
-
return typeof value === undefined;
|
|
424
|
+
return typeof value === "undefined";
|
|
422
425
|
}
|
|
423
426
|
static isArray(obj) {
|
|
424
427
|
return Array.isArray(obj);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VelcronDefinition,
|
|
1
|
+
import { VelcronDefinition, VelcronRenderContext } from "../models";
|
|
2
2
|
export declare class VelcronStyles {
|
|
3
|
-
static
|
|
3
|
+
static create(definition: VelcronDefinition, renderCtx: VelcronRenderContext): any;
|
|
4
|
+
private static createStylesForText;
|
|
5
|
+
private static createStylesForImage;
|
|
6
|
+
private static createStylesForFlexbox;
|
|
7
|
+
private static createStylesForLayoutColumnComponent;
|
|
4
8
|
private static dataBindStyles;
|
|
5
|
-
static section(sectionDef: VelcronSectionDefinition, renderCtx: VelcronRenderContext): any;
|
|
6
|
-
static layoutColumn(layoutDef: VelcronSectionDefinition, columnDef: VelcronSectionColumn, renderCtx: VelcronRenderContext): object;
|
|
7
|
-
static layoutColumnComponent(layoutDef: VelcronSectionDefinition, columnDef: VelcronSectionColumn, renderCtx: VelcronRenderContext): object;
|
|
8
9
|
}
|
package/parser/VelcronStyles.js
CHANGED
|
@@ -5,117 +5,111 @@ const VelcronData_1 = require("./VelcronData");
|
|
|
5
5
|
const models_1 = require("../models");
|
|
6
6
|
const VelcronConstants_1 = require("./VelcronConstants");
|
|
7
7
|
class VelcronStyles {
|
|
8
|
-
static
|
|
9
|
-
const bliblu = ";";
|
|
8
|
+
static create(definition, renderCtx) {
|
|
10
9
|
let result = { ...definition.style };
|
|
11
|
-
// let result = {
|
|
12
|
-
// //Margin
|
|
13
|
-
// margin: definition?.style?.margin,
|
|
14
|
-
// marginTop: definition?.style?.marginTop,
|
|
15
|
-
// marginRight: definition?.style?.marginRight,
|
|
16
|
-
// marginBottom: definition?.style?.marginBottom,
|
|
17
|
-
// marginLeft: definition?.style?.marginLeft,
|
|
18
|
-
// //Padding
|
|
19
|
-
// padding: definition?.style?.padding,
|
|
20
|
-
// paddingTop: definition?.style?.paddingTop,
|
|
21
|
-
// paddingRight: definition?.style?.paddingRight,
|
|
22
|
-
// paddingBottom: definition?.style?.paddingBottom,
|
|
23
|
-
// paddingLeft: definition?.style?.paddingLeft,
|
|
24
|
-
// height: definition.style?.height,
|
|
25
|
-
// width: definition.style?.width
|
|
26
|
-
// }
|
|
27
10
|
if (definition.type === VelcronConstants_1.VelcronConstants.components.image) {
|
|
28
|
-
|
|
29
|
-
if (!result.width) {
|
|
30
|
-
result.width = "100%";
|
|
31
|
-
}
|
|
32
|
-
if (!result.height) {
|
|
33
|
-
result.height = 400;
|
|
34
|
-
}
|
|
11
|
+
result = this.createStylesForImage(definition, result);
|
|
35
12
|
}
|
|
36
13
|
else if (definition.type === VelcronConstants_1.VelcronConstants.components.text) {
|
|
37
|
-
|
|
38
|
-
if (textDef.color) {
|
|
39
|
-
result["color"] = textDef.color;
|
|
40
|
-
}
|
|
41
|
-
if (textDef.size) {
|
|
42
|
-
result["fontSize"] = textDef.size + "px";
|
|
43
|
-
}
|
|
14
|
+
result = this.createStylesForText(definition, result);
|
|
44
15
|
}
|
|
16
|
+
else if (definition.type === VelcronConstants_1.VelcronConstants.components.flexView) {
|
|
17
|
+
//result = this.createStylesForSection(definition as VelcronFlexBoxDefinition, result);
|
|
18
|
+
result = this.createStylesForFlexbox(definition, result);
|
|
19
|
+
}
|
|
20
|
+
// else if (definition.type === VelcronConstants.components.flexPanel) {
|
|
21
|
+
// result = this.createStylesForColumn(definition as VelcronFlexBoxDefinition, result);
|
|
22
|
+
// }
|
|
45
23
|
if (renderCtx) {
|
|
46
24
|
result = VelcronStyles.dataBindStyles(result, renderCtx);
|
|
47
25
|
}
|
|
48
26
|
return result;
|
|
49
27
|
}
|
|
50
|
-
static
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
28
|
+
static createStylesForText(textDefinition, styles) {
|
|
29
|
+
if (textDefinition.color) {
|
|
30
|
+
styles["color"] = textDefinition.color;
|
|
31
|
+
}
|
|
32
|
+
if (textDefinition.size) {
|
|
33
|
+
styles["fontSize"] = textDefinition.size + "px";
|
|
34
|
+
}
|
|
57
35
|
return styles;
|
|
58
36
|
}
|
|
59
|
-
static
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
static createStylesForImage(imageDef, styles) {
|
|
38
|
+
if (!styles.width) {
|
|
39
|
+
styles.width = 200;
|
|
40
|
+
}
|
|
41
|
+
if (!styles.height) {
|
|
42
|
+
styles.height = 400;
|
|
43
|
+
}
|
|
44
|
+
styles.flex = "0 0 auto!important";
|
|
45
|
+
return styles;
|
|
66
46
|
}
|
|
67
|
-
static
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
// private static createStylesForSection(sectionDef: VelcronFlexBoxDefinition, styles: any) {
|
|
48
|
+
// styles.display = "flex";
|
|
49
|
+
// styles.width = "100%";
|
|
50
|
+
// styles["flex-direction"] = sectionDef.column ? "column" : "row";
|
|
51
|
+
// return styles;
|
|
52
|
+
// }
|
|
53
|
+
static createStylesForFlexbox(columnDef, styles) {
|
|
54
|
+
const flexGrow = columnDef.grow ? columnDef.grow : 1;
|
|
55
|
+
const flextShrink = flexGrow;
|
|
56
|
+
styles.display = "flex";
|
|
57
|
+
styles.flex = `${flexGrow}`;
|
|
58
|
+
styles["max-width"] = "100%";
|
|
59
|
+
styles["flex-direction"] = columnDef.column ? "column" : "row";
|
|
71
60
|
//Auto
|
|
72
61
|
if (columnDef.width && columnDef.width === models_1.VelcronSectionColumnWidthTypes.auto) {
|
|
73
|
-
|
|
62
|
+
styles["flex"] = `${flexGrow} ${flextShrink} auto`;
|
|
74
63
|
}
|
|
75
64
|
//Pixels
|
|
76
65
|
else if (columnDef.width && VelcronData_1.VelcronData.isString(columnDef.width) && columnDef.width.endsWith("px")) {
|
|
77
|
-
width["flex"] =
|
|
66
|
+
//width["flex"] = `${flexGrow} ${flextShrink} ${columnDef.width}`;
|
|
67
|
+
styles["max-width"] = columnDef.width;
|
|
78
68
|
}
|
|
79
69
|
//Percentage
|
|
80
70
|
else if (columnDef.width && (isNaN(columnDef.width) === false)) {
|
|
81
|
-
|
|
71
|
+
styles["flex"] = `${flexGrow} ${flextShrink} ${columnDef.width}%`;
|
|
82
72
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
if (columnDef.horizontalAlignment && columnDef.horizontalAlignment !== models_1.VelcronHorizontalAlignments.left) {
|
|
73
|
+
// if (columnDef.horizontalAlignment && columnDef.horizontalAlignment !== VelcronHorizontalAlignments.left) {
|
|
74
|
+
// //Need to add this to make horizontalAlignment work for child div
|
|
75
|
+
// result["flex-direction"] = "column";
|
|
76
|
+
// }
|
|
77
|
+
if (columnDef.horizontalAlignment) {
|
|
90
78
|
//Need to add this to make horizontalAlignment work for child div
|
|
91
|
-
|
|
79
|
+
styles["justify-content"] = columnDef.horizontalAlignment;
|
|
92
80
|
}
|
|
93
81
|
if (columnDef.verticalAlignment) {
|
|
94
82
|
if (columnDef.verticalAlignment === models_1.VerticalAlignments.center) {
|
|
95
|
-
result["flex-direction"] = "column";
|
|
96
|
-
|
|
83
|
+
//result["flex-direction"] = "column";
|
|
84
|
+
styles["align-items"] = "center";
|
|
97
85
|
}
|
|
98
86
|
else if (columnDef.verticalAlignment === models_1.VerticalAlignments.bottom) {
|
|
99
|
-
result["flex-direction"] = "column";
|
|
100
|
-
|
|
87
|
+
//result["flex-direction"] = "column";
|
|
88
|
+
styles["align-items"] = "flex-end";
|
|
101
89
|
}
|
|
102
90
|
}
|
|
103
|
-
|
|
104
|
-
return result;
|
|
91
|
+
return styles;
|
|
105
92
|
}
|
|
106
|
-
static
|
|
107
|
-
|
|
108
|
-
"display": "flex",
|
|
109
|
-
};
|
|
93
|
+
static createStylesForLayoutColumnComponent(layoutDef, columnDef, styles) {
|
|
94
|
+
styles.display = "flex";
|
|
110
95
|
if (columnDef.horizontalAlignment) {
|
|
111
96
|
if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.center) {
|
|
112
|
-
|
|
97
|
+
styles["justify-content"] = "center";
|
|
113
98
|
}
|
|
114
99
|
else if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.right) {
|
|
115
|
-
|
|
100
|
+
styles["justify-content"] = "flex-end";
|
|
116
101
|
}
|
|
117
102
|
}
|
|
118
|
-
return
|
|
103
|
+
return styles;
|
|
104
|
+
}
|
|
105
|
+
static dataBindStyles(styles, renderCtx) {
|
|
106
|
+
Object.keys(styles).forEach((key) => {
|
|
107
|
+
const style = styles[key];
|
|
108
|
+
if (style && VelcronData_1.VelcronData.isString(style)) {
|
|
109
|
+
styles[key] = VelcronData_1.VelcronData.dataBind(renderCtx, style);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return styles;
|
|
119
113
|
}
|
|
120
114
|
}
|
|
121
115
|
exports.VelcronStyles = VelcronStyles;
|