react-native-reorderable-list 0.6.1 → 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 (116) 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 +1 -3
  7. package/lib/commonjs/components/ReorderableListCell.js.map +1 -1
  8. package/lib/commonjs/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +34 -9
  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} +171 -61
  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/ScrollViewContainerContext.js +10 -0
  21. package/lib/commonjs/contexts/ScrollViewContainerContext.js.map +1 -0
  22. package/lib/commonjs/contexts/index.js +11 -0
  23. package/lib/commonjs/contexts/index.js.map +1 -1
  24. package/lib/commonjs/index.js +12 -0
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/module/components/NestedReorderableList.js +33 -0
  27. package/lib/module/components/NestedReorderableList.js.map +1 -0
  28. package/lib/module/components/ReorderableList.js +21 -0
  29. package/lib/module/components/ReorderableList.js.map +1 -0
  30. package/lib/module/components/ReorderableListCell.js +1 -3
  31. package/lib/module/components/ReorderableListCell.js.map +1 -1
  32. package/lib/module/components/{ReorderableList/ReorderableList.js → ReorderableListCore/ReorderableListCore.js} +37 -12
  33. package/lib/module/components/ReorderableListCore/ReorderableListCore.js.map +1 -0
  34. package/lib/module/components/ReorderableListCore/constants.ios.js.map +1 -0
  35. package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.js.map +1 -1
  36. package/lib/module/components/ReorderableListCore/index.js +2 -0
  37. package/lib/module/components/ReorderableListCore/index.js.map +1 -0
  38. package/lib/module/components/{ReorderableList/useReorderableList.js → ReorderableListCore/useReorderableListCore.js} +170 -60
  39. package/lib/module/components/ReorderableListCore/useReorderableListCore.js.map +1 -0
  40. package/lib/module/components/ScrollViewContainer.js +44 -0
  41. package/lib/module/components/ScrollViewContainer.js.map +1 -0
  42. package/lib/module/components/index.js +2 -0
  43. package/lib/module/components/index.js.map +1 -1
  44. package/lib/module/contexts/ScrollViewContainerContext.js +3 -0
  45. package/lib/module/contexts/ScrollViewContainerContext.js.map +1 -0
  46. package/lib/module/contexts/index.js +1 -0
  47. package/lib/module/contexts/index.js.map +1 -1
  48. package/lib/module/index.js +2 -2
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/typescript/components/NestedReorderableList.d.ts +5 -0
  51. package/lib/typescript/components/NestedReorderableList.d.ts.map +1 -0
  52. package/lib/typescript/components/ReorderableList.d.ts +5 -0
  53. package/lib/typescript/components/ReorderableList.d.ts.map +1 -0
  54. package/lib/typescript/components/ReorderableListCell.d.ts.map +1 -1
  55. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts +20 -0
  56. package/lib/typescript/components/ReorderableListCore/ReorderableListCore.d.ts.map +1 -0
  57. package/lib/typescript/components/ReorderableListCore/constants.d.ts.map +1 -0
  58. package/lib/typescript/components/ReorderableListCore/constants.ios.d.ts.map +1 -0
  59. package/lib/typescript/components/ReorderableListCore/index.d.ts +2 -0
  60. package/lib/typescript/components/ReorderableListCore/index.d.ts.map +1 -0
  61. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts +44 -0
  62. package/lib/typescript/components/ReorderableListCore/useReorderableListCore.d.ts.map +1 -0
  63. package/lib/typescript/components/ScrollViewContainer.d.ts +4 -0
  64. package/lib/typescript/components/ScrollViewContainer.d.ts.map +1 -0
  65. package/lib/typescript/components/index.d.ts +2 -0
  66. package/lib/typescript/components/index.d.ts.map +1 -1
  67. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts +15 -0
  68. package/lib/typescript/contexts/ScrollViewContainerContext.d.ts.map +1 -0
  69. package/lib/typescript/contexts/index.d.ts +1 -0
  70. package/lib/typescript/contexts/index.d.ts.map +1 -1
  71. package/lib/typescript/index.d.ts +3 -3
  72. package/lib/typescript/index.d.ts.map +1 -1
  73. package/lib/typescript/types/props.d.ts +13 -1
  74. package/lib/typescript/types/props.d.ts.map +1 -1
  75. package/package.json +1 -1
  76. package/src/components/NestedReorderableList.tsx +43 -0
  77. package/src/components/ReorderableList.tsx +29 -0
  78. package/src/components/ReorderableListCell.tsx +1 -3
  79. package/src/components/ReorderableListCore/ReorderableListCore.tsx +162 -0
  80. package/src/components/ReorderableListCore/index.ts +1 -0
  81. package/src/components/{ReorderableList/useReorderableList.ts → ReorderableListCore/useReorderableListCore.ts} +252 -75
  82. package/src/components/ScrollViewContainer.tsx +74 -0
  83. package/src/components/index.ts +2 -0
  84. package/src/contexts/ScrollViewContainerContext.ts +18 -0
  85. package/src/contexts/index.ts +1 -0
  86. package/src/index.ts +10 -1
  87. package/src/types/props.ts +21 -1
  88. package/lib/commonjs/components/ReorderableList/ReorderableList.js.map +0 -1
  89. package/lib/commonjs/components/ReorderableList/constants.ios.js.map +0 -1
  90. package/lib/commonjs/components/ReorderableList/constants.js.map +0 -1
  91. package/lib/commonjs/components/ReorderableList/index.js +0 -17
  92. package/lib/commonjs/components/ReorderableList/index.js.map +0 -1
  93. package/lib/commonjs/components/ReorderableList/useReorderableList.js.map +0 -1
  94. package/lib/module/components/ReorderableList/ReorderableList.js.map +0 -1
  95. package/lib/module/components/ReorderableList/constants.ios.js.map +0 -1
  96. package/lib/module/components/ReorderableList/index.js +0 -2
  97. package/lib/module/components/ReorderableList/index.js.map +0 -1
  98. package/lib/module/components/ReorderableList/useReorderableList.js.map +0 -1
  99. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts +0 -8
  100. package/lib/typescript/components/ReorderableList/ReorderableList.d.ts.map +0 -1
  101. package/lib/typescript/components/ReorderableList/constants.d.ts.map +0 -1
  102. package/lib/typescript/components/ReorderableList/constants.ios.d.ts.map +0 -1
  103. package/lib/typescript/components/ReorderableList/index.d.ts +0 -2
  104. package/lib/typescript/components/ReorderableList/index.d.ts.map +0 -1
  105. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts +0 -36
  106. package/lib/typescript/components/ReorderableList/useReorderableList.d.ts.map +0 -1
  107. package/src/components/ReorderableList/ReorderableList.tsx +0 -109
  108. package/src/components/ReorderableList/index.ts +0 -1
  109. /package/lib/commonjs/components/{ReorderableList → ReorderableListCore}/constants.ios.js +0 -0
  110. /package/lib/commonjs/components/{ReorderableList → ReorderableListCore}/constants.js +0 -0
  111. /package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.ios.js +0 -0
  112. /package/lib/module/components/{ReorderableList → ReorderableListCore}/constants.js +0 -0
  113. /package/lib/typescript/components/{ReorderableList → ReorderableListCore}/constants.d.ts +0 -0
  114. /package/lib/typescript/components/{ReorderableList → ReorderableListCore}/constants.ios.d.ts +0 -0
  115. /package/src/components/{ReorderableList → ReorderableListCore}/constants.ios.ts +0 -0
  116. /package/src/components/{ReorderableList → ReorderableListCore}/constants.ts +0 -0
