fluent-styles 1.62.11 → 1.62.13
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/lib/commonjs/page/index.js +1 -1
- package/lib/commonjs/page/index.js.map +1 -1
- package/lib/commonjs/utiles/viewStyleVariants.js +139 -80
- package/lib/commonjs/utiles/viewStyleVariants.js.map +1 -1
- package/lib/module/page/index.js +1 -1
- package/lib/module/page/index.js.map +1 -1
- package/lib/module/utiles/viewStyleVariants.js +139 -80
- package/lib/module/utiles/viewStyleVariants.js.map +1 -1
- package/lib/typescript/divider/index.d.ts +0 -1
- package/lib/typescript/divider/index.d.ts.map +1 -1
- package/lib/typescript/portal/PortalContext.d.ts +0 -1
- package/lib/typescript/portal/PortalContext.d.ts.map +1 -1
- package/lib/typescript/pressable/index.d.ts +0 -1
- package/lib/typescript/pressable/index.d.ts.map +1 -1
- package/lib/typescript/safeAreaProvider/index.d.ts +0 -1
- package/lib/typescript/safeAreaProvider/index.d.ts.map +1 -1
- package/lib/typescript/safeAreaView/index.d.ts +0 -1
- package/lib/typescript/safeAreaView/index.d.ts.map +1 -1
- package/lib/typescript/scrollView/index.d.ts +0 -1
- package/lib/typescript/scrollView/index.d.ts.map +1 -1
- package/lib/typescript/shape/index.d.ts +0 -1
- package/lib/typescript/shape/index.d.ts.map +1 -1
- package/lib/typescript/spacer/index.d.ts +0 -1
- package/lib/typescript/spacer/index.d.ts.map +1 -1
- package/lib/typescript/stack/index.d.ts +0 -1
- package/lib/typescript/stack/index.d.ts.map +1 -1
- package/lib/typescript/text/index.d.ts +0 -1
- package/lib/typescript/text/index.d.ts.map +1 -1
- package/lib/typescript/utiles/viewStyleVariants.d.ts +61 -55
- package/lib/typescript/utiles/viewStyleVariants.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/page/index.tsx +1 -1
- package/src/utiles/viewStyleVariants.ts +225 -186
|
@@ -1,295 +1,334 @@
|
|
|
1
1
|
import { ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A raw variant value as it arrives from a prop. Numeric props (e.g. `width={100}`)
|
|
5
|
+
* come through as `number`, string props (e.g. `width="100%"`) come through as `string`.
|
|
6
|
+
*/
|
|
7
|
+
type RawValue = string | number | null | undefined;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parses a raw prop value into a React Native `DimensionValue` (`number | \`${number}%\``).
|
|
11
|
+
*
|
|
12
|
+
* `parseFloat` alone silently discards any trailing unit (e.g. `parseFloat('100%') === 100`),
|
|
13
|
+
* which turns a percentage into a plain pixel value. This keeps the `%` suffix intact when
|
|
14
|
+
* present, and otherwise numerically parses the value (so `"16px"`, `"16dp"`, `16`, `"16"`
|
|
15
|
+
* all resolve to the number `16`, matching the previous behaviour for non-percentage units).
|
|
16
|
+
*/
|
|
17
|
+
const parseDimension = (
|
|
18
|
+
selected: RawValue,
|
|
19
|
+
{ min, max }: { min?: number; max?: number } = {}
|
|
20
|
+
): number | `${number}%` | undefined => {
|
|
21
|
+
if (selected === null || selected === undefined) return undefined;
|
|
22
|
+
|
|
23
|
+
if (typeof selected === 'number') {
|
|
24
|
+
if (isNaN(selected)) return undefined;
|
|
25
|
+
if (min !== undefined && selected < min) return undefined;
|
|
26
|
+
if (max !== undefined && selected > max) return undefined;
|
|
27
|
+
return selected;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const trimmed = selected.trim();
|
|
31
|
+
if (trimmed === '') return undefined;
|
|
32
|
+
|
|
33
|
+
const isPercent = trimmed.endsWith('%');
|
|
34
|
+
const numeric = parseFloat(trimmed);
|
|
35
|
+
if (isNaN(numeric)) return undefined;
|
|
36
|
+
if (min !== undefined && numeric < min) return undefined;
|
|
37
|
+
if (max !== undefined && numeric > max) return undefined;
|
|
38
|
+
|
|
39
|
+
return isPercent ? (`${numeric}%` as `${number}%`) : numeric;
|
|
40
|
+
};
|
|
41
|
+
|
|
3
42
|
export const viewStyleVariants = {
|
|
4
43
|
|
|
5
|
-
width: (selected:
|
|
6
|
-
const value =
|
|
7
|
-
if (
|
|
44
|
+
width: (selected: RawValue) => {
|
|
45
|
+
const value = parseDimension(selected, { min: 0 });
|
|
46
|
+
if (value === undefined) return {};
|
|
8
47
|
return { width: value } as ViewStyle;
|
|
9
48
|
},
|
|
10
|
-
|
|
11
|
-
height: (selected:
|
|
12
|
-
const value =
|
|
13
|
-
if (
|
|
49
|
+
|
|
50
|
+
height: (selected: RawValue) => {
|
|
51
|
+
const value = parseDimension(selected, { min: 0 });
|
|
52
|
+
if (value === undefined) return {};
|
|
14
53
|
return { height: value } as ViewStyle;
|
|
15
54
|
},
|
|
16
|
-
|
|
17
|
-
minWidth: (selected:
|
|
18
|
-
const value =
|
|
19
|
-
if (
|
|
55
|
+
|
|
56
|
+
minWidth: (selected: RawValue) => {
|
|
57
|
+
const value = parseDimension(selected, { min: 0 });
|
|
58
|
+
if (value === undefined) return {};
|
|
20
59
|
return { minWidth: value } as ViewStyle;
|
|
21
60
|
},
|
|
22
|
-
|
|
23
|
-
maxWidth: (selected:
|
|
24
|
-
const value =
|
|
25
|
-
if (
|
|
61
|
+
|
|
62
|
+
maxWidth: (selected: RawValue) => {
|
|
63
|
+
const value = parseDimension(selected, { min: 0 });
|
|
64
|
+
if (value === undefined) return {};
|
|
26
65
|
return { maxWidth: value } as ViewStyle;
|
|
27
66
|
},
|
|
28
|
-
|
|
29
|
-
minHeight: (selected:
|
|
30
|
-
const value =
|
|
31
|
-
if (
|
|
67
|
+
|
|
68
|
+
minHeight: (selected: RawValue) => {
|
|
69
|
+
const value = parseDimension(selected, { min: 0 });
|
|
70
|
+
if (value === undefined) return {};
|
|
32
71
|
return { minHeight: value } as ViewStyle;
|
|
33
72
|
},
|
|
34
|
-
|
|
35
|
-
maxHeight: (selected:
|
|
36
|
-
const value =
|
|
37
|
-
if (
|
|
73
|
+
|
|
74
|
+
maxHeight: (selected: RawValue) => {
|
|
75
|
+
const value = parseDimension(selected, { min: 0 });
|
|
76
|
+
if (value === undefined) return {};
|
|
38
77
|
return { maxHeight: value } as ViewStyle;
|
|
39
78
|
},
|
|
40
79
|
|
|
41
80
|
// Position Properties
|
|
42
|
-
top: (selected:
|
|
43
|
-
const value =
|
|
44
|
-
if (
|
|
81
|
+
top: (selected: RawValue) => {
|
|
82
|
+
const value = parseDimension(selected);
|
|
83
|
+
if (value === undefined) return {};
|
|
45
84
|
return { top: value } as ViewStyle;
|
|
46
85
|
},
|
|
47
|
-
|
|
48
|
-
bottom: (selected:
|
|
49
|
-
const value =
|
|
50
|
-
if (
|
|
86
|
+
|
|
87
|
+
bottom: (selected: RawValue) => {
|
|
88
|
+
const value = parseDimension(selected);
|
|
89
|
+
if (value === undefined) return {};
|
|
51
90
|
return { bottom: value } as ViewStyle;
|
|
52
91
|
},
|
|
53
|
-
|
|
54
|
-
left: (selected:
|
|
55
|
-
const value =
|
|
56
|
-
if (
|
|
92
|
+
|
|
93
|
+
left: (selected: RawValue) => {
|
|
94
|
+
const value = parseDimension(selected);
|
|
95
|
+
if (value === undefined) return {};
|
|
57
96
|
return { left: value } as ViewStyle;
|
|
58
97
|
},
|
|
59
|
-
|
|
60
|
-
right: (selected:
|
|
61
|
-
const value =
|
|
62
|
-
if (
|
|
98
|
+
|
|
99
|
+
right: (selected: RawValue) => {
|
|
100
|
+
const value = parseDimension(selected);
|
|
101
|
+
if (value === undefined) return {};
|
|
63
102
|
return { right: value } as ViewStyle;
|
|
64
103
|
},
|
|
65
104
|
|
|
66
105
|
// Margin Properties
|
|
67
|
-
margin: (selected:
|
|
68
|
-
const value =
|
|
69
|
-
if (
|
|
106
|
+
margin: (selected: RawValue) => {
|
|
107
|
+
const value = parseDimension(selected);
|
|
108
|
+
if (value === undefined) return {};
|
|
70
109
|
return { margin: value } as ViewStyle;
|
|
71
110
|
},
|
|
72
|
-
|
|
73
|
-
marginTop: (selected:
|
|
74
|
-
const value =
|
|
75
|
-
if (
|
|
111
|
+
|
|
112
|
+
marginTop: (selected: RawValue) => {
|
|
113
|
+
const value = parseDimension(selected);
|
|
114
|
+
if (value === undefined) return {};
|
|
76
115
|
return { marginTop: value } as ViewStyle;
|
|
77
116
|
},
|
|
78
|
-
|
|
79
|
-
marginBottom: (selected:
|
|
80
|
-
const value =
|
|
81
|
-
if (
|
|
117
|
+
|
|
118
|
+
marginBottom: (selected: RawValue) => {
|
|
119
|
+
const value = parseDimension(selected);
|
|
120
|
+
if (value === undefined) return {};
|
|
82
121
|
return { marginBottom: value } as ViewStyle;
|
|
83
122
|
},
|
|
84
|
-
|
|
85
|
-
marginLeft: (selected:
|
|
86
|
-
const value =
|
|
87
|
-
if (
|
|
123
|
+
|
|
124
|
+
marginLeft: (selected: RawValue) => {
|
|
125
|
+
const value = parseDimension(selected);
|
|
126
|
+
if (value === undefined) return {};
|
|
88
127
|
return { marginLeft: value } as ViewStyle;
|
|
89
128
|
},
|
|
90
|
-
|
|
91
|
-
marginRight: (selected:
|
|
92
|
-
const value =
|
|
93
|
-
if (
|
|
129
|
+
|
|
130
|
+
marginRight: (selected: RawValue) => {
|
|
131
|
+
const value = parseDimension(selected);
|
|
132
|
+
if (value === undefined) return {};
|
|
94
133
|
return { marginRight: value } as ViewStyle;
|
|
95
134
|
},
|
|
96
|
-
|
|
97
|
-
marginHorizontal: (selected:
|
|
98
|
-
const value =
|
|
99
|
-
if (
|
|
135
|
+
|
|
136
|
+
marginHorizontal: (selected: RawValue) => {
|
|
137
|
+
const value = parseDimension(selected);
|
|
138
|
+
if (value === undefined) return {};
|
|
100
139
|
return { marginHorizontal: value } as ViewStyle;
|
|
101
140
|
},
|
|
102
|
-
|
|
103
|
-
marginVertical: (selected:
|
|
104
|
-
const value =
|
|
105
|
-
if (
|
|
141
|
+
|
|
142
|
+
marginVertical: (selected: RawValue) => {
|
|
143
|
+
const value = parseDimension(selected);
|
|
144
|
+
if (value === undefined) return {};
|
|
106
145
|
return { marginVertical: value } as ViewStyle;
|
|
107
146
|
},
|
|
108
147
|
|
|
109
148
|
// Padding Properties
|
|
110
|
-
padding: (selected:
|
|
111
|
-
const value =
|
|
112
|
-
if (
|
|
149
|
+
padding: (selected: RawValue) => {
|
|
150
|
+
const value = parseDimension(selected, { min: 0 });
|
|
151
|
+
if (value === undefined) return {};
|
|
113
152
|
return { padding: value } as ViewStyle;
|
|
114
153
|
},
|
|
115
|
-
|
|
116
|
-
paddingTop: (selected:
|
|
117
|
-
const value =
|
|
118
|
-
if (
|
|
154
|
+
|
|
155
|
+
paddingTop: (selected: RawValue) => {
|
|
156
|
+
const value = parseDimension(selected, { min: 0 });
|
|
157
|
+
if (value === undefined) return {};
|
|
119
158
|
return { paddingTop: value } as ViewStyle;
|
|
120
159
|
},
|
|
121
|
-
|
|
122
|
-
paddingBottom: (selected:
|
|
123
|
-
const value =
|
|
124
|
-
if (
|
|
160
|
+
|
|
161
|
+
paddingBottom: (selected: RawValue) => {
|
|
162
|
+
const value = parseDimension(selected, { min: 0 });
|
|
163
|
+
if (value === undefined) return {};
|
|
125
164
|
return { paddingBottom: value } as ViewStyle;
|
|
126
165
|
},
|
|
127
|
-
|
|
128
|
-
paddingLeft: (selected:
|
|
129
|
-
const value =
|
|
130
|
-
if (
|
|
166
|
+
|
|
167
|
+
paddingLeft: (selected: RawValue) => {
|
|
168
|
+
const value = parseDimension(selected, { min: 0 });
|
|
169
|
+
if (value === undefined) return {};
|
|
131
170
|
return { paddingLeft: value } as ViewStyle;
|
|
132
171
|
},
|
|
133
|
-
|
|
134
|
-
paddingRight: (selected:
|
|
135
|
-
const value =
|
|
136
|
-
if (
|
|
172
|
+
|
|
173
|
+
paddingRight: (selected: RawValue) => {
|
|
174
|
+
const value = parseDimension(selected, { min: 0 });
|
|
175
|
+
if (value === undefined) return {};
|
|
137
176
|
return { paddingRight: value } as ViewStyle;
|
|
138
177
|
},
|
|
139
|
-
|
|
140
|
-
paddingHorizontal: (selected:
|
|
141
|
-
const value =
|
|
142
|
-
if (
|
|
178
|
+
|
|
179
|
+
paddingHorizontal: (selected: RawValue) => {
|
|
180
|
+
const value = parseDimension(selected, { min: 0 });
|
|
181
|
+
if (value === undefined) return {};
|
|
143
182
|
return { paddingHorizontal: value } as ViewStyle;
|
|
144
183
|
},
|
|
145
|
-
|
|
146
|
-
paddingVertical: (selected:
|
|
147
|
-
const value =
|
|
148
|
-
if (
|
|
184
|
+
|
|
185
|
+
paddingVertical: (selected: RawValue) => {
|
|
186
|
+
const value = parseDimension(selected, { min: 0 });
|
|
187
|
+
if (value === undefined) return {};
|
|
149
188
|
return { paddingVertical: value } as ViewStyle;
|
|
150
189
|
},
|
|
151
190
|
|
|
152
191
|
// Border Properties
|
|
153
|
-
borderWidth: (selected:
|
|
154
|
-
const value = parseFloat(selected);
|
|
192
|
+
borderWidth: (selected: RawValue) => {
|
|
193
|
+
const value = parseFloat(String(selected));
|
|
155
194
|
if (isNaN(value) || value < 0) return {};
|
|
156
195
|
return { borderWidth: value } as ViewStyle;
|
|
157
196
|
},
|
|
158
|
-
|
|
159
|
-
borderTopWidth: (selected:
|
|
160
|
-
const value = parseFloat(selected);
|
|
197
|
+
|
|
198
|
+
borderTopWidth: (selected: RawValue) => {
|
|
199
|
+
const value = parseFloat(String(selected));
|
|
161
200
|
if (isNaN(value) || value < 0) return {};
|
|
162
201
|
return { borderTopWidth: value } as ViewStyle;
|
|
163
202
|
},
|
|
164
|
-
|
|
165
|
-
borderBottomWidth: (selected:
|
|
166
|
-
const value = parseFloat(selected);
|
|
203
|
+
|
|
204
|
+
borderBottomWidth: (selected: RawValue) => {
|
|
205
|
+
const value = parseFloat(String(selected));
|
|
167
206
|
if (isNaN(value) || value < 0) return {};
|
|
168
207
|
return { borderBottomWidth: value } as ViewStyle;
|
|
169
208
|
},
|
|
170
|
-
|
|
171
|
-
borderLeftWidth: (selected:
|
|
172
|
-
const value = parseFloat(selected);
|
|
209
|
+
|
|
210
|
+
borderLeftWidth: (selected: RawValue) => {
|
|
211
|
+
const value = parseFloat(String(selected));
|
|
173
212
|
if (isNaN(value) || value < 0) return {};
|
|
174
213
|
return { borderLeftWidth: value } as ViewStyle;
|
|
175
214
|
},
|
|
176
|
-
|
|
177
|
-
borderRightWidth: (selected:
|
|
178
|
-
const value = parseFloat(selected);
|
|
215
|
+
|
|
216
|
+
borderRightWidth: (selected: RawValue) => {
|
|
217
|
+
const value = parseFloat(String(selected));
|
|
179
218
|
if (isNaN(value) || value < 0) return {};
|
|
180
219
|
return { borderRightWidth: value } as ViewStyle;
|
|
181
220
|
},
|
|
182
221
|
|
|
183
222
|
// Border Radius Properties
|
|
184
|
-
borderRadius: (selected:
|
|
185
|
-
const value = parseFloat(selected);
|
|
223
|
+
borderRadius: (selected: RawValue) => {
|
|
224
|
+
const value = parseFloat(String(selected));
|
|
186
225
|
if (isNaN(value) || value < 0) return {};
|
|
187
226
|
return { borderRadius: value } as ViewStyle;
|
|
188
227
|
},
|
|
189
|
-
|
|
190
|
-
borderTopLeftRadius: (selected:
|
|
191
|
-
const value = parseFloat(selected);
|
|
228
|
+
|
|
229
|
+
borderTopLeftRadius: (selected: RawValue) => {
|
|
230
|
+
const value = parseFloat(String(selected));
|
|
192
231
|
if (isNaN(value) || value < 0) return {};
|
|
193
232
|
return { borderTopLeftRadius: value } as ViewStyle;
|
|
194
233
|
},
|
|
195
|
-
|
|
196
|
-
borderTopRightRadius: (selected:
|
|
197
|
-
const value = parseFloat(selected);
|
|
234
|
+
|
|
235
|
+
borderTopRightRadius: (selected: RawValue) => {
|
|
236
|
+
const value = parseFloat(String(selected));
|
|
198
237
|
if (isNaN(value) || value < 0) return {};
|
|
199
238
|
return { borderTopRightRadius: value } as ViewStyle;
|
|
200
239
|
},
|
|
201
|
-
|
|
202
|
-
borderBottomLeftRadius: (selected:
|
|
203
|
-
const value = parseFloat(selected);
|
|
240
|
+
|
|
241
|
+
borderBottomLeftRadius: (selected: RawValue) => {
|
|
242
|
+
const value = parseFloat(String(selected));
|
|
204
243
|
if (isNaN(value) || value < 0) return {};
|
|
205
244
|
return { borderBottomLeftRadius: value } as ViewStyle;
|
|
206
245
|
},
|
|
207
|
-
|
|
208
|
-
borderBottomRightRadius: (selected:
|
|
209
|
-
const value = parseFloat(selected);
|
|
246
|
+
|
|
247
|
+
borderBottomRightRadius: (selected: RawValue) => {
|
|
248
|
+
const value = parseFloat(String(selected));
|
|
210
249
|
if (isNaN(value) || value < 0) return {};
|
|
211
250
|
return { borderBottomRightRadius: value } as ViewStyle;
|
|
212
251
|
},
|
|
213
252
|
|
|
214
253
|
// Border Color Properties (accept color strings)
|
|
215
|
-
borderColor: (selected:
|
|
216
|
-
if (!selected || selected.trim() === '') return {};
|
|
254
|
+
borderColor: (selected: RawValue) => {
|
|
255
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
217
256
|
return { borderColor: selected } as ViewStyle;
|
|
218
257
|
},
|
|
219
|
-
|
|
220
|
-
borderTopColor: (selected:
|
|
221
|
-
if (!selected || selected.trim() === '') return {};
|
|
258
|
+
|
|
259
|
+
borderTopColor: (selected: RawValue) => {
|
|
260
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
222
261
|
return { borderTopColor: selected } as ViewStyle;
|
|
223
262
|
},
|
|
224
|
-
|
|
225
|
-
borderBottomColor: (selected:
|
|
226
|
-
if (!selected || selected.trim() === '') return {};
|
|
263
|
+
|
|
264
|
+
borderBottomColor: (selected: RawValue) => {
|
|
265
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
227
266
|
return { borderBottomColor: selected } as ViewStyle;
|
|
228
267
|
},
|
|
229
|
-
|
|
230
|
-
borderLeftColor: (selected:
|
|
231
|
-
if (!selected || selected.trim() === '') return {};
|
|
268
|
+
|
|
269
|
+
borderLeftColor: (selected: RawValue) => {
|
|
270
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
232
271
|
return { borderLeftColor: selected } as ViewStyle;
|
|
233
272
|
},
|
|
234
|
-
|
|
235
|
-
borderRightColor: (selected:
|
|
236
|
-
if (!selected || selected.trim() === '') return {};
|
|
273
|
+
|
|
274
|
+
borderRightColor: (selected: RawValue) => {
|
|
275
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
237
276
|
return { borderRightColor: selected } as ViewStyle;
|
|
238
277
|
},
|
|
239
278
|
|
|
240
279
|
// Background Properties
|
|
241
|
-
backgroundColor: (selected:
|
|
242
|
-
if (!selected || selected.trim() === '') return {};
|
|
280
|
+
backgroundColor: (selected: RawValue) => {
|
|
281
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
243
282
|
return { backgroundColor: selected } as ViewStyle;
|
|
244
283
|
},
|
|
245
|
-
|
|
246
|
-
opacity: (selected:
|
|
247
|
-
const value = parseFloat(selected);
|
|
284
|
+
|
|
285
|
+
opacity: (selected: RawValue) => {
|
|
286
|
+
const value = parseFloat(String(selected));
|
|
248
287
|
if (isNaN(value) || value < 0 || value > 1) return {};
|
|
249
288
|
return { opacity: value } as ViewStyle;
|
|
250
289
|
},
|
|
251
290
|
|
|
252
291
|
// Transform Properties (simplified - only scale, rotate)
|
|
253
|
-
rotation: (selected:
|
|
254
|
-
const value = parseFloat(selected);
|
|
292
|
+
rotation: (selected: RawValue) => {
|
|
293
|
+
const value = parseFloat(String(selected));
|
|
255
294
|
if (isNaN(value)) return {};
|
|
256
295
|
return { transform: [{ rotate: `${value}deg` }] } as ViewStyle;
|
|
257
296
|
},
|
|
258
|
-
|
|
259
|
-
scale: (selected:
|
|
260
|
-
const value = parseFloat(selected);
|
|
297
|
+
|
|
298
|
+
scale: (selected: RawValue) => {
|
|
299
|
+
const value = parseFloat(String(selected));
|
|
261
300
|
if (isNaN(value) || value < 0) return {};
|
|
262
301
|
return { transform: [{ scale: value }] } as ViewStyle;
|
|
263
302
|
},
|
|
264
303
|
|
|
265
304
|
// Shadow Properties (iOS)
|
|
266
|
-
shadowOpacity: (selected:
|
|
267
|
-
const value = parseFloat(selected);
|
|
305
|
+
shadowOpacity: (selected: RawValue) => {
|
|
306
|
+
const value = parseFloat(String(selected));
|
|
268
307
|
if (isNaN(value) || value < 0 || value > 1) return {};
|
|
269
308
|
return { shadowOpacity: value } as ViewStyle;
|
|
270
309
|
},
|
|
271
|
-
|
|
272
|
-
shadowRadius: (selected:
|
|
273
|
-
const value = parseFloat(selected);
|
|
310
|
+
|
|
311
|
+
shadowRadius: (selected: RawValue) => {
|
|
312
|
+
const value = parseFloat(String(selected));
|
|
274
313
|
if (isNaN(value) || value < 0) return {};
|
|
275
314
|
return { shadowRadius: value } as ViewStyle;
|
|
276
315
|
},
|
|
277
|
-
|
|
278
|
-
shadowColor: (selected:
|
|
279
|
-
if (!selected || selected.trim() === '') return {};
|
|
316
|
+
|
|
317
|
+
shadowColor: (selected: RawValue) => {
|
|
318
|
+
if (!selected || String(selected).trim() === '') return {};
|
|
280
319
|
return { shadowColor: selected } as ViewStyle;
|
|
281
320
|
},
|
|
282
321
|
|
|
283
322
|
// Elevation (Android)
|
|
284
|
-
elevation: (selected:
|
|
285
|
-
const value = parseFloat(selected);
|
|
323
|
+
elevation: (selected: RawValue) => {
|
|
324
|
+
const value = parseFloat(String(selected));
|
|
286
325
|
if (isNaN(value) || value < 0) return {};
|
|
287
326
|
return { elevation: value } as ViewStyle;
|
|
288
327
|
},
|
|
289
328
|
|
|
290
329
|
// Z-Index
|
|
291
|
-
zIndex: (selected:
|
|
292
|
-
const value = parseInt(selected, 10);
|
|
330
|
+
zIndex: (selected: RawValue) => {
|
|
331
|
+
const value = parseInt(String(selected), 10);
|
|
293
332
|
if (isNaN(value)) return {};
|
|
294
333
|
return { zIndex: value } as ViewStyle;
|
|
295
334
|
},
|
|
@@ -300,14 +339,14 @@ export const viewStyleStringVariants = {
|
|
|
300
339
|
absolute: { position: 'absolute' } as ViewStyle,
|
|
301
340
|
relative: { position: 'relative' } as ViewStyle,
|
|
302
341
|
},
|
|
303
|
-
|
|
342
|
+
|
|
304
343
|
flexDirection: {
|
|
305
344
|
row: { flexDirection: 'row' } as ViewStyle,
|
|
306
345
|
column: { flexDirection: 'column' } as ViewStyle,
|
|
307
346
|
'row-reverse': { flexDirection: 'row-reverse' } as ViewStyle,
|
|
308
347
|
'column-reverse': { flexDirection: 'column-reverse' } as ViewStyle,
|
|
309
348
|
},
|
|
310
|
-
|
|
349
|
+
|
|
311
350
|
justifyContent: {
|
|
312
351
|
'flex-start': { justifyContent: 'flex-start' } as ViewStyle,
|
|
313
352
|
'flex-end': { justifyContent: 'flex-end' } as ViewStyle,
|
|
@@ -316,7 +355,7 @@ export const viewStyleStringVariants = {
|
|
|
316
355
|
'space-around': { justifyContent: 'space-around' } as ViewStyle,
|
|
317
356
|
'space-evenly': { justifyContent: 'space-evenly' } as ViewStyle,
|
|
318
357
|
},
|
|
319
|
-
|
|
358
|
+
|
|
320
359
|
alignItems: {
|
|
321
360
|
'flex-start': { alignItems: 'flex-start' } as ViewStyle,
|
|
322
361
|
'flex-end': { alignItems: 'flex-end' } as ViewStyle,
|
|
@@ -324,7 +363,7 @@ export const viewStyleStringVariants = {
|
|
|
324
363
|
stretch: { alignItems: 'stretch' } as ViewStyle,
|
|
325
364
|
baseline: { alignItems: 'baseline' } as ViewStyle,
|
|
326
365
|
},
|
|
327
|
-
|
|
366
|
+
|
|
328
367
|
alignSelf: {
|
|
329
368
|
auto: { alignSelf: 'auto' } as ViewStyle,
|
|
330
369
|
'flex-start': { alignSelf: 'flex-start' } as ViewStyle,
|
|
@@ -333,7 +372,7 @@ export const viewStyleStringVariants = {
|
|
|
333
372
|
stretch: { alignSelf: 'stretch' } as ViewStyle,
|
|
334
373
|
baseline: { alignSelf: 'baseline' } as ViewStyle,
|
|
335
374
|
},
|
|
336
|
-
|
|
375
|
+
|
|
337
376
|
alignContent: {
|
|
338
377
|
'flex-start': { alignContent: 'flex-start' } as ViewStyle,
|
|
339
378
|
'flex-end': { alignContent: 'flex-end' } as ViewStyle,
|
|
@@ -342,70 +381,70 @@ export const viewStyleStringVariants = {
|
|
|
342
381
|
'space-between': { alignContent: 'space-between' } as ViewStyle,
|
|
343
382
|
'space-around': { alignContent: 'space-around' } as ViewStyle,
|
|
344
383
|
},
|
|
345
|
-
|
|
384
|
+
|
|
346
385
|
flexWrap: {
|
|
347
386
|
wrap: { flexWrap: 'wrap' } as ViewStyle,
|
|
348
387
|
nowrap: { flexWrap: 'nowrap' } as ViewStyle,
|
|
349
388
|
'wrap-reverse': { flexWrap: 'wrap-reverse' } as ViewStyle,
|
|
350
389
|
},
|
|
351
|
-
|
|
390
|
+
|
|
352
391
|
overflow: {
|
|
353
392
|
visible: { overflow: 'visible' } as ViewStyle,
|
|
354
393
|
hidden: { overflow: 'hidden' } as ViewStyle,
|
|
355
394
|
scroll: { overflow: 'scroll' } as ViewStyle,
|
|
356
395
|
},
|
|
357
|
-
|
|
396
|
+
|
|
358
397
|
display: {
|
|
359
398
|
flex: { display: 'flex' } as ViewStyle,
|
|
360
399
|
none: { display: 'none' } as ViewStyle,
|
|
361
400
|
},
|
|
362
|
-
|
|
401
|
+
|
|
363
402
|
borderStyle: {
|
|
364
403
|
solid: { borderStyle: 'solid' } as ViewStyle,
|
|
365
404
|
dotted: { borderStyle: 'dotted' } as ViewStyle,
|
|
366
405
|
dashed: { borderStyle: 'dashed' } as ViewStyle,
|
|
367
406
|
},
|
|
368
407
|
// Flexbox Properties
|
|
369
|
-
flex: (selected:
|
|
370
|
-
const value = parseFloat(selected);
|
|
408
|
+
flex: (selected: RawValue) => {
|
|
409
|
+
const value = parseFloat(String(selected));
|
|
371
410
|
if (isNaN(value) || value < 0) return {};
|
|
372
411
|
return { flex: value } as ViewStyle;
|
|
373
412
|
},
|
|
374
|
-
|
|
375
|
-
flexBasis: (selected:
|
|
376
|
-
const value =
|
|
377
|
-
if (
|
|
413
|
+
|
|
414
|
+
flexBasis: (selected: RawValue) => {
|
|
415
|
+
const value = parseDimension(selected);
|
|
416
|
+
if (value === undefined) return {};
|
|
378
417
|
return { flexBasis: value } as ViewStyle;
|
|
379
418
|
},
|
|
380
|
-
|
|
381
|
-
flexGrow: (selected:
|
|
382
|
-
const value = parseFloat(selected);
|
|
419
|
+
|
|
420
|
+
flexGrow: (selected: RawValue) => {
|
|
421
|
+
const value = parseFloat(String(selected));
|
|
383
422
|
if (isNaN(value) || value < 0) return {};
|
|
384
423
|
return { flexGrow: value } as ViewStyle;
|
|
385
424
|
},
|
|
386
|
-
|
|
387
|
-
flexShrink: (selected:
|
|
388
|
-
const value = parseFloat(selected);
|
|
425
|
+
|
|
426
|
+
flexShrink: (selected: RawValue) => {
|
|
427
|
+
const value = parseFloat(String(selected));
|
|
389
428
|
if (isNaN(value) || value < 0) return {};
|
|
390
429
|
return { flexShrink: value } as ViewStyle;
|
|
391
430
|
},
|
|
392
431
|
|
|
393
432
|
// Gap Properties (for newer React Native versions)
|
|
394
|
-
gap: (selected:
|
|
395
|
-
const value = parseFloat(selected);
|
|
433
|
+
gap: (selected: RawValue) => {
|
|
434
|
+
const value = parseFloat(String(selected));
|
|
396
435
|
if (isNaN(value) || value < 0) return {};
|
|
397
436
|
return { gap: value } as ViewStyle;
|
|
398
437
|
},
|
|
399
|
-
|
|
400
|
-
columnGap: (selected:
|
|
401
|
-
const value = parseFloat(selected);
|
|
438
|
+
|
|
439
|
+
columnGap: (selected: RawValue) => {
|
|
440
|
+
const value = parseFloat(String(selected));
|
|
402
441
|
if (isNaN(value) || value < 0) return {};
|
|
403
442
|
return { columnGap: value } as ViewStyle;
|
|
404
443
|
},
|
|
405
|
-
|
|
406
|
-
rowGap: (selected:
|
|
407
|
-
const value = parseFloat(selected);
|
|
444
|
+
|
|
445
|
+
rowGap: (selected: RawValue) => {
|
|
446
|
+
const value = parseFloat(String(selected));
|
|
408
447
|
if (isNaN(value) || value < 0) return {};
|
|
409
448
|
return { rowGap: value } as ViewStyle;
|
|
410
449
|
},
|
|
411
|
-
};
|
|
450
|
+
};
|