@uniformdev/canvas-react 20.6.5-alpha.1 → 20.7.1-alpha.102
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/LICENSE.txt +1 -1
- package/dist/index.d.mts +206 -20
- package/dist/index.d.ts +206 -20
- package/dist/index.esm.js +155 -119
- package/dist/index.js +175 -143
- package/dist/index.mjs +155 -119
- package/package.json +8 -8
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,97 +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;
|
|
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.count) == null ? void 0 : _c.value) != null ? _d : 1),
|
|
228
|
-
name: (_g = (_f = (_e = pzComponent.parameters) == null ? void 0 : _e.trackingEventName) == null ? void 0 : _f.value) != null ? _g : "Untitled Personalization",
|
|
229
|
-
component: (variation) => renderChild(variation, 0)
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// src/components/ContextualEditingComponentWrapper.tsx
|
|
236
198
|
var import_canvas7 = require("@uniformdev/canvas");
|
|
237
|
-
var
|
|
238
|
-
|
|
239
|
-
// src/components/PureContextualEditingComponentWrapper.tsx
|
|
240
|
-
var import_canvas3 = require("@uniformdev/canvas");
|
|
241
|
-
var import_react2 = __toESM(require("react"));
|
|
242
|
-
var PureContextualEditingComponentWrapper = ({
|
|
243
|
-
children,
|
|
244
|
-
isPlaceholder,
|
|
245
|
-
parentComponent,
|
|
246
|
-
component,
|
|
247
|
-
slotName,
|
|
248
|
-
indexInSlot,
|
|
249
|
-
slotChildrenCount,
|
|
250
|
-
isReadOnly
|
|
251
|
-
}) => {
|
|
252
|
-
var _a, _b, _c, _d;
|
|
253
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
|
|
254
|
-
"script",
|
|
255
|
-
{
|
|
256
|
-
"data-role": import_canvas3.IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
257
|
-
"data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
|
|
258
|
-
"data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
|
|
259
|
-
"data-component-id": component == null ? void 0 : component._id,
|
|
260
|
-
"data-slot-name": slotName != null ? slotName : "",
|
|
261
|
-
"data-component-index": indexInSlot != null ? indexInSlot : "",
|
|
262
|
-
"data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
|
|
263
|
-
"data-component-name": component == null ? void 0 : component.type,
|
|
264
|
-
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
265
|
-
"data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[import_canvas3.CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
|
|
266
|
-
"data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
|
|
267
|
-
"data-is-readonly": isReadOnly
|
|
268
|
-
}
|
|
269
|
-
), children, /* @__PURE__ */ import_react2.default.createElement("script", { "data-role": import_canvas3.IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
270
|
-
};
|
|
199
|
+
var import_context_react3 = require("@uniformdev/context-react");
|
|
200
|
+
var React5 = __toESM(require("react"));
|
|
271
201
|
|
|
272
202
|
// src/components/UniformComposition.tsx
|
|
273
|
-
var
|
|
203
|
+
var import_context_react2 = require("@uniformdev/context-react");
|
|
204
|
+
var import_react7 = __toESM(require("react"));
|
|
274
205
|
|
|
275
206
|
// src/hooks/useClientConditionsComposition.ts
|
|
276
|
-
var
|
|
207
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
277
208
|
var import_immer = require("immer");
|
|
278
|
-
var
|
|
209
|
+
var import_react3 = require("react");
|
|
279
210
|
|
|
280
211
|
// src/hooks/useClientVisibilityRules.ts
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var
|
|
212
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
213
|
+
var import_context_react = require("@uniformdev/context-react");
|
|
214
|
+
var import_react2 = require("react");
|
|
284
215
|
function useClientVisibilityRules() {
|
|
285
|
-
const quirks = (0,
|
|
286
|
-
return (0,
|
|
216
|
+
const quirks = (0, import_context_react.useQuirks)({ throwOnMissingProvider: false });
|
|
217
|
+
return (0, import_react2.useMemo)(() => {
|
|
287
218
|
return {
|
|
288
|
-
...(0,
|
|
219
|
+
...(0, import_canvas2.createQuirksVisibilityRule)(quirks)
|
|
289
220
|
};
|
|
290
221
|
}, [quirks]);
|
|
291
222
|
}
|
|
@@ -293,15 +224,15 @@ function useClientVisibilityRules() {
|
|
|
293
224
|
// src/hooks/useClientConditionsComposition.ts
|
|
294
225
|
function useClientConditionsComposition(data) {
|
|
295
226
|
const rules = useClientVisibilityRules();
|
|
296
|
-
const preprocessedValue = (0,
|
|
227
|
+
const preprocessedValue = (0, import_react3.useMemo)(() => {
|
|
297
228
|
if (!data) {
|
|
298
229
|
return data;
|
|
299
230
|
}
|
|
300
231
|
try {
|
|
301
232
|
return (0, import_immer.produce)(data, (draft) => {
|
|
302
|
-
(0,
|
|
303
|
-
(0,
|
|
304
|
-
(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 });
|
|
305
236
|
});
|
|
306
237
|
});
|
|
307
238
|
} catch (e) {
|
|
@@ -313,28 +244,28 @@ function useClientConditionsComposition(data) {
|
|
|
313
244
|
}
|
|
314
245
|
|
|
315
246
|
// src/hooks/useUniformContextualEditing.ts
|
|
316
|
-
var
|
|
317
|
-
var
|
|
247
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
248
|
+
var import_react4 = require("react");
|
|
318
249
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
319
250
|
var useUniformContextualEditing = ({
|
|
320
251
|
initialCompositionValue,
|
|
321
252
|
enhance = (message) => message.composition
|
|
322
253
|
}) => {
|
|
323
|
-
const [contextualComposition, setContextualComposition] = (0,
|
|
324
|
-
const latestEventTimeStamp = (0,
|
|
325
|
-
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)(() => {
|
|
326
257
|
var _a;
|
|
327
258
|
if (!isInContextEditingMode()) {
|
|
328
259
|
return;
|
|
329
260
|
}
|
|
330
|
-
const channel2 = (0,
|
|
261
|
+
const channel2 = (0, import_canvas4.createCanvasChannel)({
|
|
331
262
|
broadcastTo: [(_a = window.opener) != null ? _a : window.top],
|
|
332
263
|
listenTo: [window]
|
|
333
264
|
});
|
|
334
265
|
return channel2;
|
|
335
266
|
}, []);
|
|
336
|
-
(0,
|
|
337
|
-
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)) {
|
|
338
269
|
setContextualComposition(void 0);
|
|
339
270
|
return;
|
|
340
271
|
}
|
|
@@ -342,7 +273,7 @@ var useUniformContextualEditing = ({
|
|
|
342
273
|
return;
|
|
343
274
|
}
|
|
344
275
|
const unsubscribeFromCompositionUpdates = channel.on("update-composition-internal", async (message) => {
|
|
345
|
-
if (!(0,
|
|
276
|
+
if (!(0, import_canvas4.isUpdateCompositionInternalMessage)(message)) {
|
|
346
277
|
return;
|
|
347
278
|
}
|
|
348
279
|
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
@@ -358,21 +289,22 @@ var useUniformContextualEditing = ({
|
|
|
358
289
|
registeredCompositionIds.delete(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
359
290
|
};
|
|
360
291
|
}, [channel, enhance, initialCompositionValue == null ? void 0 : initialCompositionValue._id, contextualComposition == null ? void 0 : contextualComposition._id]);
|
|
361
|
-
(0,
|
|
292
|
+
(0, import_react4.useEffect)(() => {
|
|
362
293
|
if (!isInContextEditingMode()) {
|
|
363
294
|
return;
|
|
364
295
|
}
|
|
365
|
-
const existingScript = document.getElementById(
|
|
296
|
+
const existingScript = document.getElementById(import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID);
|
|
366
297
|
if (existingScript) {
|
|
367
298
|
return;
|
|
368
299
|
}
|
|
369
300
|
window.__UNIFORM_CONTEXTUAL_EDITING__ = {
|
|
370
301
|
framework: "React",
|
|
371
302
|
// Make sure to also update the value in canvas-vue
|
|
372
|
-
version: 2
|
|
303
|
+
version: 2,
|
|
304
|
+
canvasPackageVersion: import_canvas4.version
|
|
373
305
|
};
|
|
374
306
|
const script = document.createElement("script");
|
|
375
|
-
script.id =
|
|
307
|
+
script.id = import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
|
|
376
308
|
script.src = getCanvasInContextEmbedScriptUrl();
|
|
377
309
|
script.async = true;
|
|
378
310
|
document.head.appendChild(script);
|
|
@@ -391,49 +323,47 @@ function isInContextEditingMode() {
|
|
|
391
323
|
return false;
|
|
392
324
|
}
|
|
393
325
|
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
394
|
-
|
|
326
|
+
import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
395
327
|
);
|
|
396
|
-
return isOpenedByInContextEditor && (0,
|
|
328
|
+
return isOpenedByInContextEditor && (0, import_canvas4.isAllowedReferrer)(window.document.referrer);
|
|
397
329
|
}
|
|
398
330
|
|
|
399
|
-
// src/components/
|
|
400
|
-
var
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
function UniformComposition({
|
|
408
|
-
data,
|
|
409
|
-
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 = ({
|
|
410
339
|
children,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return /* @__PURE__ */
|
|
421
|
-
|
|
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",
|
|
422
351
|
{
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
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
|
+
};
|
|
437
367
|
|
|
438
368
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
439
369
|
function ContextualEditingComponentWrapper({
|
|
@@ -446,16 +376,16 @@ function ContextualEditingComponentWrapper({
|
|
|
446
376
|
children
|
|
447
377
|
}) {
|
|
448
378
|
var _a;
|
|
449
|
-
const isPlaceholder = (0,
|
|
379
|
+
const isPlaceholder = (0, import_canvas6.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
450
380
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
451
381
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
452
382
|
if (!isContextualEditing) {
|
|
453
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, children);
|
|
454
384
|
}
|
|
455
385
|
if (isPlaceholder && emptyPlaceholder === null) {
|
|
456
386
|
return null;
|
|
457
387
|
}
|
|
458
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
459
389
|
PureContextualEditingComponentWrapper,
|
|
460
390
|
{
|
|
461
391
|
isPlaceholder,
|
|
@@ -470,6 +400,108 @@ function ContextualEditingComponentWrapper({
|
|
|
470
400
|
);
|
|
471
401
|
}
|
|
472
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
|
+
// provide default non-undefined values to avoid serialization issues
|
|
419
|
+
matchedRoute = "",
|
|
420
|
+
dynamicInputs = {}
|
|
421
|
+
}) {
|
|
422
|
+
const maybeContext = (0, import_context_react2.useUniformContext)({ throwOnMissingProvider: false });
|
|
423
|
+
(0, import_react7.useEffect)(() => {
|
|
424
|
+
if ((maybeContext == null ? void 0 : maybeContext.context) && (data == null ? void 0 : data._id)) {
|
|
425
|
+
maybeContext.context.updateCompositionMetadata({
|
|
426
|
+
compositionId: data._id,
|
|
427
|
+
matchedRoute,
|
|
428
|
+
dynamicInputs
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}, [data == null ? void 0 : data._id, maybeContext == null ? void 0 : maybeContext.context, matchedRoute, dynamicInputs]);
|
|
432
|
+
const ruledComposition = useClientConditionsComposition(data);
|
|
433
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
434
|
+
initialCompositionValue: ruledComposition,
|
|
435
|
+
enhance: contextualEditingEnhancer
|
|
436
|
+
});
|
|
437
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
438
|
+
UniformCompositionContext.Provider,
|
|
439
|
+
{
|
|
440
|
+
value: {
|
|
441
|
+
data: composition,
|
|
442
|
+
behaviorTracking,
|
|
443
|
+
resolveRenderer,
|
|
444
|
+
isContextualEditing,
|
|
445
|
+
matchedRoute,
|
|
446
|
+
dynamicInputs
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
/* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react7.default.createElement(
|
|
450
|
+
UniformComponent,
|
|
451
|
+
{
|
|
452
|
+
data: composition,
|
|
453
|
+
behaviorTracking,
|
|
454
|
+
resolveRenderer,
|
|
455
|
+
contextualEditingDefaultPlaceholder
|
|
456
|
+
},
|
|
457
|
+
children
|
|
458
|
+
))
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/defaultSystemComponentResolver.tsx
|
|
463
|
+
var defaultSystemComponentResolver = {
|
|
464
|
+
test: function TestComponent(component, key, renderChild) {
|
|
465
|
+
var _a, _b, _c, _d, _e;
|
|
466
|
+
const testComponent = component;
|
|
467
|
+
const variants = (_b = (_a = testComponent.slots) == null ? void 0 : _a.test) != null ? _b : [];
|
|
468
|
+
const testName = (_e = (_d = (_c = testComponent.parameters) == null ? void 0 : _c.test) == null ? void 0 : _d.value) != null ? _e : "Untitled Test";
|
|
469
|
+
const finalVariants = (0, import_canvas7.mapSlotToTestVariations)(variants);
|
|
470
|
+
const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
|
|
471
|
+
return /* @__PURE__ */ React5.createElement(
|
|
472
|
+
import_context_react3.Test,
|
|
473
|
+
{
|
|
474
|
+
key,
|
|
475
|
+
variations: finalVariants,
|
|
476
|
+
name: testName,
|
|
477
|
+
component: (variation) => renderChild(variation, key),
|
|
478
|
+
compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
},
|
|
482
|
+
personalization: function PersonalizeComponent(component, key, renderChild) {
|
|
483
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
484
|
+
const pzComponent = component;
|
|
485
|
+
const processedVariants = (0, import_canvas7.mapSlotToPersonalizedVariations)((_a = pzComponent == null ? void 0 : pzComponent.slots) == null ? void 0 : _a.pz);
|
|
486
|
+
const { data, matchedRoute, dynamicInputs } = useUniformCurrentComposition();
|
|
487
|
+
return /* @__PURE__ */ React5.createElement(
|
|
488
|
+
import_context_react3.Personalize,
|
|
489
|
+
{
|
|
490
|
+
key,
|
|
491
|
+
variations: processedVariants,
|
|
492
|
+
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),
|
|
493
|
+
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",
|
|
494
|
+
component: (variation) => renderChild(variation, 0),
|
|
495
|
+
compositionMetadata: (data == null ? void 0 : data._id) ? { compositionId: data._id, matchedRoute, dynamicInputs } : void 0,
|
|
496
|
+
algorithm: (_i = (_h = pzComponent.parameters) == null ? void 0 : _h[import_canvas7.CANVAS_PERSONALIZATION_ALGORITHM_PARAM]) == null ? void 0 : _i.value,
|
|
497
|
+
compositionId: data == null ? void 0 : data._id,
|
|
498
|
+
matchedRoute,
|
|
499
|
+
dynamicInputs
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
|
|
473
505
|
// src/components/UniformSlot.tsx
|
|
474
506
|
function UniformSlot({
|
|
475
507
|
name,
|
|
@@ -623,7 +655,7 @@ function UniformComponent({
|
|
|
623
655
|
}) {
|
|
624
656
|
var _a, _b, _c;
|
|
625
657
|
const parentData = useUniformCurrentComponent();
|
|
626
|
-
const contextContextProviderPresent = (0,
|
|
658
|
+
const contextContextProviderPresent = (0, import_context_react4.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
|
|
627
659
|
if (!data) {
|
|
628
660
|
if (process.env.NODE_ENV === "development") {
|
|
629
661
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -637,7 +669,7 @@ function UniformComponent({
|
|
|
637
669
|
contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
|
|
638
670
|
};
|
|
639
671
|
const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas9.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
|
|
640
|
-
const TrackComponent = contextValue.behaviorTracking === "onLoad" ?
|
|
672
|
+
const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react4.TrackFragment : import_context_react4.Track;
|
|
641
673
|
const resolvedChildren = resolveChildren({
|
|
642
674
|
children,
|
|
643
675
|
data,
|