@developer_tribe/react-builder 1.2.28 → 1.2.30
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 +7 -2
- package/dist/attributes-editor/attributesEditorModelTypes.d.ts +0 -1
- package/dist/build-components/index.generated.d.ts +38 -0
- package/dist/components/BuilderProvider.d.ts +9 -15
- package/dist/hooks/useLocalize.d.ts +3 -2
- package/dist/hooks/usePreviewSelection.d.ts +12 -0
- package/dist/index.cjs.js +1 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +1 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +4 -4
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +4 -4
- package/dist/index.web.esm.js.map +1 -1
- package/dist/logger.d.ts +3 -6
- package/dist/modals/IconPickerModal.d.ts +1 -1
- package/dist/pages/DebugJsonPage.d.ts +1 -4
- package/dist/product-base/index.d.ts +24 -0
- package/dist/size-matters/index.d.ts +15 -6
- package/dist/store.d.ts +5 -3
- package/dist/types/Icons.generated.d.ts +2 -0
- package/dist/types/PreviewConfig.d.ts +6 -8
- package/dist/types/Project.d.ts +4 -3
- package/dist/utils/extractTextStyle/extractTextStyle.d.ts +2 -0
- package/dist/utils/extractTextStyle/extractTextStyleNative.d.ts +2 -0
- package/dist/utils/extractViewStyle/extractViewStyle.d.ts +2 -0
- package/dist/utils/extractViewStyle/extractViewStyleNative.d.ts +2 -0
- package/package.json +1 -1
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +19 -9
- package/src/RenderPage.tsx +66 -57
- package/src/assets/.DS_Store +0 -0
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/carousel-sample.json +2 -6
- package/src/assets/samples/getSamples.ts +14 -4
- package/src/attribute-analyser/style/native/useExtractImageStyle.ts +3 -3
- package/src/attribute-analyser/style/native/useExtractTextStyle.ts +8 -2
- package/src/attribute-analyser/style/native/useExtractViewStyle.ts +7 -3
- package/src/attribute-analyser/style/web/useExtractImageStyle.ts +3 -3
- package/src/attribute-analyser/style/web/useExtractTextStyle.ts +8 -2
- package/src/attribute-analyser/style/web/useExtractViewStyle.ts +3 -3
- package/src/attributes-editor/AttributesEditorFields.tsx +1 -1
- package/src/attributes-editor/attributesEditorModelTypes.ts +0 -3
- package/src/attributes-editor/useAttributesEditorModel.ts +0 -3
- package/src/build-components/BIcon/BIcon.tsx +1 -1
- package/src/build-components/Button/Button.tsx +2 -2
- package/src/build-components/CarouselDots/CarouselDots.tsx +3 -3
- package/src/build-components/OnboardButton/OnboardButton.tsx +2 -2
- package/src/build-components/OnboardDot/OnboardDot.tsx +9 -3
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +4 -5
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +1 -1
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +2 -2
- package/src/build-components/Text/Text.tsx +2 -2
- package/src/build-components/index.generated.ts +184 -0
- package/src/components/BottomBar.tsx +7 -9
- package/src/components/BuilderProvider.tsx +47 -84
- package/src/components/EditorHeader.tsx +6 -3
- package/src/hooks/useLocalize.ts +14 -10
- package/src/hooks/usePreviewSelection.ts +66 -0
- package/src/index.ts +2 -2
- package/src/logger.ts +4 -20
- package/src/modals/IconPickerModal.tsx +1 -1
- package/src/modals/InspectModal.tsx +6 -7
- package/src/modals/ProductPresetsModal.tsx +2 -2
- package/src/pages/DebugJsonPage.tsx +0 -6
- package/src/pages/ProjectPage.tsx +12 -57
- package/src/pages/tabs/SideTool.tsx +7 -7
- package/src/product-base/extractAndroidParams.ts +4 -11
- package/src/product-base/extractIOSParams.ts +4 -10
- package/src/product-base/index.ts +36 -0
- package/src/size-matters/index.ts +44 -31
- package/src/store.ts +12 -6
- package/src/styles/modals/_inspect-modal.scss +7 -3
- package/src/types/Icons.generated.ts +244 -0
- package/src/types/PreviewConfig.ts +5 -9
- package/src/types/Project.ts +4 -3
- package/src/utils/extractImageStyle.ts +4 -2
- package/src/utils/extractTextStyle/extractTextStyle.ts +6 -1
- package/src/utils/extractTextStyle/extractTextStyleNative.ts +4 -1
- package/src/utils/extractViewStyle/extractViewStyle.ts +7 -5
- package/src/utils/extractViewStyle/extractViewStyleNative.ts +3 -1
- package/src/utils/getDefaultProject.ts +0 -1
- package/src/utils/replaceLocalizationParams.ts +1 -1
|
@@ -8,10 +8,10 @@ import { extractViewStyle } from '../../../utils/extractViewStyle';
|
|
|
8
8
|
export function useExtractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
9
9
|
node: NodeData<T>,
|
|
10
10
|
): CSSProperties {
|
|
11
|
-
const { theme, projectColors } = useBuilderParams();
|
|
11
|
+
const { mockTheme: theme, projectColors, baseSize } = useBuilderParams();
|
|
12
12
|
|
|
13
13
|
return useMemo(
|
|
14
|
-
() => extractViewStyle(node, { theme, projectColors }),
|
|
15
|
-
[node, theme, projectColors],
|
|
14
|
+
() => extractViewStyle(node, { theme, projectColors, baseSize }),
|
|
15
|
+
[node, theme, projectColors, baseSize],
|
|
16
16
|
);
|
|
17
17
|
}
|
|
@@ -5,7 +5,7 @@ import { IconPickerModal } from '../modals/IconPickerModal';
|
|
|
5
5
|
import Modal from '../modals/Modal';
|
|
6
6
|
import { loadFontFamily } from '../utils/loadFontFamily';
|
|
7
7
|
import { fontsDebug } from '../utils/fontsDebug';
|
|
8
|
-
import type { IconsType } from '../types/Icons';
|
|
8
|
+
import type { IconsType } from '../types/Icons.generated';
|
|
9
9
|
|
|
10
10
|
type IconTypePickerFieldProps = {
|
|
11
11
|
name: string;
|
|
@@ -41,9 +41,6 @@ export type AttributesEditorModel = {
|
|
|
41
41
|
isInvalidNode: boolean;
|
|
42
42
|
baseData: NodeData<NodeDefaultAttribute>;
|
|
43
43
|
data: NodeData<NodeDefaultAttribute>;
|
|
44
|
-
|
|
45
|
-
// store-derived
|
|
46
|
-
appConfig: unknown;
|
|
47
44
|
projectFonts: Fonts;
|
|
48
45
|
loadedFonts: string[] | undefined;
|
|
49
46
|
markFontLoaded: (fontFamily: string) => void;
|
|
@@ -49,13 +49,11 @@ export function useAttributesEditorModel({
|
|
|
49
49
|
|
|
50
50
|
const data = useNode(baseData);
|
|
51
51
|
const {
|
|
52
|
-
appConfig,
|
|
53
52
|
fonts: projectFonts,
|
|
54
53
|
loadedFonts,
|
|
55
54
|
markFontLoaded,
|
|
56
55
|
addError,
|
|
57
56
|
} = useRenderStore((state) => ({
|
|
58
|
-
appConfig: state.appConfig,
|
|
59
57
|
fonts: state.fonts,
|
|
60
58
|
loadedFonts: state.loadedFonts,
|
|
61
59
|
markFontLoaded: state.markFontLoaded,
|
|
@@ -414,7 +412,6 @@ export function useAttributesEditorModel({
|
|
|
414
412
|
isInvalidNode,
|
|
415
413
|
baseData,
|
|
416
414
|
data,
|
|
417
|
-
appConfig,
|
|
418
415
|
projectFonts,
|
|
419
416
|
loadedFonts,
|
|
420
417
|
markFontLoaded,
|
|
@@ -6,7 +6,7 @@ import { useLogRender } from '../../utils/useLogRender';
|
|
|
6
6
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
7
7
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
8
8
|
import { Icon } from '../../components/Icon.generated';
|
|
9
|
-
import { IconsType } from '../../types/Icons';
|
|
9
|
+
import { IconsType } from '../../types/Icons.generated';
|
|
10
10
|
import { useExtractTextStyle } from '../../attribute-analyser/style/web/useExtractTextStyle';
|
|
11
11
|
|
|
12
12
|
function BIcon({ node }: BIconComponentProps) {
|
|
@@ -15,8 +15,8 @@ function Button({ node }: ButtonComponentProps) {
|
|
|
15
15
|
const generatedId = useId();
|
|
16
16
|
const attributeName = node.sourceType ?? node.type ?? 'button';
|
|
17
17
|
const attributeKey = node.key ?? generatedId;
|
|
18
|
-
const { previewMode, selectedKey
|
|
19
|
-
const localize = useLocalize(
|
|
18
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
19
|
+
const localize = useLocalize();
|
|
20
20
|
const baseStyle = useExtractViewStyle(node);
|
|
21
21
|
const combinedTextStyle = useExtractTextStyle(node);
|
|
22
22
|
const textStyle = useMemo(() => {
|
|
@@ -51,7 +51,7 @@ function CarouselDots({ node }: CarouselDotsComponentProps) {
|
|
|
51
51
|
(stylesBag?.dot_thickness as string | number | undefined) ??
|
|
52
52
|
(attrRecord.dot_thickness as string | number | undefined);
|
|
53
53
|
|
|
54
|
-
const { theme, projectColors } = useBuilderParams();
|
|
54
|
+
const { mockTheme: theme, projectColors, baseSize } = useBuilderParams();
|
|
55
55
|
const isDark = theme === 'dark';
|
|
56
56
|
const inactiveDotColorBase = isDark
|
|
57
57
|
? GHOST_DOT_DARK_COLOR
|
|
@@ -70,12 +70,12 @@ function CarouselDots({ node }: CarouselDotsComponentProps) {
|
|
|
70
70
|
}, [inactiveDotColorBase, inactiveDotColorOverride, theme, projectColors]);
|
|
71
71
|
|
|
72
72
|
const dotSizeCss = useMemo(() => {
|
|
73
|
-
const parsed = parseSize(dotThicknessRaw);
|
|
73
|
+
const parsed = parseSize(dotThicknessRaw, baseSize);
|
|
74
74
|
if (parsed === undefined) return '10px';
|
|
75
75
|
if (typeof parsed === 'number') return `${parsed}px`;
|
|
76
76
|
if (typeof parsed === 'string' && parsed.trim()) return parsed;
|
|
77
77
|
return '10px';
|
|
78
|
-
}, [dotThicknessRaw]);
|
|
78
|
+
}, [dotThicknessRaw, baseSize]);
|
|
79
79
|
|
|
80
80
|
const dotGapCss = useMemo((): string => {
|
|
81
81
|
const px =
|
|
@@ -18,7 +18,7 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
18
18
|
node = useNode(node);
|
|
19
19
|
const attributeName = node.sourceType ?? node.type ?? 'OnboardButton';
|
|
20
20
|
const { emblaApi } = useContext(onboardContext) ?? {};
|
|
21
|
-
const { theme, projectColors
|
|
21
|
+
const { theme, projectColors } = useBuilderParams();
|
|
22
22
|
|
|
23
23
|
const context = useMockOSContext();
|
|
24
24
|
const mockPermissionManager = useMockPermission(context);
|
|
@@ -30,7 +30,7 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
30
30
|
const attrRecord = toAttributeRecord(attrs);
|
|
31
31
|
const styleBag = getStyleBag(attrs);
|
|
32
32
|
const labelRaw = attrs?.labelKey ?? '';
|
|
33
|
-
const localize = useLocalize(
|
|
33
|
+
const localize = useLocalize();
|
|
34
34
|
const label = localize(labelRaw);
|
|
35
35
|
|
|
36
36
|
const flex = (attrRecord.flex ?? styleBag?.flex ?? 1) as number;
|
|
@@ -28,7 +28,13 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
28
28
|
'normal_dot';
|
|
29
29
|
const GHOST_DOT_DARK_COLOR = '#E4E5E7';
|
|
30
30
|
const GHOST_DOT_LIGHT_COLOR = '#F7F7F9';
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
previewMode,
|
|
33
|
+
selectedKey,
|
|
34
|
+
mockTheme: theme,
|
|
35
|
+
projectColors,
|
|
36
|
+
baseSize,
|
|
37
|
+
} = useBuilderParams();
|
|
32
38
|
const isDark = theme === 'dark';
|
|
33
39
|
|
|
34
40
|
// OnboardDot specific attributes
|
|
@@ -76,12 +82,12 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
|
|
|
76
82
|
(stylesBag?.dot_thickness as string | number | undefined) ??
|
|
77
83
|
(attrRecord.dot_thickness as string | number | undefined);
|
|
78
84
|
const dotSizeCss = useMemo((): string => {
|
|
79
|
-
const parsed = parseSize(dotThicknessRaw);
|
|
85
|
+
const parsed = parseSize(dotThicknessRaw, baseSize);
|
|
80
86
|
if (parsed === undefined) return '10px';
|
|
81
87
|
if (typeof parsed === 'number') return `${parsed}px`;
|
|
82
88
|
if (typeof parsed === 'string' && parsed.trim()) return parsed;
|
|
83
89
|
return '10px';
|
|
84
|
-
}, [dotThicknessRaw]);
|
|
90
|
+
}, [dotThicknessRaw, baseSize]);
|
|
85
91
|
const dotGapCss = useMemo((): string => {
|
|
86
92
|
// Prefer px math when possible; otherwise fall back to 10px/3.
|
|
87
93
|
const px =
|
|
@@ -7,7 +7,7 @@ import { useExtractViewStyle } from '../../attribute-analyser/style/web/useExtra
|
|
|
7
7
|
import { useLogRender } from '../../utils/useLogRender';
|
|
8
8
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
9
9
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
10
|
-
import {
|
|
10
|
+
import { defaultLocalization } from '../../types/PreviewConfig';
|
|
11
11
|
import { parseColor } from '../../utils/parseColor';
|
|
12
12
|
import { getStyleBag, toAttributeRecord } from '../../utils/attributeStyle';
|
|
13
13
|
|
|
@@ -96,18 +96,17 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
|
|
|
96
96
|
node = useNode(node);
|
|
97
97
|
const attributeName = node.sourceType ?? node.type ?? 'OnboardFooter';
|
|
98
98
|
const {
|
|
99
|
-
|
|
99
|
+
localization: builderLocalization,
|
|
100
100
|
theme,
|
|
101
101
|
defaultLanguage,
|
|
102
102
|
previewMode,
|
|
103
103
|
selectedKey,
|
|
104
104
|
projectColors: builderProjectColors,
|
|
105
105
|
} = useBuilderParams();
|
|
106
|
-
const
|
|
106
|
+
const localization = builderLocalization ?? defaultLocalization;
|
|
107
107
|
const projectColors = builderProjectColors;
|
|
108
|
-
const { localication } = appConfig;
|
|
109
108
|
const lang = defaultLanguage ?? 'en';
|
|
110
|
-
const t = (key?: string) => (key ? (
|
|
109
|
+
const t = (key?: string) => (key ? (localization?.[lang]?.[key] ?? key) : '');
|
|
111
110
|
|
|
112
111
|
const attrs = node?.attributes;
|
|
113
112
|
const attrRecord = toAttributeRecord(attrs);
|
|
@@ -8,7 +8,7 @@ import { useLogRender } from '../../utils/useLogRender';
|
|
|
8
8
|
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
9
9
|
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
10
10
|
import { Icon } from '../../components/Icon.generated';
|
|
11
|
-
import { IconsType } from '../../types/Icons';
|
|
11
|
+
import { IconsType } from '../../types/Icons.generated';
|
|
12
12
|
import { usePaywallContext } from '../PaywallProvider/PaywallContext';
|
|
13
13
|
|
|
14
14
|
function PaywallCloseButton({ node }: PaywallCloseButtonComponentProps) {
|
|
@@ -21,7 +21,7 @@ function PaywallSubscribeButton({
|
|
|
21
21
|
node.sourceType ?? node.type ?? 'PaywallSubscribeButton';
|
|
22
22
|
const attributeKey = node.key ?? generatedId;
|
|
23
23
|
|
|
24
|
-
const { previewMode, selectedKey
|
|
24
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
25
25
|
|
|
26
26
|
const baseStyle = useExtractTextStyle(node);
|
|
27
27
|
|
|
@@ -35,7 +35,7 @@ function PaywallSubscribeButton({
|
|
|
35
35
|
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const localize = useLocalize(
|
|
38
|
+
const localize = useLocalize();
|
|
39
39
|
const label =
|
|
40
40
|
typeof node.children === 'string' && node.children.trim().length > 0
|
|
41
41
|
? node.children
|
|
@@ -17,7 +17,7 @@ function Text({ node }: TextComponentProps) {
|
|
|
17
17
|
const attributeKey = node.key;
|
|
18
18
|
const textRef = useRef<HTMLParagraphElement | null>(null);
|
|
19
19
|
const [autoFontSizePx, setAutoFontSizePx] = useState<number | null>(null);
|
|
20
|
-
const {
|
|
20
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
21
21
|
const keyOrText: string = node.children as string;
|
|
22
22
|
const textStyle = useExtractTextStyle(node);
|
|
23
23
|
const isSelected = isNodeSelected({
|
|
@@ -25,7 +25,7 @@ function Text({ node }: TextComponentProps) {
|
|
|
25
25
|
current: selectedKey ? { key: selectedKey } : undefined,
|
|
26
26
|
node,
|
|
27
27
|
});
|
|
28
|
-
const localize = useLocalize(
|
|
28
|
+
const localize = useLocalize();
|
|
29
29
|
const translateCounter = (node.attributes as Record<string, unknown>)
|
|
30
30
|
?.translateCounter as number | undefined;
|
|
31
31
|
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export { default as RenderNode } from './RenderNode.generated';
|
|
4
|
+
|
|
5
|
+
export { patterns } from './patterns.generated';
|
|
6
|
+
|
|
7
|
+
export const allcomponentNames = [
|
|
8
|
+
'BIcon',
|
|
9
|
+
'BackgroundImage',
|
|
10
|
+
'Button',
|
|
11
|
+
'Carousel',
|
|
12
|
+
'CarouselButtons',
|
|
13
|
+
'CarouselDots',
|
|
14
|
+
'CarouselItem',
|
|
15
|
+
'CarouselProvider',
|
|
16
|
+
'CountDown',
|
|
17
|
+
'Image',
|
|
18
|
+
'Main',
|
|
19
|
+
'NavigationBarColor',
|
|
20
|
+
'Onboard',
|
|
21
|
+
'OnboardButton',
|
|
22
|
+
'OnboardButtons',
|
|
23
|
+
'OnboardDot',
|
|
24
|
+
'OnboardFooter',
|
|
25
|
+
'OnboardImage',
|
|
26
|
+
'OnboardItem',
|
|
27
|
+
'OnboardProvider',
|
|
28
|
+
'OnboardSubtitle',
|
|
29
|
+
'OnboardTitle',
|
|
30
|
+
'PaywallBackground',
|
|
31
|
+
'PaywallCloseButton',
|
|
32
|
+
'PaywallOptions',
|
|
33
|
+
'PaywallProvider',
|
|
34
|
+
'PaywallSubscribeButton',
|
|
35
|
+
'PriceTag',
|
|
36
|
+
'Pricing',
|
|
37
|
+
'Promo',
|
|
38
|
+
'RadioButton',
|
|
39
|
+
'Separator',
|
|
40
|
+
'StatusBarColor',
|
|
41
|
+
'Text',
|
|
42
|
+
'View',
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
export type {
|
|
46
|
+
BIconPropsGenerated,
|
|
47
|
+
BIconComponentProps,
|
|
48
|
+
} from './BIcon/BIconProps.generated';
|
|
49
|
+
export type {
|
|
50
|
+
BackgroundImagePropsGenerated,
|
|
51
|
+
BackgroundImageComponentProps,
|
|
52
|
+
} from './BackgroundImage/BackgroundImageProps.generated';
|
|
53
|
+
export type {
|
|
54
|
+
ButtonPropsGenerated,
|
|
55
|
+
ButtonComponentProps,
|
|
56
|
+
} from './Button/ButtonProps.generated';
|
|
57
|
+
export type {
|
|
58
|
+
CarouselPropsGenerated,
|
|
59
|
+
CarouselComponentProps,
|
|
60
|
+
} from './Carousel/CarouselProps.generated';
|
|
61
|
+
export type {
|
|
62
|
+
CarouselButtonsPropsGenerated,
|
|
63
|
+
CarouselButtonsComponentProps,
|
|
64
|
+
} from './CarouselButtons/CarouselButtonsProps.generated';
|
|
65
|
+
export type {
|
|
66
|
+
CarouselDotsPropsGenerated,
|
|
67
|
+
CarouselDotsComponentProps,
|
|
68
|
+
} from './CarouselDots/CarouselDotsProps.generated';
|
|
69
|
+
export type {
|
|
70
|
+
CarouselItemPropsGenerated,
|
|
71
|
+
CarouselItemComponentProps,
|
|
72
|
+
} from './CarouselItem/CarouselItemProps.generated';
|
|
73
|
+
export type {
|
|
74
|
+
CarouselProviderPropsGenerated,
|
|
75
|
+
CarouselProviderComponentProps,
|
|
76
|
+
} from './CarouselProvider/CarouselProviderProps.generated';
|
|
77
|
+
export type {
|
|
78
|
+
CountDownPropsGenerated,
|
|
79
|
+
CountDownComponentProps,
|
|
80
|
+
} from './CountDown/CountDownProps.generated';
|
|
81
|
+
export type {
|
|
82
|
+
ImagePropsGenerated,
|
|
83
|
+
ImageComponentProps,
|
|
84
|
+
} from './Image/ImageProps.generated';
|
|
85
|
+
export type {
|
|
86
|
+
MainPropsGenerated,
|
|
87
|
+
MainComponentProps,
|
|
88
|
+
} from './Main/MainProps.generated';
|
|
89
|
+
export type {
|
|
90
|
+
NavigationBarColorPropsGenerated,
|
|
91
|
+
NavigationBarColorComponentProps,
|
|
92
|
+
} from './NavigationBarColor/NavigationBarColorProps.generated';
|
|
93
|
+
export type {
|
|
94
|
+
OnboardPropsGenerated,
|
|
95
|
+
OnboardComponentProps,
|
|
96
|
+
} from './Onboard/OnboardProps.generated';
|
|
97
|
+
export type {
|
|
98
|
+
OnboardButtonPropsGenerated,
|
|
99
|
+
OnboardButtonComponentProps,
|
|
100
|
+
} from './OnboardButton/OnboardButtonProps.generated';
|
|
101
|
+
export type {
|
|
102
|
+
OnboardButtonsPropsGenerated,
|
|
103
|
+
OnboardButtonsComponentProps,
|
|
104
|
+
} from './OnboardButtons/OnboardButtonsProps.generated';
|
|
105
|
+
export type {
|
|
106
|
+
OnboardDotPropsGenerated,
|
|
107
|
+
OnboardDotComponentProps,
|
|
108
|
+
} from './OnboardDot/OnboardDotProps.generated';
|
|
109
|
+
export type {
|
|
110
|
+
OnboardFooterPropsGenerated,
|
|
111
|
+
OnboardFooterComponentProps,
|
|
112
|
+
} from './OnboardFooter/OnboardFooterProps.generated';
|
|
113
|
+
export type {
|
|
114
|
+
OnboardImagePropsGenerated,
|
|
115
|
+
OnboardImageComponentProps,
|
|
116
|
+
} from './OnboardImage/OnboardImageProps.generated';
|
|
117
|
+
export type {
|
|
118
|
+
OnboardItemPropsGenerated,
|
|
119
|
+
OnboardItemComponentProps,
|
|
120
|
+
} from './OnboardItem/OnboardItemProps.generated';
|
|
121
|
+
export type {
|
|
122
|
+
OnboardProviderPropsGenerated,
|
|
123
|
+
OnboardProviderComponentProps,
|
|
124
|
+
} from './OnboardProvider/OnboardProviderProps.generated';
|
|
125
|
+
export type {
|
|
126
|
+
OnboardSubtitlePropsGenerated,
|
|
127
|
+
OnboardSubtitleComponentProps,
|
|
128
|
+
} from './OnboardSubtitle/OnboardSubtitleProps.generated';
|
|
129
|
+
export type {
|
|
130
|
+
OnboardTitlePropsGenerated,
|
|
131
|
+
OnboardTitleComponentProps,
|
|
132
|
+
} from './OnboardTitle/OnboardTitleProps.generated';
|
|
133
|
+
export type {
|
|
134
|
+
PaywallBackgroundPropsGenerated,
|
|
135
|
+
PaywallBackgroundComponentProps,
|
|
136
|
+
} from './PaywallBackground/PaywallBackgroundProps.generated';
|
|
137
|
+
export type {
|
|
138
|
+
PaywallCloseButtonPropsGenerated,
|
|
139
|
+
PaywallCloseButtonComponentProps,
|
|
140
|
+
} from './PaywallCloseButton/PaywallCloseButtonProps.generated';
|
|
141
|
+
export type {
|
|
142
|
+
PaywallOptionsPropsGenerated,
|
|
143
|
+
PaywallOptionsComponentProps,
|
|
144
|
+
} from './PaywallOptions/PaywallOptionsProps.generated';
|
|
145
|
+
export type {
|
|
146
|
+
PaywallProviderPropsGenerated,
|
|
147
|
+
PaywallProviderComponentProps,
|
|
148
|
+
} from './PaywallProvider/PaywallProviderProps.generated';
|
|
149
|
+
export type {
|
|
150
|
+
PaywallSubscribeButtonPropsGenerated,
|
|
151
|
+
PaywallSubscribeButtonComponentProps,
|
|
152
|
+
} from './PaywallSubscribeButton/PaywallSubscribeButtonProps.generated';
|
|
153
|
+
export type {
|
|
154
|
+
PriceTagPropsGenerated,
|
|
155
|
+
PriceTagComponentProps,
|
|
156
|
+
} from './PriceTag/PriceTagProps.generated';
|
|
157
|
+
export type {
|
|
158
|
+
PricingPropsGenerated,
|
|
159
|
+
PricingComponentProps,
|
|
160
|
+
} from './Pricing/PricingProps.generated';
|
|
161
|
+
export type {
|
|
162
|
+
PromoPropsGenerated,
|
|
163
|
+
PromoComponentProps,
|
|
164
|
+
} from './Promo/PromoProps.generated';
|
|
165
|
+
export type {
|
|
166
|
+
RadioButtonPropsGenerated,
|
|
167
|
+
RadioButtonComponentProps,
|
|
168
|
+
} from './RadioButton/RadioButtonProps.generated';
|
|
169
|
+
export type {
|
|
170
|
+
SeparatorPropsGenerated,
|
|
171
|
+
SeparatorComponentProps,
|
|
172
|
+
} from './Separator/SeparatorProps.generated';
|
|
173
|
+
export type {
|
|
174
|
+
StatusBarColorPropsGenerated,
|
|
175
|
+
StatusBarColorComponentProps,
|
|
176
|
+
} from './StatusBarColor/StatusBarColorProps.generated';
|
|
177
|
+
export type {
|
|
178
|
+
TextPropsGenerated,
|
|
179
|
+
TextComponentProps,
|
|
180
|
+
} from './Text/TextProps.generated';
|
|
181
|
+
export type {
|
|
182
|
+
ViewPropsGenerated,
|
|
183
|
+
ViewComponentProps,
|
|
184
|
+
} from './View/ViewProps.generated';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Icon } from './Icon.generated';
|
|
3
|
-
import type { IconsType } from '../types/Icons';
|
|
3
|
+
import type { IconsType } from '../types/Icons.generated';
|
|
4
4
|
import { useRenderStore } from '../store';
|
|
5
5
|
import type { Localication } from '../types/PreviewConfig';
|
|
6
6
|
import { InspectModal, LocalicationModal, Modal } from '../modals';
|
|
@@ -31,8 +31,8 @@ export function BottomBar({
|
|
|
31
31
|
const inspectIcon: IconsType = 'info-circle';
|
|
32
32
|
|
|
33
33
|
const {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
localization,
|
|
35
|
+
setLocalization,
|
|
36
36
|
theme,
|
|
37
37
|
setTheme,
|
|
38
38
|
defaultLanguage,
|
|
@@ -42,8 +42,8 @@ export function BottomBar({
|
|
|
42
42
|
isRtl,
|
|
43
43
|
setIsRtl,
|
|
44
44
|
} = useRenderStore((s) => ({
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
localization: s.localization,
|
|
46
|
+
setLocalization: s.setLocalization,
|
|
47
47
|
theme: s.theme,
|
|
48
48
|
setTheme: s.setTheme,
|
|
49
49
|
defaultLanguage: s.defaultLanguage,
|
|
@@ -62,7 +62,7 @@ export function BottomBar({
|
|
|
62
62
|
const activeLanguage = defaultLanguage;
|
|
63
63
|
|
|
64
64
|
const handleLocalicationChange = (next: Localication) => {
|
|
65
|
-
|
|
65
|
+
setLocalization(next);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
const themeIsActive = theme === 'dark';
|
|
@@ -170,7 +170,7 @@ export function BottomBar({
|
|
|
170
170
|
|
|
171
171
|
{isLocalizationOpen && (
|
|
172
172
|
<LocalicationModal
|
|
173
|
-
data={
|
|
173
|
+
data={localization ?? {}}
|
|
174
174
|
onChange={handleLocalicationChange}
|
|
175
175
|
onClose={() => setIsLocalizationOpen(false)}
|
|
176
176
|
/>
|
|
@@ -191,8 +191,6 @@ export function BottomBar({
|
|
|
191
191
|
description="Inspect and edit raw node JSON."
|
|
192
192
|
previewMode={previewMode}
|
|
193
193
|
setPreviewMode={setPreviewMode}
|
|
194
|
-
appConfig={appConfig}
|
|
195
|
-
setAppConfig={setAppConfig}
|
|
196
194
|
logLabel="BottomBar Debug JSON"
|
|
197
195
|
/>
|
|
198
196
|
</Modal>
|
|
@@ -2,10 +2,13 @@ import React, { createContext, useContext, useMemo } from 'react';
|
|
|
2
2
|
import type { Product } from '../paywall/types/paywall-types';
|
|
3
3
|
import type { PaywallBenefits } from '../paywall/types/benefits';
|
|
4
4
|
import {
|
|
5
|
-
type AppConfig,
|
|
6
5
|
type Theme,
|
|
7
6
|
defaultLocalization,
|
|
8
7
|
defaultTheme,
|
|
8
|
+
type Localication,
|
|
9
|
+
defaultBaseSize,
|
|
10
|
+
type BaseSize,
|
|
11
|
+
defaultLanguage,
|
|
9
12
|
mergeLocalization,
|
|
10
13
|
} from '../types/PreviewConfig';
|
|
11
14
|
import type { Fonts } from '../types/Fonts';
|
|
@@ -19,8 +22,7 @@ import { defaultProjectColors, mergeProjectColors } from '../utils';
|
|
|
19
22
|
export type Products = Product;
|
|
20
23
|
|
|
21
24
|
export type BuilderProviderParams = {
|
|
22
|
-
|
|
23
|
-
mockBenefits: PaywallBenefits;
|
|
25
|
+
// Props that are NOT in store (or are platform specific overrides)
|
|
24
26
|
/**
|
|
25
27
|
* Render platform for style extraction + meta filtering.
|
|
26
28
|
* - 'web' (default): returns CSS-friendly styles for DOM rendering.
|
|
@@ -28,22 +30,25 @@ export type BuilderProviderParams = {
|
|
|
28
30
|
*/
|
|
29
31
|
platform?: 'web' | 'native';
|
|
30
32
|
onPaywallSubscribe?: (product?: Product) => void | boolean | Promise<boolean>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
|
|
34
|
+
// Optional overrides for store values (though usually store is source of truth)
|
|
35
|
+
// We keep these in type for backwards compatibility or explicit overrides if needed,
|
|
36
|
+
// but internally we prefer store values.
|
|
37
|
+
mockProducts?: Products[];
|
|
38
|
+
mockBenefits?: PaywallBenefits;
|
|
39
|
+
mockTheme?: Theme;
|
|
40
|
+
mockDefaultLanguage?: string;
|
|
41
|
+
localization?: Localication;
|
|
42
|
+
baseSize?: BaseSize;
|
|
43
|
+
// projectColors, fonts, previewMode, selectedKey kept as they are commonly used and not explicitly asked to rename
|
|
39
44
|
projectColors?: ProjectColors;
|
|
40
45
|
fonts?: Fonts;
|
|
41
|
-
appFont?: string | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Optional selection info (used by builder UI; ignored by host runtime).
|
|
44
|
-
*/
|
|
45
46
|
previewMode?: boolean;
|
|
46
47
|
selectedKey?: string;
|
|
48
|
+
|
|
49
|
+
// Derived / Convenience values provided by the context (populated from mock* if present)
|
|
50
|
+
theme?: Theme;
|
|
51
|
+
defaultLanguage?: string;
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
type BuilderProviderProps = {
|
|
@@ -56,65 +61,29 @@ const builderContext = createContext<BuilderProviderParams | undefined>(
|
|
|
56
61
|
);
|
|
57
62
|
|
|
58
63
|
export function BuilderProvider({ params, children }: BuilderProviderProps) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
? {
|
|
83
|
-
...(params.appConfig as AppConfig),
|
|
84
|
-
localication: mergeLocalization(
|
|
85
|
-
defaultLocalization,
|
|
86
|
-
(params.appConfig as AppConfig).localication ?? {},
|
|
87
|
-
),
|
|
88
|
-
}
|
|
89
|
-
: undefined,
|
|
90
|
-
projectColors:
|
|
91
|
-
params?.projectColors && typeof params.projectColors === 'object'
|
|
92
|
-
? mergeProjectColors(defaultProjectColors, params.projectColors)
|
|
93
|
-
: defaultProjectColors,
|
|
94
|
-
fonts: Array.isArray(params?.fonts) ? (params.fonts as Fonts) : undefined,
|
|
95
|
-
appFont: params?.appFont,
|
|
96
|
-
platform: params?.platform === 'native' ? 'native' : 'web',
|
|
97
|
-
previewMode: !!params?.previewMode,
|
|
98
|
-
selectedKey:
|
|
99
|
-
typeof params?.selectedKey === 'string'
|
|
100
|
-
? params.selectedKey
|
|
101
|
-
: undefined,
|
|
102
|
-
}),
|
|
103
|
-
[
|
|
104
|
-
params?.mockBenefits,
|
|
105
|
-
params?.mockProducts,
|
|
106
|
-
params?.platform,
|
|
107
|
-
params?.onPaywallSubscribe,
|
|
108
|
-
params?.theme,
|
|
109
|
-
params?.defaultLanguage,
|
|
110
|
-
params?.appConfig,
|
|
111
|
-
params?.projectColors,
|
|
112
|
-
params?.fonts,
|
|
113
|
-
params?.appFont,
|
|
114
|
-
params?.previewMode,
|
|
115
|
-
params?.selectedKey,
|
|
116
|
-
],
|
|
117
|
-
);
|
|
64
|
+
// We rely purely on params passed from parent (which reads from store)
|
|
65
|
+
const value = useMemo<BuilderProviderParams>(() => {
|
|
66
|
+
const theme = params.mockTheme ?? defaultTheme;
|
|
67
|
+
const lang = params.mockDefaultLanguage ?? defaultLanguage;
|
|
68
|
+
return {
|
|
69
|
+
...params,
|
|
70
|
+
// Ensure defaults if missing
|
|
71
|
+
mockProducts: params.mockProducts ?? [],
|
|
72
|
+
mockBenefits: params.mockBenefits ?? {},
|
|
73
|
+
mockTheme: theme,
|
|
74
|
+
mockDefaultLanguage: lang,
|
|
75
|
+
theme,
|
|
76
|
+
defaultLanguage: lang,
|
|
77
|
+
baseSize: params.baseSize ?? defaultBaseSize,
|
|
78
|
+
projectColors: params.projectColors
|
|
79
|
+
? mergeProjectColors(defaultProjectColors, params.projectColors)
|
|
80
|
+
: defaultProjectColors,
|
|
81
|
+
localization: params.localization
|
|
82
|
+
? mergeLocalization(defaultLocalization, params.localization)
|
|
83
|
+
: defaultLocalization,
|
|
84
|
+
platform: params.platform ?? 'web',
|
|
85
|
+
};
|
|
86
|
+
}, [params]);
|
|
118
87
|
|
|
119
88
|
return (
|
|
120
89
|
<builderContext.Provider value={value}>{children}</builderContext.Provider>
|
|
@@ -122,14 +91,8 @@ export function BuilderProvider({ params, children }: BuilderProviderProps) {
|
|
|
122
91
|
}
|
|
123
92
|
|
|
124
93
|
export function useBuilderParams(): Readonly<BuilderProviderParams> {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
platform: 'web',
|
|
130
|
-
theme: defaultTheme,
|
|
131
|
-
defaultLanguage: 'en',
|
|
132
|
-
projectColors: defaultProjectColors,
|
|
133
|
-
}
|
|
134
|
-
);
|
|
94
|
+
const ctx = useContext(builderContext);
|
|
95
|
+
if (ctx) return ctx;
|
|
96
|
+
|
|
97
|
+
throw new Error('useBuilderParams must be used within BuilderProvider');
|
|
135
98
|
}
|
|
@@ -37,13 +37,15 @@ export function EditorHeader({
|
|
|
37
37
|
device: selectedDevice,
|
|
38
38
|
setDevice,
|
|
39
39
|
setCurrent,
|
|
40
|
-
|
|
40
|
+
setLocalization,
|
|
41
|
+
setBaseSize,
|
|
41
42
|
setProjectColors,
|
|
42
43
|
} = useRenderStore((s) => ({
|
|
43
44
|
device: s.device,
|
|
44
45
|
setDevice: s.setDevice,
|
|
45
46
|
setCurrent: s.setCurrent,
|
|
46
|
-
|
|
47
|
+
setLocalization: s.setLocalization,
|
|
48
|
+
setBaseSize: s.setBaseSize,
|
|
47
49
|
setProjectColors: s.setProjectColors,
|
|
48
50
|
}));
|
|
49
51
|
|
|
@@ -143,7 +145,8 @@ export function EditorHeader({
|
|
|
143
145
|
const next = repairNodeKeys(cloneNode(sample.data));
|
|
144
146
|
setEditorData(next);
|
|
145
147
|
setCurrent(next);
|
|
146
|
-
if (sample.
|
|
148
|
+
if (sample.localization) setLocalization(sample.localization);
|
|
149
|
+
if (sample.baseSize) setBaseSize(sample.baseSize);
|
|
147
150
|
setProjectColors(sample.projectColors);
|
|
148
151
|
toast.success(`Replaced with "${sample.name}"`);
|
|
149
152
|
};
|