@dotcms/react 0.0.1-alpha.9 → 0.0.1-beta.1
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 +0 -1
- package/index.esm.d.ts +1 -0
- package/index.esm.js +5336 -0
- package/package.json +33 -28
- package/src/{index.ts → index.d.ts} +3 -0
- package/src/lib/components/BlockEditorRenderer/BlockEditorRenderer.d.ts +37 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Code.d.ts +17 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Contentlet.d.ts +41 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Image.d.ts +8 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Lists.d.ts +22 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Table.d.ts +16 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Texts.d.ts +71 -0
- package/src/lib/components/BlockEditorRenderer/blocks/Video.d.ts +8 -0
- package/src/lib/components/BlockEditorRenderer/item/BlockEditorBlock.d.ts +12 -0
- package/src/lib/components/Column/Column.d.ts +19 -0
- package/src/lib/components/Container/Container.d.ts +19 -0
- package/src/lib/components/DotEditableText/DotEditableText.d.ts +30 -0
- package/src/lib/components/DotEditableText/utils.d.ts +36 -0
- package/src/lib/components/DotcmsLayout/{DotcmsLayout.tsx → DotcmsLayout.d.ts} +8 -23
- package/src/lib/components/PageProvider/PageProvider.d.ts +14 -0
- package/src/lib/components/Row/Row.d.ts +26 -0
- package/src/lib/contexts/PageContext.d.ts +8 -0
- package/src/lib/hooks/useCheckHaveContent.d.ts +5 -0
- package/src/lib/hooks/useDotcmsEditor.d.ts +13 -0
- package/src/lib/hooks/useDotcmsPageContext.d.ts +9 -0
- package/src/lib/mocks/mockPageContext.d.ts +7 -0
- package/src/lib/models/blocks.interface.d.ts +89 -0
- package/src/lib/models/content-node.interface.d.ts +82 -0
- package/src/lib/models/index.d.ts +127 -0
- package/src/lib/utils/utils.d.ts +58 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/jest.config.ts +0 -11
- package/project.json +0 -51
- package/src/lib/components/Column/Column.module.css +0 -99
- package/src/lib/components/Column/Column.spec.tsx +0 -78
- package/src/lib/components/Column/Column.tsx +0 -45
- package/src/lib/components/Container/Container.module.css +0 -7
- package/src/lib/components/Container/Container.spec.tsx +0 -82
- package/src/lib/components/Container/Container.tsx +0 -105
- package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +0 -7
- package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +0 -41
- package/src/lib/components/PageProvider/PageProvider.module.css +0 -7
- package/src/lib/components/PageProvider/PageProvider.spec.tsx +0 -54
- package/src/lib/components/PageProvider/PageProvider.tsx +0 -95
- package/src/lib/components/Row/Row.module.css +0 -5
- package/src/lib/components/Row/Row.spec.tsx +0 -92
- package/src/lib/components/Row/Row.tsx +0 -51
- package/src/lib/contexts/PageContext.tsx +0 -5
- package/src/lib/hooks/useDotcmsEditor.spec.ts +0 -56
- package/src/lib/hooks/useDotcmsEditor.ts +0 -29
- package/src/lib/hooks/useDotcmsPageContext.spec.tsx +0 -43
- package/src/lib/hooks/useDotcmsPageContext.tsx +0 -15
- package/src/lib/mocks/mockPageContext.tsx +0 -84
- package/src/lib/utils/utils.ts +0 -69
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -23
- package/tsconfig.spec.json +0 -20
- /package/src/lib/mocks/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ContentNode } from './content-node.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Block of content provided by the Block Editor
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @interface Block
|
|
8
|
+
*/
|
|
9
|
+
export interface Block {
|
|
10
|
+
content: ContentNode[];
|
|
11
|
+
type: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Props for a contentlet inside the Block Editor
|
|
15
|
+
*
|
|
16
|
+
* @export
|
|
17
|
+
* @interface DotContentletProps
|
|
18
|
+
*/
|
|
19
|
+
export interface DotContentletProps {
|
|
20
|
+
title: string;
|
|
21
|
+
baseType: string;
|
|
22
|
+
inode: string;
|
|
23
|
+
archived: boolean;
|
|
24
|
+
working: boolean;
|
|
25
|
+
locked: boolean;
|
|
26
|
+
contentType: string;
|
|
27
|
+
live: boolean;
|
|
28
|
+
identifier: string;
|
|
29
|
+
image: string;
|
|
30
|
+
imageContentAsset: string;
|
|
31
|
+
urlTitle: string;
|
|
32
|
+
url: string;
|
|
33
|
+
titleImage: string;
|
|
34
|
+
urlMap: string;
|
|
35
|
+
hasLiveVersion: boolean;
|
|
36
|
+
hasTitleImage: boolean;
|
|
37
|
+
sortOrder: number;
|
|
38
|
+
modUser: string;
|
|
39
|
+
__icon__: string;
|
|
40
|
+
contentTypeIcon: string;
|
|
41
|
+
language: string;
|
|
42
|
+
description: string;
|
|
43
|
+
shortDescription: string;
|
|
44
|
+
salePrice: string;
|
|
45
|
+
retailPrice: string;
|
|
46
|
+
mimeType: string;
|
|
47
|
+
thumbnail?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Props for a block inside the Block Editor Component
|
|
51
|
+
*
|
|
52
|
+
* @export
|
|
53
|
+
* @interface BlockProps
|
|
54
|
+
*/
|
|
55
|
+
export interface BlockProps {
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Represents the different types of Blocks that can be used in the Block Editor
|
|
60
|
+
*
|
|
61
|
+
* @export
|
|
62
|
+
* @enum {number}
|
|
63
|
+
*/
|
|
64
|
+
export declare enum Blocks {
|
|
65
|
+
PARAGRAPH = "paragraph",
|
|
66
|
+
HEADING = "heading",
|
|
67
|
+
TEXT = "text",
|
|
68
|
+
BULLET_LIST = "bulletList",
|
|
69
|
+
ORDERED_LIST = "orderedList",
|
|
70
|
+
LIST_ITEM = "listItem",
|
|
71
|
+
BLOCK_QUOTE = "blockquote",
|
|
72
|
+
CODE_BLOCK = "codeBlock",
|
|
73
|
+
HARDBREAK = "hardBreak",
|
|
74
|
+
HORIZONTAL_RULE = "horizontalRule",
|
|
75
|
+
DOT_IMAGE = "dotImage",
|
|
76
|
+
DOT_VIDEO = "dotVideo",
|
|
77
|
+
TABLE = "table",
|
|
78
|
+
DOT_CONTENT = "dotContent"
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents the validation state of a Block Editor instance
|
|
82
|
+
*
|
|
83
|
+
* @interface BlockEditorState
|
|
84
|
+
* @property {boolean} isValid - Whether the blocks structure is valid
|
|
85
|
+
* @property {string | null} error - Error message if blocks are invalid, null otherwise
|
|
86
|
+
*/
|
|
87
|
+
export interface BlockEditorState {
|
|
88
|
+
error: string | null;
|
|
89
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockProps } from './blocks.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Mark used by text content in the Block Editor
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @interface Mark
|
|
8
|
+
*/
|
|
9
|
+
export interface Mark {
|
|
10
|
+
type: string;
|
|
11
|
+
attrs: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents a Content Node used by the Block Editor
|
|
15
|
+
*
|
|
16
|
+
* @export
|
|
17
|
+
* @interface ContentNode
|
|
18
|
+
*/
|
|
19
|
+
export interface ContentNode {
|
|
20
|
+
type: string;
|
|
21
|
+
content: ContentNode[];
|
|
22
|
+
attrs?: Record<string, string>;
|
|
23
|
+
marks?: Mark[];
|
|
24
|
+
text?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Represents a Custom Renderer used by the Block Editor Component
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
* @interface CustomRenderer
|
|
31
|
+
*/
|
|
32
|
+
export type CustomRenderer<T = any> = Record<string, React.FC<T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Represents a CodeBlock used by the Block Editor Component
|
|
35
|
+
* @export
|
|
36
|
+
* @interface CodeBlockProps
|
|
37
|
+
*/
|
|
38
|
+
export type CodeBlockProps = BlockProps & ContentNode;
|
|
39
|
+
/**
|
|
40
|
+
* Represents a Heading used by the Block Editor Component
|
|
41
|
+
* @export
|
|
42
|
+
* @interface HeadingProps
|
|
43
|
+
*/
|
|
44
|
+
export type HeadingProps = BlockProps & ContentNode;
|
|
45
|
+
/**
|
|
46
|
+
* Represents a Link used by the Block Editor Component
|
|
47
|
+
* @export
|
|
48
|
+
* @interface LinkProps
|
|
49
|
+
*/
|
|
50
|
+
export type LinkProps = BlockProps & {
|
|
51
|
+
attrs?: Mark['attrs'];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Represents a Paragraph used by the Block Editor Component
|
|
55
|
+
* @export
|
|
56
|
+
* @interface ParagraphProps
|
|
57
|
+
*/
|
|
58
|
+
export type ParagraphProps = BlockProps & ContentNode;
|
|
59
|
+
/**
|
|
60
|
+
* Represents a DotCMSVideo used by the Block Editor Component
|
|
61
|
+
* @export
|
|
62
|
+
* @interface DotCMSVideoProps
|
|
63
|
+
*/
|
|
64
|
+
export type DotCMSVideoProps = ContentNode['attrs'] & {
|
|
65
|
+
data?: Record<string, string>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Represents a DotCMSImage used by the Block Editor Component
|
|
69
|
+
* @export
|
|
70
|
+
* @interface DotCMSImageProps
|
|
71
|
+
*/
|
|
72
|
+
export type DotCMSImageProps = ContentNode['attrs'] & {
|
|
73
|
+
data?: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Represents a DotContent used by the Block Editor Component
|
|
77
|
+
* @export
|
|
78
|
+
* @interface DotContentProps
|
|
79
|
+
*/
|
|
80
|
+
export type DotContentProps = ContentNode & {
|
|
81
|
+
customRenderers?: CustomRenderer;
|
|
82
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ContainerData {
|
|
3
|
+
[key: string]: {
|
|
4
|
+
container: {
|
|
5
|
+
path: string;
|
|
6
|
+
identifier: string;
|
|
7
|
+
maxContentlets: number;
|
|
8
|
+
parentPermissionable: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
containerStructures: {
|
|
11
|
+
contentTypeVar: string;
|
|
12
|
+
}[];
|
|
13
|
+
contentlets: {
|
|
14
|
+
[key: string]: {
|
|
15
|
+
contentType: string;
|
|
16
|
+
identifier: string;
|
|
17
|
+
title: string;
|
|
18
|
+
inode: string;
|
|
19
|
+
onNumberOfPages: number;
|
|
20
|
+
widgetTitle?: string;
|
|
21
|
+
baseType: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface DotCMSPageContext {
|
|
27
|
+
/**
|
|
28
|
+
* `components` is a property of the `PageProviderProps` type.
|
|
29
|
+
* It is an object that maps content type variables to their corresponding React components.
|
|
30
|
+
*
|
|
31
|
+
* It will be use to render the contentlets in the page.
|
|
32
|
+
*
|
|
33
|
+
* @property {Object} components
|
|
34
|
+
* @memberof PageProviderProps
|
|
35
|
+
* @type {Object.<string, React.ElementType>}
|
|
36
|
+
*/
|
|
37
|
+
components: {
|
|
38
|
+
[contentTypeVariable: string]: React.ElementType;
|
|
39
|
+
};
|
|
40
|
+
pageAsset: {
|
|
41
|
+
containers: ContainerData;
|
|
42
|
+
layout: {
|
|
43
|
+
header: boolean;
|
|
44
|
+
footer: boolean;
|
|
45
|
+
body: {
|
|
46
|
+
rows: {
|
|
47
|
+
styleClass: string;
|
|
48
|
+
columns: {
|
|
49
|
+
styleClass: string;
|
|
50
|
+
width: number;
|
|
51
|
+
leftOffset: number;
|
|
52
|
+
containers: {
|
|
53
|
+
identifier: string;
|
|
54
|
+
uuid: string;
|
|
55
|
+
}[];
|
|
56
|
+
}[];
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
page: {
|
|
61
|
+
title: string;
|
|
62
|
+
identifier: string;
|
|
63
|
+
};
|
|
64
|
+
viewAs: {
|
|
65
|
+
language: {
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
persona: {
|
|
69
|
+
keyTag: string;
|
|
70
|
+
};
|
|
71
|
+
variantId: string;
|
|
72
|
+
};
|
|
73
|
+
vanityUrl?: {
|
|
74
|
+
pattern: string;
|
|
75
|
+
vanityUrlId: string;
|
|
76
|
+
url: string;
|
|
77
|
+
siteId: string;
|
|
78
|
+
languageId: number;
|
|
79
|
+
forwardTo: string;
|
|
80
|
+
response: number;
|
|
81
|
+
order: number;
|
|
82
|
+
temporaryRedirect: boolean;
|
|
83
|
+
permanentRedirect: boolean;
|
|
84
|
+
forward: boolean;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
isInsideEditor: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface DotCMSContentlet {
|
|
90
|
+
archived: boolean;
|
|
91
|
+
binaryContentAsset?: string;
|
|
92
|
+
deleted?: boolean;
|
|
93
|
+
baseType: string;
|
|
94
|
+
binary?: string;
|
|
95
|
+
binaryVersion?: string;
|
|
96
|
+
file?: string;
|
|
97
|
+
contentType: string;
|
|
98
|
+
hasLiveVersion?: boolean;
|
|
99
|
+
folder: string;
|
|
100
|
+
hasTitleImage: boolean;
|
|
101
|
+
hostName: string;
|
|
102
|
+
host: string;
|
|
103
|
+
inode: string;
|
|
104
|
+
identifier: string;
|
|
105
|
+
languageId: number;
|
|
106
|
+
image?: string;
|
|
107
|
+
locked: boolean;
|
|
108
|
+
language?: string;
|
|
109
|
+
mimeType?: string;
|
|
110
|
+
modUser: string;
|
|
111
|
+
modDate: string;
|
|
112
|
+
live: boolean;
|
|
113
|
+
sortOrder: number;
|
|
114
|
+
owner: string;
|
|
115
|
+
title: string;
|
|
116
|
+
stInode: string;
|
|
117
|
+
titleImage: string;
|
|
118
|
+
modUserName: string;
|
|
119
|
+
text?: string;
|
|
120
|
+
working: boolean;
|
|
121
|
+
url: string;
|
|
122
|
+
contentTypeIcon?: string;
|
|
123
|
+
body?: string;
|
|
124
|
+
variant?: string;
|
|
125
|
+
__icon__?: string;
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ContainerData, DotCMSPageContext } from '../models';
|
|
2
|
+
import { Block, BlockEditorState } from '../models/blocks.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Get the container data from the containers object using the current container reference obtained from the layout.
|
|
5
|
+
*
|
|
6
|
+
* @param {ContainerData} containers
|
|
7
|
+
* @param {DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]} containerRef
|
|
8
|
+
* @returns {Object} Container with all the data it has.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getContainersData: (containers: ContainerData, containerRef: DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]) => {
|
|
11
|
+
acceptTypes: string;
|
|
12
|
+
contentlets: {
|
|
13
|
+
contentType: string;
|
|
14
|
+
identifier: string;
|
|
15
|
+
title: string;
|
|
16
|
+
inode: string;
|
|
17
|
+
onNumberOfPages: number;
|
|
18
|
+
widgetTitle?: string | undefined;
|
|
19
|
+
baseType: string;
|
|
20
|
+
}[];
|
|
21
|
+
variantId: string;
|
|
22
|
+
path: string;
|
|
23
|
+
identifier: string;
|
|
24
|
+
maxContentlets: number;
|
|
25
|
+
parentPermissionable: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Combine classes into a single string.
|
|
29
|
+
*
|
|
30
|
+
* @param {string[]} classes
|
|
31
|
+
* @returns {string} Combined classes
|
|
32
|
+
*/
|
|
33
|
+
export declare const combineClasses: (classes: string[]) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the start and end classes for the column based on the left offset and width.
|
|
36
|
+
*
|
|
37
|
+
* @param {number} start
|
|
38
|
+
* @param {number} end
|
|
39
|
+
* @returns {Object} Start and end classes
|
|
40
|
+
*/
|
|
41
|
+
export declare const getPositionStyleClasses: (start: number, end: number) => {
|
|
42
|
+
startClass: string;
|
|
43
|
+
endClass: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Validates the structure of a Block Editor block.
|
|
47
|
+
*
|
|
48
|
+
* This function checks that:
|
|
49
|
+
* 1. The blocks parameter is a valid object
|
|
50
|
+
* 2. The block has a 'doc' type
|
|
51
|
+
* 3. The block has a valid content array that is not empty
|
|
52
|
+
*
|
|
53
|
+
* @param {Block} blocks - The blocks structure to validate
|
|
54
|
+
* @returns {BlockEditorState} Object containing validation state and any error message
|
|
55
|
+
* @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
|
|
56
|
+
* @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
|
|
57
|
+
*/
|
|
58
|
+
export declare const isValidBlocks: (blocks: Block) => BlockEditorState;
|
package/.babelrc
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.base.json"],
|
|
3
|
-
"ignorePatterns": ["!**/*"],
|
|
4
|
-
"overrides": [
|
|
5
|
-
{
|
|
6
|
-
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
-
"rules": {}
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"files": ["*.ts", "*.tsx"],
|
|
11
|
-
"rules": {}
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"files": ["*.js", "*.jsx"],
|
|
15
|
-
"rules": {}
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
package/jest.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export default {
|
|
3
|
-
displayName: 'sdk-react',
|
|
4
|
-
preset: '../../../jest.preset.js',
|
|
5
|
-
transform: {
|
|
6
|
-
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
|
|
7
|
-
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }]
|
|
8
|
-
},
|
|
9
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
10
|
-
coverageDirectory: '../../../coverage/libs/sdk/react'
|
|
11
|
-
};
|
package/project.json
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sdk-react",
|
|
3
|
-
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "libs/sdk/react/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"tags": [],
|
|
7
|
-
"targets": {
|
|
8
|
-
"lint": {
|
|
9
|
-
"executor": "@nrwl/linter:eslint",
|
|
10
|
-
"outputs": ["{options.outputFile}"],
|
|
11
|
-
"options": {
|
|
12
|
-
"lintFilePatterns": ["libs/sdk/react/**/*.{ts,tsx,js,jsx}"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"build": {
|
|
16
|
-
"executor": "@nrwl/rollup:rollup",
|
|
17
|
-
"outputs": ["{options.outputPath}"],
|
|
18
|
-
"options": {
|
|
19
|
-
"outputPath": "dist/libs/sdk/react",
|
|
20
|
-
"tsConfig": "libs/sdk/react/tsconfig.lib.json",
|
|
21
|
-
"project": "libs/sdk/react/package.json",
|
|
22
|
-
"entryFile": "libs/sdk/react/src/index.ts",
|
|
23
|
-
"external": ["react/jsx-runtime"],
|
|
24
|
-
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
|
|
25
|
-
"compiler": "babel",
|
|
26
|
-
"extractCss": false,
|
|
27
|
-
"assets": [
|
|
28
|
-
{
|
|
29
|
-
"glob": "libs/sdk/react/README.md",
|
|
30
|
-
"input": ".",
|
|
31
|
-
"output": "."
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"test": {
|
|
37
|
-
"executor": "@nrwl/jest:jest",
|
|
38
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
39
|
-
"options": {
|
|
40
|
-
"jestConfig": "libs/sdk/react/jest.config.ts",
|
|
41
|
-
"passWithNoTests": true
|
|
42
|
-
},
|
|
43
|
-
"configurations": {
|
|
44
|
-
"ci": {
|
|
45
|
-
"ci": true,
|
|
46
|
-
"codeCoverage": true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
.col-start-1 {
|
|
2
|
-
grid-column-start: 1;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.col-start-2 {
|
|
6
|
-
grid-column-start: 2;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.col-start-3 {
|
|
10
|
-
grid-column-start: 3;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.col-start-4 {
|
|
14
|
-
grid-column-start: 4;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.col-start-5 {
|
|
18
|
-
grid-column-start: 5;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.col-start-6 {
|
|
22
|
-
grid-column-start: 6;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.col-start-7 {
|
|
26
|
-
grid-column-start: 7;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.col-start-8 {
|
|
30
|
-
grid-column-start: 8;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.col-start-9 {
|
|
34
|
-
grid-column-start: 9;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.col-start-10 {
|
|
38
|
-
grid-column-start: 10;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.col-start-11 {
|
|
42
|
-
grid-column-start: 11;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.col-start-12 {
|
|
46
|
-
grid-column-start: 12;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.col-end-1 {
|
|
50
|
-
grid-column-end: 1;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.col-end-2 {
|
|
54
|
-
grid-column-end: 2;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.col-end-3 {
|
|
58
|
-
grid-column-end: 3;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.col-end-4 {
|
|
62
|
-
grid-column-end: 4;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.col-end-5 {
|
|
66
|
-
grid-column-end: 5;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.col-end-6 {
|
|
70
|
-
grid-column-end: 6;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.col-end-7 {
|
|
74
|
-
grid-column-end: 7;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.col-end-8 {
|
|
78
|
-
grid-column-end: 8;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.col-end-9 {
|
|
82
|
-
grid-column-end: 9;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.col-end-10 {
|
|
86
|
-
grid-column-end: 10;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.col-end-11 {
|
|
90
|
-
grid-column-end: 11;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.col-end-12 {
|
|
94
|
-
grid-column-end: 12;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.col-end-13 {
|
|
98
|
-
grid-column-end: 13;
|
|
99
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
|
|
4
|
-
import * as dotcmsClient from '@dotcms/client';
|
|
5
|
-
|
|
6
|
-
import { Column } from './Column';
|
|
7
|
-
|
|
8
|
-
import { MockContextRender } from '../../mocks/mockPageContext';
|
|
9
|
-
import { ContainerProps } from '../Container/Container';
|
|
10
|
-
|
|
11
|
-
jest.mock('../Container/Container', () => {
|
|
12
|
-
return {
|
|
13
|
-
Container: ({ containerRef }: Partial<ContainerProps>) => (
|
|
14
|
-
<div data-testid="mockContainer">{containerRef?.identifier}</div>
|
|
15
|
-
)
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('Column', () => {
|
|
20
|
-
const mockColumnData = {
|
|
21
|
-
width: 6, // Adjust as needed
|
|
22
|
-
leftOffset: 3, // Adjust as needed
|
|
23
|
-
containers: [
|
|
24
|
-
{ identifier: 'Container1', uuid: 'unique-id-1' },
|
|
25
|
-
{ identifier: 'Container2', uuid: 'unique-id-2' }
|
|
26
|
-
// Add more containers as needed for your test
|
|
27
|
-
],
|
|
28
|
-
styleClass: ''
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
describe('Column is inside editor', () => {
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
jest.spyOn(dotcmsClient, 'isInsideEditor').mockReturnValue(true);
|
|
34
|
-
render(
|
|
35
|
-
<MockContextRender mockContext={{ isInsideEditor: true }}>
|
|
36
|
-
<Column column={mockColumnData} />
|
|
37
|
-
</MockContextRender>
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('applies the correct width and start classes based on props', () => {
|
|
42
|
-
const columnElement = screen.getByTestId('column');
|
|
43
|
-
expect(columnElement).toHaveClass('col-end-9');
|
|
44
|
-
expect(columnElement).toHaveClass('col-start-3');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('applies the correct data attr', () => {
|
|
48
|
-
expect(screen.getByTestId('column')).toHaveAttribute('data-dot', 'column');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders the correct number of containers', () => {
|
|
52
|
-
const containers = screen.getAllByTestId('mockContainer');
|
|
53
|
-
expect(containers.length).toBe(mockColumnData.containers.length);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('passes the correct props to each Container', () => {
|
|
57
|
-
mockColumnData.containers.forEach((container) => {
|
|
58
|
-
expect(screen.getByText(container.identifier)).toBeInTheDocument();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('Column is not inside editor', () => {
|
|
64
|
-
beforeEach(() => {
|
|
65
|
-
jest.spyOn(dotcmsClient, 'isInsideEditor').mockReturnValue(false);
|
|
66
|
-
render(
|
|
67
|
-
<MockContextRender mockContext={{ isInsideEditor: false }}>
|
|
68
|
-
<Column column={mockColumnData} />
|
|
69
|
-
</MockContextRender>
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should not have dot attrs', () => {
|
|
74
|
-
const columnElement = screen.queryByTestId('column');
|
|
75
|
-
expect(columnElement).toBeNull();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import styles from './column.module.css';
|
|
4
|
-
|
|
5
|
-
import { PageContext } from '../../contexts/PageContext';
|
|
6
|
-
import { combineClasses, getPositionStyleClasses } from '../../utils/utils';
|
|
7
|
-
import { Container } from '../Container/Container';
|
|
8
|
-
import { PageProviderContext } from '../PageProvider/PageProvider';
|
|
9
|
-
|
|
10
|
-
export interface ColumnProps {
|
|
11
|
-
readonly column: PageProviderContext['layout']['body']['rows'][0]['columns'][0];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Column({ column }: ColumnProps) {
|
|
15
|
-
const { isInsideEditor } = useContext(PageContext) as PageProviderContext;
|
|
16
|
-
|
|
17
|
-
const { startClass, endClass } = getPositionStyleClasses(
|
|
18
|
-
column.leftOffset,
|
|
19
|
-
column.width + column.leftOffset
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const combinedClasses = combineClasses([
|
|
23
|
-
styles[endClass],
|
|
24
|
-
styles[startClass],
|
|
25
|
-
column.styleClass
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
const columnProps = isInsideEditor
|
|
29
|
-
? {
|
|
30
|
-
'data-dot': 'column',
|
|
31
|
-
'data-testid': 'column'
|
|
32
|
-
}
|
|
33
|
-
: {};
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div {...columnProps} className={combinedClasses}>
|
|
37
|
-
{column.containers.map((container) => (
|
|
38
|
-
<Container
|
|
39
|
-
key={`${container.identifier}-${container.uuid}`}
|
|
40
|
-
containerRef={container}
|
|
41
|
-
/>
|
|
42
|
-
))}
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|