@developer_tribe/react-builder 1.0.1 → 1.0.3
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/AttributesEditor.d.ts +3 -1
- package/dist/DeviceMockFrame.d.ts +2 -1
- package/dist/RenderPage.d.ts +5 -3
- package/dist/attributes-editor/Field.d.ts +17 -0
- package/dist/attributes-editor/FieldInfoTooltip.d.ts +7 -0
- package/dist/attributes-editor/LayoutPreviewPicker.d.ts +12 -0
- package/dist/attributes-editor/SpecialCategorySection.d.ts +20 -0
- package/dist/attributes-editor/types.d.ts +14 -0
- package/dist/background.jpg +0 -0
- package/dist/build-components/BackgroundImage/BackgroundImage.d.ts +5 -0
- package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +44 -0
- package/dist/build-components/Button/Button.d.ts +1 -1
- package/dist/build-components/Button/ButtonProps.generated.d.ts +33 -1
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +34 -1
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +32 -0
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +32 -0
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +34 -1
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +34 -1
- package/dist/build-components/Image/ImageProps.generated.d.ts +32 -3
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +34 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +32 -0
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +32 -0
- package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +29 -0
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +11 -5
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +32 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +31 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +32 -5
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +11 -5
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +11 -5
- package/dist/build-components/Text/TextProps.generated.d.ts +11 -5
- package/dist/build-components/View/ViewProps.generated.d.ts +10 -4
- package/dist/build-components/index.d.ts +2 -1
- package/dist/build-components/patterns.generated.d.ts +6288 -136
- package/dist/components/AttributesEditorPanel.d.ts +3 -4
- package/dist/components/Breadcrumb.d.ts +3 -1
- package/dist/components/Builder.d.ts +2 -1
- package/dist/components/BuilderButton.d.ts +9 -0
- package/dist/components/Checkbox.d.ts +17 -0
- package/dist/components/DeviceButton.d.ts +8 -0
- package/dist/components/DeviceNavigationBar.d.ts +10 -0
- package/dist/components/DeviceStatusBar.d.ts +9 -0
- package/dist/components/EditorHeader.d.ts +3 -8
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/mockOS/components/MockLaunchScreenComponent.d.ts +6 -0
- package/dist/mockOS/components/MockOSRouter.d.ts +8 -0
- package/dist/mockOS/components/PermissionModal.d.ts +9 -0
- package/dist/mockOS/context/MockOSContext.d.ts +36 -0
- package/dist/mockOS/hooks/useMockNavigation.d.ts +3 -0
- package/dist/mockOS/hooks/useMockPermission.d.ts +3 -0
- package/dist/mockOS/index.d.ts +9 -0
- package/dist/mockOS/managers/mockPermissionManager.d.ts +10 -0
- package/dist/mockOS/managers/navigationManager.d.ts +17 -0
- package/dist/modals/AddComponentModal.d.ts +8 -0
- package/dist/modals/ColorModal.d.ts +11 -0
- package/dist/modals/DeviceSelectorModal.d.ts +9 -0
- package/dist/modals/LocalicationModal.d.ts +8 -0
- package/dist/modals/Modal.d.ts +12 -0
- package/dist/modals/index.d.ts +5 -0
- package/dist/pages/ProjectPage.d.ts +3 -3
- package/dist/pages/tabs/BuilderPanel.d.ts +8 -0
- package/dist/pages/tabs/{DebugTab.d.ts → SideTool.d.ts} +2 -2
- package/dist/store.d.ts +7 -3
- package/dist/styles.css +1 -1
- package/dist/types/Project.d.ts +11 -0
- package/dist/utils/analyseNode.d.ts +1 -0
- package/dist/utils/extractTextStyle.d.ts +8 -1
- package/dist/utils/extractViewStyle.d.ts +8 -1
- package/dist/utils/parseColor.d.ts +7 -0
- package/dist/utils/patterns.d.ts +24 -0
- package/package.json +2 -1
- package/scripts/prebuild/utils/createGeneratedProps.js +11 -3
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +45 -6
- package/scripts/prebuild/utils/validatePatternJson.js +13 -5
- package/src/AttributesEditor.tsx +493 -310
- package/src/DeviceMockFrame.tsx +21 -37
- package/src/RenderPage.tsx +86 -7
- package/src/assets/images/android.svg +42 -42
- package/src/assets/images/apple.svg +15 -15
- package/src/attributes-editor/Field.tsx +669 -0
- package/src/attributes-editor/FieldInfoTooltip.tsx +49 -0
- package/src/attributes-editor/LayoutPreviewPicker.tsx +199 -0
- package/src/attributes-editor/SpecialCategorySection.tsx +285 -0
- package/src/attributes-editor/types.ts +30 -0
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +87 -0
- package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +60 -0
- package/src/build-components/BackgroundImage/pattern.json +45 -0
- package/src/build-components/Button/Button.tsx +37 -2
- package/src/build-components/Button/ButtonProps.generated.ts +44 -1
- package/src/build-components/Button/pattern.json +31 -2
- package/src/build-components/Carousel/Carousel.tsx +39 -2
- package/src/build-components/Carousel/CarouselProps.generated.ts +46 -1
- package/src/build-components/Carousel/pattern.json +10 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +21 -2
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +43 -0
- package/src/build-components/CarouselButtons/pattern.json +22 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +49 -8
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +43 -0
- package/src/build-components/CarouselDots/pattern.json +15 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +21 -2
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +46 -1
- package/src/build-components/CarouselItem/pattern.json +7 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +21 -2
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +46 -1
- package/src/build-components/CarouselProvider/pattern.json +7 -0
- package/src/build-components/Image/Image.tsx +33 -2
- package/src/build-components/Image/ImageProps.generated.ts +43 -3
- package/src/build-components/Image/pattern.json +46 -3
- package/src/build-components/Onboard/Onboard.tsx +6 -1
- package/src/build-components/Onboard/OnboardProps.generated.ts +46 -1
- package/src/build-components/Onboard/pattern.json +11 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +54 -6
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +43 -0
- package/src/build-components/OnboardButton/pattern.json +71 -5
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +33 -11
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +43 -0
- package/src/build-components/OnboardButtons/pattern.json +70 -4
- package/src/build-components/OnboardDot/OnboardDot.tsx +113 -4
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +29 -0
- package/src/build-components/OnboardDot/pattern.json +55 -2
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +20 -4
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +11 -5
- package/src/build-components/OnboardFooter/pattern.json +58 -2
- package/src/build-components/OnboardImage/OnboardImage.tsx +49 -5
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +43 -3
- package/src/build-components/OnboardImage/pattern.json +21 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +17 -1
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +42 -3
- package/src/build-components/OnboardItem/pattern.json +38 -2
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +52 -18
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +44 -5
- package/src/build-components/OnboardProvider/pattern.json +44 -5
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +11 -5
- package/src/build-components/OnboardSubtitle/pattern.json +7 -1
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +11 -5
- package/src/build-components/OnboardTitle/pattern.json +7 -1
- package/src/build-components/RenderNode.generated.tsx +3 -0
- package/src/build-components/Text/Text.tsx +34 -6
- package/src/build-components/Text/TextProps.generated.ts +11 -5
- package/src/build-components/Text/pattern.json +38 -2
- package/src/build-components/View/View.tsx +33 -6
- package/src/build-components/View/ViewProps.generated.ts +10 -4
- package/src/build-components/View/pattern.json +285 -19
- package/src/build-components/index.ts +5 -0
- package/src/build-components/patterns.generated.ts +6346 -143
- package/src/components/AttributesEditorPanel.tsx +17 -64
- package/src/components/Breadcrumb.tsx +37 -5
- package/src/components/Builder.tsx +311 -108
- package/src/components/BuilderButton.tsx +127 -0
- package/src/components/Checkbox.tsx +81 -0
- package/src/components/DeviceButton.tsx +39 -0
- package/src/components/DeviceNavigationBar.tsx +201 -0
- package/src/components/DeviceStatusBar.tsx +85 -0
- package/src/components/EditorHeader.tsx +26 -74
- package/src/index.ts +2 -2
- package/src/mockOS/components/MockLaunchScreenComponent.tsx +43 -0
- package/src/mockOS/components/MockOSRouter.tsx +123 -0
- package/src/mockOS/components/PermissionModal.tsx +270 -0
- package/src/mockOS/context/MockOSContext.tsx +179 -0
- package/src/mockOS/hooks/useMockNavigation.ts +11 -0
- package/src/mockOS/hooks/useMockPermission.ts +11 -0
- package/src/mockOS/index.ts +26 -0
- package/src/mockOS/managers/mockPermissionManager.ts +54 -0
- package/src/mockOS/managers/navigationManager.ts +91 -0
- package/src/modals/AddComponentModal.tsx +313 -0
- package/src/modals/ColorModal.tsx +425 -0
- package/src/modals/DeviceSelectorModal.tsx +57 -0
- package/src/modals/LocalicationModal.tsx +54 -0
- package/src/modals/Modal.tsx +57 -0
- package/src/modals/index.ts +5 -0
- package/src/pages/ProjectPage.tsx +307 -71
- package/src/pages/tabs/{BuilderTab.tsx → BuilderPanel.tsx} +13 -9
- package/src/pages/tabs/SideTool.tsx +259 -0
- package/src/size-matters/index.ts +27 -5
- package/src/store.ts +13 -5
- package/src/styles/base/_global.scss +404 -0
- package/src/styles/components/_attributes-editor.scss +273 -0
- package/src/styles/components/_editor-shell.scss +212 -0
- package/src/styles/components/_mockos-router.scss +140 -0
- package/src/styles/components/_ui-components.scss +183 -0
- package/src/styles/foundation/_colors.scss +8 -0
- package/src/styles/{_mixins.scss → foundation/_mixins.scss} +5 -4
- package/src/styles/{_reset.scss → foundation/_reset.scss} +5 -2
- package/src/styles/foundation/_sizes.scss +37 -0
- package/src/styles/foundation/_typography.scss +4 -0
- package/src/styles/foundation/_variables.scss +3 -0
- package/src/styles/index.scss +22 -136
- package/src/styles/layout/_builder.scss +124 -0
- package/src/styles/layout/_pages.scss +3 -0
- package/src/styles/modals/_add-component.scss +122 -0
- package/src/styles/modals/_color-modal.scss +159 -0
- package/src/styles/modals/_device-selector.scss +18 -0
- package/src/styles/modals/_localication-modal.scss +68 -0
- package/src/styles/modals/_modal-shell.scss +46 -0
- package/src/styles/utilities/_carousel.scss +125 -0
- package/src/types/Project.ts +14 -0
- package/src/types/images.d.ts +8 -0
- package/src/utils/analyseNode.ts +98 -0
- package/src/utils/extractTextStyle.ts +28 -10
- package/src/utils/extractViewStyle.ts +77 -9
- package/src/utils/parseColor.ts +43 -0
- package/src/utils/patterns.ts +33 -0
- package/dist/build-components/OnboardDot/OnboardExpandingDotProps.generated.d.ts +0 -10
- package/dist/pages/tabs/BuilderTab.d.ts +0 -9
- package/dist/pages/tabs/PreviewTab.d.ts +0 -3
- package/src/build-components/OnboardDot/OnboardExpandingDotProps.generated.ts +0 -20
- package/src/pages/tabs/DebugTab.tsx +0 -23
- package/src/pages/tabs/PreviewTab.tsx +0 -194
- package/src/styles/_variables.scss +0 -27
- package/src/styles/builder.scss +0 -60
- package/src/styles/components.scss +0 -88
- package/src/styles/editor.scss +0 -174
- package/src/styles/global.scss +0 -200
- package/src/styles/pages.scss +0 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"allowUnknownAttributes": false,
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "OnboardTitle",
|
|
6
|
-
"children": "
|
|
6
|
+
"children": "string",
|
|
7
7
|
"extends": "Text",
|
|
8
8
|
"attributes": {}
|
|
9
9
|
},
|
|
@@ -11,5 +11,11 @@
|
|
|
11
11
|
"fontSize": "24@fs",
|
|
12
12
|
"fontWeight": "700",
|
|
13
13
|
"textAlign": "center"
|
|
14
|
+
},
|
|
15
|
+
"meta": {
|
|
16
|
+
"desiredParent": [">OnboardItem", ">OnboardProvider"],
|
|
17
|
+
"label": "Onboard Title",
|
|
18
|
+
"description": "Title text for an onboarding step.",
|
|
19
|
+
"attributes": {}
|
|
14
20
|
}
|
|
15
21
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { other } from './other';
|
|
13
13
|
|
|
14
14
|
// Builder components
|
|
15
|
+
import BackgroundImage from './BackgroundImage/BackgroundImage';
|
|
15
16
|
import Button from './Button/Button';
|
|
16
17
|
import Carousel from './Carousel/Carousel';
|
|
17
18
|
import CarouselButtons from './CarouselButtons/CarouselButtons';
|
|
@@ -51,6 +52,8 @@ function RenderNode({ node }: { node: Node }) {
|
|
|
51
52
|
|
|
52
53
|
const simpleNode = node as NodeData;
|
|
53
54
|
switch (simpleNode?.type) {
|
|
55
|
+
case 'background-image':
|
|
56
|
+
return <BackgroundImage node={simpleNode} />;
|
|
54
57
|
case 'button':
|
|
55
58
|
return <Button node={simpleNode} />;
|
|
56
59
|
case 'carousel':
|
|
@@ -1,22 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { TextComponentProps } from './TextProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
4
|
import { useRenderStore } from '../../store';
|
|
5
5
|
import { extractTextStyle } from '../../utils/extractTextStyle';
|
|
6
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
6
7
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
8
|
|
|
8
9
|
function Text({ node }: TextComponentProps) {
|
|
9
10
|
useLogRender('Text');
|
|
10
11
|
node = useNode(node);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const attributeName = (node as any)?.sourceType ?? node.type ?? 'text';
|
|
14
|
+
const attributeKey = node.key ?? generatedId;
|
|
15
|
+
const { appConfig, projectColors, previewMode, current } = useRenderStore(
|
|
16
|
+
(s) => ({
|
|
17
|
+
appConfig: s.appConfig,
|
|
18
|
+
projectColors: s.projectColors,
|
|
19
|
+
previewMode: s.previewMode,
|
|
20
|
+
current: s.current,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
14
23
|
const { defaultLanguage, localication } = appConfig;
|
|
15
24
|
const keyOrText: string = node.children as string;
|
|
16
|
-
const
|
|
25
|
+
const textStyle = extractTextStyle(node, { appConfig, projectColors });
|
|
26
|
+
const viewStyle = useMemo(
|
|
27
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
28
|
+
[node, appConfig, projectColors],
|
|
29
|
+
);
|
|
30
|
+
const isSelected =
|
|
31
|
+
previewMode &&
|
|
32
|
+
!!current &&
|
|
33
|
+
(current as any)?.key &&
|
|
34
|
+
(node as any)?.key &&
|
|
35
|
+
(current as any).key === (node as any).key;
|
|
36
|
+
const style = {
|
|
37
|
+
...viewStyle,
|
|
38
|
+
...textStyle,
|
|
39
|
+
...(isSelected ? { outline: '2px solid #2684FF' } : {}),
|
|
40
|
+
};
|
|
17
41
|
|
|
18
42
|
return (
|
|
19
|
-
<p
|
|
43
|
+
<p
|
|
44
|
+
attribute-name={attributeName}
|
|
45
|
+
attribute-key={attributeKey}
|
|
46
|
+
style={style}
|
|
47
|
+
>
|
|
20
48
|
{localication?.[defaultLanguage ?? 'en']?.[keyOrText] ?? keyOrText}
|
|
21
49
|
</p>
|
|
22
50
|
);
|
|
@@ -16,6 +16,7 @@ export type JustifyContentOptionType =
|
|
|
16
16
|
| 'space-between'
|
|
17
17
|
| 'space-around'
|
|
18
18
|
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
19
20
|
export type FontWeightOptionType =
|
|
20
21
|
| 'normal'
|
|
21
22
|
| 'bold'
|
|
@@ -38,7 +39,7 @@ export interface TextPropsGenerated {
|
|
|
38
39
|
alignItems?: AlignItemsOptionType;
|
|
39
40
|
justifyContent?: JustifyContentOptionType;
|
|
40
41
|
gap?: string;
|
|
41
|
-
padding?:
|
|
42
|
+
padding?: string;
|
|
42
43
|
paddingHorizontal?: string;
|
|
43
44
|
paddingVertical?: string;
|
|
44
45
|
paddingTop?: string;
|
|
@@ -46,7 +47,6 @@ export interface TextPropsGenerated {
|
|
|
46
47
|
paddingLeft?: string;
|
|
47
48
|
paddingRight?: string;
|
|
48
49
|
margin?: string;
|
|
49
|
-
marginHorizontal?: string;
|
|
50
50
|
marginVertical?: string;
|
|
51
51
|
marginTop?: string;
|
|
52
52
|
marginBottom?: string;
|
|
@@ -54,10 +54,16 @@ export interface TextPropsGenerated {
|
|
|
54
54
|
marginRight?: string;
|
|
55
55
|
backgroundColor?: string;
|
|
56
56
|
borderRadius?: string;
|
|
57
|
-
width?:
|
|
58
|
-
height?:
|
|
57
|
+
width?: string;
|
|
58
|
+
height?: string;
|
|
59
|
+
position?: PositionOptionType;
|
|
60
|
+
top?: string;
|
|
61
|
+
bottom?: string;
|
|
62
|
+
left?: string;
|
|
63
|
+
right?: string;
|
|
64
|
+
zIndex?: number;
|
|
59
65
|
color?: string;
|
|
60
|
-
fontSize?:
|
|
66
|
+
fontSize?: string;
|
|
61
67
|
fontWeight?: FontWeightOptionType;
|
|
62
68
|
textAlign?: TextAlignOptionType;
|
|
63
69
|
};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"children": "string",
|
|
7
7
|
"extends": "View",
|
|
8
8
|
"attributes": {
|
|
9
|
-
"color": "
|
|
10
|
-
"fontSize": "
|
|
9
|
+
"color": "color",
|
|
10
|
+
"fontSize": "size",
|
|
11
11
|
"fontWeight": [
|
|
12
12
|
"normal",
|
|
13
13
|
"bold",
|
|
@@ -23,5 +23,41 @@
|
|
|
23
23
|
],
|
|
24
24
|
"textAlign": ["left", "center", "right", "justify"]
|
|
25
25
|
}
|
|
26
|
+
},
|
|
27
|
+
"meta": {
|
|
28
|
+
"desiredParent": ["all"],
|
|
29
|
+
"label": "Text",
|
|
30
|
+
"description": "Displays simple text.",
|
|
31
|
+
"attributes": {
|
|
32
|
+
"color": {
|
|
33
|
+
"label": "Color",
|
|
34
|
+
"description": "Text color.",
|
|
35
|
+
"category": "style",
|
|
36
|
+
"specialCategory": null,
|
|
37
|
+
"sort": 1
|
|
38
|
+
},
|
|
39
|
+
"fontSize": {
|
|
40
|
+
"label": "Font Size",
|
|
41
|
+
"description": "Text size.",
|
|
42
|
+
"category": "style",
|
|
43
|
+
"specialCategory": null,
|
|
44
|
+
"sort": 2,
|
|
45
|
+
"preferedScale": "s"
|
|
46
|
+
},
|
|
47
|
+
"fontWeight": {
|
|
48
|
+
"label": "Font Weight",
|
|
49
|
+
"description": "Text weight.",
|
|
50
|
+
"category": "style",
|
|
51
|
+
"specialCategory": null,
|
|
52
|
+
"sort": 3
|
|
53
|
+
},
|
|
54
|
+
"textAlign": {
|
|
55
|
+
"label": "Text Align",
|
|
56
|
+
"description": "Text alignment.",
|
|
57
|
+
"category": "style",
|
|
58
|
+
"specialCategory": null,
|
|
59
|
+
"sort": 4
|
|
60
|
+
}
|
|
61
|
+
}
|
|
26
62
|
}
|
|
27
63
|
}
|
|
@@ -1,19 +1,46 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
ViewComponentProps,
|
|
4
|
-
ViewPropsGenerated,
|
|
5
|
-
} from './ViewProps.generated';
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
|
+
import type { ViewComponentProps } from './ViewProps.generated';
|
|
6
3
|
import RenderNode from '../RenderNode.generated';
|
|
7
4
|
import { Node } from '../../types/Node';
|
|
8
5
|
import useNode from '../useNode';
|
|
6
|
+
import { useRenderStore } from '../../store';
|
|
9
7
|
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
10
8
|
import { useLogRender } from '../../utils/useLogRender';
|
|
11
9
|
|
|
12
10
|
export function View({ node }: ViewComponentProps) {
|
|
13
11
|
useLogRender('View');
|
|
14
12
|
node = useNode(node);
|
|
13
|
+
const generatedId = useId();
|
|
14
|
+
const attributeName = (node as any)?.sourceType ?? node.type ?? 'view';
|
|
15
|
+
const attributeKey = node.key ?? generatedId;
|
|
16
|
+
const { previewMode, current, appConfig, projectColors } = useRenderStore(
|
|
17
|
+
(s) => ({
|
|
18
|
+
previewMode: s.previewMode,
|
|
19
|
+
current: s.current,
|
|
20
|
+
appConfig: s.appConfig,
|
|
21
|
+
projectColors: s.projectColors,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
const baseStyle = useMemo(
|
|
25
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
26
|
+
[node, appConfig, projectColors],
|
|
27
|
+
);
|
|
28
|
+
const isSelected =
|
|
29
|
+
previewMode &&
|
|
30
|
+
!!current &&
|
|
31
|
+
(current as any)?.key &&
|
|
32
|
+
(node as any)?.key &&
|
|
33
|
+
(current as any).key === (node as any).key;
|
|
34
|
+
const viewStyle = isSelected
|
|
35
|
+
? { ...baseStyle, outline: '2px solid #2684FF' }
|
|
36
|
+
: baseStyle;
|
|
15
37
|
return (
|
|
16
|
-
<div
|
|
38
|
+
<div
|
|
39
|
+
attribute-name={attributeName}
|
|
40
|
+
attribute-key={attributeKey}
|
|
41
|
+
style={viewStyle}
|
|
42
|
+
className="scroll-container"
|
|
43
|
+
>
|
|
17
44
|
<RenderNode node={node.children as Node} />
|
|
18
45
|
</div>
|
|
19
46
|
);
|
|
@@ -16,6 +16,7 @@ export type JustifyContentOptionType =
|
|
|
16
16
|
| 'space-between'
|
|
17
17
|
| 'space-around'
|
|
18
18
|
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
19
20
|
|
|
20
21
|
export interface ViewPropsGenerated {
|
|
21
22
|
child: string;
|
|
@@ -25,7 +26,7 @@ export interface ViewPropsGenerated {
|
|
|
25
26
|
alignItems?: AlignItemsOptionType;
|
|
26
27
|
justifyContent?: JustifyContentOptionType;
|
|
27
28
|
gap?: string;
|
|
28
|
-
padding?:
|
|
29
|
+
padding?: string;
|
|
29
30
|
paddingHorizontal?: string;
|
|
30
31
|
paddingVertical?: string;
|
|
31
32
|
paddingTop?: string;
|
|
@@ -33,7 +34,6 @@ export interface ViewPropsGenerated {
|
|
|
33
34
|
paddingLeft?: string;
|
|
34
35
|
paddingRight?: string;
|
|
35
36
|
margin?: string;
|
|
36
|
-
marginHorizontal?: string;
|
|
37
37
|
marginVertical?: string;
|
|
38
38
|
marginTop?: string;
|
|
39
39
|
marginBottom?: string;
|
|
@@ -41,8 +41,14 @@ export interface ViewPropsGenerated {
|
|
|
41
41
|
marginRight?: string;
|
|
42
42
|
backgroundColor?: string;
|
|
43
43
|
borderRadius?: string;
|
|
44
|
-
width?:
|
|
45
|
-
height?:
|
|
44
|
+
width?: string;
|
|
45
|
+
height?: string;
|
|
46
|
+
position?: PositionOptionType;
|
|
47
|
+
top?: string;
|
|
48
|
+
bottom?: string;
|
|
49
|
+
left?: string;
|
|
50
|
+
right?: string;
|
|
51
|
+
zIndex?: number;
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
54
|
|
|
@@ -16,25 +16,291 @@
|
|
|
16
16
|
"space-around",
|
|
17
17
|
"space-evenly"
|
|
18
18
|
],
|
|
19
|
-
"gap": "
|
|
20
|
-
"padding": "
|
|
21
|
-
"paddingHorizontal": "
|
|
22
|
-
"paddingVertical": "
|
|
23
|
-
"paddingTop": "
|
|
24
|
-
"paddingBottom": "
|
|
25
|
-
"paddingLeft": "
|
|
26
|
-
"paddingRight": "
|
|
27
|
-
"margin": "
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
19
|
+
"gap": "size",
|
|
20
|
+
"padding": "size",
|
|
21
|
+
"paddingHorizontal": "size",
|
|
22
|
+
"paddingVertical": "size",
|
|
23
|
+
"paddingTop": "size",
|
|
24
|
+
"paddingBottom": "size",
|
|
25
|
+
"paddingLeft": "size",
|
|
26
|
+
"paddingRight": "size",
|
|
27
|
+
"margin": "size",
|
|
28
|
+
"marginVertical": "size",
|
|
29
|
+
"marginTop": "size",
|
|
30
|
+
"marginBottom": "size",
|
|
31
|
+
"marginLeft": "size",
|
|
32
|
+
"marginRight": "size",
|
|
33
|
+
"backgroundColor": "color",
|
|
34
|
+
"borderRadius": "size",
|
|
35
|
+
"width": "size",
|
|
36
|
+
"height": "size",
|
|
37
|
+
"position": ["relative", "absolute"],
|
|
38
|
+
"top": "size",
|
|
39
|
+
"bottom": "size",
|
|
40
|
+
"left": "size",
|
|
41
|
+
"right": "size",
|
|
42
|
+
"zIndex": "number"
|
|
43
|
+
},
|
|
44
|
+
"defaults": {
|
|
45
|
+
"flexDirection": "column"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"meta": {
|
|
49
|
+
"desiredParent": ["all"],
|
|
50
|
+
"label": "View",
|
|
51
|
+
"description": "Base layout container.",
|
|
52
|
+
"specialCategories": {
|
|
53
|
+
"padding": {
|
|
54
|
+
"label": "Padding",
|
|
55
|
+
"description": "Uniform padding on all sides.",
|
|
56
|
+
"category": "container",
|
|
57
|
+
"sort": 1
|
|
58
|
+
},
|
|
59
|
+
"margin": {
|
|
60
|
+
"label": "Margin",
|
|
61
|
+
"description": "Uniform margin on all sides.",
|
|
62
|
+
"category": "container",
|
|
63
|
+
"sort": 2
|
|
64
|
+
},
|
|
65
|
+
"size": {
|
|
66
|
+
"label": "Size",
|
|
67
|
+
"description": "Fixed dimensions.",
|
|
68
|
+
"category": "container",
|
|
69
|
+
"sort": 3
|
|
70
|
+
},
|
|
71
|
+
"offset": {
|
|
72
|
+
"label": "Offset",
|
|
73
|
+
"description": "Absolute positioning offsets.",
|
|
74
|
+
"category": "container",
|
|
75
|
+
"sort": 4
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"attributes": {
|
|
79
|
+
"scrollable": {
|
|
80
|
+
"label": "Scrollable",
|
|
81
|
+
"description": "Turns scroll interaction on.",
|
|
82
|
+
"category": "container",
|
|
83
|
+
"specialCategory": null,
|
|
84
|
+
"sort": -1
|
|
85
|
+
},
|
|
86
|
+
"flexDirection": {
|
|
87
|
+
"label": "Flex Direction",
|
|
88
|
+
"description": "Sets row or column layout.",
|
|
89
|
+
"category": "container",
|
|
90
|
+
"specialCategory": null,
|
|
91
|
+
"sort": 4
|
|
92
|
+
},
|
|
93
|
+
"alignItems": {
|
|
94
|
+
"label": "Align Items",
|
|
95
|
+
"description": "Controls cross-axis alignment.",
|
|
96
|
+
"category": "container",
|
|
97
|
+
"specialCategory": null,
|
|
98
|
+
"sort": 3
|
|
99
|
+
},
|
|
100
|
+
"justifyContent": {
|
|
101
|
+
"label": "Justify Content",
|
|
102
|
+
"description": "Controls main-axis alignment.",
|
|
103
|
+
"category": "container",
|
|
104
|
+
"specialCategory": null,
|
|
105
|
+
"sort": 5
|
|
106
|
+
},
|
|
107
|
+
"gap": {
|
|
108
|
+
"label": "Gap",
|
|
109
|
+
"description": "Space between children.",
|
|
110
|
+
"category": "container",
|
|
111
|
+
"specialCategory": null,
|
|
112
|
+
"sort": 10,
|
|
113
|
+
"preferedScale": "s"
|
|
114
|
+
},
|
|
115
|
+
"padding": {
|
|
116
|
+
"label": "Padding",
|
|
117
|
+
"description": "Uniform padding on all sides.",
|
|
118
|
+
"category": "container",
|
|
119
|
+
"specialCategory": "padding",
|
|
120
|
+
"sort": 6,
|
|
121
|
+
"preferedScale": "s"
|
|
122
|
+
},
|
|
123
|
+
"paddingHorizontal": {
|
|
124
|
+
"label": "Padding Horizontal",
|
|
125
|
+
"description": "Left and right padding.",
|
|
126
|
+
"category": "container",
|
|
127
|
+
"specialCategory": "padding",
|
|
128
|
+
"sort": 7,
|
|
129
|
+
"preferedScale": "s"
|
|
130
|
+
},
|
|
131
|
+
"paddingVertical": {
|
|
132
|
+
"label": "Padding Vertical",
|
|
133
|
+
"description": "Top and bottom padding.",
|
|
134
|
+
"category": "container",
|
|
135
|
+
"specialCategory": "padding",
|
|
136
|
+
"sort": 8,
|
|
137
|
+
"preferedScale": "vs"
|
|
138
|
+
},
|
|
139
|
+
"paddingTop": {
|
|
140
|
+
"label": "Padding Top",
|
|
141
|
+
"description": "Top padding only.",
|
|
142
|
+
"category": "container",
|
|
143
|
+
"specialCategory": "padding",
|
|
144
|
+
"sort": 9,
|
|
145
|
+
"preferedScale": "vs"
|
|
146
|
+
},
|
|
147
|
+
"paddingBottom": {
|
|
148
|
+
"label": "Padding Bottom",
|
|
149
|
+
"description": "Bottom padding only.",
|
|
150
|
+
"category": "container",
|
|
151
|
+
"specialCategory": "padding",
|
|
152
|
+
"sort": 10,
|
|
153
|
+
"preferedScale": "vs"
|
|
154
|
+
},
|
|
155
|
+
"paddingLeft": {
|
|
156
|
+
"label": "Padding Left",
|
|
157
|
+
"description": "Left padding only.",
|
|
158
|
+
"category": "container",
|
|
159
|
+
"specialCategory": "padding",
|
|
160
|
+
"sort": 11,
|
|
161
|
+
"preferedScale": "s"
|
|
162
|
+
},
|
|
163
|
+
"paddingRight": {
|
|
164
|
+
"label": "Padding Right",
|
|
165
|
+
"description": "Right padding only.",
|
|
166
|
+
"category": "container",
|
|
167
|
+
"specialCategory": "padding",
|
|
168
|
+
"sort": 12,
|
|
169
|
+
"preferedScale": "s"
|
|
170
|
+
},
|
|
171
|
+
"margin": {
|
|
172
|
+
"label": "Margin",
|
|
173
|
+
"description": "Uniform margin on all sides.",
|
|
174
|
+
"category": "container",
|
|
175
|
+
"specialCategory": "margin",
|
|
176
|
+
"sort": 13,
|
|
177
|
+
"preferedScale": "s"
|
|
178
|
+
},
|
|
179
|
+
"marginHorizontal": {
|
|
180
|
+
"label": "Margin Horizontal",
|
|
181
|
+
"description": "Left and right margin.",
|
|
182
|
+
"category": "container",
|
|
183
|
+
"specialCategory": "margin",
|
|
184
|
+
"sort": 14,
|
|
185
|
+
"preferedScale": "s"
|
|
186
|
+
},
|
|
187
|
+
"marginVertical": {
|
|
188
|
+
"label": "Margin Vertical",
|
|
189
|
+
"description": "Top and bottom margin.",
|
|
190
|
+
"category": "container",
|
|
191
|
+
"specialCategory": "margin",
|
|
192
|
+
"sort": 15,
|
|
193
|
+
"preferedScale": "vs"
|
|
194
|
+
},
|
|
195
|
+
"marginTop": {
|
|
196
|
+
"label": "Margin Top",
|
|
197
|
+
"description": "Top margin only.",
|
|
198
|
+
"category": "container",
|
|
199
|
+
"specialCategory": "margin",
|
|
200
|
+
"sort": 16,
|
|
201
|
+
"preferedScale": "vs"
|
|
202
|
+
},
|
|
203
|
+
"marginBottom": {
|
|
204
|
+
"label": "Margin Bottom",
|
|
205
|
+
"description": "Bottom margin only.",
|
|
206
|
+
"category": "container",
|
|
207
|
+
"specialCategory": "margin",
|
|
208
|
+
"sort": 17,
|
|
209
|
+
"preferedScale": "vs"
|
|
210
|
+
},
|
|
211
|
+
"marginLeft": {
|
|
212
|
+
"label": "Margin Left",
|
|
213
|
+
"description": "Left margin only.",
|
|
214
|
+
"category": "container",
|
|
215
|
+
"specialCategory": "margin",
|
|
216
|
+
"sort": 18,
|
|
217
|
+
"preferedScale": "s"
|
|
218
|
+
},
|
|
219
|
+
"marginRight": {
|
|
220
|
+
"label": "Margin Right",
|
|
221
|
+
"description": "Right margin only.",
|
|
222
|
+
"category": "container",
|
|
223
|
+
"specialCategory": "margin",
|
|
224
|
+
"sort": 19,
|
|
225
|
+
"preferedScale": "s"
|
|
226
|
+
},
|
|
227
|
+
"backgroundColor": {
|
|
228
|
+
"label": "Background Color",
|
|
229
|
+
"description": "Background fill color.",
|
|
230
|
+
"category": "style",
|
|
231
|
+
"specialCategory": null,
|
|
232
|
+
"sort": 20
|
|
233
|
+
},
|
|
234
|
+
"borderRadius": {
|
|
235
|
+
"label": "Border Radius",
|
|
236
|
+
"description": "Corner rounding amount.",
|
|
237
|
+
"category": "style",
|
|
238
|
+
"specialCategory": null,
|
|
239
|
+
"sort": 21,
|
|
240
|
+
"preferedScale": "s"
|
|
241
|
+
},
|
|
242
|
+
"width": {
|
|
243
|
+
"label": "Width",
|
|
244
|
+
"description": "Fixed width value.",
|
|
245
|
+
"category": "container",
|
|
246
|
+
"specialCategory": "size",
|
|
247
|
+
"sort": 0,
|
|
248
|
+
"preferedScale": "s"
|
|
249
|
+
},
|
|
250
|
+
"height": {
|
|
251
|
+
"label": "Height",
|
|
252
|
+
"description": "Fixed height value.",
|
|
253
|
+
"category": "container",
|
|
254
|
+
"specialCategory": "size",
|
|
255
|
+
"sort": 1,
|
|
256
|
+
"preferedScale": "vs"
|
|
257
|
+
},
|
|
258
|
+
"position": {
|
|
259
|
+
"label": "Position",
|
|
260
|
+
"description": "Sets layout positioning mode.",
|
|
261
|
+
"category": "container",
|
|
262
|
+
"specialCategory": null,
|
|
263
|
+
"sort": 2
|
|
264
|
+
},
|
|
265
|
+
"top": {
|
|
266
|
+
"label": "Top",
|
|
267
|
+
"description": "Offset from the top edge.",
|
|
268
|
+
"category": "container",
|
|
269
|
+
"specialCategory": "offset",
|
|
270
|
+
"sort": 22,
|
|
271
|
+
"preferedScale": "vs"
|
|
272
|
+
},
|
|
273
|
+
"bottom": {
|
|
274
|
+
"label": "Bottom",
|
|
275
|
+
"description": "Offset from the bottom edge.",
|
|
276
|
+
"category": "container",
|
|
277
|
+
"specialCategory": "offset",
|
|
278
|
+
"sort": 23,
|
|
279
|
+
"preferedScale": "vs"
|
|
280
|
+
},
|
|
281
|
+
"left": {
|
|
282
|
+
"label": "Left",
|
|
283
|
+
"description": "Offset from the left edge.",
|
|
284
|
+
"category": "container",
|
|
285
|
+
"specialCategory": "offset",
|
|
286
|
+
"sort": 24,
|
|
287
|
+
"preferedScale": "s"
|
|
288
|
+
},
|
|
289
|
+
"right": {
|
|
290
|
+
"label": "Right",
|
|
291
|
+
"description": "Offset from the right edge.",
|
|
292
|
+
"category": "container",
|
|
293
|
+
"specialCategory": "offset",
|
|
294
|
+
"sort": 25,
|
|
295
|
+
"preferedScale": "s"
|
|
296
|
+
},
|
|
297
|
+
"zIndex": {
|
|
298
|
+
"label": "Z-Index",
|
|
299
|
+
"description": "Controls stacking order.",
|
|
300
|
+
"category": "container",
|
|
301
|
+
"specialCategory": null,
|
|
302
|
+
"sort": 26
|
|
303
|
+
}
|
|
38
304
|
}
|
|
39
305
|
}
|
|
40
306
|
}
|
|
@@ -5,6 +5,7 @@ export { default as RenderNode } from './RenderNode.generated';
|
|
|
5
5
|
export { patterns } from './patterns.generated';
|
|
6
6
|
|
|
7
7
|
export const allcomponentNames = [
|
|
8
|
+
'background-image',
|
|
8
9
|
'button',
|
|
9
10
|
'carousel',
|
|
10
11
|
'carouselButtons',
|
|
@@ -26,6 +27,10 @@ export const allcomponentNames = [
|
|
|
26
27
|
'view',
|
|
27
28
|
] as const;
|
|
28
29
|
|
|
30
|
+
export type {
|
|
31
|
+
BackgroundImagePropsGenerated,
|
|
32
|
+
BackgroundImageComponentProps,
|
|
33
|
+
} from './BackgroundImage/BackgroundImageProps.generated';
|
|
29
34
|
export type {
|
|
30
35
|
ButtonPropsGenerated,
|
|
31
36
|
ButtonComponentProps,
|