@dotcms/react 0.0.1-alpha.1 → 0.0.1-alpha.10
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 +16 -21
- package/index.esm.d.ts +1 -0
- package/index.esm.js +1927 -0
- package/package.json +6 -7
- package/src/index.d.ts +4 -5
- package/src/lib/components/Column/Column.d.ts +5 -7
- package/src/lib/components/Container/Container.d.ts +5 -6
- package/src/lib/components/DotcmsLayout/DotcmsLayout.d.ts +34 -32
- package/src/lib/components/PageProvider/PageProvider.d.ts +84 -81
- package/src/lib/components/Row/Row.d.ts +25 -25
- package/src/lib/contexts/PageContext.d.ts +3 -3
- package/src/lib/hooks/useDotcmsEditor.d.ts +2 -0
- package/src/lib/hooks/useDotcmsPageContext.d.ts +9 -9
- package/src/lib/mocks/index.d.ts +1 -1
- package/src/lib/mocks/mockPageContext.d.ts +7 -2
- package/src/lib/utils/utils.d.ts +22 -50
- package/index.js +0 -2413
- package/src/lib/hooks/usePageEditor.d.ts +0 -48
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.10",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"react": "
|
|
6
|
-
"react-dom": "
|
|
7
|
-
"@dotcms/client": "
|
|
5
|
+
"react": ">=18",
|
|
6
|
+
"react-dom": ">=18",
|
|
7
|
+
"@dotcms/client": "0.0.1-alpha.10"
|
|
8
8
|
},
|
|
9
9
|
"description": "Official React Components library to render a dotCMS page.",
|
|
10
10
|
"repository": {
|
|
@@ -26,8 +26,7 @@
|
|
|
26
26
|
"url": "https://github.com/dotCMS/core/issues"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/dotCMS/core/tree/master/core-web/libs/sdk/react/README.md",
|
|
29
|
-
"module": "./index.js",
|
|
30
|
-
"main": "./index.js",
|
|
29
|
+
"module": "./index.esm.js",
|
|
31
30
|
"type": "module",
|
|
32
|
-
"
|
|
31
|
+
"main": "./index.esm.js"
|
|
33
32
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from './lib/components/DotcmsLayout/DotcmsLayout';
|
|
2
|
-
export * from './lib/components/PageProvider/PageProvider';
|
|
3
|
-
export * from './lib/components/Row/Row';
|
|
4
|
-
export * from './lib/hooks/useDotcmsPageContext';
|
|
5
|
-
export * from './lib/hooks/usePageEditor';
|
|
1
|
+
export * from './lib/components/DotcmsLayout/DotcmsLayout';
|
|
2
|
+
export * from './lib/components/PageProvider/PageProvider';
|
|
3
|
+
export * from './lib/components/Row/Row';
|
|
4
|
+
export * from './lib/hooks/useDotcmsPageContext';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare function Column({ column }: ColumnProps): JSX.Element;
|
|
7
|
-
export {};
|
|
1
|
+
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
2
|
+
export interface ColumnProps {
|
|
3
|
+
readonly column: PageProviderContext['layout']['body']['rows'][0]['columns'][0];
|
|
4
|
+
}
|
|
5
|
+
export declare function Column({ column }: ColumnProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare function Container({ containerRef }: ContainerProps): JSX.Element;
|
|
1
|
+
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
2
|
+
export interface ContainerProps {
|
|
3
|
+
readonly containerRef: PageProviderContext['layout']['body']['rows'][0]['columns'][0]['containers'][0];
|
|
4
|
+
}
|
|
5
|
+
export declare function Container({ containerRef }: ContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DotCMSPageEditorConfig } from '@dotcms/client';
|
|
3
|
+
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
4
|
+
/**
|
|
5
|
+
* `DotcmsPageProps` is a type that defines the properties for the `DotcmsLayout` component.
|
|
6
|
+
* It includes a readonly `entity` property that represents the context for a DotCMS page.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} DotcmsPageProps
|
|
9
|
+
*
|
|
10
|
+
* @property {PageProviderContext} entity - The context for a DotCMS page.
|
|
11
|
+
* @readonly
|
|
12
|
+
*/
|
|
13
|
+
export type DotcmsPageProps = {
|
|
14
|
+
/**
|
|
15
|
+
* `entity` is a readonly property of the `DotcmsPageProps` type.
|
|
16
|
+
* It represents the context for a DotCMS page and is of type `PageProviderContext`.
|
|
17
|
+
*
|
|
18
|
+
* @property {PageProviderContext} entity
|
|
19
|
+
* @memberof DotcmsPageProps
|
|
20
|
+
* @type {PageProviderContext}
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
readonly entity: PageProviderContext;
|
|
24
|
+
readonly config?: DotCMSPageEditorConfig;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* `DotcmsLayout` is a functional component that renders a layout for a DotCMS page.
|
|
28
|
+
* It takes a `DotcmsPageProps` object as a parameter and returns a JSX element.
|
|
29
|
+
*
|
|
30
|
+
* @category Components
|
|
31
|
+
* @param {DotcmsPageProps} props - The properties for the DotCMS page.
|
|
32
|
+
* @returns {JSX.Element} - A JSX element that represents the layout for a DotCMS page.
|
|
33
|
+
*/
|
|
34
|
+
export declare function DotcmsLayout({ entity, config }: DotcmsPageProps): JSX.Element;
|
|
@@ -1,81 +1,84 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface PageProviderProps {
|
|
3
|
-
readonly entity: any;
|
|
4
|
-
readonly children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export interface ContainerData {
|
|
7
|
-
[key: string]: {
|
|
8
|
-
container: {
|
|
9
|
-
path: string;
|
|
10
|
-
identifier: string;
|
|
11
|
-
maxContentlets: number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
* It
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface PageProviderProps {
|
|
3
|
+
readonly entity: any;
|
|
4
|
+
readonly children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export interface ContainerData {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
container: {
|
|
9
|
+
path: string;
|
|
10
|
+
identifier: string;
|
|
11
|
+
maxContentlets: number;
|
|
12
|
+
parentPermissionable: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
containerStructures: {
|
|
15
|
+
contentTypeVar: string;
|
|
16
|
+
}[];
|
|
17
|
+
contentlets: {
|
|
18
|
+
[key: string]: {
|
|
19
|
+
contentType: string;
|
|
20
|
+
identifier: string;
|
|
21
|
+
title: string;
|
|
22
|
+
inode: string;
|
|
23
|
+
onNumberOfPages: number;
|
|
24
|
+
widgetTitle?: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface PageProviderContext {
|
|
30
|
+
/**
|
|
31
|
+
* `components` is a property of the `PageProviderProps` type.
|
|
32
|
+
* It is an object that maps content type variables to their corresponding React components.
|
|
33
|
+
*
|
|
34
|
+
* It will be use to render the contentlets in the page.
|
|
35
|
+
*
|
|
36
|
+
* @property {Object} components
|
|
37
|
+
* @memberof PageProviderProps
|
|
38
|
+
* @type {Object.<string, React.ElementType>}
|
|
39
|
+
*/
|
|
40
|
+
components: {
|
|
41
|
+
[contentTypeVariable: string]: React.ElementType;
|
|
42
|
+
};
|
|
43
|
+
containers: ContainerData;
|
|
44
|
+
layout: {
|
|
45
|
+
header: boolean;
|
|
46
|
+
footer: boolean;
|
|
47
|
+
body: {
|
|
48
|
+
rows: {
|
|
49
|
+
styleClass: string;
|
|
50
|
+
columns: {
|
|
51
|
+
styleClass: string;
|
|
52
|
+
width: number;
|
|
53
|
+
leftOffset: number;
|
|
54
|
+
containers: {
|
|
55
|
+
identifier: string;
|
|
56
|
+
uuid: string;
|
|
57
|
+
}[];
|
|
58
|
+
}[];
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
page: {
|
|
63
|
+
title: string;
|
|
64
|
+
identifier: string;
|
|
65
|
+
};
|
|
66
|
+
viewAs: {
|
|
67
|
+
language: {
|
|
68
|
+
id: string;
|
|
69
|
+
};
|
|
70
|
+
persona: {
|
|
71
|
+
keyTag: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
isInsideEditor: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* `PageProvider` is a functional component that provides a context for a DotCMS page.
|
|
78
|
+
* It takes a `PageProviderProps` object as a parameter and returns a JSX element.
|
|
79
|
+
*
|
|
80
|
+
* @category Components
|
|
81
|
+
* @param {PageProviderProps} props - The properties for the PageProvider. Includes an `entity` and `children`.
|
|
82
|
+
* @returns {JSX.Element} - A JSX element that provides a context for a DotCMS page.
|
|
83
|
+
*/
|
|
84
|
+
export declare function PageProvider(props: PageProviderProps): JSX.Element;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
3
|
-
/**
|
|
4
|
-
* Props for the row component
|
|
5
|
-
*
|
|
6
|
-
* @interface RowProps
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export interface RowProps {
|
|
10
|
-
/**
|
|
11
|
-
* Row data
|
|
12
|
-
*
|
|
13
|
-
* @type {PageProviderContext['layout']['body']['rows'][0]}
|
|
14
|
-
* @memberof RowProps
|
|
15
|
-
*/
|
|
16
|
-
row: PageProviderContext['layout']['body']['rows'][0];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Renders a row
|
|
20
|
-
*
|
|
21
|
-
* @category Components
|
|
22
|
-
* @param {React.ForwardedRef<HTMLDivElement, RowProps>} ref
|
|
23
|
-
* @return {*}
|
|
24
|
-
*/
|
|
25
|
-
export declare const Row: import("react").ForwardRefExoticComponent<RowProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the row component
|
|
5
|
+
*
|
|
6
|
+
* @interface RowProps
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export interface RowProps {
|
|
10
|
+
/**
|
|
11
|
+
* Row data
|
|
12
|
+
*
|
|
13
|
+
* @type {PageProviderContext['layout']['body']['rows'][0]}
|
|
14
|
+
* @memberof RowProps
|
|
15
|
+
*/
|
|
16
|
+
row: PageProviderContext['layout']['body']['rows'][0];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Renders a row
|
|
20
|
+
*
|
|
21
|
+
* @category Components
|
|
22
|
+
* @param {React.ForwardedRef<HTMLDivElement, RowProps>} ref
|
|
23
|
+
* @return {*}
|
|
24
|
+
*/
|
|
25
|
+
export declare const Row: import("react").ForwardRefExoticComponent<RowProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
3
|
-
export declare const PageContext: import("react").Context<PageProviderContext | null>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
3
|
+
export declare const PageContext: import("react").Context<PageProviderContext | null>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
2
|
-
/**
|
|
3
|
-
* `useDotcmsPageContext` is a custom React hook that provides access to the `PageProviderContext`.
|
|
4
|
-
* It takes no parameters and returns the context value or `null` if it's not available.
|
|
5
|
-
*
|
|
6
|
-
* @category Hooks
|
|
7
|
-
* @returns {PageProviderContext | null} - The context value or `null` if it's not available.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useDotcmsPageContext(): PageProviderContext | null;
|
|
1
|
+
import { PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
2
|
+
/**
|
|
3
|
+
* `useDotcmsPageContext` is a custom React hook that provides access to the `PageProviderContext`.
|
|
4
|
+
* It takes no parameters and returns the context value or `null` if it's not available.
|
|
5
|
+
*
|
|
6
|
+
* @category Hooks
|
|
7
|
+
* @returns {PageProviderContext | null} - The context value or `null` if it's not available.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useDotcmsPageContext(): PageProviderContext | null;
|
package/src/lib/mocks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './mockPageContext';
|
|
1
|
+
export * from './mockPageContext';
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
3
|
+
export declare const mockPageContext: PageProviderContext;
|
|
4
|
+
export declare const MockContextRender: ({ children, mockContext }: {
|
|
5
|
+
children: JSX.Element;
|
|
6
|
+
mockContext: Partial<PageProviderContext>;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
package/src/lib/utils/utils.d.ts
CHANGED
|
@@ -1,50 +1,22 @@
|
|
|
1
|
-
import { ContainerData, PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
payload: string | undefined;
|
|
24
|
-
}[];
|
|
25
|
-
}[];
|
|
26
|
-
}[];
|
|
27
|
-
}[];
|
|
28
|
-
export declare const getPageContainers: (containers: ContainerData) => {
|
|
29
|
-
identifier: string;
|
|
30
|
-
uuid: string;
|
|
31
|
-
contentletsId: string[];
|
|
32
|
-
}[];
|
|
33
|
-
export declare const getContainersData: (containers: ContainerData, containerRef: PageProviderContext['layout']['body']['rows'][0]['columns'][0]['containers'][0]) => {
|
|
34
|
-
acceptTypes: string;
|
|
35
|
-
contentlets: {
|
|
36
|
-
contentType: string;
|
|
37
|
-
identifier: string;
|
|
38
|
-
title: string;
|
|
39
|
-
inode: string;
|
|
40
|
-
widgetTitle?: string | undefined;
|
|
41
|
-
}[];
|
|
42
|
-
pageContainers: {
|
|
43
|
-
identifier: string;
|
|
44
|
-
uuid: string;
|
|
45
|
-
contentletsId: string[];
|
|
46
|
-
}[];
|
|
47
|
-
path: string;
|
|
48
|
-
identifier: string;
|
|
49
|
-
maxContentlets: number;
|
|
50
|
-
};
|
|
1
|
+
import { ContainerData, PageProviderContext } from '../components/PageProvider/PageProvider';
|
|
2
|
+
export declare const getContainersData: (containers: ContainerData, containerRef: PageProviderContext['layout']['body']['rows'][0]['columns'][0]['containers'][0]) => {
|
|
3
|
+
acceptTypes: string;
|
|
4
|
+
contentlets: {
|
|
5
|
+
contentType: string;
|
|
6
|
+
identifier: string;
|
|
7
|
+
title: string;
|
|
8
|
+
inode: string;
|
|
9
|
+
onNumberOfPages: number;
|
|
10
|
+
widgetTitle?: string | undefined;
|
|
11
|
+
}[];
|
|
12
|
+
variantId: string;
|
|
13
|
+
path: string;
|
|
14
|
+
identifier: string;
|
|
15
|
+
maxContentlets: number;
|
|
16
|
+
parentPermissionable: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
export declare const combineClasses: (classes: string[]) => string;
|
|
19
|
+
export declare const getPositionStyleClasses: (start: number, end: number) => {
|
|
20
|
+
startClass: string;
|
|
21
|
+
endClass: string;
|
|
22
|
+
};
|