@draftbit/core 47.0.1-cc5ccc.2 → 47.0.1-df014a.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.
- package/lib/commonjs/components/Button.js +15 -27
- package/lib/commonjs/components/Checkbox/Checkbox.js +3 -1
- package/lib/commonjs/components/DeprecatedButton.js +151 -0
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
- package/lib/commonjs/components/DeprecatedFAB.js +2 -1
- package/lib/commonjs/components/Picker/Picker.js +4 -3
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
- package/lib/commonjs/components/Touchable.js +11 -27
- package/lib/commonjs/components/Touchable.web.js +9 -0
- package/lib/commonjs/mappings/Button.js +10 -13
- package/lib/commonjs/mappings/DatePickerModal.js +74 -0
- package/lib/commonjs/mappings/Touchable.js +20 -0
- package/lib/module/components/AvatarEdit.js +15 -4
- package/lib/module/components/Button.js +9 -21
- package/lib/module/components/CardBlock.js +14 -4
- package/lib/module/components/Checkbox/Checkbox.js +3 -2
- package/lib/module/components/CircleImage.js +16 -1
- package/lib/module/components/DeprecatedButton.js +141 -0
- package/lib/module/components/DeprecatedCardWrapper.js +20 -3
- package/lib/module/components/DeprecatedFAB.js +3 -2
- package/lib/module/components/FAB.js +22 -4
- package/lib/module/components/Picker/Picker.js +4 -3
- package/lib/module/components/Picker/PickerComponent.ios.js +37 -12
- package/lib/module/components/Picker/PickerComponent.web.js +21 -3
- package/lib/module/components/Switch.js +21 -10
- package/lib/module/components/TextField.js +78 -28
- package/lib/module/components/Touchable.js +28 -26
- package/lib/module/components/Touchable.web.js +2 -0
- package/lib/module/mappings/Button.js +11 -14
- package/lib/module/mappings/DatePickerModal.js +65 -0
- package/lib/module/mappings/Touchable.js +13 -0
- package/lib/typescript/src/components/Button.d.ts +0 -2
- package/lib/typescript/src/components/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedButton.d.ts +54 -0
- package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -0
- package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
- package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.d.ts +2 -9
- package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.web.d.ts +3 -0
- package/lib/typescript/src/components/Touchable.web.d.ts.map +1 -0
- package/lib/typescript/src/mappings/Button.d.ts +4 -113
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/DatePickerModal.d.ts +153 -0
- package/lib/typescript/src/mappings/DatePickerModal.d.ts.map +1 -0
- package/lib/typescript/src/mappings/Touchable.d.ts +22 -0
- package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Button.js +11 -18
- package/src/components/Button.tsx +11 -45
- package/src/components/Checkbox/Checkbox.js +3 -2
- package/src/components/Checkbox/Checkbox.tsx +7 -5
- package/src/components/DeprecatedButton.js +95 -0
- package/src/components/DeprecatedButton.tsx +214 -0
- package/src/components/DeprecatedCardWrapper.js +2 -2
- package/src/components/DeprecatedCardWrapper.tsx +4 -3
- package/src/components/DeprecatedFAB.js +3 -2
- package/src/components/DeprecatedFAB.tsx +5 -5
- package/src/components/Picker/Picker.js +4 -3
- package/src/components/Picker/Picker.tsx +4 -4
- package/src/components/Picker/PickerComponent.ios.js +1 -1
- package/src/components/Picker/PickerComponent.ios.tsx +1 -1
- package/src/components/Touchable.js +11 -16
- package/src/components/Touchable.tsx +11 -42
- package/src/components/Touchable.web.js +2 -0
- package/src/components/Touchable.web.tsx +3 -0
- package/src/mappings/Button.js +10 -13
- package/src/mappings/Button.ts +10 -13
- package/src/mappings/DatePickerModal.js +73 -0
- package/src/mappings/DatePickerModal.ts +91 -0
- package/src/mappings/Touchable.js +17 -0
- package/src/mappings/Touchable.ts +23 -0
- package/lib/commonjs/components/Pressable.js +0 -48
- package/lib/commonjs/mappings/Pressable.js +0 -52
- package/lib/module/components/Pressable.js +0 -40
- package/lib/module/mappings/Pressable.js +0 -45
- package/lib/typescript/src/components/Pressable.d.ts +0 -18
- package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Pressable.d.ts +0 -76
- package/lib/typescript/src/mappings/Pressable.d.ts.map +0 -1
- package/src/components/Pressable.js +0 -17
- package/src/components/Pressable.tsx +0 -67
- package/src/mappings/Pressable.js +0 -52
- package/src/mappings/Pressable.ts +0 -63
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TouchableHighlightProps,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
TextStyle,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import color from "color";
|
|
13
|
+
import Config from "./Config";
|
|
14
|
+
import Touchable from "./Touchable";
|
|
15
|
+
import Elevation from "./Elevation";
|
|
16
|
+
import { withTheme } from "../theming";
|
|
17
|
+
|
|
18
|
+
import type { Theme } from "../styles/DefaultTheme";
|
|
19
|
+
import type { IconSlot } from "../interfaces/Icon";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A button is component that the user can press to trigger an action.
|
|
23
|
+
*
|
|
24
|
+
* <div class="screenshots">
|
|
25
|
+
* <figure>
|
|
26
|
+
* <img src="screenshots/button-1.png" />
|
|
27
|
+
* <figcaption>Text button</figcaption>
|
|
28
|
+
* </figure>
|
|
29
|
+
* <figure>
|
|
30
|
+
* <img src="screenshots/button-2.png" />
|
|
31
|
+
* <figcaption>Outlined button</figcaption>
|
|
32
|
+
* </figure>
|
|
33
|
+
* <figure>
|
|
34
|
+
* <img src="screenshots/button-3.png" />
|
|
35
|
+
* <figcaption>Contained button</figcaption>
|
|
36
|
+
* </figure>
|
|
37
|
+
* </div>
|
|
38
|
+
*
|
|
39
|
+
* ## Usage
|
|
40
|
+
* ```js
|
|
41
|
+
* import * as React from 'react';
|
|
42
|
+
* import { Button } from '@draftbit/ui';
|
|
43
|
+
*
|
|
44
|
+
* const MyComponent = () => (
|
|
45
|
+
* <Button icon="add-a-photo" type="solid" onPress={() => console.log('Pressed')}>
|
|
46
|
+
* Press me
|
|
47
|
+
* </Button>
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* export default MyComponent;
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
type Props = {
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
type?: "solid" | "outline" | "text";
|
|
57
|
+
loading?: boolean;
|
|
58
|
+
icon?: string;
|
|
59
|
+
labelColor?: string;
|
|
60
|
+
color?: string;
|
|
61
|
+
children?: React.ReactNode;
|
|
62
|
+
onPress: () => void;
|
|
63
|
+
elevation?: number;
|
|
64
|
+
style?: StyleProp<ViewStyle>;
|
|
65
|
+
theme: Theme;
|
|
66
|
+
} & TouchableHighlightProps &
|
|
67
|
+
IconSlot;
|
|
68
|
+
|
|
69
|
+
const Button: React.FC<React.PropsWithChildren<Props>> = ({
|
|
70
|
+
Icon,
|
|
71
|
+
icon,
|
|
72
|
+
disabled = false,
|
|
73
|
+
type = "solid",
|
|
74
|
+
loading = false,
|
|
75
|
+
labelColor,
|
|
76
|
+
color: colorOverride,
|
|
77
|
+
children,
|
|
78
|
+
onPress,
|
|
79
|
+
elevation = 0,
|
|
80
|
+
style,
|
|
81
|
+
theme: { colors, disabledOpacity, roundness, typography },
|
|
82
|
+
...rest
|
|
83
|
+
}) => {
|
|
84
|
+
let backgroundColor, borderColor, textColor, borderWidth;
|
|
85
|
+
const buttonColor = colorOverride || colors.primary;
|
|
86
|
+
|
|
87
|
+
if (type === "solid") {
|
|
88
|
+
backgroundColor = buttonColor;
|
|
89
|
+
|
|
90
|
+
if (disabled) {
|
|
91
|
+
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
92
|
+
} else {
|
|
93
|
+
textColor = labelColor || colors.surface;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
backgroundColor = "transparent";
|
|
97
|
+
|
|
98
|
+
if (disabled) {
|
|
99
|
+
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
100
|
+
} else {
|
|
101
|
+
textColor = labelColor || buttonColor;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (type === "outline") {
|
|
106
|
+
if (disabled) {
|
|
107
|
+
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
108
|
+
} else {
|
|
109
|
+
borderColor = buttonColor;
|
|
110
|
+
}
|
|
111
|
+
borderWidth = StyleSheet.hairlineWidth;
|
|
112
|
+
} else {
|
|
113
|
+
borderColor = "transparent";
|
|
114
|
+
borderWidth = 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const buttonStyle = {
|
|
118
|
+
backgroundColor,
|
|
119
|
+
borderColor,
|
|
120
|
+
borderWidth,
|
|
121
|
+
borderRadius: roundness,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const textStyle: StyleProp<TextStyle> = {
|
|
125
|
+
textAlign: "center",
|
|
126
|
+
color: textColor,
|
|
127
|
+
marginVertical: 16,
|
|
128
|
+
marginHorizontal: 16,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const iconStyle = [
|
|
132
|
+
styles.icon,
|
|
133
|
+
{
|
|
134
|
+
marginLeft: 16,
|
|
135
|
+
marginRight: -8,
|
|
136
|
+
width: Config.buttonIconSize,
|
|
137
|
+
},
|
|
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
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
|
|
165
|
+
<Touchable
|
|
166
|
+
{...rest}
|
|
167
|
+
onPress={onPress}
|
|
168
|
+
accessibilityState={{ disabled }}
|
|
169
|
+
accessibilityRole="button"
|
|
170
|
+
disabled={disabled || loading}
|
|
171
|
+
style={[styles.button, buttonStyle, innerStyles]}
|
|
172
|
+
>
|
|
173
|
+
<View style={styles.content}>
|
|
174
|
+
{icon && loading !== true ? (
|
|
175
|
+
<View style={iconStyle}>
|
|
176
|
+
<Icon
|
|
177
|
+
name={icon}
|
|
178
|
+
size={Config.buttonIconSize}
|
|
179
|
+
color={textColor}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
) : null}
|
|
183
|
+
{loading ? (
|
|
184
|
+
<ActivityIndicator
|
|
185
|
+
size="small"
|
|
186
|
+
color={textColor}
|
|
187
|
+
style={iconStyle}
|
|
188
|
+
/>
|
|
189
|
+
) : null}
|
|
190
|
+
<Text numberOfLines={1} style={[textStyle, typography.button]}>
|
|
191
|
+
{children}
|
|
192
|
+
</Text>
|
|
193
|
+
</View>
|
|
194
|
+
</Touchable>
|
|
195
|
+
</Elevation>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const styles = StyleSheet.create({
|
|
200
|
+
button: {
|
|
201
|
+
minWidth: 64,
|
|
202
|
+
borderStyle: "solid",
|
|
203
|
+
},
|
|
204
|
+
content: {
|
|
205
|
+
flexDirection: "row",
|
|
206
|
+
alignItems: "center",
|
|
207
|
+
justifyContent: "center",
|
|
208
|
+
},
|
|
209
|
+
icon: {
|
|
210
|
+
width: Config.buttonIconSize,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export default withTheme(Button);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { withTheme } from "../theming";
|
|
3
|
-
import
|
|
3
|
+
import Touchable from "./Touchable";
|
|
4
4
|
const getWidth = (numColumns) => {
|
|
5
5
|
switch (numColumns) {
|
|
6
6
|
case 1:
|
|
@@ -13,6 +13,6 @@ const getWidth = (numColumns) => {
|
|
|
13
13
|
};
|
|
14
14
|
const Card = ({ numColumns = 3, children, onPress, style, ...rest }) => {
|
|
15
15
|
const width = getWidth(numColumns);
|
|
16
|
-
return (React.createElement(
|
|
16
|
+
return (React.createElement(Touchable, { disabled: !onPress, onPress: onPress, style: [style, { width }], ...rest }, children));
|
|
17
17
|
};
|
|
18
18
|
export default withTheme(Card);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { withTheme } from "../theming";
|
|
3
|
-
import
|
|
3
|
+
import Touchable from "./Touchable";
|
|
4
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
4
5
|
import theme from "../styles/DefaultTheme";
|
|
5
6
|
|
|
6
7
|
type Props = {
|
|
@@ -31,14 +32,14 @@ const Card: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
31
32
|
}) => {
|
|
32
33
|
const width = getWidth(numColumns);
|
|
33
34
|
return (
|
|
34
|
-
<
|
|
35
|
+
<Touchable
|
|
35
36
|
disabled={!onPress}
|
|
36
37
|
onPress={onPress}
|
|
37
38
|
style={[style, { width }]}
|
|
38
39
|
{...rest}
|
|
39
40
|
>
|
|
40
41
|
{children}
|
|
41
|
-
</
|
|
42
|
+
</Touchable>
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ActivityIndicator, View, StyleSheet,
|
|
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(
|
|
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
|
-
} &
|
|
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
|
-
<
|
|
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
|
-
</
|
|
203
|
+
</Touchable>
|
|
204
204
|
</Elevation>
|
|
205
205
|
);
|
|
206
206
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Text, Platform, Dimensions,
|
|
2
|
+
import { View, StyleSheet, Text, Platform, Dimensions, } 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";
|
|
6
6
|
import { withTheme } from "../../theming";
|
|
7
7
|
import Portal from "../Portal/Portal";
|
|
8
|
-
import
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
|
+
import Touchable from "../Touchable";
|
|
9
10
|
import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
|
|
10
11
|
function normalizeOptions(options) {
|
|
11
12
|
if (options.length === 0) {
|
|
@@ -165,7 +166,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
165
166
|
return (
|
|
166
167
|
/* marginsContainer */
|
|
167
168
|
React.createElement(View, { style: [styles.marginsContainer, marginStyles] },
|
|
168
|
-
React.createElement(
|
|
169
|
+
React.createElement(Touchable, { disabled: disabled, onPress: togglePickerVisible, style: styles.touchableContainer },
|
|
169
170
|
React.createElement(View, { pointerEvents: "none", style: [
|
|
170
171
|
styles.outsetContainer,
|
|
171
172
|
stylesWithoutBordersAndMargins,
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
ViewStyle,
|
|
8
8
|
StyleProp,
|
|
9
9
|
Dimensions,
|
|
10
|
-
Pressable,
|
|
11
10
|
} from "react-native";
|
|
12
11
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
13
12
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
@@ -15,7 +14,8 @@ import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
|
15
14
|
|
|
16
15
|
import { withTheme } from "../../theming";
|
|
17
16
|
import Portal from "../Portal/Portal";
|
|
18
|
-
import
|
|
17
|
+
import Button from "../DeprecatedButton";
|
|
18
|
+
import Touchable from "../Touchable";
|
|
19
19
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
20
20
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
21
21
|
import {
|
|
@@ -306,7 +306,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
306
306
|
/* marginsContainer */
|
|
307
307
|
<View style={[styles.marginsContainer, marginStyles]}>
|
|
308
308
|
{/* touchableContainer */}
|
|
309
|
-
<
|
|
309
|
+
<Touchable
|
|
310
310
|
disabled={disabled}
|
|
311
311
|
onPress={togglePickerVisible}
|
|
312
312
|
style={styles.touchableContainer}
|
|
@@ -342,7 +342,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
342
342
|
</View>
|
|
343
343
|
</View>
|
|
344
344
|
{assistiveTextLabel}
|
|
345
|
-
</
|
|
345
|
+
</Touchable>
|
|
346
346
|
|
|
347
347
|
{/* iosPicker */}
|
|
348
348
|
{isIos && pickerVisible ? (
|
|
@@ -5,7 +5,7 @@ import omit from "lodash.omit";
|
|
|
5
5
|
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
6
|
import { withTheme } from "../../theming";
|
|
7
7
|
import Portal from "../Portal/Portal";
|
|
8
|
-
import
|
|
8
|
+
import Button from "../DeprecatedButton";
|
|
9
9
|
import TextField from "../TextField";
|
|
10
10
|
import Touchable from "../Touchable";
|
|
11
11
|
import { extractStyles } from "../../utilities";
|
|
@@ -8,7 +8,7 @@ import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
|
8
8
|
import { withTheme } from "../../theming";
|
|
9
9
|
|
|
10
10
|
import Portal from "../Portal/Portal";
|
|
11
|
-
import
|
|
11
|
+
import Button from "../DeprecatedButton";
|
|
12
12
|
import TextField from "../TextField";
|
|
13
13
|
import Touchable from "../Touchable";
|
|
14
14
|
import { PickerComponentProps } from "./PickerTypes";
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { Pressable
|
|
3
|
-
export default function Touchable({ children, disabled, onPress,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return 1;
|
|
13
|
-
}
|
|
14
|
-
}, [activeOpacity, disabled, disabledOpacity]);
|
|
15
|
-
const _style = useCallback(({ pressed }) => [style, { opacity: getOpacity(pressed) }], [getOpacity, style]);
|
|
16
|
-
return (React.createElement(Pressable, { onPress: onPress, onLongPress: onLongPress, disabled: disabled, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: _style, ...props }, children));
|
|
1
|
+
import React from "react";
|
|
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 }) => {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
opacity: pressed || disabled ? 0.75 : 1,
|
|
8
|
+
},
|
|
9
|
+
style,
|
|
10
|
+
];
|
|
11
|
+
}, ...props }, children));
|
|
17
12
|
}
|
|
@@ -1,64 +1,33 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
Pressable,
|
|
4
|
-
PressableProps,
|
|
5
|
-
PressableStateCallbackType,
|
|
6
|
-
StyleProp,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from "react-native";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Pressable, ViewStyle, PressableProps } from "react-native";
|
|
9
3
|
|
|
10
4
|
type Props = {
|
|
11
5
|
disabled?: boolean;
|
|
12
6
|
children: React.ReactNode;
|
|
13
7
|
style?: ViewStyle;
|
|
14
8
|
onPress?: () => void;
|
|
15
|
-
onLongPress?: () => void;
|
|
16
|
-
delayLongPress?: number;
|
|
17
|
-
hitSlop?: number;
|
|
18
|
-
pressRetentionOffset?: number;
|
|
19
|
-
activeOpacity?: number;
|
|
20
|
-
disabledOpacity?: number;
|
|
21
9
|
} & PressableProps;
|
|
22
10
|
|
|
23
|
-
export type StyleType = (
|
|
24
|
-
state: PressableStateCallbackType
|
|
25
|
-
) => StyleProp<ViewStyle>;
|
|
26
|
-
|
|
27
11
|
export default function Touchable({
|
|
28
12
|
children,
|
|
29
13
|
disabled,
|
|
30
14
|
onPress,
|
|
31
|
-
onLongPress,
|
|
32
|
-
hitSlop,
|
|
33
|
-
delayLongPress,
|
|
34
|
-
activeOpacity,
|
|
35
|
-
disabledOpacity,
|
|
36
15
|
style,
|
|
37
16
|
...props
|
|
38
17
|
}: Props) {
|
|
39
|
-
const getOpacity = useCallback(
|
|
40
|
-
(pressed: boolean) => {
|
|
41
|
-
if (disabled) {
|
|
42
|
-
return disabledOpacity;
|
|
43
|
-
} else {
|
|
44
|
-
if (pressed) return activeOpacity;
|
|
45
|
-
else return 1;
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
[activeOpacity, disabled, disabledOpacity]
|
|
49
|
-
);
|
|
50
|
-
const _style = useCallback<StyleType>(
|
|
51
|
-
({ pressed }) => [style as ViewStyle, { opacity: getOpacity(pressed) }],
|
|
52
|
-
[getOpacity, style]
|
|
53
|
-
);
|
|
54
18
|
return (
|
|
55
19
|
<Pressable
|
|
56
20
|
onPress={onPress}
|
|
57
|
-
onLongPress={onLongPress}
|
|
58
21
|
disabled={disabled}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
22
|
+
hitSlop={8}
|
|
23
|
+
style={({ pressed }) => {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
opacity: pressed || disabled ? 0.75 : 1,
|
|
27
|
+
},
|
|
28
|
+
style,
|
|
29
|
+
];
|
|
30
|
+
}}
|
|
62
31
|
{...props}
|
|
63
32
|
>
|
|
64
33
|
{children}
|
package/src/mappings/Button.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections,
|
|
2
|
-
const SEED_DATA_TRIGGERS = [Triggers.OnPress
|
|
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,10 +13,11 @@ const SEED_DATA_PROPS = {
|
|
|
14
13
|
}),
|
|
15
14
|
disabled: createDisabledProp(),
|
|
16
15
|
loading: createLoadingProp(),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
};
|
|
17
|
+
const LAYOUT = {
|
|
18
|
+
backgroundColor: "transparent",
|
|
19
|
+
borderRadius: 8,
|
|
20
|
+
fontFamily: "system-700",
|
|
21
21
|
};
|
|
22
22
|
export const SEED_DATA = [
|
|
23
23
|
{
|
|
@@ -34,9 +34,8 @@ export const SEED_DATA = [
|
|
|
34
34
|
StylesPanelSections.Effects,
|
|
35
35
|
],
|
|
36
36
|
layout: {
|
|
37
|
+
...LAYOUT,
|
|
37
38
|
backgroundColor: "transparent",
|
|
38
|
-
borderRadius: 8,
|
|
39
|
-
fontFamily: "system-700",
|
|
40
39
|
borderWidth: 1,
|
|
41
40
|
textAlign: "center",
|
|
42
41
|
},
|
|
@@ -57,8 +56,7 @@ export const SEED_DATA = [
|
|
|
57
56
|
StylesPanelSections.Effects,
|
|
58
57
|
],
|
|
59
58
|
layout: {
|
|
60
|
-
|
|
61
|
-
fontFamily: "system-700",
|
|
59
|
+
...LAYOUT,
|
|
62
60
|
backgroundColor: "primary",
|
|
63
61
|
textAlign: "center",
|
|
64
62
|
},
|
|
@@ -79,8 +77,7 @@ export const SEED_DATA = [
|
|
|
79
77
|
StylesPanelSections.Effects,
|
|
80
78
|
],
|
|
81
79
|
layout: {
|
|
82
|
-
|
|
83
|
-
fontFamily: "system-700",
|
|
80
|
+
...LAYOUT,
|
|
84
81
|
backgroundColor: "primary",
|
|
85
82
|
textAlign: "center",
|
|
86
83
|
},
|
package/src/mappings/Button.ts
CHANGED
|
@@ -7,13 +7,11 @@ import {
|
|
|
7
7
|
createActionProp,
|
|
8
8
|
Triggers,
|
|
9
9
|
StylesPanelSections,
|
|
10
|
-
createNumberProp,
|
|
11
10
|
} from "@draftbit/types";
|
|
12
11
|
|
|
13
|
-
const SEED_DATA_TRIGGERS = [Triggers.OnPress
|
|
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,10 +23,12 @@ const SEED_DATA_PROPS = {
|
|
|
25
23
|
}),
|
|
26
24
|
disabled: createDisabledProp(),
|
|
27
25
|
loading: createLoadingProp(),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const LAYOUT = {
|
|
29
|
+
backgroundColor: "transparent",
|
|
30
|
+
borderRadius: 8,
|
|
31
|
+
fontFamily: "system-700",
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const SEED_DATA = [
|
|
@@ -46,9 +46,8 @@ export const SEED_DATA = [
|
|
|
46
46
|
StylesPanelSections.Effects,
|
|
47
47
|
],
|
|
48
48
|
layout: {
|
|
49
|
+
...LAYOUT,
|
|
49
50
|
backgroundColor: "transparent",
|
|
50
|
-
borderRadius: 8,
|
|
51
|
-
fontFamily: "system-700",
|
|
52
51
|
borderWidth: 1,
|
|
53
52
|
textAlign: "center",
|
|
54
53
|
},
|
|
@@ -69,8 +68,7 @@ export const SEED_DATA = [
|
|
|
69
68
|
StylesPanelSections.Effects,
|
|
70
69
|
],
|
|
71
70
|
layout: {
|
|
72
|
-
|
|
73
|
-
fontFamily: "system-700",
|
|
71
|
+
...LAYOUT,
|
|
74
72
|
backgroundColor: "primary",
|
|
75
73
|
textAlign: "center",
|
|
76
74
|
},
|
|
@@ -91,8 +89,7 @@ export const SEED_DATA = [
|
|
|
91
89
|
StylesPanelSections.Effects,
|
|
92
90
|
],
|
|
93
91
|
layout: {
|
|
94
|
-
|
|
95
|
-
fontFamily: "system-700",
|
|
92
|
+
...LAYOUT,
|
|
96
93
|
backgroundColor: "primary",
|
|
97
94
|
textAlign: "center",
|
|
98
95
|
},
|