@draftbit/core 47.0.1-ed6e56.2 → 47.1.0

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 (277) 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/DatePicker/DatePicker.js +0 -1
  6. package/lib/commonjs/components/DatePicker/DatePickerComponent.js +9 -3
  7. package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +1 -0
  8. package/lib/commonjs/components/DeprecatedButton.js +3 -27
  9. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  10. package/lib/commonjs/components/Justification.js +1 -5
  11. package/lib/commonjs/components/Pressable.js +37 -0
  12. package/lib/commonjs/components/ResizeMode.js +1 -5
  13. package/lib/commonjs/components/Swiper/Swiper.js +2 -0
  14. package/lib/commonjs/components/Touchable.js +8 -3
  15. package/lib/commonjs/index.js +7 -0
  16. package/lib/commonjs/mappings/Button.js +39 -10
  17. package/lib/commonjs/mappings/FlashList.js +45 -2
  18. package/lib/commonjs/mappings/FlatList.js +12 -0
  19. package/lib/commonjs/mappings/Swiper.js +2 -0
  20. package/lib/commonjs/mappings/Touchable.js +47 -7
  21. package/lib/module/components/Button.js +3 -3
  22. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  23. package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
  24. package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
  25. package/lib/module/components/DatePicker/DatePicker.js +0 -1
  26. package/lib/module/components/DatePicker/DatePickerComponent.js +9 -3
  27. package/lib/module/components/DatePicker/DatePickerComponent.web.js +1 -0
  28. package/lib/module/components/DeprecatedButton.js +4 -28
  29. package/lib/module/components/DeprecatedFAB.js +2 -3
  30. package/lib/module/components/Justification.js +0 -1
  31. package/lib/module/components/Pressable.js +30 -0
  32. package/lib/module/components/ResizeMode.js +0 -1
  33. package/lib/module/components/Swiper/Swiper.js +2 -0
  34. package/lib/module/components/Touchable.js +8 -3
  35. package/lib/module/index.js +1 -0
  36. package/lib/module/mappings/Button.js +40 -11
  37. package/lib/module/mappings/FlashList.js +46 -3
  38. package/lib/module/mappings/FlatList.js +13 -1
  39. package/lib/module/mappings/Swiper.js +3 -1
  40. package/lib/module/mappings/Touchable.js +49 -9
  41. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  42. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  43. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  44. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  45. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  46. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  47. package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts.map +1 -1
  48. package/lib/typescript/src/components/DatePicker/DatePickerComponent.web.d.ts.map +1 -1
  49. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +0 -2
  50. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
  51. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  52. package/lib/typescript/src/components/DeprecatedButton.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/Pressable.d.ts +10 -0
  56. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  57. package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
  58. package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Touchable.d.ts +5 -6
  60. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  61. package/lib/typescript/src/index.d.ts +1 -0
  62. package/lib/typescript/src/index.d.ts.map +1 -1
  63. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  64. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  65. package/lib/typescript/src/mappings/FlashList.d.ts +112 -2
  66. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  67. package/lib/typescript/src/mappings/FlatList.d.ts +42 -0
  68. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  69. package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
  70. package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
  71. package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
  72. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  73. package/package.json +6 -6
  74. package/src/components/Button.tsx +14 -4
  75. package/src/components/Checkbox/Checkbox.tsx +5 -7
  76. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  77. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  78. package/src/components/DatePicker/DatePicker.tsx +0 -1
  79. package/src/components/DatePicker/DatePickerComponent.tsx +11 -3
  80. package/src/components/DatePicker/DatePickerComponent.web.tsx +1 -0
  81. package/src/components/DatePicker/DatePickerComponentType.ts +0 -9
  82. package/src/components/DeprecatedButton.tsx +7 -31
  83. package/src/components/DeprecatedFAB.tsx +5 -5
  84. package/src/components/Pressable.tsx +44 -0
  85. package/src/components/Swiper/Swiper.tsx +3 -0
  86. package/src/components/Touchable.tsx +11 -7
  87. package/src/index.tsx +1 -0
  88. package/src/mappings/Button.ts +41 -10
  89. package/src/mappings/FlashList.ts +82 -30
  90. package/src/mappings/FlatList.ts +16 -0
  91. package/src/mappings/Swiper.ts +4 -0
  92. package/src/mappings/Touchable.ts +53 -6
  93. package/lib/commonjs/components/DatePicker/DatePickerInput.js +0 -133
  94. package/lib/module/components/DatePicker/DatePickerInput.js +0 -123
  95. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts +0 -18
  96. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts.map +0 -1
  97. package/src/Provider.js +0 -9
  98. package/src/components/Accordion/AccordionGroup.js +0 -44
  99. package/src/components/Accordion/AccordionItem.js +0 -32
  100. package/src/components/Accordion/index.js +0 -2
  101. package/src/components/ActionSheet/ActionSheet.js +0 -45
  102. package/src/components/ActionSheet/ActionSheetCancel.js +0 -6
  103. package/src/components/ActionSheet/ActionSheetItem.js +0 -30
  104. package/src/components/ActionSheet/index.js +0 -3
  105. package/src/components/AnimatedCircularProgress.js +0 -43
  106. package/src/components/AspectRatio.js +0 -18
  107. package/src/components/AvatarEdit.js +0 -30
  108. package/src/components/Banner.js +0 -109
  109. package/src/components/Button.js +0 -114
  110. package/src/components/Card.js +0 -57
  111. package/src/components/CardBlock.js +0 -54
  112. package/src/components/CardContainer.js +0 -69
  113. package/src/components/CardContainerRating.js +0 -79
  114. package/src/components/CardContainerShortImage.js +0 -33
  115. package/src/components/CardInline.js +0 -36
  116. package/src/components/Carousel.js +0 -68
  117. package/src/components/Checkbox/Checkbox.js +0 -63
  118. package/src/components/Checkbox/CheckboxGroup.js +0 -21
  119. package/src/components/Checkbox/CheckboxGroupRow.js +0 -77
  120. package/src/components/Checkbox/CheckboxRow.js +0 -78
  121. package/src/components/Checkbox/context.js +0 -14
  122. package/src/components/Checkbox/index.js +0 -3
  123. package/src/components/CircleImage.js +0 -8
  124. package/src/components/CircularProgress.js +0 -81
  125. package/src/components/Config.js +0 -64
  126. package/src/components/Container.js +0 -43
  127. package/src/components/DatePicker/DatePicker.js +0 -377
  128. package/src/components/DatePicker/DatePickerComponent.js +0 -11
  129. package/src/components/DatePicker/DatePickerComponent.web.js +0 -30
  130. package/src/components/DatePicker/DatePickerComponentType.js +0 -1
  131. package/src/components/DatePicker/DatePickerInput.js +0 -97
  132. package/src/components/DatePicker/DatePickerInput.tsx +0 -195
  133. package/src/components/DeprecatedButton.js +0 -95
  134. package/src/components/DeprecatedCardWrapper.js +0 -18
  135. package/src/components/DeprecatedFAB.js +0 -115
  136. package/src/components/Divider.js +0 -13
  137. package/src/components/Elevation.js +0 -20
  138. package/src/components/FAB.js +0 -46
  139. package/src/components/FieldSearchBarFull.js +0 -53
  140. package/src/components/FormRow.js +0 -19
  141. package/src/components/Header.js +0 -44
  142. package/src/components/HeaderLarge.js +0 -7
  143. package/src/components/HeaderMedium.js +0 -7
  144. package/src/components/HeaderOverline.js +0 -7
  145. package/src/components/IconButton.js +0 -35
  146. package/src/components/Image.js +0 -47
  147. package/src/components/Justification.js +0 -1
  148. package/src/components/Layout.js +0 -50
  149. package/src/components/NumberInput.js +0 -49
  150. package/src/components/Picker/Picker.js +0 -267
  151. package/src/components/Picker/PickerComponent.android.js +0 -69
  152. package/src/components/Picker/PickerComponent.ios.js +0 -79
  153. package/src/components/Picker/PickerComponent.web.js +0 -70
  154. package/src/components/Picker/PickerTypes.js +0 -1
  155. package/src/components/Portal/Portal.js +0 -35
  156. package/src/components/Portal/PortalConsumer.js +0 -27
  157. package/src/components/Portal/PortalHost.js +0 -107
  158. package/src/components/Portal/PortalManager.js +0 -32
  159. package/src/components/ProgressBar.js +0 -118
  160. package/src/components/ProgressCircle.js +0 -13
  161. package/src/components/ProgressIndicator.js +0 -27
  162. package/src/components/RadioButton/RadioButton.js +0 -17
  163. package/src/components/RadioButton/RadioButtonFieldGroup.js +0 -17
  164. package/src/components/RadioButton/RadioButtonGroup.js +0 -43
  165. package/src/components/RadioButton/RadioButtonRow.js +0 -76
  166. package/src/components/RadioButton/context.js +0 -14
  167. package/src/components/RadioButton/index.js +0 -4
  168. package/src/components/ResizeMode.js +0 -1
  169. package/src/components/Row.js +0 -48
  170. package/src/components/RowBodyIcon.js +0 -8
  171. package/src/components/RowHeadlineImageCaption.js +0 -12
  172. package/src/components/RowHeadlineImageIcon.js +0 -14
  173. package/src/components/SVG.js +0 -13
  174. package/src/components/ScreenContainer.js +0 -34
  175. package/src/components/Slider.js +0 -63
  176. package/src/components/StarRating.js +0 -50
  177. package/src/components/StepIndicator.js +0 -346
  178. package/src/components/Stepper.js +0 -41
  179. package/src/components/Surface.js +0 -32
  180. package/src/components/Swiper/Swiper.js +0 -29
  181. package/src/components/Swiper/SwiperItem.js +0 -9
  182. package/src/components/Swiper/index.js +0 -2
  183. package/src/components/Switch.js +0 -56
  184. package/src/components/Text.js +0 -33
  185. package/src/components/TextField.js +0 -428
  186. package/src/components/ToggleButton.js +0 -39
  187. package/src/components/Touchable.js +0 -12
  188. package/src/components/Touchable.web.js +0 -2
  189. package/src/components/Typography.js +0 -36
  190. package/src/components/useAuthState.js +0 -31
  191. package/src/constants.js +0 -10
  192. package/src/hooks.js +0 -12
  193. package/src/index.js +0 -52
  194. package/src/interfaces/Icon.js +0 -8
  195. package/src/mappings/Accordion.js +0 -41
  196. package/src/mappings/AccordionItem.js +0 -16
  197. package/src/mappings/ActionSheet.js +0 -13
  198. package/src/mappings/ActionSheetCancel.js +0 -19
  199. package/src/mappings/ActionSheetItem.js +0 -23
  200. package/src/mappings/ActivityIndicator.js +0 -58
  201. package/src/mappings/AudioPlayer.js +0 -57
  202. package/src/mappings/AvatarEdit.js +0 -38
  203. package/src/mappings/Banner.js +0 -32
  204. package/src/mappings/BlurView.js +0 -42
  205. package/src/mappings/Button.js +0 -87
  206. package/src/mappings/Card.js +0 -52
  207. package/src/mappings/CardBlock.js +0 -123
  208. package/src/mappings/CardContainer.js +0 -104
  209. package/src/mappings/CardContainerRating.js +0 -126
  210. package/src/mappings/CardContainerShortImage.js +0 -120
  211. package/src/mappings/CardInline.js +0 -52
  212. package/src/mappings/Carousel.js +0 -19
  213. package/src/mappings/Checkbox.js +0 -46
  214. package/src/mappings/CheckboxGroup.js +0 -26
  215. package/src/mappings/CheckboxRow.js +0 -61
  216. package/src/mappings/CircleImage.js +0 -25
  217. package/src/mappings/Container.js +0 -30
  218. package/src/mappings/CustomCode.js +0 -8
  219. package/src/mappings/DatePicker.js +0 -176
  220. package/src/mappings/Divider.js +0 -27
  221. package/src/mappings/FAB.js +0 -37
  222. package/src/mappings/Fetch.js +0 -13
  223. package/src/mappings/FieldSearchBarFull.js +0 -50
  224. package/src/mappings/FlashList.js +0 -33
  225. package/src/mappings/FlatList.js +0 -24
  226. package/src/mappings/HeaderLarge.js +0 -29
  227. package/src/mappings/HeaderMedium.js +0 -55
  228. package/src/mappings/HeaderOverline.js +0 -55
  229. package/src/mappings/Icon.js +0 -32
  230. package/src/mappings/IconButton.js +0 -35
  231. package/src/mappings/Image.js +0 -35
  232. package/src/mappings/ImageBackground.js +0 -29
  233. package/src/mappings/KeyboardAvoidingView.js +0 -41
  234. package/src/mappings/KeyboardAwareScrollView.js +0 -50
  235. package/src/mappings/Layout.js +0 -200
  236. package/src/mappings/LinearGradient.js +0 -77
  237. package/src/mappings/MapCallout.js +0 -21
  238. package/src/mappings/MapMarker.js +0 -47
  239. package/src/mappings/MapView.js +0 -139
  240. package/src/mappings/Modal.js +0 -42
  241. package/src/mappings/NumberInput.js +0 -254
  242. package/src/mappings/Picker.js +0 -148
  243. package/src/mappings/ProgressBar.js +0 -101
  244. package/src/mappings/ProgressCircle.js +0 -109
  245. package/src/mappings/ProgressIndicator.js +0 -181
  246. package/src/mappings/RadioButton.js +0 -51
  247. package/src/mappings/RadioButtonGroup.js +0 -17
  248. package/src/mappings/RadioButtonRow.js +0 -42
  249. package/src/mappings/RowBodyIcon.js +0 -75
  250. package/src/mappings/RowHeadlineImageCaption.js +0 -167
  251. package/src/mappings/RowHeadlineImageIcon.js +0 -99
  252. package/src/mappings/SVG.js +0 -20
  253. package/src/mappings/SafeAreaView.js +0 -33
  254. package/src/mappings/ScrollView.js +0 -31
  255. package/src/mappings/Slider.js +0 -60
  256. package/src/mappings/StarRating.js +0 -43
  257. package/src/mappings/Stepper.js +0 -32
  258. package/src/mappings/Surface.js +0 -14
  259. package/src/mappings/Swiper.js +0 -60
  260. package/src/mappings/SwiperItem.js +0 -8
  261. package/src/mappings/Switch.js +0 -81
  262. package/src/mappings/Text.js +0 -251
  263. package/src/mappings/TextArea.js +0 -274
  264. package/src/mappings/TextField.js +0 -391
  265. package/src/mappings/TextInput.js +0 -402
  266. package/src/mappings/ToggleButton.js +0 -50
  267. package/src/mappings/Touchable.js +0 -17
  268. package/src/mappings/Video.js +0 -81
  269. package/src/mappings/View.js +0 -207
  270. package/src/mappings/WebView.js +0 -88
  271. package/src/styles/DarkTheme.js +0 -26
  272. package/src/styles/DefaultTheme.js +0 -111
  273. package/src/styles/fonts.js +0 -62
  274. package/src/styles/overlay.js +0 -60
  275. package/src/styles/shadow.js +0 -51
  276. package/src/theming.js +0 -3
  277. package/src/utilities.js +0 -102
