@vueuse/integrations 12.8.1 → 13.0.0-beta.1
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/package.json +21 -72
- package/index.cjs +0 -703
- package/index.d.cts +0 -447
- package/index.d.ts +0 -447
- package/useAsyncValidator/component.cjs +0 -89
- package/useAsyncValidator/component.d.cts +0 -27
- package/useAsyncValidator/component.d.ts +0 -27
- package/useAsyncValidator.cjs +0 -74
- package/useAsyncValidator.d.cts +0 -47
- package/useAsyncValidator.d.ts +0 -47
- package/useAxios.cjs +0 -125
- package/useAxios.d.cts +0 -106
- package/useAxios.d.ts +0 -106
- package/useChangeCase.cjs +0 -49
- package/useChangeCase.d.cts +0 -14
- package/useChangeCase.d.ts +0 -14
- package/useCookies.cjs +0 -64
- package/useCookies.d.cts +0 -54
- package/useCookies.d.ts +0 -54
- package/useDrauu.cjs +0 -116
- package/useDrauu.d.cts +0 -32
- package/useDrauu.d.ts +0 -32
- package/useFocusTrap/component.cjs +0 -33
- package/useFocusTrap/component.d.cts +0 -17
- package/useFocusTrap/component.d.ts +0 -17
- package/useFocusTrap.cjs +0 -68
- package/useFocusTrap.d.cts +0 -54
- package/useFocusTrap.d.ts +0 -54
- package/useFuse.cjs +0 -45
- package/useFuse.d.cts +0 -32
- package/useFuse.d.ts +0 -32
- package/useIDBKeyval.cjs +0 -63
- package/useIDBKeyval.d.cts +0 -43
- package/useIDBKeyval.d.ts +0 -43
- package/useJwt.cjs +0 -27
- package/useJwt.d.cts +0 -27
- package/useJwt.d.ts +0 -27
- package/useNProgress.cjs +0 -37
- package/useNProgress.d.cts +0 -20
- package/useNProgress.d.ts +0 -20
- package/useQRCode.cjs +0 -21
- package/useQRCode.d.cts +0 -14
- package/useQRCode.d.ts +0 -14
- package/useSortable/component.cjs +0 -91
- package/useSortable/component.d.cts +0 -40
- package/useSortable/component.d.ts +0 -40
- package/useSortable.cjs +0 -67
- package/useSortable.d.cts +0 -40
- package/useSortable.d.ts +0 -40
package/useIDBKeyval.d.cts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ConfigurableFlush, RemovableRef } from '@vueuse/shared';
|
|
2
|
-
import { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseIDBOptions extends ConfigurableFlush {
|
|
5
|
-
/**
|
|
6
|
-
* Watch for deep changes
|
|
7
|
-
*
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
deep?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* On error callback
|
|
13
|
-
*
|
|
14
|
-
* Default log error to `console.error`
|
|
15
|
-
*/
|
|
16
|
-
onError?: (error: unknown) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Use shallow ref as reference
|
|
19
|
-
*
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
shallow?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Write the default value to the storage when it does not exist
|
|
25
|
-
*
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
writeDefaults?: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface UseIDBKeyvalReturn<T> {
|
|
31
|
-
data: RemovableRef<T>;
|
|
32
|
-
isFinished: ShallowRef<boolean>;
|
|
33
|
-
set: (value: T) => Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param key
|
|
38
|
-
* @param initialValue
|
|
39
|
-
* @param options
|
|
40
|
-
*/
|
|
41
|
-
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions): UseIDBKeyvalReturn<T>;
|
|
42
|
-
|
|
43
|
-
export { type UseIDBKeyvalReturn, type UseIDBOptions, useIDBKeyval };
|
package/useIDBKeyval.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ConfigurableFlush, RemovableRef } from '@vueuse/shared';
|
|
2
|
-
import { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseIDBOptions extends ConfigurableFlush {
|
|
5
|
-
/**
|
|
6
|
-
* Watch for deep changes
|
|
7
|
-
*
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
deep?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* On error callback
|
|
13
|
-
*
|
|
14
|
-
* Default log error to `console.error`
|
|
15
|
-
*/
|
|
16
|
-
onError?: (error: unknown) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Use shallow ref as reference
|
|
19
|
-
*
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
shallow?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Write the default value to the storage when it does not exist
|
|
25
|
-
*
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
writeDefaults?: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface UseIDBKeyvalReturn<T> {
|
|
31
|
-
data: RemovableRef<T>;
|
|
32
|
-
isFinished: ShallowRef<boolean>;
|
|
33
|
-
set: (value: T) => Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param key
|
|
38
|
-
* @param initialValue
|
|
39
|
-
* @param options
|
|
40
|
-
*/
|
|
41
|
-
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions): UseIDBKeyvalReturn<T>;
|
|
42
|
-
|
|
43
|
-
export { type UseIDBKeyvalReturn, type UseIDBOptions, useIDBKeyval };
|
package/useJwt.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jwtDecode = require('jwt-decode');
|
|
4
|
-
var vue = require('vue');
|
|
5
|
-
|
|
6
|
-
function useJwt(encodedJwt, options = {}) {
|
|
7
|
-
const {
|
|
8
|
-
onError,
|
|
9
|
-
fallbackValue = null
|
|
10
|
-
} = options;
|
|
11
|
-
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
12
|
-
try {
|
|
13
|
-
return jwtDecode.jwtDecode(encodedJwt2, options2);
|
|
14
|
-
} catch (err) {
|
|
15
|
-
onError == null ? void 0 : onError(err);
|
|
16
|
-
return fallbackValue;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const header = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt), { header: true }));
|
|
20
|
-
const payload = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt)));
|
|
21
|
-
return {
|
|
22
|
-
header,
|
|
23
|
-
payload
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.useJwt = useJwt;
|
package/useJwt.d.cts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
2
|
-
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseJwtOptions<Fallback> {
|
|
5
|
-
/**
|
|
6
|
-
* Value returned when encounter error on decoding
|
|
7
|
-
*
|
|
8
|
-
* @default null
|
|
9
|
-
*/
|
|
10
|
-
fallbackValue?: Fallback;
|
|
11
|
-
/**
|
|
12
|
-
* Error callback for decoding
|
|
13
|
-
*/
|
|
14
|
-
onError?: (error: unknown) => void;
|
|
15
|
-
}
|
|
16
|
-
interface UseJwtReturn<Payload, Header, Fallback> {
|
|
17
|
-
header: ComputedRef<Header | Fallback>;
|
|
18
|
-
payload: ComputedRef<Payload | Fallback>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Reactive decoded jwt token.
|
|
22
|
-
*
|
|
23
|
-
* @see https://vueuse.org/useJwt
|
|
24
|
-
*/
|
|
25
|
-
declare function useJwt<Payload extends object = JwtPayload, Header extends object = JwtHeader, Fallback = null>(encodedJwt: MaybeRefOrGetter<string>, options?: UseJwtOptions<Fallback>): UseJwtReturn<Payload, Header, Fallback>;
|
|
26
|
-
|
|
27
|
-
export { type UseJwtOptions, type UseJwtReturn, useJwt };
|
package/useJwt.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
2
|
-
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
-
|
|
4
|
-
interface UseJwtOptions<Fallback> {
|
|
5
|
-
/**
|
|
6
|
-
* Value returned when encounter error on decoding
|
|
7
|
-
*
|
|
8
|
-
* @default null
|
|
9
|
-
*/
|
|
10
|
-
fallbackValue?: Fallback;
|
|
11
|
-
/**
|
|
12
|
-
* Error callback for decoding
|
|
13
|
-
*/
|
|
14
|
-
onError?: (error: unknown) => void;
|
|
15
|
-
}
|
|
16
|
-
interface UseJwtReturn<Payload, Header, Fallback> {
|
|
17
|
-
header: ComputedRef<Header | Fallback>;
|
|
18
|
-
payload: ComputedRef<Payload | Fallback>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Reactive decoded jwt token.
|
|
22
|
-
*
|
|
23
|
-
* @see https://vueuse.org/useJwt
|
|
24
|
-
*/
|
|
25
|
-
declare function useJwt<Payload extends object = JwtPayload, Header extends object = JwtHeader, Fallback = null>(encodedJwt: MaybeRefOrGetter<string>, options?: UseJwtOptions<Fallback>): UseJwtReturn<Payload, Header, Fallback>;
|
|
26
|
-
|
|
27
|
-
export { type UseJwtOptions, type UseJwtReturn, useJwt };
|
package/useNProgress.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var shared = require('@vueuse/shared');
|
|
4
|
-
var nprogress = require('nprogress');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
function useNProgress(currentProgress = null, options) {
|
|
8
|
-
const progress = shared.toRef(currentProgress);
|
|
9
|
-
const isLoading = vue.computed({
|
|
10
|
-
set: (load) => load ? nprogress.start() : nprogress.done(),
|
|
11
|
-
get: () => typeof progress.value === "number" && progress.value < 1
|
|
12
|
-
});
|
|
13
|
-
if (options)
|
|
14
|
-
nprogress.configure(options);
|
|
15
|
-
const setProgress = nprogress.set;
|
|
16
|
-
nprogress.set = (n) => {
|
|
17
|
-
progress.value = n;
|
|
18
|
-
return setProgress.call(nprogress, n);
|
|
19
|
-
};
|
|
20
|
-
vue.watchEffect(() => {
|
|
21
|
-
if (typeof progress.value === "number" && shared.isClient)
|
|
22
|
-
setProgress.call(nprogress, progress.value);
|
|
23
|
-
});
|
|
24
|
-
shared.tryOnScopeDispose(nprogress.remove);
|
|
25
|
-
return {
|
|
26
|
-
isLoading,
|
|
27
|
-
progress,
|
|
28
|
-
start: nprogress.start,
|
|
29
|
-
done: nprogress.done,
|
|
30
|
-
remove: () => {
|
|
31
|
-
progress.value = null;
|
|
32
|
-
nprogress.remove();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.useNProgress = useNProgress;
|
package/useNProgress.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
-
import nprogress, { NProgressOptions } from 'nprogress';
|
|
4
|
-
|
|
5
|
-
type UseNProgressOptions = Partial<NProgressOptions>;
|
|
6
|
-
/**
|
|
7
|
-
* Reactive progress bar.
|
|
8
|
-
*
|
|
9
|
-
* @see https://vueuse.org/useNProgress
|
|
10
|
-
*/
|
|
11
|
-
declare function useNProgress(currentProgress?: MaybeRefOrGetter<number | null | undefined>, options?: UseNProgressOptions): {
|
|
12
|
-
isLoading: vue.WritableComputedRef<boolean, boolean>;
|
|
13
|
-
progress: vue.Ref<number | null | undefined, number | null | undefined>;
|
|
14
|
-
start: () => nprogress.NProgress;
|
|
15
|
-
done: (force?: boolean) => nprogress.NProgress;
|
|
16
|
-
remove: () => void;
|
|
17
|
-
};
|
|
18
|
-
type UseNProgressReturn = ReturnType<typeof useNProgress>;
|
|
19
|
-
|
|
20
|
-
export { type UseNProgressOptions, type UseNProgressReturn, useNProgress };
|
package/useNProgress.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
-
import nprogress, { NProgressOptions } from 'nprogress';
|
|
4
|
-
|
|
5
|
-
type UseNProgressOptions = Partial<NProgressOptions>;
|
|
6
|
-
/**
|
|
7
|
-
* Reactive progress bar.
|
|
8
|
-
*
|
|
9
|
-
* @see https://vueuse.org/useNProgress
|
|
10
|
-
*/
|
|
11
|
-
declare function useNProgress(currentProgress?: MaybeRefOrGetter<number | null | undefined>, options?: UseNProgressOptions): {
|
|
12
|
-
isLoading: vue.WritableComputedRef<boolean, boolean>;
|
|
13
|
-
progress: vue.Ref<number | null | undefined, number | null | undefined>;
|
|
14
|
-
start: () => nprogress.NProgress;
|
|
15
|
-
done: (force?: boolean) => nprogress.NProgress;
|
|
16
|
-
remove: () => void;
|
|
17
|
-
};
|
|
18
|
-
type UseNProgressReturn = ReturnType<typeof useNProgress>;
|
|
19
|
-
|
|
20
|
-
export { type UseNProgressOptions, type UseNProgressReturn, useNProgress };
|
package/useQRCode.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var shared = require('@vueuse/shared');
|
|
4
|
-
var QRCode = require('qrcode');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
function useQRCode(text, options) {
|
|
8
|
-
const src = shared.toRef(text);
|
|
9
|
-
const result = vue.shallowRef("");
|
|
10
|
-
vue.watch(
|
|
11
|
-
src,
|
|
12
|
-
async (value) => {
|
|
13
|
-
if (src.value && shared.isClient)
|
|
14
|
-
result.value = await QRCode.toDataURL(value, options);
|
|
15
|
-
},
|
|
16
|
-
{ immediate: true }
|
|
17
|
-
);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.useQRCode = useQRCode;
|
package/useQRCode.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
-
import QRCode from 'qrcode';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Wrapper for qrcode.
|
|
7
|
-
*
|
|
8
|
-
* @see https://vueuse.org/useQRCode
|
|
9
|
-
* @param text
|
|
10
|
-
* @param options
|
|
11
|
-
*/
|
|
12
|
-
declare function useQRCode(text: MaybeRefOrGetter<string>, options?: QRCode.QRCodeToDataURLOptions): vue.ShallowRef<string, string>;
|
|
13
|
-
|
|
14
|
-
export { useQRCode };
|
package/useQRCode.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
-
import QRCode from 'qrcode';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Wrapper for qrcode.
|
|
7
|
-
*
|
|
8
|
-
* @see https://vueuse.org/useQRCode
|
|
9
|
-
* @param text
|
|
10
|
-
* @param options
|
|
11
|
-
*/
|
|
12
|
-
declare function useQRCode(text: MaybeRefOrGetter<string>, options?: QRCode.QRCodeToDataURLOptions): vue.ShallowRef<string, string>;
|
|
13
|
-
|
|
14
|
-
export { useQRCode };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@vueuse/core');
|
|
4
|
-
var vue = require('vue');
|
|
5
|
-
var Sortable = require('sortablejs');
|
|
6
|
-
|
|
7
|
-
function useSortable(el, list, options = {}) {
|
|
8
|
-
let sortable;
|
|
9
|
-
const { document = core.defaultDocument, ...resetOptions } = options;
|
|
10
|
-
const defaultOptions = {
|
|
11
|
-
onUpdate: (e) => {
|
|
12
|
-
moveArrayElement(list, e.oldIndex, e.newIndex, e);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const start = () => {
|
|
16
|
-
const target = typeof el === "string" ? document?.querySelector(el) : core.unrefElement(el);
|
|
17
|
-
if (!target || sortable !== void 0)
|
|
18
|
-
return;
|
|
19
|
-
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
20
|
-
};
|
|
21
|
-
const stop = () => {
|
|
22
|
-
sortable?.destroy();
|
|
23
|
-
sortable = void 0;
|
|
24
|
-
};
|
|
25
|
-
const option = (name, value) => {
|
|
26
|
-
if (value !== void 0)
|
|
27
|
-
sortable?.option(name, value);
|
|
28
|
-
else
|
|
29
|
-
return sortable?.option(name);
|
|
30
|
-
};
|
|
31
|
-
core.tryOnMounted(start);
|
|
32
|
-
core.tryOnScopeDispose(stop);
|
|
33
|
-
return {
|
|
34
|
-
stop,
|
|
35
|
-
start,
|
|
36
|
-
option
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function insertNodeAt(parentElement, element, index) {
|
|
40
|
-
const refElement = parentElement.children[index];
|
|
41
|
-
parentElement.insertBefore(element, refElement);
|
|
42
|
-
}
|
|
43
|
-
function removeNode(node) {
|
|
44
|
-
if (node.parentNode)
|
|
45
|
-
node.parentNode.removeChild(node);
|
|
46
|
-
}
|
|
47
|
-
function moveArrayElement(list, from, to, e = null) {
|
|
48
|
-
if (e != null) {
|
|
49
|
-
removeNode(e.item);
|
|
50
|
-
insertNodeAt(e.from, e.item, from);
|
|
51
|
-
}
|
|
52
|
-
const _valueIsRef = vue.isRef(list);
|
|
53
|
-
const array = _valueIsRef ? [...vue.toValue(list)] : vue.toValue(list);
|
|
54
|
-
if (to >= 0 && to < array.length) {
|
|
55
|
-
const element = array.splice(from, 1)[0];
|
|
56
|
-
vue.nextTick(() => {
|
|
57
|
-
array.splice(to, 0, element);
|
|
58
|
-
if (_valueIsRef)
|
|
59
|
-
list.value = array;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const UseSortable = /* @__PURE__ */ /*@__PURE__*/ vue.defineComponent({
|
|
65
|
-
name: "UseSortable",
|
|
66
|
-
props: {
|
|
67
|
-
modelValue: {
|
|
68
|
-
type: Array,
|
|
69
|
-
required: true
|
|
70
|
-
},
|
|
71
|
-
tag: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: "div"
|
|
74
|
-
},
|
|
75
|
-
options: {
|
|
76
|
-
type: Object,
|
|
77
|
-
required: true
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
setup(props, { slots }) {
|
|
81
|
-
const list = core.useVModel(props, "modelValue");
|
|
82
|
-
const target = vue.ref();
|
|
83
|
-
const data = vue.reactive(useSortable(target, list, props.options));
|
|
84
|
-
return () => {
|
|
85
|
-
if (slots.default)
|
|
86
|
-
return vue.h(props.tag, { ref: target }, slots.default(data));
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
exports.UseSortable = UseSortable;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType } from 'vue';
|
|
3
|
-
import { ConfigurableDocument } from '@vueuse/core';
|
|
4
|
-
import { Options } from 'sortablejs';
|
|
5
|
-
|
|
6
|
-
type UseSortableOptions = Options & ConfigurableDocument;
|
|
7
|
-
|
|
8
|
-
declare const UseSortable: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
9
|
-
modelValue: {
|
|
10
|
-
type: PropType<any[]>;
|
|
11
|
-
required: true;
|
|
12
|
-
};
|
|
13
|
-
tag: {
|
|
14
|
-
type: StringConstructor;
|
|
15
|
-
default: string;
|
|
16
|
-
};
|
|
17
|
-
options: {
|
|
18
|
-
type: PropType<UseSortableOptions>;
|
|
19
|
-
required: true;
|
|
20
|
-
};
|
|
21
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}> | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: PropType<any[]>;
|
|
26
|
-
required: true;
|
|
27
|
-
};
|
|
28
|
-
tag: {
|
|
29
|
-
type: StringConstructor;
|
|
30
|
-
default: string;
|
|
31
|
-
};
|
|
32
|
-
options: {
|
|
33
|
-
type: PropType<UseSortableOptions>;
|
|
34
|
-
required: true;
|
|
35
|
-
};
|
|
36
|
-
}>> & Readonly<{}>, {
|
|
37
|
-
tag: string;
|
|
38
|
-
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
39
|
-
|
|
40
|
-
export { UseSortable };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType } from 'vue';
|
|
3
|
-
import { ConfigurableDocument } from '@vueuse/core';
|
|
4
|
-
import { Options } from 'sortablejs';
|
|
5
|
-
|
|
6
|
-
type UseSortableOptions = Options & ConfigurableDocument;
|
|
7
|
-
|
|
8
|
-
declare const UseSortable: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
9
|
-
modelValue: {
|
|
10
|
-
type: PropType<any[]>;
|
|
11
|
-
required: true;
|
|
12
|
-
};
|
|
13
|
-
tag: {
|
|
14
|
-
type: StringConstructor;
|
|
15
|
-
default: string;
|
|
16
|
-
};
|
|
17
|
-
options: {
|
|
18
|
-
type: PropType<UseSortableOptions>;
|
|
19
|
-
required: true;
|
|
20
|
-
};
|
|
21
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}> | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: PropType<any[]>;
|
|
26
|
-
required: true;
|
|
27
|
-
};
|
|
28
|
-
tag: {
|
|
29
|
-
type: StringConstructor;
|
|
30
|
-
default: string;
|
|
31
|
-
};
|
|
32
|
-
options: {
|
|
33
|
-
type: PropType<UseSortableOptions>;
|
|
34
|
-
required: true;
|
|
35
|
-
};
|
|
36
|
-
}>> & Readonly<{}>, {
|
|
37
|
-
tag: string;
|
|
38
|
-
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
39
|
-
|
|
40
|
-
export { UseSortable };
|
package/useSortable.cjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@vueuse/core');
|
|
4
|
-
var Sortable = require('sortablejs');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
function useSortable(el, list, options = {}) {
|
|
8
|
-
let sortable;
|
|
9
|
-
const { document = core.defaultDocument, ...resetOptions } = options;
|
|
10
|
-
const defaultOptions = {
|
|
11
|
-
onUpdate: (e) => {
|
|
12
|
-
moveArrayElement(list, e.oldIndex, e.newIndex, e);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const start = () => {
|
|
16
|
-
const target = typeof el === "string" ? document == null ? void 0 : document.querySelector(el) : core.unrefElement(el);
|
|
17
|
-
if (!target || sortable !== void 0)
|
|
18
|
-
return;
|
|
19
|
-
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
20
|
-
};
|
|
21
|
-
const stop = () => {
|
|
22
|
-
sortable == null ? void 0 : sortable.destroy();
|
|
23
|
-
sortable = void 0;
|
|
24
|
-
};
|
|
25
|
-
const option = (name, value) => {
|
|
26
|
-
if (value !== void 0)
|
|
27
|
-
sortable == null ? void 0 : sortable.option(name, value);
|
|
28
|
-
else
|
|
29
|
-
return sortable == null ? void 0 : sortable.option(name);
|
|
30
|
-
};
|
|
31
|
-
core.tryOnMounted(start);
|
|
32
|
-
core.tryOnScopeDispose(stop);
|
|
33
|
-
return {
|
|
34
|
-
stop,
|
|
35
|
-
start,
|
|
36
|
-
option
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function insertNodeAt(parentElement, element, index) {
|
|
40
|
-
const refElement = parentElement.children[index];
|
|
41
|
-
parentElement.insertBefore(element, refElement);
|
|
42
|
-
}
|
|
43
|
-
function removeNode(node) {
|
|
44
|
-
if (node.parentNode)
|
|
45
|
-
node.parentNode.removeChild(node);
|
|
46
|
-
}
|
|
47
|
-
function moveArrayElement(list, from, to, e = null) {
|
|
48
|
-
if (e != null) {
|
|
49
|
-
removeNode(e.item);
|
|
50
|
-
insertNodeAt(e.from, e.item, from);
|
|
51
|
-
}
|
|
52
|
-
const _valueIsRef = vue.isRef(list);
|
|
53
|
-
const array = _valueIsRef ? [...vue.toValue(list)] : vue.toValue(list);
|
|
54
|
-
if (to >= 0 && to < array.length) {
|
|
55
|
-
const element = array.splice(from, 1)[0];
|
|
56
|
-
vue.nextTick(() => {
|
|
57
|
-
array.splice(to, 0, element);
|
|
58
|
-
if (_valueIsRef)
|
|
59
|
-
list.value = array;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exports.insertNodeAt = insertNodeAt;
|
|
65
|
-
exports.moveArrayElement = moveArrayElement;
|
|
66
|
-
exports.removeNode = removeNode;
|
|
67
|
-
exports.useSortable = useSortable;
|
package/useSortable.d.cts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ConfigurableDocument } from '@vueuse/core';
|
|
2
|
-
import Sortable, { Options } from 'sortablejs';
|
|
3
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
4
|
-
|
|
5
|
-
interface UseSortableReturn {
|
|
6
|
-
/**
|
|
7
|
-
* start sortable instance
|
|
8
|
-
*/
|
|
9
|
-
start: () => void;
|
|
10
|
-
/**
|
|
11
|
-
* destroy sortable instance
|
|
12
|
-
*/
|
|
13
|
-
stop: () => void;
|
|
14
|
-
/**
|
|
15
|
-
* Options getter/setter
|
|
16
|
-
* @param name a Sortable.Options property.
|
|
17
|
-
* @param value a value.
|
|
18
|
-
*/
|
|
19
|
-
option: (<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]) => void) & (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K]);
|
|
20
|
-
}
|
|
21
|
-
type UseSortableOptions = Options & ConfigurableDocument;
|
|
22
|
-
declare function useSortable<T>(selector: string, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
23
|
-
declare function useSortable<T>(el: MaybeRefOrGetter<HTMLElement | null | undefined>, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
24
|
-
/**
|
|
25
|
-
* Inserts a element into the DOM at a given index.
|
|
26
|
-
* @param parentElement
|
|
27
|
-
* @param element
|
|
28
|
-
* @param {number} index
|
|
29
|
-
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L81C1-L94C2
|
|
30
|
-
*/
|
|
31
|
-
declare function insertNodeAt(parentElement: Element, element: Element, index: number): void;
|
|
32
|
-
/**
|
|
33
|
-
* Removes a node from the DOM.
|
|
34
|
-
* @param {Node} node
|
|
35
|
-
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L96C1-L102C2
|
|
36
|
-
*/
|
|
37
|
-
declare function removeNode(node: Node): void;
|
|
38
|
-
declare function moveArrayElement<T>(list: MaybeRefOrGetter<T[]>, from: number, to: number, e?: Sortable.SortableEvent | null): void;
|
|
39
|
-
|
|
40
|
-
export { type UseSortableOptions, type UseSortableReturn, insertNodeAt, moveArrayElement, removeNode, useSortable };
|
package/useSortable.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ConfigurableDocument } from '@vueuse/core';
|
|
2
|
-
import Sortable, { Options } from 'sortablejs';
|
|
3
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
4
|
-
|
|
5
|
-
interface UseSortableReturn {
|
|
6
|
-
/**
|
|
7
|
-
* start sortable instance
|
|
8
|
-
*/
|
|
9
|
-
start: () => void;
|
|
10
|
-
/**
|
|
11
|
-
* destroy sortable instance
|
|
12
|
-
*/
|
|
13
|
-
stop: () => void;
|
|
14
|
-
/**
|
|
15
|
-
* Options getter/setter
|
|
16
|
-
* @param name a Sortable.Options property.
|
|
17
|
-
* @param value a value.
|
|
18
|
-
*/
|
|
19
|
-
option: (<K extends keyof Sortable.Options>(name: K, value: Sortable.Options[K]) => void) & (<K extends keyof Sortable.Options>(name: K) => Sortable.Options[K]);
|
|
20
|
-
}
|
|
21
|
-
type UseSortableOptions = Options & ConfigurableDocument;
|
|
22
|
-
declare function useSortable<T>(selector: string, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
23
|
-
declare function useSortable<T>(el: MaybeRefOrGetter<HTMLElement | null | undefined>, list: MaybeRefOrGetter<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
24
|
-
/**
|
|
25
|
-
* Inserts a element into the DOM at a given index.
|
|
26
|
-
* @param parentElement
|
|
27
|
-
* @param element
|
|
28
|
-
* @param {number} index
|
|
29
|
-
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L81C1-L94C2
|
|
30
|
-
*/
|
|
31
|
-
declare function insertNodeAt(parentElement: Element, element: Element, index: number): void;
|
|
32
|
-
/**
|
|
33
|
-
* Removes a node from the DOM.
|
|
34
|
-
* @param {Node} node
|
|
35
|
-
* @see https://github.com/Alfred-Skyblue/vue-draggable-plus/blob/a3829222095e1949bf2c9a20979d7b5930e66f14/src/utils/index.ts#L96C1-L102C2
|
|
36
|
-
*/
|
|
37
|
-
declare function removeNode(node: Node): void;
|
|
38
|
-
declare function moveArrayElement<T>(list: MaybeRefOrGetter<T[]>, from: number, to: number, e?: Sortable.SortableEvent | null): void;
|
|
39
|
-
|
|
40
|
-
export { type UseSortableOptions, type UseSortableReturn, insertNodeAt, moveArrayElement, removeNode, useSortable };
|