@draftbit/core 47.0.1-ed6e56.2 → 47.1.1-1883fa.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 (127) hide show
  1. package/lib/commonjs/components/Button.js +3 -3
  2. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
  3. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
  4. package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
  5. package/lib/commonjs/components/DatePicker/DatePicker.js +0 -1
  6. package/lib/commonjs/components/DatePicker/DatePickerComponent.js +9 -3
  7. package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +1 -0
  8. package/lib/commonjs/components/DeprecatedButton.js +3 -27
  9. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  10. package/lib/commonjs/components/Pressable.js +37 -0
  11. package/lib/commonjs/components/Swiper/Swiper.js +2 -0
  12. package/lib/commonjs/components/Touchable.js +8 -3
  13. package/lib/commonjs/index.js +7 -0
  14. package/lib/commonjs/mappings/Button.js +39 -10
  15. package/lib/commonjs/mappings/DatePicker.js +1 -1
  16. package/lib/commonjs/mappings/FlashList.js +79 -2
  17. package/lib/commonjs/mappings/FlatList.js +27 -0
  18. package/lib/commonjs/mappings/ScrollView.js +6 -0
  19. package/lib/commonjs/mappings/Swiper.js +2 -0
  20. package/lib/commonjs/mappings/TextField.js +2 -2
  21. package/lib/commonjs/mappings/Touchable.js +47 -7
  22. package/lib/module/components/Button.js +3 -3
  23. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  24. package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
  25. package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
  26. package/lib/module/components/DatePicker/DatePicker.js +0 -1
  27. package/lib/module/components/DatePicker/DatePickerComponent.js +9 -3
  28. package/lib/module/components/DatePicker/DatePickerComponent.web.js +1 -0
  29. package/lib/module/components/DeprecatedButton.js +4 -28
  30. package/lib/module/components/DeprecatedFAB.js +2 -3
  31. package/lib/module/components/Pressable.js +30 -0
  32. package/lib/module/components/Swiper/Swiper.js +2 -0
  33. package/lib/module/components/Touchable.js +8 -3
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/mappings/Button.js +40 -11
  36. package/lib/module/mappings/DatePicker.js +1 -1
  37. package/lib/module/mappings/FlashList.js +80 -3
  38. package/lib/module/mappings/FlatList.js +28 -1
  39. package/lib/module/mappings/ScrollView.js +7 -1
  40. package/lib/module/mappings/Swiper.js +3 -1
  41. package/lib/module/mappings/TextField.js +2 -2
  42. package/lib/module/mappings/Touchable.js +49 -9
  43. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  44. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  45. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  46. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  47. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  48. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  49. package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts.map +1 -1
  50. package/lib/typescript/src/components/DatePicker/DatePickerComponent.web.d.ts.map +1 -1
  51. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +0 -2
  52. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
  53. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  54. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -1
  55. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  56. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  57. package/lib/typescript/src/components/Pressable.d.ts +10 -0
  58. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  59. package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
  60. package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Touchable.d.ts +5 -6
  62. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  63. package/lib/typescript/src/index.d.ts +1 -0
  64. package/lib/typescript/src/index.d.ts.map +1 -1
  65. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  66. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  67. package/lib/typescript/src/mappings/DatePicker.d.ts +1 -1
  68. package/lib/typescript/src/mappings/FlashList.d.ts +183 -2
  69. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  70. package/lib/typescript/src/mappings/FlatList.d.ts +73 -0
  71. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  72. package/lib/typescript/src/mappings/ScrollView.d.ts +21 -0
  73. package/lib/typescript/src/mappings/ScrollView.d.ts.map +1 -1
  74. package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
  75. package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
  76. package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
  77. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  78. package/package.json +6 -6
  79. package/src/components/Button.js +3 -3
  80. package/src/components/Button.tsx +14 -4
  81. package/src/components/Checkbox/Checkbox.js +2 -3
  82. package/src/components/Checkbox/Checkbox.tsx +5 -7
  83. package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
  84. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  85. package/src/components/Checkbox/CheckboxRow.js +2 -3
  86. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  87. package/src/components/DatePicker/DatePicker.js +1 -1
  88. package/src/components/DatePicker/DatePicker.tsx +0 -1
  89. package/src/components/DatePicker/DatePickerComponent.js +5 -3
  90. package/src/components/DatePicker/DatePickerComponent.tsx +11 -3
  91. package/src/components/DatePicker/DatePickerComponent.web.js +1 -1
  92. package/src/components/DatePicker/DatePickerComponent.web.tsx +1 -0
  93. package/src/components/DatePicker/DatePickerComponentType.ts +0 -9
  94. package/src/components/DeprecatedButton.js +4 -16
  95. package/src/components/DeprecatedButton.tsx +7 -31
  96. package/src/components/DeprecatedFAB.js +2 -3
  97. package/src/components/DeprecatedFAB.tsx +5 -5
  98. package/src/components/Pressable.js +12 -0
  99. package/src/components/Pressable.tsx +44 -0
  100. package/src/components/Swiper/Swiper.js +2 -2
  101. package/src/components/Swiper/Swiper.tsx +3 -0
  102. package/src/components/Touchable.js +3 -3
  103. package/src/components/Touchable.tsx +11 -7
  104. package/src/index.js +1 -0
  105. package/src/index.tsx +1 -0
  106. package/src/mappings/Button.js +39 -10
  107. package/src/mappings/Button.ts +41 -10
  108. package/src/mappings/DatePicker.js +1 -1
  109. package/src/mappings/DatePicker.ts +1 -1
  110. package/src/mappings/FlashList.js +111 -31
  111. package/src/mappings/FlashList.ts +120 -30
  112. package/src/mappings/FlatList.js +28 -1
  113. package/src/mappings/FlatList.ts +34 -0
  114. package/src/mappings/ScrollView.js +7 -1
  115. package/src/mappings/ScrollView.ts +9 -0
  116. package/src/mappings/Swiper.js +3 -1
  117. package/src/mappings/Swiper.ts +4 -0
  118. package/src/mappings/TextField.js +2 -2
  119. package/src/mappings/TextField.ts +2 -2
  120. package/src/mappings/Touchable.js +50 -7
  121. package/src/mappings/Touchable.ts +53 -6
  122. package/lib/commonjs/components/DatePicker/DatePickerInput.js +0 -133
  123. package/lib/module/components/DatePicker/DatePickerInput.js +0 -123
  124. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts +0 -18
  125. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts.map +0 -1
  126. package/src/components/DatePicker/DatePickerInput.js +0 -97
  127. package/src/components/DatePicker/DatePickerInput.tsx +0 -195
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, Platform, } from "react-native";
2
+ import { StyleSheet, View, Platform, Pressable, } from "react-native";
3
3
  import { isString } from "lodash";
