@draftbit/core 46.1.4-e6469c.0 → 46.2.1-435444.1
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/CardContainer.js +16 -5
- package/lib/commonjs/components/CardContainer.js.map +1 -1
- package/lib/commonjs/components/Carousel.js +3 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/Config.js +3 -3
- package/lib/commonjs/components/Config.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +3 -3
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponentType.js.map +1 -1
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -14
- package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +4 -5
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +135 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +161 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +136 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerTypes.js +6 -0
- package/lib/commonjs/components/Picker/PickerTypes.js.map +1 -0
- package/lib/commonjs/components/RadioButton/RadioButton.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/StepIndicator.js +1 -1
- package/lib/commonjs/components/StepIndicator.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +1 -1
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/mappings/NumberInput.js +241 -0
- package/lib/commonjs/mappings/NumberInput.js.map +1 -0
- package/lib/commonjs/mappings/RadioButton.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/mappings/Text.js +33 -26
- package/lib/commonjs/mappings/Text.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js +181 -2
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/commonjs/mappings/TextField.js +191 -2
- package/lib/commonjs/mappings/TextField.js.map +1 -1
- package/lib/commonjs/mappings/TextInput.js +180 -29
- package/lib/commonjs/mappings/TextInput.js.map +1 -1
- package/lib/commonjs/utilities.js +1 -1
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Carousel.js +3 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/Config.js +3 -3
- package/lib/module/components/Config.js.map +1 -1
- package/lib/module/components/Container.js +17 -5
- package/lib/module/components/Container.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +3 -3
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/HeaderLarge.js.map +1 -1
- package/lib/module/components/HeaderMedium.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +4 -5
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +112 -0
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.ios.js +135 -0
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.web.js +113 -0
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/components/Picker/PickerTypes.js +2 -0
- package/lib/module/components/Picker/PickerTypes.js.map +1 -0
- package/lib/module/components/RadioButton/RadioButton.js +1 -1
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/StepIndicator.js +1 -1
- package/lib/module/components/StepIndicator.js.map +1 -1
- package/lib/module/components/Stepper.js +1 -1
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/Touchable.js +2 -16
- package/lib/module/components/Touchable.js.map +1 -1
- package/lib/module/mappings/NumberInput.js +231 -0
- package/lib/module/mappings/NumberInput.js.map +1 -0
- package/lib/module/mappings/Text.js +33 -26
- package/lib/module/mappings/Text.js.map +1 -1
- package/lib/module/mappings/TextArea.js +182 -3
- package/lib/module/mappings/TextArea.js.map +1 -1
- package/lib/module/mappings/TextField.js +192 -3
- package/lib/module/mappings/TextField.js.map +1 -1
- package/lib/module/mappings/TextInput.js +180 -29
- package/lib/module/mappings/TextInput.js.map +1 -1
- package/lib/module/utilities.js +1 -1
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +7 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +18 -0
- package/lib/typescript/src/mappings/NumberInput.d.ts +297 -0
- package/lib/typescript/src/mappings/Text.d.ts +24 -10
- package/lib/typescript/src/mappings/TextArea.d.ts +1 -11
- package/lib/typescript/src/mappings/TextField.d.ts +4 -4
- package/lib/typescript/src/mappings/TextInput.d.ts +3 -254
- package/package.json +3 -3
- package/src/components/ActionSheet/ActionSheet.js +1 -1
- package/src/components/Carousel.js +4 -2
- package/src/components/Checkbox/Checkbox.js +3 -3
- package/src/components/Checkbox/CheckboxGroupRow.js +2 -2
- package/src/components/Checkbox/CheckboxRow.js +3 -3
- package/src/components/CircularProgress.js +29 -26
- package/src/components/DatePicker/DatePicker.js +1 -1
- package/src/components/NumberInput.js +1 -1
- package/src/components/Picker/Picker.js +8 -8
- package/src/components/Picker/Picker.tsx +8 -6
- package/src/components/Picker/PickerComponent.android.js +69 -0
- package/src/components/Picker/PickerComponent.android.tsx +116 -0
- package/src/components/Picker/PickerComponent.ios.js +79 -0
- package/src/components/Picker/PickerComponent.ios.tsx +142 -0
- package/src/components/Picker/PickerComponent.web.js +70 -0
- package/src/components/Picker/PickerComponent.web.tsx +117 -0
- package/src/components/Picker/PickerTypes.js +1 -0
- package/src/components/Picker/PickerTypes.ts +18 -0
- package/src/components/Portal/Portal.js +2 -2
- package/src/components/Portal/PortalConsumer.js +0 -1
- package/src/components/Portal/PortalHost.js +43 -41
- package/src/components/Portal/PortalManager.js +21 -18
- package/src/components/ProgressBar.js +9 -9
- package/src/components/RadioButton/RadioButton.js +3 -3
- package/src/components/RadioButton/RadioButtonGroup.js +1 -1
- package/src/components/RadioButton/RadioButtonRow.js +3 -3
- package/src/components/StepIndicator.js +225 -225
- package/src/components/Stepper.js +2 -2
- package/src/components/Text.js +0 -1
- package/src/components/TextField.js +62 -59
- package/src/constants.js +1 -1
- package/src/mappings/NumberInput.js +248 -0
- package/src/mappings/NumberInput.ts +267 -0
- package/src/mappings/Text.js +33 -26
- package/src/mappings/Text.ts +34 -27
- package/src/mappings/TextArea.js +210 -3
- package/src/mappings/TextArea.ts +216 -3
- package/src/mappings/TextField.js +220 -3
- package/src/mappings/TextField.ts +227 -3
- package/src/mappings/TextInput.js +208 -31
- package/src/mappings/TextInput.ts +214 -34
|
@@ -0,0 +1,142 @@
|
|
|
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);
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
var _a, _b;
|
|
11
|
+
const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
|
+
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
+
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
+
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
+
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
17
|
+
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
18
|
+
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
19
|
+
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
+
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
21
|
+
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
22
|
+
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
23
|
+
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
+
...viewStyles }, } = extractStyles(style);
|
|
25
|
+
const textField = React.useRef(undefined);
|
|
26
|
+
const onValueChange = (itemValue, itemIndex) => {
|
|
27
|
+
toggleFocus();
|
|
28
|
+
onValueChangeOverride(itemValue, itemIndex);
|
|
29
|
+
};
|
|
30
|
+
const toggleFocus = () => {
|
|
31
|
+
if (!disabled) {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const stylesWithoutMargin = style &&
|
|
37
|
+
omit(StyleSheet.flatten(style), [
|
|
38
|
+
"margin",
|
|
39
|
+
"marginTop",
|
|
40
|
+
"marginRight",
|
|
41
|
+
"marginBottom",
|
|
42
|
+
"marginLeft",
|
|
43
|
+
]);
|
|
44
|
+
const selectedLabel = selectedValue &&
|
|
45
|
+
((_b = (_a = options.find((o) => o.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : selectedValue);
|
|
46
|
+
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
47
|
+
React.createElement(View, null,
|
|
48
|
+
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: onValueChange, style: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
opacity: 0,
|
|
51
|
+
position: "absolute",
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0,
|
|
54
|
+
right: 0,
|
|
55
|
+
bottom: 0,
|
|
56
|
+
width: "100%",
|
|
57
|
+
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
58
|
+
React.createElement(View, { pointerEvents: "none" },
|
|
59
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
ref: textField, disabled: disabled,
|
|
62
|
+
// @ts-expect-error
|
|
63
|
+
style: stylesWithoutMargin })))));
|
|
64
|
+
};
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
container: {
|
|
67
|
+
alignSelf: "stretch",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
export default withTheme(Picker);
|
|
@@ -0,0 +1,117 @@
|
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -24,12 +24,12 @@ import { ThemeProvider, withTheme } from "../../theming";
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
class Portal extends React.Component {
|
|
27
|
-
// @component ./PortalHost.tsx
|
|
28
|
-
static Host = PortalHost;
|
|
29
27
|
render() {
|
|
30
28
|
const { children, theme } = this.props;
|
|
31
29
|
return (React.createElement(PortalContext.Consumer, null, (manager) => (React.createElement(PortalConsumer, { manager: manager },
|
|
32
30
|
React.createElement(ThemeProvider, { theme: theme }, children)))));
|
|
33
31
|
}
|
|
34
32
|
}
|
|
33
|
+
// @component ./PortalHost.tsx
|
|
34
|
+
Portal.Host = PortalHost;
|
|
35
35
|
export default withTheme(Portal);
|
|
@@ -14,7 +14,6 @@ export default class PortalConsumer extends React.Component {
|
|
|
14
14
|
this.checkManager();
|
|
15
15
|
this.props.manager.unmount(this.key);
|
|
16
16
|
}
|
|
17
|
-
key;
|
|
18
17
|
checkManager() {
|
|
19
18
|
if (!this.props.manager) {
|
|
20
19
|
throw new Error("Looks like you forgot to wrap your root component with `Provider` component from `react-native-paper`.\n\n" +
|
|
@@ -27,7 +27,48 @@ export const PortalContext = React.createContext(null);
|
|
|
27
27
|
* Here any `Portal` elements under `<App />` are rendered alongside `<App />` and will appear above `<App />` like a `Modal`.
|
|
28
28
|
*/
|
|
29
29
|
export default class PortalHost extends React.Component {
|
|
30
|
-
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.setManager = (manager) => {
|
|
33
|
+
this.manager = manager;
|
|
34
|
+
};
|
|
35
|
+
this.mount = (children) => {
|
|
36
|
+
const key = this.nextKey++;
|
|
37
|
+
if (this.manager) {
|
|
38
|
+
this.manager.mount(key, children);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.queue.push({ type: "mount", key, children });
|
|
42
|
+
}
|
|
43
|
+
return key;
|
|
44
|
+
};
|
|
45
|
+
this.update = (key, children) => {
|
|
46
|
+
if (this.manager) {
|
|
47
|
+
this.manager.update(key, children);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const op = { type: "mount", key, children };
|
|
51
|
+
const index = this.queue.findIndex((o) => o.type === "mount" || (o.type === "update" && o.key === key));
|
|
52
|
+
if (index > -1) {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
this.queue[index] = op;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.queue.push(op);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.unmount = (key) => {
|
|
62
|
+
if (this.manager) {
|
|
63
|
+
this.manager.unmount(key);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.queue.push({ type: "unmount", key });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this.nextKey = 0;
|
|
70
|
+
this.queue = [];
|
|
71
|
+
}
|
|
31
72
|
componentDidMount() {
|
|
32
73
|
const manager = this.manager;
|
|
33
74
|
const queue = this.queue;
|
|
@@ -48,46 +89,6 @@ export default class PortalHost extends React.Component {
|
|
|
48
89
|
}
|
|
49
90
|
}
|
|
50
91
|
}
|
|
51
|
-
setManager = (manager) => {
|
|
52
|
-
this.manager = manager;
|
|
53
|
-
};
|
|
54
|
-
mount = (children) => {
|
|
55
|
-
const key = this.nextKey++;
|
|
56
|
-
if (this.manager) {
|
|
57
|
-
this.manager.mount(key, children);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.queue.push({ type: "mount", key, children });
|
|
61
|
-
}
|
|
62
|
-
return key;
|
|
63
|
-
};
|
|
64
|
-
update = (key, children) => {
|
|
65
|
-
if (this.manager) {
|
|
66
|
-
this.manager.update(key, children);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const op = { type: "mount", key, children };
|
|
70
|
-
const index = this.queue.findIndex((o) => o.type === "mount" || (o.type === "update" && o.key === key));
|
|
71
|
-
if (index > -1) {
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
this.queue[index] = op;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.queue.push(op);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
unmount = (key) => {
|
|
81
|
-
if (this.manager) {
|
|
82
|
-
this.manager.unmount(key);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.queue.push({ type: "unmount", key });
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
nextKey = 0;
|
|
89
|
-
queue = [];
|
|
90
|
-
manager;
|
|
91
92
|
render() {
|
|
92
93
|
return (React.createElement(PortalContext.Provider, { value: {
|
|
93
94
|
mount: this.mount,
|
|
@@ -98,6 +99,7 @@ export default class PortalHost extends React.Component {
|
|
|
98
99
|
React.createElement(PortalManager, { ref: this.setManager })));
|
|
99
100
|
}
|
|
100
101
|
}
|
|
102
|
+
PortalHost.displayName = "Portal.Host";
|
|
101
103
|
const styles = StyleSheet.create({
|
|
102
104
|
container: {
|
|
103
105
|
flex: 1,
|
|
@@ -4,25 +4,28 @@ import { View, StyleSheet } from "react-native";
|
|
|
4
4
|
* Portal host is the component which actually renders all Portals.
|
|
5
5
|
*/
|
|
6
6
|
export default class PortalManager extends React.PureComponent {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.state = {
|
|
10
|
+
portals: [],
|
|
11
|
+
};
|
|
12
|
+
this.mount = (key, children) => {
|
|
13
|
+
this.setState((state) => ({
|
|
14
|
+
portals: [...state.portals, { key, children }],
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
this.update = (key, children) => this.setState((state) => ({
|
|
18
|
+
portals: state.portals.map((item) => {
|
|
19
|
+
if (item.key === key) {
|
|
20
|
+
return { ...item, children };
|
|
21
|
+
}
|
|
22
|
+
return item;
|
|
23
|
+
}),
|
|
13
24
|
}));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return { ...item, children };
|
|
19
|
-
}
|
|
20
|
-
return item;
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
unmount = (key) => this.setState((state) => ({
|
|
24
|
-
portals: state.portals.filter((item) => item.key !== key),
|
|
25
|
-
}));
|
|
25
|
+
this.unmount = (key) => this.setState((state) => ({
|
|
26
|
+
portals: state.portals.filter((item) => item.key !== key),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
26
29
|
render() {
|
|
27
30
|
return this.state.portals.map(({ key, children }) => (React.createElement(View, { key: key, collapsable: false /* Need collapsable=false here to clip the elevations, otherwise they appear above sibling components */, pointerEvents: "box-none", style: StyleSheet.absoluteFill }, children)));
|
|
28
31
|
}
|
|
@@ -5,6 +5,15 @@ const BAR_WIDTH_ZERO_POSITION = INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_
|
|
|
5
5
|
export default class ProgressBar extends Component {
|
|
6
6
|
constructor(props) {
|
|
7
7
|
super(props);
|
|
8
|
+
this.handleLayout = (event) => {
|
|
9
|
+
const { width = 150, onLayout } = this.props;
|
|
10
|
+
if (!width) {
|
|
11
|
+
this.setState({ width: event.nativeEvent.layout.width });
|
|
12
|
+
}
|
|
13
|
+
if (onLayout) {
|
|
14
|
+
onLayout(event);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
8
17
|
const { progress: progressP = 0, indeterminate = false } = props;
|
|
9
18
|
const progress = Math.min(Math.max(progressP, 0), 1);
|
|
10
19
|
this.state = {
|
|
@@ -50,15 +59,6 @@ export default class ProgressBar extends Component {
|
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
handleLayout = (event) => {
|
|
54
|
-
const { width = 150, onLayout } = this.props;
|
|
55
|
-
if (!width) {
|
|
56
|
-
this.setState({ width: event.nativeEvent.layout.width });
|
|
57
|
-
}
|
|
58
|
-
if (onLayout) {
|
|
59
|
-
onLayout(event);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
62
|
animate() {
|
|
63
63
|
const { useNativeDriver = false, indeterminateAnimationDuration = 1000 } = this.props;
|
|
64
64
|
this.state.animationValue.setValue(0);
|
|
@@ -7,10 +7,10 @@ const RadioButton = ({ Icon, disabled = false, color, value = "", selected, unse
|
|
|
7
7
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
8
8
|
const realValue = getValueForRadioButton(value);
|
|
9
9
|
const realContextValue = getValueForRadioButton(contextValue);
|
|
10
|
-
const isSelected = selected
|
|
10
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
11
11
|
const handlePress = () => {
|
|
12
|
-
onPress
|
|
13
|
-
onValueChange
|
|
12
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
13
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
14
14
|
};
|
|
15
15
|
return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
|
|
16
16
|
};
|
|
@@ -20,7 +20,7 @@ const RadioButtonGroup = ({ direction = Direction.Vertical, value = "", onValueC
|
|
|
20
20
|
const handleValueChange = (newValue) => {
|
|
21
21
|
const realNewValue = getValueForRadioButton(newValue);
|
|
22
22
|
setInternalValue(realNewValue);
|
|
23
|
-
onValueChange
|
|
23
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
|
|
24
24
|
};
|
|
25
25
|
const _containerStyle = [
|
|
26
26
|
{
|
|
@@ -34,10 +34,10 @@ const RadioButtonRow = ({ Icon, label, value = "", color, unselectedColor, onPre
|
|
|
34
34
|
const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
|
|
35
35
|
const realValue = getValueForRadioButton(value);
|
|
36
36
|
const realContextValue = getValueForRadioButton(contextValue);
|
|
37
|
-
const isSelected = selected
|
|
37
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
38
38
|
const handlePress = () => {
|
|
39
|
-
onPress
|
|
40
|
-
onValueChange
|
|
39
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
40
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
41
41
|
};
|
|
42
42
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
43
43
|
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|