@draftbit/core 47.0.1-17098e.2 → 47.0.1-2aab54.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 (141) hide show
  1. package/lib/commonjs/components/Button.js +15 -27
  2. package/lib/commonjs/components/Checkbox/Checkbox.js +3 -1
  3. package/lib/commonjs/components/Checkbox/CheckboxGroup.js +17 -2
  4. package/lib/commonjs/components/DeprecatedButton.js +151 -0
  5. package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
  6. package/lib/commonjs/components/DeprecatedFAB.js +2 -1
  7. package/lib/commonjs/components/Picker/Picker.js +4 -3
  8. package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
  9. package/lib/commonjs/components/Touchable.js +11 -27
  10. package/lib/commonjs/components/Touchable.web.js +9 -0
  11. package/lib/commonjs/index.js +25 -82
  12. package/lib/commonjs/mappings/Button.js +10 -14
  13. package/lib/commonjs/mappings/NativeBase/AlertDialog.js +93 -0
  14. package/lib/commonjs/mappings/NativeBase/Button.js +84 -0
  15. package/lib/commonjs/mappings/NativeBase/DataDisplay.js +48 -0
  16. package/lib/commonjs/mappings/NativeBase/Feedback.js +74 -0
  17. package/lib/commonjs/mappings/NativeBase/Layout.js +114 -0
  18. package/lib/commonjs/mappings/NativeBase/Media.js +49 -0
  19. package/lib/commonjs/mappings/NativeBase/Menu.js +111 -0
  20. package/lib/commonjs/mappings/NativeBase/Modal.js +93 -0
  21. package/lib/commonjs/mappings/NativeBase/Other.js +94 -0
  22. package/lib/commonjs/mappings/NativeBase/Popover.js +99 -0
  23. package/lib/commonjs/mappings/Touchable.js +20 -0
  24. package/lib/module/components/Button.js +9 -21
  25. package/lib/module/components/Checkbox/Checkbox.js +3 -2
  26. package/lib/module/components/DeprecatedButton.js +141 -0
  27. package/lib/module/components/DeprecatedCardWrapper.js +2 -2
  28. package/lib/module/components/DeprecatedFAB.js +3 -2
  29. package/lib/module/components/Picker/Picker.js +4 -3
  30. package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
  31. package/lib/module/components/Touchable.js +10 -25
  32. package/lib/module/components/Touchable.web.js +2 -0
  33. package/lib/module/index.js +121 -31
  34. package/lib/module/mappings/Button.js +11 -15
  35. package/lib/module/mappings/NativeBase/AlertDialog.js +86 -0
  36. package/lib/module/mappings/NativeBase/Button.js +86 -0
  37. package/lib/module/mappings/NativeBase/DataDisplay.js +41 -0
  38. package/lib/module/mappings/NativeBase/Feedback.js +67 -0
  39. package/lib/module/mappings/NativeBase/Layout.js +107 -0
  40. package/lib/module/mappings/NativeBase/Media.js +42 -0
  41. package/lib/module/mappings/NativeBase/Menu.js +104 -0
  42. package/lib/module/mappings/NativeBase/Modal.js +86 -0
  43. package/lib/module/mappings/NativeBase/Other.js +87 -0
  44. package/lib/module/mappings/NativeBase/Popover.js +92 -0
  45. package/lib/module/mappings/Touchable.js +13 -0
  46. package/lib/typescript/src/components/Button.d.ts +0 -2
  47. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  48. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  49. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  50. package/lib/typescript/src/components/DeprecatedButton.d.ts +54 -0
  51. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -0
  52. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
  53. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  54. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  55. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  56. package/lib/typescript/src/components/Touchable.d.ts +2 -9
  57. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  58. package/lib/typescript/src/components/Touchable.web.d.ts +3 -0
  59. package/lib/typescript/src/components/Touchable.web.d.ts.map +1 -0
  60. package/lib/typescript/src/index.d.ts +102 -29
  61. package/lib/typescript/src/index.d.ts.map +1 -1
  62. package/lib/typescript/src/mappings/Button.d.ts +2 -224
  63. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  64. package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts +134 -0
  65. package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts.map +1 -0
  66. package/lib/typescript/src/mappings/NativeBase/Button.d.ts +1 -0
  67. package/lib/typescript/src/mappings/NativeBase/Button.d.ts.map +1 -0
  68. package/lib/typescript/src/mappings/{Pressable.d.ts → NativeBase/DataDisplay.d.ts} +34 -40
  69. package/lib/typescript/src/mappings/NativeBase/DataDisplay.d.ts.map +1 -0
  70. package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts +2 -0
  71. package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts.map +1 -0
  72. package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +146 -0
  73. package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +1 -0
  74. package/lib/typescript/src/mappings/NativeBase/Media.d.ts +48 -0
  75. package/lib/typescript/src/mappings/NativeBase/Media.d.ts.map +1 -0
  76. package/lib/typescript/src/mappings/NativeBase/Menu.d.ts +227 -0
  77. package/lib/typescript/src/mappings/NativeBase/Menu.d.ts.map +1 -0
  78. package/lib/typescript/src/mappings/NativeBase/Modal.d.ts +133 -0
  79. package/lib/typescript/src/mappings/NativeBase/Modal.d.ts.map +1 -0
  80. package/lib/typescript/src/mappings/NativeBase/Other.d.ts +179 -0
  81. package/lib/typescript/src/mappings/NativeBase/Other.d.ts.map +1 -0
  82. package/lib/typescript/src/mappings/NativeBase/Popover.d.ts +136 -0
  83. package/lib/typescript/src/mappings/NativeBase/Popover.d.ts.map +1 -0
  84. package/lib/typescript/src/mappings/Touchable.d.ts +22 -0
  85. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -0
  86. package/package.json +3 -3
  87. package/src/components/Button.js +11 -18
  88. package/src/components/Button.tsx +11 -45
  89. package/src/components/Checkbox/Checkbox.js +3 -2
  90. package/src/components/Checkbox/Checkbox.tsx +7 -5
  91. package/src/components/DeprecatedButton.js +95 -0
  92. package/src/components/DeprecatedButton.tsx +214 -0
  93. package/src/components/DeprecatedCardWrapper.js +2 -2
  94. package/src/components/DeprecatedCardWrapper.tsx +4 -3
  95. package/src/components/DeprecatedFAB.js +3 -2
  96. package/src/components/DeprecatedFAB.tsx +5 -5
  97. package/src/components/Picker/Picker.js +4 -3
  98. package/src/components/Picker/Picker.tsx +4 -4
  99. package/src/components/Picker/PickerComponent.ios.js +1 -1
  100. package/src/components/Picker/PickerComponent.ios.tsx +1 -1
  101. package/src/components/Touchable.js +11 -16
  102. package/src/components/Touchable.tsx +11 -42
  103. package/src/components/Touchable.web.js +2 -0
  104. package/src/components/Touchable.web.tsx +3 -0
  105. package/src/index.js +112 -31
  106. package/src/index.tsx +123 -43
  107. package/src/mappings/Button.js +10 -14
  108. package/src/mappings/Button.ts +10 -14
  109. package/src/mappings/NativeBase/AlertDialog.js +103 -0
  110. package/src/mappings/NativeBase/AlertDialog.ts +118 -0
  111. package/src/mappings/NativeBase/Button.js +84 -0
  112. package/src/mappings/NativeBase/Button.ts +83 -0
  113. package/src/mappings/NativeBase/DataDisplay.js +54 -0
  114. package/src/mappings/NativeBase/DataDisplay.ts +64 -0
  115. package/src/mappings/NativeBase/Feedback.js +89 -0
  116. package/src/mappings/NativeBase/Feedback.ts +100 -0
  117. package/src/mappings/NativeBase/Layout.js +140 -0
  118. package/src/mappings/NativeBase/Layout.ts +152 -0
  119. package/src/mappings/NativeBase/Media.js +56 -0
  120. package/src/mappings/NativeBase/Media.ts +65 -0
  121. package/src/mappings/NativeBase/Menu.js +134 -0
  122. package/src/mappings/NativeBase/Menu.ts +150 -0
  123. package/src/mappings/NativeBase/Modal.js +103 -0
  124. package/src/mappings/NativeBase/Modal.ts +118 -0
  125. package/src/mappings/NativeBase/Other.js +123 -0
  126. package/src/mappings/NativeBase/Other.ts +139 -0
  127. package/src/mappings/NativeBase/Popover.js +123 -0
  128. package/src/mappings/NativeBase/Popover.ts +136 -0
  129. package/src/mappings/Touchable.js +17 -0
  130. package/src/mappings/Touchable.ts +23 -0
  131. package/lib/commonjs/components/Pressable.js +0 -48
  132. package/lib/commonjs/mappings/Pressable.js +0 -52
  133. package/lib/module/components/Pressable.js +0 -40
  134. package/lib/module/mappings/Pressable.js +0 -45
  135. package/lib/typescript/src/components/Pressable.d.ts +0 -18
  136. package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
  137. package/lib/typescript/src/mappings/Pressable.d.ts.map +0 -1
  138. package/src/components/Pressable.js +0 -17
  139. package/src/components/Pressable.tsx +0 -67
  140. package/src/mappings/Pressable.js +0 -52
  141. package/src/mappings/Pressable.ts +0 -63
