@draftbit/core 44.1.12 → 44.1.13-6f194c.0
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/Accordion/index.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +23 -47
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +34 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.js +253 -0
- package/lib/commonjs/components/Picker/PickerComponent.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +34 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/components/Picker/Picker.js +26 -47
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +21 -0
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.js +231 -0
- package/lib/module/components/Picker/PickerComponent.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.web.js +21 -0
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/components/StepIndicator.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
- package/lib/typescript/src/components/Picker/PickerComponent.d.ts +4501 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
- package/package.json +2 -2
- package/src/components/Picker/Picker.js +21 -19
- package/src/components/Picker/Picker.tsx +30 -12
- package/src/components/Picker/PickerComponent.android.js +18 -0
- package/src/components/Picker/PickerComponent.android.tsx +37 -0
- package/src/components/Picker/PickerComponent.js +185 -0
- package/src/components/Picker/PickerComponent.tsx +321 -0
- package/src/components/Picker/PickerComponent.web.js +18 -0
- package/src/components/Picker/PickerComponent.web.tsx +37 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
import { PickerOption } from "./Picker";
|
|
4
|
+
interface PickerComponentProps {
|
|
5
|
+
Icon: IconSlot["Icon"];
|
|
6
|
+
androidPickerRef: React.RefObject<any>;
|
|
7
|
+
togglePickerVisible: () => void;
|
|
8
|
+
pickerOptions: PickerOption[];
|
|
9
|
+
internalValue: string | undefined;
|
|
10
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PickerComponent: React.FC<PickerComponentProps>;
|
|
13
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "44.1.
|
|
3
|
+
"version": "44.1.13-6f194c.0+6f194c98",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
]
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "6f194c9891a5370de170060fbc0a190e14060825"
|
|
83
83
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Text,
|
|
2
|
+
import { View, StyleSheet, Text, Dimensions, } from "react-native";
|
|
3
3
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
4
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
6
|
import { withTheme } from "../../theming";
|
|
7
|
-
import Portal from "../Portal/Portal";
|
|
8
|
-
import Button from "../DeprecatedButton";
|
|
7
|
+
// import Portal from "../Portal/Portal";
|
|
8
|
+
// import Button from "../DeprecatedButton";
|
|
9
9
|
import Touchable from "../Touchable";
|
|
10
10
|
import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
import { PickerComponent } from "./PickerComponent";
|
|
11
13
|
function normalizeOptions(options) {
|
|
12
14
|
if (options.length === 0) {
|
|
13
15
|
return [];
|
|
@@ -31,11 +33,13 @@ function normalizeOptions(options) {
|
|
|
31
33
|
throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
|
|
32
34
|
}
|
|
33
35
|
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
34
|
-
const isIos = Platform.OS === "ios";
|
|
36
|
+
// const isIos = Platform.OS === "ios";
|
|
35
37
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
36
38
|
const disabledColor = "rgb(240, 240, 240)";
|
|
37
39
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
38
|
-
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
40
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
41
|
+
// theme,
|
|
42
|
+
assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
|
|
39
43
|
const androidPickerRef = React.useRef(undefined);
|
|
40
44
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
41
45
|
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
@@ -61,7 +65,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
61
65
|
const pickerOptions = placeholder
|
|
62
66
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
63
67
|
: normalizedOptions;
|
|
64
|
-
const { colors } = theme;
|
|
68
|
+
// const { colors } = theme;
|
|
65
69
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
66
70
|
const additionalBorderStyles = ["backgroundColor"];
|
|
67
71
|
const additionalMarginStyles = [
|
|
@@ -181,17 +185,14 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
181
185
|
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
|
|
182
186
|
rightIcon)),
|
|
183
187
|
assistiveTextLabel),
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
193
|
-
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
|
|
194
|
-
!isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
|
|
188
|
+
React.createElement(View, null, pickerVisible ? (React.createElement(PickerComponent, { ...{
|
|
189
|
+
Icon,
|
|
190
|
+
androidPickerRef,
|
|
191
|
+
togglePickerVisible,
|
|
192
|
+
pickerOptions,
|
|
193
|
+
internalValue,
|
|
194
|
+
handleValueChange,
|
|
195
|
+
} })) : null)));
|
|
195
196
|
};
|
|
196
197
|
export default withTheme(Picker);
|
|
197
198
|
const styles = StyleSheet.create({
|
|
@@ -207,6 +208,7 @@ const styles = StyleSheet.create({
|
|
|
207
208
|
width: "100%",
|
|
208
209
|
alignSelf: "stretch",
|
|
209
210
|
alignItems: "center",
|
|
211
|
+
backgroundColor: "pink", // TODO
|
|
210
212
|
},
|
|
211
213
|
outsetContainer: {
|
|
212
214
|
flex: 1,
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
5
|
Text,
|
|
6
|
-
Platform,
|
|
6
|
+
// Platform,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
StyleProp,
|
|
9
9
|
Dimensions,
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
12
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
13
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
12
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
13
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
14
14
|
|
|
15
15
|
import { withTheme } from "../../theming";
|
|
16
|
-
import Portal from "../Portal/Portal";
|
|
17
|
-
import Button from "../DeprecatedButton";
|
|
16
|
+
// import Portal from "../Portal/Portal";
|
|
17
|
+
// import Button from "../DeprecatedButton";
|
|
18
18
|
import Touchable from "../Touchable";
|
|
19
19
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
20
20
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
borderStyleNames,
|
|
25
25
|
marginStyleNames,
|
|
26
26
|
} from "../../utilities";
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
import { PickerComponent } from "./PickerComponent";
|
|
27
29
|
|
|
28
30
|
export interface PickerOption {
|
|
29
31
|
value: string;
|
|
@@ -83,7 +85,7 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
86
|
-
const isIos = Platform.OS === "ios";
|
|
88
|
+
// const isIos = Platform.OS === "ios";
|
|
87
89
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
88
90
|
const disabledColor = "rgb(240, 240, 240)";
|
|
89
91
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
@@ -98,7 +100,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
98
100
|
placeholder,
|
|
99
101
|
value,
|
|
100
102
|
disabled = false,
|
|
101
|
-
theme,
|
|
103
|
+
// theme,
|
|
102
104
|
assistiveText,
|
|
103
105
|
label,
|
|
104
106
|
iconColor = unstyledColor,
|
|
@@ -145,7 +147,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
145
147
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
146
148
|
: normalizedOptions;
|
|
147
149
|
|
|
148
|
-
const { colors } = theme;
|
|
150
|
+
// const { colors } = theme;
|
|
149
151
|
|
|
150
152
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
151
153
|
|
|
@@ -344,8 +346,23 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
344
346
|
{assistiveTextLabel}
|
|
345
347
|
</Touchable>
|
|
346
348
|
|
|
349
|
+
<View>
|
|
350
|
+
{pickerVisible ? (
|
|
351
|
+
<PickerComponent
|
|
352
|
+
{...{
|
|
353
|
+
Icon,
|
|
354
|
+
androidPickerRef,
|
|
355
|
+
togglePickerVisible,
|
|
356
|
+
pickerOptions,
|
|
357
|
+
internalValue,
|
|
358
|
+
handleValueChange,
|
|
359
|
+
}}
|
|
360
|
+
/>
|
|
361
|
+
) : null}
|
|
362
|
+
</View>
|
|
363
|
+
|
|
347
364
|
{/* iosPicker */}
|
|
348
|
-
{isIos && pickerVisible ? (
|
|
365
|
+
{/* isIos && pickerVisible ? (
|
|
349
366
|
<Portal>
|
|
350
367
|
<View
|
|
351
368
|
style={[
|
|
@@ -381,10 +398,10 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
381
398
|
</SafeAreaView>
|
|
382
399
|
</View>
|
|
383
400
|
</Portal>
|
|
384
|
-
) : null}
|
|
401
|
+
) : null */}
|
|
385
402
|
|
|
386
403
|
{/* nonIosPicker */}
|
|
387
|
-
{!isIos && pickerVisible ? (
|
|
404
|
+
{/* !isIos && pickerVisible ? (
|
|
388
405
|
<NativePicker
|
|
389
406
|
enabled={pickerVisible}
|
|
390
407
|
selectedValue={internalValue}
|
|
@@ -401,7 +418,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
401
418
|
/>
|
|
402
419
|
))}
|
|
403
420
|
</NativePicker>
|
|
404
|
-
) : null}
|
|
421
|
+
) : null */}
|
|
405
422
|
</View>
|
|
406
423
|
);
|
|
407
424
|
};
|
|
@@ -421,6 +438,7 @@ const styles = StyleSheet.create({
|
|
|
421
438
|
width: "100%",
|
|
422
439
|
alignSelf: "stretch",
|
|
423
440
|
alignItems: "center",
|
|
441
|
+
backgroundColor: "pink", // TODO
|
|
424
442
|
},
|
|
425
443
|
outsetContainer: {
|
|
426
444
|
flex: 1,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { /* StyleSheet, Dimensions, View, */ Text } from "react-native";
|
|
3
|
+
export const PickerComponent = () => {
|
|
4
|
+
return React.createElement(Text, null, "android");
|
|
5
|
+
};
|
|
6
|
+
// const styles = StyleSheet.create({
|
|
7
|
+
// nonIosPicker: {
|
|
8
|
+
// opacity: 0,
|
|
9
|
+
// position: "absolute",
|
|
10
|
+
// top: 0,
|
|
11
|
+
// left: 0,
|
|
12
|
+
// right: 0,
|
|
13
|
+
// bottom: 0,
|
|
14
|
+
// width: "100%",
|
|
15
|
+
// maxWidth: deviceWidth,
|
|
16
|
+
// maxHeight: deviceHeight,
|
|
17
|
+
// },
|
|
18
|
+
// });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { /* StyleSheet, Dimensions, View, */ Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
|
|
6
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
7
|
+
|
|
8
|
+
import { PickerOption } from "./Picker";
|
|
9
|
+
|
|
10
|
+
// const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
11
|
+
|
|
12
|
+
interface PickerComponentProps {
|
|
13
|
+
Icon: IconSlot["Icon"];
|
|
14
|
+
androidPickerRef: React.RefObject<any>;
|
|
15
|
+
togglePickerVisible: () => void;
|
|
16
|
+
pickerOptions: PickerOption[];
|
|
17
|
+
internalValue: string | undefined;
|
|
18
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const PickerComponent: React.FC<PickerComponentProps> = () => {
|
|
22
|
+
return <Text>android</Text>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// const styles = StyleSheet.create({
|
|
26
|
+
// nonIosPicker: {
|
|
27
|
+
// opacity: 0,
|
|
28
|
+
// position: "absolute",
|
|
29
|
+
// top: 0,
|
|
30
|
+
// left: 0,
|
|
31
|
+
// right: 0,
|
|
32
|
+
// bottom: 0,
|
|
33
|
+
// width: "100%",
|
|
34
|
+
// maxWidth: deviceWidth,
|
|
35
|
+
// maxHeight: deviceHeight,
|
|
36
|
+
// },
|
|
37
|
+
// });
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, /* StyleSheet, */ Text, Platform } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { omit, pick, pickBy, identity } from "lodash";
|
|
5
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
|
+
import { withTheme } from "../../theming";
|
|
7
|
+
import Portal from "../Portal/Portal";
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
|
+
import Touchable from "../Touchable";
|
|
10
|
+
import { extractStyles } from "../../utilities";
|
|
11
|
+
const Picker = ({ Icon, style, options = [], placeholder = "", value: selectedValue = "", disabled = false, onValueChange = () => { }, theme, assistiveText, label, leftIconMode = "inset", leftIconName, placeholderTextColor, rightIconName, type, }) => {
|
|
12
|
+
const [pickerVisible, setIsPickerVisible] = React.useState(false);
|
|
13
|
+
const { viewStyles, textStyles } = extractStyles(style);
|
|
14
|
+
const { colors } = theme;
|
|
15
|
+
console.log({
|
|
16
|
+
// viewStyles,
|
|
17
|
+
// textStyles,
|
|
18
|
+
// options,
|
|
19
|
+
// placeholder,
|
|
20
|
+
// selectedValue,
|
|
21
|
+
// theme,
|
|
22
|
+
// disabled,
|
|
23
|
+
// onValueChange,
|
|
24
|
+
// colors,
|
|
25
|
+
// assistiveText,
|
|
26
|
+
// label,
|
|
27
|
+
// leftIconMode,
|
|
28
|
+
// leftIconName,
|
|
29
|
+
// placeholderTextColor,
|
|
30
|
+
// rightIconName,
|
|
31
|
+
// type,
|
|
32
|
+
});
|
|
33
|
+
const borders = [
|
|
34
|
+
"borderRadius",
|
|
35
|
+
"borderTopLeftRadius",
|
|
36
|
+
"borderTopRightRadius",
|
|
37
|
+
"borderBottomRightRadius",
|
|
38
|
+
"borderBottomLeftRadius",
|
|
39
|
+
"borderTopWidth",
|
|
40
|
+
"borderRightWidth",
|
|
41
|
+
"borderBottomWidth",
|
|
42
|
+
"borderLeftWidth",
|
|
43
|
+
"borderColor",
|
|
44
|
+
"borderStyle",
|
|
45
|
+
];
|
|
46
|
+
const borderStyles = {
|
|
47
|
+
...{
|
|
48
|
+
...(type === "solid"
|
|
49
|
+
? {
|
|
50
|
+
borderTopLeftRadius: 5,
|
|
51
|
+
borderTopRightRadius: 5,
|
|
52
|
+
borderBottomRightRadius: 5,
|
|
53
|
+
borderBottomLeftRadius: 5,
|
|
54
|
+
borderTopWidth: 1,
|
|
55
|
+
borderRightWidth: 1,
|
|
56
|
+
borderLeftWidth: 1,
|
|
57
|
+
}
|
|
58
|
+
: {}),
|
|
59
|
+
borderBottomWidth: 1,
|
|
60
|
+
borderColor: colors.light,
|
|
61
|
+
borderStyle: "solid",
|
|
62
|
+
},
|
|
63
|
+
...pick(viewStyles, borders),
|
|
64
|
+
};
|
|
65
|
+
const margins = ["marginLeft", "marginRight", "marginTop", "marginBottom"];
|
|
66
|
+
const marginStyles = pick(viewStyles, margins);
|
|
67
|
+
const stylesWithoutBordersAndMargins = {
|
|
68
|
+
...{
|
|
69
|
+
height: 60,
|
|
70
|
+
width: "100%",
|
|
71
|
+
},
|
|
72
|
+
...omit(viewStyles, [...borders, ...margins]),
|
|
73
|
+
};
|
|
74
|
+
const selectedLabel = selectedValue &&
|
|
75
|
+
(options.find((o) => o.value === selectedValue)?.label ??
|
|
76
|
+
selectedValue);
|
|
77
|
+
const labelText = label ? (React.createElement(Text, { style: {
|
|
78
|
+
textAlign: textStyles.textAlign,
|
|
79
|
+
color: colors.light,
|
|
80
|
+
fontSize: 12,
|
|
81
|
+
paddingBottom: 4,
|
|
82
|
+
} }, label)) : null;
|
|
83
|
+
const leftIconOutset = leftIconMode === "outset";
|
|
84
|
+
const leftIcon = leftIconName ? (React.createElement(Icon, { name: leftIconName, size: 24, style: {
|
|
85
|
+
marginRight: 8,
|
|
86
|
+
marginLeft: -6,
|
|
87
|
+
} })) : null;
|
|
88
|
+
const rightIcon = rightIconName ? (React.createElement(Icon, { name: rightIconName, size: 24, style: {
|
|
89
|
+
marginRight: -6,
|
|
90
|
+
marginLeft: 8,
|
|
91
|
+
} })) : null;
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
const width = stylesWithoutBordersAndMargins?.width ?? undefined;
|
|
94
|
+
const textAlign = textStyles?.textAlign;
|
|
95
|
+
const paddingLeft = leftIconOutset &&
|
|
96
|
+
(!textAlign || textAlign === "left" || textAlign === "justify")
|
|
97
|
+
? 28 // icon size + 4
|
|
98
|
+
: 0;
|
|
99
|
+
const assistiveTextLabel = assistiveText ? (React.createElement(Text, { style: {
|
|
100
|
+
textAlign,
|
|
101
|
+
width,
|
|
102
|
+
paddingLeft,
|
|
103
|
+
color: colors.light,
|
|
104
|
+
fontSize: 12,
|
|
105
|
+
paddingTop: 4,
|
|
106
|
+
} }, assistiveText)) : null;
|
|
107
|
+
const primaryTextStyle = {
|
|
108
|
+
color: colors.light,
|
|
109
|
+
fontSize: 14,
|
|
110
|
+
...pickBy(textStyles, identity),
|
|
111
|
+
...(placeholder === selectedValue
|
|
112
|
+
? { color: placeholderTextColor ?? colors.light }
|
|
113
|
+
: {}),
|
|
114
|
+
};
|
|
115
|
+
const toggleVisibility = () => setIsPickerVisible(!pickerVisible);
|
|
116
|
+
return (React.createElement(View, { style: [
|
|
117
|
+
{
|
|
118
|
+
alignSelf: "stretch",
|
|
119
|
+
},
|
|
120
|
+
marginStyles,
|
|
121
|
+
] },
|
|
122
|
+
React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility, style: { alignSelf: "stretch", alignItems: "center" } },
|
|
123
|
+
React.createElement(View, { pointerEvents: "none", style: [
|
|
124
|
+
{
|
|
125
|
+
//alignSelf: "stretch",
|
|
126
|
+
flexDirection: "row",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
justifyContent: "space-between",
|
|
129
|
+
},
|
|
130
|
+
stylesWithoutBordersAndMargins,
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
!leftIconOutset && borderStyles,
|
|
133
|
+
] },
|
|
134
|
+
leftIcon,
|
|
135
|
+
React.createElement(View, { style: [
|
|
136
|
+
{
|
|
137
|
+
flex: 1,
|
|
138
|
+
height: "100%",
|
|
139
|
+
flexDirection: "row",
|
|
140
|
+
alignItems: "center",
|
|
141
|
+
justifyContent: "space-between",
|
|
142
|
+
paddingLeft: 12,
|
|
143
|
+
paddingRight: 12,
|
|
144
|
+
},
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
leftIconOutset && borderStyles,
|
|
147
|
+
] },
|
|
148
|
+
React.createElement(View, { style: {
|
|
149
|
+
flex: 1,
|
|
150
|
+
// paddingTop: 0,
|
|
151
|
+
// paddingRight: 0, // add inner text paddding settings
|
|
152
|
+
// paddingLeft: 0,
|
|
153
|
+
// paddingBottom: 0,
|
|
154
|
+
} },
|
|
155
|
+
labelText,
|
|
156
|
+
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
|
|
157
|
+
rightIcon)),
|
|
158
|
+
assistiveTextLabel),
|
|
159
|
+
Platform.OS === "ios" && pickerVisible ? (React.createElement(Portal, null,
|
|
160
|
+
React.createElement(View, { style: {
|
|
161
|
+
position: "absolute",
|
|
162
|
+
bottom: 0,
|
|
163
|
+
left: 0,
|
|
164
|
+
right: 0,
|
|
165
|
+
flexDirection: "row",
|
|
166
|
+
justifyContent: "center",
|
|
167
|
+
backgroundColor: colors.divider,
|
|
168
|
+
} },
|
|
169
|
+
React.createElement(SafeAreaView, { style: {
|
|
170
|
+
backgroundColor: "white",
|
|
171
|
+
flexDirection: "column",
|
|
172
|
+
width: "100%",
|
|
173
|
+
} },
|
|
174
|
+
React.createElement(Button, { Icon: Icon, type: "text", onPress: toggleVisibility, style: { alignSelf: "flex-end" } }, "Close"),
|
|
175
|
+
React.createElement(NativePicker, { style: { backgroundColor: "white" }, selectedValue: selectedValue, onValueChange: onValueChange }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))))))) : (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: selectedValue, onValueChange: onValueChange, style: {
|
|
176
|
+
opacity: 0,
|
|
177
|
+
position: "absolute",
|
|
178
|
+
top: 0,
|
|
179
|
+
left: 0,
|
|
180
|
+
right: 0,
|
|
181
|
+
bottom: 0,
|
|
182
|
+
width: "100%",
|
|
183
|
+
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))))));
|
|
184
|
+
};
|
|
185
|
+
export default withTheme(Picker);
|