@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,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewPropsGenerated } from './ViewProps.generated';
|
|
3
|
+
import RenderNode from '../RenderNode.generated';
|
|
4
|
+
import { Node, NodeData } from '../../types/Node';
|
|
5
|
+
|
|
6
|
+
function mapAttributesToStyle(
|
|
7
|
+
attributes: ViewPropsGenerated['attributes'],
|
|
8
|
+
): React.CSSProperties {
|
|
9
|
+
const scrollable = attributes?.scrollable ?? false;
|
|
10
|
+
const style: React.CSSProperties = {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column',
|
|
13
|
+
};
|
|
14
|
+
if (!attributes) return style;
|
|
15
|
+
if (scrollable) {
|
|
16
|
+
if (attributes.flexDirection === 'row') {
|
|
17
|
+
style.overflowX = 'auto';
|
|
18
|
+
style.overflowY = 'hidden';
|
|
19
|
+
style.maxWidth = '100%';
|
|
20
|
+
style.maxHeight = '100%';
|
|
21
|
+
} else {
|
|
22
|
+
style.overflowY = 'auto';
|
|
23
|
+
style.overflowX = 'hidden';
|
|
24
|
+
style.maxHeight = '100%';
|
|
25
|
+
style.maxWidth = '100%';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (attributes.flexDirection) style.flexDirection = attributes.flexDirection;
|
|
29
|
+
if (attributes.alignItems)
|
|
30
|
+
style.alignItems =
|
|
31
|
+
attributes.alignItems as React.CSSProperties['alignItems'];
|
|
32
|
+
if (attributes.justifyContent)
|
|
33
|
+
style.justifyContent =
|
|
34
|
+
attributes.justifyContent as React.CSSProperties['justifyContent'];
|
|
35
|
+
if (attributes.gap !== undefined) style.gap = attributes.gap;
|
|
36
|
+
if (attributes.padding !== undefined) style.padding = attributes.padding;
|
|
37
|
+
if (attributes.margin !== undefined) style.margin = attributes.margin;
|
|
38
|
+
if (attributes.backgroundColor)
|
|
39
|
+
style.backgroundColor = attributes.backgroundColor;
|
|
40
|
+
if (attributes.borderRadius !== undefined)
|
|
41
|
+
style.borderRadius = attributes.borderRadius;
|
|
42
|
+
if (attributes.width !== undefined) style.width = attributes.width;
|
|
43
|
+
if (attributes.height !== undefined) style.height = attributes.height;
|
|
44
|
+
return style;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type ViewComponentProps = {
|
|
48
|
+
node: NodeData<ViewPropsGenerated['attributes']>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function View({ node }: ViewComponentProps) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
style={mapAttributesToStyle(node.attributes ?? {})}
|
|
55
|
+
className="primitive primitive-view"
|
|
56
|
+
>
|
|
57
|
+
<RenderNode node={node.children as Node} />
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default React.memo(View);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface ViewPropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
scrollable?: boolean;
|
|
7
|
+
flexDirection?: 'row' | 'column';
|
|
8
|
+
alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
|
|
9
|
+
justifyContent?:
|
|
10
|
+
| 'flex-start'
|
|
11
|
+
| 'center'
|
|
12
|
+
| 'flex-end'
|
|
13
|
+
| 'space-between'
|
|
14
|
+
| 'space-around'
|
|
15
|
+
| 'space-evenly';
|
|
16
|
+
gap?: number;
|
|
17
|
+
padding?: number;
|
|
18
|
+
margin?: number;
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
borderRadius?: number;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "view",
|
|
6
|
+
"children": ["node", "array"],
|
|
7
|
+
"attributes": {
|
|
8
|
+
"scrollable": "boolean",
|
|
9
|
+
"flexDirection": ["row", "column"],
|
|
10
|
+
"alignItems": ["flex-start", "center", "flex-end", "stretch", "baseline"],
|
|
11
|
+
"justifyContent": [
|
|
12
|
+
"flex-start",
|
|
13
|
+
"center",
|
|
14
|
+
"flex-end",
|
|
15
|
+
"space-between",
|
|
16
|
+
"space-around",
|
|
17
|
+
"space-evenly"
|
|
18
|
+
],
|
|
19
|
+
"gap": "number",
|
|
20
|
+
"padding": "number",
|
|
21
|
+
"margin": "number",
|
|
22
|
+
"backgroundColor": "string",
|
|
23
|
+
"borderRadius": "number",
|
|
24
|
+
"width": "number",
|
|
25
|
+
"height": "number"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import './styles/index.scss';
|
|
2
|
+
import RenderNode from './build-components/RenderNode.generated';
|
|
3
|
+
import AttributesEditor from './AttributesEditor';
|
|
4
|
+
|
|
5
|
+
export { TargetedScreenSize } from './types/TargetedScreenSize';
|
|
6
|
+
export { Node, NodeData, NodeDefaultAttribute } from './types/Node';
|
|
7
|
+
export { Project } from './types/Project';
|
|
8
|
+
export {
|
|
9
|
+
isNodeNullOrUndefined,
|
|
10
|
+
isNodeString,
|
|
11
|
+
isNodeArray,
|
|
12
|
+
isEmptyObject,
|
|
13
|
+
analyseNode,
|
|
14
|
+
} from './utils/analyseNode';
|
|
15
|
+
export { getSamples } from './assets/samples/getSamples';
|
|
16
|
+
export { PreviewConfig } from './types/PreviewConfig';
|
|
17
|
+
export { RenderPage } from './RenderPage';
|
|
18
|
+
export { RenderMainNode } from './RenderMainNode';
|
|
19
|
+
export { novaToJson } from './utils/novaToJson';
|
|
20
|
+
export type { Localication } from './types/PreviewConfig';
|
|
21
|
+
export { RenderNode };
|
|
22
|
+
export { getDevices } from './utils/getDevices';
|
|
23
|
+
export type { Device } from './types/Device';
|
|
24
|
+
export { AttributesEditor };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
.embla {
|
|
2
|
+
max-width: 48rem;
|
|
3
|
+
margin: auto;
|
|
4
|
+
--slide-height: 19rem;
|
|
5
|
+
--slide-spacing: 1rem;
|
|
6
|
+
--slide-size: 70%;
|
|
7
|
+
}
|
|
8
|
+
.embla__viewport {
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
11
|
+
.embla__container {
|
|
12
|
+
display: flex;
|
|
13
|
+
touch-action: pan-y pinch-zoom;
|
|
14
|
+
margin-left: calc(var(--slide-spacing) * -1);
|
|
15
|
+
}
|
|
16
|
+
.embla__slide {
|
|
17
|
+
transform: translate3d(0, 0, 0);
|
|
18
|
+
flex: 0 0 var(--slide-size);
|
|
19
|
+
min-width: 0;
|
|
20
|
+
padding-left: var(--slide-spacing);
|
|
21
|
+
flex: 0 0 100%;
|
|
22
|
+
}
|
|
23
|
+
.embla__slide__number {
|
|
24
|
+
box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
|
|
25
|
+
border-radius: 1.8rem;
|
|
26
|
+
font-size: 4rem;
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
height: var(--slide-height);
|
|
32
|
+
user-select: none;
|
|
33
|
+
}
|
|
34
|
+
.embla__controls {
|
|
35
|
+
display: grid;
|
|
36
|
+
grid-template-columns: auto 1fr;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
gap: 1.2rem;
|
|
39
|
+
margin-top: 1.8rem;
|
|
40
|
+
}
|
|
41
|
+
.embla__buttons {
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: repeat(2, 1fr);
|
|
44
|
+
gap: 0.6rem;
|
|
45
|
+
align-items: center;
|
|
46
|
+
}
|
|
47
|
+
.embla__button {
|
|
48
|
+
-webkit-tap-highlight-color: rgba(var(--text-high-contrast-rgb-value), 0.5);
|
|
49
|
+
-webkit-appearance: none;
|
|
50
|
+
appearance: none;
|
|
51
|
+
background-color: transparent;
|
|
52
|
+
touch-action: manipulation;
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
border: 0;
|
|
57
|
+
padding: 0;
|
|
58
|
+
margin: 0;
|
|
59
|
+
box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
|
|
60
|
+
width: 3.6rem;
|
|
61
|
+
height: 3.6rem;
|
|
62
|
+
z-index: 1;
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
color: var(--text-body);
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
}
|
|
69
|
+
.embla__button:disabled {
|
|
70
|
+
color: var(--detail-high-contrast);
|
|
71
|
+
}
|
|
72
|
+
.embla__button__svg {
|
|
73
|
+
width: 35%;
|
|
74
|
+
height: 35%;
|
|
75
|
+
}
|
|
76
|
+
.embla__dots {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-wrap: wrap;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
align-items: center;
|
|
81
|
+
margin-right: 0;
|
|
82
|
+
height: 50px;
|
|
83
|
+
}
|
|
84
|
+
.embla__dot {
|
|
85
|
+
-webkit-tap-highlight-color: rgba(var(--text-high-contrast-rgb-value), 0.5);
|
|
86
|
+
-webkit-appearance: none;
|
|
87
|
+
appearance: none;
|
|
88
|
+
background-color: transparent;
|
|
89
|
+
touch-action: manipulation;
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
border: 0;
|
|
94
|
+
padding: 0;
|
|
95
|
+
margin: 0;
|
|
96
|
+
width: 2.6rem;
|
|
97
|
+
height: 2.6rem;
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
border-radius: 50%;
|
|
102
|
+
}
|
|
103
|
+
.embla__dot:after {
|
|
104
|
+
box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
|
|
105
|
+
width: 1.4rem;
|
|
106
|
+
height: 1.4rem;
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
content: '';
|
|
111
|
+
}
|
|
112
|
+
.embla__dot--selected:after {
|
|
113
|
+
box-shadow: inset 0 0 0 0.2rem var(--text-body);
|
|
114
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Device {
|
|
2
|
+
name: string;
|
|
3
|
+
platform: string; // ios, android
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
type: 'phone' | 'tablet';
|
|
7
|
+
/**
|
|
8
|
+
* Relative importance for generic targeting and display ordering.
|
|
9
|
+
* 1 = highest importance, 5 = lowest importance
|
|
10
|
+
*/
|
|
11
|
+
importance?: 1 | 2 | 3 | 4 | 5;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type NodeDefaultAttribute = Record<
|
|
2
|
+
string,
|
|
3
|
+
boolean | string | number | null | undefined | string[]
|
|
4
|
+
>;
|
|
5
|
+
|
|
6
|
+
export type Node<T = NodeDefaultAttribute> =
|
|
7
|
+
| null
|
|
8
|
+
| undefined
|
|
9
|
+
| string
|
|
10
|
+
| {}
|
|
11
|
+
| Node<T>[]
|
|
12
|
+
| NodeData<T>;
|
|
13
|
+
|
|
14
|
+
export interface NodeData<T = Record<string, unknown>> {
|
|
15
|
+
type: string;
|
|
16
|
+
children: Node<Record<string, unknown>>;
|
|
17
|
+
attributes?: T;
|
|
18
|
+
key?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TargetedScreenSize } from './TargetedScreenSize';
|
|
2
|
+
|
|
3
|
+
export interface PreviewConfig {
|
|
4
|
+
theme: 'light' | 'dark';
|
|
5
|
+
screenSize: TargetedScreenSize;
|
|
6
|
+
isRtl: boolean;
|
|
7
|
+
screenStyle: {
|
|
8
|
+
light: { backgroundColor: string; color: string };
|
|
9
|
+
dark: { backgroundColor: string; color: string };
|
|
10
|
+
};
|
|
11
|
+
localication: Localication;
|
|
12
|
+
defaultLanguage?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Localication = {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from '../types/Node';
|
|
2
|
+
import { PreviewConfig } from './PreviewConfig';
|
|
3
|
+
|
|
4
|
+
export interface ProjectBase<T> {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
data: T;
|
|
8
|
+
previewConfig: PreviewConfig;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Project extends ProjectBase<Node> {}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Node, NodeData, NodeDefaultAttribute } from '../types/Node';
|
|
2
|
+
|
|
3
|
+
export function isNodeNullOrUndefined<T = NodeDefaultAttribute>(
|
|
4
|
+
node: Node<T>,
|
|
5
|
+
): boolean {
|
|
6
|
+
return node === null || node === undefined;
|
|
7
|
+
}
|
|
8
|
+
export function isNodeString<T = NodeDefaultAttribute>(node: Node<T>): boolean {
|
|
9
|
+
return typeof node === 'string';
|
|
10
|
+
}
|
|
11
|
+
export function isNodeArray<T = NodeDefaultAttribute>(node: Node<T>): boolean {
|
|
12
|
+
return node instanceof Array;
|
|
13
|
+
}
|
|
14
|
+
export function isEmptyObject<T = NodeDefaultAttribute>(
|
|
15
|
+
node: Node<T>,
|
|
16
|
+
): boolean {
|
|
17
|
+
return Object.keys(node as Object).length === 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function analyseNode(node: Node<NodeDefaultAttribute>): {
|
|
21
|
+
valid: boolean;
|
|
22
|
+
message?: string;
|
|
23
|
+
} {
|
|
24
|
+
if (isNodeNullOrUndefined(node)) {
|
|
25
|
+
return {
|
|
26
|
+
valid: true,
|
|
27
|
+
message: 'null or undefined is valid',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isNodeString(node)) {
|
|
32
|
+
return {
|
|
33
|
+
valid: true,
|
|
34
|
+
message: 'string is valid',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isNodeArray(node)) {
|
|
39
|
+
const nodeArray = node as unknown as Node[];
|
|
40
|
+
for (const value of nodeArray) {
|
|
41
|
+
const { valid, message } = analyseNode(value);
|
|
42
|
+
if (!valid) {
|
|
43
|
+
return {
|
|
44
|
+
valid: false,
|
|
45
|
+
message: message,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
// array is valid
|
|
51
|
+
valid: true,
|
|
52
|
+
message: 'Array is valid',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const recordData = node as NodeData;
|
|
56
|
+
if (isEmptyObject(recordData)) {
|
|
57
|
+
return {
|
|
58
|
+
valid: true,
|
|
59
|
+
message: 'empty object is valid',
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
if (recordData.children) {
|
|
63
|
+
const { valid, message } = analyseNode(recordData.children);
|
|
64
|
+
if (!valid) {
|
|
65
|
+
return {
|
|
66
|
+
valid: false,
|
|
67
|
+
message: message,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
valid: true,
|
|
74
|
+
message: 'everthing is valid',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Node, NodeData } from '../types/Node';
|
|
2
|
+
|
|
3
|
+
export const isCarouselProvider = (node: Node): node is NodeData => {
|
|
4
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
5
|
+
return 'type' in node && node.type === 'carouselProvider';
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const isCarousel = (node: Node): node is NodeData => {
|
|
9
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
10
|
+
return 'type' in node && node.type === 'carousel';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const isCarouselItem = (node: Node): node is NodeData => {
|
|
14
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
15
|
+
return 'type' in node && node.type === 'carouselItem';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const isCarouselDots = (node: Node): node is NodeData => {
|
|
19
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
20
|
+
return 'type' in node && node.type === 'carouselDots';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const isCarouselButtons = (node: Node): node is NodeData => {
|
|
24
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
25
|
+
return 'type' in node && node.type === 'carouselButtons';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const isCarouselComponent = (node: Node): boolean => {
|
|
29
|
+
return (
|
|
30
|
+
isCarouselProvider(node) ||
|
|
31
|
+
isCarousel(node) ||
|
|
32
|
+
isCarouselItem(node) ||
|
|
33
|
+
isCarouselDots(node) ||
|
|
34
|
+
isCarouselButtons(node)
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Node, NodeData } from '../types/Node';
|
|
2
|
+
|
|
3
|
+
export const isOnboardProvider = (node: Node): node is NodeData => {
|
|
4
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
5
|
+
return 'type' in node && (node as NodeData).type === 'OnboardProvider';
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const isOnboard = (node: Node): node is NodeData => {
|
|
9
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
10
|
+
return 'type' in node && (node as NodeData).type === 'Onboard';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const isOnboardItem = (node: Node): node is NodeData => {
|
|
14
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
15
|
+
return 'type' in node && (node as NodeData).type === 'OnboardItem';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const isOnboardExpandingDot = (node: Node): node is NodeData => {
|
|
19
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
20
|
+
return 'type' in node && (node as NodeData).type === 'OnboardExpandingDot';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const isOnboardBoardTitle = (node: Node): node is NodeData => {
|
|
24
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
25
|
+
return 'type' in node && (node as NodeData).type === 'OnboardBoardTitle';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const isOnboardSubtitle = (node: Node): node is NodeData => {
|
|
29
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return false;
|
|
30
|
+
return 'type' in node && (node as NodeData).type === 'OnboardSubtitle';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const isOnboardComponent = (node: Node): boolean => {
|
|
34
|
+
return (
|
|
35
|
+
isOnboardProvider(node) ||
|
|
36
|
+
isOnboard(node) ||
|
|
37
|
+
isOnboardItem(node) ||
|
|
38
|
+
isOnboardExpandingDot(node) ||
|
|
39
|
+
isOnboardBoardTitle(node) ||
|
|
40
|
+
isOnboardSubtitle(node) ||
|
|
41
|
+
(function isOnboardButtons(n: Node): n is NodeData {
|
|
42
|
+
if (!n || typeof n !== 'object' || Array.isArray(n)) return false;
|
|
43
|
+
return 'type' in n && (n as NodeData).type === 'OnboardButtons';
|
|
44
|
+
})(node) ||
|
|
45
|
+
(function isOnboardButton(n: Node): n is NodeData {
|
|
46
|
+
if (!n || typeof n !== 'object' || Array.isArray(n)) return false;
|
|
47
|
+
return 'type' in n && (n as NodeData).type === 'OnboardButton';
|
|
48
|
+
})(node) ||
|
|
49
|
+
(function isOnboardImage(n: Node): n is NodeData {
|
|
50
|
+
if (!n || typeof n !== 'object' || Array.isArray(n)) return false;
|
|
51
|
+
return 'type' in n && (n as NodeData).type === 'OnboardImage';
|
|
52
|
+
})(node)
|
|
53
|
+
);
|
|
54
|
+
};
|