@draftbit/core 48.4.9-5b8587.2 → 48.4.9-719f89.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/Checkbox/Checkbox.js +1 -1
- package/lib/commonjs/components/IconButton.js +1 -1
- package/lib/commonjs/components/Picker/Picker.js +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +1 -0
- package/lib/commonjs/components/Picker/PickerTypes.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/Checkbox/Checkbox.js +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/typescript/src/components/IconButton.js +0 -2
- package/lib/typescript/src/components/IconButton.js.map +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts +36 -0
- package/lib/typescript/src/components/Picker/Picker.js +288 -0
- package/lib/typescript/src/components/Picker/Picker.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerComponent.android.js +70 -0
- package/lib/typescript/src/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +7 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js +80 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.js +71 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +18 -0
- package/lib/typescript/src/components/Picker/PickerTypes.js +2 -0
- package/lib/typescript/src/components/Picker/PickerTypes.js.map +1 -0
- package/lib/typescript/src/components/TextField.d.ts +3 -3
- package/lib/typescript/src/components/TextField.js +6 -9
- 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 +0 -8
- package/lib/typescript/src/utilities.js +1 -22
- package/lib/typescript/src/utilities.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/components/Checkbox/Checkbox.js +1 -1
- package/src/components/Checkbox/Checkbox.js.map +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/IconButton.js +0 -2
- package/src/components/IconButton.js.map +1 -1
- package/src/components/IconButton.tsx +0 -2
- package/src/components/Picker/Picker.js +288 -0
- package/src/components/Picker/Picker.js.map +1 -0
- package/src/components/Picker/Picker.tsx +509 -0
- package/src/components/Picker/PickerComponent.android.js +70 -0
- package/src/components/Picker/PickerComponent.android.js.map +1 -0
- package/src/components/Picker/PickerComponent.android.tsx +116 -0
- package/src/components/Picker/PickerComponent.ios.js +80 -0
- package/src/components/Picker/PickerComponent.ios.js.map +1 -0
- package/src/components/Picker/PickerComponent.ios.tsx +142 -0
- package/src/components/Picker/PickerComponent.web.js +71 -0
- package/src/components/Picker/PickerComponent.web.js.map +1 -0
- package/src/components/Picker/PickerComponent.web.tsx +117 -0
- package/src/components/Picker/PickerTypes.js +2 -0
- package/src/components/Picker/PickerTypes.js.map +1 -0
- package/src/components/Picker/PickerTypes.ts +18 -0
- package/src/components/TextField.js +6 -9
- package/src/components/TextField.js.map +1 -1
- package/src/components/TextField.tsx +8 -14
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/index.tsx +1 -1
- package/src/utilities.js +1 -22
- package/src/utilities.js.map +1 -1
- package/src/utilities.ts +1 -33
- package/lib/commonjs/components/Picker/DropDownPicker.js +0 -1
- package/lib/commonjs/components/Picker/NativePicker.js +0 -1
- package/lib/commonjs/components/Picker/PickerCommon.js +0 -1
- package/lib/commonjs/components/Picker/PickerInputContainer.js +0 -1
- package/lib/commonjs/components/Picker/index.js +0 -1
- package/lib/typescript/src/components/Picker/DropDownPicker.d.ts +0 -12
- package/lib/typescript/src/components/Picker/DropDownPicker.js +0 -31
- package/lib/typescript/src/components/Picker/DropDownPicker.js.map +0 -1
- package/lib/typescript/src/components/Picker/NativePicker.d.ts +0 -4
- package/lib/typescript/src/components/Picker/NativePicker.js +0 -92
- package/lib/typescript/src/components/Picker/NativePicker.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerCommon.d.ts +0 -28
- package/lib/typescript/src/components/Picker/PickerCommon.js +0 -23
- package/lib/typescript/src/components/Picker/PickerCommon.js.map +0 -1
- package/lib/typescript/src/components/Picker/PickerInputContainer.d.ts +0 -10
- package/lib/typescript/src/components/Picker/PickerInputContainer.js +0 -26
- package/lib/typescript/src/components/Picker/PickerInputContainer.js.map +0 -1
- package/lib/typescript/src/components/Picker/index.d.ts +0 -7
- package/lib/typescript/src/components/Picker/index.js +0 -13
- package/lib/typescript/src/components/Picker/index.js.map +0 -1
- package/src/components/Picker/DropDownPicker.js +0 -31
- package/src/components/Picker/DropDownPicker.js.map +0 -1
- package/src/components/Picker/DropDownPicker.tsx +0 -84
- package/src/components/Picker/NativePicker.js +0 -92
- package/src/components/Picker/NativePicker.js.map +0 -1
- package/src/components/Picker/NativePicker.tsx +0 -148
- package/src/components/Picker/PickerCommon.js +0 -23
- package/src/components/Picker/PickerCommon.js.map +0 -1
- package/src/components/Picker/PickerCommon.ts +0 -61
- package/src/components/Picker/PickerInputContainer.js +0 -26
- package/src/components/Picker/PickerInputContainer.js.map +0 -1
- package/src/components/Picker/PickerInputContainer.tsx +0 -76
- package/src/components/Picker/index.js +0 -13
- package/src/components/Picker/index.js.map +0 -1
- package/src/components/Picker/index.tsx +0 -19
|
@@ -1,92 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAqB,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAEpC,MAAM,YAAY,GAAgC,CAAC,EACjD,OAAO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SAAS,CAAC,CAAC,CAAC;IAE/B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,aAAa,IAAI,mBAAmB,EAAE;YACxC,QAAQ,CAAC,OAAO,EAAE,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEzC,OAAO,CACL,oBAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,KAAK,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,KAC3C,IAAI,IAGP,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,YAAY,EAAE,CACtB,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,YAAY,EAAE;QACZ,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,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"}
|
|
@@ -1,148 +0,0 @@
|
|
|
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;
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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, zIndex, 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, { zIndex }] },
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;AAarC,MAAM,oBAAoB,GAEtB,CAAC,EACH,OAAO,GAAG,EAAE,EACZ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,WAAW,EACX,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,MAAM,EACN,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,cAAc,EAAE,EAAE,MAAM,EAAE,CAAC;QACvC,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"}
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
zIndex?: number;
|
|
21
|
-
onPress?: () => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const PickerInputContainer: React.FC<
|
|
25
|
-
React.PropsWithChildren<PickerInputContainerProps>
|
|
26
|
-
> = ({
|
|
27
|
-
options = [],
|
|
28
|
-
onPress,
|
|
29
|
-
Icon,
|
|
30
|
-
style,
|
|
31
|
-
placeholder,
|
|
32
|
-
selectedValue,
|
|
33
|
-
disabled = false,
|
|
34
|
-
zIndex,
|
|
35
|
-
children,
|
|
36
|
-
...rest
|
|
37
|
-
}) => {
|
|
38
|
-
const containerStyle = StyleSheet.flatten([
|
|
39
|
-
extractSizeStyles(style),
|
|
40
|
-
extractPositionStyles(style),
|
|
41
|
-
extractFlexItemStyles(style),
|
|
42
|
-
extractBorderAndMarginStyles(style).marginStyles,
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
const textFieldStyle = omit(
|
|
46
|
-
StyleSheet.flatten(style),
|
|
47
|
-
Object.keys(containerStyle)
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const selectedLabel =
|
|
51
|
-
options
|
|
52
|
-
.find((option) => option.value === selectedValue)
|
|
53
|
-
?.label.toString() ||
|
|
54
|
-
selectedValue ||
|
|
55
|
-
placeholder;
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<View style={[containerStyle, { zIndex }]}>
|
|
59
|
-
<Touchable disabled={disabled} onPress={onPress}>
|
|
60
|
-
<TextField
|
|
61
|
-
Icon={Icon}
|
|
62
|
-
numberOfLines={1}
|
|
63
|
-
onChangeText={() => {}}
|
|
64
|
-
value={selectedLabel?.toString()}
|
|
65
|
-
editable={false}
|
|
66
|
-
disabled={disabled}
|
|
67
|
-
style={textFieldStyle}
|
|
68
|
-
{...rest}
|
|
69
|
-
/>
|
|
70
|
-
</Touchable>
|
|
71
|
-
{children}
|
|
72
|
-
</View>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default PickerInputContainer;
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|