@developer_tribe/react-builder 0.1.0 → 0.1.4
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/dist/build-components/Button/Button.d.ts +2 -2
- package/dist/build-components/Carousel/Carousel.d.ts +2 -2
- package/dist/build-components/CarouselButtons/CarouselButtons.d.ts +2 -2
- package/dist/build-components/CarouselDots/CarouselDots.d.ts +2 -2
- package/dist/build-components/CarouselItem/CarouselItem.d.ts +2 -2
- package/dist/build-components/CarouselProvider/CarouselProvider.d.ts +2 -2
- package/dist/build-components/Image/Image.d.ts +2 -2
- package/dist/build-components/Onboard/Onboard.d.ts +2 -2
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitle.d.ts +2 -2
- package/dist/build-components/OnboardButton/OnboardButton.d.ts +2 -2
- package/dist/build-components/OnboardButtons/OnboardButtons.d.ts +2 -2
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDot.d.ts +2 -2
- package/dist/build-components/OnboardFooter/OnboardFooter.d.ts +2 -2
- package/dist/build-components/OnboardImage/OnboardImage.d.ts +2 -2
- package/dist/build-components/OnboardItem/OnboardItem.d.ts +2 -2
- package/dist/build-components/OnboardProvider/OnboardProvider.d.ts +2 -2
- package/dist/build-components/OnboardSubtitle/OnboardSubtitle.d.ts +2 -2
- package/dist/build-components/RenderNode.generated.d.ts +1 -1
- package/dist/build-components/Text/Text.d.ts +2 -2
- package/dist/build-components/View/View.d.ts +2 -2
- package/dist/build-components/other.d.ts +3 -0
- package/dist/utils/generateRandomKeyForNode.d.ts +1 -0
- package/package.json +12 -5
- package/scripts/prebuild/build-components.js +528 -0
- package/scripts/prebuild/prebuild.js +11 -0
- package/scripts/public/bin.js +57 -0
- package/scripts/public/scripts/build/index.js +31 -0
- package/scripts/public/scripts/build/info.json +11 -0
- package/scripts/public/scripts/build/utils/checkFolderAndFilesValid.js +41 -0
- package/scripts/public/scripts/build/utils/checkPathExists.js +9 -0
- package/scripts/public/scripts/build/utils/createMissingFoldersAndFiles.js +54 -0
- package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +82 -0
- package/scripts/public/scripts/build/utils/getAllComponents.js +11 -0
- package/src/AttributesEditor.tsx +107 -0
- package/src/RenderMainNode.tsx +37 -0
- package/src/RenderPage.tsx +61 -0
- package/src/assets/devices.json +730 -0
- package/src/assets/samples/carousel-sample.json +108 -0
- package/src/assets/samples/getSamples.ts +28 -0
- package/src/assets/samples/simple-1.json +46 -0
- package/src/assets/samples/simple-2.json +233 -0
- package/src/assets/samples/vpn-onboard-1.json +799 -0
- package/src/assets/samples/vpn-onboard-2.json +790 -0
- package/src/assets/samples/vpn-onboard-3.json +803 -0
- package/src/assets/samples/vpn-onboard-4.json +804 -0
- package/src/build-components/Button/Button.tsx +13 -0
- package/src/build-components/Button/ButtonProps.generated.ts +21 -0
- package/src/build-components/Button/pattern.json +25 -0
- package/src/build-components/Carousel/Carousel.tsx +27 -0
- package/src/build-components/Carousel/CarouselProps.generated.ts +6 -0
- package/src/build-components/Carousel/pattern.json +9 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +47 -0
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +9 -0
- package/src/build-components/CarouselButtons/pattern.json +12 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +40 -0
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +14 -0
- package/src/build-components/CarouselDots/pattern.json +18 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +18 -0
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +6 -0
- package/src/build-components/CarouselItem/pattern.json +9 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +26 -0
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +6 -0
- package/src/build-components/CarouselProvider/pattern.json +9 -0
- package/src/build-components/Image/Image.tsx +35 -0
- package/src/build-components/Image/ImageProps.generated.ts +12 -0
- package/src/build-components/Image/pattern.json +15 -0
- package/src/build-components/Onboard/Onboard.tsx +14 -0
- package/src/build-components/Onboard/OnboardProps.generated.ts +6 -0
- package/src/build-components/Onboard/pattern.json +9 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitle.tsx +28 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.generated.ts +21 -0
- package/src/build-components/OnboardBoardTitle/pattern.json +25 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +59 -0
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +13 -0
- package/src/build-components/OnboardButton/pattern.json +16 -0
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +76 -0
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +12 -0
- package/src/build-components/OnboardButtons/pattern.json +15 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDot.tsx +14 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.generated.ts +14 -0
- package/src/build-components/OnboardExpandingDot/pattern.json +18 -0
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +13 -0
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +24 -0
- package/src/build-components/OnboardFooter/pattern.json +28 -0
- package/src/build-components/OnboardImage/OnboardImage.tsx +14 -0
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +12 -0
- package/src/build-components/OnboardImage/pattern.json +15 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +29 -0
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +6 -0
- package/src/build-components/OnboardItem/pattern.json +9 -0
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +65 -0
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +6 -0
- package/src/build-components/OnboardProvider/pattern.json +9 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +28 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +21 -0
- package/src/build-components/OnboardSubtitle/pattern.json +25 -0
- package/src/build-components/RenderNode.generated.tsx +97 -0
- package/src/build-components/Text/Text.tsx +23 -0
- package/src/build-components/Text/TextProps.generated.ts +21 -0
- package/src/build-components/Text/pattern.json +26 -0
- package/src/build-components/View/View.tsx +62 -0
- package/src/build-components/View/ViewProps.generated.ts +24 -0
- package/src/build-components/View/pattern.json +28 -0
- package/src/build-components/other.ts +6 -0
- package/src/index.ts +24 -0
- package/src/styles/index.scss +114 -0
- package/src/types/Device.ts +12 -0
- package/src/types/Node.ts +19 -0
- package/src/types/PreviewConfig.ts +19 -0
- package/src/types/Project.ts +11 -0
- package/src/types/TargetedScreenSize.ts +4 -0
- package/src/utils/analyseNode.ts +77 -0
- package/src/utils/generateRandomKeyForNode.ts +3 -0
- package/src/utils/getDevices.ts +6 -0
- package/src/utils/isCarousel.ts +36 -0
- package/src/utils/isOnboard.ts +54 -0
- package/src/utils/novaToJson.ts +253 -0
- package/src/utils/patterns.ts +63 -0
- package/dist/build-components/Button/ButtonProps.d.ts +0 -3
- package/dist/build-components/Carousel/CarouselProps.d.ts +0 -3
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.d.ts +0 -3
- package/dist/build-components/CarouselDots/CarouselDotsProps.d.ts +0 -3
- package/dist/build-components/CarouselItem/CarouselItemProps.d.ts +0 -3
- package/dist/build-components/CarouselProvider/CarouselProviderProps.d.ts +0 -3
- package/dist/build-components/Image/ImageProps.d.ts +0 -3
- package/dist/build-components/Onboard/OnboardProps.d.ts +0 -3
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitleProps.d.ts +0 -3
- package/dist/build-components/OnboardButton/OnboardButtonProps.d.ts +0 -3
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.d.ts +0 -3
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDotProps.d.ts +0 -3
- package/dist/build-components/OnboardFooter/OnboardFooterProps.d.ts +0 -3
- package/dist/build-components/OnboardImage/OnboardImageProps.d.ts +0 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.d.ts +0 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.d.ts +0 -3
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.d.ts +0 -3
- package/dist/build-components/Text/TextProps.d.ts +0 -3
- package/dist/build-components/View/ViewProps.d.ts +0 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import Path from 'path';
|
|
3
|
+
|
|
4
|
+
function toPropsName(name) {
|
|
5
|
+
return `${name}Props`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Create folders and base component files if missing
|
|
9
|
+
export function createMissingFoldersAndFiles(targetRootPath, components) {
|
|
10
|
+
const buildComponentsTarget = Path.join(
|
|
11
|
+
targetRootPath,
|
|
12
|
+
'src',
|
|
13
|
+
'build-components'
|
|
14
|
+
);
|
|
15
|
+
if (!fs.existsSync(buildComponentsTarget)) {
|
|
16
|
+
fs.mkdirSync(buildComponentsTarget, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Ensure fallback helper exists
|
|
20
|
+
const otherPath = Path.join(buildComponentsTarget, 'other.ts');
|
|
21
|
+
if (!fs.existsSync(otherPath)) {
|
|
22
|
+
const otherContent = `import React from 'react';
|
|
23
|
+
import type { Node } from '@developer_tribe/react-builder';
|
|
24
|
+
|
|
25
|
+
export function other(type: string, node: Node): React.ReactNode {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
fs.writeFileSync(otherPath, otherContent, 'utf8');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
for (const component of components) {
|
|
33
|
+
const dir = Path.join(buildComponentsTarget, component);
|
|
34
|
+
if (!fs.existsSync(dir)) {
|
|
35
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// component tsx
|
|
39
|
+
const tsxPath = Path.join(dir, `${component}.tsx`);
|
|
40
|
+
if (!fs.existsSync(tsxPath)) {
|
|
41
|
+
const propsName = toPropsName(component);
|
|
42
|
+
const content = `import React from 'react';
|
|
43
|
+
import type { ${propsName} } from '@developer_tribe/react-builder';
|
|
44
|
+
|
|
45
|
+
function ${component}(props: { node: any }) {
|
|
46
|
+
return "hello world";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default React.memo(${component});
|
|
50
|
+
`;
|
|
51
|
+
fs.writeFileSync(tsxPath, content, 'utf8');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import Path from 'path';
|
|
3
|
+
|
|
4
|
+
function readPatternType(builderComponentsPath, componentName) {
|
|
5
|
+
try {
|
|
6
|
+
const p = Path.join(builderComponentsPath, componentName, 'pattern.json');
|
|
7
|
+
const raw = fs.readFileSync(p, 'utf8');
|
|
8
|
+
const json = JSON.parse(raw.toString('utf8'));
|
|
9
|
+
const type = json?.pattern?.type;
|
|
10
|
+
if (typeof type === 'string' && type.length > 0) return type;
|
|
11
|
+
} catch {}
|
|
12
|
+
return componentName.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createRenderNodeGenerated(
|
|
16
|
+
builderComponentsPath,
|
|
17
|
+
targetRootPath,
|
|
18
|
+
components
|
|
19
|
+
) {
|
|
20
|
+
const buildComponentsTarget = Path.join(
|
|
21
|
+
targetRootPath,
|
|
22
|
+
'src',
|
|
23
|
+
'build-components'
|
|
24
|
+
);
|
|
25
|
+
if (!fs.existsSync(buildComponentsTarget)) {
|
|
26
|
+
fs.mkdirSync(buildComponentsTarget, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const targetPath = Path.join(
|
|
30
|
+
buildComponentsTarget,
|
|
31
|
+
'RenderNode.generated.tsx'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const imports = components
|
|
35
|
+
.map(name => `import ${name} from './${name}/${name}';`)
|
|
36
|
+
.join('\n');
|
|
37
|
+
|
|
38
|
+
const cases = components
|
|
39
|
+
.map(name => {
|
|
40
|
+
const type = readPatternType(builderComponentsPath, name);
|
|
41
|
+
return ` case ${JSON.stringify(type)}:\n return <${name} node={simpleNode} />;`;
|
|
42
|
+
})
|
|
43
|
+
.join('\n');
|
|
44
|
+
|
|
45
|
+
const content = `/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
46
|
+
import React from 'react';
|
|
47
|
+
import { Node, NodeData, isNodeArray, isNodeNullOrUndefined, isNodeString } from '@developer_tribe/react-builder';
|
|
48
|
+
import { other } from './other';
|
|
49
|
+
${imports}
|
|
50
|
+
|
|
51
|
+
function RenderNode({ node }: { node: Node }) {
|
|
52
|
+
if (isNodeNullOrUndefined(node)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (isNodeString(node)) {
|
|
56
|
+
return <Text node={{ children: node as string, type: 'text' }} />;
|
|
57
|
+
}
|
|
58
|
+
if (isNodeArray(node)) {
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
{(node as Node[]).map((item: Node, index) => (
|
|
62
|
+
<RenderNode key={index} node={item} />
|
|
63
|
+
))}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const simpleNode = node as NodeData;
|
|
69
|
+
switch (simpleNode?.type) {
|
|
70
|
+
${cases}
|
|
71
|
+
default:
|
|
72
|
+
return other(simpleNode?.type, node);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default React.memo(RenderNode);
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
fs.writeFileSync(targetPath, content, 'utf8');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// no default export
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import Path from 'path';
|
|
3
|
+
|
|
4
|
+
// Get immediate subfolder names within the given build-components path
|
|
5
|
+
export function getAllComponents(buildComponentsPath) {
|
|
6
|
+
const items = fs.readdirSync(buildComponentsPath, { withFileTypes: true });
|
|
7
|
+
return items
|
|
8
|
+
.filter(item => item.isDirectory())
|
|
9
|
+
.map(dir => dir.name)
|
|
10
|
+
.sort();
|
|
11
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node, NodeData, NodeDefaultAttribute } from './types/Node';
|
|
3
|
+
import { isNodeString } from './utils/analyseNode';
|
|
4
|
+
import { getAttributeSchema } from './utils/patterns';
|
|
5
|
+
|
|
6
|
+
type AttributesEditorProps = {
|
|
7
|
+
node: Node;
|
|
8
|
+
onChange: (next: Node) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function Field({
|
|
12
|
+
name,
|
|
13
|
+
type,
|
|
14
|
+
value,
|
|
15
|
+
onChange,
|
|
16
|
+
}: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string | string[];
|
|
19
|
+
value: any;
|
|
20
|
+
onChange: (v: any) => void;
|
|
21
|
+
}) {
|
|
22
|
+
if (Array.isArray(type)) {
|
|
23
|
+
return (
|
|
24
|
+
<select
|
|
25
|
+
value={value ?? ''}
|
|
26
|
+
onChange={(e) => onChange(e.target.value)}
|
|
27
|
+
className="input"
|
|
28
|
+
>
|
|
29
|
+
<option value="">(none)</option>
|
|
30
|
+
{type.map((opt) => (
|
|
31
|
+
<option key={opt} value={opt}>
|
|
32
|
+
{opt}
|
|
33
|
+
</option>
|
|
34
|
+
))}
|
|
35
|
+
</select>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (type === 'number') {
|
|
39
|
+
return (
|
|
40
|
+
<input
|
|
41
|
+
type="number"
|
|
42
|
+
value={value ?? ''}
|
|
43
|
+
onChange={(e) =>
|
|
44
|
+
onChange(e.target.value === '' ? undefined : Number(e.target.value))
|
|
45
|
+
}
|
|
46
|
+
className="input"
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (type === 'boolean') {
|
|
51
|
+
return (
|
|
52
|
+
<input
|
|
53
|
+
type="checkbox"
|
|
54
|
+
checked={Boolean(value)}
|
|
55
|
+
onChange={(e) => onChange(e.target.checked)}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<input
|
|
61
|
+
type="text"
|
|
62
|
+
value={value ?? ''}
|
|
63
|
+
onChange={(e) =>
|
|
64
|
+
onChange(e.target.value === '' ? undefined : e.target.value)
|
|
65
|
+
}
|
|
66
|
+
className="input"
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function AttributesEditor({ node, onChange }: AttributesEditorProps) {
|
|
72
|
+
if (!node || isNodeString(node)) return null;
|
|
73
|
+
const data = node as NodeData<NodeDefaultAttribute>;
|
|
74
|
+
const schema = getAttributeSchema(data?.type) ?? {};
|
|
75
|
+
const attributes = (data?.attributes ?? {}) as NodeDefaultAttribute;
|
|
76
|
+
|
|
77
|
+
const entries = Object.entries(schema);
|
|
78
|
+
if (entries.length === 0) {
|
|
79
|
+
return (
|
|
80
|
+
<div style={{ padding: 8, opacity: 0.7 }}>No editable attributes</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8 }}>
|
|
86
|
+
{entries.map(([name, type]) => (
|
|
87
|
+
<React.Fragment key={name}>
|
|
88
|
+
<div style={{ alignSelf: 'center' }}>{name}</div>
|
|
89
|
+
<Field
|
|
90
|
+
name={name}
|
|
91
|
+
type={type}
|
|
92
|
+
value={attributes?.[name]}
|
|
93
|
+
onChange={(val) => {
|
|
94
|
+
const next: NodeData<NodeDefaultAttribute> = {
|
|
95
|
+
...data,
|
|
96
|
+
attributes: { ...(attributes ?? {}), [name]: val },
|
|
97
|
+
};
|
|
98
|
+
onChange(next);
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
</React.Fragment>
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default React.memo(AttributesEditor);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createContext, useState } from 'react';
|
|
2
|
+
import { Node } from './index';
|
|
3
|
+
|
|
4
|
+
import { Localication } from './types/PreviewConfig';
|
|
5
|
+
import RenderNode from './build-components/RenderNode.generated';
|
|
6
|
+
export const mainNodeContext = createContext<{
|
|
7
|
+
localication?: Localication;
|
|
8
|
+
defaultLanguage?: string;
|
|
9
|
+
theme?: 'light' | 'dark';
|
|
10
|
+
warning?: string;
|
|
11
|
+
setWarning?: (message: string) => void;
|
|
12
|
+
} | null>(null);
|
|
13
|
+
|
|
14
|
+
export function RenderMainNode({
|
|
15
|
+
node,
|
|
16
|
+
localication,
|
|
17
|
+
defaultLanguage,
|
|
18
|
+
theme,
|
|
19
|
+
}: {
|
|
20
|
+
node: Node;
|
|
21
|
+
localication?: Localication;
|
|
22
|
+
defaultLanguage?: string;
|
|
23
|
+
theme?: 'light' | 'dark';
|
|
24
|
+
warning?: string;
|
|
25
|
+
setWarning?: (message: string) => void;
|
|
26
|
+
}) {
|
|
27
|
+
const [warning, setWarning] = useState<string>('');
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<mainNodeContext.Provider
|
|
31
|
+
value={{ localication, defaultLanguage, theme, warning, setWarning }}
|
|
32
|
+
>
|
|
33
|
+
{warning && <div className="warning">{warning}</div>}
|
|
34
|
+
<RenderNode node={node} />
|
|
35
|
+
</mainNodeContext.Provider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Localication } from './types/PreviewConfig';
|
|
2
|
+
import { TargetedScreenSize } from './types/TargetedScreenSize';
|
|
3
|
+
import { RenderMainNode } from './RenderMainNode';
|
|
4
|
+
import { Node } from './types/Node';
|
|
5
|
+
type RenderPageProps = {
|
|
6
|
+
data: Node;
|
|
7
|
+
screenSize: TargetedScreenSize;
|
|
8
|
+
isRtl: boolean;
|
|
9
|
+
screenStyle: {
|
|
10
|
+
light: { backgroundColor: string; color: string };
|
|
11
|
+
dark: { backgroundColor: string; color: string };
|
|
12
|
+
};
|
|
13
|
+
theme: 'dark' | 'light';
|
|
14
|
+
localication: Localication;
|
|
15
|
+
defaultLanguage?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function RenderPage({
|
|
19
|
+
data,
|
|
20
|
+
screenSize,
|
|
21
|
+
theme,
|
|
22
|
+
isRtl,
|
|
23
|
+
screenStyle,
|
|
24
|
+
localication,
|
|
25
|
+
defaultLanguage,
|
|
26
|
+
}: RenderPageProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div className="stage-wrapper" style={{ overflow: 'auto' }}>
|
|
29
|
+
<div
|
|
30
|
+
className="stage"
|
|
31
|
+
style={{
|
|
32
|
+
width: screenSize.width,
|
|
33
|
+
height: screenSize.height,
|
|
34
|
+
minWidth: screenSize.width,
|
|
35
|
+
maxWidth: screenSize.width,
|
|
36
|
+
minHeight: screenSize.height,
|
|
37
|
+
maxHeight: screenSize.height,
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
position: 'relative',
|
|
40
|
+
padding: 4,
|
|
41
|
+
direction: isRtl ? 'rtl' : 'ltr',
|
|
42
|
+
backgroundColor:
|
|
43
|
+
theme === 'dark'
|
|
44
|
+
? screenStyle.dark.backgroundColor
|
|
45
|
+
: screenStyle.light.backgroundColor,
|
|
46
|
+
color:
|
|
47
|
+
theme === 'dark' ? screenStyle.dark.color : screenStyle.light.color,
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{
|
|
51
|
+
<RenderMainNode
|
|
52
|
+
localication={localication}
|
|
53
|
+
node={data}
|
|
54
|
+
defaultLanguage={defaultLanguage}
|
|
55
|
+
theme={theme}
|
|
56
|
+
/>
|
|
57
|
+
}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|