@uniformdev/canvas-react 19.32.1-alpha.4 → 19.33.1-alpha.10

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.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import * as _uniformdev_canvas from '@uniformdev/canvas';
3
- import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
- export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
3
+ import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
+ export { createUniformApiEnhancer } from '@uniformdev/canvas';
5
5
  import { RichTextNode } from '@uniformdev/richtext';
6
6
 
7
7
  /**
@@ -41,40 +41,6 @@ type ComponentStore = {
41
41
  **/
42
42
  declare function DefaultNotImplementedComponent(props: ComponentProps): React$1.JSX.Element | null;
43
43
 
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'>;
72
- /**
73
- * Adds inline editing capability to text parameters
74
- * @deprecated This component is unstable, and not ready for production usage.
75
- **/
76
- declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
77
-
78
44
  type UniformComponentProps<TRenderProps = unknown> = {
79
45
  /** The data of the component instance */
80
46
  data?: ComponentInstance | RootComponentInstance;
@@ -93,16 +59,11 @@ type UniformComponentProps<TRenderProps = unknown> = {
93
59
  * Default: onView
94
60
  */
95
61
  behaviorTracking?: 'onLoad' | 'onView';
96
- /**
97
- * The default placeholder to pass to the parameter component that support inline editing (such as UniformText).
98
- */
99
- contextualEditingDefaultPlaceholder?: UniformTextProps['placeholder'];
100
62
  };
101
63
  type UniformComponentContextValue = {
102
64
  data?: UniformComponentProps['data'];
103
65
  resolveRenderer?: UniformComponentProps['resolveRenderer'];
104
66
  behaviorTracking?: UniformComponentProps['behaviorTracking'];
105
- contextualEditingDefaultPlaceholder?: UniformComponentProps['contextualEditingDefaultPlaceholder'];
106
67
  };
107
68
  /**
108
69
  * Gets the data of the closest `<UniformComponent />` ancestor.
@@ -113,7 +74,7 @@ declare function useUniformCurrentComponent(): UniformComponentContextValue;
113
74
  * Note that the actual rendering happens inside `<UniformSlot />`, this component only provides the services needed to achieve that.
114
75
  * This component is used internally by `<UniformComposition />`, which you should use in most cases.
115
76
  */
116
- declare function UniformComponent<TRenderProps = unknown>({ data, resolveRenderer, children, behaviorTracking, contextualEditingDefaultPlaceholder, }: UniformComponentProps<TRenderProps>): React$1.JSX.Element | null;
77
+ declare function UniformComponent<TRenderProps = unknown>({ data, resolveRenderer, children, behaviorTracking, }: UniformComponentProps<TRenderProps>): React$1.JSX.Element | null;
117
78
 
118
79
  type UseUniformContextualEditingProps = {
119
80
  initialCompositionValue?: RootComponentInstance;
@@ -267,7 +228,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
267
228
  * It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
268
229
  * It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
269
230
  */
270
- declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
231
+ declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
271
232
 
272
233
  type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
273
234
  node: TNode;
@@ -345,12 +306,62 @@ type UniformSlotProps<TSlotNames extends string> = {
345
306
  /** Renders a named Slot within a Composition. */
346
307
  declare function UniformSlot<TSlotNames extends string = string>({ name, resolveRenderer, children, emptyPlaceholder, }: UniformSlotProps<TSlotNames>): JSX.Element | null;
347
308
 
309
+ type ParameterTextValue = string | undefined;
310
+ type UniformTextProps = {
311
+ /**
312
+ * The name of the HTML tag to render.
313
+ * @default "span"
314
+ */
315
+ as?: React$1.ElementType;
316
+ /** The ID of the parameter. */
317
+ parameterId: string;
318
+ /**
319
+ * When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
320
+ * @default false
321
+ */
322
+ isMultiline?: boolean;
323
+ /**
324
+ * Sets the value to show in Canvas editor when the parameter value is empty.
325
+ * @default undefined
326
+ */
327
+ placeholder?: string;
328
+ /**
329
+ * A function to customize the rendering of the parameter value. Useful to format the value before rendering it.
330
+ * @default "(value) => value"
331
+ */
332
+ render?: (value: ParameterTextValue) => React$1.ReactNode;
333
+ } & Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'children'>;
334
+ /**
335
+ * Adds inline editing capability to text parameters
336
+ * @deprecated This component is unstable, and not ready for production usage.
337
+ **/
338
+ declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
339
+
340
+ type GetParameterAttributesProps = {
341
+ /** The public Id of the parameter */
342
+ id: string;
343
+ /** The component object where this parameter is used */
344
+ component: ComponentInstance;
345
+ /**
346
+ * Sets the value to show in Canvas editor when the parameter value is empty.
347
+ * @default undefined
348
+ */
349
+ placeholder?: string;
350
+ };
348
351
  /**
349
352
  * Returns the attributes needed to annotate a Uniform parameter for inline editing.
350
353
  * Supports only text parameters at the moment.
351
354
  * @deprecated Unstable, and not ready for production usage.
352
355
  **/
353
- declare const getParameterAttributes: typeof getParameterAttributes$1;
356
+ declare const getParameterAttributes: ({ id, component, placeholder }: GetParameterAttributesProps) => {
357
+ 'data-uniform-component-id': string | undefined;
358
+ 'data-uniform-parameter-id': string;
359
+ 'data-uniform-parameter-value': {};
360
+ 'data-uniform-parameter-type': string | undefined;
361
+ 'data-uniform-placeholder': string | undefined;
362
+ contentEditable: boolean;
363
+ suppressContentEditableWarning: boolean;
364
+ };
354
365
 
355
366
  type UseCompositionEventEffectOptions = Omit<Partial<SubscribeToCompositionOptions>, 'callback'> & {
356
367
  enabled: boolean;
@@ -393,4 +404,4 @@ declare const createComponentStoreResolver: (options: {
393
404
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
394
405
  }) => RenderComponentResolver;
395
406
 
396
- export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
407
+ export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, GetParameterAttributesProps, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
package/dist/index.esm.js CHANGED
@@ -295,8 +295,7 @@ function UniformComposition({
295
295
  behaviorTracking = "onView",
296
296
  children,
297
297
  resolveRenderer,
298
- contextualEditingEnhancer,
299
- contextualEditingDefaultPlaceholder
298
+ contextualEditingEnhancer
300
299
  }) {
301
300
  const { composition, isContextualEditing } = useUniformContextualEditing({
302
301
  initialCompositionValue: data,
@@ -312,8 +311,7 @@ function UniformComposition({
312
311
  {
313
312
  data: composition,
314
313
  behaviorTracking,
315
- resolveRenderer,
316
- contextualEditingDefaultPlaceholder
314
+ resolveRenderer
317
315
  },
318
316
  children
319
317
  ))
@@ -501,8 +499,7 @@ function UniformComponent({
501
499
  data,
502
500
  resolveRenderer,
503
501
  children,
504
- behaviorTracking,
505
- contextualEditingDefaultPlaceholder
502
+ behaviorTracking
506
503
  }) {
507
504
  var _a, _b, _c;
508
505
  const parentData = useUniformCurrentComponent();
@@ -516,8 +513,7 @@ function UniformComponent({
516
513
  const contextValue = {
517
514
  data,
518
515
  resolveRenderer: resolveRenderer || parentData.resolveRenderer || componentStoreResolver,
519
- behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView",
520
- contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
516
+ behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView"
521
517
  };
522
518
  const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
523
519
  const TrackComponent = contextValue.behaviorTracking === "onLoad" ? TrackFragment : Track;
@@ -692,23 +688,25 @@ var UniformText = ({
692
688
  render = (value) => value,
693
689
  ...props
694
690
  }) => {
695
- var _a, _b;
696
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
691
+ const { data: componentData } = useUniformCurrentComponent();
697
692
  const { isContextualEditing } = useUniformCurrentComposition();
698
693
  const [isFocused, setIsFocused] = useState2(false);
699
694
  const parameter = useMemo3(() => {
700
- var _a2;
701
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
695
+ var _a;
696
+ return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
702
697
  }, [componentData, parameterId]);
703
- const value = parameter == null ? void 0 : parameter.value;
704
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
705
- const shouldSkipCustomRendering = isFocused && isEditable;
698
+ const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
699
+ const isEditable = useMemo3(() => {
700
+ var _a, _b;
701
+ return (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
702
+ }, [parameter]);
706
703
  const handleOnFocus = useCallback(() => {
707
704
  setIsFocused(true);
708
705
  }, [setIsFocused]);
709
706
  const handleOnBlur = useCallback(() => {
710
707
  setIsFocused(false);
711
708
  }, [setIsFocused]);
709
+ const shouldSkipCustomRendering = useMemo3(() => isFocused && isEditable, [isFocused, isEditable]);
712
710
  if (!parameter) {
713
711
  console.warn(
714
712
  `UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
@@ -718,20 +716,19 @@ var UniformText = ({
718
716
  if (!isContextualEditing) {
719
717
  return /* @__PURE__ */ React17.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
720
718
  }
721
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
722
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
723
719
  return /* @__PURE__ */ React17.createElement(
724
720
  Tag,
725
721
  {
726
722
  ...props,
727
- ...getParameterAttributes({
728
- component: componentData,
729
- id: parameterId,
730
- isMultiline
731
- }),
723
+ "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
724
+ "data-uniform-parameter-id": parameterId,
725
+ "data-uniform-parameter-value": value != null ? value : "",
732
726
  "data-uniform-parameter-type": "text",
733
- "data-uniform-placeholder": computedPlaceholder,
727
+ "data-uniform-is-multiline": isMultiline,
728
+ "data-uniform-placeholder": placeholder,
734
729
  style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
730
+ contentEditable: isEditable,
731
+ suppressContentEditableWarning: true,
735
732
  onFocus: handleOnFocus,
736
733
  onBlur: handleOnBlur
737
734
  },
@@ -740,12 +737,20 @@ var UniformText = ({
740
737
  };
741
738
 
742
739
  // src/helpers/getParameterAttributes.ts
743
- import {
744
- getParameterAttributes as defaultGetParameterAttributes
745
- } from "@uniformdev/canvas";
746
- var getParameterAttributes = (options) => {
740
+ var getParameterAttributes = ({ id, component, placeholder }) => {
741
+ var _a, _b, _c;
742
+ const componentId = component == null ? void 0 : component._id;
743
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
744
+ const value = parameter == null ? void 0 : parameter.value;
745
+ const type = parameter == null ? void 0 : parameter.type;
746
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
747
747
  return {
748
- ...defaultGetParameterAttributes(options),
748
+ "data-uniform-component-id": componentId,
749
+ "data-uniform-parameter-id": id,
750
+ "data-uniform-parameter-value": value != null ? value : "",
751
+ "data-uniform-parameter-type": type,
752
+ "data-uniform-placeholder": placeholder,
753
+ contentEditable: isEditable,
749
754
  suppressContentEditableWarning: true
750
755
  };
751
756
  };
package/dist/index.js CHANGED
@@ -327,8 +327,7 @@ function UniformComposition({
327
327
  behaviorTracking = "onView",
328
328
  children,
329
329
  resolveRenderer,
330
- contextualEditingEnhancer,
331
- contextualEditingDefaultPlaceholder
330
+ contextualEditingEnhancer
332
331
  }) {
333
332
  const { composition, isContextualEditing } = useUniformContextualEditing({
334
333
  initialCompositionValue: data,
@@ -344,8 +343,7 @@ function UniformComposition({
344
343
  {
345
344
  data: composition,
346
345
  behaviorTracking,
347
- resolveRenderer,
348
- contextualEditingDefaultPlaceholder
346
+ resolveRenderer
349
347
  },
350
348
  children
351
349
  ))
@@ -533,8 +531,7 @@ function UniformComponent({
533
531
  data,
534
532
  resolveRenderer,
535
533
  children,
536
- behaviorTracking,
537
- contextualEditingDefaultPlaceholder
534
+ behaviorTracking
538
535
  }) {
539
536
  var _a, _b, _c;
540
537
  const parentData = useUniformCurrentComponent();
@@ -548,8 +545,7 @@ function UniformComponent({
548
545
  const contextValue = {
549
546
  data,
550
547
  resolveRenderer: resolveRenderer || parentData.resolveRenderer || componentStoreResolver,
551
- behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView",
552
- contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
548
+ behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView"
553
549
  };
554
550
  const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[import_canvas6.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
555
551
  const TrackComponent = contextValue.behaviorTracking === "onLoad" ? import_context_react2.TrackFragment : import_context_react2.Track;
@@ -721,23 +717,25 @@ var UniformText = ({
721
717
  render = (value) => value,
722
718
  ...props
723
719
  }) => {
724
- var _a, _b;
725
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
720
+ const { data: componentData } = useUniformCurrentComponent();
726
721
  const { isContextualEditing } = useUniformCurrentComposition();
727
722
  const [isFocused, setIsFocused] = (0, import_react17.useState)(false);
728
723
  const parameter = (0, import_react17.useMemo)(() => {
729
- var _a2;
730
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
724
+ var _a;
725
+ return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
731
726
  }, [componentData, parameterId]);
732
- const value = parameter == null ? void 0 : parameter.value;
733
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
734
- const shouldSkipCustomRendering = isFocused && isEditable;
727
+ const value = (0, import_react17.useMemo)(() => parameter == null ? void 0 : parameter.value, [parameter]);
728
+ const isEditable = (0, import_react17.useMemo)(() => {
729
+ var _a, _b;
730
+ return (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
731
+ }, [parameter]);
735
732
  const handleOnFocus = (0, import_react17.useCallback)(() => {
736
733
  setIsFocused(true);
737
734
  }, [setIsFocused]);
738
735
  const handleOnBlur = (0, import_react17.useCallback)(() => {
739
736
  setIsFocused(false);
740
737
  }, [setIsFocused]);
738
+ const shouldSkipCustomRendering = (0, import_react17.useMemo)(() => isFocused && isEditable, [isFocused, isEditable]);
741
739
  if (!parameter) {
742
740
  console.warn(
743
741
  `UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
@@ -747,20 +745,19 @@ var UniformText = ({
747
745
  if (!isContextualEditing) {
748
746
  return /* @__PURE__ */ import_react17.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
749
747
  }
750
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
751
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
752
748
  return /* @__PURE__ */ import_react17.default.createElement(
753
749
  Tag,
754
750
  {
755
751
  ...props,
756
- ...getParameterAttributes({
757
- component: componentData,
758
- id: parameterId,
759
- isMultiline
760
- }),
752
+ "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
753
+ "data-uniform-parameter-id": parameterId,
754
+ "data-uniform-parameter-value": value != null ? value : "",
761
755
  "data-uniform-parameter-type": "text",
762
- "data-uniform-placeholder": computedPlaceholder,
756
+ "data-uniform-is-multiline": isMultiline,
757
+ "data-uniform-placeholder": placeholder,
763
758
  style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
759
+ contentEditable: isEditable,
760
+ suppressContentEditableWarning: true,
764
761
  onFocus: handleOnFocus,
765
762
  onBlur: handleOnBlur
766
763
  },
@@ -769,16 +766,26 @@ var UniformText = ({
769
766
  };
770
767
 
771
768
  // src/helpers/getParameterAttributes.ts
772
- var import_canvas7 = require("@uniformdev/canvas");
773
- var getParameterAttributes = (options) => {
769
+ var getParameterAttributes = ({ id, component, placeholder }) => {
770
+ var _a, _b, _c;
771
+ const componentId = component == null ? void 0 : component._id;
772
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
773
+ const value = parameter == null ? void 0 : parameter.value;
774
+ const type = parameter == null ? void 0 : parameter.type;
775
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
774
776
  return {
775
- ...(0, import_canvas7.getParameterAttributes)(options),
777
+ "data-uniform-component-id": componentId,
778
+ "data-uniform-parameter-id": id,
779
+ "data-uniform-parameter-value": value != null ? value : "",
780
+ "data-uniform-parameter-type": type,
781
+ "data-uniform-placeholder": placeholder,
782
+ contentEditable: isEditable,
776
783
  suppressContentEditableWarning: true
777
784
  };
778
785
  };
779
786
 
780
787
  // src/hooks/useCompositionEventEffect.ts
781
- var import_canvas8 = require("@uniformdev/canvas");
788
+ var import_canvas7 = require("@uniformdev/canvas");
782
789
  var import_react18 = require("react");
783
790
  function useCompositionEventEffect({
784
791
  enabled,
@@ -792,12 +799,12 @@ function useCompositionEventEffect({
792
799
  }
793
800
  let goodbye = void 0;
794
801
  const loadEffect = async () => {
795
- const eventBus = await (0, import_canvas8.createEventBus)();
802
+ const eventBus = await (0, import_canvas7.createEventBus)();
796
803
  if (eventBus) {
797
- goodbye = (0, import_canvas8.subscribeToComposition)({
804
+ goodbye = (0, import_canvas7.subscribeToComposition)({
798
805
  eventBus,
799
806
  compositionId,
800
- compositionState: import_canvas8.CANVAS_DRAFT_STATE,
807
+ compositionState: import_canvas7.CANVAS_DRAFT_STATE,
801
808
  projectId,
802
809
  callback: effect,
803
810
  event: "updated"
@@ -814,7 +821,7 @@ function useCompositionEventEffect({
814
821
  }
815
822
 
816
823
  // src/hooks/useUniformContextualEditingState.ts
817
- var import_canvas9 = require("@uniformdev/canvas");
824
+ var import_canvas8 = require("@uniformdev/canvas");
818
825
  var import_react19 = require("react");
819
826
  var useUniformContextualEditingState = ({
820
827
  global = false
@@ -826,7 +833,7 @@ var useUniformContextualEditingState = ({
826
833
  if (!isContextualEditing) {
827
834
  return;
828
835
  }
829
- const channel2 = (0, import_canvas9.createCanvasChannel)({
836
+ const channel2 = (0, import_canvas8.createCanvasChannel)({
830
837
  broadcastTo: [window],
831
838
  listenTo: [window]
832
839
  });
@@ -838,7 +845,7 @@ var useUniformContextualEditingState = ({
838
845
  }
839
846
  const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
840
847
  var _a;
841
- if (!(0, import_canvas9.isUpdateContextualEditingStateInternalMessage)(message)) {
848
+ if (!(0, import_canvas8.isUpdateContextualEditingStateInternalMessage)(message)) {
842
849
  return;
843
850
  }
844
851
  if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
package/dist/index.mjs CHANGED
@@ -295,8 +295,7 @@ function UniformComposition({
295
295
  behaviorTracking = "onView",
296
296
  children,
297
297
  resolveRenderer,
298
- contextualEditingEnhancer,
299
- contextualEditingDefaultPlaceholder
298
+ contextualEditingEnhancer
300
299
  }) {
301
300
  const { composition, isContextualEditing } = useUniformContextualEditing({
302
301
  initialCompositionValue: data,
@@ -312,8 +311,7 @@ function UniformComposition({
312
311
  {
313
312
  data: composition,
314
313
  behaviorTracking,
315
- resolveRenderer,
316
- contextualEditingDefaultPlaceholder
314
+ resolveRenderer
317
315
  },
318
316
  children
319
317
  ))
@@ -501,8 +499,7 @@ function UniformComponent({
501
499
  data,
502
500
  resolveRenderer,
503
501
  children,
504
- behaviorTracking,
505
- contextualEditingDefaultPlaceholder
502
+ behaviorTracking
506
503
  }) {
507
504
  var _a, _b, _c;
508
505
  const parentData = useUniformCurrentComponent();
@@ -516,8 +513,7 @@ function UniformComponent({
516
513
  const contextValue = {
517
514
  data,
518
515
  resolveRenderer: resolveRenderer || parentData.resolveRenderer || componentStoreResolver,
519
- behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView",
520
- contextualEditingDefaultPlaceholder: contextualEditingDefaultPlaceholder != null ? contextualEditingDefaultPlaceholder : parentData.contextualEditingDefaultPlaceholder
516
+ behaviorTracking: (_a = behaviorTracking != null ? behaviorTracking : parentData == null ? void 0 : parentData.behaviorTracking) != null ? _a : "onView"
521
517
  };
522
518
  const enrichmentTags = (_c = (_b = data.parameters) == null ? void 0 : _b[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _c.value;
523
519
  const TrackComponent = contextValue.behaviorTracking === "onLoad" ? TrackFragment : Track;
@@ -692,23 +688,25 @@ var UniformText = ({
692
688
  render = (value) => value,
693
689
  ...props
694
690
  }) => {
695
- var _a, _b;
696
- const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
691
+ const { data: componentData } = useUniformCurrentComponent();
697
692
  const { isContextualEditing } = useUniformCurrentComposition();
698
693
  const [isFocused, setIsFocused] = useState2(false);
699
694
  const parameter = useMemo3(() => {
700
- var _a2;
701
- return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
695
+ var _a;
696
+ return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
702
697
  }, [componentData, parameterId]);
703
- const value = parameter == null ? void 0 : parameter.value;
704
- const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
705
- const shouldSkipCustomRendering = isFocused && isEditable;
698
+ const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
699
+ const isEditable = useMemo3(() => {
700
+ var _a, _b;
701
+ return (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
702
+ }, [parameter]);
706
703
  const handleOnFocus = useCallback(() => {
707
704
  setIsFocused(true);
708
705
  }, [setIsFocused]);
709
706
  const handleOnBlur = useCallback(() => {
710
707
  setIsFocused(false);
711
708
  }, [setIsFocused]);
709
+ const shouldSkipCustomRendering = useMemo3(() => isFocused && isEditable, [isFocused, isEditable]);
712
710
  if (!parameter) {
713
711
  console.warn(
714
712
  `UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
@@ -718,20 +716,19 @@ var UniformText = ({
718
716
  if (!isContextualEditing) {
719
717
  return /* @__PURE__ */ React17.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
720
718
  }
721
- const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
722
- const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
723
719
  return /* @__PURE__ */ React17.createElement(
724
720
  Tag,
725
721
  {
726
722
  ...props,
727
- ...getParameterAttributes({
728
- component: componentData,
729
- id: parameterId,
730
- isMultiline
731
- }),
723
+ "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
724
+ "data-uniform-parameter-id": parameterId,
725
+ "data-uniform-parameter-value": value != null ? value : "",
732
726
  "data-uniform-parameter-type": "text",
733
- "data-uniform-placeholder": computedPlaceholder,
727
+ "data-uniform-is-multiline": isMultiline,
728
+ "data-uniform-placeholder": placeholder,
734
729
  style: isMultiline ? { whiteSpace: "pre-wrap" } : {},
730
+ contentEditable: isEditable,
731
+ suppressContentEditableWarning: true,
735
732
  onFocus: handleOnFocus,
736
733
  onBlur: handleOnBlur
737
734
  },
@@ -740,12 +737,20 @@ var UniformText = ({
740
737
  };
741
738
 
742
739
  // src/helpers/getParameterAttributes.ts
743
- import {
744
- getParameterAttributes as defaultGetParameterAttributes
745
- } from "@uniformdev/canvas";
746
- var getParameterAttributes = (options) => {
740
+ var getParameterAttributes = ({ id, component, placeholder }) => {
741
+ var _a, _b, _c;
742
+ const componentId = component == null ? void 0 : component._id;
743
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
744
+ const value = parameter == null ? void 0 : parameter.value;
745
+ const type = parameter == null ? void 0 : parameter.type;
746
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
747
747
  return {
748
- ...defaultGetParameterAttributes(options),
748
+ "data-uniform-component-id": componentId,
749
+ "data-uniform-parameter-id": id,
750
+ "data-uniform-parameter-value": value != null ? value : "",
751
+ "data-uniform-parameter-type": type,
752
+ "data-uniform-placeholder": placeholder,
753
+ contentEditable: isEditable,
749
754
  suppressContentEditableWarning: true
750
755
  };
751
756
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.32.1-alpha.4+e139d9ab3",
3
+ "version": "19.33.1-alpha.10+468c89c72",
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.32.1-alpha.4+e139d9ab3",
28
- "@uniformdev/context": "19.32.1-alpha.4+e139d9ab3",
29
- "@uniformdev/context-react": "19.32.1-alpha.4+e139d9ab3",
30
- "@uniformdev/richtext": "19.32.1-alpha.4+e139d9ab3"
27
+ "@uniformdev/canvas": "19.33.1-alpha.10+468c89c72",
28
+ "@uniformdev/context": "19.33.1-alpha.10+468c89c72",
29
+ "@uniformdev/context-react": "19.33.1-alpha.10+468c89c72",
30
+ "@uniformdev/richtext": "19.33.1-alpha.10+468c89c72"
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": "e139d9ab324b00fff68e36751585b829c3bb1fb5"
47
+ "gitHead": "468c89c7236b39c598fc7fcce5b318d23a1fbd55"
48
48
  }