@uniformdev/canvas-react 19.46.1-alpha.8 → 19.47.1-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 */
@@ -257,6 +231,7 @@ type UniformCompositionContextValue = {
257
231
  behaviorTracking?: UniformCompositionProps['behaviorTracking'];
258
232
  isContextualEditing: boolean;
259
233
  };
234
+ declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
260
235
  /**
261
236
  * Gets the data of the closest `<UniformComposition />` ancestor.
262
237
  */
@@ -268,6 +243,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
268
243
  */
269
244
  declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
270
245
 
246
+ type UniformPlaygroundDecorator = (options: {
247
+ children: React$1.ReactNode;
248
+ data: ComponentInstance | RootComponentInstance;
249
+ }) => React$1.ReactElement;
250
+ type UniformPlaygroundProps = {
251
+ /**
252
+ * Allows wrapping the playground in custom components.
253
+ * Useful to customize the playground to allow previewing the components in realistic scenarios
254
+ * (e.g. different background color, different parent size)
255
+ * @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
256
+ */
257
+ decorators?: UniformPlaygroundDecorator[];
258
+ } & Omit<UniformCompositionProps, 'data'>;
259
+ /**
260
+ * Playground where you can freely live preview your components and pattern.
261
+ */
262
+ declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
263
+
271
264
  type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
272
265
  node: TNode;
273
266
  };
@@ -404,4 +397,4 @@ declare const createComponentStoreResolver: (options: {
404
397
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
405
398
  }) => RenderComponentResolver;
406
399
 
407
- export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
400
+ export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
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 */
@@ -257,6 +231,7 @@ type UniformCompositionContextValue = {
257
231
  behaviorTracking?: UniformCompositionProps['behaviorTracking'];
258
232
  isContextualEditing: boolean;
259
233
  };
234
+ declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
260
235
  /**
261
236
  * Gets the data of the closest `<UniformComposition />` ancestor.
262
237
  */
@@ -268,6 +243,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
268
243
  */
269
244
  declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
270
245
 
246
+ type UniformPlaygroundDecorator = (options: {
247
+ children: React$1.ReactNode;
248
+ data: ComponentInstance | RootComponentInstance;
249
+ }) => React$1.ReactElement;
250
+ type UniformPlaygroundProps = {
251
+ /**
252
+ * Allows wrapping the playground in custom components.
253
+ * Useful to customize the playground to allow previewing the components in realistic scenarios
254
+ * (e.g. different background color, different parent size)
255
+ * @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
256
+ */
257
+ decorators?: UniformPlaygroundDecorator[];
258
+ } & Omit<UniformCompositionProps, 'data'>;
259
+ /**
260
+ * Playground where you can freely live preview your components and pattern.
261
+ */
262
+ declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
263
+
271
264
  type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
272
265
  node: TNode;
273
266
  };
@@ -404,4 +397,4 @@ declare const createComponentStoreResolver: (options: {
404
397
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
405
398
  }) => RenderComponentResolver;
406
399
 
407
- export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
400
+ export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };