@uniformdev/canvas-react 20.6.2-alpha.11 → 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 +152 -120
- package/dist/index.js +175 -144
- package/dist/index.mjs +152 -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,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,21 +289,22 @@ 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
|
}
|
|
370
300
|
window.__UNIFORM_CONTEXTUAL_EDITING__ = {
|
|
371
301
|
framework: "React",
|
|
372
302
|
// Make sure to also update the value in canvas-vue
|
|
373
|
-
version: 2
|
|
303
|
+
version: 2,
|
|
304
|
+
canvasPackageVersion: import_canvas4.version
|
|
374
305
|
};
|
|
375
306
|
const script = document.createElement("script");
|
|
376
|
-
script.id =
|
|
307
|
+
script.id = import_canvas4.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
|
|
377
308
|
script.src = getCanvasInContextEmbedScriptUrl();
|
|
378
309
|
script.async = true;
|
|
379
310
|
document.head.appendChild(script);
|
|
@@ -392,49 +323,47 @@ function isInContextEditingMode() {
|
|
|
392
323
|
return false;
|
|
393
324
|
}
|
|
394
325
|
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
395
|
-
|
|
326
|
+
import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
396
327
|
);
|
|
397
|
-
return isOpenedByInContextEditor && (0,
|
|
328
|
+
return isOpenedByInContextEditor && (0, import_canvas4.isAllowedReferrer)(window.document.referrer);
|
|
398
329
|
}
|
|
399
330
|
|
|
400
|
-
// src/components/
|
|
401
|
-
var
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
function UniformComposition({
|
|
409
|
-
data,
|
|
410
|
-
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 = ({
|
|
411
339
|
children,
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return /* @__PURE__ */
|
|
422
|
-
|
|
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",
|
|
423
351
|
{
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
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
|
+
};
|
|
438
367
|
|
|
439
368
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
440
369
|
function ContextualEditingComponentWrapper({
|
|
@@ -447,16 +376,16 @@ function ContextualEditingComponentWrapper({
|
|
|
447
376
|
children
|
|
448
377
|
}) {
|
|
449
378
|
var _a;
|
|
450
|
-
const isPlaceholder = (0,
|
|
379
|
+
const isPlaceholder = (0, import_canvas6.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
451
380
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
452
381
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
453
382
|
if (!isContextualEditing) {
|
|
454
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, children);
|
|
455
384
|
}
|
|
456
385
|
if (isPlaceholder && emptyPlaceholder === null) {
|
|
457
386
|
return null;
|
|
458
387
|
}
|
|
459
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
460
389
|
PureContextualEditingComponentWrapper,
|
|
461
390
|
{
|
|
462
391
|
isPlaceholder,
|
|
@@ -471,6 +400,108 @@ function ContextualEditingComponentWrapper({
|
|
|
471
400
|
);
|
|
472
401
|
}
|
|
473
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
|
+
|
|
474
505
|
// src/components/UniformSlot.tsx
|
|
475
506
|
function UniformSlot({
|
|
476
507
|
name,
|
|
@@ -624,7 +655,7 @@ function UniformComponent({
|
|
|
624
655
|
}) {
|
|
625
656
|
var _a, _b, _c;
|
|
626
657
|
const parentData = useUniformCurrentComponent();
|
|
627
|
-
const contextContextProviderPresent = (0,
|
|
658
|
+
const contextContextProviderPresent = (0, import_context_react4.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
|
|
628
659
|
if (!data) {
|
|
629
660
|
if (process.env.NODE_ENV === "development") {
|
|
630
661
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -638,7 +669,7 @@ function UniformComponent({
|
|
|
638
669
|
contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
|
|
639
670
|
};
|
|
640
671
|
const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas9.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
|
|
641
|
-
const TrackComponent = contextValue.behaviorTracking === "onLoad" ?
|
|
672
|
+
const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react4.TrackFragment : import_context_react4.Track;
|
|
642
673
|
const resolvedChildren = resolveChildren({
|
|
643
674
|
children,
|
|
644
675
|
data,
|