@draftbit/core 46.7.9-157e2b.2 → 46.7.9-193328.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/commonjs/components/DatePicker/DatePicker.js +14 -1
  2. package/lib/commonjs/components/DeckSwiper/DeckSwiper.js +74 -0
  3. package/lib/commonjs/components/DeckSwiper/DeckSwiperCard.js +34 -0
  4. package/lib/commonjs/components/DeckSwiper/index.js +20 -0
  5. package/lib/commonjs/components/DeprecatedFAB.js +3 -21
  6. package/lib/commonjs/components/NumberInput.js +10 -10
  7. package/lib/commonjs/components/Picker/Picker.js +10 -3
  8. package/lib/commonjs/index.js +13 -0
  9. package/lib/commonjs/mappings/DatePicker.js +8 -2
  10. package/lib/commonjs/mappings/DeckSwiper.js +55 -0
  11. package/lib/commonjs/mappings/DeckSwiperCard.js +23 -0
  12. package/lib/commonjs/mappings/HtmlElements.js +177 -0
  13. package/lib/commonjs/mappings/Picker.js +5 -0
  14. package/lib/module/components/CircleImage.js +1 -16
  15. package/lib/module/components/DatePicker/DatePicker.js +15 -2
  16. package/lib/module/components/DeckSwiper/DeckSwiper.js +66 -0
  17. package/lib/module/components/DeckSwiper/DeckSwiperCard.js +26 -0
  18. package/lib/module/components/DeckSwiper/index.js +2 -0
  19. package/lib/module/components/NumberInput.js +10 -10
  20. package/lib/module/components/Picker/Picker.js +11 -4
  21. package/lib/module/index.js +1 -0
  22. package/lib/module/mappings/DatePicker.js +9 -3
  23. package/lib/module/mappings/DeckSwiper.js +48 -0
  24. package/lib/module/mappings/DeckSwiperCard.js +16 -0
  25. package/lib/module/mappings/HtmlElements.js +170 -0
  26. package/lib/module/mappings/Picker.js +6 -1
  27. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +1 -0
  28. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  29. package/lib/typescript/src/components/DeckSwiper/DeckSwiper.d.ts +15 -0
  30. package/lib/typescript/src/components/DeckSwiper/DeckSwiper.d.ts.map +1 -0
  31. package/lib/typescript/src/components/DeckSwiper/DeckSwiperCard.d.ts +13 -0
  32. package/lib/typescript/src/components/DeckSwiper/DeckSwiperCard.d.ts.map +1 -0
  33. package/lib/typescript/src/components/DeckSwiper/index.d.ts +3 -0
  34. package/lib/typescript/src/components/DeckSwiper/index.d.ts.map +1 -0
  35. package/lib/typescript/src/components/Picker/Picker.d.ts +1 -0
  36. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  37. package/lib/typescript/src/index.d.ts +1 -0
  38. package/lib/typescript/src/index.d.ts.map +1 -1
  39. package/lib/typescript/src/mappings/DatePicker.d.ts +10 -0
  40. package/lib/typescript/src/mappings/DatePicker.d.ts.map +1 -1
  41. package/lib/typescript/src/mappings/DeckSwiper.d.ts +86 -0
  42. package/lib/typescript/src/mappings/DeckSwiper.d.ts.map +1 -0
  43. package/lib/typescript/src/mappings/DeckSwiperCard.d.ts +16 -0
  44. package/lib/typescript/src/mappings/DeckSwiperCard.d.ts.map +1 -0
  45. package/lib/typescript/src/mappings/HtmlElements.d.ts +77 -0
  46. package/lib/typescript/src/mappings/HtmlElements.d.ts.map +1 -0
  47. package/lib/typescript/src/mappings/Picker.d.ts +10 -0
  48. package/lib/typescript/src/mappings/Picker.d.ts.map +1 -1
  49. package/package.json +5 -3
  50. package/src/components/DatePicker/DatePicker.js +8 -3
  51. package/src/components/DatePicker/DatePicker.tsx +10 -1
  52. package/src/components/DeckSwiper/DeckSwiper.js +35 -0
  53. package/src/components/DeckSwiper/DeckSwiper.tsx +94 -0
  54. package/src/components/DeckSwiper/DeckSwiperCard.js +21 -0
  55. package/src/components/DeckSwiper/DeckSwiperCard.tsx +41 -0
  56. package/src/components/DeckSwiper/index.js +2 -0
  57. package/src/components/DeckSwiper/index.tsx +2 -0
  58. package/src/components/NumberInput.js +9 -9
  59. package/src/components/NumberInput.tsx +11 -11
  60. package/src/components/Picker/Picker.js +9 -3
  61. package/src/components/Picker/Picker.tsx +14 -2
  62. package/src/index.js +1 -0
  63. package/src/index.tsx +2 -0
  64. package/src/mappings/DatePicker.js +8 -2
  65. package/src/mappings/DatePicker.ts +8 -1
  66. package/src/mappings/DeckSwiper.js +48 -0
  67. package/src/mappings/DeckSwiper.ts +57 -0
  68. package/src/mappings/DeckSwiperCard.js +16 -0
  69. package/src/mappings/DeckSwiperCard.ts +20 -0
  70. package/src/mappings/HtmlElements.js +193 -0
  71. package/src/mappings/HtmlElements.ts +207 -0
  72. package/src/mappings/Picker.js +6 -1
  73. package/src/mappings/Picker.ts +6 -0
  74. package/lib/commonjs/mappings/expo/Image.js +0 -90
  75. package/lib/module/mappings/expo/Image.js +0 -83
  76. package/lib/typescript/src/mappings/expo/Image.d.ts +0 -155
  77. package/lib/typescript/src/mappings/expo/Image.d.ts.map +0 -1
  78. package/src/mappings/expo/Image.js +0 -107
  79. package/src/mappings/expo/Image.ts +0 -131
