@draftbit/core 46.1.1 → 46.1.4-e6469c.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/ActionSheet/index.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +2 -4
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +5 -7
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/mappings/CheckboxGroup.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
- package/lib/commonjs/mappings/Swiper.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponent.web.js +2 -4
- package/lib/module/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +5 -4
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Touchable.js +16 -2
- package/lib/module/components/Touchable.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DatePicker/DatePickerComponent.web.js +2 -2
- package/src/components/DatePicker/DatePickerComponent.web.tsx +2 -2
- package/src/components/Picker/Picker.js +5 -4
- package/src/components/Picker/Picker.tsx +6 -8
- package/lib/commonjs/components/Picker/PickerComponent.android.js +0 -135
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +0 -161
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +0 -136
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +0 -1
- package/lib/commonjs/components/Picker/PickerTypes.js +0 -6
- package/lib/commonjs/components/Picker/PickerTypes.js.map +0 -1
- package/lib/module/components/Picker/PickerComponent.android.js +0 -112
- package/lib/module/components/Picker/PickerComponent.android.js.map +0 -1
- package/lib/module/components/Picker/PickerComponent.ios.js +0 -135
- package/lib/module/components/Picker/PickerComponent.ios.js.map +0 -1
- package/lib/module/components/Picker/PickerComponent.web.js +0 -113
- package/lib/module/components/Picker/PickerComponent.web.js.map +0 -1
- package/lib/module/components/Picker/PickerTypes.js +0 -2
- package/lib/module/components/Picker/PickerTypes.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +0 -7
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +0 -18
- package/src/components/Picker/PickerComponent.android.js +0 -68
- package/src/components/Picker/PickerComponent.android.tsx +0 -116
- package/src/components/Picker/PickerComponent.ios.js +0 -78
- package/src/components/Picker/PickerComponent.ios.tsx +0 -142
- package/src/components/Picker/PickerComponent.web.js +0 -69
- package/src/components/Picker/PickerComponent.web.tsx +0 -117
- package/src/components/Picker/PickerTypes.js +0 -1
- package/src/components/Picker/PickerTypes.ts +0 -18
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
-
import omit from "lodash.omit";
|
|
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 TextField from "../TextField";
|
|
10
|
-
import Touchable from "../Touchable";
|
|
11
|
-
import { extractStyles } from "../../utilities";
|
|
12
|
-
const Picker = ({ Icon, style, options, placeholder, selectedValue, disabled = false, onValueChange = () => { }, theme: { colors }, ...props }) => {
|
|
13
|
-
const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
-
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
-
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
-
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
17
|
-
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
18
|
-
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
19
|
-
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
-
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
21
|
-
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
22
|
-
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
23
|
-
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
-
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
25
|
-
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
26
|
-
...viewStyles }, } = extractStyles(style);
|
|
27
|
-
const textField = React.useRef(undefined);
|
|
28
|
-
const [pickerVisible, setIsPickerVisible] = React.useState(false);
|
|
29
|
-
const toggleVisibility = () => {
|
|
30
|
-
setIsPickerVisible(!pickerVisible);
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
33
|
-
};
|
|
34
|
-
const stylesWithoutMargin = style &&
|
|
35
|
-
omit(StyleSheet.flatten(style), [
|
|
36
|
-
"margin",
|
|
37
|
-
"marginTop",
|
|
38
|
-
"marginRight",
|
|
39
|
-
"marginBottom",
|
|
40
|
-
"marginLeft",
|
|
41
|
-
]);
|
|
42
|
-
const selectedLabel = selectedValue &&
|
|
43
|
-
(options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
|
|
44
|
-
return (React.createElement(View, { style: [styles.container, viewStyles] },
|
|
45
|
-
React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
|
|
46
|
-
React.createElement(TextField, { ...props, value: String(selectedLabel), placeholder: placeholder,
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
ref: textField, disabled: disabled, pointerEvents: "none",
|
|
49
|
-
// @ts-expect-error
|
|
50
|
-
style: stylesWithoutMargin, Icon: Icon })),
|
|
51
|
-
pickerVisible && (React.createElement(Portal, null,
|
|
52
|
-
React.createElement(View, { style: [styles.picker, { backgroundColor: colors.divider }] },
|
|
53
|
-
React.createElement(SafeAreaView, { style: styles.pickerContainer },
|
|
54
|
-
React.createElement(Button, { Icon: Icon, type: "text", onPress: toggleVisibility, style: styles.closeButton }, "Close"),
|
|
55
|
-
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 }))))))))));
|
|
56
|
-
};
|
|
57
|
-
const styles = StyleSheet.create({
|
|
58
|
-
container: {
|
|
59
|
-
alignSelf: "stretch",
|
|
60
|
-
},
|
|
61
|
-
picker: {
|
|
62
|
-
position: "absolute",
|
|
63
|
-
bottom: 0,
|
|
64
|
-
left: 0,
|
|
65
|
-
right: 0,
|
|
66
|
-
flexDirection: "row",
|
|
67
|
-
justifyContent: "center",
|
|
68
|
-
},
|
|
69
|
-
pickerContainer: {
|
|
70
|
-
backgroundColor: "white",
|
|
71
|
-
flexDirection: "column",
|
|
72
|
-
width: "100%",
|
|
73
|
-
},
|
|
74
|
-
closeButton: {
|
|
75
|
-
alignSelf: "flex-end",
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
export default withTheme(Picker);
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
-
import omit from "lodash.omit";
|
|
5
|
-
|
|
6
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
7
|
-
|
|
8
|
-
import { withTheme } from "../../theming";
|
|
9
|
-
|
|
10
|
-
import Portal from "../Portal/Portal";
|
|
11
|
-
import Button from "../DeprecatedButton";
|
|
12
|
-
import TextField from "../TextField";
|
|
13
|
-
import Touchable from "../Touchable";
|
|
14
|
-
import { PickerComponentProps } from "./PickerTypes";
|
|
15
|
-
import { extractStyles } from "../../utilities";
|
|
16
|
-
import type { IconSlot } from "../../interfaces/Icon";
|
|
17
|
-
|
|
18
|
-
const Picker: React.FC<PickerComponentProps & IconSlot> = ({
|
|
19
|
-
Icon,
|
|
20
|
-
style,
|
|
21
|
-
options,
|
|
22
|
-
placeholder,
|
|
23
|
-
selectedValue,
|
|
24
|
-
disabled = false,
|
|
25
|
-
onValueChange = () => {},
|
|
26
|
-
theme: { colors },
|
|
27
|
-
...props
|
|
28
|
-
}) => {
|
|
29
|
-
const {
|
|
30
|
-
viewStyles: {
|
|
31
|
-
borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
|
-
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
|
-
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
34
|
-
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
35
|
-
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
36
|
-
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
37
|
-
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
38
|
-
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
39
|
-
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
40
|
-
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
41
|
-
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
42
|
-
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
43
|
-
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
44
|
-
...viewStyles
|
|
45
|
-
},
|
|
46
|
-
} = extractStyles(style);
|
|
47
|
-
|
|
48
|
-
const textField = React.useRef<typeof TextField | undefined>(undefined);
|
|
49
|
-
const [pickerVisible, setIsPickerVisible] = React.useState(false);
|
|
50
|
-
|
|
51
|
-
const toggleVisibility = () => {
|
|
52
|
-
setIsPickerVisible(!pickerVisible);
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const stylesWithoutMargin =
|
|
58
|
-
style &&
|
|
59
|
-
omit(StyleSheet.flatten(style), [
|
|
60
|
-
"margin",
|
|
61
|
-
"marginTop",
|
|
62
|
-
"marginRight",
|
|
63
|
-
"marginBottom",
|
|
64
|
-
"marginLeft",
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
const selectedLabel =
|
|
68
|
-
selectedValue &&
|
|
69
|
-
(options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<View style={[styles.container, viewStyles]}>
|
|
73
|
-
<Touchable disabled={disabled} onPress={toggleVisibility}>
|
|
74
|
-
<TextField
|
|
75
|
-
{...props}
|
|
76
|
-
value={String(selectedLabel)}
|
|
77
|
-
placeholder={placeholder}
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
80
|
-
disabled={disabled}
|
|
81
|
-
pointerEvents="none"
|
|
82
|
-
// @ts-expect-error
|
|
83
|
-
style={stylesWithoutMargin}
|
|
84
|
-
Icon={Icon}
|
|
85
|
-
/>
|
|
86
|
-
</Touchable>
|
|
87
|
-
{pickerVisible && (
|
|
88
|
-
<Portal>
|
|
89
|
-
<View style={[styles.picker, { backgroundColor: colors.divider }]}>
|
|
90
|
-
<SafeAreaView style={styles.pickerContainer}>
|
|
91
|
-
<Button
|
|
92
|
-
Icon={Icon}
|
|
93
|
-
type="text"
|
|
94
|
-
onPress={toggleVisibility}
|
|
95
|
-
style={styles.closeButton}
|
|
96
|
-
>
|
|
97
|
-
Close
|
|
98
|
-
</Button>
|
|
99
|
-
<NativePicker
|
|
100
|
-
style={{ backgroundColor: "white" }}
|
|
101
|
-
selectedValue={selectedValue}
|
|
102
|
-
onValueChange={onValueChange}
|
|
103
|
-
>
|
|
104
|
-
{options.map((o: any) => (
|
|
105
|
-
<NativePicker.Item
|
|
106
|
-
label={o.label}
|
|
107
|
-
value={o.value}
|
|
108
|
-
key={o.value}
|
|
109
|
-
/>
|
|
110
|
-
))}
|
|
111
|
-
</NativePicker>
|
|
112
|
-
</SafeAreaView>
|
|
113
|
-
</View>
|
|
114
|
-
</Portal>
|
|
115
|
-
)}
|
|
116
|
-
</View>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const styles = StyleSheet.create({
|
|
121
|
-
container: {
|
|
122
|
-
alignSelf: "stretch",
|
|
123
|
-
},
|
|
124
|
-
picker: {
|
|
125
|
-
position: "absolute",
|
|
126
|
-
bottom: 0,
|
|
127
|
-
left: 0,
|
|
128
|
-
right: 0,
|
|
129
|
-
flexDirection: "row",
|
|
130
|
-
justifyContent: "center",
|
|
131
|
-
},
|
|
132
|
-
pickerContainer: {
|
|
133
|
-
backgroundColor: "white",
|
|
134
|
-
flexDirection: "column",
|
|
135
|
-
width: "100%",
|
|
136
|
-
},
|
|
137
|
-
closeButton: {
|
|
138
|
-
alignSelf: "flex-end",
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export default withTheme(Picker);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
-
import omit from "lodash.omit";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import { extractStyles } from "../../utilities";
|
|
7
|
-
import TextField from "../TextField";
|
|
8
|
-
import Touchable from "../Touchable";
|
|
9
|
-
const Picker = ({ style, options, placeholder, selectedValue, disabled = false, onValueChange: onValueChangeOverride = () => { }, ...props }) => {
|
|
10
|
-
const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
11
|
-
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
|
-
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
-
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
-
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
-
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
-
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
17
|
-
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
18
|
-
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
19
|
-
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
-
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
21
|
-
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
22
|
-
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
23
|
-
...viewStyles }, } = extractStyles(style);
|
|
24
|
-
const textField = React.useRef(undefined);
|
|
25
|
-
const onValueChange = (itemValue, itemIndex) => {
|
|
26
|
-
toggleFocus();
|
|
27
|
-
onValueChangeOverride(itemValue, itemIndex);
|
|
28
|
-
};
|
|
29
|
-
const toggleFocus = () => {
|
|
30
|
-
if (!disabled) {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const stylesWithoutMargin = style &&
|
|
36
|
-
omit(StyleSheet.flatten(style), [
|
|
37
|
-
"margin",
|
|
38
|
-
"marginTop",
|
|
39
|
-
"marginRight",
|
|
40
|
-
"marginBottom",
|
|
41
|
-
"marginLeft",
|
|
42
|
-
]);
|
|
43
|
-
const selectedLabel = selectedValue &&
|
|
44
|
-
(options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
|
|
45
|
-
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
46
|
-
React.createElement(View, null,
|
|
47
|
-
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: onValueChange, style: {
|
|
48
|
-
flex: 1,
|
|
49
|
-
opacity: 0,
|
|
50
|
-
position: "absolute",
|
|
51
|
-
top: 0,
|
|
52
|
-
left: 0,
|
|
53
|
-
right: 0,
|
|
54
|
-
bottom: 0,
|
|
55
|
-
width: "100%",
|
|
56
|
-
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
57
|
-
React.createElement(View, { pointerEvents: "none" },
|
|
58
|
-
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
ref: textField, disabled: disabled,
|
|
61
|
-
// @ts-expect-error
|
|
62
|
-
style: stylesWithoutMargin })))));
|
|
63
|
-
};
|
|
64
|
-
const styles = StyleSheet.create({
|
|
65
|
-
container: {
|
|
66
|
-
alignSelf: "stretch",
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
export default withTheme(Picker);
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
-
import omit from "lodash.omit";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import { extractStyles } from "../../utilities";
|
|
7
|
-
|
|
8
|
-
import TextField from "../TextField";
|
|
9
|
-
import Touchable from "../Touchable";
|
|
10
|
-
import { PickerComponentProps } from "./PickerTypes";
|
|
11
|
-
|
|
12
|
-
const Picker: React.FC<PickerComponentProps> = ({
|
|
13
|
-
style,
|
|
14
|
-
options,
|
|
15
|
-
placeholder,
|
|
16
|
-
selectedValue,
|
|
17
|
-
disabled = false,
|
|
18
|
-
onValueChange: onValueChangeOverride = () => {},
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
viewStyles: {
|
|
23
|
-
borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
-
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
25
|
-
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
26
|
-
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
27
|
-
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
|
-
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
|
-
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
30
|
-
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
31
|
-
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
|
-
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
|
-
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
34
|
-
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
35
|
-
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
36
|
-
...viewStyles
|
|
37
|
-
},
|
|
38
|
-
} = extractStyles(style);
|
|
39
|
-
|
|
40
|
-
const textField = React.useRef<typeof TextField | undefined>(undefined);
|
|
41
|
-
|
|
42
|
-
const onValueChange = (itemValue: string, itemIndex: number) => {
|
|
43
|
-
toggleFocus();
|
|
44
|
-
onValueChangeOverride(itemValue, itemIndex);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const toggleFocus = () => {
|
|
48
|
-
if (!disabled) {
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const stylesWithoutMargin =
|
|
55
|
-
style &&
|
|
56
|
-
omit(StyleSheet.flatten(style), [
|
|
57
|
-
"margin",
|
|
58
|
-
"marginTop",
|
|
59
|
-
"marginRight",
|
|
60
|
-
"marginBottom",
|
|
61
|
-
"marginLeft",
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
const selectedLabel =
|
|
65
|
-
selectedValue &&
|
|
66
|
-
(options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Touchable
|
|
70
|
-
disabled={disabled}
|
|
71
|
-
onPress={toggleFocus}
|
|
72
|
-
style={[styles.container, viewStyles]}
|
|
73
|
-
>
|
|
74
|
-
<View>
|
|
75
|
-
<NativePicker
|
|
76
|
-
enabled={!disabled}
|
|
77
|
-
selectedValue={selectedValue}
|
|
78
|
-
onValueChange={onValueChange}
|
|
79
|
-
style={{
|
|
80
|
-
flex: 1,
|
|
81
|
-
opacity: 0,
|
|
82
|
-
position: "absolute",
|
|
83
|
-
top: 0,
|
|
84
|
-
left: 0,
|
|
85
|
-
right: 0,
|
|
86
|
-
bottom: 0,
|
|
87
|
-
width: "100%",
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
{options.map((o) => (
|
|
91
|
-
<NativePicker.Item label={o.label} value={o.value} key={o.value} />
|
|
92
|
-
))}
|
|
93
|
-
</NativePicker>
|
|
94
|
-
<View pointerEvents="none">
|
|
95
|
-
<TextField
|
|
96
|
-
{...props}
|
|
97
|
-
value={selectedLabel}
|
|
98
|
-
placeholder={placeholder}
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
101
|
-
disabled={disabled}
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
style={stylesWithoutMargin}
|
|
104
|
-
/>
|
|
105
|
-
</View>
|
|
106
|
-
</View>
|
|
107
|
-
</Touchable>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const styles = StyleSheet.create({
|
|
112
|
-
container: {
|
|
113
|
-
alignSelf: "stretch",
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
export default withTheme(Picker);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ViewStyle } from "react-native";
|
|
2
|
-
import { StyleProp } from "react-native";
|
|
3
|
-
import { Props as TextFieldProps } from "../TextField";
|
|
4
|
-
|
|
5
|
-
export interface PickerOption {
|
|
6
|
-
value: string;
|
|
7
|
-
label: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface PickerComponentProps extends TextFieldProps {
|
|
11
|
-
style?: StyleProp<ViewStyle> & { height?: number };
|
|
12
|
-
options: PickerOption[];
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
selectedValue: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
onValueChange?: (value: string, index: number) => void;
|
|
17
|
-
defaultValue?: string;
|
|
18
|
-
}
|