@draftbit/core 47.0.1-54c307.2 → 47.0.1-cc5ccc.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 +27 -15
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
- package/lib/commonjs/components/DeprecatedFAB.js +1 -2
- package/lib/commonjs/components/Picker/Picker.js +3 -4
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
- package/lib/commonjs/components/Pressable.js +48 -0
- package/lib/commonjs/components/Touchable.js +27 -11
- package/lib/commonjs/mappings/Button.js +13 -10
- package/lib/commonjs/mappings/Pressable.js +52 -0
- package/lib/module/components/Button.js +21 -9
- package/lib/module/components/Checkbox/Checkbox.js +2 -3
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/DeprecatedCardWrapper.js +2 -2
- package/lib/module/components/DeprecatedFAB.js +2 -3
- package/lib/module/components/Picker/Picker.js +3 -4
- package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
- package/lib/module/components/Pressable.js +40 -0
- package/lib/module/components/Touchable.js +25 -10
- package/lib/module/mappings/Button.js +14 -11
- package/lib/module/mappings/Pressable.js +45 -0
- package/lib/typescript/src/components/Button.d.ts +2 -0
- 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/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/Pressable.d.ts +18 -0
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/Touchable.d.ts +9 -2
- package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Button.d.ts +113 -4
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Pressable.d.ts +76 -0
- package/lib/typescript/src/mappings/Pressable.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Button.js +18 -11
- package/src/components/Button.tsx +45 -11
- package/src/components/Checkbox/Checkbox.js +2 -3
- package/src/components/Checkbox/Checkbox.tsx +5 -7
- package/src/components/DatePicker/DatePicker.js +1 -1
- package/src/components/DatePicker/DatePicker.tsx +1 -1
- package/src/components/DeprecatedCardWrapper.js +2 -2
- package/src/components/DeprecatedCardWrapper.tsx +3 -4
- package/src/components/DeprecatedFAB.js +2 -3
- package/src/components/DeprecatedFAB.tsx +5 -5
- package/src/components/Picker/Picker.js +3 -4
- 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 +17 -0
- package/src/components/Pressable.tsx +67 -0
- package/src/components/Touchable.js +16 -11
- package/src/components/Touchable.tsx +42 -11
- package/src/mappings/Button.js +13 -10
- package/src/mappings/Button.ts +13 -10
- package/src/mappings/Pressable.js +52 -0
- package/src/mappings/Pressable.ts +63 -0
- package/lib/commonjs/components/DeprecatedButton.js +0 -151
- package/lib/commonjs/components/Touchable.web.js +0 -9
- package/lib/commonjs/mappings/Touchable.js +0 -20
- package/lib/module/components/DeprecatedButton.js +0 -141
- package/lib/module/components/Touchable.web.js +0 -2
- package/lib/module/mappings/Touchable.js +0 -13
- package/lib/typescript/src/components/DeprecatedButton.d.ts +0 -54
- package/lib/typescript/src/components/DeprecatedButton.d.ts.map +0 -1
- package/lib/typescript/src/components/Touchable.web.d.ts +0 -3
- package/lib/typescript/src/components/Touchable.web.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Touchable.d.ts +0 -22
- package/lib/typescript/src/mappings/Touchable.d.ts.map +0 -1
- package/src/components/DeprecatedButton.js +0 -95
- package/src/components/DeprecatedButton.tsx +0 -214
- package/src/components/Touchable.web.js +0 -2
- package/src/components/Touchable.web.tsx +0 -3
- package/src/mappings/Touchable.js +0 -17
- package/src/mappings/Touchable.ts +0 -23
package/src/mappings/Button.ts
CHANGED
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
createActionProp,
|
|
8
8
|
Triggers,
|
|
9
9
|
StylesPanelSections,
|
|
10
|
+
createNumberProp,
|
|
10
11
|
} from "@draftbit/types";
|
|
11
12
|
|
|
12
|
-
const SEED_DATA_TRIGGERS = [Triggers.OnPress];
|
|
13
|
+
const SEED_DATA_TRIGGERS = [Triggers.OnPress, Triggers.OnLongPress];
|
|
13
14
|
const SEED_DATA_PROPS = {
|
|
14
15
|
onPress: createActionProp(),
|
|
16
|
+
onLongPress: createActionProp(),
|
|
15
17
|
icon: createIconProp({
|
|
16
18
|
defaultValue: null,
|
|
17
19
|
required: false,
|
|
@@ -23,12 +25,10 @@ const SEED_DATA_PROPS = {
|
|
|
23
25
|
}),
|
|
24
26
|
disabled: createDisabledProp(),
|
|
25
27
|
loading: createLoadingProp(),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
borderRadius: 8,
|
|
31
|
-
fontFamily: "system-700",
|
|
28
|
+
activeOpacity: createNumberProp(),
|
|
29
|
+
disabledOpacity: createNumberProp(),
|
|
30
|
+
delayLongPress: createNumberProp(),
|
|
31
|
+
hitSlop: createNumberProp(),
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const SEED_DATA = [
|
|
@@ -46,8 +46,9 @@ export const SEED_DATA = [
|
|
|
46
46
|
StylesPanelSections.Effects,
|
|
47
47
|
],
|
|
48
48
|
layout: {
|
|
49
|
-
...LAYOUT,
|
|
50
49
|
backgroundColor: "transparent",
|
|
50
|
+
borderRadius: 8,
|
|
51
|
+
fontFamily: "system-700",
|
|
51
52
|
borderWidth: 1,
|
|
52
53
|
textAlign: "center",
|
|
53
54
|
},
|
|
@@ -68,7 +69,8 @@ export const SEED_DATA = [
|
|
|
68
69
|
StylesPanelSections.Effects,
|
|
69
70
|
],
|
|
70
71
|
layout: {
|
|
71
|
-
|
|
72
|
+
borderRadius: 8,
|
|
73
|
+
fontFamily: "system-700",
|
|
72
74
|
backgroundColor: "primary",
|
|
73
75
|
textAlign: "center",
|
|
74
76
|
},
|
|
@@ -89,7 +91,8 @@ export const SEED_DATA = [
|
|
|
89
91
|
StylesPanelSections.Effects,
|
|
90
92
|
],
|
|
91
93
|
layout: {
|
|
92
|
-
|
|
94
|
+
borderRadius: 8,
|
|
95
|
+
fontFamily: "system-700",
|
|
93
96
|
backgroundColor: "primary",
|
|
94
97
|
textAlign: "center",
|
|
95
98
|
},
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createActionProp, Triggers, createNumberProp, StylesPanelSections, GROUPS, } from "@draftbit/types";
|
|
2
|
+
const SEED_DATA_PROPS = {
|
|
3
|
+
stylesPanelSections: [
|
|
4
|
+
StylesPanelSections.Size,
|
|
5
|
+
StylesPanelSections.Margins,
|
|
6
|
+
StylesPanelSections.Borders,
|
|
7
|
+
],
|
|
8
|
+
layout: {},
|
|
9
|
+
triggers: [Triggers.OnPress, Triggers.OnLongPress],
|
|
10
|
+
props: {
|
|
11
|
+
onPress: createActionProp(),
|
|
12
|
+
onLongPress: createActionProp(),
|
|
13
|
+
activeOpacity: createNumberProp({
|
|
14
|
+
label: "Active Opacity",
|
|
15
|
+
description: "The opacity when the button is pressed.",
|
|
16
|
+
defaultValue: 0.8,
|
|
17
|
+
group: GROUPS.basic,
|
|
18
|
+
}),
|
|
19
|
+
disabledOpacity: createNumberProp({
|
|
20
|
+
label: "Disabled Opacity",
|
|
21
|
+
description: "The opacity when the button is disabled.",
|
|
22
|
+
defaultValue: 0.8,
|
|
23
|
+
group: GROUPS.basic,
|
|
24
|
+
}),
|
|
25
|
+
delayLongPress: createNumberProp({
|
|
26
|
+
label: "Delay Long Press",
|
|
27
|
+
description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
28
|
+
group: GROUPS.basic,
|
|
29
|
+
}),
|
|
30
|
+
hitSlop: createNumberProp({
|
|
31
|
+
label: "Hit Slop",
|
|
32
|
+
description: "Sets additional distance outside of element in which a press can be detected.",
|
|
33
|
+
group: GROUPS.basic,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const SEED_DATA = [
|
|
38
|
+
{
|
|
39
|
+
name: "Touchable",
|
|
40
|
+
tag: "Touchable",
|
|
41
|
+
description: "An interactive view with no styles",
|
|
42
|
+
category: COMPONENT_TYPES.button,
|
|
43
|
+
...SEED_DATA_PROPS,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Pressable",
|
|
47
|
+
tag: "Pressable",
|
|
48
|
+
description: "An interactive view with no styles",
|
|
49
|
+
category: COMPONENT_TYPES.deprecated,
|
|
50
|
+
...SEED_DATA_PROPS,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
createActionProp,
|
|
4
|
+
Triggers,
|
|
5
|
+
createNumberProp,
|
|
6
|
+
StylesPanelSections,
|
|
7
|
+
GROUPS,
|
|
8
|
+
} from "@draftbit/types";
|
|
9
|
+
|
|
10
|
+
const SEED_DATA_PROPS = {
|
|
11
|
+
stylesPanelSections: [
|
|
12
|
+
StylesPanelSections.Size,
|
|
13
|
+
StylesPanelSections.Margins,
|
|
14
|
+
StylesPanelSections.Borders,
|
|
15
|
+
],
|
|
16
|
+
layout: {},
|
|
17
|
+
triggers: [Triggers.OnPress, Triggers.OnLongPress],
|
|
18
|
+
props: {
|
|
19
|
+
onPress: createActionProp(),
|
|
20
|
+
onLongPress: createActionProp(),
|
|
21
|
+
activeOpacity: createNumberProp({
|
|
22
|
+
label: "Active Opacity",
|
|
23
|
+
description: "The opacity when the button is pressed.",
|
|
24
|
+
defaultValue: 0.8,
|
|
25
|
+
group: GROUPS.basic,
|
|
26
|
+
}),
|
|
27
|
+
disabledOpacity: createNumberProp({
|
|
28
|
+
label: "Disabled Opacity",
|
|
29
|
+
description: "The opacity when the button is disabled.",
|
|
30
|
+
defaultValue: 0.8,
|
|
31
|
+
group: GROUPS.basic,
|
|
32
|
+
}),
|
|
33
|
+
delayLongPress: createNumberProp({
|
|
34
|
+
label: "Delay Long Press",
|
|
35
|
+
description:
|
|
36
|
+
"Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
37
|
+
group: GROUPS.basic,
|
|
38
|
+
}),
|
|
39
|
+
hitSlop: createNumberProp({
|
|
40
|
+
label: "Hit Slop",
|
|
41
|
+
description:
|
|
42
|
+
"Sets additional distance outside of element in which a press can be detected.",
|
|
43
|
+
group: GROUPS.basic,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const SEED_DATA = [
|
|
49
|
+
{
|
|
50
|
+
name: "Touchable",
|
|
51
|
+
tag: "Touchable",
|
|
52
|
+
description: "An interactive view with no styles",
|
|
53
|
+
category: COMPONENT_TYPES.button,
|
|
54
|
+
...SEED_DATA_PROPS,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "Pressable",
|
|
58
|
+
tag: "Pressable",
|
|
59
|
+
description: "An interactive view with no styles",
|
|
60
|
+
category: COMPONENT_TYPES.deprecated,
|
|
61
|
+
...SEED_DATA_PROPS,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _color = _interopRequireDefault(require("color"));
|
|
10
|
-
var _Config = _interopRequireDefault(require("./Config"));
|
|
11
|
-
var _Touchable = _interopRequireDefault(require("./Touchable"));
|
|
12
|
-
var _Elevation = _interopRequireDefault(require("./Elevation"));
|
|
13
|
-
var _theming = require("../theming");
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
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); }
|
|
16
|
-
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; }
|
|
17
|
-
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); }
|
|
18
|
-
const Button = _ref => {
|
|
19
|
-
let {
|
|
20
|
-
Icon,
|
|
21
|
-
icon,
|
|
22
|
-
disabled = false,
|
|
23
|
-
type = "solid",
|
|
24
|
-
loading = false,
|
|
25
|
-
labelColor,
|
|
26
|
-
color: colorOverride,
|
|
27
|
-
children,
|
|
28
|
-
onPress,
|
|
29
|
-
elevation = 0,
|
|
30
|
-
style,
|
|
31
|
-
theme: {
|
|
32
|
-
colors,
|
|
33
|
-
disabledOpacity,
|
|
34
|
-
roundness,
|
|
35
|
-
typography
|
|
36
|
-
},
|
|
37
|
-
...rest
|
|
38
|
-
} = _ref;
|
|
39
|
-
let backgroundColor, borderColor, textColor, borderWidth;
|
|
40
|
-
const buttonColor = colorOverride || colors.primary;
|
|
41
|
-
if (type === "solid") {
|
|
42
|
-
backgroundColor = buttonColor;
|
|
43
|
-
if (disabled) {
|
|
44
|
-
textColor = (0, _color.default)(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
45
|
-
} else {
|
|
46
|
-
textColor = labelColor || colors.surface;
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
backgroundColor = "transparent";
|
|
50
|
-
if (disabled) {
|
|
51
|
-
textColor = (0, _color.default)(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
52
|
-
} else {
|
|
53
|
-
textColor = labelColor || buttonColor;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (type === "outline") {
|
|
57
|
-
if (disabled) {
|
|
58
|
-
borderColor = (0, _color.default)(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
59
|
-
} else {
|
|
60
|
-
borderColor = buttonColor;
|
|
61
|
-
}
|
|
62
|
-
borderWidth = _reactNative.StyleSheet.hairlineWidth;
|
|
63
|
-
} else {
|
|
64
|
-
borderColor = "transparent";
|
|
65
|
-
borderWidth = 0;
|
|
66
|
-
}
|
|
67
|
-
const buttonStyle = {
|
|
68
|
-
backgroundColor,
|
|
69
|
-
borderColor,
|
|
70
|
-
borderWidth,
|
|
71
|
-
borderRadius: roundness
|
|
72
|
-
};
|
|
73
|
-
const textStyle = {
|
|
74
|
-
textAlign: "center",
|
|
75
|
-
color: textColor,
|
|
76
|
-
marginVertical: 16,
|
|
77
|
-
marginHorizontal: 16
|
|
78
|
-
};
|
|
79
|
-
const iconStyle = [styles.icon, {
|
|
80
|
-
marginLeft: 16,
|
|
81
|
-
marginRight: -8,
|
|
82
|
-
width: _Config.default.buttonIconSize
|
|
83
|
-
}];
|
|
84
|
-
const {
|
|
85
|
-
margin,
|
|
86
|
-
marginEnd,
|
|
87
|
-
marginTop,
|
|
88
|
-
marginLeft,
|
|
89
|
-
marginRight,
|
|
90
|
-
marginBottom,
|
|
91
|
-
marginHorizontal,
|
|
92
|
-
marginVertical,
|
|
93
|
-
...innerStyles
|
|
94
|
-
} = _reactNative.StyleSheet.flatten(style || {});
|
|
95
|
-
const margins = {
|
|
96
|
-
margin,
|
|
97
|
-
marginEnd,
|
|
98
|
-
marginTop,
|
|
99
|
-
marginLeft,
|
|
100
|
-
marginRight,
|
|
101
|
-
marginBottom,
|
|
102
|
-
marginHorizontal,
|
|
103
|
-
marginVertical
|
|
104
|
-
};
|
|
105
|
-
return /*#__PURE__*/React.createElement(_Elevation.default, {
|
|
106
|
-
style: {
|
|
107
|
-
elevation,
|
|
108
|
-
alignSelf: "stretch",
|
|
109
|
-
...margins
|
|
110
|
-
}
|
|
111
|
-
}, /*#__PURE__*/React.createElement(_Touchable.default, _extends({}, rest, {
|
|
112
|
-
onPress: onPress,
|
|
113
|
-
accessibilityState: {
|
|
114
|
-
disabled
|
|
115
|
-
},
|
|
116
|
-
accessibilityRole: "button",
|
|
117
|
-
disabled: disabled || loading,
|
|
118
|
-
style: [styles.button, buttonStyle, innerStyles]
|
|
119
|
-
}), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
120
|
-
style: styles.content
|
|
121
|
-
}, icon && loading !== true ? /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
122
|
-
style: iconStyle
|
|
123
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
124
|
-
name: icon,
|
|
125
|
-
size: _Config.default.buttonIconSize,
|
|
126
|
-
color: textColor
|
|
127
|
-
})) : null, loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
|
|
128
|
-
size: "small",
|
|
129
|
-
color: textColor,
|
|
130
|
-
style: iconStyle
|
|
131
|
-
}) : null, /*#__PURE__*/React.createElement(_reactNative.Text, {
|
|
132
|
-
numberOfLines: 1,
|
|
133
|
-
style: [textStyle, typography.button]
|
|
134
|
-
}, children))));
|
|
135
|
-
};
|
|
136
|
-
const styles = _reactNative.StyleSheet.create({
|
|
137
|
-
button: {
|
|
138
|
-
minWidth: 64,
|
|
139
|
-
borderStyle: "solid"
|
|
140
|
-
},
|
|
141
|
-
content: {
|
|
142
|
-
flexDirection: "row",
|
|
143
|
-
alignItems: "center",
|
|
144
|
-
justifyContent: "center"
|
|
145
|
-
},
|
|
146
|
-
icon: {
|
|
147
|
-
width: _Config.default.buttonIconSize
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
var _default = (0, _theming.withTheme)(Button);
|
|
151
|
-
exports.default = _default;
|
|
@@ -1,20 +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 = {
|
|
9
|
-
name: "Touchable",
|
|
10
|
-
tag: "Touchable",
|
|
11
|
-
description: "Simple button with no styles",
|
|
12
|
-
category: _types.COMPONENT_TYPES.button,
|
|
13
|
-
stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.Margins, _types.StylesPanelSections.Borders],
|
|
14
|
-
layout: {},
|
|
15
|
-
triggers: [_types.Triggers.OnPress],
|
|
16
|
-
props: {
|
|
17
|
-
onPress: (0, _types.createActionProp)()
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.SEED_DATA = SEED_DATA;
|
|
@@ -1,141 +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 * as React from "react";
|
|
3
|
-
import { ActivityIndicator, View, Text, StyleSheet } from "react-native";
|
|
4
|
-
import color from "color";
|
|
5
|
-
import Config from "./Config";
|
|
6
|
-
import Touchable from "./Touchable";
|
|
7
|
-
import Elevation from "./Elevation";
|
|
8
|
-
import { withTheme } from "../theming";
|
|
9
|
-
const Button = _ref => {
|
|
10
|
-
let {
|
|
11
|
-
Icon,
|
|
12
|
-
icon,
|
|
13
|
-
disabled = false,
|
|
14
|
-
type = "solid",
|
|
15
|
-
loading = false,
|
|
16
|
-
labelColor,
|
|
17
|
-
color: colorOverride,
|
|
18
|
-
children,
|
|
19
|
-
onPress,
|
|
20
|
-
elevation = 0,
|
|
21
|
-
style,
|
|
22
|
-
theme: {
|
|
23
|
-
colors,
|
|
24
|
-
disabledOpacity,
|
|
25
|
-
roundness,
|
|
26
|
-
typography
|
|
27
|
-
},
|
|
28
|
-
...rest
|
|
29
|
-
} = _ref;
|
|
30
|
-
let backgroundColor, borderColor, textColor, borderWidth;
|
|
31
|
-
const buttonColor = colorOverride || colors.primary;
|
|
32
|
-
if (type === "solid") {
|
|
33
|
-
backgroundColor = buttonColor;
|
|
34
|
-
if (disabled) {
|
|
35
|
-
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
36
|
-
} else {
|
|
37
|
-
textColor = labelColor || colors.surface;
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
backgroundColor = "transparent";
|
|
41
|
-
if (disabled) {
|
|
42
|
-
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
43
|
-
} else {
|
|
44
|
-
textColor = labelColor || buttonColor;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (type === "outline") {
|
|
48
|
-
if (disabled) {
|
|
49
|
-
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
50
|
-
} else {
|
|
51
|
-
borderColor = buttonColor;
|
|
52
|
-
}
|
|
53
|
-
borderWidth = StyleSheet.hairlineWidth;
|
|
54
|
-
} else {
|
|
55
|
-
borderColor = "transparent";
|
|
56
|
-
borderWidth = 0;
|
|
57
|
-
}
|
|
58
|
-
const buttonStyle = {
|
|
59
|
-
backgroundColor,
|
|
60
|
-
borderColor,
|
|
61
|
-
borderWidth,
|
|
62
|
-
borderRadius: roundness
|
|
63
|
-
};
|
|
64
|
-
const textStyle = {
|
|
65
|
-
textAlign: "center",
|
|
66
|
-
color: textColor,
|
|
67
|
-
marginVertical: 16,
|
|
68
|
-
marginHorizontal: 16
|
|
69
|
-
};
|
|
70
|
-
const iconStyle = [styles.icon, {
|
|
71
|
-
marginLeft: 16,
|
|
72
|
-
marginRight: -8,
|
|
73
|
-
width: Config.buttonIconSize
|
|
74
|
-
}];
|
|
75
|
-
const {
|
|
76
|
-
margin,
|
|
77
|
-
marginEnd,
|
|
78
|
-
marginTop,
|
|
79
|
-
marginLeft,
|
|
80
|
-
marginRight,
|
|
81
|
-
marginBottom,
|
|
82
|
-
marginHorizontal,
|
|
83
|
-
marginVertical,
|
|
84
|
-
...innerStyles
|
|
85
|
-
} = StyleSheet.flatten(style || {});
|
|
86
|
-
const margins = {
|
|
87
|
-
margin,
|
|
88
|
-
marginEnd,
|
|
89
|
-
marginTop,
|
|
90
|
-
marginLeft,
|
|
91
|
-
marginRight,
|
|
92
|
-
marginBottom,
|
|
93
|
-
marginHorizontal,
|
|
94
|
-
marginVertical
|
|
95
|
-
};
|
|
96
|
-
return /*#__PURE__*/React.createElement(Elevation, {
|
|
97
|
-
style: {
|
|
98
|
-
elevation,
|
|
99
|
-
alignSelf: "stretch",
|
|
100
|
-
...margins
|
|
101
|
-
}
|
|
102
|
-
}, /*#__PURE__*/React.createElement(Touchable, _extends({}, rest, {
|
|
103
|
-
onPress: onPress,
|
|
104
|
-
accessibilityState: {
|
|
105
|
-
disabled
|
|
106
|
-
},
|
|
107
|
-
accessibilityRole: "button",
|
|
108
|
-
disabled: disabled || loading,
|
|
109
|
-
style: [styles.button, buttonStyle, innerStyles]
|
|
110
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
111
|
-
style: styles.content
|
|
112
|
-
}, icon && loading !== true ? /*#__PURE__*/React.createElement(View, {
|
|
113
|
-
style: iconStyle
|
|
114
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
115
|
-
name: icon,
|
|
116
|
-
size: Config.buttonIconSize,
|
|
117
|
-
color: textColor
|
|
118
|
-
})) : null, loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
119
|
-
size: "small",
|
|
120
|
-
color: textColor,
|
|
121
|
-
style: iconStyle
|
|
122
|
-
}) : null, /*#__PURE__*/React.createElement(Text, {
|
|
123
|
-
numberOfLines: 1,
|
|
124
|
-
style: [textStyle, typography.button]
|
|
125
|
-
}, children))));
|
|
126
|
-
};
|
|
127
|
-
const styles = StyleSheet.create({
|
|
128
|
-
button: {
|
|
129
|
-
minWidth: 64,
|
|
130
|
-
borderStyle: "solid"
|
|
131
|
-
},
|
|
132
|
-
content: {
|
|
133
|
-
flexDirection: "row",
|
|
134
|
-
alignItems: "center",
|
|
135
|
-
justifyContent: "center"
|
|
136
|
-
},
|
|
137
|
-
icon: {
|
|
138
|
-
width: Config.buttonIconSize
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
export default withTheme(Button);
|
|
@@ -1,13 +0,0 @@
|
|
|
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: [StylesPanelSections.Size, StylesPanelSections.Margins, StylesPanelSections.Borders],
|
|
8
|
-
layout: {},
|
|
9
|
-
triggers: [Triggers.OnPress],
|
|
10
|
-
props: {
|
|
11
|
-
onPress: createActionProp()
|
|
12
|
-
}
|
|
13
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { TouchableHighlightProps, StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import type { Theme } from "../styles/DefaultTheme";
|
|
4
|
-
import type { IconSlot } from "../interfaces/Icon";
|
|
5
|
-
/**
|
|
6
|
-
* A button is component that the user can press to trigger an action.
|
|
7
|
-
*
|
|
8
|
-
* <div class="screenshots">
|
|
9
|
-
* <figure>
|
|
10
|
-
* <img src="screenshots/button-1.png" />
|
|
11
|
-
* <figcaption>Text button</figcaption>
|
|
12
|
-
* </figure>
|
|
13
|
-
* <figure>
|
|
14
|
-
* <img src="screenshots/button-2.png" />
|
|
15
|
-
* <figcaption>Outlined button</figcaption>
|
|
16
|
-
* </figure>
|
|
17
|
-
* <figure>
|
|
18
|
-
* <img src="screenshots/button-3.png" />
|
|
19
|
-
* <figcaption>Contained button</figcaption>
|
|
20
|
-
* </figure>
|
|
21
|
-
* </div>
|
|
22
|
-
*
|
|
23
|
-
* ## Usage
|
|
24
|
-
* ```js
|
|
25
|
-
* import * as React from 'react';
|
|
26
|
-
* import { Button } from '@draftbit/ui';
|
|
27
|
-
*
|
|
28
|
-
* const MyComponent = () => (
|
|
29
|
-
* <Button icon="add-a-photo" type="solid" onPress={() => console.log('Pressed')}>
|
|
30
|
-
* Press me
|
|
31
|
-
* </Button>
|
|
32
|
-
* );
|
|
33
|
-
*
|
|
34
|
-
* export default MyComponent;
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
declare type Props = {
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
type?: "solid" | "outline" | "text";
|
|
40
|
-
loading?: boolean;
|
|
41
|
-
icon?: string;
|
|
42
|
-
labelColor?: string;
|
|
43
|
-
color?: string;
|
|
44
|
-
children?: React.ReactNode;
|
|
45
|
-
onPress: () => void;
|
|
46
|
-
elevation?: number;
|
|
47
|
-
style?: StyleProp<ViewStyle>;
|
|
48
|
-
theme: Theme;
|
|
49
|
-
} & TouchableHighlightProps & IconSlot;
|
|
50
|
-
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<React.PropsWithChildren<Props>, "theme"> & {
|
|
51
|
-
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
52
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<React.PropsWithChildren<Props>> & React.FC<React.PropsWithChildren<Props>>, {}>;
|
|
53
|
-
export default _default;
|
|
54
|
-
//# sourceMappingURL=DeprecatedButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeprecatedButton.d.ts","sourceRoot":"","sources":["../../../../src/components/DeprecatedButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,uBAAuB,EACvB,SAAS,EACT,SAAS,EAEV,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,aAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;CACd,GAAG,uBAAuB,GACzB,QAAQ,CAAC;;;;AAmJX,wBAAiC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Touchable.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Touchable.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const SEED_DATA: {
|
|
2
|
-
name: string;
|
|
3
|
-
tag: string;
|
|
4
|
-
description: string;
|
|
5
|
-
category: string;
|
|
6
|
-
stylesPanelSections: string[];
|
|
7
|
-
layout: {};
|
|
8
|
-
triggers: string[];
|
|
9
|
-
props: {
|
|
10
|
-
onPress: {
|
|
11
|
-
label: string;
|
|
12
|
-
description: string;
|
|
13
|
-
editable: boolean;
|
|
14
|
-
required: boolean;
|
|
15
|
-
formType: string;
|
|
16
|
-
propType: string;
|
|
17
|
-
defaultValue: null;
|
|
18
|
-
group: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=Touchable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Touchable.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Touchable.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAerB,CAAC"}
|