@draftbit/core 47.0.1-2f600c.2 → 47.0.1-4681da.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 (80) hide show
  1. package/lib/commonjs/components/AspectRatio.js +1 -17
  2. package/lib/commonjs/components/Button.js +3 -3
  3. package/lib/commonjs/components/Checkbox/Checkbox.js +3 -1
  4. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +2 -1
  5. package/lib/commonjs/components/Checkbox/CheckboxRow.js +2 -1
  6. package/lib/commonjs/components/DeprecatedButton.js +27 -3
  7. package/lib/commonjs/components/DeprecatedFAB.js +2 -1
  8. package/lib/commonjs/components/Touchable.js +3 -8
  9. package/lib/commonjs/constants.js +1 -1
  10. package/lib/commonjs/mappings/Button.js +10 -39
  11. package/lib/commonjs/mappings/FlashList.js +45 -2
  12. package/lib/commonjs/mappings/FlatList.js +12 -0
  13. package/lib/commonjs/mappings/Touchable.js +7 -47
  14. package/lib/module/components/Accordion/AccordionItem.js +4 -25
  15. package/lib/module/components/AnimatedCircularProgress.js +1 -13
  16. package/lib/module/components/Button.js +3 -3
  17. package/lib/module/components/Checkbox/Checkbox.js +6 -4
  18. package/lib/module/components/Checkbox/CheckboxGroupRow.js +7 -25
  19. package/lib/module/components/Checkbox/CheckboxRow.js +8 -25
  20. package/lib/module/components/DeprecatedButton.js +28 -4
  21. package/lib/module/components/DeprecatedCardWrapper.js +1 -18
  22. package/lib/module/components/DeprecatedFAB.js +3 -2
  23. package/lib/module/components/NumberInput.js +3 -12
  24. package/lib/module/components/Portal/Portal.js +6 -2
  25. package/lib/module/components/ProgressBar.js +7 -39
  26. package/lib/module/components/Switch.js +10 -21
  27. package/lib/module/components/Touchable.js +3 -8
  28. package/lib/module/constants.js +0 -1
  29. package/lib/module/mappings/Button.js +11 -40
  30. package/lib/module/mappings/FlashList.js +46 -3
  31. package/lib/module/mappings/FlatList.js +13 -1
  32. package/lib/module/mappings/Touchable.js +9 -49
  33. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  34. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  35. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  36. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  37. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  38. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  39. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -1
  40. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  41. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  42. package/lib/typescript/src/components/Touchable.d.ts +2 -7
  43. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  44. package/lib/typescript/src/mappings/Button.d.ts +4 -113
  45. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  46. package/lib/typescript/src/mappings/FlashList.d.ts +112 -2
  47. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  48. package/lib/typescript/src/mappings/FlatList.d.ts +42 -0
  49. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  50. package/lib/typescript/src/mappings/Touchable.d.ts +5 -59
  51. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  52. package/package.json +3 -3
  53. package/src/components/Button.js +3 -3
  54. package/src/components/Button.tsx +4 -14
  55. package/src/components/Checkbox/Checkbox.js +3 -2
  56. package/src/components/Checkbox/Checkbox.tsx +7 -5
  57. package/src/components/Checkbox/CheckboxGroupRow.js +3 -2
  58. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  59. package/src/components/Checkbox/CheckboxRow.js +3 -2
  60. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  61. package/src/components/DeprecatedButton.js +16 -4
  62. package/src/components/DeprecatedButton.tsx +31 -7
  63. package/src/components/DeprecatedFAB.js +3 -2
  64. package/src/components/DeprecatedFAB.tsx +5 -5
  65. package/src/components/Touchable.js +3 -3
  66. package/src/components/Touchable.tsx +4 -14
  67. package/src/mappings/Button.js +10 -39
  68. package/src/mappings/Button.ts +10 -41
  69. package/src/mappings/FlashList.js +77 -31
  70. package/src/mappings/FlashList.ts +82 -30
  71. package/src/mappings/FlatList.js +13 -1
  72. package/src/mappings/FlatList.ts +16 -0
  73. package/src/mappings/Touchable.js +7 -50
  74. package/src/mappings/Touchable.ts +6 -53
  75. package/lib/commonjs/components/Pressable.js +0 -37
  76. package/lib/module/components/Pressable.js +0 -30
  77. package/lib/typescript/src/components/Pressable.d.ts +0 -16
  78. package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
  79. package/src/components/Pressable.js +0 -12
  80. package/src/components/Pressable.tsx +0 -50
