@dotcms/react 0.0.1-alpha.1 → 0.0.1-alpha.11

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.
Files changed (41) hide show
  1. package/.babelrc +12 -0
  2. package/.eslintrc.json +18 -0
  3. package/README.md +16 -21
  4. package/jest.config.ts +11 -0
  5. package/package.json +27 -31
  6. package/project.json +51 -0
  7. package/src/{index.d.ts → index.ts} +4 -5
  8. package/src/lib/components/Column/Column.module.css +99 -0
  9. package/src/lib/components/Column/Column.spec.tsx +78 -0
  10. package/src/lib/components/Column/Column.tsx +45 -0
  11. package/src/lib/components/Container/Container.module.css +7 -0
  12. package/src/lib/components/Container/Container.spec.tsx +82 -0
  13. package/src/lib/components/Container/Container.tsx +106 -0
  14. package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +7 -0
  15. package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +41 -0
  16. package/src/lib/components/DotcmsLayout/{DotcmsLayout.d.ts → DotcmsLayout.tsx} +48 -32
  17. package/src/lib/components/PageProvider/PageProvider.module.css +7 -0
  18. package/src/lib/components/PageProvider/PageProvider.spec.tsx +54 -0
  19. package/src/lib/components/PageProvider/{PageProvider.d.ts → PageProvider.tsx} +95 -81
  20. package/src/lib/components/Row/Row.module.css +5 -0
  21. package/src/lib/components/Row/Row.spec.tsx +92 -0
  22. package/src/lib/components/Row/Row.tsx +51 -0
  23. package/src/lib/contexts/PageContext.tsx +5 -0
  24. package/src/lib/hooks/useDotcmsEditor.spec.ts +56 -0
  25. package/src/lib/hooks/useDotcmsEditor.ts +29 -0
  26. package/src/lib/hooks/useDotcmsPageContext.spec.tsx +43 -0
  27. package/src/lib/hooks/{useDotcmsPageContext.d.ts → useDotcmsPageContext.tsx} +15 -9
  28. package/src/lib/mocks/{index.d.ts → index.ts} +1 -1
  29. package/src/lib/mocks/mockPageContext.tsx +84 -0
  30. package/src/lib/utils/utils.ts +69 -0
  31. package/tsconfig.json +20 -0
  32. package/tsconfig.lib.json +23 -0
  33. package/tsconfig.spec.json +20 -0
  34. package/index.js +0 -2413
  35. package/src/lib/components/Column/Column.d.ts +0 -7
  36. package/src/lib/components/Container/Container.d.ts +0 -6
  37. package/src/lib/components/Row/Row.d.ts +0 -25
  38. package/src/lib/contexts/PageContext.d.ts +0 -3
  39. package/src/lib/hooks/usePageEditor.d.ts +0 -48
  40. package/src/lib/mocks/mockPageContext.d.ts +0 -2
  41. package/src/lib/utils/utils.d.ts +0 -50
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { PageProviderContext } from '../PageProvider/PageProvider';
3
- interface ColumnProps {
4
- readonly column: PageProviderContext['layout']['body']['rows'][0]['columns'][0];
5
- }
6
- export declare function Column({ column }: ColumnProps): JSX.Element;
7
- export {};
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { PageProviderContext } from '../PageProvider/PageProvider';
3
- export interface ContainerProps {
4
- readonly containerRef: PageProviderContext['layout']['body']['rows'][0]['columns'][0]['containers'][0];
5
- }
6
- export declare function Container({ containerRef }: ContainerProps): JSX.Element;
@@ -1,25 +0,0 @@
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 +0,0 @@
1
- /// <reference types="react" />
2
- import { PageProviderContext } from '../components/PageProvider/PageProvider';
3
- export declare const PageContext: import("react").Context<PageProviderContext | null>;
@@ -1,48 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * `PageEditorOptions` is an interface that defines the options for the `usePageEditor` hook.
4
- * It includes an optional `reloadFunction` that is called when the editor needs to reload the page to get changes,
5
- * and an optional `pathname` that represents the path of the page that the editor is editing.
6
- *
7
- * @interface PageEditorOptions
8
- *
9
- * @property {Function} reloadFunction - An optional function that is called when the editor needs to reload the page to get changes.
10
- * @property {string} pathname - An optional string that represents the path of the page that the editor is editing.
11
- */
12
- interface PageEditorOptions {
13
- /**
14
- * `reloadFunction` is an optional function that can be provided to the `PageEditorOptions` object.
15
- * It is called when the dotcms editor needs to reload the page to get changes.
16
- *
17
- * @property {Function} reloadFunction
18
- * @default window.location.reload
19
- * @memberof PageEditorOptions
20
- * @type {() => void}
21
- * @optional
22
- */
23
- reloadFunction?: () => void;
24
- /**
25
- * `pathname` is an optional string that can be provided to the `PageEditorOptions` object.
26
- * It represents the path of the page that the editor is editing.
27
- * When this path changes, the editor will update its own state and reload the page to get the changes.
28
- * @property {string} pathname
29
- * @memberof PageEditorOptions
30
- * @type {string}
31
- * @optional
32
- */
33
- pathname?: string;
34
- }
35
- /**
36
- * `usePageEditor` is a custom React hook that sets up the page editor for a DotCMS page.
37
- * It takes a `PageEditorOptions` object as a parameter and returns a reference to the rows of the page.
38
- *
39
- * This hook is the main brigde between your webapp and the dotcms page editor.
40
- *
41
- *
42
- * @category Hooks
43
- * @param {PageEditorOptions} props - The options for the page editor. Includes a `reloadFunction` and a `pathname`.
44
- * @returns {React.RefObject<HTMLDivElement>[]} - A reference to the rows of the page.
45
- * @throws {Error} - Throws an error if the `pathname` is not provided.
46
- */
47
- export declare const usePageEditor: (props: PageEditorOptions) => import("react").MutableRefObject<HTMLDivElement[]>;
48
- export {};
@@ -1,2 +0,0 @@
1
- import { PageProviderContext } from '../components/PageProvider/PageProvider';
2
- export declare const mockPageContext: PageProviderContext;
@@ -1,50 +0,0 @@
1
- import { ContainerData, PageProviderContext } from '../components/PageProvider/PageProvider';
2
- export declare function getPageElementBound(rowsNodes: HTMLDivElement[] | null): {
3
- x: number;
4
- y: number;
5
- width: number;
6
- height: number;
7
- columns: {
8
- x: number;
9
- y: number;
10
- width: number;
11
- height: number;
12
- containers: {
13
- x: number;
14
- y: number;
15
- width: number;
16
- height: number;
17
- payload: string | undefined;
18
- contentlets: {
19
- x: number;
20
- y: number;
21
- width: number;
22
- height: number;
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
- };