@uniformdev/canvas-react 19.50.0 → 19.50.2-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.
@@ -0,0 +1,41 @@
1
+ import { ComponentInstance } from '@uniformdev/canvas';
2
+ import React from 'react';
3
+
4
+ type ParameterTextValue = string | undefined;
5
+ type PureUniformTextProps = {
6
+ /**
7
+ * The name of the HTML tag to render.
8
+ * @default "span"
9
+ */
10
+ as?: React.ElementType;
11
+ /** The ID of the parameter. */
12
+ parameterId: string;
13
+ /** The component that contains the parameter. */
14
+ component: ComponentInstance;
15
+ skipCustomRendering: boolean;
16
+ isContextualEditing: boolean;
17
+ /**
18
+ * When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
19
+ * @default false
20
+ */
21
+ isMultiline?: boolean;
22
+ /**
23
+ * Sets the value to show in Canvas editor when the parameter value is empty.
24
+ * Can be a static string, or a function to generate the placeholder out of parameter info.
25
+ * @default undefined
26
+ */
27
+ placeholder?: string | ((parameter: {
28
+ id: string;
29
+ }) => string | undefined);
30
+ /**
31
+ * A function to customize the rendering of the parameter value. Useful to format the value before rendering it.
32
+ * @default "(value) => value"
33
+ */
34
+ render?: (value: ParameterTextValue) => React.ReactNode;
35
+ } & Omit<React.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
36
+ /**
37
+ * Renders text parameters. Offers inline editing capability out of the box.
38
+ */
39
+ declare const PureUniformText: ({ as: Tag, parameterId, component, skipCustomRendering, isContextualEditing, isMultiline, placeholder, render, ...props }: PureUniformTextProps) => React.JSX.Element | null;
40
+
41
+ export { PureUniformText, PureUniformTextProps };
package/dist/core.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { ComponentInstance } from '@uniformdev/canvas';
2
+ import React from 'react';
3
+
4
+ type ParameterTextValue = string | undefined;
5
+ type PureUniformTextProps = {
6
+ /**
7
+ * The name of the HTML tag to render.
8
+ * @default "span"
9
+ */
10
+ as?: React.ElementType;
11
+ /** The ID of the parameter. */
12
+ parameterId: string;
13
+ /** The component that contains the parameter. */
14
+ component: ComponentInstance;
15
+ skipCustomRendering: boolean;
16
+ isContextualEditing: boolean;
17
+ /**
18
+ * When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
19
+ * @default false
20
+ */
21
+ isMultiline?: boolean;
22
+ /**
23
+ * Sets the value to show in Canvas editor when the parameter value is empty.
24
+ * Can be a static string, or a function to generate the placeholder out of parameter info.
25
+ * @default undefined
26
+ */
27
+ placeholder?: string | ((parameter: {
28
+ id: string;
29
+ }) => string | undefined);
30
+ /**
31
+ * A function to customize the rendering of the parameter value. Useful to format the value before rendering it.
32
+ * @default "(value) => value"
33
+ */
34
+ render?: (value: ParameterTextValue) => React.ReactNode;
35
+ } & Omit<React.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
36
+ /**
37
+ * Renders text parameters. Offers inline editing capability out of the box.
38
+ */
39
+ declare const PureUniformText: ({ as: Tag, parameterId, component, skipCustomRendering, isContextualEditing, isMultiline, placeholder, render, ...props }: PureUniformTextProps) => React.JSX.Element | null;
40
+
41
+ export { PureUniformText, PureUniformTextProps };
package/dist/core.js ADDED
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core.ts
31
+ var core_exports = {};
32
+ __export(core_exports, {
33
+ PureUniformText: () => PureUniformText
34
+ });
35
+ module.exports = __toCommonJS(core_exports);
36
+
37
+ // src/components/PureUniformText.tsx
38
+ var import_react = __toESM(require("react"));
39
+
40
+ // src/helpers/getParameterAttributes.ts
41
+ var import_canvas = require("@uniformdev/canvas");
42
+ var getParameterAttributes = (options) => {
43
+ return {
44
+ ...(0, import_canvas.getParameterAttributes)(options),
45
+ suppressContentEditableWarning: true
46
+ };
47
+ };
48
+
49
+ // src/components/PureUniformText.tsx
50
+ var PureUniformText = ({
51
+ as: Tag = "span",
52
+ parameterId,
53
+ component,
54
+ skipCustomRendering,
55
+ isContextualEditing,
56
+ isMultiline = false,
57
+ placeholder,
58
+ render = (value) => value,
59
+ ...props
60
+ }) => {
61
+ var _a;
62
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
63
+ const value = parameter == null ? void 0 : parameter.value;
64
+ if (!parameter) {
65
+ return null;
66
+ }
67
+ if (!isContextualEditing) {
68
+ return /* @__PURE__ */ import_react.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
69
+ }
70
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
71
+ return /* @__PURE__ */ import_react.default.createElement(
72
+ Tag,
73
+ {
74
+ ...props,
75
+ ...getParameterAttributes({
76
+ component,
77
+ id: parameterId,
78
+ isMultiline
79
+ }),
80
+ "data-uniform-parameter-type": "text",
81
+ "data-uniform-placeholder": computedPlaceholder,
82
+ style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
83
+ },
84
+ skipCustomRendering ? value : render(value)
85
+ );
86
+ };
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ PureUniformText
90
+ });
package/dist/core.mjs ADDED
@@ -0,0 +1,55 @@
1
+ // src/components/PureUniformText.tsx
2
+ import React from "react";
3
+
4
+ // src/helpers/getParameterAttributes.ts
5
+ import {
6
+ getParameterAttributes as defaultGetParameterAttributes
7
+ } from "@uniformdev/canvas";
8
+ var getParameterAttributes = (options) => {
9
+ return {
10
+ ...defaultGetParameterAttributes(options),
11
+ suppressContentEditableWarning: true
12
+ };
13
+ };
14
+
15
+ // src/components/PureUniformText.tsx
16
+ var PureUniformText = ({
17
+ as: Tag = "span",
18
+ parameterId,
19
+ component,
20
+ skipCustomRendering,
21
+ isContextualEditing,
22
+ isMultiline = false,
23
+ placeholder,
24
+ render = (value) => value,
25
+ ...props
26
+ }) => {
27
+ var _a;
28
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
29
+ const value = parameter == null ? void 0 : parameter.value;
30
+ if (!parameter) {
31
+ return null;
32
+ }
33
+ if (!isContextualEditing) {
34
+ return /* @__PURE__ */ React.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
35
+ }
36
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
37
+ return /* @__PURE__ */ React.createElement(
38
+ Tag,
39
+ {
40
+ ...props,
41
+ ...getParameterAttributes({
42
+ component,
43
+ id: parameterId,
44
+ isMultiline
45
+ }),
46
+ "data-uniform-parameter-type": "text",
47
+ "data-uniform-placeholder": computedPlaceholder,
48
+ style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
49
+ },
50
+ skipCustomRendering ? value : render(value)
51
+ );
52
+ };
53
+ export {
54
+ PureUniformText
55
+ };
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import * as _uniformdev_canvas from '@uniformdev/canvas';
3
3
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
4
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
5
+ import { PureUniformTextProps } from './core.mjs';
5
6
  import { RichTextNode } from '@uniformdev/richtext';
