react-native-sortable-dynamic 0.2.1 → 0.3.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/README.md +13 -11
- package/lib/commonjs/SortableContainer.js +11 -4
- package/lib/commonjs/SortableContainer.js.map +1 -1
- package/lib/commonjs/SortableView.js +11 -2
- package/lib/commonjs/SortableView.js.map +1 -1
- package/lib/module/SortableContainer.js +11 -4
- package/lib/module/SortableContainer.js.map +1 -1
- package/lib/module/SortableView.js +11 -2
- package/lib/module/SortableView.js.map +1 -1
- package/package.json +1 -1
- package/src/SortableContainer.js +16 -5
- package/src/SortableView.js +9 -0
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/module/package.json +0 -1
package/README.md
CHANGED
|
@@ -161,17 +161,19 @@ export default App;
|
|
|
161
161
|
|
|
162
162
|
#### `SortableView`
|
|
163
163
|
|
|
164
|
-
| Prop
|
|
165
|
-
|
|
|
166
|
-
| `config`
|
|
167
|
-
| `data`
|
|
168
|
-
| `editing`
|
|
169
|
-
| `onDragEnd`
|
|
170
|
-
| `renderItem`
|
|
171
|
-
| `onPress`
|
|
172
|
-
| `onLongPress`
|
|
173
|
-
| `itemStyle`
|
|
174
|
-
| `itemProps`
|
|
164
|
+
| Prop | Type | Description |
|
|
165
|
+
| ----------------------------- | ---------- | -------------------------------------------------------------------------------------------------- |
|
|
166
|
+
| `config` | `object` | Configuration options such as `MARGIN` and `COL`. Use this to dynamically adjust the grid layout. |
|
|
167
|
+
| `data` | `array` | Array of items to be rendered and sorted. |
|
|
168
|
+
| `editing` | `boolean` | If true, allows items to be dragged and reordered. |
|
|
169
|
+
| `onDragEnd` | `function` | Callback function that receives updated positions when the drag ends. |
|
|
170
|
+
| `renderItem` | `function` | Function to render each item inside the sortable container. Receives item and index as parameters. |
|
|
171
|
+
| `onPress` | `function` | Function to handle the press event on a sortable item. |
|
|
172
|
+
| `onLongPress` | `function` | Function to handle the long press event on a sortable item. |
|
|
173
|
+
| `itemStyle` | `object` | Custom style to apply to each SortableItem. |
|
|
174
|
+
| `itemProps` | `object` | Additional props to be passed to each SortableItem. |
|
|
175
|
+
| `scrollContainerStyle` | `object` | Custom style to apply to the scroll container. |
|
|
176
|
+
| `scrollContentContainerStyle` | `object` | Custom style to apply to the scroll content container. |
|
|
175
177
|
|
|
176
178
|
### Note
|
|
177
179
|
|
|
@@ -27,8 +27,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
27
27
|
* @param {function} renderItem - Function to render the content of each item inside the sortable container. Receives an object containing `item` and `index`.
|
|
28
28
|
* @param {function} onPress - Function to handle the press event on a sortable item.
|
|
29
29
|
* @param {function} onLongPress - Function to handle the long press event on a sortable item.
|
|
30
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
31
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
30
32
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
31
33
|
* @param {...object} itemProps - Additional props to be passed to each SortableItem.
|
|
34
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
32
35
|
*
|
|
33
36
|
* Usage:
|
|
34
37
|
* <SortableContainer
|
|
@@ -47,7 +50,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
47
50
|
renderItem,
|
|
48
51
|
onPress,
|
|
49
52
|
onLongPress,
|
|
53
|
+
scrollContainerStyle,
|
|
54
|
+
scrollContentContainerStyle,
|
|
50
55
|
itemStyle,
|
|
56
|
+
scrollViewProps,
|
|
51
57
|
...itemProps
|
|
52
58
|
}) => {
|
|
53
59
|
// Get the configuration for columns and size from context
|
|
@@ -77,14 +83,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
77
83
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView, {
|
|
78
84
|
onScroll: onScroll,
|
|
79
85
|
ref: scrollView,
|
|
80
|
-
contentContainerStyle: {
|
|
86
|
+
contentContainerStyle: [{
|
|
81
87
|
// Calculate the total height needed for the scroll view content
|
|
82
88
|
height: Math.ceil(data.length / COL) * SIZE
|
|
83
|
-
},
|
|
89
|
+
}, scrollContentContainerStyle],
|
|
84
90
|
showsVerticalScrollIndicator: false,
|
|
85
91
|
bounces: false,
|
|
86
|
-
scrollEventThrottle: 16
|
|
87
|
-
,
|
|
92
|
+
scrollEventThrottle: 16,
|
|
93
|
+
style: scrollContainerStyle,
|
|
94
|
+
...scrollViewProps,
|
|
88
95
|
children: data.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_SortableItemWrapper.default, {
|
|
89
96
|
id: item.id.toString(),
|
|
90
97
|
positions: positions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_SortableItemWrapper","_interopRequireDefault","_SortableItem","_Config","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SortableContainer","data","editing","onDragEnd","renderItem","onPress","onLongPress","itemStyle","itemProps","COL","SIZE","useSortableConfig","scrollY","useSharedValue","scrollView","useAnimatedRef","positions","reduce","acc","item","index","id","onScroll","useAnimatedScrollHandler","contentOffset","y","value","jsx","ScrollView","ref","contentContainerStyle","height","Math","ceil","length","showsVerticalScrollIndicator","bounces","scrollEventThrottle","children","map","toString","draggable","reorderable","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_SortableItemWrapper","_interopRequireDefault","_SortableItem","_Config","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SortableContainer","data","editing","onDragEnd","renderItem","onPress","onLongPress","scrollContainerStyle","scrollContentContainerStyle","itemStyle","scrollViewProps","itemProps","COL","SIZE","useSortableConfig","scrollY","useSharedValue","scrollView","useAnimatedRef","positions","reduce","acc","item","index","id","onScroll","useAnimatedScrollHandler","contentOffset","y","value","jsx","ScrollView","ref","contentContainerStyle","height","Math","ceil","length","showsVerticalScrollIndicator","bounces","scrollEventThrottle","style","children","map","toString","draggable","reorderable","_default","exports","memo"],"sourceRoot":"../../src","sources":["SortableContainer.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAKA,IAAAE,oBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAA6C,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAG,uBAAAI,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,SAAAR,wBAAAQ,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC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AAQ,CAAC,CAAE;QACvBC,SAAS,EAAEvB,IAAI,CAACuB,SAAU;QAC1BC,WAAW,EAAExB,IAAI,CAACwB,WAAY;QAC9BzC,OAAO,EAAEA,CAAA,KAAMA,OAAO,IAAIA,OAAO,CAACiB,IAAI,CAAE;QACxChB,WAAW,EAAEA,CAAA,KAAMA,WAAW,IAAIA,WAAW,CAACgB,IAAI,CAAE;QACpDmB,KAAK,EAAEhC,SAAU;QAAA,GACbE,SAAS;QAAA+B,QAAA,EAEZtC,UAAU,CAAC;UAAEkB,IAAI,EAAEA,IAAI;UAAEC;QAAM,CAAC;MAAC,CACtB;IAAC,GAtBVD,IAAI,CAACE,EAAE,CAACoB,QAAQ,CAAC,CAuBH,CACtB;EAAC,CACiB,CAAC;AAE1B,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAlE,OAAA,gBAEa,IAAAmE,WAAI,EAACjD,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -24,8 +24,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
24
24
|
* @param {function} renderItem - Function to render each item inside the sortable view. Receives an object containing `item` and `index`.
|
|
25
25
|
* @param {function} onPress - Function to handle the press event on an item.
|
|
26
26
|
* @param {function} onLongPress - Function to handle the long press event on an item.
|
|
27
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
28
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
27
29
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
28
30
|
* @param {object} itemProps - Additional props to be passed to each SortableItem.
|
|
31
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
29
32
|
*
|
|
30
33
|
* Usage:
|
|
31
34
|
* <SortableView
|
|
@@ -47,8 +50,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
47
50
|
renderItem,
|
|
48
51
|
onPress,
|
|
49
52
|
onLongPress,
|
|
53
|
+
scrollContainerStyle,
|
|
54
|
+
scrollContentContainerStyle,
|
|
50
55
|
itemStyle,
|
|
51
|
-
itemProps
|
|
56
|
+
itemProps,
|
|
57
|
+
scrollViewProps = {}
|
|
52
58
|
}) => {
|
|
53
59
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Config.default, {
|
|
54
60
|
config: config,
|
|
@@ -61,8 +67,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
61
67
|
renderItem: renderItem,
|
|
62
68
|
onPress: onPress,
|
|
63
69
|
onLongPress: onLongPress,
|
|
70
|
+
scrollContainerStyle: scrollContainerStyle,
|
|
71
|
+
scrollContentContainerStyle: scrollContentContainerStyle,
|
|
64
72
|
style: itemStyle,
|
|
65
|
-
...itemProps
|
|
73
|
+
...itemProps,
|
|
74
|
+
scrollViewProps: scrollViewProps
|
|
66
75
|
})
|
|
67
76
|
});
|
|
68
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_Config","_SortableContainer","_jsxRuntime","e","__esModule","default","SortableView","config","data","editing","onDragEnd","renderItem","onPress","onLongPress","itemStyle","itemProps","jsx","children","positions","style","_default","exports"],"sourceRoot":"../../src","sources":["SortableView.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAoD,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAMG,YAAY,GAAGA,CAAC;EACpBC,MAAM;EACNC,IAAI;EACJC,OAAO;EACPC,SAAS;EACTC,UAAU;EACVC,OAAO;EACPC,WAAW;EACXC,SAAS;EACTC;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_Config","_SortableContainer","_jsxRuntime","e","__esModule","default","SortableView","config","data","editing","onDragEnd","renderItem","onPress","onLongPress","scrollContainerStyle","scrollContentContainerStyle","itemStyle","itemProps","scrollViewProps","jsx","children","positions","style","_default","exports"],"sourceRoot":"../../src","sources":["SortableView.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAoD,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAMG,YAAY,GAAGA,CAAC;EACpBC,MAAM;EACNC,IAAI;EACJC,OAAO;EACPC,SAAS;EACTC,UAAU;EACVC,OAAO;EACPC,WAAW;EACXC,oBAAoB;EACpBC,2BAA2B;EAC3BC,SAAS;EACTC,SAAS;EACTC,eAAe,GAAG,CAAC;AACrB,CAAC,KAAK;EACJ,oBACE,IAAAhB,WAAA,CAAAiB,GAAA,EAACnB,OAAA,CAAAK,OAAoB;IAACE,MAAM,EAAEA,MAAO;IAAAa,QAAA,eACnC,IAAAlB,WAAA,CAAAiB,GAAA,EAAClB,kBAAA,CAAAI,OAAiB;MAChBI,OAAO,EAAEA,OAAQ;MACjBD,IAAI,EAAEA,IAAK;MACXE,SAAS,EAAGW,SAAS,IAAK;QACxBX,SAAS,CAACW,SAAS,CAAC;MACtB,CAAE;MACFV,UAAU,EAAEA,UAAW;MACvBC,OAAO,EAAEA,OAAQ;MACjBC,WAAW,EAAEA,WAAY;MACzBC,oBAAoB,EAAEA,oBAAqB;MAC3CC,2BAA2B,EAAEA,2BAA4B;MACzDO,KAAK,EAAEN,SAAU;MAAA,GACbC,SAAS;MACbC,eAAe,EAAEA;IAAgB,CAClC;EAAC,CACkB,CAAC;AAE3B,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEaC,YAAY","ignoreList":[]}
|
|
@@ -20,8 +20,11 @@ import { useSortableConfig } from "./Config.js";
|
|
|
20
20
|
* @param {function} renderItem - Function to render the content of each item inside the sortable container. Receives an object containing `item` and `index`.
|
|
21
21
|
* @param {function} onPress - Function to handle the press event on a sortable item.
|
|
22
22
|
* @param {function} onLongPress - Function to handle the long press event on a sortable item.
|
|
23
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
24
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
23
25
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
24
26
|
* @param {...object} itemProps - Additional props to be passed to each SortableItem.
|
|
27
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
25
28
|
*
|
|
26
29
|
* Usage:
|
|
27
30
|
* <SortableContainer
|
|
@@ -42,7 +45,10 @@ const SortableContainer = ({
|
|
|
42
45
|
renderItem,
|
|
43
46
|
onPress,
|
|
44
47
|
onLongPress,
|
|
48
|
+
scrollContainerStyle,
|
|
49
|
+
scrollContentContainerStyle,
|
|
45
50
|
itemStyle,
|
|
51
|
+
scrollViewProps,
|
|
46
52
|
...itemProps
|
|
47
53
|
}) => {
|
|
48
54
|
// Get the configuration for columns and size from context
|
|
@@ -72,14 +78,15 @@ const SortableContainer = ({
|
|
|
72
78
|
return /*#__PURE__*/_jsx(Animated.ScrollView, {
|
|
73
79
|
onScroll: onScroll,
|
|
74
80
|
ref: scrollView,
|
|
75
|
-
contentContainerStyle: {
|
|
81
|
+
contentContainerStyle: [{
|
|
76
82
|
// Calculate the total height needed for the scroll view content
|
|
77
83
|
height: Math.ceil(data.length / COL) * SIZE
|
|
78
|
-
},
|
|
84
|
+
}, scrollContentContainerStyle],
|
|
79
85
|
showsVerticalScrollIndicator: false,
|
|
80
86
|
bounces: false,
|
|
81
|
-
scrollEventThrottle: 16
|
|
82
|
-
,
|
|
87
|
+
scrollEventThrottle: 16,
|
|
88
|
+
style: scrollContainerStyle,
|
|
89
|
+
...scrollViewProps,
|
|
83
90
|
children: data.map((item, index) => /*#__PURE__*/_jsx(SortableItemWrapper, {
|
|
84
91
|
id: item.id.toString(),
|
|
85
92
|
positions: positions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","Animated","useAnimatedRef","useAnimatedScrollHandler","useSharedValue","SortableItemWrapper","SortableItem","useSortableConfig","jsx","_jsx","SortableContainer","data","editing","onDragEnd","renderItem","onPress","onLongPress","itemStyle","itemProps","COL","SIZE","scrollY","scrollView","positions","reduce","acc","item","index","id","onScroll","contentOffset","y","value","ScrollView","ref","contentContainerStyle","height","Math","ceil","length","showsVerticalScrollIndicator","bounces","scrollEventThrottle","children","map","toString","draggable","reorderable"
|
|
1
|
+
{"version":3,"names":["React","memo","Animated","useAnimatedRef","useAnimatedScrollHandler","useSharedValue","SortableItemWrapper","SortableItem","useSortableConfig","jsx","_jsx","SortableContainer","data","editing","onDragEnd","renderItem","onPress","onLongPress","scrollContainerStyle","scrollContentContainerStyle","itemStyle","scrollViewProps","itemProps","COL","SIZE","scrollY","scrollView","positions","reduce","acc","item","index","id","onScroll","contentOffset","y","value","ScrollView","ref","contentContainerStyle","height","Math","ceil","length","showsVerticalScrollIndicator","bounces","scrollEventThrottle","style","children","map","toString","draggable","reorderable"],"sourceRoot":"../../src","sources":["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C;UAAEe,IAAI,EAAEA,IAAI;UAAEC;QAAM,CAAC;MAAC,CACtB;IAAC,GAtBVD,IAAI,CAACE,EAAE,CAACkB,QAAQ,CAAC,CAuBH,CACtB;EAAC,CACiB,CAAC;AAE1B,CAAC;AAED,4BAAejD,IAAI,CAACU,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -19,8 +19,11 @@ import SortableContainer from "./SortableContainer.js";
|
|
|
19
19
|
* @param {function} renderItem - Function to render each item inside the sortable view. Receives an object containing `item` and `index`.
|
|
20
20
|
* @param {function} onPress - Function to handle the press event on an item.
|
|
21
21
|
* @param {function} onLongPress - Function to handle the long press event on an item.
|
|
22
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
23
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
22
24
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
23
25
|
* @param {object} itemProps - Additional props to be passed to each SortableItem.
|
|
26
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
24
27
|
*
|
|
25
28
|
* Usage:
|
|
26
29
|
* <SortableView
|
|
@@ -44,8 +47,11 @@ const SortableView = ({
|
|
|
44
47
|
renderItem,
|
|
45
48
|
onPress,
|
|
46
49
|
onLongPress,
|
|
50
|
+
scrollContainerStyle,
|
|
51
|
+
scrollContentContainerStyle,
|
|
47
52
|
itemStyle,
|
|
48
|
-
itemProps
|
|
53
|
+
itemProps,
|
|
54
|
+
scrollViewProps = {}
|
|
49
55
|
}) => {
|
|
50
56
|
return /*#__PURE__*/_jsx(SortableListProvider, {
|
|
51
57
|
config: config,
|
|
@@ -58,8 +64,11 @@ const SortableView = ({
|
|
|
58
64
|
renderItem: renderItem,
|
|
59
65
|
onPress: onPress,
|
|
60
66
|
onLongPress: onLongPress,
|
|
67
|
+
scrollContainerStyle: scrollContainerStyle,
|
|
68
|
+
scrollContentContainerStyle: scrollContentContainerStyle,
|
|
61
69
|
style: itemStyle,
|
|
62
|
-
...itemProps
|
|
70
|
+
...itemProps,
|
|
71
|
+
scrollViewProps: scrollViewProps
|
|
63
72
|
})
|
|
64
73
|
});
|
|
65
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SortableListProvider","SortableContainer","jsx","_jsx","SortableView","config","data","editing","onDragEnd","renderItem","onPress","onLongPress","itemStyle","itemProps","children","positions","style"],"sourceRoot":"../../src","sources":["SortableView.js"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,oBAAoB,MAAM,aAAU;AAC3C,OAAOC,iBAAiB,MAAM,wBAAqB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["React","SortableListProvider","SortableContainer","jsx","_jsx","SortableView","config","data","editing","onDragEnd","renderItem","onPress","onLongPress","scrollContainerStyle","scrollContentContainerStyle","itemStyle","itemProps","scrollViewProps","children","positions","style"],"sourceRoot":"../../src","sources":["SortableView.js"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,oBAAoB,MAAM,aAAU;AAC3C,OAAOC,iBAAiB,MAAM,wBAAqB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAjCA,SAAAC,GAAA,IAAAC,IAAA;AAkCA,MAAMC,YAAY,GAAGA,CAAC;EACpBC,MAAM;EACNC,IAAI;EACJC,OAAO;EACPC,SAAS;EACTC,UAAU;EACVC,OAAO;EACPC,WAAW;EACXC,oBAAoB;EACpBC,2BAA2B;EAC3BC,SAAS;EACTC,SAAS;EACTC,eAAe,GAAG,CAAC;AACrB,CAAC,KAAK;EACJ,oBACEb,IAAA,CAACH,oBAAoB;IAACK,MAAM,EAAEA,MAAO;IAAAY,QAAA,eACnCd,IAAA,CAACF,iBAAiB;MAChBM,OAAO,EAAEA,OAAQ;MACjBD,IAAI,EAAEA,IAAK;MACXE,SAAS,EAAGU,SAAS,IAAK;QACxBV,SAAS,CAACU,SAAS,CAAC;MACtB,CAAE;MACFT,UAAU,EAAEA,UAAW;MACvBC,OAAO,EAAEA,OAAQ;MACjBC,WAAW,EAAEA,WAAY;MACzBC,oBAAoB,EAAEA,oBAAqB;MAC3CC,2BAA2B,EAAEA,2BAA4B;MACzDM,KAAK,EAAEL,SAAU;MAAA,GACbC,SAAS;MACbC,eAAe,EAAEA;IAAgB,CAClC;EAAC,CACkB,CAAC;AAE3B,CAAC;AAED,eAAeZ,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-sortable-dynamic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "This package provides a highly customizable, animated, and performant sortable grid list component for React Native. It allows users to easily reorder grid items through drag-and-drop gestures, with smooth animations powered by react-native-reanimated and gesture handling by react-native-gesture-handler.",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
package/src/SortableContainer.js
CHANGED
|
@@ -22,8 +22,11 @@ import { useSortableConfig } from './Config';
|
|
|
22
22
|
* @param {function} renderItem - Function to render the content of each item inside the sortable container. Receives an object containing `item` and `index`.
|
|
23
23
|
* @param {function} onPress - Function to handle the press event on a sortable item.
|
|
24
24
|
* @param {function} onLongPress - Function to handle the long press event on a sortable item.
|
|
25
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
26
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
25
27
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
26
28
|
* @param {...object} itemProps - Additional props to be passed to each SortableItem.
|
|
29
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
27
30
|
*
|
|
28
31
|
* Usage:
|
|
29
32
|
* <SortableContainer
|
|
@@ -43,7 +46,10 @@ const SortableContainer = ({
|
|
|
43
46
|
renderItem,
|
|
44
47
|
onPress,
|
|
45
48
|
onLongPress,
|
|
49
|
+
scrollContainerStyle,
|
|
50
|
+
scrollContentContainerStyle,
|
|
46
51
|
itemStyle,
|
|
52
|
+
scrollViewProps,
|
|
47
53
|
...itemProps
|
|
48
54
|
}) => {
|
|
49
55
|
// Get the configuration for columns and size from context
|
|
@@ -67,13 +73,18 @@ const SortableContainer = ({
|
|
|
67
73
|
<Animated.ScrollView
|
|
68
74
|
onScroll={onScroll}
|
|
69
75
|
ref={scrollView}
|
|
70
|
-
contentContainerStyle={
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
contentContainerStyle={[
|
|
77
|
+
{
|
|
78
|
+
// Calculate the total height needed for the scroll view content
|
|
79
|
+
height: Math.ceil(data.length / COL) * SIZE,
|
|
80
|
+
},
|
|
81
|
+
scrollContentContainerStyle,
|
|
82
|
+
]}
|
|
74
83
|
showsVerticalScrollIndicator={false}
|
|
75
84
|
bounces={false}
|
|
76
|
-
scrollEventThrottle={16}
|
|
85
|
+
scrollEventThrottle={16}
|
|
86
|
+
style={scrollContainerStyle}
|
|
87
|
+
{...scrollViewProps}
|
|
77
88
|
>
|
|
78
89
|
{/* Render each item using the SortableItemWrapper and SortableItem components */}
|
|
79
90
|
{data.map((item, index) => (
|
package/src/SortableView.js
CHANGED
|
@@ -17,8 +17,11 @@ import SortableContainer from './SortableContainer';
|
|
|
17
17
|
* @param {function} renderItem - Function to render each item inside the sortable view. Receives an object containing `item` and `index`.
|
|
18
18
|
* @param {function} onPress - Function to handle the press event on an item.
|
|
19
19
|
* @param {function} onLongPress - Function to handle the long press event on an item.
|
|
20
|
+
* @param {object} scrollContainerStyle - Custom style to apply to the scroll container.
|
|
21
|
+
* @param {object} scrollContentContainerStyle - Custom style to apply to the scroll content container.
|
|
20
22
|
* @param {object} itemStyle - Custom style to apply to each SortableItem.
|
|
21
23
|
* @param {object} itemProps - Additional props to be passed to each SortableItem.
|
|
24
|
+
* @param {object} scrollViewProps - Additional props to be passed to the ScrollView component.
|
|
22
25
|
*
|
|
23
26
|
* Usage:
|
|
24
27
|
* <SortableView
|
|
@@ -41,8 +44,11 @@ const SortableView = ({
|
|
|
41
44
|
renderItem,
|
|
42
45
|
onPress,
|
|
43
46
|
onLongPress,
|
|
47
|
+
scrollContainerStyle,
|
|
48
|
+
scrollContentContainerStyle,
|
|
44
49
|
itemStyle,
|
|
45
50
|
itemProps,
|
|
51
|
+
scrollViewProps = {},
|
|
46
52
|
}) => {
|
|
47
53
|
return (
|
|
48
54
|
<SortableListProvider config={config}>
|
|
@@ -55,8 +61,11 @@ const SortableView = ({
|
|
|
55
61
|
renderItem={renderItem}
|
|
56
62
|
onPress={onPress}
|
|
57
63
|
onLongPress={onLongPress}
|
|
64
|
+
scrollContainerStyle={scrollContainerStyle}
|
|
65
|
+
scrollContentContainerStyle={scrollContentContainerStyle}
|
|
58
66
|
style={itemStyle}
|
|
59
67
|
{...itemProps}
|
|
68
|
+
scrollViewProps={scrollViewProps}
|
|
60
69
|
/>
|
|
61
70
|
</SortableListProvider>
|
|
62
71
|
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|