@uniformdev/canvas-react 19.38.2 → 19.38.3-alpha.78

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.mjs CHANGED
@@ -330,9 +330,10 @@ function ContextualEditingComponentWrapper({
330
330
  emptyPlaceholder,
331
331
  children
332
332
  }) {
333
- var _a, _b, _c, _d;
333
+ var _a, _b, _c, _d, _e;
334
334
  const isPlaceholder = (component == null ? void 0 : component._id) === PLACEHOLDER_ID;
335
335
  const { isContextualEditing } = useUniformCurrentComposition();
336
+ const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
336
337
  return !isContextualEditing ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
337
338
  "script",
338
339
  {
@@ -345,8 +346,9 @@ function ContextualEditingComponentWrapper({
345
346
  "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
346
347
  "data-component-name": component == null ? void 0 : component.type,
347
348
  "data-is-placeholder": isPlaceholder ? "true" : void 0,
348
- "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
349
- "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : ""
349
+ "data-is-localized": ((_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
350
+ "data-component-title": (_e = (_d = (_c = component == null ? void 0 : component.parameters) == null ? void 0 : _c.title) == null ? void 0 : _d.value) != null ? _e : "",
351
+ "data-is-readonly": isReadOnly
350
352
  }
351
353
  ), isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children, /* @__PURE__ */ React4.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
352
354
  }
@@ -356,7 +358,8 @@ function UniformSlot({
356
358
  name,
357
359
  resolveRenderer,
358
360
  children,
359
- emptyPlaceholder
361
+ emptyPlaceholder,
362
+ wrapperComponent
360
363
  }) {
361
364
  var _a;
362
365
  const { data: parentData, resolveRenderer: parentResolveRenderer } = useUniformCurrentComponent();
@@ -374,12 +377,10 @@ function UniformSlot({
374
377
  return null;
375
378
  }
376
379
  const resolver = resolveRenderer != null ? resolveRenderer : parentResolveRenderer;
377
- const systemResolver = defaultSystemComponentResolver;
378
380
  const finalChildren = slot.map((component, index) => {
379
381
  const child = renderComponent({
380
382
  component,
381
383
  resolveRenderer: resolver,
382
- resolveSystem: systemResolver,
383
384
  key: `inner-${index}`,
384
385
  indexInSlot: index,
385
386
  slotName: name,
@@ -390,12 +391,15 @@ function UniformSlot({
390
391
  const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
391
392
  return React5.createElement(React5.Fragment, { key: index }, elements);
392
393
  });
393
- return React5.createElement(React5.Fragment, void 0, finalChildren);
394
+ if (!wrapperComponent) {
395
+ return React5.createElement(React5.Fragment, void 0, finalChildren);
396
+ }
397
+ const Wrapper = wrapperComponent;
398
+ return /* @__PURE__ */ React5.createElement(Wrapper, { items: finalChildren, slotName: name });
394
399
  }
395
400
  function renderComponent({
396
401
  component,
397
402
  resolveRenderer,
398
- resolveSystem,
399
403
  key = 0,
400
404
  indexInSlot,
401
405
  slotName,
@@ -405,7 +409,7 @@ function renderComponent({
405
409
  }) {
406
410
  const RenderComponent = resolveRenderer == null ? void 0 : resolveRenderer(component);
407
411
  if (component.type === CANVAS_TEST_TYPE) {
408
- const testComponent = resolveSystem.test(
412
+ const testComponent = defaultSystemComponentResolver.test(
409
413
  component,
410
414
  key,
411
415
  (variantComponent, key2) => {
@@ -413,7 +417,6 @@ function renderComponent({
413
417
  return renderComponent({
414
418
  component: variantComponent,
415
419
  resolveRenderer,
416
- resolveSystem,
417
420
  key: key2,
418
421
  parentComponent: component,
419
422
  slotName: CANVAS_TEST_SLOT,
@@ -437,7 +440,7 @@ function renderComponent({
437
440
  testComponent
438
441
  );
439
442
  } else if (component.type === CANVAS_PERSONALIZE_TYPE) {
440
- const personalizationComponent = resolveSystem.personalization(
443
+ const personalizationComponent = defaultSystemComponentResolver.personalization(
441
444
  component,
442
445
  key,
443
446
  (variantComponent, key2) => {
@@ -445,7 +448,6 @@ function renderComponent({
445
448
  return renderComponent({
446
449
  component: variantComponent,
447
450
  resolveRenderer,
448
- resolveSystem,
449
451
  key: key2,
450
452
  parentComponent: component,
451
453
  slotName: CANVAS_PERSONALIZE_SLOT,
@@ -556,60 +558,110 @@ function resolveChildren({
556
558
  return renderChildren;
557
559
  }
558
560
 
561
+ // src/components/UniformPlayground.tsx
562
+ import { EMPTY_COMPOSITION as EMPTY_COMPOSITION3 } from "@uniformdev/canvas";
563
+ import React7, { useMemo as useMemo2 } from "react";
564
+ var UniformPlayground = ({
565
+ resolveRenderer,
566
+ decorators = [],
567
+ contextualEditingEnhancer,
568
+ behaviorTracking,
569
+ contextualEditingDefaultPlaceholder,
570
+ children
571
+ }) => {
572
+ const { composition, isContextualEditing } = useUniformContextualEditing({
573
+ initialCompositionValue: EMPTY_COMPOSITION3,
574
+ enhance: contextualEditingEnhancer
575
+ });
576
+ const renderedComponent = useMemo2(() => {
577
+ if (!composition) {
578
+ return null;
579
+ }
580
+ let component = /* @__PURE__ */ React7.createElement(
581
+ UniformComponent,
582
+ {
583
+ data: composition,
584
+ behaviorTracking,
585
+ resolveRenderer,
586
+ contextualEditingDefaultPlaceholder
587
+ },
588
+ children
589
+ );
590
+ decorators.forEach((Decorator) => {
591
+ component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
592
+ });
593
+ return component;
594
+ }, [
595
+ children,
596
+ resolveRenderer,
597
+ decorators,
598
+ composition,
599
+ behaviorTracking,
600
+ contextualEditingDefaultPlaceholder
601
+ ]);
602
+ return /* @__PURE__ */ React7.createElement(
603
+ UniformCompositionContext.Provider,
604
+ {
605
+ value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
606
+ },
607
+ /* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
608
+ );
609
+ };
610
+
559
611
  // src/components/UniformRichText/UniformRichText.tsx
560
612
  import {
561
613
  isRichTextValue,
562
614
  isRichTextValueConsideredEmpty
563
615
  } from "@uniformdev/richtext";
564
- import React16, { useMemo as useMemo2 } from "react";
616
+ import React17, { useMemo as useMemo3 } from "react";
565
617
 
566
618
  // src/components/UniformRichText/UniformRichTextNode.tsx
567
619
  import { isRichTextNode } from "@uniformdev/richtext";
568
- import React15 from "react";
620
+ import React16 from "react";
569
621
 
570
622
  // src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
571
- import React7 from "react";
623
+ import React8 from "react";
572
624
  var HeadingRichTextNode = ({ children, node }) => {
573
625
  const { tag } = node;
574
626
  const HTag = tag != null ? tag : "h1";
575
- return /* @__PURE__ */ React7.createElement(HTag, null, children);
627
+ return /* @__PURE__ */ React8.createElement(HTag, null, children);
576
628
  };
577
629
 
578
630
  // src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
579
- import React8 from "react";
631
+ import React9 from "react";
580
632
  var LinebreakRichTextNode = () => {
581
- return /* @__PURE__ */ React8.createElement("br", null);
633
+ return /* @__PURE__ */ React9.createElement("br", null);
582
634
  };
583
635
 
584
636
  // src/components/UniformRichText/nodes/LinkRichTextNode.tsx
585
637
  import { linkParamValueToHref } from "@uniformdev/richtext";
586
- import React9 from "react";
638
+ import React10 from "react";
587
639
  var LinkRichTextNode = ({ children, node }) => {
588
640
  const { link } = node;
589
- return /* @__PURE__ */ React9.createElement("a", { href: linkParamValueToHref(link) }, children);
641
+ return /* @__PURE__ */ React10.createElement("a", { href: linkParamValueToHref(link) }, children);
590
642
  };
591
643
 
592
644
  // src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
593
- import React10 from "react";
645
+ import React11 from "react";
594
646
  var ListItemRichTextNode = ({ children, node }) => {
595
647
  const { value } = node;
596
- return /* @__PURE__ */ React10.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
648
+ return /* @__PURE__ */ React11.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
597
649
  };
598
650
 
599
651
  // src/components/UniformRichText/nodes/ListRichTextNode.tsx
600
- import React11 from "react";
652
+ import React12 from "react";
601
653
  var ListRichTextNode = ({ children, node }) => {
602
654
  const { tag, start } = node;
603
655
  const ListTag = tag != null ? tag : "ul";
604
- return /* @__PURE__ */ React11.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
656
+ return /* @__PURE__ */ React12.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
605
657
  };
606
658
 
607
659
  // src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
608
660
  import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
609
- import React12 from "react";
661
+ import React13 from "react";
610
662
  var ParagraphRichTextNode = ({ children, node }) => {
611
663
  const { format, direction } = node;
612
- return /* @__PURE__ */ React12.createElement(
664
+ return /* @__PURE__ */ React13.createElement(
613
665
  "p",
614
666
  {
615
667
  dir: isPureDirection(direction) ? direction : void 0,
@@ -620,18 +672,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
620
672
  };
621
673
 
622
674
  // src/components/UniformRichText/nodes/TabRichTextNode.tsx
623
- import React13 from "react";
675
+ import React14 from "react";
624
676
  var TabRichTextNode = () => {
625
- return /* @__PURE__ */ React13.createElement(React13.Fragment, null, " ");
677
+ return /* @__PURE__ */ React14.createElement(React14.Fragment, null, " ");
626
678
  };
627
679
 
628
680
  // src/components/UniformRichText/nodes/TextRichTextNode.tsx
629
681
  import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
630
- import React14 from "react";
682
+ import React15 from "react";
631
683
  var TextRichTextNode = ({ node }) => {
632
684
  const { text, format } = node;
633
685
  const tags = getRichTextTagsFromTextFormat(format);
634
- return /* @__PURE__ */ React14.createElement(React14.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React14.createElement(Tag, null, children), text) : text);
686
+ return /* @__PURE__ */ React15.createElement(React15.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React15.createElement(Tag, null, children), text) : text);
635
687
  };
636
688
 
637
689
  // src/components/UniformRichText/UniformRichTextNode.tsx
@@ -646,8 +698,8 @@ function UniformRichTextNode({ node, ...props }) {
646
698
  if (!NodeRenderer) {
647
699
  return null;
648
700
  }
649
- const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React15.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
650
- return /* @__PURE__ */ React15.createElement(NodeRenderer, { node }, children);
701
+ const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React16.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
702
+ return /* @__PURE__ */ React16.createElement(NodeRenderer, { node }, children);
651
703
  }
652
704
  var rendererMap = /* @__PURE__ */ new Map([
653
705
  ["heading", HeadingRichTextNode],
@@ -656,12 +708,12 @@ var rendererMap = /* @__PURE__ */ new Map([
656
708
  ["list", ListRichTextNode],
657
709
  ["listitem", ListItemRichTextNode],
658
710
  ["paragraph", ParagraphRichTextNode],
659
- ["quote", ({ children }) => /* @__PURE__ */ React15.createElement("blockquote", null, children)],
711
+ ["quote", ({ children }) => /* @__PURE__ */ React16.createElement("blockquote", null, children)],
660
712
  [
661
713
  "code",
662
- ({ children }) => /* @__PURE__ */ React15.createElement("pre", null, /* @__PURE__ */ React15.createElement("code", null, children))
714
+ ({ children }) => /* @__PURE__ */ React16.createElement("pre", null, /* @__PURE__ */ React16.createElement("code", null, children))
663
715
  ],
664
- ["root", ({ children }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, children)],
716
+ ["root", ({ children }) => /* @__PURE__ */ React16.createElement(React16.Fragment, null, children)],
665
717
  ["text", TextRichTextNode],
666
718
  ["tab", TabRichTextNode]
667
719
  ]);
@@ -670,20 +722,20 @@ var resolveRichTextDefaultRenderer = (node) => {
670
722
  };
671
723
 
672
724
  // src/components/UniformRichText/UniformRichText.tsx
673
- var UniformRichText = React16.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
725
+ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
674
726
  const { data: componentData } = useUniformCurrentComponent();
675
- const parameter = useMemo2(() => {
727
+ const parameter = useMemo3(() => {
676
728
  var _a;
677
729
  return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
678
730
  }, [componentData, parameterId]);
679
- const value = useMemo2(() => parameter == null ? void 0 : parameter.value, [parameter]);
731
+ const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
680
732
  if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
681
733
  return null;
682
- return Tag === null ? /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React16.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
734
+ return Tag === null ? /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React17.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
683
735
  });
684
736
 
685
737
  // src/components/UniformText.tsx
686
- import React17, { useCallback, useMemo as useMemo3, useState as useState2 } from "react";
738
+ import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
687
739
  var UniformText = ({
688
740
  as: Tag = "span",
689
741
  parameterId,
@@ -696,7 +748,7 @@ var UniformText = ({
696
748
  const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
697
749
  const { isContextualEditing } = useUniformCurrentComposition();
698
750
  const [isFocused, setIsFocused] = useState2(false);
699
- const parameter = useMemo3(() => {
751
+ const parameter = useMemo4(() => {
700
752
  var _a2;
701
753
  return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
702
754
  }, [componentData, parameterId]);
@@ -710,17 +762,14 @@ var UniformText = ({
710
762
  setIsFocused(false);
711
763
  }, [setIsFocused]);
712
764
  if (!parameter) {
713
- console.warn(
714
- `UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
715
- );
716
765
  return null;
717
766
  }
718
767
  if (!isContextualEditing) {
719
- return /* @__PURE__ */ React17.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
768
+ return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
720
769
  }
721
770
  const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
722
771
  const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
723
- return /* @__PURE__ */ React17.createElement(
772
+ return /* @__PURE__ */ React18.createElement(
724
773
  Tag,
725
774
  {
726
775
  ...props,
@@ -795,14 +844,14 @@ import {
795
844
  createCanvasChannel as createCanvasChannel2,
796
845
  isUpdateContextualEditingStateInternalMessage
797
846
  } from "@uniformdev/canvas";
798
- import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
847
+ import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
799
848
  var useUniformContextualEditingState = ({
800
849
  global = false
801
850
  } = {}) => {
802
851
  const { isContextualEditing } = useUniformCurrentComposition();
803
852
  const { data: componentData } = useUniformCurrentComponent();
804
853
  const [selectedComponentReference, setSelectedComponentReference] = useState3();
805
- const channel = useMemo4(() => {
854
+ const channel = useMemo5(() => {
806
855
  if (!isContextualEditing) {
807
856
  return;
808
857
  }
@@ -841,6 +890,8 @@ export {
841
890
  NOT_IMPLEMENTED_COMPONENT,
842
891
  UniformComponent,
843
892
  UniformComposition,
893
+ UniformCompositionContext,
894
+ UniformPlayground,
844
895
  UniformRichText,
845
896
  UniformRichTextNode,
846
897
  UniformSlot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.38.2",
3
+ "version": "19.38.3-alpha.78+5c9892bf1",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -24,17 +24,17 @@
24
24
  "document": "api-extractor run --local"
25
25
  },
26
26
  "dependencies": {
27
- "@uniformdev/canvas": "19.38.2",
28
- "@uniformdev/context": "19.38.2",
29
- "@uniformdev/context-react": "19.38.2",
30
- "@uniformdev/richtext": "19.38.2"
27
+ "@uniformdev/canvas": "19.38.3-alpha.78+5c9892bf1",
28
+ "@uniformdev/context": "19.38.3-alpha.78+5c9892bf1",
29
+ "@uniformdev/context-react": "19.38.3-alpha.78+5c9892bf1",
30
+ "@uniformdev/richtext": "19.38.3-alpha.78+5c9892bf1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">= 16 || 17 || 18",
34
34
  "react-dom": ">=16"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/react": "18.2.7",
37
+ "@types/react": "18.2.20",
38
38
  "react": "18.2.0",
39
39
  "react-dom": "18.2.0"
40
40
  },
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "b97fd17fd44e0f5bd3806e942b516cb2bd218096"
47
+ "gitHead": "5c9892bf101584d351d06b65e1658a1237594cfb"
48
48
  }