@@ -0,0 +1,179 @@
1
+ export declare const SEED_DATA: ({
2
+ name: string;
3
+ tag: string;
4
+ description: string;
5
+ category: string;
6
+ packageName: string;
7
+ doc_link: string;
8
+ code_link: string;
9
+ stylesPanelSections: string[];
10
+ layout: {};
11
+ triggers: {};
12
+ props: {
13
+ placement: {
14
+ group: string;
15
+ label: string;
16
+ description: string;
17
+ editable: boolean;
18
+ required: boolean;
19
+ formType: string;
20
+ propType: string;
21
+ defaultValue: null;
22
+ options: never[];
23
+ };
24
+ label: any;
25
+ icon: {
26
+ label: string;
27
+ description: string;
28
+ formType: string;
29
+ propType: string;
30
+ defaultValue: string;
31
+ required: boolean;
32
+ editable: boolean;
33
+ group: string;
34
+ };
35
+ isOpen?: undefined;
36
+ isDisabled?: undefined;
37
+ defaultIsOpen?: undefined;
38
+ onOpen?: undefined;
39
+ onClose?: undefined;
40
+ openDelay?: undefined;
41
+ closeDelay?: undefined;
42
+ arrowSize?: undefined;
43
+ hasArrow?: undefined;
44
+ offset?: undefined;
45
+ };
46
+ allowChildren?: undefined;
47
+ } | {
48
+ name: string;
49
+ tag: string;
50
+ description: string;
51
+ category: string;
52
+ packageName: string;
53
+ allowChildren: boolean;
54
+ stylesPanelSections: string[];
55
+ layout: {};
56
+ triggers: string[];
57
+ props: {
58
+ label: any;
59
+ isOpen: {
60
+ label: string;
61
+ description: string;
62
+ formType: string;
63
+ propType: string;
64
+ defaultValue: boolean;
65
+ editable: boolean;
66
+ required: boolean;
67
+ group: string;
68
+ };
69
+ isDisabled: {
70
+ label: string;
71
+ description: string;
72
+ group: string;
73
+ editable: boolean;
74
+ required: boolean;
75
+ formType: string;
76
+ propType: string;
77
+ defaultValue: null;
78
+ };
79
+ defaultIsOpen: {
80
+ label: string;
81
+ description: string;
82
+ formType: string;
83
+ propType: string;
84
+ defaultValue: boolean;
85
+ editable: boolean;
86
+ required: boolean;
87
+ group: string;
88
+ };
89
+ onOpen: {
90
+ label: string;
91
+ description: string;
92
+ editable: boolean;
93
+ required: boolean;
94
+ formType: string;
95
+ propType: string;
96
+ defaultValue: null;
97
+ group: string;
98
+ };
99
+ onClose: {
100
+ label: string;
101
+ description: string;
102
+ editable: boolean;
103
+ required: boolean;
104
+ formType: string;
105
+ propType: string;
106
+ defaultValue: null;
107
+ group: string;
108
+ };
109
+ openDelay: {
110
+ label: string;
111
+ description: string;
112
+ formType: string;
113
+ propType: string;
114
+ group: string;
115
+ defaultValue: null;
116
+ editable: boolean;
117
+ required: boolean;
118
+ step: number;
119
+ };
120
+ closeDelay: {
121
+ label: string;
122
+ description: string;
123
+ formType: string;
124
+ propType: string;
125
+ group: string;
126
+ defaultValue: null;
127
+ editable: boolean;
128
+ required: boolean;
129
+ step: number;
130
+ };
131
+ placement: {
132
+ group: string;
133
+ label: string;
134
+ description: string;
135
+ editable: boolean;
136
+ required: boolean;
137
+ formType: string;
138
+ propType: string;
139
+ defaultValue: null;
140
+ options: never[];
141
+ };
142
+ arrowSize: {
143
+ label: string;
144
+ description: string;
145
+ formType: string;
146
+ propType: string;
147
+ group: string;
148
+ defaultValue: null;
149
+ editable: boolean;
150
+ required: boolean;
151
+ step: number;
152
+ };
153
+ hasArrow: {
154
+ label: string;
155
+ description: string;
156
+ formType: string;
157
+ propType: string;
158
+ defaultValue: boolean;
159
+ editable: boolean;
160
+ required: boolean;
161
+ group: string;
162
+ };
163
+ offset: {
164
+ label: string;
165
+ description: string;
166
+ formType: string;
167
+ propType: string;
168
+ group: string;
169
+ defaultValue: null;
170
+ editable: boolean;
171
+ required: boolean;
172
+ step: number;
173
+ };
174
+ icon?: undefined;
175
+ };
176
+ doc_link?: undefined;
177
+ code_link?: undefined;
178
+ })[];
179
+ //# sourceMappingURL=Other.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Other.d.ts","sourceRoot":"","sources":["../../../../../src/mappings/NativeBase/Other.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4HrB,CAAC"}
@@ -0,0 +1,136 @@
1
+ export declare const SEED_DATA: ({
2
+ allowChildren: boolean;
3
+ props: {
4
+ isOpen: {
5
+ label: string;
6
+ description: string;
7
+ formType: string;
8
+ propType: string;
9
+ defaultValue: boolean;
10
+ editable: boolean;
11
+ required: boolean;
12
+ group: string;
13
+ };
14
+ defaultIsOpen: {
15
+ label: string;
16
+ description: string;
17
+ formType: string;
18
+ propType: string;
19
+ defaultValue: boolean;
20
+ editable: boolean;
21
+ required: boolean;
22
+ group: string;
23
+ };
24
+ trapFocus: {
25
+ label: string;
26
+ description: string;
27
+ formType: string;
28
+ propType: string;
29
+ defaultValue: boolean;
30
+ editable: boolean;
31
+ required: boolean;
32
+ group: string;
33
+ };
34
+ shouldFlip: {
35
+ label: string;
36
+ description: string;
37
+ formType: string;
38
+ propType: string;
39
+ defaultValue: boolean;
40
+ editable: boolean;
41
+ required: boolean;
42
+ group: string;
43
+ };
44
+ shouldOverlapWithTrigger: {
45
+ label: string;
46
+ description: string;
47
+ formType: string;
48
+ propType: string;
49
+ defaultValue: boolean;
50
+ editable: boolean;
51
+ required: boolean;
52
+ group: string;
53
+ };
54
+ isKeyboardDismissable: {
55
+ label: string;
56
+ description: string;
57
+ formType: string;
58
+ propType: string;
59
+ defaultValue: boolean;
60
+ editable: boolean;
61
+ required: boolean;
62
+ group: string;
63
+ };
64
+ placement: {
65
+ group: string;
66
+ label: string;
67
+ description: string;
68
+ editable: boolean;
69
+ required: boolean;
70
+ formType: string;
71
+ propType: string;
72
+ defaultValue: null;
73
+ options: never[];
74
+ };
75
+ useRNModal: {
76
+ label: string;
77
+ description: string;
78
+ formType: string;
79
+ propType: string;
80
+ defaultValue: boolean;
81
+ editable: boolean;
82
+ required: boolean;
83
+ group: string;
84
+ };
85
+ onOpen: {
86
+ label: string;
87
+ description: string;
88
+ editable: boolean;
89
+ required: boolean;
90
+ formType: string;
91
+ propType: string;
92
+ defaultValue: null;
93
+ group: string;
94
+ };
95
+ onClose: {
96
+ label: string;
97
+ description: string;
98
+ editable: boolean;
99
+ required: boolean;
100
+ formType: string;
101
+ propType: string;
102
+ defaultValue: null;
103
+ group: string;
104
+ };
105
+ };
106
+ category: string;
107
+ packageName: string;
108
+ stylesPanelSections: string[];
109
+ layout: {};
110
+ triggers: {};
111
+ name: string;
112
+ tag: string;
113
+ description: string;
114
+ } | {
115
+ props: {
116
+ isOpen?: undefined;
117
+ defaultIsOpen?: undefined;
118
+ trapFocus?: undefined;
119
+ shouldFlip?: undefined;
120
+ shouldOverlapWithTrigger?: undefined;
121
+ isKeyboardDismissable?: undefined;
122
+ placement?: undefined;
123
+ useRNModal?: undefined;
124
+ onOpen?: undefined;
125
+ onClose?: undefined;
126
+ };
127
+ category: string;
128
+ packageName: string;
129
+ stylesPanelSections: string[];
130
+ layout: {};
131
+ triggers: {};
132
+ name: string;
133
+ tag: string;
134
+ description: string;
135
+ })[];
136
+ //# sourceMappingURL=Popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../../../src/mappings/NativeBase/Popover.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4GrB,CAAC"}
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Touchable.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Touchable.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAerB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "47.0.1-17098e.2+17098ef",
3
+ "version": "47.0.1-2aab54.2+2aab543",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "^47.0.1-17098e.2+17098ef",
44
+ "@draftbit/types": "^47.0.1-2aab54.2+2aab543",
45
45
  "@material-ui/core": "^4.11.0",
