@developer_tribe/react-builder 1.2.27 → 1.2.28

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 (156) hide show
  1. package/dist/assets/samples/getSamples.d.ts +0 -3
  2. package/dist/build-components/BIcon/BIconProps.generated.d.ts +1 -2
  3. package/dist/build-components/CountDown/CountDownProps.generated.d.ts +2 -1
  4. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -2
  5. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -2
  6. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -2
  7. package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -2
  8. package/dist/build-components/PaywallOptions/usePaywallOptionParamsFactory.d.ts +1 -1
  9. package/dist/build-components/PriceTag/PriceTag.d.ts +5 -0
  10. package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +63 -0
  11. package/dist/build-components/Pricing/Pricing.d.ts +5 -0
  12. package/dist/build-components/Pricing/PricingProps.generated.d.ts +59 -0
  13. package/dist/build-components/Promo/Promo.d.ts +5 -0
  14. package/dist/build-components/Promo/PromoProps.generated.d.ts +59 -0
  15. package/dist/build-components/Text/TextProps.generated.d.ts +1 -2
  16. package/dist/build-components/index.d.ts +4 -1
  17. package/dist/build-components/patterns.generated.d.ts +1405 -202
  18. package/dist/components/BuilderProvider.d.ts +5 -3
  19. package/dist/components/ParamsProvider.d.ts +16 -8
  20. package/dist/hooks/useSyncHtmlThemeClass.d.ts +1 -1
  21. package/dist/index.cjs.js +4 -4
  22. package/dist/index.cjs.js.map +1 -1
  23. package/dist/index.d.ts +14 -3
  24. package/dist/index.esm.js +4 -4
  25. package/dist/index.esm.js.map +1 -1
  26. package/dist/index.web.cjs.js +4 -4
  27. package/dist/index.web.cjs.js.map +1 -1
  28. package/dist/index.web.esm.js +4 -4
  29. package/dist/index.web.esm.js.map +1 -1
  30. package/dist/logger.d.ts +18 -0
  31. package/dist/modals/InspectModal.d.ts +5 -0
  32. package/dist/modals/index.d.ts +1 -1
  33. package/dist/pages/ProjectPage.d.ts +3 -3
  34. package/dist/paywall/hooks/useCalculateLocalizedPrice.d.ts +4 -2
  35. package/dist/paywall/hooks/useDiscountRate.d.ts +3 -2
  36. package/dist/paywall/types/paywall-types.d.ts +7 -32
  37. package/dist/product-base/buildPaywallLocalizationParams.d.ts +16 -0
  38. package/dist/product-base/calculations.d.ts +29 -0
  39. package/dist/product-base/extractAndroidParams.d.ts +24 -0
  40. package/dist/product-base/extractIOSParams.d.ts +24 -0
  41. package/dist/product-base/index.d.ts +27 -0
  42. package/dist/product-base/periodLocalizationKeys.d.ts +44 -0
  43. package/dist/product-base/types.d.ts +155 -0
  44. package/dist/product-base/usePaywallLocalizationParams.d.ts +29 -0
  45. package/dist/store.d.ts +7 -1
  46. package/dist/styles.css +1 -1
  47. package/dist/types/PreviewConfig.d.ts +10 -16
  48. package/dist/utils/extractTextStyle/extractTextStyle.d.ts +2 -2
  49. package/dist/utils/extractTextStyle/extractTextStyleNative.d.ts +2 -2
  50. package/dist/utils/replaceLocalizationParams.d.ts +1 -1
  51. package/package.json +2 -2
  52. package/scripts/migrate-samples-to-current.ts +3 -3
  53. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +28 -12
  54. package/src/DeviceMockFrame.tsx +15 -10
  55. package/src/assets/meta.json +1 -1
  56. package/src/assets/samples/carousel-sample.json +6 -5
  57. package/src/assets/samples/getSamples.ts +16 -49
  58. package/src/assets/samples/paywall-1.json +64 -22
  59. package/src/assets/samples/paywall-2.json +0 -15
  60. package/src/assets/samples/paywall-app-delete-offer.json +0 -15
  61. package/src/assets/samples/paywall-app-open-offer.json +0 -15
  62. package/src/assets/samples/paywall-back-offer.json +0 -15
  63. package/src/assets/samples/paywall-notification-offer.json +0 -15
  64. package/src/assets/samples/simple-1.json +1 -16
  65. package/src/assets/samples/simple-2.json +0 -15
  66. package/src/assets/samples/unmigrated-builder-1.1.1.json +0 -3
  67. package/src/assets/samples/unmigrated-builder1.json +0 -3
  68. package/src/assets/samples/unvalidated-builder1.json +0 -3
  69. package/src/assets/samples/unvalidated-crash1.json +0 -3
  70. package/src/assets/samples/unvalidated-crashcomponent1.json +0 -3
  71. package/src/assets/samples/vpn-onboard-1.json +1 -34
  72. package/src/assets/samples/vpn-onboard-2.json +1 -34
  73. package/src/assets/samples/vpn-onboard-3.json +1 -42
  74. package/src/assets/samples/vpn-onboard-4.json +0 -73
  75. package/src/assets/samples/vpn-onboard-5.json +0 -73
  76. package/src/assets/samples/vpn-onboard-6.json +0 -73
  77. package/src/assets/samples/vpn-onboard-7.json +529 -0
  78. package/src/attribute-analyser/style/native/useExtractImageStyle.ts +1 -4
  79. package/src/attribute-analyser/style/native/useExtractTextStyle.ts +3 -12
  80. package/src/attribute-analyser/style/native/useExtractViewStyle.ts +1 -4
  81. package/src/attribute-analyser/style/web/useExtractImageStyle.ts +1 -4
  82. package/src/attribute-analyser/style/web/useExtractTextStyle.ts +3 -12
  83. package/src/attribute-analyser/style/web/useExtractViewStyle.ts +1 -4
  84. package/src/attributes-editor/useAttributesEditorModel.ts +5 -52
  85. package/src/build-components/BIcon/BIconProps.generated.ts +1 -2
  86. package/src/build-components/CarouselDots/CarouselDots.tsx +6 -13
  87. package/src/build-components/CountDown/CountDownProps.generated.ts +2 -1
  88. package/src/build-components/NavigationBarColor/NavigationBarColor.tsx +2 -2
  89. package/src/build-components/OnboardButton/OnboardButton.tsx +1 -2
  90. package/src/build-components/OnboardDot/OnboardDot.tsx +6 -18
  91. package/src/build-components/OnboardFooter/OnboardFooter.tsx +5 -3
  92. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -2
  93. package/src/build-components/OnboardFooter/pattern.json +1 -1
  94. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -2
  95. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -2
  96. package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -2
  97. package/src/build-components/PaywallOptions/PaywallOptions.tsx +3 -3
  98. package/src/build-components/PaywallOptions/usePaywallOptionParamsFactory.ts +26 -13
  99. package/src/build-components/PaywallProvider/PaywallProvider.tsx +51 -12
  100. package/src/build-components/PriceTag/PriceTag.tsx +25 -0
  101. package/src/build-components/PriceTag/PriceTagProps.generated.ts +83 -0
  102. package/src/build-components/PriceTag/pattern.json +53 -0
  103. package/src/build-components/Pricing/Pricing.tsx +13 -0
  104. package/src/build-components/Pricing/PricingProps.generated.ts +76 -0
  105. package/src/build-components/Pricing/pattern.json +25 -0
  106. package/src/build-components/Promo/Promo.tsx +13 -0
  107. package/src/build-components/Promo/PromoProps.generated.ts +76 -0
  108. package/src/build-components/Promo/pattern.json +25 -0
  109. package/src/build-components/RadioButton/RadioButton.tsx +3 -5
  110. package/src/build-components/RenderNode.generated.tsx +15 -0
  111. package/src/build-components/StatusBarColor/StatusBarColor.tsx +2 -2
  112. package/src/build-components/Text/Text.tsx +12 -5
  113. package/src/build-components/Text/TextProps.generated.ts +1 -2
  114. package/src/build-components/Text/pattern.json +3 -2
  115. package/src/build-components/index.ts +15 -0
  116. package/src/build-components/patterns.generated.ts +1454 -181
  117. package/src/components/BottomBar.tsx +42 -39
  118. package/src/components/BuilderProvider.tsx +41 -14
  119. package/src/components/LocalizationParamsProvider.tsx +1 -1
  120. package/src/components/ParamsProvider.tsx +36 -11
  121. package/src/hooks/useLocalize.ts +7 -4
  122. package/src/hooks/useParams.ts +1 -1
  123. package/src/hooks/useSyncHtmlThemeClass.ts +2 -2
  124. package/src/index.ts +52 -8
  125. package/src/logger.ts +39 -0
  126. package/src/modals/InspectModal.tsx +331 -0
  127. package/src/modals/ProductPresetsModal.tsx +6 -13
  128. package/src/modals/index.ts +1 -1
  129. package/src/pages/DebugJsonPage.tsx +9 -22
  130. package/src/pages/ProjectDebug.tsx +1 -1
  131. package/src/pages/ProjectPage.tsx +29 -11
  132. package/src/pages/tabs/SideTool.tsx +28 -104
  133. package/src/paywall/hooks/useCalculateLocalizedPrice.ts +8 -3
  134. package/src/paywall/hooks/useDiscountRate.ts +11 -3
  135. package/src/paywall/types/paywall-types.ts +7 -38
  136. package/src/product-base/buildPaywallLocalizationParams.ts +100 -0
  137. package/src/product-base/calculations.ts +93 -0
  138. package/src/product-base/extractAndroidParams.ts +207 -0
  139. package/src/product-base/extractIOSParams.ts +199 -0
  140. package/src/product-base/index.ts +28 -0
  141. package/src/product-base/mockProducts.json +489 -0
  142. package/src/product-base/periodLocalizationKeys.ts +114 -0
  143. package/src/product-base/types.ts +183 -0
  144. package/src/product-base/usePaywallLocalizationParams.ts +61 -0
  145. package/src/store.ts +18 -1
  146. package/src/styles/index.scss +1 -0
  147. package/src/styles/modals/_inspect-modal.scss +155 -0
  148. package/src/types/PreviewConfig.ts +157 -16
  149. package/src/utils/extractTextStyle/extractTextStyle.ts +14 -6
  150. package/src/utils/extractTextStyle/extractTextStyleNative.ts +8 -6
  151. package/src/utils/logRenderStore.ts +6 -10
  152. package/src/utils/parseColor.ts +0 -1
  153. package/src/utils/replaceLocalizationParams.ts +8 -4
  154. package/dist/modals/ScreenColorsModal.d.ts +0 -8
  155. package/src/assets/products.json +0 -98
  156. package/src/modals/ScreenColorsModal.tsx +0 -121
