@draftbit/core 47.0.1-17098e.2 → 47.0.1-2aab54.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/Checkbox/CheckboxGroup.js +17 -2
- 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/index.js +25 -82
- package/lib/commonjs/mappings/Button.js +10 -14
- package/lib/commonjs/mappings/NativeBase/AlertDialog.js +93 -0
- package/lib/commonjs/mappings/NativeBase/Button.js +84 -0
- package/lib/commonjs/mappings/NativeBase/DataDisplay.js +48 -0
- package/lib/commonjs/mappings/NativeBase/Feedback.js +74 -0
- package/lib/commonjs/mappings/NativeBase/Layout.js +114 -0
- package/lib/commonjs/mappings/NativeBase/Media.js +49 -0
- package/lib/commonjs/mappings/NativeBase/Menu.js +111 -0
- package/lib/commonjs/mappings/NativeBase/Modal.js +93 -0
- package/lib/commonjs/mappings/NativeBase/Other.js +94 -0
- package/lib/commonjs/mappings/NativeBase/Popover.js +99 -0
- package/lib/commonjs/mappings/Touchable.js +20 -0
- package/lib/module/components/Button.js +9 -21
- package/lib/module/components/Checkbox/Checkbox.js +3 -2
- package/lib/module/components/DeprecatedButton.js +141 -0
- package/lib/module/components/DeprecatedCardWrapper.js +2 -2
- package/lib/module/components/DeprecatedFAB.js +3 -2
- package/lib/module/components/Picker/Picker.js +4 -3
- package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
- package/lib/module/components/Touchable.js +10 -25
- package/lib/module/components/Touchable.web.js +2 -0
- package/lib/module/index.js +121 -31
- package/lib/module/mappings/Button.js +11 -15
- package/lib/module/mappings/NativeBase/AlertDialog.js +86 -0
- package/lib/module/mappings/NativeBase/Button.js +86 -0
- package/lib/module/mappings/NativeBase/DataDisplay.js +41 -0
- package/lib/module/mappings/NativeBase/Feedback.js +67 -0
- package/lib/module/mappings/NativeBase/Layout.js +107 -0
- package/lib/module/mappings/NativeBase/Media.js +42 -0
- package/lib/module/mappings/NativeBase/Menu.js +104 -0
- package/lib/module/mappings/NativeBase/Modal.js +86 -0
- package/lib/module/mappings/NativeBase/Other.js +87 -0
- package/lib/module/mappings/NativeBase/Popover.js +92 -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/index.d.ts +102 -29
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Button.d.ts +2 -224
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts +134 -0
- package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Button.d.ts +1 -0
- package/lib/typescript/src/mappings/NativeBase/Button.d.ts.map +1 -0
- package/lib/typescript/src/mappings/{Pressable.d.ts → NativeBase/DataDisplay.d.ts} +34 -40
- package/lib/typescript/src/mappings/NativeBase/DataDisplay.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts +2 -0
- package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +146 -0
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Media.d.ts +48 -0
- package/lib/typescript/src/mappings/NativeBase/Media.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Menu.d.ts +227 -0
- package/lib/typescript/src/mappings/NativeBase/Menu.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Modal.d.ts +133 -0
- package/lib/typescript/src/mappings/NativeBase/Modal.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Other.d.ts +179 -0
- package/lib/typescript/src/mappings/NativeBase/Other.d.ts.map +1 -0
- package/lib/typescript/src/mappings/NativeBase/Popover.d.ts +136 -0
- package/lib/typescript/src/mappings/NativeBase/Popover.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/index.js +112 -31
- package/src/index.tsx +123 -43
- package/src/mappings/Button.js +10 -14
- package/src/mappings/Button.ts +10 -14
- package/src/mappings/NativeBase/AlertDialog.js +103 -0
- package/src/mappings/NativeBase/AlertDialog.ts +118 -0
- package/src/mappings/NativeBase/Button.js +84 -0
- package/src/mappings/NativeBase/Button.ts +83 -0
- package/src/mappings/NativeBase/DataDisplay.js +54 -0
- package/src/mappings/NativeBase/DataDisplay.ts +64 -0
- package/src/mappings/NativeBase/Feedback.js +89 -0
- package/src/mappings/NativeBase/Feedback.ts +100 -0
- package/src/mappings/NativeBase/Layout.js +140 -0
- package/src/mappings/NativeBase/Layout.ts +152 -0
- package/src/mappings/NativeBase/Media.js +56 -0
- package/src/mappings/NativeBase/Media.ts +65 -0
- package/src/mappings/NativeBase/Menu.js +134 -0
- package/src/mappings/NativeBase/Menu.ts +150 -0
- package/src/mappings/NativeBase/Modal.js +103 -0
- package/src/mappings/NativeBase/Modal.ts +118 -0
- package/src/mappings/NativeBase/Other.js +123 -0
- package/src/mappings/NativeBase/Other.ts +139 -0
- package/src/mappings/NativeBase/Popover.js +123 -0
- package/src/mappings/NativeBase/Popover.ts +136 -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.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/index.js
CHANGED
|
@@ -2,51 +2,132 @@ export { injectIcon } from "./interfaces/Icon";
|
|
|
2
2
|
export { withTheme, ThemeProvider } from "./theming";
|
|
3
3
|
export { default as Provider } from "./Provider";
|
|
4
4
|
export { default as DefaultTheme } from "./styles/DefaultTheme";
|
|
5
|
-
|
|
5
|
+
/** Replaced By NativeBase
|
|
6
|
+
* export { default as Avatar } from "./components/CircleImage";
|
|
7
|
+
* export { default as Container } from "./components/Container";
|
|
8
|
+
* export { default as FAB } from "./components/FAB";
|
|
9
|
+
* export {
|
|
10
|
+
Center,
|
|
11
|
+
Circle,
|
|
12
|
+
Square,
|
|
13
|
+
Row,
|
|
14
|
+
Stack,
|
|
15
|
+
Spacer,
|
|
16
|
+
} from "./components/Layout";
|
|
17
|
+
*/
|
|
18
|
+
// BASIC
|
|
19
|
+
export { default as ScreenContainer } from "./components/ScreenContainer";
|
|
6
20
|
export { default as Banner } from "./components/Banner";
|
|
21
|
+
// BUTTONS
|
|
7
22
|
export { Button, ButtonSolid, ButtonOutline } from "./components/Button";
|
|
8
|
-
export {
|
|
9
|
-
export { default as AvatarEdit } from "./components/AvatarEdit";
|
|
10
|
-
export { default as Card } from "./components/Card";
|
|
11
|
-
export { default as Carousel } from "./components/Carousel";
|
|
12
|
-
export { Checkbox, CheckboxGroup, CheckboxRow } from "./components/Checkbox";
|
|
13
|
-
export { default as CircleImage } from "./components/CircleImage";
|
|
14
|
-
export { default as Container } from "./components/Container";
|
|
15
|
-
export { default as Divider } from "./components/Divider";
|
|
16
|
-
export { default as FAB } from "./components/FAB";
|
|
17
|
-
export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
|
|
23
|
+
export { Link } from "./components/Text";
|
|
18
24
|
export { default as IconButton } from "./components/IconButton";
|
|
19
|
-
export { default as
|
|
20
|
-
export { default as
|
|
25
|
+
export { default as Touchable } from "./components/Touchable";
|
|
26
|
+
export { default as ToggleButton } from "./components/ToggleButton";
|
|
27
|
+
// INPUTS
|
|
28
|
+
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
21
29
|
export { default as NumberInput } from "./components/NumberInput";
|
|
22
|
-
export { default as
|
|
30
|
+
export { default as TextField } from "./components/TextField";
|
|
31
|
+
export { default as FieldSearchBarFull } from "./components/FieldSearchBarFull";
|
|
32
|
+
export { default as Picker } from "./components/Picker/Picker";
|
|
33
|
+
// CONTROLS
|
|
34
|
+
export { Checkbox, CheckboxGroup, CheckboxRow } from "./components/Checkbox";
|
|
35
|
+
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
36
|
+
export { default as Slider } from "./components/Slider";
|
|
37
|
+
export { default as Stepper } from "./components/Stepper";
|
|
23
38
|
export { default as StarRating } from "./components/StarRating";
|
|
24
|
-
export { default as Surface } from "./components/Surface";
|
|
25
39
|
export { default as Switch, SwitchRow } from "./components/Switch";
|
|
26
|
-
|
|
27
|
-
export { default as
|
|
28
|
-
export { default as
|
|
40
|
+
// MEDIA
|
|
41
|
+
export { default as SVG } from "./components/SVG";
|
|
42
|
+
export { default as Image } from "./components/Image";
|
|
43
|
+
// export { default as Avatar } from "./components/CircleImage"; Replaced by NativeBase
|
|
44
|
+
export { default as AvatarEdit } from "./components/AvatarEdit";
|
|
45
|
+
export { default as CircleImage } from "./components/CircleImage";
|
|
46
|
+
// SWIPER
|
|
47
|
+
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
48
|
+
// CONTAINERS
|
|
29
49
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
50
|
+
export { default as Surface } from "./components/Surface";
|
|
51
|
+
// ACTIONSHEET
|
|
30
52
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
/* Deprecated: Fix or Delete! */
|
|
35
|
-
export { default as CardBlock } from "./components/CardBlock";
|
|
36
|
-
export { default as CardContainer } from "./components/CardContainer";
|
|
37
|
-
export { default as CardContainerRating } from "./components/CardContainerRating";
|
|
38
|
-
export { default as CardInline } from "./components/CardInline";
|
|
39
|
-
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
53
|
+
// OTHER
|
|
54
|
+
export { default as Carousel } from "./components/Carousel";
|
|
55
|
+
export { default as Divider } from "./components/Divider";
|
|
40
56
|
export { default as HeaderLarge } from "./components/HeaderLarge";
|
|
41
57
|
export { default as HeaderMedium } from "./components/HeaderMedium";
|
|
42
58
|
export { default as HeaderOverline } from "./components/HeaderOverline";
|
|
43
|
-
export { default as Picker } from "./components/Picker/Picker";
|
|
44
59
|
export { default as ProgressBar } from "./components/ProgressBar";
|
|
45
60
|
export { default as ProgressCircle } from "./components/ProgressCircle";
|
|
46
61
|
export { default as RowBodyIcon } from "./components/RowBodyIcon";
|
|
47
62
|
export { default as RowHeadlineImageCaption } from "./components/RowHeadlineImageCaption";
|
|
48
63
|
export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIcon";
|
|
49
|
-
export { default as
|
|
50
|
-
export { default as
|
|
64
|
+
export { default as Card } from "./components/Card";
|
|
65
|
+
export { default as CardBlock } from "./components/CardBlock";
|
|
66
|
+
export { default as CardContainer } from "./components/CardContainer";
|
|
67
|
+
export { default as CardContainerRating } from "./components/CardContainerRating";
|
|
68
|
+
export { default as CardInline } from "./components/CardInline";
|
|
51
69
|
export { useAuthState } from "./components/useAuthState";
|
|
52
|
-
|
|
70
|
+
/**
|
|
71
|
+
* NativeBase Components Jan 2023
|
|
72
|
+
*
|
|
73
|
+
* ALERT
|
|
74
|
+
* - AlertDialog
|
|
75
|
+
* - AlertDialog.Header
|
|
76
|
+
* - AlertDialog.Body
|
|
77
|
+
* - AlertDialog.Footer
|
|
78
|
+
* - AlertDialog.Content
|
|
79
|
+
* - AlertDialog.CloseButton
|
|
80
|
+
*
|
|
81
|
+
* FORMS
|
|
82
|
+
* - Button -- COMMENTED OUT
|
|
83
|
+
* - Button.Group -- COMMENTED OUT
|
|
84
|
+
* - Fab
|
|
85
|
+
*
|
|
86
|
+
* DATA DISPLAY
|
|
87
|
+
* - Badge
|
|
88
|
+
* - Divider
|
|
89
|
+
*
|
|
90
|
+
* FEEDBACK
|
|
91
|
+
* - Alert
|
|
92
|
+
* - Alert.Icon
|
|
93
|
+
* - Progress
|
|
94
|
+
*
|
|
95
|
+
* LAYOUT
|
|
96
|
+
* - AspectRatio
|
|
97
|
+
* - Box
|
|
98
|
+
* - Center
|
|
99
|
+
* - Square
|
|
100
|
+
* - Circle
|
|
101
|
+
* - Column
|
|
102
|
+
* - Container
|
|
103
|
+
* - Flex
|
|
104
|
+
* - Spacer
|
|
105
|
+
* - Row
|
|
106
|
+
* - Stack
|
|
107
|
+
* - ZStack
|
|
108
|
+
*
|
|
109
|
+
* MEDIA
|
|
110
|
+
* - Avatar
|
|
111
|
+
* - Avatar.Badge
|
|
112
|
+
* - Avatar.Group
|
|
113
|
+
*
|
|
114
|
+
* MENU
|
|
115
|
+
* - Menu
|
|
116
|
+
* - Menu.Item
|
|
117
|
+
* - Menu.Group
|
|
118
|
+
* - Menu.OptionGroup
|
|
119
|
+
* - Menu.ItemOption
|
|
120
|
+
* - Menu.Trigger
|
|
121
|
+
*
|
|
122
|
+
* MODAL
|
|
123
|
+
* - Modal
|
|
124
|
+
* - Modal.Content
|
|
125
|
+
* - Modal.Header
|
|
126
|
+
* - Modal.Footer
|
|
127
|
+
* - Modal.Body
|
|
128
|
+
* - Modal.CloseButton
|
|
129
|
+
*
|
|
130
|
+
* OTHER
|
|
131
|
+
* - Tooltip
|
|
132
|
+
*
|
|
133
|
+
* */
|