@uniformdev/canvas-react 19.135.0 → 19.135.1-alpha.11
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 +245 -90
- package/dist/index.d.ts +245 -90
- package/dist/index.esm.js +125 -60
- package/dist/index.js +210 -146
- package/dist/index.mjs +125 -60
- package/package.json +11 -9
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_canvas6.createUniformApiEnhancer,
|
|
50
50
|
getParameterAttributes: () => getParameterAttributes,
|
|
51
51
|
registerUniformComponent: () => registerUniformComponent,
|
|
52
52
|
useCompositionEventEffect: () => useCompositionEventEffect,
|
|
@@ -131,9 +131,9 @@ registerUniformComponent({ type: "${componentType}", component: ${proposedFileNa
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/components/UniformComponent.tsx
|
|
134
|
-
var
|
|
135
|
-
var
|
|
136
|
-
var
|
|
134
|
+
var import_canvas9 = require("@uniformdev/canvas");
|
|
135
|
+
var import_context_react3 = require("@uniformdev/context-react");
|
|
136
|
+
var import_react9 = __toESM(require("react"));
|
|
137
137
|
|
|
138
138
|
// src/helpers/convertComponentToProps.ts
|
|
139
139
|
function convertComponentToProps(component) {
|
|
@@ -192,8 +192,8 @@ var componentStoreResolver = createComponentStoreResolver({
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// src/components/UniformSlot.tsx
|
|
195
|
-
var
|
|
196
|
-
var
|
|
195
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
196
|
+
var import_react8 = __toESM(require("react"));
|
|
197
197
|
|
|
198
198
|
// src/defaultSystemComponentResolver.tsx
|
|
199
199
|
var import_canvas2 = require("@uniformdev/canvas");
|
|
@@ -234,8 +234,8 @@ var defaultSystemComponentResolver = {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
237
|
-
var
|
|
238
|
-
var
|
|
237
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
238
|
+
var import_react7 = __toESM(require("react"));
|
|
239
239
|
|
|
240
240
|
// src/components/PureContextualEditingComponentWrapper.tsx
|
|
241
241
|
var import_canvas3 = require("@uniformdev/canvas");
|
|
@@ -271,30 +271,71 @@ var PureContextualEditingComponentWrapper = ({
|
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
// src/components/UniformComposition.tsx
|
|
274
|
-
var
|
|
274
|
+
var import_react6 = __toESM(require("react"));
|
|
275
275
|
|
|
276
|
-
// src/hooks/
|
|
276
|
+
// src/hooks/useClientConditionsComposition.ts
|
|
277
|
+
var import_canvas5 = require("@uniformdev/canvas");
|
|
278
|
+
var import_immer = require("immer");
|
|
279
|
+
var import_react4 = require("react");
|
|
280
|
+
|
|
281
|
+
// src/hooks/useClientVisibilityRules.ts
|
|
277
282
|
var import_canvas4 = require("@uniformdev/canvas");
|
|
283
|
+
var import_context_react2 = require("@uniformdev/context-react");
|
|
278
284
|
var import_react3 = require("react");
|
|
285
|
+
function useClientVisibilityRules() {
|
|
286
|
+
const quirks = (0, import_context_react2.useQuirks)({ throwOnMissingProvider: false });
|
|
287
|
+
return (0, import_react3.useMemo)(() => {
|
|
288
|
+
return {
|
|
289
|
+
...(0, import_canvas4.createQuirksVisibilityRule)(quirks)
|
|
290
|
+
};
|
|
291
|
+
}, [quirks]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/hooks/useClientConditionsComposition.ts
|
|
295
|
+
function useClientConditionsComposition(data) {
|
|
296
|
+
const rules = useClientVisibilityRules();
|
|
297
|
+
const preprocessedValue = (0, import_react4.useMemo)(() => {
|
|
298
|
+
if (!data) {
|
|
299
|
+
return data;
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
return (0, import_immer.produce)(data, (draft) => {
|
|
303
|
+
(0, import_canvas5.walkNodeTree)(draft, (context) => {
|
|
304
|
+
(0, import_canvas5.evaluateWalkTreeNodeVisibility)({ context, rules, showIndeterminate: false });
|
|
305
|
+
(0, import_canvas5.evaluateWalkTreePropertyCriteria)({ node: context.node, rules, keepIndeterminate: false });
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
} catch (e) {
|
|
309
|
+
console.error("Error evaluating visibility rules:", e.stack);
|
|
310
|
+
return data;
|
|
311
|
+
}
|
|
312
|
+
}, [data, rules]);
|
|
313
|
+
return preprocessedValue;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/hooks/useUniformContextualEditing.ts
|
|
317
|
+
var import_canvas6 = require("@uniformdev/canvas");
|
|
318
|
+
var import_react5 = require("react");
|
|
279
319
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
280
320
|
var useUniformContextualEditing = ({
|
|
281
321
|
initialCompositionValue,
|
|
282
322
|
enhance = (message) => message.composition
|
|
283
323
|
}) => {
|
|
284
|
-
const [contextualComposition, setContextualComposition] = (0,
|
|
285
|
-
const
|
|
324
|
+
const [contextualComposition, setContextualComposition] = (0, import_react5.useState)();
|
|
325
|
+
const latestEventTimeStamp = (0, import_react5.useRef)();
|
|
326
|
+
const channel = (0, import_react5.useMemo)(() => {
|
|
286
327
|
var _a;
|
|
287
328
|
if (!isInContextEditingMode()) {
|
|
288
329
|
return;
|
|
289
330
|
}
|
|
290
|
-
const channel2 = (0,
|
|
331
|
+
const channel2 = (0, import_canvas6.createCanvasChannel)({
|
|
291
332
|
broadcastTo: [(_a = window.opener) != null ? _a : window.top],
|
|
292
333
|
listenTo: [window]
|
|
293
334
|
});
|
|
294
335
|
return channel2;
|
|
295
336
|
}, []);
|
|
296
|
-
(0,
|
|
297
|
-
if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !==
|
|
337
|
+
(0, import_react5.useEffect)(() => {
|
|
338
|
+
if ((contextualComposition == null ? void 0 : contextualComposition._id) && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== import_canvas6.EMPTY_COMPOSITION._id && (initialCompositionValue == null ? void 0 : initialCompositionValue._id) !== (contextualComposition == null ? void 0 : contextualComposition._id)) {
|
|
298
339
|
setContextualComposition(void 0);
|
|
299
340
|
return;
|
|
300
341
|
}
|
|
@@ -302,11 +343,15 @@ var useUniformContextualEditing = ({
|
|
|
302
343
|
return;
|
|
303
344
|
}
|
|
304
345
|
const unsubscribeFromCompositionUpdates = channel.on("update-composition-internal", async (message) => {
|
|
305
|
-
if (!(0,
|
|
346
|
+
if (!(0, import_canvas6.isUpdateCompositionInternalMessage)(message)) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
306
350
|
return;
|
|
307
351
|
}
|
|
308
352
|
const enhancedComposition = await enhance(message);
|
|
309
353
|
setContextualComposition(enhancedComposition);
|
|
354
|
+
latestEventTimeStamp.current = message.eventTimestamp;
|
|
310
355
|
});
|
|
311
356
|
registeredCompositionIds.add(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
312
357
|
return () => {
|
|
@@ -314,11 +359,11 @@ var useUniformContextualEditing = ({
|
|
|
314
359
|
registeredCompositionIds.delete(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
315
360
|
};
|
|
316
361
|
}, [channel, enhance, initialCompositionValue == null ? void 0 : initialCompositionValue._id, contextualComposition == null ? void 0 : contextualComposition._id]);
|
|
317
|
-
(0,
|
|
362
|
+
(0, import_react5.useEffect)(() => {
|
|
318
363
|
if (!isInContextEditingMode()) {
|
|
319
364
|
return;
|
|
320
365
|
}
|
|
321
|
-
const existingScript = document.getElementById(
|
|
366
|
+
const existingScript = document.getElementById(import_canvas6.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID);
|
|
322
367
|
if (existingScript) {
|
|
323
368
|
return;
|
|
324
369
|
}
|
|
@@ -328,7 +373,7 @@ var useUniformContextualEditing = ({
|
|
|
328
373
|
version: 2
|
|
329
374
|
};
|
|
330
375
|
const script = document.createElement("script");
|
|
331
|
-
script.id =
|
|
376
|
+
script.id = import_canvas6.IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
|
|
332
377
|
script.src = getCanvasInContextEmbedScriptUrl();
|
|
333
378
|
script.async = true;
|
|
334
379
|
document.head.appendChild(script);
|
|
@@ -347,18 +392,18 @@ function isInContextEditingMode() {
|
|
|
347
392
|
return false;
|
|
348
393
|
}
|
|
349
394
|
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
350
|
-
|
|
395
|
+
import_canvas6.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
351
396
|
);
|
|
352
|
-
return isOpenedByInContextEditor && (0,
|
|
397
|
+
return isOpenedByInContextEditor && (0, import_canvas6.isAllowedReferrer)(window.document.referrer);
|
|
353
398
|
}
|
|
354
399
|
|
|
355
400
|
// src/components/UniformComposition.tsx
|
|
356
|
-
var UniformCompositionContext = (0,
|
|
401
|
+
var UniformCompositionContext = (0, import_react6.createContext)({
|
|
357
402
|
data: void 0,
|
|
358
403
|
isContextualEditing: false
|
|
359
404
|
});
|
|
360
405
|
function useUniformCurrentComposition() {
|
|
361
|
-
return (0,
|
|
406
|
+
return (0, import_react6.useContext)(UniformCompositionContext);
|
|
362
407
|
}
|
|
363
408
|
function UniformComposition({
|
|
364
409
|
data,
|
|
@@ -368,16 +413,17 @@ function UniformComposition({
|
|
|
368
413
|
contextualEditingEnhancer,
|
|
369
414
|
contextualEditingDefaultPlaceholder
|
|
370
415
|
}) {
|
|
416
|
+
const ruledComposition = useClientConditionsComposition(data);
|
|
371
417
|
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
372
|
-
initialCompositionValue:
|
|
418
|
+
initialCompositionValue: ruledComposition,
|
|
373
419
|
enhance: contextualEditingEnhancer
|
|
374
420
|
});
|
|
375
|
-
return /* @__PURE__ */
|
|
421
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
376
422
|
UniformCompositionContext.Provider,
|
|
377
423
|
{
|
|
378
424
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
379
425
|
},
|
|
380
|
-
/* @__PURE__ */
|
|
426
|
+
/* @__PURE__ */ import_react6.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react6.default.createElement(
|
|
381
427
|
UniformComponent,
|
|
382
428
|
{
|
|
383
429
|
data: composition,
|
|
@@ -401,16 +447,16 @@ function ContextualEditingComponentWrapper({
|
|
|
401
447
|
children
|
|
402
448
|
}) {
|
|
403
449
|
var _a;
|
|
404
|
-
const isPlaceholder = (0,
|
|
450
|
+
const isPlaceholder = (0, import_canvas7.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
405
451
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
406
452
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
407
453
|
if (!isContextualEditing) {
|
|
408
|
-
return /* @__PURE__ */
|
|
454
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, children);
|
|
409
455
|
}
|
|
410
456
|
if (isPlaceholder && emptyPlaceholder === null) {
|
|
411
457
|
return null;
|
|
412
458
|
}
|
|
413
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
414
460
|
PureContextualEditingComponentWrapper,
|
|
415
461
|
{
|
|
416
462
|
isPlaceholder,
|
|
@@ -440,7 +486,7 @@ function UniformSlot({
|
|
|
440
486
|
}
|
|
441
487
|
const slot = (_a = parentData.slots) == null ? void 0 : _a[name];
|
|
442
488
|
if (!slot || !Array.isArray(slot)) {
|
|
443
|
-
if (process.env.NODE_ENV === "development" && parentData.type !==
|
|
489
|
+
if (process.env.NODE_ENV === "development" && parentData.type !== import_canvas8.EMPTY_COMPOSITION.type) {
|
|
444
490
|
console.warn(
|
|
445
491
|
`[canvas-dev] slot '${name}' was rendered, but it was not defined on its component. This is expected if the slot is optional, otherwise it may indicate a typo. Component:`,
|
|
446
492
|
parentData
|
|
@@ -461,13 +507,13 @@ function UniformSlot({
|
|
|
461
507
|
emptyPlaceholder
|
|
462
508
|
});
|
|
463
509
|
const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
|
|
464
|
-
return
|
|
510
|
+
return import_react8.default.createElement(import_react8.default.Fragment, { key: index }, elements);
|
|
465
511
|
});
|
|
466
512
|
if (!wrapperComponent) {
|
|
467
|
-
return
|
|
513
|
+
return import_react8.default.createElement(import_react8.default.Fragment, void 0, finalChildren);
|
|
468
514
|
}
|
|
469
515
|
const Wrapper = wrapperComponent;
|
|
470
|
-
return /* @__PURE__ */
|
|
516
|
+
return /* @__PURE__ */ import_react8.default.createElement(Wrapper, { items: finalChildren, slotName: name });
|
|
471
517
|
}
|
|
472
518
|
function renderComponent({
|
|
473
519
|
component,
|
|
@@ -480,7 +526,7 @@ function renderComponent({
|
|
|
480
526
|
emptyPlaceholder
|
|
481
527
|
}) {
|
|
482
528
|
const RenderComponent = resolveRenderer == null ? void 0 : resolveRenderer(component);
|
|
483
|
-
if (component.type ===
|
|
529
|
+
if (component.type === import_canvas8.CANVAS_TEST_TYPE) {
|
|
484
530
|
const testComponent = defaultSystemComponentResolver.test(
|
|
485
531
|
component,
|
|
486
532
|
key,
|
|
@@ -491,15 +537,15 @@ function renderComponent({
|
|
|
491
537
|
resolveRenderer,
|
|
492
538
|
key: key2,
|
|
493
539
|
parentComponent: component,
|
|
494
|
-
slotName:
|
|
495
|
-
slotChildrenCount: (_a = component == null ? void 0 : component.slots) == null ? void 0 : _a[
|
|
496
|
-
indexInSlot: (_b = component == null ? void 0 : component.slots) == null ? void 0 : _b[
|
|
540
|
+
slotName: import_canvas8.CANVAS_TEST_SLOT,
|
|
541
|
+
slotChildrenCount: (_a = component == null ? void 0 : component.slots) == null ? void 0 : _a[import_canvas8.CANVAS_TEST_SLOT].length,
|
|
542
|
+
indexInSlot: (_b = component == null ? void 0 : component.slots) == null ? void 0 : _b[import_canvas8.CANVAS_TEST_SLOT].findIndex(
|
|
497
543
|
({ _id }) => variantComponent._id === _id
|
|
498
544
|
)
|
|
499
545
|
});
|
|
500
546
|
}
|
|
501
547
|
);
|
|
502
|
-
return /* @__PURE__ */
|
|
548
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
503
549
|
ContextualEditingComponentWrapper,
|
|
504
550
|
{
|
|
505
551
|
component,
|
|
@@ -511,7 +557,7 @@ function renderComponent({
|
|
|
511
557
|
},
|
|
512
558
|
testComponent
|
|
513
559
|
);
|
|
514
|
-
} else if (component.type ===
|
|
560
|
+
} else if (component.type === import_canvas8.CANVAS_PERSONALIZE_TYPE) {
|
|
515
561
|
const personalizationComponent = defaultSystemComponentResolver.personalization(
|
|
516
562
|
component,
|
|
517
563
|
key,
|
|
@@ -522,15 +568,15 @@ function renderComponent({
|
|
|
522
568
|
resolveRenderer,
|
|
523
569
|
key: key2,
|
|
524
570
|
parentComponent: component,
|
|
525
|
-
slotName:
|
|
526
|
-
slotChildrenCount: (_a = component == null ? void 0 : component.slots) == null ? void 0 : _a[
|
|
527
|
-
indexInSlot: (_b = component == null ? void 0 : component.slots) == null ? void 0 : _b[
|
|
571
|
+
slotName: import_canvas8.CANVAS_PERSONALIZE_SLOT,
|
|
572
|
+
slotChildrenCount: (_a = component == null ? void 0 : component.slots) == null ? void 0 : _a[import_canvas8.CANVAS_PERSONALIZE_SLOT].length,
|
|
573
|
+
indexInSlot: (_b = component == null ? void 0 : component.slots) == null ? void 0 : _b[import_canvas8.CANVAS_PERSONALIZE_SLOT].findIndex(
|
|
528
574
|
({ _id }) => variantComponent._id === _id
|
|
529
575
|
)
|
|
530
576
|
});
|
|
531
577
|
}
|
|
532
578
|
);
|
|
533
|
-
return /* @__PURE__ */
|
|
579
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
534
580
|
ContextualEditingComponentWrapper,
|
|
535
581
|
{
|
|
536
582
|
component,
|
|
@@ -544,7 +590,7 @@ function renderComponent({
|
|
|
544
590
|
);
|
|
545
591
|
} else if (RenderComponent) {
|
|
546
592
|
const props = convertComponentToProps(component);
|
|
547
|
-
return /* @__PURE__ */
|
|
593
|
+
return /* @__PURE__ */ import_react8.default.createElement(UniformComponent, { key, data: component, resolveRenderer }, /* @__PURE__ */ import_react8.default.createElement(
|
|
548
594
|
ContextualEditingComponentWrapper,
|
|
549
595
|
{
|
|
550
596
|
component,
|
|
@@ -554,7 +600,7 @@ function renderComponent({
|
|
|
554
600
|
slotChildrenCount,
|
|
555
601
|
emptyPlaceholder
|
|
556
602
|
},
|
|
557
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ import_react8.default.createElement(RenderComponent, { ...props })
|
|
558
604
|
));
|
|
559
605
|
} else if (process.env.NODE_ENV !== "production") {
|
|
560
606
|
console.warn(
|
|
@@ -567,9 +613,9 @@ function renderComponent({
|
|
|
567
613
|
}
|
|
568
614
|
|
|
569
615
|
// src/components/UniformComponent.tsx
|
|
570
|
-
var UniformComponentContext = (0,
|
|
616
|
+
var UniformComponentContext = (0, import_react9.createContext)({});
|
|
571
617
|
function useUniformCurrentComponent() {
|
|
572
|
-
return (0,
|
|
618
|
+
return (0, import_react9.useContext)(UniformComponentContext);
|
|
573
619
|
}
|
|
574
620
|
function UniformComponent({
|
|
575
621
|
data,
|
|
@@ -580,7 +626,7 @@ function UniformComponent({
|
|
|
580
626
|
}) {
|
|
581
627
|
var _a, _b, _c;
|
|
582
628
|
const parentData = useUniformCurrentComponent();
|
|
583
|
-
const contextContextProviderPresent = (0,
|
|
629
|
+
const contextContextProviderPresent = (0, import_context_react3.useUniformContext)({ throwOnMissingProvider: false }) !== void 0;
|
|
584
630
|
if (!data) {
|
|
585
631
|
if (process.env.NODE_ENV === "development") {
|
|
586
632
|
console.warn(`[canvas-dev] UniformComponent was rendered with no data, nothing will be output.`);
|
|
@@ -593,17 +639,17 @@ function UniformComponent({
|
|
|
593
639
|
behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView",
|
|
594
640
|
contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
|
|
595
641
|
};
|
|
596
|
-
const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[
|
|
597
|
-
const TrackComponent = contextValue.behaviorTracking === "onLoad" ?
|
|
642
|
+
const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas9.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
|
|
643
|
+
const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react3.TrackFragment : import_context_react3.Track;
|
|
598
644
|
const resolvedChildren = resolveChildren({
|
|
599
645
|
children,
|
|
600
646
|
data,
|
|
601
647
|
hasParentLayout: Boolean(parentData.data),
|
|
602
648
|
resolveRenderer: contextValue.resolveRenderer
|
|
603
649
|
});
|
|
604
|
-
return /* @__PURE__ */
|
|
650
|
+
return /* @__PURE__ */ import_react9.default.createElement(UniformComponentContext.Provider, { value: contextValue }, contextContextProviderPresent ? (
|
|
605
651
|
/* auto-track behavior signals when in a Canvas context */
|
|
606
|
-
/* @__PURE__ */
|
|
652
|
+
/* @__PURE__ */ import_react9.default.createElement(TrackComponent, { behavior: enrichmentTags }, resolvedChildren)
|
|
607
653
|
) : resolvedChildren);
|
|
608
654
|
}
|
|
609
655
|
function resolveChildren({
|
|
@@ -616,14 +662,14 @@ function resolveChildren({
|
|
|
616
662
|
if (!children && !hasParentLayout) {
|
|
617
663
|
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
618
664
|
if (topLevelComponent) {
|
|
619
|
-
children =
|
|
665
|
+
children = import_react9.default.createElement(topLevelComponent, convertComponentToProps(data));
|
|
620
666
|
} else {
|
|
621
667
|
if (Object.keys((_a = data.slots) != null ? _a : {}).length > 1 && process.env.NODE_ENV === "development") {
|
|
622
668
|
console.warn(
|
|
623
669
|
`[canvas-dev] All the slots in component '${data.type}' are rendered in no particular order. Use '<UniformSlot name={slotName} />' to reliably render the slots.`
|
|
624
670
|
);
|
|
625
671
|
}
|
|
626
|
-
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */
|
|
672
|
+
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */ import_react9.default.createElement(UniformSlot, { key: slotName, name: slotName }));
|
|
627
673
|
}
|
|
628
674
|
}
|
|
629
675
|
const renderChildren = typeof children === "function" ? children(convertComponentToProps(data)) : children;
|
|
@@ -631,47 +677,38 @@ function resolveChildren({
|
|
|
631
677
|
}
|
|
632
678
|
|
|
633
679
|
// src/components/UniformPlayground.tsx
|
|
634
|
-
var
|
|
635
|
-
var
|
|
680
|
+
var import_canvas10 = require("@uniformdev/canvas");
|
|
681
|
+
var import_react10 = __toESM(require("react"));
|
|
636
682
|
var UniformPlayground = ({
|
|
637
683
|
resolveRenderer,
|
|
638
684
|
decorators = [],
|
|
639
685
|
contextualEditingEnhancer,
|
|
640
686
|
behaviorTracking,
|
|
641
|
-
contextualEditingDefaultPlaceholder
|
|
642
|
-
children
|
|
687
|
+
contextualEditingDefaultPlaceholder
|
|
643
688
|
}) => {
|
|
644
689
|
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
645
|
-
initialCompositionValue:
|
|
690
|
+
initialCompositionValue: import_canvas10.EMPTY_COMPOSITION,
|
|
646
691
|
enhance: contextualEditingEnhancer
|
|
647
692
|
});
|
|
648
|
-
const renderedComponent = (0,
|
|
693
|
+
const renderedComponent = (0, import_react10.useMemo)(() => {
|
|
649
694
|
if (!composition) {
|
|
650
695
|
return null;
|
|
651
696
|
}
|
|
652
|
-
let component = /* @__PURE__ */
|
|
697
|
+
let component = /* @__PURE__ */ import_react10.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react10.default.createElement(
|
|
653
698
|
UniformComponent,
|
|
654
699
|
{
|
|
655
700
|
data: composition,
|
|
656
701
|
behaviorTracking,
|
|
657
702
|
resolveRenderer,
|
|
658
703
|
contextualEditingDefaultPlaceholder
|
|
659
|
-
}
|
|
660
|
-
children
|
|
704
|
+
}
|
|
661
705
|
));
|
|
662
706
|
decorators.forEach((Decorator) => {
|
|
663
|
-
component = /* @__PURE__ */
|
|
707
|
+
component = /* @__PURE__ */ import_react10.default.createElement(Decorator, { data: composition }, component);
|
|
664
708
|
});
|
|
665
709
|
return component;
|
|
666
|
-
}, [
|
|
667
|
-
|
|
668
|
-
resolveRenderer,
|
|
669
|
-
decorators,
|
|
670
|
-
composition,
|
|
671
|
-
behaviorTracking,
|
|
672
|
-
contextualEditingDefaultPlaceholder
|
|
673
|
-
]);
|
|
674
|
-
return /* @__PURE__ */ import_react8.default.createElement(
|
|
710
|
+
}, [resolveRenderer, decorators, composition, behaviorTracking, contextualEditingDefaultPlaceholder]);
|
|
711
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
675
712
|
UniformCompositionContext.Provider,
|
|
676
713
|
{
|
|
677
714
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
@@ -681,57 +718,57 @@ var UniformPlayground = ({
|
|
|
681
718
|
};
|
|
682
719
|
|
|
683
720
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
684
|
-
var
|
|
685
|
-
var
|
|
686
|
-
var
|
|
721
|
+
var import_canvas11 = require("@uniformdev/canvas");
|
|
722
|
+
var import_richtext6 = require("@uniformdev/richtext");
|
|
723
|
+
var import_react21 = __toESM(require("react"));
|
|
687
724
|
|
|
688
725
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
689
|
-
var
|
|
690
|
-
var
|
|
726
|
+
var import_richtext5 = require("@uniformdev/richtext");
|
|
727
|
+
var import_react20 = __toESM(require("react"));
|
|
691
728
|
|
|
692
729
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
693
|
-
var
|
|
730
|
+
var import_react11 = __toESM(require("react"));
|
|
694
731
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
695
732
|
const { tag } = node;
|
|
696
733
|
const HTag = tag != null ? tag : "h1";
|
|
697
|
-
return /* @__PURE__ */
|
|
734
|
+
return /* @__PURE__ */ import_react11.default.createElement(HTag, null, children);
|
|
698
735
|
};
|
|
699
736
|
|
|
700
737
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
701
|
-
var
|
|
738
|
+
var import_react12 = __toESM(require("react"));
|
|
702
739
|
var LinebreakRichTextNode = () => {
|
|
703
|
-
return /* @__PURE__ */
|
|
740
|
+
return /* @__PURE__ */ import_react12.default.createElement("br", null);
|
|
704
741
|
};
|
|
705
742
|
|
|
706
743
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
707
744
|
var import_richtext = require("@uniformdev/richtext");
|
|
708
|
-
var
|
|
745
|
+
var import_react13 = __toESM(require("react"));
|
|
709
746
|
var LinkRichTextNode = ({ children, node }) => {
|
|
710
747
|
const { link } = node;
|
|
711
|
-
return /* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ import_react13.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
|
|
712
749
|
};
|
|
713
750
|
|
|
714
751
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
715
|
-
var
|
|
752
|
+
var import_react14 = __toESM(require("react"));
|
|
716
753
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
717
754
|
const { value } = node;
|
|
718
|
-
return /* @__PURE__ */
|
|
755
|
+
return /* @__PURE__ */ import_react14.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
719
756
|
};
|
|
720
757
|
|
|
721
758
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
722
|
-
var
|
|
759
|
+
var import_react15 = __toESM(require("react"));
|
|
723
760
|
var ListRichTextNode = ({ children, node }) => {
|
|
724
761
|
const { tag, start } = node;
|
|
725
762
|
const ListTag = tag != null ? tag : "ul";
|
|
726
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ import_react15.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
727
764
|
};
|
|
728
765
|
|
|
729
766
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
730
767
|
var import_richtext2 = require("@uniformdev/richtext");
|
|
731
|
-
var
|
|
768
|
+
var import_react16 = __toESM(require("react"));
|
|
732
769
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
733
770
|
const { format, direction } = node;
|
|
734
|
-
return /* @__PURE__ */
|
|
771
|
+
return /* @__PURE__ */ import_react16.default.createElement(
|
|
735
772
|
"p",
|
|
736
773
|
{
|
|
737
774
|
dir: (0, import_richtext2.isPureDirection)(direction) ? direction : void 0,
|
|
@@ -741,26 +778,34 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
741
778
|
);
|
|
742
779
|
};
|
|
743
780
|
|
|
781
|
+
// src/components/UniformRichText/nodes/TableCellRichTextNode.tsx
|
|
782
|
+
var import_richtext3 = require("@uniformdev/richtext");
|
|
783
|
+
var import_react17 = __toESM(require("react"));
|
|
784
|
+
var TableCellRichTextNode = ({ children, node }) => {
|
|
785
|
+
const { headerState } = node;
|
|
786
|
+
const TableCellTag = (0, import_richtext3.getRichTextTagFromTableCellHeaderState)(headerState);
|
|
787
|
+
return /* @__PURE__ */ import_react17.default.createElement(TableCellTag, null, children);
|
|
788
|
+
};
|
|
789
|
+
|
|
744
790
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
745
|
-
var
|
|
791
|
+
var import_react18 = __toESM(require("react"));
|
|
746
792
|
var TabRichTextNode = () => {
|
|
747
|
-
return /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_react18.default.Fragment, null, " ");
|
|
748
794
|
};
|
|
749
795
|
|
|
750
796
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
751
|
-
var
|
|
752
|
-
var
|
|
797
|
+
var import_richtext4 = require("@uniformdev/richtext");
|
|
798
|
+
var import_react19 = __toESM(require("react"));
|
|
753
799
|
var TextRichTextNode = ({ node }) => {
|
|
754
800
|
const { text, format } = node;
|
|
755
|
-
const tags = (0,
|
|
756
|
-
return /* @__PURE__ */
|
|
801
|
+
const tags = (0, import_richtext4.getRichTextTagsFromTextFormat)(format);
|
|
802
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ import_react19.default.createElement(Tag, null, children), text) : text);
|
|
757
803
|
};
|
|
758
804
|
|
|
759
805
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
760
806
|
function UniformRichTextNode({ node, ...props }) {
|
|
761
807
|
var _a;
|
|
762
|
-
if (!(0,
|
|
763
|
-
return null;
|
|
808
|
+
if (!(0, import_richtext5.isRichTextNode)(node)) return null;
|
|
764
809
|
let NodeRenderer = (_a = props.resolveRichTextRenderer) == null ? void 0 : _a.call(props, node);
|
|
765
810
|
if (typeof NodeRenderer === "undefined") {
|
|
766
811
|
NodeRenderer = resolveRichTextDefaultRenderer(node);
|
|
@@ -768,8 +813,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
768
813
|
if (!NodeRenderer) {
|
|
769
814
|
return null;
|
|
770
815
|
}
|
|
771
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
772
|
-
return /* @__PURE__ */
|
|
816
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ import_react20.default.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
817
|
+
return /* @__PURE__ */ import_react20.default.createElement(NodeRenderer, { node }, children);
|
|
773
818
|
}
|
|
774
819
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
775
820
|
["heading", HeadingRichTextNode],
|
|
@@ -778,49 +823,59 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
778
823
|
["list", ListRichTextNode],
|
|
779
824
|
["listitem", ListItemRichTextNode],
|
|
780
825
|
["paragraph", ParagraphRichTextNode],
|
|
781
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
826
|
+
["quote", ({ children }) => /* @__PURE__ */ import_react20.default.createElement("blockquote", null, children)],
|
|
782
827
|
[
|
|
783
828
|
"code",
|
|
784
|
-
({ children }) => /* @__PURE__ */
|
|
829
|
+
({ children }) => /* @__PURE__ */ import_react20.default.createElement("pre", null, /* @__PURE__ */ import_react20.default.createElement("code", null, children))
|
|
785
830
|
],
|
|
786
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
831
|
+
["root", ({ children }) => /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, children)],
|
|
787
832
|
["text", TextRichTextNode],
|
|
788
|
-
["tab", TabRichTextNode]
|
|
833
|
+
["tab", TabRichTextNode],
|
|
834
|
+
[
|
|
835
|
+
"table",
|
|
836
|
+
({ children }) => /* @__PURE__ */ import_react20.default.createElement("table", null, /* @__PURE__ */ import_react20.default.createElement("tbody", null, children))
|
|
837
|
+
],
|
|
838
|
+
["tablerow", ({ children }) => /* @__PURE__ */ import_react20.default.createElement("tr", null, children)],
|
|
839
|
+
["tablecell", TableCellRichTextNode]
|
|
789
840
|
]);
|
|
790
841
|
var resolveRichTextDefaultRenderer = (node) => {
|
|
791
842
|
return rendererMap.get(node.type);
|
|
792
843
|
};
|
|
793
844
|
|
|
794
845
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
795
|
-
var UniformRichText =
|
|
796
|
-
|
|
797
|
-
const
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const value = (0, import_react18.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
802
|
-
if (!value || !(0, import_richtext5.isRichTextValue)(value) || (0, import_richtext5.isRichTextValueConsideredEmpty)(value))
|
|
846
|
+
var UniformRichText = import_react21.default.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", placeholder, ...props }, ref) {
|
|
847
|
+
var _a;
|
|
848
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
849
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
850
|
+
const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
851
|
+
if (!parameter) {
|
|
803
852
|
return null;
|
|
804
|
-
|
|
853
|
+
}
|
|
854
|
+
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
855
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
856
|
+
const value = parameter.value;
|
|
857
|
+
if (!value || !(0, import_richtext6.isRichTextValue)(value)) return null;
|
|
858
|
+
if (!isContextualEditing && (0, import_richtext6.isRichTextValueConsideredEmpty)(value)) return null;
|
|
859
|
+
return Tag === null ? /* @__PURE__ */ import_react21.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ import_react21.default.createElement(
|
|
805
860
|
Tag,
|
|
806
861
|
{
|
|
807
862
|
ref,
|
|
808
863
|
...props,
|
|
809
|
-
...{
|
|
810
|
-
[
|
|
811
|
-
[
|
|
812
|
-
[
|
|
813
|
-
}
|
|
864
|
+
...isContextualEditing ? {
|
|
865
|
+
[import_canvas11.ATTRIBUTE_COMPONENT_ID]: componentData == null ? void 0 : componentData._id,
|
|
866
|
+
[import_canvas11.ATTRIBUTE_PARAMETER_ID]: parameterId,
|
|
867
|
+
[import_canvas11.ATTRIBUTE_PARAMETER_TYPE]: "richText"
|
|
868
|
+
} : {}
|
|
814
869
|
},
|
|
815
|
-
/* @__PURE__ */
|
|
870
|
+
(0, import_richtext6.isRichTextValueConsideredEmpty)(value) ? /* @__PURE__ */ import_react21.default.createElement("p", null, /* @__PURE__ */ import_react21.default.createElement("i", null, computedPlaceholder)) : /* @__PURE__ */ import_react21.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
|
|
816
871
|
);
|
|
817
872
|
});
|
|
818
873
|
|
|
819
874
|
// src/components/UniformText.tsx
|
|
820
|
-
var
|
|
875
|
+
var import_react23 = __toESM(require("react"));
|
|
821
876
|
|
|
822
877
|
// src/components/PureUniformText.tsx
|
|
823
|
-
var
|
|
878
|
+
var import_react22 = __toESM(require("react"));
|
|
824
879
|
var PureUniformText = ({
|
|
825
880
|
as: Tag = "span",
|
|
826
881
|
parameterId,
|
|
@@ -839,10 +894,10 @@ var PureUniformText = ({
|
|
|
839
894
|
return null;
|
|
840
895
|
}
|
|
841
896
|
if (!isContextualEditing) {
|
|
842
|
-
return /* @__PURE__ */
|
|
897
|
+
return /* @__PURE__ */ import_react22.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
843
898
|
}
|
|
844
899
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
845
|
-
return /* @__PURE__ */
|
|
900
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
846
901
|
Tag,
|
|
847
902
|
{
|
|
848
903
|
...props,
|
|
@@ -871,7 +926,7 @@ var UniformText = ({
|
|
|
871
926
|
var _a, _b, _c;
|
|
872
927
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
873
928
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
874
|
-
const [isFocused, setIsFocused] = (0,
|
|
929
|
+
const [isFocused, setIsFocused] = (0, import_react23.useState)(false);
|
|
875
930
|
const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
876
931
|
const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
|
|
877
932
|
const shouldSkipCustomRendering = isFocused && isEditable;
|
|
@@ -880,7 +935,7 @@ var UniformText = ({
|
|
|
880
935
|
}
|
|
881
936
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
882
937
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
883
|
-
return /* @__PURE__ */
|
|
938
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
884
939
|
PureUniformText,
|
|
885
940
|
{
|
|
886
941
|
...props,
|
|
@@ -903,35 +958,35 @@ var UniformText = ({
|
|
|
903
958
|
};
|
|
904
959
|
|
|
905
960
|
// src/helpers/getParameterAttributes.ts
|
|
906
|
-
var
|
|
961
|
+
var import_canvas12 = require("@uniformdev/canvas");
|
|
907
962
|
var getParameterAttributes = (options) => {
|
|
908
963
|
return {
|
|
909
|
-
...(0,
|
|
964
|
+
...(0, import_canvas12.getParameterAttributes)(options),
|
|
910
965
|
suppressContentEditableWarning: true
|
|
911
966
|
};
|
|
912
967
|
};
|
|
913
968
|
|
|
914
969
|
// src/hooks/useCompositionEventEffect.ts
|
|
915
|
-
var
|
|
916
|
-
var
|
|
970
|
+
var import_canvas13 = require("@uniformdev/canvas");
|
|
971
|
+
var import_react24 = require("react");
|
|
917
972
|
function useCompositionEventEffect({
|
|
918
973
|
enabled,
|
|
919
974
|
projectId,
|
|
920
975
|
compositionId,
|
|
921
976
|
effect
|
|
922
977
|
}) {
|
|
923
|
-
(0,
|
|
978
|
+
(0, import_react24.useEffect)(() => {
|
|
924
979
|
if (!enabled || !compositionId || !projectId) {
|
|
925
980
|
return;
|
|
926
981
|
}
|
|
927
982
|
let goodbye = void 0;
|
|
928
983
|
const loadEffect = async () => {
|
|
929
|
-
const eventBus = await (0,
|
|
984
|
+
const eventBus = await (0, import_canvas13.createEventBus)();
|
|
930
985
|
if (eventBus) {
|
|
931
|
-
goodbye = (0,
|
|
986
|
+
goodbye = (0, import_canvas13.subscribeToComposition)({
|
|
932
987
|
eventBus,
|
|
933
988
|
compositionId,
|
|
934
|
-
compositionState:
|
|
989
|
+
compositionState: import_canvas13.CANVAS_DRAFT_STATE,
|
|
935
990
|
projectId,
|
|
936
991
|
callback: effect,
|
|
937
992
|
event: "updated"
|
|
@@ -948,34 +1003,42 @@ function useCompositionEventEffect({
|
|
|
948
1003
|
}
|
|
949
1004
|
|
|
950
1005
|
// src/hooks/useUniformContextualEditingState.ts
|
|
951
|
-
var
|
|
952
|
-
var
|
|
1006
|
+
var import_canvas14 = require("@uniformdev/canvas");
|
|
1007
|
+
var import_react25 = require("react");
|
|
953
1008
|
var useUniformContextualEditingState = ({
|
|
954
1009
|
global = false
|
|
955
1010
|
} = {}) => {
|
|
956
1011
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
957
1012
|
const { data: componentData } = useUniformCurrentComponent();
|
|
958
|
-
const [selectedComponentReference, setSelectedComponentReference] = (0,
|
|
959
|
-
const
|
|
1013
|
+
const [selectedComponentReference, setSelectedComponentReference] = (0, import_react25.useState)();
|
|
1014
|
+
const [previewMode, setPreviewMode] = (0, import_react25.useState)(
|
|
1015
|
+
isContextualEditing ? "editor" : void 0
|
|
1016
|
+
);
|
|
1017
|
+
const channel = (0, import_react25.useMemo)(() => {
|
|
960
1018
|
if (!isContextualEditing) {
|
|
961
1019
|
return;
|
|
962
1020
|
}
|
|
963
|
-
const channel2 = (0,
|
|
1021
|
+
const channel2 = (0, import_canvas14.createCanvasChannel)({
|
|
964
1022
|
broadcastTo: [window],
|
|
965
1023
|
listenTo: [window]
|
|
966
1024
|
});
|
|
967
1025
|
return channel2;
|
|
968
1026
|
}, [isContextualEditing]);
|
|
969
|
-
(0,
|
|
1027
|
+
(0, import_react25.useEffect)(() => {
|
|
1028
|
+
var _a, _b;
|
|
970
1029
|
if (!channel) {
|
|
971
1030
|
return;
|
|
972
1031
|
}
|
|
1032
|
+
if (typeof window !== "undefined") {
|
|
1033
|
+
setPreviewMode((_b = (_a = window.__UNIFORM_CONTEXTUAL_EDITING__) == null ? void 0 : _a.state) == null ? void 0 : _b.previewMode);
|
|
1034
|
+
}
|
|
973
1035
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
974
|
-
var
|
|
975
|
-
if (!(0,
|
|
1036
|
+
var _a2;
|
|
1037
|
+
if (!(0, import_canvas14.isUpdateContextualEditingStateInternalMessage)(message)) {
|
|
976
1038
|
return;
|
|
977
1039
|
}
|
|
978
|
-
|
|
1040
|
+
setPreviewMode(message.state.previewMode);
|
|
1041
|
+
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a2 = message.state.selectedComponentReference) == null ? void 0 : _a2.parentId)) {
|
|
979
1042
|
setSelectedComponentReference(void 0);
|
|
980
1043
|
return;
|
|
981
1044
|
}
|
|
@@ -984,13 +1047,14 @@ var useUniformContextualEditingState = ({
|
|
|
984
1047
|
return () => {
|
|
985
1048
|
unsubscribe();
|
|
986
1049
|
};
|
|
987
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
988
|
-
return (0,
|
|
1050
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
1051
|
+
return (0, import_react25.useMemo)(
|
|
989
1052
|
() => ({
|
|
990
1053
|
isContextualEditing,
|
|
991
|
-
selectedComponentReference
|
|
1054
|
+
selectedComponentReference,
|
|
1055
|
+
previewMode
|
|
992
1056
|
}),
|
|
993
|
-
[isContextualEditing, selectedComponentReference]
|
|
1057
|
+
[isContextualEditing, selectedComponentReference, previewMode]
|
|
994
1058
|
);
|
|
995
1059
|
};
|
|
996
1060
|
// Annotate the CommonJS export names for ESM import in node:
|