@developer_tribe/react-builder 1.2.29 → 1.2.31
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/BIcon/BIcon.d.ts +1 -1
- package/dist/build-components/BackgroundImage/BackgroundImage.d.ts +1 -1
- package/dist/build-components/Button/Button.d.ts +1 -1
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +4 -0
- package/dist/build-components/OnboardButton/OnboardButton.d.ts +1 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +0 -2
- package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
- package/dist/build-components/PaywallCloseButton/PaywallCloseButton.d.ts +1 -1
- package/dist/build-components/Text/Text.d.ts +1 -1
- package/dist/build-components/index.generated.d.ts +38 -0
- package/dist/build-components/patterns.generated.d.ts +11 -17
- 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 +2 -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/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/dist/utils/useMergedStyle.d.ts +1 -1
- 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/assets/samples/vpn-onboard-1.json +21 -21
- package/src/assets/samples/vpn-onboard-2.json +21 -45
- package/src/assets/samples/vpn-onboard-3.json +21 -53
- package/src/assets/samples/vpn-onboard-4.json +21 -21
- package/src/assets/samples/vpn-onboard-5.json +33 -33
- package/src/assets/samples/vpn-onboard-6.json +21 -21
- package/src/assets/samples/vpn-onboard-7.json +21 -21
- 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 +2 -2
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +1 -1
- package/src/build-components/Button/Button.tsx +3 -3
- package/src/build-components/CarouselDots/CarouselDots.tsx +10 -19
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +4 -0
- package/src/build-components/CarouselDots/pattern.json +12 -1
- package/src/build-components/Main/Main.tsx +1 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +13 -11
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +0 -2
- package/src/build-components/OnboardButton/pattern.json +0 -16
- package/src/build-components/OnboardDot/OnboardDot.tsx +19 -25
- package/src/build-components/OnboardDot/pattern.json +2 -1
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +4 -5
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +2 -2
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +2 -2
- package/src/build-components/RadioButton/RadioButton.tsx +6 -3
- package/src/build-components/RenderNode.generated.tsx +7 -7
- package/src/build-components/Text/Text.tsx +3 -3
- package/src/build-components/index.generated.ts +184 -0
- package/src/build-components/patterns.generated.ts +11 -17
- 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 +0 -2
- package/src/logger.ts +4 -20
- package/src/modals/IconPickerModal.tsx +1 -1
- package/src/modals/InspectModal.tsx +6 -7
- 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/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/projectColors.ts +3 -2
- package/src/utils/useMergedStyle.ts +9 -7
|
@@ -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';
|
|
@@ -2129,6 +2129,10 @@ export const patterns = [
|
|
|
2129
2129
|
'sliding_dot',
|
|
2130
2130
|
'liquid_like',
|
|
2131
2131
|
],
|
|
2132
|
+
dot_thickness: 'size',
|
|
2133
|
+
inactive_dot_opacity: 'number',
|
|
2134
|
+
inactive_dot_color: 'color',
|
|
2135
|
+
active_dot_color: 'color',
|
|
2132
2136
|
},
|
|
2133
2137
|
},
|
|
2134
2138
|
meta: {
|
|
@@ -2453,6 +2457,11 @@ export const patterns = [
|
|
|
2453
2457
|
flexGrow: 0,
|
|
2454
2458
|
flexShrink: 0,
|
|
2455
2459
|
},
|
|
2460
|
+
dotType: 'expanding_dot',
|
|
2461
|
+
dot_thickness: 10,
|
|
2462
|
+
inactive_dot_opacity: 0.3,
|
|
2463
|
+
active_dot_color: 'STATIC_COLORS.ONBOARD_DOT_ACTIVE',
|
|
2464
|
+
inactive_dot_color: 'THEME_COLORS.BACKGROUND',
|
|
2456
2465
|
},
|
|
2457
2466
|
types: {},
|
|
2458
2467
|
},
|
|
@@ -5270,7 +5279,6 @@ export const patterns = [
|
|
|
5270
5279
|
zIndex: 'number',
|
|
5271
5280
|
},
|
|
5272
5281
|
labelKey: 'string',
|
|
5273
|
-
button_text_color: 'color',
|
|
5274
5282
|
animation: [
|
|
5275
5283
|
'simple-animation',
|
|
5276
5284
|
'line-animation',
|
|
@@ -5279,7 +5287,6 @@ export const patterns = [
|
|
|
5279
5287
|
'blur-line-animation',
|
|
5280
5288
|
],
|
|
5281
5289
|
animation_color: 'color',
|
|
5282
|
-
button_background_color: 'color',
|
|
5283
5290
|
flex: 'number',
|
|
5284
5291
|
events: 'EventObject[]',
|
|
5285
5292
|
},
|
|
@@ -5330,13 +5337,6 @@ export const patterns = [
|
|
|
5330
5337
|
sort: 21,
|
|
5331
5338
|
preferredScale: 's',
|
|
5332
5339
|
},
|
|
5333
|
-
button_text_color: {
|
|
5334
|
-
label: 'Button Text Color',
|
|
5335
|
-
description: 'Text color of the button.',
|
|
5336
|
-
category: 'style',
|
|
5337
|
-
specialCategory: null,
|
|
5338
|
-
sort: 2,
|
|
5339
|
-
},
|
|
5340
5340
|
animation: {
|
|
5341
5341
|
label: 'Animation',
|
|
5342
5342
|
description: 'Animation style for the button.',
|
|
@@ -5351,13 +5351,6 @@ export const patterns = [
|
|
|
5351
5351
|
specialCategory: null,
|
|
5352
5352
|
sort: 4,
|
|
5353
5353
|
},
|
|
5354
|
-
button_background_color: {
|
|
5355
|
-
label: 'Button Background Color',
|
|
5356
|
-
description: 'Background color of the button.',
|
|
5357
|
-
category: 'style',
|
|
5358
|
-
specialCategory: null,
|
|
5359
|
-
sort: 5,
|
|
5360
|
-
},
|
|
5361
5354
|
},
|
|
5362
5355
|
attributes: {
|
|
5363
5356
|
scrollable: {
|
|
@@ -6524,7 +6517,8 @@ export const patterns = [
|
|
|
6524
6517
|
dotType: 'expanding_dot',
|
|
6525
6518
|
dot_thickness: 10,
|
|
6526
6519
|
inactive_dot_opacity: 0.3,
|
|
6527
|
-
active_dot_color: '
|
|
6520
|
+
active_dot_color: 'STATIC_COLORS.ONBOARD_DOT_ACTIVE',
|
|
6521
|
+
inactive_dot_color: 'THEME_COLORS.BACKGROUND',
|
|
6528
6522
|
},
|
|
6529
6523
|
types: {},
|
|
6530
6524
|
},
|
|
@@ -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 mxissing
|
|
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
|
};
|
package/src/hooks/useLocalize.ts
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import type
|
|
3
|
-
import { defaultAppConfig } from '../types/PreviewConfig';
|
|
2
|
+
import { type Localication, defaultLocalization } from '../types/PreviewConfig';
|
|
4
3
|
import { useBuilderParams } from '../components/BuilderProvider';
|
|
5
4
|
import { useLocalizationParams } from './useLocalizationParams';
|
|
6
5
|
import { replaceLocalizationParams } from '../utils/replaceLocalizationParams';
|
|
7
6
|
|
|
8
7
|
export type LocalizeFn = (keyOrText: string) => string;
|
|
9
8
|
|
|
10
|
-
export function useLocalize(options?: {
|
|
9
|
+
export function useLocalize(options?: {
|
|
10
|
+
localization?: Localication;
|
|
11
|
+
defaultLanguage?: string;
|
|
12
|
+
}): LocalizeFn {
|
|
11
13
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
localization: builderLocalization,
|
|
15
|
+
mockDefaultLanguage: builderDefaultLanguage,
|
|
14
16
|
} = useBuilderParams();
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
//TODO: genelle (react-native ksımına export et)
|
|
18
|
+
const localization =
|
|
19
|
+
options?.localization ?? builderLocalization ?? defaultLocalization;
|
|
20
|
+
const defaultLanguage =
|
|
21
|
+
options?.defaultLanguage ?? builderDefaultLanguage ?? 'en';
|
|
18
22
|
const params = useLocalizationParams();
|
|
19
23
|
|
|
20
24
|
return useCallback(
|
|
21
25
|
(keyOrText: string) => {
|
|
22
|
-
const raw =
|
|
26
|
+
const raw = localization?.[defaultLanguage]?.[keyOrText] ?? keyOrText;
|
|
23
27
|
return replaceLocalizationParams(raw, params);
|
|
24
28
|
},
|
|
25
|
-
[defaultLanguage,
|
|
29
|
+
[defaultLanguage, localization, params],
|
|
26
30
|
);
|
|
27
31
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useEffect, type RefObject } from 'react';
|
|
2
|
+
import type { Node } from '../types/Node';
|
|
3
|
+
import { findNodeByKeyNested } from '../utils/findNodeByKeyNested';
|
|
4
|
+
|
|
5
|
+
type UsePreviewSelectionParams = {
|
|
6
|
+
previewMode: boolean;
|
|
7
|
+
data: Node;
|
|
8
|
+
rootRef: RefObject<HTMLDivElement>;
|
|
9
|
+
onSelectNode?: (node: Node | null) => void;
|
|
10
|
+
setCurrent: (node: Node) => void;
|
|
11
|
+
forceRender: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function usePreviewSelection({
|
|
15
|
+
previewMode,
|
|
16
|
+
data,
|
|
17
|
+
rootRef,
|
|
18
|
+
onSelectNode,
|
|
19
|
+
setCurrent,
|
|
20
|
+
forceRender,
|
|
21
|
+
}: UsePreviewSelectionParams) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!previewMode) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const root = rootRef.current;
|
|
28
|
+
if (!root) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handleClick = (event: MouseEvent) => {
|
|
33
|
+
const target = event.target as HTMLElement | null;
|
|
34
|
+
|
|
35
|
+
if (!target) return;
|
|
36
|
+
|
|
37
|
+
// Ignore clicks on carousel dots to avoid interfering with navigation
|
|
38
|
+
if (target.closest('.embla__dot')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Some build-components may attach synthetic keys (e.g. React `useId()`),
|
|
43
|
+
// which are not present in the persisted node tree. Walk up until we find
|
|
44
|
+
// an attribute-key that resolves to a real node.
|
|
45
|
+
let element = target.closest('[attribute-key]') as HTMLElement | null;
|
|
46
|
+
while (element) {
|
|
47
|
+
const key = element.getAttribute('attribute-key');
|
|
48
|
+
if (key) {
|
|
49
|
+
const node = findNodeByKeyNested(data, key);
|
|
50
|
+
if (node) {
|
|
51
|
+
setCurrent(node);
|
|
52
|
+
onSelectNode?.(node);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
element = element.parentElement?.closest('[attribute-key]') ?? null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
root.addEventListener('click', handleClick);
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
root.removeEventListener('click', handleClick);
|
|
64
|
+
};
|
|
65
|
+
}, [previewMode, data, onSelectNode, setCurrent, forceRender, rootRef]); // forceRender: retrigger effect when we want to force a refresh (e.g. route change)
|
|
66
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,13 +16,11 @@ export type { Node, NodeData, NodeDefaultAttribute } from './types/Node';
|
|
|
16
16
|
export type { Project, ProjectColors, ProjectMeta } from './types/Project';
|
|
17
17
|
export type { Device } from './types/Device';
|
|
18
18
|
export type {
|
|
19
|
-
AppConfig,
|
|
20
19
|
Theme,
|
|
21
20
|
Localication,
|
|
22
21
|
LocalizationKey,
|
|
23
22
|
} from './types/PreviewConfig';
|
|
24
23
|
export {
|
|
25
|
-
defaultAppConfig,
|
|
26
24
|
defaultTheme,
|
|
27
25
|
defaultLocalization,
|
|
28
26
|
mergeLocalization,
|
package/src/logger.ts
CHANGED
|
@@ -6,33 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
type LogPayload = Record<string, unknown>;
|
|
9
|
-
type LogOptions = { remote?: boolean };
|
|
10
9
|
|
|
11
10
|
function noop() {}
|
|
12
|
-
|
|
11
|
+
//TODO: bizim logger'ı kullan
|
|
13
12
|
export const iapLogger = {
|
|
14
|
-
error(
|
|
15
|
-
_tags: string[],
|
|
16
|
-
message: string,
|
|
17
|
-
payload?: LogPayload,
|
|
18
|
-
_opts?: LogOptions,
|
|
19
|
-
) {
|
|
13
|
+
error(_tags: string[], message: string, payload?: LogPayload) {
|
|
20
14
|
console.error(`[iap] ${message}`, payload);
|
|
21
15
|
},
|
|
22
|
-
warn(
|
|
23
|
-
_tags: string[],
|
|
24
|
-
message: string,
|
|
25
|
-
payload?: LogPayload,
|
|
26
|
-
_opts?: LogOptions,
|
|
27
|
-
) {
|
|
16
|
+
warn(_tags: string[], message: string, payload?: LogPayload) {
|
|
28
17
|
console.warn(`[iap] ${message}`, payload);
|
|
29
18
|
},
|
|
30
|
-
info(
|
|
31
|
-
_tags: string[],
|
|
32
|
-
message: string,
|
|
33
|
-
payload?: LogPayload,
|
|
34
|
-
_opts?: LogOptions,
|
|
35
|
-
) {
|
|
19
|
+
info(_tags: string[], message: string, payload?: LogPayload) {
|
|
36
20
|
console.info(`[iap] ${message}`, payload);
|
|
37
21
|
},
|
|
38
22
|
debug: noop,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import Modal from './Modal';
|
|
3
|
-
import { Icons, type IconsType } from '../types/Icons';
|
|
3
|
+
import { Icons, type IconsType } from '../types/Icons.generated';
|
|
4
4
|
import { Icon } from '../components/Icon.generated';
|
|
5
5
|
|
|
6
6
|
type IconPickerModalProps = {
|