@vue-dnd-kit/core 0.0.25-beta → 0.0.26-beta

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.
@@ -1,73 +1,73 @@
1
- /**
2
- * Hook for creating custom drag container with overlay management.
3
- * Provides functionality for controlling drag visualization and element positioning.
4
- *
5
- * This hook is typically used to create custom drag overlays, layers,
6
- * and control how dragged elements are displayed during drag operations.
7
- *
8
- * @example
9
- * ```vue
10
- * <script setup lang="ts">
11
- * import { computed } from 'vue';
12
- * import { useDragContainer } from '../composables/useDragContainer';
13
- *
14
- * const { elementRef, pointerPosition, isDragging, draggingElements } =
15
- * useDragContainer();
16
- *
17
- * const computedStyle = computed(() => ({
18
- * transform: `translate3d(${
19
- * (pointerPosition.current.value?.x ?? 0) -
20
- * (pointerPosition.offset.pixel.value?.x ?? 0)
21
- * }px, ${
22
- * (pointerPosition.current.value?.y ?? 0) -
23
- * (pointerPosition.offset.pixel.value?.y ?? 0)
24
- * }px, 0)`,
25
- * }));
26
- *</script>
27
- *
28
- *<template>
29
- * <Teleport to="body">
30
- * <div
31
- * v-if="isDragging"
32
- * ref="elementRef"
33
- * :style="computedStyle"
34
- * class="default-drag-overlay"
35
- * >
36
- * <div
37
- * v-for="(element, index) in draggingElements"
38
- * :key="index"
39
- * v-html="element.initialHTML"
40
- * :style="{
41
- * width: `${element.initialRect?.width}px`,
42
- * height: `${element.initialRect?.height}px`,
43
- * }"
44
- * />
45
- * </div>
46
- * </Teleport>
47
- *</template>
48
- *
49
- *<style scoped>
50
- * .default-drag-overlay {
51
- * position: fixed;
52
- * top: 0;
53
- * left: 0;
54
- * background-color: rgba(0, 0, 0, 0.5);
55
- * transition: 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
56
- * z-index: 1000;
57
- * }
58
- *</style>
59
- *
60
- * ```
61
- *
62
- * @returns {Object} Container controls and state
63
- * @property {Ref<HTMLElement | null>} elementRef - Reference to be bound to container element
64
- * @property {Ref<IDragElement[]>} draggingElements - Currently dragged elements
65
- * @property {IPointerPosition} pointerPosition - Current pointer coordinates and offsets
66
- * @property {Ref<boolean>} isDragging - Whether drag operation is in progress
67
- */
68
- export declare const useDragContainer: () => {
69
- elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
70
- draggingElements: import('vue').Ref<import('..').IDraggingElement[], import('..').IDraggingElement[]>;
71
- pointerPosition: import('..').IPointerPosition;
72
- isDragging: import('vue').Ref<boolean, boolean>;
73
- };
1
+ /**
2
+ * Hook for creating custom drag container with overlay management.
3
+ * Provides functionality for controlling drag visualization and element positioning.
4
+ *
5
+ * This hook is typically used to create custom drag overlays, layers,
6
+ * and control how dragged elements are displayed during drag operations.
7
+ *
8
+ * @example
9
+ * ```vue
10
+ * <script setup lang="ts">
11
+ * import { computed } from 'vue';
12
+ * import { useDragContainer } from '../composables/useDragContainer';
13
+ *
14
+ * const { elementRef, pointerPosition, isDragging, draggingElements } =
15
+ * useDragContainer();
16
+ *
17
+ * const computedStyle = computed(() => ({
18
+ * transform: `translate3d(${
19
+ * (pointerPosition.current.value?.x ?? 0) -
20
+ * (pointerPosition.offset.pixel.value?.x ?? 0)
21
+ * }px, ${
22
+ * (pointerPosition.current.value?.y ?? 0) -
23
+ * (pointerPosition.offset.pixel.value?.y ?? 0)
24
+ * }px, 0)`,
25
+ * }));
26
+ *</script>
27
+ *
28
+ *<template>
29
+ * <Teleport to="body">
30
+ * <div
31
+ * v-if="isDragging"
32
+ * ref="elementRef"
33
+ * :style="computedStyle"
34
+ * class="default-drag-overlay"
35
+ * >
36
+ * <div
37
+ * v-for="(element, index) in draggingElements"
38
+ * :key="index"
39
+ * v-html="element.initialHTML"
40
+ * :style="{
41
+ * width: `${element.initialRect?.width}px`,
42
+ * height: `${element.initialRect?.height}px`,
43
+ * }"
44
+ * />
45
+ * </div>
46
+ * </Teleport>
47
+ *</template>
48
+ *
49
+ *<style scoped>
50
+ * .default-drag-overlay {
51
+ * position: fixed;
52
+ * top: 0;
53
+ * left: 0;
54
+ * background-color: rgba(0, 0, 0, 0.5);
55
+ * transition: 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
56
+ * z-index: 1000;
57
+ * }
58
+ *</style>
59
+ *
60
+ * ```
61
+ *
62
+ * @returns {Object} Container controls and state
63
+ * @property {Ref<HTMLElement | null>} elementRef - Reference to be bound to container element
64
+ * @property {Ref<IDragElement[]>} draggingElements - Currently dragged elements
65
+ * @property {IPointerPosition} pointerPosition - Current pointer coordinates and offsets
66
+ * @property {Ref<boolean>} isDragging - Whether drag operation is in progress
67
+ */
68
+ export declare const useDragContainer: () => {
69
+ elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
70
+ draggingElements: import('vue').Ref<import('..').IDraggingElement[], import('..').IDraggingElement[]>;
71
+ pointerPosition: import('..').IPointerPosition;
72
+ isDragging: import('vue').Ref<boolean, boolean>;
73
+ };
@@ -1,51 +1,50 @@
1
1
  import { IUseDragOptions } from "../types";