4
4
  import { extractStyles } from "../../utilities";
5
5
  import { usePrevious } from "../../hooks";
6
6
  import Text from "../Text";
7
- import Touchable from "../Touchable";
8
7
  import Checkbox from "./Checkbox";
9
8
  export var Direction;
10
9
  (function (Direction) {
@@ -46,7 +45,7 @@ const CheckboxRow = ({ label = "Label", labelStyle, labelContainerStyle, checkbo
46
45
  }
47
46
  };
48
47
  const { textStyles, viewStyles } = extractStyles(style);
49
- return (React.createElement(Touchable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
48
+ return (React.createElement(Pressable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
50
49
  React.createElement(View, { style: [
51
50
  styles.label,
52
51
  {
@@ -6,6 +6,7 @@ import {
6
6
  TextStyle,
7
7
  View,
8
8
  Platform,
9
+ Pressable,
9
10
  } from "react-native";
10
11
  import { isString } from "lodash";
11
12
 
@@ -13,7 +14,6 @@ import type { IconSlot } from "../../interfaces/Icon";
13
14
  import { extractStyles } from "../../utilities";
14
15
  import { usePrevious } from "../../hooks";
15
16
  import Text from "../Text";
16
- import Touchable from "../Touchable";
17
17
  import Checkbox, { CheckboxProps } from "./Checkbox";
18
18
 
19
19
  export enum Direction {
@@ -100,7 +100,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
100
100
  const { textStyles, viewStyles } = extractStyles(style);
101
101
 
102
102
  return (
103
- <Touchable
103
+ <Pressable
104
104
  onPress={handlePress}
105
105
  style={[viewStyles, styles.mainParent, { flexDirection: direction }]}
106
106
  disabled={disabled}
@@ -130,7 +130,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
130
130
  uncheckedIcon={uncheckedIcon}
131
131
  size={size}
132
132
  />
133
- </Touchable>
133
+ </Pressable>
134
134
  );
135
135
  };
136
136
 
@@ -333,7 +333,7 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
333
333
  paddingRight: insets.right,
334
334
  },
335
335
  ] },
336
- React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, displayMode: "default", isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
336
+ React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
337
337
  toggleVisibility();
338
338
  setValue(data);
339
339
  onDateChange(data);
@@ -515,7 +515,6 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
515
515
  <DateTimePicker
516
516
  value={getValidDate()}
517
517
  mode={mode}
518
- displayMode="default"
519
518
  isVisible={pickerVisible}
520
519
  toggleVisibility={toggleVisibility}
521
520
  onChange={(_event: any, data: any) => {
@@ -1,11 +1,13 @@
1
1
  import React from "react";
2
+ import { Platform } from "react-native";
3
+ import DateTimePicker from "@react-native-community/datetimepicker";
2
4
  import DateTimePickerModal from "react-native-modal-datetime-picker";
3
- const DatePickerComponent = ({ value, onChange, displayMode = "default", mode, toggleVisibility, }) => {
4
- return (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: displayMode, onCancel: () => {
5
+ const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, }) => {
6
+ return Platform.OS === "ios" || Platform.OS === "android" ? (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: Platform.OS === "ios" ? "spinner" : "default", onCancel: () => {
5
7
  console.log("Picker cancelled before selecting anything.");
6
8
  toggleVisibility();
7
9
  }, onConfirm: (data) => {
8
10
  onChange(null, data);
9
- } }));
11
+ } })) : (React.createElement(DateTimePicker, { value: value, mode: mode, onChange: onChange, display: "default" }));
10
12
  };
11
13
  export default DatePickerComponent;
@@ -1,20 +1,21 @@
1
1
  import React from "react";
2
+ import { Platform } from "react-native";
3
+ import DateTimePicker from "@react-native-community/datetimepicker";
2
4
  import DateTimePickerModal from "react-native-modal-datetime-picker";
3
5
  import { DatePickerComponentProps as Props } from "./DatePickerComponentType";
4
6
 
5
7
  const DatePickerComponent: React.FC<React.PropsWithChildren<Props>> = ({
6
8
  value,
7
9
  onChange,
8
- displayMode = "default",
9
10
  mode,
10
11
  toggleVisibility,
11
12
  }) => {
12
- return (
13
+ return Platform.OS === "ios" || Platform.OS === "android" ? (
13
14
  <DateTimePickerModal
14
15
  date={value}
15
16
  mode={mode}
16
17
  isVisible={true}
17
- display={displayMode}
18
+ display={Platform.OS === "ios" ? "spinner" : "default"}
18
19
  onCancel={() => {
19
20
  console.log("Picker cancelled before selecting anything.");
20
21
  toggleVisibility();
@@ -23,6 +24,13 @@ const DatePickerComponent: React.FC<React.PropsWithChildren<Props>> = ({
23
24
  onChange(null, data);
24
25
  }}
25
26
  />
27
+ ) : (
28
+ <DateTimePicker
29
+ value={value}
30
+ mode={mode}
31
+ onChange={onChange}
32
+ display={"default"}
33
+ />
26
34
  );
27
35
  };
28
36
 
@@ -25,6 +25,6 @@ const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, isVisibl
25
25
  React.createElement(Picker, { value: value, open: isVisible, onChange: (d) => {
26
26
  toggleVisibility();
27
27
  onChange(null, d);
28
- }, onClose: () => toggleVisibility(), TextFieldComponent: () => null }))));
28
+ }, onClose: () => toggleVisibility(), variant: "dialog", TextFieldComponent: () => null }))));
29
29
  };