@@ -0,0 +1,86 @@
1
+ export declare const SEED_DATA: {
2
+ name: string;
3
+ tag: string;
4
+ description: string;
5
+ category: string;
6
+ stylesPanelSections: string[];
7
+ layout: {
8
+ width: string;
9
+ };
10
+ triggers: string[];
11
+ props: {
12
+ onIndexChanged: {
13
+ label: string;
14
+ description: string;
15
+ editable: boolean;
16
+ required: boolean;
17
+ formType: string;
18
+ propType: string;
19
+ defaultValue: null;
20
+ group: string;
21
+ };
22
+ onEndReached: {
23
+ label: string;
24
+ description: string;
25
+ editable: boolean;
26
+ required: boolean;
27
+ formType: string;
28
+ propType: string;
29
+ defaultValue: null;
30
+ group: string;
31
+ };
32
+ startCardIndex: {
33
+ label: string;
34
+ description: string;
35
+ formType: string;
36
+ propType: string;
37
+ group: string;
38
+ defaultValue: null;
39
+ editable: boolean;
40
+ required: boolean;
41
+ step: number;
42
+ };
43
+ infiniteSwiping: {
44
+ label: string;
45
+ description: string;
46
+ formType: string;
47
+ propType: string;
48
+ defaultValue: boolean;
49
+ editable: boolean;
50
+ required: boolean;
51
+ group: string;
52
+ };
53
+ verticalEnabled: {
54
+ label: string;
55
+ description: string;
56
+ formType: string;
57
+ propType: string;
58
+ defaultValue: boolean;
59
+ editable: boolean;
60
+ required: boolean;
61
+ group: string;
62
+ };
63
+ horizontalEnabled: {
64
+ label: string;
65
+ description: string;
66
+ formType: string;
67
+ propType: string;
68
+ defaultValue: boolean;
69
+ editable: boolean;
70
+ required: boolean;
71
+ group: string;
72
+ };
73
+ visibleCardCount: {
74
+ label: string;
75
+ description: string;
76
+ formType: string;
77
+ propType: string;
78
+ group: string;
79
+ defaultValue: null;
80
+ editable: boolean;
81
+ required: boolean;
82
+ step: number;
83
+ };
84
+ };
85
+ };
86
+ //# sourceMappingURL=DeckSwiper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeckSwiper.d.ts","sourceRoot":"","sources":["../../../../src/mappings/DeckSwiper.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CrB,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const SEED_DATA: {
2
+ name: string;
3
+ tag: string;
4
+ description: string;
5
+ category: string;
6
+ stylesPanelSections: string[];
7
+ layout: {
8
+ flex: number;
9
+ alignItems: string;
10
+ justifyContent: string;
11
+ padding: number;
12
+ borderWidth: number;
13
+ };
14
+ props: {};
15
+ };
16
+ //# sourceMappingURL=DeckSwiperCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeckSwiperCard.d.ts","sourceRoot":"","sources":["../../../../src/mappings/DeckSwiperCard.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAcrB,CAAC"}
@@ -0,0 +1,77 @@
1
+ export declare const SEED_DATA: ({
2
+ props: {
3
+ href: any;
4
+ target: {
5
+ group: string;
6
+ label: string;
7
+ description: string;
8
+ formType: string;
9
+ defaultValue: string;
10
+ options: string[];
11
+ };
12
+ };
13
+ category: string;
14
+ doc_link: string;
15
+ code_link: string;
16
+ packageName: string;
17
+ stylesPanelSections: string[];
18
+ layout: {
19
+ margin: number;
20
+ };
21
+ triggers: string[];
22
+ name: string;
23
+ tag: string;
24
+ } | {
25
+ props: {
26
+ href?: undefined;
27
+ target?: undefined;
28
+ };
29
+ category: string;
30
+ doc_link: string;
31
+ code_link: string;
32
+ packageName: string;
33
+ stylesPanelSections: string[];
34
+ layout: {
35
+ margin: number;
36
+ };
37
+ triggers: string[];
38
+ name: string;
39
+ tag: string;
40
+ } | {
41
+ category: string;
42
+ props: {
43
+ children: {
44
+ group: string;
45
+ label: string;
46
+ description: string;
47
+ defaultValue: string;
48
+ editable: boolean;
49
+ required: boolean;
50
+ formType: string;
51
+ propType: string;
52
+ };
53
+ };
54
+ doc_link: string;
55
+ code_link: string;
56
+ packageName: string;
57
+ stylesPanelSections: string[];
58
+ layout: {
59
+ margin: number;
60
+ };
61
+ triggers: string[];
62
+ name: string;
63
+ tag: string;
64
+ } | {
65
+ doc_link: string;
66
+ code_link: string;
67
+ packageName: string;
68
+ stylesPanelSections: string[];
69
+ layout: {
70
+ margin: number;
71
+ };
72
+ triggers: string[];
73
+ category: string;
74
+ name: string;
75
+ tag: string;
76
+ })[];
77
+ //# sourceMappingURL=HtmlElements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HtmlElements.d.ts","sourceRoot":"","sources":["../../../../src/mappings/HtmlElements.ts"],"names":[],"mappings":"AAsFA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwHrB,CAAC"}
@@ -40,6 +40,16 @@ export declare const SEED_DATA: {
40
40
  formType: string;
41
41
  propType: string;
42
42
  };
