react-virtual-sortable 1.1.2 → 1.1.4

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/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "react-virtual-sortable",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "A virtual scrolling list component that can be sorted by dragging",
5
- "main": "dist/virtual-list.js",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
6
7
  "types": "types/index.d.ts",
7
8
  "files": [
8
9
  "dist",
@@ -38,7 +39,7 @@
38
39
  },
39
40
  "homepage": "https://github.com/mfuu/react-virtual-sortable#readme",
40
41
  "dependencies": {
41
- "sortable-dnd": "^0.7.1"
42
+ "sortable-dnd": "^0.7.2"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@babel/core": "^7.16.7",
package/types/index.d.ts CHANGED
@@ -1,12 +1,31 @@
1
1
  import * as React from 'react';
2
- import { Group, ScrollSpeed, SortableEvent } from 'sortable-dnd';
2
+ import { SortableEvent, Group, ScrollSpeed } from 'sortable-dnd';
3
3
 
4
+ type DIRECTION = 'FRONT' | 'BEHIND' | 'STATIONARY';
4
5
  interface Range {
5
6
  start: number;
6
7
  end: number;
7
8
  front: number;
8
9
  behind: number;
9
10
  }
11
+ interface ScrollEvent {
12
+ top: boolean;
13
+ bottom: boolean;
14
+ offset: number;
15
+ direction: DIRECTION;
16
+ }
17
+ interface DragEvent$1<T> {
18
+ key: T;
19
+ index: number;
20
+ event: SortableEvent;
21
+ }
22
+ interface DropEvent$1<T> {
23
+ key: T;
24
+ event: SortableEvent;
25
+ changed: boolean;
26
+ oldIndex: number;
27
+ newIndex: number;
28
+ }
10
29
 
11
30
  type KeyValueType = string | number;
12
31
  type RenderFunc<T> = (item: T, index: number, key: KeyValueType) => React.ReactElement;
@@ -26,7 +45,7 @@ interface DropEvent<T> {
26
45
  oldIndex: number;
27
46
  newIndex: number;
28
47
  }
29
- interface VirtualProps<T> {
48
+ interface VirtualListProps<T> {
30
49
  dataKey: string;
31
50
  dataSource: T[];
32
51
  children: React.ReactElement | RenderFunc<T>;
@@ -67,11 +86,12 @@ interface VirtualProps<T> {
67
86
  footer?: React.ReactNode;
68
87
  onTop?: () => void;
69
88
  onBottom?: () => void;
89
+ onScroll?: (event: ScrollEvent) => void;
70
90
  onDrag?: (event: DragEvent<T>) => void;
71
91
  onDrop?: (event: DropEvent<T>) => void;
72
92
  onRangeChange?: (range: Range) => void;
73
93
  }
74
- interface VirtualComponentRef {
94
+ interface VirtualListHandle {
75
95
  getSize: (key: KeyValueType) => number;
76
96
  getOffset: () => number;
77
97
  getClientSize: () => number;
@@ -83,13 +103,13 @@ interface VirtualComponentRef {
83
103
  scrollToBottom: () => void;
84
104
  }
85
105
 
86
- declare function VirtualList<T>(props: VirtualProps<T>, ref: React.ForwardedRef<VirtualComponentRef>): React.ReactElement<{
106
+ declare function VirtualList<T>(props: VirtualListProps<T>, ref: React.ForwardedRef<VirtualListHandle>): React.ReactElement<{
87
107
  ref: React.MutableRefObject<HTMLElement | undefined>;
88
108
  style: React.CSSProperties;
89
109
  className: string;
90
110
  }, string | React.JSXElementConstructor<any>>;
91
- declare const _default: <T>(props: VirtualProps<T> & {
92
- ref?: React.ForwardedRef<VirtualComponentRef> | undefined;
111
+ declare const _default: <T>(props: VirtualListProps<T> & {
112
+ ref?: React.ForwardedRef<VirtualListHandle> | undefined;
93
113
  }) => ReturnType<typeof VirtualList>;
94
114
 
95
- export { _default as default };
115
+ export { DragEvent$1 as DragEvent, DropEvent$1 as DropEvent, Range, ScrollEvent, VirtualListHandle, _default as default };