@dotcms/react 0.0.1-alpha.38 → 0.0.1-alpha.39

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 (64) hide show
  1. package/.babelrc +12 -0
  2. package/.eslintrc.json +18 -0
  3. package/jest.config.ts +11 -0
  4. package/package.json +4 -8
  5. package/project.json +56 -0
  6. package/src/lib/components/BlockEditorRenderer/BlockEditorRenderer.spec.tsx +51 -0
  7. package/src/lib/components/BlockEditorRenderer/{BlockEditorRenderer.d.ts → BlockEditorRenderer.tsx} +16 -2
  8. package/src/lib/components/BlockEditorRenderer/blocks/{Code.d.ts → Code.tsx} +14 -2
  9. package/src/lib/components/BlockEditorRenderer/blocks/{Contentlet.d.ts → Contentlet.tsx} +21 -1
  10. package/src/lib/components/BlockEditorRenderer/blocks/Image.tsx +18 -0
  11. package/src/lib/components/BlockEditorRenderer/blocks/{Lists.d.ts → Lists.tsx} +12 -3
  12. package/src/lib/components/BlockEditorRenderer/blocks/Table.tsx +60 -0
  13. package/src/lib/components/BlockEditorRenderer/blocks/Texts.tsx +126 -0
  14. package/src/lib/components/BlockEditorRenderer/blocks/Video.tsx +26 -0
  15. package/src/lib/components/BlockEditorRenderer/item/BlockEditorBlock.spec.tsx +634 -0
  16. package/src/lib/components/BlockEditorRenderer/item/BlockEditorBlock.tsx +146 -0
  17. package/src/lib/components/Column/Column.module.css +99 -0
  18. package/src/lib/components/Column/Column.spec.tsx +78 -0
  19. package/src/lib/components/Column/Column.tsx +59 -0
  20. package/src/lib/components/Container/Container.module.css +7 -0
  21. package/src/lib/components/Container/Container.spec.tsx +155 -0
  22. package/src/lib/components/Container/Container.tsx +122 -0
  23. package/src/lib/components/DotEditableText/DotEditableText.spec.tsx +232 -0
  24. package/src/lib/components/DotEditableText/DotEditableText.tsx +168 -0
  25. package/src/lib/components/DotEditableText/utils.ts +82 -0
  26. package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +7 -0
  27. package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +46 -0
  28. package/src/lib/components/DotcmsLayout/{DotcmsLayout.d.ts → DotcmsLayout.tsx} +18 -2
  29. package/src/lib/components/PageProvider/PageProvider.module.css +7 -0
  30. package/src/lib/components/PageProvider/PageProvider.spec.tsx +59 -0
  31. package/src/lib/components/PageProvider/{PageProvider.d.ts → PageProvider.tsx} +10 -1
  32. package/src/lib/components/Row/Row.module.css +5 -0
  33. package/src/lib/components/Row/Row.spec.tsx +92 -0
  34. package/src/lib/components/Row/Row.tsx +52 -0
  35. package/src/lib/contexts/{PageContext.d.ts → PageContext.tsx} +4 -2
  36. package/src/lib/hooks/useDotcmsEditor.spec.ts +176 -0
  37. package/src/lib/hooks/useDotcmsEditor.ts +94 -0
  38. package/src/lib/hooks/useDotcmsPageContext.spec.tsx +47 -0
  39. package/src/lib/hooks/{useDotcmsPageContext.d.ts → useDotcmsPageContext.tsx} +7 -1
  40. package/src/lib/mocks/mockPageContext.tsx +113 -0
  41. package/src/lib/models/{blocks.interface.d.ts → blocks.interface.ts} +19 -16
  42. package/src/lib/models/{content-node.interface.d.ts → content-node.interface.ts} +12 -4
  43. package/src/lib/models/{index.d.ts → index.ts} +5 -2
  44. package/src/lib/utils/utils.ts +89 -0
  45. package/tsconfig.json +20 -0
  46. package/tsconfig.lib.json +23 -0
  47. package/tsconfig.spec.json +20 -0
  48. package/index.esm.d.ts +0 -1
  49. package/index.esm.js +0 -5172
  50. package/src/lib/components/BlockEditorRenderer/blocks/Image.d.ts +0 -8
  51. package/src/lib/components/BlockEditorRenderer/blocks/Table.d.ts +0 -16
  52. package/src/lib/components/BlockEditorRenderer/blocks/Texts.d.ts +0 -71
  53. package/src/lib/components/BlockEditorRenderer/blocks/Video.d.ts +0 -8
  54. package/src/lib/components/BlockEditorRenderer/item/BlockEditorBlock.d.ts +0 -12
  55. package/src/lib/components/Column/Column.d.ts +0 -19
  56. package/src/lib/components/Container/Container.d.ts +0 -19
  57. package/src/lib/components/DotEditableText/DotEditableText.d.ts +0 -31
  58. package/src/lib/components/DotEditableText/utils.d.ts +0 -36
  59. package/src/lib/components/Row/Row.d.ts +0 -26
  60. package/src/lib/hooks/useDotcmsEditor.d.ts +0 -13
  61. package/src/lib/mocks/mockPageContext.d.ts +0 -8
  62. package/src/lib/utils/utils.d.ts +0 -43
  63. /package/src/{index.d.ts → index.ts} +0 -0
  64. /package/src/lib/mocks/{index.d.ts → index.ts} +0 -0