@@ -1,7 +1,7 @@
1
1
  import type { NodeData } from '../../types/Node';
2
2
  import type { TextPropsGenerated } from '../../build-components/Text/TextProps.generated';
3
- import type { AppConfig } from '../../types/PreviewConfig';
4
- import { defaultAppConfig } from '../../types/PreviewConfig';
3
+ import type { Theme } from '../../types/PreviewConfig';
4
+ import { defaultTheme } from '../../types/PreviewConfig';
5
5
  import type { ProjectColors } from '../../types/Project';
6
6
  import type { Fonts } from '../../types/Fonts';
7
7
  import { fs, parseSize } from '../../size-matters';
@@ -15,7 +15,7 @@ import {
15
15
  import { getStyleBag, toAttributeRecord } from '../attributeStyle';
16
16
 
17
17
  export type ExtractTextStyleNativeOptions = {
18
- appConfig?: AppConfig;
18
+ theme?: Theme;
19
19
  projectColors?: ProjectColors;
20
20
  fonts?: Fonts;
21
21
  };
@@ -46,10 +46,12 @@ export function extractTextStyleNative<
46
46
  return styleBag?.[key];
47
47
  };
48
48
 
49
- const resolvedAppConfig = options.appConfig ?? defaultAppConfig;
50
- const { screenStyle, theme } = resolvedAppConfig;
49
+ const theme = options.theme ?? defaultTheme;
51
50
  const fallbackColor =
