@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,377 +0,0 @@
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, displayMode: "default", 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);
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- import DateTimePickerModal from "react-native-modal-datetime-picker";
3
- const DatePickerComponent = ({ value, onChange, displayMode = "default", mode, toggleVisibility, }) => {
4
- return (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: displayMode, onCancel: () => {
5
- console.log("Picker cancelled before selecting anything.");
6
- toggleVisibility();
7
- }, onConfirm: (data) => {
8
- onChange(null, data);
9
- } }));
10
- };
11
- export default DatePickerComponent;
@@ -1,30 +0,0 @@
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(), TextFieldComponent: () => null }))));
29
- };
30
- export default withTheme(DatePickerComponent);
@@ -1 +0,0 @@
1
- export {};
@@ -1,97 +0,0 @@
1
- import * as React from "react";
2
- import { View, TextInput, Platform, } from "react-native";
3
- import { useSafeAreaInsets } from "react-native-safe-area-context";
4
- import dateFormat from "dateformat";
5
- import Portal from "../Portal/Portal";
6
- import Touchable from "../Touchable";
7
- import DateTimePicker from "./DatePickerComponent";
8
- const MONTHS = [
9
- "January",
10
- "February",
11
- "March",
12
- "April",
13
- "May",
14
- "June",
15
- "July",
16
- "August",
17
- "September",
18
- "October",
19
- "November",
20
- "December",
21
- ];
22
- const DatePickerInput = ({ style, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, androidDisplay = "default", iosDisplay = "default", webDisplay = "dialog", placeholder, ...props }) => {
23
- const [value, setValue] = React.useState(date || defaultValue);
24
- React.useEffect(() => {
25
- if (defaultValue != null) {
26
- setValue(defaultValue);
27
- }
28
- }, [defaultValue]);
29
- const [pickerVisible, setPickerVisible] = React.useState(false);
30
- const [focused, setFocused] = React.useState(false);
31
- const getValidDate = () => {
32
- if (!value) {
33
- return new Date();
34
- }
35
- return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
36
- };
37
- const formatDate = () => {
38
- if (!value)
39
- return "";
40
- let newDate = getValidDate();
41
- if (format)
42
- return dateFormat(newDate, format);
43
- if (mode === "time") {
44
- return `${newDate.toLocaleTimeString()}`;
45
- }
46
- if (mode === "datetime") {
47
- return `${newDate.toLocaleString()}`;
48
- }
49
- return `${MONTHS[newDate.getMonth()]} ${newDate.getDate()}, ${newDate.getFullYear()}`;
50
- };
51
- const toggleVisibility = async () => {
52
- setPickerVisible(!pickerVisible);
53
- focused ? _handleBlur() : _handleFocus();
54
- };
55
- const insets = useSafeAreaInsets();
56
- React.useEffect(() => {
57
- setValue(date);
58
- }, [date]);
59
- const _handleFocus = () => {
60
- if (disabled) {
61
- return;
62
- }
63
- setFocused(true);
64
- };
65
- const _handleBlur = () => {
66
- if (disabled) {
67
- return;
68
- }
69
- setFocused(false);
70
- };
71
- return (React.createElement(View, null,
72
- React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
73
- React.createElement(TextInput, { value: formatDate(), placeholder: placeholder, editable: !disabled, onFocus: _handleFocus, onBlur: _handleBlur, style: style, ...props })),
74
- pickerVisible && (React.createElement(Portal, null,
75
- React.createElement(View, { style: {
76
- paddingTop: insets.top,
77
- paddingBottom: insets.bottom,
78
- paddingLeft: insets.left,
79
- paddingRight: insets.right,
80
- } },
81
- Platform.OS === "web" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
82
- toggleVisibility();
83
- setValue(data);
84
- onDateChange(data);
85
- } })),
86
- Platform.OS === "ios" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, displayMode: iosDisplay, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
87
- toggleVisibility();
88
- setValue(data);
89
- onDateChange(data);
90
- } })),
91
- Platform.OS === "android" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, variant: webDisplay, displayMode: androidDisplay, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
92
- toggleVisibility();
93
- setValue(data);
94
- onDateChange(data);
95
- } })))))));
96
- };
97
- export default DatePickerInput;