@vue-dnd-kit/core 0.5.4 → 0.5.6
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/LICENSE +21 -21
- package/README.md +252 -274
- package/dist/index.d.ts +2535 -9
- package/dist/vue-dnd-kit-core.cjs.js +2 -1
- package/dist/vue-dnd-kit-core.cjs.js.map +1 -0
- package/dist/vue-dnd-kit-core.es.js +317 -471
- package/dist/vue-dnd-kit-core.es.js.map +1 -0
- package/package.json +73 -73
- package/dist/composables/useDnDStore.d.ts +0 -2347
- package/dist/composables/useDragContainer.d.ts +0 -606
- package/dist/composables/useDraggable.d.ts +0 -17
- package/dist/composables/useDroppable.d.ts +0 -91
- package/dist/composables/useKeyboard.d.ts +0 -10
- package/dist/composables/usePointer.d.ts +0 -7
- package/dist/composables/useSelection.d.ts +0 -9
- package/dist/composables/useSensor.d.ts +0 -8
- package/dist/managers/useElementManager.d.ts +0 -10
- package/dist/managers/useEventManager.d.ts +0 -6
- package/dist/managers/useZoneManager.d.ts +0 -9
- package/dist/plugin.d.ts +0 -13
- package/dist/types/index.d.ts +0 -143
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/events.d.ts +0 -1
- package/dist/utils/geometry.d.ts +0 -17
- package/dist/utils/namespaces.d.ts +0 -2
- package/dist/utils/operations.d.ts +0 -14
- package/dist/utils/sensor.d.ts +0 -3
- package/dist/vue-shims.d.ts +0 -5
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { IUseDropOptions } from "../types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hook for creating drop zones that can accept dragged elements.
|
|
5
|
-
* Manages drop zone registration and interaction states.
|
|
6
|
-
*
|
|
7
|
-
* @param options - Configuration options for drop zone
|
|
8
|
-
* @param options.groups - Groups that this zone accepts. Elements can only be
|
|
9
|
-
* dropped if they share at least one group with the zone
|
|
10
|
-
* @param options.events - Event handlers for drop zone lifecycle
|
|
11
|
-
* @param options.events.onDrop - Called when compatible element is dropped
|
|
12
|
-
* @param options.events.onHover - Called when compatible element hovers
|
|
13
|
-
* @param options.events.onLeave - Called when element leaves zone
|
|
14
|
-
* @param options.data - Custom data accessible in event handlers
|
|
15
|
-
*
|
|
16
|
-
* @returns Object containing:
|
|
17
|
-
* - elementRef: Reference to be bound to drop zone element
|
|
18
|
-
* - isOvered: Whether zone is currently being hovered by dragged element
|
|
19
|
-
* - isAllowed: Whether currently dragged element can be dropped (groups match)
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```vue
|
|
23
|
-
* <template>
|
|
24
|
-
* <div
|
|
25
|
-
* ref="elementRef"
|
|
26
|
-
* :class="{
|
|
27
|
-
* 'drop-zone': true,
|
|
28
|
-
* 'zone-hovered': isOvered,
|
|
29
|
-
* 'drop-allowed': isAllowed && isOvered,
|
|
30
|
-
* 'drop-forbidden': !isAllowed && isOvered
|
|
31
|
-
* }"
|
|
32
|
-
* >
|
|
33
|
-
* <slot />
|
|
34
|
-
* </div>
|
|
35
|
-
* </template>
|
|
36
|
-
*
|
|
37
|
-
* <script setup lang="ts">
|
|
38
|
-
* const { elementRef, isOvered, isAllowed } = useDrop({
|
|
39
|
-
* // Зона принимает только элементы из группы 'items'
|
|
40
|
-
* groups: ['items'],
|
|
41
|
-
* events: {
|
|
42
|
-
* onDrop: (store) => {
|
|
43
|
-
* const droppedElements = store.draggingElements.value;
|
|
44
|
-
* console.log('Elements dropped!', droppedElements);
|
|
45
|
-
* },
|
|
46
|
-
* onHover: (store) => {
|
|
47
|
-
* // Подсветка зоны при наведении совместимого элемента
|
|
48
|
-
* if (isAllowed.value) {
|
|
49
|
-
* console.log('Compatible element hovering!');
|
|
50
|
-
* }
|
|
51
|
-
* },
|
|
52
|
-
* onLeave: () => {
|
|
53
|
-
* console.log('Element left drop zone');
|
|
54
|
-
* }
|
|
55
|
-
* },
|
|
56
|
-
* // Пользовательские данные доступны в обработчиках
|
|
57
|
-
* data: {
|
|
58
|
-
* zoneId: 'main-drop-zone',
|
|
59
|
-
* acceptLimit: 5
|
|
60
|
-
* }
|
|
61
|
-
* });
|
|
62
|
-
* </script>
|
|
63
|
-
*
|
|
64
|
-
* <style scoped>
|
|
65
|
-
* .drop-zone {
|
|
66
|
-
* border: 2px dashed #ccc;
|
|
67
|
-
* padding: 20px;
|
|
68
|
-
* transition: all 0.3s;
|
|
69
|
-
* }
|
|
70
|
-
*
|
|
71
|
-
* .zone-hovered {
|
|
72
|
-
* background: #f0f0f0;
|
|
73
|
-
* }
|
|
74
|
-
*
|
|
75
|
-
* .drop-allowed {
|
|
76
|
-
* border-color: #4CAF50;
|
|
77
|
-
* background: #E8F5E9;
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* .drop-forbidden {
|
|
81
|
-
* border-color: #F44336;
|
|
82
|
-
* background: #FFEBEE;
|
|
83
|
-
* }
|
|
84
|
-
* </style>
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
export declare const useDroppable: (options?: IUseDropOptions) => {
|
|
88
|
-
elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
89
|
-
isOvered: import('vue').ComputedRef<boolean>;
|
|
90
|
-
isAllowed: import('vue').ComputedRef<boolean>;
|
|
91
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
export interface IKeyboardOptions {
|
|
4
|
-
moveStep?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare const useKeyboard: (elementRef: Ref<HTMLElement | null>, options?: IKeyboardOptions) => {
|
|
7
|
-
onKeyboardStart: (event: KeyboardEvent) => void;
|
|
8
|
-
onKeyboardMove: () => void;
|
|
9
|
-
onKeyboardEnd: () => void;
|
|
10
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
export declare const useSelection: (elementRef: Ref<HTMLElement | null>) => {
|
|
4
|
-
handleUnselect: () => void;
|
|
5
|
-
handleSelect: () => void;
|
|
6
|
-
handleToggleSelect: () => void;
|
|
7
|
-
isSelected: import('vue').ComputedRef<boolean>;
|
|
8
|
-
isParentOfSelected: import('vue').ComputedRef<boolean>;
|
|
9
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IUseDragOptions } from "../types";
|
|
2
|
-
import { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
export declare const useSensor: (elementRef: Ref<HTMLElement | null>, options?: IUseDragOptions) => {
|
|
5
|
-
activate: (event: PointerEvent | KeyboardEvent) => void;
|
|
6
|
-
track: (event: PointerEvent | WheelEvent | KeyboardEvent) => void;
|
|
7
|
-
deactivate: (triggerEvents?: boolean) => void;
|
|
8
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IUseDragOptions } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare const useElementManager: (options?: IUseDragOptions) => {
|
|
4
|
-
elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
5
|
-
registerElement: () => void;
|
|
6
|
-
unregisterElement: () => void;
|
|
7
|
-
isDragging: import('vue').ComputedRef<boolean>;
|
|
8
|
-
isOvered: import('vue').ComputedRef<boolean>;
|
|
9
|
-
isAllowed: import('vue').ComputedRef<boolean>;
|
|
10
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IUseDropOptions } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare const useZoneManager: (options?: IUseDropOptions) => {
|
|
4
|
-
elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
5
|
-
registerZone: () => void;
|
|
6
|
-
unregisterZone: () => void;
|
|
7
|
-
isOvered: import('vue').ComputedRef<boolean>;
|
|
8
|
-
isAllowed: import('vue').ComputedRef<boolean>;
|
|
9
|
-
};
|
package/dist/plugin.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { Component, ComputedRef, Ref, ShallowRef } from 'vue';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface IDnDStore {
|
|
5
|
-
isDragging: Ref<boolean>;
|
|
6
|
-
activeContainer: IActiveContainer;
|
|
7
|
-
elements: Ref<IDragElement[]>;
|
|
8
|
-
selectedElements: Ref<IDragElement[]>;
|
|
9
|
-
draggingElements: Ref<IDraggingElement[]>;
|
|
10
|
-
zones: Ref<IDropZone[]>;
|
|
11
|
-
hovered: {
|
|
12
|
-
zone: Ref<IDropZone | null>;
|
|
13
|
-
element: Ref<IDragElement | null>;
|
|
14
|
-
};
|
|
15
|
-
pointerPosition: IPointerPosition;
|
|
16
|
-
keyboard: {
|
|
17
|
-
w: Ref<boolean>;
|
|
18
|
-
s: Ref<boolean>;
|
|
19
|
-
a: Ref<boolean>;
|
|
20
|
-
d: Ref<boolean>;
|
|
21
|
-
ctrl: Ref<boolean>;
|
|
22
|
-
shift: Ref<boolean>;
|
|
23
|
-
alt: Ref<boolean>;
|
|
24
|
-
meta: Ref<boolean>;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface IActiveContainer {
|
|
29
|
-
component: Ref<Component | null>;
|
|
30
|
-
ref: Ref<HTMLElement | null>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface IPointerPosition {
|
|
34
|
-
start: Ref<IPoint | null>;
|
|
35
|
-
current: Ref<IPoint | null>;
|
|
36
|
-
offset: {
|
|
37
|
-
percent: Ref<IPoint | null>;
|
|
38
|
-
pixel: Ref<IPoint | null>;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface IDragElement {
|
|
43
|
-
node: HTMLElement | Element | null;
|
|
44
|
-
groups: string[];
|
|
45
|
-
layer: Component | null;
|
|
46
|
-
defaultLayer: Component | null;
|
|
47
|
-
data: {
|
|
48
|
-
source?: any[];
|
|
49
|
-
index?: number;
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
} | null;
|
|
52
|
-
events: {
|
|
53
|
-
onHover?: (store: IDnDStore) => void;
|
|
54
|
-
onLeave?: (store: IDnDStore) => void;
|
|
55
|
-
onEnd?: (store: IDnDStore) => void;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const test: IDragElement['data'];
|
|
60
|
-
|
|
61
|
-
export interface IDraggingElement extends IDragElement {
|
|
62
|
-
initialHTML: string;
|
|
63
|
-
initialRect?: DOMRect;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface IDropZone {
|
|
67
|
-
node: HTMLElement | Element | null;
|
|
68
|
-
groups: string[];
|
|
69
|
-
data?: {
|
|
70
|
-
source?: any[];
|
|
71
|
-
[key: string]: any;
|
|
72
|
-
};
|
|
73
|
-
events: {
|
|
74
|
-
onHover?: (store: IDnDStore) => void;
|
|
75
|
-
onLeave?: (store: IDnDStore) => void;
|
|
76
|
-
onDrop?: (store: IDnDStore) => void;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface IPoint {
|
|
81
|
-
x: number;
|
|
82
|
-
y: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface IUseDropOptions {
|
|
86
|
-
groups?: string[];
|
|
87
|
-
events?: {
|
|
88
|
-
onDrop?: (store: IDnDStore) => void;
|
|
89
|
-
onHover?: (store: IDnDStore) => void;
|
|
90
|
-
onLeave?: (store: IDnDStore) => void;
|
|
91
|
-
};
|
|
92
|
-
data?: {
|
|
93
|
-
source?: any[];
|
|
94
|
-
[key: string]: any;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export interface IUseDragOptions extends IUseSensorOptions {
|
|
98
|
-
groups?: string[];
|
|
99
|
-
events?: {
|
|
100
|
-
onEnd?: (store: IDnDStore) => void;
|
|
101
|
-
onStart?: (store: IDnDStore) => void;
|
|
102
|
-
onMove?: (store: IDnDStore) => void;
|
|
103
|
-
onHover?: (store: IDnDStore) => void;
|
|
104
|
-
onLeave?: (store: IDnDStore) => void;
|
|
105
|
-
};
|
|
106
|
-
keyboard?: {
|
|
107
|
-
moveStep?: number;
|
|
108
|
-
};
|
|
109
|
-
data?: {
|
|
110
|
-
source?: any[];
|
|
111
|
-
index?: number;
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
};
|
|
114
|
-
layer?: Component | null;
|
|
115
|
-
container?: Component;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type ISensor = (
|
|
119
|
-
store: IDnDStore
|
|
120
|
-
) => HTMLElement | HTMLElement[] | Element | Element[] | null;
|
|
121
|
-
|
|
122
|
-
export interface IBoundingBox {
|
|
123
|
-
x: number;
|
|
124
|
-
y: number;
|
|
125
|
-
width: number;
|
|
126
|
-
height: number;
|
|
127
|
-
bottom: number;
|
|
128
|
-
left: number;
|
|
129
|
-
right: number;
|
|
130
|
-
top: number;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface IUseSensorOptions {
|
|
134
|
-
sensor?: {
|
|
135
|
-
throttle?: number;
|
|
136
|
-
setup?: ISensor;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface ICollisionDetectionResult {
|
|
141
|
-
element: IDragElement | null;
|
|
142
|
-
zone: IDropZone | null;
|
|
143
|
-
}
|
package/dist/utils/dom.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDescendant: (element: HTMLElement | Element | null, container: HTMLElement | Element) => boolean;
|
package/dist/utils/events.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const preventEvent: (event: Event) => void;
|
package/dist/utils/geometry.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IBoundingBox, IPoint } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare const checkCollision: (boxA: IBoundingBox, boxB: IBoundingBox) => boolean;
|
|
4
|
-
export declare const getBoundingBox: (element: HTMLElement | null) => IBoundingBox;
|
|
5
|
-
export declare const getCenter: (box: IBoundingBox) => IPoint;
|
|
6
|
-
export declare const getOffset: (element: HTMLElement | null, pointer: IPoint) => {
|
|
7
|
-
pixel: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
};
|
|
11
|
-
percent: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const getDistance: (pointA: IPoint, pointB: IPoint) => number;
|
|
17
|
-
export declare const getOverlapPercent: (boxA: IBoundingBox, boxB: IBoundingBox) => number;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IDnDStore } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare class DnDOperations {
|
|
4
|
-
static remove: (source?: any[], index?: number) => any;
|
|
5
|
-
static insert: (target?: any[], index?: number, item?: any) => void;
|
|
6
|
-
static move: (source?: any[], sourceIndex?: number, target?: any[], targetIndex?: number) => void;
|
|
7
|
-
static swap: (source?: any[], sourceIndex?: number, target?: any[], targetIndex?: number) => void;
|
|
8
|
-
static copy: (source?: any[], index?: number, target?: any[], targetIndex?: number) => void;
|
|
9
|
-
static applyTransfer: (store: IDnDStore) => void;
|
|
10
|
-
static applyCopy: (store: IDnDStore) => void;
|
|
11
|
-
static applySwap: (store: IDnDStore) => void;
|
|
12
|
-
static applyRemove: (store: IDnDStore) => void;
|
|
13
|
-
static applyInsert: (store: IDnDStore, items: any[]) => void;
|
|
14
|
-
}
|
package/dist/utils/sensor.d.ts
DELETED