feat(tree): exports TreeDragInfo & TreeDropInfo type

This commit is contained in:
07akioni 2021-07-06 16:17:39 +08:00
parent 6841e05087
commit b1075e01ae
5 changed files with 39 additions and 17 deletions

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-tree` exports `TreeDragInfo` & `TreeDropInfo` type.
## 2.15.3 (2021-07-05)
### Feats

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-tree` 导出 `TreeDragInfo` & `TreeDropInfo` 类型
## 2.15.3 (2021-07-05)
### Feats

View File

@ -1,3 +1,3 @@
export { default as NTree } from './src/Tree'
export type { TreeProps } from './src/Tree'
export type { TreeOption } from './src/interface'
export type { TreeOption, TreeDragInfo, TreeDropInfo } from './src/interface'

View File

@ -28,8 +28,8 @@ import NTreeNode from './TreeNode'
import { keysWithFilter, emptyImage, defaultFilter } from './utils'
import { useKeyboard } from './keyboard'
import {
DragInfo,
DropInfo,
TreeDragInfo,
TreeDropInfo,
TreeOptions,
Key,
TreeOption,
@ -132,12 +132,22 @@ const treeProps = {
default: true
},
virtualScroll: Boolean,
onDragenter: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDragleave: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDragend: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDragstart: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDragover: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDrop: [Function, Array] as PropType<MaybeArray<(e: DragInfo) => void>>,
onDragenter: [Function, Array] as PropType<
MaybeArray<(e: TreeDragInfo) => void>
>,
onDragleave: [Function, Array] as PropType<
MaybeArray<(e: TreeDragInfo) => void>
>,
onDragend: [Function, Array] as PropType<
MaybeArray<(e: TreeDragInfo) => void>
>,
onDragstart: [Function, Array] as PropType<
MaybeArray<(e: TreeDragInfo) => void>
>,
onDragover: [Function, Array] as PropType<
MaybeArray<(e: TreeDragInfo) => void>
>,
onDrop: [Function, Array] as PropType<MaybeArray<(e: TreeDragInfo) => void>>,
onUpdateCheckedKeys: [Function, Array] as PropType<
MaybeArray<(value: Key[]) => void>
>,
@ -449,27 +459,27 @@ export default defineComponent({
if (_onUpdateSelectedKeys) call(_onUpdateSelectedKeys, value)
}
// Drag & Drop
function doDragEnter (info: DragInfo): void {
function doDragEnter (info: TreeDragInfo): void {
const { onDragenter } = props
if (onDragenter) call(onDragenter, info)
}
function doDragLeave (info: DragInfo): void {
function doDragLeave (info: TreeDragInfo): void {
const { onDragleave } = props
if (onDragleave) call(onDragleave, info)
}
function doDragEnd (info: DragInfo): void {
function doDragEnd (info: TreeDragInfo): void {
const { onDragend } = props
if (onDragend) call(onDragend, info)
}
function doDragStart (info: DragInfo): void {
function doDragStart (info: TreeDragInfo): void {
const { onDragstart } = props
if (onDragstart) call(onDragstart, info)
}
function doDragOver (info: DragInfo): void {
function doDragOver (info: TreeDragInfo): void {
const { onDragover } = props
if (onDragover) call(onDragover, info)
}
function doDrop (info: DropInfo): void {
function doDrop (info: TreeDropInfo): void {
const { onDrop } = props
if (onDrop) call(onDrop, info)
}

View File

@ -20,12 +20,12 @@ export type TreeOption = TreeOptionBase & { [k: string]: unknown }
export type TreeOptions = TreeOption[]
export interface DragInfo {
export interface TreeDragInfo {
event: DragEvent
node: TreeOption
}
export interface DropInfo {
export interface TreeDropInfo {
event: DragEvent
node: TreeOption
dragNode: TreeOption