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