43
+ autoDismissKeyboard: {
44
+ label: string;
45
+ description: string;
46
+ formType: string;
47
+ propType: string;
48
+ defaultValue: boolean;
49
+ editable: boolean;
50
+ required: boolean;
51
+ group: string;
52
+ };
43
53
  label: {
44
54
  group: string;
45
55
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Picker.ts"],"names":[],"mappings":"AA8HA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCrB,CAAC"}
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Picker.ts"],"names":[],"mappings":"AA+HA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.7.9-157e2b.2+157e2b1",
3
+ "version": "46.7.9-193328.2+1933281",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,7 +41,8 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "^46.7.9-157e2b.2+157e2b1",
44
+ "@draftbit/types": "^46.7.9-193328.2+1933281",
45
+ "@expo/html-elements": "^0.3.1",
45
46
  "@material-ui/core": "^4.11.0",
46
47
  "@material-ui/pickers": "^3.2.10",
47
48
  "@react-native-community/slider": "4.2.3",
@@ -53,6 +54,7 @@
53
54
  "lodash.isnumber": "^3.0.3",
54
55
  "lodash.omit": "^4.5.0",
55
56
  "lodash.tonumber": "^4.0.3",
57
+ "react-native-deck-swiper": "^2.0.12",
56
58
  "react-native-modal-datetime-picker": "^13.0.0",
57
59
  "react-native-svg": "12.3.0",
58
60
  "react-native-typography": "^1.4.1",
@@ -91,5 +93,5 @@
91
93
  ]
