@developer_tribe/react-builder 1.2.8 → 1.2.9
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/AttributesEditor.d.ts +2 -11
- package/dist/attribute-analyser/style/native/useExtractImageStyle.d.ts +10 -0
- package/dist/attribute-analyser/style/native/useExtractTextStyle.d.ts +9 -0
- package/dist/attribute-analyser/style/native/useExtractViewStyle.d.ts +8 -0
- package/dist/attribute-analyser/style/web/useExtractImageStyle.d.ts +4 -0
- package/dist/attribute-analyser/style/web/useExtractTextStyle.d.ts +4 -0
- package/dist/attribute-analyser/style/web/useExtractViewStyle.d.ts +4 -0
- package/dist/attributes-editor/AttributesEditorFields.d.ts +18 -0
- package/dist/attributes-editor/AttributesEditorView.d.ts +4 -0
- package/dist/attributes-editor/attributesEditorModelTypes.d.ts +67 -0
- package/dist/attributes-editor/attributesEditorUtils.d.ts +19 -0
- package/dist/attributes-editor/useAttributesEditorModel.d.ts +2 -0
- package/dist/build-components/BIcon/BIconProps.generated.d.ts +6 -6
- package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +3 -3
- package/dist/build-components/Button/ButtonProps.generated.d.ts +1 -1
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +2 -2
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +4 -4
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +3 -3
- 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/Image/ImageProps.generated.d.ts +5 -3
- package/dist/build-components/Main/MainProps.generated.d.ts +2 -2
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +9 -8
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +11 -11
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +15 -9
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +10 -10
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +8 -6
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +6 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +5 -4
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +3 -3
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +3 -3
- package/dist/build-components/PaywallBackground/PaywallBackgroundProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +6 -6
- 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/RadioButton/RadioButtonProps.generated.d.ts +4 -4
- package/dist/build-components/Text/TextProps.generated.d.ts +3 -3
- package/dist/build-components/View/ViewProps.generated.d.ts +1 -1
- package/dist/build-components/patterns.generated.d.ts +2690 -5804
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.cjs.js +6 -4
- package/dist/index.native.cjs.js.map +1 -1
- package/dist/index.native.d.ts +5 -6
- package/dist/index.native.esm.js +6 -4
- package/dist/index.native.esm.js.map +1 -1
- package/dist/migrations/migratePipe.d.ts +1 -1
- package/dist/migrations/migrations/1.1.2_extract_component_attributes_from_style.d.ts +2 -0
- package/dist/mockOS/components/PermissionModal.d.ts +1 -2
- package/dist/styles.css +1 -1
- package/dist/types/PreviewConfig.d.ts +1 -5
- package/dist/utils/getMeta.d.ts +5 -0
- package/dist/utils/patterns.d.ts +12 -0
- package/package.json +2 -1
- package/scripts/prebuild/prebuild.js +14 -0
- package/scripts/prebuild/utils/createGeneratedProps.js +19 -13
- package/scripts/prebuild/utils/index.js +1 -0
- package/scripts/prebuild/utils/updateMetaJson.js +66 -0
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +37 -3
- package/scripts/prebuild/utils/validatePatternJson.js +27 -2
- package/scripts/public/scripts/build/index.js +20 -3
- package/scripts/public/scripts/build/info.json +6 -0
- package/scripts/public/scripts/build/utils/createComponentsIndex.js +9 -3
- package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +66 -8
- package/src/AttributesEditor.tsx +8 -944
- package/src/assets/meta.json +4 -0
- package/src/assets/samples/carousel-sample.json +1 -1
- package/src/assets/samples/getSamples.ts +2 -0
- package/src/assets/samples/paywall-1.json +11 -7
- package/src/assets/samples/simple-1.json +3 -3
- package/src/assets/samples/simple-2.json +3 -3
- package/src/assets/samples/unmigrated-builder-1.1.1.json +87 -0
- package/src/assets/samples/unmigrated-builder1.json +1 -1
- package/src/assets/samples/unvalidated-builder1.json +3 -3
- package/src/assets/samples/unvalidated-crash1.json +1 -1
- package/src/assets/samples/unvalidated-crashcomponent1.json +1 -1
- package/src/assets/samples/vpn-onboard-1.json +1 -1
- package/src/assets/samples/vpn-onboard-2.json +1 -1
- package/src/assets/samples/vpn-onboard-3.json +1 -1
- package/src/assets/samples/vpn-onboard-4.json +1 -1
- package/src/assets/samples/vpn-onboard-5.json +1 -1
- package/src/assets/samples/vpn-onboard-6.json +1 -1
- package/src/attribute-analyser/style/native/useExtractImageStyle.ts +46 -0
- package/src/attribute-analyser/style/native/useExtractTextStyle.ts +50 -0
- package/src/attribute-analyser/style/native/useExtractViewStyle.ts +32 -0
- package/src/attribute-analyser/style/web/useExtractImageStyle.ts +20 -0
- package/src/attribute-analyser/style/web/useExtractTextStyle.ts +27 -0
- package/src/attribute-analyser/style/web/useExtractViewStyle.ts +20 -0
- package/src/attributes-editor/AttributesEditorFields.tsx +248 -0
- package/src/attributes-editor/AttributesEditorView.tsx +360 -0
- package/src/attributes-editor/attributesEditorModelTypes.ts +86 -0
- package/src/attributes-editor/attributesEditorUtils.ts +102 -0
- package/src/attributes-editor/useAttributesEditorModel.ts +477 -0
- package/src/build-components/BIcon/BIcon.tsx +4 -4
- package/src/build-components/BIcon/BIconProps.generated.ts +6 -6
- package/src/build-components/BIcon/pattern.json +5 -6
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +3 -2
- package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +3 -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 +17 -15
- package/src/build-components/Carousel/Carousel.tsx +1 -1
- package/src/build-components/Carousel/CarouselProps.generated.ts +2 -2
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +4 -7
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +7 -7
- package/src/build-components/CarouselButtons/pattern.json +2 -1
- package/src/build-components/CarouselDots/CarouselDots.tsx +2 -2
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +9 -9
- package/src/build-components/CarouselItem/CarouselItem.tsx +1 -1
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +1 -1
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +1 -1
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +1 -1
- package/src/build-components/Image/Image.tsx +1 -1
- package/src/build-components/Image/ImageProps.generated.ts +5 -3
- package/src/build-components/Image/pattern.json +10 -9
- package/src/build-components/Main/Main.tsx +2 -2
- package/src/build-components/Main/MainProps.generated.ts +2 -2
- package/src/build-components/Main/pattern.json +2 -1
- package/src/build-components/Onboard/OnboardProps.generated.ts +1 -1
- package/src/build-components/OnboardButton/OnboardButton.tsx +7 -6
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +14 -13
- package/src/build-components/OnboardButton/pattern.json +9 -7
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +31 -31
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +14 -14
- package/src/build-components/OnboardButtons/pattern.json +9 -7
- package/src/build-components/OnboardDot/OnboardDot.tsx +7 -6
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +26 -9
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +17 -16
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +10 -10
- package/src/build-components/OnboardFooter/pattern.json +16 -14
- package/src/build-components/OnboardImage/OnboardImage.tsx +8 -8
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +8 -6
- package/src/build-components/OnboardImage/pattern.json +2 -1
- package/src/build-components/OnboardItem/OnboardItem.tsx +1 -1
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +6 -3
- package/src/build-components/OnboardItem/pattern.json +2 -1
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +1 -1
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +5 -4
- package/src/build-components/OnboardProvider/pattern.json +2 -1
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +3 -3
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +3 -3
- package/src/build-components/PaywallBackground/PaywallBackground.tsx +1 -1
- package/src/build-components/PaywallBackground/PaywallBackgroundProps.generated.ts +1 -1
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +5 -4
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +6 -6
- package/src/build-components/PaywallOptions/PaywallOptionButton.tsx +1 -1
- package/src/build-components/PaywallOptions/PaywallOptionsProps.generated.ts +1 -1
- package/src/build-components/PaywallProvider/PaywallProvider.tsx +1 -1
- package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +1 -1
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +1 -1
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.ts +1 -1
- package/src/build-components/RadioButton/RadioButton.tsx +5 -5
- package/src/build-components/RadioButton/RadioButtonProps.generated.ts +4 -4
- package/src/build-components/RadioButton/pattern.json +9 -7
- package/src/build-components/Text/Text.tsx +6 -6
- package/src/build-components/Text/TextProps.generated.ts +3 -3
- package/src/build-components/Text/pattern.json +15 -11
- package/src/build-components/View/View.tsx +1 -1
- package/src/build-components/View/ViewProps.generated.ts +1 -1
- package/src/build-components/View/pattern.json +71 -66
- package/src/build-components/patterns.generated.ts +3059 -6008
- package/src/components/AttributesEditorPanel.tsx +2 -2
- package/src/index.native.ts +6 -9
- package/src/index.ts +4 -0
- package/src/migrations/migratePipe.ts +7 -3
- package/src/migrations/migrations/1.1.2_extract_component_attributes_from_style.ts +211 -0
- package/src/mockOS/components/MockOSRouter.tsx +3 -1
- package/src/mockOS/components/PermissionModal.tsx +20 -160
- package/src/mockOS/components/SubscriptionModal.tsx +41 -278
- package/src/pages/ProjectPage.tsx +12 -6
- package/src/styles/components/_attributes-editor.scss +122 -0
- package/src/styles/components/_mockos-router.scss +388 -0
- package/src/styles/components/_onboard.scss +23 -0
- package/src/styles/index.scss +1 -0
- package/src/types/PreviewConfig.ts +1 -5
- package/src/utils/analyseNodeByPatterns.ts +39 -4
- package/src/utils/extractTextStyle/extractTextStyle.ts +4 -1
- package/src/utils/getMeta.ts +15 -0
- package/src/utils/patterns.ts +47 -4
- package/dist/hooks/useExtractImageStyle.d.ts +0 -5
- package/dist/hooks/useExtractTextStyle.d.ts +0 -3
- package/dist/hooks/useExtractViewStyle.d.ts +0 -3
- package/src/hooks/useExtractImageStyle.ts +0 -30
- package/src/hooks/useExtractTextStyle.ts +0 -34
- package/src/hooks/useExtractViewStyle.ts +0 -30
- package/src/migrations/migrations/1.1.0_normalize_style_attributes.ts +0 -80
|
@@ -6,6 +6,7 @@ import unvalidatedBuilder1 from './unvalidated-builder1.json';
|
|
|
6
6
|
import unvalidatedCrash1 from './unvalidated-crash1.json';
|
|
7
7
|
import unvalidatedCrashComponent1 from './unvalidated-crashcomponent1.json';
|
|
8
8
|
import unmigratedBuilder1 from './unmigrated-builder1.json';
|
|
9
|
+
import unmigratedBuilder1_1_1 from './unmigrated-builder-1.1.1.json';
|
|
9
10
|
import paywall1 from './paywall-1.json';
|
|
10
11
|
import vpnOnboard1 from './vpn-onboard-1.json';
|
|
11
12
|
import vpnOnboard2 from './vpn-onboard-2.json';
|
|
@@ -40,6 +41,7 @@ export function getSamples(): Project[] {
|
|
|
40
41
|
normalizeSample(unvalidatedCrash1),
|
|
41
42
|
normalizeSample(unvalidatedCrashComponent1),
|
|
42
43
|
normalizeSample(unmigratedBuilder1),
|
|
44
|
+
normalizeSample(unmigratedBuilder1_1_1),
|
|
43
45
|
normalizeSample(paywall1),
|
|
44
46
|
...onboardSamples,
|
|
45
47
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "Simple Paywall",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "paywall",
|
|
5
5
|
"appConfig": {
|
|
6
6
|
"theme": "light",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"type": "PaywallProvider",
|
|
29
29
|
"attributes": {
|
|
30
30
|
"style": {
|
|
31
|
-
"scrollable": true,
|
|
32
31
|
"flexDirection": "column",
|
|
33
32
|
"alignItems": "stretch",
|
|
34
33
|
"justifyContent": "flex-start",
|
|
@@ -38,7 +37,8 @@
|
|
|
38
37
|
"paddingBottom": 16,
|
|
39
38
|
"gap": 12,
|
|
40
39
|
"backgroundColor": "#F5F7FA"
|
|
41
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"scrollable": true
|
|
42
42
|
},
|
|
43
43
|
"children": [
|
|
44
44
|
{
|
|
@@ -54,12 +54,13 @@
|
|
|
54
54
|
"attributes": {
|
|
55
55
|
"style": {
|
|
56
56
|
"position": "absolute",
|
|
57
|
-
"top":
|
|
57
|
+
"top": 24,
|
|
58
58
|
"left": 16,
|
|
59
59
|
"width": 32,
|
|
60
60
|
"height": 32,
|
|
61
61
|
"borderRadius": 16,
|
|
62
62
|
"backgroundColor": "#FFFFFF",
|
|
63
|
+
"color": "#000",
|
|
63
64
|
"zIndex": 10
|
|
64
65
|
}
|
|
65
66
|
},
|
|
@@ -213,7 +214,8 @@
|
|
|
213
214
|
"type": "text",
|
|
214
215
|
"attributes": {
|
|
215
216
|
"style": {
|
|
216
|
-
"flex": 4
|
|
217
|
+
"flex": 4,
|
|
218
|
+
"color": "#000"
|
|
217
219
|
}
|
|
218
220
|
},
|
|
219
221
|
"children": "@productDescription — Unlock all premium features for a month."
|
|
@@ -223,7 +225,8 @@
|
|
|
223
225
|
"attributes": {
|
|
224
226
|
"style": {
|
|
225
227
|
"flex": 1,
|
|
226
|
-
"textAlign": "right"
|
|
228
|
+
"textAlign": "right",
|
|
229
|
+
"color": "#000"
|
|
227
230
|
}
|
|
228
231
|
},
|
|
229
232
|
"children": "@localizedPrice"
|
|
@@ -236,7 +239,8 @@
|
|
|
236
239
|
"style": {
|
|
237
240
|
"marginRight": 4,
|
|
238
241
|
"flex": 0,
|
|
239
|
-
"width": 32
|
|
242
|
+
"width": 32,
|
|
243
|
+
"color": "#000"
|
|
240
244
|
}
|
|
241
245
|
},
|
|
242
246
|
"children": null
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hello-world",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "other",
|
|
5
5
|
"appConfig": {
|
|
6
6
|
"theme": "light",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"type": "view",
|
|
22
22
|
"attributes": {
|
|
23
23
|
"style": {
|
|
24
|
-
"scrollable": true,
|
|
25
24
|
"flexDirection": "column",
|
|
26
25
|
"alignItems": "center",
|
|
27
26
|
"justifyContent": "center",
|
|
28
27
|
"gap": 12,
|
|
29
28
|
"padding": 16,
|
|
30
29
|
"backgroundColor": "#F5F7FA"
|
|
31
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"scrollable": true
|
|
32
32
|
},
|
|
33
33
|
"children": [
|
|
34
34
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hello-world-2-advanced",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "other",
|
|
5
5
|
"appConfig": {
|
|
6
6
|
"theme": "light",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"type": "view",
|
|
22
22
|
"attributes": {
|
|
23
23
|
"style": {
|
|
24
|
-
"scrollable": true,
|
|
25
24
|
"flexDirection": "column",
|
|
26
25
|
"alignItems": "stretch",
|
|
27
26
|
"justifyContent": "flex-start",
|
|
28
27
|
"gap": 16,
|
|
29
28
|
"padding": 16,
|
|
30
29
|
"backgroundColor": "#F3F4F6"
|
|
31
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"scrollable": true
|
|
32
32
|
},
|
|
33
33
|
"children": [
|
|
34
34
|
{
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unmigrated-builder-1.1.1",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"type": "other",
|
|
5
|
+
"appConfig": {
|
|
6
|
+
"theme": "light"
|
|
7
|
+
},
|
|
8
|
+
"data": {
|
|
9
|
+
"type": "view",
|
|
10
|
+
"attributes": {
|
|
11
|
+
"scrollable": true,
|
|
12
|
+
"style": {
|
|
13
|
+
"flexDirection": "column",
|
|
14
|
+
"alignItems": "center",
|
|
15
|
+
"justifyContent": "center",
|
|
16
|
+
"gap": 12,
|
|
17
|
+
"padding": 24,
|
|
18
|
+
"backgroundColor": "#F5F7FA"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"children": [
|
|
22
|
+
{
|
|
23
|
+
"type": "text",
|
|
24
|
+
"attributes": {
|
|
25
|
+
"style": {
|
|
26
|
+
"fontSize": 22,
|
|
27
|
+
"fontWeight": "700",
|
|
28
|
+
"color": "#111827",
|
|
29
|
+
"textAlign": "center"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"children": "Intentionally unmigrated sample (for combined 1.1.2)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "text",
|
|
36
|
+
"attributes": {
|
|
37
|
+
"style": {
|
|
38
|
+
"fontSize": 14,
|
|
39
|
+
"color": "#6B7280",
|
|
40
|
+
"textAlign": "center",
|
|
41
|
+
"paddingHorizontal": 8
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"children": "This project has version 1.1.1 so the Migration page should appear. Click “Migrate now” to move component props and non-style flags out of attributes.style (combined 1.1.2)."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"type": "view",
|
|
48
|
+
"attributes": {
|
|
49
|
+
"style": {
|
|
50
|
+
"flexDirection": "row",
|
|
51
|
+
"alignItems": "center",
|
|
52
|
+
"justifyContent": "center",
|
|
53
|
+
"gap": 12,
|
|
54
|
+
"marginTop": 16
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"children": [
|
|
58
|
+
{
|
|
59
|
+
"type": "BIcon",
|
|
60
|
+
"attributes": {
|
|
61
|
+
"style": {
|
|
62
|
+
"iconType": "check",
|
|
63
|
+
"strokeWidth": 3,
|
|
64
|
+
"color": "#22c55e",
|
|
65
|
+
"fontSize": "18"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"children": null
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "image",
|
|
72
|
+
"attributes": {
|
|
73
|
+
"src": "https://images.unsplash.com/photo-1521737604893-d14cc237f11d?auto=format&fit=crop&w=1200&q=80",
|
|
74
|
+
"width": 48,
|
|
75
|
+
"height": 48,
|
|
76
|
+
"style": {
|
|
77
|
+
"resizeMode": "contain",
|
|
78
|
+
"borderRadius": 12
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"children": null
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"textAlign": "center",
|
|
36
36
|
"paddingHorizontal": 8
|
|
37
37
|
},
|
|
38
|
-
"children": "This project has version 1.0.0 so the Migration page should appear. Click “Migrate now” to normalize legacy flat style keys into attributes.style (1.1.
|
|
38
|
+
"children": "This project has version 1.0.0 so the Migration page should appear. Click “Migrate now” to normalize legacy flat style keys into attributes.style and move misplaced props out of style (combined 1.1.2)."
|
|
39
39
|
}
|
|
40
40
|
]
|
|
41
41
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unvalidated-builder1",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "other",
|
|
5
5
|
"appConfig": {
|
|
6
6
|
"theme": "light"
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"type": "view",
|
|
10
10
|
"attributes": {
|
|
11
11
|
"style": {
|
|
12
|
-
"scrollable": true,
|
|
13
12
|
"flexDirection": "column",
|
|
14
13
|
"alignItems": "center",
|
|
15
14
|
"justifyContent": "center",
|
|
@@ -17,7 +16,8 @@
|
|
|
17
16
|
"padding": 24,
|
|
18
17
|
"backgroundColor": "#F5F7FA"
|
|
19
18
|
},
|
|
20
|
-
"foo": 1
|
|
19
|
+
"foo": 1,
|
|
20
|
+
"scrollable": true
|
|
21
21
|
},
|
|
22
22
|
"children": [
|
|
23
23
|
{
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { NodeData } from '../../../types/Node';
|
|
3
|
+
import type { ImagePropsGenerated } from '../../../build-components/Image/ImageProps.generated';
|
|
4
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
5
|
+
import { extractImageStyleNative } from '../../../utils/extractImageStyle';
|
|
6
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
7
|
+
|
|
8
|
+
export function useExtractImageStyle<
|
|
9
|
+
T extends ImagePropsGenerated['attributes'],
|
|
10
|
+
>(node: NodeData<T>) {
|
|
11
|
+
const { appConfig, projectColors: builderProjectColors } = useBuilderParams();
|
|
12
|
+
const theme = appConfig?.theme ?? defaultAppConfig.theme;
|
|
13
|
+
const projectColors = builderProjectColors;
|
|
14
|
+
|
|
15
|
+
return useMemo(() => {
|
|
16
|
+
// extractImageStyleNative includes `resizeMode` in the returned object, but in RN
|
|
17
|
+
// resizeMode is typically passed as an Image prop. We normalize to `{ style, other }`.
|
|
18
|
+
const styleWithResizeMode = extractImageStyleNative(node, {
|
|
19
|
+
theme,
|
|
20
|
+
projectColors,
|
|
21
|
+
});
|
|
22
|
+
const { resizeMode: resizeModeFromStyle, ...style } =
|
|
23
|
+
(styleWithResizeMode as unknown as Record<string, unknown>) ?? {};
|
|
24
|
+
|
|
25
|
+
const attrs = node.attributes as unknown as Record<string, unknown>;
|
|
26
|
+
const styleBag =
|
|
27
|
+
(attrs?.style as Record<string, unknown> | undefined) ?? undefined;
|
|
28
|
+
const { style: _style, ...rest } = attrs ?? {};
|
|
29
|
+
void _style;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
style,
|
|
33
|
+
other: {
|
|
34
|
+
...rest,
|
|
35
|
+
// In RN, resizeMode is commonly an Image prop (not style). We expose it as "other".
|
|
36
|
+
resizeMode: (resizeModeFromStyle ??
|
|
37
|
+
(styleBag?.resizeMode as unknown)) as
|
|
38
|
+
| 'cover'
|
|
39
|
+
| 'contain'
|
|
40
|
+
| 'stretch'
|
|
41
|
+
| 'center'
|
|
42
|
+
| undefined,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}, [node, theme, projectColors]);
|
|
46
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { NodeData } from '../../../types/Node';
|
|
3
|
+
import type { TextPropsGenerated } from '../../../build-components/Text/TextProps.generated';
|
|
4
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
5
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
6
|
+
import { extractTextStyleNative } from '../../../utils/extractTextStyle';
|
|
7
|
+
|
|
8
|
+
export function useExtractTextStyle<T extends TextPropsGenerated['attributes']>(
|
|
9
|
+
node: NodeData<T>,
|
|
10
|
+
) {
|
|
11
|
+
const {
|
|
12
|
+
appConfig: builderAppConfig,
|
|
13
|
+
projectColors: builderProjectColors,
|
|
14
|
+
fonts: builderFonts,
|
|
15
|
+
} = useBuilderParams();
|
|
16
|
+
|
|
17
|
+
const appConfig = builderAppConfig ?? defaultAppConfig;
|
|
18
|
+
const projectColors = builderProjectColors;
|
|
19
|
+
const fonts = builderFonts;
|
|
20
|
+
|
|
21
|
+
return useMemo(
|
|
22
|
+
() => {
|
|
23
|
+
const style = extractTextStyleNative(node, {
|
|
24
|
+
appConfig,
|
|
25
|
+
projectColors,
|
|
26
|
+
fonts,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const attrs = node.attributes as unknown as Record<string, unknown>;
|
|
30
|
+
const styleBag =
|
|
31
|
+
(attrs?.style as Record<string, unknown> | undefined) ?? undefined;
|
|
32
|
+
const { style: _style, ...rest } = attrs ?? {};
|
|
33
|
+
void _style;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
style,
|
|
37
|
+
other: {
|
|
38
|
+
...rest,
|
|
39
|
+
// These are "behavior" flags stored under style in the schema.
|
|
40
|
+
adjustsFontSizeToFit: styleBag?.adjustsFontSizeToFit as
|
|
41
|
+
| boolean
|
|
42
|
+
| undefined,
|
|
43
|
+
showEllipsis: styleBag?.showEllipsis as boolean | undefined,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
// fonts is intentionally included: extractTextStyleNative resolves weights via font definitions.
|
|
48
|
+
[node, appConfig, projectColors, fonts],
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { NodeData } from '../../../types/Node';
|
|
3
|
+
import type { ViewPropsGenerated } from '../../../build-components/View/ViewProps.generated';
|
|
4
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
5
|
+
import { extractViewStyleNative } from '../../../utils/extractViewStyle';
|
|
6
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
7
|
+
|
|
8
|
+
export function useExtractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
9
|
+
node: NodeData<T>,
|
|
10
|
+
) {
|
|
11
|
+
const { appConfig, projectColors: builderProjectColors } = useBuilderParams();
|
|
12
|
+
const theme = appConfig?.theme ?? defaultAppConfig.theme;
|
|
13
|
+
const projectColors = builderProjectColors;
|
|
14
|
+
|
|
15
|
+
return useMemo(() => {
|
|
16
|
+
const style = extractViewStyleNative(node, { theme, projectColors });
|
|
17
|
+
|
|
18
|
+
const attrs = node.attributes as unknown as Record<string, unknown>;
|
|
19
|
+
const styleBag =
|
|
20
|
+
(attrs?.style as Record<string, unknown> | undefined) ?? undefined;
|
|
21
|
+
const { style: _style, ...rest } = attrs ?? {};
|
|
22
|
+
void _style;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
style,
|
|
26
|
+
other: {
|
|
27
|
+
...rest,
|
|
28
|
+
scrollable: styleBag?.scrollable as boolean | undefined,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}, [node, theme, projectColors]);
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import type { NodeData } from '../../../types/Node';
|
|
4
|
+
import type { ImagePropsGenerated } from '../../../build-components/Image/ImageProps.generated';
|
|
5
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
6
|
+
import { extractImageStyle } from '../../../utils/extractImageStyle';
|
|
7
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
8
|
+
|
|
9
|
+
export function useExtractImageStyle<
|
|
10
|
+
T extends ImagePropsGenerated['attributes'],
|
|
11
|
+
>(node: NodeData<T>): CSSProperties {
|
|
12
|
+
const { appConfig, projectColors: builderProjectColors } = useBuilderParams();
|
|
13
|
+
const theme = appConfig?.theme ?? defaultAppConfig.theme;
|
|
14
|
+
const projectColors = builderProjectColors;
|
|
15
|
+
|
|
16
|
+
return useMemo(
|
|
17
|
+
() => extractImageStyle(node, { theme, projectColors }),
|
|
18
|
+
[node, theme, projectColors],
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import type { NodeData } from '../../../types/Node';
|
|
4
|
+
import type { TextPropsGenerated } from '../../../build-components/Text/TextProps.generated';
|
|
5
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
6
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
7
|
+
import { extractTextStyle } from '../../../utils/extractTextStyle';
|
|
8
|
+
|
|
9
|
+
export function useExtractTextStyle<T extends TextPropsGenerated['attributes']>(
|
|
10
|
+
node: NodeData<T>,
|
|
11
|
+
): CSSProperties {
|
|
12
|
+
const {
|
|
13
|
+
appConfig: builderAppConfig,
|
|
14
|
+
projectColors: builderProjectColors,
|
|
15
|
+
fonts: builderFonts,
|
|
16
|
+
} = useBuilderParams();
|
|
17
|
+
|
|
18
|
+
const appConfig = builderAppConfig ?? defaultAppConfig;
|
|
19
|
+
const projectColors = builderProjectColors;
|
|
20
|
+
const fonts = builderFonts;
|
|
21
|
+
|
|
22
|
+
return useMemo(
|
|
23
|
+
() => extractTextStyle(node, { appConfig, projectColors, fonts }),
|
|
24
|
+
// fonts is intentionally included: extractTextStyle resolves weights via font definitions.
|
|
25
|
+
[node, appConfig, projectColors, fonts],
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import type { NodeData } from '../../../types/Node';
|
|
4
|
+
import type { ViewPropsGenerated } from '../../../build-components/View/ViewProps.generated';
|
|
5
|
+
import { useBuilderParams } from '../../../components/BuilderProvider';
|
|
6
|
+
import { extractViewStyle } from '../../../utils/extractViewStyle';
|
|
7
|
+
import { defaultAppConfig } from '../../../types/PreviewConfig';
|
|
8
|
+
|
|
9
|
+
export function useExtractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
10
|
+
node: NodeData<T>,
|
|
11
|
+
): CSSProperties {
|
|
12
|
+
const { appConfig, projectColors: builderProjectColors } = useBuilderParams();
|
|
13
|
+
const theme = appConfig?.theme ?? defaultAppConfig.theme;
|
|
14
|
+
const projectColors = builderProjectColors;
|
|
15
|
+
|
|
16
|
+
return useMemo(
|
|
17
|
+
() => extractViewStyle(node, { theme, projectColors }),
|
|
18
|
+
[node, theme, projectColors],
|
|
19
|
+
);
|
|
20
|
+
}
|