@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.
Files changed (79) hide show
  1. package/lib/commonjs/components/Button.js +27 -15
  2. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
  3. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  4. package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
  5. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  6. package/lib/commonjs/components/Picker/Picker.js +3 -4
  7. package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
  8. package/lib/commonjs/components/Pressable.js +48 -0
  9. package/lib/commonjs/components/Touchable.js +27 -11
  10. package/lib/commonjs/mappings/Button.js +13 -10
  11. package/lib/commonjs/mappings/Pressable.js +52 -0
  12. package/lib/module/components/Button.js +21 -9
  13. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  14. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  15. package/lib/module/components/DeprecatedCardWrapper.js +2 -2
  16. package/lib/module/components/DeprecatedFAB.js +2 -3
  17. package/lib/module/components/Picker/Picker.js +3 -4
  18. package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
  19. package/lib/module/components/Pressable.js +40 -0
  20. package/lib/module/components/Touchable.js +25 -10
  21. package/lib/module/mappings/Button.js +14 -11
  22. package/lib/module/mappings/Pressable.js +45 -0
  23. package/lib/typescript/src/components/Button.d.ts +2 -0
  24. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  25. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  26. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  27. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
  28. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  29. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  30. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  31. package/lib/typescript/src/components/Pressable.d.ts +18 -0
  32. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  33. package/lib/typescript/src/components/Touchable.d.ts +9 -2
  34. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  35. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  36. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  37. package/lib/typescript/src/mappings/Pressable.d.ts +76 -0
  38. package/lib/typescript/src/mappings/Pressable.d.ts.map +1 -0
  39. package/package.json +3 -3
  40. package/src/components/Button.js +18 -11
  41. package/src/components/Button.tsx +45 -11
  42. package/src/components/Checkbox/Checkbox.js +2 -3
  43. package/src/components/Checkbox/Checkbox.tsx +5 -7
  44. package/src/components/DatePicker/DatePicker.js +1 -1
  45. package/src/components/DatePicker/DatePicker.tsx +1 -1
  46. package/src/components/DeprecatedCardWrapper.js +2 -2
  47. package/src/components/DeprecatedCardWrapper.tsx +3 -4
  48. package/src/components/DeprecatedFAB.js +2 -3
  49. package/src/components/DeprecatedFAB.tsx +5 -5
  50. package/src/components/Picker/Picker.js +3 -4
  51. package/src/components/Picker/Picker.tsx +4 -4
  52. package/src/components/Picker/PickerComponent.ios.js +1 -1
  53. package/src/components/Picker/PickerComponent.ios.tsx +1 -1
  54. package/src/components/Pressable.js +17 -0
  55. package/src/components/Pressable.tsx +67 -0
  56. package/src/components/Touchable.js +16 -11
  57. package/src/components/Touchable.tsx +42 -11
  58. package/src/mappings/Button.js +13 -10
  59. package/src/mappings/Button.ts +13 -10
  60. package/src/mappings/Pressable.js +52 -0
  61. package/src/mappings/Pressable.ts +63 -0
  62. package/lib/commonjs/components/DeprecatedButton.js +0 -151
  63. package/lib/commonjs/components/Touchable.web.js +0 -9
  64. package/lib/commonjs/mappings/Touchable.js +0 -20
  65. package/lib/module/components/DeprecatedButton.js +0 -141
  66. package/lib/module/components/Touchable.web.js +0 -2
  67. package/lib/module/mappings/Touchable.js +0 -13
  68. package/lib/typescript/src/components/DeprecatedButton.d.ts +0 -54
  69. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +0 -1
  70. package/lib/typescript/src/components/Touchable.web.d.ts +0 -3
  71. package/lib/typescript/src/components/Touchable.web.d.ts.map +0 -1
  72. package/lib/typescript/src/mappings/Touchable.d.ts +0 -22
  73. package/lib/typescript/src/mappings/Touchable.d.ts.map +0 -1
  74. package/src/components/DeprecatedButton.js +0 -95
  75. package/src/components/DeprecatedButton.tsx +0 -214
  76. package/src/components/Touchable.web.js +0 -2
  77. package/src/components/Touchable.web.tsx +0 -3
  78. package/src/mappings/Touchable.js +0 -17
  79. package/src/mappings/Touchable.ts +0 -23
