@draftbit/core 47.0.0 → 47.0.1-0e56b5.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 (244) hide show
  1. package/lib/commonjs/components/Button.js +31 -22
  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/Justification.js +5 -1
  6. package/lib/commonjs/components/Picker/Picker.js +3 -4
  7. package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
  8. package/lib/commonjs/components/Pressable.js +48 -0
  9. package/lib/commonjs/components/ResizeMode.js +5 -1
  10. package/lib/commonjs/components/Touchable.js +27 -11
  11. package/lib/commonjs/mappings/Button.js +29 -10
  12. package/lib/commonjs/mappings/Pressable.js +52 -0
  13. package/lib/module/components/Button.js +25 -16
  14. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  15. package/lib/module/components/DeprecatedCardWrapper.js +2 -2
  16. package/lib/module/components/DeprecatedFAB.js +2 -3
  17. package/lib/module/components/Justification.js +1 -0
  18. package/lib/module/components/Picker/Picker.js +3 -4
  19. package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
  20. package/lib/module/components/Pressable.js +40 -0
  21. package/lib/module/components/ResizeMode.js +1 -0
  22. package/lib/module/components/Touchable.js +25 -10
  23. package/lib/module/mappings/Button.js +30 -11
  24. package/lib/module/mappings/Pressable.js +45 -0
  25. package/lib/typescript/src/components/Button.d.ts +2 -0
  26. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  27. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  28. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  29. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
  30. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  31. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  32. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  33. package/lib/typescript/src/components/Pressable.d.ts +18 -0
  34. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  35. package/lib/typescript/src/components/Touchable.d.ts +9 -2
  36. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  37. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  38. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  39. package/lib/typescript/src/mappings/Pressable.d.ts +76 -0
  40. package/lib/typescript/src/mappings/Pressable.d.ts.map +1 -0
  41. package/package.json +3 -3
  42. package/src/Provider.js +9 -0
  43. package/src/components/Accordion/AccordionGroup.js +44 -0
  44. package/src/components/Accordion/AccordionItem.js +32 -0
  45. package/src/components/Accordion/index.js +2 -0
  46. package/src/components/ActionSheet/ActionSheet.js +45 -0
  47. package/src/components/ActionSheet/ActionSheetCancel.js +6 -0
  48. package/src/components/ActionSheet/ActionSheetItem.js +30 -0
  49. package/src/components/ActionSheet/index.js +3 -0
  50. package/src/components/AnimatedCircularProgress.js +43 -0
  51. package/src/components/AspectRatio.js +18 -0
  52. package/src/components/AvatarEdit.js +30 -0
  53. package/src/components/Banner.js +109 -0
  54. package/src/components/Button.js +118 -0
  55. package/src/components/Button.tsx +49 -18
  56. package/src/components/Card.js +57 -0
  57. package/src/components/CardBlock.js +54 -0
  58. package/src/components/CardContainer.js +69 -0
  59. package/src/components/CardContainerRating.js +79 -0
  60. package/src/components/CardContainerShortImage.js +33 -0
  61. package/src/components/CardInline.js +36 -0
  62. package/src/components/Carousel.js +68 -0
  63. package/src/components/Checkbox/Checkbox.js +62 -0
  64. package/src/components/Checkbox/Checkbox.tsx +5 -7
  65. package/src/components/Checkbox/CheckboxGroup.js +21 -0
  66. package/src/components/Checkbox/CheckboxGroupRow.js +77 -0
  67. package/src/components/Checkbox/CheckboxRow.js +78 -0
  68. package/src/components/Checkbox/context.js +14 -0
  69. package/src/components/Checkbox/index.js +3 -0
  70. package/src/components/CircleImage.js +8 -0
  71. package/src/components/CircularProgress.js +81 -0
  72. package/src/components/Config.js +64 -0
  73. package/src/components/Container.js +43 -0
  74. package/src/components/DatePicker/DatePicker.js +377 -0
  75. package/src/components/DatePicker/DatePickerComponent.js +13 -0
  76. package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
  77. package/src/components/DatePicker/DatePickerComponentType.js +1 -0
  78. package/src/components/DeprecatedCardWrapper.js +18 -0
  79. package/src/components/DeprecatedCardWrapper.tsx +3 -4
  80. package/src/components/DeprecatedFAB.js +114 -0
  81. package/src/components/DeprecatedFAB.tsx +5 -5
  82. package/src/components/Divider.js +13 -0
  83. package/src/components/Elevation.js +20 -0
  84. package/src/components/FAB.js +46 -0
  85. package/src/components/FieldSearchBarFull.js +53 -0
  86. package/src/components/FormRow.js +19 -0
  87. package/src/components/Header.js +44 -0
  88. package/src/components/HeaderLarge.js +7 -0
  89. package/src/components/HeaderMedium.js +7 -0
  90. package/src/components/HeaderOverline.js +7 -0
  91. package/src/components/IconButton.js +35 -0
  92. package/src/components/Image.js +47 -0
  93. package/src/components/Justification.js +1 -0
  94. package/src/components/Layout.js +50 -0
  95. package/src/components/NumberInput.js +49 -0
  96. package/src/components/Picker/Picker.js +266 -0
  97. package/src/components/Picker/Picker.tsx +4 -4
  98. package/src/components/Picker/PickerComponent.android.js +69 -0
  99. package/src/components/Picker/PickerComponent.ios.js +79 -0
  100. package/src/components/Picker/PickerComponent.ios.tsx +1 -1
  101. package/src/components/Picker/PickerComponent.web.js +70 -0
  102. package/src/components/Picker/PickerTypes.js +1 -0
  103. package/src/components/Portal/Portal.js +35 -0
  104. package/src/components/Portal/PortalConsumer.js +27 -0
  105. package/src/components/Portal/PortalHost.js +107 -0
  106. package/src/components/Portal/PortalManager.js +32 -0
  107. package/src/components/Pressable.js +17 -0
  108. package/src/components/Pressable.tsx +67 -0
  109. package/src/components/ProgressBar.js +118 -0
  110. package/src/components/ProgressCircle.js +13 -0
  111. package/src/components/ProgressIndicator.js +27 -0
  112. package/src/components/RadioButton/RadioButton.js +17 -0
  113. package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
  114. package/src/components/RadioButton/RadioButtonGroup.js +43 -0
  115. package/src/components/RadioButton/RadioButtonRow.js +76 -0
  116. package/src/components/RadioButton/context.js +14 -0
  117. package/src/components/RadioButton/index.js +4 -0
  118. package/src/components/ResizeMode.js +1 -0
  119. package/src/components/Row.js +48 -0
  120. package/src/components/RowBodyIcon.js +8 -0
  121. package/src/components/RowHeadlineImageCaption.js +12 -0
  122. package/src/components/RowHeadlineImageIcon.js +14 -0
  123. package/src/components/SVG.js +13 -0
  124. package/src/components/ScreenContainer.js +34 -0
  125. package/src/components/Slider.js +63 -0
  126. package/src/components/StarRating.js +50 -0
  127. package/src/components/StepIndicator.js +346 -0
  128. package/src/components/Stepper.js +41 -0
  129. package/src/components/Surface.js +32 -0
  130. package/src/components/Swiper/Swiper.js +29 -0
  131. package/src/components/Swiper/SwiperItem.js +9 -0
  132. package/src/components/Swiper/index.js +2 -0
  133. package/src/components/Switch.js +56 -0
  134. package/src/components/Text.js +33 -0
  135. package/src/components/TextField.js +428 -0
  136. package/src/components/ToggleButton.js +39 -0
  137. package/src/components/Touchable.js +17 -0
  138. package/src/components/Touchable.tsx +42 -11
  139. package/src/components/Typography.js +36 -0
  140. package/src/components/useAuthState.js +31 -0
  141. package/src/constants.js +10 -0
  142. package/src/hooks.js +12 -0
  143. package/src/index.js +52 -0
  144. package/src/interfaces/Icon.js +8 -0
  145. package/src/mappings/Accordion.js +41 -0
  146. package/src/mappings/AccordionItem.js +16 -0
  147. package/src/mappings/ActionSheet.js +13 -0
  148. package/src/mappings/ActionSheetCancel.js +19 -0
  149. package/src/mappings/ActionSheetItem.js +23 -0
  150. package/src/mappings/ActivityIndicator.js +58 -0
  151. package/src/mappings/AudioPlayer.js +57 -0
  152. package/src/mappings/AvatarEdit.js +38 -0
  153. package/src/mappings/Banner.js +32 -0
  154. package/src/mappings/BlurView.js +42 -0
  155. package/src/mappings/Button.js +106 -0
  156. package/src/mappings/Button.ts +31 -10
  157. package/src/mappings/Card.js +52 -0
  158. package/src/mappings/CardBlock.js +123 -0
  159. package/src/mappings/CardContainer.js +104 -0
  160. package/src/mappings/CardContainerRating.js +126 -0
  161. package/src/mappings/CardContainerShortImage.js +120 -0
  162. package/src/mappings/CardInline.js +52 -0
  163. package/src/mappings/Carousel.js +19 -0
  164. package/src/mappings/Checkbox.js +46 -0
  165. package/src/mappings/CheckboxGroup.js +26 -0
  166. package/src/mappings/CheckboxRow.js +61 -0
  167. package/src/mappings/CircleImage.js +25 -0
  168. package/src/mappings/Container.js +30 -0
  169. package/src/mappings/CustomCode.js +8 -0
  170. package/src/mappings/DatePicker.js +176 -0
  171. package/src/mappings/Divider.js +27 -0
  172. package/src/mappings/FAB.js +37 -0
  173. package/src/mappings/Fetch.js +13 -0
  174. package/src/mappings/FieldSearchBarFull.js +50 -0
  175. package/src/mappings/FlashList.js +33 -0
  176. package/src/mappings/FlatList.js +24 -0
  177. package/src/mappings/HeaderLarge.js +29 -0
  178. package/src/mappings/HeaderMedium.js +55 -0
  179. package/src/mappings/HeaderOverline.js +55 -0
  180. package/src/mappings/Icon.js +32 -0
  181. package/src/mappings/IconButton.js +35 -0
  182. package/src/mappings/Image.js +35 -0
  183. package/src/mappings/ImageBackground.js +29 -0
  184. package/src/mappings/KeyboardAvoidingView.js +41 -0
  185. package/src/mappings/KeyboardAwareScrollView.js +50 -0
  186. package/src/mappings/Layout.js +200 -0
  187. package/src/mappings/LinearGradient.js +77 -0
  188. package/src/mappings/MapCallout.js +21 -0
  189. package/src/mappings/MapMarker.js +47 -0
  190. package/src/mappings/MapView.js +139 -0
  191. package/src/mappings/Modal.js +42 -0
  192. package/src/mappings/NumberInput.js +254 -0
  193. package/src/mappings/Picker.js +148 -0
  194. package/src/mappings/Pressable.js +52 -0
  195. package/src/mappings/Pressable.ts +63 -0
  196. package/src/mappings/ProgressBar.js +101 -0
  197. package/src/mappings/ProgressCircle.js +109 -0
  198. package/src/mappings/ProgressIndicator.js +181 -0
  199. package/src/mappings/RadioButton.js +51 -0
  200. package/src/mappings/RadioButtonGroup.js +17 -0
  201. package/src/mappings/RadioButtonRow.js +42 -0
  202. package/src/mappings/RowBodyIcon.js +75 -0
  203. package/src/mappings/RowHeadlineImageCaption.js +167 -0
  204. package/src/mappings/RowHeadlineImageIcon.js +99 -0
  205. package/src/mappings/SVG.js +20 -0
  206. package/src/mappings/SafeAreaView.js +33 -0
  207. package/src/mappings/ScrollView.js +31 -0
  208. package/src/mappings/Slider.js +60 -0
  209. package/src/mappings/StarRating.js +43 -0
  210. package/src/mappings/Stepper.js +32 -0
  211. package/src/mappings/Surface.js +14 -0
  212. package/src/mappings/Swiper.js +60 -0
  213. package/src/mappings/SwiperItem.js +8 -0
  214. package/src/mappings/Switch.js +81 -0
  215. package/src/mappings/Text.js +251 -0
  216. package/src/mappings/TextArea.js +274 -0
  217. package/src/mappings/TextField.js +391 -0
  218. package/src/mappings/TextInput.js +402 -0
  219. package/src/mappings/ToggleButton.js +50 -0
  220. package/src/mappings/Video.js +81 -0
  221. package/src/mappings/View.js +207 -0
  222. package/src/mappings/WebView.js +88 -0
  223. package/src/styles/DarkTheme.js +26 -0
  224. package/src/styles/DefaultTheme.js +111 -0
  225. package/src/styles/fonts.js +62 -0
  226. package/src/styles/overlay.js +60 -0
  227. package/src/styles/shadow.js +51 -0
  228. package/src/theming.js +3 -0
  229. package/src/utilities.js +102 -0
  230. package/lib/commonjs/components/DeprecatedButton.js +0 -151
  231. package/lib/commonjs/components/Touchable.web.js +0 -9
  232. package/lib/commonjs/mappings/Touchable.js +0 -20
  233. package/lib/module/components/DeprecatedButton.js +0 -141
  234. package/lib/module/components/Touchable.web.js +0 -2
  235. package/lib/module/mappings/Touchable.js +0 -13
  236. package/lib/typescript/src/components/DeprecatedButton.d.ts +0 -54
  237. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +0 -1
  238. package/lib/typescript/src/components/Touchable.web.d.ts +0 -3
  239. package/lib/typescript/src/components/Touchable.web.d.ts.map +0 -1
  240. package/lib/typescript/src/mappings/Touchable.d.ts +0 -22
  241. package/lib/typescript/src/mappings/Touchable.d.ts.map +0 -1
  242. package/src/components/DeprecatedButton.tsx +0 -214
  243. package/src/components/Touchable.web.tsx +0 -3
  244. package/src/mappings/Touchable.ts +0 -23