@@ -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":[]}
@@ -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,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReorderableListCell.d.ts","sourceRoot":"","sources":["../../../src/components/ReorderableListCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmC,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAEvE,OAAiB,EAEf,WAAW,EAMZ,MAAM,yBAAyB,CAAC;AAKjC,UAAU,wBAAwB,CAAC,CAAC,CAClC,SAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IAC7C,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAElC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,mBAAmB,+LA2G/B,CAAC"}
1
+ {"version":3,"file":"ReorderableListCell.d.ts","sourceRoot":"","sources":["../../../src/components/ReorderableListCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmC,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAEvE,OAAiB,EAEf,WAAW,EAMZ,MAAM,yBAAyB,CAAC;AAKjC,UAAU,wBAAwB,CAAC,CAAC,CAClC,SAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IAC7C,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAElC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,mBAAmB,+LAyG/B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { FlatList, ScrollView } from 'react-native';
3
+ import { NativeGesture } from 'react-native-gesture-handler';
4
+ import { SharedValue } from 'react-native-reanimated';
5
+ import type { ReorderableListProps } from '../../types';
6
+ interface ReorderableListCoreProps<T> extends ReorderableListProps<T> {
7
+ scrollViewContainerRef: React.RefObject<ScrollView> | undefined;
8
+ scrollViewHeightY: SharedValue<number> | undefined;
9
+ scrollViewScrollOffsetY: SharedValue<number> | undefined;
10
+ scrollViewScrollEnabled: SharedValue<boolean> | undefined;
11
+ outerScrollGesture: NativeGesture | undefined;
12
+ initialScrollViewScrollEnabled: boolean | undefined;
13
+ scrollable: boolean | undefined;
14
+ scrollEnabled: boolean | undefined;
15
+ }
16
+ declare const MemoizedReorderableListCore: <T>(props: ReorderableListCoreProps<T> & {
17
+ ref?: React.ForwardedRef<FlatList<T> | null> | undefined;
18
+ }) => React.ReactElement;
19
+ export { MemoizedReorderableListCore as ReorderableListCore };
20
+ //# sourceMappingURL=ReorderableListCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReorderableListCore.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/ReorderableListCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,QAAQ,EAGR,UAAU,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGL,aAAa,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAiB,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAK9D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAStD,UAAU,wBAAwB,CAAC,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,CAAC;IAEnE,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAChE,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,kBAAkB,EAAE,aAAa,GAAG,SAAS,CAAC;IAC9C,8BAA8B,EAAE,OAAO,GAAG,SAAS,CAAC;IACpD,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAmHD,QAAA,MAAM,2BAA2B;;MAM5B,MAAM,YAAY,CAAC;AAExB,OAAO,EAAC,2BAA2B,IAAI,mBAAmB,EAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,gBAAgB,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.ios.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/constants.ios.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,gBAAgB,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ReorderableListCore';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { FlatList, LayoutChangeEvent, NativeScrollEvent, ScrollView } from 'react-native';
3
+ import { SharedValue } from 'react-native-reanimated';
4
+ import { ReorderableListDragEndEvent } from '../../types';
5
+ import type { ReorderableListReorderEvent } from '../../types';
6
+ interface UseReorderableListCoreArgs<T> {
7
+ ref: React.ForwardedRef<FlatList<T>>;
8
+ autoscrollThreshold: number;
9
+ autoscrollSpeedScale: number;
10
+ autoscrollDelay: number;
11
+ animationDuration: number;
12
+ dragReorderThreshold: number;
13
+ onReorder: (event: ReorderableListReorderEvent) => void;
14
+ onDragEnd?: (event: ReorderableListDragEndEvent) => void;
15
+ onScroll?: (event: NativeScrollEvent) => void;
16
+ onLayout?: (event: LayoutChangeEvent) => void;
17
+ scrollViewContainerRef: React.RefObject<ScrollView> | undefined;
18
+ scrollViewHeightY: SharedValue<number> | undefined;
19
+ scrollViewScrollOffsetY: SharedValue<number> | undefined;
20
+ scrollViewScrollEnabled: SharedValue<boolean> | undefined;
21
+ initialScrollEnabled: boolean | undefined;
22
+ initialScrollViewScrollEnabled: boolean | undefined;
23
+ nestedScrollable: boolean | undefined;
24
+ }
25
+ export declare const useReorderableListCore: <T>({ ref, autoscrollThreshold, autoscrollSpeedScale, autoscrollDelay, animationDuration, dragReorderThreshold, onReorder, onDragEnd, onScroll, onLayout, scrollViewContainerRef, scrollViewHeightY, scrollViewScrollOffsetY, scrollViewScrollEnabled, initialScrollEnabled, initialScrollViewScrollEnabled, nestedScrollable, }: UseReorderableListCoreArgs<T>) => {
26
+ gestureHandler: import("react-native-gesture-handler/lib/typescript/handlers/gestures/gestureComposition").SimultaneousGesture;
27
+ handleScroll: import("react-native-reanimated").ScrollHandlerProcessed<Record<string, unknown>>;
28
+ handleFlatListLayout: (e: LayoutChangeEvent) => void;
29
+ handleRef: (value: FlatList<T>) => void;
30
+ startDrag: (index: number) => void;
31
+ listContextValue: {
32
+ draggedHeight: SharedValue<number>;
33
+ currentIndex: SharedValue<number>;
34
+ draggedIndex: SharedValue<number>;
35
+ dragEndHandlers: SharedValue<((from: number, to: number) => void)[][]>;
36
+ };
37
+ itemOffset: SharedValue<number[]>;
38
+ itemHeight: SharedValue<number[]>;
39
+ draggedIndex: SharedValue<number>;
40
+ dragY: SharedValue<number>;
41
+ duration: SharedValue<number>;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=useReorderableListCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReorderableListCore.d.ts","sourceRoot":"","sources":["../../../../src/components/ReorderableListCore/useReorderableListCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAEX,MAAM,cAAc,CAAC;AAGtB,OAAiB,EAGf,WAAW,EAWZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAC,2BAA2B,EAAuB,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAO7D,UAAU,0BAA0B,CAAC,CAAC;IACpC,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;IACxD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAChE,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,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1C,8BAA8B,EAAE,OAAO,GAAG,SAAS,CAAC;IACpD,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,sBAAsB;;;;;uBAkiBvB,MAAM;;;;;6CAtfN,MAAM,MAAM,MAAM,KAAK,IAAI;;;;;;;CA8jBtC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ScrollViewContainerProps } from '../types';
3
+ export declare const ScrollViewContainer: React.FC<ScrollViewContainerProps>;
4
+ //# sourceMappingURL=ScrollViewContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollViewContainer.d.ts","sourceRoot":"","sources":["../../../src/components/ScrollViewContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgB,MAAM,OAAO,CAAC;AAWrC,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4DlE,CAAC"}
@@ -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.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ScrollView } from 'react-native';
3
+ import { NativeGesture } from 'react-native-gesture-handler';
4
+ import { SharedValue } from 'react-native-reanimated';
5
+ interface ScrollViewContainerContextData {
6
+ scrollViewContainerRef: React.RefObject<ScrollView>;
7
+ scrollViewHeightY: SharedValue<number>;
8
+ scrollViewScrollOffsetY: SharedValue<number>;
9
+ scrollViewScrollEnabled: SharedValue<boolean>;
10
+ outerScrollGesture: NativeGesture;
11
+ initialScrollViewScrollEnabled: boolean;
12
+ }
13
+ export declare const ScrollViewContainerContext: React.Context<ScrollViewContainerContextData | undefined>;
14
+ export {};
15
+ //# sourceMappingURL=ScrollViewContainerContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollViewContainerContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/ScrollViewContainerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEpD,UAAU,8BAA8B;IACtC,sBAAsB,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpD,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9C,kBAAkB,EAAE,aAAa,CAAC;IAClC,8BAA8B,EAAE,OAAO,CAAC;CACzC;AAED,eAAO,MAAM,0BAA0B,2DAE3B,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './ReorderableCellContext';
2
2
  export * from './ReorderableListContext';
3
+ export * from './ScrollViewContainerContext';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
@@ -1,7 +1,7 @@
1
- import { ReorderableList, ReorderableListItem } from './components';
1
+ import { NestedReorderableList, ReorderableList, ReorderableListItem, ScrollViewContainer } from './components';
2
2
  import { useReorderableDrag, useReorderableDragEnd, useReorderableDragStart } from './hooks';
3
- import type { ReorderableListDragEndEvent, ReorderableListItemConfig, ReorderableListItemProps, ReorderableListProps, ReorderableListReorderEvent } from './types';
3
+ import type { ReorderableListDragEndEvent, ReorderableListItemConfig, ReorderableListItemProps, ReorderableListProps, ReorderableListReorderEvent, ScrollViewContainerProps } from './types';
4
4
  import { reorderItems } from './utils';
5
- export { useReorderableDrag, useReorderableDragStart, useReorderableDragEnd, ReorderableListProps, ReorderableListReorderEvent, ReorderableListDragEndEvent, ReorderableListItem, ReorderableListItemConfig, ReorderableListItemProps, reorderItems, };
5
+ export { useReorderableDrag, useReorderableDragStart, useReorderableDragEnd, ReorderableListProps, ReorderableListReorderEvent, ReorderableListDragEndEvent, ReorderableListItem, ReorderableListItemConfig, ReorderableListItemProps, ScrollViewContainer, ScrollViewContainerProps, NestedReorderableList, reorderItems, };
6
6
  export default ReorderableList;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,GACb,CAAC;AACF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,GACb,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { FlatListProps, NativeScrollEvent, ViewProps } from 'react-native';
1
+ import type { FlatListProps, NativeScrollEvent, ScrollViewProps, ViewProps } from 'react-native';
2
2
  import { EasingFunction } from 'react-native-reanimated';
3
3
  export interface ReorderableListReorderEvent {
4
4
  /**
@@ -100,5 +100,17 @@ export interface ReorderableListItemProps extends ViewProps {
100
100
  */
101
101
  scaleAnimationConfig?: ReorderableListItemConfig;
102
102
  }
103
+ export interface ScrollViewContainerProps extends Omit<ScrollViewProps, 'onScroll'> {
104
+ /**
105
+ * 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.
106
+ */
107
+ onScroll?: (event: NativeScrollEvent) => void;
108
+ }
109
+ export interface NestedReorderableListProps<T> extends ReorderableListProps<T> {
110
+ /**
111
+ * Whether the nested list is scrollable or not. If the nested list has a fixed height and it's scrollable it should be set to `true`, otherwise `false`. Default: `false`.
112
+ */
113
+ scrollable?: boolean;
114
+ }
103
115
  export {};
104
116
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@
1
1
  {
2
2
  "name": "react-native-reorderable-list",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Reorderable list for React Native applications, powered by Reanimated",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -0,0 +1,43 @@
1
+ import React, {forwardRef} from 'react';
2
+ import {FlatList} from 'react-native';
3
+
4
+ import {ReorderableListCore} from './ReorderableListCore';
5
+ import {ScrollViewContainerContext} from '../contexts';
6
+ import {useContext} from '../hooks';
7
+ import type {NestedReorderableListProps} from '../types';
8
+
9
+ const NestedReorderableListWithRef = <T,>(
10
+ {scrollable, scrollEnabled = true, ...rest}: NestedReorderableListProps<T>,
11
+ ref?: React.ForwardedRef<FlatList<T>>,
12
+ ) => {
13
+ const {
14
+ scrollViewContainerRef,
15
+ scrollViewScrollOffsetY,
16
+ scrollViewHeightY,
17
+ scrollViewScrollEnabled,
18
+ outerScrollGesture,
19
+ initialScrollViewScrollEnabled,
20
+ } = useContext(ScrollViewContainerContext);
21
+
22
+ return (
23
+ <ReorderableListCore
24
+ {...rest}
25
+ ref={ref}
26
+ scrollViewContainerRef={scrollViewContainerRef}
27
+ scrollViewScrollOffsetY={scrollViewScrollOffsetY}
28
+ scrollViewHeightY={scrollViewHeightY}
29
+ outerScrollGesture={outerScrollGesture}
30
+ scrollViewScrollEnabled={scrollViewScrollEnabled}
31
+ initialScrollViewScrollEnabled={initialScrollViewScrollEnabled}
32
+ scrollable={scrollable}
33
+ scrollEnabled={scrollEnabled}
34
+ nestedScrollEnabled
35
+ />
36
+ );
37
+ };
38
+
39
+ export const NestedReorderableList = forwardRef(
40
+ NestedReorderableListWithRef,
41
+ ) as <T>(
42
+ props: NestedReorderableListProps<T> & React.RefAttributes<FlatList<T>>,
43
+ ) => JSX.Element;
@@ -0,0 +1,29 @@
1
+ import React, {forwardRef} from 'react';
2
+ import {FlatList} from 'react-native';
3
+
4
+ import {ReorderableListCore} from './ReorderableListCore';
5
+ import type {ReorderableListProps} from '../types';
6
+
7
+ const ReorderableListWithRef = <T,>(
8
+ {scrollEnabled = true, ...rest}: ReorderableListProps<T>,
9
+ ref: React.Ref<FlatList<T>>,
10
+ ) => {
11
+ return (
12
+ <ReorderableListCore
13
+ {...rest}
14
+ ref={ref}
15
+ scrollEnabled={scrollEnabled}
16
+ initialScrollViewScrollEnabled={true}
17
+ scrollable={true}
18
+ scrollViewContainerRef={undefined}
19
+ scrollViewScrollOffsetY={undefined}
20
+ scrollViewHeightY={undefined}
21
+ outerScrollGesture={undefined}
22
+ scrollViewScrollEnabled={undefined}
23
+ />
24
+ );
25
+ };
26
+
27
+ export const ReorderableList = forwardRef(ReorderableListWithRef) as <T>(
28
+ props: ReorderableListProps<T> & React.RefAttributes<FlatList<T>>,
29
+ ) => JSX.Element;
@@ -119,9 +119,7 @@ export const ReorderableListCell = memo(
119
119
  itemHeight.value[index] = height;
120
120
  })(e.nativeEvent.layout.y, e.nativeEvent.layout.height);
121
121
 
122
- if (onLayout) {
123
- onLayout(e);
124
- }
122
+ onLayout?.(e);
125
123
  };
