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