@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
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "carouselItem",
|
|
6
6
|
"children": "node",
|
|
7
|
+
"extends": "View",
|
|
8
|
+
"attributes": {}
|
|
9
|
+
},
|
|
10
|
+
"meta": {
|
|
11
|
+
"desiredParent": ["=Carousel"],
|
|
12
|
+
"label": "Carousel Item",
|
|
13
|
+
"description": "Single slide inside a carousel.",
|
|
7
14
|
"attributes": {}
|
|
8
15
|
}
|
|
9
16
|
}
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import React, { createContext } from 'react';
|
|
1
|
+
import React, { createContext, useId, useMemo } from 'react';
|
|
2
2
|
import type { CarouselProviderComponentProps } from './CarouselProviderProps.generated';
|
|
3
3
|
import { RenderNode } from '../..';
|
|
4
4
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
5
5
|
import useNode from '../useNode';
|
|
6
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
7
|
+
import { useRenderStore } from '../../store';
|
|
6
8
|
|
|
7
9
|
export const carouselContext = createContext<any>(undefined);
|
|
8
10
|
function CarouselProvider({ node }: CarouselProviderComponentProps) {
|
|
9
11
|
node = useNode(node);
|
|
10
12
|
const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
|
|
13
|
+
const generatedId = useId();
|
|
14
|
+
const attributeName =
|
|
15
|
+
(node as any)?.sourceType ?? node.type ?? 'carouselProvider';
|
|
16
|
+
const attributeKey = node.key ?? generatedId;
|
|
17
|
+
const { appConfig, projectColors } = useRenderStore((s) => ({
|
|
18
|
+
appConfig: s.appConfig,
|
|
19
|
+
projectColors: s.projectColors,
|
|
20
|
+
}));
|
|
21
|
+
const viewStyle = useMemo(
|
|
22
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
23
|
+
[node, appConfig, projectColors],
|
|
24
|
+
);
|
|
11
25
|
return (
|
|
12
26
|
<carouselContext.Provider value={emblaApi}>
|
|
13
|
-
<div
|
|
27
|
+
<div
|
|
28
|
+
attribute-name={attributeName}
|
|
29
|
+
attribute-key={attributeKey}
|
|
30
|
+
className="carousel-provider"
|
|
31
|
+
style={viewStyle}
|
|
32
|
+
>
|
|
14
33
|
<div className="embla">
|
|
15
34
|
<div className="embla__viewport" ref={emblaRef}>
|
|
16
35
|
{node.children && <RenderNode node={node.children} />}
|
|
@@ -2,9 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
import type { NodeData } from '../../types/Node';
|
|
4
4
|
|
|
5
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
6
|
+
export type AlignItemsOptionType =
|
|
7
|
+
| 'flex-start'
|
|
8
|
+
| 'center'
|
|
9
|
+
| 'flex-end'
|
|
10
|
+
| 'stretch'
|
|
11
|
+
| 'baseline';
|
|
12
|
+
export type JustifyContentOptionType =
|
|
13
|
+
| 'flex-start'
|
|
14
|
+
| 'center'
|
|
15
|
+
| 'flex-end'
|
|
16
|
+
| 'space-between'
|
|
17
|
+
| 'space-around'
|
|
18
|
+
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
20
|
+
|
|
5
21
|
export interface CarouselProviderPropsGenerated {
|
|
6
22
|
child: string;
|
|
7
|
-
attributes: {
|
|
23
|
+
attributes: {
|
|
24
|
+
scrollable?: boolean;
|
|
25
|
+
flexDirection?: FlexDirectionOptionType;
|
|
26
|
+
alignItems?: AlignItemsOptionType;
|
|
27
|
+
justifyContent?: JustifyContentOptionType;
|
|
28
|
+
gap?: string;
|
|
29
|
+
padding?: string;
|
|
30
|
+
paddingHorizontal?: string;
|
|
31
|
+
paddingVertical?: string;
|
|
32
|
+
paddingTop?: string;
|
|
33
|
+
paddingBottom?: string;
|
|
34
|
+
paddingLeft?: string;
|
|
35
|
+
paddingRight?: string;
|
|
36
|
+
margin?: string;
|
|
37
|
+
marginVertical?: string;
|
|
38
|
+
marginTop?: string;
|
|
39
|
+
marginBottom?: string;
|
|
40
|
+
marginLeft?: string;
|
|
41
|
+
marginRight?: string;
|
|
42
|
+
backgroundColor?: string;
|
|
43
|
+
borderRadius?: string;
|
|
44
|
+
width?: string;
|
|
45
|
+
height?: string;
|
|
46
|
+
position?: PositionOptionType;
|
|
47
|
+
top?: string;
|
|
48
|
+
bottom?: string;
|
|
49
|
+
left?: string;
|
|
50
|
+
right?: string;
|
|
51
|
+
zIndex?: number;
|
|
52
|
+
};
|
|
8
53
|
}
|
|
9
54
|
|
|
10
55
|
export interface CarouselProviderComponentProps {
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "carouselProvider",
|
|
6
6
|
"children": "node",
|
|
7
|
+
"extends": "View",
|
|
8
|
+
"attributes": {}
|
|
9
|
+
},
|
|
10
|
+
"meta": {
|
|
11
|
+
"desiredParent": ["root", ">View"],
|
|
12
|
+
"label": "Carousel Provider",
|
|
13
|
+
"description": "Provides carousel context to its children.",
|
|
7
14
|
"attributes": {}
|
|
8
15
|
}
|
|
9
16
|
}
|
|
@@ -1,19 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { ImageComponentProps } from './ImageProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
+
import { useRenderStore } from '../../store';
|
|
4
5
|
import { extractImageStyle } from '../../utils/extractImageStyle';
|
|
6
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
5
7
|
import { useLogRender } from '../../utils/useLogRender';
|
|
6
8
|
|
|
7
9
|
function Image({ node }: ImageComponentProps) {
|
|
8
10
|
useLogRender('Image');
|
|
9
11
|
node = useNode(node);
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const attributeName = (node as any)?.sourceType ?? node.type ?? 'image';
|
|
14
|
+
const attributeKey = node.key ?? generatedId;
|
|
15
|
+
const { previewMode, current, appConfig, projectColors } = useRenderStore(
|
|
16
|
+
(s) => ({
|
|
17
|
+
previewMode: s.previewMode,
|
|
18
|
+
current: s.current,
|
|
19
|
+
appConfig: s.appConfig,
|
|
20
|
+
projectColors: s.projectColors,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
const viewStyle = useMemo(
|
|
24
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
25
|
+
[node, appConfig, projectColors],
|
|
26
|
+
);
|
|
27
|
+
const imageStyle = extractImageStyle(node);
|
|
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 style = {
|
|
35
|
+
...viewStyle,
|
|
36
|
+
...imageStyle,
|
|
37
|
+
...(isSelected ? { outline: '2px solid #2684FF' } : {}),
|
|
38
|
+
};
|
|
10
39
|
return (
|
|
11
40
|
<img
|
|
12
41
|
key={node.key}
|
|
42
|
+
attribute-name={attributeName}
|
|
43
|
+
attribute-key={attributeKey}
|
|
13
44
|
src={node.attributes?.src}
|
|
14
45
|
width={node.attributes?.width}
|
|
15
46
|
height={node.attributes?.height}
|
|
16
|
-
style={
|
|
47
|
+
style={style}
|
|
17
48
|
alt=""
|
|
18
49
|
/>
|
|
19
50
|
);
|
|
@@ -2,16 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
import type { NodeData } from '../../types/Node';
|
|
4
4
|
|
|
5
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
6
|
+
export type AlignItemsOptionType =
|
|
7
|
+
| 'flex-start'
|
|
8
|
+
| 'center'
|
|
9
|
+
| 'flex-end'
|
|
10
|
+
| 'stretch'
|
|
11
|
+
| 'baseline';
|
|
12
|
+
export type JustifyContentOptionType =
|
|
13
|
+
| 'flex-start'
|
|
14
|
+
| 'center'
|
|
15
|
+
| 'flex-end'
|
|
16
|
+
| 'space-between'
|
|
17
|
+
| 'space-around'
|
|
18
|
+
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
5
20
|
export type ResizeModeOptionType = 'cover' | 'contain' | 'stretch' | 'center';
|
|
6
21
|
|
|
7
22
|
export interface ImagePropsGenerated {
|
|
8
23
|
child: string;
|
|
9
24
|
attributes: {
|
|
25
|
+
scrollable?: boolean;
|
|
26
|
+
flexDirection?: FlexDirectionOptionType;
|
|
27
|
+
alignItems?: AlignItemsOptionType;
|
|
28
|
+
justifyContent?: JustifyContentOptionType;
|
|
29
|
+
gap?: string;
|
|
30
|
+
padding?: string;
|
|
31
|
+
paddingHorizontal?: string;
|
|
32
|
+
paddingVertical?: string;
|
|
33
|
+
paddingTop?: string;
|
|
34
|
+
paddingBottom?: string;
|
|
35
|
+
paddingLeft?: string;
|
|
36
|
+
paddingRight?: string;
|
|
37
|
+
margin?: string;
|
|
38
|
+
marginVertical?: string;
|
|
39
|
+
marginTop?: string;
|
|
40
|
+
marginBottom?: string;
|
|
41
|
+
marginLeft?: string;
|
|
42
|
+
marginRight?: string;
|
|
43
|
+
backgroundColor?: string;
|
|
44
|
+
borderRadius?: string;
|
|
45
|
+
width?: string;
|
|
46
|
+
height?: string;
|
|
47
|
+
position?: PositionOptionType;
|
|
48
|
+
top?: string;
|
|
49
|
+
bottom?: string;
|
|
50
|
+
left?: string;
|
|
51
|
+
right?: string;
|
|
52
|
+
zIndex?: number;
|
|
10
53
|
src?: string;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
54
|
resizeMode?: ResizeModeOptionType;
|
|
14
|
-
borderRadius?: number;
|
|
15
55
|
};
|
|
16
56
|
}
|
|
17
57
|
|
|
@@ -4,12 +4,55 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "image",
|
|
6
6
|
"children": "never",
|
|
7
|
+
"extends": "View",
|
|
7
8
|
"attributes": {
|
|
8
9
|
"src": "string",
|
|
9
|
-
"width": "
|
|
10
|
-
"height": "
|
|
10
|
+
"width": "size",
|
|
11
|
+
"height": "size",
|
|
11
12
|
"resizeMode": ["cover", "contain", "stretch", "center"],
|
|
12
|
-
"borderRadius": "
|
|
13
|
+
"borderRadius": "size"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"meta": {
|
|
17
|
+
"desiredParent": ["all"],
|
|
18
|
+
"label": "Image",
|
|
19
|
+
"description": "Shows an image or graphic.",
|
|
20
|
+
"attributes": {
|
|
21
|
+
"src": {
|
|
22
|
+
"label": "Src",
|
|
23
|
+
"description": "Image source URL.",
|
|
24
|
+
"category": "other",
|
|
25
|
+
"specialCategory": null,
|
|
26
|
+
"sort": 1
|
|
27
|
+
},
|
|
28
|
+
"width": {
|
|
29
|
+
"label": "Width",
|
|
30
|
+
"description": "Image width.",
|
|
31
|
+
"category": "container",
|
|
32
|
+
"specialCategory": null,
|
|
33
|
+
"sort": 2
|
|
34
|
+
},
|
|
35
|
+
"height": {
|
|
36
|
+
"label": "Height",
|
|
37
|
+
"description": "Image height.",
|
|
38
|
+
"category": "container",
|
|
39
|
+
"specialCategory": null,
|
|
40
|
+
"sort": 3
|
|
41
|
+
},
|
|
42
|
+
"resizeMode": {
|
|
43
|
+
"label": "Resize Mode",
|
|
44
|
+
"description": "How the image fits the frame.",
|
|
45
|
+
"category": "style",
|
|
46
|
+
"specialCategory": null,
|
|
47
|
+
"sort": 4
|
|
48
|
+
},
|
|
49
|
+
"borderRadius": {
|
|
50
|
+
"label": "Border Radius",
|
|
51
|
+
"description": "Corner rounding.",
|
|
52
|
+
"category": "style",
|
|
53
|
+
"specialCategory": null,
|
|
54
|
+
"sort": 5
|
|
55
|
+
}
|
|
13
56
|
}
|
|
14
57
|
}
|
|
15
58
|
}
|
|
@@ -7,7 +7,12 @@ import { useLogRender } from '../../utils/useLogRender';
|
|
|
7
7
|
function Onboard({ node }: OnboardComponentProps) {
|
|
8
8
|
useLogRender('Onboard');
|
|
9
9
|
node = useNode(node);
|
|
10
|
-
|
|
10
|
+
const attributeName = node.type ?? 'Onboard';
|
|
11
|
+
return (
|
|
12
|
+
<Carousel
|
|
13
|
+
node={{ ...node, type: 'carousel', sourceType: attributeName } as any}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export default React.memo(Onboard);
|
|
@@ -2,9 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
import type { NodeData } from '../../types/Node';
|
|
4
4
|
|
|
5
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
6
|
+
export type AlignItemsOptionType =
|
|
7
|
+
| 'flex-start'
|
|
8
|
+
| 'center'
|
|
9
|
+
| 'flex-end'
|
|
10
|
+
| 'stretch'
|
|
11
|
+
| 'baseline';
|
|
12
|
+
export type JustifyContentOptionType =
|
|
13
|
+
| 'flex-start'
|
|
14
|
+
| 'center'
|
|
15
|
+
| 'flex-end'
|
|
16
|
+
| 'space-between'
|
|
17
|
+
| 'space-around'
|
|
18
|
+
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
20
|
+
|
|
5
21
|
export interface OnboardPropsGenerated {
|
|
6
22
|
child: string;
|
|
7
|
-
attributes: {
|
|
23
|
+
attributes: {
|
|
24
|
+
scrollable?: boolean;
|
|
25
|
+
flexDirection?: FlexDirectionOptionType;
|
|
26
|
+
alignItems?: AlignItemsOptionType;
|
|
27
|
+
justifyContent?: JustifyContentOptionType;
|
|
28
|
+
gap?: string;
|
|
29
|
+
padding?: string;
|
|
30
|
+
paddingHorizontal?: string;
|
|
31
|
+
paddingVertical?: string;
|
|
32
|
+
paddingTop?: string;
|
|
33
|
+
paddingBottom?: string;
|
|
34
|
+
paddingLeft?: string;
|
|
35
|
+
paddingRight?: string;
|
|
36
|
+
margin?: string;
|
|
37
|
+
marginVertical?: string;
|
|
38
|
+
marginTop?: string;
|
|
39
|
+
marginBottom?: string;
|
|
40
|
+
marginLeft?: string;
|
|
41
|
+
marginRight?: string;
|
|
42
|
+
backgroundColor?: string;
|
|
43
|
+
borderRadius?: string;
|
|
44
|
+
width?: string;
|
|
45
|
+
height?: string;
|
|
46
|
+
position?: PositionOptionType;
|
|
47
|
+
top?: string;
|
|
48
|
+
bottom?: string;
|
|
49
|
+
left?: string;
|
|
50
|
+
right?: string;
|
|
51
|
+
zIndex?: number;
|
|
52
|
+
};
|
|
8
53
|
}
|
|
9
54
|
|
|
10
55
|
export interface OnboardComponentProps {
|
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "Onboard",
|
|
6
6
|
"children": "node",
|
|
7
|
+
"extends": "View",
|
|
8
|
+
"attributes": {},
|
|
9
|
+
"defaults": {
|
|
10
|
+
"flexDirection": "row"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"meta": {
|
|
14
|
+
"desiredParent": ["=OnboardProvider"],
|
|
15
|
+
"desiredChildren": ["=OnboardItem"],
|
|
16
|
+
"label": "Onboard",
|
|
17
|
+
"description": "Wraps the onboarding flow.",
|
|
7
18
|
"attributes": {}
|
|
8
19
|
}
|
|
9
20
|
}
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import type {
|
|
1
|
+
import React, { useContext, useId, useMemo, useRef } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
EventObjectGenerated,
|
|
4
|
+
OnboardButtonComponentProps,
|
|
5
|
+
} from './OnboardButtonProps.generated';
|
|
3
6
|
import { onboardContext } from '../OnboardProvider/OnboardProvider';
|
|
4
7
|
import useNode from '../useNode';
|
|
5
8
|
import { useRenderStore } from '../../store';
|
|
6
9
|
import { useLogRender } from '../../utils/useLogRender';
|
|
10
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
11
|
+
import { useMockOSContext, useMockPermission } from '../../mockOS';
|
|
7
12
|
|
|
8
13
|
function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
9
14
|
useLogRender('OnboardButton');
|
|
10
15
|
node = useNode(node);
|
|
16
|
+
const attributeName =
|
|
17
|
+
(node as any)?.sourceType ?? node.type ?? 'OnboardButton';
|
|
11
18
|
const { emblaApi } = useContext(onboardContext) ?? {};
|
|
12
|
-
const { appConfig } = useRenderStore((s) => ({
|
|
19
|
+
const { appConfig, projectColors } = useRenderStore((s) => ({
|
|
13
20
|
appConfig: s.appConfig,
|
|
21
|
+
projectColors: s.projectColors,
|
|
14
22
|
}));
|
|
15
23
|
|
|
24
|
+
const context = useMockOSContext();
|
|
25
|
+
const mockPermissionManager = useMockPermission(context);
|
|
26
|
+
const handledEventsRef = useRef<EventObjectGenerated[]>([]);
|
|
27
|
+
const generatedId = useId();
|
|
28
|
+
const attributeKey = node.key ?? generatedId;
|
|
29
|
+
|
|
16
30
|
const labelRaw = node.attributes?.labelKey ?? '';
|
|
17
31
|
const label =
|
|
18
32
|
(appConfig.localication?.[appConfig.defaultLanguage ?? 'en']?.[
|
|
@@ -22,18 +36,49 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
22
36
|
const flex = node.attributes?.flex ?? 1;
|
|
23
37
|
const textColor = node.attributes?.button_text_color ?? '#FFFFFF';
|
|
24
38
|
const backgroundColor = node.attributes?.button_background_color ?? '#0066FF';
|
|
39
|
+
const viewStyle = useMemo(
|
|
40
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
41
|
+
[node, appConfig, projectColors],
|
|
42
|
+
);
|
|
25
43
|
|
|
26
44
|
const handleClick = () => {
|
|
27
|
-
|
|
45
|
+
//TODO: any ??
|
|
46
|
+
const events: EventObjectGenerated[] = node.attributes?.events ?? [];
|
|
28
47
|
let navigateHandled = false;
|
|
48
|
+
|
|
29
49
|
for (const e of events) {
|
|
50
|
+
// Check if event is already handled
|
|
51
|
+
if (handledEventsRef.current.includes(e)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
30
55
|
if (e.type === 'Permission') {
|
|
31
|
-
|
|
56
|
+
const permission = e.permission ?? 'camera';
|
|
57
|
+
mockPermissionManager.requestPermission(permission);
|
|
58
|
+
handledEventsRef.current.push(e);
|
|
59
|
+
//TODO: cause user to click second time
|
|
60
|
+
return;
|
|
32
61
|
} else if (e.type === 'Navigate') {
|
|
33
|
-
const eventTargetIndex =
|
|
62
|
+
const eventTargetIndex = e.targetIndex;
|
|
34
63
|
if (typeof eventTargetIndex === 'number') {
|
|
35
64
|
emblaApi?.scrollTo(eventTargetIndex);
|
|
36
65
|
navigateHandled = true;
|
|
66
|
+
handledEventsRef.current.push(e);
|
|
67
|
+
//TODO: cause user to click second time
|
|
68
|
+
return;
|
|
69
|
+
} else if (e.navigate_to) {
|
|
70
|
+
const eventTarget = e.navigate_to;
|
|
71
|
+
if (typeof eventTarget === 'string') {
|
|
72
|
+
navigateHandled = true;
|
|
73
|
+
handledEventsRef.current.push(e);
|
|
74
|
+
//TODO: cause user to click second time
|
|
75
|
+
if (context) {
|
|
76
|
+
context.navigation(eventTarget as any);
|
|
77
|
+
} else {
|
|
78
|
+
alert('Mock OS context not available for navigation.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
37
82
|
}
|
|
38
83
|
}
|
|
39
84
|
}
|
|
@@ -42,9 +87,12 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
42
87
|
|
|
43
88
|
return (
|
|
44
89
|
<button
|
|
90
|
+
attribute-name={attributeName}
|
|
91
|
+
attribute-key={attributeKey}
|
|
45
92
|
className="onboard__button"
|
|
46
93
|
onClick={handleClick}
|
|
47
94
|
style={{
|
|
95
|
+
...viewStyle,
|
|
48
96
|
flex,
|
|
49
97
|
color: textColor,
|
|
50
98
|
backgroundColor,
|
|
@@ -4,6 +4,21 @@ import type { NodeData } from '../../types/Node';
|
|
|
4
4
|
|
|
5
5
|
export type TypeOptionType = 'Permission' | 'Navigate';
|
|
6
6
|
export type PermissionOptionType = 'att' | 'notification' | 'rating' | 'GDPR';
|
|
7
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
8
|
+
export type AlignItemsOptionType =
|
|
9
|
+
| 'flex-start'
|
|
10
|
+
| 'center'
|
|
11
|
+
| 'flex-end'
|
|
12
|
+
| 'stretch'
|
|
13
|
+
| 'baseline';
|
|
14
|
+
export type JustifyContentOptionType =
|
|
15
|
+
| 'flex-start'
|
|
16
|
+
| 'center'
|
|
17
|
+
| 'flex-end'
|
|
18
|
+
| 'space-between'
|
|
19
|
+
| 'space-around'
|
|
20
|
+
| 'space-evenly';
|
|
21
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
7
22
|
export type AnimationOptionType =
|
|
8
23
|
| 'simple-animation'
|
|
9
24
|
| 'line-animation'
|
|
@@ -21,6 +36,34 @@ export interface EventObjectGenerated {
|
|
|
21
36
|
export interface OnboardButtonPropsGenerated {
|
|
22
37
|
child: string;
|
|
23
38
|
attributes: {
|
|
39
|
+
scrollable?: boolean;
|
|
40
|
+
flexDirection?: FlexDirectionOptionType;
|
|
41
|
+
alignItems?: AlignItemsOptionType;
|
|
42
|
+
justifyContent?: JustifyContentOptionType;
|
|
43
|
+
gap?: string;
|
|
44
|
+
padding?: string;
|
|
45
|
+
paddingHorizontal?: string;
|
|
46
|
+
paddingVertical?: string;
|
|
47
|
+
paddingTop?: string;
|
|
48
|
+
paddingBottom?: string;
|
|
49
|
+
paddingLeft?: string;
|
|
50
|
+
paddingRight?: string;
|
|
51
|
+
margin?: string;
|
|
52
|
+
marginVertical?: string;
|
|
53
|
+
marginTop?: string;
|
|
54
|
+
marginBottom?: string;
|
|
55
|
+
marginLeft?: string;
|
|
56
|
+
marginRight?: string;
|
|
57
|
+
backgroundColor?: string;
|
|
58
|
+
borderRadius?: string;
|
|
59
|
+
width?: string;
|
|
60
|
+
height?: string;
|
|
61
|
+
position?: PositionOptionType;
|
|
62
|
+
top?: string;
|
|
63
|
+
bottom?: string;
|
|
64
|
+
left?: string;
|
|
65
|
+
right?: string;
|
|
66
|
+
zIndex?: number;
|
|
24
67
|
labelKey?: string;
|
|
25
68
|
button_text_color?: string;
|
|
26
69
|
animation?: AnimationOptionType;
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "OnboardButton",
|
|
6
6
|
"children": "never",
|
|
7
|
+
"extends": "View",
|
|
7
8
|
"attributes": {
|
|
8
9
|
"labelKey": "string",
|
|
9
|
-
"button_text_color": "
|
|
10
|
+
"button_text_color": "color",
|
|
10
11
|
"animation": [
|
|
11
12
|
"simple-animation",
|
|
12
13
|
"line-animation",
|
|
@@ -14,18 +15,83 @@
|
|
|
14
15
|
"blur-animation",
|
|
15
16
|
"blur-line-animation"
|
|
16
17
|
],
|
|
17
|
-
"animation_color": "
|
|
18
|
-
"button_background_color": "
|
|
18
|
+
"animation_color": "color",
|
|
19
|
+
"button_background_color": "color",
|
|
19
20
|
"flex": "number",
|
|
20
21
|
"events": "EventObject[]"
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
"types": {
|
|
24
25
|
"EventObject": {
|
|
25
|
-
"type": [
|
|
26
|
-
|
|
26
|
+
"type": [
|
|
27
|
+
"Permission",
|
|
28
|
+
"Navigate"
|
|
29
|
+
],
|
|
30
|
+
"permission": [
|
|
31
|
+
"att",
|
|
32
|
+
"notification",
|
|
33
|
+
"rating",
|
|
34
|
+
"GDPR",
|
|
35
|
+
"null"
|
|
36
|
+
],
|
|
27
37
|
"navigate_to": "string",
|
|
28
38
|
"targetIndex": "number"
|
|
29
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"meta": {
|
|
42
|
+
"desiredParent": ["=OnboardButtons"],
|
|
43
|
+
"label": "Onboard Button",
|
|
44
|
+
"description": "Single action button for onboarding.",
|
|
45
|
+
"attributes": {
|
|
46
|
+
"labelKey": {
|
|
47
|
+
"label": "Label Key",
|
|
48
|
+
"description": "Localization key for the button text.",
|
|
49
|
+
"category": "other",
|
|
50
|
+
"specialCategory": null,
|
|
51
|
+
"sort": 1
|
|
52
|
+
},
|
|
53
|
+
"button_text_color": {
|
|
54
|
+
"label": "Button Text Color",
|
|
55
|
+
"description": "Text color of the button.",
|
|
56
|
+
"category": "style",
|
|
57
|
+
"specialCategory": null,
|
|
58
|
+
"sort": 2
|
|
59
|
+
},
|
|
60
|
+
"animation": {
|
|
61
|
+
"label": "Animation",
|
|
62
|
+
"description": "Animation style for the button.",
|
|
63
|
+
"category": "style",
|
|
64
|
+
"specialCategory": null,
|
|
65
|
+
"sort": 3
|
|
66
|
+
},
|
|
67
|
+
"animation_color": {
|
|
68
|
+
"label": "Animation Color",
|
|
69
|
+
"description": "Color used by the animation.",
|
|
70
|
+
"category": "style",
|
|
71
|
+
"specialCategory": null,
|
|
72
|
+
"sort": 4
|
|
73
|
+
},
|
|
74
|
+
"button_background_color": {
|
|
75
|
+
"label": "Button Background Color",
|
|
76
|
+
"description": "Background color of the button.",
|
|
77
|
+
"category": "style",
|
|
78
|
+
"specialCategory": null,
|
|
79
|
+
"sort": 5
|
|
80
|
+
},
|
|
81
|
+
"flex": {
|
|
82
|
+
"label": "Flex",
|
|
83
|
+
"description": "Flex grow value in layout.",
|
|
84
|
+
"category": "container",
|
|
85
|
+
"specialCategory": null,
|
|
86
|
+
"sort": 6
|
|
87
|
+
},
|
|
88
|
+
"events": {
|
|
89
|
+
"label": "Events",
|
|
90
|
+
"description": "List of events fired by the button.",
|
|
91
|
+
"category": "other",
|
|
92
|
+
"specialCategory": null,
|
|
93
|
+
"sort": 7
|
|
94
|
+
}
|
|
95
|
+
}
|
|
30
96
|
}
|
|
31
97
|
}
|