@omnia/velcron 7.0.380-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.
Files changed (56) hide show
  1. package/README.md +6 -0
  2. package/actions/ActionResults.d.ts +4 -0
  3. package/actions/ActionResults.js +14 -0
  4. package/actions/Alert.d.ts +2 -0
  5. package/actions/Alert.js +12 -0
  6. package/actions/Array.d.ts +3 -0
  7. package/actions/Array.js +22 -0
  8. package/actions/Debounce.d.ts +2 -0
  9. package/actions/Debounce.js +43 -0
  10. package/actions/Delay.d.ts +2 -0
  11. package/actions/Delay.js +14 -0
  12. package/actions/Http.d.ts +2 -0
  13. package/actions/Http.js +15 -0
  14. package/actions/IActionHandler.d.ts +5 -0
  15. package/actions/IActionHandler.js +2 -0
  16. package/actions/Log.d.ts +2 -0
  17. package/actions/Log.js +10 -0
  18. package/actions/MsGraph.d.ts +2 -0
  19. package/actions/MsGraph.js +16 -0
  20. package/actions/MsSharePoint.d.ts +2 -0
  21. package/actions/MsSharePoint.js +17 -0
  22. package/actions/index.d.ts +10 -0
  23. package/actions/index.js +13 -0
  24. package/index.d.ts +3 -0
  25. package/index.js +6 -0
  26. package/models/Enums.d.ts +53 -0
  27. package/models/Enums.js +66 -0
  28. package/models/VelcronDefinitions.d.ts +213 -0
  29. package/models/VelcronDefinitions.js +2 -0
  30. package/models/VelcronDescriptors.d.ts +34 -0
  31. package/models/VelcronDescriptors.js +2 -0
  32. package/models/VelcronEvents.d.ts +16 -0
  33. package/models/VelcronEvents.js +2 -0
  34. package/models/VelcronTypes.d.ts +10 -0
  35. package/models/VelcronTypes.js +2 -0
  36. package/models/ViewModelAndContext.d.ts +4 -0
  37. package/models/ViewModelAndContext.js +2 -0
  38. package/models/index.d.ts +6 -0
  39. package/models/index.js +9 -0
  40. package/package.json +27 -0
  41. package/parser/TextValue.d.ts +4 -0
  42. package/parser/TextValue.js +9 -0
  43. package/parser/VelcronActions.d.ts +36 -0
  44. package/parser/VelcronActions.js +445 -0
  45. package/parser/VelcronConstants.d.ts +28 -0
  46. package/parser/VelcronConstants.js +31 -0
  47. package/parser/VelcronData.d.ts +39 -0
  48. package/parser/VelcronData.js +628 -0
  49. package/parser/VelcronLogger.d.ts +6 -0
  50. package/parser/VelcronLogger.js +18 -0
  51. package/parser/VelcronRenderers.d.ts +10 -0
  52. package/parser/VelcronRenderers.js +114 -0
  53. package/parser/VelcronStyles.d.ts +8 -0
  54. package/parser/VelcronStyles.js +121 -0
  55. package/parser/index.d.ts +7 -0
  56. package/parser/index.js +10 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VelcronLogger = void 0;