6
7
 
7
8
  /**
@@ -41,38 +42,11 @@ type ComponentStore = {
41
42
  **/
42
43
  declare function DefaultNotImplementedComponent(props: ComponentProps): React$1.JSX.Element | null;
43
44
 
44
- type ParameterTextValue = string | undefined;
45
- type UniformTextProps = {
46
- /**
47
- * The name of the HTML tag to render.
48
- * @default "span"
49
- */
50
- as?: React$1.ElementType;
51
- /** The ID of the parameter. */
52
- parameterId: string;
53
- /**
54
- * When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
55
- * @default false
56
- */
57
- isMultiline?: boolean;
58
- /**
59
- * Sets the value to show in Canvas editor when the parameter value is empty.
60
- * Can be a static string, or a function to generate the placeholder out of parameter info.
61
- * @default undefined
62
- */
63
- placeholder?: string | ((parameter: {
64
- id: string;
65
- }) => string | undefined);
66
- /**
67
- * A function to customize the rendering of the parameter value. Useful to format the value before rendering it.
68
- * @default "(value) => value"
69
- */
70
- render?: (value: ParameterTextValue) => React$1.ReactNode;
71
- } & Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
45
+ type UniformTextProps = Omit<PureUniformTextProps, 'skipCustomRendering' | 'isContextualEditing'>;
72
46
  /**
73
47
  * Renders text parameters. Offers inline editing capability out of the box.
74
48
  */
