@draftbit/core 47.0.1-5c6c55.2 → 47.0.1-ad0ed2.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 (64) hide show
  1. package/lib/commonjs/components/Button.js +3 -3
  2. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
  3. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
  4. package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
  5. package/lib/commonjs/components/DeprecatedButton.js +3 -27
  6. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  7. package/lib/commonjs/components/Pressable.js +37 -0
  8. package/lib/commonjs/components/Touchable.js +8 -3
  9. package/lib/commonjs/mappings/Button.js +27 -9
  10. package/lib/commonjs/mappings/Touchable.js +39 -7
  11. package/lib/module/components/Button.js +3 -3
  12. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  13. package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
  14. package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
  15. package/lib/module/components/DeprecatedButton.js +4 -28
  16. package/lib/module/components/DeprecatedFAB.js +2 -3
  17. package/lib/module/components/Pressable.js +30 -0
  18. package/lib/module/components/Touchable.js +8 -3
  19. package/lib/module/mappings/Button.js +28 -10
  20. package/lib/module/mappings/Touchable.js +41 -9
  21. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  22. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  23. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  24. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  25. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  26. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  27. package/lib/typescript/src/components/DeprecatedButton.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/Pressable.d.ts +16 -0
  31. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  32. package/lib/typescript/src/components/Touchable.d.ts +7 -2
  33. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  34. package/lib/typescript/src/mappings/Button.d.ts +93 -4
  35. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  36. package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
  37. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  38. package/package.json +3 -3
  39. package/src/components/Button.js +3 -3
  40. package/src/components/Button.tsx +14 -4
  41. package/src/components/Checkbox/Checkbox.js +2 -3
  42. package/src/components/Checkbox/Checkbox.tsx +5 -7
  43. package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
  44. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  45. package/src/components/Checkbox/CheckboxRow.js +2 -3
  46. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  47. package/src/components/DeprecatedButton.js +4 -16
  48. package/src/components/DeprecatedButton.tsx +7 -31
  49. package/src/components/DeprecatedFAB.js +2 -3
  50. package/src/components/DeprecatedFAB.tsx +5 -5
  51. package/src/components/Pressable.js +12 -0
  52. package/src/components/Pressable.tsx +50 -0
  53. package/src/components/Touchable.js +3 -3
  54. package/src/components/Touchable.tsx +14 -4
  55. package/src/mappings/Button.js +27 -9
  56. package/src/mappings/Button.ts +29 -9
  57. package/src/mappings/Touchable.js +42 -7
  58. package/src/mappings/Touchable.ts +46 -6
  59. package/lib/commonjs/mappings/DatePickerModal.js +0 -75
  60. package/lib/module/mappings/DatePickerModal.js +0 -66
  61. package/lib/typescript/src/mappings/DatePickerModal.d.ts +0 -155
  62. package/lib/typescript/src/mappings/DatePickerModal.d.ts.map +0 -1
  63. package/src/mappings/DatePickerModal.js +0 -74
  64. package/src/mappings/DatePickerModal.ts +0 -92
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, Platform, } from "react-native";
2
+ import { StyleSheet, View, Platform, Pressable, } from "react-native";
3
3
  import { isString } from "lodash";
4
4
  import { extractStyles } from "../../utilities";
5
5
  import { usePrevious } from "../../hooks";
6
6
  import Text from "../Text";
7
- import Touchable from "../Touchable";
8
7
  import Checkbox from "./Checkbox";
9
8
  export var Direction;
