@draftbit/core 47.0.1-cc5ccc.2 → 47.0.1-d5418f.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 +17 -29
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
- package/lib/commonjs/components/CircularProgress.js +26 -8
- package/lib/commonjs/components/DeprecatedButton.js +127 -0
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
- package/lib/commonjs/components/Picker/Picker.js +4 -3
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
- package/lib/commonjs/components/Pressable.js +12 -23
- package/lib/commonjs/components/Touchable.js +13 -24
- package/lib/commonjs/components/Touchable.web.js +9 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/mappings/Button.js +31 -5
- package/lib/commonjs/mappings/FlashList.js +45 -2
- package/lib/commonjs/mappings/FlatList.js +12 -0
- package/lib/commonjs/mappings/{Pressable.js → Touchable.js} +17 -9
- package/lib/module/components/Button.js +11 -23
- package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
- package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
- package/lib/module/components/DeprecatedButton.js +117 -0
- package/lib/module/components/DeprecatedCardWrapper.js +2 -2
- package/lib/module/components/Picker/Picker.js +4 -3
- package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
- package/lib/module/components/Pressable.js +11 -21
- package/lib/module/components/RadioButton/RadioButtonRow.js +24 -5
- package/lib/module/components/Touchable.js +12 -22
- package/lib/module/components/Touchable.web.js +2 -0
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/Button.js +32 -6
- package/lib/module/mappings/FlashList.js +46 -3
- package/lib/module/mappings/FlatList.js +13 -1
- package/lib/module/mappings/{Pressable.js → Touchable.js} +18 -10
- 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 +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxRow.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/Picker/Picker.d.ts.map +1 -1
- package/lib/typescript/src/components/Pressable.d.ts +3 -11
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.d.ts +3 -11
- 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/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Button.d.ts +1 -1
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/FlashList.d.ts +112 -2
- package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/FlatList.d.ts +42 -0
- package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/{Pressable.d.ts → Touchable.d.ts} +1 -1
- 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 +12 -36
- package/src/components/Checkbox/Checkbox.tsx +2 -2
- package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
- package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
- package/src/components/Checkbox/CheckboxRow.js +2 -3
- package/src/components/Checkbox/CheckboxRow.tsx +3 -3
- package/src/components/DeprecatedButton.js +83 -0
- package/src/components/DeprecatedButton.tsx +190 -0
- package/src/components/DeprecatedCardWrapper.js +2 -2
- package/src/components/DeprecatedCardWrapper.tsx +4 -3
- 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/Pressable.js +10 -15
- package/src/components/Pressable.tsx +11 -34
- package/src/components/Touchable.js +11 -16
- package/src/components/Touchable.tsx +13 -40
- package/src/components/Touchable.web.js +2 -0
- package/src/components/Touchable.web.tsx +3 -0
- package/src/index.js +1 -0
- package/src/index.tsx +1 -0
- package/src/mappings/Button.js +32 -6
- package/src/mappings/Button.ts +34 -6
- package/src/mappings/FlashList.js +77 -31
- package/src/mappings/FlashList.ts +82 -30
- package/src/mappings/FlatList.js +13 -1
- package/src/mappings/FlatList.ts +16 -0
- package/src/mappings/{Pressable.js → Touchable.js} +18 -10
- package/src/mappings/{Pressable.ts → Touchable.ts} +18 -11
- package/lib/typescript/src/mappings/Pressable.d.ts.map +0 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Text,
|
|
4
4
|
Pressable,
|
|
5
5
|
PressableProps,
|
|
6
|
-
PressableStateCallbackType,
|
|
7
6
|
Platform,
|
|
8
7
|
StyleSheet,
|
|
9
|
-
StyleProp,
|
|
10
8
|
TextStyle,
|
|
11
|
-
ViewStyle,
|
|
12
9
|
ActivityIndicator,
|
|
13
10
|
} from "react-native";
|
|
14
11
|
|
|
@@ -35,7 +32,6 @@ type BaseProps = {
|
|
|
35
32
|
disabledOpacity?: number;
|
|
36
33
|
delayLongPress?: number;
|
|
37
34
|
hitSlop?: number;
|
|
38
|
-
pressRetentionOffset?: number;
|
|
39
35
|
icon?: string;
|
|
40
36
|
} & PressableProps &
|
|
41
37
|
IconSlot;
|
|
@@ -51,27 +47,20 @@ type Props = {
|
|
|
51
47
|
disabledOpacity?: number;
|
|
52
48
|
delayLongPress?: number;
|
|
53
49
|
hitSlop?: number;
|
|
54
|
-
pressRetentionOffset?: number;
|
|
55
50
|
icon?: string;
|
|
56
51
|
theme: Theme;
|
|
57
52
|
} & PressableProps &
|
|
58
53
|
IconSlot;
|
|
59
54
|
|
|
60
|
-
export type StyleType = (
|
|
61
|
-
state: PressableStateCallbackType
|
|
62
|
-
) => StyleProp<ViewStyle>;
|
|
63
|
-
|
|
64
55
|
function Base({
|
|
65
56
|
Icon,
|
|
66
57
|
icon,
|
|
67
58
|
title,
|
|
68
|
-
onPress,
|
|
69
|
-
onLongPress,
|
|
70
|
-
activeOpacity,
|
|
71
|
-
disabledOpacity,
|
|
72
59
|
loading,
|
|
73
60
|
disabled,
|
|
74
61
|
style,
|
|
62
|
+
activeOpacity,
|
|
63
|
+
disabledOpacity,
|
|
75
64
|
...props
|
|
76
65
|
}: BaseProps): JSX.Element {
|
|
77
66
|
const {
|
|
@@ -111,31 +100,18 @@ function Base({
|
|
|
111
100
|
buttonStyles.justifyContent = "flex-end";
|
|
112
101
|
}
|
|
113
102
|
|
|
114
|
-
const getOpacity = useCallback(
|
|
115
|
-
(pressed: boolean) => {
|
|
116
|
-
if (disabled) {
|
|
117
|
-
return disabledOpacity;
|
|
118
|
-
} else {
|
|
119
|
-
if (pressed) return activeOpacity;
|
|
120
|
-
else return 1;
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
[activeOpacity, disabled, disabledOpacity]
|
|
124
|
-
);
|
|
125
|
-
const _style = useCallback<StyleType>(
|
|
126
|
-
({ pressed }) => [
|
|
127
|
-
buttonStyles as ViewStyle,
|
|
128
|
-
{ opacity: getOpacity(pressed) },
|
|
129
|
-
],
|
|
130
|
-
[getOpacity, buttonStyles]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
103
|
return (
|
|
134
104
|
<Pressable
|
|
135
|
-
onPress={onPress}
|
|
136
|
-
onLongPress={onLongPress}
|
|
137
105
|
disabled={disabled || loading}
|
|
138
|
-
style={(
|
|
106
|
+
style={({ pressed }) => {
|
|
107
|
+
return [
|
|
108
|
+
styles.base,
|
|
109
|
+
{
|
|
110
|
+
opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
|
|
111
|
+
},
|
|
112
|
+
buttonStyles,
|
|
113
|
+
];
|
|
114
|
+
}}
|
|
139
115
|
{...props}
|
|
140
116
|
>
|
|
141
117
|
{loading ? (
|
|
@@ -2,10 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
|
-
StyleProp,
|
|
6
|
-
ViewStyle,
|
|
7
5
|
Pressable,
|
|
8
6
|
PressableProps,
|
|
7
|
+
StyleProp,
|
|
8
|
+
ViewStyle,
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import { useTheme } from "../../theming";
|
|
11
11
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -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 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";
|
|
8
7
|
import { extractStyles } from "../../utilities";
|
|
9
8
|
export var Direction;
|
|
10
9
|
(function (Direction) {
|
|
@@ -41,7 +40,7 @@ const CheckboxGroupRow = ({ Icon, label = "Label", status, value, onPress, label
|
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
42
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
44
|
-
return (React.createElement(
|
|
43
|
+
return (React.createElement(Pressable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
45
44
|
React.createElement(View, { style: [
|
|
46
45
|
styles.label,
|
|
47
46
|
{
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
TextStyle,
|
|
7
7
|
View,
|
|
8
8
|
Platform,
|
|
9
|
+
Pressable,
|
|
9
10
|
} from "react-native";
|
|
10
11
|
import Checkbox, { CheckboxProps } from "./Checkbox";
|
|
11
12
|
import Text from "../Text";
|
|
12
13
|
import { useCheckboxGroupContext } from "./context";
|
|
13
14
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
14
15
|
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
|
-
<
|
|
95
|
+
<Pressable
|
|
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
|
-
</
|
|
128
|
+
</Pressable>
|
|
129
129
|
);
|
|
130
130
|
};
|
|
131
131
|
|
|
@@ -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(
|
|
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
|
-
<
|
|
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
|
-
</
|
|
133
|
+
</Pressable>
|
|
134
134
|
);
|
|
135
135
|
};
|
|
136
136
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ActivityIndicator, View, Text, StyleSheet, Pressable, } from "react-native";
|
|
3
|
+
import color from "color";
|
|
4
|
+
import Config from "./Config";
|
|
5
|
+
import Elevation from "./Elevation";
|
|
6
|
+
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
|
+
let backgroundColor, borderColor, textColor, borderWidth;
|
|
9
|
+
const buttonColor = colorOverride || colors.primary;
|
|
10
|
+
if (type === "solid") {
|
|
11
|
+
backgroundColor = buttonColor;
|
|
12
|
+
if (disabled) {
|
|
13
|
+
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
textColor = labelColor || colors.surface;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
backgroundColor = "transparent";
|
|
21
|
+
if (disabled) {
|
|
22
|
+
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
textColor = labelColor || buttonColor;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (type === "outline") {
|
|
29
|
+
if (disabled) {
|
|
30
|
+
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
borderColor = buttonColor;
|
|
34
|
+
}
|
|
35
|
+
borderWidth = StyleSheet.hairlineWidth;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
borderColor = "transparent";
|
|
39
|
+
borderWidth = 0;
|
|
40
|
+
}
|
|
41
|
+
const buttonStyle = {
|
|
42
|
+
backgroundColor,
|
|
43
|
+
borderColor,
|
|
44
|
+
borderWidth,
|
|
45
|
+
borderRadius: roundness,
|
|
46
|
+
};
|
|
47
|
+
const textStyle = {
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
color: textColor,
|
|
50
|
+
marginVertical: 16,
|
|
51
|
+
marginHorizontal: 16,
|
|
52
|
+
};
|
|
53
|
+
const iconStyle = [
|
|
54
|
+
styles.icon,
|
|
55
|
+
{
|
|
56
|
+
marginLeft: 16,
|
|
57
|
+
marginRight: -8,
|
|
58
|
+
width: Config.buttonIconSize,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
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] },
|
|
63
|
+
React.createElement(View, { style: styles.content },
|
|
64
|
+
icon && loading !== true ? (React.createElement(View, { style: iconStyle },
|
|
65
|
+
React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
|
|
66
|
+
loading ? (React.createElement(ActivityIndicator, { size: "small", color: textColor, style: iconStyle })) : null,
|
|
67
|
+
React.createElement(Text, { numberOfLines: 1, style: [textStyle, typography.button] }, children)))));
|
|
68
|
+
};
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
button: {
|
|
71
|
+
minWidth: 64,
|
|
72
|
+
borderStyle: "solid",
|
|
73
|
+
},
|
|
74
|
+
content: {
|
|
75
|
+
flexDirection: "row",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
justifyContent: "center",
|
|
78
|
+
},
|
|
79
|
+
icon: {
|
|
80
|
+
width: Config.buttonIconSize,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
export default withTheme(Button);
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
StyleProp,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
TextStyle,
|
|
10
|
+
Pressable,
|
|
11
|
+
PressableProps,
|
|
12
|
+
} from "react-native";
|
|
13
|
+
import color from "color";
|
|
14
|
+
import Config from "./Config";
|
|
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
|
+
} & PressableProps &
|
|
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
|
+
theme: { colors, disabledOpacity, roundness, typography },
|
|
81
|
+
...rest
|
|
82
|
+
}) => {
|
|
83
|
+
let backgroundColor, borderColor, textColor, borderWidth;
|
|
84
|
+
const buttonColor = colorOverride || colors.primary;
|
|
85
|
+
|
|
86
|
+
if (type === "solid") {
|
|
87
|
+
backgroundColor = buttonColor;
|
|
88
|
+
|
|
89
|
+
if (disabled) {
|
|
90
|
+
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
91
|
+
} else {
|
|
92
|
+
textColor = labelColor || colors.surface;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
backgroundColor = "transparent";
|
|
96
|
+
|
|
97
|
+
if (disabled) {
|
|
98
|
+
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
99
|
+
} else {
|
|
100
|
+
textColor = labelColor || buttonColor;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (type === "outline") {
|
|
105
|
+
if (disabled) {
|
|
106
|
+
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
107
|
+
} else {
|
|
108
|
+
borderColor = buttonColor;
|
|
109
|
+
}
|
|
110
|
+
borderWidth = StyleSheet.hairlineWidth;
|
|
111
|
+
} else {
|
|
112
|
+
borderColor = "transparent";
|
|
113
|
+
borderWidth = 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const buttonStyle = {
|
|
117
|
+
backgroundColor,
|
|
118
|
+
borderColor,
|
|
119
|
+
borderWidth,
|
|
120
|
+
borderRadius: roundness,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const textStyle: StyleProp<TextStyle> = {
|
|
124
|
+
textAlign: "center",
|
|
125
|
+
color: textColor,
|
|
126
|
+
marginVertical: 16,
|
|
127
|
+
marginHorizontal: 16,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const iconStyle = [
|
|
131
|
+
styles.icon,
|
|
132
|
+
{
|
|
133
|
+
marginLeft: 16,
|
|
134
|
+
marginRight: -8,
|
|
135
|
+
width: Config.buttonIconSize,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<Elevation style={{ elevation, alignSelf: "stretch" }}>
|
|
141
|
+
<Pressable
|
|
142
|
+
{...rest}
|
|
143
|
+
onPress={onPress}
|
|
144
|
+
accessibilityState={{ disabled }}
|
|
145
|
+
accessibilityRole="button"
|
|
146
|
+
disabled={disabled || loading}
|
|
147
|
+
style={[styles.button, buttonStyle]}
|
|
148
|
+
>
|
|
149
|
+
<View style={styles.content}>
|
|
150
|
+
{icon && loading !== true ? (
|
|
151
|
+
<View style={iconStyle}>
|
|
152
|
+
<Icon
|
|
153
|
+
name={icon}
|
|
154
|
+
size={Config.buttonIconSize}
|
|
155
|
+
color={textColor}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
) : null}
|
|
159
|
+
{loading ? (
|
|
160
|
+
<ActivityIndicator
|
|
161
|
+
size="small"
|
|
162
|
+
color={textColor}
|
|
163
|
+
style={iconStyle}
|
|
164
|
+
/>
|
|
165
|
+
) : null}
|
|
166
|
+
<Text numberOfLines={1} style={[textStyle, typography.button]}>
|
|
167
|
+
{children}
|
|
168
|
+
</Text>
|
|
169
|
+
</View>
|
|
170
|
+
</Pressable>
|
|
171
|
+
</Elevation>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const styles = StyleSheet.create({
|
|
176
|
+
button: {
|
|
177
|
+
minWidth: 64,
|
|
178
|
+
borderStyle: "solid",
|
|
179
|
+
},
|
|
180
|
+
content: {
|
|
181
|
+
flexDirection: "row",
|
|
182
|
+
alignItems: "center",
|
|
183
|
+
justifyContent: "center",
|
|
184
|
+
},
|
|
185
|
+
icon: {
|
|
186
|
+
width: Config.buttonIconSize,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
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,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
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { Pressable as NativePressable, } from "react-native";
|
|
3
|
-
export default function Pressable({ 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(NativePressable, { onPress: onPress, onLongPress: onLongPress, disabled: disabled, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: _style, ...props }, children));
|
|
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));
|
|
17
12
|
}
|