@dotcms/react 1.2.6-next.2 → 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.
@@ -1,8 +1,3 @@
1
1
  export { DotCMSLayoutBody } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.esm.js';
2
- export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow.esm.js';
3
- export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen.esm.js';
4
- export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage.esm.js';
5
- export { DotCMSBlockEditorRenderer } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.esm.js';
6
- export { useAISearch } from './lib/next/hooks/useAISearch.esm.js';
7
- export { useStyleEditorSchemas } from './lib/next/hooks/useStyleEditorSchemas.esm.js';
8
2
  export { buildSlots } from './lib/next/utils/buildSlots.esm.js';
3
+ export { DotCMSBlockEditorRenderer } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.esm.js';
@@ -67,7 +67,7 @@ function CustomComponent({
67
67
  userComponents,
68
68
  slots
69
69
  } = useContext(DotCMSPageContext);
70
- const slotNode = slots == null ? void 0 : slots[contentlet == null ? void 0 : contentlet.identifier];
70
+ const slotNode = contentlet != null && contentlet.identifier ? slots == null ? void 0 : slots[contentlet.identifier] : undefined;
71
71
  if (slotNode !== undefined) {
72
72
  return jsx(Fragment, {
73
73
  children: slotNode
@@ -1,5 +1,3 @@
1
- import { jsx } from 'react/jsx-runtime';
2
-
3
1
  /**
4
2
  * Builds a slots map of pre-rendered server component nodes keyed by contentlet identifier.
5
3
  *
@@ -7,23 +5,24 @@ import { jsx } from 'react/jsx-runtime';
7
5
  * (e.g., components that fetch data) within a DotCMS page layout. Pass the
8
6
  * resulting map to `DotCMSLayoutBody` via the `slots` prop.
9
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
+ *
10
11
  * @public
11
12
  * @param containers - The containers map from `pageAsset.containers`
12
13
  * @param serverComponents - A map of content type names to async server components
13
- * @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
14
15
  *
15
16
  * @example
16
17
  * ```tsx
17
- * const slots = buildSlots(pageContent.pageAsset.containers, {
18
+ * const slots = await buildSlots(pageContent.pageAsset.containers, {
18
19
  * BlogList: BlogListContainer,
19
20
  * });
20
21
  *
21
22
  * <DotCMSLayoutBody page={pageAsset} components={pageComponents} slots={slots} />
22
23
  * ```
23
24
  */
24
- function buildSlots(containers,
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- serverComponents) {
25
+ async function buildSlots(containers, serverComponents) {
27
26
  const slots = {};
28
27
  for (const {
29
28
  contentlets
@@ -31,8 +30,8 @@ serverComponents) {
31
30
  for (const contentletList of Object.values(contentlets)) {
32
31
  for (const contentlet of contentletList) {
33
32
  const Component = serverComponents[contentlet.contentType];
34
- if (Component) {
35
- slots[contentlet.identifier] = jsx(Component, Object.assign({}, contentlet));
33
+ if (Component && contentlet.identifier) {
34
+ slots[contentlet.identifier] = await Component(contentlet);
36
35
  }
37
36
  }
38
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/react",
3
- "version": "1.2.6-next.2",
3
+ "version": "1.3.0-next.1",
4
4
  "peerDependencies": {
5
5
  "react": ">=18",
6
6
  "react-dom": ">=18"
package/src/index.d.ts CHANGED
@@ -3,8 +3,9 @@ export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow';
3
3
  export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen';
4
4
  export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage';
5
5
  export { DotCMSEditableText } from './lib/next/components/DotCMSEditableText/DotCMSEditableText';
6
- export { DotCMSBlockEditorRenderer, BlockEditorRendererProps, CustomRenderer, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
7
- export { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
6
+ export { DotCMSBlockEditorRenderer, CustomRenderer } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
7
+ export type { BlockEditorRendererProps, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
8
+ export type { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
8
9
  export { useAISearch } from './lib/next/hooks/useAISearch';
9
10
  export { useStyleEditorSchemas } from './lib/next/hooks/useStyleEditorSchemas';
10
11
  export type { DotCMSAISearchValue, DotCMSAISearchProps } from './lib/next/shared/types';
@@ -1,11 +1,6 @@
1
1
  export { DotCMSLayoutBody } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
2
- export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow';
3
- export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen';
4
- export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage';
2
+ export type { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
3
+ export { buildSlots } from './lib/next/utils/buildSlots';
5
4
  export { DotCMSBlockEditorRenderer, CustomRenderer } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
6
5
  export type { BlockEditorRendererProps, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
7
- export type { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
8
- export { useAISearch } from './lib/next/hooks/useAISearch';
9
- export { useStyleEditorSchemas } from './lib/next/hooks/useStyleEditorSchemas';
10
6
  export type { DotCMSAISearchValue, DotCMSAISearchProps } from './lib/next/shared/types';
11
- export { buildSlots } from './lib/next/utils/buildSlots';
@@ -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>;
7
+ slots?: Record<string, ReactNode>;
8
8
  children: ReactNode;
9
9
  }
10
10
  /**
@@ -8,7 +8,7 @@ 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>} 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;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { DotCMSPageAssetContainers } from '@dotcms/types';
2
+ import { DotCMSBasicContentlet, DotCMSPageAssetContainers } from '@dotcms/types';
3
3
  /**
4
4
  * Builds a slots map of pre-rendered server component nodes keyed by contentlet identifier.
5
5
  *
@@ -7,18 +7,21 @@ import { 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, React.ComponentType<any>>): Record<string, ReactNode>;
27
+ export declare function buildSlots(containers: DotCMSPageAssetContainers, serverComponents: Record<string, (props: DotCMSBasicContentlet) => ReactNode | Promise<ReactNode>>): Promise<Record<string, ReactNode>>;