@draftbit/core 44.1.12-e30b54.2 → 44.1.13-91822a.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.
Files changed (49) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +21 -5
  2. package/lib/commonjs/components/Picker/Picker.js +50 -48
  3. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  4. package/lib/commonjs/components/Picker/PickerComponent.android.js +59 -0
  5. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
  6. package/lib/commonjs/components/Picker/PickerComponent.ios.js +87 -0
  7. package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
  8. package/lib/commonjs/components/Picker/PickerComponent.web.js +59 -0
  9. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
  10. package/lib/commonjs/components/Portal/PortalManager.js.map +1 -1
  11. package/lib/commonjs/components/Swiper/Swiper.js.map +1 -1
  12. package/lib/commonjs/mappings/FAB.js.map +1 -1
  13. package/lib/commonjs/mappings/KeyboardAwareScrollView.js +1 -1
  14. package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -1
  15. package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
  16. package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
  17. package/lib/commonjs/mappings/ScrollView.js.map +1 -1
  18. package/lib/commonjs/mappings/Slider.js.map +1 -1
  19. package/lib/commonjs/mappings/Swiper.js.map +1 -1
  20. package/lib/commonjs/mappings/View.js.map +1 -1
  21. package/lib/module/components/DatePicker/DatePickerComponent.web.js.map +1 -1
  22. package/lib/module/components/Justification.js +1 -1
  23. package/lib/module/components/Picker/Picker.js +52 -48
  24. package/lib/module/components/Picker/Picker.js.map +1 -1
  25. package/lib/module/components/Picker/PickerComponent.android.js +41 -0
  26. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
  27. package/lib/module/components/Picker/PickerComponent.ios.js +64 -0
  28. package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
  29. package/lib/module/components/Picker/PickerComponent.web.js +41 -0
  30. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
  31. package/lib/module/components/StepIndicator.js.map +1 -1
  32. package/lib/module/constants.js.map +1 -1
  33. package/lib/module/mappings/Banner.js.map +1 -1
  34. package/lib/module/mappings/KeyboardAwareScrollView.js +1 -1
  35. package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -1
  36. package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
  37. package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +13 -0
  38. package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
  39. package/package.json +3 -3
  40. package/src/components/Picker/Picker.js +39 -20
  41. package/src/components/Picker/Picker.tsx +53 -18
  42. package/src/components/Picker/PickerComponent.android.js +20 -0
  43. package/src/components/Picker/PickerComponent.android.tsx +59 -0
  44. package/src/components/Picker/PickerComponent.ios.js +40 -0
  45. package/src/components/Picker/PickerComponent.ios.tsx +86 -0
  46. package/src/components/Picker/PickerComponent.web.js +20 -0
  47. package/src/components/Picker/PickerComponent.web.tsx +59 -0
  48. package/src/mappings/KeyboardAwareScrollView.js +1 -1
  49. package/src/mappings/KeyboardAwareScrollView.ts +1 -1
@@ -1,13 +1,15 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Text, Platform, } from "react-native";
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, theme, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
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, togglePickerVisible] = React.useReducer((state) => !state, false);
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
- platform === "ios" && pickerVisible ? (React.createElement(Portal, null,
175
- React.createElement(View, { style: [
176
- styles.iosPicker,
177
- {
178
- backgroundColor: colors.divider,
179
- },
180
- ] },
181
- React.createElement(SafeAreaView, { style: styles.iosSafeArea },
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
+ 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, togglePickerVisible] = React.useReducer(
114
- (state) => !state,
115
- false
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,21 @@ const Picker: React.FC<PickerProps> = ({
334
346
  {assistiveTextLabel}
335
347
  </Touchable>
336
348
 
349
+ {pickerVisible ? (
350
+ <PickerComponent
351
+ {...{
352
+ Icon,
353
+ androidPickerRef,
354
+ togglePickerVisible,
355
+ pickerOptions,
356
+ internalValue,
357
+ handleValueChange,
358
+ }}
359
+ />
360
+ ) : null}
361
+
337
362
  {/* iosPicker */}
338
- {platform === "ios" && pickerVisible ? (
363
+ {/* isIos && pickerVisible ? (
339
364
  <Portal>
340
365
  <View
341
366
  style={[
@@ -371,15 +396,17 @@ const Picker: React.FC<PickerProps> = ({
371
396
  </SafeAreaView>
372
397
  </View>
373
398
  </Portal>
374
- ) : null}
399
+ ) : null */}
375
400
 
376
401
  {/* nonIosPicker */}
377
- {platform !== "ios" ? (
402
+ {/* !isIos && pickerVisible ? (
378
403
  <NativePicker
379
- enabled={!disabled}
404
+ enabled={pickerVisible}
380
405
  selectedValue={internalValue}
381
406
  onValueChange={handleValueChange}
382
407
  style={styles.nonIosPicker}
408
+ ref={androidPickerRef}
409
+ onBlur={() => setPickerVisible(false)}
383
410
  >
384
411
  {(pickerOptions as unknown as PickerOption[]).map((option) => (
385
412
  <NativePicker.Item
@@ -389,7 +416,7 @@ const Picker: React.FC<PickerProps> = ({
389
416
  />
390
417
  ))}
391
418
  </NativePicker>
392
- ) : null}
419
+ ) : null */}
393
420
  </View>
394
421
  );
395
422
  };
@@ -400,6 +427,8 @@ const styles = StyleSheet.create({
400
427
  marginsContainer: {
401
428
  alignSelf: "stretch",
402
429
  alignItems: "center",
430
+ width: "100%",
431
+ maxWidth: deviceWidth,
403
432
  },
404
433
  touchableContainer: {
405
434
  flex: 1,
@@ -436,11 +465,15 @@ const styles = StyleSheet.create({
436
465
  right: 0,
437
466
  flexDirection: "row",
438
467
  justifyContent: "center",
468
+ width: "100%",
469
+ maxWidth: deviceWidth,
470
+ maxHeight: deviceHeight,
439
471
  },
440
472
  iosSafeArea: {
441
473
  backgroundColor: "white",
442
474
  flexDirection: "column",
443
475
  width: "100%",
476
+ maxWidth: deviceWidth,
444
477
  },
445
478
  iosButton: {
446
479
  alignSelf: "flex-end",
@@ -456,5 +489,7 @@ const styles = StyleSheet.create({
456
489
  right: 0,
457
490
  bottom: 0,
458
491
  width: "100%",
492
+ maxWidth: deviceWidth,
493
+ maxHeight: deviceHeight,
459
494
  },
460
495
  });
@@ -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
+ });
@@ -40,7 +40,7 @@ export const SEED_DATA = {
40
40
  defaultValue: true,
41
41
  }),
42
42
  keyboardShouldPersistTaps: createTextEnumProp({
43
- label: "Allow Touch Events With Open Keyboard",
43
+ label: "Allow Touch Events",
44
44
  description: "Allows touch events on visible components to be processed while the keyboard is open",
45
45
  defaultValue: "never",
46
46
  options: ["never", "always"],
@@ -51,7 +51,7 @@ export const SEED_DATA = {
51
51
  defaultValue: true,
52
52
  }),
53
53
  keyboardShouldPersistTaps: createTextEnumProp({
54
- label: "Allow Touch Events With Open Keyboard",
54
+ label: "Allow Touch Events",
55
55
  description:
56
56
  "Allows touch events on visible components to be processed while the keyboard is open",
57
57
  defaultValue: "never",