2
-
3
- /**
4
- * Main hook for making elements draggable.
5
- * Provides all necessary functionality for drag and drop operations.
6
- *
7
- * @param options - Configuration options for draggable element
8
- * @param options.groups - Groups that element belongs to (for drop zone filtering)
9
- * @param options.events - Event handlers for drag lifecycle
10
- * @param options.data - Custom data to be passed to event handlers
11
- * @param options.layer - Custom component to render while dragging
12
- * @param options.container - Parent container component reference
13
- *
14
- * @returns Object containing:
15
- * - elementRef: Reference to be bound to draggable element
16
- * - isDragging: Whether element is currently being dragged
17
- * - isOvered: Whether element is being hovered by dragged element
18
- * - isAllowed: Whether element can interact with current drop zone based on group matching
19
- * - pointerPosition: Current pointer coordinates
20
- * - handleDragStart: Function to initiate drag operation
21
- *
22
- * @example
23
- * ```vue
24
- * <template>
25
- * <div
26
- * ref="elementRef"
27
- * :class="{ 'dragging': isDragging }"
28
- * @pointerdown="handleDragStart"
29
- * >
30
- * Drag me!
31
- * </div>
32
- * </template>
33
- *
34
- * <script setup lang="ts">
35
- * const { elementRef, isDragging, handleDragStart } = useDrag({
36
- * groups: ['items'],
37
- * events: {
38
- * onEnd: (store) => console.log('Drag ended!'),
39
- * }
40
- * });
41
- * </script>
42
- * ```
43
- */
44
- export declare const useDraggable: (options?: IUseDragOptions) => {
45
- pointerPosition: import('../types').IPointerPosition;
46
- elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
47
- isDragging: import('vue').ComputedRef<boolean>;
48
- isOvered: import('vue').ComputedRef<boolean>;
49
- isAllowed: import('vue').ComputedRef<boolean>;
50
- handleDragStart: (event: PointerEvent) => void;
51
- };
2
+ /**
3
+ * Main hook for making elements draggable.
4
+ * Provides all necessary functionality for drag and drop operations.
5
+ *
6
+ * @param options - Configuration options for draggable element
7
+ * @param options.groups - Groups that element belongs to (for drop zone filtering)
8
+ * @param options.events - Event handlers for drag lifecycle
9
+ * @param options.data - Custom data to be passed to event handlers
10
+ * @param options.layer - Custom component to render while dragging
11
+ * @param options.container - Parent container component reference
12
+ *
13
+ * @returns Object containing:
14
+ * - elementRef: Reference to be bound to draggable element
15
+ * - isDragging: Whether element is currently being dragged
16
+ * - isOvered: Whether element is being hovered by dragged element
17
+ * - isAllowed: Whether element can interact with current drop zone based on group matching
18
+ * - pointerPosition: Current pointer coordinates
19
+ * - handleDragStart: Function to initiate drag operation
20
+ *
21
+ * @example
22
+ * ```vue
23
+ * <template>
24
+ * <div
25
+ * ref="elementRef"
26
+ * :class="{ 'dragging': isDragging }"
27
+ * @pointerdown="handleDragStart"
28
+ * >
29
+ * Drag me!
30
+ * </div>
31
+ * </template>
32
+ *
33
+ * <script setup lang="ts">
34
+ * const { elementRef, isDragging, handleDragStart } = useDraggable({
35
+ * groups: ['items'],
36
+ * events: {
37
+ * onEnd: (store) => console.log('Drag ended!'),
38
+ * }
39
+ * });
40
+ * </script>
41
+ * ```
42
+ */
43
+ export declare const useDraggable: (options?: IUseDragOptions) => {
44
+ pointerPosition: import('../types').IPointerPosition;
45
+ elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
46
+ isDragging: import('vue').ComputedRef<boolean>;
47
+ isOvered: import('vue').ComputedRef<boolean>;
48
+ isAllowed: import('vue').ComputedRef<boolean>;
49
+ handleDragStart: (event: PointerEvent) => void;
50
+ };
@@ -1,91 +1,90 @@
1
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
- };
2
+ /**
3
+ * Hook for creating drop zones that can accept dragged elements.
4
+ * Manages drop zone registration and interaction states.
5
+ *
6
+ * @param options - Configuration options for drop zone
7
+ * @param options.groups - Groups that this zone accepts. Elements can only be
8
+ * dropped if they share at least one group with the zone
9
+ * @param options.events - Event handlers for drop zone lifecycle
10
+ * @param options.events.onDrop - Called when compatible element is dropped
11
+ * @param options.events.onHover - Called when compatible element hovers
12
+ * @param options.events.onLeave - Called when element leaves zone
13
+ * @param options.data - Custom data accessible in event handlers
14
+ *
15
+ * @returns Object containing:
16
+ * - elementRef: Reference to be bound to drop zone element
17
+ * - isOvered: Whether zone is currently being hovered by dragged element
18
+ * - isAllowed: Whether currently dragged element can be dropped (groups match)
19
+ *
20
+ * @example
21
+ * ```vue
22
+ * <template>
23
+ * <div
24
+ * ref="elementRef"
25
+ * :class="{
26
+ * 'drop-zone': true,
27
+ * 'zone-hovered': isOvered,
28
+ * 'drop-allowed': isAllowed && isOvered,
29
+ * 'drop-forbidden': !isAllowed && isOvered
30
+ * }"
31
+ * >
32
+ * <slot />
33
+ * </div>
34
+ * </template>
35
+ *
36
+ * <script setup lang="ts">
37
+ * const { elementRef, isOvered, isAllowed } = useDrop({
38
+ * // Зона принимает только элементы из группы 'items'
39
+ * groups: ['items'],
40
+ * events: {
41
+ * onDrop: (store) => {
42
+ * const droppedElements = store.draggingElements.value;
43
+ * console.log('Elements dropped!', droppedElements);
44
+ * },
45
+ * onHover: (store) => {
46
+ * // Подсветка зоны при наведении совместимого элемента
47
+ * if (isAllowed.value) {
48
+ * console.log('Compatible element hovering!');
49
+ * }
50
+ * },
51
+ * onLeave: () => {
52
+ * console.log('Element left drop zone');
53
+ * }
54
+ * },
55
+ * // Пользовательские данные доступны в обработчиках
56
+ * data: {
57
+ * zoneId: 'main-drop-zone',
58
+ * acceptLimit: 5
59
+ * }
60
+ * });
61
+ * </script>
62
+ *
63
+ * <style scoped>
64
+ * .drop-zone {
65
+ * border: 2px dashed #ccc;
66
+ * padding: 20px;
67
+ * transition: all 0.3s;
68
+ * }
69
+ *
70
+ * .zone-hovered {
71
+ * background: #f0f0f0;
72
+ * }
73
+ *
74
+ * .drop-allowed {
75
+ * border-color: #4CAF50;
76
+ * background: #E8F5E9;
77
+ * }
78
+ *
79
+ * .drop-forbidden {
80
+ * border-color: #F44336;
81
+ * background: #FFEBEE;
82
+ * }
83
+ * </style>
84
+ * ```
85
+ */
86
+ export declare const useDroppable: (options?: IUseDropOptions) => {
87
+ elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
88
+ isOvered: import('vue').ComputedRef<boolean>;
89
+ isAllowed: import('vue').ComputedRef<boolean>;
90
+ };
@@ -1,7 +1,6 @@
1
1
  import { Ref } from 'vue';