92
94
  ]
93
95
  },
94
- "gitHead": "157e2b18fb2aca142c8ba3f448f3e6e36232db26"
96
+ "gitHead": "1933281a981a18f99c4c7eaeccf250cad7e58d23"
95
97
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, } from "react-native";
2
+ import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, Keyboard, } from "react-native";
3
3
  import { useSafeAreaInsets } from "react-native-safe-area-context";
4
4
  import dateFormat from "dateformat";
5
5
  import { withTheme } from "../../theming";
@@ -25,7 +25,7 @@ const MONTHS = [
25
25
  "November",
26
26
  "December",
27
27
  ];
28
- const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, ...props }) => {
28
+ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, autoDismissKeyboard = true, ...props }) => {
29
29
  const [value, setValue] = React.useState(date || defaultValue);
30
30
  React.useEffect(() => {
31
31
  if (defaultValue != null) {
@@ -113,6 +113,11 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
113
113
  clearTimeout(_showPlaceholder());
114
114
  };
115
115
  }, [focused, label, placeholder]);
116
+ React.useEffect(() => {
117
+ if (pickerVisible && autoDismissKeyboard) {
118
+ Keyboard.dismiss();
119
+ }
120
+ }, [pickerVisible, autoDismissKeyboard]);
116
121
  const _handleFocus = () => {
117
122
  if (disabled) {
118
123
  return;
@@ -132,7 +137,7 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
132
137
  ? labelSize
133
138
  : typography.caption.fontSize;
134
139
  const hasActiveOutline = focused;
135
- let inputTextColor, activeColor, underlineColor, borderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
140
+ let inputTextColor, activeColor, underlineColor, borderColor = inputBorderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
136
141
  inputTextColor = colors.strong;
137
142
  if (disabled) {
138
143
  activeColor = colors.light;
@@ -12,6 +12,7 @@ import {
12
12
  I18nManager,
13
13
  LayoutChangeEvent,
14
14
  TextInput as NativeTextInput,
15
+ Keyboard,
15
16
  } from "react-native";
16
17
  import { useSafeAreaInsets } from "react-native-safe-area-context";
17
18
 
@@ -55,6 +56,7 @@ type Props = {
55
56
  rightIconName?: string;
56
57
  borderColor?: string;
57
58
  borderColorActive?: string;
59
+ autoDismissKeyboard?: boolean;
58
60
  } & IconSlot &
59
61
  TextInputProps;
60
62
 
@@ -93,6 +95,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
93
95
  placeholder,
94
96
  borderColor: inputBorderColor,
95
97
  borderColorActive: inputBorderColorActive,
98
+ autoDismissKeyboard = true,
96
99
  ...props
97
100
  }) => {
98
101
  const [value, setValue] = React.useState<any>(date || defaultValue);
@@ -204,6 +207,12 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
204
207
  };
205
208
  }, [focused, label, placeholder]);
206
209
 
