@developer_tribe/react-builder 1.2.31 → 1.2.32

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 (129) hide show
  1. package/dist/build-components/BIcon/BIconProps.generated.d.ts +1 -1
  2. package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +1 -1
  3. package/dist/build-components/Button/ButtonProps.generated.d.ts +1 -1
  4. package/dist/build-components/Carousel/CarouselProps.generated.d.ts +1 -1
  5. package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +1 -1
  6. package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +1 -1
  7. package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +1 -1
  8. package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +1 -1
  9. package/dist/build-components/CountDown/CountDownProps.generated.d.ts +1 -1
  10. package/dist/build-components/Image/ImageProps.generated.d.ts +1 -1
  11. package/dist/build-components/Main/MainProps.generated.d.ts +1 -1
  12. package/dist/build-components/NavigationBarColor/NavigationBarColorProps.generated.d.ts +1 -1
  13. package/dist/build-components/Onboard/OnboardProps.generated.d.ts +1 -1
  14. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +2 -2
  15. package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +1 -1
  16. package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +1 -1
  17. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -1
  18. package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +1 -1
  19. package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +1 -1
  20. package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +1 -1
  21. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -1
  22. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -1
  23. package/dist/build-components/PaywallBackground/PaywallBackgroundProps.generated.d.ts +1 -1
  24. package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -1
  25. package/dist/build-components/PaywallOptions/PaywallOptionsProps.generated.d.ts +1 -1
  26. package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +1 -1
  27. package/dist/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.d.ts +1 -1
  28. package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +1 -1
  29. package/dist/build-components/Pricing/PricingProps.generated.d.ts +1 -1
  30. package/dist/build-components/Promo/PromoProps.generated.d.ts +1 -1
  31. package/dist/build-components/RadioButton/RadioButtonProps.generated.d.ts +1 -1
  32. package/dist/build-components/Separator/SeparatorProps.generated.d.ts +1 -1
  33. package/dist/build-components/StatusBarColor/StatusBarColorProps.generated.d.ts +1 -1
  34. package/dist/build-components/Text/TextProps.generated.d.ts +1 -1
  35. package/dist/build-components/View/ViewProps.generated.d.ts +1 -1
  36. package/dist/build-components/patterns.generated.d.ts +62 -52
  37. package/dist/index.cjs.js +1 -1
  38. package/dist/index.cjs.js.map +1 -1
  39. package/dist/index.esm.js +1 -1
  40. package/dist/index.esm.js.map +1 -1
  41. package/dist/index.web.cjs.js +3 -3
  42. package/dist/index.web.cjs.js.map +1 -1
  43. package/dist/index.web.esm.js +3 -3
  44. package/dist/index.web.esm.js.map +1 -1
  45. package/dist/utils/attributeStyle.d.ts +2 -2
  46. package/dist/utils/patterns.d.ts +2 -2
  47. package/package.json +1 -1
  48. package/scripts/prebuild/utils/createGeneratedProps.js +9 -9
  49. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +9 -9
  50. package/src/RenderPage.tsx +42 -1
  51. package/src/assets/meta.json +1 -1
  52. package/src/assets/samples/vpn-onboard-1.json +0 -24
  53. package/src/build-components/BIcon/BIconProps.generated.ts +1 -1
  54. package/src/build-components/BIcon/pattern.json +4 -2
  55. package/src/build-components/BackgroundImage/BackgroundImage.tsx +1 -1
  56. package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +1 -1
  57. package/src/build-components/BackgroundImage/pattern.json +11 -3
  58. package/src/build-components/Button/Button.tsx +2 -2
  59. package/src/build-components/Button/ButtonProps.generated.ts +1 -1
  60. package/src/build-components/Button/pattern.json +5 -3
  61. package/src/build-components/Carousel/CarouselProps.generated.ts +1 -1
  62. package/src/build-components/Carousel/pattern.json +9 -3
  63. package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +1 -1
  64. package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +1 -1
  65. package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +1 -1
  66. package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +1 -1
  67. package/src/build-components/CarouselProvider/pattern.json +5 -2
  68. package/src/build-components/CountDown/CountDownProps.generated.ts +1 -1
  69. package/src/build-components/CountDown/pattern.json +4 -2
  70. package/src/build-components/Image/ImageProps.generated.ts +1 -1
  71. package/src/build-components/Image/pattern.json +11 -4
  72. package/src/build-components/Main/MainProps.generated.ts +1 -1
  73. package/src/build-components/Main/pattern.json +4 -2
  74. package/src/build-components/NavigationBarColor/NavigationBarColorProps.generated.ts +1 -1
  75. package/src/build-components/NavigationBarColor/pattern.json +5 -3
  76. package/src/build-components/Onboard/OnboardProps.generated.ts +1 -1
  77. package/src/build-components/Onboard/pattern.json +7 -3
  78. package/src/build-components/OnboardButton/OnboardButton.tsx +2 -23
  79. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +2 -2
  80. package/src/build-components/OnboardButton/pattern.json +44 -30
  81. package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +1 -1
  82. package/src/build-components/OnboardButtons/pattern.json +16 -5
  83. package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +1 -1
  84. package/src/build-components/OnboardDot/pattern.json +4 -2
  85. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -1
  86. package/src/build-components/OnboardFooter/pattern.json +4 -2
  87. package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +1 -1
  88. package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +1 -1
  89. package/src/build-components/OnboardItem/pattern.json +12 -4
  90. package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +1 -1
  91. package/src/build-components/OnboardProvider/pattern.json +9 -3
  92. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -1
  93. package/src/build-components/OnboardSubtitle/pattern.json +5 -2
  94. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -1
  95. package/src/build-components/OnboardTitle/pattern.json +5 -2
  96. package/src/build-components/PaywallBackground/PaywallBackgroundProps.generated.ts +1 -1
  97. package/src/build-components/PaywallBackground/pattern.json +4 -2
  98. package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +1 -1
  99. package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -1
  100. package/src/build-components/PaywallCloseButton/pattern.json +4 -2
  101. package/src/build-components/PaywallOptions/PaywallOptionsProps.generated.ts +1 -1
  102. package/src/build-components/PaywallOptions/pattern.json +4 -2
  103. package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +1 -1
  104. package/src/build-components/PaywallProvider/pattern.json +4 -2
  105. package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.ts +1 -1
  106. package/src/build-components/PaywallSubscribeButton/pattern.json +4 -2
  107. package/src/build-components/PriceTag/PriceTagProps.generated.ts +1 -1
  108. package/src/build-components/PriceTag/pattern.json +10 -4
  109. package/src/build-components/Pricing/PricingProps.generated.ts +1 -1
  110. package/src/build-components/Pricing/pattern.json +4 -2
  111. package/src/build-components/Promo/PromoProps.generated.ts +1 -1
  112. package/src/build-components/Promo/pattern.json +4 -2
  113. package/src/build-components/RadioButton/RadioButtonProps.generated.ts +1 -1
  114. package/src/build-components/Separator/SeparatorProps.generated.ts +1 -1
  115. package/src/build-components/Separator/pattern.json +5 -3
  116. package/src/build-components/StatusBarColor/StatusBarColorProps.generated.ts +1 -1
  117. package/src/build-components/StatusBarColor/pattern.json +5 -3
  118. package/src/build-components/Text/Text.tsx +1 -1
  119. package/src/build-components/Text/TextProps.generated.ts +1 -1
  120. package/src/build-components/Text/pattern.json +5 -3
  121. package/src/build-components/View/ViewProps.generated.ts +1 -1
  122. package/src/build-components/View/pattern.json +18 -6
  123. package/src/build-components/patterns.generated.ts +62 -52
  124. package/src/build-components/useNode.ts +2 -16
  125. package/src/migrations/migrations/1.1.2_extract_component_attributes_from_style.ts +31 -10
  126. package/src/utils/analyseNodeByPatterns.ts +2 -2
  127. package/src/utils/attributeStyle.ts +9 -3
  128. package/src/utils/extractImageStyle.ts +4 -4
  129. package/src/utils/patterns.ts +3 -3
