Skip to content

Commit

Permalink
chore(table): adjust parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
kungege committed Oct 26, 2023
1 parent 321f71c commit feca480
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/table/src/components/DragSortTable/demos/drag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ export default () => {
const [dataSource, setDataSource] = useState(data);

const handleDragSortEnd = (
newDataSource: any,
beforeIndex: number,
afterIndex: number,
newDataSource: any,
) => {
console.log('排序后的数据', newDataSource);
console.log('排序前的index', beforeIndex);
console.log('排序后的index', afterIndex);
setDataSource(newDataSource);
message.success('修改列表排序成功');
};
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/components/DragSortTable/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ nav:
| --- | --- | --- | --- |
| dragSortKey | If this parameter is configured, the drag sorting handle will be displayed in the row corresponding to the key, allowing drag sorting | `string` | - |
| dragSortHandlerRender | The function for rendering custom drag sorting handles. If dragSortKey is configured but this parameter is not configured, the default handle icon is used | `(rowData: T, idx: number) => React.ReactNode` | `<MenuOutlined className= "dragSortDefaultHandle" style={{ cursor: 'grab', color: '#999' }} />` |
| onDragSortEnd | Drag sort completion callback | `(beforeIndex: number, afterIndex: number, newDataSource: T[]) => Promise<void> \| void` | - |
| onDragSortEnd | Drag sort completion callback | `(newDataSource: T[], beforeIndex: number, afterIndex: number) => Promise<void> \| void` | - |
2 changes: 1 addition & 1 deletion packages/table/src/components/DragSortTable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ atomId: DragSortTable
| --- | --- | --- | --- |
| dragSortKey | 如配置此参数,则会在该 key 对应的行显示拖拽排序把手,允许拖拽排序 | `string` | - |
| dragSortHandlerRender | 渲染自定义拖动排序把手的函数 如配置了 dragSortKey 但未配置此参数,则使用默认把手图标 | `(rowData: T, idx: number) => React.ReactNode` | `<MenuOutlined className="dragSortDefaultHandle" style={{ cursor: 'grab', color: '#999' }} />` |
| onDragSortEnd | 拖动排序完成回调 | `(beforeIndex: number, afterIndex: number, newDataSource: T[]) => Promise<void> \| void` | - |
| onDragSortEnd | 拖动排序完成回调 | `(newDataSource: T[], beforeIndex: number, afterIndex: number) => Promise<void> \| void` | - |
2 changes: 1 addition & 1 deletion packages/table/src/components/DragSortTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export type DragTableProps<T, U> = {
dragSortHandlerRender?: (rowData: T, idx: number) => React.ReactNode;
/** @name 拖动排序完成回调 */
onDragSortEnd?: (
newDataSource: T[],
beforeIndex: number,
afterIndex: number,
newDataSource: T[],
) => Promise<void> | void;
} & ProTableProps<T, U>;

Expand Down
4 changes: 2 additions & 2 deletions packages/table/src/utils/useDragSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ const SortableItemCell = React.memo((props: any) => {
export interface UseDragSortOptions<T> {
dataSource?: T[];
onDragSortEnd?: (
newDataSource: T[],
beforeIndex: number,
afterIndex: number,
newDataSource: T[],
) => Promise<void> | void;
dragSortKey?: string;
components?: TableComponents<T>;
Expand All @@ -137,9 +137,9 @@ export function useDragSort<T>(props: UseDragSortOptions<T>) {
parseInt(over.id as string),
);
onDragSortEnd?.(
newData || [],
parseInt(active.id as string),
parseInt(over.id as string),
newData || [],
);
}
},
Expand Down

0 comments on commit feca480

Please sign in to comment.