30
30
  export default withTheme(DatePickerComponent);
@@ -48,6 +48,7 @@ const DatePickerComponent: React.FC<Props & { theme: typeof Theme }> = ({
48
48
  onChange(null, d);
49
49
  }}
50
50
  onClose={() => toggleVisibility()}
51
+ variant="dialog"
51
52
  TextFieldComponent={() => null}
52
53
  />
53
54
  </ThemeProvider>
@@ -6,14 +6,5 @@ export interface DatePickerComponentProps {
6
6
  mode: "date" | "time" | "datetime";
7
7
  toggleVisibility: () => void;
8
8
  isVisible?: boolean;
9
- displayMode?:
10
- | "default"
11
- | "compact"
12
- | "inline"
13
- | "spinner"
14
- | "clock"
15
- | "calendar"
16
- | undefined;
17
- variant?: "dialog" | "inline" | undefined;
18
9
  theme?: typeof theme;
19
10
  }
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
2
+ import { ActivityIndicator, View, Text, StyleSheet, Pressable, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
- import Touchable from "./Touchable";
6
5
  import Elevation from "./Elevation";
7
6
  import { withTheme } from "../theming";
8
- const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
7
+ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
9
8
  let backgroundColor, borderColor, textColor, borderWidth;
10
9
  const buttonColor = colorOverride || colors.primary;
11
10
  if (type === "solid") {
@@ -59,19 +58,8 @@ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false,
59
58
  width: Config.buttonIconSize,
60
59
  },
61
60
  ];