@@ -2,7 +2,6 @@ import { NodeData, NodeDefaultAttribute } from '../types/Node';
2
2
  import { getDefaultsForType } from '../utils/patterns';
3
3
 
4
4
  type WithStyleBags = {
5
- style?: Record<string, unknown>;
6
5
  styles?: Record<string, unknown>;
7
6
  };
8
7
 
@@ -15,29 +14,16 @@ export default function useNode<
15
14
  const nodeAttributes = ((node.attributes as T) ?? ({} as T)) as T &
16
15
  WithStyleBags;
17
16
  const defaultAttributes = defaults as T & WithStyleBags;
18
- // Merge styles from both defaults and node (schemaVersion=2 uses `styles` only).
19
- // Read legacy `style` for back-compat with old persisted data, but output only `styles`.
20
- const defaultStyle = {
21
- ...(defaultAttributes?.style ?? {}),
17
+ // Deep-merge styles so default style values aren't lost when the node provides partial overrides.
18
+ const mergedStyle = {
22
19
  ...(defaultAttributes?.styles ?? {}),
23
- };
24
- const nodeStyle = {
25
- ...(nodeAttributes?.style ?? {}),
26
20
  ...(nodeAttributes?.styles ?? {}),
27
21
  };
28
- const mergedStyle = {
29
- ...defaultStyle,
30
- ...nodeStyle,
31
- };
32
22
  const mergedRecord: Record<string, unknown> = {
33
23
  ...(defaultAttributes as Record<string, unknown>),
34
24
  ...(nodeAttributes as Record<string, unknown>),
35
- // Deep merge styles so default style values aren't lost when the node provides partial overrides.
36
- // Only use `styles` (schemaVersion=2). Remove legacy `style` to avoid validator rejection.
37
25
  styles: mergedStyle,
38
26
  };
39
- // Remove legacy `style` key if it was inherited from defaults or node attributes.
40
- delete mergedRecord.style;
41
27
  if (
42
28
  typeof mergedRecord.styles === 'object' &&
43
29
  mergedRecord.styles != null &&
@@ -50,11 +50,16 @@ function normalizeStyleAttributes(node: Node, styleKeys: Set<string>): Node {
50
50
  }
51
51
 
52
52
  const nextAttrs: Record<string, unknown> = { ...(record.attributes ?? {}) };
53
- const prevStyle = isPlainObject(nextAttrs.style) ? nextAttrs.style : {};
54
- const nextStyle: Record<string, unknown> = { ...prevStyle };
53
+ // Read from both legacy `style` and `styles` for backwards compatibility.
54
+ const prevStyleLegacy = isPlainObject(nextAttrs.style) ? nextAttrs.style : {};
55
+ const prevStyles = isPlainObject(nextAttrs.styles) ? nextAttrs.styles : {};
56
+ const nextStyle: Record<string, unknown> = {
57
+ ...prevStyleLegacy,
58
+ ...prevStyles,
59
+ };
55
60
 
56
61
  for (const [k, v] of Object.entries(nextAttrs)) {
57
- if (k === 'style') continue;
62
+ if (k === 'style' || k === 'styles') continue;
58
63
  if (!styleKeys.has(k)) continue;
59
64
 
60
65
  // If already set in style, prefer style (drop legacy flat key).
@@ -62,8 +67,10 @@ function normalizeStyleAttributes(node: Node, styleKeys: Set<string>): Node {
62
67
  delete nextAttrs[k];
63
68
  }
64
69
 
70
+ // Always output as `styles` (schemaVersion=2). Remove legacy `style`.
71
+ delete nextAttrs.style;
65
72
  if (Object.keys(nextStyle).length > 0) {
66
- nextAttrs.style = nextStyle;
73
+ nextAttrs.styles = nextStyle;
67
74
  }
68
75
 
69
76
  return {
@@ -77,16 +84,16 @@ function getStyleSubSchemaKeys(
77
84
  schema: Record<string, unknown> | undefined,
78
85
  ): Set<string> {
79
86
  if (!schema) return new Set();
80
- const style = schema.style;
81
- if (!isPlainObject(style)) return new Set();
82
- return new Set(Object.keys(style));
87
+ const styles = schema.styles;
88
+ if (!isPlainObject(styles)) return new Set();
89
+ return new Set(Object.keys(styles));
83
90
  }
84
91
 
85
92
  function getTopLevelAttributeKeys(
86
93
  schema: Record<string, unknown> | undefined,
87
94
  ): Set<string> {
88
95
  if (!schema) return new Set();
89
- const keys = Object.keys(schema).filter((k) => k !== 'style');
96
+ const keys = Object.keys(schema).filter((k) => k !== 'styles');
90
97
  return new Set(keys);
91
98
  }
92
99
 
@@ -131,7 +138,18 @@ function extractAttributesFromStyle(
131
138
  }
132
139
 
133
140
  const nextAttrs: Record<string, unknown> = { ...(record.attributes ?? {}) };
134
- const style = nextAttrs.style;
141
+ // Read from both legacy `style` and canonical `styles`.
142
+ const legacyStyle = nextAttrs.style;
143
+ const canonicalStyles = nextAttrs.styles;
144
+ const style = isPlainObject(canonicalStyles)
145
+ ? canonicalStyles
146
+ : isPlainObject(legacyStyle)
147
+ ? legacyStyle
148
+ : undefined;
149
+
150
+ if (!style) {
151
+ return { ...record, children: nextChildren, attributes: nextAttrs };
152
+ }
135
153
 
136
154
  if (!isPlainObject(style)) {
137
155
  return { ...record, children: nextChildren, attributes: nextAttrs };
@@ -174,8 +192,11 @@ function extractAttributesFromStyle(
174
192
 
175
193
  if (Object.keys(nextStyle).length === 0) {
176
194
  delete nextAttrs.style;
195
+ delete nextAttrs.styles;
177
196
  } else {
178
- nextAttrs.style = nextStyle;
197
+ // Always output as `styles` (schemaVersion=2). Remove legacy `style`.
198
+ delete nextAttrs.style;
199
+ nextAttrs.styles = nextStyle;
179
200
  }
180
201
 
181
202
  return {
@@ -22,7 +22,7 @@ export type AnalyseResultWithPath = {
22
22
  };
23
23
 
24
24
  type AttributeTypeSpec = string | string[];
25
- // schema v2 supports nesting style specs under `attributes.style` (one level deep)
25
+ // schema v2 supports nesting style specs under `attributes.styles` (one level deep)
26
26
  type NestedAttributeSchema = Record<string, AttributeTypeSpec>;
27
27
  type AttributeSchema = Record<
28
28
  string,
@@ -60,7 +60,7 @@ function getStyleSubSchema(
60
60
  schema: AttributeSchema | undefined,
61
61
  ): AttributeSchema {
62
62
  if (!schema) return {};
63
- const maybe = schema.style;
63
+ const maybe = schema.styles;
64
64
  if (!maybe) return {};
65
65
  if (typeof maybe === 'string' || Array.isArray(maybe)) return {};
66
66
  return (maybe ?? {}) as AttributeSchema;
@@ -1,19 +1,25 @@
1
1
  /**
2
2
  * Shared utilities for attribute/style bag access.
3
- * schemaVersion=2 uses `attributes.styles`, legacy uses `attributes.style`.
3
+ * schemaVersion=2 uses `attributes.styles` exclusively.
4
4
  */
5
5
 
6
6
  import type { NodeDefaultAttribute } from '../types/Node';
7
7
 
8
- /** Returns styles or style bag from attributes (schemaVersion=2 uses styles, legacy uses style). */
8
+ /** Returns styles bag from attributes (schemaVersion=2 uses `styles` only). Throws if legacy `style` is found. */
9
9
  export function getStyleBag(
10
10
  attributes: NodeDefaultAttribute | undefined,
11
11
  ): Record<string, unknown> | undefined {
12
12
  const record = toAttributeRecord(attributes);
13
- const bag = record.styles ?? record.style;
13
+ if ('style' in record && record.style != null) {
14
+ throw new Error(
15
+ '[getStyleBag] Legacy "style" key detected in attributes. Use "styles" instead (schemaVersion=2).',
16
+ );
17
+ }
18
+ const bag = record.styles;
14
19
  return isPlainObject(bag) ? (bag as Record<string, unknown>) : undefined;
15
20
  }
16
21
 
22
+ //TODO: sil
17
23
  /** Safe indexed access to attributes. Use for reading style/direct props. */
18
24
  export function toAttributeRecord(
19
25
  attributes: unknown,
@@ -19,9 +19,9 @@ export function extractImageStyle<T extends ImagePropsGenerated['attributes']>(
19
19
 
20
20
  if (!attributes) return style;
21
21
 
22
- // Map resizeMode to CSS object-fit (schemaVersion=2 uses `styles`, fallback to legacy `style`)
22
+ // Map resizeMode to CSS object-fit (schemaVersion=2 uses `styles`)
23
23
  const stylesBag = getStyleBag(attributes) as
24
- | ImagePropsGenerated['attributes']['style']
24
+ | ImagePropsGenerated['attributes']['styles']
25
25
  | undefined;
26
26
  const resizeMode: ResizeModeOptionType | undefined =
27
27
  stylesBag?.resizeMode ?? (attributes as any).resizeMode;
@@ -40,9 +40,9 @@ export function extractImageStyleNative<
40
40
  const attributes = node.attributes;
41
41
  if (!attributes) return {};
42
42
 
43
- // schemaVersion=2 uses `styles`, fallback to legacy `style`
43
+ // schemaVersion=2 uses `styles`
44
44
  const nativeStylesBag = getStyleBag(attributes) as
45
- | ImagePropsGenerated['attributes']['style']
45
+ | ImagePropsGenerated['attributes']['styles']
46
46
  | undefined;
47
47
  const resizeMode: ResizeModeOptionType | undefined =
48
48
  nativeStylesBag?.resizeMode ?? (attributes as any).resizeMode;
@@ -73,7 +73,7 @@ function normalizePlatform(platform?: BuilderPlatform | null): BuilderPlatform {
73
73
 
74
74
  /**
75
75
  * Keys that conceptually behave like component props (behavior/flags) rather than
76
- * style properties. These should NOT be normalized into `attributes.style`.
76
+ * style properties. These should NOT be normalized into `attributes.styles`.
77
77
  */
78
78
  export const NON_STYLE_ATTRIBUTE_KEYS = new Set<string>([
79
79
  'scrollable',
@@ -82,7 +82,7 @@ export const NON_STYLE_ATTRIBUTE_KEYS = new Set<string>([
82
82
  ]);
83
83
 
84
84
  /**
85
- * schemaVersion=2 stores style-like keys inside `attributes.style`.
85
+ * schemaVersion=2 stores style-like keys inside `attributes.styles`.
86
86
  *
87
87
  * We treat View+Text schema keys as style-like by default, but explicitly exclude
88
88
  * known non-style props (behavior flags).
@@ -97,7 +97,7 @@ export function getStyleAttributeKeySet(): Set<string> {
97
97
  unknown
98
98
  >;
99
99
  const getNestedStyleKeys = (schema: Record<string, unknown>): string[] => {
100
- const nested = schema.style;
100
+ const nested = schema.styles;
101
101
  return typeof nested === 'object' && nested
102
102
  ? Object.keys(nested)
103
103
  : Object.keys(schema);