@draftbit/core 48.4.8 → 48.4.9-37755.2
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/Picker/DropDownPicker.js +1 -0
- package/lib/commonjs/components/Picker/NativePicker.js +1 -0
- package/lib/commonjs/components/Picker/PickerCommon.js +1 -0
- package/lib/commonjs/components/Picker/PickerInputContainer.js +1 -0
- package/lib/commonjs/components/Picker/index.js +1 -0
- package/lib/commonjs/components/TextField.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/utilities.js +1 -1
- package/lib/typescript/src/components/Picker/DropDownPicker.d.ts +4 -0
- package/lib/typescript/src/components/Picker/DropDownPicker.js +27 -0
- package/lib/typescript/src/components/Picker/DropDownPicker.js.map +1 -0
- package/lib/typescript/src/components/Picker/NativePicker.d.ts +4 -0
- package/lib/typescript/src/components/Picker/NativePicker.js +92 -0
- package/lib/typescript/src/components/Picker/NativePicker.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerCommon.d.ts +28 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js +23 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.d.ts +9 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.js +26 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.js.map +1 -0
- package/lib/typescript/src/components/Picker/index.d.ts +7 -0
- package/lib/typescript/src/components/Picker/index.js +13 -0
- package/lib/typescript/src/components/Picker/index.js.map +1 -0
- package/lib/typescript/src/components/TextField.d.ts +3 -3
- package/lib/typescript/src/components/TextField.js +9 -6
- package/lib/typescript/src/components/TextField.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.js +1 -1
- package/lib/typescript/src/index.js.map +1 -1
- package/lib/typescript/src/utilities.d.ts +8 -0
- package/lib/typescript/src/utilities.js +22 -1
- package/lib/typescript/src/utilities.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/components/Picker/DropDownPicker.js +27 -0
- package/src/components/Picker/DropDownPicker.js.map +1 -0
- package/src/components/Picker/DropDownPicker.tsx +63 -0
- package/src/components/Picker/NativePicker.js +92 -0
- package/src/components/Picker/NativePicker.js.map +1 -0
- package/src/components/Picker/NativePicker.tsx +148 -0
- package/src/components/Picker/PickerCommon.js +23 -0
- package/src/components/Picker/PickerCommon.js.map +1 -0
- package/src/components/Picker/PickerCommon.ts +61 -0
- package/src/components/Picker/PickerInputContainer.js +26 -0
- package/src/components/Picker/PickerInputContainer.js.map +1 -0
- package/src/components/Picker/PickerInputContainer.tsx +74 -0
- package/src/components/Picker/index.js +13 -0
- package/src/components/Picker/index.js.map +1 -0
- package/src/components/Picker/index.tsx +19 -0
- package/src/components/TextField.js +9 -6
- package/src/components/TextField.js.map +1 -1
- package/src/components/TextField.tsx +14 -8
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/index.tsx +1 -1
- package/src/utilities.js +22 -1
- package/src/utilities.js.map +1 -1
- package/src/utilities.ts +33 -1
- package/lib/commonjs/components/Picker/Picker.js +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +0 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +0 -1
- package/lib/commonjs/components/Picker/PickerTypes.js +0 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts +0 -36
- package/lib/typescript/src/components/Picker/Picker.js +0 -288
- package/lib/typescript/src/components/Picker/Picker.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerComponent.android.js +0 -70
- package/lib/typescript/src/components/Picker/PickerComponent.android.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +0 -7
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js +0 -80
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +0 -6
- package/lib/typescript/src/components/Picker/PickerComponent.web.js +0 -71
- package/lib/typescript/src/components/Picker/PickerComponent.web.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +0 -18
- package/lib/typescript/src/components/Picker/PickerTypes.js +0 -2
- package/lib/typescript/src/components/Picker/PickerTypes.js.map +0 -1
- package/src/components/Picker/Picker.js +0 -288
- package/src/components/Picker/Picker.js.map +0 -1
- package/src/components/Picker/Picker.tsx +0 -509
- package/src/components/Picker/PickerComponent.android.js +0 -70
- package/src/components/Picker/PickerComponent.android.js.map +0 -1
- package/src/components/Picker/PickerComponent.android.tsx +0 -116
- package/src/components/Picker/PickerComponent.ios.js +0 -80
- package/src/components/Picker/PickerComponent.ios.js.map +0 -1
- package/src/components/Picker/PickerComponent.ios.tsx +0 -142
- package/src/components/Picker/PickerComponent.web.js +0 -71
- package/src/components/Picker/PickerComponent.web.js.map +0 -1
- package/src/components/Picker/PickerComponent.web.tsx +0 -117
- package/src/components/Picker/PickerTypes.js +0 -2
- package/src/components/Picker/PickerTypes.js.map +0 -1
- package/src/components/Picker/PickerTypes.ts +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "48.4.
|
|
3
|
+
"version": "48.4.9-037755.2+0377550",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "48.
|
|
44
|
+
"@draftbit/types": "^48.4.9-037755.2+0377550",
|
|
45
45
|
"@expo/vector-icons": "^13.0.0",
|
|
46
46
|
"@material-ui/core": "^4.11.0",
|
|
47
47
|
"@material-ui/pickers": "^3.2.10",
|
|
@@ -52,11 +52,13 @@
|
|
|
52
52
|
"date-fns": "^2.16.1",
|
|
53
53
|
"dateformat": "^3.0.3",
|
|
54
54
|
"expo-av": "~13.2.1",
|
|
55
|
+
"lodash.isequal": "^4.5.0",
|
|
55
56
|
"lodash.isnumber": "^3.0.3",
|
|
56
57
|
"lodash.omit": "^4.5.0",
|
|
57
58
|
"lodash.tonumber": "^4.0.3",
|
|
58
59
|
"react-native-confirmation-code-field": "^7.3.1",
|
|
59
60
|
"react-native-deck-swiper": "^2.0.12",
|
|
61
|
+
"react-native-dropdown-picker": "^5.4.6",
|
|
60
62
|
"react-native-gesture-handler": "~2.9.0",
|
|
61
63
|
"react-native-markdown-display": "^7.0.0-alpha.2",
|
|
62
64
|
"react-native-modal-datetime-picker": "^13.0.0",
|
|
@@ -100,5 +102,5 @@
|
|
|
100
102
|
],
|
|
101
103
|
"testEnvironment": "node"
|
|
102
104
|
},
|
|
103
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "03775508511877e60ed570b1f7598919969bf64b"
|
|
104
106
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Keyboard } from "react-native";
|
|
3
|
+
import { useDeepCompareEffect, useDeepCompareMemo } from "../../utilities";
|
|
4
|
+
import { normalizeToPickerOptions } from "./PickerCommon";
|
|
5
|
+
import PickerInputContainer from "./PickerInputContainer";
|
|
6
|
+
import DropDownPickerComponent from "react-native-dropdown-picker";
|
|
7
|
+
const DropDownPicker = ({ options: optionsProp = [], onValueChange, Icon, placeholder, value, autoDismissKeyboard = true, ...rest }) => {
|
|
8
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
9
|
+
const [internalValue, setInternalValue] = React.useState();
|
|
10
|
+
const options = useDeepCompareMemo(() => normalizeToPickerOptions(optionsProp).map((option) => ({
|
|
11
|
+
label: option.label.toString(),
|
|
12
|
+
value: option.value,
|
|
13
|
+
})), [optionsProp]);
|
|
14
|
+
useDeepCompareEffect(() => {
|
|
15
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(internalValue || "");
|
|
16
|
+
}, [internalValue, onValueChange]);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (pickerVisible && autoDismissKeyboard) {
|
|
19
|
+
Keyboard.dismiss();
|
|
20
|
+
}
|
|
21
|
+
}, [pickerVisible, autoDismissKeyboard]);
|
|
22
|
+
return (React.createElement(PickerInputContainer, { Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), ...rest },
|
|
23
|
+
React.createElement(DropDownPickerComponent, { open: pickerVisible, setOpen: setPickerVisible, value: value || null, setValue: setInternalValue, items: options, placeholder: placeholder, listMode: "SCROLLVIEW" })));
|
|
24
|
+
};
|
|
25
|
+
// const styles = StyleSheet.create({});
|
|
26
|
+
export default DropDownPicker;
|
|
27
|
+
//# sourceMappingURL=DropDownPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDownPicker.js","sourceRoot":"","sources":["DropDownPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAqB,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAEnE,MAAM,cAAc,GAAgC,CAAC,EACnD,OAAO,EAAE,WAAW,GAAG,EAAE,EACzB,aAAa,EACb,IAAI,EACJ,WAAW,EACX,KAAK,EACL,mBAAmB,GAAG,IAAI,EAC1B,GAAG,IAAI,EAC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AAC,YAAY,GACrB,CACmB,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,wCAAwC;AAExC,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Keyboard } from "react-native";
|
|
3
|
+
import { useDeepCompareEffect, useDeepCompareMemo } from "../../utilities";
|
|
4
|
+
import { CommonPickerProps, normalizeToPickerOptions } from "./PickerCommon";
|
|
5
|
+
import PickerInputContainer from "./PickerInputContainer";
|
|
6
|
+
import DropDownPickerComponent from "react-native-dropdown-picker";
|
|
7
|
+
|
|
8
|
+
const DropDownPicker: React.FC<CommonPickerProps> = ({
|
|
9
|
+
options: optionsProp = [],
|
|
10
|
+
onValueChange,
|
|
11
|
+
Icon,
|
|
12
|
+
placeholder,
|
|
13
|
+
value,
|
|
14
|
+
autoDismissKeyboard = true,
|
|
15
|
+
...rest
|
|
16
|
+
}) => {
|
|
17
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
18
|
+
const [internalValue, setInternalValue] = React.useState<string | number>();
|
|
19
|
+
|
|
20
|
+
const options = useDeepCompareMemo(
|
|
21
|
+
() =>
|
|
22
|
+
normalizeToPickerOptions(optionsProp).map((option) => ({
|
|
23
|
+
label: option.label.toString(),
|
|
24
|
+
value: option.value,
|
|
25
|
+
})),
|
|
26
|
+
[optionsProp]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
useDeepCompareEffect(() => {
|
|
30
|
+
onValueChange?.(internalValue || "");
|
|
31
|
+
}, [internalValue, onValueChange]);
|
|
32
|
+
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (pickerVisible && autoDismissKeyboard) {
|
|
35
|
+
Keyboard.dismiss();
|
|
36
|
+
}
|
|
37
|
+
}, [pickerVisible, autoDismissKeyboard]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<PickerInputContainer
|
|
41
|
+
Icon={Icon}
|
|
42
|
+
placeholder={placeholder}
|
|
43
|
+
selectedValue={value}
|
|
44
|
+
options={options}
|
|
45
|
+
onPress={() => setPickerVisible(!pickerVisible)}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
<DropDownPickerComponent
|
|
49
|
+
open={pickerVisible}
|
|
50
|
+
setOpen={setPickerVisible}
|
|
51
|
+
value={value || null}
|
|
52
|
+
setValue={setInternalValue}
|
|
53
|
+
items={options}
|
|
54
|
+
placeholder={placeholder}
|
|
55
|
+
listMode="SCROLLVIEW"
|
|
56
|
+
/>
|
|
57
|
+
</PickerInputContainer>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// const styles = StyleSheet.create({});
|
|
62
|
+
|
|
63
|
+
export default DropDownPicker;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Platform, Keyboard } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { Picker as NativePickerComponent } from "@react-native-picker/picker";
|
|
5
|
+
import Portal from "../Portal/Portal";
|
|
6
|
+
import { Button } from "../Button";
|
|
7
|
+
import { useDeepCompareMemo } from "../../utilities";
|
|
8
|
+
import { normalizeToPickerOptions } from "./PickerCommon";
|
|
9
|
+
import PickerInputContainer from "./PickerInputContainer";
|
|
10
|
+
const isIos = Platform.OS === "ios";
|
|
11
|
+
const isWeb = Platform.OS === "web";
|
|
12
|
+
const NativePicker = ({ options: optionsProp = [], onValueChange, Icon, placeholder, value, autoDismissKeyboard = true, ...rest }) => {
|
|
13
|
+
const pickerRef = React.useRef(null);
|
|
14
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
15
|
+
const options = useDeepCompareMemo(() => {
|
|
16
|
+
const normalizedOptions = normalizeToPickerOptions(optionsProp);
|
|
17
|
+
// Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
18
|
+
// Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
19
|
+
if (placeholder) {
|
|
20
|
+
return [{ label: placeholder, value: placeholder }, ...normalizedOptions];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return normalizedOptions;
|
|
24
|
+
}
|
|
25
|
+
}, [placeholder, optionsProp]);
|
|
26
|
+
// When no placeholder is provided then first item should be marked selected to reflect underlying Picker internal state
|
|
27
|
+
if (!placeholder && options.length && !value && value !== options[0].value) {
|
|
28
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(options[0].value);
|
|
29
|
+
}
|
|
30
|
+
const renderNativePicker = () => (React.createElement(NativePickerComponent, { ref: pickerRef, selectedValue: value, onValueChange: (newValue) => {
|
|
31
|
+
if (newValue !== placeholder) {
|
|
32
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
33
|
+
}
|
|
34
|
+
else if (newValue === placeholder) {
|
|
35
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange("");
|
|
36
|
+
}
|
|
37
|
+
}, style: [
|
|
38
|
+
styles.nativePicker,
|
|
39
|
+
isIos ? styles.iosNativePicker : styles.nonIosPicker,
|
|
40
|
+
], onBlur: () => setPickerVisible(false) }, options.map((option) => (React.createElement(NativePickerComponent.Item, { label: option.label.toString(), value: option.value, key: option.value })))));
|
|
41
|
+
const renderPicker = () => {
|
|
42
|
+
if (isIos) {
|
|
43
|
+
return (React.createElement(Portal, null,
|
|
44
|
+
React.createElement(SafeAreaView, { style: styles.nativePicker },
|
|
45
|
+
React.createElement(View, { style: styles.iosPickerContent },
|
|
46
|
+
React.createElement(Button, { Icon: Icon, type: "text", onPress: () => setPickerVisible(!pickerVisible), style: styles.iosButton }, "Close"),
|
|
47
|
+
renderNativePicker()))));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return renderNativePicker();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (pickerVisible && pickerRef.current) {
|
|
56
|
+
(_a = pickerRef === null || pickerRef === void 0 ? void 0 : pickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
|
+
}
|
|
58
|
+
}, [pickerVisible, pickerRef]);
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (pickerVisible && autoDismissKeyboard) {
|
|
61
|
+
Keyboard.dismiss();
|
|
62
|
+
}
|
|
63
|
+
}, [pickerVisible, autoDismissKeyboard]);
|
|
64
|
+
return (React.createElement(PickerInputContainer, { Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), ...rest }, (pickerVisible || isWeb) && renderPicker()));
|
|
65
|
+
};
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
nativePicker: {
|
|
68
|
+
position: "absolute",
|
|
69
|
+
bottom: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
right: 0,
|
|
72
|
+
flexDirection: "row",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
width: "100%",
|
|
75
|
+
backgroundColor: "white",
|
|
76
|
+
},
|
|
77
|
+
iosPickerContent: {
|
|
78
|
+
flexDirection: "column",
|
|
79
|
+
width: "100%",
|
|
80
|
+
},
|
|
81
|
+
iosButton: {
|
|
82
|
+
alignSelf: "flex-end",
|
|
83
|
+
},
|
|
84
|
+
iosNativePicker: {
|
|
85
|
+
backgroundColor: "white",
|
|
86
|
+
},
|
|
87
|
+
nonIosPicker: {
|
|
88
|
+
opacity: 0,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
export default NativePicker;
|
|
92
|
+
//# sourceMappingURL=NativePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativePicker.js","sourceRoot":"","sources":["NativePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACp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QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,OAAO;KACzB;IACD,gBAAgB,EAAE;QAChB,aAAa,EAAE,QAAQ;QACvB,KAAK,EAAE,MAAM;KACd;IACD,SAAS,EAAE;QACT,SAAS,EAAE,UAAU;KACtB;IACD,eAAe,EAAE;QACf,eAAe,EAAE,OAAO;KACzB;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;CACF,CAAC,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Platform, Keyboard } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { Picker as NativePickerComponent } from "@react-native-picker/picker";
|
|
5
|
+
import Portal from "../Portal/Portal";
|
|
6
|
+
import { Button } from "../Button";
|
|
7
|
+
import { useDeepCompareMemo } from "../../utilities";
|
|
8
|
+
import { CommonPickerProps, normalizeToPickerOptions } from "./PickerCommon";
|
|
9
|
+
import PickerInputContainer from "./PickerInputContainer";
|
|
10
|
+
|
|
11
|
+
const isIos = Platform.OS === "ios";
|
|
12
|
+
const isWeb = Platform.OS === "web";
|
|
13
|
+
|
|
14
|
+
const NativePicker: React.FC<CommonPickerProps> = ({
|
|
15
|
+
options: optionsProp = [],
|
|
16
|
+
onValueChange,
|
|
17
|
+
Icon,
|
|
18
|
+
placeholder,
|
|
19
|
+
value,
|
|
20
|
+
autoDismissKeyboard = true,
|
|
21
|
+
...rest
|
|
22
|
+
}) => {
|
|
23
|
+
const pickerRef = React.useRef<NativePickerComponent<string | number>>(null);
|
|
24
|
+
|
|
25
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
26
|
+
|
|
27
|
+
const options = useDeepCompareMemo(() => {
|
|
28
|
+
const normalizedOptions = normalizeToPickerOptions(optionsProp);
|
|
29
|
+
|
|
30
|
+
// Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
31
|
+
// Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
32
|
+
if (placeholder) {
|
|
33
|
+
return [{ label: placeholder, value: placeholder }, ...normalizedOptions];
|
|
34
|
+
} else {
|
|
35
|
+
return normalizedOptions;
|
|
36
|
+
}
|
|
37
|
+
}, [placeholder, optionsProp]);
|
|
38
|
+
|
|
39
|
+
// When no placeholder is provided then first item should be marked selected to reflect underlying Picker internal state
|
|
40
|
+
if (!placeholder && options.length && !value && value !== options[0].value) {
|
|
41
|
+
onValueChange?.(options[0].value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const renderNativePicker = () => (
|
|
45
|
+
<NativePickerComponent
|
|
46
|
+
ref={pickerRef}
|
|
47
|
+
selectedValue={value}
|
|
48
|
+
onValueChange={(newValue) => {
|
|
49
|
+
if (newValue !== placeholder) {
|
|
50
|
+
onValueChange?.(newValue);
|
|
51
|
+
} else if (newValue === placeholder) {
|
|
52
|
+
onValueChange?.("");
|
|
53
|
+
}
|
|
54
|
+
}}
|
|
55
|
+
style={[
|
|
56
|
+
styles.nativePicker,
|
|
57
|
+
isIos ? styles.iosNativePicker : styles.nonIosPicker,
|
|
58
|
+
]}
|
|
59
|
+
onBlur={() => setPickerVisible(false)}
|
|
60
|
+
>
|
|
61
|
+
{options.map((option) => (
|
|
62
|
+
<NativePickerComponent.Item
|
|
63
|
+
label={option.label.toString()}
|
|
64
|
+
value={option.value}
|
|
65
|
+
key={option.value}
|
|
66
|
+
/>
|
|
67
|
+
))}
|
|
68
|
+
</NativePickerComponent>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const renderPicker = () => {
|
|
72
|
+
if (isIos) {
|
|
73
|
+
return (
|
|
74
|
+
<Portal>
|
|
75
|
+
<SafeAreaView style={styles.nativePicker}>
|
|
76
|
+
<View style={styles.iosPickerContent}>
|
|
77
|
+
<Button
|
|
78
|
+
Icon={Icon}
|
|
79
|
+
type="text"
|
|
80
|
+
onPress={() => setPickerVisible(!pickerVisible)}
|
|
81
|
+
style={styles.iosButton}
|
|
82
|
+
>
|
|
83
|
+
{"Close"}
|
|
84
|
+
</Button>
|
|
85
|
+
{renderNativePicker()}
|
|
86
|
+
</View>
|
|
87
|
+
</SafeAreaView>
|
|
88
|
+
</Portal>
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
return renderNativePicker();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
if (pickerVisible && pickerRef.current) {
|
|
97
|
+
pickerRef?.current?.focus();
|
|
98
|
+
}
|
|
99
|
+
}, [pickerVisible, pickerRef]);
|
|
100
|
+
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
if (pickerVisible && autoDismissKeyboard) {
|
|
103
|
+
Keyboard.dismiss();
|
|
104
|
+
}
|
|
105
|
+
}, [pickerVisible, autoDismissKeyboard]);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<PickerInputContainer
|
|
109
|
+
Icon={Icon}
|
|
110
|
+
placeholder={placeholder}
|
|
111
|
+
selectedValue={value}
|
|
112
|
+
options={options}
|
|
113
|
+
onPress={() => setPickerVisible(!pickerVisible)}
|
|
114
|
+
{...rest}
|
|
115
|
+
>
|
|
116
|
+
{/* Web version is collapsed by default, always show to allow direct expand */}
|
|
117
|
+
{(pickerVisible || isWeb) && renderPicker()}
|
|
118
|
+
</PickerInputContainer>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const styles = StyleSheet.create({
|
|
123
|
+
nativePicker: {
|
|
124
|
+
position: "absolute",
|
|
125
|
+
bottom: 0,
|
|
126
|
+
left: 0,
|
|
127
|
+
right: 0,
|
|
128
|
+
flexDirection: "row",
|
|
129
|
+
justifyContent: "center",
|
|
130
|
+
width: "100%",
|
|
131
|
+
backgroundColor: "white",
|
|
132
|
+
},
|
|
133
|
+
iosPickerContent: {
|
|
134
|
+
flexDirection: "column",
|
|
135
|
+
width: "100%",
|
|
136
|
+
},
|
|
137
|
+
iosButton: {
|
|
138
|
+
alignSelf: "flex-end",
|
|
139
|
+
},
|
|
140
|
+
iosNativePicker: {
|
|
141
|
+
backgroundColor: "white",
|
|
142
|
+
},
|
|
143
|
+
nonIosPicker: {
|
|
144
|
+
opacity: 0,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export default NativePicker;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isObject } from "lodash";
|
|
2
|
+
export function normalizeToPickerOptions(options) {
|
|
3
|
+
if (options.length === 0) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
const firstOption = options[0];
|
|
7
|
+
if (typeof firstOption === ("string" || "number")) {
|
|
8
|
+
return options.map((option) => ({
|
|
9
|
+
label: option,
|
|
10
|
+
value: option,
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
if (isObject(firstOption) && firstOption.value && firstOption.label) {
|
|
14
|
+
return options.map((option) => {
|
|
15
|
+
return {
|
|
16
|
+
label: option.label,
|
|
17
|
+
value: option.value,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Picker options must be either an array of strings, numbers, or an array of { "label": string | number; "value": string | number; } objects.');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=PickerCommon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerCommon.js","sourceRoot":"","sources":["PickerCommon.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA8BlC,MAAM,UAAU,wBAAwB,CACtC,OAA6C;IAE7C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/B,IAAI,OAAO,WAAW,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC9B,KAAK,EAAE,MAAyB;YAChC,KAAK,EAAE,MAAyB;SACjC,CAAC,CAAC,CAAC;KACL;IAED,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;QACnE,OAAQ,OAA0B,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAChD,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
2
|
+
import { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
import { isObject } from "lodash";
|
|
4
|
+
|
|
5
|
+
export interface PickerOption {
|
|
6
|
+
value: string | number;
|
|
7
|
+
label: string | number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PickerInputContainerProps extends IconSlot {
|
|
11
|
+
error?: any;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
style?: StyleProp<ViewStyle> | TextStyle;
|
|
15
|
+
label?: string;
|
|
16
|
+
assistiveText?: string;
|
|
17
|
+
iconColor?: string;
|
|
18
|
+
iconSize?: number;
|
|
19
|
+
leftIconMode?: "inset" | "outset";
|
|
20
|
+
leftIconName?: string;
|
|
21
|
+
placeholderTextColor?: string;
|
|
22
|
+
rightIconName?: string;
|
|
23
|
+
type?: "solid" | "underline";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CommonPickerProps extends PickerInputContainerProps {
|
|
27
|
+
value?: string | number;
|
|
28
|
+
options: PickerOption[] | string[] | number[];
|
|
29
|
+
onValueChange: (value: string | number) => void;
|
|
30
|
+
autoDismissKeyboard?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function normalizeToPickerOptions(
|
|
34
|
+
options: PickerOption[] | string[] | number[]
|
|
35
|
+
): PickerOption[] {
|
|
36
|
+
if (options.length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const firstOption = options[0];
|
|
41
|
+
|
|
42
|
+
if (typeof firstOption === ("string" || "number")) {
|
|
43
|
+
return options.map((option) => ({
|
|
44
|
+
label: option as string | number,
|
|
45
|
+
value: option as string | number,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isObject(firstOption) && firstOption.value && firstOption.label) {
|
|
50
|
+
return (options as PickerOption[]).map((option) => {
|
|
51
|
+
return {
|
|
52
|
+
label: option.label,
|
|
53
|
+
value: option.value,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
throw new Error(
|
|
59
|
+
'Picker options must be either an array of strings, numbers, or an array of { "label": string | number; "value": string | number; } objects.'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import omit from "lodash.omit";
|
|
4
|
+
import { extractSizeStyles, extractPositionStyles, extractFlexItemStyles, extractBorderAndMarginStyles, } from "../../utilities";
|
|
5
|
+
import TextField from "../TextField";
|
|
6
|
+
import Touchable from "../Touchable";
|
|
7
|
+
const PickerInputContainer = ({ options = [], onPress, Icon, style, placeholder, selectedValue, disabled = false, children, ...rest }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const containerStyle = StyleSheet.flatten([
|
|
10
|
+
extractSizeStyles(style),
|
|
11
|
+
extractPositionStyles(style),
|
|
12
|
+
extractFlexItemStyles(style),
|
|
13
|
+
extractBorderAndMarginStyles(style).marginStyles,
|
|
14
|
+
]);
|
|
15
|
+
const textFieldStyle = omit(StyleSheet.flatten(style), Object.keys(containerStyle));
|
|
16
|
+
const selectedLabel = ((_a = options
|
|
17
|
+
.find((option) => option.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label.toString()) ||
|
|
18
|
+
selectedValue ||
|
|
19
|
+
placeholder;
|
|
20
|
+
return (React.createElement(View, { style: containerStyle },
|
|
21
|
+
React.createElement(Touchable, { disabled: disabled, onPress: onPress },
|
|
22
|
+
React.createElement(TextField, { Icon: Icon, numberOfLines: 1, onChangeText: () => { }, value: selectedLabel === null || selectedLabel === void 0 ? void 0 : selectedLabel.toString(), editable: false, disabled: disabled, style: textFieldStyle, ...rest })),
|
|
23
|
+
children));
|
|
24
|
+
};
|
|
25
|
+
export default PickerInputContainer;
|
|
26
|
+
//# sourceMappingURL=PickerInputContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerInputContainer.js","sourceRoot":"","sources":["PickerInputContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,cAAc,CAAC;AAYrC,MAAM,oBAAoB,GAEtB,CAAC,EACH,OAAO,GAAG,EAAE,EACZ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,WAAW,EACX,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,EAAE;;IACH,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;QACxC,iBAAiB,CAAC,KAAK,CAAC;QACxB,qBAAqB,CAAC,KAAK,CAAC;QAC5B,qBAAqB,CAAC,KAAK,CAAC;QAC5B,4BAA4B,CAAC,KAAK,CAAC,CAAC,YAAY;KACjD,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,IAAI,CACzB,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EACzB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAC5B,CAAC;IAEF,MAAM,aAAa,GACjB,CAAA,MAAA,OAAO;SACJ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC,0CAC/C,KAAK,CAAC,QAAQ,EAAE;QACpB,aAAa;QACb,WAAW,CAAC;IAEd,OAAO,CACL,oBAAC,IAAI,IAAC,KAAK,EAAE,cAAc;QACzB,oBAAC,SAAS,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC7C,oBAAC,SAAS,IACR,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,CAAC,EAChB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,KAAK,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,EAAE,EAChC,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,cAAc,KACjB,IAAI,GACR,CACQ;QACX,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import omit from "lodash.omit";
|
|
4
|
+
import {
|
|
5
|
+
extractSizeStyles,
|
|
6
|
+
extractPositionStyles,
|
|
7
|
+
extractFlexItemStyles,
|
|
8
|
+
extractBorderAndMarginStyles,
|
|
9
|
+
} from "../../utilities";
|
|
10
|
+
import TextField from "../TextField";
|
|
11
|
+
import Touchable from "../Touchable";
|
|
12
|
+
import {
|
|
13
|
+
PickerInputContainerProps as ExposedPickerInputContainerProps,
|
|
14
|
+
PickerOption,
|
|
15
|
+
} from "./PickerCommon";
|
|
16
|
+
|
|
17
|
+
interface PickerInputContainerProps extends ExposedPickerInputContainerProps {
|
|
18
|
+
selectedValue?: string | number;
|
|
19
|
+
options: PickerOption[];
|
|
20
|
+
onPress?: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PickerInputContainer: React.FC<
|
|
24
|
+
React.PropsWithChildren<PickerInputContainerProps>
|
|
25
|
+
> = ({
|
|
26
|
+
options = [],
|
|
27
|
+
onPress,
|
|
28
|
+
Icon,
|
|
29
|
+
style,
|
|
30
|
+
placeholder,
|
|
31
|
+
selectedValue,
|
|
32
|
+
disabled = false,
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
35
|
+
}) => {
|
|
36
|
+
const containerStyle = StyleSheet.flatten([
|
|
37
|
+
extractSizeStyles(style),
|
|
38
|
+
extractPositionStyles(style),
|
|
39
|
+
extractFlexItemStyles(style),
|
|
40
|
+
extractBorderAndMarginStyles(style).marginStyles,
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const textFieldStyle = omit(
|
|
44
|
+
StyleSheet.flatten(style),
|
|
45
|
+
Object.keys(containerStyle)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const selectedLabel =
|
|
49
|
+
options
|
|
50
|
+
.find((option) => option.value === selectedValue)
|
|
51
|
+
?.label.toString() ||
|
|
52
|
+
selectedValue ||
|
|
53
|
+
placeholder;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<View style={containerStyle}>
|
|
57
|
+
<Touchable disabled={disabled} onPress={onPress}>
|
|
58
|
+
<TextField
|
|
59
|
+
Icon={Icon}
|
|
60
|
+
numberOfLines={1}
|
|
61
|
+
onChangeText={() => {}}
|
|
62
|
+
value={selectedLabel?.toString()}
|
|
63
|
+
editable={false}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
style={textFieldStyle}
|
|
66
|
+
{...rest}
|
|
67
|
+
/>
|
|
68
|
+
</Touchable>
|
|
69
|
+
{children}
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default PickerInputContainer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import NativePicker from "./NativePicker";
|
|
3
|
+
import DropDownPicker from "./DropDownPicker";
|
|
4
|
+
const Picker = ({ mode = "native", ...rest }) => {
|
|
5
|
+
switch (mode) {
|
|
6
|
+
case "native":
|
|
7
|
+
return React.createElement(NativePicker, { ...rest });
|
|
8
|
+
case "dropdown":
|
|
9
|
+
return React.createElement(DropDownPicker, { ...rest });
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export default Picker;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAM9C,MAAM,MAAM,GAA0B,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACrE,QAAQ,IAAI,EAAE;QACZ,KAAK,QAAQ;YACX,OAAO,oBAAC,YAAY,OAAK,IAAI,GAAI,CAAC;QACpC,KAAK,UAAU;YACb,OAAO,oBAAC,cAAc,OAAK,IAAI,GAAI,CAAC;KACvC;AACH,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CommonPickerProps } from "./PickerCommon";
|
|
3
|
+
import NativePicker from "./NativePicker";
|
|
4
|
+
import DropDownPicker from "./DropDownPicker";
|
|
5
|
+
|
|
6
|
+
interface PickerProps extends CommonPickerProps {
|
|
7
|
+
mode?: "native" | "dropdown";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Picker: React.FC<PickerProps> = ({ mode = "native", ...rest }) => {
|
|
11
|
+
switch (mode) {
|
|
12
|
+
case "native":
|
|
13
|
+
return <NativePicker {...rest} />;
|
|
14
|
+
case "dropdown":
|
|
15
|
+
return <DropDownPicker {...rest} />;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Picker;
|