@draftbit/core 43.4.10 → 43.4.11-ca8fc3.1

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 (198) hide show
  1. package/lib/commonjs/components/Accordion/AccordionItem.js +21 -5
  2. package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
  3. package/lib/commonjs/components/Elevation.js +14 -3
  4. package/lib/commonjs/components/Elevation.js.map +1 -1
  5. package/lib/commonjs/components/FAB.js +19 -5
  6. package/lib/commonjs/components/FAB.js.map +1 -1
  7. package/lib/commonjs/components/Justification.js +3 -0
  8. package/lib/commonjs/components/ResizeMode.js +3 -0
  9. package/lib/commonjs/mappings/Icon.js +3 -1
  10. package/lib/commonjs/mappings/Icon.js.map +1 -1
  11. package/lib/commonjs/mappings/KeyboardAwareScrollView.js +48 -0
  12. package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -0
  13. package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
  14. package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
  15. package/lib/module/components/Justification.js +1 -1
  16. package/lib/module/components/Picker/PickerTypes.js.map +1 -1
  17. package/lib/module/components/ResizeMode.js +1 -1
  18. package/lib/module/components/Typography.js.map +1 -1
  19. package/lib/module/mappings/Icon.js +3 -1
  20. package/lib/module/mappings/Icon.js.map +1 -1
  21. package/lib/module/mappings/KeyboardAwareScrollView.js +39 -0
  22. package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -0
  23. package/lib/typescript/src/mappings/Icon.d.ts +1 -1
  24. package/lib/typescript/src/mappings/KeyboardAwareScrollView.d.ts +82 -0
  25. package/package.json +2 -2
  26. package/src/Provider.js +9 -0
  27. package/src/components/Accordion/AccordionGroup.js +44 -0
  28. package/src/components/Accordion/AccordionItem.js +32 -0
  29. package/src/components/Accordion/index.js +2 -0
  30. package/src/components/ActionSheet/ActionSheet.js +45 -0
  31. package/src/components/ActionSheet/ActionSheetCancel.js +6 -0
  32. package/src/components/ActionSheet/ActionSheetItem.js +30 -0
  33. package/src/components/ActionSheet/index.js +3 -0
  34. package/src/components/AnimatedCircularProgress.js +43 -0
  35. package/src/components/AspectRatio.js +18 -0
  36. package/src/components/AvatarEdit.js +30 -0
  37. package/src/components/Button.js +112 -0
  38. package/src/components/Card.js +57 -0
  39. package/src/components/CardBlock.js +54 -0
  40. package/src/components/CardContainer.js +69 -0
  41. package/src/components/CardContainerRating.js +79 -0
  42. package/src/components/CardContainerShortImage.js +33 -0
  43. package/src/components/CardInline.js +36 -0
  44. package/src/components/Carousel.js +66 -0
  45. package/src/components/Checkbox/Checkbox.js +63 -0
  46. package/src/components/Checkbox/CheckboxGroup.js +21 -0
  47. package/src/components/Checkbox/CheckboxRow.js +77 -0
  48. package/src/components/Checkbox/context.js +14 -0
  49. package/src/components/Checkbox/index.js +3 -0
  50. package/src/components/CircleImage.js +8 -0
  51. package/src/components/CircularProgress.js +78 -0
  52. package/src/components/Config.js +63 -0
  53. package/src/components/Container.js +44 -0
  54. package/src/components/DatePicker/DatePicker.js +370 -0
  55. package/src/components/DatePicker/DatePickerComponent.js +13 -0
  56. package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
  57. package/src/components/DatePicker/DatePickerComponentType.js +1 -0
  58. package/src/components/DeprecatedButton.js +95 -0
  59. package/src/components/DeprecatedCardWrapper.js +18 -0
  60. package/src/components/DeprecatedFAB.js +115 -0
  61. package/src/components/Divider.js +13 -0
  62. package/src/components/Elevation.js +20 -0
  63. package/src/components/FAB.js +46 -0
  64. package/src/components/FieldSearchBarFull.js +53 -0
  65. package/src/components/FormRow.js +19 -0
  66. package/src/components/Header.js +44 -0
  67. package/src/components/HeaderLarge.js +7 -0
  68. package/src/components/HeaderMedium.js +7 -0
  69. package/src/components/HeaderOverline.js +7 -0
  70. package/src/components/IconButton.js +35 -0
  71. package/src/components/Image.js +47 -0
  72. package/src/components/Justification.js +1 -0
  73. package/src/components/Layout.js +50 -0
  74. package/src/components/NumberInput.js +50 -0
  75. package/src/components/Picker/Picker.js +56 -0
  76. package/src/components/Picker/PickerComponent.android.js +68 -0
  77. package/src/components/Picker/PickerComponent.ios.js +78 -0
  78. package/src/components/Picker/PickerComponent.web.js +69 -0
  79. package/src/components/Picker/PickerTypes.js +1 -0
  80. package/src/components/Portal/Portal.js +35 -0
  81. package/src/components/Portal/PortalConsumer.js +28 -0
  82. package/src/components/Portal/PortalHost.js +105 -0
  83. package/src/components/Portal/PortalManager.js +29 -0
  84. package/src/components/ProgressBar.js +118 -0
  85. package/src/components/ProgressCircle.js +13 -0
  86. package/src/components/ProgressIndicator.js +27 -0
  87. package/src/components/RadioButton/RadioButton.js +17 -0
  88. package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
  89. package/src/components/RadioButton/RadioButtonGroup.js +39 -0
  90. package/src/components/RadioButton/RadioButtonRow.js +76 -0
  91. package/src/components/RadioButton/context.js +14 -0
  92. package/src/components/RadioButton/index.js +4 -0
  93. package/src/components/ResizeMode.js +1 -0
  94. package/src/components/Row.js +48 -0
  95. package/src/components/RowBodyIcon.js +8 -0
  96. package/src/components/RowHeadlineImageCaption.js +12 -0
  97. package/src/components/RowHeadlineImageIcon.js +14 -0
  98. package/src/components/ScreenContainer.js +35 -0
  99. package/src/components/Slider.js +63 -0
  100. package/src/components/StarRating.js +50 -0
  101. package/src/components/StepIndicator.js +346 -0
  102. package/src/components/Stepper.js +53 -0
  103. package/src/components/Surface.js +23 -0
  104. package/src/components/Swiper/Swiper.js +18 -0
  105. package/src/components/Swiper/SwiperItem.js +9 -0
  106. package/src/components/Swiper/index.js +2 -0
  107. package/src/components/Switch.js +56 -0
  108. package/src/components/Text.js +28 -0
  109. package/src/components/TextField.js +419 -0
  110. package/src/components/ToggleButton.js +39 -0
  111. package/src/components/Touchable.js +12 -0
  112. package/src/components/Touchable.web.js +2 -0
  113. package/src/components/Typography.js +36 -0
  114. package/src/components/useAuthState.js +31 -0
  115. package/src/constants.js +10 -0
  116. package/src/hooks.js +12 -0
  117. package/src/index.js +50 -0
  118. package/src/interfaces/Icon.js +8 -0
  119. package/src/mappings/Accordion.js +37 -0
  120. package/src/mappings/AccordionItem.js +16 -0
  121. package/src/mappings/ActionSheet.js +13 -0
  122. package/src/mappings/ActionSheetCancel.js +19 -0
  123. package/src/mappings/ActionSheetItem.js +22 -0
  124. package/src/mappings/ActivityIndicator.js +53 -0
  125. package/src/mappings/AudioPlayer.js +20 -0
  126. package/src/mappings/AvatarEdit.js +37 -0
  127. package/src/mappings/BlurView.js +41 -0
  128. package/src/mappings/Button.js +56 -0
  129. package/src/mappings/Card.js +52 -0
  130. package/src/mappings/CardBlock.js +122 -0
  131. package/src/mappings/CardContainer.js +102 -0
  132. package/src/mappings/CardContainerRating.js +124 -0
  133. package/src/mappings/CardContainerShortImage.js +118 -0
  134. package/src/mappings/CardInline.js +51 -0
  135. package/src/mappings/Carousel.js +18 -0
  136. package/src/mappings/Checkbox.js +45 -0
  137. package/src/mappings/CheckboxGroup.js +25 -0
  138. package/src/mappings/CheckboxRow.js +37 -0
  139. package/src/mappings/CircleImage.js +24 -0
  140. package/src/mappings/Container.js +29 -0
  141. package/src/mappings/CustomCode.js +8 -0
  142. package/src/mappings/DatePicker.js +146 -0
  143. package/src/mappings/Divider.js +26 -0
  144. package/src/mappings/FAB.js +36 -0
  145. package/src/mappings/Fetch.js +12 -0
  146. package/src/mappings/FieldSearchBarFull.js +49 -0
  147. package/src/mappings/FlatList.js +19 -0
  148. package/src/mappings/HeaderLarge.js +28 -0
  149. package/src/mappings/HeaderMedium.js +54 -0
  150. package/src/mappings/HeaderOverline.js +54 -0
  151. package/src/mappings/Icon.js +25 -0
  152. package/src/mappings/Icon.ts +4 -1
  153. package/src/mappings/IconButton.js +30 -0
  154. package/src/mappings/Image.js +15 -0
  155. package/src/mappings/ImageBackground.js +28 -0
  156. package/src/mappings/KeyboardAvoidingView.js +40 -0
  157. package/src/mappings/KeyboardAwareScrollView.js +38 -0
  158. package/src/mappings/KeyboardAwareScrollView.ts +48 -0
  159. package/src/mappings/Layout.js +195 -0
  160. package/src/mappings/LinearGradient.js +77 -0
  161. package/src/mappings/MapCallout.js +19 -0
  162. package/src/mappings/MapMarker.js +46 -0
  163. package/src/mappings/Modal.js +41 -0
  164. package/src/mappings/Picker.js +137 -0
  165. package/src/mappings/ProgressBar.js +100 -0
  166. package/src/mappings/ProgressCircle.js +108 -0
  167. package/src/mappings/ProgressIndicator.js +180 -0
  168. package/src/mappings/RadioButton.js +50 -0
  169. package/src/mappings/RadioButtonGroup.js +16 -0
  170. package/src/mappings/RadioButtonRow.js +37 -0
  171. package/src/mappings/RowBodyIcon.js +75 -0
  172. package/src/mappings/RowHeadlineImageCaption.js +167 -0
  173. package/src/mappings/RowHeadlineImageIcon.js +99 -0
  174. package/src/mappings/SafeAreaView.js +33 -0
  175. package/src/mappings/ScrollView.js +30 -0
  176. package/src/mappings/Slider.js +59 -0
  177. package/src/mappings/StarRating.js +46 -0
  178. package/src/mappings/Stepper.js +28 -0
  179. package/src/mappings/Surface.js +13 -0
  180. package/src/mappings/Swiper.js +60 -0
  181. package/src/mappings/SwiperItem.js +8 -0
  182. package/src/mappings/Switch.js +75 -0
  183. package/src/mappings/Text.js +227 -0
  184. package/src/mappings/TextArea.js +52 -0
  185. package/src/mappings/TextField.js +158 -0
  186. package/src/mappings/TextInput.js +208 -0
  187. package/src/mappings/ToggleButton.js +50 -0
  188. package/src/mappings/Touchable.js +12 -0
  189. package/src/mappings/Video.js +74 -0
  190. package/src/mappings/View.js +206 -0
  191. package/src/mappings/WebView.js +13 -0
  192. package/src/styles/DarkTheme.js +26 -0
  193. package/src/styles/DefaultTheme.js +111 -0
  194. package/src/styles/fonts.js +62 -0
  195. package/src/styles/overlay.js +60 -0
  196. package/src/styles/shadow.js +51 -0
  197. package/src/theming.js +3 -0
  198. package/src/utilities.js +54 -0
