@dotcms/react 0.0.1-beta.1 → 0.0.1-beta.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/README.md +24 -3
- package/es.regexp.to-string.esm.js +1878 -0
- package/index.esm.js +68 -1943
- package/next.esm.d.ts +1 -0
- package/next.esm.js +665 -0
- package/package.json +3 -2
- package/src/index.d.ts +1 -7
- package/src/lib/{components → deprecated/components}/DotcmsLayout/DotcmsLayout.d.ts +1 -0
- package/src/lib/deprecated/deprecated_api.d.ts +7 -0
- package/src/lib/next/__test__/mock.d.ts +11 -0
- package/src/lib/next/components/Column/Column.d.ts +37 -0
- package/src/lib/next/components/Container/Container.d.ts +32 -0
- package/src/lib/next/components/Container/ContainerFallbakcs.d.ts +24 -0
- package/src/lib/next/components/Contentlet/Contentlet.d.ts +32 -0
- package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +36 -0
- package/src/lib/next/components/DotCMSLayoutBody/components/ErrorMessage.d.ts +9 -0
- package/src/lib/next/components/FallbackComponent/FallbackComponent.d.ts +41 -0
- package/src/lib/next/components/Row/Row.d.ts +21 -0
- package/src/lib/next/contexts/DotCMSPageContext.d.ts +23 -0
- package/src/lib/next/hooks/useCheckVisibleContent.d.ts +24 -0
- package/src/lib/next/hooks/useIsDevMode.d.ts +13 -0
- package/src/lib/next/types.d.ts +421 -0
- package/src/lib/next/utils/index.d.ts +136 -0
- package/src/next.d.ts +1 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/BlockEditorRenderer.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Code.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Contentlet.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Image.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Lists.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Table.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Texts.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/blocks/Video.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/BlockEditorRenderer/item/BlockEditorBlock.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/Column/Column.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/Container/Container.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/DotEditableText/DotEditableText.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/DotEditableText/utils.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/PageProvider/PageProvider.d.ts +0 -0
- /package/src/lib/{components → deprecated/components}/Row/Row.d.ts +0 -0
- /package/src/lib/{contexts → deprecated/contexts}/PageContext.d.ts +0 -0
- /package/src/lib/{hooks → deprecated/hooks}/useCheckHaveContent.d.ts +0 -0
- /package/src/lib/{hooks → deprecated/hooks}/useDotcmsEditor.d.ts +0 -0
- /package/src/lib/{hooks → deprecated/hooks}/useDotcmsPageContext.d.ts +0 -0
- /package/src/lib/{mocks → deprecated/mocks}/index.d.ts +0 -0
- /package/src/lib/{mocks → deprecated/mocks}/mockPageContext.d.ts +0 -0
- /package/src/lib/{models → deprecated/models}/blocks.interface.d.ts +0 -0
- /package/src/lib/{models → deprecated/models}/content-node.interface.d.ts +0 -0
- /package/src/lib/{models → deprecated/models}/index.d.ts +0 -0
- /package/src/lib/{utils → deprecated/utils}/utils.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './components/DotcmsLayout/DotcmsLayout';
|
|
2
|
+
export * from './components/DotEditableText/DotEditableText';
|
|
3
|
+
export * from './components/PageProvider/PageProvider';
|
|
4
|
+
export * from './components/Row/Row';
|
|
5
|
+
export * from './hooks/useDotcmsPageContext';
|
|
6
|
+
export * from './components/BlockEditorRenderer/BlockEditorRenderer';
|
|
7
|
+
export * from './models/content-node.interface';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DotCMSColumnContainer, DotCMSPageAsset, DotPageAssetLayoutColumn } from '../types';
|
|
2
|
+
export declare const MOCK_COLUMN: DotPageAssetLayoutColumn;
|
|
3
|
+
export declare const MOCK_CONTAINER: DotCMSColumnContainer;
|
|
4
|
+
export declare const MOCK_PAGE_ASSET: DotCMSPageAsset;
|
|
5
|
+
export declare const EMPTY_PAGE_ASSET: DotCMSPageAsset;
|
|
6
|
+
export declare const MOCK_CONTAINER_DATA: {
|
|
7
|
+
uuid: string;
|
|
8
|
+
identifier: string;
|
|
9
|
+
acceptTypes: string;
|
|
10
|
+
maxContentlets: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DotPageAssetLayoutColumn } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Props for the Column component, which represents a single column in the grid layout system.
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @interface ColumnProps
|
|
9
|
+
* @property {DotPageAssetLayoutColumn} column - Column configuration from dotCMS Page API including
|
|
10
|
+
* width, leftOffset, styleClass, and containers
|
|
11
|
+
*/
|
|
12
|
+
export interface ColumnProps {
|
|
13
|
+
readonly column: DotPageAssetLayoutColumn;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*
|
|
18
|
+
* Renders a Column component that represents a single column in a 12-column grid system.
|
|
19
|
+
* The column's position and width are determined by the leftOffset and width properties
|
|
20
|
+
* from the dotCMS Page API. Uses CSS Grid classes for positioning.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Column column={{
|
|
25
|
+
* leftOffset: 0,
|
|
26
|
+
* width: 6,
|
|
27
|
+
* styleClass: "custom-class",
|
|
28
|
+
* containers: []
|
|
29
|
+
* }} />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
|
|
33
|
+
* @export
|
|
34
|
+
* @param {ColumnProps} { column } - Column configuration object
|
|
35
|
+
* @return {JSX.Element} Rendered column with its containers positioned in the grid
|
|
36
|
+
*/
|
|
37
|
+
export declare function Column({ column }: ColumnProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DotCMSColumnContainer } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Props for the Container component
|
|
6
|
+
* @interface DotCMSContainerRendererProps
|
|
7
|
+
* @property {DotCMSColumnContainer} container - The container data to be rendered
|
|
8
|
+
*/
|
|
9
|
+
type DotCMSContainerRendererProps = {
|
|
10
|
+
container: DotCMSColumnContainer;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*
|
|
15
|
+
* Container component that renders DotCMS containers and their contentlets.
|
|
16
|
+
* This component is responsible for:
|
|
17
|
+
* - Rendering container content based on DotCMS Page API data
|
|
18
|
+
* - Handling empty container states
|
|
19
|
+
* - Providing proper data attributes for DotCMS functionality
|
|
20
|
+
* - Managing container contentlets rendering
|
|
21
|
+
*
|
|
22
|
+
* @component
|
|
23
|
+
* @param {DotCMSContainerRendererProps} props - Component properties
|
|
24
|
+
* @returns {JSX.Element} Rendered container with its contentlets or empty state message
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Container container={containerData} />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function Container({ container }: DotCMSContainerRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DotContainerAttributes } from '../../utils';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Component to display when a container is not found in the system.
|
|
6
|
+
* Only renders in development mode for debugging purposes.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @param {Object} props - Component properties
|
|
10
|
+
* @param {string} props.identifier - Container identifier
|
|
11
|
+
* @returns {JSX.Element | null} Message about missing container or null in production
|
|
12
|
+
*/
|
|
13
|
+
export declare const ContainerNoFound: ({ identifier }: {
|
|
14
|
+
identifier: string;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*
|
|
19
|
+
* Component to display when a container is empty.
|
|
20
|
+
*
|
|
21
|
+
* @param {DotContainerAttributes} dotAttributes
|
|
22
|
+
* @return {*}
|
|
23
|
+
*/
|
|
24
|
+
export declare const EmptyContainer: (dotAttributes: DotContainerAttributes) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DotCMSContentlet } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Props for the Contentlet component
|
|
6
|
+
* @interface DotCMSContentletRendererProps
|
|
7
|
+
* @property {DotCMSContentlet} contentlet - The contentlet data to be rendered
|
|
8
|
+
* @property {string} container - The container identifier where the contentlet is placed
|
|
9
|
+
*/
|
|
10
|
+
interface DotCMSContentletRendererProps {
|
|
11
|
+
contentlet: DotCMSContentlet;
|
|
12
|
+
container: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Contentlet component that renders DotCMS content with development mode support
|
|
16
|
+
*
|
|
17
|
+
* @component
|
|
18
|
+
* @param {DotCMSContentletRendererProps} props - Component properties
|
|
19
|
+
* @param {DotCMSContentlet} props.contentlet - The contentlet to be rendered
|
|
20
|
+
* @param {string} props.container - The container identifier
|
|
21
|
+
* @returns {JSX.Element} Rendered contentlet with appropriate wrapper and attributes
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <Contentlet
|
|
26
|
+
* contentlet={myContentlet}
|
|
27
|
+
* container="container-1"
|
|
28
|
+
* />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function Contentlet({ contentlet, container }: DotCMSContentletRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DotCMSPageRendererMode } from '../../contexts/DotCMSPageContext';
|
|
3
|
+
import { DotCMSContentlet, DotCMSPageAsset } from '../../types';
|
|
4
|
+
interface DotCMSLayoutBodyProps {
|
|
5
|
+
page: DotCMSPageAsset;
|
|
6
|
+
components: Record<string, React.ComponentType<DotCMSContentlet>>;
|
|
7
|
+
mode?: DotCMSPageRendererMode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* DotCMSLayoutBody component renders the layout body for a DotCMS page.
|
|
11
|
+
*
|
|
12
|
+
* It utilizes the page asset's layout body to render rows using the Row component.
|
|
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.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @component
|
|
19
|
+
* @param {Object} props - Component properties.
|
|
20
|
+
* @param {DotCMSPageAsset} props.page - The DotCMS page asset containing the layout information.
|
|
21
|
+
* @param {Record<string, React.ComponentType<DotCMSContentlet>>} [props.components] - Optional mapping of custom components for content rendering.
|
|
22
|
+
* @param {DotCMSPageRendererMode} [props.mode='production'] - The renderer mode; defaults to 'production'. Alternate modes might trigger different behaviors.
|
|
23
|
+
*
|
|
24
|
+
* @returns {JSX.Element} The rendered DotCMS page body or an error message if the layout body is missing.
|
|
25
|
+
*
|
|
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
|
+
*/
|
|
35
|
+
export declare const DotCMSLayoutBody: ({ page, components, mode }: DotCMSLayoutBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DotCMSPageRendererMode } from '../../../contexts/DotCMSPageContext';
|
|
2
|
+
/**
|
|
3
|
+
* Error message component for when the page body is missing
|
|
4
|
+
*
|
|
5
|
+
* @return {JSX.Element} Error message component
|
|
6
|
+
*/
|
|
7
|
+
export declare const ErrorMessage: ({ mode }: {
|
|
8
|
+
mode: DotCMSPageRendererMode;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DotCMSContentlet } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Type definition for components that can be used as fallback when no matching component is found
|
|
7
|
+
*/
|
|
8
|
+
export type NoComponentType = React.ComponentType<DotCMSContentlet>;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*
|
|
12
|
+
* Props for the FallbackComponent
|
|
13
|
+
* @interface DotCMSFallbackComponentProps
|
|
14
|
+
* @property {React.ComponentType<DotCMSContentlet>} [UserNoComponent] - Optional custom component to render when no matching component is found
|
|
15
|
+
* @property {DotCMSContentlet} [contentlet] - The contentlet that couldn't be rendered
|
|
16
|
+
*/
|
|
17
|
+
interface DotCMSFallbackComponentProps {
|
|
18
|
+
contentlet: DotCMSContentlet;
|
|
19
|
+
UserNoComponent?: React.ComponentType<DotCMSContentlet>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*
|
|
24
|
+
* Renders a fallback component when no matching component is found for a content type
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
* @param {DotCMSFallbackComponentProps} props - Component properties
|
|
28
|
+
* @param {NoComponentType} [props.UserNoComponent] - Optional custom component to render
|
|
29
|
+
* @param {DotCMSContentlet} [props.contentlet] - The contentlet that couldn't be rendered
|
|
30
|
+
* @returns {JSX.Element} The rendered fallback component
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <FallbackComponent
|
|
35
|
+
* UserNoComponent={CustomNoComponent}
|
|
36
|
+
* contentlet={contentlet}
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function FallbackComponent({ UserNoComponent, contentlet }: DotCMSFallbackComponentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DotPageAssetLayoutRow } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Props for the Row component
|
|
6
|
+
* @interface DotCMSRowRendererProps
|
|
7
|
+
* @property {DotPageAssetLayoutRow} row - The row data to be rendered
|
|
8
|
+
*/
|
|
9
|
+
type DotCMSRowRendererProps = {
|
|
10
|
+
row: DotPageAssetLayoutRow;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* This component renders a row with all it's content using the layout provided by dotCMS Page API.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
|
|
16
|
+
* @category Components
|
|
17
|
+
* @param {React.ForwardedRef<HTMLDivElement, DotCMS>} ref
|
|
18
|
+
* @return {JSX.Element} Rendered rows with columns
|
|
19
|
+
*/
|
|
20
|
+
export declare const Row: ({ row }: DotCMSRowRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DotCMSContentlet, DotCMSPageAsset } from '../types';
|
|
3
|
+
export type DotCMSPageRendererMode = 'production' | 'development';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
* Props for the DotCMSPageContext
|
|
8
|
+
* @interface DotCMSPageContextProps
|
|
9
|
+
* @property {DotCMSPageAsset} pageAsset - The DotCMS page asset
|
|
10
|
+
* @property {RendererMode} mode - The renderer mode
|
|
11
|
+
* @property {Record<string, React.ComponentType<DotCMSContentlet>>} userComponents - The user components
|
|
12
|
+
*/
|
|
13
|
+
export interface DotCMSPageContextProps {
|
|
14
|
+
pageAsset: DotCMSPageAsset;
|
|
15
|
+
mode: DotCMSPageRendererMode;
|
|
16
|
+
userComponents: Record<string, React.ComponentType<DotCMSContentlet>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The `PageContext` is a React context that provides access to the DotCMS page context.
|
|
20
|
+
*
|
|
21
|
+
* @category Contexts
|
|
22
|
+
*/
|
|
23
|
+
export declare const DotCMSPageContext: import("react").Context<DotCMSPageContextProps>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* A custom React hook that checks whether a referenced HTMLDivElement has visible content based on its height.
|
|
5
|
+
*
|
|
6
|
+
* @param {RefObject<HTMLDivElement>} ref - A React ref object pointing to an HTMLDivElement.
|
|
7
|
+
* @returns {boolean} - Returns true if the element's height is greater than zero (indicating visible content), otherwise false.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { useRef } from 'react';
|
|
11
|
+
* import { useCheckVisibleContent } from 'src/lib/next/hooks/useCheckVisibleContent';
|
|
12
|
+
*
|
|
13
|
+
* function MyComponent() {
|
|
14
|
+
* const contentRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
* const isContentVisible = useCheckVisibleContent(contentRef);
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <div ref={contentRef}>
|
|
19
|
+
* {isContentVisible ? 'Content is visible' : 'Content is not visible'}
|
|
20
|
+
* </div>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export declare const useCheckVisibleContent: (ref: RefObject<HTMLDivElement>) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DotCMSPageRendererMode } from '../contexts/DotCMSPageContext';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* A React hook that determines if the current environment is in development mode.
|
|
5
|
+
*
|
|
6
|
+
* The hook returns `true` if either:
|
|
7
|
+
* - The context mode (or the optional `renderMode` argument) is set to 'development', or
|
|
8
|
+
* - The application is running inside the DotCMS editor (as determined by `isInsideEditor()`).
|
|
9
|
+
*
|
|
10
|
+
* @param {DotCMSPageRendererMode} [renderMode] - Optional override for the render mode.
|
|
11
|
+
* @returns {boolean} - `true` if in development mode or inside the editor; otherwise, `false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useIsDevMode: (renderMode?: DotCMSPageRendererMode) => boolean;
|