@uniformdev/canvas 20.13.3-alpha.12 → 20.14.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.d.mts CHANGED
@@ -10105,7 +10105,10 @@ interface paths$6 {
10105
10105
  path?: never;
10106
10106
  cookie?: never;
10107
10107
  };
10108
- /** @description Gets all preview URLs */
10108
+ /**
10109
+ * @deprecated
10110
+ * @description Gets all preview URLs
10111
+ */
10109
10112
  get: {
10110
10113
  parameters: {
10111
10114
  query: {
@@ -10150,7 +10153,10 @@ interface paths$6 {
10150
10153
  500: components$6["responses"]["InternalServerError"];
10151
10154
  };
10152
10155
  };
10153
- /** @description Upserts a preview URL */
10156
+ /**
10157
+ * @deprecated
10158
+ * @description Upserts a preview URL
10159
+ */
10154
10160
  put: {
10155
10161
  parameters: {
10156
10162
  query?: never;
@@ -10212,7 +10218,10 @@ interface paths$6 {
10212
10218
  };
10213
10219
  };
10214
10220
  post?: never;
10215
- /** @description Deletes a preview URL */
10221
+ /**
10222
+ * @deprecated
10223
+ * @description Deletes a preview URL
10224
+ */
10216
10225
  delete: {
10217
10226
  parameters: {
10218
10227
  query?: never;
@@ -12097,13 +12106,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
12097
12106
  * When false, indeterminate criteria will fail the summary result, and the node will be hidden
12098
12107
  */
12099
12108
  showIndeterminate?: boolean;
12109
+ /**
12110
+ * When evaluating visibility of a root node, this controls what happens when the node is found to be invisible.
12111
+ * When 'throw' (default), an error is thrown.
12112
+ * When 'ignore', the node is left intact. False is still returned.
12113
+ */
12114
+ rootNodeInvisibleHandling?: 'throw' | 'ignore';
12100
12115
  }
12101
12116
  /**
12102
12117
  * Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
12103
12118
  *
12104
12119
  * If the function returns false, that means the current node is removed and you should stop any other code handling.
12105
12120
  */
12106
- declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12121
+ declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12107
12122
 
12108
12123
  interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
12109
12124
  node: ComponentInstance;
@@ -12393,6 +12408,8 @@ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
12393
12408
 
12394
12409
  /**
12395
12410
  * API client to work with Uniform Project Preview entities
12411
+ *
12412
+ * @deprecated beta functionality subject to change
12396
12413
  */
12397
12414
  declare class PreviewClient extends ApiClient {
12398
12415
  constructor(options: ClientOptions);
package/dist/index.d.ts CHANGED
@@ -10105,7 +10105,10 @@ interface paths$6 {
10105
10105
  path?: never;
10106
10106
  cookie?: never;
10107
10107
  };
10108
- /** @description Gets all preview URLs */
10108
+ /**
10109
+ * @deprecated
10110
+ * @description Gets all preview URLs
10111
+ */
10109
10112
  get: {
10110
10113
  parameters: {
10111
10114
  query: {
@@ -10150,7 +10153,10 @@ interface paths$6 {
10150
10153
  500: components$6["responses"]["InternalServerError"];
10151
10154
  };
10152
10155
  };
10153
- /** @description Upserts a preview URL */
10156
+ /**
10157
+ * @deprecated
10158
+ * @description Upserts a preview URL
10159
+ */
10154
10160
  put: {
10155
10161
  parameters: {
10156
10162
  query?: never;
@@ -10212,7 +10218,10 @@ interface paths$6 {
10212
10218
  };
10213
10219
  };
10214
10220
  post?: never;
10215
- /** @description Deletes a preview URL */
10221
+ /**
10222
+ * @deprecated
10223
+ * @description Deletes a preview URL
10224
+ */
10216
10225
  delete: {
10217
10226
  parameters: {
10218
10227
  query?: never;
@@ -12097,13 +12106,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
12097
12106
  * When false, indeterminate criteria will fail the summary result, and the node will be hidden
12098
12107
  */
12099
12108
  showIndeterminate?: boolean;
12109
+ /**
12110
+ * When evaluating visibility of a root node, this controls what happens when the node is found to be invisible.
12111
+ * When 'throw' (default), an error is thrown.
12112
+ * When 'ignore', the node is left intact. False is still returned.
12113
+ */
12114
+ rootNodeInvisibleHandling?: 'throw' | 'ignore';
12100
12115
  }
12101
12116
  /**
12102
12117
  * Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
12103
12118
  *
12104
12119
  * If the function returns false, that means the current node is removed and you should stop any other code handling.
12105
12120
  */
12106
- declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12121
+ declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12107
12122
 
12108
12123
  interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
12109
12124
  node: ComponentInstance;
@@ -12393,6 +12408,8 @@ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
12393
12408
 
12394
12409
  /**
12395
12410
  * API client to work with Uniform Project Preview entities
12411
+ *
12412
+ * @deprecated beta functionality subject to change
12396
12413
  */
12397
12414
  declare class PreviewClient extends ApiClient {
12398
12415
  constructor(options: ClientOptions);
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
- actions.remove();
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
- const isUsingModernOptions = typeof locale === "string";
2340
- const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
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
- if (isUsingModernOptions) {
2345
- localizeProperties(node, locale, vizControlLocaleRule);
2346
- }
2350
+ localizeProperties(node, locale, vizControlLocaleRule);
2347
2351
  return;
2348
2352
  }
2349
- if (isUsingModernOptions) {
2350
- const result = evaluateWalkTreeNodeVisibility({
2351
- context,
2352
- rules: vizControlLocaleRule,
2353
- showIndeterminate: true
2354
- });
2355
- if (!result) {
2356
- return;
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
- if (isUsingModernOptions) {
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 if (isUsingModernOptions) {
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
- actions.remove();
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
- const isUsingModernOptions = typeof locale === "string";
2503
- const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
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
- if (isUsingModernOptions) {
2508
- localizeProperties(node, locale, vizControlLocaleRule);
2509
- }
2513
+ localizeProperties(node, locale, vizControlLocaleRule);
2510
2514
  return;
2511
2515
  }
2512
- if (isUsingModernOptions) {
2513
- const result = evaluateWalkTreeNodeVisibility({
2514
- context,
2515
- rules: vizControlLocaleRule,
2516
- showIndeterminate: true
2517
- });
2518
- if (!result) {
2519
- return;
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
- if (isUsingModernOptions) {
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 if (isUsingModernOptions) {
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
- actions.remove();
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
- const isUsingModernOptions = typeof locale === "string";
2340
- const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
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
- if (isUsingModernOptions) {
2345
- localizeProperties(node, locale, vizControlLocaleRule);
2346
- }
2350
+ localizeProperties(node, locale, vizControlLocaleRule);
2347
2351
  return;
2348
2352
  }
2349
- if (isUsingModernOptions) {
2350
- const result = evaluateWalkTreeNodeVisibility({
2351
- context,
2352
- rules: vizControlLocaleRule,
2353
- showIndeterminate: true
2354
- });
2355
- if (!result) {
2356
- return;
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
- if (isUsingModernOptions) {
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 if (isUsingModernOptions) {
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.13.3-alpha.12+21928e999b",
3
+ "version": "20.14.0",
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.13.3-alpha.12+21928e999b",
42
- "@uniformdev/context": "20.13.3-alpha.12+21928e999b",
43
- "@uniformdev/richtext": "20.13.3-alpha.12+21928e999b",
41
+ "@uniformdev/assets": "20.14.0",
42
+ "@uniformdev/context": "20.14.0",
43
+ "@uniformdev/richtext": "20.14.0",
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": "21928e999b3570c04b285c4e9793a34ad6c43b5e"
52
+ "gitHead": "958a8fe27da8ec9191a1a09f289f6f7418dd16d6"
53
53
  }