@dotcms/react 1.2.6-next.3 → 1.3.0-next.1

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.
@@ -5,21 +5,24 @@
5
5
  * (e.g., components that fetch data) within a DotCMS page layout. Pass the
6
6
  * resulting map to `DotCMSLayoutBody` via the `slots` prop.
7
7
  *
8
+ * Each component is awaited, so the returned record contains resolved `ReactNode`
9
+ * values — safe to pass as props to client components without `React.use()`.
10
+ *
8
11
  * @public
9
12
  * @param containers - The containers map from `pageAsset.containers`
10
13
  * @param serverComponents - A map of content type names to async server components
11
- * @returns A record mapping contentlet identifiers to pre-rendered ReactNodes
14
+ * @returns A promise resolving to a record mapping contentlet identifiers to pre-rendered ReactNodes
12
15
  *
13
16
  * @example
14
17
  * ```tsx
15
- * const slots = buildSlots(pageContent.pageAsset.containers, {
18
+ * const slots = await buildSlots(pageContent.pageAsset.containers, {
16
19
  * BlogList: BlogListContainer,
17
20
  * });
18
21
  *
19
22
  * <DotCMSLayoutBody page={pageAsset} components={pageComponents} slots={slots} />
20
23
  * ```
21
24
  */
22
- function buildSlots(containers, serverComponents) {
25
+ async function buildSlots(containers, serverComponents) {
23
26
  const slots = {};
24
27
  for (const {
25
28
  contentlets
@@ -28,7 +31,7 @@ function buildSlots(containers, serverComponents) {
28
31
  for (const contentlet of contentletList) {
29
32
  const Component = serverComponents[contentlet.contentType];
30
33
  if (Component && contentlet.identifier) {
31
- slots[contentlet.identifier] = Component(contentlet);
34
+ slots[contentlet.identifier] = await Component(contentlet);
32
35
  }
33
36
  }
34
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/react",
3
- "version": "1.2.6-next.3",
3
+ "version": "1.3.0-next.1",
4
4
  "peerDependencies": {
5
5
  "react": ">=18",
6
6
  "react-dom": ">=18"
@@ -22,7 +22,7 @@ export interface DotCMSLayoutBodyProps<TContentlet extends DotCMSBasicContentlet
22
22
  * <DotCMSLayoutBody page={pageAsset} components={pageComponents} slots={slots} />
23
23
  * ```
24
24
  */
25
- slots?: Record<string, ReactNode | Promise<ReactNode>>;
25
+ slots?: Record<string, ReactNode>;
26
26
  }
27
27
  /**
28
28
  * DotCMSLayoutBody component renders the layout body for a DotCMS page.
@@ -4,7 +4,7 @@ interface DotCMSPageProviderProps {
4
4
  page: DotCMSPageAsset;
5
5
  components: Record<string, React.ComponentType<any>>;
6
6
  mode: DotCMSPageRendererMode;
7
- slots: Record<string, ReactNode | Promise<ReactNode>>;
7
+ slots?: Record<string, ReactNode>;
8
8
  children: ReactNode;
9
9
  }
10
10
  /**
@@ -8,13 +8,13 @@ import { DotCMSBasicContentlet, DotCMSPageAsset, DotCMSPageRendererMode } from '
8
8
  * @property {DotCMSPageAsset} pageAsset - The DotCMS page asset
9
9
  * @property {RendererMode} mode - The renderer mode
10
10
  * @property {Record<string, React.ComponentType<DotCMSContentlet>>} userComponents - The user components
11
- * @property {Record<string, ReactNode | Promise<ReactNode>>} [slots] - Pre-rendered server component nodes keyed by contentlet identifier
11
+ * @property {Record<string, ReactNode>} [slots] - Pre-rendered server component nodes keyed by contentlet identifier
12
12
  */
13
13
  export interface DotCMSPageContextProps {
14
14
  pageAsset: DotCMSPageAsset;
15
15
  mode: DotCMSPageRendererMode;
16
16
  userComponents: Record<string, React.ComponentType<DotCMSBasicContentlet>>;
17
- slots?: Record<string, ReactNode | Promise<ReactNode>>;
17
+ slots?: Record<string, ReactNode>;
18
18
  }
19
19
  /**
20
20
  * The `PageContext` is a React context that provides access to the DotCMS page context.
@@ -7,18 +7,21 @@ import { DotCMSBasicContentlet, DotCMSPageAssetContainers } from '@dotcms/types'
7
7
  * (e.g., components that fetch data) within a DotCMS page layout. Pass the
8
8
  * resulting map to `DotCMSLayoutBody` via the `slots` prop.
9
9
  *
10
+ * Each component is awaited, so the returned record contains resolved `ReactNode`
11
+ * values — safe to pass as props to client components without `React.use()`.
12
+ *
10
13
  * @public
11
14
  * @param containers - The containers map from `pageAsset.containers`
12
15
  * @param serverComponents - A map of content type names to async server components
13
- * @returns A record mapping contentlet identifiers to pre-rendered ReactNodes
16
+ * @returns A promise resolving to a record mapping contentlet identifiers to pre-rendered ReactNodes
14
17
  *
15
18
  * @example
16
19
  * ```tsx
17
- * const slots = buildSlots(pageContent.pageAsset.containers, {
20
+ * const slots = await buildSlots(pageContent.pageAsset.containers, {
18
21
  * BlogList: BlogListContainer,
19
22
  * });
20
23
  *
21
24
  * <DotCMSLayoutBody page={pageAsset} components={pageComponents} slots={slots} />
22
25
  * ```
23
26
  */
24
- export declare function buildSlots(containers: DotCMSPageAssetContainers, serverComponents: Record<string, (props: DotCMSBasicContentlet) => ReactNode | Promise<ReactNode>>): Record<string, ReactNode | Promise<ReactNode>>;
27
+ export declare function buildSlots(containers: DotCMSPageAssetContainers, serverComponents: Record<string, (props: DotCMSBasicContentlet) => ReactNode | Promise<ReactNode>>): Promise<Record<string, ReactNode>>;