@vueuse/integrations 12.0.0 → 12.2.0-beta.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.
- package/README.md +2 -2
- package/package.json +36 -6
- package/useAsyncValidator/component.cjs +0 -89
- package/useAsyncValidator/component.d.cts +0 -27
- package/useAsyncValidator/component.d.mts +0 -27
- package/useAsyncValidator/component.d.ts +0 -27
- package/useAsyncValidator/component.mjs +0 -87
- package/useFocusTrap/component.cjs +0 -33
- package/useFocusTrap/component.d.cts +0 -17
- package/useFocusTrap/component.d.mts +0 -17
- package/useFocusTrap/component.d.ts +0 -17
- package/useFocusTrap/component.mjs +0 -31
- package/useSortable/component.cjs +0 -91
- package/useSortable/component.d.cts +0 -40
- package/useSortable/component.d.mts +0 -40
- package/useSortable/component.d.ts +0 -40
- package/useSortable/component.mjs +0 -89
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ npm i @vueuse/integrations
|
|
|
35
35
|
For better tree-shaking result, import functions from submodules, for example:
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import { useAxios } from '@vueuse/integrations/useAxios'
|
|
39
|
-
|
|
40
38
|
// Don't
|
|
41
39
|
import { useAxios } from '@vueuse/integrations'
|
|
40
|
+
|
|
41
|
+
import { useAxios } from '@vueuse/integrations/useAxios'
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "12.2.0-beta.3",
|
|
4
5
|
"description": "Integration wrappers for utility libraries",
|
|
5
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
7
|
"license": "MIT",
|
|
@@ -91,7 +92,16 @@
|
|
|
91
92
|
"module": "./index.mjs",
|
|
92
93
|
"unpkg": "./index.iife.min.js",
|
|
93
94
|
"jsdelivr": "./index.iife.min.js",
|
|
94
|
-
"types": "./index.d.
|
|
95
|
+
"types": "./index.d.ts",
|
|
96
|
+
"files": [
|
|
97
|
+
"*.cjs",
|
|
98
|
+
"*.d.cts",
|
|
99
|
+
"*.d.mts",
|
|
100
|
+
"*.d.ts",
|
|
101
|
+
"*.js",
|
|
102
|
+
"*.mjs",
|
|
103
|
+
"index.json"
|
|
104
|
+
],
|
|
95
105
|
"peerDependencies": {
|
|
96
106
|
"async-validator": "^4",
|
|
97
107
|
"axios": "^1",
|
|
@@ -145,8 +155,28 @@
|
|
|
145
155
|
}
|
|
146
156
|
},
|
|
147
157
|
"dependencies": {
|
|
148
|
-
"
|
|
149
|
-
"@vueuse/
|
|
150
|
-
"
|
|
158
|
+
"vue": "^3.5.13",
|
|
159
|
+
"@vueuse/core": "12.2.0-beta.3",
|
|
160
|
+
"@vueuse/shared": "12.2.0-beta.3"
|
|
161
|
+
},
|
|
162
|
+
"devDependencies": {
|
|
163
|
+
"@types/nprogress": "^0.2.3",
|
|
164
|
+
"@types/qrcode": "^1.5.5",
|
|
165
|
+
"@types/sortablejs": "^1.15.8",
|
|
166
|
+
"async-validator": "^4.2.5",
|
|
167
|
+
"axios": "^1.7.9",
|
|
168
|
+
"change-case": "^5.4.4",
|
|
169
|
+
"drauu": "^0.4.2",
|
|
170
|
+
"focus-trap": "^7.6.2",
|
|
171
|
+
"fuse.js": "^7.0.0",
|
|
172
|
+
"idb-keyval": "^6.2.1",
|
|
173
|
+
"jwt-decode": "^4.0.0",
|
|
174
|
+
"nprogress": "^0.2.0",
|
|
175
|
+
"qrcode": "^1.5.4",
|
|
176
|
+
"sortablejs": "^1.15.6",
|
|
177
|
+
"universal-cookie": "^7.2.2"
|
|
178
|
+
},
|
|
179
|
+
"scripts": {
|
|
180
|
+
"build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild"
|
|
151
181
|
}
|
|
152
|
-
}
|
|
182
|
+
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var vue = require('vue');
|
|
4
|
-
var shared = require('@vueuse/shared');
|
|
5
|
-
var Schema = require('async-validator');
|
|
6
|
-
|
|
7
|
-
const AsyncValidatorSchema = Schema.default || Schema;
|
|
8
|
-
function useAsyncValidator(value, rules, options = {}) {
|
|
9
|
-
const {
|
|
10
|
-
validateOption = {},
|
|
11
|
-
immediate = true,
|
|
12
|
-
manual = false
|
|
13
|
-
} = options;
|
|
14
|
-
const valueRef = shared.toRef(value);
|
|
15
|
-
const errorInfo = vue.shallowRef(null);
|
|
16
|
-
const isFinished = vue.ref(true);
|
|
17
|
-
const pass = vue.ref(!immediate || manual);
|
|
18
|
-
const errors = vue.computed(() => errorInfo.value?.errors || []);
|
|
19
|
-
const errorFields = vue.computed(() => errorInfo.value?.fields || {});
|
|
20
|
-
const validator = vue.computed(() => new AsyncValidatorSchema(shared.toValue(rules)));
|
|
21
|
-
const execute = async () => {
|
|
22
|
-
isFinished.value = false;
|
|
23
|
-
pass.value = false;
|
|
24
|
-
try {
|
|
25
|
-
await validator.value.validate(valueRef.value, validateOption);
|
|
26
|
-
pass.value = true;
|
|
27
|
-
errorInfo.value = null;
|
|
28
|
-
} catch (err) {
|
|
29
|
-
errorInfo.value = err;
|
|
30
|
-
} finally {
|
|
31
|
-
isFinished.value = true;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
pass: pass.value,
|
|
35
|
-
errorInfo: errorInfo.value,
|
|
36
|
-
errors: errors.value,
|
|
37
|
-
errorFields: errorFields.value
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
if (!manual) {
|
|
41
|
-
vue.watch(
|
|
42
|
-
[valueRef, validator],
|
|
43
|
-
() => execute(),
|
|
44
|
-
{ immediate, deep: true }
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
const shell = {
|
|
48
|
-
isFinished,
|
|
49
|
-
pass,
|
|
50
|
-
errors,
|
|
51
|
-
errorInfo,
|
|
52
|
-
errorFields,
|
|
53
|
-
execute
|
|
54
|
-
};
|
|
55
|
-
function waitUntilFinished() {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
shared.until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
...shell,
|
|
62
|
-
then(onFulfilled, onRejected) {
|
|
63
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const UseAsyncValidator = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
69
|
-
name: "UseAsyncValidator",
|
|
70
|
-
props: {
|
|
71
|
-
form: {
|
|
72
|
-
type: Object,
|
|
73
|
-
required: true
|
|
74
|
-
},
|
|
75
|
-
rules: {
|
|
76
|
-
type: Object,
|
|
77
|
-
required: true
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
setup(props, { slots }) {
|
|
81
|
-
const data = vue.reactive(useAsyncValidator(props.form, props.rules));
|
|
82
|
-
return () => {
|
|
83
|
-
if (slots.default)
|
|
84
|
-
return slots.default(data);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
exports.UseAsyncValidator = UseAsyncValidator;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType } from 'vue';
|
|
3
|
-
import { Rules } from 'async-validator';
|
|
4
|
-
|
|
5
|
-
declare const UseAsyncValidator: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
6
|
-
form: {
|
|
7
|
-
type: PropType<Record<string, any>>;
|
|
8
|
-
required: true;
|
|
9
|
-
};
|
|
10
|
-
rules: {
|
|
11
|
-
type: PropType<Rules>;
|
|
12
|
-
required: true;
|
|
13
|
-
};
|
|
14
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
17
|
-
form: {
|
|
18
|
-
type: PropType<Record<string, any>>;
|
|
19
|
-
required: true;
|
|
20
|
-
};
|
|
21
|
-
rules: {
|
|
22
|
-
type: PropType<Rules>;
|
|
23
|
-
required: true;
|
|
24
|
-
};
|
|
25
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
26
|
-
|
|
27
|
-
export { UseAsyncValidator };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType } from 'vue';
|
|
3
|
-
import { Rules } from 'async-validator';
|
|
4
|
-
|
|
5
|
-
declare const UseAsyncValidator: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
6
|
-
form: {
|
|
7
|
-
type: PropType<Record<string, any>>;
|
|
8
|
-
required: true;
|
|
9
|
-
};
|
|
10
|
-
rules: {
|
|
11
|
-
type: PropType<Rules>;
|
|
12
|
-
required: true;
|
|
13
|
-
};
|
|
14
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
17
|
-
form: {
|
|
18
|
-
type: PropType<Record<string, any>>;
|
|
19
|
-
required: true;
|
|
20
|
-
};
|
|
21
|
-
rules: {
|
|
22
|
-
type: PropType<Rules>;
|
|
23
|
-
required: true;
|
|
24
|
-
};
|
|
25
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
26
|
-
|
|
27
|
-
export { UseAsyncValidator };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { PropType } from 'vue';
|
|
3
|
-
import { Rules } from 'async-validator';
|
|
4
|
-
|
|
5
|
-
declare const UseAsyncValidator: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
6
|
-
form: {
|
|
7
|
-
type: PropType<Record<string, any>>;
|
|
8
|
-
required: true;
|
|
9
|
-
};
|
|
10
|
-
rules: {
|
|
11
|
-
type: PropType<Rules>;
|
|
12
|
-
required: true;
|
|
13
|
-
};
|
|
14
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
17
|
-
form: {
|
|
18
|
-
type: PropType<Record<string, any>>;
|
|
19
|
-
required: true;
|
|
20
|
-
};
|
|
21
|
-
rules: {
|
|
22
|
-
type: PropType<Rules>;
|
|
23
|
-
required: true;
|
|
24
|
-
};
|
|
25
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
26
|
-
|
|
27
|
-
export { UseAsyncValidator };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { shallowRef, ref, computed, watch, defineComponent, reactive } from 'vue';
|
|
2
|
-
import { toRef, toValue, until } from '@vueuse/shared';
|
|
3
|
-
import Schema from 'async-validator';
|
|
4
|
-
|
|
5
|
-
const AsyncValidatorSchema = Schema.default || Schema;
|
|
6
|
-
function useAsyncValidator(value, rules, options = {}) {
|
|
7
|
-
const {
|
|
8
|
-
validateOption = {},
|
|
9
|
-
immediate = true,
|
|
10
|
-
manual = false
|
|
11
|
-
} = options;
|
|
12
|
-
const valueRef = toRef(value);
|
|
13
|
-
const errorInfo = shallowRef(null);
|
|
14
|
-
const isFinished = ref(true);
|
|
15
|
-
const pass = ref(!immediate || manual);
|
|
16
|
-
const errors = computed(() => errorInfo.value?.errors || []);
|
|
17
|
-
const errorFields = computed(() => errorInfo.value?.fields || {});
|
|
18
|
-
const validator = computed(() => new AsyncValidatorSchema(toValue(rules)));
|
|
19
|
-
const execute = async () => {
|
|
20
|
-
isFinished.value = false;
|
|
21
|
-
pass.value = false;
|
|
22
|
-
try {
|
|
23
|
-
await validator.value.validate(valueRef.value, validateOption);
|
|
24
|
-
pass.value = true;
|
|
25
|
-
errorInfo.value = null;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
errorInfo.value = err;
|
|
28
|
-
} finally {
|
|
29
|
-
isFinished.value = true;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
pass: pass.value,
|
|
33
|
-
errorInfo: errorInfo.value,
|
|
34
|
-
errors: errors.value,
|
|
35
|
-
errorFields: errorFields.value
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
if (!manual) {
|
|
39
|
-
watch(
|
|
40
|
-
[valueRef, validator],
|
|
41
|
-
() => execute(),
|
|
42
|
-
{ immediate, deep: true }
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
const shell = {
|
|
46
|
-
isFinished,
|
|
47
|
-
pass,
|
|
48
|
-
errors,
|
|
49
|
-
errorInfo,
|
|
50
|
-
errorFields,
|
|
51
|
-
execute
|
|
52
|
-
};
|
|
53
|
-
function waitUntilFinished() {
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
...shell,
|
|
60
|
-
then(onFulfilled, onRejected) {
|
|
61
|
-
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const UseAsyncValidator = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
67
|
-
name: "UseAsyncValidator",
|
|
68
|
-
props: {
|
|
69
|
-
form: {
|
|
70
|
-
type: Object,
|
|
71
|
-
required: true
|
|
72
|
-
},
|
|
73
|
-
rules: {
|
|
74
|
-
type: Object,
|
|
75
|
-
required: true
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
setup(props, { slots }) {
|
|
79
|
-
const data = reactive(useAsyncValidator(props.form, props.rules));
|
|
80
|
-
return () => {
|
|
81
|
-
if (slots.default)
|
|
82
|
-
return slots.default(data);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export { UseAsyncValidator };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@vueuse/core');
|
|
4
|
-
var focusTrap = require('focus-trap');
|
|
5
|
-
var vue = require('vue');
|
|
6
|
-
|
|
7
|
-
const UseFocusTrap = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
8
|
-
name: "UseFocusTrap",
|
|
9
|
-
props: ["as", "options"],
|
|
10
|
-
setup(props, { slots }) {
|
|
11
|
-
let trap;
|
|
12
|
-
const target = vue.ref();
|
|
13
|
-
const activate = () => trap && trap.activate();
|
|
14
|
-
const deactivate = () => trap && trap.deactivate();
|
|
15
|
-
vue.watch(
|
|
16
|
-
() => core.unrefElement(target),
|
|
17
|
-
(el) => {
|
|
18
|
-
if (!el)
|
|
19
|
-
return;
|
|
20
|
-
trap = focusTrap.createFocusTrap(el, props.options || {});
|
|
21
|
-
activate();
|
|
22
|
-
},
|
|
23
|
-
{ flush: "post" }
|
|
24
|
-
);
|
|
25
|
-
vue.onScopeDispose(() => deactivate());
|
|
26
|
-
return () => {
|
|
27
|
-
if (slots.default)
|
|
28
|
-
return vue.h(props.as || "div", { ref: target }, slots.default());
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
exports.UseFocusTrap = UseFocusTrap;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { RenderableComponent } from '@vueuse/core';
|
|
3
|
-
import { Options } from 'focus-trap';
|
|
4
|
-
|
|
5
|
-
interface UseFocusTrapOptions extends Options {
|
|
6
|
-
/**
|
|
7
|
-
* Immediately activate the trap
|
|
8
|
-
*/
|
|
9
|
-
immediate?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ComponentUseFocusTrapOptions extends RenderableComponent {
|
|
13
|
-
options?: UseFocusTrapOptions;
|
|
14
|
-
}
|
|
15
|
-
declare const UseFocusTrap: vue.DefineComponent<ComponentUseFocusTrapOptions, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<ComponentUseFocusTrapOptions> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
16
|
-
|
|
17
|
-
export { type ComponentUseFocusTrapOptions, UseFocusTrap };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { RenderableComponent } from '@vueuse/core';
|
|
3
|
-
import { Options } from 'focus-trap';
|
|
4
|
-
|
|
5
|
-
interface UseFocusTrapOptions extends Options {
|
|
6
|
-
/**
|
|
7
|
-
* Immediately activate the trap
|
|
8
|
-
*/
|
|
9
|
-
immediate?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ComponentUseFocusTrapOptions extends RenderableComponent {
|
|
13
|
-
options?: UseFocusTrapOptions;
|
|
14
|
-
}
|
|
15
|
-
declare const UseFocusTrap: vue.DefineComponent<ComponentUseFocusTrapOptions, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<ComponentUseFocusTrapOptions> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
16
|
-
|
|
17
|
-
export { type ComponentUseFocusTrapOptions, UseFocusTrap };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { RenderableComponent } from '@vueuse/core';
|
|
3
|
-
import { Options } from 'focus-trap';
|
|
4
|
-
|
|
5
|
-
interface UseFocusTrapOptions extends Options {
|
|
6
|
-
/**
|
|
7
|
-
* Immediately activate the trap
|
|
8
|
-
*/
|
|
9
|
-
immediate?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ComponentUseFocusTrapOptions extends RenderableComponent {
|
|
13
|
-
options?: UseFocusTrapOptions;
|
|
14
|
-
}
|
|
15
|
-
declare const UseFocusTrap: vue.DefineComponent<ComponentUseFocusTrapOptions, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<ComponentUseFocusTrapOptions> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
16
|
-
|
|
17
|
-
export { type ComponentUseFocusTrapOptions, UseFocusTrap };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { unrefElement } from '@vueuse/core';
|
|
2
|
-
import { createFocusTrap } from 'focus-trap';
|
|
3
|
-
import { defineComponent, ref, watch, onScopeDispose, h } from 'vue';
|
|
4
|
-
|
|
5
|
-
const UseFocusTrap = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
6
|
-
name: "UseFocusTrap",
|
|
7
|
-
props: ["as", "options"],
|
|
8
|
-
setup(props, { slots }) {
|
|
9
|
-
let trap;
|
|
10
|
-
const target = ref();
|
|
11
|
-
const activate = () => trap && trap.activate();
|
|
12
|
-
const deactivate = () => trap && trap.deactivate();
|
|
13
|
-
watch(
|
|
14
|
-
() => unrefElement(target),
|
|
15
|
-
(el) => {
|
|
16
|
-
if (!el)
|
|
17
|
-
return;
|
|
18
|
-
trap = createFocusTrap(el, props.options || {});
|
|
19
|
-
activate();
|
|
20
|
-
},
|
|
21
|
-
{ flush: "post" }
|
|
22
|
-
);
|
|
23
|
-
onScopeDispose(() => deactivate());
|
|
24
|
-
return () => {
|
|
25
|
-
if (slots.default)
|
|
26
|
-
return h(props.as || "div", { ref: target }, slots.default());
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { UseFocusTrap };
|
|
@@ -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 ? [...core.toValue(list)] : core.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 };
|
|
@@ -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,89 +0,0 @@
|
|
|
1
|
-
import { tryOnMounted, tryOnScopeDispose, unrefElement, defaultDocument, toValue, useVModel } from '@vueuse/core';
|
|
2
|
-
import { isRef, nextTick, defineComponent, ref, reactive, h } from 'vue';
|
|
3
|
-
import Sortable from 'sortablejs';
|
|
4
|
-
|
|
5
|
-
function useSortable(el, list, options = {}) {
|
|
6
|
-
let sortable;
|
|
7
|
-
const { document = defaultDocument, ...resetOptions } = options;
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
onUpdate: (e) => {
|
|
10
|
-
moveArrayElement(list, e.oldIndex, e.newIndex, e);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const start = () => {
|
|
14
|
-
const target = typeof el === "string" ? document?.querySelector(el) : unrefElement(el);
|
|
15
|
-
if (!target || sortable !== void 0)
|
|
16
|
-
return;
|
|
17
|
-
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
18
|
-
};
|
|
19
|
-
const stop = () => {
|
|
20
|
-
sortable?.destroy();
|
|
21
|
-
sortable = void 0;
|
|
22
|
-
};
|
|
23
|
-
const option = (name, value) => {
|
|
24
|
-
if (value !== void 0)
|
|
25
|
-
sortable?.option(name, value);
|
|
26
|
-
else
|
|
27
|
-
return sortable?.option(name);
|
|
28
|
-
};
|
|
29
|
-
tryOnMounted(start);
|
|
30
|
-
tryOnScopeDispose(stop);
|
|
31
|
-
return {
|
|
32
|
-
stop,
|
|
33
|
-
start,
|
|
34
|
-
option
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function insertNodeAt(parentElement, element, index) {
|
|
38
|
-
const refElement = parentElement.children[index];
|
|
39
|
-
parentElement.insertBefore(element, refElement);
|
|
40
|
-
}
|
|
41
|
-
function removeNode(node) {
|
|
42
|
-
if (node.parentNode)
|
|
43
|
-
node.parentNode.removeChild(node);
|
|
44
|
-
}
|
|
45
|
-
function moveArrayElement(list, from, to, e = null) {
|
|
46
|
-
if (e != null) {
|
|
47
|
-
removeNode(e.item);
|
|
48
|
-
insertNodeAt(e.from, e.item, from);
|
|
49
|
-
}
|
|
50
|
-
const _valueIsRef = isRef(list);
|
|
51
|
-
const array = _valueIsRef ? [...toValue(list)] : toValue(list);
|
|
52
|
-
if (to >= 0 && to < array.length) {
|
|
53
|
-
const element = array.splice(from, 1)[0];
|
|
54
|
-
nextTick(() => {
|
|
55
|
-
array.splice(to, 0, element);
|
|
56
|
-
if (_valueIsRef)
|
|
57
|
-
list.value = array;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const UseSortable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
63
|
-
name: "UseSortable",
|
|
64
|
-
props: {
|
|
65
|
-
modelValue: {
|
|
66
|
-
type: Array,
|
|
67
|
-
required: true
|
|
68
|
-
},
|
|
69
|
-
tag: {
|
|
70
|
-
type: String,
|
|
71
|
-
default: "div"
|
|
72
|
-
},
|
|
73
|
-
options: {
|
|
74
|
-
type: Object,
|
|
75
|
-
required: true
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
setup(props, { slots }) {
|
|
79
|
-
const list = useVModel(props, "modelValue");
|
|
80
|
-
const target = ref();
|
|
81
|
-
const data = reactive(useSortable(target, list, props.options));
|
|
82
|
-
return () => {
|
|
83
|
-
if (slots.default)
|
|
84
|
-
return h(props.tag, { ref: target }, slots.default(data));
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export { UseSortable };
|