@draftbit/core 47.0.1-cc5ccc.2 → 47.0.1-ed6e56.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/DatePicker/DatePicker.js +1 -0
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js +3 -9
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +0 -1
- package/lib/commonjs/components/DatePicker/DatePickerInput.js +133 -0
- 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/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/DatePicker/DatePicker.js +1 -0
- package/lib/module/components/DatePicker/DatePickerComponent.js +3 -9
- package/lib/module/components/DatePicker/DatePickerComponent.web.js +0 -1
- package/lib/module/components/DatePicker/DatePickerInput.js +123 -0
- 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/mappings/Button.js +11 -14
- 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/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponent.web.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +2 -0
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts +18 -0
- package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts.map +1 -0
- 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/Touchable.d.ts +22 -0
- package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -0
- package/package.json +6 -6
- 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/DatePicker/DatePicker.js +1 -1
- package/src/components/DatePicker/DatePicker.tsx +1 -0
- package/src/components/DatePicker/DatePickerComponent.js +3 -5
- package/src/components/DatePicker/DatePickerComponent.tsx +3 -11
- package/src/components/DatePicker/DatePickerComponent.web.js +1 -1
- package/src/components/DatePicker/DatePickerComponent.web.tsx +0 -1
- package/src/components/DatePicker/DatePickerComponentType.ts +9 -0
- package/src/components/DatePicker/DatePickerInput.js +97 -0
- package/src/components/DatePicker/DatePickerInput.tsx +195 -0
- 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/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
|
@@ -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
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Touchable",
|
|
4
|
+
tag: "Touchable",
|
|
5
|
+
description: "Simple button with no styles",
|
|
6
|
+
category: COMPONENT_TYPES.button,
|
|
7
|
+
stylesPanelSections: [
|
|
8
|
+
StylesPanelSections.Size,
|
|
9
|
+
StylesPanelSections.Margins,
|
|
10
|
+
StylesPanelSections.Borders,
|
|
11
|
+
],
|
|
12
|
+
layout: {},
|
|
13
|
+
triggers: [Triggers.OnPress],
|
|
14
|
+
props: {
|
|
15
|
+
onPress: createActionProp(),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
createActionProp,
|
|
4
|
+
Triggers,
|
|
5
|
+
StylesPanelSections,
|
|
6
|
+
} from "@draftbit/types";
|
|
7
|
+
|
|
8
|
+
export const SEED_DATA = {
|
|
9
|
+
name: "Touchable",
|
|
10
|
+
tag: "Touchable",
|
|
11
|
+
description: "Simple button with no styles",
|
|
12
|
+
category: COMPONENT_TYPES.button,
|
|
13
|
+
stylesPanelSections: [
|
|
14
|
+
StylesPanelSections.Size,
|
|
15
|
+
StylesPanelSections.Margins,
|
|
16
|
+
StylesPanelSections.Borders,
|
|
17
|
+
],
|
|
18
|
+
layout: {},
|
|
19
|
+
triggers: [Triggers.OnPress],
|
|
20
|
+
props: {
|
|
21
|
+
onPress: createActionProp(),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Pressable;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
function Pressable(_ref) {
|
|
13
|
-
let {
|
|
14
|
-
children,
|
|
15
|
-
disabled,
|
|
16
|
-
onPress,
|
|
17
|
-
onLongPress,
|
|
18
|
-
hitSlop,
|
|
19
|
-
delayLongPress,
|
|
20
|
-
activeOpacity,
|
|
21
|
-
disabledOpacity,
|
|
22
|
-
style,
|
|
23
|
-
...props
|
|
24
|
-
} = _ref;
|
|
25
|
-
const getOpacity = (0, _react.useCallback)(pressed => {
|
|
26
|
-
if (disabled) {
|
|
27
|
-
return disabledOpacity;
|
|
28
|
-
} else {
|
|
29
|
-
if (pressed) return activeOpacity;else return 1;
|
|
30
|
-
}
|
|
31
|
-
}, [activeOpacity, disabled, disabledOpacity]);
|
|
32
|
-
const _style = (0, _react.useCallback)(_ref2 => {
|
|
33
|
-
let {
|
|
34
|
-
pressed
|
|
35
|
-
} = _ref2;
|
|
36
|
-
return [style, {
|
|
37
|
-
opacity: getOpacity(pressed)
|
|
38
|
-
}];
|
|
39
|
-
}, [getOpacity, style]);
|
|
40
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, _extends({
|
|
41
|
-
onPress: onPress,
|
|
42
|
-
onLongPress: onLongPress,
|
|
43
|
-
disabled: disabled,
|
|
44
|
-
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
45
|
-
hitSlop: hitSlop ? hitSlop : 8,
|
|
46
|
-
style: _style
|
|
47
|
-
}, props), children);
|
|
48
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SEED_DATA = void 0;
|
|
7
|
-
var _types = require("@draftbit/types");
|
|
8
|
-
const SEED_DATA_PROPS = {
|
|
9
|
-
stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.Margins, _types.StylesPanelSections.Borders],
|
|
10
|
-
layout: {},
|
|
11
|
-
triggers: [_types.Triggers.OnPress, _types.Triggers.OnLongPress],
|
|
12
|
-
props: {
|
|
13
|
-
onPress: (0, _types.createActionProp)(),
|
|
14
|
-
onLongPress: (0, _types.createActionProp)(),
|
|
15
|
-
activeOpacity: (0, _types.createNumberProp)({
|
|
16
|
-
label: "Active Opacity",
|
|
17
|
-
description: "The opacity when the button is pressed.",
|
|
18
|
-
defaultValue: 0.8,
|
|
19
|
-
group: _types.GROUPS.basic
|
|
20
|
-
}),
|
|
21
|
-
disabledOpacity: (0, _types.createNumberProp)({
|
|
22
|
-
label: "Disabled Opacity",
|
|
23
|
-
description: "The opacity when the button is disabled.",
|
|
24
|
-
defaultValue: 0.8,
|
|
25
|
-
group: _types.GROUPS.basic
|
|
26
|
-
}),
|
|
27
|
-
delayLongPress: (0, _types.createNumberProp)({
|
|
28
|
-
label: "Delay Long Press",
|
|
29
|
-
description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
30
|
-
group: _types.GROUPS.basic
|
|
31
|
-
}),
|
|
32
|
-
hitSlop: (0, _types.createNumberProp)({
|
|
33
|
-
label: "Hit Slop",
|
|
34
|
-
description: "Sets additional distance outside of element in which a press can be detected.",
|
|
35
|
-
group: _types.GROUPS.basic
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const SEED_DATA = [{
|
|
40
|
-
name: "Touchable",
|
|
41
|
-
tag: "Touchable",
|
|
42
|
-
description: "An interactive view with no styles",
|
|
43
|
-
category: _types.COMPONENT_TYPES.button,
|
|
44
|
-
...SEED_DATA_PROPS
|
|
45
|
-
}, {
|
|
46
|
-
name: "Pressable",
|
|
47
|
-
tag: "Pressable",
|
|
48
|
-
description: "An interactive view with no styles",
|
|
49
|
-
category: _types.COMPONENT_TYPES.deprecated,
|
|
50
|
-
...SEED_DATA_PROPS
|
|
51
|
-
}];
|
|
52
|
-
exports.SEED_DATA = SEED_DATA;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React, { useCallback } from "react";
|
|
3
|
-
import { Pressable as NativePressable } from "react-native";
|
|
4
|
-
export default function Pressable(_ref) {
|
|
5
|
-
let {
|
|
6
|
-
children,
|
|
7
|
-
disabled,
|
|
8
|
-
onPress,
|
|
9
|
-
onLongPress,
|
|
10
|
-
hitSlop,
|
|
11
|
-
delayLongPress,
|
|
12
|
-
activeOpacity,
|
|
13
|
-
disabledOpacity,
|
|
14
|
-
style,
|
|
15
|
-
...props
|
|
16
|
-
} = _ref;
|
|
17
|
-
const getOpacity = useCallback(pressed => {
|
|
18
|
-
if (disabled) {
|
|
19
|
-
return disabledOpacity;
|
|
20
|
-
} else {
|
|
21
|
-
if (pressed) return activeOpacity;else return 1;
|
|
22
|
-
}
|
|
23
|
-
}, [activeOpacity, disabled, disabledOpacity]);
|
|
24
|
-
const _style = useCallback(_ref2 => {
|
|
25
|
-
let {
|
|
26
|
-
pressed
|
|
27
|
-
} = _ref2;
|
|
28
|
-
return [style, {
|
|
29
|
-
opacity: getOpacity(pressed)
|
|
30
|
-
}];
|
|
31
|
-
}, [getOpacity, style]);
|
|
32
|
-
return /*#__PURE__*/React.createElement(NativePressable, _extends({
|
|
33
|
-
onPress: onPress,
|
|
34
|
-
onLongPress: onLongPress,
|
|
35
|
-
disabled: disabled,
|
|
36
|
-
delayLongPress: delayLongPress ? delayLongPress : 500,
|
|
37
|
-
hitSlop: hitSlop ? hitSlop : 8,
|
|
38
|
-
style: _style
|
|
39
|
-
}, props), children);
|
|
40
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createActionProp, Triggers, createNumberProp, StylesPanelSections, GROUPS } from "@draftbit/types";
|
|
2
|
-
const SEED_DATA_PROPS = {
|
|
3
|
-
stylesPanelSections: [StylesPanelSections.Size, StylesPanelSections.Margins, StylesPanelSections.Borders],
|
|
4
|
-
layout: {},
|
|
5
|
-
triggers: [Triggers.OnPress, Triggers.OnLongPress],
|
|
6
|
-
props: {
|
|
7
|
-
onPress: createActionProp(),
|
|
8
|
-
onLongPress: createActionProp(),
|
|
9
|
-
activeOpacity: createNumberProp({
|
|
10
|
-
label: "Active Opacity",
|
|
11
|
-
description: "The opacity when the button is pressed.",
|
|
12
|
-
defaultValue: 0.8,
|
|
13
|
-
group: GROUPS.basic
|
|
14
|
-
}),
|
|
15
|
-
disabledOpacity: createNumberProp({
|
|
16
|
-
label: "Disabled Opacity",
|
|
17
|
-
description: "The opacity when the button is disabled.",
|
|
18
|
-
defaultValue: 0.8,
|
|
19
|
-
group: GROUPS.basic
|
|
20
|
-
}),
|
|
21
|
-
delayLongPress: createNumberProp({
|
|
22
|
-
label: "Delay Long Press",
|
|
23
|
-
description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
24
|
-
group: GROUPS.basic
|
|
25
|
-
}),
|
|
26
|
-
hitSlop: createNumberProp({
|
|
27
|
-
label: "Hit Slop",
|
|
28
|
-
description: "Sets additional distance outside of element in which a press can be detected.",
|
|
29
|
-
group: GROUPS.basic
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export const SEED_DATA = [{
|
|
34
|
-
name: "Touchable",
|
|
35
|
-
tag: "Touchable",
|
|
36
|
-
description: "An interactive view with no styles",
|
|
37
|
-
category: COMPONENT_TYPES.button,
|
|
38
|
-
...SEED_DATA_PROPS
|
|
39
|
-
}, {
|
|
40
|
-
name: "Pressable",
|
|
41
|
-
tag: "Pressable",
|
|
42
|
-
description: "An interactive view with no styles",
|
|
43
|
-
category: COMPONENT_TYPES.deprecated,
|
|
44
|
-
...SEED_DATA_PROPS
|
|
45
|
-
}];
|