210
+ React.useEffect(() => {
211
+ if (pickerVisible && autoDismissKeyboard) {
212
+ Keyboard.dismiss();
213
+ }
214
+ }, [pickerVisible, autoDismissKeyboard]);
215
+
207
216
  const _handleFocus = () => {
208
217
  if (disabled) {
209
218
  return;
@@ -232,7 +241,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
232
241
  let inputTextColor,
233
242
  activeColor,
234
243
  underlineColor,
235
- borderColor,
244
+ borderColor = inputBorderColor,
236
245
  placeholderColor,
237
246
  containerStyle: StyleProp<ViewStyle>,
238
247
  backgroundColor,
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+ import DeckSwiperComponent from "react-native-deck-swiper";
4
+ const DeckSwiper = ({ onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, style, children, }) => {
5
+ const childrenArray = React.useMemo(() => React.Children.toArray(children), [children]);
6
+ // an array of indices based on children count
7
+ const cardsFillerData = React.useMemo(() => Array.from(Array(childrenArray.length).keys()), [childrenArray]);
8
+ /**
9
+ * By default react-native-deck-swiper positions everything with absolute position.
10
+ * To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
11
+ *
12
+ *
13
+ * Since all children of that View are absolutley positioned, the View does not have a height and still looks and behaves weird.
14
+ * To fix/mitage this without setting a static height, the first card is rendered in invisible state to take up space.
15
+ * This effectivley makes the default height of the container be the height of the first card.
16
+ */
17
+ return (React.createElement(View, null,
18
+ React.createElement(View, { style: styles.containerHeightFiller }, childrenArray.length && childrenArray[0]),
19
+ React.createElement(DeckSwiperComponent, { cards: cardsFillerData, renderCard: (_, i) => React.createElement(React.Fragment, null, childrenArray[i]), keyExtractor: (card) => card === null || card === void 0 ? void 0 : card.toString(), containerStyle: StyleSheet.flatten([styles.cardsContainer, style]), cardStyle: styles.card, onSwiped: onIndexChanged, onSwipedAll: onEndReached, cardIndex: startCardIndex, infinite: infiniteSwiping, verticalSwipe: verticalEnabled, horizontalSwipe: horizontalEnabled, showSecondCard: visibleCardCount > 1, stackSize: visibleCardCount, backgroundColor: "transparent", cardVerticalMargin: 0, cardHorizontalMargin: 0 })));
20
+ };
21
+ const styles = StyleSheet.create({
22
+ cardsContainer: {
23
+ width: "100%",
24
+ },
25
+ card: {
26
+ left: 0,
27
+ right: 0,
28
+ width: "auto",
29
+ height: "auto",
30
+ },
31
+ containerHeightFiller: {
32
+ opacity: 0.0,
33
+ },
34
+ });
35
+ export default DeckSwiper;
@@ -0,0 +1,94 @@
1
+ import React from "react";
2
+ import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
3
+ import DeckSwiperComponent from "react-native-deck-swiper";
4
+
5
+ export interface DeckSwiperProps {
6
+ onIndexChanged?: (index: number) => void;
7
+ onEndReached?: () => void;
8
+ startCardIndex?: number;
9
+ infiniteSwiping?: boolean;
10
+ verticalEnabled?: boolean;
11
+ horizontalEnabled?: boolean;
12
+ visibleCardCount?: number;
13
+ style?: StyleProp<ViewStyle>;
14
+ }
15
+
16
+ const DeckSwiper: React.FC<React.PropsWithChildren<DeckSwiperProps>> = ({
17
+ onIndexChanged,
18
+ onEndReached,
19
+ startCardIndex = 0,
20
+ infiniteSwiping = false,
21
+ verticalEnabled = true,
22
+ horizontalEnabled = true,
23
+ visibleCardCount = 1,
24
+ style,
25
+ children,
26
+ }) => {
27
+ const childrenArray = React.useMemo(
28
+ () => React.Children.toArray(children),
29
+ [children]
30
+ );
31
+
32
+ // an array of indices based on children count
33
+ const cardsFillerData = React.useMemo(
34
+ () => Array.from(Array(childrenArray.length).keys()),
35
+ [childrenArray]
36
+ );
37
+
38
+ /**
39
+ * By default react-native-deck-swiper positions everything with absolute position.
40
+ * To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
41
+ *
42
+ *
43
+ * Since all children of that View are absolutley positioned, the View does not have a height and still looks and behaves weird.
44
+ * To fix/mitage this without setting a static height, the first card is rendered in invisible state to take up space.
45
+ * This effectivley makes the default height of the container be the height of the first card.
46
+ */
47
+
48
+ return (
49
+ <View>
50
+ <View style={styles.containerHeightFiller}>
51
+ {childrenArray.length && childrenArray[0]}
52
+ </View>
53
+ <DeckSwiperComponent
54
+ cards={cardsFillerData}
55
+ renderCard={(_, i) => <>{childrenArray[i]}</>}
56
+ keyExtractor={(card) => card?.toString()}
57
+ containerStyle={
58
+ StyleSheet.flatten([styles.cardsContainer, style]) as
59
+ | object
60
+ | undefined
61
+ }
62
+ cardStyle={styles.card as object | undefined}
63
+ onSwiped={onIndexChanged}
64
+ onSwipedAll={onEndReached}
65
+ cardIndex={startCardIndex}
66
+ infinite={infiniteSwiping}
67
+ verticalSwipe={verticalEnabled}
68
+ horizontalSwipe={horizontalEnabled}
69
+ showSecondCard={visibleCardCount > 1}
70
+ stackSize={visibleCardCount}
71
+ backgroundColor="transparent"
72
+ cardVerticalMargin={0}
73
+ cardHorizontalMargin={0}
74
+ />
75
+ </View>
76
+ );
77
+ };
78
+
79
+ const styles = StyleSheet.create({
80
+ cardsContainer: {
81
+ width: "100%",
82
+ },
83
+ card: {
84
+ left: 0,
85
+ right: 0,
86
+ width: "auto",
87
+ height: "auto",
88
+ },
89
+ containerHeightFiller: {
90
+ opacity: 0.0,
91
+ },
92
+ });
93
+
94
+ export default DeckSwiper;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { withTheme } from "../../theming";
4
+ const DeckSwiperCard = ({ style, children, theme, }) => (React.createElement(View, { style: [
5
+ styles.card,
6
+ {
7
+ backgroundColor: theme.colors.background,
8
+ borderColor: theme.colors.divider,
9
+ },
10
+ style,
11
+ ] }, children));
12
+ const styles = StyleSheet.create({
13
+ card: {
14
+ flex: 1,
15
+ alignItems: "center",
16
+ justifyContent: "center",
17
+ padding: 20,
18
+ borderWidth: 2,
19
+ },
20
+ });
21
+ export default withTheme(DeckSwiperCard);
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { View, StyleSheet, StyleProp, ViewStyle } from "react-native";
3
+ import type { Theme } from "../../styles/DefaultTheme";
4
+ import { withTheme } from "../../theming";
5
+
6
+ export interface DeckSwiperCardProps {
7
+ style?: StyleProp<ViewStyle>;
8
+ children: React.ReactNode;
9
+ theme: Theme;
10
+ }
11
+
12
+ const DeckSwiperCard: React.FC<DeckSwiperCardProps> = ({
13
+ style,
14
+ children,
15
+ theme,
16
+ }) => (
17
+ <View
18
+ style={[
19
+ styles.card,
20
+ {
21
+ backgroundColor: theme.colors.background,
22
+ borderColor: theme.colors.divider,
23
+ },
24
+ style,
25
+ ]}
26
+ >
27
+ {children}
28
+ </View>
29
+ );
30
+
31
+ const styles = StyleSheet.create({
32
+ card: {
33
+ flex: 1,
34
+ alignItems: "center",
35
+ justifyContent: "center",
36
+ padding: 20,
37
+ borderWidth: 2,
38
+ },
39
+ });
40
+
41
+ export default withTheme(DeckSwiperCard);
@@ -0,0 +1,2 @@
1
+ export { default as DeckSwiper } from "./DeckSwiper";
2
+ export { default as DeckSwiperCard } from "./DeckSwiperCard";
@@ -0,0 +1,2 @@
1
+ export { default as DeckSwiper } from "./DeckSwiper";
2
+ export { default as DeckSwiperCard } from "./DeckSwiperCard";
@@ -20,16 +20,8 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
20
20
  return valueToFormat.toString();
21
21
  }
22
22
  }
