react-native-reorderable-list 0.13.1 → 0.14.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 (54) hide show
  1. package/README.md +69 -9
  2. package/lib/commonjs/components/{ReorderableListCore/useReorderableListCore.js → ReorderableListCore.js} +112 -57
  3. package/lib/commonjs/components/ReorderableListCore.js.map +1 -0
  4. package/lib/commonjs/components/ScrollViewContainer.js +12 -4
  5. package/lib/commonjs/components/ScrollViewContainer.js.map +1 -1
  6. package/lib/commonjs/components/{ReorderableListCore/animationDefaults.js → constants.js} +26 -2
  7. package/lib/commonjs/components/constants.js.map +1 -0
  8. package/lib/module/components/{ReorderableListCore/useReorderableListCore.js → ReorderableListCore.js} +112 -55
  9. package/lib/module/components/ReorderableListCore.js.map +1 -0
  10. package/lib/module/components/ScrollViewContainer.js +13 -4
  11. package/lib/module/components/ScrollViewContainer.js.map +1 -1
  12. package/lib/module/components/constants.js +52 -0
  13. package/lib/module/components/constants.js.map +1 -0
  14. package/lib/typescript/components/{ReorderableListCore/ReorderableListCore.d.ts → ReorderableListCore.d.ts} +1 -1
  15. package/lib/typescript/components/ReorderableListCore.d.ts.map +1 -0
  16. package/lib/typescript/components/ScrollViewContainer.d.ts +2 -1
  17. package/lib/typescript/components/ScrollViewContainer.d.ts.map +1 -1
  18. package/lib/typescript/components/{ReorderableListCore/animationDefaults.d.ts → constants.d.ts} +6 -1
  19. package/lib/typescript/components/constants.d.ts.map +1 -0
  20. package/lib/typescript/types/props.d.ts +9 -0
  21. package/lib/typescript/types/props.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/src/components/{ReorderableListCore/useReorderableListCore.ts → ReorderableListCore.tsx} +184 -99
  24. package/src/components/ScrollViewContainer.tsx +22 -9
  25. package/src/components/{ReorderableListCore/animationDefaults.ts → constants.ts} +34 -0
  26. package/src/types/props.ts +9 -0
  27. package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js +0 -123
  28. package/lib/commonjs/components/ReorderableListCore/ReorderableListCore.js.map +0 -1
  29. package/lib/commonjs/components/ReorderableListCore/animationDefaults.js.map +0 -1
  30. package/lib/commonjs/components/ReorderableListCore/autoscrollConfig.js +0 -31
  31. package/lib/commonjs/components/ReorderableListCore/autoscrollConfig.js.map +0 -1
  32. package/lib/commonjs/components/ReorderableListCore/index.js +0 -17
  33. package/lib/commonjs/components/ReorderableListCore/index.js.map +0 -1
  34. package/lib/commonjs/components/ReorderableListCore/useReorderableListCore.js.map +0 -1
  35. package/lib/module/components/ReorderableListCore/ReorderableListCore.js +0 -116
  36. package/lib/module/components/ReorderableListCore/ReorderableListCore.js.map +0 -1
  37. package/lib/module/components/ReorderableListCore/animationDefaults.js +0 -28
  38. package/lib/module/components/ReorderableListCore/animationDefaults.js.map +0 -1
  39. package/lib/module/components/ReorderableListCore/autoscrollConfig.js +0 -25
  40. package/lib/module/components/ReorderableListCore/autoscrollConfig.js.map +0 -1
  41. package/lib/module/components/ReorderableListCore/index.js +0 -2
  42. package/lib/module/components/ReorderableListCore/index.js.map +0 -1
  43. package/lib/module/components/ReorderableListCore/useReorderableListCore.js.map +0 -1
  44. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts.map +0 -1
  45. package/lib/typescript/components/ReorderableListCore/animationDefaults.d.ts.map +0 -1
  46. package/lib/typescript/components/ReorderableListCore/autoscrollConfig.d.ts +0 -6
  47. package/lib/typescript/components/ReorderableListCore/autoscrollConfig.d.ts.map +0 -1
  48. package/lib/typescript/components/ReorderableListCore/index.d.ts +0 -2
  49. package/lib/typescript/components/ReorderableListCore/index.d.ts.map +0 -1
  50. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts +0 -183
  51. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts.map +0 -1
  52. package/src/components/ReorderableListCore/ReorderableListCore.tsx +0 -178
  53. package/src/components/ReorderableListCore/autoscrollConfig.ts +0 -31
  54. package/src/components/ReorderableListCore/index.ts +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"useReorderableListCore.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/useReorderableListCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,UAAU,EAEX,MAAM,cAAc,CAAC;AAQtB,OAAiB,EAGf,WAAW,EAYZ,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,2BAA2B,EAE5B,MAAM,aAAa,CAAC;AAOrB,UAAU,0BAA0B,CAAC,CAAC;IACpC,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,SAAS,CAAC;IACvE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,IAAI,CAAC;IAC7D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;IACzD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAC;IACjE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAChE,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACjD,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACnD,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACzD,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC1D,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1C,8BAA8B,EAAE,OAAO,GAAG,SAAS,CAAC;IACpD,cAAc,EAAE,6BAA6B,GAAG,SAAS,CAAC;IAC1D,sBAAsB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5C,UAAU,EAAE,OAAO,CAAC;IACpB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAED,eAAO,MAAM,sBAAsB;;;;;uBA8tBvB,MAAM;;;;;6CAvqBN,MAAM,MAAM,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2wBtC,CAAC"}
