@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
@@ -21,10 +21,11 @@ function Base(_ref) {
21
21
  Icon,
22
22
  icon,
23
23
  title,
24
- onPress,
25
24
  loading,
26
25
  disabled,
27
26
  style,
27
+ activeOpacity,
28
+ disabledOpacity,
28
29
  ...props
29
30
  } = _ref;
30
31
  const {
@@ -61,14 +62,13 @@ function Base(_ref) {
61
62
  buttonStyles.justifyContent = "flex-end";
62
63
  }
63
64
  return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
64
- onPress: onPress,
65
65
  disabled: disabled || loading,
66
66
  style: _ref2 => {
67
67
  let {
68
68
  pressed
69
69
  } = _ref2;
70
70
  return [styles.base, {
71
- opacity: pressed || disabled ? 0.75 : 1
71
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
72
72
  }, buttonStyles];
73
73
  }
74
74
  }, props), loading ? /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, {
@@ -7,9 +7,7 @@ exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _theming = require("../../theming");
10
- var _Touchable = _interopRequireDefault(require("../Touchable"));
11
10
  var _hooks = require("../../hooks");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
  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); }
14
12
  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; }
15
13
  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); }
@@ -60,7 +58,7 @@ const Checkbox = _ref => {
60
58
  onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
61
59
  }
62
60
  };
