@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.
Files changed (109) hide show
  1. package/dist/RenderPage.d.ts +7 -2
  2. package/dist/attributes-editor/attributesEditorModelTypes.d.ts +0 -1
  3. package/dist/build-components/BIcon/BIcon.d.ts +1 -1
  4. package/dist/build-components/BackgroundImage/BackgroundImage.d.ts +1 -1
  5. package/dist/build-components/Button/Button.d.ts +1 -1
  6. package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +4 -0
  7. package/dist/build-components/OnboardButton/OnboardButton.d.ts +1 -1
  8. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +0 -2
  9. package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
  10. package/dist/build-components/PaywallCloseButton/PaywallCloseButton.d.ts +1 -1
  11. package/dist/build-components/Text/Text.d.ts +1 -1
  12. package/dist/build-components/index.generated.d.ts +38 -0
  13. package/dist/build-components/patterns.generated.d.ts +11 -17
  14. package/dist/components/BuilderProvider.d.ts +9 -15
  15. package/dist/hooks/useLocalize.d.ts +3 -2
  16. package/dist/hooks/usePreviewSelection.d.ts +12 -0
  17. package/dist/index.cjs.js +1 -28
  18. package/dist/index.cjs.js.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.esm.js +1 -28
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.web.cjs.js +4 -4
  23. package/dist/index.web.cjs.js.map +1 -1
  24. package/dist/index.web.esm.js +4 -4
  25. package/dist/index.web.esm.js.map +1 -1
  26. package/dist/logger.d.ts +3 -6
  27. package/dist/modals/IconPickerModal.d.ts +1 -1
  28. package/dist/pages/DebugJsonPage.d.ts +1 -4
  29. package/dist/size-matters/index.d.ts +15 -6
  30. package/dist/store.d.ts +5 -3
  31. package/dist/types/Icons.generated.d.ts +2 -0
  32. package/dist/types/PreviewConfig.d.ts +6 -8
  33. package/dist/types/Project.d.ts +4 -3
  34. package/dist/utils/extractTextStyle/extractTextStyle.d.ts +2 -0
  35. package/dist/utils/extractTextStyle/extractTextStyleNative.d.ts +2 -0
  36. package/dist/utils/extractViewStyle/extractViewStyle.d.ts +2 -0
  37. package/dist/utils/extractViewStyle/extractViewStyleNative.d.ts +2 -0
  38. package/dist/utils/useMergedStyle.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +19 -9
  41. package/src/RenderPage.tsx +66 -57
  42. package/src/assets/.DS_Store +0 -0
  43. package/src/assets/meta.json +1 -1
  44. package/src/assets/samples/carousel-sample.json +2 -6
  45. package/src/assets/samples/getSamples.ts +14 -4
  46. package/src/assets/samples/vpn-onboard-1.json +21 -21
  47. package/src/assets/samples/vpn-onboard-2.json +21 -45
  48. package/src/assets/samples/vpn-onboard-3.json +21 -53
  49. package/src/assets/samples/vpn-onboard-4.json +21 -21
  50. package/src/assets/samples/vpn-onboard-5.json +33 -33
  51. package/src/assets/samples/vpn-onboard-6.json +21 -21
  52. package/src/assets/samples/vpn-onboard-7.json +21 -21
  53. package/src/attribute-analyser/style/native/useExtractImageStyle.ts +3 -3
  54. package/src/attribute-analyser/style/native/useExtractTextStyle.ts +8 -2
  55. package/src/attribute-analyser/style/native/useExtractViewStyle.ts +7 -3
  56. package/src/attribute-analyser/style/web/useExtractImageStyle.ts +3 -3
  57. package/src/attribute-analyser/style/web/useExtractTextStyle.ts +8 -2
  58. package/src/attribute-analyser/style/web/useExtractViewStyle.ts +3 -3
  59. package/src/attributes-editor/AttributesEditorFields.tsx +1 -1
  60. package/src/attributes-editor/attributesEditorModelTypes.ts +0 -3
  61. package/src/attributes-editor/useAttributesEditorModel.ts +0 -3
  62. package/src/build-components/BIcon/BIcon.tsx +2 -2
  63. package/src/build-components/BackgroundImage/BackgroundImage.tsx +1 -1
  64. package/src/build-components/Button/Button.tsx +3 -3
  65. package/src/build-components/CarouselDots/CarouselDots.tsx +10 -19
  66. package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +4 -0
  67. package/src/build-components/CarouselDots/pattern.json +12 -1
  68. package/src/build-components/Main/Main.tsx +1 -0
  69. package/src/build-components/OnboardButton/OnboardButton.tsx +13 -11
  70. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +0 -2
  71. package/src/build-components/OnboardButton/pattern.json +0 -16
  72. package/src/build-components/OnboardDot/OnboardDot.tsx +19 -25
  73. package/src/build-components/OnboardDot/pattern.json +2 -1
  74. package/src/build-components/OnboardFooter/OnboardFooter.tsx +4 -5
  75. package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +2 -2
  76. package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +2 -2
  77. package/src/build-components/RadioButton/RadioButton.tsx +6 -3
  78. package/src/build-components/RenderNode.generated.tsx +7 -7
  79. package/src/build-components/Text/Text.tsx +3 -3
  80. package/src/build-components/index.generated.ts +184 -0
  81. package/src/build-components/patterns.generated.ts +11 -17
  82. package/src/components/BottomBar.tsx +7 -9
  83. package/src/components/BuilderProvider.tsx +47 -84
  84. package/src/components/EditorHeader.tsx +6 -3
  85. package/src/hooks/useLocalize.ts +14 -10
  86. package/src/hooks/usePreviewSelection.ts +66 -0
  87. package/src/index.ts +0 -2
  88. package/src/logger.ts +4 -20
  89. package/src/modals/IconPickerModal.tsx +1 -1
  90. package/src/modals/InspectModal.tsx +6 -7
  91. package/src/pages/DebugJsonPage.tsx +0 -6
  92. package/src/pages/ProjectPage.tsx +12 -57
  93. package/src/pages/tabs/SideTool.tsx +7 -7
  94. package/src/product-base/extractAndroidParams.ts +4 -11
  95. package/src/product-base/extractIOSParams.ts +4 -10
  96. package/src/size-matters/index.ts +44 -31
  97. package/src/store.ts +12 -6
  98. package/src/styles/modals/_inspect-modal.scss +7 -3
  99. package/src/types/Icons.generated.ts +244 -0
  100. package/src/types/PreviewConfig.ts +5 -9
  101. package/src/types/Project.ts +4 -3
  102. package/src/utils/extractImageStyle.ts +4 -2
  103. package/src/utils/extractTextStyle/extractTextStyle.ts +6 -1
  104. package/src/utils/extractTextStyle/extractTextStyleNative.ts +4 -1
  105. package/src/utils/extractViewStyle/extractViewStyle.ts +7 -5
  106. package/src/utils/extractViewStyle/extractViewStyleNative.ts +3 -1
  107. package/src/utils/getDefaultProject.ts +0 -1
  108. package/src/utils/projectColors.ts +3 -2
  109. 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: '#007AFF',
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
- appConfig,
35
- setAppConfig,
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
- appConfig: s.appConfig,
46
- setAppConfig: s.setAppConfig,
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
- setAppConfig({ ...appConfig, localication: next });
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={appConfig.localication ?? {}}
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
- mockProducts: Products[];
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
- * Optional runtime config + styling inputs.
33
- * These are intentionally passed down via BuilderProvider so `build-components`
34
- * never need to touch `useRenderStore`.
35
- */
36
- theme?: Theme;
37
- defaultLanguage?: string;
38
- appConfig?: AppConfig;
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
- const value = useMemo<BuilderProviderParams>(
60
- () => ({
61
- mockProducts: Array.isArray(params?.mockProducts)
62
- ? params.mockProducts
63
- : [],
64
- mockBenefits:
65
- params?.mockBenefits && typeof params.mockBenefits === 'object'
66
- ? (params.mockBenefits as PaywallBenefits)
67
- : {},
68
- onPaywallSubscribe:
69
- typeof params?.onPaywallSubscribe === 'function'
70
- ? params.onPaywallSubscribe
71
- : undefined,
72
- theme:
73
- params?.theme === 'light' || params?.theme === 'dark'
74
- ? params.theme
75
- : defaultTheme,
76
- defaultLanguage:
77
- typeof params?.defaultLanguage === 'string'
78
- ? params.defaultLanguage
79
- : 'en',
80
- appConfig:
81
- params?.appConfig && typeof params.appConfig === 'object'
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
- return (
126
- useContext(builderContext) ?? {
127
- mockProducts: [],
128
- mockBenefits: {},
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
- setAppConfig,
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
- setAppConfig: s.setAppConfig,
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.appConfig) setAppConfig(sample.appConfig);
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
  };
@@ -1,27 +1,31 @@
1
1
  import { useCallback } from 'react';
2
- import type { AppConfig } from '../types/PreviewConfig';
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?: { appConfig?: AppConfig }): LocalizeFn {
9
+ export function useLocalize(options?: {
10
+ localization?: Localication;
11
+ defaultLanguage?: string;
12
+ }): LocalizeFn {
11
13
  const {
12
- appConfig: builderAppConfig,
13
- defaultLanguage: builderDefaultLanguage,
14
+ localization: builderLocalization,
15
+ mockDefaultLanguage: builderDefaultLanguage,
14
16
  } = useBuilderParams();
15
- const appConfig = options?.appConfig ?? builderAppConfig ?? defaultAppConfig;
16
- const defaultLanguage = builderDefaultLanguage ?? 'en';
17
- const { localication } = appConfig;
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 = localication?.[defaultLanguage]?.[keyOrText] ?? keyOrText;
26
+ const raw = localization?.[defaultLanguage]?.[keyOrText] ?? keyOrText;
23
27
  return replaceLocalizationParams(raw, params);
24
28
  },
25
- [defaultLanguage, localication, params],
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 = {