62
- const { margin, marginEnd, marginTop, marginLeft, marginRight, marginBottom, marginHorizontal, marginVertical, ...innerStyles } = StyleSheet.flatten(style || {});
63
- const margins = {
64
- margin,
65
- marginEnd,
66
- marginTop,
67
- marginLeft,
68
- marginRight,
69
- marginBottom,
70
- marginHorizontal,
71
- marginVertical,
72
- };
73
- return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch", ...margins } },
74
- React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle, innerStyles] },
61
+ return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch" } },
62
+ React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle] },
75
63
  React.createElement(View, { style: styles.content },
76
64
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
77
65
  React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
@@ -4,14 +4,14 @@ import {
4
4
  View,
5
5
  Text,
6
6
  StyleSheet,
7
- TouchableHighlightProps,
8
7
  StyleProp,
9
8
  ViewStyle,
10
9
  TextStyle,
10
+ Pressable,
11
+ PressableProps,
11
12
  } from "react-native";
12
13
  import color from "color";
13
14
  import Config from "./Config";
14
- import Touchable from "./Touchable";
15
15
  import Elevation from "./Elevation";
16
16
  import { withTheme } from "../theming";
17
17
 
@@ -63,7 +63,7 @@ type Props = {
63
63
  elevation?: number;
64
64
  style?: StyleProp<ViewStyle>;
65
65
  theme: Theme;
66
- } & TouchableHighlightProps &
66
+ } & PressableProps &
67
67
  IconSlot;
68
68
 
69
69
  const Button: React.FC<React.PropsWithChildren<Props>> = ({
@@ -77,7 +77,6 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
77
77
  children,
78
78
  onPress,
79
79
  elevation = 0,
80
- style,
81
80
  theme: { colors, disabledOpacity, roundness, typography },
82
81
  ...rest
83
82
  }) => {
@@ -137,38 +136,15 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
137
136
  },
138
137
  ];
139
138
 
