ferns-ui 0.35.0 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/package.json +35 -34
  2. package/src/Common.ts +0 -1
  3. package/src/Field.tsx +1 -2
  4. package/src/Modal.tsx +18 -19
  5. package/src/SegmentedControl.tsx +6 -1
  6. package/src/TapToEdit.tsx +3 -1
  7. package/updateDeps.js +14 -0
  8. package/dist/ActionSheet.d.ts +0 -492
  9. package/dist/ActionSheet.js +0 -649
  10. package/dist/ActionSheet.js.map +0 -1
  11. package/dist/Avatar.d.ts +0 -68
  12. package/dist/Avatar.js +0 -152
  13. package/dist/Avatar.js.map +0 -1
  14. package/dist/Badge.d.ts +0 -10
  15. package/dist/Badge.js +0 -36
  16. package/dist/Badge.js.map +0 -1
  17. package/dist/Banner.d.ts +0 -27
  18. package/dist/Banner.js +0 -56
  19. package/dist/Banner.js.map +0 -1
  20. package/dist/BlurBox.d.ts +0 -5
  21. package/dist/BlurBox.js +0 -28
  22. package/dist/BlurBox.js.map +0 -1
  23. package/dist/BlurBox.native.d.ts +0 -6
  24. package/dist/BlurBox.native.js +0 -30
  25. package/dist/BlurBox.native.js.map +0 -1
  26. package/dist/Body.d.ts +0 -6
  27. package/dist/Body.js +0 -21
  28. package/dist/Body.js.map +0 -1
  29. package/dist/Box.d.ts +0 -3
  30. package/dist/Box.js +0 -251
  31. package/dist/Box.js.map +0 -1
  32. package/dist/Button.d.ts +0 -26
  33. package/dist/Button.js +0 -120
  34. package/dist/Button.js.map +0 -1
  35. package/dist/Card.d.ts +0 -5
  36. package/dist/Card.js +0 -8
  37. package/dist/Card.js.map +0 -1
  38. package/dist/CheckBox.d.ts +0 -3
  39. package/dist/CheckBox.js +0 -40
  40. package/dist/CheckBox.js.map +0 -1
  41. package/dist/Common.d.ts +0 -869
  42. package/dist/Common.js +0 -46
  43. package/dist/Common.js.map +0 -1
  44. package/dist/Constants.d.ts +0 -4
  45. package/dist/Constants.js +0 -54
  46. package/dist/Constants.js.map +0 -1
  47. package/dist/CustomSelect.d.ts +0 -14
  48. package/dist/CustomSelect.js +0 -43
  49. package/dist/CustomSelect.js.map +0 -1
  50. package/dist/DateTimeActionSheet.d.ts +0 -12
  51. package/dist/DateTimeActionSheet.js +0 -248
  52. package/dist/DateTimeActionSheet.js.map +0 -1
  53. package/dist/DateTimeField.android.d.ts +0 -3
  54. package/dist/DateTimeField.android.js +0 -66
  55. package/dist/DateTimeField.android.js.map +0 -1
  56. package/dist/DateTimeField.d.ts +0 -3
  57. package/dist/DateTimeField.ios.d.ts +0 -3
  58. package/dist/DateTimeField.ios.js +0 -48
  59. package/dist/DateTimeField.ios.js.map +0 -1
  60. package/dist/DateTimeField.js +0 -35
  61. package/dist/DateTimeField.js.map +0 -1
  62. package/dist/DecimalRangeActionSheet.d.ts +0 -18
  63. package/dist/DecimalRangeActionSheet.js +0 -65
  64. package/dist/DecimalRangeActionSheet.js.map +0 -1
  65. package/dist/ErrorBoundary.d.ts +0 -19
  66. package/dist/ErrorBoundary.js +0 -29
  67. package/dist/ErrorBoundary.js.map +0 -1
  68. package/dist/ErrorPage.d.ts +0 -10
  69. package/dist/ErrorPage.js +0 -20
  70. package/dist/ErrorPage.js.map +0 -1
  71. package/dist/FernsProvider.d.ts +0 -4
  72. package/dist/FernsProvider.js +0 -9
  73. package/dist/FernsProvider.js.map +0 -1
  74. package/dist/Field.d.ts +0 -17
  75. package/dist/Field.js +0 -114
  76. package/dist/Field.js.map +0 -1
  77. package/dist/FieldWithLabels.d.ts +0 -3
  78. package/dist/FieldWithLabels.js +0 -8
  79. package/dist/FieldWithLabels.js.map +0 -1
  80. package/dist/FlatList.d.ts +0 -2
  81. package/dist/FlatList.js +0 -3
  82. package/dist/FlatList.js.map +0 -1
  83. package/dist/Form.d.ts +0 -22
  84. package/dist/Form.js +0 -89
  85. package/dist/Form.js.map +0 -1
  86. package/dist/HeaderButtons.d.ts +0 -31
  87. package/dist/HeaderButtons.js +0 -53
  88. package/dist/HeaderButtons.js.map +0 -1
  89. package/dist/Heading.d.ts +0 -11
  90. package/dist/Heading.js +0 -46
  91. package/dist/Heading.js.map +0 -1
  92. package/dist/HeightActionSheet.d.ts +0 -16
  93. package/dist/HeightActionSheet.js +0 -58
  94. package/dist/HeightActionSheet.js.map +0 -1
  95. package/dist/Hyperlink.d.ts +0 -43
  96. package/dist/Hyperlink.js +0 -135
  97. package/dist/Hyperlink.js.map +0 -1
  98. package/dist/Icon.d.ts +0 -4
  99. package/dist/Icon.js +0 -14
  100. package/dist/Icon.js.map +0 -1
  101. package/dist/IconButton.d.ts +0 -26
  102. package/dist/IconButton.js +0 -78
  103. package/dist/IconButton.js.map +0 -1
  104. package/dist/Image.d.ts +0 -8
  105. package/dist/Image.js +0 -37
  106. package/dist/Image.js.map +0 -1
  107. package/dist/ImageBackground.d.ts +0 -10
  108. package/dist/ImageBackground.js +0 -8
  109. package/dist/ImageBackground.js.map +0 -1
  110. package/dist/InfoTooltipButton.d.ts +0 -8
  111. package/dist/InfoTooltipButton.js +0 -6
  112. package/dist/InfoTooltipButton.js.map +0 -1
  113. package/dist/Layer.d.ts +0 -9
  114. package/dist/Layer.js +0 -12
  115. package/dist/Layer.js.map +0 -1
  116. package/dist/Link.d.ts +0 -9
  117. package/dist/Link.js +0 -12
  118. package/dist/Link.js.map +0 -1
  119. package/dist/Mask.d.ts +0 -2
  120. package/dist/Mask.js +0 -19
  121. package/dist/Mask.js.map +0 -1
  122. package/dist/MediaQuery.d.ts +0 -4
  123. package/dist/MediaQuery.js +0 -52
  124. package/dist/MediaQuery.js.map +0 -1
  125. package/dist/Meta.d.ts +0 -5
  126. package/dist/Meta.js +0 -7
  127. package/dist/Meta.js.map +0 -1
  128. package/dist/Modal.d.ts +0 -19
  129. package/dist/Modal.js +0 -101
  130. package/dist/Modal.js.map +0 -1
  131. package/dist/ModalSheet.d.ts +0 -7
  132. package/dist/ModalSheet.js +0 -42
  133. package/dist/ModalSheet.js.map +0 -1
  134. package/dist/NumberPickerActionSheet.d.ts +0 -16
  135. package/dist/NumberPickerActionSheet.js +0 -29
  136. package/dist/NumberPickerActionSheet.js.map +0 -1
  137. package/dist/Page.d.ts +0 -26
  138. package/dist/Page.js +0 -38
  139. package/dist/Page.js.map +0 -1
  140. package/dist/Permissions.d.ts +0 -2
  141. package/dist/Permissions.js +0 -35
  142. package/dist/Permissions.js.map +0 -1
  143. package/dist/PickerSelect.d.ts +0 -109
  144. package/dist/PickerSelect.js +0 -296
  145. package/dist/PickerSelect.js.map +0 -1
  146. package/dist/Pill.d.ts +0 -5
  147. package/dist/Pill.js +0 -10
  148. package/dist/Pill.js.map +0 -1
  149. package/dist/Pog.d.ts +0 -15
  150. package/dist/Pog.js +0 -48
  151. package/dist/Pog.js.map +0 -1
  152. package/dist/ProgressBar.d.ts +0 -9
  153. package/dist/ProgressBar.js +0 -41
  154. package/dist/ProgressBar.js.map +0 -1
  155. package/dist/ScrollView.d.ts +0 -2
  156. package/dist/ScrollView.js +0 -3
  157. package/dist/ScrollView.js.map +0 -1
  158. package/dist/SegmentedControl.d.ts +0 -3
  159. package/dist/SegmentedControl.js +0 -55
  160. package/dist/SegmentedControl.js.map +0 -1
  161. package/dist/SelectList.d.ts +0 -18
  162. package/dist/SelectList.js +0 -48
  163. package/dist/SelectList.js.map +0 -1
  164. package/dist/SideDrawer.d.ts +0 -13
  165. package/dist/SideDrawer.js +0 -22
  166. package/dist/SideDrawer.js.map +0 -1
  167. package/dist/Spinner.d.ts +0 -3
  168. package/dist/Spinner.js +0 -16
  169. package/dist/Spinner.js.map +0 -1
  170. package/dist/SplitPage.d.ts +0 -3
  171. package/dist/SplitPage.js +0 -149
  172. package/dist/SplitPage.js.map +0 -1
  173. package/dist/SplitPage.native.d.ts +0 -3
  174. package/dist/SplitPage.native.js +0 -79
  175. package/dist/SplitPage.native.js.map +0 -1
  176. package/dist/Switch.d.ts +0 -5
  177. package/dist/Switch.js +0 -10
  178. package/dist/Switch.js.map +0 -1
  179. package/dist/Table.d.ts +0 -30
  180. package/dist/Table.js +0 -31
  181. package/dist/Table.js.map +0 -1
  182. package/dist/TableHeader.d.ts +0 -22
  183. package/dist/TableHeader.js +0 -11
  184. package/dist/TableHeader.js.map +0 -1
  185. package/dist/TableHeaderCell.d.ts +0 -15
  186. package/dist/TableHeaderCell.js +0 -36
  187. package/dist/TableHeaderCell.js.map +0 -1
  188. package/dist/TableRow.d.ts +0 -29
  189. package/dist/TableRow.js +0 -30
  190. package/dist/TableRow.js.map +0 -1
  191. package/dist/TapToEdit.d.ts +0 -19
  192. package/dist/TapToEdit.js +0 -136
  193. package/dist/TapToEdit.js.map +0 -1
  194. package/dist/Text.d.ts +0 -19
  195. package/dist/Text.js +0 -91
  196. package/dist/Text.js.map +0 -1
  197. package/dist/TextArea.d.ts +0 -6
  198. package/dist/TextArea.js +0 -24
  199. package/dist/TextArea.js.map +0 -1
  200. package/dist/TextField.d.ts +0 -3
  201. package/dist/TextField.js +0 -260
  202. package/dist/TextField.js.map +0 -1
  203. package/dist/TextFieldNumberActionSheet.d.ts +0 -15
  204. package/dist/TextFieldNumberActionSheet.js +0 -28
  205. package/dist/TextFieldNumberActionSheet.js.map +0 -1
  206. package/dist/Toast.d.ts +0 -12
  207. package/dist/Toast.js +0 -46
  208. package/dist/Toast.js.map +0 -1
  209. package/dist/Tooltip.d.ts +0 -9
  210. package/dist/Tooltip.js +0 -174
  211. package/dist/Tooltip.js.map +0 -1
  212. package/dist/UnifiedScreens.d.ts +0 -9
  213. package/dist/UnifiedScreens.js +0 -25
  214. package/dist/UnifiedScreens.js.map +0 -1
  215. package/dist/Unifier.d.ts +0 -45
  216. package/dist/Unifier.js +0 -291
  217. package/dist/Unifier.js.map +0 -1
  218. package/dist/Utilities.d.ts +0 -31
  219. package/dist/Utilities.js +0 -73
  220. package/dist/Utilities.js.map +0 -1
  221. package/dist/WithLabel.d.ts +0 -14
  222. package/dist/WithLabel.js +0 -15
  223. package/dist/WithLabel.js.map +0 -1
  224. package/dist/dayjsExtended.d.ts +0 -2
  225. package/dist/dayjsExtended.js +0 -9
  226. package/dist/dayjsExtended.js.map +0 -1
  227. package/dist/index.d.ts +0 -1299
  228. package/dist/index.js.map +0 -1
  229. package/dist/tableContext.d.ts +0 -21
  230. package/dist/tableContext.js +0 -35
  231. package/dist/tableContext.js.map +0 -1
@@ -1,649 +0,0 @@
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