ferns-ui 0.2.0 → 0.2.3

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 (342) hide show
  1. package/dist/ActionSheet.js.map +1 -1
  2. package/dist/Button.js +1 -2
  3. package/dist/Button.js.map +1 -1
  4. package/dist/CheckBox.js +1 -1
  5. package/dist/CheckBox.js.map +1 -1
  6. package/dist/Common.d.ts +3 -3
  7. package/dist/Common.js.map +1 -1
  8. package/dist/DateTimeActionSheet.js.map +1 -1
  9. package/dist/DecimalRangeActionSheet.js.map +1 -1
  10. package/dist/ErrorBoundary.d.ts +1 -1
  11. package/dist/Field.d.ts +12 -14
  12. package/dist/Field.js +95 -98
  13. package/dist/Field.js.map +1 -1
  14. package/dist/HeightActionSheet.js.map +1 -1
  15. package/dist/Icon.d.ts +0 -3
  16. package/dist/Icon.js +4 -112
  17. package/dist/Icon.js.map +1 -1
  18. package/dist/IconButton.js +1 -1
  19. package/dist/IconButton.js.map +1 -1
  20. package/dist/NumberPickerActionSheet.js.map +1 -1
  21. package/dist/PickerSelect.d.ts +4 -4
  22. package/dist/Pog.js +1 -1
  23. package/dist/Pog.js.map +1 -1
  24. package/dist/SplitPage.js.map +1 -1
  25. package/dist/TapToEdit.js +1 -1
  26. package/dist/TapToEdit.js.map +1 -1
  27. package/dist/TextField.js +1 -1
  28. package/dist/TextField.js.map +1 -1
  29. package/dist/TextFieldNumberActionSheet.js.map +1 -1
  30. package/dist/Unifier.js +1 -9
  31. package/dist/Unifier.js.map +1 -1
  32. package/package.json +31 -30
  33. package/src/Button.tsx +1 -1
  34. package/src/CheckBox.tsx +1 -1
  35. package/src/Common.ts +3 -2
  36. package/src/Field.tsx +91 -98
  37. package/src/Icon.tsx +3 -122
  38. package/src/IconButton.tsx +1 -1
  39. package/src/Pog.tsx +2 -2
  40. package/src/TapToEdit.tsx +1 -1
  41. package/src/TextField.tsx +1 -1
  42. package/src/TextFieldNumberActionSheet.tsx +1 -1
  43. package/dist/Banner.stories.d.ts +0 -1
  44. package/dist/Banner.stories.js +0 -13
  45. package/dist/Banner.stories.js.map +0 -1
  46. package/dist/Box.stories.d.ts +0 -1
  47. package/dist/Box.stories.js +0 -45
  48. package/dist/Box.stories.js.map +0 -1
  49. package/dist/Button.stories.d.ts +0 -1
  50. package/dist/Button.stories.js +0 -41
  51. package/dist/Button.stories.js.map +0 -1
  52. package/dist/Card.stories.d.ts +0 -6
  53. package/dist/Card.stories.js +0 -18
  54. package/dist/Card.stories.js.map +0 -1
  55. package/dist/CheckBox.stories.d.ts +0 -1
  56. package/dist/CheckBox.stories.js +0 -28
  57. package/dist/CheckBox.stories.js.map +0 -1
  58. package/dist/Field.stories.d.ts +0 -6
  59. package/dist/Field.stories.js +0 -38
  60. package/dist/Field.stories.js.map +0 -1
  61. package/dist/Form.stories.d.ts +0 -6
  62. package/dist/Form.stories.js +0 -36
  63. package/dist/Form.stories.js.map +0 -1
  64. package/dist/HeaderButtons.stories.d.ts +0 -6
  65. package/dist/HeaderButtons.stories.js +0 -6
  66. package/dist/HeaderButtons.stories.js.map +0 -1
  67. package/dist/Heading.stories.d.ts +0 -1
  68. package/dist/Heading.stories.js +0 -22
  69. package/dist/Heading.stories.js.map +0 -1
  70. package/dist/Icon.stories.d.ts +0 -1
  71. package/dist/Icon.stories.js +0 -30
  72. package/dist/Icon.stories.js.map +0 -1
  73. package/dist/IconButton.stories.d.ts +0 -1
  74. package/dist/IconButton.stories.js +0 -16
  75. package/dist/IconButton.stories.js.map +0 -1
  76. package/dist/Link.stories.d.ts +0 -1
  77. package/dist/Link.stories.js +0 -18
  78. package/dist/Link.stories.js.map +0 -1
  79. package/dist/Mask.stories.d.ts +0 -1
  80. package/dist/Mask.stories.js +0 -28
  81. package/dist/Mask.stories.js.map +0 -1
  82. package/dist/Pill.stories.d.ts +0 -1
  83. package/dist/Pill.stories.js +0 -38
  84. package/dist/Pill.stories.js.map +0 -1
  85. package/dist/SegmentedControl.stories.d.ts +0 -1
  86. package/dist/SegmentedControl.stories.js +0 -31
  87. package/dist/SegmentedControl.stories.js.map +0 -1
  88. package/dist/SelectList.stories.d.ts +0 -1
  89. package/dist/SelectList.stories.js +0 -26
  90. package/dist/SelectList.stories.js.map +0 -1
  91. package/dist/Spinner.stories.d.ts +0 -1
  92. package/dist/Spinner.stories.js +0 -12
  93. package/dist/Spinner.stories.js.map +0 -1
  94. package/dist/SplitPage.stories.d.ts +0 -1
  95. package/dist/SplitPage.stories.js +0 -15
  96. package/dist/SplitPage.stories.js.map +0 -1
  97. package/dist/StorybookContainer.d.ts +0 -4
  98. package/dist/StorybookContainer.js +0 -8
  99. package/dist/StorybookContainer.js.map +0 -1
  100. package/dist/Switch.stories.d.ts +0 -1
  101. package/dist/Switch.stories.js +0 -34
  102. package/dist/Switch.stories.js.map +0 -1
  103. package/dist/Text.stories.d.ts +0 -1
  104. package/dist/Text.stories.js +0 -37
  105. package/dist/Text.stories.js.map +0 -1
  106. package/dist/TextArea.stories.d.ts +0 -10
  107. package/dist/TextArea.stories.js +0 -24
  108. package/dist/TextArea.stories.js.map +0 -1
  109. package/dist/TextField.stories.d.ts +0 -6
  110. package/dist/TextField.stories.js +0 -18
  111. package/dist/TextField.stories.js.map +0 -1
  112. package/dist/dist/ActionSheet.d.ts +0 -139
  113. package/dist/dist/ActionSheet.js +0 -637
  114. package/dist/dist/ActionSheet.js.map +0 -1
  115. package/dist/dist/Banner.d.ts +0 -12
  116. package/dist/dist/Banner.js +0 -49
  117. package/dist/dist/Banner.js.map +0 -1
  118. package/dist/dist/Banner.stories.d.ts +0 -1
  119. package/dist/dist/Banner.stories.js +0 -9
  120. package/dist/dist/Banner.stories.js.map +0 -1
  121. package/dist/dist/BlurBox.d.ts +0 -7
  122. package/dist/dist/BlurBox.js +0 -29
  123. package/dist/dist/BlurBox.js.map +0 -1
  124. package/dist/dist/BlurBox.native.d.ts +0 -9
  125. package/dist/dist/BlurBox.native.js +0 -32
  126. package/dist/dist/BlurBox.native.js.map +0 -1
  127. package/dist/dist/Body.d.ts +0 -12
  128. package/dist/dist/Body.js +0 -19
  129. package/dist/dist/Body.js.map +0 -1
  130. package/dist/dist/Box.d.ts +0 -205
  131. package/dist/dist/Box.js +0 -229
  132. package/dist/dist/Box.js.map +0 -1
  133. package/dist/dist/Box.stories.d.ts +0 -1
  134. package/dist/dist/Box.stories.js +0 -37
  135. package/dist/dist/Box.stories.js.map +0 -1
  136. package/dist/dist/Button.d.ts +0 -16
  137. package/dist/dist/Button.js +0 -98
  138. package/dist/dist/Button.js.map +0 -1
  139. package/dist/dist/Button.stories.d.ts +0 -13
  140. package/dist/dist/Button.stories.js +0 -26
  141. package/dist/dist/Button.stories.js.map +0 -1
  142. package/dist/dist/Card.d.ts +0 -6
  143. package/dist/dist/Card.js +0 -9
  144. package/dist/dist/Card.js.map +0 -1
  145. package/dist/dist/Card.stories.d.ts +0 -6
  146. package/dist/dist/Card.stories.js +0 -11
  147. package/dist/dist/Card.stories.js.map +0 -1
  148. package/dist/dist/CheckBox.d.ts +0 -8
  149. package/dist/dist/CheckBox.js +0 -23
  150. package/dist/dist/CheckBox.js.map +0 -1
  151. package/dist/dist/CheckBox.stories.d.ts +0 -1
  152. package/dist/dist/CheckBox.stories.js +0 -22
  153. package/dist/dist/CheckBox.stories.js.map +0 -1
  154. package/dist/dist/Common.d.ts +0 -5
  155. package/dist/dist/Common.js +0 -47
  156. package/dist/dist/Common.js.map +0 -1
  157. package/dist/dist/DateTimeActionSheet.d.ts +0 -5
  158. package/dist/dist/DateTimeActionSheet.js +0 -24
  159. package/dist/dist/DateTimeActionSheet.js.map +0 -1
  160. package/dist/dist/DecimalRangeActionSheet.d.ts +0 -9
  161. package/dist/dist/DecimalRangeActionSheet.js +0 -57
  162. package/dist/dist/DecimalRangeActionSheet.js.map +0 -1
  163. package/dist/dist/ErrorBoundary.d.ts +0 -12
  164. package/dist/dist/ErrorBoundary.js +0 -32
  165. package/dist/dist/ErrorBoundary.js.map +0 -1
  166. package/dist/dist/ErrorPage.d.ts +0 -7
  167. package/dist/dist/ErrorPage.js +0 -15
  168. package/dist/dist/ErrorPage.js.map +0 -1
  169. package/dist/dist/Field.d.ts +0 -17
  170. package/dist/dist/Field.js +0 -136
  171. package/dist/dist/Field.js.map +0 -1
  172. package/dist/dist/Field.stories.d.ts +0 -6
  173. package/dist/dist/Field.stories.js +0 -25
  174. package/dist/dist/Field.stories.js.map +0 -1
  175. package/dist/dist/FieldWithLabels.d.ts +0 -10
  176. package/dist/dist/FieldWithLabels.js +0 -7
  177. package/dist/dist/FieldWithLabels.js.map +0 -1
  178. package/dist/dist/FlatList.d.ts +0 -1
  179. package/dist/dist/FlatList.js +0 -4
  180. package/dist/dist/FlatList.js.map +0 -1
  181. package/dist/dist/Form.d.ts +0 -15
  182. package/dist/dist/Form.js +0 -56
  183. package/dist/dist/Form.js.map +0 -1
  184. package/dist/dist/Form.stories.d.ts +0 -6
  185. package/dist/dist/Form.stories.js +0 -27
  186. package/dist/dist/Form.stories.js.map +0 -1
  187. package/dist/dist/HeaderButtons.d.ts +0 -39
  188. package/dist/dist/HeaderButtons.js +0 -50
  189. package/dist/dist/HeaderButtons.js.map +0 -1
  190. package/dist/dist/HeaderButtons.stories.d.ts +0 -6
  191. package/dist/dist/HeaderButtons.stories.js +0 -7
  192. package/dist/dist/HeaderButtons.stories.js.map +0 -1
  193. package/dist/dist/Heading.d.ts +0 -32
  194. package/dist/dist/Heading.js +0 -47
  195. package/dist/dist/Heading.js.map +0 -1
  196. package/dist/dist/Heading.stories.d.ts +0 -1
  197. package/dist/dist/Heading.stories.js +0 -11
  198. package/dist/dist/Heading.stories.js.map +0 -1
  199. package/dist/dist/HeightActionSheet.d.ts +0 -9
  200. package/dist/dist/HeightActionSheet.js +0 -50
  201. package/dist/dist/HeightActionSheet.js.map +0 -1
  202. package/dist/dist/Icon.d.ts +0 -12
  203. package/dist/dist/Icon.js +0 -126
  204. package/dist/dist/Icon.js.map +0 -1
  205. package/dist/dist/Icon.stories.d.ts +0 -1
  206. package/dist/dist/Icon.stories.js +0 -11
  207. package/dist/dist/Icon.stories.js.map +0 -1
  208. package/dist/dist/IconButton.d.ts +0 -42
  209. package/dist/dist/IconButton.js +0 -41
  210. package/dist/dist/IconButton.js.map +0 -1
  211. package/dist/dist/IconButton.stories.d.ts +0 -1
  212. package/dist/dist/IconButton.stories.js +0 -8
  213. package/dist/dist/IconButton.stories.js.map +0 -1
  214. package/dist/dist/Image.d.ts +0 -9
  215. package/dist/dist/Image.js +0 -37
  216. package/dist/dist/Image.js.map +0 -1
  217. package/dist/dist/ImageBackground.d.ts +0 -6
  218. package/dist/dist/ImageBackground.js +0 -9
  219. package/dist/dist/ImageBackground.js.map +0 -1
  220. package/dist/dist/Layer.d.ts +0 -5
  221. package/dist/dist/Layer.js +0 -13
  222. package/dist/dist/Layer.js.map +0 -1
  223. package/dist/dist/Link.d.ts +0 -7
  224. package/dist/dist/Link.js +0 -13
  225. package/dist/dist/Link.js.map +0 -1
  226. package/dist/dist/Link.stories.d.ts +0 -1
  227. package/dist/dist/Link.stories.js +0 -8
  228. package/dist/dist/Link.stories.js.map +0 -1
  229. package/dist/dist/Mask.d.ts +0 -5
  230. package/dist/dist/Mask.js +0 -23
  231. package/dist/dist/Mask.js.map +0 -1
  232. package/dist/dist/Mask.stories.d.ts +0 -1
  233. package/dist/dist/Mask.stories.js +0 -13
  234. package/dist/dist/Mask.stories.js.map +0 -1
  235. package/dist/dist/MediaQuery.d.ts +0 -2
  236. package/dist/dist/MediaQuery.js +0 -34
  237. package/dist/dist/MediaQuery.js.map +0 -1
  238. package/dist/dist/Meta.d.ts +0 -6
  239. package/dist/dist/Meta.js +0 -8
  240. package/dist/dist/Meta.js.map +0 -1
  241. package/dist/dist/ModalSheet.d.ts +0 -3
  242. package/dist/dist/ModalSheet.js +0 -43
  243. package/dist/dist/ModalSheet.js.map +0 -1
  244. package/dist/dist/NumberPickerActionSheet.d.ts +0 -5
  245. package/dist/dist/NumberPickerActionSheet.js +0 -25
  246. package/dist/dist/NumberPickerActionSheet.js.map +0 -1
  247. package/dist/dist/Page.d.ts +0 -9
  248. package/dist/dist/Page.js +0 -26
  249. package/dist/dist/Page.js.map +0 -1
  250. package/dist/dist/Permissions.d.ts +0 -1
  251. package/dist/dist/Permissions.js +0 -36
  252. package/dist/dist/Permissions.js.map +0 -1
  253. package/dist/dist/PickerSelect.d.ts +0 -172
  254. package/dist/dist/PickerSelect.js +0 -403
  255. package/dist/dist/PickerSelect.js.map +0 -1
  256. package/dist/dist/Pill.d.ts +0 -7
  257. package/dist/dist/Pill.js +0 -10
  258. package/dist/dist/Pill.js.map +0 -1
  259. package/dist/dist/Pill.stories.d.ts +0 -1
  260. package/dist/dist/Pill.stories.js +0 -36
  261. package/dist/dist/Pill.stories.js.map +0 -1
  262. package/dist/dist/Pog.d.ts +0 -7
  263. package/dist/dist/Pog.js +0 -144
  264. package/dist/dist/Pog.js.map +0 -1
  265. package/dist/dist/ProgressBar.d.ts +0 -16
  266. package/dist/dist/ProgressBar.js +0 -40
  267. package/dist/dist/ProgressBar.js.map +0 -1
  268. package/dist/dist/ScrollView.d.ts +0 -1
  269. package/dist/dist/ScrollView.js +0 -4
  270. package/dist/dist/ScrollView.js.map +0 -1
  271. package/dist/dist/SegmentedControl.d.ts +0 -9
  272. package/dist/dist/SegmentedControl.js +0 -18
  273. package/dist/dist/SegmentedControl.js.map +0 -1
  274. package/dist/dist/SegmentedControl.stories.d.ts +0 -1
  275. package/dist/dist/SegmentedControl.stories.js +0 -32
  276. package/dist/dist/SegmentedControl.stories.js.map +0 -1
  277. package/dist/dist/SelectList.d.ts +0 -9
  278. package/dist/dist/SelectList.js +0 -29
  279. package/dist/dist/SelectList.js.map +0 -1
  280. package/dist/dist/SelectList.stories.d.ts +0 -1
  281. package/dist/dist/SelectList.stories.js +0 -24
  282. package/dist/dist/SelectList.stories.js.map +0 -1
  283. package/dist/dist/Spinner.d.ts +0 -44
  284. package/dist/dist/Spinner.js +0 -58
  285. package/dist/dist/Spinner.js.map +0 -1
  286. package/dist/dist/Spinner.stories.d.ts +0 -1
  287. package/dist/dist/Spinner.stories.js +0 -10
  288. package/dist/dist/Spinner.stories.js.map +0 -1
  289. package/dist/dist/SplitPage.d.ts +0 -7
  290. package/dist/dist/SplitPage.js +0 -20
  291. package/dist/dist/SplitPage.js.map +0 -1
  292. package/dist/dist/SplitPage.stories.d.ts +0 -1
  293. package/dist/dist/SplitPage.stories.js +0 -7
  294. package/dist/dist/SplitPage.stories.js.map +0 -1
  295. package/dist/dist/StorybookContainer.d.ts +0 -7
  296. package/dist/dist/StorybookContainer.js +0 -9
  297. package/dist/dist/StorybookContainer.js.map +0 -1
  298. package/dist/dist/Switch.d.ts +0 -6
  299. package/dist/dist/Switch.js +0 -10
  300. package/dist/dist/Switch.js.map +0 -1
  301. package/dist/dist/Switch.stories.d.ts +0 -1
  302. package/dist/dist/Switch.stories.js +0 -27
  303. package/dist/dist/Switch.stories.js.map +0 -1
  304. package/dist/dist/TapToEdit.d.ts +0 -9
  305. package/dist/dist/TapToEdit.js +0 -27
  306. package/dist/dist/TapToEdit.js.map +0 -1
  307. package/dist/dist/Text.d.ts +0 -36
  308. package/dist/dist/Text.js +0 -86
  309. package/dist/dist/Text.js.map +0 -1
  310. package/dist/dist/Text.stories.d.ts +0 -1
  311. package/dist/dist/Text.stories.js +0 -13
  312. package/dist/dist/Text.stories.js.map +0 -1
  313. package/dist/dist/TextArea.d.ts +0 -6
  314. package/dist/dist/TextArea.js +0 -13
  315. package/dist/dist/TextArea.js.map +0 -1
  316. package/dist/dist/TextArea.stories.d.ts +0 -12
  317. package/dist/dist/TextArea.stories.js +0 -21
  318. package/dist/dist/TextArea.stories.js.map +0 -1
  319. package/dist/dist/TextField.d.ts +0 -47
  320. package/dist/dist/TextField.js +0 -199
  321. package/dist/dist/TextField.js.map +0 -1
  322. package/dist/dist/TextField.stories.d.ts +0 -6
  323. package/dist/dist/TextField.stories.js +0 -15
  324. package/dist/dist/TextField.stories.js.map +0 -1
  325. package/dist/dist/TextFieldNumberActionSheet.d.ts +0 -5
  326. package/dist/dist/TextFieldNumberActionSheet.js +0 -24
  327. package/dist/dist/TextFieldNumberActionSheet.js.map +0 -1
  328. package/dist/dist/UnifiedScreens.d.ts +0 -2
  329. package/dist/dist/UnifiedScreens.js +0 -26
  330. package/dist/dist/UnifiedScreens.js.map +0 -1
  331. package/dist/dist/Unifier.d.ts +0 -131
  332. package/dist/dist/Unifier.js +0 -198
  333. package/dist/dist/Unifier.js.map +0 -1
  334. package/dist/dist/Utilities.d.ts +0 -51
  335. package/dist/dist/Utilities.js +0 -77
  336. package/dist/dist/Utilities.js.map +0 -1
  337. package/dist/dist/WithLabel.d.ts +0 -6
  338. package/dist/dist/WithLabel.js +0 -23
  339. package/dist/dist/WithLabel.js.map +0 -1
  340. package/dist/dist/index.d.ts +0 -43
  341. package/dist/dist/index.js +0 -49
  342. package/dist/dist/index.js.map +0 -1