@@ -1,8 +0,0 @@
1
- import { ContentNode } from '../../../models/content-node.interface';
2
- /**
3
- * Renders an image component for dotCMS.
4
- *
5
- * @param props - The props for the DotCMSImage component.
6
- * @returns The rendered image component.
7
- */
8
- export declare const DotCMSImage: (props: ContentNode) => import("react/jsx-runtime").JSX.Element;
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { ContentNode } from '../../../models/content-node.interface';
3
- interface TableRendererProps {
4
- content: ContentNode[];
5
- blockEditorItem: React.FC<{
6
- content: ContentNode[];
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 {};
@@ -1,71 +0,0 @@
1
- import { BlockProps } from '../../../models/blocks.interface';
2
- import { ContentNode, HeadingProps, LinkProps, ParagraphProps } from '../../../models/content-node.interface';
3
- /**
4
- * Renders the text in bold.
5
- *
6
- * @param children - The content to be rendered in bold.
7
- */
8
- export declare const Bold: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
9
- /**
10
- * Renders the text in italic format.
11
- *
12
- * @param children - The content to be rendered in italic.
13
- */
14
- export declare const Italic: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
15
- /**
16
- * Renders a strike-through text.
17
- *
18
- * @param children - The content to be rendered within the strike-through element.
19
- */
20
- export declare const Strike: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
21
- /**
22
- * Renders an underline element for the given children.
23
- *
24
- * @param children - The content to be underlined.
25
- */
26
- export declare const Underline: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
27
- /**
28
- * Renders a paragraph element.
29
- *
30
- * @param children - The content of the paragraph.
31
- * @param attrs - The style attributes for the paragraph.
32
- * @returns The rendered paragraph element.
33
- */
34
- export declare const Paragraph: ({ children, attrs }: ParagraphProps) => import("react/jsx-runtime").JSX.Element;
35
- /**
36
- * Renders a link component.
37
- *
38
- * @param children - The content of the link.
39
- * @param attrs - The attributes to be applied to the link.
40
- * @returns The rendered link component.
41
- */
42
- export declare const Link: ({ children, attrs }: LinkProps) => import("react/jsx-runtime").JSX.Element;
43
- /**
44
- * Renders a heading element with the specified level.
45
- *
46
- * @param children - The content of the heading.
47
- * @param attrs - The attributes for the heading.
48
- * @returns The rendered heading element.
49
- */
50
- export declare const Heading: ({ children, attrs }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
51
- /**
52
- * Renders the superscript text.
53
- *
54
- * @param children - The content to be rendered as superscript.
55
- */
56
- export declare const Superscript: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
57
- /**
58
- * Renders a subscript element.
59
- *
60
- * @param children - The content to be rendered as subscript.
61
- */
62
- export declare const Subscript: ({ children }: BlockProps) => import("react/jsx-runtime").JSX.Element;
63
- type TextBlockProps = Omit<ContentNode, 'content' | 'attrs'>;
64
- /**
65
- * Renders a text block with optional marks.
66
- *
67
- * @param props - The props for the TextBlock component.
68
- * @returns The rendered text block.
69
- */
70
- export declare const TextBlock: (props: TextBlockProps) => string | import("react/jsx-runtime").JSX.Element | undefined;
71
- export {};
@@ -1,8 +0,0 @@
1
- import { ContentNode } from '../../../models/content-node.interface';
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: (props: ContentNode) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- import { ContentNode, CustomRenderer } from '../../../models/content-node.interface';
2
- /**
3
- * Renders a block editor item based on the provided content and custom renderers.
4
- *
5
- * @param content - The content nodes to render.
6
- * @param customRenderers - Optional custom renderers for specific node types.
7
- * @returns The rendered block editor item.
8
- */
9
- export declare const BlockEditorBlock: ({ content, customRenderers }: {
10
- content: ContentNode[];
11
- customRenderers?: CustomRenderer;
12
- }) => import("react/jsx-runtime").JSX.Element[];
@@ -1,19 +0,0 @@
1
- import { DotCMSPageContext } from '../../models';
2
- /**
3
- * Props for Column component to render a column with its containers.
4
- *
5
- * @export
6
- * @interface ColumnProps
7
- */
8
- export interface ColumnProps {
9
- readonly column: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0];
10
- }
11
- /**
12
- * Renders a Column with its containers using information provided by dotCMS Page API.
13
- *
14
- * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
15
- * @export
16
- * @param {ColumnProps} { column }
17
- * @return {JSX.Element} Rendered column with containers
18
- */
19
- export declare function Column({ column }: ColumnProps): import("react/jsx-runtime").JSX.Element;
@@ -1,19 +0,0 @@
1
- import { DotCMSPageContext } from '../../models';
2
- /**
3
- * Props for the Container component.
4
- *
5
- * @export
6
- * @interface ContainerProps
7
- */
8
- export interface ContainerProps {
9
- readonly containerRef: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0];
10
- }
11
- /**
12
- * Renders a Container with its content using information provided by dotCMS Page API.
13
- *
14
- * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
15
- * @export
16
- * @param {ContainerProps} { containerRef }
17
- * @return {JSX.Element} Rendered container with content
18
- */
19
- export declare function Container({ containerRef }: ContainerProps): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +0,0 @@
1
- /// <reference types="react" />
2
- import { DotEditableTextProps } from './utils';
3
- /**
4
- * Allows inline edit content pulled from dotCMS API using TinyMCE editor
5
- *
6
- * @export
7
- * @component
8
- * @param {Readonly<DotEditableTextProps>} props {
9
- * mode = 'plain',
10
- * format = 'text',
11
- * contentlet,
12
- * fieldName = ''
13
- * }
14
- * @example
15
- * ```javascript
16
- * import { DotEditableText } from '@dotcms/react';
17
- *
18
- * const MyContentletWithTitle = ({ contentlet }) => (
19
- * <h2>
20
- * <DotEditableText
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 DotEditableText({ mode, format, contentlet, fieldName }: Readonly<DotEditableTextProps>): JSX.Element;
31
- export default DotEditableText;
@@ -1,36 +0,0 @@
1
- import { IAllProps } from '@tinymce/tinymce-react';
2
- import { DotCMSContentlet } from '../../models';
3
- export type DOT_EDITABLE_TEXT_FORMAT = 'html' | 'text';
4
- export type DOT_EDITABLE_TEXT_MODE = 'minimal' | 'full' | 'plain';
5
- export interface DotEditableTextProps {
6
- /**
7
- * Represents the field name of the `contentlet` that can be edited
8
- *
9
- * @memberof DotEditableTextProps
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 DotEditableTextProps
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 DotEditableTextProps
24
- */
25
- mode?: DOT_EDITABLE_TEXT_MODE;
26
- /**
27
- * Represents the `contentlet` that can be inline edited
28
- *
29
- * @type {DotCMSContentlet}
30
- * @memberof DotEditableTextProps
31
- */
32
- contentlet: DotCMSContentlet;
33
- }
34
- export declare const TINYMCE_CONFIG: {
35
- [key in DOT_EDITABLE_TEXT_MODE]: IAllProps['init'];
36
- };
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- import { DotCMSPageContext } from '../../models';
3
- /**
4
- * Props for the row component
5
- *
6
- * @interface RowProps
7
- *
8
- */
9
- export interface RowProps {
10
- /**
11
- * Row data
12
- *
13
- * @type {DotCMSPageContext['layout']['body']['rows'][0]}
14
- * @memberof RowProps
15
- */
16
- row: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0];
17
- }
18
- /**
19
- * This component renders a row with all it's content using the layout provided by dotCMS Page API.
20
- *
21
- * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
22
- * @category Components
23
- * @param {React.ForwardedRef<HTMLDivElement, RowProps>} ref
24
- * @return {JSX.Element} Rendered rows with columns
25
- */
26
- export declare const Row: import("react").ForwardRefExoticComponent<RowProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,13 +0,0 @@
1
- import { DotcmsPageProps } from '../components/DotcmsLayout/DotcmsLayout';
2
- import { DotCMSPageContext } from '../models';
3
- /**
4
- * Custom Hook to handle the DotCMS editor interaction with the page.
5
- *
6
- * @category Hooks
7
- * @param {DotcmsPageProps} props {
8
- * pageContext,
9
- * config,
10
- * }
11
- * @returns {DotCMSPageContext} The context for a DotCMS page provided by the editor.
12
- */
13
- export declare const useDotcmsEditor: ({ pageContext, config }: DotcmsPageProps) => DotCMSPageContext;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { DotCMSPageContext, DotCMSContentlet } from '../models';
3
- export declare const dotcmsContentletMock: DotCMSContentlet;
4
- export declare const mockPageContext: DotCMSPageContext;
5
- export declare const MockContextRender: ({ children, mockContext }: {
6
- children: JSX.Element;
7
- mockContext: Partial<DotCMSPageContext>;
8
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,43 +0,0 @@
1
- import { ContainerData, DotCMSPageContext } from '../models';
2
- /**
3
- * Get the container data from the containers object using the current container reference obtained from the layout.
4
- *
5
- * @param {ContainerData} containers
6
- * @param {DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]} containerRef
7
- * @returns {Object} Container with all the data it has.
8
- */
9
- export declare const getContainersData: (containers: ContainerData, containerRef: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]) => {
10
- acceptTypes: string;
11
- contentlets: {
12
- contentType: string;
13
- identifier: string;
14
- title: string;
15
- inode: string;
16
- onNumberOfPages: number;
17
- widgetTitle?: string | undefined;
18
- baseType: string;
19
- }[];
20
- variantId: string;
21
- path: string;
22
- identifier: string;
23
- maxContentlets: number;
24
- parentPermissionable: Record<string, string>;
25
- };
26
- /**
27
- * Combine classes into a single string.
28
- *
29
- * @param {string[]} classes
30
- * @returns {string} Combined classes
31
- */
32
- export declare const combineClasses: (classes: string[]) => string;
33
- /**
34
- * Get the start and end classes for the column based on the left offset and width.
35
- *
36
- * @param {number} start
37
- * @param {number} end
38
- * @returns {Object} Start and end classes
39
- */
40
- export declare const getPositionStyleClasses: (start: number, end: number) => {
41
- startClass: string;
42
- endClass: string;
43
- };
File without changes
File without changes