52
- theme === 'light' ? screenStyle.light.color : screenStyle.dark.color;
51
+ parseColor('THEME_COLORS.TEXT', {
52
+ projectColors: options.projectColors,
53
+ theme,
54
+ }) ?? 'THEME_COLORS.TEXT';
53
55
 
54
56
  const style: Record<string, unknown> = {};
55
57
  if (!attributes) {
@@ -84,7 +84,7 @@ export function logRenderStore(options: LogRenderStoreOptions = {}): void {
84
84
 
85
85
  if (isFn(groupCollapsed)) groupCollapsed(title);
86
86
  else {
87
- console.log(title);
87
+ console.info(title);
88
88
  }
89
89
 
90
90
  const persistedRaw = includeLocalStorage
@@ -105,21 +105,17 @@ export function logRenderStore(options: LogRenderStoreOptions = {}): void {
105
105
  // NOTE: Logging objects in devtools can be confusing because they are "live" references.
106
106
  // This JSON string is a stable snapshot of this click, and is copy/paste-friendly.
107
107
 
108
- console.log('json', json);
108
+ console.info('json', json);
109
109
 
110
- console.log('state', snapshot);
110
+ console.info('state', snapshot);
111
111
 
112
- console.log('actions', actions);
113
-
114
- console.log('rawState (includes functions)', state);
112
+ console.info('actions', actions);
115
113
 
116
114
  if (includeLocalStorage) {
117
- console.log('localStorage.render-store (raw)', persistedRaw);
118
-
119
- console.log('localStorage.render-store (parsed)', persistedParsed);
115
+ console.info('localStorage.render-store (raw)', persistedRaw);
120
116
  }
121
117
  if (extra) {
122
- console.log('extra', extra);
118
+ console.info('extra', extra);
123
119
  }
124
120
 
125
121
  if (isFn(groupEnd)) groupEnd();
@@ -19,7 +19,6 @@ export function parseColor(value?: string, options: ParseColorOptions = {}) {
19
19
  if (trimmed.startsWith(STATIC_PREFIX)) {
20
20
  const token = trimmed.slice(STATIC_PREFIX.length);
21
21
  const resolved = projectColors.STATIC_COLORS?.[token];
22
- console.log('resolved', value, resolved);
23
22
  return typeof resolved === 'string' && resolved.trim()
24
23
  ? resolved.trim()
25
24
  : trimmed;
@@ -1,15 +1,19 @@
1
1
  export function replaceLocalizationParams(
2
2
  text: string,
3
- params?: Record<string, string> | null,
3
+ params?: Record<string, string | undefined> | null
4
4
  ): string {
5
5
  if (!text) return text;
6
6
  if (!params) return text;
7
7
 
8
+ // Sort longest keys first to avoid prefix collisions
9
+ // (e.g. @trialPeriod matching inside @trialPeriodUnit)
10
+ const sorted = Object.entries(params).sort(([a], [b]) => b.length - a.length);
11
+
8
12
  return (
9
- Object.entries(params).reduce((acc, [key, val]) => {
13
+ sorted.reduce((acc, [key, val]) => {
14
+ if (val == null) return acc;
10
15
  const needle = `@${key}`;
11
- // Replace all occurrences without regex escaping pitfalls.
12
- return acc.split(needle).join(String(val));
16
+ return acc.split(needle).join(val);
13
17
  }, text) || text
14
18
  );
15
19
  }
@@ -1,8 +0,0 @@
1
- import type { AppConfig } from '../types/PreviewConfig';
2
- type ScreenColorsModalProps = {
3
- appConfig: AppConfig;
4
- onChange: (next: AppConfig) => void;
5
- onClose: () => void;
6
- };
7
- export declare function ScreenColorsModal({ appConfig, onChange, onClose, }: ScreenColorsModalProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,98 +0,0 @@
1
- {
2
- "Embeded Paywall": [
3
- {
4
- "productId": "com.app.premium.monthly",
5
- "title": "Premium Monthly",
6
- "description": "Unlock all premium features for a month.",
7
- "localizedPrice": "$4.99",
8
- "price": "4.99",
9
- "currency": "USD"
10
- },
11
- {
12
- "productId": "com.app.pro.yearly",
13
- "title": "Pro Yearly",
14
- "description": "Best value: full access for a year.",
15
- "localizedPrice": "€39.99",
16
- "price": "39.99",
17
- "currency": "EUR"
18
- },
19
- {
20
- "productId": "com.app.plus.weekly",
21
- "title": "Plus Weekly",
22
- "description": "Try Plus with a flexible weekly plan.",
23
- "localizedPrice": "£1.99",
24
- "price": "1.99",
25
- "currency": "GBP"
26
- }
27
- ],
28
- "type-1": [
29
- {
30
- "productId": "com.app.premium.monthly",
31
- "title": "Premium Monthly",
32
- "description": "Unlock all premium features for a month.",
33
- "localizedPrice": "$4.99",
34
- "price": "4.99",
35
- "currency": "USD"
36
- },
37
- {
38
- "productId": "com.app.pro.yearly",
39
- "title": "Pro Yearly",
40
- "description": "Best value: full access for a year.",
41
- "localizedPrice": "€39.99",
42
- "price": "39.99",
43
- "currency": "EUR"
44
- },
45
- {
46
- "productId": "com.app.plus.weekly",
47
- "title": "Plus Weekly",
48
- "description": "Try Plus with a flexible weekly plan.",
49
- "localizedPrice": "£1.99",
50
- "price": "1.99",
51
- "currency": "GBP"
52
- }
53
- ],
54
- "type-2": [
55
- {
56
- "productId": "com.app.starter.monthly",
57
- "title": "Starter Monthly",
58
- "description": "Basic access to get started.",
59
- "localizedPrice": "$2.99",
60
- "price": "2.99",
61
- "currency": "USD"
62
- },
63
- {
64
- "productId": "com.app.gold.monthly",
65
- "title": "Gold Monthly",
66
- "description": "Gold tier with extra perks.",
67
- "localizedPrice": "₺149.99",
68
- "price": "149.99",
69
- "currency": "TRY"
70
- },
71
- {
72
- "productId": "com.app.premium.yearly",
73
- "title": "Premium Yearly",
74
- "description": "Unlock premium for a year.",
75
- "localizedPrice": "$49.99",
76
- "price": "49.99",
77
- "currency": "USD"
78
- },
79
- {
80
- "productId": "com.app.pro.lifetime",
81
- "title": "Pro Lifetime",
82
- "description": "One-time purchase for lifetime access.",
83
- "localizedPrice": "€99.99",
84
- "price": "99.99",
85
- "currency": "EUR"
86
- }
87
- ],
88
- "type-3": [
89
- {
90
- "productId": "com.app.plus.yearly",
91
- "title": "Plus Yearly",
92
- "description": "Yearly plan with a big discount.",
93
- "localizedPrice": "$24.99",
94
- "price": "24.99",
95
- "currency": "USD"
96
- }
97
- ]
98
- }
@@ -1,121 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import type { AppConfig } from '../types/PreviewConfig';
3
- import { defaultAppConfig } from '../types/PreviewConfig';
4
- import Modal from './Modal';
5
-
6
- type ScreenMode = 'light' | 'dark';
7
- type ScreenColorKey = keyof AppConfig['screenStyle']['light'];
8
-
9
- type ScreenColorsModalProps = {
10
- appConfig: AppConfig;
11
- onChange: (next: AppConfig) => void;
12
- onClose: () => void;
13
- };
14
-
15
- type ColorField = {
16
- id: string;
17
- label: string;
18
- mode: ScreenMode;
19
- key: ScreenColorKey;
20
- };
21
-
22
- const colorFields: ColorField[] = [
23
- {
24
- id: 'light-bg',
25
- label: 'Light Background',
26
- mode: 'light',
27
- key: 'backgroundColor',
28
- },
29
- {
30
- id: 'light-color',
31
- label: 'Light Text',
32
- mode: 'light',
33
- key: 'color',
34
- },
35
- {
36
- id: 'dark-bg',
37
- label: 'Dark Background',
38
- mode: 'dark',
39
- key: 'backgroundColor',
40
- },
41
- {
42
- id: 'dark-color',
43
- label: 'Dark Text',
44
- mode: 'dark',
45
- key: 'color',
46
- },
47
- ];
48
-
49
- export function ScreenColorsModal({
50
- appConfig,
51
- onChange,
52
- onClose,
53
- }: ScreenColorsModalProps) {
54
- const defaults = defaultAppConfig.screenStyle;
55
-
56
- const getValue = (mode: ScreenMode, key: ScreenColorKey) =>
57
- appConfig.screenStyle?.[mode]?.[key] ?? defaults[mode][key];
58
-
59
- const handleChange = (mode: ScreenMode, key: ScreenColorKey, value: string) =>
60
- onChange({
61
- ...appConfig,
62
- screenStyle: {
63
- ...defaults,
64
- ...appConfig.screenStyle,
65
- [mode]: {
66
- ...defaults[mode],
67
- ...appConfig.screenStyle?.[mode],
68
- [key]: value,
69
- },
70
- },
71
- });
72
-
73
- const headerDescription = useMemo(
74
- () =>
75
- 'Edit light/dark screen background & text colors used in the preview.',
76
- [],
77
- );
78
-
79
- return (
80
- <Modal
81
- onClose={onClose}
82
- ariaLabelledBy="screen-colors-title"
83
- contentClassName="localication-modal__content"
84
- >
85
- <div className="modal__header localication-modal__header">
86
- <div className="localication-modal__header-main">
87
- <h3 id="screen-colors-title" className="modal__title">
88
- Screen Colors
89
- </h3>
90
- <p className="localication-modal__description">{headerDescription}</p>
91
- </div>
92
- <button type="button" className="editor-button" onClick={onClose}>
93
- Close
94
- </button>
95
- </div>
96
-
97
- <div className="localication-modal__body">
98
- <div
99
- style={{
100
- display: 'grid',
101
- gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
102
- gap: 12,
103
- }}
104
- >
105
- {colorFields.map(({ id, label, mode, key }) => (
106
- <React.Fragment key={id}>
107
- <div style={{ alignSelf: 'center' }}>{label}</div>
108
- <input
109
- id={id}
110
- type="color"
111
- className="input input--color"
112
- value={String(getValue(mode, key))}
113
- onChange={(e) => handleChange(mode, key, e.target.value)}
114
- />
115
- </React.Fragment>
116
- ))}
117
- </div>
118
- </div>
119
- </Modal>
120
- );
121
- }