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/package.json
CHANGED
|
@@ -1,56 +1,216 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reorderable-list",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Reorderable list for React Native applications, powered by Reanimated
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Reorderable list for React Native applications, powered by Reanimated",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
11
10
|
"files": [
|
|
12
|
-
"
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__fixtures__",
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
13
28
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"prepack": "bob build",
|
|
34
|
+
"release": "release-it",
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"bootstrap": "yarn example && yarn install"
|
|
17
37
|
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"react-native",
|
|
40
|
+
"ios",
|
|
41
|
+
"android",
|
|
42
|
+
"reanimated",
|
|
43
|
+
"reorderable",
|
|
44
|
+
"sortable",
|
|
45
|
+
"flatlist",
|
|
46
|
+
"list",
|
|
47
|
+
"drag-and-drop",
|
|
48
|
+
"dnd"
|
|
49
|
+
],
|
|
50
|
+
"repository": "https://github.com/omahili/react-native-reorderable-list",
|
|
18
51
|
"author": "Omar Mahili",
|
|
19
52
|
"license": "MIT",
|
|
20
53
|
"bugs": {
|
|
21
54
|
"url": "https://github.com/omahili/react-native-reorderable-list/issues"
|
|
22
55
|
},
|
|
23
56
|
"homepage": "https://github.com/omahili/react-native-reorderable-list#readme",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"fast-memoize": "^2.5.2"
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
59
|
},
|
|
28
60
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"eslint
|
|
38
|
-
"eslint-
|
|
39
|
-
"eslint-
|
|
40
|
-
"eslint-plugin-
|
|
41
|
-
"eslint-plugin-
|
|
42
|
-
"
|
|
43
|
-
"prettier": "^2.
|
|
44
|
-
"react": "
|
|
45
|
-
"react-native": "
|
|
46
|
-
"react-native-
|
|
47
|
-
"react-native-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
61
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
62
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
63
|
+
"@react-native/babel-preset": "0.75.3",
|
|
64
|
+
"@react-native/eslint-config": "0.75.3",
|
|
65
|
+
"@react-native/metro-config": "0.75.3",
|
|
66
|
+
"@react-native/typescript-config": "0.75.3",
|
|
67
|
+
"@release-it/conventional-changelog": "^8.0.2",
|
|
68
|
+
"@types/react": "^18.3.9",
|
|
69
|
+
"eslint": "^8.4.1",
|
|
70
|
+
"eslint-config-prettier": "^8.5.0",
|
|
71
|
+
"eslint-import-resolver-typescript": "^3.5.5",
|
|
72
|
+
"eslint-plugin-import": "^2.27.5",
|
|
73
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
74
|
+
"jest": "^29.6.3",
|
|
75
|
+
"prettier": "^2.8.8",
|
|
76
|
+
"react": "18.3.1",
|
|
77
|
+
"react-native": "0.75.3",
|
|
78
|
+
"react-native-builder-bob": "^0.20.0",
|
|
79
|
+
"react-native-gesture-handler": "^2.12.0",
|
|
80
|
+
"react-native-reanimated": "^3.15.3",
|
|
81
|
+
"release-it": "^17.6.0",
|
|
82
|
+
"tsc": "^2.0.4",
|
|
83
|
+
"typescript": "5.0.4"
|
|
50
84
|
},
|
|
51
85
|
"peerDependencies": {
|
|
52
|
-
"react
|
|
53
|
-
"react-native
|
|
54
|
-
"react-native-
|
|
86
|
+
"react": "*",
|
|
87
|
+
"react-native": "*",
|
|
88
|
+
"react-native-gesture-handler": ">=2.0.0",
|
|
89
|
+
"react-native-reanimated": ">=3.6.0"
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">= 18.0.0"
|
|
93
|
+
},
|
|
94
|
+
"packageManager": "yarn@4.5.0",
|
|
95
|
+
"jest": {
|
|
96
|
+
"preset": "react-native",
|
|
97
|
+
"modulePathIgnorePatterns": [
|
|
98
|
+
"<rootDir>/example/node_modules",
|
|
99
|
+
"<rootDir>/lib/"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"commitlint": {
|
|
103
|
+
"extends": [
|
|
104
|
+
"@commitlint/config-conventional"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"release-it": {
|
|
108
|
+
"git": {
|
|
109
|
+
"commitMessage": "chore: release ${version}",
|
|
110
|
+
"tagName": "v${version}"
|
|
111
|
+
},
|
|
112
|
+
"npm": {
|
|
113
|
+
"publish": true
|
|
114
|
+
},
|
|
115
|
+
"github": {
|
|
116
|
+
"release": true
|
|
117
|
+
},
|
|
118
|
+
"plugins": {
|
|
119
|
+
"@release-it/conventional-changelog": {
|
|
120
|
+
"preset": {
|
|
121
|
+
"name": "angular"
|
|
122
|
+
},
|
|
123
|
+
"infile": "CHANGELOG.md"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"eslintConfig": {
|
|
128
|
+
"root": true,
|
|
129
|
+
"extends": [
|
|
130
|
+
"@react-native-community",
|
|
131
|
+
"plugin:import/recommended",
|
|
132
|
+
"prettier"
|
|
133
|
+
],
|
|
134
|
+
"plugins": [
|
|
135
|
+
"import"
|
|
136
|
+
],
|
|
137
|
+
"rules": {
|
|
138
|
+
"prettier/prettier": [
|
|
139
|
+
"error",
|
|
140
|
+
{
|
|
141
|
+
"quoteProps": "consistent",
|
|
142
|
+
"singleQuote": true,
|
|
143
|
+
"tabWidth": 2,
|
|
144
|
+
"bracketSpacing": false,
|
|
145
|
+
"bracketSameLine": true,
|
|
146
|
+
"trailingComma": "all",
|
|
147
|
+
"arrowParens": "avoid"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"import/order": [
|
|
151
|
+
"error",
|
|
152
|
+
{
|
|
153
|
+
"groups": [
|
|
154
|
+
"builtin",
|
|
155
|
+
"external"
|
|
156
|
+
],
|
|
157
|
+
"pathGroups": [
|
|
158
|
+
{
|
|
159
|
+
"pattern": "react+(|-native)",
|
|
160
|
+
"group": "builtin",
|
|
161
|
+
"position": "before"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"pathGroupsExcludedImportTypes": [
|
|
165
|
+
"react"
|
|
166
|
+
],
|
|
167
|
+
"newlines-between": "always",
|
|
168
|
+
"alphabetize": {
|
|
169
|
+
"order": "asc",
|
|
170
|
+
"caseInsensitive": true
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"sort-imports": [
|
|
175
|
+
"error",
|
|
176
|
+
{
|
|
177
|
+
"ignoreDeclarationSort": true
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
"settings": {
|
|
182
|
+
"import/resolver": {
|
|
183
|
+
"typescript": {
|
|
184
|
+
"project": "tsconfig.json"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"eslintIgnore": [
|
|
190
|
+
"node_modules/",
|
|
191
|
+
"lib/"
|
|
192
|
+
],
|
|
193
|
+
"prettier": {
|
|
194
|
+
"quoteProps": "consistent",
|
|
195
|
+
"singleQuote": true,
|
|
196
|
+
"tabWidth": 2,
|
|
197
|
+
"bracketSpacing": false,
|
|
198
|
+
"bracketSameLine": true,
|
|
199
|
+
"trailingComma": "all",
|
|
200
|
+
"arrowParens": "avoid"
|
|
201
|
+
},
|
|
202
|
+
"react-native-builder-bob": {
|
|
203
|
+
"source": "src",
|
|
204
|
+
"output": "lib",
|
|
205
|
+
"targets": [
|
|
206
|
+
"commonjs",
|
|
207
|
+
"module",
|
|
208
|
+
[
|
|
209
|
+
"typescript",
|
|
210
|
+
{
|
|
211
|
+
"project": "tsconfig.build.json"
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
]
|
|
55
215
|
}
|
|
56
216
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, {useCallback} from 'react';
|
|
2
|
+
import {CellRendererProps, FlatList, FlatListProps} from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {GestureDetector} from 'react-native-gesture-handler';
|
|
5
|
+
import Animated from 'react-native-reanimated';
|
|
6
|
+
|
|
7
|
+
import {AUTOSCROLL_DELAY} from './constants';
|
|
8
|
+
import {useReorderableList} from './useReorderableList';
|
|
9
|
+
import {ReorderableListContext} from '../../contexts';
|
|
10
|
+
import type {ReorderableListProps} from '../../types';
|
|
11
|
+
import {ReorderableListCell} from '../ReorderableListCell';
|
|
12
|
+
|
|
13
|
+
const AnimatedFlatList = Animated.createAnimatedComponent(
|
|
14
|
+
FlatList,
|
|
15
|
+
) as unknown as <T>(
|
|
16
|
+
props: FlatListProps<T> & {ref?: React.Ref<FlatList<T>>},
|
|
17
|
+
) => React.ReactElement;
|
|
18
|
+
|
|
19
|
+
const ReorderableList = <T,>(
|
|
20
|
+
{
|
|
21
|
+
data,
|
|
22
|
+
autoscrollThreshold = 0.1,
|
|
23
|
+
autoscrollSpeedScale = 1,
|
|
24
|
+
autoscrollDelay = AUTOSCROLL_DELAY,
|
|
25
|
+
animationDuration = 200,
|
|
26
|
+
dragReorderThreshold = 0.2,
|
|
27
|
+
onLayout,
|
|
28
|
+
onReorder,
|
|
29
|
+
onScroll,
|
|
30
|
+
keyExtractor,
|
|
31
|
+
extraData,
|
|
32
|
+
...rest
|
|
33
|
+
}: ReorderableListProps<T>,
|
|
34
|
+
ref: React.ForwardedRef<FlatList<T>>,
|
|
35
|
+
) => {
|
|
36
|
+
const {
|
|
37
|
+
gestureHandler,
|
|
38
|
+
handleScroll,
|
|
39
|
+
handleFlatListLayout,
|
|
40
|
+
handleRef,
|
|
41
|
+
startDrag,
|
|
42
|
+
listContextValue,
|
|
43
|
+
itemOffset,
|
|
44
|
+
itemHeight,
|
|
45
|
+
dragY,
|
|
46
|
+
draggedIndex,
|
|
47
|
+
releasedIndex,
|
|
48
|
+
duration,
|
|
49
|
+
} = useReorderableList({
|
|
50
|
+
ref,
|
|
51
|
+
autoscrollThreshold,
|
|
52
|
+
autoscrollSpeedScale,
|
|
53
|
+
autoscrollDelay,
|
|
54
|
+
animationDuration,
|
|
55
|
+
dragReorderThreshold,
|
|
56
|
+
onLayout,
|
|
57
|
+
onReorder,
|
|
58
|
+
onScroll,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const renderAnimatedCell = useCallback(
|
|
62
|
+
({index, children, item, onLayout: onCellLayout}: CellRendererProps<T>) => (
|
|
63
|
+
<ReorderableListCell
|
|
64
|
+
// forces remount of components with key change
|
|
65
|
+
key={keyExtractor ? keyExtractor(item, index) : index}
|
|
66
|
+
item={item}
|
|
67
|
+
extraData={extraData}
|
|
68
|
+
index={index}
|
|
69
|
+
itemOffset={itemOffset}
|
|
70
|
+
itemHeight={itemHeight}
|
|
71
|
+
dragY={dragY}
|
|
72
|
+
draggedIndex={draggedIndex}
|
|
73
|
+
releasedIndex={releasedIndex}
|
|
74
|
+
animationDuration={duration}
|
|
75
|
+
startDrag={startDrag}
|
|
76
|
+
children={children}
|
|
77
|
+
onLayout={onCellLayout}
|
|
78
|
+
/>
|
|
79
|
+
),
|
|
80
|
+
[
|
|
81
|
+
itemOffset,
|
|
82
|
+
itemHeight,
|
|
83
|
+
startDrag,
|
|
84
|
+
dragY,
|
|
85
|
+
draggedIndex,
|
|
86
|
+
releasedIndex,
|
|
87
|
+
duration,
|
|
88
|
+
keyExtractor,
|
|
89
|
+
extraData,
|
|
90
|
+
],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<ReorderableListContext.Provider value={listContextValue}>
|
|
95
|
+
<GestureDetector gesture={gestureHandler}>
|
|
96
|
+
<AnimatedFlatList
|
|
97
|
+
{...rest}
|
|
98
|
+
ref={handleRef}
|
|
99
|
+
data={data}
|
|
100
|
+
CellRendererComponent={renderAnimatedCell}
|
|
101
|
+
onLayout={handleFlatListLayout}
|
|
102
|
+
onScroll={handleScroll}
|
|
103
|
+
scrollEventThrottle={1}
|
|
104
|
+
horizontal={false}
|
|
105
|
+
removeClippedSubviews={false}
|
|
106
|
+
keyExtractor={keyExtractor}
|
|
107
|
+
extraData={extraData}
|
|
108
|
+
numColumns={1}
|
|
109
|
+
/>
|
|
110
|
+
</GestureDetector>
|
|
111
|
+
</ReorderableListContext.Provider>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const MemoizedReorderableList = React.memo(
|
|
116
|
+
React.forwardRef(ReorderableList),
|
|
117
|
+
) as <T>(
|
|
118
|
+
props: ReorderableListProps<T> & {
|
|
119
|
+
ref?: React.ForwardedRef<FlatListProps<T>>;
|
|
120
|
+
},
|
|
121
|
+
) => React.ReactElement;
|
|
122
|
+
|
|
123
|
+
export {MemoizedReorderableList as ReorderableList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ReorderableList';
|