@@ -1,195 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- View,
4
- StyleProp,
5
- ViewStyle,
6
- TextInputProps,
7
- TextInput,
8
- Platform,
9
- } from "react-native";
10
- import { useSafeAreaInsets } from "react-native-safe-area-context";
11
-
12
- import dateFormat from "dateformat";
13
- import Portal from "../Portal/Portal";
14
- import Touchable from "../Touchable";
15
- import DateTimePicker from "./DatePickerComponent";
16
-
17
- type Props = {
18
- style?: StyleProp<ViewStyle>;
19
- date?: Date;
20
- format?: string;
21
- onDateChange?: (data?: Date) => void;
22
- defaultValue?: Date;
23
- disabled?: boolean;
24
- mode?: "date" | "time" | "datetime";
25
- androidDisplay: "default" | "spinner" | "calendar" | "clock";
26
- iosDisplay: "default" | "spinner" | "compact" | "inline";
27
- webDisplay: "dialog" | "inline";
28
- placeholder?: string;
29
- } & TextInputProps;
30
-
31
- const MONTHS = [
32
- "January",
33
- "February",
34
- "March",
35
- "April",
36
- "May",
37
- "June",
38
- "July",
39
- "August",
40
- "September",
41
- "October",
42
- "November",
43
- "December",
44
- ];
45
-
46
- const DatePickerInput: React.FC<React.PropsWithChildren<Props>> = ({
47
- style,
48
- date,
49
- onDateChange = () => {},
50
- defaultValue,
51
- disabled = false,
52
- mode = "date",
53
- format,
54
- androidDisplay = "default",
55
- iosDisplay = "default",
56
- webDisplay = "dialog",
57
- placeholder,
58
- ...props
59
- }) => {
60
- const [value, setValue] = React.useState<any>(date || defaultValue);
61
-
62
- React.useEffect(() => {
63
- if (defaultValue != null) {
64
- setValue(defaultValue);
65
- }
66
- }, [defaultValue]);
67
-
68
- const [pickerVisible, setPickerVisible] = React.useState(false);
69
- const [focused, setFocused] = React.useState<boolean>(false);
70
-
71
- const getValidDate = (): Date => {
72
- if (!value) {
73
- return new Date();
74
- }
75
- return typeof value?.getMonth === "function" ? value : new Date();
76
- };
77
-
78
- const formatDate = (): string => {
79
- if (!value) return "";
80
- let newDate = getValidDate();
81
-
82
- if (format) return dateFormat(newDate, format);
83
-
84
- if (mode === "time") {
85
- return `${newDate.toLocaleTimeString()}`;
86
- }
87
-
88
- if (mode === "datetime") {
89
- return `${newDate.toLocaleString()}`;
90
- }
91
-
92
- return `${
93
- MONTHS[newDate.getMonth()]
94
- } ${newDate.getDate()}, ${newDate.getFullYear()}`;
95
- };
96
-
97
- const toggleVisibility = async () => {
98
- setPickerVisible(!pickerVisible);
99
- focused ? _handleBlur() : _handleFocus();
100
- };
101
-
102
- const insets = useSafeAreaInsets();
103
-
104
- React.useEffect(() => {
105
- setValue(date);
106
- }, [date]);
107
-
108
- const _handleFocus = () => {
109
- if (disabled) {
110
- return;
111
- }
112
-
113
- setFocused(true);
114
- };
115
-
116
- const _handleBlur = () => {
117
- if (disabled) {
118
- return;
119
- }
120
- setFocused(false);
121
- };
122
-
123
- return (
124
- <View>
125
- <Touchable disabled={disabled} onPress={toggleVisibility}>
126
- <TextInput
127
- value={formatDate()}
128
- placeholder={placeholder}
129
- editable={!disabled}
130
- onFocus={_handleFocus}
131
- onBlur={_handleBlur}
132
- style={style}
133
- {...props}
134
- />
135
- </Touchable>
136
- {pickerVisible && (
137
- <Portal>
138
- <View
139
- style={{
140
- paddingTop: insets.top,
141
- paddingBottom: insets.bottom,
142
- paddingLeft: insets.left,
143
- paddingRight: insets.right,
144
- }}
145
- >
146
- {Platform.OS === "web" && (
147
- <DateTimePicker
148
- value={getValidDate()}
149
- mode={mode}
150
- isVisible={pickerVisible}
151
- toggleVisibility={toggleVisibility}
152
- onChange={(_event: any, data: any) => {
153
- toggleVisibility();
154
- setValue(data);
155
- onDateChange(data);
156
- }}
157
- />
158
- )}
159
- {Platform.OS === "ios" && (
160
- <DateTimePicker
161
- value={getValidDate()}
162
- mode={mode}
163
- displayMode={iosDisplay}
164
- isVisible={pickerVisible}
165
- toggleVisibility={toggleVisibility}
166
- onChange={(_event: any, data: any) => {
167
- toggleVisibility();
168
- setValue(data);
169
- onDateChange(data);
170
- }}
171
- />
172
- )}
173
- {Platform.OS === "android" && (
174
- <DateTimePicker
175
- value={getValidDate()}
176
- mode={mode}
177
- variant={webDisplay}
178
- displayMode={androidDisplay}
179
- isVisible={pickerVisible}
180
- toggleVisibility={toggleVisibility}
181
- onChange={(_event: any, data: any) => {
182
- toggleVisibility();
183
- setValue(data);
184
- onDateChange(data);
185
- }}
186
- />
187
- )}
188
- </View>
189
- </Portal>
190
- )}
191
- </View>
192
- );
193
- };
194
-
195
- export default DatePickerInput;
@@ -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);
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import { withTheme } from "../theming";
3
- import Touchable from "./Touchable";
4
- const getWidth = (numColumns) => {
5
- switch (numColumns) {
6
- case 1:
7
- return "33%";
8
- case 2:
9
- return "50%";
10
- default:
11
- return "100%";
12
- }
13
- };
14
- const Card = ({ numColumns = 3, children, onPress, style, ...rest }) => {
15
- const width = getWidth(numColumns);
16
- return (React.createElement(Touchable, { disabled: !onPress, onPress: onPress, style: [style, { width }], ...rest }, children));
17
- };
18
- export default withTheme(Card);
@@ -1,115 +0,0 @@
1
- import * as React from "react";
2
- import { ActivityIndicator, View, StyleSheet, } from "react-native";
3
- import color from "color";
4
- import Config from "./Config";
5
- import Text from "./Text";
6
- import Touchable from "./Touchable";
7
- import Elevation from "./Elevation";
8
- import { withTheme } from "../theming";
9
- const FAB = ({ Icon, icon, disabled = false, type = "solid", loading = false, color: colorOverride, label, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
10
- let backgroundColor, borderColor, textColor, borderWidth;
11
- const buttonColor = colorOverride || colors.primary;
12
- if (type === "standard" || type === "extended" || type === "fixed") {
13
- backgroundColor = buttonColor;
14
- if (disabled) {
15
- textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
16
- }
17
- else {
18
- textColor = colors.surface;
19
- }
20
- }
21
- else {
22
- backgroundColor = "transparent";
23
- if (disabled) {
24
- textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
25
- }
26
- else {
27
- textColor = buttonColor;
28
- }
29
- }
30
- if (type === "outline") {
31
- if (disabled) {
32
- borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
33
- }
34
- else {
35
- borderColor = buttonColor;
36
- }
37
- borderWidth = StyleSheet.hairlineWidth;
38
- }
39
- else {
40
- borderColor = "transparent";
41
- borderWidth = 0;
42
- }
43
- const buttonStyle = {
44
- backgroundColor,
45
- borderColor,
46
- borderWidth,
47
- borderRadius: roundness,
48
- alignItems: "center",
49
- justifyContent: "center",
50
- };
51
- const buttonStyles = [styles.button, buttonStyle];
52
- const contentStyle = [styles.content];
53
- const textStyle = {
54
- textAlign: "center",
55
- color: textColor,
56
- };
57
- const iconStyle = [
58
- styles.icon,
59
- {
60
- width: Config.buttonIconSize,
61
- },
62
- ];
63
- if (type === "standard" || type === "outline") {
64
- buttonStyle.width = Config.FABSize;
65
- buttonStyle.height = Config.FABSize;
66
- buttonStyle.borderRadius = Config.FABBorderRadius;
67
- contentStyle.push({
68
- width: Config.FABSize,
69
- height: Config.FABSize,
70
- });
71
- }
72
- if (type === "extended" || type === "fixed") {
73
- iconStyle.push({
74
- marginLeft: 16,
75
- marginRight: -8,
76
- });
77
- textStyle.margin = 16;
78
- }
79
- if (type === "fixed") {
80
- buttonStyles.push({
81
- height: Config.FABFixedHeight,
82
- alignSelf: "stretch",
83
- });
84
- }
85
- return (React.createElement(Elevation, { style: [{ elevation }, style] },
86
- React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: buttonStyles },
87
- React.createElement(View, { style: styles.content },
88
- icon && loading !== true ? (React.createElement(View, { style: iconStyle },
89
- React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
90
- loading ? (React.createElement(ActivityIndicator, { size: "small", color: textColor, style: iconStyle })) : null,
91
- label ? (React.createElement(Text, { numberOfLines: 1, style: [textStyle, typography.button] }, label)) : null))));
92
- };
93
- const styles = StyleSheet.create({
94
- button: {
95
- borderStyle: "solid",
96
- },
97
- content: {
98
- flexDirection: "row",
99
- alignItems: "center",
100
- justifyContent: "center",
101
- },
102
- icon: {
103
- alignItems: "center",
104
- justifyContent: "center",
105
- width: Config.buttonIconSize,
106
- },
107
- fixed: {
108
- left: 0,
109
- right: 0,
110
- bottom: 0,
111
- height: 64,
112
- borderRadius: 0,
113
- },
114
- });
115
- export default withTheme(FAB);
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- import { StyleSheet, View } from "react-native";
3
- import { withTheme } from "../theming";
4
- const Divider = ({ style, color, theme: { colors }, ...rest }) => {
5
- return (React.createElement(View, { style: [
6
- {
7
- backgroundColor: color || colors.divider,
8
- height: StyleSheet.hairlineWidth,
9
- },
10
- style,
11
- ], ...rest }));
12
- };
13
- export default withTheme(Divider);
@@ -1,20 +0,0 @@
1
- import * as React from "react";
2
- import { Animated, StyleSheet, View, } from "react-native";
3
- import shadow from "../styles/shadow";
4
- import { withTheme } from "../theming";
5
- /* directly copied from https://github.com/callstack/react-native-paper/blob/main/src/components/Surface.tsx#L62 */
6
- const Elevation = ({ style, theme, children, ...rest }) => {
7
- const { elevation = 4, borderRadius: radius } = StyleSheet.flatten(style) || {};
8
- const { colors } = theme;
9
- const borderRadius = radius;
10
- return (React.createElement(Animated.View, { ...rest, style: [
11
- {
12
- borderRadius,
13
- backgroundColor: colors.surface,
14
- },
15
- elevation ? shadow(elevation) : null,
16
- style,
17
- ] },
18
- React.createElement(View, { style: { overflow: "hidden", borderRadius } }, children)));
19
- };
20
- export default withTheme(Elevation);
@@ -1,46 +0,0 @@
1
- import * as React from "react";
2
- import { View, StyleSheet, Pressable, ActivityIndicator, Platform, } from "react-native";
3
- import { withTheme } from "../theming";
4
- const FAB = ({ onPress, disabled, loading, iconName = "MaterialIcons/add", style, theme, iconColor, bgColor, size = 50, Icon, ...props }) => {
5
- const backgroundColor = bgColor || theme.colors.primary;
6
- const color = iconColor || "#FFF";
7
- return (React.createElement(View, { style: [
8
- {
9
- width: size,
10
- height: size,
11
- borderRadius: size / 2,
12
- overflow: "hidden",
13
- },
14
- style,
15
- ] },
16
- React.createElement(Pressable, { onPress: onPress, disabled: loading || disabled, android_ripple: {
17
- color: "#333",
18
- radius: size / 4,
19
- }, style: ({ pressed }) => {
20
- return [
21
- styles.button,
22
- {
23
- opacity: pressed || disabled ? 0.75 : 1,
24
- width: size,
25
- height: size,
26
- borderRadius: size / 2,
27
- backgroundColor,
28
- },
29
- ];
30
- }, ...props },
31
- React.createElement(View, null, loading ? (React.createElement(ActivityIndicator, { style: size > 50 ? { marginTop: 2, marginLeft: 2 } : undefined, size: size <= 50 ? "small" : "large", color: color })) : (React.createElement(Icon, { name: iconName, size: size, color: color }))))));
32
- };
33
- const styles = StyleSheet.create({
34
- button: {
35
- backgroundColor: "#5a45ff",
36
- justifyContent: "center",
37
- alignItems: "center",
38
- ...Platform.select({
39
- web: {
40
- cursor: "pointer",
41
- userSelect: "none",
42
- },
43
- }),
44
- },
45
- });
46
- export default withTheme(FAB);
@@ -1,53 +0,0 @@
1
- import * as React from "react";
2
- import { View, TextInput, StyleSheet, } from "react-native";
3
- import { withTheme } from "../theming";
4
- import Config from "./Config";
5
- const FieldSearchBarFull = ({ showIcon, Icon, icon = "search", placeholder = "", style, theme: { colors, typography }, onChange: changeOverride, onSubmit: submitOverride, value, defaultValue, }) => {
6
- const [focused, setIsFocused] = React.useState(false);
7
- const onBlur = () => {
8
- setIsFocused(false);
9
- };
10
- const [internalValue, setInternalValue] = React.useState(value || defaultValue);
11
- React.useEffect(() => {
12
- if (value != null) {
13
- setInternalValue(value);
14
- }
15
- }, [value]);
16
- React.useEffect(() => {
17
- if (defaultValue != null) {
18
- setInternalValue(defaultValue);
19
- }
20
- }, [defaultValue]);
21
- const onChange = React.useCallback((text) => {
22
- changeOverride && changeOverride(text);
23
- }, [changeOverride]);
24
- const onFocus = () => {
25
- setIsFocused(true);
26
- };
27
- const onSubmit = (e) => {
28
- submitOverride && submitOverride(e);
29
- };
30
- const { lineHeight, ...typeStyles } = typography.body2; // eslint-disable-line @typescript-eslint/no-unused-vars
31
- const handleChangeText = (newValue) => {
32
- setInternalValue(newValue);
33
- if (onChange) {
34
- onChange(newValue);
35
- }
36
- };
37
- return (React.createElement(View, { style: [styles.container, style] },
38
- showIcon && (React.createElement(Icon, { name: icon, size: Config.fieldSearchBarFullIconSize, color: focused ? colors.primary : colors.light })),
39
- React.createElement(View, { style: { marginLeft: showIcon ? 12 : 0, flex: 1 } },
40
- React.createElement(TextInput, { clearButtonMode: "while-editing", placeholder: placeholder, value: internalValue, onBlur: onBlur, onFocus: onFocus, onChangeText: handleChangeText, onSubmitEditing: onSubmit, placeholderTextColor: colors.light, style: [
41
- {
42
- color: colors.medium,
43
- },
44
- typeStyles,
45
- ] }))));
46
- };
47
- const styles = StyleSheet.create({
48
- container: {
49
- flexDirection: "row",
50
- alignItems: "center",
51
- },
52
- });
53
- export default withTheme(FieldSearchBarFull);
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import { Text, StyleSheet } from "react-native";
3
- import { extractStyles } from "../utilities";
4
- import Touchable from "./Touchable";
5
- export default function FormRow({ disabled, direction, children, label, style, onPress, ...rest }) {
6
- const { textStyles, viewStyles } = extractStyles(style);
7
- return (React.createElement(Touchable, { disabled: disabled, onPress: onPress, style: [styles.row, { flexDirection: direction }, viewStyles], ...rest },
8
- React.createElement(Text, { style: textStyles }, label),
9
- children));
10
- }
11
- const styles = StyleSheet.create({
12
- row: {
13
- marginLeft: 8,
14
- marginRight: 8,
15
- flexDirection: "row",
16
- justifyContent: "space-between",
17
- alignItems: "center",
18
- },
19
- });
@@ -1,44 +0,0 @@
1
- import * as React from "react";
2
- import { View, Text, StyleSheet, } from "react-native";
3
- import { withTheme } from "../theming";
4
- import Divider from "./Divider";
5
- import Touchable from "./Touchable";
6
- import Config from "./Config";
7
- const Header = ({ Icon, titleTypeStyle, titleColor, title, buttonText, dividerTopMargin, icon, onPress, style, theme: { colors, typography }, }) => {
8
- return (React.createElement(View, { style: [styles.container, style] },
9
- React.createElement(View, { style: styles.topContainer },
10
- React.createElement(Text, { style: [
11
- titleTypeStyle,
12
- {
13
- color: titleColor,
14
- flex: 1,
15
- },
16
- ], numberOfLines: 1 }, title),
17
- onPress && (React.createElement(Touchable, { style: { alignSelf: "center", marginLeft: 12 }, onPress: onPress },
18
- React.createElement(View, { style: styles.buttonContainer },
19
- React.createElement(Text, { style: [
20
- typography.subtitle2,
21
- {
22
- color: colors.light,
23
- marginRight: 8,
24
- },
25
- ], numberOfLines: 1 }, buttonText),
26
- React.createElement(Icon, { name: icon, size: Config.headerIconSize, color: colors.light }))))),
27
- React.createElement(Divider, { style: { marginTop: dividerTopMargin || 16 } })));
28
- };
29
- const styles = StyleSheet.create({
30
- container: {
31
- alignSelf: "stretch",
32
- },
33
- topContainer: {
34
- flexDirection: "row",
35
- justifyContent: "space-between",
36
- alignItems: "center",
37
- },
38
- buttonContainer: {
39
- flexDirection: "row",
40
- justifyContent: "center",
41
- alignItems: "center",
42
- },
43
- });
44
- export default withTheme(Header);
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { withTheme } from "../theming";
3
- import Header from "./Header";
4
- const HeaderLarge = ({ Icon, title, buttonText, icon, onPress = () => { }, style, theme: { colors, typography }, }) => {
5
- return (React.createElement(Header, { Icon: Icon, titleTypeStyle: typography.headline4, titleColor: colors.strong, title: title, buttonText: buttonText, icon: icon, onPress: onPress, style: style }));
6
- };
7
- export default withTheme(HeaderLarge);
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { withTheme } from "../theming";
3
- import Header from "./Header";
4
- const HeaderMedium = ({ Icon, title, buttonText, icon, onPress = () => { }, style, theme: { colors, typography }, }) => {
5
- return (React.createElement(Header, { Icon: Icon, titleTypeStyle: typography.headline6, titleColor: colors.strong, title: title, buttonText: buttonText, icon: icon, onPress: onPress, style: style }));
6
- };
7
- export default withTheme(HeaderMedium);
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { withTheme } from "../theming";
3
- import Header from "./Header";
4
- const HeaderOverline = ({ Icon, title, buttonText, icon, onPress = () => { }, style, theme: { colors, typography }, }) => {
5
- return (React.createElement(Header, { Icon: Icon, titleTypeStyle: typography.overline, titleColor: colors.light, title: title && title.toUpperCase(), buttonText: buttonText, icon: icon, dividerTopMargin: 12, onPress: onPress, style: style }));
6
- };
7
- export default withTheme(HeaderOverline);