126
124
 
127
125
  return (
@@ -0,0 +1,162 @@
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, {SharedValue} from 'react-native-reanimated';
16
+
17
+ import {AUTOSCROLL_DELAY} from './constants';
18
+ import {useReorderableListCore} from './useReorderableListCore';
19
+ import {ReorderableListContext} from '../../contexts';
20
+ import type {ReorderableListProps} from '../../types';
21
+ import {ReorderableListCell} from '../ReorderableListCell';
22
+
23
+ const AnimatedFlatList = Animated.createAnimatedComponent(
24
+ FlatList,
25
+ ) as unknown as <T>(
26
+ props: FlatListProps<T> & {ref?: React.Ref<FlatList<T>>},
27
+ ) => React.ReactElement;
28
+
29
+ interface ReorderableListCoreProps<T> extends ReorderableListProps<T> {
30
+ // not optional but undefined to avoid forgetting to pass a prop
31
+ scrollViewContainerRef: React.RefObject<ScrollView> | undefined;
32
+ scrollViewHeightY: SharedValue<number> | undefined;
33
+ scrollViewScrollOffsetY: SharedValue<number> | undefined;
34
+ scrollViewScrollEnabled: SharedValue<boolean> | undefined;
35
+ outerScrollGesture: NativeGesture | undefined;
36
+ initialScrollViewScrollEnabled: boolean | undefined;
37
+ scrollable: boolean | undefined;
38
+ scrollEnabled: boolean | undefined;
39
+ }
40
+
41
+ const ReorderableListCore = <T,>(
42
+ {
43
+ data,
44
+ autoscrollThreshold = 0.1,
45
+ autoscrollSpeedScale = 1,
46
+ autoscrollDelay = AUTOSCROLL_DELAY,
47
+ animationDuration = 200,
48
+ dragReorderThreshold = 0.2,
49
+ onLayout,
50
+ onReorder,
51
+ onScroll,
52
+ onDragEnd,
53
+ keyExtractor,
54
+ extraData,
55
+ scrollViewContainerRef,
56
+ scrollViewHeightY,
57
+ scrollViewScrollOffsetY,
58
+ scrollViewScrollEnabled,
59
+ scrollEnabled,
60
+ initialScrollViewScrollEnabled,
61
+ scrollable,
62
+ outerScrollGesture,
63
+ ...rest
64
+ }: ReorderableListCoreProps<T>,
65
+ ref: React.ForwardedRef<FlatList<T>>,
66
+ ) => {
67
+ const {
68
+ gestureHandler,
69
+ handleScroll,
70
+ handleFlatListLayout,
71
+ handleRef,
72
+ startDrag,
73
+ listContextValue,
74
+ itemOffset,
75
+ itemHeight,
76
+ dragY,
77
+ draggedIndex,
78
+ duration,
79
+ } = useReorderableListCore({
80
+ ref,
81
+ autoscrollThreshold,
82
+ autoscrollSpeedScale,
83
+ autoscrollDelay,
84
+ animationDuration,
85
+ dragReorderThreshold,
86
+ onLayout,
87
+ onReorder,
88
+ onScroll,
89
+ onDragEnd,
90
+ scrollViewContainerRef,
91
+ scrollViewHeightY,
92
+ scrollViewScrollOffsetY,
93
+ scrollViewScrollEnabled,
94
+ // flatlist will default to true if we pass explicitly undefined,
95
+ // but internally we would treat it as false, so we force true
96
+ initialScrollEnabled:
97
+ typeof scrollEnabled === 'undefined' ? true : scrollEnabled,
98
+ initialScrollViewScrollEnabled:
99
+ typeof initialScrollViewScrollEnabled === 'undefined'
100
+ ? true
101
+ : initialScrollViewScrollEnabled,
102
+ nestedScrollable: scrollable,
103
+ });
104
+
105
+ const combinedGesture = useMemo(() => {
106
+ // android is able to handle nested scroll view, but not the full height ones like iOS
107
+ if (outerScrollGesture && !(Platform.OS === 'android' && scrollable)) {
108
+ return Gesture.Simultaneous(outerScrollGesture, gestureHandler);
109
+ }
110
+
111
+ return gestureHandler;
112
+ }, [scrollable, outerScrollGesture, gestureHandler]);
113
+
114
+ const renderAnimatedCell = useCallback(
115
+ ({cellKey, ...props}: CellRendererProps<T>) => (
116
+ <ReorderableListCell
117
+ {...props}
118
+ // forces remount with key change on reorder
119
+ key={`${cellKey}+${props.index}`}
120
+ itemOffset={itemOffset}
121
+ itemHeight={itemHeight}
122
+ dragY={dragY}
123
+ draggedIndex={draggedIndex}
124
+ animationDuration={duration}
125
+ startDrag={startDrag}
126
+ />
127
+ ),
128
+ [itemOffset, itemHeight, dragY, draggedIndex, duration, startDrag],
129
+ );
130
+
131
+ return (
132
+ <ReorderableListContext.Provider value={listContextValue}>
133
+ <GestureDetector gesture={combinedGesture}>
134
+ <AnimatedFlatList
135
+ {...rest}
136
+ ref={handleRef}
137
+ data={data}
138
+ CellRendererComponent={renderAnimatedCell}
139
+ onLayout={handleFlatListLayout}
140
+ onScroll={handleScroll}
141
+ scrollEventThrottle={1}
142
+ horizontal={false}
143
+ removeClippedSubviews={false}
144
+ keyExtractor={keyExtractor}
145
+ extraData={extraData}
146
+ numColumns={1}
147
+ scrollEnabled={scrollEnabled}
148
+ />
149
+ </GestureDetector>
150
+ </ReorderableListContext.Provider>
151
+ );
152
+ };
153
+
154
+ const MemoizedReorderableListCore = React.memo(
155
+ React.forwardRef(ReorderableListCore),
156
+ ) as <T>(
157
+ props: ReorderableListCoreProps<T> & {
158
+ ref?: React.ForwardedRef<FlatList<T> | null>;
159
+ },
160
+ ) => React.ReactElement;
161
+
162
+ export {MemoizedReorderableListCore as ReorderableListCore};
@@ -0,0 +1 @@
1
+ export * from './ReorderableListCore';