@uniformdev/canvas-react 19.8.0 → 19.10.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.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import React$1, { Key, ReactNode } from 'react';
1
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, SubscribeToCompositionOptions } from '@uniformdev/canvas';
2
3
  export { createUniformApiEnhancer } from '@uniformdev/canvas';
3
- import React$1, { Key, ReactNode } from 'react';
4
4
 
5
5
  /**
6
6
  * Props passed to a Canvas component implementation.
@@ -37,7 +37,7 @@ type ComponentStore = {
37
37
  * To make this work, it needs to be the default returned from the
38
38
  * resolveRenderer() function when the component is unknown.
39
39
  **/
40
- declare function DefaultNotImplementedComponent(props: ComponentProps): JSX.Element | null;
40
+ declare function DefaultNotImplementedComponent(props: ComponentProps): React$1.JSX.Element | null;
41
41
 
42
42
  type UniformComponentProps<TRenderProps = unknown> = {
43
43
  /** The data of the component instance */
@@ -72,7 +72,7 @@ declare function useUniformCurrentComponent(): UniformComponentContextValue;
72
72
  * Note that the actual rendering happens inside `<UniformSlot />`, this component only provides the services needed to achieve that.
73
73
  * This component is used internally by `<UniformComposition />`, which you should use in most cases.
74
74
  */
75
- declare function UniformComponent<TRenderProps = unknown>({ data, resolveRenderer, children, behaviorTracking, }: UniformComponentProps<TRenderProps>): JSX.Element | null;
75
+ declare function UniformComponent<TRenderProps = unknown>({ data, resolveRenderer, children, behaviorTracking, }: UniformComponentProps<TRenderProps>): React$1.JSX.Element | null;
76
76
 
77
77
  type UseUniformContextualEditingProps = {
78
78
  initialCompositionValue?: RootComponentInstance;
@@ -226,7 +226,7 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
226
226
  * It renders the full tree of components, and provides some services to the children, such as `useUniformCurrentComposition`.
227
227
  * It also takes care of enabling [Contextual Editing](https://docs.uniform.app/capabilities/composition/contextual-editing).
228
228
  */
229
- declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, }: UniformCompositionProps<TRenderProps>): JSX.Element;
229
+ declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
230
230
 
231
231
  type CustomSlotChildRenderFunc = (options: {
232
232
  child: ReactNode;
@@ -282,7 +282,33 @@ type UniformTextProps = {
282
282
  * Adds inline editing capability to text parameters
283
283
  * @deprecated This component is unstable, and not ready for production usage.
284
284
  **/
285
- declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => JSX.Element | null;
285
+ declare const UniformText: ({ as: Tag, parameterId, isMultiline, placeholder, render, ...props }: UniformTextProps) => React$1.JSX.Element | null;
286
+
287
+ type GetParameterAttributesProps = {
288
+ /** The public Id of the parameter */
289
+ id: string;
290
+ /** The component object where this parameter is used */
291
+ component: ComponentInstance;
292
+ /**
293
+ * Sets the value to show in Canvas editor when the parameter value is empty.
294
+ * @default undefined
295
+ */
296
+ placeholder?: string;
297
+ };
298
+ /**
299
+ * Returns the attributes needed to annotate a Uniform parameter for inline editing.
300
+ * Supports only text parameters at the moment.
301
+ * @deprecated Unstable, and not ready for production usage.
302
+ **/
303
+ declare const getParameterAttributes: ({ id, component, placeholder }: GetParameterAttributesProps) => {
304
+ 'data-uniform-component-id': string | undefined;
305
+ 'data-uniform-parameter-id': string;
306
+ 'data-uniform-parameter-value': {};
307
+ 'data-uniform-parameter-type': string | undefined;
308
+ 'data-uniform-placeholder': string | undefined;
309
+ contentEditable: boolean;
310
+ suppressContentEditableWarning: boolean;
311
+ };
286
312
 
287
313
  type UseCompositionEventEffectOptions = Omit<Partial<SubscribeToCompositionOptions>, 'callback'> & {
288
314
  enabled: boolean;
@@ -307,4 +333,4 @@ declare const createComponentStoreResolver: (options: {
307
333
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
308
334
  }) => RenderComponentResolver;
309
335
 
310
- export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformCurrentComponent, useUniformCurrentComposition };
336
+ export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, GetParameterAttributesProps, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformCurrentComponent, useUniformCurrentComposition };
package/dist/index.esm.js CHANGED
@@ -553,7 +553,7 @@ function resolveChildren({
553
553
  }
554
554
 
555
555
  // src/components/UniformText.tsx
556
- import React7, { useCallback, useMemo as useMemo2, useRef, useState as useState2 } from "react";
556
+ import React7, { useCallback, useMemo as useMemo2, useState as useState2 } from "react";
557
557
  var UniformText = ({
558
558
  as: Tag = "span",
559
559
  parameterId,
@@ -564,7 +564,6 @@ var UniformText = ({
564
564
  }) => {
565
565
  const { data: componentData } = useUniformCurrentComponent();
566
566
  const { isContextualEditing } = useUniformCurrentComposition();
567
- const elementRef = useRef(null);
568
567
  const [isFocused, setIsFocused] = useState2(false);
569
568
  const parameter = useMemo2(() => {
570
569
  var _a;
@@ -595,7 +594,6 @@ var UniformText = ({
595
594
  Tag,
596
595
  {
597
596
  ...props,
598
- ref: elementRef,
599
597
  "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
600
598
  "data-uniform-parameter-id": parameterId,
601
599
  "data-uniform-parameter-value": value != null ? value : "",
@@ -612,6 +610,25 @@ var UniformText = ({
612
610
  );
613
611
  };
614
612
 
613
+ // src/helpers/getParameterAttributes.ts
614
+ var getParameterAttributes = ({ id, component, placeholder }) => {
615
+ var _a, _b, _c;
616
+ const componentId = component == null ? void 0 : component._id;
617
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
618
+ const value = parameter == null ? void 0 : parameter.value;
619
+ const type = parameter == null ? void 0 : parameter.type;
620
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
621
+ return {
622
+ "data-uniform-component-id": componentId,
623
+ "data-uniform-parameter-id": id,
624
+ "data-uniform-parameter-value": value != null ? value : "",
625
+ "data-uniform-parameter-type": type,
626
+ "data-uniform-placeholder": placeholder,
627
+ contentEditable: isEditable,
628
+ suppressContentEditableWarning: true
629
+ };
630
+ };
631
+
615
632
  // src/hooks/useCompositionEventEffect.ts
616
633
  import {
617
634
  CANVAS_DRAFT_STATE,
@@ -663,6 +680,7 @@ export {
663
680
  createComponentStore,
664
681
  createComponentStoreResolver,
665
682
  createUniformApiEnhancer,
683
+ getParameterAttributes,
666
684
  registerUniformComponent,
667
685
  useCompositionEventEffect,
668
686
  useUniformContextualEditing,
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ __export(src_exports, {
41
41
  createComponentStore: () => createComponentStore,
42
42
  createComponentStoreResolver: () => createComponentStoreResolver,
43
43
  createUniformApiEnhancer: () => import_canvas3.createUniformApiEnhancer,
44
+ getParameterAttributes: () => getParameterAttributes,
44
45
  registerUniformComponent: () => registerUniformComponent,
45
46
  useCompositionEventEffect: () => useCompositionEventEffect,
46
47
  useUniformContextualEditing: () => useUniformContextualEditing,
@@ -592,7 +593,6 @@ var UniformText = ({
592
593
  }) => {
593
594
  const { data: componentData } = useUniformCurrentComponent();
594
595
  const { isContextualEditing } = useUniformCurrentComposition();
595
- const elementRef = (0, import_react7.useRef)(null);
596
596
  const [isFocused, setIsFocused] = (0, import_react7.useState)(false);
597
597
  const parameter = (0, import_react7.useMemo)(() => {
598
598
  var _a;
@@ -623,7 +623,6 @@ var UniformText = ({
623
623
  Tag,
624
624
  {
625
625
  ...props,
626
- ref: elementRef,
627
626
  "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
628
627
  "data-uniform-parameter-id": parameterId,
629
628
  "data-uniform-parameter-value": value != null ? value : "",
@@ -640,6 +639,25 @@ var UniformText = ({
640
639
  );
641
640
  };
642
641
 
642
+ // src/helpers/getParameterAttributes.ts
643
+ var getParameterAttributes = ({ id, component, placeholder }) => {
644
+ var _a, _b, _c;
645
+ const componentId = component == null ? void 0 : component._id;
646
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
647
+ const value = parameter == null ? void 0 : parameter.value;
648
+ const type = parameter == null ? void 0 : parameter.type;
649
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
650
+ return {
651
+ "data-uniform-component-id": componentId,
652
+ "data-uniform-parameter-id": id,
653
+ "data-uniform-parameter-value": value != null ? value : "",
654
+ "data-uniform-parameter-type": type,
655
+ "data-uniform-placeholder": placeholder,
656
+ contentEditable: isEditable,
657
+ suppressContentEditableWarning: true
658
+ };
659
+ };
660
+
643
661
  // src/hooks/useCompositionEventEffect.ts
644
662
  var import_canvas7 = require("@uniformdev/canvas");
645
663
  var import_react8 = require("react");
@@ -688,6 +706,7 @@ function useCompositionEventEffect({
688
706
  createComponentStore,
689
707
  createComponentStoreResolver,
690
708
  createUniformApiEnhancer,
709
+ getParameterAttributes,
691
710
  registerUniformComponent,
692
711
  useCompositionEventEffect,
693
712
  useUniformContextualEditing,
package/dist/index.mjs CHANGED
@@ -553,7 +553,7 @@ function resolveChildren({
553
553
  }
554
554
 
555
555
  // src/components/UniformText.tsx
556
- import React7, { useCallback, useMemo as useMemo2, useRef, useState as useState2 } from "react";
556
+ import React7, { useCallback, useMemo as useMemo2, useState as useState2 } from "react";
557
557
  var UniformText = ({
558
558
  as: Tag = "span",
559
559
  parameterId,
@@ -564,7 +564,6 @@ var UniformText = ({
564
564
  }) => {
565
565
  const { data: componentData } = useUniformCurrentComponent();
566
566
  const { isContextualEditing } = useUniformCurrentComposition();
567
- const elementRef = useRef(null);
568
567
  const [isFocused, setIsFocused] = useState2(false);
569
568
  const parameter = useMemo2(() => {
570
569
  var _a;
@@ -595,7 +594,6 @@ var UniformText = ({
595
594
  Tag,
596
595
  {
597
596
  ...props,
598
- ref: elementRef,
599
597
  "data-uniform-component-id": componentData == null ? void 0 : componentData._id,
600
598
  "data-uniform-parameter-id": parameterId,
601
599
  "data-uniform-parameter-value": value != null ? value : "",
@@ -612,6 +610,25 @@ var UniformText = ({
612
610
  );
613
611
  };
614
612
 
613
+ // src/helpers/getParameterAttributes.ts
614
+ var getParameterAttributes = ({ id, component, placeholder }) => {
615
+ var _a, _b, _c;
616
+ const componentId = component == null ? void 0 : component._id;
617
+ const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[id];
618
+ const value = parameter == null ? void 0 : parameter.value;
619
+ const type = parameter == null ? void 0 : parameter.type;
620
+ const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
621
+ return {
622
+ "data-uniform-component-id": componentId,
623
+ "data-uniform-parameter-id": id,
624
+ "data-uniform-parameter-value": value != null ? value : "",
625
+ "data-uniform-parameter-type": type,
626
+ "data-uniform-placeholder": placeholder,
627
+ contentEditable: isEditable,
628
+ suppressContentEditableWarning: true
629
+ };
630
+ };
631
+
615
632
  // src/hooks/useCompositionEventEffect.ts
616
633
  import {
617
634
  CANVAS_DRAFT_STATE,
@@ -663,6 +680,7 @@ export {
663
680
  createComponentStore,
664
681
  createComponentStoreResolver,
665
682
  createUniformApiEnhancer,
683
+ getParameterAttributes,
666
684
  registerUniformComponent,
667
685
  useCompositionEventEffect,
668
686
  useUniformContextualEditing,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.8.0",
3
+ "version": "19.10.0",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -24,16 +24,16 @@
24
24
  "document": "api-extractor run --local"
25
25
  },
26
26
  "dependencies": {
27
- "@uniformdev/canvas": "19.8.0",
28
- "@uniformdev/context": "19.8.0",
29
- "@uniformdev/context-react": "19.8.0"
27
+ "@uniformdev/canvas": "19.10.0",
28
+ "@uniformdev/context": "19.10.0",
29
+ "@uniformdev/context-react": "19.10.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">= 16 || 17 || 18",
33
33
  "react-dom": ">=16"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/react": "18.2.5",
36
+ "@types/react": "18.2.6",
37
37
  "react": "18.2.0",
38
38
  "react-dom": "18.2.0"
39
39
  },
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "70eb9277bbfaee5f9245e1b26b4e77caede22944"
46
+ "gitHead": "149f942da715ed802545850283f9b99291829a04"
47
47
  }