@developer_tribe/react-builder 1.2.22 → 1.2.24

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 (106) hide show
  1. package/dist/attribute-analyser/style/native/useExtractImageStyle.d.ts +6 -6
  2. package/dist/attribute-analyser/style/native/useExtractTextStyle.d.ts +6 -4
  3. package/dist/attribute-analyser/style/native/useExtractViewStyle.d.ts +5 -3
  4. package/dist/build-components/Image/ImageProps.generated.d.ts +2 -4
  5. package/dist/build-components/NavigationBarColor/NavigationBarColor.d.ts +5 -0
  6. package/dist/build-components/NavigationBarColor/NavigationBarColorProps.generated.d.ts +54 -0
  7. package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +1 -3
  8. package/dist/build-components/Separator/Separator.d.ts +5 -0
  9. package/dist/build-components/Separator/SeparatorProps.generated.d.ts +21 -0
  10. package/dist/build-components/StatusBarColor/StatusBarColor.d.ts +5 -0
  11. package/dist/build-components/StatusBarColor/StatusBarColorProps.generated.d.ts +54 -0
  12. package/dist/build-components/index.d.ts +4 -1
  13. package/dist/build-components/patterns.generated.d.ts +2111 -1251
  14. package/dist/components/AttributesEditorPanel.d.ts +1 -1
  15. package/dist/components/BuilderProvider.d.ts +1 -1
  16. package/dist/index.cjs.js +4 -4
  17. package/dist/index.cjs.js.map +1 -1
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.esm.js +4 -4
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/index.web.cjs.js +6 -6
  22. package/dist/index.web.cjs.js.map +1 -1
  23. package/dist/index.web.esm.js +4 -4
  24. package/dist/index.web.esm.js.map +1 -1
  25. package/dist/store.d.ts +4 -0
  26. package/dist/styles.css +1 -1
  27. package/dist/utils/attributeStyle.d.ts +21 -0
  28. package/dist/utils/extractImageStyle.d.ts +1 -1
  29. package/dist/utils/extractViewStyle/extractViewStyleNative.d.ts +1 -1
  30. package/package.json +7 -2
  31. package/src/DeviceMockFrame.tsx +8 -2
  32. package/src/assets/meta.json +1 -1
  33. package/src/assets/samples/paywall-1.json +44 -39
  34. package/src/assets/samples/paywall-2.json +44 -25
  35. package/src/assets/samples/paywall-app-delete-offer.json +40 -21
  36. package/src/assets/samples/paywall-app-open-offer.json +40 -21
  37. package/src/assets/samples/paywall-back-offer.json +40 -21
  38. package/src/assets/samples/paywall-notification-offer.json +40 -21
  39. package/src/assets/samples/vpn-onboard-1.json +84 -39
  40. package/src/assets/samples/vpn-onboard-2.json +85 -40
  41. package/src/assets/samples/vpn-onboard-3.json +84 -39
  42. package/src/assets/samples/vpn-onboard-4.json +84 -39
  43. package/src/assets/samples/vpn-onboard-5.json +102 -55
  44. package/src/assets/samples/vpn-onboard-6.json +87 -38
  45. package/src/attribute-analyser/style/native/useExtractImageStyle.ts +31 -25
  46. package/src/attribute-analyser/style/native/useExtractTextStyle.ts +26 -11
  47. package/src/attribute-analyser/style/native/useExtractViewStyle.ts +21 -11
  48. package/src/attributes-editor/useAttributesEditorModel.ts +23 -17
  49. package/src/build-components/BackgroundImage/pattern.json +9 -7
  50. package/src/build-components/CarouselDots/CarouselDots.tsx +12 -11
  51. package/src/build-components/CarouselProvider/CarouselProvider.tsx +3 -1
  52. package/src/build-components/Image/ImageProps.generated.ts +2 -4
  53. package/src/build-components/Image/pattern.json +15 -25
  54. package/src/build-components/NavigationBarColor/NavigationBarColor.tsx +39 -0
  55. package/src/build-components/NavigationBarColor/NavigationBarColorProps.generated.ts +71 -0
  56. package/src/build-components/NavigationBarColor/pattern.json +34 -0
  57. package/src/build-components/OnboardButton/OnboardButton.tsx +19 -5
  58. package/src/build-components/OnboardButtons/OnboardButtons.tsx +8 -10
  59. package/src/build-components/OnboardDot/OnboardDot.tsx +12 -10
  60. package/src/build-components/OnboardFooter/OnboardFooter.tsx +15 -4
  61. package/src/build-components/OnboardImage/OnboardImage.tsx +1 -1
  62. package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +1 -3
  63. package/src/build-components/OnboardProvider/OnboardProvider.tsx +3 -1
  64. package/src/build-components/RenderNode.generated.tsx +15 -0
  65. package/src/build-components/Separator/Separator.tsx +41 -0
  66. package/src/build-components/Separator/SeparatorProps.generated.ts +26 -0
  67. package/src/build-components/Separator/pattern.json +59 -0
  68. package/src/build-components/StatusBarColor/StatusBarColor.tsx +39 -0
  69. package/src/build-components/StatusBarColor/StatusBarColorProps.generated.ts +71 -0
  70. package/src/build-components/StatusBarColor/pattern.json +34 -0
  71. package/src/build-components/Text/pattern.json +45 -38
  72. package/src/build-components/index.ts +15 -0
  73. package/src/build-components/patterns.generated.ts +2153 -1272
  74. package/src/build-components/useNode.ts +24 -25
  75. package/src/components/AttributesEditorPanel.tsx +4 -5
  76. package/src/components/Builder.tsx +1 -2
  77. package/src/components/BuilderProvider.tsx +43 -6
  78. package/src/components/JsonTextEditor.tsx +2 -2
  79. package/src/components/LoadingComponent.tsx +1 -1
  80. package/src/components/RenderErrorBoundary.tsx +1 -3
  81. package/src/index.ts +3 -0
  82. package/src/migrations/migrations/1.1.2_extract_component_attributes_from_style.ts +3 -3
  83. package/src/modals/BenefitPresetsModal.tsx +1 -1
  84. package/src/modals/ProductPresetsModal.tsx +1 -1
  85. package/src/pages/DebugJsonPage.tsx +7 -4
  86. package/src/pages/ProjectDebug.tsx +1 -1
  87. package/src/pages/ProjectPage.tsx +31 -32
  88. package/src/pages/ProjectValidationPage.tsx +2 -2
  89. package/src/store.ts +13 -0
  90. package/src/styles/layout/_builder.scss +6 -0
  91. package/src/utils/__special_exceptions.ts +5 -5
  92. package/src/utils/analyseNode.ts +2 -2
  93. package/src/utils/analyseNodeByPatterns.ts +10 -9
  94. package/src/utils/analyseNodeStructural.ts +1 -1
  95. package/src/utils/attributeStyle.ts +104 -0
  96. package/src/utils/extractImageStyle.ts +17 -13
  97. package/src/utils/extractTextStyle/extractTextStyle.ts +7 -7
  98. package/src/utils/extractTextStyle/extractTextStyleNative.ts +10 -10
  99. package/src/utils/extractViewStyle/extractViewStyle.ts +8 -11
  100. package/src/utils/extractViewStyle/extractViewStyleNative.ts +19 -19
  101. package/src/utils/loadFontFamily.ts +14 -19
  102. package/src/utils/logRenderStore.ts +5 -4
  103. package/src/utils/nodeTree.ts +1 -1
  104. package/src/utils/patterns.ts +26 -31
  105. package/src/utils/repairNodeKeys.ts +5 -7
  106. package/src/utils/wrapNodeInMain.ts +3 -3