2
-
3
- export declare const usePointer: (elementRef: Ref<HTMLElement | null>) => {
4
- onPointerStart: (event: PointerEvent) => void;
5
- onPointerMove: (event: PointerEvent | WheelEvent) => void;
6
- onPointerEnd: () => void;
7
- };
2
+ export declare const usePointer: (elementRef: Ref<HTMLElement | null>) => {
3
+ onPointerStart: (event: PointerEvent) => void;
4
+ onPointerMove: (event: PointerEvent | WheelEvent) => void;
5
+ onPointerEnd: () => void;
6
+ };
@@ -1,14 +1,13 @@
1
1
  import { Ref } from 'vue';
2
-
3
- /**
4
- * Hook for managing element selection in drag and drop interface
5
- * @param elementRef - Reference to the HTML element that can be selected
6
- * @returns Object containing selection state and handlers
7
- */
8
- export declare const useSelection: (elementRef: Ref<HTMLElement | null>) => {
9
- handleUnselect: () => void;
10
- handleSelect: () => void;
11
- handleToggleSelect: () => void;
12
- isSelected: import('vue').ComputedRef<boolean>;
13
- isParentOfSelected: import('vue').ComputedRef<boolean>;
14
- };
2
+ /**
3
+ * Hook for managing element selection in drag and drop interface
4
+ * @param elementRef - Reference to the HTML element that can be selected
5
+ * @returns Object containing selection state and handlers
6
+ */
7
+ export declare const useSelection: (elementRef: Ref<HTMLElement | null>) => {
8
+ handleUnselect: () => void;
9
+ handleSelect: () => void;
10
+ handleToggleSelect: () => void;
11
+ isSelected: import('vue').ComputedRef<boolean>;
12
+ isParentOfSelected: import('vue').ComputedRef<boolean>;
13
+ };
@@ -1,7 +1,6 @@
1
1
  import { Ref } from 'vue';
