@uniformdev/canvas 20.12.1-alpha.23 → 20.12.1-alpha.26

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
@@ -553,7 +553,7 @@ interface components$n {
553
553
  categoryId?: string | null;
554
554
  /** @description Description of the component definition */
555
555
  description?: string;
556
- /** @description Description of the component definition */
556
+ /** @description Preview image URL for the component definition (shown in the UI) */
557
557
  previewImageUrl?: string;
558
558
  /**
559
559
  * @description if this component uses team permissions or custom permissions
@@ -778,7 +778,7 @@ interface components$m {
778
778
  categoryId?: string | null;
779
779
  /** @description Description of the component definition */
780
780
  description?: string;
781
- /** @description Description of the component definition */
781
+ /** @description Preview image URL for the component definition (shown in the UI) */
782
782
  previewImageUrl?: string;
783
783
  /**
784
784
  * @description if this component uses team permissions or custom permissions
@@ -10105,10 +10105,7 @@ interface paths$6 {
10105
10105
  path?: never;
10106
10106
  cookie?: never;
10107
10107
  };
10108
- /**
10109
- * @deprecated
10110
- * @description Gets all preview URLs
10111
- */
10108
+ /** @description Gets all preview URLs */
10112
10109
  get: {
10113
10110
  parameters: {
10114
10111
  query: {
@@ -10153,10 +10150,7 @@ interface paths$6 {
10153
10150
  500: components$6["responses"]["InternalServerError"];
10154
10151
  };
10155
10152
  };
10156
- /**
10157
- * @deprecated
10158
- * @description Upserts a preview URL
10159
- */
10153
+ /** @description Upserts a preview URL */
10160
10154
  put: {
10161
10155
  parameters: {
10162
10156
  query?: never;
@@ -10218,10 +10212,7 @@ interface paths$6 {
10218
10212
  };
10219
10213
  };
10220
10214
  post?: never;
10221
- /**
10222
- * @deprecated
10223
- * @description Deletes a preview URL
10224
- */
10215
+ /** @description Deletes a preview URL */
10225
10216
  delete: {
10226
10217
  parameters: {
10227
10218
  query?: never;
@@ -12106,13 +12097,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
12106
12097
  * When false, indeterminate criteria will fail the summary result, and the node will be hidden
12107
12098
  */
12108
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';
12109
12106
  }
12110
12107
  /**
12111
12108
  * Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
12112
12109
  *
12113
12110
  * If the function returns false, that means the current node is removed and you should stop any other code handling.
12114
12111
  */
12115
- declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12112
+ declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12116
12113
 
12117
12114
  interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
12118
12115
  node: ComponentInstance;
@@ -12402,8 +12399,6 @@ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
12402
12399
 
12403
12400
  /**
12404
12401
  * API client to work with Uniform Project Preview entities
12405
- *
12406
- * @deprecated beta functionality subject to change
12407
12402
  */
12408
12403
  declare class PreviewClient extends ApiClient {
12409
12404
  constructor(options: ClientOptions);
package/dist/index.d.ts CHANGED
@@ -553,7 +553,7 @@ interface components$n {
553
553
  categoryId?: string | null;
554
554
  /** @description Description of the component definition */
555
555
  description?: string;
556
- /** @description Description of the component definition */
556
+ /** @description Preview image URL for the component definition (shown in the UI) */
557
557
  previewImageUrl?: string;
558
558
  /**
559
559
  * @description if this component uses team permissions or custom permissions
@@ -778,7 +778,7 @@ interface components$m {
778
778
  categoryId?: string | null;
779
779
  /** @description Description of the component definition */
780
780
  description?: string;
781
- /** @description Description of the component definition */
781
+ /** @description Preview image URL for the component definition (shown in the UI) */
782
782
  previewImageUrl?: string;
783
783
  /**
784
784
  * @description if this component uses team permissions or custom permissions
@@ -10105,10 +10105,7 @@ interface paths$6 {
10105
10105
  path?: never;
10106
10106
  cookie?: never;
10107
10107
  };
10108
- /**
10109
- * @deprecated
10110
- * @description Gets all preview URLs
10111
- */
10108
+ /** @description Gets all preview URLs */
10112
10109
  get: {
10113
10110
  parameters: {
10114
10111
  query: {
@@ -10153,10 +10150,7 @@ interface paths$6 {
10153
10150
  500: components$6["responses"]["InternalServerError"];
10154
10151
  };
10155
10152
  };
10156
- /**
10157
- * @deprecated
10158
- * @description Upserts a preview URL
10159
- */
10153
+ /** @description Upserts a preview URL */
10160
10154
  put: {
10161
10155
  parameters: {
10162
10156
  query?: never;
@@ -10218,10 +10212,7 @@ interface paths$6 {
10218
10212
  };
10219
10213
  };
10220
10214
  post?: never;
10221
- /**
10222
- * @deprecated
10223
- * @description Deletes a preview URL
10224
- */
10215
+ /** @description Deletes a preview URL */
10225
10216
  delete: {
10226
10217
  parameters: {
10227
10218
  query?: never;
@@ -12106,13 +12097,19 @@ interface EvaluateNodeTreeVisibilityOptions extends Pick<EvaluateNodeVisibilityO
12106
12097
  * When false, indeterminate criteria will fail the summary result, and the node will be hidden
12107
12098
  */
12108
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';
12109
12106
  }
12110
12107
  /**
12111
12108
  * Function to call to evaluate visibility rules when traversing the node tree with walkNodeTree.
12112
12109
  *
12113
12110
  * If the function returns false, that means the current node is removed and you should stop any other code handling.
12114
12111
  */
12115
- declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12112
+ declare function evaluateWalkTreeNodeVisibility({ rules, showIndeterminate, rootNodeInvisibleHandling, context, }: EvaluateNodeTreeVisibilityOptions): boolean | undefined;
12116
12113
 
12117
12114
  interface EvaluateWalkTreePropertyCriteriaOptions extends Pick<EvaluatePropertyCriteriaOptions, 'rules' | 'keepIndeterminate'> {
12118
12115
  node: ComponentInstance;
@@ -12402,8 +12399,6 @@ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
12402
12399
 
12403
12400
  /**
12404
12401
  * API client to work with Uniform Project Preview entities
12405
- *
12406
- * @deprecated beta functionality subject to change
12407
12402
  */
12408
12403
  declare class PreviewClient extends ApiClient {
12409
12404
  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.12.1-alpha.23+36df23cbe9",
3
+ "version": "20.12.1-alpha.26+727af74745",
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.12.1-alpha.23+36df23cbe9",
42
- "@uniformdev/context": "20.12.1-alpha.23+36df23cbe9",
43
- "@uniformdev/richtext": "20.12.1-alpha.23+36df23cbe9",
41
+ "@uniformdev/assets": "20.12.1-alpha.26+727af74745",
42
+ "@uniformdev/context": "20.12.1-alpha.26+727af74745",
43
+ "@uniformdev/richtext": "20.12.1-alpha.26+727af74745",
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": "36df23cbe9ca246137efcf2f4a57e04d029406cc"
52
+ "gitHead": "727af74745bafe690997e093f65e0c3d0aef5a45"
53
53
  }