@@ -1,637 +0,0 @@
1
- import React, { Component, createRef } from "react";
2
- import { Animated, Dimensions, findNodeHandle, FlatList, Keyboard, Modal, Platform, SafeAreaView, StatusBar, StyleSheet, TextInput, TouchableOpacity, UIManager, View, } from "react-native";
3
- export const styles = StyleSheet.create({
4
- scrollView: {
5
- height: "100%",
6
- width: "100%",
7
- backgroundColor: "transparent",
8
- },
9
- container: {
10
- width: "100%",
11
- backgroundColor: "white",
12
- alignSelf: "center",
13
- },
14
- safearea: {
15
- position: "absolute",
16
- top: 999999,
17
- left: 999999,
18
- },
19
- indicator: {
20
- height: 6,
21
- width: 45,
22
- borderRadius: 100,
23
- backgroundColor: "#f0f0f0",
24
- marginVertical: 5,
25
- alignSelf: "center",
26
- },
27
- parentContainer: {
28
- width: "100%",
29
- height: "100%",
30
- justifyContent: "center",
31
- alignItems: "center",
32
- },
33
- });
34
- export function getDeviceHeight(statusBarTranslucent) {
35
- let height = Dimensions.get("window").height;
36
- if (Platform.OS === "android" && !statusBarTranslucent) {
37
- return StatusBar.currentHeight ? height - StatusBar.currentHeight : height;
38
- }
39
- return height;
40
- }
41
- export const getElevation = (elevation) => {
42
- if (!elevation) {
43
- return {};
44
- }
45
- return {
46
- elevation,
47
- shadowColor: "black",
48
- shadowOffset: { width: 0.3 * elevation, height: 0.5 * elevation },
49
- shadowOpacity: 0.2,
50
- shadowRadius: 0.7 * elevation,
51
- };
52
- };
53
- export const SUPPORTED_ORIENTATIONS = ["portrait", "portrait-upside-down", "landscape", "landscape-left", "landscape-right"];
54
- export const waitAsync = (ms) => new Promise((resolve) => {
55
- setTimeout(() => {
56
- resolve(null);
57
- }, ms);
58
- });
59
- let safeAreaInnerHeight = 0;
60
- const dummyData = ["dummy"];
61
- let safeAreaPaddingTop = Platform.OS === "android" ? StatusBar.currentHeight || 0 : 0;
62
- let calculatedDeviceHeight = Dimensions.get("window").height;
63
- const defaultProps = {
64
- animated: true,
65
- closeOnPressBack: true,
66
- bounciness: 8,
67
- extraScroll: 0,
68
- closeAnimationDuration: 300,
69
- delayActionSheetDrawTime: 0,
70
- openAnimationSpeed: 12,
71
- springOffset: 100,
72
- elevation: 5,
73
- initialOffsetFromBottom: 1,
74
- indicatorColor: "#f0f0f0",
75
- defaultOverlayOpacity: 0.3,
76
- overlayColor: "black",
77
- closable: true,
78
- bottomOffset: 0,
79
- closeOnTouchBackdrop: true,
80
- drawUnderStatusBar: true,
81
- statusBarTranslucent: true,
82
- keyboardMode: "padding",
83
- gestureEnabled: false,
84
- };
85
- export class ActionSheet extends Component {
86
- constructor(props) {
87
- super(props);
88
- this.actionSheetHeight = 0;
89
- this.prevScroll = 0;
90
- this.timeout = null;
91
- this.offsetY = 0;
92
- this.currentOffsetFromBottom = 0;
93
- this.scrollAnimationEndValue = 0;
94
- this.hasBounced = false;
95
- this.layoutHasCalled = false;
96
- this.isClosing = false;
97
- this.isRecoiling = false;
98
- this.isReachedTop = false;
99
- this.deviceLayoutCalled = false;
100
- /**
101
- * Snap ActionSheet to Offset
102
- */
103
- this.snapToOffset = (offset) => {
104
- let correction = this.state.deviceHeight * 0.15;
105
- let extraScroll = this.props.extraScroll || 0;
106
- let scrollOffset = this.props.gestureEnabled
107
- ? offset + correction + extraScroll
108
- : offset + correction + extraScroll;
109
- this.currentOffsetFromBottom = offset / this.actionSheetHeight;
110
- this._scrollTo(scrollOffset);
111
- this.updateActionSheetPosition(scrollOffset);
112
- };
113
- // Open the ActionSheet
114
- this.show = () => {
115
- this.setModalVisible(true);
116
- };
117
- // Close the ActionSheet
118
- this.hide = () => {
119
- this.setModalVisible(false);
120
- };
121
- /**
122
- * Open/Close the ActionSheet
123
- */
124
- this.setModalVisible = (visible) => {
125
- let modalVisible = this.state.modalVisible;
126
- if (visible !== undefined) {
127
- if (modalVisible === visible) {
128
- return;
129
- }
130
- modalVisible = !visible;
131
- }
132
- if (!modalVisible) {
133
- this.setState({
134
- modalVisible: true,
135
- scrollable: this.props.gestureEnabled || false,
136
- });
137
- }
138
- else {
139
- this._hideModal();
140
- }
141
- };
142
- this._hideModal = () => {
143
- if (this.isClosing)
144
- return;
145
- this.isClosing = true;
146
- this._hideAnimation();
147
- };
148
- this.measure = async () => {
149
- return new Promise((resolve) => {
150
- setTimeout(() => {
151
- UIManager.measureInWindow(this.safeAreaViewRef.current._nativeTag, (x, y, width, height) => {
152
- safeAreaPaddingTop = height;
153
- resolve(height === 0 ? 20 : height);
154
- });
155
- }, 100);
156
- });
157
- };
158
- this._showModal = async (event) => {
159
- let { gestureEnabled, delayActionSheetDraw, delayActionSheetDrawTime } = this.props;
160
- if (!(event === null || event === void 0 ? void 0 : event.nativeEvent))
161
- return;
162
- let height = event.nativeEvent.layout.height;
163
- if (this.layoutHasCalled) {
164
- this.actionSheetHeight = height;
165
- this._returnToPrevScrollPosition(height);
166
- return;
167
- }
168
- else {
169
- this.layoutHasCalled = true;
170
- this.actionSheetHeight = height;
171
- let scrollOffset = this.getInitialScrollPosition();
172
- this.isRecoiling = false;
173
- if (Platform.OS === "ios") {
174
- await waitAsync(delayActionSheetDrawTime);
175
- }
176
- else {
177
- if (delayActionSheetDraw) {
178
- await waitAsync(delayActionSheetDrawTime);
179
- }
180
- }
181
- this._scrollTo(scrollOffset, false);
182
- this.prevScroll = scrollOffset;
183
- if (Platform.OS === "ios") {
184
- await waitAsync(delayActionSheetDrawTime !== null && delayActionSheetDrawTime !== void 0 ? delayActionSheetDrawTime : 0 / 2);
185
- }
186
- else {
187
- if (delayActionSheetDraw) {
188
- await waitAsync(delayActionSheetDrawTime !== null && delayActionSheetDrawTime !== void 0 ? delayActionSheetDrawTime : 0 / 2);
189
- }
190
- }
191
- this._openAnimation(scrollOffset);
192
- this.underlayScale.setValue(1);
193
- this.underlayTranslateY.setValue(100);
194
- if (!gestureEnabled) {
195
- this.props.onPositionChanged && this.props.onPositionChanged(true);
196
- }
197
- this.updateActionSheetPosition(scrollOffset);
198
- }
199
- };
200
- this._openAnimation = (scrollOffset) => {
201
- let { bounciness, bounceOnOpen, animated, openAnimationSpeed } = this.props;
202
- if (animated) {
203
- this.transformValue.setValue(scrollOffset);
204
- Animated.parallel([
205
- Animated.spring(this.transformValue, {
206
- toValue: 0,
207
- bounciness: bounceOnOpen ? bounciness : 1,
208
- speed: openAnimationSpeed,
209
- useNativeDriver: true,
210
- }),
211
- Animated.timing(this.opacityValue, {
212
- toValue: 1,
213
- duration: 150,
214
- useNativeDriver: true,
215
- }),
216
- ]).start();
217
- }
218
- else {
219
- this.opacityValue.setValue(1);
220
- }
221
- };
222
- this._onScrollBegin = async () => { };
223
- this._onScrollBeginDrag = async (event) => {
224
- let verticalOffset = event.nativeEvent.contentOffset.y;
225
- this.prevScroll = verticalOffset;
226
- };
227
- this._onScrollEnd = async (event) => {
228
- var _a;
229
- let { springOffset, extraScroll } = this.props;
230
- let verticalOffset = event.nativeEvent.contentOffset.y;
231
- let correction = this.state.deviceHeight * 0.15;
232
- if (this.isRecoiling)
233
- return;
234
- if (this.prevScroll < verticalOffset) {
235
- if (verticalOffset - this.prevScroll > (springOffset !== null && springOffset !== void 0 ? springOffset : 0) * 0.75) {
236
- this.isRecoiling = true;
237
- this._applyHeightLimiter();
238
- this.currentOffsetFromBottom =
239
- this.currentOffsetFromBottom < ((_a = this.props.initialOffsetFromBottom) !== null && _a !== void 0 ? _a : 0)
240
- ? this.props.initialOffsetFromBottom
241
- : 1;
242
- let scrollOffset = this.actionSheetHeight * this.currentOffsetFromBottom + correction + (extraScroll !== null && extraScroll !== void 0 ? extraScroll : 0);
243
- this._scrollTo(scrollOffset);
244
- await waitAsync(300);
245
- this.isRecoiling = false;
246
- this.props.onPositionChanged && this.props.onPositionChanged(true);
247
- }
248
- else {
249
- this._returnToPrevScrollPosition(this.actionSheetHeight);
250
- }
251
- }
252
- else {
253
- if (this.prevScroll - verticalOffset > (springOffset !== null && springOffset !== void 0 ? springOffset : 0)) {
254
- this._hideModal();
255
- }
256
- else {
257
- if (this.isRecoiling) {
258
- return;
259
- }
260
- this.isRecoiling = true;
261
- this._returnToPrevScrollPosition(this.actionSheetHeight);
262
- await waitAsync(300);
263
- this.isRecoiling = false;
264
- }
265
- }
266
- };
267
- this._scrollTo = (y, animated = true) => {
268
- var _a;
269
- this.scrollAnimationEndValue = y;
270
- this.prevScroll = y;
271
- (_a = this.scrollViewRef.current) === null || _a === void 0 ? void 0 : _a._listRef._scrollRef.scrollTo({
272
- x: 0,
273
- y: this.scrollAnimationEndValue,
274
- animated: animated,
275
- });
276
- };
277
- this._onTouchMove = () => {
278
- if (this.props.closeOnTouchBackdrop) {
279
- this._hideModal();
280
- }
281
- this.setState({
282
- scrollable: false,
283
- });
284
- };
285
- this._onTouchStart = () => {
286
- if (this.props.closeOnTouchBackdrop) {
287
- this._hideModal();
288
- }
289
- this.setState({
290
- scrollable: false,
291
- });
292
- };
293
- this._onTouchEnd = () => {
294
- this._returnToPrevScrollPosition(this.actionSheetHeight);
295
- if (this.props.gestureEnabled) {
296
- this.setState({
297
- scrollable: true,
298
- });
299
- }
300
- };
301
- this._onScroll = (event) => {
302
- this.offsetY = event.nativeEvent.contentOffset.y;
303
- let correction = this.state.deviceHeight * 0.15;
304
- let distanceFromTop = this.actionSheetHeight + correction - this.offsetY;
305
- if (this.actionSheetHeight < this.offsetY) {
306
- if (!this.isReachedTop) {
307
- this.isReachedTop = true;
308
- this.props.onPositionChanged && this.props.onPositionChanged(true);
309
- }
310
- }
311
- else {
312
- if (this.isReachedTop) {
313
- this.isReachedTop = false;
314
- this.props.onPositionChanged && this.props.onPositionChanged(false);
315
- }
316
- }
317
- if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
318
- if (distanceFromTop < safeAreaPaddingTop) {
319
- if (!this.props.drawUnderStatusBar)
320
- return;
321
- this.indicatorTranslateY.setValue(-this.state.paddingTop + (safeAreaPaddingTop - distanceFromTop));
322
- }
323
- else {
324
- this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
325
- }
326
- }
327
- };
328
- this._onRequestClose = () => {
329
- if (this.props.closeOnPressBack)
330
- this._hideModal();
331
- };
332
- this._onTouchBackdrop = () => {
333
- if (this.props.closeOnTouchBackdrop) {
334
- this._hideModal();
335
- }
336
- };
337
- this._onKeyboardShow = (event) => {
338
- this.setState({
339
- keyboard: true,
340
- });
341
- // eslint-disable-next-line @typescript-eslint/no-var-requires
342
- const ReactNativeVersion = require("react-native/Libraries/Core/ReactNativeVersion");
343
- let v = ReactNativeVersion.version.major + ReactNativeVersion.version.minor;
344
- v = parseInt(v);
345
- if (v >= 63 || Platform.OS === "ios") {
346
- let keyboardHeight = event.endCoordinates.height;
347
- const { height: windowHeight } = Dimensions.get("window");
348
- const currentlyFocusedField = TextInput.State.currentlyFocusedField
349
- ? findNodeHandle(TextInput.State.currentlyFocusedField())
350
- : TextInput.State.currentlyFocusedField();
351
- if (!currentlyFocusedField) {
352
- return;
353
- }
354
- UIManager.measure(currentlyFocusedField, (originX, originY, width, height, pageX, pageY) => {
355
- const fieldHeight = height;
356
- const fieldTop = pageY;
357
- const gap = windowHeight - keyboardHeight - (fieldTop + fieldHeight);
358
- if (gap >= 0) {
359
- return;
360
- }
361
- let toValue = this.props.keyboardMode === "position" ? -(keyboardHeight + 15) : gap - 10;
362
- Animated.timing(this.transformValue, {
363
- toValue: toValue,
364
- duration: 250,
365
- useNativeDriver: true,
366
- }).start();
367
- });
368
- }
369
- else {
370
- Animated.timing(this.transformValue, {
371
- toValue: -10,
372
- duration: 250,
373
- useNativeDriver: true,
374
- }).start();
375
- }
376
- };
377
- /**
378
- * Attach this to any child ScrollView Component's onScrollEndDrag,
379
- * onMomentumScrollEnd,onScrollAnimationEnd callbacks to handle the ActionSheet
380
- * closing and bouncing back properly.
381
- */
382
- this.handleChildScrollEnd = async () => {
383
- var _a, _b;
384
- if (this.offsetY > this.prevScroll)
385
- return;
386
- if (this.prevScroll - ((_a = this.props.springOffset) !== null && _a !== void 0 ? _a : 0) > this.offsetY) {
387
- let scrollOffset = this.getInitialScrollPosition();
388
- if (this.offsetY > scrollOffset - 100) {
389
- this.isRecoiling = true;
390
- this._scrollTo(scrollOffset);
391
- this.currentOffsetFromBottom = (_b = this.props.initialOffsetFromBottom) !== null && _b !== void 0 ? _b : 0;
392
- this.prevScroll = scrollOffset;
393
- setTimeout(() => {
394
- this.isRecoiling = false;
395
- }, 500);
396
- }
397
- else {
398
- this._hideModal();
399
- }
400
- }
401
- else {
402
- this.isRecoiling = true;
403
- this._scrollTo(this.prevScroll, true);
404
- setTimeout(() => {
405
- this.isRecoiling = false;
406
- }, 500);
407
- }
408
- };
409
- this._onKeyboardHide = () => {
410
- this.setState({
411
- keyboard: false,
412
- });
413
- this.opacityValue.setValue(1);
414
- Animated.timing(this.transformValue, {
415
- toValue: 0,
416
- duration: 100,
417
- useNativeDriver: true,
418
- }).start();
419
- };
420
- this._onDeviceLayout = async (_event) => {
421
- let event = Object.assign({}, _event);
422
- if (this.timeout) {
423
- clearTimeout(this.timeout);
424
- }
425
- this.timeout = setTimeout(async () => {
426
- var _a;
427
- let safeMarginFromTop = 0;
428
- let measuredPadding = Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;
429
- if (!this.props.drawUnderStatusBar) {
430
- if (Platform.OS === "android" && !this.props.statusBarTranslucent)
431
- return;
432
- safeMarginFromTop = measuredPadding !== null && measuredPadding !== void 0 ? measuredPadding : 0;
433
- this.indicatorTranslateY.setValue(-measuredPadding);
434
- }
435
- else {
436
- this.updateActionSheetPosition(this.offsetY);
437
- }
438
- let height = event.nativeEvent.layout.height - safeMarginFromTop;
439
- let width = Dimensions.get("window").width;
440
- if ((height === null || height === void 0 ? void 0 : height.toFixed(0)) === (calculatedDeviceHeight === null || calculatedDeviceHeight === void 0 ? void 0 : calculatedDeviceHeight.toFixed(0)) &&
441
- (width === null || width === void 0 ? void 0 : width.toFixed(0)) === ((_a = this.state.deviceWidth) === null || _a === void 0 ? void 0 : _a.toFixed(0)) &&
442
- this.deviceLayoutCalled)
443
- return;
444
- this.deviceLayoutCalled = true;
445
- calculatedDeviceHeight = height;
446
- this.setState({
447
- deviceHeight: height,
448
- deviceWidth: width,
449
- portrait: height > width,
450
- paddingTop: measuredPadding,
451
- });
452
- }, 1);
453
- };
454
- this._keyExtractor = (item) => item;
455
- this.state = {
456
- modalVisible: false,
457
- scrollable: false,
458
- layoutHasCalled: false,
459
- keyboard: false,
460
- deviceHeight: calculatedDeviceHeight || getDeviceHeight(this.props.statusBarTranslucent),
461
- deviceWidth: Dimensions.get("window").width,
462
- portrait: true,
463
- safeAreaInnerHeight,
464
- paddingTop: safeAreaPaddingTop,
465
- };
466
- this.actionSheetHeight = 0;
467
- this.prevScroll = 0;
468
- this.scrollAnimationEndValue = 0;
469
- this.hasBounced = false;
470
- this.scrollViewRef = createRef();
471
- this.layoutHasCalled = false;
472
- this.isClosing = false;
473
- this.isRecoiling = false;
474
- this.offsetY = 0;
475
- this.safeAreaViewRef = createRef();
476
- this.transformValue = new Animated.Value(0);
477
- this.opacityValue = new Animated.Value(0);
478
- this.borderRadius = new Animated.Value(10);
479
- this.currentOffsetFromBottom = this.props.initialOffsetFromBottom;
480
- this.underlayTranslateY = new Animated.Value(100);
481
- this.underlayScale = new Animated.Value(1);
482
- this.indicatorTranslateY = new Animated.Value(-this.state.paddingTop | 0);
483
- this.isReachedTop = false;
484
- this.deviceLayoutCalled = false;
485
- this.timeout = null;
486
- }
487
- _hideAnimation() {
488
- let { animated, closeAnimationDuration, bottomOffset, initialOffsetFromBottom, extraScroll, closable, } = this.props;
489
- Animated.parallel([
490
- Animated.timing(this.opacityValue, {
491
- toValue: closable ? 0 : 1,
492
- duration: animated ? closeAnimationDuration : 1,
493
- useNativeDriver: true,
494
- }),
495
- Animated.timing(this.transformValue, {
496
- toValue: closable ? this.actionSheetHeight * 2 : 0,
497
- duration: animated ? closeAnimationDuration : 1,
498
- useNativeDriver: true,
499
- }),
500
- ]).start();
501
- waitAsync(closeAnimationDuration / 1.5).then(() => {
502
- if (!closable) {
503
- if (bottomOffset && bottomOffset > 0) {
504
- this.snapToOffset(bottomOffset);
505
- }
506
- else {
507
- this._scrollTo((this.actionSheetHeight * (initialOffsetFromBottom || 0)) +
508
- this.state.deviceHeight * 0.1 +
509
- (extraScroll !== null && extraScroll !== void 0 ? extraScroll : 0), true);
510
- this.currentOffsetFromBottom = initialOffsetFromBottom;
511
- }
512
- this.isClosing = false;
513
- }
514
- else {
515
- this._scrollTo(0, false);
516
- this.currentOffsetFromBottom = initialOffsetFromBottom;
517
- this.setState({
518
- modalVisible: !closable,
519
- }, () => {
520
- this.isClosing = false;
521
- this.isReachedTop = false;
522
- this.props.onPositionChanged && this.props.onPositionChanged(false);
523
- this.indicatorTranslateY.setValue(-this.state.paddingTop);
524
- this.layoutHasCalled = false;
525
- this.deviceLayoutCalled = false;
526
- this.props.onClose && this.props.onClose();
527
- });
528
- }
529
- });
530
- }
531
- _applyHeightLimiter() {
532
- if (this.actionSheetHeight > this.state.deviceHeight) {
533
- this.actionSheetHeight =
534
- (this.actionSheetHeight - (this.actionSheetHeight - this.state.deviceHeight)) * 1;
535
- }
536
- }
537
- updateActionSheetPosition(scrollPosition) {
538
- if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
539
- let correction = this.state.deviceHeight * 0.15;
540
- let distanceFromTop = this.actionSheetHeight + correction - scrollPosition;
541
- if (distanceFromTop < safeAreaPaddingTop) {
542
- if (!this.props.drawUnderStatusBar)
543
- return;
544
- this.indicatorTranslateY.setValue(0);
545
- }
546
- else {
547
- this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
548
- }
549
- }
550
- }
551
- _returnToPrevScrollPosition(height) {
552
- var _a;
553
- let correction = this.state.deviceHeight * 0.15;
554
- let scrollOffset = height * this.currentOffsetFromBottom + correction + ((_a = this.props.extraScroll) !== null && _a !== void 0 ? _a : 0);
555
- this.updateActionSheetPosition(scrollOffset);
556
- this._scrollTo(scrollOffset);
557
- }
558
- componentDidMount() {
559
- Keyboard.addListener(Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow", this._onKeyboardShow);
560
- Keyboard.addListener(Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide", this._onKeyboardHide);
561
- }
562
- componentWillUnmount() {
563
- Keyboard.removeListener(Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow", this._onKeyboardShow);
564
- Keyboard.removeListener(Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide", this._onKeyboardHide);
565
- }
566
- getInitialScrollPosition() {
567
- var _a, _b, _c, _d;
568
- this._applyHeightLimiter();
569
- let correction = this.state.deviceHeight * 0.15;
570
- let scrollPosition = this.props.gestureEnabled
571
- ? this.actionSheetHeight * ((_a = this.props.initialOffsetFromBottom) !== null && _a !== void 0 ? _a : 0) +
572
- correction +
573
- ((_b = this.props.extraScroll) !== null && _b !== void 0 ? _b : 0)
574
- : this.actionSheetHeight + correction + ((_c = this.props.extraScroll) !== null && _c !== void 0 ? _c : 0);
575
- this.currentOffsetFromBottom = (_d = this.props.initialOffsetFromBottom) !== null && _d !== void 0 ? _d : 0;
576
- this.updateActionSheetPosition(scrollPosition);
577
- return scrollPosition;
578
- }
579
- render() {
580
- let { scrollable, modalVisible, keyboard } = this.state;
581
- let { onOpen, overlayColor, gestureEnabled, elevation, indicatorColor, defaultOverlayOpacity, children, containerStyle, CustomHeaderComponent, headerAlwaysVisible, keyboardShouldPersistTaps, statusBarTranslucent, } = this.props;
582
- return (React.createElement(Modal, { visible: modalVisible, animationType: "none",
583
- // testID={testID}
584
- supportedOrientations: SUPPORTED_ORIENTATIONS, onShow: onOpen, onRequestClose: this._onRequestClose, transparent: true, statusBarTranslucent: statusBarTranslucent }, React.createElement(Animated.View, { onLayout: this._onDeviceLayout, style: [
585
- styles.parentContainer,
586
- {
587
- opacity: this.opacityValue,
588
- width: this.state.deviceWidth,
589
- },
590
- ] }, React.createElement(SafeAreaView, { ref: this.safeAreaViewRef, style: styles.safearea }, React.createElement(View, null)), React.createElement(FlatList, { bounces: false, keyboardShouldPersistTaps: keyboardShouldPersistTaps, ref: this.scrollViewRef, scrollEventThrottle: 5, showsVerticalScrollIndicator: false, onMomentumScrollBegin: this._onScrollBegin, onMomentumScrollEnd: this._onScrollEnd, scrollEnabled: scrollable && !keyboard, onScrollBeginDrag: this._onScrollBeginDrag, onTouchEnd: this._onTouchEnd, onScroll: this._onScroll, scrollsToTop: false, style: [
591
- styles.scrollView,
592
- {
593
- width: this.state.deviceWidth,
594
- },
595
- ], contentContainerStyle: {
596
- width: this.state.deviceWidth,
597
- }, data: dummyData, keyExtractor: this._keyExtractor, renderItem: () => (React.createElement(View, { style: {
598
- width: "100%",
599
- } }, React.createElement(Animated.View, { onTouchStart: this._onTouchBackdrop, onTouchMove: this._onTouchBackdrop, onTouchEnd: this._onTouchBackdrop, style: {
600
- height: "100%",
601
- width: "100%",
602
- position: "absolute",
603
- zIndex: 1,
604
- backgroundColor: overlayColor,
605
- opacity: defaultOverlayOpacity,
606
- } }), React.createElement(View, { onTouchMove: this._onTouchMove, onTouchStart: this._onTouchStart, onTouchEnd: this._onTouchEnd, style: {
607
- height: this.state.deviceHeight * 1.15,
608
- width: "100%",
609
- zIndex: 10,
610
- } }, React.createElement(TouchableOpacity, { onPress: this._onTouchBackdrop, onLongPress: this._onTouchBackdrop, style: {
611
- height: this.state.deviceHeight * 1.15,
612
- width: "100%",
613
- } })), React.createElement(Animated.View, { onLayout: this._showModal, style: [
614
- styles.container,
615
- {
616
- borderRadius: 10,
617
- },
618
- containerStyle,
619
- Object.assign(Object.assign({}, getElevation(elevation)), { zIndex: 11, opacity: this.opacityValue, transform: [
620
- {
621
- translateY: this.transformValue,
622
- },
623
- ], maxHeight: this.state.deviceHeight }),
624
- ] }, React.createElement(Animated.View, { style: {
625
- maxHeight: this.state.deviceHeight,
626
- transform: [
627
- {
628
- translateY: this.indicatorTranslateY,
629
- },
630
- ],
631
- marginTop: this.state.paddingTop,
632
- } }, gestureEnabled || headerAlwaysVisible ? (CustomHeaderComponent ? (CustomHeaderComponent) : (React.createElement(Animated.View, { style: [styles.indicator, { backgroundColor: indicatorColor }] }))) : null, children)))) }))));
633
- }
634
- }
635
- ActionSheet.defaultProps = defaultProps;
636
- //# sourceMappingURL=ActionSheet.js.map
637
- //# sourceMappingURL=ActionSheet.js.map