@uniformdev/canvas-react 20.37.1-alpha.1 → 20.37.1-alpha.15
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 +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +147 -118
- package/dist/index.js +173 -144
- package/dist/index.mjs +147 -118
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -727,12 +728,12 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
727
728
|
isContextualEditing: boolean;
|
|
728
729
|
};
|
|
729
730
|
|
|
730
|
-
type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & {
|
|
731
|
+
type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & Omit<CompositionMetadata, 'compositionId'> & {
|
|
731
732
|
/** The composition data */
|
|
732
733
|
data?: RootComponentInstance;
|
|
733
734
|
contextualEditingEnhancer?: UseUniformContextualEditingProps['enhance'];
|
|
734
735
|
};
|
|
735
|
-
type UniformCompositionContextValue = {
|
|
736
|
+
type UniformCompositionContextValue = Omit<CompositionMetadata, 'compositionId'> & {
|
|
736
737
|
data: UniformCompositionProps['data'] | undefined;
|
|
737
738
|
resolveRenderer?: UniformCompositionProps['resolveRenderer'];
|
|
738
739
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
@@ -748,7 +749,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
748
749
|
* It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
|
|
749
750
|
* It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
|
|
750
751
|
*/
|
|
751
|
-
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
752
|
+
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, matchedRoute, dynamicInputs, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
752
753
|
|
|
753
754
|
type UniformPlaygroundDecorator = (props: {
|
|
754
755
|
/** The rendered component instance, needs to be wrapped and rendered by the decorator */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -727,12 +728,12 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
727
728
|
isContextualEditing: boolean;
|
|
728
729
|
};
|
|
729
730
|
|
|
730
|
-
type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & {
|
|
731
|
+
type UniformCompositionProps<TRenderProps = unknown> = UniformComponentProps<TRenderProps> & Omit<CompositionMetadata, 'compositionId'> & {
|
|
731
732
|
/** The composition data */
|
|
732
733
|
data?: RootComponentInstance;
|
|
733
734
|
contextualEditingEnhancer?: UseUniformContextualEditingProps['enhance'];
|
|
734
735
|
};
|
|
735
|
-
type UniformCompositionContextValue = {
|
|
736
|
+
type UniformCompositionContextValue = Omit<CompositionMetadata, 'compositionId'> & {
|
|
736
737
|
data: UniformCompositionProps['data'] | undefined;
|
|
737
738
|
resolveRenderer?: UniformCompositionProps['resolveRenderer'];
|
|
738
739
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
@@ -748,7 +749,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
748
749
|
* It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
|
|
749
750
|
* It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
|
|
750
751
|
*/
|
|
751
|
-
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
752
|
+
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, matchedRoute, dynamicInputs, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
752
753
|
|
|
753
754
|
type UniformPlaygroundDecorator = (props: {
|
|
754
755
|
/** 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 } from "@uniformdev/context-react";
|
|
80
|
+
import { Track, TrackFragment, useUniformContext as useUniformContext2 } 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,87 +155,11 @@ import {
|
|
|
155
155
|
mapSlotToTestVariations
|
|
156
156
|
} from "@uniformdev/canvas";
|
|
157
157
|
import { Personalize, Test } from "@uniformdev/context-react";
|
|
158
|
-
import * as
|
|
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
|
-
};
|
|
158
|
+
import * as React5 from "react";
|
|
236
159
|
|
|
237
160
|
// src/components/UniformComposition.tsx
|
|
238
|
-
import
|
|
161
|
+
import { useUniformContext } from "@uniformdev/context-react";
|
|
162
|
+
import React4, { createContext, useContext, useEffect as useEffect2 } from "react";
|
|
239
163
|
|
|
240
164
|
// src/hooks/useClientConditionsComposition.ts
|
|
241
165
|
import {
|
|
@@ -375,6 +299,84 @@ function isInContextEditingMode() {
|
|
|
375
299
|
return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
|
|
376
300
|
}
|
|
377
301
|
|
|
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
|
+
|
|
378
380
|
// src/components/UniformComposition.tsx
|
|
379
381
|
var UniformCompositionContext = createContext({
|
|
380
382
|
data: void 0,
|
|
@@ -389,8 +391,20 @@ function UniformComposition({
|
|
|
389
391
|
children,
|
|
390
392
|
resolveRenderer,
|
|
391
393
|
contextualEditingEnhancer,
|
|
392
|
-
contextualEditingDefaultPlaceholder
|
|
394
|
+
contextualEditingDefaultPlaceholder,
|
|
395
|
+
matchedRoute,
|
|
396
|
+
dynamicInputs
|
|
393
397
|
}) {
|
|
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]);
|
|
394
408
|
const ruledComposition = useClientConditionsComposition(data);
|
|
395
409
|
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
396
410
|
initialCompositionValue: ruledComposition,
|
|
@@ -399,7 +413,14 @@ function UniformComposition({
|
|
|
399
413
|
return /* @__PURE__ */ React4.createElement(
|
|
400
414
|
UniformCompositionContext.Provider,
|
|
401
415
|
{
|
|
402
|
-
value: {
|
|
416
|
+
value: {
|
|
417
|
+
data: composition,
|
|
418
|
+
behaviorTracking,
|
|
419
|
+
resolveRenderer,
|
|
420
|
+
isContextualEditing,
|
|
421
|
+
matchedRoute,
|
|
422
|
+
dynamicInputs
|
|
423
|
+
}
|
|
403
424
|
},
|
|
404
425
|
/* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
|
|
405
426
|
UniformComponent,
|
|
@@ -414,40 +435,48 @@ function UniformComposition({
|
|
|
414
435
|
);
|
|
415
436
|
}
|
|
416
437
|
|
|
417
|
-
// src/
|
|
418
|
-
|
|
419
|
-
component,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
+
);
|
|
436
478
|
}
|
|
437
|
-
|
|
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
|
-
}
|
|
479
|
+
};
|
|
451
480
|
|
|
452
481
|
// src/components/UniformSlot.tsx
|
|
453
482
|
function UniformSlot({
|
|
@@ -602,7 +631,7 @@ function UniformComponent({
|
|
|
602
631
|
}) {
|
|
603
632
|
var _a, _b, _c;
|
|
604
633
|
const parentData = useUniformCurrentComponent();
|
|
605
|
-
const contextContextProviderPresent =
|
|
634
|
+
const contextContextProviderPresent = useUniformContext2({ throwOnMissingProvider: false }) !== void 0;
|
|
606
635
|
if (!data) {
|
|
607
636
|
if (process.env.NODE_ENV === "development") {
|
|
608
637
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -987,7 +1016,7 @@ import {
|
|
|
987
1016
|
createCanvasChannel as createCanvasChannel2,
|
|
988
1017
|
isUpdateContextualEditingStateInternalMessage
|
|
989
1018
|
} from "@uniformdev/canvas";
|
|
990
|
-
import { useEffect as
|
|
1019
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
991
1020
|
var useUniformContextualEditingState = ({
|
|
992
1021
|
global = false
|
|
993
1022
|
} = {}) => {
|
|
@@ -1007,7 +1036,7 @@ var useUniformContextualEditingState = ({
|
|
|
1007
1036
|
});
|
|
1008
1037
|
return channel2;
|
|
1009
1038
|
}, [isContextualEditing]);
|
|
1010
|
-
|
|
1039
|
+
useEffect3(() => {
|
|
1011
1040
|
var _a, _b;
|
|
1012
1041
|
if (!channel) {
|
|
1013
1042
|
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: () =>
|
|
49
|
+
createUniformApiEnhancer: () => import_canvas4.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
|
|
134
|
+
var import_context_react4 = require("@uniformdev/context-react");
|
|
135
135
|
var import_react9 = __toESM(require("react"));
|
|
136
136
|
|
|
137
137
|
// src/helpers/convertComponentToProps.ts
|
|
@@ -195,98 +195,28 @@ 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
|
|
237
198
|
var import_canvas7 = require("@uniformdev/canvas");
|
|
238
|
-
var
|
|
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
|
-
};
|
|
199
|
+
var import_context_react3 = require("@uniformdev/context-react");
|
|
200
|
+
var React5 = __toESM(require("react"));
|
|
272
201
|
|
|
273
202
|
// src/components/UniformComposition.tsx
|
|
274
|
-
var
|
|
203
|
+
var import_context_react2 = require("@uniformdev/context-react");
|
|
204
|
+
var import_react7 = __toESM(require("react"));
|
|
275
205
|
|
|
276
206
|
// src/hooks/useClientConditionsComposition.ts
|
|
277
|
-
var
|
|
207
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
278
208
|
var import_immer = require("immer");
|
|
279
|
-
var
|
|
209
|
+
var import_react3 = require("react");
|
|
280
210
|
|
|
281
211
|
// src/hooks/useClientVisibilityRules.ts
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
212
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
213
|
+
var import_context_react = require("@uniformdev/context-react");
|
|
214
|
+
var import_react2 = require("react");
|
|
285
215
|
function useClientVisibilityRules() {
|
|
286
|
-
const quirks = (0,
|
|
287
|
-
return (0,
|
|
216
|
+
const quirks = (0, import_context_react.useQuirks)({ throwOnMissingProvider: false });
|
|
217
|
+
return (0, import_react2.useMemo)(() => {
|
|
288
218
|
return {
|
|
289
|
-
...(0,
|
|
219
|
+
...(0, import_canvas2.createQuirksVisibilityRule)(quirks)
|
|
290
220
|
};
|
|
291
221
|
}, [quirks]);
|
|
292
222
|
}
|
|
@@ -294,15 +224,15 @@ function useClientVisibilityRules() {
|
|
|
294
224
|
// src/hooks/useClientConditionsComposition.ts
|
|
295
225
|
function useClientConditionsComposition(data) {
|
|
296
226
|
const rules = useClientVisibilityRules();
|
|
297
|
-
const preprocessedValue = (0,
|
|
227
|
+
const preprocessedValue = (0, import_react3.useMemo)(() => {
|
|
298
228
|
if (!data) {
|
|
299
229
|
return data;
|
|
300
230
|
}
|
|
301
231
|
try {
|
|
302
232
|
return (0, import_immer.produce)(data, (draft) => {
|
|
303
|
-
(0,
|
|
304
|
-
(0,
|
|
305
|
-
(0,
|
|
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 });
|
|
306
236
|
});
|
|
307
237
|
});
|
|
308
238
|
} catch (e) {
|
|
@@ -314,28 +244,28 @@ function useClientConditionsComposition(data) {
|
|
|
314
244
|
}
|
|
315
245
|
|
|
316
246
|
// src/hooks/useUniformContextualEditing.ts
|
|
317
|
-
var
|
|
318
|
-
var
|
|
247
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
248
|
+
var import_react4 = require("react");
|
|
319
249
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
320
250
|
var useUniformContextualEditing = ({
|
|
321
251
|
initialCompositionValue,
|
|
322
252
|
enhance = (message) => message.composition
|
|
323
253
|
}) => {
|
|
324
|
-
const [contextualComposition, setContextualComposition] = (0,
|
|
325
|
-
const latestEventTimeStamp = (0,
|
|
326
|
-
const channel = (0,
|
|
254
|
+
const [contextualComposition, setContextualComposition] = (0, import_react4.useState)();
|
|
255
|
+
const latestEventTimeStamp = (0, import_react4.useRef)();
|
|
256
|
+
const channel = (0, import_react4.useMemo)(() => {
|
|
327
257
|
var _a;
|
|
328
258
|
if (!isInContextEditingMode()) {
|
|
329
259
|
return;
|
|
330
260
|
}
|
|
331
|
-
const channel2 = (0,
|
|
261
|
+
const channel2 = (0, import_canvas4.createCanvasChannel)({
|
|
332
262
|
broadcastTo: [(_a = window.opener) != null ? _a : window.top],
|
|
333
263
|
listenTo: [window]
|
|
334
264
|
});
|
|
335
265
|
return channel2;
|
|
336
266
|
}, []);
|
|
337
|
-
(0,
|
|
338
|
-
if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !==
|
|
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)) {
|
|
339
269
|
setContextualComposition(void 0);
|
|
340
270
|
return;
|
|
341
271
|
}
|
|
@@ -343,7 +273,7 @@ var useUniformContextualEditing = ({
|
|
|
343
273
|
return;
|
|
344
274
|
}
|
|
345
275
|
const unsubscribeFromCompositionUpdates = channel.on("update-composition-internal", async (message) => {
|
|
346
|
-
if (!(0,
|
|
276
|
+
if (!(0, import_canvas4.isUpdateCompositionInternalMessage)(message)) {
|
|
347
277
|
return;
|
|
348
278
|
}
|
|
349
279
|
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
@@ -359,11 +289,11 @@ var useUniformContextualEditing = ({
|
|
|
359
289
|
registeredCompositionIds.delete(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
360
290
|
};
|
|
361
291
|
}, [channel, enhance, initialCompositionValue == null ? void 0 : initialCompositionValue._id, contextualComposition == null ? void 0 : contextualComposition._id]);
|
|
362
|
-
(0,
|
|
292
|
+
(0, import_react4.useEffect)(() => {
|
|
363
293
|
if (!isInContextEditingMode()) {
|
|
364
294
|
return;
|
|
365
295
|
}
|
|
366
|
-
const existingScript = document.getElementById(
|
|
296
|
+
const existingScript = document.getElementById(import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID);
|
|
367
297
|
if (existingScript) {
|
|
368
298
|
return;
|
|
369
299
|
}
|
|
@@ -371,10 +301,10 @@ var useUniformContextualEditing = ({
|
|
|
371
301
|
framework: "React",
|
|
372
302
|
// Make sure to also update the value in canvas-vue
|
|
373
303
|
version: 2,
|
|
374
|
-
canvasPackageVersion:
|
|
304
|
+
canvasPackageVersion: import_canvas4.version
|
|
375
305
|
};
|
|
376
306
|
const script = document.createElement("script");
|
|
377
|
-
script.id =
|
|
307
|
+
script.id = import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
|
|
378
308
|
script.src = getCanvasInContextEmbedScriptUrl();
|
|
379
309
|
script.async = true;
|
|
380
310
|
document.head.appendChild(script);
|
|
@@ -393,49 +323,47 @@ function isInContextEditingMode() {
|
|
|
393
323
|
return false;
|
|
394
324
|
}
|
|
395
325
|
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
396
|
-
|
|
326
|
+
import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
397
327
|
);
|
|
398
|
-
return isOpenedByInContextEditor && (0,
|
|
328
|
+
return isOpenedByInContextEditor && (0, import_canvas4.isAllowedReferrer)(window.document.referrer);
|
|
399
329
|
}
|
|
400
330
|
|
|
401
|
-
// src/components/
|
|
402
|
-
var
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
function UniformComposition({
|
|
410
|
-
data,
|
|
411
|
-
behaviorTracking = "onView",
|
|
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 = ({
|
|
412
339
|
children,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
return /* @__PURE__ */
|
|
423
|
-
|
|
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",
|
|
424
351
|
{
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
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
|
+
};
|
|
439
367
|
|
|
440
368
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
441
369
|
function ContextualEditingComponentWrapper({
|
|
@@ -448,16 +376,16 @@ function ContextualEditingComponentWrapper({
|
|
|
448
376
|
children
|
|
449
377
|
}) {
|
|
450
378
|
var _a;
|
|
451
|
-
const isPlaceholder = (0,
|
|
379
|
+
const isPlaceholder = (0, import_canvas6.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
452
380
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
453
381
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
454
382
|
if (!isContextualEditing) {
|
|
455
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, children);
|
|
456
384
|
}
|
|
457
385
|
if (isPlaceholder && emptyPlaceholder === null) {
|
|
458
386
|
return null;
|
|
459
387
|
}
|
|
460
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
461
389
|
PureContextualEditingComponentWrapper,
|
|
462
390
|
{
|
|
463
391
|
isPlaceholder,
|
|
@@ -472,6 +400,107 @@ function ContextualEditingComponentWrapper({
|
|
|
472
400
|
);
|
|
473
401
|
}
|
|
474
402
|
|
|
403
|
+
// src/components/UniformComposition.tsx
|
|
404
|
+
var UniformCompositionContext = (0, import_react7.createContext)({
|
|
405
|
+
data: void 0,
|
|
406
|
+
isContextualEditing: false
|
|
407
|
+
});
|
|
408
|
+
function useUniformCurrentComposition() {
|
|
409
|
+
return (0, import_react7.useContext)(UniformCompositionContext);
|
|
410
|
+
}
|
|
411
|
+
function UniformComposition({
|
|
412
|
+
data,
|
|
413
|
+
behaviorTracking = "onView",
|
|
414
|
+
children,
|
|
415
|
+
resolveRenderer,
|
|
416
|
+
contextualEditingEnhancer,
|
|
417
|
+
contextualEditingDefaultPlaceholder,
|
|
418
|
+
matchedRoute,
|
|
419
|
+
dynamicInputs
|
|
420
|
+
}) {
|
|
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
|
+
const ruledComposition = useClientConditionsComposition(data);
|
|
432
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
433
|
+
initialCompositionValue: ruledComposition,
|
|
434
|
+
enhance: contextualEditingEnhancer
|
|
435
|
+
});
|
|
436
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
437
|
+
UniformCompositionContext.Provider,
|
|
438
|
+
{
|
|
439
|
+
value: {
|
|
440
|
+
data: composition,
|
|
441
|
+
behaviorTracking,
|
|
442
|
+
resolveRenderer,
|
|
443
|
+
isContextualEditing,
|
|
444
|
+
matchedRoute,
|
|
445
|
+
dynamicInputs
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
/* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react7.default.createElement(
|
|
449
|
+
UniformComponent,
|
|
450
|
+
{
|
|
451
|
+
data: composition,
|
|
452
|
+
behaviorTracking,
|
|
453
|
+
resolveRenderer,
|
|
454
|
+
contextualEditingDefaultPlaceholder
|
|
455
|
+
},
|
|
456
|
+
children
|
|
457
|
+
))
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
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
|
+
);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
|
|
475
504
|
// src/components/UniformSlot.tsx
|
|
476
505
|
function UniformSlot({
|
|
477
506
|
name,
|
|
@@ -625,7 +654,7 @@ function UniformComponent({
|
|
|
625
654
|
}) {
|
|
626
655
|
var _a, _b, _c;
|
|
627
656
|
const parentData = useUniformCurrentComponent();
|
|
628
|
-
const contextContextProviderPresent = (0,
|
|
657
|
+
const contextContextProviderPresent = (0, import_context_react4.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
|
|
629
658
|
if (!data) {
|
|
630
659
|
if (process.env.NODE_ENV === "development") {
|
|
631
660
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -639,7 +668,7 @@ function UniformComponent({
|
|
|
639
668
|
contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
|
|
640
669
|
};
|
|
641
670
|
const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas9.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
|
|
642
|
-
const TrackComponent = contextValue.behaviorTracking === "onLoad" ?
|
|
671
|
+
const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react4.TrackFragment : import_context_react4.Track;
|
|
643
672
|
const resolvedChildren = resolveChildren({
|
|
644
673
|
children,
|
|
645
674
|
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 } from "@uniformdev/context-react";
|
|
80
|
+
import { Track, TrackFragment, useUniformContext as useUniformContext2 } 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,87 +155,11 @@ import {
|
|
|
155
155
|
mapSlotToTestVariations
|
|
156
156
|
} from "@uniformdev/canvas";
|
|
157
157
|
import { Personalize, Test } from "@uniformdev/context-react";
|
|
158
|
-
import * as
|
|
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
|
-
};
|
|
158
|
+
import * as React5 from "react";
|
|
236
159
|
|
|
237
160
|
// src/components/UniformComposition.tsx
|
|
238
|
-
import
|
|
161
|
+
import { useUniformContext } from "@uniformdev/context-react";
|
|
162
|
+
import React4, { createContext, useContext, useEffect as useEffect2 } from "react";
|
|
239
163
|
|
|
240
164
|
// src/hooks/useClientConditionsComposition.ts
|
|
241
165
|
import {
|
|
@@ -375,6 +299,84 @@ function isInContextEditingMode() {
|
|
|
375
299
|
return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
|
|
376
300
|
}
|
|
377
301
|
|
|
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
|
+
|
|
378
380
|
// src/components/UniformComposition.tsx
|
|
379
381
|
var UniformCompositionContext = createContext({
|
|
380
382
|
data: void 0,
|
|
@@ -389,8 +391,20 @@ function UniformComposition({
|
|
|
389
391
|
children,
|
|
390
392
|
resolveRenderer,
|
|
391
393
|
contextualEditingEnhancer,
|
|
392
|
-
contextualEditingDefaultPlaceholder
|
|
394
|
+
contextualEditingDefaultPlaceholder,
|
|
395
|
+
matchedRoute,
|
|
396
|
+
dynamicInputs
|
|
393
397
|
}) {
|
|
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]);
|
|
394
408
|
const ruledComposition = useClientConditionsComposition(data);
|
|
395
409
|
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
396
410
|
initialCompositionValue: ruledComposition,
|
|
@@ -399,7 +413,14 @@ function UniformComposition({
|
|
|
399
413
|
return /* @__PURE__ */ React4.createElement(
|
|
400
414
|
UniformCompositionContext.Provider,
|
|
401
415
|
{
|
|
402
|
-
value: {
|
|
416
|
+
value: {
|
|
417
|
+
data: composition,
|
|
418
|
+
behaviorTracking,
|
|
419
|
+
resolveRenderer,
|
|
420
|
+
isContextualEditing,
|
|
421
|
+
matchedRoute,
|
|
422
|
+
dynamicInputs
|
|
423
|
+
}
|
|
403
424
|
},
|
|
404
425
|
/* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
|
|
405
426
|
UniformComponent,
|
|
@@ -414,40 +435,48 @@ function UniformComposition({
|
|
|
414
435
|
);
|
|
415
436
|
}
|
|
416
437
|
|
|
417
|
-
// src/
|
|
418
|
-
|
|
419
|
-
component,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
+
);
|
|
436
478
|
}
|
|
437
|
-
|
|
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
|
-
}
|
|
479
|
+
};
|
|
451
480
|
|
|
452
481
|
// src/components/UniformSlot.tsx
|
|
453
482
|
function UniformSlot({
|
|
@@ -602,7 +631,7 @@ function UniformComponent({
|
|
|
602
631
|
}) {
|
|
603
632
|
var _a, _b, _c;
|
|
604
633
|
const parentData = useUniformCurrentComponent();
|
|
605
|
-
const contextContextProviderPresent =
|
|
634
|
+
const contextContextProviderPresent = useUniformContext2({ throwOnMissingProvider: false }) !== void 0;
|
|
606
635
|
if (!data) {
|
|
607
636
|
if (process.env.NODE_ENV === "development") {
|
|
608
637
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -987,7 +1016,7 @@ import {
|
|
|
987
1016
|
createCanvasChannel as createCanvasChannel2,
|
|
988
1017
|
isUpdateContextualEditingStateInternalMessage
|
|
989
1018
|
} from "@uniformdev/canvas";
|
|
990
|
-
import { useEffect as
|
|
1019
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
991
1020
|
var useUniformContextualEditingState = ({
|
|
992
1021
|
global = false
|
|
993
1022
|
} = {}) => {
|
|
@@ -1007,7 +1036,7 @@ var useUniformContextualEditingState = ({
|
|
|
1007
1036
|
});
|
|
1008
1037
|
return channel2;
|
|
1009
1038
|
}, [isContextualEditing]);
|
|
1010
|
-
|
|
1039
|
+
useEffect3(() => {
|
|
1011
1040
|
var _a, _b;
|
|
1012
1041
|
if (!channel) {
|
|
1013
1042
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-react",
|
|
3
|
-
"version": "20.37.1-alpha.
|
|
3
|
+
"version": "20.37.1-alpha.15+2338ab9fcc",
|
|
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.37.1-alpha.
|
|
49
|
-
"@uniformdev/context": "20.37.1-alpha.
|
|
50
|
-
"@uniformdev/context-react": "20.37.1-alpha.
|
|
51
|
-
"@uniformdev/richtext": "20.37.1-alpha.
|
|
48
|
+
"@uniformdev/canvas": "20.37.1-alpha.15+2338ab9fcc",
|
|
49
|
+
"@uniformdev/context": "20.37.1-alpha.15+2338ab9fcc",
|
|
50
|
+
"@uniformdev/context-react": "20.37.1-alpha.15+2338ab9fcc",
|
|
51
|
+
"@uniformdev/richtext": "20.37.1-alpha.15+2338ab9fcc"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"immer": ">= 10",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "2338ab9fcc327bb23c4addbfedcd84dfb2ec257c"
|
|
71
71
|
}
|