@@ -0,0 +1,370 @@
1
+ import * as React from "react";
2
+ import { View, Animated, Text, StyleSheet, Platform, I18nManager, TextInput as NativeTextInput, } from "react-native";
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
+ import dateFormat from "dateformat";
5
+ import { withTheme } from "../../theming";
6
+ import Portal from "../Portal/Portal";
7
+ import Button from "../DeprecatedButton";
8
+ import Touchable from "../Touchable";
9
+ import DateTimePicker from "./DatePickerComponent";
10
+ const AnimatedText = Animated.createAnimatedComponent(Text);
11
+ const FOCUS_ANIMATION_DURATION = 150;
12
+ const BLUR_ANIMATION_DURATION = 180;
13
+ const ICON_SIZE = 24;
14
+ const MONTHS = [
15
+ "January",
16
+ "February",
17
+ "March",
18
+ "April",
19
+ "May",
20
+ "June",
21
+ "July",
22
+ "August",
23
+ "September",
24
+ "October",
25
+ "November",
26
+ "December",
27
+ ];
28
+ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, placeholder, ...props }) => {
29
+ const [value, setValue] = React.useState(date || defaultValue);
30
+ React.useEffect(() => {
31
+ if (defaultValue != null) {
32
+ setValue(defaultValue);
33
+ }
34
+ }, [defaultValue]);
35
+ const [pickerVisible, setPickerVisible] = React.useState(false);
36
+ const [labeled] = React.useState(new Animated.Value(date ? 0 : 1));
37
+ const [placeholder1, setPlaceholder1] = React.useState("");
38
+ const [focused, setFocused] = React.useState(false);
39
+ const [labelLayout, setLabelLayout] = React.useState({ measured: false, width: 0 });
40
+ const getValidDate = () => {
41
+ if (!value) {
42
+ return new Date();
43
+ }
44
+ return typeof value?.getMonth === "function" ? value : new Date();
45
+ };
46
+ const formatDate = () => {
47
+ if (!value)
48
+ return "";
49
+ let newDate = getValidDate();
50
+ if (format)
51
+ return dateFormat(newDate, format);
52
+ if (mode === "time") {
53
+ return `${newDate.toLocaleTimeString()}`;
54
+ }
55
+ if (mode === "datetime") {
56
+ return `${newDate.toLocaleString()}`;
57
+ }
58
+ return `${MONTHS[newDate.getMonth()]} ${newDate.getDate()}, ${newDate.getFullYear()}`;
59
+ };
60
+ const toggleVisibility = async () => {
61
+ setPickerVisible(!pickerVisible);
62
+ focused ? _handleBlur() : _handleFocus();
63
+ };
64
+ const insets = useSafeAreaInsets();
65
+ // const _restoreLabel = () =>
66
+ // Animated.timing(labeled, {
67
+ // toValue: 1,
68
+ // duration: FOCUS_ANIMATION_DURATION,
69
+ // useNativeDriver: true,
70
+ // }).start();
71
+ // const _minmizeLabel = () =>
72
+ // Animated.timing(labeled, {
73
+ // toValue: 0,
74
+ // duration: BLUR_ANIMATION_DURATION,
75
+ // useNativeDriver: true,
76
+ // }).start();
77
+ // const _showPlaceholder = () =>
78
+ // setTimeout(() => setPlaceholder1(placeholder || ""), 50);
79
+ const _hidePlaceholder = () => {
80
+ setPlaceholder1("");
81
+ };
82
+ React.useEffect(() => {
83
+ setValue(date);
84
+ }, [date]);
85
+ React.useEffect(() => {
86
+ if (value || focused || placeholder1) {
87
+ // _minmizeLabel();
88
+ Animated.timing(labeled, {
89
+ toValue: 0,
90
+ duration: BLUR_ANIMATION_DURATION,
91
+ useNativeDriver: true,
92
+ }).start();
93
+ }
94
+ else {
95
+ // _restoreLabel();
96
+ Animated.timing(labeled, {
97
+ toValue: 1,
98
+ duration: FOCUS_ANIMATION_DURATION,
99
+ useNativeDriver: true,
100
+ }).start();
101
+ }
102
+ }, [value, focused, placeholder1, labeled]);
103
+ React.useEffect(() => {
104
+ const _showPlaceholder = () => setTimeout(() => setPlaceholder1(placeholder || ""), 50);
105
+ if (focused || !label) {
106
+ _showPlaceholder();
107
+ }
108
+ else {
109
+ _hidePlaceholder();
110
+ }
111
+ return () => {
112
+ clearTimeout(_showPlaceholder());
113
+ };
114
+ }, [focused, label, placeholder]);
115
+ const _handleFocus = () => {
116
+ if (disabled) {
117
+ return;
118
+ }
119
+ setFocused(true);
120
+ };
121
+ const _handleBlur = () => {
122
+ if (disabled) {
123
+ return;
124
+ }
125
+ setFocused(false);
126
+ };
127
+ const MINIMIZED_LABEL_Y_OFFSET = -(typography.caption.lineHeight + 4);
128
+ const OUTLINE_MINIMIZED_LABEL_Y_OFFSET = -(16 * 0.5 + 4);
129
+ const MAXIMIZED_LABEL_FONT_SIZE = typography.subtitle1.fontSize;
130
+ const MINIMIZED_LABEL_FONT_SIZE = typography.caption.fontSize;
131
+ const hasActiveOutline = focused;
132
+ let inputTextColor, activeColor, underlineColor, borderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
133
+ inputTextColor = colors.strong;
134
+ if (disabled) {
135
+ activeColor = colors.light;
136
+ placeholderColor = colors.light;
137
+ borderColor = "transparent";
138
+ underlineColor = "transparent";
139
+ backgroundColor = colors.divider;
140
+ }
141
+ else {
142
+ activeColor = colors.primary;
143
+ placeholderColor = borderColor = colors.light;
144
+ underlineColor = colors.light;
145
+ backgroundColor = colors.background;
146
+ }
147
+ const { lineHeight, ...subtitle1 } = typography.subtitle1;
148
+ inputStyle = {
149
+ paddingVertical: 0,
150
+ color: inputTextColor,
151
+ paddingLeft: leftIconName && leftIconMode === "inset"
152
+ ? ICON_SIZE + (type === "solid" ? 16 : 12)
153
+ : 0,
154
+ paddingRight: rightIconName ? ICON_SIZE + 16 + 4 : 12,
155
+ ...subtitle1,
156
+ height: lineHeight,
157
+ };
158
+ if (type === "underline") {
159
+ containerStyle = {
160
+ borderTopLeftRadius: roundness,
161
+ borderTopRightRadius: roundness,
162
+ paddingBottom: 12,
163
+ marginTop: 16,
164
+ };
165
+ }
166
+ else {
167
+ containerStyle = {
168
+ borderRadius: roundness,
169
+ borderColor: hasActiveOutline ? activeColor : borderColor,
170
+ borderWidth: 1,
171
+ paddingTop: labeled ? 16 * 1.5 : 16,
172
+ paddingBottom: labeled ? 16 * 0.5 : 16,
173
+ opacity: disabled ? disabledOpacity : 1,
174
+ backgroundColor,
175
+ };
176
+ inputStyle.paddingHorizontal = 12;
177
+ }
178
+ if (leftIconName && leftIconMode === "outset") {
179
+ containerStyle.marginLeft = ICON_SIZE + 8;
180
+ }
181
+ let leftIconColor;
182
+ if (focused) {
183
+ leftIconColor = colors.primary;
184
+ }
185
+ else {
186
+ leftIconColor = colors.light;
187
+ }
188
+ const leftIconProps = {
189
+ size: 24,
190
+ color: leftIconColor,
191
+ name: leftIconName || "",
192
+ };
193
+ const leftIconStyle = {
194
+ position: "absolute",
195
+ marginTop: type === "solid"
196
+ ? leftIconMode === "inset"
197
+ ? MINIMIZED_LABEL_FONT_SIZE + 4
198
+ : 16
199
+ : leftIconMode === "outset"
200
+ ? 16
201
+ : 0,
202
+ };
203
+ const labelStyle = {
204
+ ...typography.subtitle1,
205
+ top: type === "solid" ? 16 : 0,
206
+ left: leftIconName && leftIconMode === "inset"
207
+ ? ICON_SIZE + (type === "solid" ? 16 : 12)
208
+ : 0,
209
+ transform: [
210
+ {
211
+ // Move label to top
212
+ translateY: labeled.interpolate({
213
+ inputRange: [0, 1],
214
+ outputRange: [
215
+ type === "solid"
216
+ ? OUTLINE_MINIMIZED_LABEL_Y_OFFSET
217
+ : MINIMIZED_LABEL_Y_OFFSET,
218
+ 0,
219
+ ],
220
+ }),
221
+ },
222
+ {
223
+ // Make label smaller
224
+ scale: labeled.interpolate({
225
+ inputRange: [0, 1],
226
+ outputRange: [
227
+ MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE,
228
+ 1,
229
+ ],
230
+ }),
231
+ },
232
+ {
233
+ // Offset label scale since RN doesn't support transform origin
234
+ translateX: labeled.interpolate({
235
+ inputRange: [0, 1],
236
+ outputRange: [
237
+ -(1 - MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE) *
238
+ (labelLayout.width / 2),
239
+ 0,
240
+ ],
241
+ }),
242
+ },
243
+ ],
244
+ };
245
+ const inputStyles = [
246
+ styles.input,
247
+ inputStyle,
248
+ type === "solid" ? { marginHorizontal: 12 } : {},
249
+ ];
250
+ // const render = (props) => <NativeTextInput {...props} />;
251
+ return (React.createElement(View, { style: [styles.container, style] },
252
+ React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
253
+ React.createElement(View, { pointerEvents: "none" },
254
+ React.createElement(View, { style: [styles.container, style] },
255
+ leftIconName && leftIconMode === "outset" ? (React.createElement(Icon, { ...leftIconProps, style: leftIconStyle })) : null,
256
+ React.createElement(View, { style: [containerStyle, style ? { height: style.height } : {}] },
257
+ type === "underline" ? (
258
+ // When type === 'flat', render an underline
259
+ React.createElement(Animated.View, { style: [
260
+ styles.underline,
261
+ {
262
+ backgroundColor: focused ? activeColor : underlineColor,
263
+ // Underlines is thinner when input is not focused
264
+ transform: [{ scaleY: focused ? 1 : 0.5 }],
265
+ },
266
+ ] })) : null,
267
+ label ? (
268
+ // Position colored placeholder and gray placeholder on top of each other and crossfade them
269
+ // This gives the effect of animating the color, but allows us to use native driver
270
+ React.createElement(View, { pointerEvents: "none", style: [
271
+ StyleSheet.absoluteFill,
272
+ {
273
+ opacity:
274
+ // Hide the label in minimized state until we measure its width
275
+ date || focused ? (labelLayout.measured ? 1 : 0) : 1,
276
+ },
277
+ ] },
278
+ React.createElement(AnimatedText, { onLayout: (e) => setLabelLayout({
279
+ width: e.nativeEvent.layout.width,
280
+ measured: true,
281
+ }), style: [
282
+ styles.placeholder,
283
+ type === "solid" ? { paddingHorizontal: 12 } : {},
284
+ labelStyle,
285
+ {
286
+ color: colors.light,
287
+ opacity: labeled.interpolate({
288
+ inputRange: [0, 1],
289
+ outputRange: [hasActiveOutline ? 1 : 0, 0],
290
+ }),
291
+ },
292
+ ], numberOfLines: 1 }, label),
293
+ React.createElement(AnimatedText, { style: [
294
+ styles.placeholder,
295
+ type === "solid" ? { paddingHorizontal: 12 } : {},
296
+ labelStyle,
297
+ {
298
+ color: placeholderColor,
299
+ opacity: hasActiveOutline ? labeled : 1,
300
+ },
301
+ ], numberOfLines: 1 }, label))) : null,
302
+ leftIconName && leftIconMode === "inset" ? (React.createElement(Icon, { ...leftIconProps, style: {
303
+ ...leftIconStyle,
304
+ marginLeft: type === "solid" ? 16 : 0,
305
+ } })) : null,
306
+ React.createElement(NativeTextInput, { value: formatDate(), placeholder: label ? placeholder1 : placeholder, editable: !disabled, placeholderTextColor: placeholderColor, selectionColor: activeColor, onFocus: _handleFocus, onBlur: _handleBlur, underlineColorAndroid: "transparent", style: inputStyles, ...props })),
307
+ rightIconName ? (React.createElement(Icon, { name: rightIconName, size: ICON_SIZE, color: colors.light, style: {
308
+ position: "absolute",
309
+ right: 16,
310
+ marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16,
311
+ } })) : null))),
312
+ pickerVisible && (React.createElement(Portal, null,
313
+ React.createElement(View, { style: [
314
+ styles.picker,
315
+ {
316
+ backgroundColor: colors.divider,
317
+ },
318
+ ] },
319
+ React.createElement(View, { style: [
320
+ styles.pickerContainer,
321
+ {
322
+ paddingTop: insets.top,
323
+ paddingBottom: insets.bottom,
324
+ paddingLeft: insets.left,
325
+ paddingRight: insets.right,
326
+ },
327
+ ] },
328
+ Platform.OS === "ios" && (React.createElement(Button, { Icon: Icon, type: "text", onPress: toggleVisibility, style: styles.closeButton }, "Close")),
329
+ React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
330
+ Platform.OS === "ios" ? null : toggleVisibility();
331
+ setValue(data);
332
+ onDateChange(data);
333
+ } })))))));
334
+ };
335
+ const styles = StyleSheet.create({
336
+ container: {
337
+ alignSelf: "stretch",
338
+ },
339
+ picker: {
340
+ position: "absolute",
341
+ bottom: 0,
342
+ left: 0,
343
+ right: 0,
344
+ flexDirection: "row",
345
+ justifyContent: "center",
346
+ },
347
+ underline: {
348
+ position: "absolute",
349
+ left: 0,
350
+ right: 0,
351
+ bottom: 0,
352
+ height: 2,
353
+ },
354
+ input: {
355
+ flexGrow: 1,
356
+ justifyContent: "center",
357
+ textAlignVertical: "center",
358
+ margin: 0,
359
+ textAlign: I18nManager.isRTL ? "right" : "left",
360
+ },
361
+ placeholder: {
362
+ position: "absolute",
363
+ left: 0,
364
+ },
365
+ pickerContainer: { flexDirection: "column", width: "100%" },
366
+ closeButton: {
367
+ alignSelf: "flex-end",
368
+ },
369
+ });
370
+ export default withTheme(DatePicker);
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { Platform } from "react-native";
3
+ import DateTimePicker from "@react-native-community/datetimepicker";
4
+ import DateTimePickerModal from "react-native-modal-datetime-picker";
5
+ const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, }) => {
6
+ return Platform.OS === "ios" || Platform.OS === "android" ? (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: Platform.OS === "ios" ? "spinner" : "default", onCancel: () => {
7
+ console.log("Picker cancelled before selecting anything.");
8
+ toggleVisibility();
9
+ }, onConfirm: (data) => {
10
+ onChange(null, data);
11
+ } })) : (React.createElement(DateTimePicker, { value: value, mode: mode, onChange: onChange, display: "default" }));
12
+ };
13
+ export default DatePickerComponent;
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import DateFnsUtils from "@date-io/date-fns";
3
+ import { MuiPickersUtilsProvider, DatePicker, TimePicker, DateTimePicker, } from "@material-ui/pickers";
4
+ import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles";
5
+ import { withTheme } from "../../theming";
6
+ import Theme from "../../styles/DefaultTheme";
7
+ const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, isVisible, theme, }) => {
8
+ const internalTheme = createMuiTheme({
9
+ palette: {
10
+ primary: {
11
+ main: theme?.colors?.primary ?? Theme.colors.primary,
12
+ },
13
+ secondary: {
14
+ main: theme?.colors?.secondary ?? Theme.colors.secondary,
15
+ },
16
+ },
17
+ });
18
+ const Picker = mode === "date"
19
+ ? DatePicker
20
+ : mode === "time"
21
+ ? TimePicker
22
+ : DateTimePicker;
23
+ return (React.createElement(MuiPickersUtilsProvider, { utils: DateFnsUtils },
24
+ React.createElement(ThemeProvider, { theme: internalTheme },
25
+ React.createElement(Picker, { value: value, open: isVisible, onChange: (d) => {
26
+ toggleVisibility();
27
+ onChange(null, d);
28
+ }, onClose: () => toggleVisibility(), variant: "dialog", TextFieldComponent: () => null }))));
29
+ };
30
+ export default withTheme(DatePickerComponent);
@@ -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);
@@ -0,0 +1,18 @@
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);
@@ -0,0 +1,115 @@
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);
@@ -0,0 +1,13 @@
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);
@@ -0,0 +1,20 @@
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);