75
- declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
49
+ declare const UniformText: ({ as: tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
76
50
 
77
51
  type UniformComponentProps<TRenderProps = unknown> = {
78
52
  /** The data of the component instance */
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import * as _uniformdev_canvas from '@uniformdev/canvas';
3
3
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
4
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
5
+ import { PureUniformTextProps } from './core.js';
5
6
  import { RichTextNode } from '@uniformdev/richtext';
6
7
 
7
8
  /**
@@ -41,38 +42,11 @@ type ComponentStore = {
41
42
  **/
42
43
  declare function DefaultNotImplementedComponent(props: ComponentProps): React$1.JSX.Element | null;
43
44
 
44
- type ParameterTextValue = string | undefined;
45
- type UniformTextProps = {
46
- /**
47
- * The name of the HTML tag to render.
48
- * @default "span"
49
- */
50
- as?: React$1.ElementType;
51
- /** The ID of the parameter. */
52
- parameterId: string;
53
- /**
54
- * When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
55
- * @default false
56
- */
57
- isMultiline?: boolean;
58
- /**
59
- * Sets the value to show in Canvas editor when the parameter value is empty.
60
- * Can be a static string, or a function to generate the placeholder out of parameter info.
61
- * @default undefined
62
- */
63
- placeholder?: string | ((parameter: {
64
- id: string;
65
- }) => string | undefined);
66
- /**
67
- * A function to customize the rendering of the parameter value. Useful to format the value before rendering it.
68
- * @default "(value) => value"
69
- */
70
- render?: (value: ParameterTextValue) => React$1.ReactNode;
71
- } & Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'children' | 'placeholder'>;
45
+ type UniformTextProps = Omit<PureUniformTextProps, 'skipCustomRendering' | 'isContextualEditing'>;
72
46
  /**
73
47
  * Renders text parameters. Offers inline editing capability out of the box.
74
48
  */
75
- declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
49
+ declare const UniformText: ({ as: tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
76
50
 
77
51
  type UniformComponentProps<TRenderProps = unknown> = {
78
52
  /** The data of the component instance */
package/dist/index.esm.js CHANGED
@@ -735,56 +735,88 @@ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId
735
735
  });
736
736
 
737
737
  // src/components/UniformText.tsx
738
- import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
739
- var UniformText = ({
738
+ import React19, { useState as useState2 } from "react";
739
+
740
+ // src/components/PureUniformText.tsx
741
+ import React18 from "react";
742
+ var PureUniformText = ({
740
743
  as: Tag = "span",
741
744
  parameterId,
745
+ component,
746
+ skipCustomRendering,
747
+ isContextualEditing,
742
748
  isMultiline = false,
743
749
  placeholder,
744
750
  render = (value) => value,
745
751
  ...props
746
752
  }) => {
747
- var _a, _b;
748
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
749
- const { isContextualEditing } = useUniformCurrentComposition();
750
- const [isFocused, setIsFocused] = useState2(false);
751
- const parameter = useMemo4(() => {
752
- var _a2;
753
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
754
- }, [componentData, parameterId]);
753
+ var _a;
754
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
755
755
  const value = parameter == null ? void 0 : parameter.value;
756
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
757
- const shouldSkipCustomRendering = isFocused && isEditable;
758
- const handleOnFocus = useCallback(() => {
759
- setIsFocused(true);
760
- }, [setIsFocused]);
761
- const handleOnBlur = useCallback(() => {
762
- setIsFocused(false);
763
- }, [setIsFocused]);
764
756
  if (!parameter) {
765
757
  return null;
766
758
  }
767
759
  if (!isContextualEditing) {
768
760
  return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
769
761
  }
770
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
771
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
762
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
772
763
  return /* @__PURE__ */ React18.createElement(
773
764
  Tag,
774
765
  {
775
766
  ...props,
776
767
  ...getParameterAttributes({
777
- component: componentData,
768
+ component,
778
769
  id: parameterId,
779
770
  isMultiline
780
771
  }),
781
772
  "data-uniform-parameter-type": "text",
782
773
  "data-uniform-placeholder": computedPlaceholder,
783
- style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
784
- onFocus: handleOnFocus,
785
- onBlur: handleOnBlur
774
+ style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
786
775
  },
787
- shouldSkipCustomRendering ? value : render(value)
776
+ skipCustomRendering ? value : render(value)
777
+ );
778
+ };
779
+
780
+ // src/components/UniformText.tsx
781
+ var UniformText = ({
782
+ as: tag = "span",
783
+ parameterId,
784
+ isMultiline = false,
785
+ placeholder,
786
+ render = (value) => value,
787
+ ...props
788
+ }) => {
789
+ var _a, _b, _c;
790
+ const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
791
+ const { isContextualEditing } = useUniformCurrentComposition();
792
+ const [isFocused, setIsFocused] = useState2(false);
793
+ const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
794
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
795
+ const shouldSkipCustomRendering = isFocused && isEditable;
796
+ if (!parameter) {
797
+ return null;
798
+ }
799
+ const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
800
+ const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
801
+ return /* @__PURE__ */ React19.createElement(
802
+ PureUniformText,
803
+ {
804
+ ...props,
805
+ as: tag,
806
+ parameterId,
807
+ component: componentData,
808
+ skipCustomRendering: shouldSkipCustomRendering,
809
+ isContextualEditing,
810
+ placeholder: computedPlaceholder,
811
+ render,
812
+ isMultiline,
813
+ onFocus: () => {
814
+ setIsFocused(true);
815
+ },
816
+ onBlur: () => {
817
+ setIsFocused(false);
818
+ }
819
+ }
788
820
  );
789
821
  };
790
822
 
@@ -844,14 +876,14 @@ import {
844
876
  createCanvasChannel as createCanvasChannel2,
845
877
  isUpdateContextualEditingStateInternalMessage
846
878
  } from "@uniformdev/canvas";
847
- import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
879
+ import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
848
880
  var useUniformContextualEditingState = ({
849
881
  global = false
850
882
  } = {}) => {
851
883
  const { isContextualEditing } = useUniformCurrentComposition();
852
884
  const { data: componentData } = useUniformCurrentComponent();
853
885
  const [selectedComponentReference, setSelectedComponentReference] = useState3();
854
- const channel = useMemo5(() => {
886
+ const channel = useMemo4(() => {
855
887
  if (!isContextualEditing) {
856
888
  return;
857
889
  }
package/dist/index.js CHANGED
@@ -766,56 +766,88 @@ var UniformRichText = import_react17.default.forwardRef(function UniformRichText
766
766
  });
767
767
 
768
768
  // src/components/UniformText.tsx
769
+ var import_react19 = __toESM(require("react"));
770
+
771
+ // src/components/PureUniformText.tsx
769
772
  var import_react18 = __toESM(require("react"));
770
- var UniformText = ({
773
+ var PureUniformText = ({
771
774
  as: Tag = "span",
772
775
  parameterId,
776
+ component,
777
+ skipCustomRendering,
778
+ isContextualEditing,
773
779
  isMultiline = false,
774
780
  placeholder,
775
781
  render = (value) => value,
776
782
  ...props
777
783
  }) => {
778
- var _a, _b;
779
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
780
- const { isContextualEditing } = useUniformCurrentComposition();
781
- const [isFocused, setIsFocused] = (0, import_react18.useState)(false);
782
- const parameter = (0, import_react18.useMemo)(() => {
783
- var _a2;
784
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
785
- }, [componentData, parameterId]);
784
+ var _a;
785
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
786
786
  const value = parameter == null ? void 0 : parameter.value;
787
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
788
- const shouldSkipCustomRendering = isFocused && isEditable;
789
- const handleOnFocus = (0, import_react18.useCallback)(() => {
790
- setIsFocused(true);
791
- }, [setIsFocused]);
792
- const handleOnBlur = (0, import_react18.useCallback)(() => {
793
- setIsFocused(false);
794
- }, [setIsFocused]);
795
787
  if (!parameter) {
796
788
  return null;
797
789
  }
798
790
  if (!isContextualEditing) {
799
791
  return /* @__PURE__ */ import_react18.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
800
792
  }
801
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
802
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
793
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
803
794
  return /* @__PURE__ */ import_react18.default.createElement(
804
795
  Tag,
805
796
  {
806
797
  ...props,
807
798
  ...getParameterAttributes({
808
- component: componentData,
799
+ component,
809
800
  id: parameterId,
810
801
  isMultiline
811
802
  }),
812
803
  "data-uniform-parameter-type": "text",
813
804
  "data-uniform-placeholder": computedPlaceholder,
814
- style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
815
- onFocus: handleOnFocus,
816
- onBlur: handleOnBlur
805
+ style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
817
806
  },
818
- shouldSkipCustomRendering ? value : render(value)
807
+ skipCustomRendering ? value : render(value)
808
+ );
809
+ };
810
+
811
+ // src/components/UniformText.tsx
812
+ var UniformText = ({
813
+ as: tag = "span",
814
+ parameterId,
815
+ isMultiline = false,
816
+ placeholder,
817
+ render = (value) => value,
818
+ ...props
819
+ }) => {
820
+ var _a, _b, _c;
821
+ const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
822
+ const { isContextualEditing } = useUniformCurrentComposition();
823
+ const [isFocused, setIsFocused] = (0, import_react19.useState)(false);
824
+ const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
825
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
826
+ const shouldSkipCustomRendering = isFocused && isEditable;
827
+ if (!parameter) {
828
+ return null;
829
+ }
830
+ const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
831
+ const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
832
+ return /* @__PURE__ */ import_react19.default.createElement(
833
+ PureUniformText,
834
+ {
835
+ ...props,
836
+ as: tag,
837
+ parameterId,
838
+ component: componentData,
839
+ skipCustomRendering: shouldSkipCustomRendering,
840
+ isContextualEditing,
841
+ placeholder: computedPlaceholder,
842
+ render,
843
+ isMultiline,
844
+ onFocus: () => {
845
+ setIsFocused(true);
846
+ },
847
+ onBlur: () => {
848
+ setIsFocused(false);
849
+ }
850
+ }
819
851
  );
820
852
  };
821
853
 
@@ -830,14 +862,14 @@ var getParameterAttributes = (options) => {
830
862
 
831
863
  // src/hooks/useCompositionEventEffect.ts
832
864
  var import_canvas9 = require("@uniformdev/canvas");
833
- var import_react19 = require("react");
865
+ var import_react20 = require("react");
834
866
  function useCompositionEventEffect({
835
867
  enabled,
836
868
  projectId,
837
869
  compositionId,
838
870
  effect
839
871
  }) {
840
- (0, import_react19.useEffect)(() => {
872
+ (0, import_react20.useEffect)(() => {
841
873
  if (!enabled || !compositionId || !projectId) {
842
874
  return;
843
875
  }
@@ -866,14 +898,14 @@ function useCompositionEventEffect({
866
898
 
867
899
  // src/hooks/useUniformContextualEditingState.ts
868
900
  var import_canvas10 = require("@uniformdev/canvas");
869
- var import_react20 = require("react");
901
+ var import_react21 = require("react");
870
902
  var useUniformContextualEditingState = ({
871
903
  global = false
872
904
  } = {}) => {
873
905
  const { isContextualEditing } = useUniformCurrentComposition();
874
906
  const { data: componentData } = useUniformCurrentComponent();
875
- const [selectedComponentReference, setSelectedComponentReference] = (0, import_react20.useState)();
876
- const channel = (0, import_react20.useMemo)(() => {
907
+ const [selectedComponentReference, setSelectedComponentReference] = (0, import_react21.useState)();
908
+ const channel = (0, import_react21.useMemo)(() => {
877
909
  if (!isContextualEditing) {
878
910
  return;
879
911
  }
@@ -883,7 +915,7 @@ var useUniformContextualEditingState = ({
883
915
  });
884
916
  return channel2;
885
917
  }, [isContextualEditing]);
886
- (0, import_react20.useEffect)(() => {
918
+ (0, import_react21.useEffect)(() => {
887
919
  if (!channel) {
888
920
  return;
889
921
  }
package/dist/index.mjs CHANGED
@@ -735,56 +735,88 @@ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId
735
735
  });
736
736
 
737
737
  // src/components/UniformText.tsx
738
- import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
739
- var UniformText = ({
738
+ import React19, { useState as useState2 } from "react";
739
+
740
+ // src/components/PureUniformText.tsx
741
+ import React18 from "react";
742
+ var PureUniformText = ({
740
743
  as: Tag = "span",
741
744
  parameterId,
745
+ component,
746
+ skipCustomRendering,
747
+ isContextualEditing,
742
748
  isMultiline = false,
743
749
  placeholder,
744
750
  render = (value) => value,
745
751
  ...props
746
752
  }) => {
747
- var _a, _b;
748
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
749
- const { isContextualEditing } = useUniformCurrentComposition();
750
- const [isFocused, setIsFocused] = useState2(false);
751
- const parameter = useMemo4(() => {
752
- var _a2;
753
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
754
- }, [componentData, parameterId]);
753
+ var _a;
754
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
755
755
  const value = parameter == null ? void 0 : parameter.value;
756
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
757
- const shouldSkipCustomRendering = isFocused && isEditable;
758
- const handleOnFocus = useCallback(() => {
759
- setIsFocused(true);
760
- }, [setIsFocused]);
761
- const handleOnBlur = useCallback(() => {
762
- setIsFocused(false);
763
- }, [setIsFocused]);
764
756
  if (!parameter) {
765
757
  return null;
766
758
  }
767
759
  if (!isContextualEditing) {
768
760
  return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
769
761
  }
770
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
771
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
762
+ const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
772
763
  return /* @__PURE__ */ React18.createElement(
773
764
  Tag,
774
765
  {
775
766
  ...props,
776
767
  ...getParameterAttributes({
777
- component: componentData,
768
+ component,
778
769
  id: parameterId,
779
770
  isMultiline
780
771
  }),
781
772
  "data-uniform-parameter-type": "text",
782
773
  "data-uniform-placeholder": computedPlaceholder,
783
- style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
784
- onFocus: handleOnFocus,
785
- onBlur: handleOnBlur
774
+ style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
786
775
  },
787
- shouldSkipCustomRendering ? value : render(value)
776
+ skipCustomRendering ? value : render(value)
777
+ );
778
+ };
779
+
780
+ // src/components/UniformText.tsx
781
+ var UniformText = ({
782
+ as: tag = "span",
783
+ parameterId,
784
+ isMultiline = false,
785
+ placeholder,
786
+ render = (value) => value,
787
+ ...props
788
+ }) => {
789
+ var _a, _b, _c;
790
+ const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
791
+ const { isContextualEditing } = useUniformCurrentComposition();
792
+ const [isFocused, setIsFocused] = useState2(false);
793
+ const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
794
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
795
+ const shouldSkipCustomRendering = isFocused && isEditable;
796
+ if (!parameter) {
797
+ return null;
798
+ }
799
+ const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
800
+ const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
801
+ return /* @__PURE__ */ React19.createElement(
802
+ PureUniformText,
803
+ {
804
+ ...props,
805
+ as: tag,
806
+ parameterId,
807
+ component: componentData,
808
+ skipCustomRendering: shouldSkipCustomRendering,
809
+ isContextualEditing,
810
+ placeholder: computedPlaceholder,
811
+ render,
812
+ isMultiline,
813
+ onFocus: () => {
814
+ setIsFocused(true);
815
+ },
816
+ onBlur: () => {
817
+ setIsFocused(false);
818
+ }
819
+ }
788
820
  );
789
821
  };
790
822
 
@@ -844,14 +876,14 @@ import {
844
876
  createCanvasChannel as createCanvasChannel2,
845
877
  isUpdateContextualEditingStateInternalMessage
846
878
  } from "@uniformdev/canvas";
847
- import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
879
+ import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
848
880
  var useUniformContextualEditingState = ({
849
881
  global = false
850
882
  } = {}) => {
851
883
  const { isContextualEditing } = useUniformCurrentComposition();
852
884
  const { data: componentData } = useUniformCurrentComponent();
853
885
  const [selectedComponentReference, setSelectedComponentReference] = useState3();
854
- const channel = useMemo5(() => {
886
+ const channel = useMemo4(() => {
855
887
  if (!isContextualEditing) {
856
888
  return;
857
889
  }
package/package.json CHANGED
@@ -1,19 +1,39 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.50.0",
3
+ "version": "19.50.2-alpha.11+3ffe35383",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.esm.js",
8
8
  "exports": {
9
- "import": {
10
- "types": "./dist/index.d.mts",
11
- "node": "./dist/index.mjs",
12
- "default": "./dist/index.esm.js"
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "node": "./dist/index.mjs",
13
+ "default": "./dist/index.esm.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
13
19
  },
14
- "require": "./dist/index.js"
20
+ "./core": {
21
+ "types": "./dist/core.d.ts",
22
+ "import": "./dist/core.mjs",
23
+ "require": "./dist/core.js"
24
+ }
15
25
  },
16
26
  "types": "./dist/index.d.ts",
27
+ "typesVersions": {
28
+ "*": {
29
+ "*": [
30
+ "./dist/index.d.ts"
31
+ ],
32
+ "core": [
33
+ "./dist/core.d.ts"
34
+ ]
35
+ }
36
+ },
17
37
  "sideEffects": false,
18
38
  "scripts": {
19
39
  "build": "tsup",
@@ -25,17 +45,17 @@
25
45
  "document": "api-extractor run --local"
26
46
  },
27
47
  "dependencies": {
28
- "@uniformdev/canvas": "19.50.0",
29
- "@uniformdev/context": "19.50.0",
30
- "@uniformdev/context-react": "19.50.0",
31
- "@uniformdev/richtext": "19.50.0"
48
+ "@uniformdev/canvas": "19.50.2-alpha.11+3ffe35383",
49
+ "@uniformdev/context": "19.50.2-alpha.11+3ffe35383",
50
+ "@uniformdev/context-react": "19.50.2-alpha.11+3ffe35383",
51
+ "@uniformdev/richtext": "19.50.2-alpha.11+3ffe35383"
32
52
  },
33
53
  "peerDependencies": {
34
54
  "react": ">= 16 || 17 || 18",
35
55
  "react-dom": ">=16"
36
56
  },
37
57
  "devDependencies": {
38
- "@types/react": "18.2.20",
58
+ "@types/react": "18.2.21",
39
59
  "react": "18.2.0",
40
60
  "react-dom": "18.2.0"
41
61
  },
@@ -45,5 +65,5 @@
45
65
  "publishConfig": {
46
66
  "access": "public"
47
67
  },
48
- "gitHead": "b5591b7986196c3917e9cababafaeeef1871cd47"
68
+ "gitHead": "3ffe35383d936fe485db7afd0506f4ea40386926"
49
69
  }