@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
package/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toRef, toValue, until, noop, tryOnScopeDispose, isClient } from '@vueuse/shared';
|
|
2
2
|
import Schema from 'async-validator';
|
|
3
|
-
import { shallowRef, ref, computed, watch, watchEffect, nextTick } from 'vue-demi';
|
|
3
|
+
import { shallowRef, ref, computed, watch, watchEffect, isRef, nextTick } from 'vue-demi';
|
|
4
4
|
import axios, { AxiosError } from 'axios';
|
|
5
5
|
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
|
|
6
6
|
import Cookie from 'universal-cookie';
|
|
7
7
|
import { createDrauu } from 'drauu';
|
|
8
|
-
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1, tryOnMounted, toValue as toValue$1, defaultDocument } from '@vueuse/core';
|
|
8
|
+
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1, watchPausable, tryOnMounted, toValue as toValue$1, defaultDocument } from '@vueuse/core';
|
|
9
9
|
import { createFocusTrap } from 'focus-trap';
|
|
10
10
|
import Fuse from 'fuse.js';
|
|
11
11
|
import { get, set, del, update } from 'idb-keyval';
|
|
@@ -14,25 +14,6 @@ import nprogress from 'nprogress';
|
|
|
14
14
|
import QRCode from 'qrcode';
|
|
15
15
|
import Sortable from 'sortablejs';
|
|
16
16
|
|
|
17
|
-
var __defProp$6 = Object.defineProperty;
|
|
18
|
-
var __defProps$2 = Object.defineProperties;
|
|
19
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
20
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
21
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
22
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
23
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
24
|
-
var __spreadValues$6 = (a, b) => {
|
|
25
|
-
for (var prop in b || (b = {}))
|
|
26
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
27
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
28
|
-
if (__getOwnPropSymbols$6)
|
|
29
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
30
|
-
if (__propIsEnum$6.call(b, prop))
|
|
31
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
32
|
-
}
|
|
33
|
-
return a;
|
|
34
|
-
};
|
|
35
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
36
17
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
37
18
|
function useAsyncValidator(value, rules, options = {}) {
|
|
38
19
|
const {
|
|
@@ -44,14 +25,8 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
44
25
|
const errorInfo = shallowRef(null);
|
|
45
26
|
const isFinished = ref(true);
|
|
46
27
|
const pass = ref(!immediate || manual);
|
|
47
|
-
const errors = computed(() =>
|
|
48
|
-
|
|
49
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
50
|
-
});
|
|
51
|
-
const errorFields = computed(() => {
|
|
52
|
-
var _a;
|
|
53
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
54
|
-
});
|
|
28
|
+
const errors = computed(() => errorInfo.value?.errors || []);
|
|
29
|
+
const errorFields = computed(() => errorInfo.value?.fields || {});
|
|
55
30
|
const validator = computed(() => new AsyncValidatorSchema(toValue(rules)));
|
|
56
31
|
const execute = async () => {
|
|
57
32
|
isFinished.value = false;
|
|
@@ -92,32 +67,14 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
92
67
|
until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
93
68
|
});
|
|
94
69
|
}
|
|
95
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
...shell,
|
|
96
72
|
then(onFulfilled, onRejected) {
|
|
97
73
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
98
74
|
}
|
|
99
|
-
}
|
|
75
|
+
};
|
|
100
76
|
}
|
|
101
77
|
|
|
102
|
-
var __defProp$5 = Object.defineProperty;
|
|
103
|
-
var __defProps$1 = Object.defineProperties;
|
|
104
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
105
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
106
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
107
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
108
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
109
|
-
var __spreadValues$5 = (a, b) => {
|
|
110
|
-
for (var prop in b || (b = {}))
|
|
111
|
-
if (__hasOwnProp$5.call(b, prop))
|
|
112
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
113
|
-
if (__getOwnPropSymbols$5)
|
|
114
|
-
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
115
|
-
if (__propIsEnum$5.call(b, prop))
|
|
116
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
117
|
-
}
|
|
118
|
-
return a;
|
|
119
|
-
};
|
|
120
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
121
78
|
function useAxios(...args) {
|
|
122
79
|
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
123
80
|
const argsPlaceholder = typeof url === "string" ? 1 : 0;
|
|
@@ -127,7 +84,7 @@ function useAxios(...args) {
|
|
|
127
84
|
immediate: !!argsPlaceholder,
|
|
128
85
|
shallow: true
|
|
129
86
|
};
|
|
130
|
-
const isAxiosInstance = (val) => !!
|
|
87
|
+
const isAxiosInstance = (val) => !!val?.request;
|
|
131
88
|
if (args.length > 0 + argsPlaceholder) {
|
|
132
89
|
if (isAxiosInstance(args[0 + argsPlaceholder]))
|
|
133
90
|
instance = args[0 + argsPlaceholder];
|
|
@@ -183,7 +140,7 @@ function useAxios(...args) {
|
|
|
183
140
|
let executeCounter = 0;
|
|
184
141
|
const execute = (executeUrl = url, config = {}) => {
|
|
185
142
|
error.value = void 0;
|
|
186
|
-
const _url = typeof executeUrl === "string" ? executeUrl : url
|
|
143
|
+
const _url = typeof executeUrl === "string" ? executeUrl : url ?? config.url;
|
|
187
144
|
if (_url === void 0) {
|
|
188
145
|
error.value = new AxiosError(AxiosError.ERR_INVALID_URL);
|
|
189
146
|
isFinished.value = true;
|
|
@@ -194,7 +151,7 @@ function useAxios(...args) {
|
|
|
194
151
|
loading(true);
|
|
195
152
|
executeCounter += 1;
|
|
196
153
|
const currentExecuteCounter = executeCounter;
|
|
197
|
-
instance(_url,
|
|
154
|
+
instance(_url, { ...defaultConfig, ...typeof executeUrl === "object" ? executeUrl : config, cancelToken: cancelToken.token }).then((r) => {
|
|
198
155
|
response.value = r;
|
|
199
156
|
const result2 = r.data;
|
|
200
157
|
data.value = result2;
|
|
@@ -203,8 +160,7 @@ function useAxios(...args) {
|
|
|
203
160
|
error.value = e;
|
|
204
161
|
onError(e);
|
|
205
162
|
}).finally(() => {
|
|
206
|
-
|
|
207
|
-
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
163
|
+
options.onFinish?.();
|
|
208
164
|
if (currentExecuteCounter === executeCounter)
|
|
209
165
|
loading(false);
|
|
210
166
|
});
|
|
@@ -224,7 +180,10 @@ function useAxios(...args) {
|
|
|
224
180
|
abort,
|
|
225
181
|
execute
|
|
226
182
|
};
|
|
227
|
-
return
|
|
183
|
+
return {
|
|
184
|
+
...result,
|
|
185
|
+
...promise
|
|
186
|
+
};
|
|
228
187
|
}
|
|
229
188
|
|
|
230
189
|
var changeCase = /*#__PURE__*/Object.freeze({
|
|
@@ -256,22 +215,6 @@ function useChangeCase(input, type, options) {
|
|
|
256
215
|
});
|
|
257
216
|
}
|
|
258
217
|
|
|
259
|
-
var __defProp$4 = Object.defineProperty;
|
|
260
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
261
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
262
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
263
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
264
|
-
var __spreadValues$4 = (a, b) => {
|
|
265
|
-
for (var prop in b || (b = {}))
|
|
266
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
267
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
268
|
-
if (__getOwnPropSymbols$4)
|
|
269
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
270
|
-
if (__propIsEnum$4.call(b, prop))
|
|
271
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
272
|
-
}
|
|
273
|
-
return a;
|
|
274
|
-
};
|
|
275
218
|
function createCookies(req) {
|
|
276
219
|
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
277
220
|
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
@@ -302,14 +245,14 @@ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies =
|
|
|
302
245
|
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
|
|
303
246
|
watchingDependencies.push(args[0]);
|
|
304
247
|
touches.value;
|
|
305
|
-
return cookies.get(args[0],
|
|
248
|
+
return cookies.get(args[0], { doNotParse, ...args[1] });
|
|
306
249
|
},
|
|
307
250
|
/**
|
|
308
251
|
* Reactive get all cookies
|
|
309
252
|
*/
|
|
310
253
|
getAll: (...args) => {
|
|
311
254
|
touches.value;
|
|
312
|
-
return cookies.getAll(
|
|
255
|
+
return cookies.getAll({ doNotParse, ...args[0] });
|
|
313
256
|
},
|
|
314
257
|
set: (...args) => cookies.set(...args),
|
|
315
258
|
remove: (...args) => cookies.remove(...args),
|
|
@@ -327,22 +270,6 @@ function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
|
327
270
|
return false;
|
|
328
271
|
}
|
|
329
272
|
|
|
330
|
-
var __defProp$3 = Object.defineProperty;
|
|
331
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
332
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
333
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
334
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
335
|
-
var __spreadValues$3 = (a, b) => {
|
|
336
|
-
for (var prop in b || (b = {}))
|
|
337
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
338
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
339
|
-
if (__getOwnPropSymbols$3)
|
|
340
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
341
|
-
if (__propIsEnum$3.call(b, prop))
|
|
342
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
343
|
-
}
|
|
344
|
-
return a;
|
|
345
|
-
};
|
|
346
273
|
function useDrauu(target, options) {
|
|
347
274
|
const drauuInstance = ref();
|
|
348
275
|
let disposables = [];
|
|
@@ -371,34 +298,15 @@ function useDrauu(target, options) {
|
|
|
371
298
|
instance.mode = brush.value.mode;
|
|
372
299
|
}
|
|
373
300
|
}, { deep: true });
|
|
374
|
-
const undo = () =>
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
return (_a = drauuInstance.value) == null ? void 0 : _a.redo();
|
|
381
|
-
};
|
|
382
|
-
const clear = () => {
|
|
383
|
-
var _a;
|
|
384
|
-
return (_a = drauuInstance.value) == null ? void 0 : _a.clear();
|
|
385
|
-
};
|
|
386
|
-
const cancel = () => {
|
|
387
|
-
var _a;
|
|
388
|
-
return (_a = drauuInstance.value) == null ? void 0 : _a.cancel();
|
|
389
|
-
};
|
|
390
|
-
const load = (svg) => {
|
|
391
|
-
var _a;
|
|
392
|
-
return (_a = drauuInstance.value) == null ? void 0 : _a.load(svg);
|
|
393
|
-
};
|
|
394
|
-
const dump = () => {
|
|
395
|
-
var _a;
|
|
396
|
-
return (_a = drauuInstance.value) == null ? void 0 : _a.dump();
|
|
397
|
-
};
|
|
301
|
+
const undo = () => drauuInstance.value?.undo();
|
|
302
|
+
const redo = () => drauuInstance.value?.redo();
|
|
303
|
+
const clear = () => drauuInstance.value?.clear();
|
|
304
|
+
const cancel = () => drauuInstance.value?.cancel();
|
|
305
|
+
const load = (svg) => drauuInstance.value?.load(svg);
|
|
306
|
+
const dump = () => drauuInstance.value?.dump();
|
|
398
307
|
const cleanup = () => {
|
|
399
|
-
var _a;
|
|
400
308
|
disposables.forEach((dispose) => dispose());
|
|
401
|
-
|
|
309
|
+
drauuInstance.value?.unmount();
|
|
402
310
|
};
|
|
403
311
|
const syncStatus = () => {
|
|
404
312
|
if (drauuInstance.value) {
|
|
@@ -415,7 +323,7 @@ function useDrauu(target, options) {
|
|
|
415
323
|
return;
|
|
416
324
|
if (drauuInstance.value)
|
|
417
325
|
cleanup();
|
|
418
|
-
drauuInstance.value = createDrauu(
|
|
326
|
+
drauuInstance.value = createDrauu({ el, ...options });
|
|
419
327
|
syncStatus();
|
|
420
328
|
disposables = [
|
|
421
329
|
drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
|
|
@@ -450,40 +358,9 @@ function useDrauu(target, options) {
|
|
|
450
358
|
};
|
|
451
359
|
}
|
|
452
360
|
|
|
453
|
-
var __defProp$2 = Object.defineProperty;
|
|
454
|
-
var __defProps = Object.defineProperties;
|
|
455
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
456
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
457
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
458
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
459
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
460
|
-
var __spreadValues$2 = (a, b) => {
|
|
461
|
-
for (var prop in b || (b = {}))
|
|
462
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
463
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
464
|
-
if (__getOwnPropSymbols$2)
|
|
465
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
466
|
-
if (__propIsEnum$2.call(b, prop))
|
|
467
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
468
|
-
}
|
|
469
|
-
return a;
|
|
470
|
-
};
|
|
471
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
472
|
-
var __objRest$1 = (source, exclude) => {
|
|
473
|
-
var target = {};
|
|
474
|
-
for (var prop in source)
|
|
475
|
-
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
476
|
-
target[prop] = source[prop];
|
|
477
|
-
if (source != null && __getOwnPropSymbols$2)
|
|
478
|
-
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
479
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
480
|
-
target[prop] = source[prop];
|
|
481
|
-
}
|
|
482
|
-
return target;
|
|
483
|
-
};
|
|
484
361
|
function useFocusTrap(target, options = {}) {
|
|
485
362
|
let trap;
|
|
486
|
-
const
|
|
363
|
+
const { immediate, ...focusTrapOptions } = options;
|
|
487
364
|
const hasFocus = ref(false);
|
|
488
365
|
const isPaused = ref(false);
|
|
489
366
|
const activate = (opts) => trap && trap.activate(opts);
|
|
@@ -505,7 +382,8 @@ function useFocusTrap(target, options = {}) {
|
|
|
505
382
|
(el) => {
|
|
506
383
|
if (!el)
|
|
507
384
|
return;
|
|
508
|
-
trap = createFocusTrap(el,
|
|
385
|
+
trap = createFocusTrap(el, {
|
|
386
|
+
...focusTrapOptions,
|
|
509
387
|
onActivate() {
|
|
510
388
|
hasFocus.value = true;
|
|
511
389
|
if (options.onActivate)
|
|
@@ -516,7 +394,7 @@ function useFocusTrap(target, options = {}) {
|
|
|
516
394
|
if (options.onDeactivate)
|
|
517
395
|
options.onDeactivate();
|
|
518
396
|
}
|
|
519
|
-
})
|
|
397
|
+
});
|
|
520
398
|
if (immediate)
|
|
521
399
|
activate();
|
|
522
400
|
},
|
|
@@ -535,18 +413,14 @@ function useFocusTrap(target, options = {}) {
|
|
|
535
413
|
|
|
536
414
|
function useFuse(search, data, options) {
|
|
537
415
|
const createFuse = () => {
|
|
538
|
-
var _a, _b;
|
|
539
416
|
return new Fuse(
|
|
540
|
-
|
|
541
|
-
|
|
417
|
+
toValue(data) ?? [],
|
|
418
|
+
toValue(options)?.fuseOptions
|
|
542
419
|
);
|
|
543
420
|
};
|
|
544
421
|
const fuse = ref(createFuse());
|
|
545
422
|
watch(
|
|
546
|
-
() =>
|
|
547
|
-
var _a;
|
|
548
|
-
return (_a = toValue(options)) == null ? void 0 : _a.fuseOptions;
|
|
549
|
-
},
|
|
423
|
+
() => toValue(options)?.fuseOptions,
|
|
550
424
|
() => {
|
|
551
425
|
fuse.value = createFuse();
|
|
552
426
|
},
|
|
@@ -561,9 +435,9 @@ function useFuse(search, data, options) {
|
|
|
561
435
|
);
|
|
562
436
|
const results = computed(() => {
|
|
563
437
|
const resolved = toValue(options);
|
|
564
|
-
if (
|
|
438
|
+
if (resolved?.matchAllWhenSearchEmpty && !toValue(search))
|
|
565
439
|
return toValue(data).map((item, index) => ({ item, refIndex: index }));
|
|
566
|
-
const limit = resolved
|
|
440
|
+
const limit = resolved?.resultLimit;
|
|
567
441
|
return fuse.value.search(toValue(search), limit ? { limit } : void 0);
|
|
568
442
|
});
|
|
569
443
|
return {
|
|
@@ -572,22 +446,6 @@ function useFuse(search, data, options) {
|
|
|
572
446
|
};
|
|
573
447
|
}
|
|
574
448
|
|
|
575
|
-
var __defProp$1 = Object.defineProperty;
|
|
576
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
577
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
578
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
579
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
580
|
-
var __spreadValues$1 = (a, b) => {
|
|
581
|
-
for (var prop in b || (b = {}))
|
|
582
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
583
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
584
|
-
if (__getOwnPropSymbols$1)
|
|
585
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
586
|
-
if (__propIsEnum$1.call(b, prop))
|
|
587
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
588
|
-
}
|
|
589
|
-
return a;
|
|
590
|
-
};
|
|
591
449
|
function useIDBKeyval(key, initialValue, options = {}) {
|
|
592
450
|
const {
|
|
593
451
|
flush = "pre",
|
|
@@ -624,7 +482,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
624
482
|
if (Array.isArray(data.value))
|
|
625
483
|
await update(key, () => JSON.parse(JSON.stringify(data.value)));
|
|
626
484
|
else if (typeof data.value === "object")
|
|
627
|
-
await update(key, () =>
|
|
485
|
+
await update(key, () => ({ ...data.value }));
|
|
628
486
|
else
|
|
629
487
|
await update(key, () => data.value);
|
|
630
488
|
}
|
|
@@ -632,8 +490,21 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
632
490
|
onError(e);
|
|
633
491
|
}
|
|
634
492
|
}
|
|
635
|
-
|
|
636
|
-
|
|
493
|
+
const {
|
|
494
|
+
pause: pauseWatch,
|
|
495
|
+
resume: resumeWatch
|
|
496
|
+
} = watchPausable(data, () => write(), { flush, deep });
|
|
497
|
+
async function setData(value) {
|
|
498
|
+
pauseWatch();
|
|
499
|
+
data.value = value;
|
|
500
|
+
await write();
|
|
501
|
+
resumeWatch();
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
set: setData,
|
|
505
|
+
isFinished,
|
|
506
|
+
data
|
|
507
|
+
};
|
|
637
508
|
}
|
|
638
509
|
|
|
639
510
|
function useJwt(encodedJwt, options = {}) {
|
|
@@ -645,7 +516,7 @@ function useJwt(encodedJwt, options = {}) {
|
|
|
645
516
|
try {
|
|
646
517
|
return jwt_decode(encodedJwt2, options2);
|
|
647
518
|
} catch (err) {
|
|
648
|
-
onError
|
|
519
|
+
onError?.(err);
|
|
649
520
|
return fallbackValue;
|
|
650
521
|
}
|
|
651
522
|
};
|
|
@@ -701,64 +572,41 @@ function useQRCode(text, options) {
|
|
|
701
572
|
return result;
|
|
702
573
|
}
|
|
703
574
|
|
|
704
|
-
var __defProp = Object.defineProperty;
|
|
705
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
706
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
707
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
708
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
709
|
-
var __spreadValues = (a, b) => {
|
|
710
|
-
for (var prop in b || (b = {}))
|
|
711
|
-
if (__hasOwnProp.call(b, prop))
|
|
712
|
-
__defNormalProp(a, prop, b[prop]);
|
|
713
|
-
if (__getOwnPropSymbols)
|
|
714
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
715
|
-
if (__propIsEnum.call(b, prop))
|
|
716
|
-
__defNormalProp(a, prop, b[prop]);
|
|
717
|
-
}
|
|
718
|
-
return a;
|
|
719
|
-
};
|
|
720
|
-
var __objRest = (source, exclude) => {
|
|
721
|
-
var target = {};
|
|
722
|
-
for (var prop in source)
|
|
723
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
724
|
-
target[prop] = source[prop];
|
|
725
|
-
if (source != null && __getOwnPropSymbols)
|
|
726
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
727
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
728
|
-
target[prop] = source[prop];
|
|
729
|
-
}
|
|
730
|
-
return target;
|
|
731
|
-
};
|
|
732
575
|
function useSortable(el, list, options = {}) {
|
|
733
576
|
let sortable;
|
|
734
|
-
const
|
|
577
|
+
const { document = defaultDocument, ...resetOptions } = options;
|
|
735
578
|
const defaultOptions = {
|
|
736
579
|
onUpdate: (e) => {
|
|
737
580
|
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
738
581
|
}
|
|
739
582
|
};
|
|
740
583
|
const start = () => {
|
|
741
|
-
const target = typeof el === "string" ? document
|
|
584
|
+
const target = typeof el === "string" ? document?.querySelector(el) : unrefElement(el);
|
|
742
585
|
if (!target)
|
|
743
586
|
return;
|
|
744
|
-
sortable = new Sortable(target,
|
|
587
|
+
sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
|
|
745
588
|
};
|
|
746
|
-
const stop = () => sortable
|
|
589
|
+
const stop = () => sortable?.destroy();
|
|
747
590
|
const option = (name, value) => {
|
|
748
591
|
if (value !== void 0)
|
|
749
|
-
sortable
|
|
592
|
+
sortable?.option(name, value);
|
|
750
593
|
else
|
|
751
|
-
return sortable
|
|
594
|
+
return sortable?.option(name);
|
|
752
595
|
};
|
|
753
596
|
tryOnMounted(start);
|
|
754
597
|
tryOnScopeDispose$1(stop);
|
|
755
598
|
return { stop, start, option };
|
|
756
599
|
}
|
|
757
600
|
function moveArrayElement(list, from, to) {
|
|
758
|
-
const
|
|
601
|
+
const _valueIsRef = isRef(list);
|
|
602
|
+
const array = _valueIsRef ? [...toValue$1(list)] : toValue$1(list);
|
|
759
603
|
if (to >= 0 && to < array.length) {
|
|
760
604
|
const element = array.splice(from, 1)[0];
|
|
761
|
-
nextTick(() =>
|
|
605
|
+
nextTick(() => {
|
|
606
|
+
array.splice(to, 0, element);
|
|
607
|
+
if (_valueIsRef)
|
|
608
|
+
list.value = array;
|
|
609
|
+
});
|
|
762
610
|
}
|
|
763
611
|
}
|
|
764
612
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"import": "./index.mjs",
|
|
26
|
+
"require": "./index.cjs"
|
|
27
27
|
},
|
|
28
28
|
"./*": "./*",
|
|
29
29
|
"./useAsyncValidator": {
|
|
@@ -145,8 +145,8 @@
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@vueuse/core": "10.
|
|
149
|
-
"@vueuse/shared": "10.
|
|
148
|
+
"@vueuse/core": "10.4.0",
|
|
149
|
+
"@vueuse/shared": "10.4.0",
|
|
150
150
|
"vue-demi": ">=0.14.5"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
@@ -164,6 +164,6 @@
|
|
|
164
164
|
"nprogress": "^0.2.0",
|
|
165
165
|
"qrcode": "^1.5.3",
|
|
166
166
|
"sortablejs": "^1.15.0",
|
|
167
|
-
"universal-cookie": "^
|
|
167
|
+
"universal-cookie": "^6.1.0"
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -4,25 +4,6 @@ var vueDemi = require('vue-demi');
|
|
|
4
4
|
var shared = require('@vueuse/shared');
|
|
5
5
|
var Schema = require('async-validator');
|
|
6
6
|
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __defProps = Object.defineProperties;
|
|
9
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
7
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
27
8
|
function useAsyncValidator(value, rules, options = {}) {
|
|
28
9
|
const {
|
|
@@ -34,14 +15,8 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
34
15
|
const errorInfo = vueDemi.shallowRef(null);
|
|
35
16
|
const isFinished = vueDemi.ref(true);
|
|
36
17
|
const pass = vueDemi.ref(!immediate || manual);
|
|
37
|
-
const errors = vueDemi.computed(() =>
|
|
38
|
-
|
|
39
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
40
|
-
});
|
|
41
|
-
const errorFields = vueDemi.computed(() => {
|
|
42
|
-
var _a;
|
|
43
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
44
|
-
});
|
|
18
|
+
const errors = vueDemi.computed(() => errorInfo.value?.errors || []);
|
|
19
|
+
const errorFields = vueDemi.computed(() => errorInfo.value?.fields || {});
|
|
45
20
|
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.toValue(rules)));
|
|
46
21
|
const execute = async () => {
|
|
47
22
|
isFinished.value = false;
|
|
@@ -82,11 +57,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
82
57
|
shared.until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
83
58
|
});
|
|
84
59
|
}
|
|
85
|
-
return
|
|
60
|
+
return {
|
|
61
|
+
...shell,
|
|
86
62
|
then(onFulfilled, onRejected) {
|
|
87
63
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
88
64
|
}
|
|
89
|
-
}
|
|
65
|
+
};
|
|
90
66
|
}
|
|
91
67
|
|
|
92
68
|
const UseAsyncValidator = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
@@ -2,25 +2,6 @@ import { shallowRef, ref, computed, watch, defineComponent, reactive } from 'vue
|
|
|
2
2
|
import { toRef, toValue, until } from '@vueuse/shared';
|
|
3
3
|
import Schema from 'async-validator';
|
|
4
4
|
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defProps = Object.defineProperties;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
5
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
25
6
|
function useAsyncValidator(value, rules, options = {}) {
|
|
26
7
|
const {
|
|
@@ -32,14 +13,8 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
32
13
|
const errorInfo = shallowRef(null);
|
|
33
14
|
const isFinished = ref(true);
|
|
34
15
|
const pass = ref(!immediate || manual);
|
|
35
|
-
const errors = computed(() =>
|
|
36
|
-
|
|
37
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
38
|
-
});
|
|
39
|
-
const errorFields = computed(() => {
|
|
40
|
-
var _a;
|
|
41
|
-
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
42
|
-
});
|
|
16
|
+
const errors = computed(() => errorInfo.value?.errors || []);
|
|
17
|
+
const errorFields = computed(() => errorInfo.value?.fields || {});
|
|
43
18
|
const validator = computed(() => new AsyncValidatorSchema(toValue(rules)));
|
|
44
19
|
const execute = async () => {
|
|
45
20
|
isFinished.value = false;
|
|
@@ -80,11 +55,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
80
55
|
until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
81
56
|
});
|
|
82
57
|
}
|
|
83
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
...shell,
|
|
84
60
|
then(onFulfilled, onRejected) {
|
|
85
61
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
86
62
|
}
|
|
87
|
-
}
|
|
63
|
+
};
|
|
88
64
|
}
|
|
89
65
|
|
|
90
66
|
const UseAsyncValidator = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|