vue-dnd-sortable 0.1.1 → 0.1.3

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.
@@ -0,0 +1,22 @@
1
+ import type { Coords } from './types';
2
+ interface ActivatorOptions {
3
+ element: HTMLElement;
4
+ onStart?: (coords: Coords) => void;
5
+ onMove?: (coords: Coords) => void;
6
+ onEnd?: (e: PointerEvent) => void;
7
+ }
8
+ export declare class Activator {
9
+ private document;
10
+ private listeners;
11
+ private documentListeners;
12
+ private options;
13
+ private windowListeners;
14
+ constructor(options: ActivatorOptions);
15
+ private deactivate;
16
+ private activate;
17
+ private handleStart;
18
+ private handleMove;
19
+ private handleEnd;
20
+ private clearSelection;
21
+ }
22
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { UniqueIdentifier } from './types';
2
+ import type { DomRectMap } from './utilities';
3
+ interface CollisionResult {
4
+ id: UniqueIdentifier;
5
+ value: number;
6
+ }
7
+ export type CollisionDetector = (options: {
8
+ rect: DOMRect;
9
+ rects: DomRectMap;
10
+ }) => CollisionResult[];
11
+ export declare const rectangleIntersection: CollisionDetector;
12
+ export declare const closestToCenter: CollisionDetector;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { default as DndProvider } from './provider.vue';
@@ -0,0 +1,26 @@
1
+ import type { CollisionDetector } from '../collision';
2
+ import type { DndEndEvent } from '../context';
3
+ import type { UniqueIdentifier } from '../types';
4
+ interface Props {
5
+ items: UniqueIdentifier[];
6
+ collision?: CollisionDetector;
7
+ axis?: 'x' | 'y';
8
+ }
9
+ declare var __VLS_1: {};
10
+ type __VLS_Slots = {} & {
11
+ default?: (props: typeof __VLS_1) => any;
12
+ };
13
+ declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ end: (event: DndEndEvent) => any;
15
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
16
+ onEnd?: ((event: DndEndEvent) => any) | undefined;
17
+ }>, {
18
+ collision: CollisionDetector;
19
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,10 @@
1
+ import type { MaybeRefOrGetter } from 'vue';
2
+ import type { UniqueIdentifier } from './types';
3
+ export interface SortableOptions {
4
+ id: UniqueIdentifier;
5
+ element: MaybeRefOrGetter<HTMLElement | null>;
6
+ handleElement?: MaybeRefOrGetter<HTMLElement | null>;
7
+ }
8
+ export declare function useSortable(options: SortableOptions): {
9
+ isDragging: import("vue").ComputedRef<boolean>;
10
+ };
@@ -0,0 +1,21 @@
1
+ import type { ComputedRef, Ref } from 'vue';
2
+ import type { Coords, Nullable, UniqueIdentifier } from './types';
3
+ import type { DomRectMap } from './utilities/rects';
4
+ interface DndContext {
5
+ elements: Ref<Map<UniqueIdentifier, HTMLElement>>;
6
+ rects: Ref<DomRectMap>;
7
+ items: ComputedRef<UniqueIdentifier[]>;
8
+ translate: Ref<Coords | null>;
9
+ active: Ref<UniqueIdentifier | null>;
10
+ over: Ref<UniqueIdentifier | null>;
11
+ sortedRects: Ref<DOMRect[]>;
12
+ activeIndex: ComputedRef<number | null>;
13
+ overIndex: ComputedRef<number | null>;
14
+ activate: (id: UniqueIdentifier, handle: Nullable<HTMLElement>) => void;
15
+ }
16
+ export interface DndEndEvent {
17
+ active: UniqueIdentifier;
18
+ over: UniqueIdentifier | null;
19
+ }
20
+ export declare const injectDndContext: <T extends DndContext | null | undefined = DndContext>(fallback?: T | undefined) => T extends null ? DndContext | null : DndContext, provideDndContext: (contextValue: DndContext) => DndContext;
21
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { DndEndEvent } from './context';
2
+ import type { UniqueIdentifier } from './types';
3
+ export declare function arrayMove(arr: UniqueIdentifier[], event: DndEndEvent): UniqueIdentifier[];
@@ -0,0 +1,4 @@
1
+ export * from './collision';
2
+ export * from './components';
3
+ export * from './composables';
4
+ export * from './helpers';
@@ -0,0 +1,7 @@
1
+ import type { Coords } from './types';
2
+ export declare function verticalListSortingStrategy(args: {
3
+ rects: DOMRect[];
4
+ activeIndex: number;
5
+ overIndex: number;
6
+ index: number;
7
+ }): Coords | null;
@@ -0,0 +1,6 @@
1
+ export type UniqueIdentifier = string | number;
2
+ export type Nullable<T> = T | null | undefined;
3
+ export interface Coords {
4
+ x: number;
5
+ y: number;
6
+ }
@@ -0,0 +1 @@
1
+ export declare function createContext<TContextValue>(componentName: string): readonly [<T extends TContextValue | null | undefined = TContextValue>(fallback?: T) => T extends null ? TContextValue | null : TContextValue, (contextValue: TContextValue) => TContextValue];
@@ -0,0 +1,3 @@
1
+ export * from './context';
2
+ export * from './rects';
3
+ export declare function isValidIndex(index: number | null): index is number;
@@ -0,0 +1,3 @@
1
+ import type { UniqueIdentifier } from '../types';
2
+ export type DomRectMap = Map<UniqueIdentifier, DOMRect>;
3
+ export declare function getSortedRects(items: UniqueIdentifier[], rects: DomRectMap): DOMRect[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-dnd-sortable",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Simple sortable for vue",
5
5
  "type": "module",
6
6
  "main": "dist/vue-dnd.umd.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "typescript": "^5.8.3",
28
- "vue": "^3.5.17"
28
+ "vue": "^3.5"
29
29
  },
30
30
  "keywords": [
31
31
  "vue",