react-virtual-sortable 1.1.1 → 1.1.3

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.1",
3
+ "version": "1.1.3",
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,14 +1,22 @@
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
+ }
10
17
 
11
18
  type KeyValueType = string | number;
19
+ type EventType = 'onTop' | 'onBottom' | 'onScroll' | 'onDrag' | 'onDrop' | 'onRangeChange';
12
20
  type RenderFunc<T> = (item: T, index: number, key: KeyValueType) => React.ReactElement;
13
21
  interface DragEvent<T> {
14
22
  key: KeyValueType;
@@ -26,7 +34,7 @@ interface DropEvent<T> {
26
34
  oldIndex: number;
27
35
  newIndex: number;
28
36
  }
29
- interface VirtualProps<T> {
37
+ interface VirtualListProps<T> {
30
38
  dataKey: string;
31
39
  dataSource: T[];
32
40
  children: React.ReactElement | RenderFunc<T>;
@@ -67,11 +75,12 @@ interface VirtualProps<T> {
67
75
  footer?: React.ReactNode;
68
76
  onTop?: () => void;
69
77
  onBottom?: () => void;
78
+ onScroll?: (event: ScrollEvent) => void;
70
79
  onDrag?: (event: DragEvent<T>) => void;
71
80
  onDrop?: (event: DropEvent<T>) => void;
72
81
  onRangeChange?: (range: Range) => void;
73
82
  }
74
- interface VirtualComponentRef {
83
+ interface VirtualListHandle {
75
84
  getSize: (key: KeyValueType) => number;
76
85
  getOffset: () => number;
77
86
  getClientSize: () => number;
@@ -82,14 +91,21 @@ interface VirtualComponentRef {
82
91
  scrollToOffset: (offset: number) => void;
83
92
  scrollToBottom: () => void;
84
93
  }
94
+ interface ListItemProps {
95
+ dataKey: KeyValueType;
96
+ dragging: KeyValueType;
97
+ horizontal: boolean;
98
+ children: React.ReactElement;
99
+ onSizeChange: (key: KeyValueType, size: number) => void;
100
+ }
85
101
 
86
- declare function VirtualList<T>(props: VirtualProps<T>, ref: React.ForwardedRef<VirtualComponentRef>): React.ReactElement<{
102
+ declare function VirtualList<T>(props: VirtualListProps<T>, ref: React.ForwardedRef<VirtualListHandle>): React.ReactElement<{
87
103
  ref: React.MutableRefObject<HTMLElement | undefined>;
88
104
  style: React.CSSProperties;
89
105
  className: string;
90
106
  }, string | React.JSXElementConstructor<any>>;
91
- declare const _default: <T>(props: VirtualProps<T> & {
92
- ref?: React.ForwardedRef<VirtualComponentRef> | undefined;
107
+ declare const _default: <T>(props: VirtualListProps<T> & {
108
+ ref?: React.ForwardedRef<VirtualListHandle> | undefined;
93
109
  }) => ReturnType<typeof VirtualList>;
94
110
 
95
- export { _default as default };
111
+ export { DragEvent, DropEvent, EventType, KeyValueType, ListItemProps, RenderFunc, VirtualListHandle, VirtualListProps, _default as default };