@@ -1,95 +0,0 @@
1
- import * as React from "react";
2
- import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
3
- import color from "color";
4
- import Config from "./Config";
5
- import Touchable from "./Touchable";
6
- import Elevation from "./Elevation";
7
- import { withTheme } from "../theming";
8
- const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
9
- let backgroundColor, borderColor, textColor, borderWidth;
10
- const buttonColor = colorOverride || colors.primary;
11
- if (type === "solid") {
12
- backgroundColor = buttonColor;
13
- if (disabled) {
14
- textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
15
- }
16
- else {
17
- textColor = labelColor || colors.surface;
18
- }
19
- }
20
- else {
21
- backgroundColor = "transparent";
22
- if (disabled) {
23
- textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
24
- }
25
- else {
26
- textColor = labelColor || buttonColor;
27
- }
28
- }
29
- if (type === "outline") {
30
- if (disabled) {
31
- borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
32
- }
33
- else {
34
- borderColor = buttonColor;
35
- }
36
- borderWidth = StyleSheet.hairlineWidth;
37
- }
38
- else {
39
- borderColor = "transparent";
40
- borderWidth = 0;
41
- }
42
- const buttonStyle = {
43
- backgroundColor,
44
- borderColor,
45
- borderWidth,
46
- borderRadius: roundness,
47
- };
48
- const textStyle = {
49
- textAlign: "center",
50
- color: textColor,
51
- marginVertical: 16,
52
- marginHorizontal: 16,
53
- };
54
- const iconStyle = [
55
- styles.icon,
56
- {
57
- marginLeft: 16,
58
- marginRight: -8,
59
- width: Config.buttonIconSize,
60
- },
61
- ];
62
- const { margin, marginEnd, marginTop, marginLeft, marginRight, marginBottom, marginHorizontal, marginVertical, ...innerStyles } = StyleSheet.flatten(style || {});
63
- const margins = {
64
- margin,
65
- marginEnd,
66
- marginTop,
67
- marginLeft,
68
- marginRight,
69
- marginBottom,
70
- marginHorizontal,
71
- marginVertical,
72
- };
73
- return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch", ...margins } },
74
- React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle, innerStyles] },
75
- React.createElement(View, { style: styles.content },
76
- icon && loading !== true ? (React.createElement(View, { style: iconStyle },
77
- React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
78
- loading ? (React.createElement(ActivityIndicator, { size: "small", color: textColor, style: iconStyle })) : null,
79
- React.createElement(Text, { numberOfLines: 1, style: [textStyle, typography.button] }, children)))));
80
- };
81
- const styles = StyleSheet.create({
82
- button: {
83
- minWidth: 64,
84
- borderStyle: "solid",
85
- },
86
- content: {
87
- flexDirection: "row",
88
- alignItems: "center",
89
- justifyContent: "center",
90
- },
91
- icon: {
92
- width: Config.buttonIconSize,
93
- },
94
- });
95
- export default withTheme(Button);
@@ -1,214 +0,0 @@
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,2 +0,0 @@
1
- import { TouchableOpacity } from "react-native";
2
- export default TouchableOpacity;
@@ -1,3 +0,0 @@
1
- import { TouchableOpacity } from "react-native";
2
-
3
- export default TouchableOpacity;
@@ -1,17 +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: [
8
- StylesPanelSections.Size,
9
- StylesPanelSections.Margins,
10
- StylesPanelSections.Borders,
11
- ],
12
- layout: {},
13
- triggers: [Triggers.OnPress],
14
- props: {
15
- onPress: createActionProp(),
16
- },
17
- };
@@ -1,23 +0,0 @@
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
- };