@@ -0,0 +1,102 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { isString, isNumber, pick, pickBy, identity } from "lodash";
3
+ export function extractStyles(style) {
4
+ const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
5
+ const textStyles = {
6
+ color,
7
+ fontFamily,
8
+ fontWeight,
9
+ fontSize,
10
+ lineHeight,
11
+ letterSpacing,
12
+ textTransform,
13
+ textAlign,
14
+ textDecorationLine,
15
+ textDecorationColor,
16
+ textDecorationStyle,
17
+ };
18
+ return { viewStyles, textStyles };
19
+ }
20
+ export const borderStyleNames = [
21
+ "borderRadius",
22
+ "borderBottomColor",
23
+ "borderBottomEndRadius",
24
+ "borderBottomLeftRadius",
25
+ "borderBottomRightRadius",
26
+ "borderBottomStartRadius",
27
+ "borderBottomWidth",
28
+ "borderColor",
29
+ "borderEndColor",
30
+ "borderLeftColor",
31
+ "borderLeftWidth",
32
+ "borderRadius",
33
+ "borderRightColor",
34
+ "borderRightWidth",
35
+ "borderStartColor",
36
+ "borderStyle",
37
+ "borderTopColor",
38
+ "borderTopEndRadius",
39
+ "borderTopLeftRadius",
40
+ "borderTopRightRadius",
41
+ "borderTopStartRadius",
42
+ "borderTopWidth",
43
+ "borderWidth",
44
+ ];
45
+ export const marginStyleNames = [
46
+ "margin",
47
+ "marginBottom",
48
+ "marginEnd",
49
+ "marginHorizontal",
50
+ "marginLeft",
51
+ "marginRight",
52
+ "marginStart",
53
+ "marginTop",
54
+ "marginVertical",
55
+ ];
56
+ export function extractBorderAndMarginStyles(style, additionalBorderStyles, additionalMarginStyles) {
57
+ const flatStyle = StyleSheet.flatten(style || {});
58
+ const borderStyles = pickBy(pick(flatStyle, [
59
+ ...borderStyleNames,
60
+ ...(additionalBorderStyles ? additionalBorderStyles : []),
61
+ ]), identity);
62
+ const marginStyles = pickBy(pick(flatStyle, [
63
+ ...marginStyleNames,
64
+ ...(additionalMarginStyles ? additionalMarginStyles : []),
65
+ ]), identity);
66
+ return { borderStyles, marginStyles };
67
+ }
68
+ /**
69
+ * Merges a style object on top of another style object. In React Native,
70
+ * keys with undefined values in a style object will still override styles
71
+ * that appear earlier in a sequence. This avoids that problem.
72
+ *
73
+ * This lets us avoid the `...(something ? { something } : {})` pattern.
74
+ * There doesn't seem to be a better way to do this. These all seem to not
75
+ * work (i.e. they all result in `{ color: undefined }`:
76
+ * `const mergedStyles = [{ color: "red" }, { color: undefined }]`
77
+ * `const mergedStyles = StyleSheet.compose({ color: "red" }, { color: undefined })`
78
+ * `const mergedStyles = StyleSheet.flatten([{ color: "red" }, { color: undefined }])`
79
+ */
80
+ export function applyStyles(baseStyles, stylesToApply) {
81
+ if (!stylesToApply) {
82
+ return;
83
+ }
84
+ const flattenedStyles = StyleSheet.flatten(baseStyles);
85
+ for (const [key, value] of Object.entries(stylesToApply)) {
86
+ if (value != null) {
87
+ flattenedStyles[key] = value;
88
+ }
89
+ }
90
+ return flattenedStyles;
91
+ }
92
+ export function getValueForRadioButton(value) {
93
+ if (isString(value)) {
94
+ return value;
95
+ }
96
+ else if (isNumber(value)) {
97
+ return String(value);
98
+ }
99
+ else {
100
+ throw new Error(`Invalid value: ${value}`);
101
+ }
102
+ }
@@ -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"}