@vueuse/integrations 10.3.0 → 10.4.0
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/index.cjs +62 -214
- package/index.d.cts +8 -18
- package/index.d.mts +8 -18
- package/index.d.ts +8 -18
- package/index.iife.js +62 -214
- package/index.iife.min.js +1 -1
- package/index.mjs +64 -216
- package/package.json +6 -6
- package/useAsyncValidator/component.cjs +5 -29
- package/useAsyncValidator/component.mjs +5 -29
- package/useAsyncValidator.cjs +5 -29
- package/useAsyncValidator.d.cts +1 -1
- package/useAsyncValidator.d.mts +1 -1
- package/useAsyncValidator.d.ts +1 -1
- package/useAsyncValidator.iife.js +5 -29
- package/useAsyncValidator.iife.min.js +1 -1
- package/useAsyncValidator.mjs +5 -29
- package/useAxios.cjs +8 -25
- package/useAxios.d.cts +1 -1
- package/useAxios.d.mts +1 -1
- package/useAxios.d.ts +1 -1
- package/useAxios.iife.js +8 -25
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +8 -25
- package/useChangeCase.d.cts +2 -14
- package/useChangeCase.d.mts +2 -14
- package/useChangeCase.d.ts +2 -14
- package/useCookies.cjs +2 -18
- package/useCookies.iife.js +2 -18
- package/useCookies.iife.min.js +1 -1
- package/useCookies.mjs +2 -18
- package/useDrauu.cjs +8 -43
- package/useDrauu.d.cts +1 -1
- package/useDrauu.d.mts +1 -1
- package/useDrauu.d.ts +1 -1
- package/useDrauu.iife.js +8 -43
- package/useDrauu.iife.min.js +1 -1
- package/useDrauu.mjs +8 -43
- package/useFocusTrap/component.d.cts +1 -1
- package/useFocusTrap/component.d.mts +1 -1
- package/useFocusTrap/component.d.ts +1 -1
- package/useFocusTrap.cjs +4 -34
- package/useFocusTrap.d.cts +1 -1
- package/useFocusTrap.d.mts +1 -1
- package/useFocusTrap.d.ts +1 -1
- package/useFocusTrap.iife.js +4 -34
- package/useFocusTrap.iife.min.js +1 -1
- package/useFocusTrap.mjs +4 -34
- package/useFuse.cjs +5 -9
- package/useFuse.d.cts +1 -1
- package/useFuse.d.mts +1 -1
- package/useFuse.d.ts +1 -1
- package/useFuse.iife.js +5 -9
- package/useFuse.iife.min.js +1 -1
- package/useFuse.mjs +5 -9
- package/useIDBKeyval.cjs +17 -19
- package/useIDBKeyval.d.cts +8 -6
- package/useIDBKeyval.d.mts +8 -6
- package/useIDBKeyval.d.ts +8 -6
- package/useIDBKeyval.iife.js +18 -21
- package/useIDBKeyval.iife.min.js +1 -1
- package/useIDBKeyval.mjs +18 -20
- package/useJwt.cjs +1 -1
- package/useJwt.d.cts +1 -1
- package/useJwt.d.mts +1 -1
- package/useJwt.d.ts +1 -1
- package/useJwt.iife.js +1 -1
- package/useJwt.iife.min.js +1 -1
- package/useJwt.mjs +1 -1
- package/useNProgress.d.cts +1 -1
- package/useNProgress.d.mts +1 -1
- package/useNProgress.d.ts +1 -1
- package/useSortable/component.cjs +13 -36
- package/useSortable/component.mjs +14 -37
- package/useSortable.cjs +13 -36
- package/useSortable.d.cts +1 -1
- package/useSortable.d.mts +1 -1
- package/useSortable.d.ts +1 -1
- package/useSortable.iife.js +13 -36
- package/useSortable.iife.min.js +1 -1
- package/useSortable.mjs +14 -37
|
@@ -1,65 +1,42 @@
|
|
|
1
|
-
import { nextTick, defineComponent, ref, reactive, h } from 'vue-demi';
|
|
1
|
+
import { isRef, nextTick, defineComponent, ref, reactive, h } from 'vue-demi';
|
|
2
2
|
import { tryOnMounted, tryOnScopeDispose, unrefElement, defaultDocument, toValue, useVModel } from '@vueuse/core';
|
|
3
3
|
import Sortable from 'sortablejs';
|
|
4
4
|
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
5
|
function useSortable(el, list, options = {}) {
|
|
34
6
|
let sortable;
|
|
35
|
-
const
|
|
7
|
+
const { document = defaultDocument, ...resetOptions } = options;
|
|
36
8
|
const defaultOptions = {
|
|
37
9
|
onUpdate: (e) => {
|
|
38
10
|
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
39
11
|
}
|
|
40
12
|
};
|
|
41
13
|
const start = () => {
|
|
42
|
-
const target = typeof el === "string" ? document
|
|
14
|
+
const target = typeof el === "string" ? document?.querySelector(el) : unrefElement(el);
|
|
43
15
|
if (!target)
|
|
44
16
|
return;
|
|
45
|
-
sortable = new Sortable(target,
|
|
17
|
+
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
46
18
|
};
|
|
47
|
-
const stop = () => sortable
|
|
19
|
+
const stop = () => sortable?.destroy();
|
|
48
20
|
const option = (name, value) => {
|
|
49
21
|
if (value !== void 0)
|
|
50
|
-
sortable
|
|
22
|
+
sortable?.option(name, value);
|
|
51
23
|
else
|
|
52
|
-
return sortable
|
|
24
|
+
return sortable?.option(name);
|
|
53
25
|
};
|
|
54
26
|
tryOnMounted(start);
|
|
55
27
|
tryOnScopeDispose(stop);
|
|
56
28
|
return { stop, start, option };
|
|
57
29
|
}
|
|
58
30
|
function moveArrayElement(list, from, to) {
|
|
59
|
-
const
|
|
31
|
+
const _valueIsRef = isRef(list);
|
|
32
|
+
const array = _valueIsRef ? [...toValue(list)] : toValue(list);
|
|
60
33
|
if (to >= 0 && to < array.length) {
|
|
61
34
|
const element = array.splice(from, 1)[0];
|
|
62
|
-
nextTick(() =>
|
|
35
|
+
nextTick(() => {
|
|
36
|
+
array.splice(to, 0, element);
|
|
37
|
+
if (_valueIsRef)
|
|
38
|
+
list.value = array;
|
|
39
|
+
});
|
|
63
40
|
}
|
|
64
41
|
}
|
|
65
42
|
|
package/useSortable.cjs
CHANGED
|
@@ -4,64 +4,41 @@ var core = require('@vueuse/core');
|
|
|
4
4
|
var Sortable = require('sortablejs');
|
|
5
5
|
var vueDemi = require('vue-demi');
|
|
6
6
|
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
7
|
function useSortable(el, list, options = {}) {
|
|
36
8
|
let sortable;
|
|
37
|
-
const
|
|
9
|
+
const { document = core.defaultDocument, ...resetOptions } = options;
|
|
38
10
|
const defaultOptions = {
|
|
39
11
|
onUpdate: (e) => {
|
|
40
12
|
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
41
13
|
}
|
|
42
14
|
};
|
|
43
15
|
const start = () => {
|
|
44
|
-
const target = typeof el === "string" ? document
|
|
16
|
+
const target = typeof el === "string" ? document?.querySelector(el) : core.unrefElement(el);
|
|
45
17
|
if (!target)
|
|
46
18
|
return;
|
|
47
|
-
sortable = new Sortable(target,
|
|
19
|
+
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
48
20
|
};
|
|
49
|
-
const stop = () => sortable
|
|
21
|
+
const stop = () => sortable?.destroy();
|
|
50
22
|
const option = (name, value) => {
|
|
51
23
|
if (value !== void 0)
|
|
52
|
-
sortable
|
|
24
|
+
sortable?.option(name, value);
|
|
53
25
|
else
|
|
54
|
-
return sortable
|
|
26
|
+
return sortable?.option(name);
|
|
55
27
|
};
|
|
56
28
|
core.tryOnMounted(start);
|
|
57
29
|
core.tryOnScopeDispose(stop);
|
|
58
30
|
return { stop, start, option };
|
|
59
31
|
}
|
|
60
32
|
function moveArrayElement(list, from, to) {
|
|
61
|
-
const
|
|
33
|
+
const _valueIsRef = vueDemi.isRef(list);
|
|
34
|
+
const array = _valueIsRef ? [...core.toValue(list)] : core.toValue(list);
|
|
62
35
|
if (to >= 0 && to < array.length) {
|
|
63
36
|
const element = array.splice(from, 1)[0];
|
|
64
|
-
vueDemi.nextTick(() =>
|
|
37
|
+
vueDemi.nextTick(() => {
|
|
38
|
+
array.splice(to, 0, element);
|
|
39
|
+
if (_valueIsRef)
|
|
40
|
+
list.value = array;
|
|
41
|
+
});
|
|
65
42
|
}
|
|
66
43
|
}
|
|
67
44
|
|
package/useSortable.d.cts
CHANGED
|
@@ -23,4 +23,4 @@ declare function useSortable<T>(selector: string, list: MaybeRefOrGetter<T[]>, o
|
|
|
23
23
|
declare function useSortable<T>(el: MaybeRefOrGetter<HTMLElement | null | undefined>, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
24
24
|
declare function moveArrayElement<T>(list: MaybeRefOrGetter<T[]>, from: number, to: number): void;
|
|
25
25
|
|
|
26
|
-
export { UseSortableOptions, UseSortableReturn, moveArrayElement, useSortable };
|
|
26
|
+
export { type UseSortableOptions, type UseSortableReturn, moveArrayElement, useSortable };
|
package/useSortable.d.mts
CHANGED
|
@@ -23,4 +23,4 @@ declare function useSortable<T>(selector: string, list: MaybeRefOrGetter<T[]>, o
|
|
|
23
23
|
declare function useSortable<T>(el: MaybeRefOrGetter<HTMLElement | null | undefined>, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
24
24
|
declare function moveArrayElement<T>(list: MaybeRefOrGetter<T[]>, from: number, to: number): void;
|
|
25
25
|
|
|
26
|
-
export { UseSortableOptions, UseSortableReturn, moveArrayElement, useSortable };
|
|
26
|
+
export { type UseSortableOptions, type UseSortableReturn, moveArrayElement, useSortable };
|
package/useSortable.d.ts
CHANGED
|
@@ -23,4 +23,4 @@ declare function useSortable<T>(selector: string, list: MaybeRefOrGetter<T[]>, o
|
|
|
23
23
|
declare function useSortable<T>(el: MaybeRefOrGetter<HTMLElement | null | undefined>, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
24
24
|
declare function moveArrayElement<T>(list: MaybeRefOrGetter<T[]>, from: number, to: number): void;
|
|
25
25
|
|
|
26
|
-
export { UseSortableOptions, UseSortableReturn, moveArrayElement, useSortable };
|
|
26
|
+
export { type UseSortableOptions, type UseSortableReturn, moveArrayElement, useSortable };
|
package/useSortable.iife.js
CHANGED
|
@@ -117,64 +117,41 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
117
117
|
;(function (exports, core, Sortable, vueDemi) {
|
|
118
118
|
'use strict';
|
|
119
119
|
|
|
120
|
-
var __defProp = Object.defineProperty;
|
|
121
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
122
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
123
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
124
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
125
|
-
var __spreadValues = (a, b) => {
|
|
126
|
-
for (var prop in b || (b = {}))
|
|
127
|
-
if (__hasOwnProp.call(b, prop))
|
|
128
|
-
__defNormalProp(a, prop, b[prop]);
|
|
129
|
-
if (__getOwnPropSymbols)
|
|
130
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
131
|
-
if (__propIsEnum.call(b, prop))
|
|
132
|
-
__defNormalProp(a, prop, b[prop]);
|
|
133
|
-
}
|
|
134
|
-
return a;
|
|
135
|
-
};
|
|
136
|
-
var __objRest = (source, exclude) => {
|
|
137
|
-
var target = {};
|
|
138
|
-
for (var prop in source)
|
|
139
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
140
|
-
target[prop] = source[prop];
|
|
141
|
-
if (source != null && __getOwnPropSymbols)
|
|
142
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
143
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
144
|
-
target[prop] = source[prop];
|
|
145
|
-
}
|
|
146
|
-
return target;
|
|
147
|
-
};
|
|
148
120
|
function useSortable(el, list, options = {}) {
|
|
149
121
|
let sortable;
|
|
150
|
-
const
|
|
122
|
+
const { document = core.defaultDocument, ...resetOptions } = options;
|
|
151
123
|
const defaultOptions = {
|
|
152
124
|
onUpdate: (e) => {
|
|
153
125
|
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
154
126
|
}
|
|
155
127
|
};
|
|
156
128
|
const start = () => {
|
|
157
|
-
const target = typeof el === "string" ? document
|
|
129
|
+
const target = typeof el === "string" ? document?.querySelector(el) : core.unrefElement(el);
|
|
158
130
|
if (!target)
|
|
159
131
|
return;
|
|
160
|
-
sortable = new Sortable(target,
|
|
132
|
+
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
161
133
|
};
|
|
162
|
-
const stop = () => sortable
|
|
134
|
+
const stop = () => sortable?.destroy();
|
|
163
135
|
const option = (name, value) => {
|
|
164
136
|
if (value !== void 0)
|
|
165
|
-
sortable
|
|
137
|
+
sortable?.option(name, value);
|
|
166
138
|
else
|
|
167
|
-
return sortable
|
|
139
|
+
return sortable?.option(name);
|
|
168
140
|
};
|
|
169
141
|
core.tryOnMounted(start);
|
|
170
142
|
core.tryOnScopeDispose(stop);
|
|
171
143
|
return { stop, start, option };
|
|
172
144
|
}
|
|
173
145
|
function moveArrayElement(list, from, to) {
|
|
174
|
-
const
|
|
146
|
+
const _valueIsRef = vueDemi.isRef(list);
|
|
147
|
+
const array = _valueIsRef ? [...core.toValue(list)] : core.toValue(list);
|
|
175
148
|
if (to >= 0 && to < array.length) {
|
|
176
149
|
const element = array.splice(from, 1)[0];
|
|
177
|
-
vueDemi.nextTick(() =>
|
|
150
|
+
vueDemi.nextTick(() => {
|
|
151
|
+
array.splice(to, 0, element);
|
|
152
|
+
if (_valueIsRef)
|
|
153
|
+
list.value = array;
|
|
154
|
+
});
|
|
178
155
|
}
|
|
179
156
|
}
|
|
180
157
|
|
package/useSortable.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(n,t,u){if(n.install)return n;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(t.version.slice(0,4)==="2.7."){let
|
|
1
|
+
var VueDemi=function(n,t,u){if(n.install)return n;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(t.version.slice(0,4)==="2.7."){let o=function(e,i){var r,f={},d={config:t.config,use:t.use.bind(t),mixin:t.mixin.bind(t),component:t.component.bind(t),provide:function(c,l){return f[c]=l,this},directive:function(c,l){return l?(t.directive(c,l),d):t.directive(c)},mount:function(c,l){return r||(r=new t(Object.assign({propsData:i},e,{provide:Object.assign(f,e.provide)})),r.$mount(c,l),r)},unmount:function(){r&&(r.$destroy(),r=void 0)}};return d};var p=o;for(var s in t)n[s]=t[s];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=t,n.Vue2=t,n.version=t.version,n.warn=t.util.warn,n.hasInjectionContext=()=>!!n.getCurrentInstance(),n.createApp=o}else if(t.version.slice(0,2)==="2.")if(u){for(var s in u)n[s]=u[s];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=t,n.Vue2=t,n.version=t.version,n.hasInjectionContext=()=>!!n.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(t.version.slice(0,2)==="3."){for(var s in t)n[s]=t[s];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=t,n.Vue2=void 0,n.version=t.version,n.set=function(o,e,i){return Array.isArray(o)?(o.length=Math.max(o.length,e),o.splice(e,1,i),i):(o[e]=i,i)},n.del=function(o,e){if(Array.isArray(o)){o.splice(e,1);return}delete o[e]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");return n}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,t,u,s){"use strict";function p(e,i,r={}){let f;const{document:d=t.defaultDocument,...c}=r,l={onUpdate:a=>{o(i,a.oldIndex,a.newIndex)}},v=()=>{const a=typeof e=="string"?d?.querySelector(e):t.unrefElement(e);a&&(f=new u(a,{...l,...c}))},y=()=>f?.destroy(),h=(a,b)=>{if(b!==void 0)f?.option(a,b);else return f?.option(a)};return t.tryOnMounted(v),t.tryOnScopeDispose(y),{stop:y,start:v,option:h}}function o(e,i,r){const f=s.isRef(e),d=f?[...t.toValue(e)]:t.toValue(e);if(r>=0&&r<d.length){const c=d.splice(i,1)[0];s.nextTick(()=>{d.splice(r,0,c),f&&(e.value=d)})}}n.moveArrayElement=o,n.useSortable=p})(this.VueUse=this.VueUse||{},VueUse,Sortable,VueDemi);
|
package/useSortable.mjs
CHANGED
|
@@ -1,65 +1,42 @@
|
|
|
1
1
|
import { tryOnMounted, tryOnScopeDispose, toValue, unrefElement, defaultDocument } from '@vueuse/core';
|
|
2
2
|
import Sortable from 'sortablejs';
|
|
3
|
-
import { nextTick } from 'vue-demi';
|
|
3
|
+
import { isRef, nextTick } from 'vue-demi';
|
|
4
4
|
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
5
|
function useSortable(el, list, options = {}) {
|
|
34
6
|
let sortable;
|
|
35
|
-
const
|
|
7
|
+
const { document = defaultDocument, ...resetOptions } = options;
|
|
36
8
|
const defaultOptions = {
|
|
37
9
|
onUpdate: (e) => {
|
|
38
10
|
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
39
11
|
}
|
|
40
12
|
};
|
|
41
13
|
const start = () => {
|
|
42
|
-
const target = typeof el === "string" ? document
|
|
14
|
+
const target = typeof el === "string" ? document?.querySelector(el) : unrefElement(el);
|
|
43
15
|
if (!target)
|
|
44
16
|
return;
|
|
45
|
-
sortable = new Sortable(target,
|
|
17
|
+
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
46
18
|
};
|
|
47
|
-
const stop = () => sortable
|
|
19
|
+
const stop = () => sortable?.destroy();
|
|
48
20
|
const option = (name, value) => {
|
|
49
21
|
if (value !== void 0)
|
|
50
|
-
sortable
|
|
22
|
+
sortable?.option(name, value);
|
|
51
23
|
else
|
|
52
|
-
return sortable
|
|
24
|
+
return sortable?.option(name);
|
|
53
25
|
};
|
|
54
26
|
tryOnMounted(start);
|
|
55
27
|
tryOnScopeDispose(stop);
|
|
56
28
|
return { stop, start, option };
|
|
57
29
|
}
|
|
58
30
|
function moveArrayElement(list, from, to) {
|
|
59
|
-
const
|
|
31
|
+
const _valueIsRef = isRef(list);
|
|
32
|
+
const array = _valueIsRef ? [...toValue(list)] : toValue(list);
|
|
60
33
|
if (to >= 0 && to < array.length) {
|
|
61
34
|
const element = array.splice(from, 1)[0];
|
|
62
|
-
nextTick(() =>
|
|
35
|
+
nextTick(() => {
|
|
36
|
+
array.splice(to, 0, element);
|
|
37
|
+
if (_valueIsRef)
|
|
38
|
+
list.value = array;
|
|
39
|
+
});
|
|
63
40
|
}
|
|
64
41
|
}
|
|
65
42
|
|