@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.
@@ -18,12 +18,13 @@ export interface BuiltInComponentRenderers {
18
18
  "WebView": any;
19
19
  "CustomComponent": any;
20
20
  "Dialog": any;
21
- "Section": any;
21
+ "FlexView": any;
22
22
  "Icon": any;
23
23
  }
24
24
  export type DynamicViewModel = object;
25
25
  export interface OnItemRenderedHookResult {
26
- cssClass: Object;
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: VelcronIcon;
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 VelcronSectionDefinition extends VelcronDefinition {
195
- type: "Section";
196
- columns: Array<VelcronSectionColumn>;
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "7.0.498-dev",
4
+ "version": "7.0.499-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -10,7 +10,7 @@ export declare const VelcronConstants: {
10
10
  progressCircle: string;
11
11
  webView: string;
12
12
  dialog: string;
13
- section: string;
13
+ flexView: string;
14
14
  icon: string;
15
15
  };
16
16
  events: {
@@ -13,7 +13,7 @@ exports.VelcronConstants = {
13
13
  progressCircle: "ProgressCircle",
14
14
  webView: "WebView",
15
15
  dialog: "Dialog",
16
- section: "Section",
16
+ flexView: "FlexView",
17
17
  icon: "Icon"
18
18
  },
19
19
  events: {
@@ -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, VelcronSectionDefinition, VelcronSectionColumn, VelcronRenderContext } from "../models";
1
+ import { VelcronDefinition, VelcronRenderContext } from "../models";
2
2
  export declare class VelcronStyles {
3
- static component(definition: VelcronDefinition, renderCtx: VelcronRenderContext): any;
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
  }
@@ -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 component(definition, renderCtx) {
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
- //Set default width and height values on Images
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
- const textDef = definition;
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 dataBindStyles(styles, renderCtx) {
51
- Object.keys(styles).forEach((key) => {
52
- const style = styles[key];
53
- if (style && VelcronData_1.VelcronData.isString(style)) {
54
- styles[key] = VelcronData_1.VelcronData.dataBind(renderCtx, style);
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 section(sectionDef, renderCtx) {
60
- let result = {
61
- "display": "flex",
62
- ...sectionDef.style,
63
- };
64
- result = VelcronStyles.dataBindStyles(result, renderCtx);
65
- return result;
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 layoutColumn(layoutDef, columnDef, renderCtx) {
68
- //Default is stretch
69
- const width = {};
70
- width["flex"] = 1;
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
- width["flex"] = "0 0 auto";
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"] = `0 0 ${columnDef.width}`;
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
- width["flex"] = `0 0 ${columnDef.width}%`;
71
+ styles["flex"] = `${flexGrow} ${flextShrink} ${columnDef.width}%`;
82
72
  }
83
- let result = {
84
- "display": "flex",
85
- ...width,
86
- ...layoutDef.columnStyle,
87
- ...columnDef.style
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
- result["flex-direction"] = "column";
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
- result["justify-content"] = "center";
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
- result["justify-content"] = "flex-end";
87
+ //result["flex-direction"] = "column";
88
+ styles["align-items"] = "flex-end";
101
89
  }
102
90
  }
103
- result = VelcronStyles.dataBindStyles(result, renderCtx);
104
- return result;
91
+ return styles;
105
92
  }
106
- static layoutColumnComponent(layoutDef, columnDef, renderCtx) {
107
- const result = {
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
- result["justify-content"] = "center";
97
+ styles["justify-content"] = "center";
113
98
  }
114
99
  else if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.right) {
115
- result["justify-content"] = "flex-end";
100
+ styles["justify-content"] = "flex-end";
116
101
  }
117
102
  }
118
- return result;
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;