@omnia/velcron 8.0.90-vnext → 8.0.91-vnext
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 +8 -2
- package/models/VelcronDefinitions.js +1 -1
- package/models/VelcronPropertyEditorDefinitions.d.ts +1 -1
- package/package.json +1 -1
- package/parser/VelcronActions.js +1 -1
- package/parser/VelcronConstants.d.ts +2 -0
- package/parser/VelcronConstants.js +4 -2
- package/parser/VelcronData.d.ts +1 -1
- package/parser/VelcronData.js +38 -42
- package/parser/VelcronRenderers.js +1 -2
- package/templatebuilder/state/VelcronColorSchemaBuilder.js +1 -1
- package/templatebuilder/state/VelcronContentStateBuilder.js +1 -1
- package/templatebuilder/state/VelcronImageStateBuilder.js +2 -2
|
@@ -7,7 +7,7 @@ import { useVelcronBlueprintStore } from "../stores/VelcronBlueprint";
|
|
|
7
7
|
export interface ResolvedComponentRenderer {
|
|
8
8
|
component: unknown;
|
|
9
9
|
definition: VelcronDefinition;
|
|
10
|
-
customComponent
|
|
10
|
+
customComponent?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface BuiltInComponentRenderers {
|
|
13
13
|
"view": unknown;
|
|
@@ -23,6 +23,7 @@ export interface BuiltInComponentRenderers {
|
|
|
23
23
|
"icon": unknown;
|
|
24
24
|
"chip": unknown;
|
|
25
25
|
"markdown": unknown;
|
|
26
|
+
"slot": unknown;
|
|
26
27
|
}
|
|
27
28
|
export interface ColorSchemaReference {
|
|
28
29
|
name: string;
|
|
@@ -215,7 +216,7 @@ export interface VelcronTextDefinition extends VelcronDefinitionWithEditMode, Ve
|
|
|
215
216
|
}
|
|
216
217
|
export declare enum VelcronImageRatios {
|
|
217
218
|
square = "square",
|
|
218
|
-
landscape = "
|
|
219
|
+
landscape = "landscape"
|
|
219
220
|
}
|
|
220
221
|
export interface VelcronImageDefinition extends VelcronDefinition {
|
|
221
222
|
type: "image";
|
|
@@ -279,6 +280,11 @@ export interface VelcronChipDefinition extends VelcronDefinition {
|
|
|
279
280
|
disabled?: boolean;
|
|
280
281
|
events?: VelcronOnPressEvent;
|
|
281
282
|
}
|
|
283
|
+
export interface VelcronSlotDefinition extends VelcronDefinition {
|
|
284
|
+
type: "slot";
|
|
285
|
+
bind: string;
|
|
286
|
+
value: VelcroncomponentArrayType;
|
|
287
|
+
}
|
|
282
288
|
export type VelcronCustomComponentDefinition = VelcronComponentDefinition;
|
|
283
289
|
export type VelcronRenderProps<TDefinition> = {
|
|
284
290
|
definition: TDefinition;
|
|
@@ -4,5 +4,5 @@ exports.VelcronImageRatios = void 0;
|
|
|
4
4
|
var VelcronImageRatios;
|
|
5
5
|
(function (VelcronImageRatios) {
|
|
6
6
|
VelcronImageRatios["square"] = "square";
|
|
7
|
-
VelcronImageRatios["landscape"] = "
|
|
7
|
+
VelcronImageRatios["landscape"] = "landscape";
|
|
8
8
|
})(VelcronImageRatios = exports.VelcronImageRatios || (exports.VelcronImageRatios = {}));
|
|
@@ -8,7 +8,7 @@ export interface VelcronPropertyEditor<TSettings = any> {
|
|
|
8
8
|
type: BuiltInPropertyEditorType | string;
|
|
9
9
|
settings?: TSettings;
|
|
10
10
|
stateMapping?: string;
|
|
11
|
-
propertyMapping?:
|
|
11
|
+
propertyMapping?: boolean;
|
|
12
12
|
component?: unknown;
|
|
13
13
|
}
|
|
14
14
|
export interface BuiltInPropertyEditors {
|
package/package.json
CHANGED
package/parser/VelcronActions.js
CHANGED
|
@@ -331,7 +331,7 @@ class VelcronActions {
|
|
|
331
331
|
return text;
|
|
332
332
|
}
|
|
333
333
|
static parseAndExecuteComputed(renderContext, template) {
|
|
334
|
-
VelcronData_1.VelcronData.getTokens(template).forEach(token => {
|
|
334
|
+
VelcronData_1.VelcronData.getTokens(template, false).forEach(token => {
|
|
335
335
|
const paramValues = [];
|
|
336
336
|
VelcronActions.parseFunction(renderContext.computed, token, renderContext, paramValues, (acName, params) => {
|
|
337
337
|
const funcContent = renderContext.computed[acName];
|
|
@@ -13,6 +13,7 @@ export declare const VelcronConstants: {
|
|
|
13
13
|
icon: string;
|
|
14
14
|
chip: string;
|
|
15
15
|
markdown: string;
|
|
16
|
+
slot: string;
|
|
16
17
|
};
|
|
17
18
|
events: {
|
|
18
19
|
idTokenStart: string;
|
|
@@ -25,5 +26,6 @@ export declare const VelcronConstants: {
|
|
|
25
26
|
properties: {
|
|
26
27
|
tokenStart: string;
|
|
27
28
|
tokenEnd: string;
|
|
29
|
+
propsToken: string;
|
|
28
30
|
};
|
|
29
31
|
};
|
|
@@ -16,6 +16,7 @@ exports.VelcronConstants = {
|
|
|
16
16
|
icon: "icon",
|
|
17
17
|
chip: "chip",
|
|
18
18
|
markdown: "markdown",
|
|
19
|
+
slot: "slot",
|
|
19
20
|
},
|
|
20
21
|
events: {
|
|
21
22
|
idTokenStart: "$ev{",
|
|
@@ -26,7 +27,8 @@ exports.VelcronConstants = {
|
|
|
26
27
|
stateRootToken: "$state"
|
|
27
28
|
},
|
|
28
29
|
properties: {
|
|
29
|
-
tokenStart: "
|
|
30
|
-
tokenEnd: "}"
|
|
30
|
+
tokenStart: "{{",
|
|
31
|
+
tokenEnd: "}}",
|
|
32
|
+
propsToken: "$props"
|
|
31
33
|
}
|
|
32
34
|
};
|
package/parser/VelcronData.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare class VelcronData {
|
|
|
26
26
|
static extendObject(obj: any): any;
|
|
27
27
|
static getOrSetObjectByPath<T>(object: Object, path: string, value?: any): T | null;
|
|
28
28
|
static getOrSetObjectByPathUsingRenderContext<T>(renderContext: VelcronRenderContext, path: string, value?: any): T;
|
|
29
|
-
static getTokens(template: any): string[];
|
|
29
|
+
static getTokens(template: any, removeBrackets: boolean): string[];
|
|
30
30
|
static ensureEventId(event: string): string;
|
|
31
31
|
static ensureKeys(ui: VelcronDefinition | VelcronAppDefinition, generateNewKeys?: boolean): void;
|
|
32
32
|
static removeKeys(ui: VelcronDefinition | VelcronAppDefinition): void;
|
package/parser/VelcronData.js
CHANGED
|
@@ -10,10 +10,9 @@ class VelcronData {
|
|
|
10
10
|
if (!VelcronData.isString(text)) {
|
|
11
11
|
return text;
|
|
12
12
|
}
|
|
13
|
-
const tokens = this.getTokens(text);
|
|
14
|
-
tokens.forEach((
|
|
15
|
-
let data = this.getOrSetObjectByPathUsingRenderContext(renderContext,
|
|
16
|
-
const token = VelcronConstants_1.VelcronConstants.properties.tokenStart + name + VelcronConstants_1.VelcronConstants.properties.tokenEnd;
|
|
13
|
+
const tokens = this.getTokens(text, false);
|
|
14
|
+
tokens.forEach((token) => {
|
|
15
|
+
let data = this.getOrSetObjectByPathUsingRenderContext(renderContext, token.replace(/\s*{{\s*|\s*}}\s*/g, ""));
|
|
17
16
|
if (data instanceof TextValue_1.TextValue) {
|
|
18
17
|
data = data.value;
|
|
19
18
|
}
|
|
@@ -508,52 +507,49 @@ class VelcronData {
|
|
|
508
507
|
variables[renderContext.id].hasOwnProperty(path)) {
|
|
509
508
|
result = variables[renderContext.id][path];
|
|
510
509
|
}
|
|
510
|
+
else if (path.startsWith(VelcronConstants_1.VelcronConstants.properties.propsToken + ".")) {
|
|
511
|
+
//props in a custom component $props.
|
|
512
|
+
path = path.substring(VelcronConstants_1.VelcronConstants.properties.propsToken.length + 1);
|
|
513
|
+
const propObj = VelcronData.getOrSetObjectByPath(renderContext.properties, path);
|
|
514
|
+
if (VelcronData.isString(propObj)) {
|
|
515
|
+
const propString = propObj;
|
|
516
|
+
path = VelcronData.dataBind(renderContext, propString);
|
|
517
|
+
result = path;
|
|
518
|
+
}
|
|
519
|
+
result = propObj;
|
|
520
|
+
}
|
|
511
521
|
else {
|
|
512
|
-
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
const propObj = renderContext.properties[path];
|
|
516
|
-
if (VelcronData.isString(propObj)) {
|
|
517
|
-
const propString = propObj;
|
|
518
|
-
path = VelcronData.dataBind(renderContext, propString);
|
|
519
|
-
}
|
|
520
|
-
result = propObj;
|
|
522
|
+
const tokens = VelcronData.getTokens(path, true);
|
|
523
|
+
if (tokens.length > 0) {
|
|
524
|
+
path = tokens[0];
|
|
521
525
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
result = VelcronData.getOrSetObjectByPath(object, path, value);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
//For example if you bind to Array of ["string"] the currentContext is only a string so we just return the object without mapping path
|
|
542
|
-
result = object;
|
|
543
|
-
}
|
|
544
|
-
if (typeof result === "undefined" && pathIsPropertyValue) {
|
|
545
|
-
result = path;
|
|
546
|
-
}
|
|
526
|
+
let object = null;
|
|
527
|
+
if (path.startsWith(`${VelcronConstants_1.VelcronConstants.state.stateRootToken}.`) || path === VelcronConstants_1.VelcronConstants.state.stateRootToken) {
|
|
528
|
+
//Fetch from the data object
|
|
529
|
+
object = renderContext.rootContext;
|
|
530
|
+
path = path.substring(6);
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
//Fetch from current ctx
|
|
534
|
+
object = renderContext.currentContext;
|
|
535
|
+
}
|
|
536
|
+
if (VelcronData.isObject(object)) {
|
|
537
|
+
result = VelcronData.getOrSetObjectByPath(object, path, value);
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
//For example if you bind to Array of ["string"] the currentContext is only a string so we just return the object without mapping path
|
|
541
|
+
result = object;
|
|
547
542
|
}
|
|
548
543
|
}
|
|
549
544
|
return result;
|
|
550
545
|
}
|
|
551
|
-
static getTokens(template) {
|
|
546
|
+
static getTokens(template, removeBrackets) {
|
|
552
547
|
const tokens = [];
|
|
553
548
|
if (template) {
|
|
554
|
-
template.replace(/(
|
|
555
|
-
|
|
556
|
-
|
|
549
|
+
template.replace(removeBrackets ? /{{\s*(.+?)\s*}}/g : /(\{{.+?\}})/g, (foundToken, token) => {
|
|
550
|
+
const tokenWithVar = removeBrackets ? token : foundToken;
|
|
551
|
+
tokens.push(tokenWithVar);
|
|
552
|
+
return tokenWithVar;
|
|
557
553
|
});
|
|
558
554
|
}
|
|
559
555
|
return tokens;
|
|
@@ -95,7 +95,6 @@ class VelcronRenderers {
|
|
|
95
95
|
//Fetch the custom component definition
|
|
96
96
|
const customDef = rendererInfo.definition;
|
|
97
97
|
if (customDef.properties) {
|
|
98
|
-
// customDef.properties.forEach((prop) => {
|
|
99
98
|
Object.keys(customDef.properties).forEach((propName) => {
|
|
100
99
|
const prop = customDef.properties ? customDef.properties[propName] : null;
|
|
101
100
|
if (!prop || (prop.required && !definition.hasOwnProperty(propName))) {
|
|
@@ -106,7 +105,7 @@ class VelcronRenderers {
|
|
|
106
105
|
if (VelcronData_1.VelcronData.isString(definition[propName])) {
|
|
107
106
|
//Properties can be databound so if its a string we try do databind
|
|
108
107
|
//this is true for other values such as number / string also
|
|
109
|
-
result.properties[propName] = VelcronData_1.VelcronData.dataBind(
|
|
108
|
+
result.properties[propName] = VelcronData_1.VelcronData.dataBind(result, definition[propName]);
|
|
110
109
|
}
|
|
111
110
|
else {
|
|
112
111
|
result.properties[propName] = definition[propName];
|
|
@@ -5,7 +5,7 @@ const VelcronStateBuilderBase_1 = require("./VelcronStateBuilderBase");
|
|
|
5
5
|
class VelcronColorSchemaStateBuilder extends VelcronStateBuilderBase_1.VelcronStateBuilderBase {
|
|
6
6
|
constructor(stateBuilder) {
|
|
7
7
|
super(stateBuilder);
|
|
8
|
-
this.bind = "
|
|
8
|
+
this.bind = "{{colorSchemaType}}";
|
|
9
9
|
}
|
|
10
10
|
add(colorSchema) {
|
|
11
11
|
this.colorSchema = colorSchema;
|
|
@@ -11,14 +11,14 @@ class VelcronImageStateBuilder extends VelcronStateBuilderBase_1.VelcronStateBui
|
|
|
11
11
|
this.mainImageUrl = url;
|
|
12
12
|
return this;
|
|
13
13
|
},
|
|
14
|
-
bind: "
|
|
14
|
+
bind: "{{main-image.url}}"
|
|
15
15
|
},
|
|
16
16
|
ratio: {
|
|
17
17
|
add: (ratio) => {
|
|
18
18
|
this.mainImageRatio = ratio;
|
|
19
19
|
return this;
|
|
20
20
|
},
|
|
21
|
-
bind: "
|
|
21
|
+
bind: "{{main-image.ratio}}"
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|