@@ -61,7 +61,7 @@ type Pattern = {
61
61
  meta?: PatternMeta;
62
62
  };
63
63
 
64
- const patterns: Pattern[] = generatedPatterns as unknown as Pattern[];
64
+ const patterns = generatedPatterns as unknown as Pattern[];
65
65
 
66
66
  export type BuilderPlatform = 'web' | 'native';
67
67
 
@@ -86,16 +86,22 @@ export const NON_STYLE_ATTRIBUTE_KEYS = new Set<string>([
86
86
  * known non-style props (behavior flags).
87
87
  */
88
88
  export function getStyleAttributeKeySet(): Set<string> {
89
- const viewSchema = getAttributeSchema('View') ?? {};
90
- const textSchema = getAttributeSchema('Text') ?? {};
91
- const viewStyle =
92
- typeof (viewSchema as any)?.style === 'object' && (viewSchema as any)?.style
93
- ? Object.keys((viewSchema as any).style)
94
- : Object.keys(viewSchema);
95
- const textStyle =
96
- typeof (textSchema as any)?.style === 'object' && (textSchema as any)?.style
97
- ? Object.keys((textSchema as any).style)
98
- : Object.keys(textSchema);
89
+ const viewSchema = (getAttributeSchema('View') ?? {}) as Record<
90
+ string,
91
+ unknown
92
+ >;
93
+ const textSchema = (getAttributeSchema('Text') ?? {}) as Record<
94
+ string,
95
+ unknown
96
+ >;
97
+ const getNestedStyleKeys = (schema: Record<string, unknown>): string[] => {
98
+ const nested = schema.style;
99
+ return typeof nested === 'object' && nested
100
+ ? Object.keys(nested)
101
+ : Object.keys(schema);
102
+ };
103
+ const viewStyle = getNestedStyleKeys(viewSchema);
104
+ const textStyle = getNestedStyleKeys(textSchema);
99
105
  const out = new Set<string>([...viewStyle, ...textStyle]);
100
106
  for (const k of NON_STYLE_ATTRIBUTE_KEYS) out.delete(k);
101
107
  return out;
@@ -209,23 +215,18 @@ export function getAttributeMeta(
209
215
  const attributes = p?.meta?.attributes;
210
216
 
211
217
  // Some patterns store style meta under `meta.attributes.styles` (nested) instead of `meta.styles`.
218
+ const attrsRecord = attributes as Record<string, unknown> | undefined;
212
219
  const nestedStyles =
213
- attributes &&
214
- typeof attributes === 'object' &&
215
- (attributes as any).styles &&
216
- typeof (attributes as any).styles === 'object'
217
- ? ((attributes as any).styles as Record<string, AttributeMeta>)
220
+ attrsRecord && typeof attrsRecord.styles === 'object' && attrsRecord.styles
221
+ ? (attrsRecord.styles as Record<string, AttributeMeta>)
218
222
  : undefined;
219
223
 
220
224
  // When `meta.attributes.styles` exists, treat `meta.attributes` (minus `styles`) as non-style meta.
221
- const attributesWithoutNestedStyles =
222
- attributes && typeof attributes === 'object'
223
- ? Object.fromEntries(
224
- Object.entries(attributes as Record<string, unknown>).filter(
225
- ([k]) => k !== 'styles',
226
- ),
227
- )
228
- : attributes;
225
+ const attributesWithoutNestedStyles = attrsRecord
226
+ ? Object.fromEntries(
227
+ Object.entries(attrsRecord).filter(([k]) => k !== 'styles'),
228
+ )
229
+ : attributes;
229
230
 
230
231
  // schemaVersion=2 prefers `meta.styles` but some repos split UI meta into:
231
232
  // - meta.styles: style-tab fields
@@ -261,13 +262,7 @@ export function getTypeSchema(
261
262
  ): Record<string, string | string[]> | undefined {
262
263
  if (!componentType || !typeName) return undefined;
263
264
  const p = getPatternByType(componentType);
264
- // Some JSON imports may not type-check "types" so we fallback to any access
265
- const types: Record<string, Record<string, string | string[]>> | undefined = (
266
- p as unknown as {
267
- types?: Record<string, Record<string, string | string[]>>;
268
- }
269
- )?.types;
270
- return types?.[typeName];
265
+ return p?.types?.[typeName];
271
266
  }
272
267
 
273
268
  /** Utility: returns true if the type name refers to a primitive scalar */
@@ -2,13 +2,11 @@ import type { Node, NodeData } from '../types/Node';
2
2
  import { generateRandomKeyForNode } from './generateRandomKeyForNode';
3
3
 
4
4
  function isNodeDataLike(value: unknown): value is NodeData {
5
- return (
6
- typeof value === 'object' &&
7
- value !== null &&
8
- !Array.isArray(value) &&
9
- 'type' in (value as any) &&
10
- 'children' in (value as any)
11
- );
5
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
6
+ return false;
7
+ }
8
+ const record = value as Record<string, unknown>;
9
+ return 'type' in record && 'children' in record;
12
10
  }
13
11
 
14
12
  function normalizeKey(value: unknown): string | undefined {
@@ -39,10 +39,10 @@ function stripNestedIsMain(node: Node, isRoot: boolean): Node {
39
39
  if (!shouldDemote && nextChildren === prevChildren) return node;
40
40
 
41
41
  return {
42
- ...(node as any),
42
+ ...node,
43
43
  ...(shouldDemote ? { isMain: false } : null),
44
44
  children: nextChildren,
45
- } as NodeData;
45
+ };
46
46
  }
47
47
 
48
48
  export function wrapNodeInMain(node: Node): NodeData {
@@ -50,7 +50,7 @@ export function wrapNodeInMain(node: Node): NodeData {
50
50
  // Ensure no nested nodes keep `isMain: true`.
51
51
  const cleaned = stripNestedIsMain(node, true) as NodeData;
52
52
  // Keep root as main.
53
- if (cleaned.isMain !== true) return { ...(cleaned as any), isMain: true };
53
+ if (cleaned.isMain !== true) return { ...cleaned, isMain: true };
54
54
  return cleaned;
55
55
  }
56
56