23
- return "0";
23
+ return "";
24
24
  };
25
- // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
26
- useEffect(() => {
27
- const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
28
- if (currentStringNumberValue !== defaultStringNumberValue) {
29
- setCurrentStringNumberValue(defaultStringNumberValue);
30
- }
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
- }, []);
33
25
  const handleChangeText = (newValue) => {
34
26
  const newStringNumberValue = formatValueToStringNumber(newValue);
35
27
  const number = parseFloat(newStringNumberValue);
@@ -44,6 +36,14 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
44
36
  }
45
37
  // eslint-disable-next-line react-hooks/exhaustive-deps
46
38
  }, [value]);
39
+ // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
40
+ useEffect(() => {
41
+ const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
42
+ if (currentStringNumberValue !== defaultStringNumberValue) {
43
+ setCurrentStringNumberValue(defaultStringNumberValue);
44
+ }
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ }, []);
47
47
  return (React.createElement(TextInput, { keyboardType: "numeric", value: currentStringNumberValue, onChangeText: handleChangeText, ...props }));
48
48
  };
49
49
  export default NumberInput;
@@ -31,19 +31,9 @@ const NumberInput: FC<Props> = ({
31
31
  }
32
32
  }
33
33
 
34
- return "0";
34
+ return "";
35
35
  };
