@dotcms/react 0.0.1-alpha.7 → 0.0.1-alpha.9

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/jest.config.ts +11 -0
  4. package/package.json +27 -30
  5. package/project.json +51 -0
  6. package/src/{index.d.ts → index.ts} +0 -1
  7. package/src/lib/components/Column/Column.module.css +99 -0
  8. package/src/lib/components/Column/Column.spec.tsx +78 -0
  9. package/src/lib/components/Column/Column.tsx +45 -0
  10. package/src/lib/components/Container/Container.module.css +7 -0
  11. package/src/lib/components/Container/Container.spec.tsx +82 -0
  12. package/src/lib/components/Container/Container.tsx +105 -0
  13. package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +7 -0
  14. package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +41 -0
  15. package/src/lib/components/DotcmsLayout/{DotcmsLayout.d.ts → DotcmsLayout.tsx} +19 -3
  16. package/src/lib/components/PageProvider/PageProvider.module.css +7 -0
  17. package/src/lib/components/PageProvider/PageProvider.spec.tsx +54 -0
  18. package/src/lib/components/PageProvider/{PageProvider.d.ts → PageProvider.tsx} +14 -1
  19. package/src/lib/components/Row/Row.module.css +5 -0
  20. package/src/lib/components/Row/Row.spec.tsx +92 -0
  21. package/src/lib/components/Row/Row.tsx +51 -0
  22. package/src/lib/contexts/PageContext.tsx +5 -0
  23. package/src/lib/hooks/useDotcmsEditor.spec.ts +56 -0
  24. package/src/lib/hooks/useDotcmsEditor.ts +29 -0
  25. package/src/lib/hooks/useDotcmsPageContext.spec.tsx +43 -0
  26. package/src/lib/hooks/{useDotcmsPageContext.d.ts → useDotcmsPageContext.tsx} +7 -1
  27. package/src/lib/mocks/mockPageContext.tsx +84 -0
  28. package/src/lib/utils/utils.ts +69 -0
  29. package/tsconfig.json +20 -0
  30. package/tsconfig.lib.json +23 -0
  31. package/tsconfig.spec.json +20 -0
  32. package/index.esm.d.ts +0 -1
  33. package/index.esm.js +0 -2912
  34. package/src/lib/components/Column/Column.d.ts +0 -5
  35. package/src/lib/components/Container/Container.d.ts +0 -5
  36. package/src/lib/components/Row/Row.d.ts +0 -25
  37. package/src/lib/contexts/PageContext.d.ts +0 -3
  38. package/src/lib/hooks/usePageEditor.d.ts +0 -50
  39. package/src/lib/mocks/mockPageContext.d.ts +0 -7
  40. package/src/lib/utils/utils.d.ts +0 -55
  41. /package/src/lib/mocks/{index.d.ts → index.ts} +0 -0
@@ -1,5 +0,0 @@
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,5 +0,0 @@
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,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,50 +0,0 @@
1
- /**
2
- * `PageEditorOptions` is an interface that defines the options for the `usePageEditor` hook.
3
- * It includes an optional `reloadFunction` that is called when the editor needs to reload the page to get changes,
4
- * and an optional `pathname` that represents the path of the page that the editor is editing.
5
- *
6
- * @interface PageEditorOptions
7
- *
8
- * @property {Function} reloadFunction - An optional function that is called when the editor needs to reload the page to get changes.
9
- * @property {string} pathname - An optional string that represents the path of the page that the editor is editing.
10
- */
11
- interface PageEditorOptions {
12
- /**
13
- * `reloadFunction` is an optional function that can be provided to the `PageEditorOptions` object.
14
- * It is called when the dotcms editor needs to reload the page to get changes.
15
- *
16
- * @property {Function} reloadFunction
17
- * @default window.location.reload
18
- * @memberof PageEditorOptions
19
- * @type {() => void}
20
- * @optional
21
- */
22
- reloadFunction?: () => void;
23
- /**
24
- * `pathname` is an optional string that can be provided to the `PageEditorOptions` object.
25
- * It represents the path of the page that the editor is editing.
26
- * When this path changes, the editor will update its own state and reload the page to get the changes.
27
- * @property {string} pathname
28
- * @memberof PageEditorOptions
29
- * @type {string}
30
- * @optional
31
- */
32
- pathname?: string;
33
- }
34
- /**
35
- * `usePageEditor` is a custom React hook that sets up the page editor for a DotCMS page.
36
- * It takes a `PageEditorOptions` object as a parameter and returns a reference to the rows of the page.
37
- *
38
- * This hook is the main brigde between your webapp and the dotcms page editor.
39
- *
40
- *
41
- * @category Hooks
42
- * @param {PageEditorOptions} props - The options for the page editor. Includes a `reloadFunction` and a `pathname`.
43
- * @returns {{rowsRef: React.RefObject<HTMLDivElement>[], isInsideEditor: boolean}} - Returns a reference to the rows of the page and a boolean that indicates if the page is inside the editor.
44
- * @throws {Error} - Throws an error if the `pathname` is not provided.
45
- */
46
- export declare const usePageEditor: (props: PageEditorOptions) => {
47
- rowsRef: React.MutableRefObject<HTMLDivElement[]>;
48
- isInsideEditor: boolean;
49
- };
50
- export {};
@@ -1,7 +0,0 @@
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;
@@ -1,55 +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
- };
51
- export declare const combineClasses: (classes: string[]) => string;
52
- export declare const getPositionStyleClasses: (start: number, end: number) => {
53
- startClass: string;
54
- endClass: string;
55
- };
File without changes