@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.
- package/dist/build-components/BIcon/BIconProps.generated.d.ts +1 -1
- package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +1 -1
- package/dist/build-components/Button/ButtonProps.generated.d.ts +1 -1
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +1 -1
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +1 -1
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +1 -1
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +1 -1
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +1 -1
- package/dist/build-components/CountDown/CountDownProps.generated.d.ts +1 -1
- package/dist/build-components/Image/ImageProps.generated.d.ts +1 -1
- package/dist/build-components/Main/MainProps.generated.d.ts +1 -1
- package/dist/build-components/NavigationBarColor/NavigationBarColorProps.generated.d.ts +1 -1
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +2 -2
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallBackground/PaywallBackgroundProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallOptions/PaywallOptionsProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.d.ts +1 -1
- package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +1 -1
- package/dist/build-components/Pricing/PricingProps.generated.d.ts +1 -1
- package/dist/build-components/Promo/PromoProps.generated.d.ts +1 -1
- package/dist/build-components/RadioButton/RadioButtonProps.generated.d.ts +1 -1
- package/dist/build-components/Separator/SeparatorProps.generated.d.ts +1 -1
- package/dist/build-components/StatusBarColor/StatusBarColorProps.generated.d.ts +1 -1
- package/dist/build-components/Text/TextProps.generated.d.ts +1 -1
- package/dist/build-components/View/ViewProps.generated.d.ts +1 -1
- package/dist/build-components/patterns.generated.d.ts +62 -52
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +3 -3
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +3 -3
- package/dist/index.web.esm.js.map +1 -1
- package/dist/utils/attributeStyle.d.ts +2 -2
- package/dist/utils/patterns.d.ts +2 -2
- package/package.json +1 -1
- package/scripts/prebuild/utils/createGeneratedProps.js +9 -9
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +9 -9
- package/src/RenderPage.tsx +42 -1
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/vpn-onboard-1.json +0 -24
- package/src/build-components/BIcon/BIconProps.generated.ts +1 -1
- package/src/build-components/BIcon/pattern.json +4 -2
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +1 -1
- package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +1 -1
- package/src/build-components/BackgroundImage/pattern.json +11 -3
- package/src/build-components/Button/Button.tsx +2 -2
- package/src/build-components/Button/ButtonProps.generated.ts +1 -1
- package/src/build-components/Button/pattern.json +5 -3
- package/src/build-components/Carousel/CarouselProps.generated.ts +1 -1
- package/src/build-components/Carousel/pattern.json +9 -3
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +1 -1
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +1 -1
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +1 -1
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +1 -1
- package/src/build-components/CarouselProvider/pattern.json +5 -2
- package/src/build-components/CountDown/CountDownProps.generated.ts +1 -1
- package/src/build-components/CountDown/pattern.json +4 -2
- package/src/build-components/Image/ImageProps.generated.ts +1 -1
- package/src/build-components/Image/pattern.json +11 -4
- package/src/build-components/Main/MainProps.generated.ts +1 -1
- package/src/build-components/Main/pattern.json +4 -2
- package/src/build-components/NavigationBarColor/NavigationBarColorProps.generated.ts +1 -1
- package/src/build-components/NavigationBarColor/pattern.json +5 -3
- package/src/build-components/Onboard/OnboardProps.generated.ts +1 -1
- package/src/build-components/Onboard/pattern.json +7 -3
- package/src/build-components/OnboardButton/OnboardButton.tsx +2 -23
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +2 -2
- package/src/build-components/OnboardButton/pattern.json +44 -30
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +1 -1
- package/src/build-components/OnboardButtons/pattern.json +16 -5
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +1 -1
- package/src/build-components/OnboardDot/pattern.json +4 -2
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -1
- package/src/build-components/OnboardFooter/pattern.json +4 -2
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +1 -1
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +1 -1
- package/src/build-components/OnboardItem/pattern.json +12 -4
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +1 -1
- package/src/build-components/OnboardProvider/pattern.json +9 -3
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -1
- package/src/build-components/OnboardSubtitle/pattern.json +5 -2
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -1
- package/src/build-components/OnboardTitle/pattern.json +5 -2
- package/src/build-components/PaywallBackground/PaywallBackgroundProps.generated.ts +1 -1
- package/src/build-components/PaywallBackground/pattern.json +4 -2
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +1 -1
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -1
- package/src/build-components/PaywallCloseButton/pattern.json +4 -2
- package/src/build-components/PaywallOptions/PaywallOptionsProps.generated.ts +1 -1
- package/src/build-components/PaywallOptions/pattern.json +4 -2
- package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +1 -1
- package/src/build-components/PaywallProvider/pattern.json +4 -2
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.ts +1 -1
- package/src/build-components/PaywallSubscribeButton/pattern.json +4 -2
- package/src/build-components/PriceTag/PriceTagProps.generated.ts +1 -1
- package/src/build-components/PriceTag/pattern.json +10 -4
- package/src/build-components/Pricing/PricingProps.generated.ts +1 -1
- package/src/build-components/Pricing/pattern.json +4 -2
- package/src/build-components/Promo/PromoProps.generated.ts +1 -1
- package/src/build-components/Promo/pattern.json +4 -2
- package/src/build-components/RadioButton/RadioButtonProps.generated.ts +1 -1
- package/src/build-components/Separator/SeparatorProps.generated.ts +1 -1
- package/src/build-components/Separator/pattern.json +5 -3
- package/src/build-components/StatusBarColor/StatusBarColorProps.generated.ts +1 -1
- package/src/build-components/StatusBarColor/pattern.json +5 -3
- package/src/build-components/Text/Text.tsx +1 -1
- package/src/build-components/Text/TextProps.generated.ts +1 -1
- package/src/build-components/Text/pattern.json +5 -3
- package/src/build-components/View/ViewProps.generated.ts +1 -1
- package/src/build-components/View/pattern.json +18 -6
- package/src/build-components/patterns.generated.ts +62 -52
- package/src/build-components/useNode.ts +2 -16
- package/src/migrations/migrations/1.1.2_extract_component_attributes_from_style.ts +31 -10
- package/src/utils/analyseNodeByPatterns.ts +2 -2
- package/src/utils/attributeStyle.ts +9 -3
- package/src/utils/extractImageStyle.ts +4 -4
- 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
|
-
//
|
|
19
|
-
|
|
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
|
-
|
|
54
|
-
const
|
|
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.
|
|
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
|
|
81
|
-
if (!isPlainObject(
|
|
82
|
-
return new Set(Object.keys(
|
|
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 !== '
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
|
3
|
+
* schemaVersion=2 uses `attributes.styles` exclusively.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { NodeDefaultAttribute } from '../types/Node';
|
|
7
7
|
|
|
8
|
-
/** Returns styles
|
|
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
|
-
|
|
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
|
|
22
|
+
// Map resizeMode to CSS object-fit (schemaVersion=2 uses `styles`)
|
|
23
23
|
const stylesBag = getStyleBag(attributes) as
|
|
24
|
-
| ImagePropsGenerated['attributes']['
|
|
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
|
|
43
|
+
// schemaVersion=2 uses `styles`
|
|
44
44
|
const nativeStylesBag = getStyleBag(attributes) as
|
|
45
|
-
| ImagePropsGenerated['attributes']['
|
|
45
|
+
| ImagePropsGenerated['attributes']['styles']
|
|
46
46
|
| undefined;
|
|
47
47
|
const resizeMode: ResizeModeOptionType | undefined =
|
|
48
48
|
nativeStylesBag?.resizeMode ?? (attributes as any).resizeMode;
|
package/src/utils/patterns.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
100
|
+
const nested = schema.styles;
|
|
101
101
|
return typeof nested === 'object' && nested
|
|
102
102
|
? Object.keys(nested)
|
|
103
103
|
: Object.keys(schema);
|