10
9
  (function (Direction) {
@@ -46,7 +45,7 @@ const CheckboxRow = ({ label = "Label", labelStyle, labelContainerStyle, checkbo
46
45
  }
47
46
  };
48
47
  const { textStyles, viewStyles } = extractStyles(style);
49
- return (React.createElement(Touchable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
48
+ return (React.createElement(Pressable, { onPress: handlePress, style: [viewStyles, styles.mainParent, { flexDirection: direction }], disabled: disabled, ...rest },
50
49
  React.createElement(View, { style: [
51
50
  styles.label,
52
51
  {
@@ -6,6 +6,7 @@ import {
6
6
  TextStyle,
7
7
  View,
8
8
  Platform,
9
+ Pressable,
9
10
  } from "react-native";
10
11
  import { isString } from "lodash";
11
12
 
@@ -13,7 +14,6 @@ import type { IconSlot } from "../../interfaces/Icon";
13
14
  import { extractStyles } from "../../utilities";
14
15
  import { usePrevious } from "../../hooks";
15
16
  import Text from "../Text";
16
- import Touchable from "../Touchable";
17
17
  import Checkbox, { CheckboxProps } from "./Checkbox";
18
18
 
19
19
  export enum Direction {
@@ -100,7 +100,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
100
100
  const { textStyles, viewStyles } = extractStyles(style);
101
101
 
102
102
  return (
103
- <Touchable
103
+ <Pressable
104
104
  onPress={handlePress}
105
105
  style={[viewStyles, styles.mainParent, { flexDirection: direction }]}
106
106
  disabled={disabled}
@@ -130,7 +130,7 @@ const CheckboxRow: React.FC<CheckboxRowProps & IconSlot> = ({
130
130
  uncheckedIcon={uncheckedIcon}
131
131
  size={size}
132
132
  />
133
- </Touchable>
133
+ </Pressable>
134
134
  );
135
135
  };
136
136
 
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
2
+ import { ActivityIndicator, View, Text, StyleSheet, Pressable, } from "react-native";
3
3
  import color from "color";
4
4
  import Config from "./Config";
5
- import Touchable from "./Touchable";
6
5
  import Elevation from "./Elevation";
7
6
  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 }) => {
7
+ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
9
8
  let backgroundColor, borderColor, textColor, borderWidth;
10
9
  const buttonColor = colorOverride || colors.primary;
11
10
  if (type === "solid") {
@@ -59,19 +58,8 @@ const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false,
59
58
  width: Config.buttonIconSize,
60
59
  },
61
60
  ];
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] },
61
+ return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch" } },
62
+ React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle] },
75
63
  React.createElement(View, { style: styles.content },
76
64
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
77
65
  React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
@@ -4,14 +4,14 @@ import {
4
4
  View,
5
5
  Text,
6
6
  StyleSheet,
7
- TouchableHighlightProps,
8
7
  StyleProp,
9
8
  ViewStyle,
10
9
  TextStyle,
10
+ Pressable,
11
+ PressableProps,
11
12
  } from "react-native";
12
13
  import color from "color";
13
14
  import Config from "./Config";
14
- import Touchable from "./Touchable";
15
15
  import Elevation from "./Elevation";
16
16
  import { withTheme } from "../theming";
17
17
 
@@ -63,7 +63,7 @@ type Props = {
63
63
  elevation?: number;
64
64
  style?: StyleProp<ViewStyle>;
65
65
  theme: Theme;
66
- } & TouchableHighlightProps &
66
+ } & PressableProps &
67
67
  IconSlot;
68
68
 
69
69
  const Button: React.FC<React.PropsWithChildren<Props>> = ({
@@ -77,7 +77,6 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
77
77
  children,
78
78
  onPress,
79
79
  elevation = 0,
80
- style,
81
80
  theme: { colors, disabledOpacity, roundness, typography },
82
81
  ...rest
83
82
  }) => {
@@ -137,38 +136,15 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
137
136
  },
138
137
  ];
139
138
 
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
139
  return (
164
- <Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
165
- <Touchable
140
+ <Elevation style={{ elevation, alignSelf: "stretch" }}>
141
+ <Pressable
166
142
  {...rest}
167
143
  onPress={onPress}
168
144
  accessibilityState={{ disabled }}
169
145
  accessibilityRole="button"
170
146
  disabled={disabled || loading}
171
- style={[styles.button, buttonStyle, innerStyles]}
147
+ style={[styles.button, buttonStyle]}
172
148
  >
173
149
  <View style={styles.content}>
174
150
  {icon && loading !== true ? (
@@ -191,7 +167,7 @@ const Button: React.FC<React.PropsWithChildren<Props>> = ({
191
167
  {children}
192
168
  </Text>
193
169
  </View>
194
- </Touchable>
170
+ </Pressable>
195
171
  </Elevation>
196
172
  );
197
173
  };
@@ -1,9 +1,8 @@
1
1
  import * as React from "react";
2
- import { ActivityIndicator, View, StyleSheet, } from "react-native";
2
+ import { ActivityIndicator, View, StyleSheet, Pressable, } 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";
7
6
  import Elevation from "./Elevation";
8
7
  import { withTheme } from "../theming";
9
8
  const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, color: colorOverride, label, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
@@ -83,7 +82,7 @@ const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, co
83
82
  });
84
83
  }
85
84
  return (React.createElement(Elevation, { style: [{ elevation }, style] },
86
- React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
85
+ React.createElement(Pressable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
87
86
  React.createElement(View, { style: styles.content },
88
87
  icon && loading !== true ? (React.createElement(View, { style: iconStyle },
89
88
  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,
7
6
  StyleProp,
8
7
  ViewStyle,
9
8
  TextStyle,
9
+ Pressable,
10
+ PressableProps,
10
11
  } from "react-native";
11
12
  import color from "color";
12
13
  import Config from "./Config";
13
14
  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
- } & TouchableHighlightProps &
68
+ } & PressableProps &
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
- <Touchable
172
+ <Pressable
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
- </Touchable>
203
+ </Pressable>
204
204
  </Elevation>
205
205
  );
206
206
  };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { Pressable as NativePressable, } from "react-native";
3
+ export default function Pressable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
+ return (React.createElement(NativePressable, { onPress: onPress, disabled: disabled, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
5
+ return [
6
+ {
7
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
8
+ },
9
+ style,
10
+ ];
11
+ }, ...props }, children));
12
+ }
@@ -0,0 +1,50 @@
1
+ import React from "react";
2
+ import {
3
+ Pressable as NativePressable,
4
+ PressableProps,
5
+ ViewStyle,
6
+ } from "react-native";
7
+
8
+ type Props = {
9
+ disabled?: boolean;
10
+ children: React.ReactNode;
11
+ style?: ViewStyle;
12
+ onPress?: () => void;
13
+ onLongPress?: () => void;
14
+ delayLongPress?: number;
15
+ hitSlop?: number;
16
+ activeOpacity?: number;
17
+ disabledOpacity?: number;
18
+ } & PressableProps;
19
+
20
+ export default function Pressable({
21
+ children,
22
+ disabled,
23
+ onPress,
24
+ activeOpacity,
25
+ disabledOpacity,
26
+ delayLongPress,
27
+ hitSlop,
28
+ style,
29
+ ...props
30
+ }: Props) {
31
+ return (
32
+ <NativePressable
33
+ onPress={onPress}
34
+ disabled={disabled}
35
+ delayLongPress={delayLongPress ? delayLongPress : 500}
36
+ hitSlop={hitSlop ? hitSlop : 8}
37
+ style={({ pressed }) => {
38
+ return [
39
+ {
40
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
41
+ },
42
+ style,
43
+ ];
44
+ }}
45
+ {...props}
46
+ >
47
+ {children}
48
+ </NativePressable>
49
+ );
50
+ }
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
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 }) => {
3
+ export default function Touchable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
+ return (React.createElement(Pressable, { disabled: disabled, onPress: onPress, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
5
5
  return [
6
6
  {
7
- opacity: pressed || disabled ? 0.75 : 1,
7
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
8
8
  },
9
9
  style,
10
10
  ];
@@ -1,29 +1,39 @@
1
1
  import React from "react";
2
- import { Pressable, ViewStyle, PressableProps } from "react-native";
2
+ import { Pressable, PressableProps, ViewStyle } from "react-native";
3
3
 
4
4
  type Props = {
5
5
  disabled?: boolean;
6
6
  children: React.ReactNode;
7
7
  style?: ViewStyle;
8
8
  onPress?: () => void;
9
+ onLongPress?: () => void;
10
+ delayLongPress?: number;
11
+ hitSlop?: number;
12
+ activeOpacity?: number;
13
+ disabledOpacity?: number;
9
14
  } & PressableProps;
10
15
 
11
16
  export default function Touchable({
12
17
  children,
13
18
  disabled,
14
19
  onPress,
20
+ activeOpacity,
21
+ disabledOpacity,
22
+ delayLongPress,
23
+ hitSlop,
15
24
  style,
16
25
  ...props
17
26
  }: Props) {
18
27
  return (
19
28
  <Pressable
20
- onPress={onPress}
21
29
  disabled={disabled}
22
- hitSlop={8}
30
+ onPress={onPress}
31
+ delayLongPress={delayLongPress ? delayLongPress : 500}
32
+ hitSlop={hitSlop ? hitSlop : 8}
23
33
  style={({ pressed }) => {
24
34
  return [
25
35
  {
26
- opacity: pressed || disabled ? 0.75 : 1,
36
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
27
37
  },
28
38
  style,
29
39
  ];
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createIconProp, createTextProp, createDisabledProp, createLoadingProp, createActionProp, Triggers, StylesPanelSections, createStaticNumberProp, } from "@draftbit/types";
2
2
  const SEED_DATA_TRIGGERS = [Triggers.OnPress];
3
3
  const SEED_DATA_PROPS = {
4
4
  onPress: createActionProp(),
@@ -13,11 +13,26 @@ const SEED_DATA_PROPS = {
13
13
  }),
14
14
  disabled: createDisabledProp(),
15
15
  loading: createLoadingProp(),
16
- };
17
- const LAYOUT = {
18
- backgroundColor: "transparent",
19
- borderRadius: 8,
20
- fontFamily: "system-700",
16
+ activeOpacity: createStaticNumberProp({
17
+ label: "Active Opacity",
18
+ description: "Opacity of the button when active.",
19
+ required: false,
20
+ }),
21
+ disabledOpacity: createStaticNumberProp({
22
+ label: "Disabled Opacity",
23
+ description: "Opacity of the button when disabled.",
24
+ required: false,
25
+ }),
26
+ delayLongPress: createStaticNumberProp({
27
+ label: "Delay Long Press",
28
+ description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
29
+ required: false,
30
+ }),
31
+ hitSlop: createStaticNumberProp({
32
+ label: "Hit Slop",
33
+ description: "Sets additional distance outside of element in which a press can be detected",
34
+ required: false,
35
+ }),
21
36
  };
22
37
  export const SEED_DATA = [
23
38
  {
@@ -34,7 +49,8 @@ export const SEED_DATA = [
34
49
  StylesPanelSections.Effects,
35
50
  ],
36
51
  layout: {
37
- ...LAYOUT,
52
+ borderRadius: 8,
53
+ fontFamily: "system-700",
38
54
  backgroundColor: "transparent",
39
55
  borderWidth: 1,
40
56
  textAlign: "center",
@@ -56,7 +72,8 @@ export const SEED_DATA = [
56
72
  StylesPanelSections.Effects,
57
73
  ],
58
74
  layout: {
59
- ...LAYOUT,
75
+ borderRadius: 8,
76
+ fontFamily: "system-700",
60
77
  backgroundColor: "primary",
61
78
  textAlign: "center",
62
79
  },
@@ -77,7 +94,8 @@ export const SEED_DATA = [
77
94
  StylesPanelSections.Effects,
78
95
  ],
79
96
  layout: {
80
- ...LAYOUT,
97
+ borderRadius: 8,
98
+ fontFamily: "system-700",
81
99
  backgroundColor: "primary",
82
100
  textAlign: "center",
83
101
  },
@@ -7,6 +7,7 @@ import {
7
7
  createActionProp,
8
8
  Triggers,
9
9
  StylesPanelSections,
10
+ createStaticNumberProp,
10
11
  } from "@draftbit/types";
11
12
 
12
13
  const SEED_DATA_TRIGGERS = [Triggers.OnPress];
@@ -23,12 +24,28 @@ const SEED_DATA_PROPS = {
23
24
  }),
24
25
  disabled: createDisabledProp(),
25
26
  loading: createLoadingProp(),
26
- };
27
-
28
- const LAYOUT = {
29
- backgroundColor: "transparent",
30
- borderRadius: 8,
31
- fontFamily: "system-700",
27
+ activeOpacity: createStaticNumberProp({
28
+ label: "Active Opacity",
29
+ description: "Opacity of the button when active.",
30
+ required: false,
31
+ }),
32
+ disabledOpacity: createStaticNumberProp({
33
+ label: "Disabled Opacity",
34
+ description: "Opacity of the button when disabled.",
35
+ required: false,
36
+ }),
37
+ delayLongPress: createStaticNumberProp({
38
+ label: "Delay Long Press",
39
+ description:
40
+ "Duration (in milliseconds) from onPressIn before onLongPress is called.",
41
+ required: false,
42
+ }),
43
+ hitSlop: createStaticNumberProp({
44
+ label: "Hit Slop",
45
+ description:
46
+ "Sets additional distance outside of element in which a press can be detected",
47
+ required: false,
48
+ }),
32
49
  };
33
50
 
34
51
  export const SEED_DATA = [
@@ -46,7 +63,8 @@ export const SEED_DATA = [
46
63
  StylesPanelSections.Effects,
47
64
  ],
48
65
  layout: {
49
- ...LAYOUT,
66
+ borderRadius: 8,
67
+ fontFamily: "system-700",
50
68
  backgroundColor: "transparent",
51
69
  borderWidth: 1,
52
70
  textAlign: "center",
@@ -68,7 +86,8 @@ export const SEED_DATA = [
68
86
  StylesPanelSections.Effects,
69
87
  ],
70
88
  layout: {
71
- ...LAYOUT,
89
+ borderRadius: 8,
90
+ fontFamily: "system-700",
72
91
  backgroundColor: "primary",
73
92
  textAlign: "center",
74
93
  },
@@ -89,7 +108,8 @@ export const SEED_DATA = [
89
108
  StylesPanelSections.Effects,
90
109
  ],
91
110
  layout: {
92
- ...LAYOUT,
111
+ borderRadius: 8,
112
+ fontFamily: "system-700",
93
113
  backgroundColor: "primary",
94
114
  textAlign: "center",
95
115
  },
@@ -1,17 +1,52 @@
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,
1
+ import { COMPONENT_TYPES, createActionProp, Triggers, createNumberProp, StylesPanelSections, GROUPS, } from "@draftbit/types";
2
+ const SEED_DATA_PROPS = {
7
3
  stylesPanelSections: [
8
4
  StylesPanelSections.Size,
9
5
  StylesPanelSections.Margins,
10
6
  StylesPanelSections.Borders,
11
7
  ],
12
8
  layout: {},
13
- triggers: [Triggers.OnPress],
9
+ triggers: [Triggers.OnPress, Triggers.OnLongPress],
14
10
  props: {
15
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
+ }),
16
35
  },
17
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.deprecated,
43
+ ...SEED_DATA_PROPS,
44
+ },
45
+ {
46
+ name: "Pressable",
47
+ tag: "Pressable",
48
+ description: "An interactive view with no styles",
49
+ category: COMPONENT_TYPES.button,
50
+ ...SEED_DATA_PROPS,
51
+ },
52
+ ];
@@ -2,22 +2,62 @@ import {
2
2
  COMPONENT_TYPES,
3
3
  createActionProp,
4
4
  Triggers,
5
+ createNumberProp,
5
6
  StylesPanelSections,
7
+ GROUPS,
6
8
  } from "@draftbit/types";
7
9
 
8
- export const SEED_DATA = {
9
- name: "Touchable",
10
- tag: "Touchable",
11
- description: "Simple button with no styles",
12
- category: COMPONENT_TYPES.button,
10
+ const SEED_DATA_PROPS = {
13
11
  stylesPanelSections: [
14
12
  StylesPanelSections.Size,
15
13
  StylesPanelSections.Margins,
16
14
  StylesPanelSections.Borders,
17
15
  ],
18
16
  layout: {},
19
- triggers: [Triggers.OnPress],
17
+ triggers: [Triggers.OnPress, Triggers.OnLongPress],
20
18
  props: {
21
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
+ }),
22
45
  },
23
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.deprecated,
54
+ ...SEED_DATA_PROPS,
55
+ },
56
+ {
57
+ name: "Pressable",
58
+ tag: "Pressable",
59
+ description: "An interactive view with no styles",
60
+ category: COMPONENT_TYPES.button,
61
+ ...SEED_DATA_PROPS,
62
+ },
63
+ ];