@movable/studio-framework 3.5.1 → 3.6.0
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/dist/index.es.js +59 -1
- package/dist/index.js +59 -1
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -2691,11 +2691,62 @@ class StudioFramework {
|
|
|
2691
2691
|
conditionalDynamicProperty
|
|
2692
2692
|
} = model;
|
|
2693
2693
|
if (!conditionalDynamicProperty) return [true, null];
|
|
2694
|
+
return this.resolveCondition(conditionalDynamicProperty);
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
async resolveCondition(expression) {
|
|
2698
|
+
if ('operator' in expression) {
|
|
2699
|
+
const {
|
|
2700
|
+
operator,
|
|
2701
|
+
operands
|
|
2702
|
+
} = expression;
|
|
2703
|
+
|
|
2704
|
+
if (!operands?.length) {
|
|
2705
|
+
return [false, new Error(`Missing operands for logical operation: ${operator}`)];
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
switch (operator) {
|
|
2709
|
+
case 'AND':
|
|
2710
|
+
{
|
|
2711
|
+
for (const operand of operands) {
|
|
2712
|
+
const [result, error] = await this.evaluateOperand(operand);
|
|
2713
|
+
if (error) return [false, error];
|
|
2714
|
+
if (!result) return [false, null]; // Short-circuit AND on first false
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
return [true, null]; // All conditions were true
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
case 'OR':
|
|
2721
|
+
{
|
|
2722
|
+
for (const operand of operands) {
|
|
2723
|
+
const [result, error] = await this.evaluateOperand(operand);
|
|
2724
|
+
if (error) return [false, error];
|
|
2725
|
+
if (result) return [true, null]; // Short-circuit OR on first true
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
return [false, null]; // No conditions were true
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
default:
|
|
2732
|
+
return [false, new Error(`Unsupported operator: ${operator}`)];
|
|
2733
|
+
}
|
|
2734
|
+
} // Simple dynamic property case
|
|
2735
|
+
|
|
2736
|
+
|
|
2737
|
+
return this.evaluateOperand(expression);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
async evaluateOperand(operand) {
|
|
2741
|
+
if ('operator' in operand) {
|
|
2742
|
+
return this.resolveCondition(operand);
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2694
2745
|
const {
|
|
2695
2746
|
propertyGroupKey = '',
|
|
2696
2747
|
propertyPath = '',
|
|
2697
2748
|
context = {}
|
|
2698
|
-
} =
|
|
2749
|
+
} = operand;
|
|
2699
2750
|
return this.getPropertyTuple(propertyGroupKey, propertyPath, context);
|
|
2700
2751
|
}
|
|
2701
2752
|
|
|
@@ -3070,6 +3121,12 @@ class StudioFramework {
|
|
|
3070
3121
|
CD.resume();
|
|
3071
3122
|
}
|
|
3072
3123
|
|
|
3124
|
+
logCurrentCanvas(currentCanvas) {
|
|
3125
|
+
if (window.MICapture?.setCanvasKey) {
|
|
3126
|
+
window.MICapture.setCanvasKey(currentCanvas.name);
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3073
3130
|
async render(targetElement) {
|
|
3074
3131
|
if (window.MICapture?.isPreview) console.log('Preview Render');
|
|
3075
3132
|
let currentCanvas;
|
|
@@ -3077,6 +3134,7 @@ class StudioFramework {
|
|
|
3077
3134
|
try {
|
|
3078
3135
|
CD.pause();
|
|
3079
3136
|
currentCanvas = await this.getCurrentCanvas();
|
|
3137
|
+
this.logCurrentCanvas(currentCanvas);
|
|
3080
3138
|
const clickthroughURL = await this.handleClickthrough(currentCanvas);
|
|
3081
3139
|
const canvasTags = currentCanvas?.tags || [];
|
|
3082
3140
|
const tags = await this.getCurrentTags(canvasTags, currentCanvas);
|
package/dist/index.js
CHANGED
|
@@ -2701,11 +2701,62 @@ class StudioFramework {
|
|
|
2701
2701
|
conditionalDynamicProperty
|
|
2702
2702
|
} = model;
|
|
2703
2703
|
if (!conditionalDynamicProperty) return [true, null];
|
|
2704
|
+
return this.resolveCondition(conditionalDynamicProperty);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
async resolveCondition(expression) {
|
|
2708
|
+
if ('operator' in expression) {
|
|
2709
|
+
const {
|
|
2710
|
+
operator,
|
|
2711
|
+
operands
|
|
2712
|
+
} = expression;
|
|
2713
|
+
|
|
2714
|
+
if (!operands?.length) {
|
|
2715
|
+
return [false, new Error(`Missing operands for logical operation: ${operator}`)];
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
switch (operator) {
|
|
2719
|
+
case 'AND':
|
|
2720
|
+
{
|
|
2721
|
+
for (const operand of operands) {
|
|
2722
|
+
const [result, error] = await this.evaluateOperand(operand);
|
|
2723
|
+
if (error) return [false, error];
|
|
2724
|
+
if (!result) return [false, null]; // Short-circuit AND on first false
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
return [true, null]; // All conditions were true
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
case 'OR':
|
|
2731
|
+
{
|
|
2732
|
+
for (const operand of operands) {
|
|
2733
|
+
const [result, error] = await this.evaluateOperand(operand);
|
|
2734
|
+
if (error) return [false, error];
|
|
2735
|
+
if (result) return [true, null]; // Short-circuit OR on first true
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
return [false, null]; // No conditions were true
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
default:
|
|
2742
|
+
return [false, new Error(`Unsupported operator: ${operator}`)];
|
|
2743
|
+
}
|
|
2744
|
+
} // Simple dynamic property case
|
|
2745
|
+
|
|
2746
|
+
|
|
2747
|
+
return this.evaluateOperand(expression);
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
async evaluateOperand(operand) {
|
|
2751
|
+
if ('operator' in operand) {
|
|
2752
|
+
return this.resolveCondition(operand);
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2704
2755
|
const {
|
|
2705
2756
|
propertyGroupKey = '',
|
|
2706
2757
|
propertyPath = '',
|
|
2707
2758
|
context = {}
|
|
2708
|
-
} =
|
|
2759
|
+
} = operand;
|
|
2709
2760
|
return this.getPropertyTuple(propertyGroupKey, propertyPath, context);
|
|
2710
2761
|
}
|
|
2711
2762
|
|
|
@@ -3080,6 +3131,12 @@ class StudioFramework {
|
|
|
3080
3131
|
CD__default['default'].resume();
|
|
3081
3132
|
}
|
|
3082
3133
|
|
|
3134
|
+
logCurrentCanvas(currentCanvas) {
|
|
3135
|
+
if (window.MICapture?.setCanvasKey) {
|
|
3136
|
+
window.MICapture.setCanvasKey(currentCanvas.name);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3083
3140
|
async render(targetElement) {
|
|
3084
3141
|
if (window.MICapture?.isPreview) console.log('Preview Render');
|
|
3085
3142
|
let currentCanvas;
|
|
@@ -3087,6 +3144,7 @@ class StudioFramework {
|
|
|
3087
3144
|
try {
|
|
3088
3145
|
CD__default['default'].pause();
|
|
3089
3146
|
currentCanvas = await this.getCurrentCanvas();
|
|
3147
|
+
this.logCurrentCanvas(currentCanvas);
|
|
3090
3148
|
const clickthroughURL = await this.handleClickthrough(currentCanvas);
|
|
3091
3149
|
const canvasTags = currentCanvas?.tags || [];
|
|
3092
3150
|
const tags = await this.getCurrentTags(canvasTags, currentCanvas);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movable/studio-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "A Component library for reactive Studio apps.",
|
|
5
5
|
"author": "Movable Ink",
|
|
6
6
|
"repository": "movableink/studio-framework",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@babel/preset-react": "^7.14.5",
|
|
32
32
|
"@babel/preset-typescript": "^7.13.0",
|
|
33
33
|
"@movable/eslint-config-react": "^1.0.1",
|
|
34
|
-
"@movable/framework-types": "^3.
|
|
35
|
-
"@movable/studio-framework-test-helpers": "^3.
|
|
34
|
+
"@movable/framework-types": "^3.6.0",
|
|
35
|
+
"@movable/studio-framework-test-helpers": "^3.6.0",
|
|
36
36
|
"@types/qunit": "^2.11.1",
|
|
37
37
|
"@types/qunit-dom": "^0.7.0",
|
|
38
38
|
"@types/react": "^17.0.6",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"volta": {
|
|
67
67
|
"extends": "../../package.json"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "f147d1c8f7b5f0abb762d8cd1c7f8709b890be2b"
|
|
70
70
|
}
|