@omnia/velcron 7.5.44-dev → 7.5.45-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 +7 -1
- package/package.json +1 -1
- package/parser/VelcronActions.js +1 -1
- package/parser/VelcronConstants.d.ts +2 -0
- package/parser/VelcronConstants.js +5 -3
- package/parser/VelcronData.d.ts +1 -1
- package/parser/VelcronData.js +38 -43
- package/parser/VelcronRenderers.js +0 -1
|
@@ -6,7 +6,7 @@ import { ColorSchema, useVelcronThemingStore } from "..";
|
|
|
6
6
|
export interface ResolvedComponentRenderer {
|
|
7
7
|
component: unknown;
|
|
8
8
|
definition: VelcronDefinition;
|
|
9
|
-
customComponent
|
|
9
|
+
customComponent?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface BuiltInComponentRenderers {
|
|
12
12
|
"View": unknown;
|
|
@@ -21,6 +21,7 @@ export interface BuiltInComponentRenderers {
|
|
|
21
21
|
"Dialog": unknown;
|
|
22
22
|
"Icon": unknown;
|
|
23
23
|
"Chip": unknown;
|
|
24
|
+
"Slot": unknown;
|
|
24
25
|
}
|
|
25
26
|
export interface ColorSchemaReference {
|
|
26
27
|
name: string;
|
|
@@ -251,6 +252,11 @@ export interface VelcronChipDefinition extends VelcronDefinition, VelcronCustomT
|
|
|
251
252
|
disabled?: boolean;
|
|
252
253
|
events?: VelcronOnPressEvent;
|
|
253
254
|
}
|
|
255
|
+
export interface VelcronSlotDefinition extends VelcronDefinition, VelcronCustomThemeSettings {
|
|
256
|
+
type: "Slot";
|
|
257
|
+
bind: string;
|
|
258
|
+
value: VelcroncomponentArrayType;
|
|
259
|
+
}
|
|
254
260
|
/*** Custom Components ***********************************************************************/
|
|
255
261
|
export type VelcronCustomComponentDefinition = VelcronComponentDescriptor & VelcronComponentDefinition;
|
|
256
262
|
export type VelcronRenderProps<TDefinition> = {
|
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];
|
|
@@ -12,6 +12,7 @@ export declare const VelcronConstants: {
|
|
|
12
12
|
dialog: string;
|
|
13
13
|
icon: string;
|
|
14
14
|
chip: string;
|
|
15
|
+
slot: string;
|
|
15
16
|
};
|
|
16
17
|
events: {
|
|
17
18
|
idTokenStart: string;
|
|
@@ -24,5 +25,6 @@ export declare const VelcronConstants: {
|
|
|
24
25
|
properties: {
|
|
25
26
|
tokenStart: string;
|
|
26
27
|
tokenEnd: string;
|
|
28
|
+
propsToken: string;
|
|
27
29
|
};
|
|
28
30
|
};
|
|
@@ -14,7 +14,8 @@ exports.VelcronConstants = {
|
|
|
14
14
|
webView: "WebView",
|
|
15
15
|
dialog: "Dialog",
|
|
16
16
|
icon: "Icon",
|
|
17
|
-
chip: "Chip"
|
|
17
|
+
chip: "Chip",
|
|
18
|
+
slot: "Slot"
|
|
18
19
|
},
|
|
19
20
|
events: {
|
|
20
21
|
idTokenStart: "$ev{",
|
|
@@ -25,7 +26,8 @@ exports.VelcronConstants = {
|
|
|
25
26
|
stateRootToken: "$state"
|
|
26
27
|
},
|
|
27
28
|
properties: {
|
|
28
|
-
tokenStart: "
|
|
29
|
-
tokenEnd: "}"
|
|
29
|
+
tokenStart: "{{",
|
|
30
|
+
tokenEnd: "}}",
|
|
31
|
+
propsToken: "$props"
|
|
30
32
|
}
|
|
31
33
|
};
|
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,53 +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
|
-
return path;
|
|
520
|
-
}
|
|
521
|
-
result = propObj;
|
|
522
|
+
const tokens = VelcronData.getTokens(path, true);
|
|
523
|
+
if (tokens.length > 0) {
|
|
524
|
+
path = tokens[0];
|
|
522
525
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
result = VelcronData.getOrSetObjectByPath(object, path, value);
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
//For example if you bind to Array of ["string"] the currentContext is only a string so we just return the object without mapping path
|
|
543
|
-
result = object;
|
|
544
|
-
}
|
|
545
|
-
if (typeof result === "undefined" && pathIsPropertyValue) {
|
|
546
|
-
result = path;
|
|
547
|
-
}
|
|
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;
|
|
548
542
|
}
|
|
549
543
|
}
|
|
550
544
|
return result;
|
|
551
545
|
}
|
|
552
|
-
static getTokens(template) {
|
|
546
|
+
static getTokens(template, removeBrackets) {
|
|
553
547
|
const tokens = [];
|
|
554
548
|
if (template) {
|
|
555
|
-
template.replace(/(
|
|
556
|
-
|
|
557
|
-
|
|
549
|
+
template.replace(removeBrackets ? /{{\s*(.+?)\s*}}/g : /(\{{.+?\}})/g, (foundToken, token) => {
|
|
550
|
+
const tokenWithVar = removeBrackets ? token : foundToken;
|
|
551
|
+
tokens.push(tokenWithVar);
|
|
552
|
+
return tokenWithVar;
|
|
558
553
|
});
|
|
559
554
|
}
|
|
560
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))) {
|