140
- const {
141
- margin,
142
- marginEnd,
143
- marginTop,
144
- marginLeft,
145
- marginRight,
146
- marginBottom,
147
- marginHorizontal,
148
- marginVertical,
149
- ...innerStyles
150
- } = StyleSheet.flatten(style || {});
151
-
152
- const margins = {
153
- margin,
154
- marginEnd,
155
- marginTop,
156
- marginLeft,
157
- marginRight,
158
- marginBottom,
159
- marginHorizontal,
160
- marginVertical,
161
- };
162
-
163
139
  return (
164
- <Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
165
- <Touchable
140
+ <Elevation style={{ elevation, alignSelf: "stretch" }}>
141
+ <Pressable
166
142
  {...rest}
167
143
  onPress={onPress}
168
144
  accessibilityState={{ disabled }}
169
145
  accessibilityRole="button"
170
146
  disabled={disabled || loading}
171
- style={[styles.button, buttonStyle, innerStyles]}
147
+ style={[styles.button, buttonStyle]}
172
148
  >
173
149
  <View style={styles.content}>
174
150
  {icon && loading !== true ? (
@@ -191,7 +167,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
191
167
  {children}
192
168
  </Text>
193
169
  </View>
194
- </Touchable>
170
+ </Pressable>
195
171
  </Elevation>
196
172
  );
197
173
  };
@@ -1,9 +1,8 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, StyleSheet, } from "react-native";
2
+ import { ActivityIndicator, View, StyleSheet, Pressable, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
5
  import Text from "./Text";
6
- import Touchable from "./Touchable";
7
6
  import Elevation from "./Elevation";
8
7
  import { withTheme } from "../theming";
9
8
  const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, color: colorOverride, label, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
@@ -83,7 +82,7 @@ const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, co
83
82
  });
84
83
  }