63
- return /*#__PURE__*/React.createElement(_Touchable.default, _extends({}, rest, {
61
+ return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({}, rest, {
64
62
  onPress: handlePress,
65
63
  disabled: disabled,
66
64
  accessibilityState: {
@@ -9,7 +9,6 @@ var _reactNative = require("react-native");
9
9
  var _Checkbox = _interopRequireDefault(require("./Checkbox"));
10
10
  var _Text = _interopRequireDefault(require("../Text"));
11
11
  var _context = require("./context");
12
- var _Touchable = _interopRequireDefault(require("../Touchable"));
13
12
  var _utilities = require("../../utilities");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  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); }
@@ -73,7 +72,7 @@ const CheckboxGroupRow = _ref => {
73
72
  textStyles,
74
73
  viewStyles
75
74
  } = (0, _utilities.extractStyles)(style);
76
- return /*#__PURE__*/React.createElement(_Touchable.default, _extends({
75
+ return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
77
76
  onPress: handlePress,
78
77
  style: [styles.mainParent, {
79
78
  flexDirection: direction
@@ -10,7 +10,6 @@ var _lodash = require("lodash");
10
10
  var _utilities = require("../../utilities");
11
11
  var _hooks = require("../../hooks");
12
12
  var _Text = _interopRequireDefault(require("../Text"));
13
- var _Touchable = _interopRequireDefault(require("../Touchable"));
14
13
  var _Checkbox = _interopRequireDefault(require("./Checkbox"));
15
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
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); }
@@ -83,7 +82,7 @@ const CheckboxRow = _ref => {
83
82
  textStyles,
84
83
  viewStyles
85
84
  } = (0, _utilities.extractStyles)(style);
86
- return /*#__PURE__*/React.createElement(_Touchable.default, _extends({
85
+ return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
87
86
  onPress: handlePress,
88
87
  style: [viewStyles, styles.mainParent, {
89
88
  flexDirection: direction
@@ -8,7 +8,6 @@ var React = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _color = _interopRequireDefault(require("color"));
10
10
  var _Config = _interopRequireDefault(require("./Config"));
11
- var _Touchable = _interopRequireDefault(require("./Touchable"));
12
11
  var _Elevation = _interopRequireDefault(require("./Elevation"));
13
12
  var _theming = require("../theming");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -27,7 +26,6 @@ const Button = _ref => {
27
26
  children,
28
27
  onPress,
29
28
  elevation = 0,
30
- style,
31
29
  theme: {
32
30
  colors,
33
31
  disabledOpacity,
@@ -81,41 +79,19 @@ const Button = _ref => {
81
79
  marginRight: -8,
82
80
  width: _Config.default.buttonIconSize
83
81
  }];
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
82
  return /*#__PURE__*/React.createElement(_Elevation.default, {
106
83
  style: {
107
84
  elevation,
108
- alignSelf: "stretch",
109
- ...margins
85
+ alignSelf: "stretch"
110
86
  }
111
- }, /*#__PURE__*/React.createElement(_Touchable.default, _extends({}, rest, {
87
+ }, /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({}, rest, {
112
88
  onPress: onPress,
113
89
  accessibilityState: {
114
90
  disabled
115
91
  },
116
92
  accessibilityRole: "button",
117
93
  disabled: disabled || loading,
118
- style: [styles.button, buttonStyle, innerStyles]
94
+ style: [styles.button, buttonStyle]
119
95
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
120
96
  style: styles.content
121
97
  }, icon && loading !== true ? /*#__PURE__*/React.createElement(_reactNative.View, {
@@ -9,7 +9,6 @@ var _reactNative = require("react-native");
9
9
  var _color = _interopRequireDefault(require("color"));
10
10
  var _Config = _interopRequireDefault(require("./Config"));
11
11
  var _Text = _interopRequireDefault(require("./Text"));
12
- var _Touchable = _interopRequireDefault(require("./Touchable"));
13
12
  var _Elevation = _interopRequireDefault(require("./Elevation"));
14
13
  var _theming = require("../theming");
15
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -107,7 +106,7 @@ const FAB = _ref => {
107
106
  style: [{
108
107
  elevation
109
108
  }, style]
110
- }, /*#__PURE__*/React.createElement(_Touchable.default, _extends({}, rest, {
109
+ }, /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({}, rest, {
111
110
  onPress: onPress,
112
111
  accessibilityState: {
113
112
  disabled
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Pressable;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ 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); }
11
+ function Pressable(_ref) {
12
+ let {
13
+ children,
14
+ disabled,
15
+ onPress,
16
+ activeOpacity,
17
+ disabledOpacity,
18
+ delayLongPress,
19
+ hitSlop,
20
+ style,
21
+ ...props
22
+ } = _ref;
23
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, _extends({
24
+ onPress: onPress,
25
+ disabled: disabled,
26
+ delayLongPress: delayLongPress ? delayLongPress : 500,
27
+ hitSlop: hitSlop ? hitSlop : 8,
28
+ style: _ref2 => {
29
+ let {
30
+ pressed
31
+ } = _ref2;
32
+ return [{
33
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
34
+ }, style];
35
+ }
36
+ }, props), children);
37
+ }
@@ -13,19 +13,24 @@ function Touchable(_ref) {
13
13
  children,
14
14
  disabled,
15
15
  onPress,
16
+ activeOpacity,
17
+ disabledOpacity,
18
+ delayLongPress,
19
+ hitSlop,
16
20
  style,
17
21
  ...props
18
22
  } = _ref;
19
23
  return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, _extends({
20
- onPress: onPress,
21
24
  disabled: disabled,
22
- hitSlop: 8,
25
+ onPress: onPress,
26
+ delayLongPress: delayLongPress ? delayLongPress : 500,
27
+ hitSlop: hitSlop ? hitSlop : 8,
23
28
  style: _ref2 => {
24
29
  let {
25
30
  pressed
26
31
  } = _ref2;
27
32
  return [{
28
- opacity: pressed || disabled ? 0.75 : 1
33
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
29
34
  }, style];
30
35
  }
31
36
  }, props), children);
@@ -18,12 +18,27 @@ const SEED_DATA_PROPS = {
18
18
  defaultValue: "Get Started"
19
19
  }),
20
20
  disabled: (0, _types.createDisabledProp)(),
21
- loading: (0, _types.createLoadingProp)()
22
- };
23
- const LAYOUT = {
24
- backgroundColor: "transparent",
25
- borderRadius: 8,
26
- fontFamily: "system-700"
21
+ loading: (0, _types.createLoadingProp)(),
22
+ activeOpacity: (0, _types.createStaticNumberProp)({
23
+ label: "Active Opacity",
24
+ description: "Opacity of the button when active.",
25
+ required: false
26
+ }),
27
+ disabledOpacity: (0, _types.createStaticNumberProp)({
28
+ label: "Disabled Opacity",
29
+ description: "Opacity of the button when disabled.",
30
+ required: false
31
+ }),
32
+ delayLongPress: (0, _types.createStaticNumberProp)({
33
+ label: "Delay Long Press",
34
+ description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
35
+ required: false
36
+ }),
37
+ hitSlop: (0, _types.createStaticNumberProp)({
38
+ label: "Hit Slop",
39
+ description: "Sets additional distance outside of element in which a press can be detected",
40
+ required: false
41
+ })
27
42
  };
28
43
  const SEED_DATA = [{
29
44
  name: "Button Outline",
@@ -31,7 +46,8 @@ const SEED_DATA = [{
31
46
  category: _types.COMPONENT_TYPES.deprecated,
32
47
  stylesPanelSections: [_types.StylesPanelSections.Typography, _types.StylesPanelSections.Background, _types.StylesPanelSections.Borders, _types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects],
33
48
  layout: {
34
- ...LAYOUT,
49
+ borderRadius: 8,
50
+ fontFamily: "system-700",
35
51
  backgroundColor: "transparent",
36
52
  borderWidth: 1,
37
53
  textAlign: "center"
@@ -44,7 +60,8 @@ const SEED_DATA = [{
44
60
  category: _types.COMPONENT_TYPES.deprecated,
45
61
  stylesPanelSections: [_types.StylesPanelSections.Typography, _types.StylesPanelSections.Background, _types.StylesPanelSections.Borders, _types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects],
46
62
  layout: {
47
- ...LAYOUT,
63
+ borderRadius: 8,
64
+ fontFamily: "system-700",
48
65
  backgroundColor: "primary",
49
66
  textAlign: "center"
50
67
  },
@@ -56,7 +73,8 @@ const SEED_DATA = [{
56
73
  category: _types.COMPONENT_TYPES.button,
57
74
  stylesPanelSections: [_types.StylesPanelSections.Typography, _types.StylesPanelSections.Background, _types.StylesPanelSections.Borders, _types.StylesPanelSections.Size, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Position, _types.StylesPanelSections.Effects],
58
75
  layout: {
59
- ...LAYOUT,
76
+ borderRadius: 8,
77
+ fontFamily: "system-700",
60
78
  backgroundColor: "primary",
61
79
  textAlign: "center"
62
80
  },
@@ -5,16 +5,48 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SEED_DATA = void 0;
7
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,
8
+ const SEED_DATA_PROPS = {
13
9
  stylesPanelSections: [_types.StylesPanelSections.Size, _types.StylesPanelSections.Margins, _types.StylesPanelSections.Borders],
14
10
  layout: {},
15
- triggers: [_types.Triggers.OnPress],
11
+ triggers: [_types.Triggers.OnPress, _types.Triggers.OnLongPress],
16
12
  props: {
17
- onPress: (0, _types.createActionProp)()
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
+ })
18
37
  }
19
38
  };
39
+ const SEED_DATA = [{
40
+ name: "Touchable",
41
+ tag: "Touchable",
42
+ description: "An interactive view with no styles",
43
+ category: _types.COMPONENT_TYPES.deprecated,
44
+ ...SEED_DATA_PROPS
45
+ }, {
46
+ name: "Pressable",
47
+ tag: "Pressable",
48
+ description: "An interactive view with no styles",
49
+ category: _types.COMPONENT_TYPES.button,
50
+ ...SEED_DATA_PROPS
51
+ }];
20
52
  exports.SEED_DATA = SEED_DATA;
@@ -13,10 +13,11 @@ function Base(_ref) {
13
13
  Icon,
14
14
  icon,
15
15
  title,
16
- onPress,
17
16
  loading,
18
17
  disabled,
19
18
  style,
19
+ activeOpacity,
20
+ disabledOpacity,
20
21
  ...props
21
22
  } = _ref;
22
23
  const {
@@ -53,14 +54,13 @@ function Base(_ref) {
53
54
  buttonStyles.justifyContent = "flex-end";
54
55
  }
55
56
  return /*#__PURE__*/React.createElement(Pressable, _extends({
56
- onPress: onPress,
57
57
  disabled: disabled || loading,
58
58
  style: _ref2 => {
59
59
  let {
60
60
  pressed
61
61
  } = _ref2;
62
62
  return [styles.base, {
63
- opacity: pressed || disabled ? 0.75 : 1
63
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
64
64
  }, buttonStyles];
65
65
  }
66
66
  }, props), loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
@@ -1,8 +1,7 @@
1
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
2
  import * as React from "react";
3
- import { View, StyleSheet } from "react-native";
3
+ import { View, StyleSheet, Pressable } from "react-native";
4
4
  import { useTheme } from "../../theming";
5
- import Touchable from "../Touchable";
6
5
  import { usePrevious } from "../../hooks";
7
6
  const Checkbox = _ref => {
8
7
  let {
@@ -51,7 +50,7 @@ const Checkbox = _ref => {
51
50
  onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
52
51
  }
53
52
  };
54
- return /*#__PURE__*/React.createElement(Touchable, _extends({}, rest, {
53
+ return /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
55
54
  onPress: handlePress,
56
55
  disabled: disabled,
57
56
  accessibilityState: {
@@ -1,11 +1,10 @@
1
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
2
  import * as React from "react";
3
- import { StyleSheet, View, Platform } from "react-native";
3
+ import { StyleSheet, View, Platform, Pressable } from "react-native";
4
4
  import Checkbox from "./Checkbox";
5
5
  import Text from "../Text";
6
6
  import { useCheckboxGroupContext } from "./context";
7
7
  import { Direction as GroupDirection } from "./context";
8
- import Touchable from "../Touchable";
9
8
  import { extractStyles } from "../../utilities";
10
9
  export let Direction;
11
10
  (function (Direction) {
@@ -64,7 +63,7 @@ const CheckboxGroupRow = _ref => {
64
63
  textStyles,
65
64
  viewStyles
66
65
  } = extractStyles(style);
67
- return /*#__PURE__*/React.createElement(Touchable, _extends({
66
+ return /*#__PURE__*/React.createElement(Pressable, _extends({
68
67
  onPress: handlePress,
69
68
  style: [styles.mainParent, {
70
69
  flexDirection: direction
@@ -1,11 +1,10 @@
1
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
2
  import * as React from "react";
3
- import { StyleSheet, View, Platform } from "react-native";
3
+ import { StyleSheet, View, Platform, Pressable } from "react-native";
4
4
  import { isString } from "lodash";
5
5
  import { extractStyles } from "../../utilities";
6
6
  import { usePrevious } from "../../hooks";
7
7
  import Text from "../Text";
8
- import Touchable from "../Touchable";
9
8
  import Checkbox from "./Checkbox";
10
9
  export let Direction;
11
10
  (function (Direction) {
@@ -73,7 +72,7 @@ const CheckboxRow = _ref => {
73
72
  textStyles,
74
73
  viewStyles
75
74
  } = extractStyles(style);
76
- return /*#__PURE__*/React.createElement(Touchable, _extends({
75
+ return /*#__PURE__*/React.createElement(Pressable, _extends({
77
76
  onPress: handlePress,
78
77
  style: [viewStyles, styles.mainParent, {
79
78
  flexDirection: direction
@@ -1,9 +1,8 @@
1
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
2
  import * as React from "react";
3
- import { ActivityIndicator, View, Text, StyleSheet } from "react-native";
3
+ import { ActivityIndicator, View, Text, StyleSheet, Pressable } from "react-native";
4
4
  import color from "color";
5
5
  import Config from "./Config";
6
- import Touchable from "./Touchable";
7
6
  import Elevation from "./Elevation";
8
7
  import { withTheme } from "../theming";
9
8
  const Button = _ref => {
@@ -18,7 +17,6 @@ const Button = _ref => {
18
17
  children,
19
18
  onPress,
20
19
  elevation = 0,
21
- style,
22
20
  theme: {
23
21
  colors,
24
22
  disabledOpacity,
@@ -72,41 +70,19 @@ const Button = _ref => {
72
70
  marginRight: -8,
73
71
  width: Config.buttonIconSize
74
72
  }];
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
73
  return /*#__PURE__*/React.createElement(Elevation, {
97
74
  style: {
98
75
  elevation,
99
- alignSelf: "stretch",
100
- ...margins
76
+ alignSelf: "stretch"
101
77
  }
102
- }, /*#__PURE__*/React.createElement(Touchable, _extends({}, rest, {
78
+ }, /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
103
79
  onPress: onPress,
104
80
  accessibilityState: {
105
81
  disabled
106
82
  },
107
83
  accessibilityRole: "button",
108
84
  disabled: disabled || loading,
109
- style: [styles.button, buttonStyle, innerStyles]
85
+ style: [styles.button, buttonStyle]
110
86
  }), /*#__PURE__*/React.createElement(View, {
111
87
  style: styles.content
112
88
  }, icon && loading !== true ? /*#__PURE__*/React.createElement(View, {
@@ -1,10 +1,9 @@
1
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
2
  import * as React from "react";
3
- import { ActivityIndicator, View, StyleSheet } from "react-native";
3
+ import { ActivityIndicator, View, StyleSheet, Pressable } from "react-native";
4
4
  import color from "color";
5
5
  import Config from "./Config";
6
6
  import Text from "./Text";
7
- import Touchable from "./Touchable";
8
7
  import Elevation from "./Elevation";
9
8
  import { withTheme } from "../theming";
10
9
  const FAB = _ref => {
@@ -98,7 +97,7 @@ const FAB = _ref => {
98
97
  style: [{
99
98
  elevation
100
99
  }, style]
101
- }, /*#__PURE__*/React.createElement(Touchable, _extends({}, rest, {
100
+ }, /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
102
101
  onPress: onPress,
103
102
  accessibilityState: {
104
103
  disabled
@@ -0,0 +1,30 @@
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 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
+ activeOpacity,
10
+ disabledOpacity,
11
+ delayLongPress,
12
+ hitSlop,
13
+ style,
14
+ ...props
15
+ } = _ref;
16
+ return /*#__PURE__*/React.createElement(NativePressable, _extends({
17
+ onPress: onPress,
18
+ disabled: disabled,
19
+ delayLongPress: delayLongPress ? delayLongPress : 500,
20
+ hitSlop: hitSlop ? hitSlop : 8,
21
+ style: _ref2 => {
22
+ let {
23
+ pressed
24
+ } = _ref2;
25
+ return [{
26
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
27
+ }, style];
28
+ }
29
+ }, props), children);
30
+ }
@@ -6,19 +6,24 @@ export default function Touchable(_ref) {
6
6
  children,
7
7
  disabled,
8
8
  onPress,
9
+ activeOpacity,
10
+ disabledOpacity,
11
+ delayLongPress,
12
+ hitSlop,
9
13
  style,
10
14
  ...props
11
15
  } = _ref;
12
16
  return /*#__PURE__*/React.createElement(Pressable, _extends({
13
- onPress: onPress,
14
17
  disabled: disabled,
15
- hitSlop: 8,
18
+ onPress: onPress,
19
+ delayLongPress: delayLongPress ? delayLongPress : 500,
20
+ hitSlop: hitSlop ? hitSlop : 8,
16
21
  style: _ref2 => {
17
22
  let {
18
23
  pressed
19
24
  } = _ref2;
20
25
  return [{
21
- opacity: pressed || disabled ? 0.75 : 1
26
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1
22
27
  }, style];
23
28
  }
24
29
  }, props), children);
@@ -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(),
@@ -12,12 +12,27 @@ const SEED_DATA_PROPS = {
12
12
  defaultValue: "Get Started"
13
13
  }),
14
14
  disabled: createDisabledProp(),
15
- loading: createLoadingProp()
16
- };
17
- const LAYOUT = {
18
- backgroundColor: "transparent",
19
- borderRadius: 8,
20
- fontFamily: "system-700"
15
+ loading: createLoadingProp(),
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
  name: "Button Outline",
@@ -25,7 +40,8 @@ export const SEED_DATA = [{
25
40
  category: COMPONENT_TYPES.deprecated,
26
41
  stylesPanelSections: [StylesPanelSections.Typography, StylesPanelSections.Background, StylesPanelSections.Borders, StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects],
27
42
  layout: {
28
- ...LAYOUT,
43
+ borderRadius: 8,
44
+ fontFamily: "system-700",
29
45
  backgroundColor: "transparent",
30
46
  borderWidth: 1,
31
47
  textAlign: "center"
@@ -38,7 +54,8 @@ export const SEED_DATA = [{
38
54
  category: COMPONENT_TYPES.deprecated,
39
55
  stylesPanelSections: [StylesPanelSections.Typography, StylesPanelSections.Background, StylesPanelSections.Borders, StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects],
40
56
  layout: {
41
- ...LAYOUT,
57
+ borderRadius: 8,
58
+ fontFamily: "system-700",
42
59
  backgroundColor: "primary",
43
60
  textAlign: "center"
44
61
  },
@@ -50,7 +67,8 @@ export const SEED_DATA = [{
50
67
  category: COMPONENT_TYPES.button,
51
68
  stylesPanelSections: [StylesPanelSections.Typography, StylesPanelSections.Background, StylesPanelSections.Borders, StylesPanelSections.Size, StylesPanelSections.MarginsAndPaddings, StylesPanelSections.Position, StylesPanelSections.Effects],
52
69
  layout: {
53
- ...LAYOUT,
70
+ borderRadius: 8,
71
+ fontFamily: "system-700",
54
72
  backgroundColor: "primary",
55
73
  textAlign: "center"
56
74
  },