@uniformdev/canvas-react 19.35.3-alpha.82 → 19.36.1-alpha.0

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 CHANGED
@@ -70,9 +70,8 @@ type UniformTextProps = {
70
70
  render?: (value: ParameterTextValue) => React$1.ReactNode;
71
71
  } & Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
72
72
  /**
73
- * Adds inline editing capability to text parameters
74
- * @deprecated This component is unstable, and not ready for production usage.
75
- **/
73
+ * Renders text parameters. Offers inline editing capability out of the box.
74
+ */
76
75
  declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
77
76
 
78
77
  type UniformComponentProps<TRenderProps = unknown> = {
@@ -348,8 +347,7 @@ declare function UniformSlot<TSlotNames extends string = string>({ name, resolve
348
347
  /**
349
348
  * Returns the attributes needed to annotate a Uniform parameter for inline editing.
350
349
  * Supports only text parameters at the moment.
351
- * @deprecated Unstable, and not ready for production usage.
352
- **/
350
+ */
353
351
  declare const getParameterAttributes: typeof getParameterAttributes$1;
354
352
 
355
353
  type UseCompositionEventEffectOptions = Omit<Partial<SubscribeToCompositionOptions>, 'callback'> & {
package/dist/index.d.ts CHANGED
@@ -70,9 +70,8 @@ type UniformTextProps = {
70
70
  render?: (value: ParameterTextValue) => React$1.ReactNode;
71
71
  } & Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
72
72
  /**
73
- * Adds inline editing capability to text parameters
74
- * @deprecated This component is unstable, and not ready for production usage.
75
- **/
73
+ * Renders text parameters. Offers inline editing capability out of the box.
74
+ */
76
75
  declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
77
76
 
78
77
  type UniformComponentProps<TRenderProps = unknown> = {
@@ -348,8 +347,7 @@ declare function UniformSlot<TSlotNames extends string = string>({ name, resolve
348
347
  /**
349
348
  * Returns the attributes needed to annotate a Uniform parameter for inline editing.
350
349
  * Supports only text parameters at the moment.
351
- * @deprecated Unstable, and not ready for production usage.
352
- **/
350
+ */
353
351
  declare const getParameterAttributes: typeof getParameterAttributes$1;
354
352
 
355
353
  type UseCompositionEventEffectOptions = Omit<Partial<SubscribeToCompositionOptions>, 'callback'> & {
package/dist/index.esm.js CHANGED
@@ -557,61 +557,11 @@ function resolveChildren({
557
557
  }
558
558
 
559
559
  // src/components/UniformRichText/UniformRichText.tsx
560
- import {
561
- getParameterAttributes
562
- } from "@uniformdev/canvas";
563
560
  import {
564
561
  isRichTextValue,
565
562
  isRichTextValueConsideredEmpty
566
563
  } from "@uniformdev/richtext";
567
- import React16, { useMemo as useMemo3 } from "react";
568
-
569
- // src/hooks/useUniformContextualEditingState.ts
570
- import {
571
- createCanvasChannel as createCanvasChannel2,
572
- isUpdateContextualEditingStateInternalMessage
573
- } from "@uniformdev/canvas";
574
- import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
575
- var useUniformContextualEditingState = ({
576
- global = false
577
- } = {}) => {
578
- const { isContextualEditing } = useUniformCurrentComposition();
579
- const { data: componentData } = useUniformCurrentComponent();
580
- const [selectedComponentReference, setSelectedComponentReference] = useState2();
581
- const channel = useMemo2(() => {
582
- if (!isContextualEditing) {
583
- return;
584
- }
585
- const channel2 = createCanvasChannel2({
586
- broadcastTo: [window],
587
- listenTo: [window]
588
- });
589
- return channel2;
590
- }, [isContextualEditing]);
591
- useEffect2(() => {
592
- if (!channel) {
593
- return;
594
- }
595
- const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
596
- var _a;
597
- if (!isUpdateContextualEditingStateInternalMessage(message)) {
598
- return;
599
- }
600
- if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
601
- setSelectedComponentReference(void 0);
602
- return;
603
- }
604
- setSelectedComponentReference(message.state.selectedComponentReference);
605
- });
606
- return () => {
607
- unsubscribe();
608
- };
609
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
610
- return {
611
- isContextualEditing,
612
- selectedComponentReference
613
- };
614
- };
564
+ import React16, { useMemo as useMemo2 } from "react";
615
565
 
616
566
  // src/components/UniformRichText/UniformRichTextNode.tsx
617
567
  import { isRichTextNode } from "@uniformdev/richtext";
@@ -722,32 +672,18 @@ var resolveRichTextDefaultRenderer = (node) => {
722
672
  // src/components/UniformRichText/UniformRichText.tsx
723
673
  var UniformRichText = React16.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
724
674
  const { data: componentData } = useUniformCurrentComponent();
725
- const { selectedComponentReference } = useUniformContextualEditingState({ global: true });
726
- const parameter = useMemo3(() => {
675
+ const parameter = useMemo2(() => {
727
676
  var _a;
728
677
  return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
729
678
  }, [componentData, parameterId]);
730
- const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
679
+ const value = useMemo2(() => parameter == null ? void 0 : parameter.value, [parameter]);
731
680
  if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
732
681
  return null;
733
- return Tag === null ? /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React16.createElement(
734
- Tag,
735
- {
736
- ref,
737
- ...props,
738
- ...getParameterAttributes({
739
- component: componentData,
740
- id: parameterId
741
- }),
742
- tabIndex: 0,
743
- "data-uniform-selected-parameter": (selectedComponentReference == null ? void 0 : selectedComponentReference.id) === parameterId && selectedComponentReference.parentId === (componentData == null ? void 0 : componentData._id)
744
- },
745
- /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
746
- );
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 }));
747
683
  });
748
684
 
749
685
  // src/components/UniformText.tsx
750
- import React17, { useCallback, useMemo as useMemo4, useState as useState3 } from "react";
686
+ import React17, { useCallback, useMemo as useMemo3, useState as useState2 } from "react";
751
687
  var UniformText = ({
752
688
  as: Tag = "span",
753
689
  parameterId,
@@ -759,8 +695,8 @@ var UniformText = ({
759
695
  var _a, _b;
760
696
  const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
761
697
  const { isContextualEditing } = useUniformCurrentComposition();
762
- const [isFocused, setIsFocused] = useState3(false);
763
- const parameter = useMemo4(() => {
698
+ const [isFocused, setIsFocused] = useState2(false);
699
+ const parameter = useMemo3(() => {
764
700
  var _a2;
765
701
  return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
766
702
  }, [componentData, parameterId]);
@@ -788,7 +724,7 @@ var UniformText = ({
788
724
  Tag,
789
725
  {
790
726
  ...props,
791
- ...getParameterAttributes2({
727
+ ...getParameterAttributes({
792
728
  component: componentData,
793
729
  id: parameterId,
794
730
  isMultiline
@@ -807,7 +743,7 @@ var UniformText = ({
807
743
  import {
808
744
  getParameterAttributes as defaultGetParameterAttributes
809
745
  } from "@uniformdev/canvas";
810
- var getParameterAttributes2 = (options) => {
746
+ var getParameterAttributes = (options) => {
811
747
  return {
812
748
  ...defaultGetParameterAttributes(options),
813
749
  suppressContentEditableWarning: true
@@ -820,14 +756,14 @@ import {
820
756
  createEventBus,
821
757
  subscribeToComposition
822
758
  } from "@uniformdev/canvas";
823
- import { useEffect as useEffect3 } from "react";
759
+ import { useEffect as useEffect2 } from "react";
824
760
  function useCompositionEventEffect({
825
761
  enabled,
826
762
  projectId,
827
763
  compositionId,
828
764
  effect
829
765
  }) {
830
- useEffect3(() => {
766
+ useEffect2(() => {
831
767
  if (!enabled || !compositionId || !projectId) {
832
768
  return;
833
769
  }
@@ -853,6 +789,53 @@ function useCompositionEventEffect({
853
789
  };
854
790
  }, [compositionId, enabled, projectId, effect]);
855
791
  }
792
+
793
+ // src/hooks/useUniformContextualEditingState.ts
794
+ import {
795
+ createCanvasChannel as createCanvasChannel2,
796
+ isUpdateContextualEditingStateInternalMessage
797
+ } from "@uniformdev/canvas";
798
+ import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
799
+ var useUniformContextualEditingState = ({
800
+ global = false
801
+ } = {}) => {
802
+ const { isContextualEditing } = useUniformCurrentComposition();
803
+ const { data: componentData } = useUniformCurrentComponent();
804
+ const [selectedComponentReference, setSelectedComponentReference] = useState3();
805
+ const channel = useMemo4(() => {
806
+ if (!isContextualEditing) {
807
+ return;
808
+ }
809
+ const channel2 = createCanvasChannel2({
810
+ broadcastTo: [window],
811
+ listenTo: [window]
812
+ });
813
+ return channel2;
814
+ }, [isContextualEditing]);
815
+ useEffect3(() => {
816
+ if (!channel) {
817
+ return;
818
+ }
819
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
820
+ var _a;
821
+ if (!isUpdateContextualEditingStateInternalMessage(message)) {
822
+ return;
823
+ }
824
+ if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
825
+ setSelectedComponentReference(void 0);
826
+ return;
827
+ }
828
+ setSelectedComponentReference(message.state.selectedComponentReference);
829
+ });
830
+ return () => {
831
+ unsubscribe();
832
+ };
833
+ }, [global, channel, componentData == null ? void 0 : componentData._id]);
834
+ return {
835
+ isContextualEditing,
836
+ selectedComponentReference
837
+ };
838
+ };
856
839
  export {
857
840
  DefaultNotImplementedComponent,
858
841
  NOT_IMPLEMENTED_COMPONENT,
@@ -867,7 +850,7 @@ export {
867
850
  createComponentStore,
868
851
  createComponentStoreResolver,
869
852
  createUniformApiEnhancer,
870
- getParameterAttributes2 as getParameterAttributes,
853
+ getParameterAttributes,
871
854
  registerUniformComponent,
872
855
  useCompositionEventEffect,
873
856
  useUniformContextualEditing,
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ __export(src_exports, {
43
43
  createComponentStore: () => createComponentStore,
44
44
  createComponentStoreResolver: () => createComponentStoreResolver,
45
45
  createUniformApiEnhancer: () => import_canvas3.createUniformApiEnhancer,
46
- getParameterAttributes: () => getParameterAttributes2,
46
+ getParameterAttributes: () => getParameterAttributes,
47
47
  registerUniformComponent: () => registerUniformComponent,
48
48
  useCompositionEventEffect: () => useCompositionEventEffect,
49
49
  useUniformContextualEditing: () => useUniformContextualEditing,
@@ -589,101 +589,56 @@ function resolveChildren({
589
589
  }
590
590
 
591
591
  // src/components/UniformRichText/UniformRichText.tsx
592
- var import_canvas8 = require("@uniformdev/canvas");
593
592
  var import_richtext5 = require("@uniformdev/richtext");
594
- var import_react17 = __toESM(require("react"));
595
-
596
- // src/hooks/useUniformContextualEditingState.ts
597
- var import_canvas7 = require("@uniformdev/canvas");
598
- var import_react7 = require("react");
599
- var useUniformContextualEditingState = ({
600
- global = false
601
- } = {}) => {
602
- const { isContextualEditing } = useUniformCurrentComposition();
603
- const { data: componentData } = useUniformCurrentComponent();
604
- const [selectedComponentReference, setSelectedComponentReference] = (0, import_react7.useState)();
605
- const channel = (0, import_react7.useMemo)(() => {
606
- if (!isContextualEditing) {
607
- return;
608
- }
609
- const channel2 = (0, import_canvas7.createCanvasChannel)({
610
- broadcastTo: [window],
611
- listenTo: [window]
612
- });
613
- return channel2;
614
- }, [isContextualEditing]);
615
- (0, import_react7.useEffect)(() => {
616
- if (!channel) {
617
- return;
618
- }
619
- const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
620
- var _a;
621
- if (!(0, import_canvas7.isUpdateContextualEditingStateInternalMessage)(message)) {
622
- return;
623
- }
624
- if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
625
- setSelectedComponentReference(void 0);
626
- return;
627
- }
628
- setSelectedComponentReference(message.state.selectedComponentReference);
629
- });
630
- return () => {
631
- unsubscribe();
632
- };
633
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
634
- return {
635
- isContextualEditing,
636
- selectedComponentReference
637
- };
638
- };
593
+ var import_react16 = __toESM(require("react"));
639
594
 
640
595
  // src/components/UniformRichText/UniformRichTextNode.tsx
641
596
  var import_richtext4 = require("@uniformdev/richtext");
642
- var import_react16 = __toESM(require("react"));
597
+ var import_react15 = __toESM(require("react"));
643
598
 
644
599
  // src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
645
- var import_react8 = __toESM(require("react"));
600
+ var import_react7 = __toESM(require("react"));
646
601
  var HeadingRichTextNode = ({ children, node }) => {
647
602
  const { tag } = node;
648
603
  const HTag = tag != null ? tag : "h1";
649
- return /* @__PURE__ */ import_react8.default.createElement(HTag, null, children);
604
+ return /* @__PURE__ */ import_react7.default.createElement(HTag, null, children);
650
605
  };
651
606
 
652
607
  // src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
653
- var import_react9 = __toESM(require("react"));
608
+ var import_react8 = __toESM(require("react"));
654
609
  var LinebreakRichTextNode = () => {
655
- return /* @__PURE__ */ import_react9.default.createElement("br", null);
610
+ return /* @__PURE__ */ import_react8.default.createElement("br", null);
656
611
  };
657
612
 
658
613
  // src/components/UniformRichText/nodes/LinkRichTextNode.tsx
659
614
  var import_richtext = require("@uniformdev/richtext");
660
- var import_react10 = __toESM(require("react"));
615
+ var import_react9 = __toESM(require("react"));
661
616
  var LinkRichTextNode = ({ children, node }) => {
662
617
  const { link } = node;
663
- return /* @__PURE__ */ import_react10.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
618
+ return /* @__PURE__ */ import_react9.default.createElement("a", { href: (0, import_richtext.linkParamValueToHref)(link) }, children);
664
619
  };
665
620
 
666
621
  // src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
667
- var import_react11 = __toESM(require("react"));
622
+ var import_react10 = __toESM(require("react"));
668
623
  var ListItemRichTextNode = ({ children, node }) => {
669
624
  const { value } = node;
670
- return /* @__PURE__ */ import_react11.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
625
+ return /* @__PURE__ */ import_react10.default.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
671
626
  };
672
627
 
673
628
  // src/components/UniformRichText/nodes/ListRichTextNode.tsx
674
- var import_react12 = __toESM(require("react"));
629
+ var import_react11 = __toESM(require("react"));
675
630
  var ListRichTextNode = ({ children, node }) => {
676
631
  const { tag, start } = node;
677
632
  const ListTag = tag != null ? tag : "ul";
678
- return /* @__PURE__ */ import_react12.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
633
+ return /* @__PURE__ */ import_react11.default.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
679
634
  };
680
635
 
681
636
  // src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
682
637
  var import_richtext2 = require("@uniformdev/richtext");
683
- var import_react13 = __toESM(require("react"));
638
+ var import_react12 = __toESM(require("react"));
684
639
  var ParagraphRichTextNode = ({ children, node }) => {
685
640
  const { format, direction } = node;
686
- return /* @__PURE__ */ import_react13.default.createElement(
641
+ return /* @__PURE__ */ import_react12.default.createElement(
687
642
  "p",
688
643
  {
689
644
  dir: (0, import_richtext2.isPureDirection)(direction) ? direction : void 0,
@@ -694,18 +649,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
694
649
  };
695
650
 
696
651
  // src/components/UniformRichText/nodes/TabRichTextNode.tsx
697
- var import_react14 = __toESM(require("react"));
652
+ var import_react13 = __toESM(require("react"));
698
653
  var TabRichTextNode = () => {
699
- return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, " ");
654
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, " ");
700
655
  };
701
656
 
702
657
  // src/components/UniformRichText/nodes/TextRichTextNode.tsx
703
658
  var import_richtext3 = require("@uniformdev/richtext");
704
- var import_react15 = __toESM(require("react"));
659
+ var import_react14 = __toESM(require("react"));
705
660
  var TextRichTextNode = ({ node }) => {
706
661
  const { text, format } = node;
707
662
  const tags = (0, import_richtext3.getRichTextTagsFromTextFormat)(format);
708
- return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ import_react15.default.createElement(Tag, null, children), text) : text);
663
+ return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ import_react14.default.createElement(Tag, null, children), text) : text);
709
664
  };
710
665
 
711
666
  // src/components/UniformRichText/UniformRichTextNode.tsx
@@ -720,8 +675,8 @@ function UniformRichTextNode({ node, ...props }) {
720
675
  if (!NodeRenderer) {
721
676
  return null;
722
677
  }
723
- const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ import_react16.default.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
724
- return /* @__PURE__ */ import_react16.default.createElement(NodeRenderer, { node }, children);
678
+ const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ import_react15.default.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
679
+ return /* @__PURE__ */ import_react15.default.createElement(NodeRenderer, { node }, children);
725
680
  }
726
681
  var rendererMap = /* @__PURE__ */ new Map([
727
682
  ["heading", HeadingRichTextNode],
@@ -730,12 +685,12 @@ var rendererMap = /* @__PURE__ */ new Map([
730
685
  ["list", ListRichTextNode],
731
686
  ["listitem", ListItemRichTextNode],
732
687
  ["paragraph", ParagraphRichTextNode],
733
- ["quote", ({ children }) => /* @__PURE__ */ import_react16.default.createElement("blockquote", null, children)],
688
+ ["quote", ({ children }) => /* @__PURE__ */ import_react15.default.createElement("blockquote", null, children)],
734
689
  [
735
690
  "code",
736
- ({ children }) => /* @__PURE__ */ import_react16.default.createElement("pre", null, /* @__PURE__ */ import_react16.default.createElement("code", null, children))
691
+ ({ children }) => /* @__PURE__ */ import_react15.default.createElement("pre", null, /* @__PURE__ */ import_react15.default.createElement("code", null, children))
737
692
  ],
738
- ["root", ({ children }) => /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, children)],
693
+ ["root", ({ children }) => /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, children)],
739
694
  ["text", TextRichTextNode],
740
695
  ["tab", TabRichTextNode]
741
696
  ]);
@@ -744,34 +699,20 @@ var resolveRichTextDefaultRenderer = (node) => {
744
699
  };
745
700
 
746
701
  // src/components/UniformRichText/UniformRichText.tsx
747
- var UniformRichText = import_react17.default.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
702
+ var UniformRichText = import_react16.default.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
748
703
  const { data: componentData } = useUniformCurrentComponent();
749
- const { selectedComponentReference } = useUniformContextualEditingState({ global: true });
750
- const parameter = (0, import_react17.useMemo)(() => {
704
+ const parameter = (0, import_react16.useMemo)(() => {
751
705
  var _a;
752
706
  return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
753
707
  }, [componentData, parameterId]);
754
- const value = (0, import_react17.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
708
+ const value = (0, import_react16.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
755
709
  if (!value || !(0, import_richtext5.isRichTextValue)(value) || (0, import_richtext5.isRichTextValueConsideredEmpty)(value))
756
710
  return null;
757
- return Tag === null ? /* @__PURE__ */ import_react17.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ import_react17.default.createElement(
758
- Tag,
759
- {
760
- ref,
761
- ...props,
762
- ...(0, import_canvas8.getParameterAttributes)({
763
- component: componentData,
764
- id: parameterId
765
- }),
766
- tabIndex: 0,
767
- "data-uniform-selected-parameter": (selectedComponentReference == null ? void 0 : selectedComponentReference.id) === parameterId && selectedComponentReference.parentId === (componentData == null ? void 0 : componentData._id)
768
- },
769
- /* @__PURE__ */ import_react17.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
770
- );
711
+ return Tag === null ? /* @__PURE__ */ import_react16.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ import_react16.default.createElement(Tag, { ref, ...props }, /* @__PURE__ */ import_react16.default.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
771
712
  });
772
713
 
773
714
  // src/components/UniformText.tsx
774
- var import_react18 = __toESM(require("react"));
715
+ var import_react17 = __toESM(require("react"));
775
716
  var UniformText = ({
776
717
  as: Tag = "span",
777
718
  parameterId,
@@ -783,18 +724,18 @@ var UniformText = ({
783
724
  var _a, _b;
784
725
  const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
785
726
  const { isContextualEditing } = useUniformCurrentComposition();
786
- const [isFocused, setIsFocused] = (0, import_react18.useState)(false);
787
- const parameter = (0, import_react18.useMemo)(() => {
727
+ const [isFocused, setIsFocused] = (0, import_react17.useState)(false);
728
+ const parameter = (0, import_react17.useMemo)(() => {
788
729
  var _a2;
789
730
  return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
790
731
  }, [componentData, parameterId]);
791
732
  const value = parameter == null ? void 0 : parameter.value;
792
733
  const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
793
734
  const shouldSkipCustomRendering = isFocused && isEditable;
794
- const handleOnFocus = (0, import_react18.useCallback)(() => {
735
+ const handleOnFocus = (0, import_react17.useCallback)(() => {
795
736
  setIsFocused(true);
796
737
  }, [setIsFocused]);
797
- const handleOnBlur = (0, import_react18.useCallback)(() => {
738
+ const handleOnBlur = (0, import_react17.useCallback)(() => {
798
739
  setIsFocused(false);
799
740
  }, [setIsFocused]);
800
741
  if (!parameter) {
@@ -804,15 +745,15 @@ var UniformText = ({
804
745
  return null;
805
746
  }
806
747
  if (!isContextualEditing) {
807
- return /* @__PURE__ */ import_react18.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
748
+ return /* @__PURE__ */ import_react17.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
808
749
  }
809
750
  const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
810
751
  const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
811
- return /* @__PURE__ */ import_react18.default.createElement(
752
+ return /* @__PURE__ */ import_react17.default.createElement(
812
753
  Tag,
813
754
  {
814
755
  ...props,
815
- ...getParameterAttributes2({
756
+ ...getParameterAttributes({
816
757
  component: componentData,
817
758
  id: parameterId,
818
759
  isMultiline
@@ -828,35 +769,35 @@ var UniformText = ({
828
769
  };
829
770
 
830
771
  // src/helpers/getParameterAttributes.ts
831
- var import_canvas9 = require("@uniformdev/canvas");
832
- var getParameterAttributes2 = (options) => {
772
+ var import_canvas7 = require("@uniformdev/canvas");
773
+ var getParameterAttributes = (options) => {
833
774
  return {
834
- ...(0, import_canvas9.getParameterAttributes)(options),
775
+ ...(0, import_canvas7.getParameterAttributes)(options),
835
776
  suppressContentEditableWarning: true
836
777
  };
837
778
  };
838
779
 
839
780
  // src/hooks/useCompositionEventEffect.ts
840
- var import_canvas10 = require("@uniformdev/canvas");
841
- var import_react19 = require("react");
781
+ var import_canvas8 = require("@uniformdev/canvas");
782
+ var import_react18 = require("react");
842
783
  function useCompositionEventEffect({
843
784
  enabled,
844
785
  projectId,
845
786
  compositionId,
846
787
  effect
847
788
  }) {
848
- (0, import_react19.useEffect)(() => {
789
+ (0, import_react18.useEffect)(() => {
849
790
  if (!enabled || !compositionId || !projectId) {
850
791
  return;
851
792
  }
852
793
  let goodbye = void 0;
853
794
  const loadEffect = async () => {
854
- const eventBus = await (0, import_canvas10.createEventBus)();
795
+ const eventBus = await (0, import_canvas8.createEventBus)();
855
796
  if (eventBus) {
856
- goodbye = (0, import_canvas10.subscribeToComposition)({
797
+ goodbye = (0, import_canvas8.subscribeToComposition)({
857
798
  eventBus,
858
799
  compositionId,
859
- compositionState: import_canvas10.CANVAS_DRAFT_STATE,
800
+ compositionState: import_canvas8.CANVAS_DRAFT_STATE,
860
801
  projectId,
861
802
  callback: effect,
862
803
  event: "updated"
@@ -871,6 +812,50 @@ function useCompositionEventEffect({
871
812
  };
872
813
  }, [compositionId, enabled, projectId, effect]);
873
814
  }
815
+
816
+ // src/hooks/useUniformContextualEditingState.ts
817
+ var import_canvas9 = require("@uniformdev/canvas");
818
+ var import_react19 = require("react");
819
+ var useUniformContextualEditingState = ({
820
+ global = false
821
+ } = {}) => {
822
+ const { isContextualEditing } = useUniformCurrentComposition();
823
+ const { data: componentData } = useUniformCurrentComponent();
824
+ const [selectedComponentReference, setSelectedComponentReference] = (0, import_react19.useState)();
825
+ const channel = (0, import_react19.useMemo)(() => {
826
+ if (!isContextualEditing) {
827
+ return;
828
+ }
829
+ const channel2 = (0, import_canvas9.createCanvasChannel)({
830
+ broadcastTo: [window],
831
+ listenTo: [window]
832
+ });
833
+ return channel2;
834
+ }, [isContextualEditing]);
835
+ (0, import_react19.useEffect)(() => {
836
+ if (!channel) {
837
+ return;
838
+ }
839
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
840
+ var _a;
841
+ if (!(0, import_canvas9.isUpdateContextualEditingStateInternalMessage)(message)) {
842
+ return;
843
+ }
844
+ if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
845
+ setSelectedComponentReference(void 0);
846
+ return;
847
+ }
848
+ setSelectedComponentReference(message.state.selectedComponentReference);
849
+ });
850
+ return () => {
851
+ unsubscribe();
852
+ };
853
+ }, [global, channel, componentData == null ? void 0 : componentData._id]);
854
+ return {
855
+ isContextualEditing,
856
+ selectedComponentReference
857
+ };
858
+ };
874
859
  // Annotate the CommonJS export names for ESM import in node:
875
860
  0 && (module.exports = {
876
861
  DefaultNotImplementedComponent,
package/dist/index.mjs CHANGED
@@ -557,61 +557,11 @@ function resolveChildren({
557
557
  }
558
558
 
559
559
  // src/components/UniformRichText/UniformRichText.tsx
560
- import {
561
- getParameterAttributes
562
- } from "@uniformdev/canvas";
563
560
  import {
564
561
  isRichTextValue,
565
562
  isRichTextValueConsideredEmpty
566
563
  } from "@uniformdev/richtext";
567
- import React16, { useMemo as useMemo3 } from "react";
568
-
569
- // src/hooks/useUniformContextualEditingState.ts
570
- import {
571
- createCanvasChannel as createCanvasChannel2,
572
- isUpdateContextualEditingStateInternalMessage
573
- } from "@uniformdev/canvas";
574
- import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
575
- var useUniformContextualEditingState = ({
576
- global = false
577
- } = {}) => {
578
- const { isContextualEditing } = useUniformCurrentComposition();
579
- const { data: componentData } = useUniformCurrentComponent();
580
- const [selectedComponentReference, setSelectedComponentReference] = useState2();
581
- const channel = useMemo2(() => {
582
- if (!isContextualEditing) {
583
- return;
584
- }
585
- const channel2 = createCanvasChannel2({
586
- broadcastTo: [window],
587
- listenTo: [window]
588
- });
589
- return channel2;
590
- }, [isContextualEditing]);
591
- useEffect2(() => {
592
- if (!channel) {
593
- return;
594
- }
595
- const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
596
- var _a;
597
- if (!isUpdateContextualEditingStateInternalMessage(message)) {
598
- return;
599
- }
600
- if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
601
- setSelectedComponentReference(void 0);
602
- return;
603
- }
604
- setSelectedComponentReference(message.state.selectedComponentReference);
605
- });
606
- return () => {
607
- unsubscribe();
608
- };
609
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
610
- return {
611
- isContextualEditing,
612
- selectedComponentReference
613
- };
614
- };
564
+ import React16, { useMemo as useMemo2 } from "react";
615
565
 
616
566
  // src/components/UniformRichText/UniformRichTextNode.tsx
617
567
  import { isRichTextNode } from "@uniformdev/richtext";
@@ -722,32 +672,18 @@ var resolveRichTextDefaultRenderer = (node) => {
722
672
  // src/components/UniformRichText/UniformRichText.tsx
723
673
  var UniformRichText = React16.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
724
674
  const { data: componentData } = useUniformCurrentComponent();
725
- const { selectedComponentReference } = useUniformContextualEditingState({ global: true });
726
- const parameter = useMemo3(() => {
675
+ const parameter = useMemo2(() => {
727
676
  var _a;
728
677
  return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
729
678
  }, [componentData, parameterId]);
730
- const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
679
+ const value = useMemo2(() => parameter == null ? void 0 : parameter.value, [parameter]);
731
680
  if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
732
681
  return null;
733
- return Tag === null ? /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React16.createElement(
734
- Tag,
735
- {
736
- ref,
737
- ...props,
738
- ...getParameterAttributes({
739
- component: componentData,
740
- id: parameterId
741
- }),
742
- tabIndex: 0,
743
- "data-uniform-selected-parameter": (selectedComponentReference == null ? void 0 : selectedComponentReference.id) === parameterId && selectedComponentReference.parentId === (componentData == null ? void 0 : componentData._id)
744
- },
745
- /* @__PURE__ */ React16.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
746
- );
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 }));
747
683
  });
748
684
 
749
685
  // src/components/UniformText.tsx
750
- import React17, { useCallback, useMemo as useMemo4, useState as useState3 } from "react";
686
+ import React17, { useCallback, useMemo as useMemo3, useState as useState2 } from "react";
751
687
  var UniformText = ({
752
688
  as: Tag = "span",
753
689
  parameterId,
@@ -759,8 +695,8 @@ var UniformText = ({
759
695
  var _a, _b;
760
696
  const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
761
697
  const { isContextualEditing } = useUniformCurrentComposition();
762
- const [isFocused, setIsFocused] = useState3(false);
763
- const parameter = useMemo4(() => {
698
+ const [isFocused, setIsFocused] = useState2(false);
699
+ const parameter = useMemo3(() => {
764
700
  var _a2;
765
701
  return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
766
702
  }, [componentData, parameterId]);
@@ -788,7 +724,7 @@ var UniformText = ({
788
724
  Tag,
789
725
  {
790
726
  ...props,
791
- ...getParameterAttributes2({
727
+ ...getParameterAttributes({
792
728
  component: componentData,
793
729
  id: parameterId,
794
730
  isMultiline
@@ -807,7 +743,7 @@ var UniformText = ({
807
743
  import {
808
744
  getParameterAttributes as defaultGetParameterAttributes
809
745
  } from "@uniformdev/canvas";
810
- var getParameterAttributes2 = (options) => {
746
+ var getParameterAttributes = (options) => {
811
747
  return {
812
748
  ...defaultGetParameterAttributes(options),
813
749
  suppressContentEditableWarning: true
@@ -820,14 +756,14 @@ import {
820
756
  createEventBus,
821
757
  subscribeToComposition
822
758
  } from "@uniformdev/canvas";
823
- import { useEffect as useEffect3 } from "react";
759
+ import { useEffect as useEffect2 } from "react";
824
760
  function useCompositionEventEffect({
825
761
  enabled,
826
762
  projectId,
827
763
  compositionId,
828
764
  effect
829
765
  }) {
830
- useEffect3(() => {
766
+ useEffect2(() => {
831
767
  if (!enabled || !compositionId || !projectId) {
832
768
  return;
833
769
  }
@@ -853,6 +789,53 @@ function useCompositionEventEffect({
853
789
  };
854
790
  }, [compositionId, enabled, projectId, effect]);
855
791
  }
792
+
793
+ // src/hooks/useUniformContextualEditingState.ts
794
+ import {
795
+ createCanvasChannel as createCanvasChannel2,
796
+ isUpdateContextualEditingStateInternalMessage
797
+ } from "@uniformdev/canvas";
798
+ import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
799
+ var useUniformContextualEditingState = ({
800
+ global = false
801
+ } = {}) => {
802
+ const { isContextualEditing } = useUniformCurrentComposition();
803
+ const { data: componentData } = useUniformCurrentComponent();
804
+ const [selectedComponentReference, setSelectedComponentReference] = useState3();
805
+ const channel = useMemo4(() => {
806
+ if (!isContextualEditing) {
807
+ return;
808
+ }
809
+ const channel2 = createCanvasChannel2({
810
+ broadcastTo: [window],
811
+ listenTo: [window]
812
+ });
813
+ return channel2;
814
+ }, [isContextualEditing]);
815
+ useEffect3(() => {
816
+ if (!channel) {
817
+ return;
818
+ }
819
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
820
+ var _a;
821
+ if (!isUpdateContextualEditingStateInternalMessage(message)) {
822
+ return;
823
+ }
824
+ if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
825
+ setSelectedComponentReference(void 0);
826
+ return;
827
+ }
828
+ setSelectedComponentReference(message.state.selectedComponentReference);
829
+ });
830
+ return () => {
831
+ unsubscribe();
832
+ };
833
+ }, [global, channel, componentData == null ? void 0 : componentData._id]);
834
+ return {
835
+ isContextualEditing,
836
+ selectedComponentReference
837
+ };
838
+ };
856
839
  export {
857
840
  DefaultNotImplementedComponent,
858
841
  NOT_IMPLEMENTED_COMPONENT,
@@ -867,7 +850,7 @@ export {
867
850
  createComponentStore,
868
851
  createComponentStoreResolver,
869
852
  createUniformApiEnhancer,
870
- getParameterAttributes2 as getParameterAttributes,
853
+ getParameterAttributes,
871
854
  registerUniformComponent,
872
855
  useCompositionEventEffect,
873
856
  useUniformContextualEditing,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.35.3-alpha.82+4bc341093",
3
+ "version": "19.36.1-alpha.0+a6b7449c1",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -24,10 +24,10 @@
24
24
  "document": "api-extractor run --local"
25
25
  },
26
26
  "dependencies": {
27
- "@uniformdev/canvas": "19.35.3-alpha.82+4bc341093",
28
- "@uniformdev/context": "19.35.3-alpha.82+4bc341093",
29
- "@uniformdev/context-react": "19.35.3-alpha.82+4bc341093",
30
- "@uniformdev/richtext": "19.35.3-alpha.82+4bc341093"
27
+ "@uniformdev/canvas": "19.36.1-alpha.0+a6b7449c1",
28
+ "@uniformdev/context": "19.36.1-alpha.0+a6b7449c1",
29
+ "@uniformdev/context-react": "19.36.1-alpha.0+a6b7449c1",
30
+ "@uniformdev/richtext": "19.36.1-alpha.0+a6b7449c1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">= 16 || 17 || 18",
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "4bc341093bc946900df2646fe53eca4bcddc693c"
47
+ "gitHead": "a6b7449c13066f2bdef2d5209c230986507fb454"
48
48
  }