@dotcms/react 0.0.1-beta.3 → 0.0.1-beta.30
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/README.md +165 -62
- package/index.esm.js +49 -2169
- package/next.esm.js +943 -249
- package/package.json +7 -4
- package/src/lib/deprecated/components/DotEditableText/DotEditableText.d.ts +1 -0
- package/src/lib/deprecated/components/DotcmsLayout/DotcmsLayout.d.ts +1 -0
- package/src/lib/deprecated/mocks/mockPageContext.d.ts +1 -0
- package/src/lib/next/__test__/mock.d.ts +2 -1
- package/src/lib/next/components/Column/Column.d.ts +1 -1
- package/src/lib/next/components/Container/Container.d.ts +1 -1
- package/src/lib/next/components/Container/{ContainerFallbakcs.d.ts → ContainerFallbacks.d.ts} +2 -2
- package/src/lib/next/components/Contentlet/Contentlet.d.ts +2 -2
- package/src/lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.d.ts +27 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/BlockEditorBlock.d.ts +15 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Code.d.ts +24 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Contentlet.d.ts +14 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Image.d.ts +10 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Lists.d.ts +26 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Table.d.ts +16 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Texts.d.ts +81 -0
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Video.d.ts +10 -0
- package/src/lib/next/components/DotCMSEditableText/DotCMSEditableText.d.ts +31 -0
- package/src/lib/next/components/DotCMSEditableText/utils.d.ts +36 -0
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +8 -17
- package/src/lib/next/components/DotCMSLayoutBody/components/ErrorMessage.d.ts +1 -4
- package/src/lib/next/components/DotCMSShow/DotCMSShow.d.ts +49 -0
- package/src/lib/next/components/FallbackComponent/FallbackComponent.d.ts +6 -6
- package/src/lib/next/components/Row/Row.d.ts +1 -1
- package/src/lib/next/contexts/DotCMSPageContext.d.ts +2 -3
- package/src/lib/next/hooks/useDotCMSShowWhen.d.ts +31 -0
- package/src/lib/next/hooks/useEditableDotCMSPage.d.ts +90 -0
- package/src/lib/next/hooks/useIsDevMode.d.ts +2 -5
- package/src/next.d.ts +5 -0
- package/web.url-search-params.size.esm.js +4216 -0
- package/es.regexp.to-string.esm.js +0 -1878
- package/src/lib/next/types.d.ts +0 -421
- package/src/lib/next/utils/index.d.ts +0 -136
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.30",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=18",
|
|
6
6
|
"react-dom": ">=18",
|
|
7
|
-
"@dotcms/client": "0.0.1-beta.
|
|
8
|
-
"@dotcms/uve": "0.0.1-beta.
|
|
9
|
-
"@tinymce/tinymce-react": "^
|
|
7
|
+
"@dotcms/client": "0.0.1-beta.30",
|
|
8
|
+
"@dotcms/uve": "0.0.1-beta.30",
|
|
9
|
+
"@tinymce/tinymce-react": "^6.0.0"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@dotcms/types": "next"
|
|
10
13
|
},
|
|
11
14
|
"description": "Official React Components library to render a dotCMS page.",
|
|
12
15
|
"repository": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DotCMSColumnContainer, DotCMSPageAsset, DotPageAssetLayoutColumn } from '
|
|
1
|
+
import { DotCMSColumnContainer, DotCMSPageAsset, DotPageAssetLayoutColumn, DotCMSBasicContentlet } from '@dotcms/types';
|
|
2
2
|
export declare const MOCK_COLUMN: DotPageAssetLayoutColumn;
|
|
3
3
|
export declare const MOCK_CONTAINER: DotCMSColumnContainer;
|
|
4
4
|
export declare const MOCK_PAGE_ASSET: DotCMSPageAsset;
|
|
@@ -9,3 +9,4 @@ export declare const MOCK_CONTAINER_DATA: {
|
|
|
9
9
|
acceptTypes: string;
|
|
10
10
|
maxContentlets: number;
|
|
11
11
|
};
|
|
12
|
+
export declare const MOCK_CONTENTLET: DotCMSBasicContentlet;
|
package/src/lib/next/components/Container/{ContainerFallbakcs.d.ts → ContainerFallbacks.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DotContainerAttributes } from '
|
|
1
|
+
import { DotContainerAttributes } from '@dotcms/types/internal';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*
|
|
@@ -10,7 +10,7 @@ import { DotContainerAttributes } from '../../utils';
|
|
|
10
10
|
* @param {string} props.identifier - Container identifier
|
|
11
11
|
* @returns {JSX.Element | null} Message about missing container or null in production
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const ContainerNotFound: ({ identifier }: {
|
|
14
14
|
identifier: string;
|
|
15
15
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
16
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import { DotCMSContentlet } from '../../types';
|
|
|
8
8
|
* @property {string} container - The container identifier where the contentlet is placed
|
|
9
9
|
*/
|
|
10
10
|
interface DotCMSContentletRendererProps {
|
|
11
|
-
contentlet:
|
|
11
|
+
contentlet: DotCMSBasicContentlet;
|
|
12
12
|
container: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockEditorContent } from '@dotcms/types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Custom Renderer used by the Block Editor Component
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @interface CustomRenderer
|
|
8
|
+
*/
|
|
9
|
+
export type CustomRenderer<T = any> = Record<string, React.FC<T>>;
|
|
10
|
+
export interface BlockEditorRendererProps {
|
|
11
|
+
blocks: BlockEditorContent;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
className?: string;
|
|
14
|
+
customRenderers?: CustomRenderer;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* BlockEditorRenderer component for rendering block editor field.
|
|
18
|
+
*
|
|
19
|
+
* @component
|
|
20
|
+
* @param {Object} props - The component props.
|
|
21
|
+
* @param {BlockEditorContent} props.blocks - The blocks of content to render.
|
|
22
|
+
* @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
|
|
23
|
+
* @param {string} [props.className] - Optional CSS class name for the container div.
|
|
24
|
+
* @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
|
|
25
|
+
* @returns {JSX.Element} A div containing the rendered blocks of content.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DotCMSBlockEditorRenderer: ({ blocks, style, className, customRenderers }: BlockEditorRendererProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
|
+
import { CustomRenderer } from '../DotCMSBlockEditorRenderer';
|
|
3
|
+
interface BlockEditorBlockProps {
|
|
4
|
+
content: BlockEditorNode[] | undefined;
|
|
5
|
+
customRenderers?: CustomRenderer;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a block editor item based on the provided content and custom renderers.
|
|
9
|
+
*
|
|
10
|
+
* @param content - The content nodes to render.
|
|
11
|
+
* @param customRenderers - Optional custom renderers for specific node types.
|
|
12
|
+
* @returns The rendered block editor item.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BlockEditorBlock: ({ content, customRenderers }: BlockEditorBlockProps) => import("react/jsx-runtime").JSX.Element[] | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
3
|
+
interface CodeBlockProps {
|
|
4
|
+
node: BlockEditorNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a code block component.
|
|
9
|
+
*
|
|
10
|
+
* @param attrs - The attributes of the code block.
|
|
11
|
+
* @param children - The content of the code block.
|
|
12
|
+
* @returns The rendered code block component.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CodeBlock: ({ node, children }: CodeBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a blockquote component.
|
|
17
|
+
*
|
|
18
|
+
* @param children - The content to be rendered inside the blockquote.
|
|
19
|
+
* @returns The rendered blockquote component.
|
|
20
|
+
*/
|
|
21
|
+
export declare const BlockQuote: ({ children }: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
|
+
import { CustomRenderer } from '../../DotCMSBlockEditorRenderer';
|
|
3
|
+
interface DotContentProps {
|
|
4
|
+
customRenderers: CustomRenderer;
|
|
5
|
+
node: BlockEditorNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders a DotContent component.
|
|
9
|
+
*
|
|
10
|
+
* @param {DotContentProps} props - The props for the DotContent component.
|
|
11
|
+
* @returns {JSX.Element} The rendered DotContent component.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DotContent: ({ customRenderers, node }: DotContentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders an image component for dotCMS.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The node for the DotCMSImage component.
|
|
6
|
+
* @returns The rendered image component.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DotCMSImage: ({ node }: {
|
|
9
|
+
node: BlockEditorNode;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ListItemProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* ListItem component represents a list item in a block editor.
|
|
7
|
+
*
|
|
8
|
+
* @param children - The content of the list item.
|
|
9
|
+
* @returns The rendered list item element.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ListItem: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* Renders an ordered list component.
|
|
14
|
+
*
|
|
15
|
+
* @param children - The content to be rendered inside the ordered list.
|
|
16
|
+
* @returns The ordered list component.
|
|
17
|
+
*/
|
|
18
|
+
export declare const OrderedList: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* Renders a bullet list component.
|
|
21
|
+
*
|
|
22
|
+
* @param children - The content of the bullet list.
|
|
23
|
+
* @returns The rendered bullet list component.
|
|
24
|
+
*/
|
|
25
|
+
export declare const BulletList: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
3
|
+
interface TableRendererProps {
|
|
4
|
+
content: BlockEditorNode[];
|
|
5
|
+
blockEditorItem: React.FC<{
|
|
6
|
+
content: BlockEditorNode[];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders a table component for the Block Editor.
|
|
11
|
+
*
|
|
12
|
+
* @param content - The content of the table.
|
|
13
|
+
* @param blockEditorItem - The Block Editor item component.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TableRenderer: React.FC<TableRendererProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockEditorMark, BlockEditorNode } from '@dotcms/types';
|
|
3
|
+
interface MarkProps extends BlockEditorMark {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
interface TextComponentProp {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
node: BlockEditorNode;
|
|
9
|
+
}
|
|
10
|
+
interface TextNodeProps {
|
|
11
|
+
marks?: BlockEditorMark[];
|
|
12
|
+
text?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Renders the text in bold.
|
|
16
|
+
*
|
|
17
|
+
* @param children - The content to be rendered in bold.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Bold: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Renders the text in italic format.
|
|
22
|
+
*
|
|
23
|
+
* @param children - The content to be rendered in italic.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Italic: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Renders a strike-through text.
|
|
28
|
+
*
|
|
29
|
+
* @param children - The content to be rendered within the strike-through element.
|
|
30
|
+
*/
|
|
31
|
+
export declare const Strike: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Renders an underline element for the given children.
|
|
34
|
+
*
|
|
35
|
+
* @param children - The content to be underlined.
|
|
36
|
+
*/
|
|
37
|
+
export declare const Underline: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* Renders a paragraph element.
|
|
40
|
+
*
|
|
41
|
+
* @param children - The content of the paragraph.
|
|
42
|
+
* @param attrs - The style attributes for the paragraph.
|
|
43
|
+
* @returns The rendered paragraph element.
|
|
44
|
+
*/
|
|
45
|
+
export declare const Paragraph: ({ children, node }: TextComponentProp) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
/**
|
|
47
|
+
* Renders a link component.
|
|
48
|
+
*
|
|
49
|
+
* @param children - The content of the link.
|
|
50
|
+
* @param attrs - The attributes to be applied to the link.
|
|
51
|
+
* @returns The rendered link component.
|
|
52
|
+
*/
|
|
53
|
+
export declare const Link: ({ children, attrs }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
/**
|
|
55
|
+
* Renders a heading element with the specified level.
|
|
56
|
+
*
|
|
57
|
+
* @param children - The content of the heading.
|
|
58
|
+
* @param attrs - The attributes for the heading.
|
|
59
|
+
* @returns The rendered heading element.
|
|
60
|
+
*/
|
|
61
|
+
export declare const Heading: ({ children, node }: TextComponentProp) => import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
/**
|
|
63
|
+
* Renders the superscript text.
|
|
64
|
+
*
|
|
65
|
+
* @param children - The content to be rendered as superscript.
|
|
66
|
+
*/
|
|
67
|
+
export declare const Superscript: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
/**
|
|
69
|
+
* Renders a subscript element.
|
|
70
|
+
*
|
|
71
|
+
* @param children - The content to be rendered as subscript.
|
|
72
|
+
*/
|
|
73
|
+
export declare const Subscript: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
/**
|
|
75
|
+
* Renders a text block with optional marks.
|
|
76
|
+
*
|
|
77
|
+
* @param props - The props for the TextBlock component.
|
|
78
|
+
* @returns The rendered text block.
|
|
79
|
+
*/
|
|
80
|
+
export declare const TextBlock: (props?: TextNodeProps) => string | import("react/jsx-runtime").JSX.Element | undefined;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a video component for displaying videos.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The properties for the video component.
|
|
6
|
+
* @returns The rendered video component.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DotCMSVideo: ({ node }: {
|
|
9
|
+
node: BlockEditorNode;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DotCMSEditableTextProps } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Allows inline edit content pulled from dotCMS API using TinyMCE editor
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @component
|
|
8
|
+
* @param {Readonly<DotCMSEditableTextProps>} props {
|
|
9
|
+
* mode = 'plain',
|
|
10
|
+
* format = 'text',
|
|
11
|
+
* contentlet,
|
|
12
|
+
* fieldName = ''
|
|
13
|
+
* }
|
|
14
|
+
* @example
|
|
15
|
+
* ```javascript
|
|
16
|
+
* import { DotCMSEditableText } from '@dotcms/react';
|
|
17
|
+
*
|
|
18
|
+
* const MyContentletWithTitle = ({ contentlet }) => (
|
|
19
|
+
* <h2>
|
|
20
|
+
* <DotCMSEditableText
|
|
21
|
+
* contentlet={contentlet}
|
|
22
|
+
* fieldName="title"
|
|
23
|
+
* mode='full'
|
|
24
|
+
* format='text'/>
|
|
25
|
+
* </h2>
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
* @returns {JSX.Element} A component to edit content inline
|
|
29
|
+
*/
|
|
30
|
+
export declare function DotCMSEditableText({ mode, format, contentlet, fieldName }: Readonly<DotCMSEditableTextProps>): JSX.Element;
|
|
31
|
+
export default DotCMSEditableText;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IAllProps } from '@tinymce/tinymce-react';
|
|
2
|
+
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
3
|
+
export type DOT_EDITABLE_TEXT_FORMAT = 'html' | 'text';
|
|
4
|
+
export type DOT_EDITABLE_TEXT_MODE = 'minimal' | 'full' | 'plain';
|
|
5
|
+
export interface DotCMSEditableTextProps {
|
|
6
|
+
/**
|
|
7
|
+
* Represents the field name of the `contentlet` that can be edited
|
|
8
|
+
*
|
|
9
|
+
* @memberof DotCMSEditableTextProps
|
|
10
|
+
*/
|
|
11
|
+
fieldName: string;
|
|
12
|
+
/**
|
|
13
|
+
* Represents the format of the editor which can be `text` or `html`
|
|
14
|
+
*
|
|
15
|
+
* @type {DOT_EDITABLE_TEXT_FORMAT}
|
|
16
|
+
* @memberof DotCMSEditableTextProps
|
|
17
|
+
*/
|
|
18
|
+
format?: DOT_EDITABLE_TEXT_FORMAT;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the mode of the editor which can be `plain`, `minimal`, or `full`
|
|
21
|
+
*
|
|
22
|
+
* @type {DOT_EDITABLE_TEXT_MODE}
|
|
23
|
+
* @memberof DotCMSEditableTextProps
|
|
24
|
+
*/
|
|
25
|
+
mode?: DOT_EDITABLE_TEXT_MODE;
|
|
26
|
+
/**
|
|
27
|
+
* Represents the `contentlet` that can be inline edited
|
|
28
|
+
*
|
|
29
|
+
* @type {DotCMSBasicContentlet}
|
|
30
|
+
* @memberof DotCMSEditableTextProps
|
|
31
|
+
*/
|
|
32
|
+
contentlet: DotCMSBasicContentlet;
|
|
33
|
+
}
|
|
34
|
+
export declare const TINYMCE_CONFIG: {
|
|
35
|
+
[key in DOT_EDITABLE_TEXT_MODE]: IAllProps['init'];
|
|
36
|
+
};
|
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DotCMSPageRendererMode } from '
|
|
3
|
-
|
|
4
|
-
interface DotCMSLayoutBodyProps {
|
|
2
|
+
import { DotCMSBasicContentlet, DotCMSPageAsset, DotCMSPageRendererMode } from '@dotcms/types';
|
|
3
|
+
interface DotCMSLayoutBodyProps<TContentlet extends DotCMSBasicContentlet = DotCMSBasicContentlet> {
|
|
5
4
|
page: DotCMSPageAsset;
|
|
6
|
-
components:
|
|
5
|
+
components: {
|
|
6
|
+
[key: string]: React.ComponentType<TContentlet> | React.ComponentType<any>;
|
|
7
|
+
};
|
|
7
8
|
mode?: DotCMSPageRendererMode;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* DotCMSLayoutBody component renders the layout body for a DotCMS page.
|
|
11
12
|
*
|
|
12
|
-
* It utilizes the page asset's layout body to render
|
|
13
|
-
* If the layout body does not exist, it renders an error message
|
|
14
|
-
* It also provides context (DotCMSPageContext) with the page asset, optional user components,
|
|
15
|
-
* and the renderer mode to its children.
|
|
13
|
+
* It utilizes the dotCMS page asset's layout body to render the page body.
|
|
14
|
+
* If the layout body does not exist, it renders an error message in the mode is `development`.
|
|
16
15
|
*
|
|
17
16
|
* @public
|
|
18
17
|
* @component
|
|
19
18
|
* @param {Object} props - Component properties.
|
|
20
19
|
* @param {DotCMSPageAsset} props.page - The DotCMS page asset containing the layout information.
|
|
21
|
-
* @param {Record<string, React.ComponentType<DotCMSContentlet>>} [props.components] -
|
|
20
|
+
* @param {Record<string, React.ComponentType<DotCMSContentlet>>} [props.components] - mapping of custom components for content rendering.
|
|
22
21
|
* @param {DotCMSPageRendererMode} [props.mode='production'] - The renderer mode; defaults to 'production'. Alternate modes might trigger different behaviors.
|
|
23
22
|
*
|
|
24
23
|
* @returns {JSX.Element} The rendered DotCMS page body or an error message if the layout body is missing.
|
|
25
24
|
*
|
|
26
|
-
* -------------------------------------------------------------------
|
|
27
|
-
*
|
|
28
|
-
* El componente DotCMSLayoutBody renderiza el cuerpo del layout para una página de DotCMS.
|
|
29
|
-
*
|
|
30
|
-
* Utiliza el "body" del layout del asset de la página para renderizar las filas mediante el componente Row.
|
|
31
|
-
* Si el "body" del layout no está presente, renderiza un mensaje de error.
|
|
32
|
-
* También provee un contexto (DotCMSPageContext) con el asset de la página, componentes de usuario opcionales,
|
|
33
|
-
* y el modo del renderizado para sus componentes hijos.
|
|
34
25
|
*/
|
|
35
26
|
export declare const DotCMSLayoutBody: ({ page, components, mode }: DotCMSLayoutBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
27
|
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { DotCMSPageRendererMode } from '../../../contexts/DotCMSPageContext';
|
|
2
1
|
/**
|
|
3
2
|
* Error message component for when the page body is missing
|
|
4
3
|
*
|
|
5
4
|
* @return {JSX.Element} Error message component
|
|
6
5
|
*/
|
|
7
|
-
export declare const ErrorMessage: (
|
|
8
|
-
mode: DotCMSPageRendererMode;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare const ErrorMessage: () => false | import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UVE_MODE } from '@dotcms/types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the DotCMSShow component.
|
|
5
|
+
*
|
|
6
|
+
* @typedef {Object} DotCMSShowProps
|
|
7
|
+
* @property {React.ReactNode} children - The children to be rendered when the condition is met.
|
|
8
|
+
* @property {UVE_MODE} [when=UVE_MODE.EDIT] - The UVE mode in which the children should be rendered.
|
|
9
|
+
*/
|
|
10
|
+
type DotCMSShowProps = {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
when?: UVE_MODE;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* DotCMSShow component is used to conditionally render its children
|
|
16
|
+
* based on the Universal Visual Editor (UVE) mode. It checks if the UVE
|
|
17
|
+
* is in a specified mode and only renders its children in that case.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props - The component props.
|
|
20
|
+
* @param {React.ReactNode} props.children - The children to be rendered when the condition is met.
|
|
21
|
+
* @param {UVE_MODE} [props.when=UVE_MODE.EDIT] - The UVE mode in which the children should be rendered.
|
|
22
|
+
* @returns {React.ReactNode | null} The children if the current UVE mode matches the `when` prop, otherwise null.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Basic usage: Render content only in edit mode
|
|
26
|
+
* <DotCMSShow when={UVE_MODE.EDIT}>
|
|
27
|
+
* <div>Edit Mode Content</div>
|
|
28
|
+
* </DotCMSShow>
|
|
29
|
+
*
|
|
30
|
+
* // This will render <div>Edit Mode Content</div> only if the UVE is in edit mode.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Render content in preview mode
|
|
34
|
+
* <DotCMSShow when={UVE_MODE.PREVIEW}>
|
|
35
|
+
* <MyCustomPreviewComponent />
|
|
36
|
+
* </DotCMSShow>
|
|
37
|
+
*
|
|
38
|
+
* // MyCustomPreviewComponent will only be rendered if the UVE is in preview mode.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Render content in live mode
|
|
42
|
+
* <DotCMSShow when={UVE_MODE.LIVE}>
|
|
43
|
+
* <LiveContentComponent />
|
|
44
|
+
* </DotCMSShow>
|
|
45
|
+
*
|
|
46
|
+
* // LiveContentComponent will only be rendered if the UVE is in live mode.
|
|
47
|
+
*/
|
|
48
|
+
export declare const DotCMSShow: ({ children, when }: DotCMSShowProps) => React.ReactNode | null;
|
|
49
|
+
export {};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*
|
|
6
6
|
* Type definition for components that can be used as fallback when no matching component is found
|
|
7
7
|
*/
|
|
8
|
-
export type NoComponentType = React.ComponentType<
|
|
8
|
+
export type NoComponentType = React.ComponentType<DotCMSBasicContentlet>;
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
*
|
|
12
12
|
* Props for the FallbackComponent
|
|
13
13
|
* @interface DotCMSFallbackComponentProps
|
|
14
|
-
* @property {React.ComponentType<
|
|
15
|
-
* @property {
|
|
14
|
+
* @property {React.ComponentType<DotCMSBasicContentlet>} [UserNoComponent] - Optional custom component to render when no matching component is found
|
|
15
|
+
* @property {DotCMSBasicContentlet} [contentlet] - The contentlet that couldn't be rendered
|
|
16
16
|
*/
|
|
17
17
|
interface DotCMSFallbackComponentProps {
|
|
18
|
-
contentlet:
|
|
19
|
-
UserNoComponent?: React.ComponentType<
|
|
18
|
+
contentlet: DotCMSBasicContentlet;
|
|
19
|
+
UserNoComponent?: React.ComponentType<DotCMSBasicContentlet>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* @internal
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export type DotCMSPageRendererMode = 'production' | 'development';
|
|
2
|
+
import { DotCMSBasicContentlet, DotCMSPageAsset, DotCMSPageRendererMode } from '@dotcms/types';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*
|
|
@@ -13,7 +12,7 @@ export type DotCMSPageRendererMode = 'production' | 'development';
|
|
|
13
12
|
export interface DotCMSPageContextProps {
|
|
14
13
|
pageAsset: DotCMSPageAsset;
|
|
15
14
|
mode: DotCMSPageRendererMode;
|
|
16
|
-
userComponents: Record<string, React.ComponentType<
|
|
15
|
+
userComponents: Record<string, React.ComponentType<DotCMSBasicContentlet>>;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* The `PageContext` is a React context that provides access to the DotCMS page context.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UVE_MODE } from '@dotcms/types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook to determine if the current UVE (Universal Visual Editor) mode
|
|
4
|
+
* matches the specified mode. This hook is useful for conditionally rendering
|
|
5
|
+
* components based on the UVE mode.
|
|
6
|
+
*
|
|
7
|
+
* @param {UVE_MODE} when - The UVE mode to check against.
|
|
8
|
+
* @returns {boolean} True if the current UVE mode matches the specified mode, otherwise false.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Basic usage: Check if the UVE is in edit mode
|
|
12
|
+
* const showInEditMode = useDotCMSShowWhen(UVE_MODE.EDIT);
|
|
13
|
+
* if (showInEditMode) {
|
|
14
|
+
* // Render edit-specific components
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Check if the UVE is in preview mode
|
|
19
|
+
* const showInPreviewMode = useDotCMSShowWhen(UVE_MODE.PREVIEW);
|
|
20
|
+
* if (showInPreviewMode) {
|
|
21
|
+
* // Render preview-specific components
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Check if the UVE is in live mode
|
|
26
|
+
* const showInLiveMode = useDotCMSShowWhen(UVE_MODE.LIVE);
|
|
27
|
+
* if (showInLiveMode) {
|
|
28
|
+
* // Render live-specific components
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export declare const useDotCMSShowWhen: (when: UVE_MODE) => boolean;
|