react-native-reorderable-list 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +28 -3
  2. package/lib/commonjs/components/NestedReorderableList.js +41 -0
  3. package/lib/commonjs/components/NestedReorderableList.js.map +1 -0
  4. package/lib/commonjs/components/ReorderableList.js +29 -0
  5. package/lib/commonjs/components/ReorderableList.js.map +1 -0
  6. package/lib/commonjs/components/ReorderableListCell.js +3 -7
  7. package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
  8. package/lib/commonjs/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +35 -12
  9. package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js.map +1 -0
  10. package/lib/commonjs/components/ReorderableListCore/constants.ios.js.map +1 -0
  11. package/lib/commonjs/components/ReorderableListCore/constants.js.map +1 -0
  12. package/lib/commonjs/components/ReorderableListCore/index.js +17 -0
  13. package/lib/commonjs/components/ReorderableListCore/index.js.map +1 -0
  14. package/lib/commonjs/components/{ReorderableList/useReorderableList.js → ReorderableListCore/useReorderableListCore.js} +182 -75
  15. package/lib/commonjs/components/ReorderableListCore/useReorderableListCore.js.map +1 -0
  16. package/lib/commonjs/components/ScrollViewContainer.js +53 -0
  17. package/lib/commonjs/components/ScrollViewContainer.js.map +1 -0
  18. package/lib/commonjs/components/index.js +22 -0
  19. package/lib/commonjs/components/index.js.map +1 -1
  20. package/lib/commonjs/contexts/ReorderableCellContext.js.map +1 -1
  21. package/lib/commonjs/contexts/ReorderableListContext.js.map +1 -1
  22. package/lib/commonjs/contexts/ScrollViewContainerContext.js +10 -0
  23. package/lib/commonjs/contexts/ScrollViewContainerContext.js.map +1 -0
  24. package/lib/commonjs/contexts/index.js +11 -0
  25. package/lib/commonjs/contexts/index.js.map +1 -1
  26. package/lib/commonjs/hooks/useReorderableDragEnd.js +23 -8
  27. package/lib/commonjs/hooks/useReorderableDragEnd.js.map +1 -1
  28. package/lib/commonjs/index.js +12 -0
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/module/components/NestedReorderableList.js +33 -0
  31. package/lib/module/components/NestedReorderableList.js.map +1 -0
  32. package/lib/module/components/ReorderableList.js +21 -0
  33. package/lib/module/components/ReorderableList.js.map +1 -0
  34. package/lib/module/components/ReorderableListCell.js +3 -7
  35. package/lib/module/components/ReorderableListCell.js.map +1 -1
  36. package/lib/module/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +38 -15
  37. package/lib/module/components/ReorderableListCore/ReorderableListCore.js.map +1 -0
  38. package/lib/module/components/ReorderableListCore/constants.ios.js.map +1 -0
  39. package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.js.map +1 -1
  40. package/lib/module/components/ReorderableListCore/index.js +2 -0
  41. package/lib/module/components/ReorderableListCore/index.js.map +1 -0
  42. package/lib/module/components/{ReorderableList/useReorderableList.js → ReorderableListCore/useReorderableListCore.js} +181 -74
  43. package/lib/module/components/ReorderableListCore/useReorderableListCore.js.map +1 -0
  44. package/lib/module/components/ScrollViewContainer.js +44 -0
  45. package/lib/module/components/ScrollViewContainer.js.map +1 -0
  46. package/lib/module/components/index.js +2 -0
  47. package/lib/module/components/index.js.map +1 -1
  48. package/lib/module/contexts/ReorderableCellContext.js.map +1 -1
  49. package/lib/module/contexts/ReorderableListContext.js.map +1 -1
  50. package/lib/module/contexts/ScrollViewContainerContext.js +3 -0
  51. package/lib/module/contexts/ScrollViewContainerContext.js.map +1 -0
  52. package/lib/module/contexts/index.js +1 -0
  53. package/lib/module/contexts/index.js.map +1 -1
  54. package/lib/module/hooks/useReorderableDragEnd.js +23 -8
  55. package/lib/module/hooks/useReorderableDragEnd.js.map +1 -1
  56. package/lib/module/index.js +2 -2
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/typescript/components/NestedReorderableList.d.ts +5 -0
  59. package/lib/typescript/components/NestedReorderableList.d.ts.map +1 -0
  60. package/lib/typescript/components/ReorderableList.d.ts +5 -0
  61. package/lib/typescript/components/ReorderableList.d.ts.map +1 -0
  62. package/lib/typescript/components/ReorderableListCell.d.ts +1 -2
  63. package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
  64. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts +20 -0
  65. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts.map +1 -0
  66. package/lib/typescript/components/ReorderableListCore/constants.d.ts.map +1 -0
  67. package/lib/typescript/components/ReorderableListCore/constants.ios.d.ts.map +1 -0
  68. package/lib/typescript/components/ReorderableListCore/index.d.ts +2 -0
  69. package/lib/typescript/components/ReorderableListCore/index.d.ts.map +1 -0
  70. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts +44 -0
  71. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts.map +1 -0
  72. package/lib/typescript/components/ScrollViewContainer.d.ts +4 -0
  73. package/lib/typescript/components/ScrollViewContainer.d.ts.map +1 -0
  74. package/lib/typescript/components/index.d.ts +2 -0
  75. package/lib/typescript/components/index.d.ts.map +1 -1
  76. package/lib/typescript/contexts/ReorderableCellContext.d.ts +0 -1
  77. package/lib/typescript/contexts/ReorderableCellContext.d.ts.map +1 -1
  78. package/lib/typescript/contexts/ReorderableListContext.d.ts +1 -0
  79. package/lib/typescript/contexts/ReorderableListContext.d.ts.map +1 -1
  80. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts +15 -0
  81. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts.map +1 -0
  82. package/lib/typescript/contexts/index.d.ts +1 -0
  83. package/lib/typescript/contexts/index.d.ts.map +1 -1
  84. package/lib/typescript/hooks/useReorderableDragEnd.d.ts.map +1 -1
  85. package/lib/typescript/index.d.ts +3 -3
  86. package/lib/typescript/index.d.ts.map +1 -1
  87. package/lib/typescript/types/props.d.ts +13 -1
  88. package/lib/typescript/types/props.d.ts.map +1 -1
  89. package/package.json +1 -1
  90. package/src/components/NestedReorderableList.tsx +43 -0
  91. package/src/components/ReorderableList.tsx +29 -0
  92. package/src/components/ReorderableListCell.tsx +2 -7
  93. package/src/components/ReorderableListCore/ReorderableListCore.tsx +162 -0
  94. package/src/components/ReorderableListCore/index.ts +1 -0
  95. package/src/components/{ReorderableList/useReorderableList.ts → ReorderableListCore/useReorderableListCore.ts} +264 -85
  96. package/src/components/ScrollViewContainer.tsx +74 -0
  97. package/src/components/index.ts +2 -0
  98. package/src/contexts/ReorderableCellContext.ts +0 -1
  99. package/src/contexts/ReorderableListContext.ts +1 -0
  100. package/src/contexts/ScrollViewContainerContext.ts +18 -0
  101. package/src/contexts/index.ts +1 -0
  102. package/src/hooks/useReorderableDragEnd.ts +28 -12
  103. package/src/index.ts +10 -1
  104. package/src/types/props.ts +21 -1
  105. package/lib/commonjs/components/ReorderableList/ReorderableList.js.map +0 -1
  106. package/lib/commonjs/components/ReorderableList/constants.ios.js.map +0 -1
  107. package/lib/commonjs/components/ReorderableList/constants.js.map +0 -1
  108. package/lib/commonjs/components/ReorderableList/index.js +0 -17
  109. package/lib/commonjs/components/ReorderableList/index.js.map +0 -1
  110. package/lib/commonjs/components/ReorderableList/useReorderableList.js.map +0 -1
  111. package/lib/module/components/ReorderableList/ReorderableList.js.map +0 -1
  112. package/lib/module/components/ReorderableList/constants.ios.js.map +0 -1
  113. package/lib/module/components/ReorderableList/index.js +0 -2
  114. package/lib/module/components/ReorderableList/index.js.map +0 -1
  115. package/lib/module/components/ReorderableList/useReorderableList.js.map +0 -1
  116. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts +0 -8
  117. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts.map +0 -1
  118. package/lib/typescript/components/ReorderableList/constants.d.ts.map +0 -1
  119. package/lib/typescript/components/ReorderableList/constants.ios.d.ts.map +0 -1
  120. package/lib/typescript/components/ReorderableList/index.d.ts +0 -2
  121. package/lib/typescript/components/ReorderableList/index.d.ts.map +0 -1
  122. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts +0 -36
  123. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts.map +0 -1
  124. package/src/components/ReorderableList/ReorderableList.tsx +0 -119
  125. package/src/components/ReorderableList/index.ts +0 -1
  126. /package/lib/commonjs/components/{ReorderableList → ReorderableListCore}/constants.ios.js +0 -0
  127. /package/lib/commonjs/components/{ReorderableList → ReorderableListCore}/constants.js +0 -0
  128. /package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.ios.js +0 -0
  129. /package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.js +0 -0
  130. /package/lib/typescript/components/{ReorderableList → ReorderableListCore}/constants.d.ts +0 -0
  131. /package/lib/typescript/components/{ReorderableList → ReorderableListCore}/constants.ios.d.ts +0 -0
  132. /package/src/components/{ReorderableList → ReorderableListCore}/constants.ios.ts +0 -0
  133. /package/src/components/{ReorderableList → ReorderableListCore}/constants.ts +0 -0
