@uniformdev/canvas-react 20.36.2-alpha.90 → 20.37.1-alpha.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 CHANGED
@@ -2,7 +2,6 @@ import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
4
  import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.mjs';
5
- import { CompositionMetadata } from '@uniformdev/context';
6
5
  import { RichTextNode } from '@uniformdev/richtext';
7
6
 
8
7
  /**
@@ -728,12 +727,12 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
728
727
  isContextualEditing: boolean;
729
728
  };
730
729
 
731
- type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & Omit<CompositionMetadata, 'compositionId'> & {
730
+ type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & {
732
731
  /** The composition data */
733
732
  data?: RootComponentInstance;
734
733
  contextualEditingEnhancer?: UseUniformContextualEditingProps['enhance'];
735
734
  };
736
- type UniformCompositionContextValue = Omit<CompositionMetadata, 'compositionId'> & {
735
+ type UniformCompositionContextValue = {
737
736
  data: UniformCompositionProps['data'] | undefined;
738
737
  resolveRenderer?: UniformCompositionProps['resolveRenderer'];
739
738
  behaviorTracking?: UniformCompositionProps['behaviorTracking'];
@@ -749,7 +748,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
749
748
  * It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
750
749
  * It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
751
750
  */
752
- declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, matchedRoute, dynamicInputs, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
751
+ declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
753
752
 
754
753
  type UniformPlaygroundDecorator = (props: {
755
754
  /** The rendered component instance, needs to be wrapped and rendered by the decorator */
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
4
  import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.js';
5
- import { CompositionMetadata } from '@uniformdev/context';
6
5
  import { RichTextNode } from '@uniformdev/richtext';
7
6
 
8
7
  /**
@@ -728,12 +727,12 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
728
727
  isContextualEditing: boolean;
729
728
  };
730
729
 
731
- type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & Omit<CompositionMetadata, 'compositionId'> & {
730
+ type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & {
732
731
  /** The composition data */
733
732
  data?: RootComponentInstance;
734
733
  contextualEditingEnhancer?: UseUniformContextualEditingProps['enhance'];
735
734
  };
736
- type UniformCompositionContextValue = Omit<CompositionMetadata, 'compositionId'> & {
735
+ type UniformCompositionContextValue = {
737
736
  data: UniformCompositionProps['data'] | undefined;
738
737
  resolveRenderer?: UniformCompositionProps['resolveRenderer'];
739
738
  behaviorTracking?: UniformCompositionProps['behaviorTracking'];
@@ -749,7 +748,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
749
748
  * It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
750
749
  * It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
751
750
  */
752
- declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, matchedRoute, dynamicInputs, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
751
+ declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
753
752
 
754
753
  type UniformPlaygroundDecorator = (props: {
755
754
  /** The rendered component instance, needs to be wrapped and rendered by the decorator */
package/dist/index.esm.js CHANGED
@@ -77,7 +77,7 @@ registerUniformComponent({ type: "${componentType}", component: ${proposedFileNa
77
77
  import {
78
78
  CANVAS_ENRICHMENT_TAG_PARAM
79
79
  } from "@uniformdev/canvas";
80
- import { Track, TrackFragment, useUniformContext as useUniformContext2 } from "@uniformdev/context-react";
80
+ import { Track, TrackFragment, useUniformContext } from "@uniformdev/context-react";
81
81
  import React7, { createContext as createContext2, useContext as useContext2 } from "react";
82
82
 
83
83
  // src/helpers/convertComponentToProps.ts
@@ -155,11 +155,87 @@ import {
155
155
  mapSlotToTestVariations
156
156
  } from "@uniformdev/canvas";
157
157
  import { Personalize, Test } from "@uniformdev/context-react";
158
- import * as React5 from "react";
158
+ import * as React2 from "react";
159
+ var defaultSystemComponentResolver = {
160
+ test: (component, key, renderChild) => {
161
+ var _a, _b, _c, _d, _e;
162
+ const testComponent = component;
163
+ const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
164
+ const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
165
+ const finalVariants = mapSlotToTestVariations(variants);
166
+ return /* @__PURE__ */ React2.createElement(
167
+ Test,
168
+ {
169
+ key,
170
+ variations: finalVariants,
171
+ name: testName,
172
+ component: (variation) => renderChild(variation, key)
173
+ }
174
+ );
175
+ },
176
+ personalization: (component, key, renderChild) => {
177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
178
+ const pzComponent = component;
179
+ const processedVariants = mapSlotToPersonalizedVariations((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
180
+ return /* @__PURE__ */ React2.createElement(
181
+ Personalize,
182
+ {
183
+ key,
184
+ variations: processedVariants,
185
+ count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
186
+ name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
187
+ component: (variation) => renderChild(variation, 0),
188
+ algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value
189
+ }
190
+ );
191
+ }
192
+ };
193
+
194
+ // src/components/ContextualEditingComponentWrapper.tsx
195
+ import {
196
+ isComponentPlaceholderId
197
+ } from "@uniformdev/canvas";
198
+ import React5 from "react";
199
+
200
+ // src/components/PureContextualEditingComponentWrapper.tsx
201
+ import {
202
+ CANVAS_LOCALE_TAG_PARAM,
203
+ IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
204
+ IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
205
+ } from "@uniformdev/canvas";
206
+ import React3 from "react";
207
+ var PureContextualEditingComponentWrapper = ({
208
+ children,
209
+ isPlaceholder,
210
+ parentComponent,
211
+ component,
212
+ slotName,
213
+ indexInSlot,
214
+ slotChildrenCount,
215
+ isReadOnly
216
+ }) => {
217
+ var _a, _b, _c, _d;
218
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
219
+ "script",
220
+ {
221
+ "data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
222
+ "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
223
+ "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
224
+ "data-component-id": component == null ? void 0 : component._id,
225
+ "data-slot-name": slotName != null ? slotName : "",
226
+ "data-component-index": indexInSlot != null ? indexInSlot : "",
227
+ "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
228
+ "data-component-name": component == null ? void 0 : component.type,
229
+ "data-is-placeholder": isPlaceholder ? "true" : void 0,
230
+ "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
231
+ "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
232
+ "data-is-readonly": isReadOnly
233
+ }
234
+ ), children, /* @__PURE__ */ React3.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
235
+ };
159
236
 
160
237
  // src/components/UniformComposition.tsx
161
- import { useUniformContext } from "@uniformdev/context-react";
162
- import React4, { createContext, useContext, useEffect as useEffect2 } from "react";
238
+ import React4, { createContext, useContext } from "react";
163
239
 
164
240
  // src/hooks/useClientConditionsComposition.ts
165
241
  import {
@@ -299,84 +375,6 @@ function isInContextEditingMode() {
299
375
  return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
300
376
  }
301
377
 
302
- // src/components/ContextualEditingComponentWrapper.tsx
303
- import {
304
- isComponentPlaceholderId
305
- } from "@uniformdev/canvas";
306
- import React3 from "react";
307
-
308
- // src/components/PureContextualEditingComponentWrapper.tsx
309
- import {
310
- CANVAS_LOCALE_TAG_PARAM,
311
- IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
312
- IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
313
- } from "@uniformdev/canvas";
314
- import React2 from "react";
315
- var PureContextualEditingComponentWrapper = ({
316
- children,
317
- isPlaceholder,
318
- parentComponent,
319
- component,
320
- slotName,
321
- indexInSlot,
322
- slotChildrenCount,
323
- isReadOnly
324
- }) => {
325
- var _a, _b, _c, _d;
326
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
327
- "script",
328
- {
329
- "data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
330
- "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
331
- "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
332
- "data-component-id": component == null ? void 0 : component._id,
333
- "data-slot-name": slotName != null ? slotName : "",
334
- "data-component-index": indexInSlot != null ? indexInSlot : "",
335
- "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
336
- "data-component-name": component == null ? void 0 : component.type,
337
- "data-is-placeholder": isPlaceholder ? "true" : void 0,
338
- "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
339
- "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
340
- "data-is-readonly": isReadOnly
341
- }
342
- ), children, /* @__PURE__ */ React2.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
343
- };
344
-
345
- // src/components/ContextualEditingComponentWrapper.tsx
346
- function ContextualEditingComponentWrapper({
347
- component,
348
- parentComponent,
349
- slotName,
350
- indexInSlot,
351
- slotChildrenCount,
352
- emptyPlaceholder,
353
- children
354
- }) {
355
- var _a;
356
- const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
357
- const { isContextualEditing } = useUniformCurrentComposition();
358
- const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
359
- if (!isContextualEditing) {
360
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
361
- }
362
- if (isPlaceholder && emptyPlaceholder === null) {
363
- return null;
364
- }
365
- return /* @__PURE__ */ React3.createElement(
366
- PureContextualEditingComponentWrapper,
367
- {
368
- isPlaceholder,
369
- parentComponent,
370
- component,
371
- slotName,
372
- indexInSlot,
373
- slotChildrenCount,
374
- isReadOnly
375
- },
376
- isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
377
- );
378
- }
379
-
380
378
  // src/components/UniformComposition.tsx
381
379
  var UniformCompositionContext = createContext({
382
380
  data: void 0,
@@ -391,20 +389,8 @@ function UniformComposition({
391
389
  children,
392
390
  resolveRenderer,
393
391
  contextualEditingEnhancer,
394
- contextualEditingDefaultPlaceholder,
395
- matchedRoute,
396
- dynamicInputs
392
+ contextualEditingDefaultPlaceholder
397
393
  }) {
398
- const maybeContext = useUniformContext({ throwOnMissingProvider: false });
399
- useEffect2(() => {
400
- if ((maybeContext == null ? void 0 : maybeContext.context) && (data == null ? void 0 : data._id)) {
401
- maybeContext.context.updateCompositionMetadata({
402
- compositionId: data._id,
403
- matchedRoute,
404
- dynamicInputs
405
- });
406
- }
407
- }, [data == null ? void 0 : data._id, maybeContext == null ? void 0 : maybeContext.context, matchedRoute, dynamicInputs]);
408
394
  const ruledComposition = useClientConditionsComposition(data);
409
395
  const { composition, isContextualEditing } = useUniformContextualEditing({
410
396
  initialCompositionValue: ruledComposition,
@@ -413,14 +399,7 @@ function UniformComposition({
413
399
  return /* @__PURE__ */ React4.createElement(
414
400
  UniformCompositionContext.Provider,
415
401
  {
416
- value: {
417
- data: composition,
418
- behaviorTracking,
419
- resolveRenderer,
420
- isContextualEditing,
421
- matchedRoute,
422
- dynamicInputs
423
- }
402
+ value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
424
403
  },
425
404
  /* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
426
405
  UniformComponent,
@@ -435,48 +414,40 @@ function UniformComposition({
435
414
  );
436
415
  }
437
416
 
438
- // src/defaultSystemComponentResolver.tsx
439
- var defaultSystemComponentResolver = {
440
- test: function TestComponent(component, key, renderChild) {
441
- var _a, _b, _c, _d, _e;
442
- const testComponent = component;
443
- const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
444
- const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
445
- const finalVariants = mapSlotToTestVariations(variants);
446
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
447
- return /* @__PURE__ */ React5.createElement(
448
- Test,
449
- {
450
- key,
451
- variations: finalVariants,
452
- name: testName,
453
- component: (variation) => renderChild(variation, key),
454
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0
455
- }
456
- );
457
- },
458
- personalization: function PersonalizeComponent(component, key, renderChild) {
459
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
460
- const pzComponent = component;
461
- const processedVariants = mapSlotToPersonalizedVariations((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
462
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
463
- return /* @__PURE__ */ React5.createElement(
464
- Personalize,
465
- {
466
- key,
467
- variations: processedVariants,
468
- count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
469
- name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
470
- component: (variation) => renderChild(variation, 0),
471
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0,
472
- algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value,
473
- compositionId: data == null ? void 0 : data._id,
474
- matchedRoute,
475
- dynamicInputs
476
- }
477
- );
417
+ // src/components/ContextualEditingComponentWrapper.tsx
418
+ function ContextualEditingComponentWrapper({
419
+ component,
420
+ parentComponent,
421
+ slotName,
422
+ indexInSlot,
423
+ slotChildrenCount,
424
+ emptyPlaceholder,
425
+ children
426
+ }) {
427
+ var _a;
428
+ const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
429
+ const { isContextualEditing } = useUniformCurrentComposition();
430
+ const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
431
+ if (!isContextualEditing) {
432
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, children);
478
433
  }
479
- };
434
+ if (isPlaceholder && emptyPlaceholder === null) {
435
+ return null;
436
+ }
437
+ return /* @__PURE__ */ React5.createElement(
438
+ PureContextualEditingComponentWrapper,
439
+ {
440
+ isPlaceholder,
441
+ parentComponent,
442
+ component,
443
+ slotName,
444
+ indexInSlot,
445
+ slotChildrenCount,
446
+ isReadOnly
447
+ },
448
+ isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
449
+ );
450
+ }
480
451
 
481
452
  // src/components/UniformSlot.tsx
482
453
  function UniformSlot({
@@ -631,7 +602,7 @@ function UniformComponent({
631
602
  }) {
632
603
  var _a, _b, _c;
633
604
  const parentData = useUniformCurrentComponent();
634
- const contextContextProviderPresent = useUniformContext2({ throwOnMissingProvider: false }) !== void 0;
605
+ const contextContextProviderPresent = useUniformContext({ throwOnMissingProvider: false }) !== void 0;
635
606
  if (!data) {
636
607
  if (process.env.NODE_ENV === "development") {
637
608
  console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
@@ -1016,7 +987,7 @@ import {
1016
987
  createCanvasChannel as createCanvasChannel2,
1017
988
  isUpdateContextualEditingStateInternalMessage
1018
989
  } from "@uniformdev/canvas";
1019
- import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
990
+ import { useEffect as useEffect2, useMemo as useMemo5, useState as useState3 } from "react";
1020
991
  var useUniformContextualEditingState = ({
1021
992
  global = false
1022
993
  } = {}) => {
@@ -1036,7 +1007,7 @@ var useUniformContextualEditingState = ({
1036
1007
  });
1037
1008
  return channel2;
1038
1009
  }, [isContextualEditing]);
1039
- useEffect3(() => {
1010
+ useEffect2(() => {
1040
1011
  var _a, _b;
1041
1012
  if (!channel) {
1042
1013
  return;
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ __export(src_exports, {
46
46
  convertComponentToProps: () => convertComponentToProps,
47
47
  createComponentStore: () => createComponentStore,
48
48
  createComponentStoreResolver: () => createComponentStoreResolver,
49
- createUniformApiEnhancer: () => import_canvas4.createUniformApiEnhancer,
49
+ createUniformApiEnhancer: () => import_canvas6.createUniformApiEnhancer,
50
50
  getParameterAttributes: () => getParameterAttributes,
51
51
  registerUniformComponent: () => registerUniformComponent,
52
52
  useUniformContextualEditing: () => useUniformContextualEditing,
@@ -131,7 +131,7 @@ registerUniformComponent({ type: "${componentType}", component: ${proposedFileNa
131
131
 
132
132
  // src/components/UniformComponent.tsx
133
133
  var import_canvas9 = require("@uniformdev/canvas");
134
- var import_context_react4 = require("@uniformdev/context-react");
134
+ var import_context_react3 = require("@uniformdev/context-react");
135
135
  var import_react9 = __toESM(require("react"));
136
136
 
137
137
  // src/helpers/convertComponentToProps.ts
@@ -195,28 +195,98 @@ var import_canvas8 = require("@uniformdev/canvas");
195
195
  var import_react8 = __toESM(require("react"));
196
196
 
197
197
  // src/defaultSystemComponentResolver.tsx
198
+ var import_canvas2 = require("@uniformdev/canvas");
199
+ var import_context_react = require("@uniformdev/context-react");
200
+ var React2 = __toESM(require("react"));
201
+ var defaultSystemComponentResolver = {
202
+ test: (component, key, renderChild) => {
203
+ var _a, _b, _c, _d, _e;
204
+ const testComponent = component;
205
+ const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
206
+ const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
207
+ const finalVariants = (0, import_canvas2.mapSlotToTestVariations)(variants);
208
+ return /* @__PURE__ */ React2.createElement(
209
+ import_context_react.Test,
210
+ {
211
+ key,
212
+ variations: finalVariants,
213
+ name: testName,
214
+ component: (variation) => renderChild(variation, key)
215
+ }
216
+ );
217
+ },
218
+ personalization: (component, key, renderChild) => {
219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
220
+ const pzComponent = component;
221
+ const processedVariants = (0, import_canvas2.mapSlotToPersonalizedVariations)((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
222
+ return /* @__PURE__ */ React2.createElement(
223
+ import_context_react.Personalize,
224
+ {
225
+ key,
226
+ variations: processedVariants,
227
+ count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[import_canvas2.CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
228
+ name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[import_canvas2.CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
229
+ component: (variation) => renderChild(variation, 0),
230
+ algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[import_canvas2.CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value
231
+ }
232
+ );
233
+ }
234
+ };
235
+
236
+ // src/components/ContextualEditingComponentWrapper.tsx
198
237
  var import_canvas7 = require("@uniformdev/canvas");
199
- var import_context_react3 = require("@uniformdev/context-react");
200
- var React5 = __toESM(require("react"));
238
+ var import_react7 = __toESM(require("react"));
239
+
240
+ // src/components/PureContextualEditingComponentWrapper.tsx
241
+ var import_canvas3 = require("@uniformdev/canvas");
242
+ var import_react2 = __toESM(require("react"));
243
+ var PureContextualEditingComponentWrapper = ({
244
+ children,
245
+ isPlaceholder,
246
+ parentComponent,
247
+ component,
248
+ slotName,
249
+ indexInSlot,
250
+ slotChildrenCount,
251
+ isReadOnly
252
+ }) => {
253
+ var _a, _b, _c, _d;
254
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
255
+ "script",
256
+ {
257
+ "data-role": import_canvas3.IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
258
+ "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
259
+ "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
260
+ "data-component-id": component == null ? void 0 : component._id,
261
+ "data-slot-name": slotName != null ? slotName : "",
262
+ "data-component-index": indexInSlot != null ? indexInSlot : "",
263
+ "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
264
+ "data-component-name": component == null ? void 0 : component.type,
265
+ "data-is-placeholder": isPlaceholder ? "true" : void 0,
266
+ "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[import_canvas3.CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
267
+ "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
268
+ "data-is-readonly": isReadOnly
269
+ }
270
+ ), children, /* @__PURE__ */ import_react2.default.createElement("script", { "data-role": import_canvas3.IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
271
+ };
201
272
 
202
273
  // src/components/UniformComposition.tsx
203
- var import_context_react2 = require("@uniformdev/context-react");
204
- var import_react7 = __toESM(require("react"));
274
+ var import_react6 = __toESM(require("react"));
205
275
 
206
276
  // src/hooks/useClientConditionsComposition.ts
207
- var import_canvas3 = require("@uniformdev/canvas");
277
+ var import_canvas5 = require("@uniformdev/canvas");
208
278
  var import_immer = require("immer");
209
- var import_react3 = require("react");
279
+ var import_react4 = require("react");
210
280
 
211
281
  // src/hooks/useClientVisibilityRules.ts
212
- var import_canvas2 = require("@uniformdev/canvas");
213
- var import_context_react = require("@uniformdev/context-react");
214
- var import_react2 = require("react");
282
+ var import_canvas4 = require("@uniformdev/canvas");
283
+ var import_context_react2 = require("@uniformdev/context-react");
284
+ var import_react3 = require("react");
215
285
  function useClientVisibilityRules() {
216
- const quirks = (0, import_context_react.useQuirks)({ throwOnMissingProvider: false });
217
- return (0, import_react2.useMemo)(() => {
286
+ const quirks = (0, import_context_react2.useQuirks)({ throwOnMissingProvider: false });
287
+ return (0, import_react3.useMemo)(() => {
218
288
  return {
219
- ...(0, import_canvas2.createQuirksVisibilityRule)(quirks)
289
+ ...(0, import_canvas4.createQuirksVisibilityRule)(quirks)
220
290
  };
221
291
  }, [quirks]);
222
292
  }
@@ -224,15 +294,15 @@ function useClientVisibilityRules() {
224
294
  // src/hooks/useClientConditionsComposition.ts
225
295
  function useClientConditionsComposition(data) {
226
296
  const rules = useClientVisibilityRules();
227
- const preprocessedValue = (0, import_react3.useMemo)(() => {
297
+ const preprocessedValue = (0, import_react4.useMemo)(() => {
228
298
  if (!data) {
229
299
  return data;
230
300
  }
231
301
  try {
232
302
  return (0, import_immer.produce)(data, (draft) => {
233
- (0, import_canvas3.walkNodeTree)(draft, (context) => {
234
- (0, import_canvas3.evaluateWalkTreeNodeVisibility)({ context, rules, showIndeterminate: false });
235
- (0, import_canvas3.evaluateWalkTreePropertyCriteria)({ node: context.node, rules, keepIndeterminate: false });
303
+ (0, import_canvas5.walkNodeTree)(draft, (context) => {
304
+ (0, import_canvas5.evaluateWalkTreeNodeVisibility)({ context, rules, showIndeterminate: false });
305
+ (0, import_canvas5.evaluateWalkTreePropertyCriteria)({ node: context.node, rules, keepIndeterminate: false });
236
306
  });
237
307
  });
238
308
  } catch (e) {
@@ -244,28 +314,28 @@ function useClientConditionsComposition(data) {
244
314
  }
245
315
 
246
316
  // src/hooks/useUniformContextualEditing.ts
247
- var import_canvas4 = require("@uniformdev/canvas");
248
- var import_react4 = require("react");
317
+ var import_canvas6 = require("@uniformdev/canvas");
318
+ var import_react5 = require("react");
249
319
  var registeredCompositionIds = /* @__PURE__ */ new Set();
250
320
  var useUniformContextualEditing = ({
251
321
  initialCompositionValue,
252
322
  enhance = (message) => message.composition
253
323
  }) => {
254
- const [contextualComposition, setContextualComposition] = (0, import_react4.useState)();
255
- const latestEventTimeStamp = (0, import_react4.useRef)();
256
- const channel = (0, import_react4.useMemo)(() => {
324
+ const [contextualComposition, setContextualComposition] = (0, import_react5.useState)();
325
+ const latestEventTimeStamp = (0, import_react5.useRef)();
326
+ const channel = (0, import_react5.useMemo)(() => {
257
327
  var _a;
258
328
  if (!isInContextEditingMode()) {
259
329
  return;
260
330
  }
261
- const channel2 = (0, import_canvas4.createCanvasChannel)({
331
+ const channel2 = (0, import_canvas6.createCanvasChannel)({
262
332
  broadcastTo: [(_a = window.opener) != null ? _a : window.top],
263
333
  listenTo: [window]
264
334
  });
265
335
  return channel2;
266
336
  }, []);
267
- (0, import_react4.useEffect)(() => {
268
- if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== import_canvas4.EMPTY_COMPOSITION._id && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== (contextualComposition == null ? void 0 : contextualComposition._id)) {
337
+ (0, import_react5.useEffect)(() => {
338
+ if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== import_canvas6.EMPTY_COMPOSITION._id && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== (contextualComposition == null ? void 0 : contextualComposition._id)) {
269
339
  setContextualComposition(void 0);
270
340
  return;
271
341
  }
@@ -273,7 +343,7 @@ var useUniformContextualEditing = ({
273
343
  return;
274
344
  }
275
345
  const unsubscribeFromCompositionUpdates = channel.on("update-composition-internal", async (message) => {
276
- if (!(0, import_canvas4.isUpdateCompositionInternalMessage)(message)) {
346
+ if (!(0, import_canvas6.isUpdateCompositionInternalMessage)(message)) {
277
347
  return;
278
348
  }
279
349
  if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
@@ -289,11 +359,11 @@ var useUniformContextualEditing = ({
289
359
  registeredCompositionIds.delete(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
290
360
  };
291
361
  }, [channel, enhance, initialCompositionValue == null ? void 0 : initialCompositionValue._id, contextualComposition == null ? void 0 : contextualComposition._id]);
292
- (0, import_react4.useEffect)(() => {
362
+ (0, import_react5.useEffect)(() => {
293
363
  if (!isInContextEditingMode()) {
294
364
  return;
295
365
  }
296
- const existingScript = document.getElementById(import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID);
366
+ const existingScript = document.getElementById(import_canvas6.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID);
297
367
  if (existingScript) {
298
368
  return;
299
369
  }
@@ -301,10 +371,10 @@ var useUniformContextualEditing = ({
301
371
  framework: "React",
302
372
  // Make sure to also update the value in canvas-vue
303
373
  version: 2,
304
- canvasPackageVersion: import_canvas4.version
374
+ canvasPackageVersion: import_canvas6.version
305
375
  };
306
376
  const script = document.createElement("script");
307
- script.id = import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
377
+ script.id = import_canvas6.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
308
378
  script.src = getCanvasInContextEmbedScriptUrl();
309
379
  script.async = true;
310
380
  document.head.appendChild(script);
@@ -323,90 +393,18 @@ function isInContextEditingMode() {
323
393
  return false;
324
394
  }
325
395
  const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
326
- import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
327
- );
328
- return isOpenedByInContextEditor && (0, import_canvas4.isAllowedReferrer)(window.document.referrer);
329
- }
330
-
331
- // src/components/ContextualEditingComponentWrapper.tsx
332
- var import_canvas6 = require("@uniformdev/canvas");
333
- var import_react6 = __toESM(require("react"));
334
-
335
- // src/components/PureContextualEditingComponentWrapper.tsx
336
- var import_canvas5 = require("@uniformdev/canvas");
337
- var import_react5 = __toESM(require("react"));
338
- var PureContextualEditingComponentWrapper = ({
339
- children,
340
- isPlaceholder,
341
- parentComponent,
342
- component,
343
- slotName,
344
- indexInSlot,
345
- slotChildrenCount,
346
- isReadOnly
347
- }) => {
348
- var _a, _b, _c, _d;
349
- return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(
350
- "script",
351
- {
352
- "data-role": import_canvas5.IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
353
- "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
354
- "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
355
- "data-component-id": component == null ? void 0 : component._id,
356
- "data-slot-name": slotName != null ? slotName : "",
357
- "data-component-index": indexInSlot != null ? indexInSlot : "",
358
- "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
359
- "data-component-name": component == null ? void 0 : component.type,
360
- "data-is-placeholder": isPlaceholder ? "true" : void 0,
361
- "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[import_canvas5.CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
362
- "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
363
- "data-is-readonly": isReadOnly
364
- }
365
- ), children, /* @__PURE__ */ import_react5.default.createElement("script", { "data-role": import_canvas5.IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
366
- };
367
-
368
- // src/components/ContextualEditingComponentWrapper.tsx
369
- function ContextualEditingComponentWrapper({
370
- component,
371
- parentComponent,
372
- slotName,
373
- indexInSlot,
374
- slotChildrenCount,
375
- emptyPlaceholder,
376
- children
377
- }) {
378
- var _a;
379
- const isPlaceholder = (0, import_canvas6.isComponentPlaceholderId)(component == null ? void 0 : component._id);
380
- const { isContextualEditing } = useUniformCurrentComposition();
381
- const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
382
- if (!isContextualEditing) {
383
- return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, children);
384
- }
385
- if (isPlaceholder && emptyPlaceholder === null) {
386
- return null;
387
- }
388
- return /* @__PURE__ */ import_react6.default.createElement(
389
- PureContextualEditingComponentWrapper,
390
- {
391
- isPlaceholder,
392
- parentComponent,
393
- component,
394
- slotName,
395
- indexInSlot,
396
- slotChildrenCount,
397
- isReadOnly
398
- },
399
- isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
396
+ import_canvas6.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
400
397
  );
398
+ return isOpenedByInContextEditor && (0, import_canvas6.isAllowedReferrer)(window.document.referrer);
401
399
  }
402
400
 
403
401
  // src/components/UniformComposition.tsx
404
- var UniformCompositionContext = (0, import_react7.createContext)({
402
+ var UniformCompositionContext = (0, import_react6.createContext)({
405
403
  data: void 0,
406
404
  isContextualEditing: false
407
405
  });
408
406
  function useUniformCurrentComposition() {
409
- return (0, import_react7.useContext)(UniformCompositionContext);
407
+ return (0, import_react6.useContext)(UniformCompositionContext);
410
408
  }
411
409
  function UniformComposition({
412
410
  data,
@@ -414,38 +412,19 @@ function UniformComposition({
414
412
  children,
415
413
  resolveRenderer,
416
414
  contextualEditingEnhancer,
417
- contextualEditingDefaultPlaceholder,
418
- matchedRoute,
419
- dynamicInputs
415
+ contextualEditingDefaultPlaceholder
420
416
  }) {
421
- const maybeContext = (0, import_context_react2.useUniformContext)({ throwOnMissingProvider: false });
422
- (0, import_react7.useEffect)(() => {
423
- if ((maybeContext == null ? void 0 : maybeContext.context) && (data == null ? void 0 : data._id)) {
424
- maybeContext.context.updateCompositionMetadata({
425
- compositionId: data._id,
426
- matchedRoute,
427
- dynamicInputs
428
- });
429
- }
430
- }, [data == null ? void 0 : data._id, maybeContext == null ? void 0 : maybeContext.context, matchedRoute, dynamicInputs]);
431
417
  const ruledComposition = useClientConditionsComposition(data);
432
418
  const { composition, isContextualEditing } = useUniformContextualEditing({
433
419
  initialCompositionValue: ruledComposition,
434
420
  enhance: contextualEditingEnhancer
435
421
  });
436
- return /* @__PURE__ */ import_react7.default.createElement(
422
+ return /* @__PURE__ */ import_react6.default.createElement(
437
423
  UniformCompositionContext.Provider,
438
424
  {
439
- value: {
440
- data: composition,
441
- behaviorTracking,
442
- resolveRenderer,
443
- isContextualEditing,
444
- matchedRoute,
445
- dynamicInputs
446
- }
425
+ value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
447
426
  },
448
- /* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react7.default.createElement(
427
+ /* @__PURE__ */ import_react6.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react6.default.createElement(
449
428
  UniformComponent,
450
429
  {
451
430
  data: composition,
@@ -458,48 +437,40 @@ function UniformComposition({
458
437
  );
459
438
  }
460
439
 
461
- // src/defaultSystemComponentResolver.tsx
462
- var defaultSystemComponentResolver = {
463
- test: function TestComponent(component, key, renderChild) {
464
- var _a, _b, _c, _d, _e;
465
- const testComponent = component;
466
- const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
467
- const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
468
- const finalVariants = (0, import_canvas7.mapSlotToTestVariations)(variants);
469
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
470
- return /* @__PURE__ */ React5.createElement(
471
- import_context_react3.Test,
472
- {
473
- key,
474
- variations: finalVariants,
475
- name: testName,
476
- component: (variation) => renderChild(variation, key),
477
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0
478
- }
479
- );
480
- },
481
- personalization: function PersonalizeComponent(component, key, renderChild) {
482
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
483
- const pzComponent = component;
484
- const processedVariants = (0, import_canvas7.mapSlotToPersonalizedVariations)((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
485
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
486
- return /* @__PURE__ */ React5.createElement(
487
- import_context_react3.Personalize,
488
- {
489
- key,
490
- variations: processedVariants,
491
- count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[import_canvas7.CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
492
- name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[import_canvas7.CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
493
- component: (variation) => renderChild(variation, 0),
494
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0,
495
- algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[import_canvas7.CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value,
496
- compositionId: data == null ? void 0 : data._id,
497
- matchedRoute,
498
- dynamicInputs
499
- }
500
- );
440
+ // src/components/ContextualEditingComponentWrapper.tsx
441
+ function ContextualEditingComponentWrapper({
442
+ component,
443
+ parentComponent,
444
+ slotName,
445
+ indexInSlot,
446
+ slotChildrenCount,
447
+ emptyPlaceholder,
448
+ children
449
+ }) {
450
+ var _a;
451
+ const isPlaceholder = (0, import_canvas7.isComponentPlaceholderId)(component == null ? void 0 : component._id);
452
+ const { isContextualEditing } = useUniformCurrentComposition();
453
+ const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
454
+ if (!isContextualEditing) {
455
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, children);
501
456
  }
502
- };
457
+ if (isPlaceholder && emptyPlaceholder === null) {
458
+ return null;
459
+ }
460
+ return /* @__PURE__ */ import_react7.default.createElement(
461
+ PureContextualEditingComponentWrapper,
462
+ {
463
+ isPlaceholder,
464
+ parentComponent,
465
+ component,
466
+ slotName,
467
+ indexInSlot,
468
+ slotChildrenCount,
469
+ isReadOnly
470
+ },
471
+ isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
472
+ );
473
+ }
503
474
 
504
475
  // src/components/UniformSlot.tsx
505
476
  function UniformSlot({
@@ -654,7 +625,7 @@ function UniformComponent({
654
625
  }) {
655
626
  var _a, _b, _c;
656
627
  const parentData = useUniformCurrentComponent();
657
- const contextContextProviderPresent = (0, import_context_react4.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
628
+ const contextContextProviderPresent = (0, import_context_react3.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
658
629
  if (!data) {
659
630
  if (process.env.NODE_ENV === "development") {
660
631
  console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
@@ -668,7 +639,7 @@ function UniformComponent({
668
639
  contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
669
640
  };
670
641
  const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas9.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
671
- const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react4.TrackFragment : import_context_react4.Track;
642
+ const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react3.TrackFragment : import_context_react3.Track;
672
643
  const resolvedChildren = resolveChildren({
673
644
  children,
674
645
  data,
package/dist/index.mjs CHANGED
@@ -77,7 +77,7 @@ registerUniformComponent({ type: "${componentType}", component: ${proposedFileNa
77
77
  import {
78
78
  CANVAS_ENRICHMENT_TAG_PARAM
79
79
  } from "@uniformdev/canvas";
80
- import { Track, TrackFragment, useUniformContext as useUniformContext2 } from "@uniformdev/context-react";
80
+ import { Track, TrackFragment, useUniformContext } from "@uniformdev/context-react";
81
81
  import React7, { createContext as createContext2, useContext as useContext2 } from "react";
82
82
 
83
83
  // src/helpers/convertComponentToProps.ts
@@ -155,11 +155,87 @@ import {
155
155
  mapSlotToTestVariations
156
156
  } from "@uniformdev/canvas";
157
157
  import { Personalize, Test } from "@uniformdev/context-react";
158
- import * as React5 from "react";
158
+ import * as React2 from "react";
159
+ var defaultSystemComponentResolver = {
160
+ test: (component, key, renderChild) => {
161
+ var _a, _b, _c, _d, _e;
162
+ const testComponent = component;
163
+ const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
164
+ const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
165
+ const finalVariants = mapSlotToTestVariations(variants);
166
+ return /* @__PURE__ */ React2.createElement(
167
+ Test,
168
+ {
169
+ key,
170
+ variations: finalVariants,
171
+ name: testName,
172
+ component: (variation) => renderChild(variation, key)
173
+ }
174
+ );
175
+ },
176
+ personalization: (component, key, renderChild) => {
177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
178
+ const pzComponent = component;
179
+ const processedVariants = mapSlotToPersonalizedVariations((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
180
+ return /* @__PURE__ */ React2.createElement(
181
+ Personalize,
182
+ {
183
+ key,
184
+ variations: processedVariants,
185
+ count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
186
+ name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
187
+ component: (variation) => renderChild(variation, 0),
188
+ algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value
189
+ }
190
+ );
191
+ }
192
+ };
193
+
194
+ // src/components/ContextualEditingComponentWrapper.tsx
195
+ import {
196
+ isComponentPlaceholderId
197
+ } from "@uniformdev/canvas";
198
+ import React5 from "react";
199
+
200
+ // src/components/PureContextualEditingComponentWrapper.tsx
201
+ import {
202
+ CANVAS_LOCALE_TAG_PARAM,
203
+ IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
204
+ IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
205
+ } from "@uniformdev/canvas";
206
+ import React3 from "react";
207
+ var PureContextualEditingComponentWrapper = ({
208
+ children,
209
+ isPlaceholder,
210
+ parentComponent,
211
+ component,
212
+ slotName,
213
+ indexInSlot,
214
+ slotChildrenCount,
215
+ isReadOnly
216
+ }) => {
217
+ var _a, _b, _c, _d;
218
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
219
+ "script",
220
+ {
221
+ "data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
222
+ "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
223
+ "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
224
+ "data-component-id": component == null ? void 0 : component._id,
225
+ "data-slot-name": slotName != null ? slotName : "",
226
+ "data-component-index": indexInSlot != null ? indexInSlot : "",
227
+ "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
228
+ "data-component-name": component == null ? void 0 : component.type,
229
+ "data-is-placeholder": isPlaceholder ? "true" : void 0,
230
+ "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
231
+ "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
232
+ "data-is-readonly": isReadOnly
233
+ }
234
+ ), children, /* @__PURE__ */ React3.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
235
+ };
159
236
 
160
237
  // src/components/UniformComposition.tsx
161
- import { useUniformContext } from "@uniformdev/context-react";
162
- import React4, { createContext, useContext, useEffect as useEffect2 } from "react";
238
+ import React4, { createContext, useContext } from "react";
163
239
 
164
240
  // src/hooks/useClientConditionsComposition.ts
165
241
  import {
@@ -299,84 +375,6 @@ function isInContextEditingMode() {
299
375
  return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
300
376
  }
301
377
 
302
- // src/components/ContextualEditingComponentWrapper.tsx
303
- import {
304
- isComponentPlaceholderId
305
- } from "@uniformdev/canvas";
306
- import React3 from "react";
307
-
308
- // src/components/PureContextualEditingComponentWrapper.tsx
309
- import {
310
- CANVAS_LOCALE_TAG_PARAM,
311
- IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
312
- IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
313
- } from "@uniformdev/canvas";
314
- import React2 from "react";
315
- var PureContextualEditingComponentWrapper = ({
316
- children,
317
- isPlaceholder,
318
- parentComponent,
319
- component,
320
- slotName,
321
- indexInSlot,
322
- slotChildrenCount,
323
- isReadOnly
324
- }) => {
325
- var _a, _b, _c, _d;
326
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
327
- "script",
328
- {
329
- "data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
330
- "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
331
- "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
332
- "data-component-id": component == null ? void 0 : component._id,
333
- "data-slot-name": slotName != null ? slotName : "",
334
- "data-component-index": indexInSlot != null ? indexInSlot : "",
335
- "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
336
- "data-component-name": component == null ? void 0 : component.type,
337
- "data-is-placeholder": isPlaceholder ? "true" : void 0,
338
- "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
339
- "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
340
- "data-is-readonly": isReadOnly
341
- }
342
- ), children, /* @__PURE__ */ React2.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
343
- };
344
-
345
- // src/components/ContextualEditingComponentWrapper.tsx
346
- function ContextualEditingComponentWrapper({
347
- component,
348
- parentComponent,
349
- slotName,
350
- indexInSlot,
351
- slotChildrenCount,
352
- emptyPlaceholder,
353
- children
354
- }) {
355
- var _a;
356
- const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
357
- const { isContextualEditing } = useUniformCurrentComposition();
358
- const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
359
- if (!isContextualEditing) {
360
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
361
- }
362
- if (isPlaceholder && emptyPlaceholder === null) {
363
- return null;
364
- }
365
- return /* @__PURE__ */ React3.createElement(
366
- PureContextualEditingComponentWrapper,
367
- {
368
- isPlaceholder,
369
- parentComponent,
370
- component,
371
- slotName,
372
- indexInSlot,
373
- slotChildrenCount,
374
- isReadOnly
375
- },
376
- isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
377
- );
378
- }
379
-
380
378
  // src/components/UniformComposition.tsx
381
379
  var UniformCompositionContext = createContext({
382
380
  data: void 0,
@@ -391,20 +389,8 @@ function UniformComposition({
391
389
  children,
392
390
  resolveRenderer,
393
391
  contextualEditingEnhancer,
394
- contextualEditingDefaultPlaceholder,
395
- matchedRoute,
396
- dynamicInputs
392
+ contextualEditingDefaultPlaceholder
397
393
  }) {
398
- const maybeContext = useUniformContext({ throwOnMissingProvider: false });
399
- useEffect2(() => {
400
- if ((maybeContext == null ? void 0 : maybeContext.context) && (data == null ? void 0 : data._id)) {
401
- maybeContext.context.updateCompositionMetadata({
402
- compositionId: data._id,
403
- matchedRoute,
404
- dynamicInputs
405
- });
406
- }
407
- }, [data == null ? void 0 : data._id, maybeContext == null ? void 0 : maybeContext.context, matchedRoute, dynamicInputs]);
408
394
  const ruledComposition = useClientConditionsComposition(data);
409
395
  const { composition, isContextualEditing } = useUniformContextualEditing({
410
396
  initialCompositionValue: ruledComposition,
@@ -413,14 +399,7 @@ function UniformComposition({
413
399
  return /* @__PURE__ */ React4.createElement(
414
400
  UniformCompositionContext.Provider,
415
401
  {
416
- value: {
417
- data: composition,
418
- behaviorTracking,
419
- resolveRenderer,
420
- isContextualEditing,
421
- matchedRoute,
422
- dynamicInputs
423
- }
402
+ value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
424
403
  },
425
404
  /* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
426
405
  UniformComponent,
@@ -435,48 +414,40 @@ function UniformComposition({
435
414
  );
436
415
  }
437
416
 
438
- // src/defaultSystemComponentResolver.tsx
439
- var defaultSystemComponentResolver = {
440
- test: function TestComponent(component, key, renderChild) {
441
- var _a, _b, _c, _d, _e;
442
- const testComponent = component;
443
- const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
444
- const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
445
- const finalVariants = mapSlotToTestVariations(variants);
446
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
447
- return /* @__PURE__ */ React5.createElement(
448
- Test,
449
- {
450
- key,
451
- variations: finalVariants,
452
- name: testName,
453
- component: (variation) => renderChild(variation, key),
454
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0
455
- }
456
- );
457
- },
458
- personalization: function PersonalizeComponent(component, key, renderChild) {
459
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
460
- const pzComponent = component;
461
- const processedVariants = mapSlotToPersonalizedVariations((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
462
- const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
463
- return /* @__PURE__ */ React5.createElement(
464
- Personalize,
465
- {
466
- key,
467
- variations: processedVariants,
468
- count: Number((_d = (_c = (_b = pzComponent.parameters) == null ? void 0 : _b[CANVAS_PERSONALIZATION_TAKE_PARAM]) == null ? void 0 : _c.value) != null ? _d : 1),
469
- name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e[CANVAS_PERSONALIZATION_EVENT_NAME_PARAM]) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
470
- component: (variation) => renderChild(variation, 0),
471
- compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0,
472
- algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value,
473
- compositionId: data == null ? void 0 : data._id,
474
- matchedRoute,
475
- dynamicInputs
476
- }
477
- );
417
+ // src/components/ContextualEditingComponentWrapper.tsx
418
+ function ContextualEditingComponentWrapper({
419
+ component,
420
+ parentComponent,
421
+ slotName,
422
+ indexInSlot,
423
+ slotChildrenCount,
424
+ emptyPlaceholder,
425
+ children
426
+ }) {
427
+ var _a;
428
+ const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
429
+ const { isContextualEditing } = useUniformCurrentComposition();
430
+ const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
431
+ if (!isContextualEditing) {
432
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, children);
478
433
  }
479
- };
434
+ if (isPlaceholder && emptyPlaceholder === null) {
435
+ return null;
436
+ }
437
+ return /* @__PURE__ */ React5.createElement(
438
+ PureContextualEditingComponentWrapper,
439
+ {
440
+ isPlaceholder,
441
+ parentComponent,
442
+ component,
443
+ slotName,
444
+ indexInSlot,
445
+ slotChildrenCount,
446
+ isReadOnly
447
+ },
448
+ isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
449
+ );
450
+ }
480
451
 
481
452
  // src/components/UniformSlot.tsx
482
453
  function UniformSlot({
@@ -631,7 +602,7 @@ function UniformComponent({
631
602
  }) {
632
603
  var _a, _b, _c;
633
604
  const parentData = useUniformCurrentComponent();
634
- const contextContextProviderPresent = useUniformContext2({ throwOnMissingProvider: false }) !== void 0;
605
+ const contextContextProviderPresent = useUniformContext({ throwOnMissingProvider: false }) !== void 0;
635
606
  if (!data) {
636
607
  if (process.env.NODE_ENV === "development") {
637
608
  console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
@@ -1016,7 +987,7 @@ import {
1016
987
  createCanvasChannel as createCanvasChannel2,
1017
988
  isUpdateContextualEditingStateInternalMessage
1018
989
  } from "@uniformdev/canvas";
1019
- import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
990
+ import { useEffect as useEffect2, useMemo as useMemo5, useState as useState3 } from "react";
1020
991
  var useUniformContextualEditingState = ({
1021
992
  global = false
1022
993
  } = {}) => {
@@ -1036,7 +1007,7 @@ var useUniformContextualEditingState = ({
1036
1007
  });
1037
1008
  return channel2;
1038
1009
  }, [isContextualEditing]);
1039
- useEffect3(() => {
1010
+ useEffect2(() => {
1040
1011
  var _a, _b;
1041
1012
  if (!channel) {
1042
1013
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "20.36.2-alpha.90+94c3a288ac",
3
+ "version": "20.37.1-alpha.1+5ac67f77a7",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -45,10 +45,10 @@
45
45
  "document:prebuild": "api-extractor run --local"
46
46
  },
47
47
  "dependencies": {
48
- "@uniformdev/canvas": "20.36.2-alpha.90+94c3a288ac",
49
- "@uniformdev/context": "20.36.2-alpha.90+94c3a288ac",
50
- "@uniformdev/context-react": "20.36.2-alpha.90+94c3a288ac",
51
- "@uniformdev/richtext": "20.36.2-alpha.90+94c3a288ac"
48
+ "@uniformdev/canvas": "20.37.1-alpha.1+5ac67f77a7",
49
+ "@uniformdev/context": "20.37.1-alpha.1+5ac67f77a7",
50
+ "@uniformdev/context-react": "20.37.1-alpha.1+5ac67f77a7",
51
+ "@uniformdev/richtext": "20.37.1-alpha.1+5ac67f77a7"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "immer": ">= 10",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "94c3a288acbde88c1229222ae50bd289b7c5749e"
70
+ "gitHead": "5ac67f77a77da73d93c76b9ec23d86acbd0a2123"
71
71
  }