85
84
  return (React.createElement(Elevation, { style: [{ elevation }, style] },
86
- React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
85
+ React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
87
86
  React.createElement(View, { style: styles.content },
88
87
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
89
88
  React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
@@ -3,15 +3,15 @@ import {
3
3
  ActivityIndicator,
4
4
  View,
5
5
  StyleSheet,
6
- TouchableHighlightProps,
7
6
  StyleProp,
8
7
  ViewStyle,
9
8
  TextStyle,
9
+ Pressable,
10
+ PressableProps,
10
11
  } from "react-native";
11
12
  import color from "color";
12
13
  import Config from "./Config";
13
14
  import Text from "./Text";
14
- import Touchable from "./Touchable";
15
15
  import Elevation from "./Elevation";
16
16
  import { withTheme } from "../theming";
17
17
 
@@ -65,7 +65,7 @@ type Props = {
65
65
  elevation?: number;
66
66
  theme: Theme;
67
67
  style?: StyleProp<ViewStyle>;
68
- } & TouchableHighlightProps &
68
+ } & PressableProps &
69
69
  IconSlot;
70
70
 
71
71
  const FAB: React.FC<React.PropsWithChildren<Props>> = ({
@@ -169,7 +169,7 @@ const FAB: React.FC<React.PropsWithChildren<Props>> = ({
169
169
 
170
170
  return (
171
171
  <Elevation style={[{ elevation }, style]}>
172
- <Touchable
172
+ <Pressable
173
173
  {...rest}
174
174
  onPress={onPress}
175
175
  accessibilityState={{ disabled }}
@@ -200,7 +200,7 @@ const FAB: React.FC<React.PropsWithChildren<Props>> = ({
200
200
  </Text>
201
201
  ) : null}
202
202
  </View>
203
- </Touchable>
203
+ </Pressable>
204
204
  </Elevation>
205
205
  );
206
206
  };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { Pressable as NativePressable, } from "react-native";
3
+ export default function Pressable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
+ return (React.createElement(NativePressable, { onPress: onPress, disabled: disabled, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
5
+ return [
6
+ {
7
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
8
+ },
9
+ style,
10
+ ];
11
+ }, ...props }, children));
12
+ }
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import {
3
+ Pressable as NativePressable,
4
+ PressableProps,
5
+ ViewStyle,
6
+ } from "react-native";
7
+
8
+ type Props = {
9
+ style?: ViewStyle;
10
+ activeOpacity?: number;
11
+ disabledOpacity?: number;
12
+ } & PressableProps;
13
+
14
+ export default function Pressable({
15
+ children,
16
+ disabled,
17
+ onPress,
18
+ activeOpacity,
19
+ disabledOpacity,
20
+ delayLongPress,
21
+ hitSlop,
22
+ style,
23
+ ...props
24
+ }: Props) {
25
+ return (
26
+ <NativePressable
27
+ onPress={onPress}
28
+ disabled={disabled}
29
+ delayLongPress={delayLongPress ? delayLongPress : 500}
30
+ hitSlop={hitSlop ? hitSlop : 8}
31
+ style={({ pressed }) => {
32
+ return [
33
+ {
34
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
35
+ },
36
+ style,
37
+ ];
38
+ }}
39
+ {...props}
40
+ >
41
+ {children}
42
+ </NativePressable>
43
+ );
44
+ }
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
3
  import SwiperComponent from "react-native-web-swiper";
4
- const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, style, }) => (React.createElement(View, { style: style },
5
- React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, controlsProps: {
4
+ const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged, style, }) => (React.createElement(View, { style: style },
5
+ React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, onIndexChanged: onIndexChanged, controlsProps: {
6
6
  prevTitle,
7
7
  nextTitle,
8
8
  prevTitleStyle: { color: prevTitleColor },
@@ -19,6 +19,7 @@ export interface SwiperProps<T> {
19
19
  keyExtractor: (item: T, index: number) => string;
20
20
  renderItem?: ({ item, index }: { item: T; index: number }) => JSX.Element;
21
21
  style?: StyleProp<ViewStyle>;
22
+ onIndexChanged?: (index: number) => void;
22
23
  }
23
24
 
24
25
  const Swiper = ({
@@ -37,6 +38,7 @@ const Swiper = ({
37
38
  keyExtractor,
38
39
  renderItem,
39
40
  children,
41
+ onIndexChanged,
40
42
  style,
41
43
  }: SwiperProps<any>) => (
42
44
  <View style={style}>
@@ -46,6 +48,7 @@ const Swiper = ({
46
48
  loop={loop}
47
49
  timeout={timeout}
48
50
  vertical={vertical}
51
+ onIndexChanged={onIndexChanged}
49
52
  controlsProps={{
50
53
  prevTitle,
51
54
  nextTitle,
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { Pressable } from "react-native";
3
- export default function Touchable({ children, disabled, onPress, style, ...props }) {
4
- return (React.createElement(Pressable, { onPress: onPress, disabled: disabled, hitSlop: 8, style: ({ pressed }) => {
3
+ export default function Touchable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
+ return (React.createElement(Pressable, { disabled: disabled, onPress: onPress, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
5
5
  return [
6
6
  {
7
- opacity: pressed || disabled ? 0.75 : 1,
7
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
8
8
  },
9
9
  style,
10
10
  ];
@@ -1,29 +1,33 @@
1
1
  import React from "react";
2
- import { Pressable, ViewStyle, PressableProps } from "react-native";
2
+ import { Pressable, PressableProps, ViewStyle } from "react-native";
3
3
 
4
4
  type Props = {
5
- disabled?: boolean;
6
- children: React.ReactNode;
7
5
  style?: ViewStyle;
8
- onPress?: () => void;
6
+ activeOpacity?: number;
7
+ disabledOpacity?: number;
9
8
  } & PressableProps;
10
9
 
11
10
  export default function Touchable({
12
11
  children,
13
12
  disabled,
14
13
  onPress,
14
+ activeOpacity,
15
+ disabledOpacity,
16
+ delayLongPress,
17
+ hitSlop,
15
18
  style,
16
19
  ...props
17
20
  }: Props) {
18
21
  return (
19
22
  <Pressable
20
- onPress={onPress}
21
23
  disabled={disabled}
22
- hitSlop={8}
24
+ onPress={onPress}
25
+ delayLongPress={delayLongPress ? delayLongPress : 500}
26
+ hitSlop={hitSlop ? hitSlop : 8}
23
27
  style={({ pressed }) => {
24
28
  return [
25
29
  {
26
- opacity: pressed || disabled ? 0.75 : 1,
30
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
27
31
  },
28
32
  style,
29
33
  ];
package/src/index.js CHANGED
@@ -26,6 +26,7 @@ export { default as Switch, SwitchRow } from "./components/Switch";
26
26
  export { default as TextField } from "./components/TextField";
27
27
  export { default as ToggleButton } from "./components/ToggleButton";
28
28
  export { default as Touchable } from "./components/Touchable";
29
+ export { default as Pressable } from "./components/Pressable";
29
30
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
30
31
  export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
31
32
  export { Swiper, SwiperItem } from "./components/Swiper";
package/src/index.tsx CHANGED
@@ -27,6 +27,7 @@ export { default as Switch, SwitchRow } from "./components/Switch";
27
27
  export { default as TextField } from "./components/TextField";
28
28
  export { default as ToggleButton } from "./components/ToggleButton";
29
29
  export { default as Touchable } from "./components/Touchable";
30
+ export { default as Pressable } from "./components/Pressable";
30
31
  export { AccordionGroup, AccordionItem } from "./components/Accordion";
31
32
  export {
32
33
  ActionSheet,
@@ -1,7 +1,8 @@
1
- import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
2
- const SEED_DATA_TRIGGERS = [Triggers.OnPress];
1
+ import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, createStaticNumberProp, } from "@draftbit/types";
2
+ const SEED_DATA_TRIGGERS = [Triggers.OnPress, Triggers.OnLongPress];
3
3
  const SEED_DATA_PROPS = {
4
4
  onPress: createActionProp(),
5
+ onLongPress: createActionProp(),
5
6
  icon: createIconProp({
6
7
  defaultValue: null,
7
8
  required: false,
@@ -13,11 +14,36 @@ const SEED_DATA_PROPS = {
13
14
  }),
14
15
  disabled: createDisabledProp(),
15
16
  loading: createLoadingProp(),
16
- };
17
- const LAYOUT = {
18
- backgroundColor: "transparent",
19
- borderRadius: 8,
20
- fontFamily: "system-700",
17
+ activeOpacity: createStaticNumberProp({
18
+ label: "Active Opacity",
19
+ description: "Opacity of the button when active.",
20
+ defaultValue: 0.8,
21
+ min: 0,
22
+ max: 1,
23
+ step: 0.01,
24
+ precision: 2,
25
+ required: false,
26
+ }),
27
+ disabledOpacity: createStaticNumberProp({
28
+ label: "Disabled Opacity",
29
+ description: "Opacity of the button when disabled.",
30
+ defaultValue: 0.8,
31
+ min: 0,
32
+ max: 1,
33
+ step: 0.01,
34
+ precision: 2,
35
+ required: false,
36
+ }),
37
+ delayLongPress: createStaticNumberProp({
38
+ label: "Delay Long Press",
39
+ description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
40
+ required: false,
41
+ }),
42
+ hitSlop: createStaticNumberProp({
43
+ label: "Hit Slop",
44
+ description: "Sets additional distance outside of element in which a press can be detected",
45
+ required: false,
46
+ }),
21
47
  };
22
48
  export const SEED_DATA = [
23
49
  {
@@ -34,7 +60,8 @@ export const SEED_DATA = [
34
60
  StylesPanelSections.Effects,
35
61
  ],
36
62
  layout: {
37
- ...LAYOUT,
63
+ borderRadius: 8,
64
+ fontFamily: "system-700",
38
65
  backgroundColor: "transparent",
39
66
  borderWidth: 1,
40
67
  textAlign: "center",
@@ -56,7 +83,8 @@ export const SEED_DATA = [
56
83
  StylesPanelSections.Effects,
57
84
  ],
58
85
  layout: {
59
- ...LAYOUT,
86
+ borderRadius: 8,
87
+ fontFamily: "system-700",
60
88
  backgroundColor: "primary",
61
89
  textAlign: "center",
62
90
  },
@@ -77,7 +105,8 @@ export const SEED_DATA = [
77
105
  StylesPanelSections.Effects,
78
106
  ],
79
107
  layout: {
80
- ...LAYOUT,
108
+ borderRadius: 8,
109
+ fontFamily: "system-700",
81
110
  backgroundColor: "primary",
82
111
  textAlign: "center",
83
112
  },