@@ -7,7 +7,7 @@ const CONSTANTS = {
7
7
  padding: 8,
8
8
  icon: 24,
9
9
  };
10
- function Base({ Icon, icon, title, loading, disabled, style, activeOpacity, disabledOpacity, ...props }) {
10
+ function Base({ Icon, icon, title, onPress, loading, disabled, style, ...props }) {
11
11
  const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...buttonStyles } = StyleSheet.flatten(style || {});
12
12
  const titleStyles = {
13
13
  color,
@@ -28,11 +28,11 @@ function Base({ Icon, icon, title, loading, disabled, style, activeOpacity, disa
28
28
  if (textAlign === "right") {
29
29
  buttonStyles.justifyContent = "flex-end";
30
30
  }
31
- return (React.createElement(Pressable, { disabled: disabled || loading, style: ({ pressed }) => {
31
+ return (React.createElement(Pressable, { onPress: onPress, disabled: disabled || loading, style: ({ pressed }) => {
32
32
  return [
33
33
  styles.base,
34
34
  {
35
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
35
+ opacity: pressed || disabled ? 0.75 : 1,
36
36
  },
37
37
  buttonStyles,
38
38
  ];
@@ -2,10 +2,10 @@ import * as React from "react";
2
2
  import {
3
3
  Text,
4
4
  Pressable,
5
- PressableProps,
6
5
  Platform,
7
6
  StyleSheet,
8
7
  TextStyle,
8
+ PressableProps,
9
9
  ActivityIndicator,
10
10
  } from "react-native";
11
11
 
@@ -27,11 +27,6 @@ type BaseProps = {
27
27
  loading: boolean;
28
28
  style?: TextStyle;
29
29
  onPress: () => void;
30
- onLongPress?: () => void;
31
- activeOpacity?: number;
32
- disabledOpacity?: number;
33
- delayLongPress?: number;
34
- hitSlop?: number;
35
30
  icon?: string;
36
31
  } & PressableProps &
37
32
  IconSlot;
@@ -42,11 +37,6 @@ type Props = {
42
37
  loading: boolean;
43
38
  style?: TextStyle;
44
39
  onPress: () => void;
45
- onLongPress?: () => void;
46
- activeOpacity?: number;
47
- disabledOpacity?: number;
48
- delayLongPress?: number;
49
- hitSlop?: number;
50
40
  icon?: string;
51
41
  theme: Theme;
52
42
  } & PressableProps &
@@ -56,11 +46,10 @@ function Base({
56
46
  Icon,
57
47
  icon,
58
48
  title,
49
+ onPress,
59
50
  loading,
60
51
  disabled,
61
52
  style,
62
- activeOpacity,
63
- disabledOpacity,
64
53
  ...props
65
54
  }: BaseProps): JSX.Element {
66
55
  const {
@@ -102,12 +91,13 @@ function Base({
102
91
 
103
92
  return (
104
93
  <Pressable
94
+ onPress={onPress}
105
95
  disabled={disabled || loading}
106
96
  style={({ pressed }) => {
107
97
  return [
108
98
  styles.base,
109
99
  {
110
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
100
+ opacity: pressed || disabled ? 0.75 : 1,
111
101
  },
112
102
  buttonStyles,
113
103
  ];
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Pressable, } from "react-native";
2
+ import { View, StyleSheet, } from "react-native";
3
3
  import { useTheme } from "../../theming";
4
+ import Touchable from "../Touchable";
4
5
  import { usePrevious } from "../../hooks";
5
6
  const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck, color, uncheckedColor, defaultValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", size = 24, style, ...rest }) => {
6
7
  const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
@@ -32,7 +33,7 @@ const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck,
32
33
  onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
33
34
  }
34
35
  };
35
- return (React.createElement(Pressable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
36
+ return (React.createElement(Touchable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
36
37
  React.createElement(Icon, { style: styles.icon, name: internalValue ? checkedIcon : uncheckedIcon, size: size, color: checkboxColor }),
37
38
  React.createElement(View, { style: [StyleSheet.absoluteFill, styles.fillContainer] },
38
39
  React.createElement(View, { style: [
@@ -2,14 +2,14 @@ import * as React from "react";
2
2
  import {
3
3
  View,
4
4
  StyleSheet,
5
- Pressable,
6
- PressableProps,
5
+ TouchableHighlightProps,
7
6
  StyleProp,
8
7
  ViewStyle,
9
8
  } from "react-native";
10
9
  import { useTheme } from "../../theming";
11
10
  import type { IconSlot } from "../../interfaces/Icon";
12
11
 
12
+ import Touchable from "../Touchable";
13
13
  import { usePrevious } from "../../hooks";
14
14
 
15
15
  export interface CheckboxProps {
@@ -27,7 +27,9 @@ export interface CheckboxProps {
27
27
  style?: StyleProp<ViewStyle>;
28
28
  }
29
29
 
30
- const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
30
+ const Checkbox: React.FC<
31
+ CheckboxProps & TouchableHighlightProps & IconSlot
32
+ > = ({
31
33
  Icon,
32
34
  status,
33
35
  disabled = false,
@@ -85,7 +87,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
85
87
  };
86
88
 
87
89
  return (
88
- <Pressable
90
+ <Touchable
89
91
  {...rest}
90
92
  onPress={handlePress}
91
93
  disabled={disabled}
@@ -109,7 +111,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
109
111
  ]}
110
112
  />
111
113
  </View>
112
- </Pressable>
114
+ </Touchable>
113
115
  );
114
116
  };
115
117
 
@@ -1,9 +1,10 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, Platform, Pressable, } from "react-native";
2
+ import { StyleSheet, View, Platform, } from "react-native";
3
3
  import Checkbox from "./Checkbox";
4
4
  import Text from "../Text";
5
5
  import { useCheckboxGroupContext } from "./context";
6
6
  import { Direction as GroupDirection } from "./context";
7
+ import Touchable from "../Touchable";
7
8
  import { extractStyles } from "../../utilities";
8
9
  export var Direction;
9
10
  (function (Direction) {
@@ -40,7 +41,7 @@ const CheckboxGroupRow = ({ Icon, label = "Label", status, value, onPress, label
40
41
  }
41
42
  };
42
43
  const { textStyles, viewStyles } = extractStyles(style);
43
- return (React.createElement(Pressable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
44
+ return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
44
45
  React.createElement(View, { style: [
45
46
  styles.label,
46
47
  {
@@ -6,13 +6,13 @@ import {
6
6
  TextStyle,
7
7
  View,
8
8
  Platform,
9
- Pressable,
10
9
  } from "react-native";
11
10
  import Checkbox, { CheckboxProps } from "./Checkbox";
12
11
  import Text from "../Text";
13
12
  import { useCheckboxGroupContext } from "./context";
14
13
  import type { IconSlot } from "../../interfaces/Icon";
15
14
  import { Direction as GroupDirection } from "./context";
15
+ import Touchable from "../Touchable";
16
16
  import { extractStyles } from "../../utilities";
17
17
 
18
18
  export enum Direction {
@@ -92,7 +92,7 @@ const CheckboxGroupRow: React.FC<CheckboxGroupRowProps & IconSlot> = ({
92
92
  const { textStyles, viewStyles } = extractStyles(style);
93
93
 
94
94
  return (
95
- <Pressable
95
+ <Touchable
96
96
  onPress={handlePress}
97
97
  style={[styles.mainParent, { flexDirection: direction }, viewStyles]}
98
98
  disabled={disabled}
@@ -125,7 +125,7 @@ const CheckboxGroupRow: React.FC<CheckboxGroupRowProps & IconSlot> = ({
125
125
  uncheckedColor={uncheckedColor}
126
126
  />
127
127
  </View>
128
- </Pressable>
128
+ </Touchable>
129
129
  );
130
130
  };
131
131
 
@@ -1,9 +1,10 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, Platform, Pressable, } from "react-native";
2
+ import { StyleSheet, View, Platform, } 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";
7
8
  import Checkbox from "./Checkbox";
8
9
  export var Direction;
9
10
  (function (Direction) {
@@ -45,7 +46,7 @@ const CheckboxRow = ({ label = "Label", labelStyle, labelContainerStyle, checkbo
45
46
  }
46
47
  };
47
48
  const { textStyles, viewStyles } = extractStyles(style);
48
- return (React.createElement(Pressable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
49
+ return (React.createElement(Touchable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
49
50
  React.createElement(View, { style: [
50
51
  styles.label,
51
52
  {
@@ -6,7 +6,6 @@ import {
6
6
  TextStyle,
7
7
  View,
8
8
  Platform,
9
- Pressable,
10
9
  } from "react-native";
11
10
  import { isString } from "lodash";
12
11
 
@@ -14,6 +13,7 @@ import type { IconSlot } from "../../interfaces/Icon";
14
13
  import { extractStyles } from "../../utilities";
15
14
  import { usePrevious } from "../../hooks";
16
15
  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
- <Pressable
103
+ <Touchable
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
- </Pressable>
133
+ </Touchable>
134
134
  );
135
135
  };
136
136
 
@@ -1,10 +1,11 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, Text, StyleSheet, Pressable, } from "react-native";
2
+ import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
+ import Touchable from "./Touchable";
5
6
  import Elevation from "./Elevation";
6
7
  import { withTheme } from "../theming";
7
- const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
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 }) => {
8
9
  let backgroundColor, borderColor, textColor, borderWidth;
9
10
  const buttonColor = colorOverride || colors.primary;
10
11
  if (type === "solid") {
@@ -58,8 +59,19 @@ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false,
58
59
  width: Config.buttonIconSize,
59
60
  },
60
61
  ];
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] },
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] },
63
75
  React.createElement(View, { style: styles.content },
64
76
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
65
77
  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,
7
8
  StyleProp,
8
9
  ViewStyle,
9
10
  TextStyle,
10
- Pressable,
11
- PressableProps,
12
11
  } from "react-native";
13
12
  import color from "color";
14
13
  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
- } & PressableProps &
66
+ } & TouchableHighlightProps &
67
67
  IconSlot;
68
68
 
69
69
  const Button: React.FC<React.PropsWithChildren<Props>> = ({
@@ -77,6 +77,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
77
77
  children,
78
78
  onPress,
79
79
  elevation = 0,
80
+ style,
80
81
  theme: { colors, disabledOpacity, roundness, typography },
81
82
  ...rest
82
83
  }) => {
@@ -136,15 +137,38 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
136
137
  },
137
138
  ];
138
139
 
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
+
139
163
  return (
140
- <Elevation style={{ elevation, alignSelf: "stretch" }}>
141
- <Pressable
164
+ <Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
165
+ <Touchable
142
166
  {...rest}
143
167
  onPress={onPress}
144
168
  accessibilityState={{ disabled }}
145
169
  accessibilityRole="button"
146
170
  disabled={disabled || loading}
147
- style={[styles.button, buttonStyle]}
171
+ style={[styles.button, buttonStyle, innerStyles]}
148
172
  >
149
173
  <View style={styles.content}>
150
174
  {icon && loading !== true ? (
@@ -167,7 +191,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
167
191
  {children}
168
192
  </Text>
169
193
  </View>
170
- </Pressable>
194
+ </Touchable>
171
195
  </Elevation>
172
196
  );
173
197
  };
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, StyleSheet, Pressable, } from "react-native";
2
+ import { ActivityIndicator, View, StyleSheet, } 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";
6
7
  import Elevation from "./Elevation";
7
8
  import { withTheme } from "../theming";
8
9
  const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, color: colorOverride, label, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
@@ -82,7 +83,7 @@ const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, co
82
83
  });
83
84
  }
84
85
  return (React.createElement(Elevation, { style: [{ elevation }, style] },
85
- React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
86
+ React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
86
87
  React.createElement(View, { style: styles.content },
87
88
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
88
89
  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,
6
7
  StyleProp,
7
8
  ViewStyle,
8
9
  TextStyle,
9
- Pressable,
10
- PressableProps,
11
10
  } from "react-native";
12
11
  import color from "color";
13
12
  import Config from "./Config";
14
13
  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
- } & PressableProps &
68
+ } & TouchableHighlightProps &
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
- <Pressable
172
+ <Touchable
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
- </Pressable>
203
+ </Touchable>
204
204
  </Elevation>
205
205
  );
206
206
  };
@@ -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, 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 }) => {
3
+ export default function Touchable({ children, disabled, onPress, style, ...props }) {
4
+ return (React.createElement(Pressable, { onPress: onPress, disabled: disabled, hitSlop: 8, style: ({ pressed }) => {
5
5
  return [
6
6
  {
7
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
7
+ opacity: pressed || disabled ? 0.75 : 1,
8
8
  },
9
9
  style,
10
10
  ];
@@ -1,39 +1,29 @@
1
1
  import React from "react";
2
- import { Pressable, PressableProps, ViewStyle } from "react-native";
2
+ import { Pressable, ViewStyle, PressableProps } from "react-native";
3
3
 
4
4
  type Props = {
5
5
  disabled?: boolean;
6
6
  children: React.ReactNode;
7
7
  style?: ViewStyle;
8
8
  onPress?: () => void;
9
- onLongPress?: () => void;
10
- delayLongPress?: number;
11
- hitSlop?: number;
12
- activeOpacity?: number;
13
- disabledOpacity?: number;
14
9
  } & PressableProps;
15
10
 
16
11
  export default function Touchable({
17
12
  children,
18
13
  disabled,
19
14
  onPress,
20
- activeOpacity,
21
- disabledOpacity,
22
- delayLongPress,
23
- hitSlop,
24
15
  style,
25
16
  ...props
26
17
  }: Props) {
27
18
  return (
28
19
  <Pressable
29
- disabled={disabled}
30
20
  onPress={onPress}
31
- delayLongPress={delayLongPress ? delayLongPress : 500}
32
- hitSlop={hitSlop ? hitSlop : 8}
21
+ disabled={disabled}
22
+ hitSlop={8}
33
23
  style={({ pressed }) => {
34
24
  return [
35
25
  {
36
- opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
26
+ opacity: pressed || disabled ? 0.75 : 1,
37
27
  },
38
28
  style,
39
29
  ];
@@ -1,8 +1,7 @@
1
- import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, createStaticNumberProp, } from "@draftbit/types";
2
- const SEED_DATA_TRIGGERS = [Triggers.OnPress, Triggers.OnLongPress];
1
+ import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
2
+ const SEED_DATA_TRIGGERS = [Triggers.OnPress];
3
3
  const SEED_DATA_PROPS = {
4
4
  onPress: createActionProp(),
5
- onLongPress: createActionProp(),
6
5
  icon: createIconProp({
7
6
  defaultValue: null,
8
7
  required: false,
@@ -14,36 +13,11 @@ const SEED_DATA_PROPS = {
14
13
  }),
15
14
  disabled: createDisabledProp(),
16
15
  loading: createLoadingProp(),
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
- }),
16
+ };
17
+ const LAYOUT = {
18
+ backgroundColor: "transparent",
19
+ borderRadius: 8,
20
+ fontFamily: "system-700",
47
21
  };
48
22
  export const SEED_DATA = [
49
23
  {
@@ -60,8 +34,7 @@ export const SEED_DATA = [
60
34
  StylesPanelSections.Effects,
61
35
  ],
62
36
  layout: {
63
- borderRadius: 8,
64
- fontFamily: "system-700",
37
+ ...LAYOUT,
65
38
  backgroundColor: "transparent",
66
39
  borderWidth: 1,
67
40
  textAlign: "center",
@@ -83,8 +56,7 @@ export const SEED_DATA = [
83
56
  StylesPanelSections.Effects,
84
57
  ],
85
58
  layout: {
86
- borderRadius: 8,
87
- fontFamily: "system-700",
59
+ ...LAYOUT,
88
60
  backgroundColor: "primary",
89
61
  textAlign: "center",
90
62
  },
@@ -105,8 +77,7 @@ export const SEED_DATA = [
105
77
  StylesPanelSections.Effects,
106
78
  ],
107
79
  layout: {
108
- borderRadius: 8,
109
- fontFamily: "system-700",
80
+ ...LAYOUT,
110
81
  backgroundColor: "primary",
111
82
  textAlign: "center",
112
83
  },
@@ -7,13 +7,11 @@ import {
7
7
  createActionProp,
8
8
  Triggers,
9
9
  StylesPanelSections,
10
- createStaticNumberProp,
11
10
  } from "@draftbit/types";
12
11
 
13
- const SEED_DATA_TRIGGERS = [Triggers.OnPress, Triggers.OnLongPress];
12
+ const SEED_DATA_TRIGGERS = [Triggers.OnPress];
14
13
  const SEED_DATA_PROPS = {
15
14
  onPress: createActionProp(),
16
- onLongPress: createActionProp(),
17
15
  icon: createIconProp({
18
16
  defaultValue: null,
19
17
  required: false,
@@ -25,38 +23,12 @@ const SEED_DATA_PROPS = {
25
23
  }),
26
24
  disabled: createDisabledProp(),
27
25
  loading: createLoadingProp(),
28
- activeOpacity: createStaticNumberProp({
29
- label: "Active Opacity",
30
- description: "Opacity of the button when active.",
31
- defaultValue: 0.8,
32
- min: 0,
33
- max: 1,
34
- step: 0.01,
35
- precision: 2,
36
- required: false,
37
- }),
38
- disabledOpacity: createStaticNumberProp({
39
- label: "Disabled Opacity",
40
- description: "Opacity of the button when disabled.",
41
- defaultValue: 0.8,
42
- min: 0,
43
- max: 1,
44
- step: 0.01,
45
- precision: 2,
46
- required: false,
47
- }),
48
- delayLongPress: createStaticNumberProp({
49
- label: "Delay Long Press",
50
- description:
51
- "Duration (in milliseconds) from onPressIn before onLongPress is called.",
52
- required: false,
53
- }),
54
- hitSlop: createStaticNumberProp({
55
- label: "Hit Slop",
56
- description:
57
- "Sets additional distance outside of element in which a press can be detected",
58
- required: false,
59
- }),
26
+ };
27
+
28
+ const LAYOUT = {
29
+ backgroundColor: "transparent",
30
+ borderRadius: 8,
31
+ fontFamily: "system-700",
60
32
  };
61
33
 
62
34
  export const SEED_DATA = [
@@ -74,8 +46,7 @@ export const SEED_DATA = [
74
46
  StylesPanelSections.Effects,
75
47
  ],
76
48
  layout: {
77
- borderRadius: 8,
78
- fontFamily: "system-700",
49
+ ...LAYOUT,
79
50
  backgroundColor: "transparent",
80
51
  borderWidth: 1,
81
52
  textAlign: "center",
@@ -97,8 +68,7 @@ export const SEED_DATA = [
97
68
  StylesPanelSections.Effects,
98
69
  ],
99
70
  layout: {
100
- borderRadius: 8,
101
- fontFamily: "system-700",
71
+ ...LAYOUT,
102
72
  backgroundColor: "primary",
103
73
  textAlign: "center",
104
74
  },
@@ -119,8 +89,7 @@ export const SEED_DATA = [
119
89
  StylesPanelSections.Effects,
120
90
  ],
121
91
  layout: {
122
- borderRadius: 8,
123
- fontFamily: "system-700",
92
+ ...LAYOUT,
124
93
  backgroundColor: "primary",
125
94
  textAlign: "center",
126
95
  },