@uniformdev/canvas-react 19.72.2-alpha.0 → 19.73.1-alpha.12

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 { PureUniformTextProps as P, PureUniformText as a };
package/dist/core.d.mts CHANGED
@@ -1,41 +1,16 @@
1
- import { ComponentInstance } from '@uniformdev/canvas';
2
- import React from 'react';
1
+ import { ComponentInstance, RootComponentInstance } from '@uniformdev/canvas';
2
+ import React, { PropsWithChildren } from 'react';
3
+ export { a as PureUniformText, P as PureUniformTextProps } from './PureUniformText-37defdc5.js';
3
4
 
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;
5
+ type PureContextualEditingComponentWrapperProps = {
6
+ isPlaceholder: boolean | undefined;
7
+ parentComponent: ComponentInstance | undefined;
8
+ component: ComponentInstance | RootComponentInstance;
9
+ slotName: string | undefined;
10
+ indexInSlot: number | undefined;
11
+ slotChildrenCount: number | undefined;
12
+ isReadOnly: string | undefined;
13
+ };
14
+ declare const PureContextualEditingComponentWrapper: ({ children, isPlaceholder, parentComponent, component, slotName, indexInSlot, slotChildrenCount, isReadOnly, }: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => React.JSX.Element;
40
15
 
41
- export { PureUniformText, PureUniformTextProps };
16
+ export { PureContextualEditingComponentWrapper, PureContextualEditingComponentWrapperProps };
package/dist/core.d.ts CHANGED
@@ -1,41 +1,16 @@
1
- import { ComponentInstance } from '@uniformdev/canvas';
2
- import React from 'react';
1
+ import { ComponentInstance, RootComponentInstance } from '@uniformdev/canvas';
2
+ import React, { PropsWithChildren } from 'react';
3
+ export { a as PureUniformText, P as PureUniformTextProps } from './PureUniformText-37defdc5.js';
3
4
 
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;
5
+ type PureContextualEditingComponentWrapperProps = {
6
+ isPlaceholder: boolean | undefined;
7
+ parentComponent: ComponentInstance | undefined;
8
+ component: ComponentInstance | RootComponentInstance;
9
+ slotName: string | undefined;
10
+ indexInSlot: number | undefined;
11
+ slotChildrenCount: number | undefined;
12
+ isReadOnly: string | undefined;
13
+ };
14
+ declare const PureContextualEditingComponentWrapper: ({ children, isPlaceholder, parentComponent, component, slotName, indexInSlot, slotChildrenCount, isReadOnly, }: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => React.JSX.Element;
40
15
 
41
- export { PureUniformText, PureUniformTextProps };
16
+ export { PureContextualEditingComponentWrapper, PureContextualEditingComponentWrapperProps };
package/dist/core.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -30,18 +31,52 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
31
  // src/core.ts
31
32
  var core_exports = {};
32
33
  __export(core_exports, {
34
+ PureContextualEditingComponentWrapper: () => PureContextualEditingComponentWrapper,
33
35
  PureUniformText: () => PureUniformText
34
36
  });
35
37
  module.exports = __toCommonJS(core_exports);
36
38
 
37
- // src/components/PureUniformText.tsx
39
+ // src/components/PureContextualEditingComponentWrapper.tsx
40
+ var import_canvas = require("@uniformdev/canvas");
38
41
  var import_react = __toESM(require("react"));
42
+ var PureContextualEditingComponentWrapper = ({
43
+ children,
44
+ isPlaceholder,
45
+ parentComponent,
46
+ component,
47
+ slotName,
48
+ indexInSlot,
49
+ slotChildrenCount,
50
+ isReadOnly
51
+ }) => {
52
+ var _a, _b, _c, _d;
53
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
54
+ "script",
55
+ {
56
+ "data-role": import_canvas.IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
57
+ "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
58
+ "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
59
+ "data-component-id": component == null ? void 0 : component._id,
60
+ "data-slot-name": slotName != null ? slotName : "",
61
+ "data-component-index": indexInSlot != null ? indexInSlot : "",
62
+ "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
63
+ "data-component-name": component == null ? void 0 : component.type,
64
+ "data-is-placeholder": isPlaceholder ? "true" : void 0,
65
+ "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[import_canvas.CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
66
+ "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
67
+ "data-is-readonly": isReadOnly
68
+ }
69
+ ), children, /* @__PURE__ */ import_react.default.createElement("script", { "data-role": import_canvas.IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
70
+ };
71
+
72
+ // src/components/PureUniformText.tsx
73
+ var import_react2 = __toESM(require("react"));
39
74
 
40
75
  // src/helpers/getParameterAttributes.ts
41
- var import_canvas = require("@uniformdev/canvas");
76
+ var import_canvas2 = require("@uniformdev/canvas");
42
77
  var getParameterAttributes = (options) => {
43
78
  return {
44
- ...(0, import_canvas.getParameterAttributes)(options),
79
+ ...(0, import_canvas2.getParameterAttributes)(options),
45
80
  suppressContentEditableWarning: true
46
81
  };
47
82
  };
@@ -65,10 +100,10 @@ var PureUniformText = ({
65
100
  return null;
66
101
  }
67
102
  if (!isContextualEditing) {
68
- return /* @__PURE__ */ import_react.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
103
+ return /* @__PURE__ */ import_react2.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
69
104
  }
70
105
  const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
71
- return /* @__PURE__ */ import_react.default.createElement(
106
+ return /* @__PURE__ */ import_react2.default.createElement(
72
107
  Tag,
73
108
  {
74
109
  ...props,
@@ -86,5 +121,6 @@ var PureUniformText = ({
86
121
  };
87
122
  // Annotate the CommonJS export names for ESM import in node:
88
123
  0 && (module.exports = {
124
+ PureContextualEditingComponentWrapper,
89
125
  PureUniformText
90
126
  });
package/dist/core.mjs CHANGED
@@ -1,5 +1,44 @@
1
- // src/components/PureUniformText.tsx
1
+ 'use client';
2
+
3
+ // src/components/PureContextualEditingComponentWrapper.tsx
4
+ import {
5
+ CANVAS_LOCALE_TAG_PARAM,
6
+ IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
7
+ IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
8
+ } from "@uniformdev/canvas";
2
9
  import React from "react";
10
+ var PureContextualEditingComponentWrapper = ({
11
+ children,
12
+ isPlaceholder,
13
+ parentComponent,
14
+ component,
15
+ slotName,
16
+ indexInSlot,
17
+ slotChildrenCount,
18
+ isReadOnly
19
+ }) => {
20
+ var _a, _b, _c, _d;
21
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
22
+ "script",
23
+ {
24
+ "data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
25
+ "data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
26
+ "data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
27
+ "data-component-id": component == null ? void 0 : component._id,
28
+ "data-slot-name": slotName != null ? slotName : "",
29
+ "data-component-index": indexInSlot != null ? indexInSlot : "",
30
+ "data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
31
+ "data-component-name": component == null ? void 0 : component.type,
32
+ "data-is-placeholder": isPlaceholder ? "true" : void 0,
33
+ "data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
34
+ "data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
35
+ "data-is-readonly": isReadOnly
36
+ }
37
+ ), children, /* @__PURE__ */ React.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
38
+ };
39
+
40
+ // src/components/PureUniformText.tsx
41
+ import React2 from "react";
3
42
 
4
43
  // src/helpers/getParameterAttributes.ts
5
44
  import {
@@ -31,10 +70,10 @@ var PureUniformText = ({
31
70
  return null;
32
71
  }
33
72
  if (!isContextualEditing) {
34
- return /* @__PURE__ */ React.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
73
+ return /* @__PURE__ */ React2.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
35
74
  }
36
75
  const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
37
- return /* @__PURE__ */ React.createElement(
76
+ return /* @__PURE__ */ React2.createElement(
38
77
  Tag,
39
78
  {
40
79
  ...props,
@@ -51,5 +90,6 @@ var PureUniformText = ({
51
90
  );
52
91
  };
53
92
  export {
93
+ PureContextualEditingComponentWrapper,
54
94
  PureUniformText
55
95
  };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
- import { PureUniformTextProps } from './core.mjs';
4
+ import { P as PureUniformTextProps } from './PureUniformText-37defdc5.js';
5
5
  import { RichTextNode } from '@uniformdev/richtext';
6
6
 
7
7
  /**
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
- import { PureUniformTextProps } from './core.js';
4
+ import { P as PureUniformTextProps } from './PureUniformText-37defdc5.js';
5
5
  import { RichTextNode } from '@uniformdev/richtext';
6
6
 
7
7
  /**