4
+ class VelcronLogger {
5
+ static logDataError(log) {
6
+ console.error(log);
7
+ }
8
+ static logActionError(log) {
9
+ console.error(log);
10
+ }
11
+ static logError(log) {
12
+ console.error(log);
13
+ }
14
+ static logCustomComponentError(log) {
15
+ console.error(log);
16
+ }
17
+ }
18
+ exports.VelcronLogger = VelcronLogger;
@@ -0,0 +1,10 @@
1
+ import { BuiltInComponentRenderers, DynamicViewModel, ResolvedComponentRenderer, VelcronDefinition, VelcronRenderContext } from "../models";
2
+ export declare class VelcronRenderers {
3
+ private static components;
4
+ static registerComponent(type: string, component: any): void;
5
+ static hasComponents(): boolean;
6
+ static hasComponent(type: string): any;
7
+ static registerComponents(components: BuiltInComponentRenderers): void;
8
+ static getComponent(definition: VelcronDefinition, renderContext: VelcronRenderContext): ResolvedComponentRenderer;
9
+ static ensureRenderContext(rendererInfo: ResolvedComponentRenderer, definition: VelcronDefinition, currentRenderCtx: VelcronRenderContext, newViewModel?: DynamicViewModel): VelcronRenderContext;
10
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VelcronRenderers = void 0;
4
+ const VelcronLogger_1 = require("./VelcronLogger");
5
+ const VelcronData_1 = require("./VelcronData");
6
+ class VelcronRenderers {
7
+ static registerComponent(type, component) {
8
+ type = type.toLowerCase();
9
+ if (!this.components[type]) {
10
+ this.components[type] = component;
11
+ }
12
+ else {
13
+ throw `Velcron Component of type ${type} is already registered`;
14
+ }
15
+ }
16
+ // private static reactivePropertyCreator: (objToCreateOn: object, propertyName: string, value: any ) => void
17
+ // static registerReactiveObjectCreator(reactivePropertyCreator: (objToCreateOn: object, propertyName: string, value: any) => void){
18
+ // this.reactivePropertyCreator = reactivePropertyCreator;
19
+ // }
20
+ static hasComponents() {
21
+ return Object.keys(this.components).length > 0;
22
+ }
23
+ static hasComponent(type) {
24
+ type = type.toLowerCase();
25
+ return this.components[type];
26
+ }
27
+ static registerComponents(components) {
28
+ Object.keys(components).forEach((key) => {
29
+ this.registerComponent(key, components[key]);
30
+ });
31
+ }
32
+ static getComponent(definition, renderContext) {
33
+ let result;
34
+ let customComponentDefinition;
35
+ if (renderContext.components && Array.isArray(renderContext.components)) {
36
+ customComponentDefinition = renderContext.components?.find(p => p.type.toLowerCase() === definition.type.toLowerCase());
37
+ }
38
+ if (customComponentDefinition) {
39
+ if (!this.components["customcomponent"]) {
40
+ throw "Cant find the custom component renderer";
41
+ }
42
+ //Make a new instance of the custom component
43
+ const customComponentInstance = JSON.parse(JSON.stringify(customComponentDefinition));
44
+ //Apply styles coming from the usage definition
45
+ //TODO: If the custom component contains styling we should check which styling properties that
46
+ //comes from the current instance and override the ones from the original to make style overide work as we want
47
+ customComponentInstance.style = definition.style;
48
+ result = {
49
+ component: this.components["customcomponent"],
50
+ definition: customComponentInstance,
51
+ customComponent: true
52
+ };
53
+ }
54
+ else if (this.components[definition.type.toLowerCase()]) {
55
+ result = {
56
+ component: this.components[definition.type.toLowerCase()],
57
+ definition: definition,
58
+ customComponent: false
59
+ };
60
+ }
61
+ else {
62
+ throw "Cant find component";
63
+ }
64
+ return result;
65
+ }
66
+ static ensureRenderContext(rendererInfo, definition, currentRenderCtx, newViewModel) {
67
+ //Ensure we have the correct render context passing properties etc to sub components
68
+ let result = currentRenderCtx;
69
+ if (rendererInfo.customComponent || newViewModel) {
70
+ result = {
71
+ rootContext: currentRenderCtx.rootContext,
72
+ currentContext: newViewModel ? newViewModel : currentRenderCtx.currentContext,
73
+ actions: currentRenderCtx.actions,
74
+ components: currentRenderCtx.components,
75
+ hooks: currentRenderCtx.hooks,
76
+ computed: currentRenderCtx.computed
77
+ };
78
+ if (rendererInfo.customComponent) {
79
+ //Fetch the custom component definition
80
+ const customDef = rendererInfo.definition;
81
+ if (customDef.properties) {
82
+ // customDef.properties.forEach((prop) => {
83
+ Object.keys(customDef.properties).forEach((propName) => {
84
+ const prop = customDef.properties ? customDef.properties[propName] : null;
85
+ if (!prop || (prop.required && !definition.hasOwnProperty(propName))) {
86
+ VelcronLogger_1.VelcronLogger.logCustomComponentError(`Component of type ${customDef.type} requires property ${propName} but its missing`);
87
+ }
88
+ result.properties = result.properties || {};
89
+ //Callback to reactive property creator (for example vue register to make it using Vue.set but can be different in react etc)
90
+ // if(!result.properties){
91
+ // this.reactivePropertyCreator(result, 'properties', {});
92
+ // }
93
+ if (definition.hasOwnProperty(propName)) {
94
+ if (VelcronData_1.VelcronData.isString(definition[propName])) {
95
+ //Properties can be databound so if its a string we try do databind
96
+ //this is true for other values such as number / string also
97
+ result.properties[propName] = VelcronData_1.VelcronData.dataBind(currentRenderCtx, definition[propName]);
98
+ }
99
+ else {
100
+ result.properties[propName] = definition[propName];
101
+ }
102
+ }
103
+ else if (prop.hasOwnProperty("defaultValue")) {
104
+ result.properties[propName] = prop.defaultValue;
105
+ }
106
+ });
107
+ }
108
+ }
109
+ }
110
+ return result;
111
+ }
112
+ }
113
+ exports.VelcronRenderers = VelcronRenderers;
114
+ VelcronRenderers.components = {};
@@ -0,0 +1,8 @@
1
+ import { VelcronDefinition, VelcronSectionDefinition, VelcronSectionColumn, VelcronRenderContext } from "../models";
2
+ export declare class VelcronStyles {
3
+ static component(definition: VelcronDefinition, renderCtx: VelcronRenderContext): any;
4
+ 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
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VelcronStyles = void 0;
4
+ const VelcronData_1 = require("./VelcronData");
5
+ const models_1 = require("../models");
6
+ const VelcronConstants_1 = require("./VelcronConstants");
7
+ class VelcronStyles {
8
+ static component(definition, renderCtx) {
9
+ const bliblu = ";";
10
+ 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
+ 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
+ }
35
+ }
36
+ 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
+ }
44
+ }
45
+ if (renderCtx) {
46
+ result = VelcronStyles.dataBindStyles(result, renderCtx);
47
+ }
48
+ return result;
49
+ }
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
+ });
57
+ return styles;
58
+ }
59
+ static section(sectionDef, renderCtx) {
60
+ let result = {
61
+ "display": "flex",
62
+ ...sectionDef.style,
63
+ };
64
+ result = VelcronStyles.dataBindStyles(result, renderCtx);
65
+ return result;
66
+ }
67
+ static layoutColumn(layoutDef, columnDef, renderCtx) {
68
+ //Default is stretch
69
+ const width = {};
70
+ width["flex"] = 1;
71
+ //Auto
72
+ if (columnDef.width && columnDef.width === models_1.VelcronSectionColumnWidthTypes.auto) {
73
+ width["flex"] = "0 0 auto";
74
+ }
75
+ //Pixels
76
+ else if (columnDef.width && VelcronData_1.VelcronData.isString(columnDef.width) && columnDef.width.endsWith("px")) {
77
+ width["flex"] = `0 0 ${columnDef.width}`;
78
+ }
79
+ //Percentage
80
+ else if (columnDef.width && (isNaN(columnDef.width) === false)) {
81
+ width["flex"] = `0 0 ${columnDef.width}%`;
82
+ }
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) {
90
+ //Need to add this to make horizontalAlignment work for child div
91
+ result["flex-direction"] = "column";
92
+ }
93
+ if (columnDef.verticalAlignment) {
94
+ if (columnDef.verticalAlignment === models_1.VerticalAlignments.center) {
95
+ result["flex-direction"] = "column";
96
+ result["justify-content"] = "center";
97
+ }
98
+ else if (columnDef.verticalAlignment === models_1.VerticalAlignments.bottom) {
99
+ result["flex-direction"] = "column";
100
+ result["justify-content"] = "flex-end";
101
+ }
102
+ }
103
+ result = VelcronStyles.dataBindStyles(result, renderCtx);
104
+ return result;
105
+ }
106
+ static layoutColumnComponent(layoutDef, columnDef, renderCtx) {
107
+ const result = {
108
+ "display": "flex",
109
+ };
110
+ if (columnDef.horizontalAlignment) {
111
+ if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.center) {
112
+ result["justify-content"] = "center";
113
+ }
114
+ else if (columnDef.horizontalAlignment === models_1.VelcronHorizontalAlignments.right) {
115
+ result["justify-content"] = "flex-end";
116
+ }
117
+ }
118
+ return result;
119
+ }
120
+ }
121
+ exports.VelcronStyles = VelcronStyles;
@@ -0,0 +1,7 @@
1
+ export * from "./VelcronData";
2
+ export * from "./VelcronActions";
3
+ export * from "./VelcronConstants";
4
+ export * from "./VelcronStyles";
5
+ export * from "./VelcronLogger";
6
+ export * from "./VelcronRenderers";
7
+ export * from "./TextValue";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./VelcronData"), exports);
5
+ tslib_1.__exportStar(require("./VelcronActions"), exports);
6
+ tslib_1.__exportStar(require("./VelcronConstants"), exports);
7
+ tslib_1.__exportStar(require("./VelcronStyles"), exports);
8
+ tslib_1.__exportStar(require("./VelcronLogger"), exports);
9
+ tslib_1.__exportStar(require("./VelcronRenderers"), exports);
10
+ tslib_1.__exportStar(require("./TextValue"), exports);