sard-uniapp
Version:
sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库
50 lines (49 loc) • 1.37 kB
TypeScript
import { type NodeRect } from '../../utils';
import { type UnwrapRef, type InjectionKey, type StyleValue } from 'vue';
export interface DndProps<T> {
rootStyle?: StyleValue;
rootClass?: string;
list?: T[];
}
export interface DndSlots<T> {
default?(props: {
list: DndListItem<T>[];
}): any;
}
export interface DndEmits<T> {
'item-drag-start': [event: {
itemIndex: number;
}];
'item-drag-move': [event: {
itemIndex: number;
insertIndex: number;
}];
'item-drop': [event: {
itemIndex: number;
insertIndex: number;
}];
'update:list': [list: T[]];
}
export interface DndExpose {
}
export interface DndListItem<T> {
data: UnwrapRef<T>;
itemInfo: DndItemInfo;
key: string;
}
export interface DndItemInfo {
offset: number;
dragging: boolean;
}
export interface DndContext<T> {
list: DndListItem<T>[];
dragging: boolean;
currentHeight: number;
dragStart: (itemIndex: number) => void;
dragMove: (itemIndex: number, insertIndex: number) => void;
drop: (itemIndex: number, insertIndex: number) => void;
rectItems: (() => Promise<NodeRect>)[];
addRectItem: (getRect: () => Promise<NodeRect>) => void;
removeRectItem: (getRect: () => Promise<NodeRect>) => void;
}
export declare const dndContextKey: InjectionKey<DndContext<any>>;