@uniformdev/canvas-next-rsc 19.40.0 → 19.41.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.
@@ -1,11 +1,15 @@
1
1
  import { ComponentInstance } from '@uniformdev/canvas';
2
- import { Key, ReactNode } from 'react';
2
+ import React, { Key, ReactNode } from 'react';
3
3
  import { CompositionContext } from './UniformComponent';
4
4
  export type CustomSlotChildRenderFunc = (options: {
5
5
  child: ReactNode;
6
6
  component: ComponentInstance;
7
7
  key: Key;
8
8
  }) => JSX.Element;
9
+ export type UniformSlotWrapperComponentProps = {
10
+ items: ReactNode[];
11
+ slotName: string;
12
+ };
9
13
  export type UniformSlotProps<TSlotNames extends string> = {
10
14
  /** Name of the slot to render */
11
15
  name: TSlotNames;
@@ -13,8 +17,17 @@ export type UniformSlotProps<TSlotNames extends string> = {
13
17
  data: ComponentInstance;
14
18
  /** The context of the composition that is being rendered */
15
19
  context: CompositionContext;
16
- /** Optional render props enables wrapping all child components in the slot with some markup */
20
+ /**
21
+ * Optional render props enables wrapping all child components in the slot with some markup
22
+ *
23
+ * @deprecated Use `wrapperComponent` instead and define wrapping component for slot children inside.
24
+ */
17
25
  children?: CustomSlotChildRenderFunc;
26
+ /**
27
+ * Optional wrapper component around list of slot items that allows to control
28
+ * exactly how to render slot items, otherwise React.Fragment is being used
29
+ */
30
+ wrapperComponent?: React.ComponentType<UniformSlotWrapperComponentProps>;
18
31
  /**
19
32
  * Optional ReactNode to use as a placeholder in Canvas editor when the slot is empty.
20
33
  * The node is used to render a placeholder with realistic dimensions and it's never shown to users.
@@ -22,6 +35,6 @@ export type UniformSlotProps<TSlotNames extends string> = {
22
35
  */
23
36
  emptyPlaceholder?: ReactNode;
24
37
  };
25
- export declare function UniformSlot<TSlotNames extends string = string>({ name, children, emptyPlaceholder, data: parentData, context, }: UniformSlotProps<TSlotNames> & {
38
+ export declare function UniformSlot<TSlotNames extends string = string>({ name, children, emptyPlaceholder, data: parentData, wrapperComponent, context, }: UniformSlotProps<TSlotNames> & {
26
39
  data: ComponentInstance;
27
40
  }): JSX.Element | null;
@@ -1,6 +1,7 @@
1
- import { createElement, Fragment } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { createElement, Fragment } from 'react';
2
3
  import { renderComponent } from './renderComponent';
3
- export function UniformSlot({ name, children, emptyPlaceholder, data: parentData, context, }) {
4
+ export function UniformSlot({ name, children, emptyPlaceholder, data: parentData, wrapperComponent, context, }) {
4
5
  var _a;
5
6
  const slot = (_a = parentData.slots) === null || _a === void 0 ? void 0 : _a[name];
6
7
  if (!slot || !Array.isArray(slot)) {
@@ -29,5 +30,9 @@ export function UniformSlot({ name, children, emptyPlaceholder, data: parentData
29
30
  const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
30
31
  return createElement(Fragment, { key: index }, elements);
31
32
  });
32
- return createElement(Fragment, undefined, finalChildren);
33
+ if (!wrapperComponent) {
34
+ return React.createElement(React.Fragment, undefined, finalChildren);
35
+ }
36
+ const Wrapper = wrapperComponent;
37
+ return _jsx(Wrapper, { items: finalChildren, slotName: name });
33
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc",
3
- "version": "19.40.0",
3
+ "version": "19.41.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "dev": "pnpm build --watch",
@@ -56,13 +56,13 @@
56
56
  "typescript": "^5.0.4"
57
57
  },
58
58
  "dependencies": {
59
- "@uniformdev/canvas": "19.40.0",
60
- "@uniformdev/canvas-react": "19.40.0",
61
- "@uniformdev/context": "19.40.0",
62
- "@uniformdev/project-map": "19.40.0",
63
- "@uniformdev/redirect": "19.40.0",
64
- "@uniformdev/richtext": "19.40.0",
65
- "@uniformdev/webhooks": "19.40.0",
59
+ "@uniformdev/canvas": "19.41.0",
60
+ "@uniformdev/canvas-react": "19.41.0",
61
+ "@uniformdev/context": "19.41.0",
62
+ "@uniformdev/project-map": "19.41.0",
63
+ "@uniformdev/redirect": "19.41.0",
64
+ "@uniformdev/richtext": "19.41.0",
65
+ "@uniformdev/webhooks": "19.41.0",
66
66
  "@vercel/edge-config": "^0.2.0",
67
67
  "dequal": "^2.0.3",
68
68
  "js-cookie": "^3.0.5",
@@ -76,5 +76,5 @@
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "f21fe5bd9d42379336cc7cb30e5b2f1955e8c337"
79
+ "gitHead": "cd4f9fd5bbdcba2b7f7235dbf342418a6bbaacb9"
80
80
  }