@uniformdev/canvas 20.13.3-alpha.12 → 20.14.1
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.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +21 -20
- package/dist/index.js +21 -20
- package/dist/index.mjs +21 -20
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
@@ -12097,13 +12097,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
|
|
12097
12097
|
* When false, indeterminate criteria will fail the summary result, and the node will be hidden
|
12098
12098
|
*/
|
12099
12099
|
showIndeterminate?: boolean;
|
12100
|
+
/**
|
12101
|
+
* When evaluating visibility of a root node, this controls what happens when the node is found to be invisible.
|
12102
|
+
* When 'throw' (default), an error is thrown.
|
12103
|
+
* When 'ignore', the node is left intact. False is still returned.
|
12104
|
+
*/
|
12105
|
+
rootNodeInvisibleHandling?: 'throw' | 'ignore';
|
12100
12106
|
}
|
12101
12107
|
/**
|
12102
12108
|
* Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
|
12103
12109
|
*
|
12104
12110
|
* If the function returns false, that means the current node is removed and you should stop any other code handling.
|
12105
12111
|
*/
|
12106
|
-
declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
|
12112
|
+
declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
|
12107
12113
|
|
12108
12114
|
interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
|
12109
12115
|
node: ComponentInstance;
|
package/dist/index.d.ts
CHANGED
@@ -12097,13 +12097,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
|
|
12097
12097
|
* When false, indeterminate criteria will fail the summary result, and the node will be hidden
|
12098
12098
|
*/
|
12099
12099
|
showIndeterminate?: boolean;
|
12100
|
+
/**
|
12101
|
+
* When evaluating visibility of a root node, this controls what happens when the node is found to be invisible.
|
12102
|
+
* When 'throw' (default), an error is thrown.
|
12103
|
+
* When 'ignore', the node is left intact. False is still returned.
|
12104
|
+
*/
|
12105
|
+
rootNodeInvisibleHandling?: 'throw' | 'ignore';
|
12100
12106
|
}
|
12101
12107
|
/**
|
12102
12108
|
* Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
|
12103
12109
|
*
|
12104
12110
|
* If the function returns false, that means the current node is removed and you should stop any other code handling.
|
12105
12111
|
*/
|
12106
|
-
declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
|
12112
|
+
declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
|
12107
12113
|
|
12108
12114
|
interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
|
12109
12115
|
node: ComponentInstance;
|
package/dist/index.esm.js
CHANGED
@@ -2092,15 +2092,19 @@ function evaluateNodeVisibility({
|
|
2092
2092
|
function evaluateWalkTreeNodeVisibility({
|
2093
2093
|
rules,
|
2094
2094
|
showIndeterminate,
|
2095
|
+
rootNodeInvisibleHandling = "throw",
|
2095
2096
|
context
|
2096
2097
|
}) {
|
2097
|
-
const { type, node, actions } = context;
|
2098
|
+
const { type, node, actions, ancestorsAndSelf } = context;
|
2098
2099
|
if (type !== "component") {
|
2099
2100
|
return;
|
2100
2101
|
}
|
2101
2102
|
const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
|
2102
2103
|
if (result === null && !showIndeterminate || result === false) {
|
2103
|
-
|
2104
|
+
if (ancestorsAndSelf.length === 1 && rootNodeInvisibleHandling === "ignore") {
|
2105
|
+
} else {
|
2106
|
+
actions.remove();
|
2107
|
+
}
|
2104
2108
|
return false;
|
2105
2109
|
}
|
2106
2110
|
return true;
|
@@ -2336,25 +2340,24 @@ function extractLocales({ component }) {
|
|
2336
2340
|
function localize(options) {
|
2337
2341
|
const nodes = options.nodes;
|
2338
2342
|
const locale = options.locale;
|
2339
|
-
|
2340
|
-
|
2343
|
+
if (!locale) {
|
2344
|
+
return;
|
2345
|
+
}
|
2346
|
+
const vizControlLocaleRule = createLocaleVisibilityRule(locale);
|
2341
2347
|
walkNodeTree(nodes, (context) => {
|
2342
2348
|
const { type, node, actions } = context;
|
2343
2349
|
if (type !== "component") {
|
2344
|
-
|
2345
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
2346
|
-
}
|
2350
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2347
2351
|
return;
|
2348
2352
|
}
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
}
|
2353
|
+
const result = evaluateWalkTreeNodeVisibility({
|
2354
|
+
context,
|
2355
|
+
rules: vizControlLocaleRule,
|
2356
|
+
showIndeterminate: true,
|
2357
|
+
rootNodeInvisibleHandling: "ignore"
|
2358
|
+
});
|
2359
|
+
if (!result) {
|
2360
|
+
return;
|
2358
2361
|
}
|
2359
2362
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
2360
2363
|
const locales = extractLocales({ component: node });
|
@@ -2365,9 +2368,7 @@ function localize(options) {
|
|
2365
2368
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
2366
2369
|
replaceComponent.forEach((component) => {
|
2367
2370
|
removeLocaleProperty(component);
|
2368
|
-
|
2369
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
2370
|
-
}
|
2371
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
2371
2372
|
});
|
2372
2373
|
const [first, ...rest] = replaceComponent;
|
2373
2374
|
actions.replace(first);
|
@@ -2377,7 +2378,7 @@ function localize(options) {
|
|
2377
2378
|
} else {
|
2378
2379
|
actions.remove();
|
2379
2380
|
}
|
2380
|
-
} else
|
2381
|
+
} else {
|
2381
2382
|
localizeProperties(node, locale, vizControlLocaleRule);
|
2382
2383
|
}
|
2383
2384
|
});
|
package/dist/index.js
CHANGED
@@ -2255,15 +2255,19 @@ function evaluateNodeVisibility({
|
|
2255
2255
|
function evaluateWalkTreeNodeVisibility({
|
2256
2256
|
rules,
|
2257
2257
|
showIndeterminate,
|
2258
|
+
rootNodeInvisibleHandling = "throw",
|
2258
2259
|
context
|
2259
2260
|
}) {
|
2260
|
-
const { type, node, actions } = context;
|
2261
|
+
const { type, node, actions, ancestorsAndSelf } = context;
|
2261
2262
|
if (type !== "component") {
|
2262
2263
|
return;
|
2263
2264
|
}
|
2264
2265
|
const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
|
2265
2266
|
if (result === null && !showIndeterminate || result === false) {
|
2266
|
-
|
2267
|
+
if (ancestorsAndSelf.length === 1 && rootNodeInvisibleHandling === "ignore") {
|
2268
|
+
} else {
|
2269
|
+
actions.remove();
|
2270
|
+
}
|
2267
2271
|
return false;
|
2268
2272
|
}
|
2269
2273
|
return true;
|
@@ -2499,25 +2503,24 @@ function extractLocales({ component }) {
|
|
2499
2503
|
function localize(options) {
|
2500
2504
|
const nodes = options.nodes;
|
2501
2505
|
const locale = options.locale;
|
2502
|
-
|
2503
|
-
|
2506
|
+
if (!locale) {
|
2507
|
+
return;
|
2508
|
+
}
|
2509
|
+
const vizControlLocaleRule = createLocaleVisibilityRule(locale);
|
2504
2510
|
walkNodeTree(nodes, (context) => {
|
2505
2511
|
const { type, node, actions } = context;
|
2506
2512
|
if (type !== "component") {
|
2507
|
-
|
2508
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
2509
|
-
}
|
2513
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2510
2514
|
return;
|
2511
2515
|
}
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
}
|
2516
|
+
const result = evaluateWalkTreeNodeVisibility({
|
2517
|
+
context,
|
2518
|
+
rules: vizControlLocaleRule,
|
2519
|
+
showIndeterminate: true,
|
2520
|
+
rootNodeInvisibleHandling: "ignore"
|
2521
|
+
});
|
2522
|
+
if (!result) {
|
2523
|
+
return;
|
2521
2524
|
}
|
2522
2525
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
2523
2526
|
const locales = extractLocales({ component: node });
|
@@ -2528,9 +2531,7 @@ function localize(options) {
|
|
2528
2531
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
2529
2532
|
replaceComponent.forEach((component) => {
|
2530
2533
|
removeLocaleProperty(component);
|
2531
|
-
|
2532
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
2533
|
-
}
|
2534
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
2534
2535
|
});
|
2535
2536
|
const [first, ...rest] = replaceComponent;
|
2536
2537
|
actions.replace(first);
|
@@ -2540,7 +2541,7 @@ function localize(options) {
|
|
2540
2541
|
} else {
|
2541
2542
|
actions.remove();
|
2542
2543
|
}
|
2543
|
-
} else
|
2544
|
+
} else {
|
2544
2545
|
localizeProperties(node, locale, vizControlLocaleRule);
|
2545
2546
|
}
|
2546
2547
|
});
|
package/dist/index.mjs
CHANGED
@@ -2092,15 +2092,19 @@ function evaluateNodeVisibility({
|
|
2092
2092
|
function evaluateWalkTreeNodeVisibility({
|
2093
2093
|
rules,
|
2094
2094
|
showIndeterminate,
|
2095
|
+
rootNodeInvisibleHandling = "throw",
|
2095
2096
|
context
|
2096
2097
|
}) {
|
2097
|
-
const { type, node, actions } = context;
|
2098
|
+
const { type, node, actions, ancestorsAndSelf } = context;
|
2098
2099
|
if (type !== "component") {
|
2099
2100
|
return;
|
2100
2101
|
}
|
2101
2102
|
const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
|
2102
2103
|
if (result === null && !showIndeterminate || result === false) {
|
2103
|
-
|
2104
|
+
if (ancestorsAndSelf.length === 1 && rootNodeInvisibleHandling === "ignore") {
|
2105
|
+
} else {
|
2106
|
+
actions.remove();
|
2107
|
+
}
|
2104
2108
|
return false;
|
2105
2109
|
}
|
2106
2110
|
return true;
|
@@ -2336,25 +2340,24 @@ function extractLocales({ component }) {
|
|
2336
2340
|
function localize(options) {
|
2337
2341
|
const nodes = options.nodes;
|
2338
2342
|
const locale = options.locale;
|
2339
|
-
|
2340
|
-
|
2343
|
+
if (!locale) {
|
2344
|
+
return;
|
2345
|
+
}
|
2346
|
+
const vizControlLocaleRule = createLocaleVisibilityRule(locale);
|
2341
2347
|
walkNodeTree(nodes, (context) => {
|
2342
2348
|
const { type, node, actions } = context;
|
2343
2349
|
if (type !== "component") {
|
2344
|
-
|
2345
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
2346
|
-
}
|
2350
|
+
localizeProperties(node, locale, vizControlLocaleRule);
|
2347
2351
|
return;
|
2348
2352
|
}
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
}
|
2353
|
+
const result = evaluateWalkTreeNodeVisibility({
|
2354
|
+
context,
|
2355
|
+
rules: vizControlLocaleRule,
|
2356
|
+
showIndeterminate: true,
|
2357
|
+
rootNodeInvisibleHandling: "ignore"
|
2358
|
+
});
|
2359
|
+
if (!result) {
|
2360
|
+
return;
|
2358
2361
|
}
|
2359
2362
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
2360
2363
|
const locales = extractLocales({ component: node });
|
@@ -2365,9 +2368,7 @@ function localize(options) {
|
|
2365
2368
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
2366
2369
|
replaceComponent.forEach((component) => {
|
2367
2370
|
removeLocaleProperty(component);
|
2368
|
-
|
2369
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
2370
|
-
}
|
2371
|
+
localizeProperties(component, locale, vizControlLocaleRule);
|
2371
2372
|
});
|
2372
2373
|
const [first, ...rest] = replaceComponent;
|
2373
2374
|
actions.replace(first);
|
@@ -2377,7 +2378,7 @@ function localize(options) {
|
|
2377
2378
|
} else {
|
2378
2379
|
actions.remove();
|
2379
2380
|
}
|
2380
|
-
} else
|
2381
|
+
} else {
|
2381
2382
|
localizeProperties(node, locale, vizControlLocaleRule);
|
2382
2383
|
}
|
2383
2384
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.14.1",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -38,9 +38,9 @@
|
|
38
38
|
"p-throttle": "5.0.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "20.
|
42
|
-
"@uniformdev/context": "20.
|
43
|
-
"@uniformdev/richtext": "20.
|
41
|
+
"@uniformdev/assets": "20.14.1",
|
42
|
+
"@uniformdev/context": "20.14.1",
|
43
|
+
"@uniformdev/richtext": "20.14.1",
|
44
44
|
"immer": "10.1.1"
|
45
45
|
},
|
46
46
|
"files": [
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "1cf777c56f2e7f08514fd44b40700579c48a9c71"
|
53
53
|
}
|