@draftbit/core 48.4.8 → 48.4.9-3aa6b7.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/Picker.js +1 -1
- package/lib/commonjs/components/Picker/PickerInputContainer.js +1 -0
- package/lib/commonjs/components/TextField.js +1 -1
- package/lib/commonjs/utilities.js +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts +3 -35
- package/lib/typescript/src/components/Picker/Picker.js +69 -244
- package/lib/typescript/src/components/Picker/Picker.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerCommon.d.ts +27 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js +2 -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/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/utilities.d.ts +4 -0
- package/lib/typescript/src/utilities.js +15 -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/Picker.js +69 -244
- package/src/components/Picker/Picker.js.map +1 -1
- package/src/components/Picker/Picker.tsx +111 -441
- package/src/components/Picker/PickerCommon.js +2 -0
- package/src/components/Picker/PickerCommon.js.map +1 -0
- package/src/components/Picker/PickerCommon.ts +30 -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/TextField.js +9 -6
- package/src/components/TextField.js.map +1 -1
- package/src/components/TextField.tsx +14 -8
- package/src/utilities.js +15 -1
- package/src/utilities.js.map +1 -1
- package/src/utilities.ts +22 -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/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/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/lib/commonjs/components/Picker/{PickerTypes.js → PickerCommon.js} +0 -0
|
@@ -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
|
-
{"version":3,"file":"PickerTypes.js","sourceRoot":"","sources":["PickerTypes.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
-
}
|
|
File without changes
|