@dotcms/react 1.2.6-next.3 → 1.3.0-next.2
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.
- package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Image.esm.js +31 -4
- package/lib/next/utils/buildSlots.esm.js +7 -4
- package/package.json +1 -1
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +1 -1
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSPageProvider.d.ts +1 -1
- package/src/lib/next/contexts/DotCMSPageContext.d.ts +2 -2
- package/src/lib/next/utils/buildSlots.d.ts +6 -3
|
@@ -11,11 +11,38 @@ const DotCMSImage = ({
|
|
|
11
11
|
}) => {
|
|
12
12
|
const {
|
|
13
13
|
src,
|
|
14
|
-
alt
|
|
14
|
+
alt,
|
|
15
|
+
textWrap,
|
|
16
|
+
textAlign
|
|
15
17
|
} = node.attrs;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let wrapperStyle = {};
|
|
19
|
+
if (textWrap === 'left') {
|
|
20
|
+
wrapperStyle = {
|
|
21
|
+
float: 'left',
|
|
22
|
+
width: '50%',
|
|
23
|
+
margin: '0 1rem 1rem 0'
|
|
24
|
+
};
|
|
25
|
+
} else if (textWrap === 'right') {
|
|
26
|
+
wrapperStyle = {
|
|
27
|
+
float: 'right',
|
|
28
|
+
width: '50%',
|
|
29
|
+
margin: '0 0 1rem 1rem'
|
|
30
|
+
};
|
|
31
|
+
} else if (textAlign) {
|
|
32
|
+
wrapperStyle = {
|
|
33
|
+
textAlign: textAlign
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return jsx("figure", {
|
|
37
|
+
style: wrapperStyle,
|
|
38
|
+
children: jsx("img", {
|
|
39
|
+
alt: alt,
|
|
40
|
+
src: src,
|
|
41
|
+
style: textWrap ? {
|
|
42
|
+
maxWidth: '100%',
|
|
43
|
+
height: 'auto'
|
|
44
|
+
} : undefined
|
|
45
|
+
})
|
|
19
46
|
});
|
|
20
47
|
};
|
|
21
48
|
|
|
@@ -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
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
27
|
+
export declare function buildSlots(containers: DotCMSPageAssetContainers, serverComponents: Record<string, (props: DotCMSBasicContentlet) => ReactNode | Promise<ReactNode>>): Promise<Record<string, ReactNode>>;
|