@vueuse/integrations 9.12.0 → 10.0.0-beta.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/README.md +1 -0
- package/index.cjs +165 -94
- package/index.d.ts +47 -14
- package/index.iife.js +166 -96
- package/index.iife.min.js +1 -1
- package/index.mjs +165 -96
- package/package.json +21 -5
- package/useAsyncValidator/component.cjs +3 -2
- package/useAsyncValidator/component.mjs +3 -2
- package/useAsyncValidator.cjs +2 -1
- package/useAsyncValidator.iife.js +2 -1
- package/useAsyncValidator.iife.min.js +1 -1
- package/useAsyncValidator.mjs +2 -1
- package/useAxios.cjs +14 -3
- package/useAxios.d.ts +18 -10
- package/useAxios.iife.js +14 -3
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +14 -3
- package/useCookies.d.ts +1 -1
- package/useFocusTrap/component.cjs +1 -1
- package/useFocusTrap/component.mjs +1 -1
- package/useIDBKeyval.cjs +7 -4
- package/useIDBKeyval.d.ts +11 -1
- package/useIDBKeyval.iife.js +7 -4
- package/useIDBKeyval.iife.min.js +1 -1
- package/useIDBKeyval.mjs +8 -5
- package/useSortable/component.cjs +91 -0
- package/useSortable/component.d.ts +40 -0
- package/useSortable/component.mjs +89 -0
- package/useSortable.cjs +60 -0
- package/useSortable.d.ts +19 -0
- package/useSortable.iife.js +174 -0
- package/useSortable.iife.min.js +1 -0
- package/useSortable.mjs +57 -0
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ npm i <b>@vueuse/integrations</b>
|
|
|
25
25
|
- [`useJwt`](https://vueuse.org/integrations/useJwt/) — wrapper for [`jwt-decode`](https://github.com/auth0/jwt-decode)
|
|
26
26
|
- [`useNProgress`](https://vueuse.org/integrations/useNProgress/) — reactive wrapper for [`nprogress`](https://github.com/rstacruz/nprogress)
|
|
27
27
|
- [`useQRCode`](https://vueuse.org/integrations/useQRCode/) — wrapper for [`qrcode`](https://github.com/soldair/node-qrcode)
|
|
28
|
+
- [`useSortable`](https://vueuse.org/integrations/useSortable/) — wrapper for [`sortable`](https://github.com/SortableJS/Sortable)
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
<!--FUNCTIONS_LIST_ENDS-->
|
package/index.cjs
CHANGED
|
@@ -14,26 +14,28 @@ var idbKeyval = require('idb-keyval');
|
|
|
14
14
|
var jwt_decode = require('jwt-decode');
|
|
15
15
|
var nprogress = require('nprogress');
|
|
16
16
|
var QRCode = require('qrcode');
|
|
17
|
+
var Sortable = require('sortablejs');
|
|
17
18
|
|
|
18
|
-
var __defProp$
|
|
19
|
+
var __defProp$6 = Object.defineProperty;
|
|
19
20
|
var __defProps$2 = Object.defineProperties;
|
|
20
21
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
21
|
-
var __getOwnPropSymbols$
|
|
22
|
-
var __hasOwnProp$
|
|
23
|
-
var __propIsEnum$
|
|
24
|
-
var __defNormalProp$
|
|
25
|
-
var __spreadValues$
|
|
22
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
23
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
24
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
25
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
26
|
+
var __spreadValues$6 = (a, b) => {
|
|
26
27
|
for (var prop in b || (b = {}))
|
|
27
|
-
if (__hasOwnProp$
|
|
28
|
-
__defNormalProp$
|
|
29
|
-
if (__getOwnPropSymbols$
|
|
30
|
-
for (var prop of __getOwnPropSymbols$
|
|
31
|
-
if (__propIsEnum$
|
|
32
|
-
__defNormalProp$
|
|
28
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
29
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
30
|
+
if (__getOwnPropSymbols$6)
|
|
31
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
32
|
+
if (__propIsEnum$6.call(b, prop))
|
|
33
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
33
34
|
}
|
|
34
35
|
return a;
|
|
35
36
|
};
|
|
36
37
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
38
|
+
const AsyncValidatorSchema = Schema.default || Schema;
|
|
37
39
|
function useAsyncValidator(value, rules, options = {}) {
|
|
38
40
|
const errorInfo = vueDemi.ref();
|
|
39
41
|
const isFinished = vueDemi.ref(false);
|
|
@@ -50,7 +52,7 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
50
52
|
vueDemi.watchEffect(async () => {
|
|
51
53
|
isFinished.value = false;
|
|
52
54
|
pass.value = false;
|
|
53
|
-
const validator = new
|
|
55
|
+
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
54
56
|
try {
|
|
55
57
|
await validator.validate(shared.resolveUnref(value), validateOption);
|
|
56
58
|
pass.value = true;
|
|
@@ -73,28 +75,28 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
73
75
|
shared.until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
|
-
return __spreadProps$2(__spreadValues$
|
|
78
|
+
return __spreadProps$2(__spreadValues$6({}, shell), {
|
|
77
79
|
then(onFulfilled, onRejected) {
|
|
78
80
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
var __defProp$
|
|
85
|
+
var __defProp$5 = Object.defineProperty;
|
|
84
86
|
var __defProps$1 = Object.defineProperties;
|
|
85
87
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
86
|
-
var __getOwnPropSymbols$
|
|
87
|
-
var __hasOwnProp$
|
|
88
|
-
var __propIsEnum$
|
|
89
|
-
var __defNormalProp$
|
|
90
|
-
var __spreadValues$
|
|
88
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
89
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
90
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
91
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
92
|
+
var __spreadValues$5 = (a, b) => {
|
|
91
93
|
for (var prop in b || (b = {}))
|
|
92
|
-
if (__hasOwnProp$
|
|
93
|
-
__defNormalProp$
|
|
94
|
-
if (__getOwnPropSymbols$
|
|
95
|
-
for (var prop of __getOwnPropSymbols$
|
|
96
|
-
if (__propIsEnum$
|
|
97
|
-
__defNormalProp$
|
|
94
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
95
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
96
|
+
if (__getOwnPropSymbols$5)
|
|
97
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
98
|
+
if (__propIsEnum$5.call(b, prop))
|
|
99
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
98
100
|
}
|
|
99
101
|
return a;
|
|
100
102
|
};
|
|
@@ -104,7 +106,10 @@ function useAxios(...args) {
|
|
|
104
106
|
const argsPlaceholder = shared.isString(url) ? 1 : 0;
|
|
105
107
|
let defaultConfig = {};
|
|
106
108
|
let instance = axios;
|
|
107
|
-
let options = {
|
|
109
|
+
let options = {
|
|
110
|
+
immediate: !!argsPlaceholder,
|
|
111
|
+
shallow: true
|
|
112
|
+
};
|
|
108
113
|
const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
|
|
109
114
|
if (args.length > 0 + argsPlaceholder) {
|
|
110
115
|
if (isAxiosInstance(args[0 + argsPlaceholder]))
|
|
@@ -124,11 +129,13 @@ function useAxios(...args) {
|
|
|
124
129
|
const isLoading = vueDemi.ref(false);
|
|
125
130
|
const isAborted = vueDemi.ref(false);
|
|
126
131
|
const error = vueDemi.shallowRef();
|
|
127
|
-
const
|
|
132
|
+
const cancelTokenSource = axios.CancelToken.source;
|
|
133
|
+
let cancelToken = cancelTokenSource();
|
|
128
134
|
const abort = (message) => {
|
|
129
135
|
if (isFinished.value || !isLoading.value)
|
|
130
136
|
return;
|
|
131
137
|
cancelToken.cancel(message);
|
|
138
|
+
cancelToken = cancelTokenSource();
|
|
132
139
|
isAborted.value = true;
|
|
133
140
|
isLoading.value = false;
|
|
134
141
|
isFinished.value = false;
|
|
@@ -149,12 +156,18 @@ function useAxios(...args) {
|
|
|
149
156
|
isFinished.value = true;
|
|
150
157
|
return { then };
|
|
151
158
|
}
|
|
159
|
+
abort();
|
|
152
160
|
loading(true);
|
|
153
|
-
instance(_url, __spreadProps$1(__spreadValues$
|
|
161
|
+
instance(_url, __spreadProps$1(__spreadValues$5(__spreadValues$5({}, defaultConfig), typeof executeUrl === "object" ? executeUrl : config), { cancelToken: cancelToken.token })).then((r) => {
|
|
162
|
+
var _a;
|
|
154
163
|
response.value = r;
|
|
155
|
-
|
|
164
|
+
const result2 = r.data;
|
|
165
|
+
data.value = result2;
|
|
166
|
+
(_a = options.onSuccess) == null ? void 0 : _a.call(options, result2);
|
|
156
167
|
}).catch((e) => {
|
|
168
|
+
var _a;
|
|
157
169
|
error.value = e;
|
|
170
|
+
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
158
171
|
}).finally(() => loading(false));
|
|
159
172
|
return { then };
|
|
160
173
|
};
|
|
@@ -176,7 +189,7 @@ function useAxios(...args) {
|
|
|
176
189
|
abort,
|
|
177
190
|
execute
|
|
178
191
|
};
|
|
179
|
-
return __spreadProps$1(__spreadValues$
|
|
192
|
+
return __spreadProps$1(__spreadValues$5({}, result), {
|
|
180
193
|
then
|
|
181
194
|
});
|
|
182
195
|
}
|
|
@@ -210,19 +223,19 @@ function useChangeCase(input, type, options) {
|
|
|
210
223
|
});
|
|
211
224
|
}
|
|
212
225
|
|
|
213
|
-
var __defProp$
|
|
214
|
-
var __getOwnPropSymbols$
|
|
215
|
-
var __hasOwnProp$
|
|
216
|
-
var __propIsEnum$
|
|
217
|
-
var __defNormalProp$
|
|
218
|
-
var __spreadValues$
|
|
226
|
+
var __defProp$4 = Object.defineProperty;
|
|
227
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
228
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
229
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
230
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
231
|
+
var __spreadValues$4 = (a, b) => {
|
|
219
232
|
for (var prop in b || (b = {}))
|
|
220
|
-
if (__hasOwnProp$
|
|
221
|
-
__defNormalProp$
|
|
222
|
-
if (__getOwnPropSymbols$
|
|
223
|
-
for (var prop of __getOwnPropSymbols$
|
|
224
|
-
if (__propIsEnum$
|
|
225
|
-
__defNormalProp$
|
|
233
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
234
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
235
|
+
if (__getOwnPropSymbols$4)
|
|
236
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
237
|
+
if (__propIsEnum$4.call(b, prop))
|
|
238
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
226
239
|
}
|
|
227
240
|
return a;
|
|
228
241
|
};
|
|
@@ -249,11 +262,11 @@ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies =
|
|
|
249
262
|
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
|
|
250
263
|
watchingDependencies.push(args[0]);
|
|
251
264
|
touches.value;
|
|
252
|
-
return cookies.get(args[0], __spreadValues$
|
|
265
|
+
return cookies.get(args[0], __spreadValues$4({ doNotParse }, args[1]));
|
|
253
266
|
},
|
|
254
267
|
getAll: (...args) => {
|
|
255
268
|
touches.value;
|
|
256
|
-
return cookies.getAll(__spreadValues$
|
|
269
|
+
return cookies.getAll(__spreadValues$4({ doNotParse }, args[0]));
|
|
257
270
|
},
|
|
258
271
|
set: (...args) => cookies.set(...args),
|
|
259
272
|
remove: (...args) => cookies.remove(...args),
|
|
@@ -271,19 +284,19 @@ function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
|
271
284
|
return false;
|
|
272
285
|
}
|
|
273
286
|
|
|
274
|
-
var __defProp$
|
|
275
|
-
var __getOwnPropSymbols$
|
|
276
|
-
var __hasOwnProp$
|
|
277
|
-
var __propIsEnum$
|
|
278
|
-
var __defNormalProp$
|
|
279
|
-
var __spreadValues$
|
|
287
|
+
var __defProp$3 = Object.defineProperty;
|
|
288
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
289
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
290
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
291
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
292
|
+
var __spreadValues$3 = (a, b) => {
|
|
280
293
|
for (var prop in b || (b = {}))
|
|
281
|
-
if (__hasOwnProp$
|
|
282
|
-
__defNormalProp$
|
|
283
|
-
if (__getOwnPropSymbols$
|
|
284
|
-
for (var prop of __getOwnPropSymbols$
|
|
285
|
-
if (__propIsEnum$
|
|
286
|
-
__defNormalProp$
|
|
294
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
295
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
296
|
+
if (__getOwnPropSymbols$3)
|
|
297
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
298
|
+
if (__propIsEnum$3.call(b, prop))
|
|
299
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
287
300
|
}
|
|
288
301
|
return a;
|
|
289
302
|
};
|
|
@@ -357,7 +370,7 @@ function useDrauu(target, options) {
|
|
|
357
370
|
return;
|
|
358
371
|
if (drauuInstance.value)
|
|
359
372
|
cleanup();
|
|
360
|
-
drauuInstance.value = drauu.createDrauu(__spreadValues$
|
|
373
|
+
drauuInstance.value = drauu.createDrauu(__spreadValues$3({ el }, options));
|
|
361
374
|
syncStatus();
|
|
362
375
|
disposables = [
|
|
363
376
|
drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
|
|
@@ -390,40 +403,40 @@ function useDrauu(target, options) {
|
|
|
390
403
|
};
|
|
391
404
|
}
|
|
392
405
|
|
|
393
|
-
var __defProp$
|
|
406
|
+
var __defProp$2 = Object.defineProperty;
|
|
394
407
|
var __defProps = Object.defineProperties;
|
|
395
408
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
396
|
-
var __getOwnPropSymbols$
|
|
397
|
-
var __hasOwnProp$
|
|
398
|
-
var __propIsEnum$
|
|
399
|
-
var __defNormalProp$
|
|
400
|
-
var __spreadValues$
|
|
409
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
410
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
411
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
412
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
413
|
+
var __spreadValues$2 = (a, b) => {
|
|
401
414
|
for (var prop in b || (b = {}))
|
|
402
|
-
if (__hasOwnProp$
|
|
403
|
-
__defNormalProp$
|
|
404
|
-
if (__getOwnPropSymbols$
|
|
405
|
-
for (var prop of __getOwnPropSymbols$
|
|
406
|
-
if (__propIsEnum$
|
|
407
|
-
__defNormalProp$
|
|
415
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
416
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
417
|
+
if (__getOwnPropSymbols$2)
|
|
418
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
419
|
+
if (__propIsEnum$2.call(b, prop))
|
|
420
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
408
421
|
}
|
|
409
422
|
return a;
|
|
410
423
|
};
|
|
411
424
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
412
|
-
var __objRest = (source, exclude) => {
|
|
425
|
+
var __objRest$1 = (source, exclude) => {
|
|
413
426
|
var target = {};
|
|
414
427
|
for (var prop in source)
|
|
415
|
-
if (__hasOwnProp$
|
|
428
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
416
429
|
target[prop] = source[prop];
|
|
417
|
-
if (source != null && __getOwnPropSymbols$
|
|
418
|
-
for (var prop of __getOwnPropSymbols$
|
|
419
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
430
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
431
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
432
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
420
433
|
target[prop] = source[prop];
|
|
421
434
|
}
|
|
422
435
|
return target;
|
|
423
436
|
};
|
|
424
437
|
function useFocusTrap(target, options = {}) {
|
|
425
438
|
let trap;
|
|
426
|
-
const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
|
|
439
|
+
const _a = options, { immediate } = _a, focusTrapOptions = __objRest$1(_a, ["immediate"]);
|
|
427
440
|
const hasFocus = vueDemi.ref(false);
|
|
428
441
|
const isPaused = vueDemi.ref(false);
|
|
429
442
|
const activate = (opts) => trap && trap.activate(opts);
|
|
@@ -443,7 +456,7 @@ function useFocusTrap(target, options = {}) {
|
|
|
443
456
|
vueDemi.watch(() => core.unrefElement(target), (el) => {
|
|
444
457
|
if (!el)
|
|
445
458
|
return;
|
|
446
|
-
trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues$
|
|
459
|
+
trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues$2({}, focusTrapOptions), {
|
|
447
460
|
onActivate() {
|
|
448
461
|
hasFocus.value = true;
|
|
449
462
|
if (options.onActivate)
|
|
@@ -497,19 +510,19 @@ function useFuse(search, data, options) {
|
|
|
497
510
|
};
|
|
498
511
|
}
|
|
499
512
|
|
|
500
|
-
var __defProp = Object.defineProperty;
|
|
501
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
502
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
503
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
504
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
505
|
-
var __spreadValues = (a, b) => {
|
|
513
|
+
var __defProp$1 = Object.defineProperty;
|
|
514
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
515
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
516
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
517
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
518
|
+
var __spreadValues$1 = (a, b) => {
|
|
506
519
|
for (var prop in b || (b = {}))
|
|
507
|
-
if (__hasOwnProp.call(b, prop))
|
|
508
|
-
__defNormalProp(a, prop, b[prop]);
|
|
509
|
-
if (__getOwnPropSymbols)
|
|
510
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
511
|
-
if (__propIsEnum.call(b, prop))
|
|
512
|
-
__defNormalProp(a, prop, b[prop]);
|
|
520
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
521
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
522
|
+
if (__getOwnPropSymbols$1)
|
|
523
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
524
|
+
if (__propIsEnum$1.call(b, prop))
|
|
525
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
513
526
|
}
|
|
514
527
|
return a;
|
|
515
528
|
};
|
|
@@ -517,18 +530,20 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
517
530
|
const {
|
|
518
531
|
flush = "pre",
|
|
519
532
|
deep = true,
|
|
520
|
-
shallow,
|
|
533
|
+
shallow = false,
|
|
521
534
|
onError = (e) => {
|
|
522
535
|
console.error(e);
|
|
523
|
-
}
|
|
536
|
+
},
|
|
537
|
+
writeDefaults = true
|
|
524
538
|
} = options;
|
|
539
|
+
const isFinished = vueDemi.ref(false);
|
|
525
540
|
const data = (shallow ? vueDemi.shallowRef : vueDemi.ref)(initialValue);
|
|
526
541
|
const rawInit = shared.resolveUnref(initialValue);
|
|
527
542
|
async function read() {
|
|
528
543
|
try {
|
|
529
544
|
const rawValue = await idbKeyval.get(key);
|
|
530
545
|
if (rawValue === void 0) {
|
|
531
|
-
if (rawInit !== void 0 && rawInit !== null)
|
|
546
|
+
if (rawInit !== void 0 && rawInit !== null && writeDefaults)
|
|
532
547
|
await idbKeyval.set(key, rawInit);
|
|
533
548
|
} else {
|
|
534
549
|
data.value = rawValue;
|
|
@@ -536,6 +551,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
536
551
|
} catch (e) {
|
|
537
552
|
onError(e);
|
|
538
553
|
}
|
|
554
|
+
isFinished.value = true;
|
|
539
555
|
}
|
|
540
556
|
read();
|
|
541
557
|
async function write() {
|
|
@@ -546,7 +562,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
546
562
|
if (Array.isArray(data.value))
|
|
547
563
|
await idbKeyval.update(key, () => JSON.parse(JSON.stringify(data.value)));
|
|
548
564
|
else if (typeof data.value === "object")
|
|
549
|
-
await idbKeyval.update(key, () => __spreadValues({}, data.value));
|
|
565
|
+
await idbKeyval.update(key, () => __spreadValues$1({}, data.value));
|
|
550
566
|
else
|
|
551
567
|
await idbKeyval.update(key, () => data.value);
|
|
552
568
|
}
|
|
@@ -555,7 +571,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
555
571
|
}
|
|
556
572
|
}
|
|
557
573
|
vueDemi.watch(data, () => write(), { flush, deep });
|
|
558
|
-
return data;
|
|
574
|
+
return { isFinished, data };
|
|
559
575
|
}
|
|
560
576
|
|
|
561
577
|
function useJwt(encodedJwt, options = {}) {
|
|
@@ -619,7 +635,61 @@ function useQRCode(text, options) {
|
|
|
619
635
|
return result;
|
|
620
636
|
}
|
|
621
637
|
|
|
638
|
+
var __defProp = Object.defineProperty;
|
|
639
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
640
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
641
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
642
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
643
|
+
var __spreadValues = (a, b) => {
|
|
644
|
+
for (var prop in b || (b = {}))
|
|
645
|
+
if (__hasOwnProp.call(b, prop))
|
|
646
|
+
__defNormalProp(a, prop, b[prop]);
|
|
647
|
+
if (__getOwnPropSymbols)
|
|
648
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
649
|
+
if (__propIsEnum.call(b, prop))
|
|
650
|
+
__defNormalProp(a, prop, b[prop]);
|
|
651
|
+
}
|
|
652
|
+
return a;
|
|
653
|
+
};
|
|
654
|
+
var __objRest = (source, exclude) => {
|
|
655
|
+
var target = {};
|
|
656
|
+
for (var prop in source)
|
|
657
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
658
|
+
target[prop] = source[prop];
|
|
659
|
+
if (source != null && __getOwnPropSymbols)
|
|
660
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
661
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
662
|
+
target[prop] = source[prop];
|
|
663
|
+
}
|
|
664
|
+
return target;
|
|
665
|
+
};
|
|
666
|
+
function useSortable(el, list, options = {}) {
|
|
667
|
+
let sortable;
|
|
668
|
+
const _a = options, { document = core.defaultDocument } = _a, resetOptions = __objRest(_a, ["document"]);
|
|
669
|
+
const defaultOptions = {
|
|
670
|
+
onUpdate: (e) => {
|
|
671
|
+
moveArrayElement(list, e.oldIndex, e.newIndex);
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
const start = () => {
|
|
675
|
+
const target = typeof el === "string" ? document == null ? void 0 : document.querySelector(el) : core.unrefElement(el);
|
|
676
|
+
if (!target)
|
|
677
|
+
return;
|
|
678
|
+
sortable = new Sortable(target, __spreadValues(__spreadValues({}, defaultOptions), resetOptions));
|
|
679
|
+
};
|
|
680
|
+
const stop = () => sortable == null ? void 0 : sortable.destroy();
|
|
681
|
+
core.tryOnMounted(start);
|
|
682
|
+
core.tryOnScopeDispose(stop);
|
|
683
|
+
return { stop, start };
|
|
684
|
+
}
|
|
685
|
+
function moveArrayElement(list, from, to) {
|
|
686
|
+
const array = core.resolveUnref(list);
|
|
687
|
+
if (to >= 0 && to < array.length)
|
|
688
|
+
array.splice(to, 0, array.splice(from, 1)[0]);
|
|
689
|
+
}
|
|
690
|
+
|
|
622
691
|
exports.createCookies = createCookies;
|
|
692
|
+
exports.moveArrayElement = moveArrayElement;
|
|
623
693
|
exports.useAsyncValidator = useAsyncValidator;
|
|
624
694
|
exports.useAxios = useAxios;
|
|
625
695
|
exports.useChangeCase = useChangeCase;
|
|
@@ -631,3 +701,4 @@ exports.useIDBKeyval = useIDBKeyval;
|
|
|
631
701
|
exports.useJwt = useJwt;
|
|
632
702
|
exports.useNProgress = useNProgress;
|
|
633
703
|
exports.useQRCode = useQRCode;
|
|
704
|
+
exports.useSortable = useSortable;
|
package/index.d.ts
CHANGED
|
@@ -2,18 +2,19 @@ import { MaybeComputedRef, MaybeRef, ConfigurableFlush, RemovableRef } from '@vu
|
|
|
2
2
|
import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
3
3
|
import * as vue_demi from 'vue-demi';
|
|
4
4
|
import { Ref, ShallowRef, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
5
|
-
import { AxiosResponse,
|
|
5
|
+
import { AxiosResponse, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
6
6
|
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase, Options } from 'change-case';
|
|
7
7
|
import * as universal_cookie from 'universal-cookie';
|
|
8
8
|
import universal_cookie__default from 'universal-cookie';
|
|
9
|
-
import { IncomingMessage } from 'http';
|
|
9
|
+
import { IncomingMessage } from 'node:http';
|
|
10
10
|
import { Options as Options$1, Drauu, Brush } from 'drauu';
|
|
11
|
-
import { EventHookOn, MaybeComputedElementRef, Fn, MaybeElementRef } from '@vueuse/core';
|
|
11
|
+
import { EventHookOn, MaybeComputedElementRef, Fn, MaybeElementRef, ConfigurableDocument, MaybeComputedRef as MaybeComputedRef$1 } from '@vueuse/core';
|
|
12
12
|
import { Options as Options$2, ActivateOptions, DeactivateOptions } from 'focus-trap';
|
|
13
13
|
import Fuse from 'fuse.js';
|
|
14
14
|
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
15
15
|
import nprogress, { NProgressOptions } from 'nprogress';
|
|
16
16
|
import QRCode from 'qrcode';
|
|
17
|
+
import { Options as Options$3 } from 'sortablejs';
|
|
17
18
|
|
|
18
19
|
type AsyncValidatorError = Error & {
|
|
19
20
|
errors: ValidateError[];
|
|
@@ -40,7 +41,7 @@ interface UseAsyncValidatorOptions {
|
|
|
40
41
|
*/
|
|
41
42
|
declare function useAsyncValidator(value: MaybeComputedRef<Record<string, any>>, rules: MaybeComputedRef<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
|
|
42
43
|
|
|
43
|
-
interface UseAxiosReturn<T, R = AxiosResponse<T>,
|
|
44
|
+
interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
|
|
44
45
|
/**
|
|
45
46
|
* Axios Response
|
|
46
47
|
*/
|
|
@@ -64,7 +65,7 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, D = any> {
|
|
|
64
65
|
/**
|
|
65
66
|
* Any errors that may have occurred
|
|
66
67
|
*/
|
|
67
|
-
error: ShallowRef<
|
|
68
|
+
error: ShallowRef<unknown | undefined>;
|
|
68
69
|
/**
|
|
69
70
|
* Aborts the current request
|
|
70
71
|
*/
|
|
@@ -102,15 +103,15 @@ interface StrictUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
|
|
|
102
103
|
/**
|
|
103
104
|
* Manually call the axios request
|
|
104
105
|
*/
|
|
105
|
-
execute: (url?: string |
|
|
106
|
+
execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
106
107
|
}
|
|
107
108
|
interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
|
|
108
109
|
/**
|
|
109
110
|
* Manually call the axios request
|
|
110
111
|
*/
|
|
111
|
-
execute: (url: string, config?:
|
|
112
|
+
execute: (url: string, config?: AxiosRequestConfig<D>) => PromiseLike<EasyUseAxiosReturn<T, R, D>>;
|
|
112
113
|
}
|
|
113
|
-
interface UseAxiosOptions {
|
|
114
|
+
interface UseAxiosOptions<T = any> {
|
|
114
115
|
/**
|
|
115
116
|
* Will automatically run axios request when `useAxios` is used
|
|
116
117
|
*
|
|
@@ -122,13 +123,21 @@ interface UseAxiosOptions {
|
|
|
122
123
|
* @default true
|
|
123
124
|
*/
|
|
124
125
|
shallow?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Callback when error is caught.
|
|
128
|
+
*/
|
|
129
|
+
onError?: (e: unknown) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Callback when success is caught.
|
|
132
|
+
*/
|
|
133
|
+
onSuccess?: (data: T) => void;
|
|
125
134
|
}
|
|
126
|
-
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?:
|
|
135
|
+
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
127
136
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
128
|
-
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config:
|
|
129
|
-
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?:
|
|
137
|
+
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
138
|
+
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
|
|
130
139
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
|
|
131
|
-
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?:
|
|
140
|
+
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
|
|
132
141
|
|
|
133
142
|
declare const changeCase_camelCase: typeof camelCase;
|
|
134
143
|
declare const changeCase_capitalCase: typeof capitalCase;
|
|
@@ -327,6 +336,12 @@ interface UseIDBOptions extends ConfigurableFlush {
|
|
|
327
336
|
* @default false
|
|
328
337
|
*/
|
|
329
338
|
shallow?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Write the default value to the storage when it does not exist
|
|
341
|
+
*
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
writeDefaults?: boolean;
|
|
330
345
|
}
|
|
331
346
|
/**
|
|
332
347
|
*
|
|
@@ -334,7 +349,10 @@ interface UseIDBOptions extends ConfigurableFlush {
|
|
|
334
349
|
* @param initialValue
|
|
335
350
|
* @param options
|
|
336
351
|
*/
|
|
337
|
-
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeComputedRef<T>, options?: UseIDBOptions):
|
|
352
|
+
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeComputedRef<T>, options?: UseIDBOptions): {
|
|
353
|
+
data: RemovableRef<T>;
|
|
354
|
+
isFinished: Ref<boolean>;
|
|
355
|
+
};
|
|
338
356
|
|
|
339
357
|
interface UseJwtOptions<Fallback> {
|
|
340
358
|
/**
|
|
@@ -384,4 +402,19 @@ type UseNProgressReturn = ReturnType<typeof useNProgress>;
|
|
|
384
402
|
*/
|
|
385
403
|
declare function useQRCode(text: MaybeComputedRef<string>, options?: QRCode.QRCodeToDataURLOptions): vue_demi.Ref<string>;
|
|
386
404
|
|
|
387
|
-
|
|
405
|
+
interface UseSortableReturn {
|
|
406
|
+
/**
|
|
407
|
+
* start sortable instance
|
|
408
|
+
*/
|
|
409
|
+
start: () => void;
|
|
410
|
+
/**
|
|
411
|
+
* destroy sortable instance
|
|
412
|
+
*/
|
|
413
|
+
stop: () => void;
|
|
414
|
+
}
|
|
415
|
+
type UseSortableOptions = Options$3 & ConfigurableDocument;
|
|
416
|
+
declare function useSortable<T>(selector: string, list: MaybeComputedRef$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
417
|
+
declare function useSortable<T>(el: MaybeComputedRef$1<HTMLElement | null | undefined>, list: MaybeComputedRef$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
418
|
+
declare function moveArrayElement<T>(list: MaybeComputedRef$1<T[]>, from: number, to: number): void;
|
|
419
|
+
|
|
420
|
+
export { AsyncValidatorError, ChangeCaseType, EasyUseAxiosReturn, FuseOptions, StrictUseAxiosReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, UseIDBOptions, UseJwtOptions, UseJwtReturn, UseNProgressOptions, UseNProgressReturn, UseSortableOptions, UseSortableReturn, createCookies, moveArrayElement, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
|