@@ -1,178 +0,0 @@
1
- import React, {useCallback, useMemo} from 'react';
2
- import {
3
- CellRendererProps,
4
- FlatList,
5
- FlatListProps,
6
- Platform,
7
- ScrollView,
8
- } from 'react-native';
9
-
10
- import {
11
- Gesture,
12
- GestureDetector,
13
- NativeGesture,
14
- } from 'react-native-gesture-handler';
15
- import Animated, {
16
- SharedValue,
17
- useComposedEventHandler,
18
- } from 'react-native-reanimated';
19
-
20
- import {AUTOSCROLL_CONFIG} from './autoscrollConfig';
21
- import {useReorderableListCore} from './useReorderableListCore';
22
- import {ReorderableListContext} from '../../contexts';
23
- import type {ReorderableListProps} from '../../types';
24
- import {ReorderableListCell} from '../ReorderableListCell';
25
-
26
- const AnimatedFlatList = Animated.createAnimatedComponent(
27
- FlatList,
28
- ) as unknown as <T>(
29
- props: FlatListProps<T> & {ref?: React.Ref<FlatList<T>>},
30
- ) => React.ReactElement;
31
-
32
- interface ReorderableListCoreProps<T> extends ReorderableListProps<T> {
33
- // not optional but undefined to avoid forgetting to pass a prop
34
- scrollViewContainerRef: React.RefObject<ScrollView> | undefined;
35
- scrollViewPageY: SharedValue<number> | undefined;
36
- scrollViewHeightY: SharedValue<number> | undefined;
37
- scrollViewScrollOffsetY: SharedValue<number> | undefined;
38
- scrollViewScrollEnabled: SharedValue<boolean> | undefined;
39
- outerScrollGesture: NativeGesture | undefined;
40
- initialScrollViewScrollEnabled: boolean | undefined;
41
- scrollable: boolean | undefined;
42
- scrollEnabled: boolean | undefined;
43
- }
44
-
45
- const ReorderableListCore = <T,>(
46
- {
47
- autoscrollThreshold = 0.1,
48
- autoscrollThresholdOffset,
49
- autoscrollSpeedScale = 1,
50
- autoscrollDelay = AUTOSCROLL_CONFIG.delay,
51
- autoscrollActivationDelta = 5,
52
- animationDuration = 200,
53
- onLayout,
54
- onReorder,
55
- onScroll,
56
- onDragStart,
57
- onDragEnd,
58
- onIndexChange,
59
- scrollViewContainerRef,
60
- scrollViewPageY,
61
- scrollViewHeightY,
62
- scrollViewScrollOffsetY,
63
- scrollViewScrollEnabled,
64
- initialScrollViewScrollEnabled,
65
- scrollable,
66
- outerScrollGesture,
67
- cellAnimations,
68
- shouldUpdateActiveItem,
69
- panEnabled = true,
70
- panActivateAfterLongPress,
71
- ...rest
72
- }: ReorderableListCoreProps<T>,
73
- ref: React.ForwardedRef<FlatList<T>>,
74
- ) => {
75
- const {
76
- gestureHandler,
77
- handleScroll,
78
- handleFlatListLayout,
79
- handleRef,
80
- startDrag,
81
- listContextValue,
82
- itemOffset,
83
- itemHeight,
84
- dragY,
85
- draggedIndex,
86
- duration,
87
- } = useReorderableListCore({
88
- ref,
89
- autoscrollThreshold,
90
- autoscrollThresholdOffset,
91
- autoscrollSpeedScale,
92
- autoscrollDelay,
93
- autoscrollActivationDelta,
94
- animationDuration,
95
- onLayout,
96
- onReorder,
97
- onDragStart,
98
- onDragEnd,
99
- onIndexChange,
100
- scrollViewContainerRef,
101
- scrollViewPageY,
102
- scrollViewHeightY,
103
- scrollViewScrollOffsetY,
104
- scrollViewScrollEnabled,
105
- scrollable,
106
- // flatlist will default to true if we pass explicitly undefined,
107
- // but internally we would treat it as false, so we force true
108
- initialScrollEnabled:
109
- typeof rest.scrollEnabled === 'undefined' ? true : rest.scrollEnabled,
110
- initialScrollViewScrollEnabled:
111
- typeof initialScrollViewScrollEnabled === 'undefined'
112
- ? true
113
- : initialScrollViewScrollEnabled,
114
- cellAnimations,
115
- shouldUpdateActiveItem,
116
- panEnabled,
117
- panActivateAfterLongPress,
118
- });
119
-
120
- const combinedGesture = useMemo(() => {
121
- // android is able to handle nested scroll view, but not the full height ones like iOS
122
- if (outerScrollGesture && !(Platform.OS === 'android' && scrollable)) {
123
- return Gesture.Simultaneous(outerScrollGesture, gestureHandler);
124
- }
125
-
126
- return gestureHandler;
127
- }, [scrollable, outerScrollGesture, gestureHandler]);
128
-
129
- const composedScrollHandler = useComposedEventHandler([
130
- handleScroll,
131
- onScroll || null,
132
- ]);
133
-
134
- const renderAnimatedCell = useCallback(
135
- ({cellKey, ...props}: CellRendererProps<T>) => (
136
- <ReorderableListCell
137
- {...props}
138
- // forces remount with key change on reorder
139
- key={`${cellKey}+${props.index}`}
140
- itemOffset={itemOffset}
141
- itemHeight={itemHeight}
142
- dragY={dragY}
143
- draggedIndex={draggedIndex}
144
- animationDuration={duration}
145
- startDrag={startDrag}
146
- />
147
- ),
148
- [itemOffset, itemHeight, dragY, draggedIndex, duration, startDrag],
149
- );
150
-
151
- return (
152
- <ReorderableListContext.Provider value={listContextValue}>
153
- <GestureDetector gesture={combinedGesture}>
154
- <AnimatedFlatList
155
- {...rest}
156
- ref={handleRef}
157
- CellRendererComponent={renderAnimatedCell}
158
- onLayout={handleFlatListLayout}
159
- onScroll={composedScrollHandler}
160
- scrollEventThrottle={1}
161
- horizontal={false}
162
- removeClippedSubviews={false}
163
- numColumns={1}
164
- />
165
- </GestureDetector>
166
- </ReorderableListContext.Provider>
167
- );
168
- };
169
-
170
- const MemoizedReorderableListCore = React.memo(
171
- React.forwardRef(ReorderableListCore),
172
- ) as <T>(
173
- props: ReorderableListCoreProps<T> & {
174
- ref?: React.ForwardedRef<FlatList<T> | null>;
175
- },
176
- ) => React.ReactElement;
177
-
178
- export {MemoizedReorderableListCore as ReorderableListCore};
@@ -1,31 +0,0 @@
1
- import {Platform} from 'react-native';
2
-
3
- const IOS_CONFIG = {
4
- delay: 80,
5
- increment: 100,
6
- };
7
-
8
- const ANDROID_FABRIC_CONFIG = {
9
- delay: 50,
10
- increment: 80,
11
- };
12
-
13
- const ANDROID_PAPER_CONFIG = {
14
- delay: 10,
15
- increment: 4,
16
- };
17
-
18
- export const IS_FABRIC =
19
- global && typeof global === 'object' && 'nativeFabricUIManager' in global;
20
-
21
- export const AUTOSCROLL_CONFIG = Platform.select({
22
- // autoscroll behaves differently with Fabric and Paper on Android
23
- android: IS_FABRIC ? ANDROID_FABRIC_CONFIG : ANDROID_PAPER_CONFIG,
24
- ios: IOS_CONFIG,
25
-
26
- // unsupported platforms
27
- web: IOS_CONFIG,
28
- macos: IOS_CONFIG,
29
- windows: IOS_CONFIG,
30
- native: IOS_CONFIG,
31
- });
@@ -1 +0,0 @@
1
- export * from './ReorderableListCore';