@draftbit/core 44.1.12-ee6c2c.1 → 44.1.13-cd2af3.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/Picker/Picker.js +50 -54
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +59 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +87 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +59 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js +6 -0
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +52 -48
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +41 -0
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.ios.js +64 -0
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.web.js +41 -0
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/mappings/KeyboardAwareScrollView.js +7 -1
- package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +13 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
- package/lib/typescript/src/mappings/KeyboardAwareScrollView.d.ts +11 -0
- package/package.json +3 -3
- package/src/components/Picker/Picker.js +39 -20
- package/src/components/Picker/Picker.tsx +55 -18
- package/src/components/Picker/PickerComponent.android.js +20 -0
- package/src/components/Picker/PickerComponent.android.tsx +59 -0
- package/src/components/Picker/PickerComponent.ios.js +40 -0
- package/src/components/Picker/PickerComponent.ios.tsx +86 -0
- package/src/components/Picker/PickerComponent.web.js +20 -0
- package/src/components/Picker/PickerComponent.web.tsx +59 -0
- package/src/mappings/KeyboardAwareScrollView.js +7 -1
- package/src/mappings/KeyboardAwareScrollView.ts +8 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Text,
|
|
2
|
+
import { View, StyleSheet, Text, Dimensions, } from "react-native";
|
|
3
3
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
4
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
6
|
import { withTheme } from "../../theming";
|
|
7
|
-
import Portal from "../Portal/Portal";
|
|
8
|
-
import Button from "../DeprecatedButton";
|
|
7
|
+
// import Portal from "../Portal/Portal";
|
|
8
|
+
// import Button from "../DeprecatedButton";
|
|
9
9
|
import Touchable from "../Touchable";
|
|
10
10
|
import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
import { PickerComponent } from "./PickerComponent";
|
|
11
13
|
function normalizeOptions(options) {
|
|
12
14
|
if (options.length === 0) {
|
|
13
15
|
return [];
|
|
@@ -30,12 +32,20 @@ function normalizeOptions(options) {
|
|
|
30
32
|
}
|
|
31
33
|
throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
|
|
32
34
|
}
|
|
35
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
36
|
+
// const isIos = Platform.OS === "ios";
|
|
33
37
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
34
38
|
const disabledColor = "rgb(240, 240, 240)";
|
|
35
39
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
36
|
-
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
40
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
41
|
+
// theme,
|
|
42
|
+
assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
|
|
43
|
+
const androidPickerRef = React.useRef(undefined);
|
|
37
44
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
38
|
-
const [pickerVisible,
|
|
45
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
46
|
+
const togglePickerVisible = () => {
|
|
47
|
+
setPickerVisible(!pickerVisible);
|
|
48
|
+
};
|
|
39
49
|
React.useEffect(() => {
|
|
40
50
|
if (value != null) {
|
|
41
51
|
setInternalValue(value);
|
|
@@ -46,11 +56,16 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
46
56
|
setInternalValue(defaultValue);
|
|
47
57
|
}
|
|
48
58
|
}, [defaultValue]);
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (pickerVisible && androidPickerRef.current) {
|
|
61
|
+
androidPickerRef?.current?.focus();
|
|
62
|
+
}
|
|
63
|
+
}, [pickerVisible, androidPickerRef]);
|
|
49
64
|
const normalizedOptions = normalizeOptions(options);
|
|
50
65
|
const pickerOptions = placeholder
|
|
51
66
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
52
67
|
: normalizedOptions;
|
|
53
|
-
const { colors } = theme;
|
|
68
|
+
// const { colors } = theme;
|
|
54
69
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
55
70
|
const additionalBorderStyles = ["backgroundColor"];
|
|
56
71
|
const additionalMarginStyles = [
|
|
@@ -96,7 +111,6 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
96
111
|
height: 60,
|
|
97
112
|
...extractedMarginStyles,
|
|
98
113
|
};
|
|
99
|
-
const platform = Platform.OS;
|
|
100
114
|
const stylesWithoutBordersAndMargins = omit(viewStyles, [
|
|
101
115
|
...borderStyleNames,
|
|
102
116
|
...marginStyleNames,
|
|
@@ -171,23 +185,22 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
171
185
|
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
|
|
172
186
|
rightIcon)),
|
|
173
187
|
assistiveTextLabel),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
183
|
-
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
|
|
184
|
-
platform !== "ios" ? (React.createElement(NativePicker, { enabled: !disabled, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
|
|
188
|
+
React.createElement(View, null, pickerVisible ? (React.createElement(PickerComponent, { ...{
|
|
189
|
+
Icon,
|
|
190
|
+
androidPickerRef,
|
|
191
|
+
togglePickerVisible,
|
|
192
|
+
pickerOptions,
|
|
193
|
+
internalValue,
|
|
194
|
+
handleValueChange,
|
|
195
|
+
} })) : null)));
|
|
185
196
|
};
|
|
186
197
|
export default withTheme(Picker);
|
|
187
198
|
const styles = StyleSheet.create({
|
|
188
199
|
marginsContainer: {
|
|
189
200
|
alignSelf: "stretch",
|
|
190
201
|
alignItems: "center",
|
|
202
|
+
width: "100%",
|
|
203
|
+
maxWidth: deviceWidth,
|
|
191
204
|
},
|
|
192
205
|
touchableContainer: {
|
|
193
206
|
flex: 1,
|
|
@@ -224,11 +237,15 @@ const styles = StyleSheet.create({
|
|
|
224
237
|
right: 0,
|
|
225
238
|
flexDirection: "row",
|
|
226
239
|
justifyContent: "center",
|
|
240
|
+
width: "100%",
|
|
241
|
+
maxWidth: deviceWidth,
|
|
242
|
+
maxHeight: deviceHeight,
|
|
227
243
|
},
|
|
228
244
|
iosSafeArea: {
|
|
229
245
|
backgroundColor: "white",
|
|
230
246
|
flexDirection: "column",
|
|
231
247
|
width: "100%",
|
|
248
|
+
maxWidth: deviceWidth,
|
|
232
249
|
},
|
|
233
250
|
iosButton: {
|
|
234
251
|
alignSelf: "flex-end",
|
|
@@ -244,5 +261,7 @@ const styles = StyleSheet.create({
|
|
|
244
261
|
right: 0,
|
|
245
262
|
bottom: 0,
|
|
246
263
|
width: "100%",
|
|
264
|
+
maxWidth: deviceWidth,
|
|
265
|
+
maxHeight: deviceHeight,
|
|
247
266
|
},
|
|
248
267
|
});
|
|
@@ -3,17 +3,18 @@ import {
|
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
5
|
Text,
|
|
6
|
-
Platform,
|
|
6
|
+
// Platform,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
StyleProp,
|
|
9
|
+
Dimensions,
|
|
9
10
|
} from "react-native";
|
|
10
11
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
11
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
12
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
12
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
13
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
13
14
|
|
|
14
15
|
import { withTheme } from "../../theming";
|
|
15
|
-
import Portal from "../Portal/Portal";
|
|
16
|
-
import Button from "../DeprecatedButton";
|
|
16
|
+
// import Portal from "../Portal/Portal";
|
|
17
|
+
// import Button from "../DeprecatedButton";
|
|
17
18
|
import Touchable from "../Touchable";
|
|
18
19
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
19
20
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -23,6 +24,8 @@ import {
|
|
|
23
24
|
borderStyleNames,
|
|
24
25
|
marginStyleNames,
|
|
25
26
|
} from "../../utilities";
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
import { PickerComponent } from "./PickerComponent";
|
|
26
29
|
|
|
27
30
|
export interface PickerOption {
|
|
28
31
|
value: string;
|
|
@@ -81,6 +84,8 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
|
|
|
81
84
|
);
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
88
|
+
// const isIos = Platform.OS === "ios";
|
|
84
89
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
85
90
|
const disabledColor = "rgb(240, 240, 240)";
|
|
86
91
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
@@ -95,7 +100,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
95
100
|
placeholder,
|
|
96
101
|
value,
|
|
97
102
|
disabled = false,
|
|
98
|
-
theme,
|
|
103
|
+
// theme,
|
|
99
104
|
assistiveText,
|
|
100
105
|
label,
|
|
101
106
|
iconColor = unstyledColor,
|
|
@@ -106,14 +111,17 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
106
111
|
rightIconName,
|
|
107
112
|
type = "solid",
|
|
108
113
|
}) => {
|
|
114
|
+
const androidPickerRef = React.useRef<any | undefined>(undefined);
|
|
115
|
+
|
|
109
116
|
const [internalValue, setInternalValue] = React.useState<string | undefined>(
|
|
110
117
|
value || defaultValue
|
|
111
118
|
);
|
|
112
119
|
|
|
113
|
-
const [pickerVisible,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
121
|
+
|
|
122
|
+
const togglePickerVisible = () => {
|
|
123
|
+
setPickerVisible(!pickerVisible);
|
|
124
|
+
};
|
|
117
125
|
|
|
118
126
|
React.useEffect(() => {
|
|
119
127
|
if (value != null) {
|
|
@@ -127,13 +135,19 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
127
135
|
}
|
|
128
136
|
}, [defaultValue]);
|
|
129
137
|
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (pickerVisible && androidPickerRef.current) {
|
|
140
|
+
androidPickerRef?.current?.focus();
|
|
141
|
+
}
|
|
142
|
+
}, [pickerVisible, androidPickerRef]);
|
|
143
|
+
|
|
130
144
|
const normalizedOptions = normalizeOptions(options);
|
|
131
145
|
|
|
132
146
|
const pickerOptions = placeholder
|
|
133
147
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
134
148
|
: normalizedOptions;
|
|
135
149
|
|
|
136
|
-
const { colors } = theme;
|
|
150
|
+
// const { colors } = theme;
|
|
137
151
|
|
|
138
152
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
139
153
|
|
|
@@ -193,8 +207,6 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
193
207
|
...extractedMarginStyles,
|
|
194
208
|
};
|
|
195
209
|
|
|
196
|
-
const platform = Platform.OS;
|
|
197
|
-
|
|
198
210
|
const stylesWithoutBordersAndMargins = omit(viewStyles, [
|
|
199
211
|
...borderStyleNames,
|
|
200
212
|
...marginStyleNames,
|
|
@@ -334,8 +346,23 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
334
346
|
{assistiveTextLabel}
|
|
335
347
|
</Touchable>
|
|
336
348
|
|
|
349
|
+
<View>
|
|
350
|
+
{pickerVisible ? (
|
|
351
|
+
<PickerComponent
|
|
352
|
+
{...{
|
|
353
|
+
Icon,
|
|
354
|
+
androidPickerRef,
|
|
355
|
+
togglePickerVisible,
|
|
356
|
+
pickerOptions,
|
|
357
|
+
internalValue,
|
|
358
|
+
handleValueChange,
|
|
359
|
+
}}
|
|
360
|
+
/>
|
|
361
|
+
) : null}
|
|
362
|
+
</View>
|
|
363
|
+
|
|
337
364
|
{/* iosPicker */}
|
|
338
|
-
{
|
|
365
|
+
{/* isIos && pickerVisible ? (
|
|
339
366
|
<Portal>
|
|
340
367
|
<View
|
|
341
368
|
style={[
|
|
@@ -371,15 +398,17 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
371
398
|
</SafeAreaView>
|
|
372
399
|
</View>
|
|
373
400
|
</Portal>
|
|
374
|
-
) : null}
|
|
401
|
+
) : null */}
|
|
375
402
|
|
|
376
403
|
{/* nonIosPicker */}
|
|
377
|
-
{
|
|
404
|
+
{/* !isIos && pickerVisible ? (
|
|
378
405
|
<NativePicker
|
|
379
|
-
enabled={
|
|
406
|
+
enabled={pickerVisible}
|
|
380
407
|
selectedValue={internalValue}
|
|
381
408
|
onValueChange={handleValueChange}
|
|
382
409
|
style={styles.nonIosPicker}
|
|
410
|
+
ref={androidPickerRef}
|
|
411
|
+
onBlur={() => setPickerVisible(false)}
|
|
383
412
|
>
|
|
384
413
|
{(pickerOptions as unknown as PickerOption[]).map((option) => (
|
|
385
414
|
<NativePicker.Item
|
|
@@ -389,7 +418,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
389
418
|
/>
|
|
390
419
|
))}
|
|
391
420
|
</NativePicker>
|
|
392
|
-
) : null}
|
|
421
|
+
) : null */}
|
|
393
422
|
</View>
|
|
394
423
|
);
|
|
395
424
|
};
|
|
@@ -400,6 +429,8 @@ const styles = StyleSheet.create({
|
|
|
400
429
|
marginsContainer: {
|
|
401
430
|
alignSelf: "stretch",
|
|
402
431
|
alignItems: "center",
|
|
432
|
+
width: "100%",
|
|
433
|
+
maxWidth: deviceWidth,
|
|
403
434
|
},
|
|
404
435
|
touchableContainer: {
|
|
405
436
|
flex: 1,
|
|
@@ -436,11 +467,15 @@ const styles = StyleSheet.create({
|
|
|
436
467
|
right: 0,
|
|
437
468
|
flexDirection: "row",
|
|
438
469
|
justifyContent: "center",
|
|
470
|
+
width: "100%",
|
|
471
|
+
maxWidth: deviceWidth,
|
|
472
|
+
maxHeight: deviceHeight,
|
|
439
473
|
},
|
|
440
474
|
iosSafeArea: {
|
|
441
475
|
backgroundColor: "white",
|
|
442
476
|
flexDirection: "column",
|
|
443
477
|
width: "100%",
|
|
478
|
+
maxWidth: deviceWidth,
|
|
444
479
|
},
|
|
445
480
|
iosButton: {
|
|
446
481
|
alignSelf: "flex-end",
|
|
@@ -456,5 +491,7 @@ const styles = StyleSheet.create({
|
|
|
456
491
|
right: 0,
|
|
457
492
|
bottom: 0,
|
|
458
493
|
width: "100%",
|
|
494
|
+
maxWidth: deviceWidth,
|
|
495
|
+
maxHeight: deviceHeight,
|
|
459
496
|
},
|
|
460
497
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
5
|
+
export const PickerComponent = ({ androidPickerRef, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
|
|
6
|
+
return (React.createElement(NativePicker, { selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: togglePickerVisible }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
|
|
7
|
+
};
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
nonIosPicker: {
|
|
10
|
+
opacity: 0,
|
|
11
|
+
position: "absolute",
|
|
12
|
+
top: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: deviceWidth,
|
|
18
|
+
maxHeight: deviceHeight,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
|
|
6
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
7
|
+
|
|
8
|
+
import { PickerOption } from "./Picker";
|
|
9
|
+
|
|
10
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
11
|
+
|
|
12
|
+
interface PickerComponentProps {
|
|
13
|
+
Icon: IconSlot["Icon"];
|
|
14
|
+
androidPickerRef: React.RefObject<any>;
|
|
15
|
+
togglePickerVisible: () => void;
|
|
16
|
+
pickerOptions: PickerOption[];
|
|
17
|
+
internalValue: string | undefined;
|
|
18
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const PickerComponent: React.FC<PickerComponentProps> = ({
|
|
22
|
+
androidPickerRef,
|
|
23
|
+
togglePickerVisible,
|
|
24
|
+
pickerOptions,
|
|
25
|
+
internalValue,
|
|
26
|
+
handleValueChange,
|
|
27
|
+
}) => {
|
|
28
|
+
return (
|
|
29
|
+
<NativePicker
|
|
30
|
+
selectedValue={internalValue}
|
|
31
|
+
onValueChange={handleValueChange}
|
|
32
|
+
style={styles.nonIosPicker}
|
|
33
|
+
ref={androidPickerRef}
|
|
34
|
+
onBlur={togglePickerVisible}
|
|
35
|
+
>
|
|
36
|
+
{(pickerOptions as unknown as PickerOption[]).map((option) => (
|
|
37
|
+
<NativePicker.Item
|
|
38
|
+
label={option.label}
|
|
39
|
+
value={option.value}
|
|
40
|
+
key={option.value}
|
|
41
|
+
/>
|
|
42
|
+
))}
|
|
43
|
+
</NativePicker>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
nonIosPicker: {
|
|
49
|
+
opacity: 0,
|
|
50
|
+
position: "absolute",
|
|
51
|
+
top: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
width: "100%",
|
|
56
|
+
maxWidth: deviceWidth,
|
|
57
|
+
maxHeight: deviceHeight,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
import Portal from "../Portal/Portal";
|
|
6
|
+
import Button from "../DeprecatedButton";
|
|
7
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
8
|
+
export const PickerComponent = ({ Icon, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
|
|
9
|
+
return (React.createElement(Portal, null,
|
|
10
|
+
React.createElement(View, { style: styles.iosPicker },
|
|
11
|
+
React.createElement(SafeAreaView, { style: styles.iosSafeArea },
|
|
12
|
+
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
13
|
+
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))))));
|
|
14
|
+
};
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
iosPicker: {
|
|
17
|
+
position: "absolute",
|
|
18
|
+
bottom: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
justifyContent: "center",
|
|
23
|
+
width: "100%",
|
|
24
|
+
maxWidth: deviceWidth,
|
|
25
|
+
maxHeight: deviceHeight,
|
|
26
|
+
backgroundColor: "rgba(234, 237, 242, 1)",
|
|
27
|
+
},
|
|
28
|
+
iosSafeArea: {
|
|
29
|
+
backgroundColor: "white",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
width: "100%",
|
|
32
|
+
maxWidth: deviceWidth,
|
|
33
|
+
},
|
|
34
|
+
iosButton: {
|
|
35
|
+
alignSelf: "flex-end",
|
|
36
|
+
},
|
|
37
|
+
iosNativePicker: {
|
|
38
|
+
backgroundColor: "white",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
|
|
6
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
7
|
+
import Portal from "../Portal/Portal";
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
|
+
import { PickerOption } from "./Picker";
|
|
10
|
+
|
|
11
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
12
|
+
|
|
13
|
+
interface PickerComponentProps {
|
|
14
|
+
Icon: IconSlot["Icon"];
|
|
15
|
+
androidPickerRef: React.RefObject<any>;
|
|
16
|
+
togglePickerVisible: () => void;
|
|
17
|
+
pickerOptions: PickerOption[];
|
|
18
|
+
internalValue: string | undefined;
|
|
19
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PickerComponent: React.FC<PickerComponentProps> = ({
|
|
23
|
+
Icon,
|
|
24
|
+
togglePickerVisible,
|
|
25
|
+
pickerOptions,
|
|
26
|
+
internalValue,
|
|
27
|
+
handleValueChange,
|
|
28
|
+
}) => {
|
|
29
|
+
return (
|
|
30
|
+
<Portal>
|
|
31
|
+
<View style={styles.iosPicker}>
|
|
32
|
+
<SafeAreaView style={styles.iosSafeArea}>
|
|
33
|
+
<Button
|
|
34
|
+
Icon={Icon}
|
|
35
|
+
type="text"
|
|
36
|
+
onPress={togglePickerVisible}
|
|
37
|
+
style={styles.iosButton}
|
|
38
|
+
>
|
|
39
|
+
{"Close"}
|
|
40
|
+
</Button>
|
|
41
|
+
|
|
42
|
+
<NativePicker
|
|
43
|
+
style={styles.iosNativePicker}
|
|
44
|
+
selectedValue={internalValue}
|
|
45
|
+
onValueChange={handleValueChange}
|
|
46
|
+
>
|
|
47
|
+
{(pickerOptions as unknown as PickerOption[]).map((option) => (
|
|
48
|
+
<NativePicker.Item
|
|
49
|
+
label={option.label}
|
|
50
|
+
value={option.value}
|
|
51
|
+
key={option.value}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
</NativePicker>
|
|
55
|
+
</SafeAreaView>
|
|
56
|
+
</View>
|
|
57
|
+
</Portal>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
iosPicker: {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
bottom: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
right: 0,
|
|
67
|
+
flexDirection: "row",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
width: "100%",
|
|
70
|
+
maxWidth: deviceWidth,
|
|
71
|
+
maxHeight: deviceHeight,
|
|
72
|
+
backgroundColor: "rgba(234, 237, 242, 1)",
|
|
73
|
+
},
|
|
74
|
+
iosSafeArea: {
|
|
75
|
+
backgroundColor: "white",
|
|
76
|
+
flexDirection: "column",
|
|
77
|
+
width: "100%",
|
|
78
|
+
maxWidth: deviceWidth,
|
|
79
|
+
},
|
|
80
|
+
iosButton: {
|
|
81
|
+
alignSelf: "flex-end",
|
|
82
|
+
},
|
|
83
|
+
iosNativePicker: {
|
|
84
|
+
backgroundColor: "white",
|
|
85
|
+
},
|
|
86
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
5
|
+
export const PickerComponent = ({ androidPickerRef, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
|
|
6
|
+
return (React.createElement(NativePicker, { selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: togglePickerVisible }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
|
|
7
|
+
};
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
nonIosPicker: {
|
|
10
|
+
opacity: 0,
|
|
11
|
+
position: "absolute",
|
|
12
|
+
top: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: deviceWidth,
|
|
18
|
+
maxHeight: deviceHeight,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
|
|
6
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
7
|
+
|
|
8
|
+
import { PickerOption } from "./Picker";
|
|
9
|
+
|
|
10
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
11
|
+
|
|
12
|
+
interface PickerComponentProps {
|
|
13
|
+
Icon: IconSlot["Icon"];
|
|
14
|
+
androidPickerRef: React.RefObject<any>;
|
|
15
|
+
togglePickerVisible: () => void;
|
|
16
|
+
pickerOptions: PickerOption[];
|
|
17
|
+
internalValue: string | undefined;
|
|
18
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const PickerComponent: React.FC<PickerComponentProps> = ({
|
|
22
|
+
androidPickerRef,
|
|
23
|
+
togglePickerVisible,
|
|
24
|
+
pickerOptions,
|
|
25
|
+
internalValue,
|
|
26
|
+
handleValueChange,
|
|
27
|
+
}) => {
|
|
28
|
+
return (
|
|
29
|
+
<NativePicker
|
|
30
|
+
selectedValue={internalValue}
|
|
31
|
+
onValueChange={handleValueChange}
|
|
32
|
+
style={styles.nonIosPicker}
|
|
33
|
+
ref={androidPickerRef}
|
|
34
|
+
onBlur={togglePickerVisible}
|
|
35
|
+
>
|
|
36
|
+
{(pickerOptions as unknown as PickerOption[]).map((option) => (
|
|
37
|
+
<NativePicker.Item
|
|
38
|
+
label={option.label}
|
|
39
|
+
value={option.value}
|
|
40
|
+
key={option.value}
|
|
41
|
+
/>
|
|
42
|
+
))}
|
|
43
|
+
</NativePicker>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
nonIosPicker: {
|
|
49
|
+
opacity: 0,
|
|
50
|
+
position: "absolute",
|
|
51
|
+
top: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
width: "100%",
|
|
56
|
+
maxWidth: deviceWidth,
|
|
57
|
+
maxHeight: deviceHeight,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createStaticBoolProp, createStaticNumberProp, } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, createStaticBoolProp, createStaticNumberProp, createTextEnumProp, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Keyboard Aware Scroll View",
|
|
4
4
|
tag: "KeyboardAwareScrollView",
|
|
@@ -39,5 +39,11 @@ export const SEED_DATA = {
|
|
|
39
39
|
description: "Show or hide the vertical scroll indicator",
|
|
40
40
|
defaultValue: true,
|
|
41
41
|
}),
|
|
42
|
+
keyboardShouldPersistTaps: createTextEnumProp({
|
|
43
|
+
label: "Allow Touch Events",
|
|
44
|
+
description: "Allows touch events on visible components to be processed while the keyboard is open",
|
|
45
|
+
defaultValue: "never",
|
|
46
|
+
options: ["never", "always"],
|
|
47
|
+
}),
|
|
42
48
|
},
|
|
43
49
|
};
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
COMPONENT_TYPES,
|
|
3
3
|
createStaticBoolProp,
|
|
4
4
|
createStaticNumberProp,
|
|
5
|
+
createTextEnumProp,
|
|
5
6
|
} from "@draftbit/types";
|
|
6
7
|
|
|
7
8
|
export const SEED_DATA = {
|
|
@@ -49,5 +50,12 @@ export const SEED_DATA = {
|
|
|
49
50
|
description: "Show or hide the vertical scroll indicator",
|
|
50
51
|
defaultValue: true,
|
|
51
52
|
}),
|
|
53
|
+
keyboardShouldPersistTaps: createTextEnumProp({
|
|
54
|
+
label: "Allow Touch Events",
|
|
55
|
+
description:
|
|
56
|
+
"Allows touch events on visible components to be processed while the keyboard is open",
|
|
57
|
+
defaultValue: "never",
|
|
58
|
+
options: ["never", "always"],
|
|
59
|
+
}),
|
|
52
60
|
},
|
|
53
61
|
};
|