@draftbit/core 44.1.9-222859.1 → 44.1.9-55c084.1
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/components/ActionSheet/ActionSheetItem.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +19 -29
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/StepIndicator.js.map +1 -1
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/mappings/ScrollView.js.map +1 -1
- package/lib/commonjs/mappings/WebView.js.map +1 -1
- package/lib/commonjs/utilities.js +19 -0
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +22 -26
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/mappings/AudioPlayer.js.map +1 -1
- package/lib/module/utilities.js +12 -1
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/utilities.d.ts +6 -0
- package/package.json +2 -2
- package/src/components/Picker/Picker.js +36 -39
- package/src/components/Picker/Picker.tsx +42 -43
- package/src/utilities.js +32 -1
- package/src/utilities.ts +42 -1
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
Platform,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
StyleProp,
|
|
9
|
-
Dimensions,
|
|
10
9
|
} from "react-native";
|
|
11
|
-
import { omit,
|
|
10
|
+
import { omit, pickBy, identity, isObject } from "lodash";
|
|
12
11
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
13
12
|
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
14
13
|
|
|
@@ -18,7 +17,12 @@ import Button from "../DeprecatedButton";
|
|
|
18
17
|
import Touchable from "../Touchable";
|
|
19
18
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
20
19
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
21
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
extractStyles,
|
|
22
|
+
extractBorderAndMarginStyles,
|
|
23
|
+
borderStyleNames,
|
|
24
|
+
marginStyleNames,
|
|
25
|
+
} from "../../utilities";
|
|
22
26
|
|
|
23
27
|
export interface PickerOption {
|
|
24
28
|
value: string;
|
|
@@ -60,7 +64,7 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
if (
|
|
63
|
-
|
|
67
|
+
isObject(options[0]) &&
|
|
64
68
|
options[0].value !== null &&
|
|
65
69
|
options[0].label !== null
|
|
66
70
|
) {
|
|
@@ -129,24 +133,12 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
129
133
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
130
134
|
: normalizedOptions;
|
|
131
135
|
|
|
132
|
-
const { viewStyles, textStyles } = extractStyles(style);
|
|
133
|
-
|
|
134
136
|
const { colors } = theme;
|
|
135
137
|
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
"borderBottomRightRadius",
|
|
141
|
-
"borderBottomLeftRadius",
|
|
142
|
-
"borderTopWidth",
|
|
143
|
-
"borderRightWidth",
|
|
144
|
-
"borderBottomWidth",
|
|
145
|
-
"borderLeftWidth",
|
|
146
|
-
"borderColor",
|
|
147
|
-
"borderStyle",
|
|
148
|
-
"backgroundColor",
|
|
149
|
-
];
|
|
138
|
+
const { viewStyles, textStyles } = extractStyles(style);
|
|
139
|
+
|
|
140
|
+
const { marginStyles, borderStyles: extractedBorderStyles } =
|
|
141
|
+
extractBorderAndMarginStyles(viewStyles, ["backgroundColor"]);
|
|
150
142
|
|
|
151
143
|
const borderStyles = {
|
|
152
144
|
...{
|
|
@@ -165,29 +157,27 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
165
157
|
borderColor: unstyledColor,
|
|
166
158
|
borderStyle: "solid",
|
|
167
159
|
},
|
|
168
|
-
...pick(viewStyles, borders),
|
|
160
|
+
// ...pick(viewStyles, borders),
|
|
161
|
+
...pickBy(extractedBorderStyles, identity),
|
|
169
162
|
...(error ? { borderColor: errorColor } : {}),
|
|
170
163
|
...(disabled
|
|
171
164
|
? { borderColor: "transparent", backgroundColor: disabledColor }
|
|
172
165
|
: {}),
|
|
173
166
|
};
|
|
174
167
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const marginStyles = pick(viewStyles, margins);
|
|
178
|
-
|
|
179
|
-
const maxHeight =
|
|
180
|
-
viewStyles?.maxHeight && viewStyles.maxHeight !== "100%"
|
|
181
|
-
? viewStyles.maxHeight
|
|
182
|
-
: Dimensions.get("window").height;
|
|
168
|
+
const platform = Platform.OS;
|
|
183
169
|
|
|
184
170
|
const stylesWithoutBordersAndMargins = {
|
|
185
171
|
...{
|
|
186
172
|
height: 60,
|
|
187
173
|
width: "100%",
|
|
174
|
+
flex: platform === "web" ? undefined : 1,
|
|
188
175
|
},
|
|
189
|
-
...omit(viewStyles, [
|
|
190
|
-
|
|
176
|
+
...omit(viewStyles, [
|
|
177
|
+
...borderStyleNames,
|
|
178
|
+
...marginStyleNames,
|
|
179
|
+
"backgroundColor",
|
|
180
|
+
]),
|
|
191
181
|
};
|
|
192
182
|
|
|
193
183
|
const selectedLabel =
|
|
@@ -236,7 +226,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
236
226
|
/>
|
|
237
227
|
) : null;
|
|
238
228
|
|
|
239
|
-
const width = stylesWithoutBordersAndMargins?.width
|
|
229
|
+
const width = stylesWithoutBordersAndMargins?.width;
|
|
240
230
|
|
|
241
231
|
const textAlign = textStyles?.textAlign;
|
|
242
232
|
|
|
@@ -291,8 +281,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
291
281
|
style={[
|
|
292
282
|
styles.outsetContainer,
|
|
293
283
|
stylesWithoutBordersAndMargins,
|
|
294
|
-
|
|
295
|
-
!leftIconOutset && borderStyles, // set border if Icon is inset
|
|
284
|
+
!leftIconOutset ? (borderStyles as PickerProps["style"]) : {},
|
|
296
285
|
]}
|
|
297
286
|
>
|
|
298
287
|
{leftIcon}
|
|
@@ -301,8 +290,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
301
290
|
<View
|
|
302
291
|
style={[
|
|
303
292
|
styles.insetContainer,
|
|
304
|
-
|
|
305
|
-
leftIconOutset && borderStyles, // set border if Icon is outset
|
|
293
|
+
leftIconOutset ? (borderStyles as PickerProps["style"]) : {},
|
|
306
294
|
]}
|
|
307
295
|
>
|
|
308
296
|
{/* primaryTextContainer */}
|
|
@@ -321,7 +309,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
321
309
|
</Touchable>
|
|
322
310
|
|
|
323
311
|
{/* iosPicker */}
|
|
324
|
-
{
|
|
312
|
+
{platform === "ios" && pickerVisible ? (
|
|
325
313
|
<Portal>
|
|
326
314
|
<View
|
|
327
315
|
style={[
|
|
@@ -360,7 +348,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
360
348
|
) : null}
|
|
361
349
|
|
|
362
350
|
{/* nonIosPicker */}
|
|
363
|
-
{
|
|
351
|
+
{platform !== "ios" ? (
|
|
364
352
|
<NativePicker
|
|
365
353
|
enabled={!disabled}
|
|
366
354
|
selectedValue={internalValue}
|
|
@@ -383,8 +371,13 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
383
371
|
export default withTheme(Picker);
|
|
384
372
|
|
|
385
373
|
const styles = StyleSheet.create({
|
|
386
|
-
marginsContainer: {
|
|
387
|
-
|
|
374
|
+
marginsContainer: {
|
|
375
|
+
alignSelf: "stretch",
|
|
376
|
+
},
|
|
377
|
+
touchableContainer: {
|
|
378
|
+
alignSelf: "stretch",
|
|
379
|
+
alignItems: "center",
|
|
380
|
+
},
|
|
388
381
|
outsetContainer: {
|
|
389
382
|
flexDirection: "row",
|
|
390
383
|
alignItems: "center",
|
|
@@ -399,7 +392,9 @@ const styles = StyleSheet.create({
|
|
|
399
392
|
paddingLeft: 12,
|
|
400
393
|
paddingRight: 12,
|
|
401
394
|
},
|
|
402
|
-
primaryTextContainer: {
|
|
395
|
+
primaryTextContainer: {
|
|
396
|
+
flex: 1,
|
|
397
|
+
},
|
|
403
398
|
iosPicker: {
|
|
404
399
|
position: "absolute",
|
|
405
400
|
bottom: 0,
|
|
@@ -413,8 +408,12 @@ const styles = StyleSheet.create({
|
|
|
413
408
|
flexDirection: "column",
|
|
414
409
|
width: "100%",
|
|
415
410
|
},
|
|
416
|
-
iosButton: {
|
|
417
|
-
|
|
411
|
+
iosButton: {
|
|
412
|
+
alignSelf: "flex-end",
|
|
413
|
+
},
|
|
414
|
+
iosNativePicker: {
|
|
415
|
+
backgroundColor: "white",
|
|
416
|
+
},
|
|
418
417
|
nonIosPicker: {
|
|
419
418
|
opacity: 0,
|
|
420
419
|
position: "absolute",
|
package/src/utilities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
|
-
import { isString, isNumber } from "lodash";
|
|
2
|
+
import { isString, isNumber, pick } from "lodash";
|
|
3
3
|
export function extractStyles(style) {
|
|
4
4
|
const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
|
|
5
5
|
const textStyles = {
|
|
@@ -17,6 +17,37 @@ export function extractStyles(style) {
|
|
|
17
17
|
};
|
|
18
18
|
return { viewStyles, textStyles };
|
|
19
19
|
}
|
|
20
|
+
export const borderStyleNames = [
|
|
21
|
+
"borderRadius",
|
|
22
|
+
"borderTopLeftRadius",
|
|
23
|
+
"borderTopRightRadius",
|
|
24
|
+
"borderBottomRightRadius",
|
|
25
|
+
"borderBottomLeftRadius",
|
|
26
|
+
"borderTopWidth",
|
|
27
|
+
"borderRightWidth",
|
|
28
|
+
"borderBottomWidth",
|
|
29
|
+
"borderLeftWidth",
|
|
30
|
+
"borderColor",
|
|
31
|
+
"borderStyle",
|
|
32
|
+
];
|
|
33
|
+
export const marginStyleNames = [
|
|
34
|
+
"marginLeft",
|
|
35
|
+
"marginRight",
|
|
36
|
+
"marginTop",
|
|
37
|
+
"marginBottom",
|
|
38
|
+
];
|
|
39
|
+
export function extractBorderAndMarginStyles(style, additionalBorderStyles, additionalMarginStyles) {
|
|
40
|
+
const flatStyle = StyleSheet.flatten(style || {});
|
|
41
|
+
const borderStyles = pick(flatStyle, [
|
|
42
|
+
...borderStyleNames,
|
|
43
|
+
...(additionalBorderStyles ? additionalBorderStyles : []),
|
|
44
|
+
]);
|
|
45
|
+
const marginStyles = pick(flatStyle, [
|
|
46
|
+
...marginStyleNames,
|
|
47
|
+
...(additionalMarginStyles ? additionalMarginStyles : []),
|
|
48
|
+
]);
|
|
49
|
+
return { borderStyles, marginStyles };
|
|
50
|
+
}
|
|
20
51
|
/**
|
|
21
52
|
* Merges a style object on top of another style object. In React Native,
|
|
22
53
|
* keys with undefined values in a style object will still override styles
|
package/src/utilities.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet, StyleProp, TextStyle } from "react-native";
|
|
2
|
-
import { isString, isNumber } from "lodash";
|
|
2
|
+
import { isString, isNumber, pick } from "lodash";
|
|
3
3
|
|
|
4
4
|
export function extractStyles(style: StyleProp<any>) {
|
|
5
5
|
const {
|
|
@@ -34,6 +34,47 @@ export function extractStyles(style: StyleProp<any>) {
|
|
|
34
34
|
return { viewStyles, textStyles };
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export const borderStyleNames = [
|
|
38
|
+
"borderRadius",
|
|
39
|
+
"borderTopLeftRadius",
|
|
40
|
+
"borderTopRightRadius",
|
|
41
|
+
"borderBottomRightRadius",
|
|
42
|
+
"borderBottomLeftRadius",
|
|
43
|
+
"borderTopWidth",
|
|
44
|
+
"borderRightWidth",
|
|
45
|
+
"borderBottomWidth",
|
|
46
|
+
"borderLeftWidth",
|
|
47
|
+
"borderColor",
|
|
48
|
+
"borderStyle",
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export const marginStyleNames = [
|
|
52
|
+
"marginLeft",
|
|
53
|
+
"marginRight",
|
|
54
|
+
"marginTop",
|
|
55
|
+
"marginBottom",
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export function extractBorderAndMarginStyles(
|
|
59
|
+
style: StyleProp<any>,
|
|
60
|
+
additionalBorderStyles?: string[],
|
|
61
|
+
additionalMarginStyles?: string[]
|
|
62
|
+
) {
|
|
63
|
+
const flatStyle = StyleSheet.flatten(style || {});
|
|
64
|
+
|
|
65
|
+
const borderStyles = pick(flatStyle, [
|
|
66
|
+
...borderStyleNames,
|
|
67
|
+
...(additionalBorderStyles ? additionalBorderStyles : []),
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const marginStyles = pick(flatStyle, [
|
|
71
|
+
...marginStyleNames,
|
|
72
|
+
...(additionalMarginStyles ? additionalMarginStyles : []),
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
return { borderStyles, marginStyles };
|
|
76
|
+
}
|
|
77
|
+
|
|
37
78
|
/**
|
|
38
79
|
* Merges a style object on top of another style object. In React Native,
|
|
39
80
|
* keys with undefined values in a style object will still override styles
|