@@ -1,12 +1,12 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { unstable_batchedUpdates } from 'react-native';
3
3
  import { Gesture, State } from 'react-native-gesture-handler';
4
- import { Easing, cancelAnimation, measure, runOnJS, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
4
+ import { Easing, cancelAnimation, runOnJS, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
5
5
  import { AUTOSCROLL_INCREMENT } from './constants';
6
6
  import { ReorderableListState } from '../../types';
7
7
  const version = React.version.split('.');
8
8
  const hasAutomaticBatching = version.length ? parseInt(version[0], 10) >= 18 : false;
9
- export const useReorderableList = ({
9
+ export const useReorderableListCore = ({
10
10
  ref,
11
11
  autoscrollThreshold,
12
12
  autoscrollSpeedScale,
@@ -16,22 +16,30 @@ export const useReorderableList = ({
16
16
  onReorder,
17
17
  onDragEnd,
18
18
  onScroll,
19
- onLayout
19
+ onLayout,
20
+ scrollViewContainerRef,
21
+ scrollViewHeightY,
22
+ scrollViewScrollOffsetY,
23
+ scrollViewScrollEnabled,
24
+ initialScrollEnabled,
25
+ initialScrollViewScrollEnabled,
26
+ nestedScrollable
20
27
  }) => {
21
- const scrollEnabled = useSharedValue(true);
22
- const flatList = useAnimatedRef();
28
+ const flatListRef = useAnimatedRef();
29
+ const scrollEnabled = useSharedValue(initialScrollEnabled);
23
30
  const gestureState = useSharedValue(State.UNDETERMINED);
24
31
  const currentY = useSharedValue(0);
25
32
  const currentTranslationY = useSharedValue(0);
26
- const containerPositionY = useSharedValue(0);
27
- const currentScrollOffsetY = useSharedValue(0);
33
+ const flatListScrollOffsetY = useSharedValue(0);
34
+ const flatListHeightY = useSharedValue(0);
35
+ const nestedFlatListPositionY = useSharedValue(0);
28
36
  const dragScrollTranslationY = useSharedValue(0);
29
37
  const dragInitialScrollOffsetY = useSharedValue(0);
38
+ const scrollViewDragScrollTranslationY = useSharedValue(0);
39
+ const scrollViewDragInitialScrollOffsetY = useSharedValue(0);
30
40
  const draggedHeight = useSharedValue(0);
31
41
  const itemOffset = useSharedValue([]);
32
42
  const itemHeight = useSharedValue([]);
33
- const topAutoscrollArea = useSharedValue(0);
34
- const bottomAutoscrollArea = useSharedValue(0);
35
43
  const autoscrollTrigger = useSharedValue(-1);
36
44
  const lastAutoscrollTrigger = useSharedValue(-1);
37
45
  const previousY = useSharedValue(0);
@@ -40,8 +48,8 @@ export const useReorderableList = ({
40
48
  const previousIndex = useSharedValue(-1);
41
49
  const currentIndex = useSharedValue(-1);
42
50
  const draggedIndex = useSharedValue(-1);
43
- const releasedIndex = useSharedValue(-1);
44
51
  const state = useSharedValue(ReorderableListState.IDLE);
52
+ const dragEndHandlers = useSharedValue([]);
45
53
 
46
54
  // animation duration as a shared value allows to avoid re-rendering of all cells on value change
47
55
  const duration = useSharedValue(animationDuration);
@@ -51,15 +59,15 @@ export const useReorderableList = ({
51
59
  const listContextValue = useMemo(() => ({
52
60
  draggedHeight,
53
61
  currentIndex,
54
- draggedIndex
55
- }), [draggedHeight, currentIndex, draggedIndex]);
62
+ draggedIndex,
63
+ dragEndHandlers
64
+ }), [draggedHeight, currentIndex, draggedIndex, dragEndHandlers]);
56
65
  const startY = useSharedValue(0);
57
66
  const panGestureHandler = useMemo(() => Gesture.Pan().onBegin(e => {
58
67
  // prevent new dragging until item is completely released
59
68
  if (state.value === ReorderableListState.IDLE) {
60
- const relativeY = e.absoluteY - containerPositionY.value;
61
- startY.value = relativeY;
62
- currentY.value = relativeY;
69
+ startY.value = e.y;
70
+ currentY.value = e.y;
63
71
  currentTranslationY.value = e.translationY;
64
72
  if (draggedIndex.value >= 0) {
65
73
  dragY.value = e.translationY;
@@ -71,36 +79,40 @@ export const useReorderableList = ({
71
79
  currentY.value = startY.value + e.translationY;
72
80
  currentTranslationY.value = e.translationY;
73
81
  if (draggedIndex.value >= 0) {
74
- dragY.value = e.translationY + dragScrollTranslationY.value;
82
+ dragY.value = e.translationY + dragScrollTranslationY.value + scrollViewDragScrollTranslationY.value;
75
83
  }
76
84
  gestureState.value = e.state;
77
85
  }
78
- }).onEnd(e => gestureState.value = e.state).onFinalize(e => gestureState.value = e.state), [containerPositionY, currentTranslationY, currentY, dragScrollTranslationY, draggedIndex, gestureState, dragY, startY, state]);
86
+ }).onEnd(e => gestureState.value = e.state).onFinalize(e => gestureState.value = e.state), [currentTranslationY, currentY, dragScrollTranslationY, scrollViewDragScrollTranslationY, draggedIndex, gestureState, dragY, startY, state]);
79
87
  const gestureHandler = useMemo(() => Gesture.Simultaneous(Gesture.Native(), panGestureHandler), [panGestureHandler]);
80
88
  const setScrollEnabled = useCallback(enabled => {
81
- var _flatList$current;
82
- scrollEnabled.value = enabled;
83
- (_flatList$current = flatList.current) === null || _flatList$current === void 0 || _flatList$current.setNativeProps({
84
- scrollEnabled: enabled
85
- });
86
- }, [flatList, scrollEnabled]);
89
+ // if scroll is enabled on list props then we can toggle it
90
+ if (initialScrollEnabled) {
91
+ var _flatListRef$current;
92
+ scrollEnabled.value = enabled;
93
+ (_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 || _flatListRef$current.setNativeProps({
94
+ scrollEnabled: enabled
95
+ });
96
+ }
97
+ if (scrollViewContainerRef && scrollViewScrollEnabled && initialScrollViewScrollEnabled) {
98
+ var _scrollViewContainerR;
99
+ scrollViewScrollEnabled.value = enabled;
100
+ (_scrollViewContainerR = scrollViewContainerRef.current) === null || _scrollViewContainerR === void 0 || _scrollViewContainerR.setNativeProps({
101
+ scrollEnabled: enabled
102
+ });
103
+ }
104
+ }, [initialScrollEnabled, flatListRef, scrollEnabled, initialScrollViewScrollEnabled, scrollViewContainerRef, scrollViewScrollEnabled]);
87
105
  const resetSharedValues = useCallback(() => {
88
106
  'worklet';
89
107
 
90
- // must be reset before the reorder function is called
91
- // to avoid triggering on drag end event twice,
92
- // update with a delay to avoid reanimated batching the
93
- // change if updated immediately
94
- releasedIndex.value = withDelay(1, withTiming(-1, {
95
- duration: 0
96
- }));
97
- draggedIndex.value = -1;
98
108
  // current index is reset on item render for the on end event
99
- dragY.value = 0;
109
+ draggedIndex.value = -1;
100
110
  // released flag is reset after release is triggered in the item
101
111
  state.value = ReorderableListState.IDLE;
112
+ dragY.value = 0;
102
113
  dragScrollTranslationY.value = 0;
103
- }, [releasedIndex, draggedIndex, dragY, state, dragScrollTranslationY]);
114
+ scrollViewDragScrollTranslationY.value = 0;
115
+ }, [dragY, dragScrollTranslationY, scrollViewDragScrollTranslationY, draggedIndex, state]);
104
116
  const reorder = (fromIndex, toIndex) => {
105
117
  runOnUI(resetSharedValues)();
106
118
  if (fromIndex !== toIndex) {
@@ -120,7 +132,7 @@ export const useReorderableList = ({
120
132
  const getIndexFromY = useCallback(y => {
121
133
  'worklet';
122
134
 
123
- const relativeY = currentScrollOffsetY.value + y;
135
+ const relativeY = flatListScrollOffsetY.value + y;
124
136
  const count = itemOffset.value.length;
125
137
  for (let i = 0; i < count; i++) {
126
138
  if (currentIndex.value === i) {
@@ -141,7 +153,7 @@ export const useReorderableList = ({
141
153
  index: currentIndex.value,
142
154
  direction: previousDirection.value
143
155
  };
144
- }, [dragReorderThreshold, currentIndex, currentScrollOffsetY, previousDirection, itemOffset, itemHeight]);
156
+ }, [dragReorderThreshold, currentIndex, flatListScrollOffsetY, previousDirection, itemOffset, itemHeight]);
145
157
  const setCurrentIndex = useCallback(y => {
146
158
  'worklet';
147
159
 
@@ -173,15 +185,19 @@ export const useReorderableList = ({
173
185
  useAnimatedReaction(() => gestureState.value, () => {
174
186
  if (gestureState.value !== State.ACTIVE && gestureState.value !== State.BEGAN && (state.value === ReorderableListState.DRAGGING || state.value === ReorderableListState.AUTO_SCROLL)) {
175
187
  state.value = ReorderableListState.RELEASING;
176
- releasedIndex.value = draggedIndex.value;
177
188
 
178
189
  // enable back scroll on releasing
179
190
  runOnJS(setScrollEnabled)(true);
180
191
  // trigger onDragEnd event
181
- onDragEnd === null || onDragEnd === void 0 || onDragEnd({
192
+ let e = {
182
193
  from: draggedIndex.value,
183
194
  to: currentIndex.value
184
- });
195
+ };
196
+ onDragEnd === null || onDragEnd === void 0 || onDragEnd(e);
197
+ const handlers = dragEndHandlers.value[draggedIndex.value];
198
+ if (Array.isArray(handlers)) {
199
+ handlers.forEach(fn => fn(e.from, e.to));
200
+ }
185
201
 
186
202
  // they are actually swapped on drag translation
187
203
  const currentItemOffset = itemOffset.value[draggedIndex.value];
@@ -205,10 +221,87 @@ export const useReorderableList = ({
205
221
  }
206
222
  }
207
223
  });
208
- useAnimatedReaction(() => currentY.value, y => {
224
+ const calculateHiddenArea = useCallback(() => {
225
+ 'worklet';
226
+
227
+ if (!scrollViewScrollOffsetY || !scrollViewHeightY) {
228
+ return {
229
+ top: 0,
230
+ bottom: 0
231
+ };
232
+ }
233
+
234
+ // hidden area cannot be negative
235
+ const top = Math.max(0, scrollViewScrollOffsetY.value - nestedFlatListPositionY.value);
236
+ const bottom = Math.max(0, nestedFlatListPositionY.value + flatListHeightY.value - (scrollViewScrollOffsetY.value + scrollViewHeightY.value));
237
+ return {
238
+ top,
239
+ bottom
240
+ };
241
+ }, [scrollViewScrollOffsetY, scrollViewHeightY, nestedFlatListPositionY, flatListHeightY]);
242
+ const calculateThresholdArea = useCallback(hiddenArea => {
243
+ 'worklet';
244
+
245
+ const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
246
+ const visibleHeight = flatListHeightY.value - (hiddenArea.top + hiddenArea.bottom);
247
+ const top = visibleHeight * threshold;
248
+ const bottom = flatListHeightY.value - top;
249
+ return {
250
+ top,
251
+ bottom
252
+ };
253
+ }, [autoscrollThreshold, flatListHeightY]);
254
+ const calculateThresholdAreaParent = useCallback(hiddenArea => {
255
+ 'worklet';
256
+
257
+ const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
258
+ const top = flatListHeightY.value * threshold;
259
+ const bottom = flatListHeightY.value - top;
260
+
261
+ // if the hidden area is 0 then we don't have a threshold area
262
+ // we might have floating errors like 0.0001 which we should ignore
263
+ return {
264
+ top: hiddenArea.top > 0.1 ? top + hiddenArea.top : 0,
265
+ bottom: hiddenArea.bottom > 0.1 ? bottom - hiddenArea.bottom : 0
266
+ };
267
+ }, [autoscrollThreshold, flatListHeightY]);
268
+ const shouldScrollParent = useCallback(y => {
269
+ 'worklet';
270
+
271
+ const hiddenArea = calculateHiddenArea();
272
+ const thresholdAreaParent = calculateThresholdAreaParent(hiddenArea);
273
+
274
+ // we might have floating errors like 0.0001 which we should ignore
275
+ return hiddenArea.top > 0.1 && y <= thresholdAreaParent.top || hiddenArea.bottom > 0.1 && y >= thresholdAreaParent.bottom;
276
+ }, [calculateHiddenArea, calculateThresholdAreaParent]);
277
+ const scrollDirection = useCallback(y => {
278
+ 'worklet';
279
+
280
+ const hiddenArea = calculateHiddenArea();
281
+ if (shouldScrollParent(y)) {
282
+ const thresholdAreaParent = calculateThresholdAreaParent(hiddenArea);
283
+ if (y <= thresholdAreaParent.top) {
284
+ return -1;
285
+ }
286
+ if (y >= thresholdAreaParent.bottom) {
287
+ return 1;
288
+ }
289
+ return 0;
290
+ } else if (nestedScrollable) {
291
+ const thresholdArea = calculateThresholdArea(hiddenArea);
292
+ if (y <= thresholdArea.top) {
293
+ return -1;
294
+ }
295
+ if (y >= thresholdArea.bottom) {
296
+ return 1;
297
+ }
298
+ }
299
+ return 0;
300
+ }, [nestedScrollable, shouldScrollParent, calculateHiddenArea, calculateThresholdArea, calculateThresholdAreaParent]);
301
+ useAnimatedReaction(() => currentY.value + scrollViewDragScrollTranslationY.value, y => {
209
302
  if (state.value === ReorderableListState.DRAGGING || state.value === ReorderableListState.AUTO_SCROLL) {
210
303
  setCurrentIndex(y);
211
- if (y <= topAutoscrollArea.value || y >= bottomAutoscrollArea.value) {
304
+ if (scrollDirection(y)) {
212
305
  if (state.value !== ReorderableListState.AUTO_SCROLL) {
213
306
  // trigger autoscroll
214
307
  lastAutoscrollTrigger.value = autoscrollTrigger.value;
@@ -222,35 +315,62 @@ export const useReorderableList = ({
222
315
  });
223
316
  useAnimatedReaction(() => autoscrollTrigger.value, () => {
224
317
  if (autoscrollTrigger.value !== lastAutoscrollTrigger.value && state.value === ReorderableListState.AUTO_SCROLL) {
225
- const autoscrollIncrement = (currentY.value <= topAutoscrollArea.value ? -AUTOSCROLL_INCREMENT : AUTOSCROLL_INCREMENT) * autoscrollSpeedScale;
318
+ let y = currentY.value + scrollViewDragScrollTranslationY.value;
319
+ const autoscrollIncrement = scrollDirection(y) * AUTOSCROLL_INCREMENT * autoscrollSpeedScale;
226
320
  if (autoscrollIncrement !== 0) {
227
- scrollTo(flatList, 0, currentScrollOffsetY.value + autoscrollIncrement, true);
321
+ let scrollOffset = flatListScrollOffsetY.value;
322
+ let listRef = flatListRef;
323
+ if (shouldScrollParent(y) && scrollViewScrollOffsetY) {
324
+ scrollOffset = scrollViewScrollOffsetY.value;
325
+ listRef = scrollViewContainerRef;
326
+ }
327
+ scrollTo(listRef, 0, scrollOffset + autoscrollIncrement, true);
228
328
  }
229
329
 
230
330
  // when autoscrolling user may not be moving his finger so we need
231
331
  // to update the current position of the dragged item here
232
- setCurrentIndex(currentY.value);
332
+ setCurrentIndex(y);
233
333
  }
234
334
  });
335
+
336
+ // flatlist scroll handler
235
337
  const handleScroll = useAnimatedScrollHandler(e => {
236
- currentScrollOffsetY.value = e.contentOffset.y;
338
+ flatListScrollOffsetY.value = e.contentOffset.y;
237
339
 
238
340
  // checking if the list is not scrollable instead of the scrolling state
239
341
  // fixes a bug on iOS where the item is shifted after autoscrolling and then
240
342
  // moving await from autoscroll area
241
343
  if (!scrollEnabled.value) {
242
- dragScrollTranslationY.value = currentScrollOffsetY.value - dragInitialScrollOffsetY.value;
344
+ dragScrollTranslationY.value = flatListScrollOffsetY.value - dragInitialScrollOffsetY.value;
243
345
  }
244
346
  if (state.value === ReorderableListState.AUTO_SCROLL) {
245
- dragY.value = currentTranslationY.value + dragScrollTranslationY.value;
347
+ dragY.value = currentTranslationY.value + dragScrollTranslationY.value + scrollViewDragScrollTranslationY.value;
246
348
  cancelAnimation(autoscrollTrigger);
247
349
  lastAutoscrollTrigger.value = autoscrollTrigger.value;
248
350
  autoscrollTrigger.value = withDelay(autoscrollDelay, withTiming(autoscrollTrigger.value * -1, {
249
351
  duration: 0
250
352
  }));
251
- } else {}
252
- if (onScroll) {
253
- onScroll(e);
353
+ }
354
+ onScroll === null || onScroll === void 0 || onScroll(e);
355
+ });
356
+
357
+ // parent scroll handler
358
+ useAnimatedReaction(() => scrollViewScrollOffsetY === null || scrollViewScrollOffsetY === void 0 ? void 0 : scrollViewScrollOffsetY.value, value => {
359
+ if (value && scrollViewScrollEnabled) {
360
+ // checking if the list is not scrollable instead of the scrolling state
361
+ // fixes a bug on iOS where the item is shifted after autoscrolling and then
362
+ // moving await from autoscroll area
363
+ if (!scrollViewScrollEnabled.value) {
364
+ scrollViewDragScrollTranslationY.value = value - scrollViewDragInitialScrollOffsetY.value;
365
+ }
366
+ if (state.value === ReorderableListState.AUTO_SCROLL) {
367
+ dragY.value = currentTranslationY.value + scrollViewDragScrollTranslationY.value;
368
+ cancelAnimation(autoscrollTrigger);
369
+ lastAutoscrollTrigger.value = autoscrollTrigger.value;
370
+ autoscrollTrigger.value = withDelay(autoscrollDelay, withTiming(autoscrollTrigger.value * -1, {
371
+ duration: 0
372
+ }));
373
+ }
254
374
  }
255
375
  });
256
376
  const startDrag = useCallback(index => {
@@ -258,38 +378,26 @@ export const useReorderableList = ({
258
378
 
259
379
  // allow new drag when item is completely released
260
380
  if (state.value === ReorderableListState.IDLE) {
381
+ // resetting shared values again fixes a flickeing bug in nested lists where
382
+ // after scrolling the parent list it would offset the new dragged item in another nested list
383
+ resetSharedValues();
384
+ dragInitialScrollOffsetY.value = flatListScrollOffsetY.value;
385
+ scrollViewDragInitialScrollOffsetY.value = scrollViewScrollOffsetY ? scrollViewScrollOffsetY.value : 0;
261
386
  draggedHeight.value = itemHeight.value[index];
262
387
  draggedIndex.value = index;
263
388
  previousIndex.value = -1;
264
389
  currentIndex.value = index;
265
390
  state.value = ReorderableListState.DRAGGING;
266
- dragInitialScrollOffsetY.value = currentScrollOffsetY.value;
267
391
  runOnJS(setScrollEnabled)(false);
268
392
  }
269
- }, [setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, currentScrollOffsetY, dragInitialScrollOffsetY, itemHeight]);
270
- const measureFlatList = useCallback(() => {
271
- 'worklet';
272
-
273
- const measurement = measure(flatList);
274
- if (measurement === null) {
275
- return;
276
- }
277
- containerPositionY.value = measurement.pageY;
278
- }, [flatList, containerPositionY]);
393
+ }, [resetSharedValues, dragInitialScrollOffsetY, scrollViewScrollOffsetY, scrollViewDragInitialScrollOffsetY, setScrollEnabled, currentIndex, previousIndex, draggedHeight, draggedIndex, state, flatListScrollOffsetY, itemHeight]);
279
394
  const handleFlatListLayout = useCallback(e => {
280
- runOnUI(measureFlatList)();
281
- const threshold = Math.max(0, Math.min(autoscrollThreshold, 0.4));
282
- const {
283
- height
284
- } = e.nativeEvent.layout;
285
- topAutoscrollArea.value = height * threshold;
286
- bottomAutoscrollArea.value = height * (1 - threshold);
287
- if (onLayout) {
288
- onLayout(e);
289
- }
290
- }, [measureFlatList, topAutoscrollArea, bottomAutoscrollArea, autoscrollThreshold, onLayout]);
395
+ nestedFlatListPositionY.value = e.nativeEvent.layout.y;
396
+ flatListHeightY.value = e.nativeEvent.layout.height;
397
+ onLayout === null || onLayout === void 0 || onLayout(e);
398
+ }, [nestedFlatListPositionY, flatListHeightY, onLayout]);
291
399
  const handleRef = value => {
292
- flatList(value);
400
+ flatListRef(value);
293
401
  if (typeof ref === 'function') {
294
402
  ref(value);
295
403
  } else if (ref) {
@@ -306,9 +414,8 @@ export const useReorderableList = ({
306
414
  itemOffset,
307
415
  itemHeight,
308
416
  draggedIndex,
309
- releasedIndex,
310
417
  dragY,
311
418
  duration
312
419
  };
313
420
  };
314
- //# sourceMappingURL=useReorderableList.js.map
421
+ //# sourceMappingURL=useReorderableListCore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useMemo","unstable_batchedUpdates","Gesture","State","Easing","cancelAnimation","runOnJS","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useSharedValue","withDelay","withTiming","AUTOSCROLL_INCREMENT","ReorderableListState","version","split","hasAutomaticBatching","length","parseInt","useReorderableListCore","ref","autoscrollThreshold","autoscrollSpeedScale","autoscrollDelay","animationDuration","dragReorderThreshold","onReorder","onDragEnd","onScroll","onLayout","scrollViewContainerRef","scrollViewHeightY","scrollViewScrollOffsetY","scrollViewScrollEnabled","initialScrollEnabled","initialScrollViewScrollEnabled","nestedScrollable","flatListRef","scrollEnabled","gestureState","UNDETERMINED","currentY","currentTranslationY","flatListScrollOffsetY","flatListHeightY","nestedFlatListPositionY","dragScrollTranslationY","dragInitialScrollOffsetY","scrollViewDragScrollTranslationY","scrollViewDragInitialScrollOffsetY","draggedHeight","itemOffset","itemHeight","autoscrollTrigger","lastAutoscrollTrigger","previousY","dragY","previousDirection","previousIndex","currentIndex","draggedIndex","state","IDLE","dragEndHandlers","duration","value","listContextValue","startY","panGestureHandler","Pan","onBegin","e","y","translationY","onUpdate","RELEASING","onEnd","onFinalize","gestureHandler","Simultaneous","Native","setScrollEnabled","enabled","_flatListRef$current","current","setNativeProps","_scrollViewContainerR","resetSharedValues","reorder","fromIndex","toIndex","updateState","from","to","getIndexFromY","relativeY","count","i","direction","threshold","Math","max","min","height","offset","index","setCurrentIndex","newIndex","newDirection","delta","abs","itemDirection","index1","index2","newOffset1","newHeight1","newOffset2","newHeight2","ACTIVE","BEGAN","DRAGGING","AUTO_SCROLL","handlers","Array","isArray","forEach","fn","currentItemOffset","currentItemHeight","draggedItemOffset","draggedItemHeight","newTopPosition","easing","out","ease","calculateHiddenArea","top","bottom","calculateThresholdArea","hiddenArea","visibleHeight","calculateThresholdAreaParent","shouldScrollParent","thresholdAreaParent","scrollDirection","thresholdArea","autoscrollIncrement","scrollOffset","listRef","handleScroll","contentOffset","startDrag","handleFlatListLayout","nativeEvent","layout","handleRef"],"sourceRoot":"../../../../src","sources":["components/ReorderableListCore/useReorderableListCore.ts"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,WAAW,EAAEC,OAAO,QAAO,OAAO;AACjD,SAKEC,uBAAuB,QAClB,cAAc;AAErB,SAAQC,OAAO,EAAEC,KAAK,QAAO,8BAA8B;AAC3D,SAEEC,MAAM,EAENC,eAAe,EACfC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,cAAc,EACdC,SAAS,EACTC,UAAU,QACL,yBAAyB;AAEhC,SAAQC,oBAAoB,QAAO,aAAa;AAChD,SAAqCC,oBAAoB,QAAO,aAAa;AAG7E,MAAMC,OAAO,GAAGnB,KAAK,CAACmB,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC;AACxC,MAAMC,oBAAoB,GAAGF,OAAO,CAACG,MAAM,GACvCC,QA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AS;IACTJ,SAAS;IACTrF,gBAAgB;IAChBf,UAAU;IACVC,UAAU;IACVQ,YAAY;IACZJ,KAAK;IACLQ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { useMemo } from 'react';
3
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
+ import Animated, { useAnimatedRef, useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
5
+ import { ScrollViewContainerContext } from '../contexts/ScrollViewContainerContext';
6
+ export const ScrollViewContainer = ({
7
+ onLayout,
8
+ onScroll,
9
+ scrollEnabled = true,
10
+ ...rest
11
+ }) => {
12
+ const scrollViewScrollEnabled = useSharedValue(scrollEnabled);
13
+ const scrollViewContainerRef = useAnimatedRef();
14
+ const scrollViewScrollOffsetY = useSharedValue(0);
15
+ const scrollViewHeightY = useSharedValue(0);
16
+ const outerScrollGesture = useMemo(() => Gesture.Native(), []);
17
+ const handleScroll = useAnimatedScrollHandler(e => {
18
+ scrollViewScrollOffsetY.value = e.contentOffset.y;
19
+ onScroll === null || onScroll === void 0 || onScroll(e);
20
+ }, [scrollViewScrollOffsetY]);
21
+ const contextValue = useMemo(() => ({
22
+ scrollViewContainerRef,
23
+ scrollViewHeightY,
24
+ scrollViewScrollOffsetY,
25
+ scrollViewScrollEnabled,
26
+ outerScrollGesture,
27
+ initialScrollViewScrollEnabled: scrollEnabled
28
+ }), [scrollViewContainerRef, scrollViewHeightY, scrollViewScrollOffsetY, scrollViewScrollEnabled, outerScrollGesture, scrollEnabled]);
29
+ const handleLayout = e => {
30
+ scrollViewHeightY.value = e.nativeEvent.layout.height;
31
+ onLayout === null || onLayout === void 0 || onLayout(e);
32
+ };
33
+ return /*#__PURE__*/React.createElement(ScrollViewContainerContext.Provider, {
34
+ value: contextValue
35
+ }, /*#__PURE__*/React.createElement(GestureDetector, {
36
+ gesture: outerScrollGesture
37
+ }, /*#__PURE__*/React.createElement(Animated.ScrollView, _extends({}, rest, {
38
+ ref: scrollViewContainerRef,
39
+ onScroll: handleScroll,
40
+ onLayout: handleLayout,
41
+ scrollEnabled: scrollEnabled
42
+ }))));
43
+ };
44
+ //# sourceMappingURL=ScrollViewContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useMemo","Gesture","GestureDetector","Animated","useAnimatedRef","useAnimatedScrollHandler","useSharedValue","ScrollViewContainerContext","ScrollViewContainer","onLayout","onScroll","scrollEnabled","rest","scrollViewScrollEnabled","scrollViewContainerRef","scrollViewScrollOffsetY","scrollViewHeightY","outerScrollGesture","Native","handleScroll","e","value","contentOffset","y","contextValue","initialScrollViewScrollEnabled","handleLayout","nativeEvent","layout","height","createElement","Provider","gesture","ScrollView","_extends","ref"],"sourceRoot":"../../../src","sources":["components/ScrollViewContainer.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAGC,OAAO,QAAO,OAAO;AAGpC,SAAQC,OAAO,EAAEC,eAAe,QAAO,8BAA8B;AACrE,OAAOC,QAAQ,IACbC,cAAc,EACdC,wBAAwB,EACxBC,cAAc,QACT,yBAAyB;AAEhC,SAAQC,0BAA0B,QAAO,wCAAwC;AAGjF,OAAO,MAAMC,mBAAuD,GAAGA,CAAC;EACtEC,QAAQ;EACRC,QAAQ;EACRC,aAAa,GAAG,IAAI;EACpB,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,uBAAuB,GAAGP,cAAc,CAACK,aAAa,CAAC;EAC7D,MAAMG,sBAAsB,GAAGV,cAAc,CAAsB,CAAC;EACpE,MAAMW,uBAAuB,GAAGT,cAAc,CAAC,CAAC,CAAC;EACjD,MAAMU,iBAAiB,GAAGV,cAAc,CAAC,CAAC,CAAC;EAE3C,MAAMW,kBAAkB,GAAGjB,OAAO,CAAC,MAAMC,OAAO,CAACiB,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;EAE9D,MAAMC,YAAY,GAAGd,wBAAwB,CAC3Ce,CAAC,IAAI;IACHL,uBAAuB,CAACM,KAAK,GAAGD,CAAC,CAACE,aAAa,CAACC,CAAC;IAEjDb,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAGU,CAAC,CAAC;EACf,CAAC,EACD,CAACL,uBAAuB,CAC1B,CAAC;EAED,MAAMS,YAAY,GAAGxB,OAAO,CAC1B,OAAO;IACLc,sBAAsB;IACtBE,iBAAiB;IACjBD,uBAAuB;IACvBF,uBAAuB;IACvBI,kBAAkB;IAClBQ,8BAA8B,EAAEd;EAClC,CAAC,CAAC,EACF,CACEG,sBAAsB,EACtBE,iBAAiB,EACjBD,uBAAuB,EACvBF,uBAAuB,EACvBI,kBAAkB,EAClBN,aAAa,CAEjB,CAAC;EAED,MAAMe,YAAY,GAAIN,CAAoB,IAAK;IAC7CJ,iBAAiB,CAACK,KAAK,GAAGD,CAAC,CAACO,WAAW,CAACC,MAAM,CAACC,MAAM;IAErDpB,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAGW,CAAC,CAAC;EACf,CAAC;EAED,oBACErB,KAAA,CAAA+B,aAAA,CAACvB,0BAA0B,CAACwB,QAAQ;IAACV,KAAK,EAAEG;EAAa,gBACvDzB,KAAA,CAAA+B,aAAA,CAAC5B,eAAe;IAAC8B,OAAO,EAAEf;EAAmB,gBAC3ClB,KAAA,CAAA+B,aAAA,CAAC3B,QAAQ,CAAC8B,UAAU,EAAAC,QAAA,KACdtB,IAAI;IACRuB,GAAG,EAAErB,sBAAuB;IAC5BJ,QAAQ,EAAES,YAAa;IACvBV,QAAQ,EAAEiB,YAAa;IACvBf,aAAa,EAAEA;EAAc,EAC9B,CACc,CACkB,CAAC;AAE1C,CAAC","ignoreList":[]}
@@ -1,4 +1,6 @@
1
1
  export * from './ReorderableList';
2
+ export * from './NestedReorderableList';
2
3
  export * from './ReorderableListCell';
3
4
  export * from './ReorderableListItem';
5
+ export * from './ScrollViewContainer';
4
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["React","ReorderableCellContext","createContext","undefined"],"sourceRoot":"../../../src","sources":["contexts/ReorderableCellContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAWzB,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAa,CAEvDC,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","ReorderableCellContext","createContext","undefined"],"sourceRoot":"../../../src","sources":["contexts/ReorderableCellContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAUzB,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAa,CAEvDC,SAAS,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["React","ReorderableListContext","createContext","undefined"],"sourceRoot":"../../../src","sources":["contexts/ReorderableListContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AASzB,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAa,CAEvDC,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","ReorderableListContext","createContext","undefined"],"sourceRoot":"../../../src","sources":["contexts/ReorderableListContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAUzB,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAa,CAEvDC,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export const ScrollViewContainerContext = /*#__PURE__*/React.createContext(undefined);
3
+ //# sourceMappingURL=ScrollViewContainerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","ScrollViewContainerContext","createContext","undefined"],"sourceRoot":"../../../src","sources":["contexts/ScrollViewContainerContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAezB,OAAO,MAAMC,0BAA0B,gBAAGD,KAAK,CAACE,aAAa,CAE3DC,SAAS,CAAC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
1
  export * from './ReorderableCellContext';
2
2
  export * from './ReorderableListContext';
3
+ export * from './ScrollViewContainerContext';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["contexts/index.ts"],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["contexts/index.ts"],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,0BAA0B;AACxC,cAAc,8BAA8B","ignoreList":[]}
@@ -1,18 +1,33 @@
1
- import { useAnimatedReaction } from 'react-native-reanimated';
1
+ import { useEffect } from 'react';
2
2
  import { useContext } from './useContext';
3
3
  import { ReorderableCellContext, ReorderableListContext } from '../contexts';
4
4
  export const useReorderableDragEnd = onEnd => {
5
5
  const {
6
- currentIndex
6
+ dragEndHandlers
7
7
  } = useContext(ReorderableListContext);
8
8
  const {
9
- releasedIndex,
10
9
  index
11
10
  } = useContext(ReorderableCellContext);
12
- useAnimatedReaction(() => releasedIndex.value === index, newValue => {
13
- if (newValue) {
14
- onEnd(index, currentIndex.value);
15
- }
16
- }, [onEnd]);
11
+ useEffect(() => {
12
+ dragEndHandlers.modify(value => {
13
+ 'worklet';
14
+
15
+ if (!Array.isArray(value[index])) {
16
+ value[index] = [];
17
+ }
18
+ value[index].push(onEnd);
19
+ return value;
20
+ });
21
+ return () => {
22
+ dragEndHandlers.modify(value => {
23
+ 'worklet';
24
+
25
+ if (Array.isArray(value[index])) {
26
+ value[index] = value[index].filter(x => x.name !== onEnd.name);
27
+ }
28
+ return value;
29
+ });
30
+ };
31
+ }, [index, dragEndHandlers, onEnd]);
17
32
  };
18
33
  //# sourceMappingURL=useReorderableDragEnd.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useAnimatedReaction","useContext","ReorderableCellContext","ReorderableListContext","useReorderableDragEnd","onEnd","currentIndex","releasedIndex","index","value","newValue"],"sourceRoot":"../../../src","sources":["hooks/useReorderableDragEnd.ts"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,yBAAyB;AAE3D,SAAQC,UAAU,QAAO,cAAc;AACvC,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,aAAa;AAE1E,OAAO,MAAMC,qBAAqB,GAChCC,KAAyC,IACtC;EACH,MAAM;IAACC;EAAY,CAAC,GAAGL,UAAU,CAACE,sBAAsB,CAAC;EACzD,MAAM;IAACI,aAAa;IAAEC;EAAK,CAAC,GAAGP,UAAU,CAACC,sBAAsB,CAAC;EAEjEF,mBAAmB,CACjB,MAAMO,aAAa,CAACE,KAAK,KAAKD,KAAK,EACnCE,QAAQ,IAAI;IACV,IAAIA,QAAQ,EAAE;MACZL,KAAK,CAACG,KAAK,EAAEF,YAAY,CAACG,KAAK,CAAC;IAClC;EACF,CAAC,EACD,CAACJ,KAAK,CACR,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useContext","ReorderableCellContext","ReorderableListContext","useReorderableDragEnd","onEnd","dragEndHandlers","index","modify","value","Array","isArray","push","filter","x","name"],"sourceRoot":"../../../src","sources":["hooks/useReorderableDragEnd.ts"],"mappings":"AAAA,SAAQA,SAAS,QAAO,OAAO;AAE/B,SAAQC,UAAU,QAAO,cAAc;AACvC,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,aAAa;AAE1E,OAAO,MAAMC,qBAAqB,GAChCC,KAAyC,IACtC;EACH,MAAM;IAACC;EAAe,CAAC,GAAGL,UAAU,CAACE,sBAAsB,CAAC;EAC5D,MAAM;IAACI;EAAK,CAAC,GAAGN,UAAU,CAACC,sBAAsB,CAAC;EAElDF,SAAS,CAAC,MAAM;IACdM,eAAe,CAACE,MAAM,CAACC,KAAK,IAAI;MAC9B,SAAS;;MAET,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAACF,KAAK,CAAC,CAAC,EAAE;QAChCE,KAAK,CAACF,KAAK,CAAC,GAAG,EAAE;MACnB;MAEAE,KAAK,CAACF,KAAK,CAAC,CAACK,IAAI,CAACP,KAAK,CAAC;MAExB,OAAOI,KAAK;IACd,CAAC,CAAC;IAEF,OAAO,MAAM;MACXH,eAAe,CAACE,MAAM,CAACC,KAAK,IAAI;QAC9B,SAAS;;QAET,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAACF,KAAK,CAAC,CAAC,EAAE;UAC/BE,KAAK,CAACF,KAAK,CAAC,GAAGE,KAAK,CAACF,KAAK,CAAC,CAACM,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,KAAKV,KAAK,CAACU,IAAI,CAAC;QAChE;QAEA,OAAON,KAAK;MACd,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,EAAE,CAACF,KAAK,EAAED,eAAe,EAAED,KAAK,CAAC,CAAC;AACrC,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { ReorderableList, ReorderableListItem } from './components';
1
+ import { NestedReorderableList, ReorderableList, ReorderableListItem, ScrollViewContainer } from './components';
2
2
  import { useReorderableDrag, useReorderableDragEnd, useReorderableDragStart } from './hooks';
3
3
  import { reorderItems } from './utils';
4
- export { useReorderableDrag, useReorderableDragStart, useReorderableDragEnd, ReorderableListItem, reorderItems };
4
+ export { useReorderableDrag, useReorderableDragStart, useReorderableDragEnd, ReorderableListItem, ScrollViewContainer, NestedReorderableList, reorderItems };
5
5
  export default ReorderableList;
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ReorderableList","ReorderableListItem","useReorderableDrag","useReorderableDragEnd","useReorderableDragStart","reorderItems"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,mBAAmB,QAAO,cAAc;AACjE,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,uBAAuB,QAClB,SAAS;AAQhB,SAAQC,YAAY,QAAO,SAAS;AAEpC,SACEH,kBAAkB,EAClBE,uBAAuB,EACvBD,qBAAqB,EAIrBF,mBAAmB,EAGnBI,YAAY;AAEd,eAAeL,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["NestedReorderableList","ReorderableList","ReorderableListItem","ScrollViewContainer","useReorderableDrag","useReorderableDragEnd","useReorderableDragStart","reorderItems"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SACEA,qBAAqB,EACrBC,eAAe,EACfC,mBAAmB,EACnBC,mBAAmB,QACd,cAAc;AACrB,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,uBAAuB,QAClB,SAAS;AAShB,SAAQC,YAAY,QAAO,SAAS;AAEpC,SACEH,kBAAkB,EAClBE,uBAAuB,EACvBD,qBAAqB,EAIrBH,mBAAmB,EAGnBC,mBAAmB,EAEnBH,qBAAqB,EACrBO,YAAY;AAEd,eAAeN,eAAe","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FlatList } from 'react-native';
3
+ import type { NestedReorderableListProps } from '../types';
4
+ export declare const NestedReorderableList: <T>(props: NestedReorderableListProps<T> & React.RefAttributes<FlatList<T>>) => JSX.Element;
5
+ //# sourceMappingURL=NestedReorderableList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NestedReorderableList.d.ts","sourceRoot":"","sources":["../../../src/components/NestedReorderableList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAKtC,OAAO,KAAK,EAAC,0BAA0B,EAAC,MAAM,UAAU,CAAC;AAgCzD,eAAO,MAAM,qBAAqB,kFAI7B,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FlatList } from 'react-native';
3
+ import type { ReorderableListProps } from '../types';
4
+ export declare const ReorderableList: <T>(props: ReorderableListProps<T> & React.RefAttributes<FlatList<T>>) => JSX.Element;
5
+ //# sourceMappingURL=ReorderableList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReorderableList.d.ts","sourceRoot":"","sources":["../../../src/components/ReorderableList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,UAAU,CAAC;AAsBnD,eAAO,MAAM,eAAe,4EAEvB,WAAW,CAAC"}