46
46
  "@material-ui/pickers": "^3.2.10",
47
47
  "@react-native-community/slider": "4.2.4",
@@ -91,5 +91,5 @@
91
91
  ]
92
92
  ]
93
93
  },
94
- "gitHead": "17098ef43f2803aa04abc191f3f193bd8f8e7103"
94
+ "gitHead": "2aab543eb949f77531cbf78bfb3b1bab3ff5d01f"
95
95
  }
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from "react";
1
+ import * as React from "react";
2
2
  import { Text, Pressable, Platform, StyleSheet, ActivityIndicator, } from "react-native";
3
3
  import { withTheme } from "../theming";
4
4
  const CONSTANTS = {
@@ -7,7 +7,7 @@ const CONSTANTS = {
7
7
  padding: 8,
8
8
  icon: 24,
9
9
  };
10
- function Base({ Icon, icon, title, onPress, onLongPress, activeOpacity, disabledOpacity, loading, disabled, style, ...props }) {
10
+ function Base({ Icon, icon, title, onPress, loading, disabled, style, ...props }) {
11
11
  const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...buttonStyles } = StyleSheet.flatten(style || {});
12
12
  const titleStyles = {
13
13
  color,
@@ -28,22 +28,15 @@ function Base({ Icon, icon, title, onPress, onLongPress, activeOpacity, disabled
28
28
  if (textAlign === "right") {
29
29
  buttonStyles.justifyContent = "flex-end";
30
30
  }
31
- const getOpacity = useCallback((pressed) => {
32
- if (disabled) {
33
- return disabledOpacity;
34
- }
35
- else {
36
- if (pressed)
37
- return activeOpacity;
38
- else
39
- return 1;
40
- }
41
- }, [activeOpacity, disabled, disabledOpacity]);
42
- const _style = useCallback(({ pressed }) => [
43
- buttonStyles,
44
- { opacity: getOpacity(pressed) },
45
- ], [getOpacity, buttonStyles]);
46
- return (React.createElement(Pressable, { onPress: onPress, onLongPress: onLongPress, disabled: disabled || loading, style: (styles.base, _style), ...props },
31
+ return (React.createElement(Pressable, { onPress: onPress, disabled: disabled || loading, style: ({ pressed }) => {
32
+ return [
33
+ styles.base,
34
+ {
35
+ opacity: pressed || disabled ? 0.75 : 1,
36
+ },
37
+ buttonStyles,
38
+ ];
39
+ }, ...props },
47
40
  loading ? (React.createElement(ActivityIndicator, { size: "small", color: color, style: styles.loading })) : null,
48
41
  icon && !loading ? (React.createElement(Icon, { name: icon, color: color, style: styles.icon, size: CONSTANTS.icon })) : null,
49
42
  React.createElement(Text, { style: titleStyles }, title)));
@@ -1,14 +1,11 @@
1
- import React, { useCallback } from "react";
1
+ import * as React from "react";
2
2
  import {
3
3
  Text,
4
4
  Pressable,
5
- PressableProps,
6
- PressableStateCallbackType,
7
5
  Platform,
8
6
  StyleSheet,
9
- StyleProp,
10
7
  TextStyle,
11
- ViewStyle,
8
+ PressableProps,
12
9
  ActivityIndicator,
13
10
  } from "react-native";
14
11
 
@@ -30,12 +27,6 @@ type BaseProps = {
30
27
  loading: boolean;
31
28
  style?: TextStyle;
32
29
  onPress: () => void;
33
- onLongPress?: () => void;
34
- activeOpacity?: number;
35
- disabledOpacity?: number;
36
- delayLongPress?: number;
37
- hitSlop?: number;
38
- pressRetentionOffset?: number;
39
30
  icon?: string;
40
31
  } & PressableProps &
41
32
  IconSlot;
@@ -46,29 +37,16 @@ type Props = {
46
37
  loading: boolean;
47
38
  style?: TextStyle;
48
39
  onPress: () => void;
49
- onLongPress?: () => void;
50
- activeOpacity?: number;
51
- disabledOpacity?: number;
52
- delayLongPress?: number;
53
- hitSlop?: number;
54
- pressRetentionOffset?: number;
55
40
  icon?: string;
56
41
  theme: Theme;
57
42
  } & PressableProps &
58
43
  IconSlot;
59
44
 
60
- export type StyleType = (
61
- state: PressableStateCallbackType
62
- ) => StyleProp<ViewStyle>;
63
-
64
45
  function Base({
65
46
  Icon,
66
47
  icon,
67
48
  title,
68
49
  onPress,
69
- onLongPress,
70
- activeOpacity,
71
- disabledOpacity,
72
50
  loading,
73
51
  disabled,
74
52
  style,
@@ -111,31 +89,19 @@ function Base({
111
89
  buttonStyles.justifyContent = "flex-end";
112
90
  }
113
91
 
114
- const getOpacity = useCallback(
115
- (pressed: boolean) => {
116
- if (disabled) {
117
- return disabledOpacity;
118
- } else {
119
- if (pressed) return activeOpacity;
120
- else return 1;
121
- }
122
- },
123
- [activeOpacity, disabled, disabledOpacity]
124
- );
125
- const _style = useCallback<StyleType>(
126
- ({ pressed }) => [
127
- buttonStyles as ViewStyle,
128
- { opacity: getOpacity(pressed) },
129
- ],
130
- [getOpacity, buttonStyles]
131
- );
132
-
133
92
  return (
134
93
  <Pressable
135
94
  onPress={onPress}
136
- onLongPress={onLongPress}
137
95
  disabled={disabled || loading}
138
- style={(styles.base, _style)}
96
+ style={({ pressed }) => {
97
+ return [
98
+ styles.base,
99
+ {
100
+ opacity: pressed || disabled ? 0.75 : 1,
101
+ },
102
+ buttonStyles,
103
+ ];
104
+ }}
139
105
  {...props}
140
106
  >
141
107
  {loading ? (
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Pressable, } from "react-native";
2
+ import { View, StyleSheet, } from "react-native";
3
3
  import { useTheme } from "../../theming";
4
+ import Touchable from "../Touchable";
4
5
  import { usePrevious } from "../../hooks";
5
6
  const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck, color, uncheckedColor, defaultValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", size = 24, style, ...rest }) => {
6
7
  const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
@@ -32,7 +33,7 @@ const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck,
32
33
  onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
33
34
  }
34
35
  };
35
- return (React.createElement(Pressable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
36
+ return (React.createElement(Touchable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
36
37
  React.createElement(Icon, { style: styles.icon, name: internalValue ? checkedIcon : uncheckedIcon, size: size, color: checkboxColor }),
37
38
  React.createElement(View, { style: [StyleSheet.absoluteFill, styles.fillContainer] },
38
39
  React.createElement(View, { style: [
@@ -2,14 +2,14 @@ import * as React from "react";
2
2
  import {
3
3
  View,
4
4
  StyleSheet,
5
+ TouchableHighlightProps,
5
6
  StyleProp,
6
7
  ViewStyle,
7
- Pressable,
8
- PressableProps,
9
8
  } from "react-native";
10
9
  import { useTheme } from "../../theming";
11
10
  import type { IconSlot } from "../../interfaces/Icon";
12
11
 
12
+ import Touchable from "../Touchable";
13
13
  import { usePrevious } from "../../hooks";
14
14
 
15
15
  export interface CheckboxProps {
@@ -27,7 +27,9 @@ export interface CheckboxProps {
27
27
  style?: StyleProp<ViewStyle>;
28
28
  }
29
29
 
30
- const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
30
+ const Checkbox: React.FC<
31
+ CheckboxProps & TouchableHighlightProps & IconSlot
32
+ > = ({
31
33
  Icon,
32
34
  status,
33
35
  disabled = false,
@@ -85,7 +87,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
85
87
  };
86
88
 
87
89
  return (
88
- <Pressable
90
+ <Touchable
89
91
  {...rest}
90
92
  onPress={handlePress}
91
93
  disabled={disabled}
@@ -109,7 +111,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
109
111
  ]}
110
112
  />
111
113
  </View>
112
- </Pressable>
114
+ </Touchable>
113
115
  );
114
116
  };
115
117
 
@@ -0,0 +1,95 @@
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);