@developer_tribe/react-builder 1.2.28 → 1.2.30
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/RenderPage.d.ts +7 -2
- package/dist/attributes-editor/attributesEditorModelTypes.d.ts +0 -1
- package/dist/build-components/index.generated.d.ts +38 -0
- package/dist/components/BuilderProvider.d.ts +9 -15
- package/dist/hooks/useLocalize.d.ts +3 -2
- package/dist/hooks/usePreviewSelection.d.ts +12 -0
- package/dist/index.cjs.js +1 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +1 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +4 -4
- 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/logger.d.ts +3 -6
- package/dist/modals/IconPickerModal.d.ts +1 -1
- package/dist/pages/DebugJsonPage.d.ts +1 -4
- package/dist/product-base/index.d.ts +24 -0
- package/dist/size-matters/index.d.ts +15 -6
- package/dist/store.d.ts +5 -3
- package/dist/types/Icons.generated.d.ts +2 -0
- package/dist/types/PreviewConfig.d.ts +6 -8
- package/dist/types/Project.d.ts +4 -3
- package/dist/utils/extractTextStyle/extractTextStyle.d.ts +2 -0
- package/dist/utils/extractTextStyle/extractTextStyleNative.d.ts +2 -0
- package/dist/utils/extractViewStyle/extractViewStyle.d.ts +2 -0
- package/dist/utils/extractViewStyle/extractViewStyleNative.d.ts +2 -0
- package/package.json +1 -1
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +19 -9
- package/src/RenderPage.tsx +66 -57
- package/src/assets/.DS_Store +0 -0
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/carousel-sample.json +2 -6
- package/src/assets/samples/getSamples.ts +14 -4
- package/src/attribute-analyser/style/native/useExtractImageStyle.ts +3 -3
- package/src/attribute-analyser/style/native/useExtractTextStyle.ts +8 -2
- package/src/attribute-analyser/style/native/useExtractViewStyle.ts +7 -3
- package/src/attribute-analyser/style/web/useExtractImageStyle.ts +3 -3
- package/src/attribute-analyser/style/web/useExtractTextStyle.ts +8 -2
- package/src/attribute-analyser/style/web/useExtractViewStyle.ts +3 -3
- package/src/attributes-editor/AttributesEditorFields.tsx +1 -1
- package/src/attributes-editor/attributesEditorModelTypes.ts +0 -3
- package/src/attributes-editor/useAttributesEditorModel.ts +0 -3
- package/src/build-components/BIcon/BIcon.tsx +1 -1
- package/src/build-components/Button/Button.tsx +2 -2
- package/src/build-components/CarouselDots/CarouselDots.tsx +3 -3
- package/src/build-components/OnboardButton/OnboardButton.tsx +2 -2
- package/src/build-components/OnboardDot/OnboardDot.tsx +9 -3
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +4 -5
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +1 -1
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +2 -2
- package/src/build-components/Text/Text.tsx +2 -2
- package/src/build-components/index.generated.ts +184 -0
- package/src/components/BottomBar.tsx +7 -9
- package/src/components/BuilderProvider.tsx +47 -84
- package/src/components/EditorHeader.tsx +6 -3
- package/src/hooks/useLocalize.ts +14 -10
- package/src/hooks/usePreviewSelection.ts +66 -0
- package/src/index.ts +2 -2
- package/src/logger.ts +4 -20
- package/src/modals/IconPickerModal.tsx +1 -1
- package/src/modals/InspectModal.tsx +6 -7
- package/src/modals/ProductPresetsModal.tsx +2 -2
- package/src/pages/DebugJsonPage.tsx +0 -6
- package/src/pages/ProjectPage.tsx +12 -57
- package/src/pages/tabs/SideTool.tsx +7 -7
- package/src/product-base/extractAndroidParams.ts +4 -11
- package/src/product-base/extractIOSParams.ts +4 -10
- package/src/product-base/index.ts +36 -0
- package/src/size-matters/index.ts +44 -31
- package/src/store.ts +12 -6
- package/src/styles/modals/_inspect-modal.scss +7 -3
- package/src/types/Icons.generated.ts +244 -0
- package/src/types/PreviewConfig.ts +5 -9
- package/src/types/Project.ts +4 -3
- package/src/utils/extractImageStyle.ts +4 -2
- package/src/utils/extractTextStyle/extractTextStyle.ts +6 -1
- package/src/utils/extractTextStyle/extractTextStyleNative.ts +4 -1
- package/src/utils/extractViewStyle/extractViewStyle.ts +7 -5
- package/src/utils/extractViewStyle/extractViewStyleNative.ts +3 -1
- package/src/utils/getDefaultProject.ts +0 -1
- package/src/utils/replaceLocalizationParams.ts +1 -1
package/src/store.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { createWithEqualityFn } from 'zustand/traditional';
|
|
|
2
2
|
import { shallow } from 'zustand/shallow';
|
|
3
3
|
import type { Device } from './types/Device';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
defaultBaseSize,
|
|
6
|
+
defaultLocalization,
|
|
6
7
|
defaultTheme,
|
|
7
|
-
type
|
|
8
|
+
type BaseSize,
|
|
9
|
+
type Localication,
|
|
8
10
|
type Theme,
|
|
9
11
|
} from './types/PreviewConfig';
|
|
10
12
|
import { getDefaultDevice } from './utils/getDevices';
|
|
@@ -29,14 +31,16 @@ type RenderStore = {
|
|
|
29
31
|
incForceRender: () => void;
|
|
30
32
|
device: Device;
|
|
31
33
|
setDevice: (device: Device) => void;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
baseSize: BaseSize;
|
|
35
|
+
setBaseSize: (baseSize: BaseSize) => void;
|
|
34
36
|
projectColors?: ProjectColors;
|
|
35
37
|
setProjectColors: (projectColors?: ProjectColors) => void;
|
|
36
38
|
theme: Theme;
|
|
37
39
|
setTheme: (theme: Theme) => void;
|
|
38
40
|
defaultLanguage: string;
|
|
39
41
|
setDefaultLanguage: (lang: string) => void;
|
|
42
|
+
localization: Localication;
|
|
43
|
+
setLocalization: (localization: Localication) => void;
|
|
40
44
|
isRtl: boolean;
|
|
41
45
|
setIsRtl: (isRtl: boolean) => void;
|
|
42
46
|
previewMode: boolean;
|
|
@@ -106,14 +110,16 @@ export const useRenderStore = createWithEqualityFn<RenderStore>()(
|
|
|
106
110
|
set((state) => ({ forceRender: state.forceRender + 1 })),
|
|
107
111
|
device: getDefaultDevice(),
|
|
108
112
|
setDevice: (device) => set({ device }),
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
baseSize: defaultBaseSize,
|
|
114
|
+
setBaseSize: (baseSize) => set({ baseSize }),
|
|
111
115
|
projectColors: undefined,
|
|
112
116
|
setProjectColors: (projectColors) => set({ projectColors }),
|
|
113
117
|
theme: defaultTheme,
|
|
114
118
|
setTheme: (theme) => set({ theme }),
|
|
115
119
|
defaultLanguage: 'en',
|
|
116
120
|
setDefaultLanguage: (lang) => set({ defaultLanguage: lang }),
|
|
121
|
+
localization: defaultLocalization,
|
|
122
|
+
setLocalization: (localization) => set({ localization }),
|
|
117
123
|
isRtl: false,
|
|
118
124
|
setIsRtl: (isRtl) => set({ isRtl }),
|
|
119
125
|
previewMode: false,
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
font-weight: 500;
|
|
32
32
|
color: colors.$mutedTextColor;
|
|
33
33
|
border-bottom: 2px solid transparent;
|
|
34
|
-
transition:
|
|
34
|
+
transition:
|
|
35
|
+
color 0.15s,
|
|
36
|
+
border-color 0.15s;
|
|
35
37
|
|
|
36
38
|
&:hover {
|
|
37
39
|
color: colors.$textColor;
|
|
@@ -99,7 +101,8 @@
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
.inspect-modal__cell-key {
|
|
102
|
-
font-family:
|
|
104
|
+
font-family:
|
|
105
|
+
ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', monospace;
|
|
103
106
|
font-size: sizes.$fontSizeXs;
|
|
104
107
|
word-break: break-all;
|
|
105
108
|
max-width: 320px;
|
|
@@ -110,7 +113,8 @@
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
.inspect-modal__cell-value {
|
|
113
|
-
font-family:
|
|
116
|
+
font-family:
|
|
117
|
+
ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', monospace;
|
|
114
118
|
font-size: sizes.$fontSizeXs;
|
|
115
119
|
word-break: break-all;
|
|
116
120
|
display: flex;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// NOTE: This file is generated. Do not edit it manually.
|
|
2
|
+
//TODO: we might use font-icon or something more optimize
|
|
3
|
+
export const Icons = [
|
|
4
|
+
'activity',
|
|
5
|
+
'activity-heart',
|
|
6
|
+
'alert-circle',
|
|
7
|
+
'alert-triangle',
|
|
8
|
+
'anchor',
|
|
9
|
+
'archive',
|
|
10
|
+
'arrow-down',
|
|
11
|
+
'arrow-left',
|
|
12
|
+
'arrow-narrow-down-left',
|
|
13
|
+
'arrow-narrow-up-right',
|
|
14
|
+
'arrow-right',
|
|
15
|
+
'arrow-right-smooth',
|
|
16
|
+
'asterisk-01',
|
|
17
|
+
'asterisk-02',
|
|
18
|
+
'at-sign',
|
|
19
|
+
'award',
|
|
20
|
+
'battery-charging',
|
|
21
|
+
'bell-01',
|
|
22
|
+
'bell-02',
|
|
23
|
+
'bell-ringing-02',
|
|
24
|
+
'bookmark',
|
|
25
|
+
'bookmark-add',
|
|
26
|
+
'bookmark-check',
|
|
27
|
+
'bookmark-minus',
|
|
28
|
+
'bookmark-x',
|
|
29
|
+
'bubble',
|
|
30
|
+
'building-01',
|
|
31
|
+
'building-02',
|
|
32
|
+
'building-03',
|
|
33
|
+
'building-04',
|
|
34
|
+
'building-05',
|
|
35
|
+
'building-06',
|
|
36
|
+
'building-07',
|
|
37
|
+
'building-08',
|
|
38
|
+
'building-09',
|
|
39
|
+
'camera',
|
|
40
|
+
'camera-01',
|
|
41
|
+
'camera-steel',
|
|
42
|
+
'check',
|
|
43
|
+
'check-circle',
|
|
44
|
+
'check-circle-bold',
|
|
45
|
+
'check-circle-broken',
|
|
46
|
+
'check-done-01',
|
|
47
|
+
'check-done-02',
|
|
48
|
+
'check-heart',
|
|
49
|
+
'check-square',
|
|
50
|
+
'check-square-broken',
|
|
51
|
+
'check-verified-01',
|
|
52
|
+
'check-verified-02',
|
|
53
|
+
'check-verified-03',
|
|
54
|
+
'checkbox',
|
|
55
|
+
'checkv',
|
|
56
|
+
'chevron-down',
|
|
57
|
+
'chevron-down2',
|
|
58
|
+
'chevron-left',
|
|
59
|
+
'chevron-left-2',
|
|
60
|
+
'chevron-right',
|
|
61
|
+
'chevron-right-empty',
|
|
62
|
+
'chevron-right-smooth',
|
|
63
|
+
'chevron-up',
|
|
64
|
+
'circle',
|
|
65
|
+
'clock',
|
|
66
|
+
'clock-fast-forward',
|
|
67
|
+
'close',
|
|
68
|
+
'close-circle',
|
|
69
|
+
'cloud-01',
|
|
70
|
+
'cloud-blank-01',
|
|
71
|
+
'cloud-blank-02',
|
|
72
|
+
'coin',
|
|
73
|
+
'coins-02',
|
|
74
|
+
'colors',
|
|
75
|
+
'copy-01',
|
|
76
|
+
'copy-02',
|
|
77
|
+
'copy-03',
|
|
78
|
+
'copy-04',
|
|
79
|
+
'copy-05',
|
|
80
|
+
'copy-06',
|
|
81
|
+
'copy-07',
|
|
82
|
+
'corner-down-right',
|
|
83
|
+
'crypto-bold',
|
|
84
|
+
'delete-icon',
|
|
85
|
+
'diamond',
|
|
86
|
+
'dice-3',
|
|
87
|
+
'divide-01',
|
|
88
|
+
'divide-02',
|
|
89
|
+
'divide-03',
|
|
90
|
+
'document-check-bold',
|
|
91
|
+
'dots-circle',
|
|
92
|
+
'dots-grid',
|
|
93
|
+
'dots-horizontal',
|
|
94
|
+
'dots-vertical',
|
|
95
|
+
'download-01',
|
|
96
|
+
'download-02',
|
|
97
|
+
'download-03',
|
|
98
|
+
'edit-03',
|
|
99
|
+
'edit-04',
|
|
100
|
+
'edit-05',
|
|
101
|
+
'element-3',
|
|
102
|
+
'ellipse-127',
|
|
103
|
+
'exclaimation-circle',
|
|
104
|
+
'eye-off-line',
|
|
105
|
+
'face-smile',
|
|
106
|
+
'file-04',
|
|
107
|
+
'file-05',
|
|
108
|
+
'file-check-02',
|
|
109
|
+
'file-plus-01',
|
|
110
|
+
'file-shield-02',
|
|
111
|
+
'filter-funnel-01',
|
|
112
|
+
'flag-03',
|
|
113
|
+
'flash',
|
|
114
|
+
'folder',
|
|
115
|
+
'folder-plus',
|
|
116
|
+
'gallery',
|
|
117
|
+
'globe-01',
|
|
118
|
+
'globe-04',
|
|
119
|
+
'globe-bold',
|
|
120
|
+
'guard',
|
|
121
|
+
'headphones-01',
|
|
122
|
+
'headphones-02',
|
|
123
|
+
'headset-bold',
|
|
124
|
+
'heart',
|
|
125
|
+
'heart-bold',
|
|
126
|
+
'help-circle',
|
|
127
|
+
'home-2',
|
|
128
|
+
'home-line',
|
|
129
|
+
'hourglass-02',
|
|
130
|
+
'image',
|
|
131
|
+
'image-01',
|
|
132
|
+
'image-03',
|
|
133
|
+
'inbox-01',
|
|
134
|
+
'inbox-arrow-down',
|
|
135
|
+
'info-circle',
|
|
136
|
+
'keyboard-line',
|
|
137
|
+
'lamp-charge',
|
|
138
|
+
'layer',
|
|
139
|
+
'light',
|
|
140
|
+
'like-dislike',
|
|
141
|
+
'lock-03',
|
|
142
|
+
'logout',
|
|
143
|
+
'magicpen',
|
|
144
|
+
'mail',
|
|
145
|
+
'mail-01',
|
|
146
|
+
'marker',
|
|
147
|
+
'medal-star',
|
|
148
|
+
'menu',
|
|
149
|
+
'menu-04',
|
|
150
|
+
'message-circle-01',
|
|
151
|
+
'message-plus-circle',
|
|
152
|
+
'message-question-circle',
|
|
153
|
+
'message-text-circle-01',
|
|
154
|
+
'message-text-square-02',
|
|
155
|
+
'message-x-square',
|
|
156
|
+
'microphone-02',
|
|
157
|
+
'microphone-slash',
|
|
158
|
+
'mirror',
|
|
159
|
+
'moon-01',
|
|
160
|
+
'moon-bold',
|
|
161
|
+
'mouse-circle',
|
|
162
|
+
'move',
|
|
163
|
+
'notification',
|
|
164
|
+
'notification-fill',
|
|
165
|
+
'notification-text',
|
|
166
|
+
'pdf-01',
|
|
167
|
+
'pencil-01',
|
|
168
|
+
'phone',
|
|
169
|
+
'phone-01',
|
|
170
|
+
'phone-arrow-down-left',
|
|
171
|
+
'phone-arrow-up-right',
|
|
172
|
+
'phone-hang-up',
|
|
173
|
+
'phone-hangup2',
|
|
174
|
+
'phone-incoming-01',
|
|
175
|
+
'phone-outgoing-01',
|
|
176
|
+
'phone-plus',
|
|
177
|
+
'phone-x',
|
|
178
|
+
'plus',
|
|
179
|
+
'plus-circle',
|
|
180
|
+
'printer',
|
|
181
|
+
'question-mark-circle',
|
|
182
|
+
'refresh-ccw-01',
|
|
183
|
+
'refresh-cw-01',
|
|
184
|
+
'refresh-cw-04',
|
|
185
|
+
'refresh-right-square-bold',
|
|
186
|
+
'remove-circle',
|
|
187
|
+
'repeat-04',
|
|
188
|
+
'repeat-bold',
|
|
189
|
+
'ruler-pen',
|
|
190
|
+
'search',
|
|
191
|
+
'search-lg',
|
|
192
|
+
'search-md',
|
|
193
|
+
'search-refraction',
|
|
194
|
+
'send-01',
|
|
195
|
+
'send-02',
|
|
196
|
+
'send-diagonal',
|
|
197
|
+
'setting-2',
|
|
198
|
+
'settings',
|
|
199
|
+
'settings-02',
|
|
200
|
+
'settings-04',
|
|
201
|
+
'settings-2',
|
|
202
|
+
'settings-cog',
|
|
203
|
+
'share-01',
|
|
204
|
+
'share-03',
|
|
205
|
+
'share-04',
|
|
206
|
+
'share-05',
|
|
207
|
+
'share-06',
|
|
208
|
+
'share-bold',
|
|
209
|
+
'shield-01',
|
|
210
|
+
'shield-bold',
|
|
211
|
+
'solar-check',
|
|
212
|
+
'speaker',
|
|
213
|
+
'speaker-wave',
|
|
214
|
+
'speedometer-03',
|
|
215
|
+
'star',
|
|
216
|
+
'star-rounded',
|
|
217
|
+
'sun',
|
|
218
|
+
'target-03',
|
|
219
|
+
'text-input',
|
|
220
|
+
'translate',
|
|
221
|
+
'trash',
|
|
222
|
+
'trash-02',
|
|
223
|
+
'trash-03',
|
|
224
|
+
'trash-04',
|
|
225
|
+
'trush-square-bold',
|
|
226
|
+
'unlimited',
|
|
227
|
+
'user-circle',
|
|
228
|
+
'user-jogging',
|
|
229
|
+
'user-plus-01',
|
|
230
|
+
'user-square',
|
|
231
|
+
'user-x-01',
|
|
232
|
+
'user-x-02',
|
|
233
|
+
'user2',
|
|
234
|
+
'users-02',
|
|
235
|
+
'users-speaker',
|
|
236
|
+
'verify',
|
|
237
|
+
'voice-cricle',
|
|
238
|
+
'x-circle',
|
|
239
|
+
'x-close',
|
|
240
|
+
'x-sm',
|
|
241
|
+
'zap',
|
|
242
|
+
] as const;
|
|
243
|
+
|
|
244
|
+
export type IconsType = (typeof Icons)[number];
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export type Theme = 'light' | 'dark';
|
|
2
2
|
|
|
3
|
-
export interface AppConfig {
|
|
4
|
-
localication: Localication;
|
|
5
|
-
baseSize: { width: number; height: number };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
export type LocalizationKey =
|
|
9
4
|
// paywall – period
|
|
10
5
|
| 'base.builder.paywall.period.monthly'
|
|
@@ -159,7 +154,8 @@ export function mergeLocalization(
|
|
|
159
154
|
|
|
160
155
|
export const defaultTheme: Theme = 'light';
|
|
161
156
|
|
|
162
|
-
export
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
export type BaseSize = { width: number; height: number };
|
|
158
|
+
|
|
159
|
+
export const defaultBaseSize: BaseSize = { width: 375, height: 812 };
|
|
160
|
+
|
|
161
|
+
export const defaultLanguage = 'en';
|
package/src/types/Project.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node } from '../types/Node';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseSize, Localication } from './PreviewConfig';
|
|
3
3
|
|
|
4
4
|
export type ProjectColorTokenMap = Record<string, string>;
|
|
5
5
|
|
|
@@ -23,7 +23,8 @@ export interface ProjectBase<T> {
|
|
|
23
23
|
*/
|
|
24
24
|
type?: 'paywall' | 'onboard' | 'other';
|
|
25
25
|
data: T;
|
|
26
|
-
|
|
26
|
+
baseSize?: BaseSize;
|
|
27
|
+
localization?: Localication;
|
|
27
28
|
projectColors?: ProjectColors;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -32,7 +33,7 @@ export interface Project extends ProjectBase<Node> {}
|
|
|
32
33
|
/**
|
|
33
34
|
* Lightweight subset of Project containing only the essential metadata
|
|
34
35
|
* needed for persistence (name, version, type, data).
|
|
35
|
-
* Excludes runtime/editor-only fields like
|
|
36
|
+
* Excludes runtime/editor-only fields like projectColors.
|
|
36
37
|
*/
|
|
37
38
|
export type ProjectMeta = Pick<Project, 'name' | 'version' | 'type' | 'data'>;
|
|
38
39
|
|
|
@@ -23,7 +23,9 @@ export function extractImageStyle<T extends ImagePropsGenerated['attributes']>(
|
|
|
23
23
|
const stylesBag = getStyleBag(attributes) as
|
|
24
24
|
| ImagePropsGenerated['attributes']['style']
|
|
25
25
|
| undefined;
|
|
26
|
-
const resizeMode: ResizeModeOptionType | undefined =
|
|
26
|
+
const resizeMode: ResizeModeOptionType | undefined =
|
|
27
|
+
stylesBag?.resizeMode ?? (attributes as any).resizeMode;
|
|
28
|
+
|
|
27
29
|
if (resizeMode === 'cover') style.objectFit = 'cover';
|
|
28
30
|
else if (resizeMode === 'contain') style.objectFit = 'contain';
|
|
29
31
|
else if (resizeMode === 'stretch') style.objectFit = 'fill';
|
|
@@ -43,7 +45,7 @@ export function extractImageStyleNative<
|
|
|
43
45
|
| ImagePropsGenerated['attributes']['style']
|
|
44
46
|
| undefined;
|
|
45
47
|
const resizeMode: ResizeModeOptionType | undefined =
|
|
46
|
-
nativeStylesBag?.resizeMode;
|
|
48
|
+
nativeStylesBag?.resizeMode ?? (attributes as any).resizeMode;
|
|
47
49
|
|
|
48
50
|
// In RN, resizeMode is usually an Image prop, but many codebases also accept it on ImageStyle.
|
|
49
51
|
// We return it here so consumers can pass it through as they prefer.
|
|
@@ -7,6 +7,7 @@ import type { Theme } from '../../types/PreviewConfig';
|
|
|
7
7
|
import { defaultTheme } from '../../types/PreviewConfig';
|
|
8
8
|
import type { ProjectColors } from '../../types/Project';
|
|
9
9
|
import type { Fonts } from '../../types/Fonts';
|
|
10
|
+
import type { BaseSize } from '../../types/PreviewConfig';
|
|
10
11
|
import { fs, parseSize } from '../../size-matters';
|
|
11
12
|
import { parseColor } from '../parseColor';
|
|
12
13
|
import { extractViewStyle } from '../extractViewStyle';
|
|
@@ -19,6 +20,8 @@ import {
|
|
|
19
20
|
import { fontsDebug } from '../fontsDebug';
|
|
20
21
|
import { getStyleBag, toAttributeRecord } from '../attributeStyle';
|
|
21
22
|
|
|
23
|
+
// ... imports
|
|
24
|
+
|
|
22
25
|
const inFlightFontLoads: Map<string, Promise<void>> = new Map<
|
|
23
26
|
string,
|
|
24
27
|
Promise<void>
|
|
@@ -91,6 +94,7 @@ export type ExtractTextStyleOptions = {
|
|
|
91
94
|
onFontLoaded?: (fontFamily: string) => void;
|
|
92
95
|
onError?: (error: string) => void;
|
|
93
96
|
directlyTextStyle?: boolean;
|
|
97
|
+
baseSize?: BaseSize;
|
|
94
98
|
};
|
|
95
99
|
|
|
96
100
|
export function extractTextStyle<T extends TextPropsGenerated['attributes']>(
|
|
@@ -123,7 +127,7 @@ export function extractTextStyle<T extends TextPropsGenerated['attributes']>(
|
|
|
123
127
|
// Typography
|
|
124
128
|
const fontSize = get('fontSize') as string | number | undefined;
|
|
125
129
|
if (fontSize !== undefined) {
|
|
126
|
-
const parsed = parseSize(fontSize);
|
|
130
|
+
const parsed = parseSize(fontSize, options.baseSize);
|
|
127
131
|
style.fontSize = parsed as React.CSSProperties['fontSize'];
|
|
128
132
|
} else {
|
|
129
133
|
style.fontSize = fs(14);
|
|
@@ -189,6 +193,7 @@ export function extractTextStyle<T extends TextPropsGenerated['attributes']>(
|
|
|
189
193
|
const viewStyle = extractViewStyle(node, {
|
|
190
194
|
projectColors: options.projectColors,
|
|
191
195
|
theme,
|
|
196
|
+
baseSize: options.baseSize,
|
|
192
197
|
});
|
|
193
198
|
const fullStyle = { ...viewStyle, ...style };
|
|
194
199
|
|
|
@@ -4,6 +4,7 @@ import type { Theme } from '../../types/PreviewConfig';
|
|
|
4
4
|
import { defaultTheme } from '../../types/PreviewConfig';
|
|
5
5
|
import type { ProjectColors } from '../../types/Project';
|
|
6
6
|
import type { Fonts } from '../../types/Fonts';
|
|
7
|
+
import type { BaseSize } from '../../types/PreviewConfig';
|
|
7
8
|
import { fs, parseSize } from '../../size-matters';
|
|
8
9
|
import { parseColor } from '../parseColor';
|
|
9
10
|
import { extractViewStyleNative } from '../extractViewStyle';
|
|
@@ -18,6 +19,7 @@ export type ExtractTextStyleNativeOptions = {
|
|
|
18
19
|
theme?: Theme;
|
|
19
20
|
projectColors?: ProjectColors;
|
|
20
21
|
fonts?: Fonts;
|
|
22
|
+
baseSize?: BaseSize;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
function weightToNumericKey(weight: unknown): string | undefined {
|
|
@@ -61,7 +63,7 @@ export function extractTextStyleNative<
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const rawFontSize = get('fontSize') as string | number | undefined;
|
|
64
|
-
const parsedFontSize = parseSize(rawFontSize);
|
|
66
|
+
const parsedFontSize = parseSize(rawFontSize, options.baseSize);
|
|
65
67
|
if (typeof parsedFontSize === 'number') style.fontSize = parsedFontSize;
|
|
66
68
|
else style.fontSize = fs(14);
|
|
67
69
|
|
|
@@ -103,6 +105,7 @@ export function extractTextStyleNative<
|
|
|
103
105
|
const viewStyle = extractViewStyleNative(node, {
|
|
104
106
|
projectColors: options.projectColors,
|
|
105
107
|
theme,
|
|
108
|
+
baseSize: options.baseSize,
|
|
106
109
|
});
|
|
107
110
|
return { ...viewStyle, ...style };
|
|
108
111
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '../../build-components/View/ViewProps.generated';
|
|
5
5
|
import type { NodeData } from '../../types/Node';
|
|
6
6
|
import type { ProjectColors } from '../../types/Project';
|
|
7
|
+
import type { BaseSize } from '../../types/PreviewConfig';
|
|
7
8
|
import { parseSize } from '../../size-matters';
|
|
8
9
|
import { parseColor } from '../parseColor';
|
|
9
10
|
import { getStyleBag, toAttributeRecord } from '../attributeStyle';
|
|
@@ -11,6 +12,7 @@ import { getStyleBag, toAttributeRecord } from '../attributeStyle';
|
|
|
11
12
|
export type ExtractViewStyleOptions = {
|
|
12
13
|
projectColors?: ProjectColors;
|
|
13
14
|
theme?: string;
|
|
15
|
+
baseSize?: BaseSize;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
@@ -72,7 +74,7 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
72
74
|
rawValue: string | number | undefined,
|
|
73
75
|
) => {
|
|
74
76
|
if (isEmptySizeValue(rawValue)) return;
|
|
75
|
-
const parsed = parseSize(rawValue);
|
|
77
|
+
const parsed = parseSize(rawValue, options.baseSize);
|
|
76
78
|
style[property] = parsed as React.CSSProperties[K];
|
|
77
79
|
};
|
|
78
80
|
|
|
@@ -85,13 +87,13 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
85
87
|
| number
|
|
86
88
|
| undefined;
|
|
87
89
|
if (!isEmptySizeValue(paddingHorizontal)) {
|
|
88
|
-
const parsed = parseSize(paddingHorizontal);
|
|
90
|
+
const parsed = parseSize(paddingHorizontal, options.baseSize);
|
|
89
91
|
style.paddingLeft = parsed as React.CSSProperties['paddingLeft'];
|
|
90
92
|
style.paddingRight = parsed as React.CSSProperties['paddingRight'];
|
|
91
93
|
}
|
|
92
94
|
const paddingVertical = get('paddingVertical') as string | number | undefined;
|
|
93
95
|
if (!isEmptySizeValue(paddingVertical)) {
|
|
94
|
-
const parsed = parseSize(paddingVertical);
|
|
96
|
+
const parsed = parseSize(paddingVertical, options.baseSize);
|
|
95
97
|
style.paddingTop = parsed as React.CSSProperties['paddingTop'];
|
|
96
98
|
style.paddingBottom = parsed as React.CSSProperties['paddingBottom'];
|
|
97
99
|
}
|
|
@@ -115,14 +117,14 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
115
117
|
(attrRecord.marginHorizontal as string | number | undefined) ??
|
|
116
118
|
(styleBag?.marginHorizontal as string | number | undefined);
|
|
117
119
|
if (!isEmptySizeValue(marginHorizontalRaw)) {
|
|
118
|
-
const parsed = parseSize(marginHorizontalRaw);
|
|
120
|
+
const parsed = parseSize(marginHorizontalRaw, options.baseSize);
|
|
119
121
|
style.marginLeft = parsed as React.CSSProperties['marginLeft'];
|
|
120
122
|
style.marginRight = parsed as React.CSSProperties['marginRight'];
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
const marginVertical = get('marginVertical') as string | number | undefined;
|
|
124
126
|
if (!isEmptySizeValue(marginVertical)) {
|
|
125
|
-
const parsed = parseSize(marginVertical);
|
|
127
|
+
const parsed = parseSize(marginVertical, options.baseSize);
|
|
126
128
|
style.marginTop = parsed as React.CSSProperties['marginTop'];
|
|
127
129
|
style.marginBottom = parsed as React.CSSProperties['marginBottom'];
|
|
128
130
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ViewPropsGenerated } from '../../build-components/View/ViewProps.generated';
|
|
2
2
|
import type { NodeData } from '../../types/Node';
|
|
3
3
|
import type { ProjectColors } from '../../types/Project';
|
|
4
|
+
import type { BaseSize } from '../../types/PreviewConfig';
|
|
4
5
|
import { parseSize } from '../../size-matters';
|
|
5
6
|
import { parseColor } from '../parseColor';
|
|
6
7
|
import { getStyleBag, toAttributeRecord } from '../attributeStyle';
|
|
@@ -8,6 +9,7 @@ import { getStyleBag, toAttributeRecord } from '../attributeStyle';
|
|
|
8
9
|
export type ExtractViewStyleNativeOptions = {
|
|
9
10
|
projectColors?: ProjectColors;
|
|
10
11
|
theme?: string;
|
|
12
|
+
baseSize?: BaseSize;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -49,7 +51,7 @@ export function extractViewStyleNative<
|
|
|
49
51
|
|
|
50
52
|
const setParsedSize = (property: string, rawValue: unknown) => {
|
|
51
53
|
if (isEmptySizeValue(rawValue)) return;
|
|
52
|
-
const parsed = parseSize(rawValue as string | number);
|
|
54
|
+
const parsed = parseSize(rawValue as string | number, options.baseSize);
|
|
53
55
|
// RN generally expects numbers (dp). We allow percentages for width/height-like props.
|
|
54
56
|
if (typeof parsed === 'number' || typeof parsed === 'string') {
|
|
55
57
|
style[property] = parsed;
|