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