2
-
3
- export declare const useSensor: (elementRef: Ref<HTMLElement | null>) => {
4
- activate: (event: PointerEvent) => void;
5
- track: (event: PointerEvent | WheelEvent) => void;
6
- deactivate: () => void;
7
- };
2
+ export declare const useSensor: (elementRef: Ref<HTMLElement | null>) => {
3
+ activate: (event: PointerEvent) => void;
4
+ track: (event: PointerEvent | WheelEvent) => void;
5
+ deactivate: () => void;
6
+ };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import { default as DnDContext } from './components/DnDContext';
2
1
  import { default as DragOverlay } from './components/DragOverlay';
3
2
  import { useDnDStore } from './composables/useDnDStore';
4
3
  import { useDraggable } from './composables/useDraggable';
5
4
  import { useDroppable } from './composables/useDroppable';
6
5
  import { useSelection } from './composables/useSelection';
7
-
8
- export { DragOverlay, DnDContext, useDraggable, useDroppable, useDnDStore, useSelection, };
9
- export { getBoundingBox } from './utils/geometry';
10
- export type { IDnDStore, IActiveContainer, IBoundingBox, IDragElement, IDraggingElement, IDropZone, IPoint, IPointerPosition, IUseDragOptions, IUseDropOptions, } from './types';
6
+ export { DragOverlay, useDraggable, useDroppable, useDnDStore, useSelection };
7
+ export { getBoundingBox } from './utils/geometry';
8
+ export type { IDnDStore, IActiveContainer, IBoundingBox, IDragElement, IDraggingElement, IDropZone, IPoint, IPointerPosition, IUseDragOptions, IUseDropOptions, } from './types';
@@ -1,18 +1,17 @@
1
1
  import { IUseDragOptions } from "../types";
2
-
3
- /**
4
- * Hook for managing draggable elements and their interactions.
5
- * Provides methods for registering, unregistering elements,
6
- * checking if an element is being dragged, and determining if it can be dropped.
7
- *
8
- * @param options - Optional configuration object for element management
9
- * @returns Object containing element management state and methods
10
- */
11
- export declare const useElementManager: (options?: IUseDragOptions) => {
12
- elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
13
- registerElement: () => void;
14
- unregisterElement: () => void;
15
- isDragging: import('vue').ComputedRef<boolean>;
16
- isOvered: import('vue').ComputedRef<boolean>;
17
- isAllowed: import('vue').ComputedRef<boolean>;
18
- };
2
+ /**
3
+ * Hook for managing draggable elements and their interactions.
4
+ * Provides methods for registering, unregistering elements,
5
+ * checking if an element is being dragged, and determining if it can be dropped.
6
+ *
7
+ * @param options - Optional configuration object for element management
8
+ * @returns Object containing element management state and methods
9
+ */
10
+ export declare const useElementManager: (options?: IUseDragOptions) => {
11
+ elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
12
+ registerElement: () => void;
13
+ unregisterElement: () => void;
14
+ isDragging: import('vue').ComputedRef<boolean>;
15
+ isOvered: import('vue').ComputedRef<boolean>;
16
+ isAllowed: import('vue').ComputedRef<boolean>;
17
+ };
@@ -1,4 +1,4 @@
1
- export declare const useInteractionManager: () => {
2
- disableInteractions: () => void;
3
- enableInteractions: () => void;
4
- };
1
+ export declare const useInteractionManager: () => {
2
+ disableInteractions: () => void;
3
+ enableInteractions: () => void;
4
+ };
@@ -1,9 +1,8 @@
1
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
- };
2
+ export declare const useZoneManager: (options?: IUseDropOptions) => {
3
+ elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
4
+ registerZone: () => void;
5
+ unregisterZone: () => void;
6
+ isOvered: import('vue').ComputedRef<boolean>;
7
+ isAllowed: import('vue').ComputedRef<boolean>;
8
+ };