react-native-reorderable-list 0.3.0 → 0.5.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.
- package/LICENSE +1 -1
- package/README.md +118 -59
- package/lib/commonjs/components/ReorderableList/ReorderableList.js +99 -0
- package/lib/commonjs/components/ReorderableList/ReorderableList.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/constants.ios.js +10 -0
- package/lib/commonjs/components/ReorderableList/constants.ios.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/constants.js +10 -0
- package/lib/commonjs/components/ReorderableList/constants.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/index.js +17 -0
- package/lib/commonjs/components/ReorderableList/index.js.map +1 -0
- package/lib/commonjs/components/ReorderableList/useReorderableList.js +311 -0
- package/lib/commonjs/components/ReorderableList/useReorderableList.js.map +1 -0
- package/lib/commonjs/components/ReorderableListCell.js +93 -0
- package/lib/commonjs/components/ReorderableListCell.js.map +1 -0
- package/lib/commonjs/components/ReorderableListItem.js +87 -0
- package/lib/commonjs/components/ReorderableListItem.js.map +1 -0
- package/lib/commonjs/components/index.js +39 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/contexts/ReorderableCellContext.js +10 -0
- package/lib/commonjs/contexts/ReorderableCellContext.js.map +1 -0
- package/lib/commonjs/contexts/ReorderableListContext.js +10 -0
- package/lib/commonjs/contexts/ReorderableListContext.js.map +1 -0
- package/lib/commonjs/contexts/index.js +28 -0
- package/lib/commonjs/contexts/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +50 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useContext.js +16 -0
- package/lib/commonjs/hooks/useContext.js.map +1 -0
- package/lib/commonjs/hooks/useReorderableDrag.js +16 -0
- package/lib/commonjs/hooks/useReorderableDrag.js.map +1 -0
- package/lib/commonjs/hooks/useReorderableDragEnd.js +28 -0
- package/lib/commonjs/hooks/useReorderableDragEnd.js.map +1 -0
- package/lib/commonjs/hooks/useReorderableDragStart.js +22 -0
- package/lib/commonjs/hooks/useReorderableDragStart.js.map +1 -0
- package/lib/commonjs/index.js +41 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types/index.js +28 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/misc.js +14 -0
- package/lib/commonjs/types/misc.js.map +1 -0
- package/lib/commonjs/types/props.js +6 -0
- package/lib/commonjs/types/props.js.map +1 -0
- package/lib/commonjs/utils.js +23 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/components/ReorderableList/ReorderableList.js +91 -0
- package/lib/module/components/ReorderableList/ReorderableList.js.map +1 -0
- package/lib/module/components/ReorderableList/constants.ios.js +4 -0
- package/lib/module/components/ReorderableList/constants.ios.js.map +1 -0
- package/lib/module/components/ReorderableList/constants.js +4 -0
- package/lib/module/components/ReorderableList/constants.js.map +1 -0
- package/lib/module/components/ReorderableList/index.js +2 -0
- package/lib/module/components/ReorderableList/index.js.map +1 -0
- package/lib/module/components/ReorderableList/useReorderableList.js +302 -0
- package/lib/module/components/ReorderableList/useReorderableList.js.map +1 -0
- package/lib/module/components/ReorderableListCell.js +85 -0
- package/lib/module/components/ReorderableListCell.js.map +1 -0
- package/lib/module/components/ReorderableListItem.js +78 -0
- package/lib/module/components/ReorderableListItem.js.map +1 -0
- package/lib/module/components/index.js +4 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/contexts/ReorderableCellContext.js +3 -0
- package/lib/module/contexts/ReorderableCellContext.js.map +1 -0
- package/lib/module/contexts/ReorderableListContext.js +3 -0
- package/lib/module/contexts/ReorderableListContext.js.map +1 -0
- package/lib/module/contexts/index.js +3 -0
- package/lib/module/contexts/index.js.map +1 -0
- package/lib/module/hooks/index.js +5 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useContext.js +9 -0
- package/lib/module/hooks/useContext.js.map +1 -0
- package/lib/module/hooks/useReorderableDrag.js +9 -0
- package/lib/module/hooks/useReorderableDrag.js.map +1 -0
- package/lib/module/hooks/useReorderableDragEnd.js +21 -0
- package/lib/module/hooks/useReorderableDragEnd.js.map +1 -0
- package/lib/module/hooks/useReorderableDragStart.js +15 -0
- package/lib/module/hooks/useReorderableDragStart.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types/index.js +3 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/misc.js +8 -0
- package/lib/module/types/misc.js.map +1 -0
- package/lib/module/types/props.js +2 -0
- package/lib/module/types/props.js.map +1 -0
- package/lib/module/utils.js +16 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/components/ReorderableList/ReorderableList.d.ts +8 -0
- package/lib/typescript/components/ReorderableList/ReorderableList.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/constants.d.ts +3 -0
- package/lib/typescript/components/ReorderableList/constants.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/constants.ios.d.ts +3 -0
- package/lib/typescript/components/ReorderableList/constants.ios.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/index.d.ts +2 -0
- package/lib/typescript/components/ReorderableList/index.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableList/useReorderableList.d.ts +34 -0
- package/lib/typescript/components/ReorderableList/useReorderableList.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableListCell.d.ts +20 -0
- package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -0
- package/lib/typescript/components/ReorderableListItem.d.ts +4 -0
- package/lib/typescript/components/ReorderableListItem.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +4 -0
- package/lib/typescript/components/index.d.ts.map +1 -0
- package/lib/typescript/contexts/ReorderableCellContext.d.ts +11 -0
- package/lib/typescript/contexts/ReorderableCellContext.d.ts.map +1 -0
- package/lib/typescript/contexts/ReorderableListContext.d.ts +9 -0
- package/lib/typescript/contexts/ReorderableListContext.d.ts.map +1 -0
- package/lib/typescript/contexts/index.d.ts +3 -0
- package/lib/typescript/contexts/index.d.ts.map +1 -0
- package/lib/typescript/hooks/index.d.ts +5 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useContext.d.ts +3 -0
- package/lib/typescript/hooks/useContext.d.ts.map +1 -0
- package/lib/typescript/hooks/useReorderableDrag.d.ts +2 -0
- package/lib/typescript/hooks/useReorderableDrag.d.ts.map +1 -0
- package/lib/typescript/hooks/useReorderableDragEnd.d.ts +2 -0
- package/lib/typescript/hooks/useReorderableDragEnd.d.ts.map +1 -0
- package/lib/typescript/hooks/useReorderableDragStart.d.ts +2 -0
- package/lib/typescript/hooks/useReorderableDragStart.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +3 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/misc.d.ts +7 -0
- package/lib/typescript/types/misc.d.ts.map +1 -0
- package/lib/typescript/types/props.d.ts +90 -0
- package/lib/typescript/types/props.d.ts.map +1 -0
- package/lib/typescript/utils.d.ts +12 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/package.json +199 -39
- package/src/components/ReorderableList/ReorderableList.tsx +123 -0
- package/src/components/ReorderableList/constants.ios.ts +3 -0
- package/src/components/ReorderableList/constants.ts +3 -0
- package/src/components/ReorderableList/index.ts +1 -0
- package/src/components/ReorderableList/useReorderableList.ts +487 -0
- package/src/components/ReorderableListCell.tsx +143 -0
- package/src/components/ReorderableListItem.tsx +108 -0
- package/src/components/index.ts +3 -0
- package/src/contexts/ReorderableCellContext.ts +14 -0
- package/src/contexts/ReorderableListContext.ts +12 -0
- package/src/contexts/index.ts +2 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useContext.ts +11 -0
- package/src/hooks/useReorderableDrag.ts +7 -0
- package/src/hooks/useReorderableDragEnd.ts +25 -0
- package/src/hooks/useReorderableDragStart.ts +18 -0
- package/src/index.ts +26 -0
- package/src/types/index.ts +2 -0
- package/src/types/misc.ts +6 -0
- package/src/types/props.ts +101 -0
- package/src/utils.ts +15 -0
- package/dist/components/ReorderableList.d.ts +0 -7
- package/dist/components/ReorderableList.js +0 -311
- package/dist/components/ReorderableListItem.d.ts +0 -14
- package/dist/components/ReorderableListItem.js +0 -57
- package/dist/hooks/useAnimatedSharedValues.d.ts +0 -3
- package/dist/hooks/useAnimatedSharedValues.js +0 -33
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2
- package/dist/types/misc.d.ts +0 -15
- package/dist/types/misc.js +0 -7
- package/dist/types/props.d.ts +0 -27
- package/dist/types/props.js +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,75 +1,129 @@
|
|
|
1
1
|
# React Native Reorderable List
|
|
2
2
|
|
|
3
|
-
A reorderable list for React Native applications, powered by Reanimated
|
|
3
|
+
A reorderable list for React Native applications, powered by Reanimated 🚀
|
|
4
4
|
|
|
5
|
-

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## Index
|
|
9
|
+
|
|
10
|
+
- [Install](#install)
|
|
11
|
+
- [Components](#components)
|
|
12
|
+
- [ReorderableList](#reorderablelist)
|
|
13
|
+
- [ReorderableListItem](#reorderableitemanimation)
|
|
14
|
+
- [Hooks](#hooks)
|
|
15
|
+
- [useReorderableDrag](#usereorderabledrag)
|
|
16
|
+
- [useReorderableDragStart](#usereorderabledragstart)
|
|
17
|
+
- [useReorderableDragEnd](#usereorderabledragend)
|
|
18
|
+
- [Utils](#utils)
|
|
19
|
+
- [Example](#example)
|
|
20
|
+
- [License](#license)
|
|
6
21
|
|
|
7
22
|
## Install
|
|
8
23
|
|
|
9
|
-
|
|
24
|
+
Npm:
|
|
10
25
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save react-native-reorderable-list
|
|
28
|
+
```
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
Yarn:
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
```bash
|
|
33
|
+
yarn add react-native-reorderable-list
|
|
34
|
+
```
|
|
20
35
|
|
|
21
36
|
Then you need to install these two peer dependencies:
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated) >=3.6.0
|
|
39
|
+
- [React Native Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler) >=2.0.0
|
|
40
|
+
|
|
41
|
+
## Components
|
|
42
|
+
|
|
43
|
+
### ReorderableList
|
|
44
|
+
|
|
45
|
+
This component uses a [FlatList](https://reactnative.dev/docs/flatlist) and it extends its props:
|
|
46
|
+
|
|
47
|
+
| Props | Type | Required | Default | Description |
|
|
48
|
+
| -------------------- | ------------------------------------------------ | -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| autoscrollThreshold | `number` | No | `0.1` | Threshold at the extremity of the list that triggers autoscroll when an item is dragged to it. A value of `0.1` means that 10% of the area at the top and 10% at the bottom will trigger autoscroll. Min value: `0`. Max value: `0.4`. |
|
|
50
|
+
| autoscrollSpeedScale | `number` | No | `1` | Scales the autoscroll speed at which the list scrolls when an item is dragged to the scroll areas. |
|
|
51
|
+
| autoscrollDelay | `number` | No | `0` (Android), `100` (iOS) | Delay in between autoscroll triggers. Can be used to tune the autoscroll smoothness. Default values differ between platforms: `0` for Android and `100` for iOS. |
|
|
52
|
+
| dragReorderThreshold | `number` | No | `0.2` | Specifies the fraction of an item's size at which it will shift when a dragged item crosses over it. For example, `0.2` means the item shifts when the dragged item passes 20% of its height (in a vertical list). |
|
|
53
|
+
| animationDuration | `number` | No | `200` | Duration of the animations in milliseconds. Users won't be able to drag a new item until the dragged item is released and its animation to its new position ends. |
|
|
54
|
+
| onReorder | `(event: { from: number, to: number }) => void` | Yes | N/A | Event fired after an item is released and the list is reordered. |
|
|
55
|
+
| onScroll | `(event: NativeScrollEvent) => void` | No | N/A | Event fired at most once per frame during scrolling. Needs to be a `worklet`. See [Reanimated docs](https://docs.swmansion.com/react-native-reanimated) for further info. |
|
|
56
|
+
|
|
57
|
+
The following props from FlatList are not supported:
|
|
58
|
+
|
|
59
|
+
- horizontal
|
|
60
|
+
- scrollEventThrottle
|
|
61
|
+
- removeClippedSubviews
|
|
62
|
+
- CellRendererComponent
|
|
63
|
+
- numColumns
|
|
64
|
+
|
|
65
|
+
### ReorderableListItem
|
|
66
|
+
|
|
67
|
+
This component allows you to animate the item when it's dragged. It currently supports two animations: `scale` and `opacity`. Using this component is optional.
|
|
68
|
+
|
|
69
|
+
| Props | Type | Required | Default | Description |
|
|
70
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
71
|
+
| scaleAnimationConfig | `{ enabled?: boolean, valueEnd?: number, valueStart?: number, easingEnd?: EasingFunction, easingStart?: EasingFunction, duration?: number }` | false | `{ enabled: true, valueEnd: 1, valueStart: 1.025, easingStart: Easing.in(Easing.ease), easingEnd: Easing.out(Easing.ease), duration: 200 }` | Configures the scale animation of the reorderable item. |
|
|
72
|
+
| opacityAnimationConfig | `{ enabled?: boolean, valueEnd?: number, valueStart?: number, easingEnd?: EasingFunction, easingStart?: EasingFunction, duration?: number }` | false | `{ enabled: true, valueEnd: 1, valueStart: 0.75, easingStart: Easing.in(Easing.ease), easingEnd: Easing.out(Easing.ease), duration: 200, }` | Configures the opacity animation of the reorderable item. |
|
|
73
|
+
|
|
74
|
+
## Hooks
|
|
75
|
+
|
|
76
|
+
### useReorderableDrag
|
|
77
|
+
|
|
78
|
+
This hook creates a function that triggers the drag of a list item. It's usually called on a long press event. This hook can only be used inside of a list item component.
|
|
79
|
+
|
|
80
|
+
##### Returns
|
|
25
81
|
|
|
26
|
-
|
|
82
|
+
- `() => void`
|
|
27
83
|
|
|
28
|
-
|
|
84
|
+
### useReorderableDragStart
|
|
29
85
|
|
|
30
|
-
This
|
|
86
|
+
This hook allows handling the drag start event of a list item. It receives a worklet callback that is called when the drag starts. It's recommended to wrap the handler function in a useCallback as follows: `useReorderableDragStart(useCallback(...))`. This hook can only be used inside of a list item component.
|
|
31
87
|
|
|
32
|
-
|
|
88
|
+
##### Parameters
|
|
33
89
|
|
|
34
|
-
|
|
35
|
-
|---------------------------|---------------------------------------|------------|-----------|-------------------------------------------------------|
|
|
36
|
-
| renderItem | `(info: {item: T, index: number, separators: ItemSeparators, drag?: () => void, isDragged?: boolean}) => ReactElement` | yes | | Renders into the list an item from data. The function `drag` needs to be called when the drag gesture should be enabled, for example `onLongPress` event. The property `isDragged` becomes true for the dragged item. |
|
|
37
|
-
| onReorder | `(event: {fromIndex: number, toIndex: number}) => void` | yes | | Function called when an item is released and the list is reordered. |
|
|
38
|
-
| containerStyle | `StyleProp<ViewStyle>` | no | | Style for the FlatList container. |
|
|
39
|
-
| scrollAreaSize | `number` | no | `0.1` | Portion at the extremeties of the list which triggers scrolling when dragging an item. Accepts a value between `0` and `0.5`. |
|
|
40
|
-
| scrollSpeed | `number` | no | `2` | Speed at which the list scrolls. |
|
|
41
|
-
| dragScale | `number` | no | `1` | Size ratio to which an item scales when dragged. |
|
|
90
|
+
- onStart: `(index: number) => void`
|
|
42
91
|
|
|
43
|
-
|
|
92
|
+
### useReorderableDragEnd\*\*
|
|
44
93
|
|
|
45
|
-
|
|
94
|
+
This hook allows handling the drag end event of a list item. It receives a worklet callback that is called when the drag ends. It's recommended to wrap the handler function in a useCallback as follows: `useReorderableDragEnd(useCallback(...))`. This hook can only be used inside of a list item component.
|
|
46
95
|
|
|
47
|
-
|
|
48
|
-
- ```onScroll```
|
|
49
|
-
- ```scrollEventThrottle```
|
|
96
|
+
##### Parameters
|
|
50
97
|
|
|
51
|
-
|
|
98
|
+
- onEnd: `(from: number, to: number) => void`
|
|
99
|
+
|
|
100
|
+
## Utils
|
|
101
|
+
|
|
102
|
+
- **reorderItems**: `<T>(data: T[], from: number, to: number) => T[]`
|
|
103
|
+
|
|
104
|
+
This function receives an array of items, the index of the item to be moved, and the index of the new position and it returns a new array with the items reordered.
|
|
105
|
+
|
|
106
|
+
## Example
|
|
107
|
+
|
|
108
|
+
Here is an example of how to use this component. More examples can be found in the `example` directory of the repository.
|
|
52
109
|
|
|
53
110
|
```typescript
|
|
54
111
|
import React, {useState} from 'react';
|
|
55
|
-
import {Pressable, StyleSheet, Text} from 'react-native';
|
|
112
|
+
import {ListRenderItemInfo, Pressable, StyleSheet, Text} from 'react-native';
|
|
56
113
|
import ReorderableList, {
|
|
57
|
-
|
|
114
|
+
ReorderableListItem,
|
|
58
115
|
ReorderableListReorderEvent,
|
|
116
|
+
reorderItems,
|
|
117
|
+
useReorderableDrag,
|
|
59
118
|
} from 'react-native-reorderable-list';
|
|
60
119
|
|
|
61
|
-
interface
|
|
120
|
+
interface CardProps {
|
|
62
121
|
id: string;
|
|
63
122
|
color: string;
|
|
64
123
|
height: number;
|
|
65
124
|
}
|
|
66
125
|
|
|
67
|
-
|
|
68
|
-
drag?: () => void;
|
|
69
|
-
isDragged?: boolean;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const list: CardInfo[] = [
|
|
126
|
+
const list: CardProps[] = [
|
|
73
127
|
{id: '0', color: 'red', height: 100},
|
|
74
128
|
{id: '1', color: 'blue', height: 150},
|
|
75
129
|
{id: '2', color: 'green', height: 80},
|
|
@@ -82,26 +136,27 @@ const list: CardInfo[] = [
|
|
|
82
136
|
{id: '9', color: 'seagreen', height: 90},
|
|
83
137
|
];
|
|
84
138
|
|
|
85
|
-
const Card: React.FC<CardProps> = React.memo(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
139
|
+
const Card: React.FC<CardProps> = React.memo(({id, color, height}) => {
|
|
140
|
+
const drag = useReorderableDrag();
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<ReorderableListItem>
|
|
144
|
+
<Pressable style={[styles.card, {height}]} onLongPress={drag}>
|
|
145
|
+
<Text style={[styles.text, {color}]}>Card {id}</Text>
|
|
146
|
+
</Pressable>
|
|
147
|
+
</ReorderableListItem>
|
|
148
|
+
);
|
|
149
|
+
});
|
|
94
150
|
|
|
95
151
|
const App = () => {
|
|
96
152
|
const [data, setData] = useState(list);
|
|
97
153
|
|
|
98
|
-
const renderItem = (
|
|
99
|
-
{item
|
|
100
|
-
)
|
|
154
|
+
const renderItem = ({item}: ListRenderItemInfo<CardProps>) => (
|
|
155
|
+
<Card {...item} />
|
|
156
|
+
);
|
|
101
157
|
|
|
102
|
-
const handleReorder = ({
|
|
103
|
-
const newData =
|
|
104
|
-
newData.splice(toIndex, 0, newData.splice(fromIndex, 1)[0]);
|
|
158
|
+
const handleReorder = ({from, to}: ReorderableListReorderEvent) => {
|
|
159
|
+
const newData = reorderItems(data, from, to);
|
|
105
160
|
setData(newData);
|
|
106
161
|
};
|
|
107
162
|
|
|
@@ -110,8 +165,7 @@ const App = () => {
|
|
|
110
165
|
data={data}
|
|
111
166
|
onReorder={handleReorder}
|
|
112
167
|
renderItem={renderItem}
|
|
113
|
-
keyExtractor={
|
|
114
|
-
dragScale={1.025}
|
|
168
|
+
keyExtractor={item => item.id}
|
|
115
169
|
/>
|
|
116
170
|
);
|
|
117
171
|
};
|
|
@@ -126,9 +180,6 @@ const styles = StyleSheet.create({
|
|
|
126
180
|
borderWidth: 1,
|
|
127
181
|
borderColor: '#ddd',
|
|
128
182
|
},
|
|
129
|
-
dragged: {
|
|
130
|
-
opacity: 0.7,
|
|
131
|
-
},
|
|
132
183
|
text: {
|
|
133
184
|
fontSize: 20,
|
|
134
185
|
},
|
|
@@ -136,3 +187,11 @@ const styles = StyleSheet.create({
|
|
|
136
187
|
|
|
137
188
|
export default App;
|
|
138
189
|
```
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReorderableList = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
10
|
+
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
var _useReorderableList = require("./useReorderableList");
|
|
13
|
+
var _contexts = require("../../contexts");
|
|
14
|
+
var _ReorderableListCell = require("../ReorderableListCell");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
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); }
|
|
19
|
+
const AnimatedFlatList = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.FlatList);
|
|
20
|
+
const ReorderableList = ({
|
|
21
|
+
data,
|
|
22
|
+
autoscrollThreshold = 0.1,
|
|
23
|
+
autoscrollSpeedScale = 1,
|
|
24
|
+
autoscrollDelay = _constants.AUTOSCROLL_DELAY,
|
|
25
|
+
animationDuration = 200,
|
|
26
|
+
dragReorderThreshold = 0.2,
|
|
27
|
+
onLayout,
|
|
28
|
+
onReorder,
|
|
29
|
+
onScroll,
|
|
30
|
+
keyExtractor,
|
|
31
|
+
extraData,
|
|
32
|
+
...rest
|
|
33
|
+
}, ref) => {
|
|
34
|
+
const {
|
|
35
|
+
gestureHandler,
|
|
36
|
+
handleScroll,
|
|
37
|
+
handleFlatListLayout,
|
|
38
|
+
handleRef,
|
|
39
|
+
startDrag,
|
|
40
|
+
listContextValue,
|
|
41
|
+
itemOffset,
|
|
42
|
+
itemHeight,
|
|
43
|
+
dragY,
|
|
44
|
+
draggedIndex,
|
|
45
|
+
releasedIndex,
|
|
46
|
+
duration
|
|
47
|
+
} = (0, _useReorderableList.useReorderableList)({
|
|
48
|
+
ref,
|
|
49
|
+
autoscrollThreshold,
|
|
50
|
+
autoscrollSpeedScale,
|
|
51
|
+
autoscrollDelay,
|
|
52
|
+
animationDuration,
|
|
53
|
+
dragReorderThreshold,
|
|
54
|
+
onLayout,
|
|
55
|
+
onReorder,
|
|
56
|
+
onScroll
|
|
57
|
+
});
|
|
58
|
+
const renderAnimatedCell = (0, _react.useCallback)(({
|
|
59
|
+
index,
|
|
60
|
+
children,
|
|
61
|
+
item,
|
|
62
|
+
onLayout: onCellLayout
|
|
63
|
+
}) => /*#__PURE__*/_react.default.createElement(_ReorderableListCell.ReorderableListCell
|
|
64
|
+
// forces remount of components with key change
|
|
65
|
+
, {
|
|
66
|
+
key: keyExtractor ? keyExtractor(item, index) : index,
|
|
67
|
+
item: item,
|
|
68
|
+
extraData: extraData,
|
|
69
|
+
index: index,
|
|
70
|
+
itemOffset: itemOffset,
|
|
71
|
+
itemHeight: itemHeight,
|
|
72
|
+
dragY: dragY,
|
|
73
|
+
draggedIndex: draggedIndex,
|
|
74
|
+
releasedIndex: releasedIndex,
|
|
75
|
+
animationDuration: duration,
|
|
76
|
+
startDrag: startDrag,
|
|
77
|
+
children: children,
|
|
78
|
+
onLayout: onCellLayout
|
|
79
|
+
}), [itemOffset, itemHeight, startDrag, dragY, draggedIndex, releasedIndex, duration, keyExtractor, extraData]);
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_contexts.ReorderableListContext.Provider, {
|
|
81
|
+
value: listContextValue
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.GestureDetector, {
|
|
83
|
+
gesture: gestureHandler
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(AnimatedFlatList, _extends({}, rest, {
|
|
85
|
+
ref: handleRef,
|
|
86
|
+
data: data,
|
|
87
|
+
CellRendererComponent: renderAnimatedCell,
|
|
88
|
+
onLayout: handleFlatListLayout,
|
|
89
|
+
onScroll: handleScroll,
|
|
90
|
+
scrollEventThrottle: 1,
|
|
91
|
+
horizontal: false,
|
|
92
|
+
removeClippedSubviews: false,
|
|
93
|
+
keyExtractor: keyExtractor,
|
|
94
|
+
extraData: extraData,
|
|
95
|
+
numColumns: 1
|
|
96
|
+
}))));
|
|
97
|
+
};
|
|
98
|
+
const MemoizedReorderableList = exports.ReorderableList = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef(ReorderableList));
|
|
99
|
+
//# sourceMappingURL=ReorderableList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireDefault","_constants","_useReorderableList","_contexts","_ReorderableListCell","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","AnimatedFlatList","Animated","createAnimatedComponent","FlatList","ReorderableList","data","autoscrollThreshold","autoscrollSpeedScale","autoscrollDelay","AUTOSCROLL_DELAY","animationDuration","dragReorderThreshold","onLayout","onReorder","onScroll","keyExtractor","extraData","rest","ref","gestureHandler","handleScroll","handleFlatListLayout","handleRef","startDrag","listContextValue","itemOffset","itemHeight","dragY","draggedIndex","releasedIndex","duration","useReorderableList","renderAnimatedCell","useCallback","index","children","item","onCellLayout","createElement","ReorderableListCell","key","ReorderableListContext","Provider","value","GestureDetector","gesture","CellRendererComponent","scrollEventThrottle","horizontal","removeClippedSubviews","numColumns","MemoizedReorderableList","exports","React","memo","forwardRef"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/ReorderableList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,0BAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,oBAAA,GAAAR,OAAA;AAA2D,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAA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QAAQ,EAAEyB;EAAa,CACxB,CACF,EACD,CACEZ,UAAU,EACVC,UAAU,EACVH,SAAS,EACTI,KAAK,EACLC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACRf,YAAY,EACZC,SAAS,CAEb,CAAC;EAED,oBACErD,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAAClE,SAAA,CAAAqE,sBAAsB,CAACC,QAAQ;IAACC,KAAK,EAAEnB;EAAiB,gBACvD7D,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAACvE,0BAAA,CAAA6E,eAAe;IAACC,OAAO,EAAE1B;EAAe,gBACvCxD,MAAA,CAAAa,OAAA,CAAA8D,aAAA,CAACtC,gBAAgB,EAAAN,QAAA,KACXuB,IAAI;IACRC,GAAG,EAAEI,SAAU;IACfjB,IAAI,EAAEA,IAAK;IACXyC,qBAAqB,EAAEd,kBAAmB;IAC1CpB,QAAQ,EAAES,oBAAqB;IAC/BP,QAAQ,EAAEM,YAAa;IACvB2B,mBAAmB,EAAE,CAAE;IACvBC,UAAU,EAAE,KAAM;IAClBC,qBAAqB,EAAE,KAAM;IAC7BlC,YAAY,EAAEA,YAAa;IAC3BC,SAAS,EAAEA,SAAU;IACrBkC,UAAU,EAAE;EAAE,EACf,CACc,CACc,CAAC;AAEtC,CAAC;AAED,MAAMC,uBAAuB,GAAAC,OAAA,CAAAhD,eAAA,gBAAGiD,cAAK,CAACC,IAAI,cACxCD,cAAK,CAACE,UAAU,CAACnD,eAAe,CAClC,CAIuB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AUTOSCROLL_INCREMENT = exports.AUTOSCROLL_DELAY = void 0;
|
|
7
|
+
// iOS specific constants
|
|
8
|
+
const AUTOSCROLL_INCREMENT = exports.AUTOSCROLL_INCREMENT = 80;
|
|
9
|
+
const AUTOSCROLL_DELAY = exports.AUTOSCROLL_DELAY = 100;
|
|
10
|
+
//# sourceMappingURL=constants.ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AUTOSCROLL_INCREMENT","exports","AUTOSCROLL_DELAY"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/constants.ios.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,EAAE;AAC/B,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,GAAG","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AUTOSCROLL_INCREMENT = exports.AUTOSCROLL_DELAY = void 0;
|
|
7
|
+
// Default constants
|
|
8
|
+
const AUTOSCROLL_INCREMENT = exports.AUTOSCROLL_INCREMENT = 5;
|
|
9
|
+
const AUTOSCROLL_DELAY = exports.AUTOSCROLL_DELAY = 0;
|
|
10
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AUTOSCROLL_INCREMENT","exports","AUTOSCROLL_DELAY"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/constants.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CAAC;AAC9B,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ReorderableList = require("./ReorderableList");
|
|
7
|
+
Object.keys(_ReorderableList).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ReorderableList[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ReorderableList[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ReorderableList","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../../src","sources":["components/ReorderableList/index.ts"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|