@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.
- package/dist/attribute-analyser/style/native/useExtractImageStyle.d.ts +6 -6
- package/dist/attribute-analyser/style/native/useExtractTextStyle.d.ts +6 -4
- package/dist/attribute-analyser/style/native/useExtractViewStyle.d.ts +5 -3
- package/dist/build-components/Image/ImageProps.generated.d.ts +2 -4
- package/dist/build-components/NavigationBarColor/NavigationBarColor.d.ts +5 -0
- package/dist/build-components/NavigationBarColor/NavigationBarColorProps.generated.d.ts +54 -0
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +1 -3
- package/dist/build-components/Separator/Separator.d.ts +5 -0
- package/dist/build-components/Separator/SeparatorProps.generated.d.ts +21 -0
- package/dist/build-components/StatusBarColor/StatusBarColor.d.ts +5 -0
- package/dist/build-components/StatusBarColor/StatusBarColorProps.generated.d.ts +54 -0
- package/dist/build-components/index.d.ts +4 -1
- package/dist/build-components/patterns.generated.d.ts +2111 -1251
- package/dist/components/AttributesEditorPanel.d.ts +1 -1
- package/dist/components/BuilderProvider.d.ts +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +6 -6
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +4 -4
- package/dist/index.web.esm.js.map +1 -1
- package/dist/store.d.ts +4 -0
- package/dist/styles.css +1 -1
- package/dist/utils/attributeStyle.d.ts +21 -0
- package/dist/utils/extractImageStyle.d.ts +1 -1
- package/dist/utils/extractViewStyle/extractViewStyleNative.d.ts +1 -1
- package/package.json +7 -2
- package/src/DeviceMockFrame.tsx +8 -2
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/paywall-1.json +44 -39
- package/src/assets/samples/paywall-2.json +44 -25
- package/src/assets/samples/paywall-app-delete-offer.json +40 -21
- package/src/assets/samples/paywall-app-open-offer.json +40 -21
- package/src/assets/samples/paywall-back-offer.json +40 -21
- package/src/assets/samples/paywall-notification-offer.json +40 -21
- package/src/assets/samples/vpn-onboard-1.json +84 -39
- package/src/assets/samples/vpn-onboard-2.json +85 -40
- package/src/assets/samples/vpn-onboard-3.json +84 -39
- package/src/assets/samples/vpn-onboard-4.json +84 -39
- package/src/assets/samples/vpn-onboard-5.json +102 -55
- package/src/assets/samples/vpn-onboard-6.json +87 -38
- package/src/attribute-analyser/style/native/useExtractImageStyle.ts +31 -25
- package/src/attribute-analyser/style/native/useExtractTextStyle.ts +26 -11
- package/src/attribute-analyser/style/native/useExtractViewStyle.ts +21 -11
- package/src/attributes-editor/useAttributesEditorModel.ts +23 -17
- package/src/build-components/BackgroundImage/pattern.json +9 -7
- package/src/build-components/CarouselDots/CarouselDots.tsx +12 -11
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +3 -1
- package/src/build-components/Image/ImageProps.generated.ts +2 -4
- package/src/build-components/Image/pattern.json +15 -25
- package/src/build-components/NavigationBarColor/NavigationBarColor.tsx +39 -0
- package/src/build-components/NavigationBarColor/NavigationBarColorProps.generated.ts +71 -0
- package/src/build-components/NavigationBarColor/pattern.json +34 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +19 -5
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +8 -10
- package/src/build-components/OnboardDot/OnboardDot.tsx +12 -10
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +15 -4
- package/src/build-components/OnboardImage/OnboardImage.tsx +1 -1
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +1 -3
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +3 -1
- package/src/build-components/RenderNode.generated.tsx +15 -0
- package/src/build-components/Separator/Separator.tsx +41 -0
- package/src/build-components/Separator/SeparatorProps.generated.ts +26 -0
- package/src/build-components/Separator/pattern.json +59 -0
- package/src/build-components/StatusBarColor/StatusBarColor.tsx +39 -0
- package/src/build-components/StatusBarColor/StatusBarColorProps.generated.ts +71 -0
- package/src/build-components/StatusBarColor/pattern.json +34 -0
- package/src/build-components/Text/pattern.json +45 -38
- package/src/build-components/index.ts +15 -0
- package/src/build-components/patterns.generated.ts +2153 -1272
- package/src/build-components/useNode.ts +24 -25
- package/src/components/AttributesEditorPanel.tsx +4 -5
- package/src/components/Builder.tsx +1 -2
- package/src/components/BuilderProvider.tsx +43 -6
- package/src/components/JsonTextEditor.tsx +2 -2
- package/src/components/LoadingComponent.tsx +1 -1
- package/src/components/RenderErrorBoundary.tsx +1 -3
- package/src/index.ts +3 -0
- package/src/migrations/migrations/1.1.2_extract_component_attributes_from_style.ts +3 -3
- package/src/modals/BenefitPresetsModal.tsx +1 -1
- package/src/modals/ProductPresetsModal.tsx +1 -1
- package/src/pages/DebugJsonPage.tsx +7 -4
- package/src/pages/ProjectDebug.tsx +1 -1
- package/src/pages/ProjectPage.tsx +31 -32
- package/src/pages/ProjectValidationPage.tsx +2 -2
- package/src/store.ts +13 -0
- package/src/styles/layout/_builder.scss +6 -0
- package/src/utils/__special_exceptions.ts +5 -5
- package/src/utils/analyseNode.ts +2 -2
- package/src/utils/analyseNodeByPatterns.ts +10 -9
- package/src/utils/analyseNodeStructural.ts +1 -1
- package/src/utils/attributeStyle.ts +104 -0
- package/src/utils/extractImageStyle.ts +17 -13
- package/src/utils/extractTextStyle/extractTextStyle.ts +7 -7
- package/src/utils/extractTextStyle/extractTextStyleNative.ts +10 -10
- package/src/utils/extractViewStyle/extractViewStyle.ts +8 -11
- package/src/utils/extractViewStyle/extractViewStyleNative.ts +19 -19
- package/src/utils/loadFontFamily.ts +14 -19
- package/src/utils/logRenderStore.ts +5 -4
- package/src/utils/nodeTree.ts +1 -1
- package/src/utils/patterns.ts +26 -31
- package/src/utils/repairNodeKeys.ts +5 -7
- package/src/utils/wrapNodeInMain.ts +3 -3
package/src/utils/patterns.ts
CHANGED
|
@@ -61,7 +61,7 @@ type Pattern = {
|
|
|
61
61
|
meta?: PatternMeta;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
const patterns
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
214
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
...
|
|
42
|
+
...node,
|
|
43
43
|
...(shouldDemote ? { isMain: false } : null),
|
|
44
44
|
children: nextChildren,
|
|
45
|
-
}
|
|
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 { ...
|
|
53
|
+
if (cleaned.isMain !== true) return { ...cleaned, isMain: true };
|
|
54
54
|
return cleaned;
|
|
55
55
|
}
|
|
56
56
|
|