Blame view

天文台pc/tianwentai-ui/node_modules/react-dnd/src/internals/registration.ts 695 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  import type {
  	DragDropManager,
  	DragSource,
  	DropTarget,
  	Identifier,
  	SourceType,
  	TargetType,
  	Unsubscribe,
  } from 'dnd-core'
  
  export function registerTarget(
  	type: TargetType,
  	target: DropTarget,
  	manager: DragDropManager,
  ): [Identifier, Unsubscribe] {
  	const registry = manager.getRegistry()
  	const targetId = registry.addTarget(type, target)
  
  	return [targetId, () => registry.removeTarget(targetId)]
  }
  
  export function registerSource(
  	type: SourceType,
  	source: DragSource,
  	manager: DragDropManager,
  ): [Identifier, Unsubscribe] {
  	const registry = manager.getRegistry()
  	const sourceId = registry.addSource(type, source)
  
  	return [sourceId, () => registry.removeSource(sourceId)]
  }