36
36
 
37
- // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
38
- useEffect(() => {
39
- const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
40
-
41
- if (currentStringNumberValue !== defaultStringNumberValue) {
42
- setCurrentStringNumberValue(defaultStringNumberValue);
43
- }
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, []);
46
-
47
37
  const handleChangeText = (newValue: string) => {
48
38
  const newStringNumberValue = formatValueToStringNumber(newValue);
49
39
  const number = parseFloat(newStringNumberValue);
@@ -62,6 +52,16 @@ const NumberInput: FC<Props> = ({
62
52
  // eslint-disable-next-line react-hooks/exhaustive-deps
63
53
  }, [value]);
64
54
 
55
+ // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
56
+ useEffect(() => {
57
+ const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
58
+
59
+ if (currentStringNumberValue !== defaultStringNumberValue) {
60
+ setCurrentStringNumberValue(defaultStringNumberValue);
61
+ }
62
+ // eslint-disable-next-line react-hooks/exhaustive-deps
63
+ }, []);
64
+
65
65
  return (
66
66
  <TextInput
67
67
  keyboardType="numeric"
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Text, Platform, Dimensions, } from "react-native";
2
+ import { View, StyleSheet, Text, Platform, Dimensions, Keyboard, } from "react-native";
3
3
  import { omit, pickBy, identity, isObject } from "lodash";
4
4
  import { SafeAreaView } from "react-native-safe-area-context";
5
5
  import { Picker as NativePicker } from "@react-native-picker/picker";
@@ -32,10 +32,11 @@ function normalizeOptions(options) {
32
32
  }
33
33
  const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
34
34
  const isIos = Platform.OS === "ios";
35
+ const isWeb = Platform.OS === "web";
35
36
  const unstyledColor = "rgba(165, 173, 183, 1)";
36
37
  const disabledColor = "rgb(240, 240, 240)";
37
38
  const errorColor = "rgba(255, 69, 100, 1)";
38
- const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
39
+ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
39
40
  var _a, _b;
40
41
  const androidPickerRef = React.useRef(undefined);
41
42
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
@@ -59,6 +60,11 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
59
60
  (_a = androidPickerRef === null || androidPickerRef === void 0 ? void 0 : androidPickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
60
61
  }
61
62
  }, [pickerVisible, androidPickerRef]);
63
+ React.useEffect(() => {
64
+ if (pickerVisible && autoDismissKeyboard) {
65
+ Keyboard.dismiss();
66
+ }
67
+ }, [pickerVisible, autoDismissKeyboard]);
62
68
  const normalizedOptions = normalizeOptions(options);
63
69
  const pickerOptions = placeholder
64
70
  ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
@@ -186,7 +192,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
186
192
  React.createElement(View, { style: styles.iosPickerContent },
187
193
  React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
188
194
  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,
189
- !isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
195
+ !isIos && (pickerVisible || isWeb) ? (React.createElement(NativePicker, { enabled: !disabled, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
190
196
  };
191
197
  const styles = StyleSheet.create({
192
198
  marginsContainer: {