Comparing version 2.0.0 to 2.0.1
@@ -146,2 +146,3 @@ "use strict"; | ||
return (0, _vueDemi).h(_vueDemi.Fragment, [ | ||
// @ts-ignore | ||
(0, _vueDemi).h(_dragPreviewImage.default, { | ||
@@ -148,0 +149,0 @@ connect: connectPreview, |
@@ -14,11 +14,2 @@ "use strict"; | ||
function useConnector(callback, defaultOptions) { | ||
var connector = function connector(element, options) { | ||
(0, _vueDemi).set(_state, "el", element); | ||
// Because of the special nature of vue, when it calls setRef, it will pass in two parameters. Therefore, when we pass connect as a setRef function, we may receive a non-ideal options. For this reason, we assume that when there are options in the spec, The options passed in by Connect are no longer adopted to ensure that the options of spec always take precedence over the options of connect | ||
var _options = (0, _vueDemi).unref(defaultOptions) || options; | ||
if (!(0, _fastDeepEqual).default(_state.options, _options)) { | ||
(0, _vueDemi).set(_state, "options", _options); | ||
} | ||
return (0, _vueDemi).unref(element); | ||
}; | ||
var _state = (0, _vueDemi).reactive({ | ||
@@ -33,3 +24,12 @@ el: null, | ||
}); | ||
var connector = function(element, options) { | ||
(0, _vueDemi).set(_state, "el", element); | ||
// Because of the special nature of vue, when it calls setRef, it will pass in two parameters. Therefore, when we pass connect as a setRef function, we may receive a non-ideal options. For this reason, we assume that when there are options in the spec, The options passed in by Connect are no longer adopted to ensure that the options of spec always take precedence over the options of connect | ||
var _options = (0, _vueDemi).unref(defaultOptions) || options; | ||
if (!(0, _fastDeepEqual).default(_state.options, _options)) { | ||
(0, _vueDemi).set(_state, "options", _options); | ||
} | ||
return (0, _vueDemi).unref(element); | ||
}; | ||
return connector; | ||
} |
@@ -140,2 +140,3 @@ function _arrayLikeToArray(arr, len) { | ||
return h(Fragment, [ | ||
// @ts-ignore | ||
h(DragPreviewImage, { | ||
@@ -142,0 +143,0 @@ connect: connectPreview, |
import { reactive, set, unref, watchEffect } from "vue-demi"; | ||
import equal from "fast-deep-equal"; | ||
export function useConnector(callback, defaultOptions) { | ||
var connector = function connector(element, options) { | ||
set(_state, "el", element); | ||
// Because of the special nature of vue, when it calls setRef, it will pass in two parameters. Therefore, when we pass connect as a setRef function, we may receive a non-ideal options. For this reason, we assume that when there are options in the spec, The options passed in by Connect are no longer adopted to ensure that the options of spec always take precedence over the options of connect | ||
var _options = unref(defaultOptions) || options; | ||
if (!equal(_state.options, _options)) { | ||
set(_state, "options", _options); | ||
} | ||
return unref(element); | ||
}; | ||
var _state = reactive({ | ||
@@ -22,3 +13,12 @@ el: null, | ||
}); | ||
var connector = function(element, options) { | ||
set(_state, "el", element); | ||
// Because of the special nature of vue, when it calls setRef, it will pass in two parameters. Therefore, when we pass connect as a setRef function, we may receive a non-ideal options. For this reason, we assume that when there are options in the spec, The options passed in by Connect are no longer adopted to ensure that the options of spec always take precedence over the options of connect | ||
var _options = unref(defaultOptions) || options; | ||
if (!equal(_state.options, _options)) { | ||
set(_state, "options", _options); | ||
} | ||
return unref(element); | ||
}; | ||
return connector; | ||
} |
import { Ref } from 'vue-demi'; | ||
import { MaybeRef } from '../types/utils'; | ||
import { ConnectNode } from '../types'; | ||
interface ConnectorState<O> { | ||
@@ -7,3 +7,3 @@ el: Element | null; | ||
} | ||
export declare function useConnector<Options>(callback: (state: ConnectorState<Options>) => void, defaultOptions: Ref<Options | undefined>): (element: MaybeRef<Element | null>, options: MaybeRef<Options | undefined>) => Element | null; | ||
export declare function useConnector<Options>(callback: (state: ConnectorState<Options>) => void, defaultOptions: Ref<Options | undefined>): ConnectNode<Options>; | ||
export {}; |
@@ -6,3 +6,3 @@ import type { SourceConnector } from '../../internals'; | ||
import { DragPreviewOptions, DragSourceOptions } from '../../types'; | ||
export declare function useConnectDragSource<O, R, P>(connector: MaybeRef<SourceConnector>, spec: Ref<DragSourceHookSpec<O, R, P>>): (element: MaybeRef<Element | null>, options: MaybeRef<DragSourceOptions | undefined>) => Element | null; | ||
export declare function useConnectDragPreview<O, R, P>(connector: MaybeRef<SourceConnector>, spec: Ref<DragSourceHookSpec<O, R, P>>): (element: MaybeRef<Element | null>, options: MaybeRef<DragPreviewOptions | undefined>) => Element | null; | ||
export declare function useConnectDragSource<O, R, P>(connector: MaybeRef<SourceConnector>, spec: Ref<DragSourceHookSpec<O, R, P>>): import("../../types").ConnectNode<DragSourceOptions>; | ||
export declare function useConnectDragPreview<O, R, P>(connector: MaybeRef<SourceConnector>, spec: Ref<DragSourceHookSpec<O, R, P>>): import("../../types").ConnectNode<DragPreviewOptions>; |
import type { TargetConnector } from '../../internals'; | ||
import { MaybeRef } from '../../types/utils'; | ||
import { DropTargetHookSpec } from '../types'; | ||
export declare function useConnectDropTarget<O, R, P>(connector: MaybeRef<TargetConnector>, spec: MaybeRef<DropTargetHookSpec<O, R, P>>): (element: MaybeRef<Element | null>, options: any) => Element | null; | ||
export declare function useConnectDropTarget<O, R, P>(connector: MaybeRef<TargetConnector>, spec: MaybeRef<DropTargetHookSpec<O, R, P>>): import("../../types").ConnectNode<any>; |
@@ -0,6 +1,11 @@ | ||
import { ComponentPublicInstance } from 'vue-demi'; | ||
import { MaybeRef } from './utils'; | ||
export declare type ConnectableElement = MaybeRef<Element | null>; | ||
export declare type ConnectNode<Options> = (elementOrNode: ConnectableElement, options?: Options) => Element | null; | ||
export interface ConnectNode<Options> { | ||
(ref: Element | ComponentPublicInstance | null, refs: Record<string, any>): void; | ||
(ref: object | null, refs: Record<string, any>): void; | ||
<E extends Element | null>(ref: MaybeRef<E>, options?: Options): E; | ||
} | ||
export declare type ConnectDragSource<Options> = ConnectNode<Options>; | ||
export declare type ConnectDropTarget<Options> = ConnectNode<Options>; | ||
export declare type ConnectDragPreview<Options> = ConnectNode<Options>; |
{ | ||
"name": "vue3-dnd", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Drag and Drop for Vue3", | ||
@@ -5,0 +5,0 @@ "author": "hcg1023 <2293885211@qq.com>", |
@@ -21,2 +21,3 @@ # Vue3 Dn<img src="http://image.haochenguang.cn/pictures/vue3-dnd.svg" width="28"> | ||
[![npm download per month](https://img.shields.io/npm/dm/vue3-dnd.svg?style=flat-square)](https://www.npmjs.com/package/vue3-dnd) | ||
[![Featured on Openbase](https://badges.openbase.com/js/featured/vue3-dnd.svg?token=DweDwkc7YaNcSSwPw5ToxjJyG/CPuAX7J7sZFXKUg9c=)](https://openbase.com/js/vue3-dnd?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge) | ||
[![MIT License](https://img.shields.io/github/license/hcg1023/vue3-dnd.svg)](https://github.com/hcg1023/vue3-dnd/blob/main/LICENSE) | ||
@@ -23,0 +24,0 @@ |
@@ -21,2 +21,3 @@ # Vue3 Dn<img src="http://image.haochenguang.cn/pictures/vue3-dnd.svg" width="28"> | ||
[![npm download per month](https://img.shields.io/npm/dm/vue3-dnd.svg?style=flat-square)](https://www.npmjs.com/package/vue3-dnd) | ||
[![Featured on Openbase](https://badges.openbase.com/js/featured/vue3-dnd.svg?token=DweDwkc7YaNcSSwPw5ToxjJyG/CPuAX7J7sZFXKUg9c=)](https://openbase.com/js/vue3-dnd?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge) | ||
[![MIT License](https://img.shields.io/github/license/hcg1023/vue3-dnd.svg)](https://github.com/hcg1023/vue3-dnd/blob/main/LICENSE) | ||
@@ -23,0 +24,0 @@ |
315993
6811
243