@draftbit/core 47.0.1-9fd6f2.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 (75) 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/DeprecatedCardWrapper.js +2 -2
  4. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  5. package/lib/commonjs/components/Picker/Picker.js +3 -4
  6. package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
  7. package/lib/commonjs/components/Pressable.js +48 -0
  8. package/lib/commonjs/components/Touchable.js +27 -11
  9. package/lib/commonjs/mappings/Button.js +13 -10
  10. package/lib/commonjs/mappings/Pressable.js +52 -0
  11. package/lib/module/components/Button.js +21 -9
  12. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  13. package/lib/module/components/DeprecatedCardWrapper.js +2 -2
  14. package/lib/module/components/DeprecatedFAB.js +2 -3
  15. package/lib/module/components/Picker/Picker.js +3 -4
  16. package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
  17. package/lib/module/components/Pressable.js +40 -0
  18. package/lib/module/components/Touchable.js +25 -10
  19. package/lib/module/mappings/Button.js +14 -11
  20. package/lib/module/mappings/Pressable.js +45 -0
  21. package/lib/typescript/src/components/Button.d.ts +2 -0
  22. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  23. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  24. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  25. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
  26. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  27. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  28. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  29. package/lib/typescript/src/components/Pressable.d.ts +18 -0
  30. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  31. package/lib/typescript/src/components/Touchable.d.ts +9 -2
  32. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  33. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  34. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  35. package/lib/typescript/src/mappings/Pressable.d.ts +76 -0
  36. package/lib/typescript/src/mappings/Pressable.d.ts.map +1 -0
  37. package/package.json +3 -3
  38. package/src/components/Button.js +18 -11
  39. package/src/components/Button.tsx +45 -11
  40. package/src/components/Checkbox/Checkbox.js +2 -3
  41. package/src/components/Checkbox/Checkbox.tsx +5 -7
  42. package/src/components/DeprecatedCardWrapper.js +2 -2
  43. package/src/components/DeprecatedCardWrapper.tsx +3 -4
  44. package/src/components/DeprecatedFAB.js +2 -3
  45. package/src/components/DeprecatedFAB.tsx +5 -5
  46. package/src/components/Picker/Picker.js +3 -4
  47. package/src/components/Picker/Picker.tsx +4 -4
  48. package/src/components/Picker/PickerComponent.ios.js +1 -1
  49. package/src/components/Picker/PickerComponent.ios.tsx +1 -1
  50. package/src/components/Pressable.js +17 -0
  51. package/src/components/Pressable.tsx +67 -0
  52. package/src/components/Touchable.js +16 -11
  53. package/src/components/Touchable.tsx +42 -11
  54. package/src/mappings/Button.js +13 -10
  55. package/src/mappings/Button.ts +13 -10
  56. package/src/mappings/Pressable.js +52 -0
  57. package/src/mappings/Pressable.ts +63 -0
  58. package/lib/commonjs/components/DeprecatedButton.js +0 -151
  59. package/lib/commonjs/components/Touchable.web.js +0 -9
  60. package/lib/commonjs/mappings/Touchable.js +0 -20
  61. package/lib/module/components/DeprecatedButton.js +0 -141
  62. package/lib/module/components/Touchable.web.js +0 -2
  63. package/lib/module/mappings/Touchable.js +0 -13
  64. package/lib/typescript/src/components/DeprecatedButton.d.ts +0 -54
  65. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +0 -1
  66. package/lib/typescript/src/components/Touchable.web.d.ts +0 -3
  67. package/lib/typescript/src/components/Touchable.web.d.ts.map +0 -1
  68. package/lib/typescript/src/mappings/Touchable.d.ts +0 -22
  69. package/lib/typescript/src/mappings/Touchable.d.ts.map +0 -1
  70. package/src/components/DeprecatedButton.js +0 -95
  71. package/src/components/DeprecatedButton.tsx +0 -214
  72. package/src/components/Touchable.web.js +0 -2
  73. package/src/components/Touchable.web.tsx +0 -3
  74. package/src/mappings/Touchable.js +0 -17
  75. package/src/mappings/Touchable.ts +0 -23
@@ -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,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- var _default = _reactNative.TouchableOpacity;
9
- 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,2 +0,0 @@
1
- import { TouchableOpacity } from "react-native";
2
- export default TouchableOpacity;
@@ -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,3 +0,0 @@
1
- import { TouchableOpacity } from "react-native";
2
- export default TouchableOpacity;
3
- //# sourceMappingURL=Touchable.web.d.ts.map
@@ -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"}
@@ -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);