@draftbit/core 46.1.4-e6469c.0 → 46.2.1-de631b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/ActionSheet/index.js.map +1 -1
- package/lib/commonjs/components/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/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/DatePicker/DatePicker.js +3 -3
- package/lib/module/components/DatePicker/DatePicker.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/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/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/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
|
@@ -15,9 +15,10 @@ function Pager({ color, index, length, }) {
|
|
|
15
15
|
})));
|
|
16
16
|
}
|
|
17
17
|
function Carousel({ data, children, dotColor = "strong", style, ...rest }) {
|
|
18
|
+
var _a;
|
|
18
19
|
const [index, setIndex] = React.useState(0);
|
|
19
20
|
const length = React.Children.count(children);
|
|
20
|
-
const itemsLength = (data
|
|
21
|
+
const itemsLength = ((_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : 0) + length;
|
|
21
22
|
const slides = Array.isArray(data) ? data : [];
|
|
22
23
|
const { width, height } = StyleSheet.flatten(style || {});
|
|
23
24
|
const slideWidth = width || screenWidth;
|
|
@@ -35,7 +36,8 @@ function Carousel({ data, children, dotColor = "strong", style, ...rest }) {
|
|
|
35
36
|
})
|
|
36
37
|
: null,
|
|
37
38
|
React.Children.map(children, (child) => {
|
|
38
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
const s = ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.style) || {};
|
|
39
41
|
return (React.createElement(View, { style: { width: slideWidth } }, React.cloneElement(child, {
|
|
40
42
|
style: { ...s, width: slideWidth },
|
|
41
43
|
})));
|
|
@@ -25,12 +25,12 @@ const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck,
|
|
|
25
25
|
const handlePress = () => {
|
|
26
26
|
const newValue = !internalValue;
|
|
27
27
|
setInternalValue(newValue);
|
|
28
|
-
onPress
|
|
28
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(newValue);
|
|
29
29
|
if (newValue) {
|
|
30
|
-
onCheck
|
|
30
|
+
onCheck === null || onCheck === void 0 ? void 0 : onCheck();
|
|
31
31
|
}
|
|
32
32
|
if (!newValue) {
|
|
33
|
-
onUncheck
|
|
33
|
+
onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
return (React.createElement(Touchable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
|
|
@@ -36,8 +36,8 @@ const CheckboxGroupRow = ({ Icon, label = "Label", status, value, onPress, label
|
|
|
36
36
|
const isChecked = status || values.includes(value);
|
|
37
37
|
const handlePress = () => {
|
|
38
38
|
if (!disabled) {
|
|
39
|
-
onPress
|
|
40
|
-
onValueChange
|
|
39
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(!isChecked);
|
|
40
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(value, !isChecked);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
@@ -37,12 +37,12 @@ const CheckboxRow = ({ label = "Label", labelStyle, labelContainerStyle, checkbo
|
|
|
37
37
|
const handlePress = () => {
|
|
38
38
|
const newValue = !internalValue;
|
|
39
39
|
setInternalValue(newValue);
|
|
40
|
-
onPress
|
|
40
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(newValue);
|
|
41
41
|
if (newValue) {
|
|
42
|
-
onCheck
|
|
42
|
+
onCheck === null || onCheck === void 0 ? void 0 : onCheck();
|
|
43
43
|
}
|
|
44
44
|
if (!newValue) {
|
|
45
|
-
onUncheck
|
|
45
|
+
onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
@@ -2,33 +2,36 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { Svg, Path, G } from "react-native-svg";
|
|
4
4
|
class CircularProgress extends React.Component {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
|
|
8
|
+
var angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
|
9
|
+
return {
|
|
10
|
+
x: centerX + radius * Math.cos(angleInRadians),
|
|
11
|
+
y: centerY + radius * Math.sin(angleInRadians),
|
|
12
|
+
};
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
this.circlePath = (x, y, radius, startAngle, endAngle) => {
|
|
15
|
+
var start = this.polarToCartesian(x, y, radius, endAngle * 0.9999);
|
|
16
|
+
var end = this.polarToCartesian(x, y, radius, startAngle);
|
|
17
|
+
var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
|
|
18
|
+
var d = [
|
|
19
|
+
"M",
|
|
20
|
+
start.x,
|
|
21
|
+
start.y,
|
|
22
|
+
"A",
|
|
23
|
+
radius,
|
|
24
|
+
radius,
|
|
25
|
+
0,
|
|
26
|
+
largeArcFlag,
|
|
27
|
+
0,
|
|
28
|
+
end.x,
|
|
29
|
+
end.y,
|
|
30
|
+
];
|
|
31
|
+
return d.join(" ");
|
|
32
|
+
};
|
|
33
|
+
this.clampFill = (fill) => Math.min(100, Math.max(0, fill));
|
|
34
|
+
}
|
|
32
35
|
render() {
|
|
33
36
|
const { size, width, backgroundWidth, tintColor = "black", tintTransparency = true, backgroundColor, style, rotation = 90, lineCap = "butt", arcSweepAngle = 360, fill, children, childrenContainerStyle, padding = 0, renderCap, dashedBackground = { width: 0, gap: 0 }, dashedTint = { width: 0, gap: 0 }, } = this.props;
|
|
34
37
|
const maxWidthCircle = backgroundWidth
|
|
@@ -40,7 +40,7 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
|
|
|
40
40
|
if (!value) {
|
|
41
41
|
return new Date();
|
|
42
42
|
}
|
|
43
|
-
return typeof value
|
|
43
|
+
return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
|
|
44
44
|
};
|
|
45
45
|
const formatDate = () => {
|
|
46
46
|
if (!value)
|
|
@@ -34,7 +34,7 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
34
34
|
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
35
35
|
const number = parseFloat(newStringNumberValue);
|
|
36
36
|
setCurrentStringNumberValue(newStringNumberValue);
|
|
37
|
-
onChangeText
|
|
37
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(number);
|
|
38
38
|
};
|
|
39
39
|
// run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
|
|
40
40
|
useEffect(() => {
|
|
@@ -36,6 +36,7 @@ const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
|
36
36
|
const disabledColor = "rgb(240, 240, 240)";
|
|
37
37
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
38
38
|
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, theme, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
|
|
39
|
+
var _a, _b;
|
|
39
40
|
const androidPickerRef = React.useRef(undefined);
|
|
40
41
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
41
42
|
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
@@ -53,8 +54,9 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
53
54
|
}
|
|
54
55
|
}, [defaultValue]);
|
|
55
56
|
React.useEffect(() => {
|
|
57
|
+
var _a;
|
|
56
58
|
if (pickerVisible && androidPickerRef.current) {
|
|
57
|
-
androidPickerRef
|
|
59
|
+
(_a = androidPickerRef === null || androidPickerRef === void 0 ? void 0 : androidPickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
58
60
|
}
|
|
59
61
|
}, [pickerVisible, androidPickerRef]);
|
|
60
62
|
const normalizedOptions = normalizeOptions(options);
|
|
@@ -113,10 +115,8 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
113
115
|
...additionalBorderStyles,
|
|
114
116
|
...additionalMarginStyles,
|
|
115
117
|
]);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
: { label: null };
|
|
119
|
-
const selectedLabel = optionExists && optionExists.label ? optionExists.label : placeholder;
|
|
118
|
+
const selectedLabel = internalValue &&
|
|
119
|
+
((_b = (_a = pickerOptions.find((option) => option.value === internalValue)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : internalValue);
|
|
120
120
|
const labelText = label ? (React.createElement(Text, { style: {
|
|
121
121
|
textAlign: textStyles.textAlign,
|
|
122
122
|
color: unstyledColor,
|
|
@@ -132,7 +132,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
132
132
|
marginRight: -10,
|
|
133
133
|
marginLeft: 8,
|
|
134
134
|
} })) : null;
|
|
135
|
-
const textAlign = textStyles
|
|
135
|
+
const textAlign = textStyles === null || textStyles === void 0 ? void 0 : textStyles.textAlign;
|
|
136
136
|
const calculateLeftPadding = () => {
|
|
137
137
|
if (leftIconOutset) {
|
|
138
138
|
if (textAlign === "center") {
|
|
@@ -159,7 +159,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
159
159
|
};
|
|
160
160
|
const handleValueChange = (newValue, itemIndex) => {
|
|
161
161
|
if (!placeholder || itemIndex > 0) {
|
|
162
|
-
onValueChange
|
|
162
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue, itemIndex);
|
|
163
163
|
}
|
|
164
164
|
setInternalValue(newValue);
|
|
165
165
|
};
|
|
@@ -179,7 +179,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
179
179
|
] },
|
|
180
180
|
React.createElement(View, { style: styles.primaryTextContainer },
|
|
181
181
|
labelText,
|
|
182
|
-
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel))),
|
|
182
|
+
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel !== null && selectedLabel !== void 0 ? selectedLabel : placeholder))),
|
|
183
183
|
rightIcon)),
|
|
184
184
|
assistiveTextLabel),
|
|
185
185
|
isIos && pickerVisible ? (React.createElement(Portal, null,
|
|
@@ -212,12 +212,12 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
212
212
|
...additionalMarginStyles,
|
|
213
213
|
]);
|
|
214
214
|
|
|
215
|
-
const optionExists = internalValue
|
|
216
|
-
? pickerOptions.find((option) => option.value === internalValue)
|
|
217
|
-
: { label: null };
|
|
218
|
-
|
|
219
215
|
const selectedLabel =
|
|
220
|
-
|
|
216
|
+
internalValue &&
|
|
217
|
+
((pickerOptions as unknown as PickerOption[]).find(
|
|
218
|
+
(option) => option.value === internalValue
|
|
219
|
+
)?.label ??
|
|
220
|
+
internalValue);
|
|
221
221
|
|
|
222
222
|
const labelText = label ? (
|
|
223
223
|
<Text
|
|
@@ -333,7 +333,9 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
333
333
|
<View style={styles.primaryTextContainer}>
|
|
334
334
|
{labelText}
|
|
335
335
|
|
|
336
|
-
<Text style={primaryTextStyle}>
|
|
336
|
+
<Text style={primaryTextStyle}>
|
|
337
|
+
{String(selectedLabel ?? placeholder)}
|
|
338
|
+
</Text>
|
|
337
339
|
</View>
|
|
338
340
|
|
|
339
341
|
{rightIcon}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import omit from "lodash.omit";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
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
|
+
opacity: 0,
|
|
50
|
+
position: "absolute",
|
|
51
|
+
top: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
width: "100%",
|
|
56
|
+
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
57
|
+
React.createElement(View, { pointerEvents: "none" },
|
|
58
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
ref: textField, disabled: disabled,
|
|
61
|
+
// @ts-expect-error
|
|
62
|
+
style: stylesWithoutMargin })))));
|
|
63
|
+
};
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
container: {
|
|
66
|
+
alignSelf: "stretch",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
export default withTheme(Picker);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import omit from "lodash.omit";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
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
|
+
opacity: 0,
|
|
81
|
+
position: "absolute",
|
|
82
|
+
top: 0,
|
|
83
|
+
left: 0,
|
|
84
|
+
right: 0,
|
|
85
|
+
bottom: 0,
|
|
86
|
+
width: "100%",
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{options.map((o) => (
|
|
90
|
+
<NativePicker.Item label={o.label} value={o.value} key={o.value} />
|
|
91
|
+
))}
|
|
92
|
+
</NativePicker>
|
|
93
|
+
<View pointerEvents="none">
|
|
94
|
+
<TextField
|
|
95
|
+
{...props}
|
|
96
|
+
value={selectedLabel}
|
|
97
|
+
placeholder={placeholder}
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
100
|
+
disabled={disabled}
|
|
101
|
+
// @ts-expect-error
|
|
102
|
+
style={stylesWithoutMargin}
|
|
103
|
+
/>
|
|
104
|
+
</View>
|
|
105
|
+
</View>
|
|
106
|
+
</Touchable>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const styles = StyleSheet.create({
|
|
111
|
+
container: {
|
|
112
|
+
alignSelf: "stretch",
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export default withTheme(Picker);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import omit from "lodash.omit";
|
|
5
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
|
+
import { withTheme } from "../../theming";
|
|
7
|
+
import Portal from "../Portal/Portal";
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
|
+
import TextField from "../TextField";
|
|
10
|
+
import Touchable from "../Touchable";
|
|
11
|
+
import { extractStyles } from "../../utilities";
|
|
12
|
+
const Picker = ({ Icon, style, options, placeholder, selectedValue, disabled = false, onValueChange = () => { }, theme: { colors }, ...props }) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
+
borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
17
|
+
borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
18
|
+
borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
19
|
+
borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
+
borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
21
|
+
backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
22
|
+
padding, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
23
|
+
paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
+
paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
25
|
+
paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
26
|
+
paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
27
|
+
...viewStyles }, } = extractStyles(style);
|
|
28
|
+
const textField = React.useRef(undefined);
|
|
29
|
+
const [pickerVisible, setIsPickerVisible] = React.useState(false);
|
|
30
|
+
const toggleVisibility = () => {
|
|
31
|
+
setIsPickerVisible(!pickerVisible);
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
|
|
34
|
+
};
|
|
35
|
+
const stylesWithoutMargin = style &&
|
|
36
|
+
omit(StyleSheet.flatten(style), [
|
|
37
|
+
"margin",
|
|
38
|
+
"marginTop",
|
|
39
|
+
"marginRight",
|
|
40
|
+
"marginBottom",
|
|
41
|
+
"marginLeft",
|
|
42
|
+
]);
|
|
43
|
+
const selectedLabel = selectedValue &&
|
|
44
|
+
((_b = (_a = options.find((o) => o.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : selectedValue);
|
|
45
|
+
return (React.createElement(View, { style: [styles.container, viewStyles] },
|
|
46
|
+
React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
|
|
47
|
+
React.createElement(TextField, { ...props, value: String(selectedLabel), placeholder: placeholder,
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
ref: textField, disabled: disabled, pointerEvents: "none",
|
|
50
|
+
// @ts-expect-error
|
|
51
|
+
style: stylesWithoutMargin, Icon: Icon })),
|
|
52
|
+
pickerVisible && (React.createElement(Portal, null,
|
|
53
|
+
React.createElement(View, { style: [styles.picker, { backgroundColor: colors.divider }] },
|
|
54
|
+
React.createElement(SafeAreaView, { style: styles.pickerContainer },
|
|
55
|
+
React.createElement(Button, { Icon: Icon, type: "text", onPress: toggleVisibility, style: styles.closeButton }, "Close"),
|
|
56
|
+
React.createElement(NativePicker, { style: { backgroundColor: "white" }, selectedValue: selectedValue, onValueChange: onValueChange }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value }))))))))));
|
|
57
|
+
};
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
container: {
|
|
60
|
+
alignSelf: "stretch",
|
|
61
|
+
},
|
|
62
|
+
picker: {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
bottom: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
right: 0,
|
|
67
|
+
flexDirection: "row",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
},
|
|
70
|
+
pickerContainer: {
|
|
71
|
+
backgroundColor: "white",
|
|
72
|
+
flexDirection: "column",
|
|
73
|
+
width: "100%",
|
|
74
|
+
},
|
|
75
|
+
closeButton: {
|
|
76
|
+
alignSelf: "flex-end",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
export default withTheme(Picker);
|
|
@@ -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);
|