@developer_tribe/react-builder 0.1.32 → 1.0.2
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/DeviceMockFrame.d.ts +2 -17
- package/dist/RenderPage.d.ts +4 -11
- package/dist/attributes-editor/Field.d.ts +16 -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 +19 -0
- package/dist/attributes-editor/types.d.ts +14 -0
- package/dist/background.jpg +0 -0
- package/dist/build-components/Button/Button.d.ts +1 -1
- package/dist/build-components/Button/ButtonProps.generated.d.ts +26 -1
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +27 -1
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +25 -0
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +25 -0
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +27 -1
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +27 -1
- package/dist/build-components/Image/ImageProps.generated.d.ts +25 -3
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +27 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +25 -0
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +25 -0
- package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +22 -0
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +4 -5
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +25 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +24 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +25 -4
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +4 -5
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +4 -5
- package/dist/build-components/Text/TextProps.generated.d.ts +4 -5
- package/dist/build-components/View/ViewProps.generated.d.ts +3 -4
- package/dist/build-components/index.d.ts +1 -0
- package/dist/build-components/patterns.generated.d.ts +4855 -132
- package/dist/components/AttributesEditorPanel.d.ts +9 -0
- package/dist/components/Breadcrumb.d.ts +15 -0
- package/dist/components/Builder.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 +10 -0
- package/dist/index.cjs.js +6 -5
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.esm.js +6 -5
- package/dist/index.esm.js.map +1 -0
- 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 +9 -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 +11 -0
- package/dist/pages/tabs/BuilderTab.d.ts +9 -0
- package/dist/pages/tabs/DebugTab.d.ts +7 -0
- package/dist/pages/tabs/PreviewTab.d.ts +3 -0
- package/dist/store.d.ts +15 -18
- package/dist/styles.css +1 -1
- package/dist/types/PreviewConfig.d.ts +6 -3
- package/dist/types/Project.d.ts +12 -2
- package/dist/utils/copyNode.d.ts +2 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/patterns.d.ts +24 -0
- package/dist/utils/useLogRender.d.ts +1 -0
- package/package.json +17 -9
- package/scripts/prebuild/utils/createBuildComponentsIndex.js +15 -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 +434 -311
- package/src/DeviceMockFrame.tsx +42 -67
- package/src/RenderPage.tsx +8 -44
- package/src/assets/images/android.svg +43 -0
- package/src/assets/images/apple.svg +16 -0
- package/src/assets/images/background.jpg +0 -0
- package/src/assets/samples/carousel-sample.json +2 -3
- package/src/assets/samples/getSamples.ts +49 -12
- package/src/assets/samples/simple-1.json +1 -2
- package/src/assets/samples/simple-2.json +1 -2
- package/src/assets/samples/vpn-onboard-1.json +1 -2
- package/src/assets/samples/vpn-onboard-2.json +1 -2
- package/src/assets/samples/vpn-onboard-3.json +1 -2
- package/src/assets/samples/vpn-onboard-4.json +1 -2
- package/src/assets/samples/vpn-onboard-5.json +1 -2
- package/src/assets/samples/vpn-onboard-6.json +1 -2
- package/src/attributes-editor/Field.tsx +662 -0
- package/src/attributes-editor/FieldInfoTooltip.tsx +49 -0
- package/src/attributes-editor/LayoutPreviewPicker.tsx +199 -0
- package/src/attributes-editor/SpecialCategorySection.tsx +284 -0
- package/src/attributes-editor/types.ts +30 -0
- package/src/build-components/Button/Button.tsx +12 -2
- package/src/build-components/Button/ButtonProps.generated.ts +37 -1
- package/src/build-components/Button/pattern.json +31 -2
- package/src/build-components/Carousel/Carousel.tsx +17 -2
- package/src/build-components/Carousel/CarouselProps.generated.ts +39 -1
- package/src/build-components/Carousel/pattern.json +10 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +8 -2
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +36 -0
- package/src/build-components/CarouselButtons/pattern.json +22 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +42 -8
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +36 -0
- package/src/build-components/CarouselDots/pattern.json +15 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +7 -2
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +39 -1
- package/src/build-components/CarouselItem/pattern.json +7 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +10 -2
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +39 -1
- package/src/build-components/CarouselProvider/pattern.json +7 -0
- package/src/build-components/Image/Image.tsx +10 -2
- package/src/build-components/Image/ImageProps.generated.ts +36 -3
- package/src/build-components/Image/pattern.json +46 -3
- package/src/build-components/Onboard/Onboard.tsx +8 -1
- package/src/build-components/Onboard/OnboardProps.generated.ts +39 -1
- package/src/build-components/Onboard/pattern.json +11 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +53 -9
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +36 -0
- package/src/build-components/OnboardButton/pattern.json +71 -5
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +27 -17
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +36 -0
- package/src/build-components/OnboardButtons/pattern.json +70 -4
- package/src/build-components/OnboardDot/OnboardDot.tsx +106 -4
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +22 -0
- package/src/build-components/OnboardDot/pattern.json +54 -1
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +14 -6
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +4 -5
- package/src/build-components/OnboardFooter/pattern.json +58 -2
- package/src/build-components/OnboardImage/OnboardImage.tsx +29 -5
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +36 -3
- package/src/build-components/OnboardImage/pattern.json +21 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +8 -1
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +35 -3
- package/src/build-components/OnboardItem/pattern.json +38 -2
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +22 -8
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +37 -4
- package/src/build-components/OnboardProvider/pattern.json +51 -4
- package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +2 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +4 -5
- package/src/build-components/OnboardSubtitle/pattern.json +6 -0
- package/src/build-components/OnboardTitle/OnboardTitle.tsx +2 -0
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +4 -5
- package/src/build-components/OnboardTitle/pattern.json +6 -0
- package/src/build-components/Text/Text.tsx +12 -6
- package/src/build-components/Text/TextProps.generated.ts +4 -5
- package/src/build-components/Text/pattern.json +38 -2
- package/src/build-components/View/View.tsx +11 -6
- package/src/build-components/View/ViewProps.generated.ts +3 -4
- package/src/build-components/View/pattern.json +227 -19
- package/src/build-components/index.ts +22 -0
- package/src/build-components/patterns.generated.ts +4905 -139
- package/src/components/AttributesEditorPanel.tsx +58 -0
- package/src/components/Breadcrumb.tsx +80 -0
- package/src/components/Builder.tsx +375 -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 +138 -0
- package/src/index.ts +8 -4
- package/src/mockOS/components/MockLaunchScreenComponent.tsx +43 -0
- package/src/mockOS/components/MockOSRouter.tsx +115 -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 +268 -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 +150 -0
- package/src/pages/tabs/BuilderTab.tsx +33 -0
- package/src/pages/tabs/DebugTab.tsx +64 -0
- package/src/pages/tabs/PreviewTab.tsx +206 -0
- package/src/size-matters/index.ts +25 -5
- package/src/store.ts +56 -38
- package/src/styles/base/_global.scss +253 -0
- package/src/styles/components/_attributes-editor.scss +261 -0
- package/src/styles/components/_editor-shell.scss +189 -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/foundation/_mixins.scss +22 -0
- 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 -129
- package/src/styles/layout/_builder.scss +68 -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 +130 -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/PreviewConfig.ts +14 -5
- package/src/types/Project.ts +15 -2
- package/src/types/images.d.ts +8 -0
- package/src/utils/copyNode.ts +7 -0
- package/src/utils/extractTextStyle.ts +8 -4
- package/src/utils/extractViewStyle.ts +51 -7
- package/src/utils/getDevices.ts +1 -0
- package/src/utils/logger.ts +76 -0
- package/src/utils/patterns.ts +33 -0
- package/src/utils/useLogRender.ts +13 -0
- package/dist/build-components/OnboardDot/OnboardExpandingDotProps.generated.d.ts +0 -10
- package/src/build-components/OnboardDot/OnboardExpandingDotProps.generated.ts +0 -20
|
@@ -2,9 +2,47 @@
|
|
|
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
|
+
|
|
5
20
|
export interface CarouselPropsGenerated {
|
|
6
21
|
child: string;
|
|
7
|
-
attributes: {
|
|
22
|
+
attributes: {
|
|
23
|
+
scrollable?: boolean;
|
|
24
|
+
flexDirection?: FlexDirectionOptionType;
|
|
25
|
+
alignItems?: AlignItemsOptionType;
|
|
26
|
+
justifyContent?: JustifyContentOptionType;
|
|
27
|
+
gap?: string;
|
|
28
|
+
padding?: string;
|
|
29
|
+
paddingHorizontal?: string;
|
|
30
|
+
paddingVertical?: string;
|
|
31
|
+
paddingTop?: string;
|
|
32
|
+
paddingBottom?: string;
|
|
33
|
+
paddingLeft?: string;
|
|
34
|
+
paddingRight?: string;
|
|
35
|
+
margin?: string;
|
|
36
|
+
marginVertical?: string;
|
|
37
|
+
marginTop?: string;
|
|
38
|
+
marginBottom?: string;
|
|
39
|
+
marginLeft?: string;
|
|
40
|
+
marginRight?: string;
|
|
41
|
+
backgroundColor?: string;
|
|
42
|
+
borderRadius?: string;
|
|
43
|
+
width?: string;
|
|
44
|
+
height?: string;
|
|
45
|
+
};
|
|
8
46
|
}
|
|
9
47
|
|
|
10
48
|
export interface CarouselComponentProps {
|
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"allowUnknownAttributes": false,
|
|
4
4
|
"pattern": {
|
|
5
|
+
"extends": "View",
|
|
5
6
|
"type": "carousel",
|
|
6
7
|
"children": "carouselItem",
|
|
8
|
+
"attributes": {},
|
|
9
|
+
"defaults": {
|
|
10
|
+
"flexDirection": "row"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"meta": {
|
|
14
|
+
"desiredParent": ["=CarouselProvider"],
|
|
15
|
+
"label": "Carousel",
|
|
16
|
+
"description": "Container for carousel items.",
|
|
7
17
|
"attributes": {}
|
|
8
18
|
}
|
|
9
19
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import type { CarouselButtonsComponentProps } from './CarouselButtonsProps.generated';
|
|
3
3
|
import { carouselContext } from '../CarouselProvider/CarouselProvider';
|
|
4
4
|
import useNode from '../useNode';
|
|
5
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
6
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
5
7
|
|
|
6
8
|
function CarouselButtons({ node }: CarouselButtonsComponentProps) {
|
|
9
|
+
useLogRender('CarouselButtons');
|
|
7
10
|
node = useNode(node);
|
|
11
|
+
const attributeKey =
|
|
12
|
+
(node as any)?.sourceType ?? node.type ?? 'carouselButtons';
|
|
13
|
+
const style = useMemo(() => extractViewStyle(node), [node]);
|
|
8
14
|
const emblaApi = useContext(carouselContext);
|
|
9
15
|
const buttonTypes = node.attributes?.buttonType || [
|
|
10
16
|
'previous_button',
|
|
@@ -12,7 +18,7 @@ function CarouselButtons({ node }: CarouselButtonsComponentProps) {
|
|
|
12
18
|
];
|
|
13
19
|
|
|
14
20
|
return (
|
|
15
|
-
<div className="embla__buttons">
|
|
21
|
+
<div attribute-key={attributeKey} className="embla__buttons" style={style}>
|
|
16
22
|
{buttonTypes.includes('previous_button') && (
|
|
17
23
|
<button
|
|
18
24
|
onClick={() => emblaApi?.scrollPrev()}
|
|
@@ -2,6 +2,20 @@
|
|
|
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';
|
|
5
19
|
export type ButtonTypeOptionType =
|
|
6
20
|
| 'previous_button'
|
|
7
21
|
| 'next_button'
|
|
@@ -10,6 +24,28 @@ export type ButtonTypeOptionType =
|
|
|
10
24
|
export interface CarouselButtonsPropsGenerated {
|
|
11
25
|
child: string;
|
|
12
26
|
attributes: {
|
|
27
|
+
scrollable?: boolean;
|
|
28
|
+
flexDirection?: FlexDirectionOptionType;
|
|
29
|
+
alignItems?: AlignItemsOptionType;
|
|
30
|
+
justifyContent?: JustifyContentOptionType;
|
|
31
|
+
gap?: string;
|
|
32
|
+
padding?: string;
|
|
33
|
+
paddingHorizontal?: string;
|
|
34
|
+
paddingVertical?: string;
|
|
35
|
+
paddingTop?: string;
|
|
36
|
+
paddingBottom?: string;
|
|
37
|
+
paddingLeft?: string;
|
|
38
|
+
paddingRight?: string;
|
|
39
|
+
margin?: string;
|
|
40
|
+
marginVertical?: string;
|
|
41
|
+
marginTop?: string;
|
|
42
|
+
marginBottom?: string;
|
|
43
|
+
marginLeft?: string;
|
|
44
|
+
marginRight?: string;
|
|
45
|
+
backgroundColor?: string;
|
|
46
|
+
borderRadius?: string;
|
|
47
|
+
width?: string;
|
|
48
|
+
height?: string;
|
|
13
49
|
buttonType?: ButtonTypeOptionType;
|
|
14
50
|
skipNumber?: number;
|
|
15
51
|
};
|
|
@@ -4,9 +4,31 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "carouselButtons",
|
|
6
6
|
"children": "never",
|
|
7
|
+
"extends": "View",
|
|
7
8
|
"attributes": {
|
|
8
9
|
"buttonType": ["previous_button", "next_button", "skip_button"],
|
|
9
10
|
"skipNumber": "number"
|
|
10
11
|
}
|
|
12
|
+
},
|
|
13
|
+
"meta": {
|
|
14
|
+
"desiredParent": [">OnboardProvider", ">CarouselProvider"],
|
|
15
|
+
"label": "Carousel Buttons",
|
|
16
|
+
"description": "Renders built-in carousel buttons.",
|
|
17
|
+
"attributes": {
|
|
18
|
+
"buttonType": {
|
|
19
|
+
"label": "Button Type",
|
|
20
|
+
"description": "Which carousel button to show.",
|
|
21
|
+
"category": "other",
|
|
22
|
+
"specialCategory": null,
|
|
23
|
+
"sort": 1
|
|
24
|
+
},
|
|
25
|
+
"skipNumber": {
|
|
26
|
+
"label": "Skip Number",
|
|
27
|
+
"description": "Index to skip to when tapped.",
|
|
28
|
+
"category": "other",
|
|
29
|
+
"specialCategory": null,
|
|
30
|
+
"sort": 2
|
|
31
|
+
}
|
|
32
|
+
}
|
|
11
33
|
}
|
|
12
34
|
}
|
|
@@ -1,26 +1,60 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import type { CarouselDotsComponentProps } from './CarouselDotsProps.generated';
|
|
3
3
|
import { carouselContext } from '../CarouselProvider/CarouselProvider';
|
|
4
|
+
import { onboardContext } from '../OnboardProvider/OnboardProvider';
|
|
4
5
|
import useNode from '../useNode';
|
|
6
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
7
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
5
8
|
|
|
6
9
|
function CarouselDots({ node }: CarouselDotsComponentProps) {
|
|
10
|
+
useLogRender('CarouselDots');
|
|
11
|
+
|
|
7
12
|
node = useNode(node);
|
|
13
|
+
|
|
14
|
+
const attributeKey = (node as any)?.sourceType ?? node.type ?? 'carouselDots';
|
|
15
|
+
|
|
8
16
|
const dotType = node.attributes?.dotType || 'normal_dot';
|
|
9
|
-
|
|
17
|
+
|
|
18
|
+
const style = useMemo(() => {
|
|
19
|
+
return extractViewStyle(node);
|
|
20
|
+
}, [node]);
|
|
21
|
+
|
|
22
|
+
// Use the appropriate context based on sourceType
|
|
23
|
+
const isOnboard = (node as any)?.sourceType === 'OnboardDot';
|
|
24
|
+
const carouselApi = useContext(carouselContext);
|
|
25
|
+
const onboardApi = useContext(onboardContext);
|
|
26
|
+
const emblaApi = isOnboard ? onboardApi?.emblaApi : carouselApi;
|
|
27
|
+
|
|
10
28
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
11
29
|
const [scrollSnaps, setScrollSnaps] = useState<number[]>([]);
|
|
12
30
|
|
|
13
31
|
useEffect(() => {
|
|
14
32
|
if (!emblaApi) return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
const snaps = emblaApi.scrollSnapList();
|
|
34
|
+
const selected = emblaApi.selectedScrollSnap();
|
|
35
|
+
setScrollSnaps(snaps);
|
|
36
|
+
setSelectedIndex(selected);
|
|
37
|
+
|
|
38
|
+
const onSelect = () => {
|
|
39
|
+
const sel = emblaApi.selectedScrollSnap();
|
|
40
|
+
setSelectedIndex(sel);
|
|
41
|
+
};
|
|
42
|
+
emblaApi.on('select', onSelect);
|
|
43
|
+
|
|
44
|
+
// Potential cleanup if necessary
|
|
45
|
+
return () => {
|
|
46
|
+
if (emblaApi && emblaApi.off) {
|
|
47
|
+
emblaApi.off('select', onSelect);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
20
50
|
}, [emblaApi]);
|
|
21
51
|
|
|
22
52
|
return (
|
|
23
|
-
<div
|
|
53
|
+
<div
|
|
54
|
+
attribute-key={attributeKey}
|
|
55
|
+
className={`embla__dots embla__dots--${dotType}`}
|
|
56
|
+
style={style}
|
|
57
|
+
>
|
|
24
58
|
{scrollSnaps.map((snap, index) => (
|
|
25
59
|
<button
|
|
26
60
|
key={index}
|
|
@@ -2,6 +2,20 @@
|
|
|
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';
|
|
5
19
|
export type DotTypeOptionType =
|
|
6
20
|
| 'expanding_dot'
|
|
7
21
|
| 'normal_dot'
|
|
@@ -13,6 +27,28 @@ export type DotTypeOptionType =
|
|
|
13
27
|
export interface CarouselDotsPropsGenerated {
|
|
14
28
|
child: string;
|
|
15
29
|
attributes: {
|
|
30
|
+
scrollable?: boolean;
|
|
31
|
+
flexDirection?: FlexDirectionOptionType;
|
|
32
|
+
alignItems?: AlignItemsOptionType;
|
|
33
|
+
justifyContent?: JustifyContentOptionType;
|
|
34
|
+
gap?: string;
|
|
35
|
+
padding?: string;
|
|
36
|
+
paddingHorizontal?: string;
|
|
37
|
+
paddingVertical?: string;
|
|
38
|
+
paddingTop?: string;
|
|
39
|
+
paddingBottom?: string;
|
|
40
|
+
paddingLeft?: string;
|
|
41
|
+
paddingRight?: string;
|
|
42
|
+
margin?: string;
|
|
43
|
+
marginVertical?: string;
|
|
44
|
+
marginTop?: string;
|
|
45
|
+
marginBottom?: string;
|
|
46
|
+
marginLeft?: string;
|
|
47
|
+
marginRight?: string;
|
|
48
|
+
backgroundColor?: string;
|
|
49
|
+
borderRadius?: string;
|
|
50
|
+
width?: string;
|
|
51
|
+
height?: string;
|
|
16
52
|
dotType?: DotTypeOptionType;
|
|
17
53
|
};
|
|
18
54
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"pattern": {
|
|
5
5
|
"type": "carouselDots",
|
|
6
6
|
"children": "never",
|
|
7
|
+
"extends": "View",
|
|
7
8
|
"attributes": {
|
|
8
9
|
"dotType": [
|
|
9
10
|
"expanding_dot",
|
|
@@ -14,5 +15,19 @@
|
|
|
14
15
|
"liquid_like"
|
|
15
16
|
]
|
|
16
17
|
}
|
|
18
|
+
},
|
|
19
|
+
"meta": {
|
|
20
|
+
"desiredParent": [">CarouselProvider"],
|
|
21
|
+
"label": "Carousel Dots",
|
|
22
|
+
"description": "Renders page indicator dots.",
|
|
23
|
+
"attributes": {
|
|
24
|
+
"dotType": {
|
|
25
|
+
"label": "Dot Type",
|
|
26
|
+
"description": "Style used for the dots.",
|
|
27
|
+
"category": "style",
|
|
28
|
+
"specialCategory": null,
|
|
29
|
+
"sort": 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
17
32
|
}
|
|
18
33
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import type { CarouselItemComponentProps } from './CarouselItemProps.generated';
|
|
3
3
|
import { RenderNode } from '../..';
|
|
4
4
|
import useNode from '../useNode';
|
|
5
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
6
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
5
7
|
|
|
6
8
|
export function CarouselItem({ node }: CarouselItemComponentProps) {
|
|
9
|
+
useLogRender('CarouselItem');
|
|
7
10
|
node = useNode(node);
|
|
11
|
+
const attributeKey = (node as any)?.sourceType ?? node.type ?? 'carouselItem';
|
|
12
|
+
const style = useMemo(() => extractViewStyle(node), [node]);
|
|
8
13
|
return (
|
|
9
|
-
<div className="embla__slide" {
|
|
14
|
+
<div className="embla__slide" attribute-key={attributeKey} style={style}>
|
|
10
15
|
{node.children && <RenderNode node={node.children} />}
|
|
11
16
|
</div>
|
|
12
17
|
);
|
|
@@ -2,9 +2,47 @@
|
|
|
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
|
+
|
|
5
20
|
export interface CarouselItemPropsGenerated {
|
|
6
21
|
child: string;
|
|
7
|
-
attributes: {
|
|
22
|
+
attributes: {
|
|
23
|
+
scrollable?: boolean;
|
|
24
|
+
flexDirection?: FlexDirectionOptionType;
|
|
25
|
+
alignItems?: AlignItemsOptionType;
|
|
26
|
+
justifyContent?: JustifyContentOptionType;
|
|
27
|
+
gap?: string;
|
|
28
|
+
padding?: string;
|
|
29
|
+
paddingHorizontal?: string;
|
|
30
|
+
paddingVertical?: string;
|
|
31
|
+
paddingTop?: string;
|
|
32
|
+
paddingBottom?: string;
|
|
33
|
+
paddingLeft?: string;
|
|
34
|
+
paddingRight?: string;
|
|
35
|
+
margin?: string;
|
|
36
|
+
marginVertical?: string;
|
|
37
|
+
marginTop?: string;
|
|
38
|
+
marginBottom?: string;
|
|
39
|
+
marginLeft?: string;
|
|
40
|
+
marginRight?: string;
|
|
41
|
+
backgroundColor?: string;
|
|
42
|
+
borderRadius?: string;
|
|
43
|
+
width?: string;
|
|
44
|
+
height?: string;
|
|
45
|
+
};
|
|
8
46
|
}
|
|
9
47
|
|
|
10
48
|
export interface CarouselItemComponentProps {
|
|
@@ -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,24 @@
|
|
|
1
|
-
import React, { createContext } from 'react';
|
|
1
|
+
import React, { createContext, 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';
|
|
6
7
|
|
|
7
8
|
export const carouselContext = createContext<any>(undefined);
|
|
8
9
|
function CarouselProvider({ node }: CarouselProviderComponentProps) {
|
|
9
10
|
node = useNode(node);
|
|
10
11
|
const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
|
|
12
|
+
const attributeKey =
|
|
13
|
+
(node as any)?.sourceType ?? node.type ?? 'carouselProvider';
|
|
14
|
+
const viewStyle = useMemo(() => extractViewStyle(node), [node]);
|
|
11
15
|
return (
|
|
12
16
|
<carouselContext.Provider value={emblaApi}>
|
|
13
|
-
<div
|
|
17
|
+
<div
|
|
18
|
+
attribute-key={attributeKey}
|
|
19
|
+
className="carousel-provider"
|
|
20
|
+
style={viewStyle}
|
|
21
|
+
>
|
|
14
22
|
<div className="embla">
|
|
15
23
|
<div className="embla__viewport" ref={emblaRef}>
|
|
16
24
|
{node.children && <RenderNode node={node.children} />}
|
|
@@ -2,9 +2,47 @@
|
|
|
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
|
+
|
|
5
20
|
export interface CarouselProviderPropsGenerated {
|
|
6
21
|
child: string;
|
|
7
|
-
attributes: {
|
|
22
|
+
attributes: {
|
|
23
|
+
scrollable?: boolean;
|
|
24
|
+
flexDirection?: FlexDirectionOptionType;
|
|
25
|
+
alignItems?: AlignItemsOptionType;
|
|
26
|
+
justifyContent?: JustifyContentOptionType;
|
|
27
|
+
gap?: string;
|
|
28
|
+
padding?: string;
|
|
29
|
+
paddingHorizontal?: string;
|
|
30
|
+
paddingVertical?: string;
|
|
31
|
+
paddingTop?: string;
|
|
32
|
+
paddingBottom?: string;
|
|
33
|
+
paddingLeft?: string;
|
|
34
|
+
paddingRight?: string;
|
|
35
|
+
margin?: string;
|
|
36
|
+
marginVertical?: string;
|
|
37
|
+
marginTop?: string;
|
|
38
|
+
marginBottom?: string;
|
|
39
|
+
marginLeft?: string;
|
|
40
|
+
marginRight?: string;
|
|
41
|
+
backgroundColor?: string;
|
|
42
|
+
borderRadius?: string;
|
|
43
|
+
width?: string;
|
|
44
|
+
height?: string;
|
|
45
|
+
};
|
|
8
46
|
}
|
|
9
47
|
|
|
10
48
|
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,17 +1,25 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import type { ImageComponentProps } from './ImageProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
4
|
import { extractImageStyle } from '../../utils/extractImageStyle';
|
|
5
|
+
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
6
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
5
7
|
|
|
6
8
|
function Image({ node }: ImageComponentProps) {
|
|
9
|
+
useLogRender('Image');
|
|
7
10
|
node = useNode(node);
|
|
11
|
+
const attributeKey = (node as any)?.sourceType ?? node.type ?? 'image';
|
|
12
|
+
const viewStyle = useMemo(() => extractViewStyle(node), [node]);
|
|
13
|
+
const imageStyle = extractImageStyle(node);
|
|
14
|
+
const style = { ...viewStyle, ...imageStyle };
|
|
8
15
|
return (
|
|
9
16
|
<img
|
|
10
17
|
key={node.key}
|
|
18
|
+
attribute-key={attributeKey}
|
|
11
19
|
src={node.attributes?.src}
|
|
12
20
|
width={node.attributes?.width}
|
|
13
21
|
height={node.attributes?.height}
|
|
14
|
-
style={
|
|
22
|
+
style={style}
|
|
15
23
|
alt=""
|
|
16
24
|
/>
|
|
17
25
|
);
|
|
@@ -2,16 +2,49 @@
|
|
|
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';
|
|
5
19
|
export type ResizeModeOptionType = 'cover' | 'contain' | 'stretch' | 'center';
|
|
6
20
|
|
|
7
21
|
export interface ImagePropsGenerated {
|
|
8
22
|
child: string;
|
|
9
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;
|
|
10
46
|
src?: string;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
47
|
resizeMode?: ResizeModeOptionType;
|
|
14
|
-
borderRadius?: number;
|
|
15
48
|
};
|
|
16
49
|
}
|
|
17
50
|
|
|
@@ -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
|
}
|
|
@@ -2,10 +2,17 @@ import React from 'react';
|
|
|
2
2
|
import type { OnboardComponentProps } from './OnboardProps.generated';
|
|
3
3
|
import Carousel from '../Carousel/Carousel';
|
|
4
4
|
import useNode from '../useNode';
|
|
5
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
5
6
|
|
|
6
7
|
function Onboard({ node }: OnboardComponentProps) {
|
|
8
|
+
useLogRender('Onboard');
|
|
7
9
|
node = useNode(node);
|
|
8
|
-
|
|
10
|
+
const attributeKey = node.type ?? 'Onboard';
|
|
11
|
+
return (
|
|
12
|
+
<Carousel
|
|
13
|
+
node={{ ...node, type: 'carousel', sourceType: attributeKey } as any}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
9
16
|
}
|
|
10
17
|
|
|
11
18
|
export default React.memo(Onboard);
|