@developer_tribe/react-builder 1.2.2 → 1.2.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/RenderPage.d.ts +3 -1
- package/dist/build-components/PaywallOptions/PaywallOptionButton.d.ts +1 -1
- package/dist/components/BuilderProvider.d.ts +17 -0
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/hooks/useExtractTextStyle.d.ts +1 -7
- package/dist/hooks/useExtractViewStyle.d.ts +1 -7
- package/dist/hooks/useLocalize.d.ts +4 -1
- package/dist/hooks/useSafeAreaViewStyle.d.ts +2 -1
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.cjs.js +1 -28
- package/dist/index.native.cjs.js.map +1 -1
- package/dist/index.native.esm.js +1 -28
- package/dist/index.native.esm.js.map +1 -1
- package/dist/types/Node.d.ts +1 -0
- package/dist/utils/extractTextStyle/extractTextStyle.d.ts +4 -0
- package/dist/utils/extractViewStyle/extractViewStyle.d.ts +1 -2
- package/dist/utils/parseColor.d.ts +1 -2
- package/package.json +1 -1
- package/src/RenderPage.tsx +32 -20
- package/src/build-components/BIcon/BIcon.tsx +8 -14
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +9 -13
- package/src/build-components/Button/Button.tsx +11 -20
- package/src/build-components/Carousel/Carousel.tsx +8 -14
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +2 -8
- package/src/build-components/CarouselDots/CarouselDots.tsx +3 -10
- package/src/build-components/CarouselItem/CarouselItem.tsx +2 -8
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +2 -8
- package/src/build-components/Image/Image.tsx +11 -13
- package/src/build-components/Main/Main.tsx +10 -18
- package/src/build-components/OnboardButton/OnboardButton.tsx +7 -15
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +7 -14
- package/src/build-components/OnboardDot/OnboardDot.tsx +23 -23
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +16 -20
- package/src/build-components/OnboardImage/OnboardImage.tsx +10 -12
- package/src/build-components/OnboardItem/OnboardItem.tsx +2 -10
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +2 -12
- package/src/build-components/PaywallBackground/PaywallBackground.tsx +8 -11
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +9 -16
- package/src/build-components/PaywallOptions/PaywallOptionButton.tsx +11 -14
- package/src/build-components/PaywallProvider/PaywallProvider.tsx +15 -19
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +10 -16
- package/src/build-components/RadioButton/RadioButton.tsx +11 -20
- package/src/build-components/Text/Text.tsx +13 -21
- package/src/build-components/View/View.tsx +9 -12
- package/src/build-components/other.tsx +1 -1
- package/src/components/BuilderProvider.tsx +38 -0
- package/src/hooks/useExtractTextStyle.ts +12 -16
- package/src/hooks/useExtractViewStyle.ts +7 -16
- package/src/hooks/useLocalize.ts +7 -6
- package/src/hooks/useSafeAreaViewStyle.ts +4 -5
- package/src/index.ts +8 -7
- package/src/pages/ProjectDebug.tsx +16 -15
- package/src/pages/ProjectPage.tsx +17 -5
- package/src/types/Node.ts +1 -0
- package/src/utils/extractTextStyle/extractTextStyle.ts +32 -13
- package/src/utils/extractViewStyle/extractViewStyle.ts +2 -3
- package/src/utils/parseColor.ts +4 -5
|
@@ -4,11 +4,12 @@ import { onboardContext } from '../OnboardProvider/OnboardProvider';
|
|
|
4
4
|
import useNode from '../useNode';
|
|
5
5
|
import { useLogRender } from '../../utils/useLogRender';
|
|
6
6
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
7
|
-
import {
|
|
7
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
8
8
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
9
9
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
10
10
|
import { parseColor } from '../../utils/parseColor';
|
|
11
11
|
import { parseSize } from '../../size-matters';
|
|
12
|
+
import { defaultAppConfig } from '../../types/PreviewConfig';
|
|
12
13
|
|
|
13
14
|
function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
14
15
|
useLogRender('OnboardDot');
|
|
@@ -21,14 +22,13 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
21
22
|
const dotType = node.attributes?.dotType || 'normal_dot';
|
|
22
23
|
const GHOST_DOT_DARK_COLOR = '#E4E5E7';
|
|
23
24
|
const GHOST_DOT_LIGHT_COLOR = '#F7F7F9';
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
25
|
+
const {
|
|
26
|
+
previewMode,
|
|
27
|
+
selectedKey,
|
|
28
|
+
appConfig: builderAppConfig,
|
|
29
|
+
projectColors,
|
|
30
|
+
} = useBuilderParams();
|
|
31
|
+
const appConfig = builderAppConfig ?? defaultAppConfig;
|
|
32
32
|
const isDark = appConfig.theme === 'dark';
|
|
33
33
|
|
|
34
34
|
// OnboardDot specific attributes
|
|
@@ -38,20 +38,20 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
38
38
|
const inactiveDotOpacity = node.attributes?.inactive_dot_opacity ?? 0.3;
|
|
39
39
|
const activeDotColor = node.attributes?.active_dot_color;
|
|
40
40
|
const resolvedActiveDotColor = useMemo(
|
|
41
|
-
() => parseColor(activeDotColor, { appConfig, projectColors }),
|
|
42
|
-
[activeDotColor, appConfig, projectColors],
|
|
41
|
+
() => parseColor(activeDotColor, { theme: appConfig.theme, projectColors }),
|
|
42
|
+
[activeDotColor, appConfig.theme, projectColors],
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
const extractedStyle = useExtractViewStyle(node
|
|
46
|
-
appConfig,
|
|
47
|
-
projectColors,
|
|
48
|
-
});
|
|
45
|
+
const extractedStyle = useExtractViewStyle(node);
|
|
49
46
|
const baseStyle = useMemo(() => {
|
|
50
|
-
const
|
|
51
|
-
delete (innerStyle as any).flexDirection;
|
|
47
|
+
const { flexDirection: _flexDirection, ...innerStyle } = extractedStyle;
|
|
52
48
|
return innerStyle;
|
|
53
49
|
}, [extractedStyle]);
|
|
54
|
-
const isSelected = isNodeSelected({
|
|
50
|
+
const isSelected = isNodeSelected({
|
|
51
|
+
previewMode: !!previewMode,
|
|
52
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
53
|
+
node,
|
|
54
|
+
});
|
|
55
55
|
const style = useMergedStyle(
|
|
56
56
|
baseStyle,
|
|
57
57
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
@@ -73,8 +73,8 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
73
73
|
|
|
74
74
|
return {
|
|
75
75
|
// Controls the actual dot diameter (`.embla__dot:after`).
|
|
76
|
-
|
|
77
|
-
} as React.CSSProperties
|
|
76
|
+
'--embla-dot-size': cssWidth,
|
|
77
|
+
} as React.CSSProperties & Record<`--${string}`, string>;
|
|
78
78
|
}, [expandingDotWidthRaw]);
|
|
79
79
|
const containerStyle = useMergedStyle(style, expandingDotWidthOverride);
|
|
80
80
|
|
|
@@ -113,15 +113,15 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
113
113
|
>
|
|
114
114
|
{scrollSnaps.map((snap, index) => {
|
|
115
115
|
const isDotSelected = selectedIndex === index;
|
|
116
|
-
const dotStyles: React.CSSProperties = {
|
|
116
|
+
const dotStyles: React.CSSProperties & Record<`--${string}`, string> = {
|
|
117
117
|
opacity: isDotSelected ? 1 : inactiveDotOpacity,
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
if (resolvedActiveDotColor && isDotSelected) {
|
|
121
121
|
// Style the actual visual dot (rendered via `.embla__dot:after`) using a CSS variable.
|
|
122
|
-
|
|
122
|
+
dotStyles['--embla-dot-color'] = resolvedActiveDotColor;
|
|
123
123
|
} else if (!isDotSelected) {
|
|
124
|
-
|
|
124
|
+
dotStyles['--embla-dot-color'] = inactiveDotColor;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
return (
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { OnboardFooterComponentProps } from './OnboardFooterProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
-
import {
|
|
4
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
5
5
|
import { parseSize } from '../../size-matters';
|
|
6
6
|
import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
|
|
7
7
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
8
8
|
import { useLogRender } from '../../utils/useLogRender';
|
|
9
9
|
import { isNodeSelected } from '../../utils/selection';
|
|
10
10
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
11
|
+
import { defaultAppConfig } from '../../types/PreviewConfig';
|
|
11
12
|
|
|
12
13
|
type Segment =
|
|
13
14
|
| { type: 'text'; value: string }
|
|
@@ -92,29 +93,20 @@ function buildSegments(
|
|
|
92
93
|
function OnboardFooter({ node }: OnboardFooterComponentProps) {
|
|
93
94
|
useLogRender('OnboardFooter');
|
|
94
95
|
node = useNode(node);
|
|
95
|
-
const attributeName =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
current: s.current,
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
96
|
+
const attributeName = node.sourceType ?? node.type ?? 'OnboardFooter';
|
|
97
|
+
const {
|
|
98
|
+
appConfig: builderAppConfig,
|
|
99
|
+
previewMode,
|
|
100
|
+
selectedKey,
|
|
101
|
+
} = useBuilderParams();
|
|
102
|
+
const appConfig = builderAppConfig ?? defaultAppConfig;
|
|
105
103
|
const { localication, defaultLanguage } = appConfig;
|
|
106
104
|
const t = (key?: string) =>
|
|
107
105
|
key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
|
|
108
106
|
|
|
109
107
|
const text = t(node?.attributes?.textLocalizationKey);
|
|
110
|
-
const textStyle = useExtractTextStyle(node
|
|
111
|
-
|
|
112
|
-
projectColors,
|
|
113
|
-
});
|
|
114
|
-
const viewStyle = useExtractViewStyle(node as any, {
|
|
115
|
-
appConfig,
|
|
116
|
-
projectColors,
|
|
117
|
-
});
|
|
108
|
+
const textStyle = useExtractTextStyle(node);
|
|
109
|
+
const viewStyle = useExtractViewStyle(node);
|
|
118
110
|
|
|
119
111
|
const linkStyle = (color?: string): React.CSSProperties => ({
|
|
120
112
|
color,
|
|
@@ -131,7 +123,11 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
|
|
|
131
123
|
[paddingHorizontal],
|
|
132
124
|
);
|
|
133
125
|
|
|
134
|
-
const isSelected = isNodeSelected({
|
|
126
|
+
const isSelected = isNodeSelected({
|
|
127
|
+
previewMode: !!previewMode,
|
|
128
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
129
|
+
node,
|
|
130
|
+
});
|
|
135
131
|
const baseStyle = useMergedStyle(viewStyle, textStyle);
|
|
136
132
|
const paddedStyle = useMergedStyle(baseStyle, layoutStyle);
|
|
137
133
|
const generatedId = useId();
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import React, { useEffect, useId, useState } from 'react';
|
|
2
2
|
import type { OnboardImageComponentProps } from './OnboardImageProps.generated';
|
|
3
3
|
import Image from '../Image/Image';
|
|
4
|
+
import type { ImageComponentProps } from '../Image/ImageProps.generated';
|
|
4
5
|
import useNode from '../useNode';
|
|
5
6
|
import Lottie from 'lottie-react';
|
|
6
7
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
8
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
8
|
-
import { useRenderStore } from '../../store';
|
|
9
9
|
|
|
10
10
|
function OnboardImage({ node }: OnboardImageComponentProps) {
|
|
11
11
|
useLogRender('OnboardImage');
|
|
12
12
|
node = useNode(node);
|
|
13
13
|
const generatedId = useId();
|
|
14
|
-
const attributeName =
|
|
15
|
-
(node as any)?.sourceType ?? node.type ?? 'OnboardImage';
|
|
14
|
+
const attributeName = node.sourceType ?? node.type ?? 'OnboardImage';
|
|
16
15
|
const attributeKey = node.key ?? generatedId;
|
|
17
16
|
const [lottie, setLottie] = useState<string | null>(null);
|
|
18
|
-
const
|
|
19
|
-
appConfig: s.appConfig,
|
|
20
|
-
projectColors: s.projectColors,
|
|
21
|
-
}));
|
|
22
|
-
const viewStyle = useExtractViewStyle(node as any, {
|
|
23
|
-
appConfig,
|
|
24
|
-
projectColors,
|
|
25
|
-
});
|
|
17
|
+
const viewStyle = useExtractViewStyle(node);
|
|
26
18
|
|
|
27
19
|
useEffect(() => {
|
|
28
20
|
if (node.attributes?.lottie) {
|
|
@@ -72,7 +64,13 @@ function OnboardImage({ node }: OnboardImageComponentProps) {
|
|
|
72
64
|
|
|
73
65
|
return (
|
|
74
66
|
<Image
|
|
75
|
-
node={
|
|
67
|
+
node={
|
|
68
|
+
{
|
|
69
|
+
...node,
|
|
70
|
+
type: 'image',
|
|
71
|
+
sourceType: attributeName,
|
|
72
|
+
} as unknown as ImageComponentProps['node']
|
|
73
|
+
}
|
|
76
74
|
/>
|
|
77
75
|
);
|
|
78
76
|
}
|
|
@@ -2,7 +2,6 @@ import React, { useId, useMemo } from 'react';
|
|
|
2
2
|
import type { OnboardItemComponentProps } from './OnboardItemProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
4
|
import RenderNode from '../RenderNode.generated';
|
|
5
|
-
import { useRenderStore } from '../../store';
|
|
6
5
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
6
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
8
7
|
|
|
@@ -10,16 +9,9 @@ function OnboardItem({ node }: OnboardItemComponentProps) {
|
|
|
10
9
|
useLogRender('OnboardItem');
|
|
11
10
|
node = useNode(node);
|
|
12
11
|
const generatedId = useId();
|
|
13
|
-
const attributeName =
|
|
12
|
+
const attributeName = node.sourceType ?? node.type ?? 'OnboardItem';
|
|
14
13
|
const attributeKey = node.key ?? generatedId;
|
|
15
|
-
const
|
|
16
|
-
appConfig: s.appConfig,
|
|
17
|
-
projectColors: s.projectColors,
|
|
18
|
-
}));
|
|
19
|
-
const viewStyle = useExtractViewStyle(node as any, {
|
|
20
|
-
appConfig,
|
|
21
|
-
projectColors,
|
|
22
|
-
});
|
|
14
|
+
const viewStyle = useExtractViewStyle(node);
|
|
23
15
|
return (
|
|
24
16
|
<div
|
|
25
17
|
attribute-name={attributeName}
|
|
@@ -10,23 +10,16 @@ import type { NodeData } from '../../types/Node';
|
|
|
10
10
|
import type { OnboardProviderComponentProps } from './OnboardProviderProps.generated';
|
|
11
11
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
12
12
|
import RenderNode from '../RenderNode.generated';
|
|
13
|
-
import { useRenderStore } from '../../store';
|
|
14
13
|
import useNode from '../useNode';
|
|
15
14
|
import { useLogRender } from '../../utils/useLogRender';
|
|
16
15
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
17
|
-
import { ViewPropsGenerated } from '../View/ViewProps.generated';
|
|
18
16
|
|
|
19
17
|
export const onboardContext = createContext<any>(undefined);
|
|
20
18
|
function OnboardProvider({ node }: OnboardProviderComponentProps) {
|
|
21
19
|
useLogRender('OnboardProvider');
|
|
22
20
|
node = useNode(node);
|
|
23
21
|
const generatedId = useId();
|
|
24
|
-
const attributeName =
|
|
25
|
-
(node as any)?.sourceType ?? node.type ?? 'OnboardProvider';
|
|
26
|
-
const { appConfig, projectColors } = useRenderStore((s) => ({
|
|
27
|
-
appConfig: s.appConfig,
|
|
28
|
-
projectColors: s.projectColors,
|
|
29
|
-
}));
|
|
22
|
+
const attributeName = node.sourceType ?? node.type ?? 'OnboardProvider';
|
|
30
23
|
const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
|
|
31
24
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
32
25
|
const attributeKey = node.key ?? generatedId;
|
|
@@ -75,10 +68,7 @@ function OnboardProvider({ node }: OnboardProviderComponentProps) {
|
|
|
75
68
|
}, [theme]);*/
|
|
76
69
|
|
|
77
70
|
//TODO: pattern içinde direk gömmek yerine orada da inhertince eklenebilir
|
|
78
|
-
const baseStyle = useExtractViewStyle(
|
|
79
|
-
node as NodeData<ViewPropsGenerated['attributes']>,
|
|
80
|
-
{ appConfig, projectColors },
|
|
81
|
-
);
|
|
71
|
+
const baseStyle = useExtractViewStyle(node);
|
|
82
72
|
const viewStyle = useMemo(
|
|
83
73
|
() => ({
|
|
84
74
|
...baseStyle,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { PaywallBackgroundComponentProps } from './PaywallBackgroundProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
-
import {
|
|
4
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
5
5
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
6
6
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
7
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -15,18 +15,15 @@ function PaywallBackground({ node }: PaywallBackgroundComponentProps) {
|
|
|
15
15
|
const attributeName = node.type ?? 'PaywallBackground';
|
|
16
16
|
const attributeKey = node.key ?? generatedId;
|
|
17
17
|
|
|
18
|
-
const { previewMode,
|
|
19
|
-
(s) => ({
|
|
20
|
-
previewMode: s.previewMode,
|
|
21
|
-
current: s.current,
|
|
22
|
-
appConfig: s.appConfig,
|
|
23
|
-
projectColors: s.projectColors,
|
|
24
|
-
}),
|
|
25
|
-
);
|
|
18
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
26
19
|
|
|
27
|
-
const baseStyle = useExtractViewStyle(node
|
|
20
|
+
const baseStyle = useExtractViewStyle(node);
|
|
28
21
|
|
|
29
|
-
const isSelected = isNodeSelected({
|
|
22
|
+
const isSelected = isNodeSelected({
|
|
23
|
+
previewMode: !!previewMode,
|
|
24
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
25
|
+
node,
|
|
26
|
+
});
|
|
30
27
|
const style = useMergedStyle(
|
|
31
28
|
baseStyle,
|
|
32
29
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { PaywallCloseButtonComponentProps } from './PaywallCloseButtonProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
-
import {
|
|
4
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
5
5
|
import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
|
|
6
6
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
7
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -16,25 +16,18 @@ function PaywallCloseButton({ node }: PaywallCloseButtonComponentProps) {
|
|
|
16
16
|
const { onClose } = usePaywallContext();
|
|
17
17
|
|
|
18
18
|
const generatedId = useId();
|
|
19
|
-
const attributeName =
|
|
20
|
-
(node as any)?.sourceType ?? node.type ?? 'PaywallCloseButton';
|
|
19
|
+
const attributeName = node.sourceType ?? node.type ?? 'PaywallCloseButton';
|
|
21
20
|
const attributeKey = node.key ?? generatedId;
|
|
22
21
|
|
|
23
|
-
const { previewMode,
|
|
24
|
-
(s) => ({
|
|
25
|
-
previewMode: s.previewMode,
|
|
26
|
-
current: s.current,
|
|
27
|
-
appConfig: s.appConfig,
|
|
28
|
-
projectColors: s.projectColors,
|
|
29
|
-
}),
|
|
30
|
-
);
|
|
22
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
31
23
|
|
|
32
|
-
const baseStyle = useExtractTextStyle(node
|
|
33
|
-
appConfig,
|
|
34
|
-
projectColors,
|
|
35
|
-
});
|
|
24
|
+
const baseStyle = useExtractTextStyle(node);
|
|
36
25
|
|
|
37
|
-
const isSelected = isNodeSelected({
|
|
26
|
+
const isSelected = isNodeSelected({
|
|
27
|
+
previewMode: !!previewMode,
|
|
28
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
29
|
+
node,
|
|
30
|
+
});
|
|
38
31
|
const style = useMergedStyle(
|
|
39
32
|
baseStyle,
|
|
40
33
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
@@ -2,16 +2,16 @@ import { useId, useMemo } from 'react';
|
|
|
2
2
|
import type { Product } from '../../paywall/types/paywall-types';
|
|
3
3
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
4
4
|
import type { NodeData } from '../../types/Node';
|
|
5
|
-
import {
|
|
5
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
6
6
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
7
7
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
8
|
-
import
|
|
8
|
+
import RenderNode from '../RenderNode.generated';
|
|
9
9
|
|
|
10
10
|
export type OptionsButtonProps = {
|
|
11
11
|
product: Product;
|
|
12
12
|
selected: boolean;
|
|
13
13
|
onPress: (productId: string) => void;
|
|
14
|
-
node: NodeData<
|
|
14
|
+
node: NodeData<Record<string, unknown>>;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export function PaywallOptionButton({
|
|
@@ -23,24 +23,21 @@ export function PaywallOptionButton({
|
|
|
23
23
|
const generatedId = useId();
|
|
24
24
|
const productId = (product.productId ?? '').trim();
|
|
25
25
|
|
|
26
|
-
const { previewMode,
|
|
27
|
-
(s) => ({
|
|
28
|
-
previewMode: s.previewMode,
|
|
29
|
-
current: s.current,
|
|
30
|
-
appConfig: s.appConfig,
|
|
31
|
-
projectColors: s.projectColors,
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
26
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
34
27
|
|
|
35
|
-
const baseStyle = useExtractViewStyle(node
|
|
28
|
+
const baseStyle = useExtractViewStyle(node);
|
|
36
29
|
|
|
37
|
-
const isSelected = isNodeSelected({
|
|
30
|
+
const isSelected = isNodeSelected({
|
|
31
|
+
previewMode: !!previewMode,
|
|
32
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
33
|
+
node,
|
|
34
|
+
});
|
|
38
35
|
|
|
39
36
|
const mergedStyle = useMergedStyle(
|
|
40
37
|
baseStyle,
|
|
41
38
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
42
39
|
);
|
|
43
|
-
const attributeName =
|
|
40
|
+
const attributeName = node.sourceType ?? node.type ?? 'text';
|
|
44
41
|
const baseAttributeKey = (node.key ?? generatedId) as string;
|
|
45
42
|
const attributeKey = productId
|
|
46
43
|
? `${baseAttributeKey}:${productId}`
|
|
@@ -3,7 +3,6 @@ import type { PaywallProviderComponentProps } from './PaywallProviderProps.gener
|
|
|
3
3
|
import RenderNode from '../RenderNode.generated';
|
|
4
4
|
import type { Node } from '../../types/Node';
|
|
5
5
|
import useNode from '../useNode';
|
|
6
|
-
import { useRenderStore } from '../../store';
|
|
7
6
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
8
7
|
import { useLogRender } from '../../utils/useLogRender';
|
|
9
8
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -18,21 +17,17 @@ function PaywallProvider({ node }: PaywallProviderComponentProps) {
|
|
|
18
17
|
node = useNode(node);
|
|
19
18
|
|
|
20
19
|
const generatedId = useId();
|
|
21
|
-
const attributeName =
|
|
22
|
-
(node as any)?.sourceType ?? node.type ?? 'PaywallProvider';
|
|
20
|
+
const attributeName = node.sourceType ?? node.type ?? 'PaywallProvider';
|
|
23
21
|
const attributeKey = node.key ?? generatedId;
|
|
24
22
|
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const { benefits, products, onPaywallClose, onPaywallSubscribe } =
|
|
35
|
-
useBuilderParams();
|
|
23
|
+
const {
|
|
24
|
+
benefits,
|
|
25
|
+
products,
|
|
26
|
+
onPaywallClose,
|
|
27
|
+
onPaywallSubscribe,
|
|
28
|
+
previewMode,
|
|
29
|
+
selectedKey,
|
|
30
|
+
} = useBuilderParams();
|
|
36
31
|
const mockOS = useMockOSContext();
|
|
37
32
|
const benefitLocalizationParams = useMemo(() => {
|
|
38
33
|
const raw =
|
|
@@ -55,12 +50,13 @@ function PaywallProvider({ node }: PaywallProviderComponentProps) {
|
|
|
55
50
|
return params;
|
|
56
51
|
}, [benefits]);
|
|
57
52
|
|
|
58
|
-
const baseStyle = useExtractViewStyle(node
|
|
59
|
-
appConfig,
|
|
60
|
-
projectColors,
|
|
61
|
-
});
|
|
53
|
+
const baseStyle = useExtractViewStyle(node);
|
|
62
54
|
|
|
63
|
-
const isSelected = isNodeSelected({
|
|
55
|
+
const isSelected = isNodeSelected({
|
|
56
|
+
previewMode: !!previewMode,
|
|
57
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
58
|
+
node,
|
|
59
|
+
});
|
|
64
60
|
const style = useMergedStyle(
|
|
65
61
|
baseStyle,
|
|
66
62
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { PaywallSubscribeButtonComponentProps } from './PaywallSubscribeButtonProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
-
import {
|
|
4
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
5
5
|
import { useLogRender } from '../../utils/useLogRender';
|
|
6
6
|
import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
|
|
7
7
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -18,30 +18,24 @@ function PaywallSubscribeButton({
|
|
|
18
18
|
|
|
19
19
|
const generatedId = useId();
|
|
20
20
|
const attributeName =
|
|
21
|
-
|
|
21
|
+
node.sourceType ?? node.type ?? 'PaywallSubscribeButton';
|
|
22
22
|
const attributeKey = node.key ?? generatedId;
|
|
23
23
|
|
|
24
|
-
const { previewMode,
|
|
25
|
-
(s) => ({
|
|
26
|
-
previewMode: s.previewMode,
|
|
27
|
-
current: s.current,
|
|
28
|
-
appConfig: s.appConfig,
|
|
29
|
-
projectColors: s.projectColors,
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
24
|
+
const { previewMode, selectedKey, appConfig } = useBuilderParams();
|
|
32
25
|
|
|
33
|
-
const baseStyle = useExtractTextStyle(node
|
|
34
|
-
appConfig,
|
|
35
|
-
projectColors,
|
|
36
|
-
});
|
|
26
|
+
const baseStyle = useExtractTextStyle(node);
|
|
37
27
|
|
|
38
|
-
const isSelected = isNodeSelected({
|
|
28
|
+
const isSelected = isNodeSelected({
|
|
29
|
+
previewMode: !!previewMode,
|
|
30
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
31
|
+
node,
|
|
32
|
+
});
|
|
39
33
|
const style = useMergedStyle(
|
|
40
34
|
baseStyle,
|
|
41
35
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
42
36
|
);
|
|
43
37
|
|
|
44
|
-
const localize = useLocalize();
|
|
38
|
+
const localize = useLocalize({ appConfig });
|
|
45
39
|
const label =
|
|
46
40
|
typeof node.children === 'string' && node.children.trim().length > 0
|
|
47
41
|
? node.children
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useId, useMemo } from 'react';
|
|
2
2
|
import type { RadioButtonComponentProps } from './RadioButtonProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
|
-
import {
|
|
4
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
5
5
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
6
6
|
import { useLogRender } from '../../utils/useLogRender';
|
|
7
7
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -82,32 +82,23 @@ function RadioButton({ node }: RadioButtonComponentProps) {
|
|
|
82
82
|
const attributeName = node.type ?? 'RadioButton';
|
|
83
83
|
const attributeKey = node.key ?? generatedId;
|
|
84
84
|
|
|
85
|
-
const { previewMode,
|
|
86
|
-
(s) => ({
|
|
87
|
-
previewMode: s.previewMode,
|
|
88
|
-
current: s.current,
|
|
89
|
-
appConfig: s.appConfig,
|
|
90
|
-
projectColors: s.projectColors,
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
85
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
93
86
|
|
|
94
|
-
const baseStyle = useExtractViewStyle(node
|
|
95
|
-
appConfig,
|
|
96
|
-
projectColors,
|
|
97
|
-
});
|
|
87
|
+
const baseStyle = useExtractViewStyle(node);
|
|
98
88
|
|
|
99
|
-
const isSelected = isNodeSelected({
|
|
89
|
+
const isSelected = isNodeSelected({
|
|
90
|
+
previewMode: !!previewMode,
|
|
91
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
92
|
+
node,
|
|
93
|
+
});
|
|
100
94
|
const style = useMergedStyle(
|
|
101
95
|
baseStyle,
|
|
102
96
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
103
97
|
);
|
|
104
98
|
|
|
105
|
-
const selected = Boolean(
|
|
106
|
-
const color =
|
|
107
|
-
|
|
108
|
-
? ((node.attributes as any)?.color as string)
|
|
109
|
-
: undefined;
|
|
110
|
-
const size = parseNumberLike((node.attributes as any)?.size);
|
|
99
|
+
const selected = Boolean(node.attributes?.selected);
|
|
100
|
+
const color = node.attributes?.color;
|
|
101
|
+
const size = parseNumberLike(node.attributes?.size);
|
|
111
102
|
|
|
112
103
|
return (
|
|
113
104
|
<div
|
|
@@ -7,7 +7,7 @@ import React, {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import type { TextComponentProps } from './TextProps.generated';
|
|
9
9
|
import useNode from '../useNode';
|
|
10
|
-
import {
|
|
10
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
11
11
|
import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
|
|
12
12
|
import { useLogRender } from '../../utils/useLogRender';
|
|
13
13
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -18,38 +18,30 @@ function Text({ node }: TextComponentProps) {
|
|
|
18
18
|
useLogRender('Text');
|
|
19
19
|
node = useNode(node);
|
|
20
20
|
const generatedId = useId();
|
|
21
|
-
const attributeName =
|
|
21
|
+
const attributeName = node.sourceType ?? node.type ?? 'text';
|
|
22
22
|
const attributeKey = node.key ?? generatedId;
|
|
23
23
|
const textRef = useRef<HTMLParagraphElement | null>(null);
|
|
24
24
|
const [autoFontSizePx, setAutoFontSizePx] = useState<number | null>(null);
|
|
25
|
-
const { appConfig,
|
|
26
|
-
(s) => ({
|
|
27
|
-
appConfig: s.appConfig,
|
|
28
|
-
projectColors: s.projectColors,
|
|
29
|
-
previewMode: s.previewMode,
|
|
30
|
-
current: s.current,
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
25
|
+
const { appConfig, previewMode, selectedKey } = useBuilderParams();
|
|
33
26
|
const keyOrText: string = node.children as string;
|
|
34
|
-
const textStyle = useExtractTextStyle(node
|
|
35
|
-
const isSelected = isNodeSelected({
|
|
36
|
-
|
|
27
|
+
const textStyle = useExtractTextStyle(node);
|
|
28
|
+
const isSelected = isNodeSelected({
|
|
29
|
+
previewMode: !!previewMode,
|
|
30
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
31
|
+
node,
|
|
32
|
+
});
|
|
33
|
+
const localize = useLocalize({ appConfig });
|
|
37
34
|
|
|
38
35
|
const localizedText = useMemo(
|
|
39
36
|
() => localize(keyOrText),
|
|
40
37
|
[localize, keyOrText],
|
|
41
38
|
);
|
|
42
39
|
|
|
43
|
-
const attrs =
|
|
44
|
-
| (Record<string, unknown> & { style?: Record<string, unknown> })
|
|
45
|
-
| undefined;
|
|
40
|
+
const attrs = node.attributes;
|
|
46
41
|
const styleBag = attrs?.style;
|
|
47
|
-
const adjustsFontSizeToFit =
|
|
48
|
-
(attrs?.adjustsFontSizeToFit as boolean | undefined) ??
|
|
49
|
-
(styleBag?.adjustsFontSizeToFit as boolean | undefined) ??
|
|
50
|
-
false;
|
|
42
|
+
const adjustsFontSizeToFit = attrs?.adjustsFontSizeToFit ?? false;
|
|
51
43
|
const showEllipsis =
|
|
52
|
-
|
|
44
|
+
attrs?.showEllipsis ??
|
|
53
45
|
(styleBag?.showEllipsis as boolean | undefined) ??
|
|
54
46
|
false;
|
|
55
47
|
|
|
@@ -3,7 +3,7 @@ import type { ViewComponentProps } from './ViewProps.generated';
|
|
|
3
3
|
import RenderNode from '../RenderNode.generated';
|
|
4
4
|
import { Node } from '../../types/Node';
|
|
5
5
|
import useNode from '../useNode';
|
|
6
|
-
import {
|
|
6
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
7
7
|
import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
|
|
8
8
|
import { useLogRender } from '../../utils/useLogRender';
|
|
9
9
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
@@ -13,18 +13,15 @@ export function View({ node }: ViewComponentProps) {
|
|
|
13
13
|
useLogRender('View');
|
|
14
14
|
node = useNode(node);
|
|
15
15
|
const generatedId = useId();
|
|
16
|
-
const attributeName =
|
|
16
|
+
const attributeName = node.sourceType ?? node.type ?? 'view';
|
|
17
17
|
const attributeKey = node.key ?? generatedId;
|
|
18
|
-
const { previewMode,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
const baseStyle = useExtractViewStyle(node, { appConfig, projectColors });
|
|
27
|
-
const isSelected = isNodeSelected({ previewMode, current, node });
|
|
18
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
19
|
+
const baseStyle = useExtractViewStyle(node);
|
|
20
|
+
const isSelected = isNodeSelected({
|
|
21
|
+
previewMode: !!previewMode,
|
|
22
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
23
|
+
node,
|
|
24
|
+
});
|
|
28
25
|
const viewStyle = useMergedStyle(
|
|
29
26
|
baseStyle,
|
|
30
27
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|