@vueuse/integrations 9.13.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 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,27 +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$5 = Object.defineProperty;
19
+ var __defProp$6 = Object.defineProperty;
19
20
  var __defProps$2 = Object.defineProperties;
20
21
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
21
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
22
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
23
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
24
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
25
- var __spreadValues$5 = (a, b) => {
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$5.call(b, prop))
28
- __defNormalProp$5(a, prop, b[prop]);
29
- if (__getOwnPropSymbols$5)
30
- for (var prop of __getOwnPropSymbols$5(b)) {
31
- if (__propIsEnum$5.call(b, prop))
32
- __defNormalProp$5(a, prop, b[prop]);
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));
37
- const AsyncValidatorSchema = Schema || Schema.default;
38
+ const AsyncValidatorSchema = Schema.default || Schema;
38
39
  function useAsyncValidator(value, rules, options = {}) {
39
40
  const errorInfo = vueDemi.ref();
40
41
  const isFinished = vueDemi.ref(false);
@@ -74,28 +75,28 @@ function useAsyncValidator(value, rules, options = {}) {
74
75
  shared.until(isFinished).toBe(true).then(() => resolve(shell)).catch((error) => reject(error));
75
76
  });
76
77
  }
77
- return __spreadProps$2(__spreadValues$5({}, shell), {
78
+ return __spreadProps$2(__spreadValues$6({}, shell), {
78
79
  then(onFulfilled, onRejected) {
79
80
  return waitUntilFinished().then(onFulfilled, onRejected);
80
81
  }
81
82
  });
82
83
  }
83
84
 
84
- var __defProp$4 = Object.defineProperty;
85
+ var __defProp$5 = Object.defineProperty;
85
86
  var __defProps$1 = Object.defineProperties;
86
87
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
87
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
88
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
89
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
90
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
91
- var __spreadValues$4 = (a, b) => {
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) => {
92
93
  for (var prop in b || (b = {}))
93
- if (__hasOwnProp$4.call(b, prop))
94
- __defNormalProp$4(a, prop, b[prop]);
95
- if (__getOwnPropSymbols$4)
96
- for (var prop of __getOwnPropSymbols$4(b)) {
97
- if (__propIsEnum$4.call(b, prop))
98
- __defNormalProp$4(a, prop, b[prop]);
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]);
99
100
  }
100
101
  return a;
101
102
  };
@@ -105,7 +106,10 @@ function useAxios(...args) {
105
106
  const argsPlaceholder = shared.isString(url) ? 1 : 0;
106
107
  let defaultConfig = {};
107
108
  let instance = axios;
108
- let options = { immediate: !!argsPlaceholder, shallow: true };
109
+ let options = {
110
+ immediate: !!argsPlaceholder,
111
+ shallow: true
112
+ };
109
113
  const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
110
114
  if (args.length > 0 + argsPlaceholder) {
111
115
  if (isAxiosInstance(args[0 + argsPlaceholder]))
@@ -154,7 +158,7 @@ function useAxios(...args) {
154
158
  }
155
159
  abort();
156
160
  loading(true);
157
- instance(_url, __spreadProps$1(__spreadValues$4(__spreadValues$4({}, defaultConfig), typeof executeUrl === "object" ? executeUrl : config), { cancelToken: cancelToken.token })).then((r) => {
161
+ instance(_url, __spreadProps$1(__spreadValues$5(__spreadValues$5({}, defaultConfig), typeof executeUrl === "object" ? executeUrl : config), { cancelToken: cancelToken.token })).then((r) => {
158
162
  var _a;
159
163
  response.value = r;
160
164
  const result2 = r.data;
@@ -185,7 +189,7 @@ function useAxios(...args) {
185
189
  abort,
186
190
  execute
187
191
  };
188
- return __spreadProps$1(__spreadValues$4({}, result), {
192
+ return __spreadProps$1(__spreadValues$5({}, result), {
189
193
  then
190
194
  });
191
195
  }
@@ -219,19 +223,19 @@ function useChangeCase(input, type, options) {
219
223
  });
220
224
  }
221
225
 
222
- var __defProp$3 = Object.defineProperty;
223
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
224
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
225
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
226
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
227
- var __spreadValues$3 = (a, b) => {
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) => {
228
232
  for (var prop in b || (b = {}))
229
- if (__hasOwnProp$3.call(b, prop))
230
- __defNormalProp$3(a, prop, b[prop]);
231
- if (__getOwnPropSymbols$3)
232
- for (var prop of __getOwnPropSymbols$3(b)) {
233
- if (__propIsEnum$3.call(b, prop))
234
- __defNormalProp$3(a, prop, b[prop]);
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]);
235
239
  }
236
240
  return a;
237
241
  };
@@ -258,11 +262,11 @@ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies =
258
262
  if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
259
263
  watchingDependencies.push(args[0]);
260
264
  touches.value;
261
- return cookies.get(args[0], __spreadValues$3({ doNotParse }, args[1]));
265
+ return cookies.get(args[0], __spreadValues$4({ doNotParse }, args[1]));
262
266
  },
263
267
  getAll: (...args) => {
264
268
  touches.value;
265
- return cookies.getAll(__spreadValues$3({ doNotParse }, args[0]));
269
+ return cookies.getAll(__spreadValues$4({ doNotParse }, args[0]));
266
270
  },
267
271
  set: (...args) => cookies.set(...args),
268
272
  remove: (...args) => cookies.remove(...args),
@@ -280,19 +284,19 @@ function shouldUpdate(dependencies, newCookies, oldCookies) {
280
284
  return false;
281
285
  }
282
286
 
283
- var __defProp$2 = Object.defineProperty;
284
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
285
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
286
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
287
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
288
- var __spreadValues$2 = (a, b) => {
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) => {
289
293
  for (var prop in b || (b = {}))
290
- if (__hasOwnProp$2.call(b, prop))
291
- __defNormalProp$2(a, prop, b[prop]);
292
- if (__getOwnPropSymbols$2)
293
- for (var prop of __getOwnPropSymbols$2(b)) {
294
- if (__propIsEnum$2.call(b, prop))
295
- __defNormalProp$2(a, prop, b[prop]);
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]);
296
300
  }
297
301
  return a;
298
302
  };
@@ -366,7 +370,7 @@ function useDrauu(target, options) {
366
370
  return;
367
371
  if (drauuInstance.value)
368
372
  cleanup();
369
- drauuInstance.value = drauu.createDrauu(__spreadValues$2({ el }, options));
373
+ drauuInstance.value = drauu.createDrauu(__spreadValues$3({ el }, options));
370
374
  syncStatus();
371
375
  disposables = [
372
376
  drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
@@ -399,40 +403,40 @@ function useDrauu(target, options) {
399
403
  };
400
404
  }
401
405
 
402
- var __defProp$1 = Object.defineProperty;
406
+ var __defProp$2 = Object.defineProperty;
403
407
  var __defProps = Object.defineProperties;
404
408
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
405
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
406
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
407
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
408
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
409
- var __spreadValues$1 = (a, b) => {
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) => {
410
414
  for (var prop in b || (b = {}))
411
- if (__hasOwnProp$1.call(b, prop))
412
- __defNormalProp$1(a, prop, b[prop]);
413
- if (__getOwnPropSymbols$1)
414
- for (var prop of __getOwnPropSymbols$1(b)) {
415
- if (__propIsEnum$1.call(b, prop))
416
- __defNormalProp$1(a, prop, b[prop]);
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]);
417
421
  }
418
422
  return a;
419
423
  };
420
424
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
421
- var __objRest = (source, exclude) => {
425
+ var __objRest$1 = (source, exclude) => {
422
426
  var target = {};
423
427
  for (var prop in source)
424
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
428
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
425
429
  target[prop] = source[prop];
426
- if (source != null && __getOwnPropSymbols$1)
427
- for (var prop of __getOwnPropSymbols$1(source)) {
428
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
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))
429
433
  target[prop] = source[prop];
430
434
  }
431
435
  return target;
432
436
  };
433
437
  function useFocusTrap(target, options = {}) {
434
438
  let trap;
435
- const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
439
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest$1(_a, ["immediate"]);
436
440
  const hasFocus = vueDemi.ref(false);
437
441
  const isPaused = vueDemi.ref(false);
438
442
  const activate = (opts) => trap && trap.activate(opts);
@@ -452,7 +456,7 @@ function useFocusTrap(target, options = {}) {
452
456
  vueDemi.watch(() => core.unrefElement(target), (el) => {
453
457
  if (!el)
454
458
  return;
455
- trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues$1({}, focusTrapOptions), {
459
+ trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues$2({}, focusTrapOptions), {
456
460
  onActivate() {
457
461
  hasFocus.value = true;
458
462
  if (options.onActivate)
@@ -506,19 +510,19 @@ function useFuse(search, data, options) {
506
510
  };
507
511
  }
508
512
 
509
- var __defProp = Object.defineProperty;
510
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
511
- var __hasOwnProp = Object.prototype.hasOwnProperty;
512
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
513
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
514
- 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) => {
515
519
  for (var prop in b || (b = {}))
516
- if (__hasOwnProp.call(b, prop))
517
- __defNormalProp(a, prop, b[prop]);
518
- if (__getOwnPropSymbols)
519
- for (var prop of __getOwnPropSymbols(b)) {
520
- if (__propIsEnum.call(b, prop))
521
- __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]);
522
526
  }
523
527
  return a;
524
528
  };
@@ -526,18 +530,20 @@ function useIDBKeyval(key, initialValue, options = {}) {
526
530
  const {
527
531
  flush = "pre",
528
532
  deep = true,
529
- shallow,
533
+ shallow = false,
530
534
  onError = (e) => {
531
535
  console.error(e);
532
- }
536
+ },
537
+ writeDefaults = true
533
538
  } = options;
539
+ const isFinished = vueDemi.ref(false);
534
540
  const data = (shallow ? vueDemi.shallowRef : vueDemi.ref)(initialValue);
535
541
  const rawInit = shared.resolveUnref(initialValue);
536
542
  async function read() {
537
543
  try {
538
544
  const rawValue = await idbKeyval.get(key);
539
545
  if (rawValue === void 0) {
540
- if (rawInit !== void 0 && rawInit !== null)
546
+ if (rawInit !== void 0 && rawInit !== null && writeDefaults)
541
547
  await idbKeyval.set(key, rawInit);
542
548
  } else {
543
549
  data.value = rawValue;
@@ -545,6 +551,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
545
551
  } catch (e) {
546
552
  onError(e);
547
553
  }
554
+ isFinished.value = true;
548
555
  }
549
556
  read();
550
557
  async function write() {
@@ -555,7 +562,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
555
562
  if (Array.isArray(data.value))
556
563
  await idbKeyval.update(key, () => JSON.parse(JSON.stringify(data.value)));
557
564
  else if (typeof data.value === "object")
558
- await idbKeyval.update(key, () => __spreadValues({}, data.value));
565
+ await idbKeyval.update(key, () => __spreadValues$1({}, data.value));
559
566
  else
560
567
  await idbKeyval.update(key, () => data.value);
561
568
  }
@@ -564,7 +571,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
564
571
  }
565
572
  }
566
573
  vueDemi.watch(data, () => write(), { flush, deep });
567
- return data;
574
+ return { isFinished, data };
568
575
  }
569
576
 
570
577
  function useJwt(encodedJwt, options = {}) {
@@ -628,7 +635,61 @@ function useQRCode(text, options) {
628
635
  return result;
629
636
  }
630
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
+
631
691
  exports.createCookies = createCookies;
692
+ exports.moveArrayElement = moveArrayElement;
632
693
  exports.useAsyncValidator = useAsyncValidator;
633
694
  exports.useAxios = useAxios;
634
695
  exports.useChangeCase = useChangeCase;
@@ -640,3 +701,4 @@ exports.useIDBKeyval = useIDBKeyval;
640
701
  exports.useJwt = useJwt;
641
702
  exports.useNProgress = useNProgress;
642
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, AxiosError, RawAxiosRequestConfig, AxiosInstance } from 'axios';
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>, D = any> {
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<AxiosError<T, D> | undefined>;
68
+ error: ShallowRef<unknown | undefined>;
68
69
  /**
69
70
  * Aborts the current request
70
71
  */
@@ -102,13 +103,13 @@ 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 | RawAxiosRequestConfig<D>, config?: RawAxiosRequestConfig<D>) => PromiseLike<StrictUseAxiosReturn<T, R, D>>;
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?: RawAxiosRequestConfig<D>) => PromiseLike<EasyUseAxiosReturn<T, R, D>>;
112
+ execute: (url: string, config?: AxiosRequestConfig<D>) => PromiseLike<EasyUseAxiosReturn<T, R, D>>;
112
113
  }
113
114
  interface UseAxiosOptions<T = any> {
114
115
  /**
@@ -131,12 +132,12 @@ interface UseAxiosOptions<T = any> {
131
132
  */
132
133
  onSuccess?: (data: T) => void;
133
134
  }
134
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: RawAxiosRequestConfig<D>, options?: UseAxiosOptions<T>): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
135
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions<T>): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
136
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config: RawAxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions<T>): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
137
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: RawAxiosRequestConfig<D>): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
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>>;
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>>;
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>>;
138
139
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
139
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: RawAxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & PromiseLike<EasyUseAxiosReturn<T, R, D>>;
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>>;
140
141
 
141
142
  declare const changeCase_camelCase: typeof camelCase;
142
143
  declare const changeCase_capitalCase: typeof capitalCase;
@@ -335,6 +336,12 @@ interface UseIDBOptions extends ConfigurableFlush {
335
336
  * @default false
336
337
  */
337
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;
338
345
  }
339
346
  /**
340
347
  *
@@ -342,7 +349,10 @@ interface UseIDBOptions extends ConfigurableFlush {
342
349
  * @param initialValue
343
350
  * @param options
344
351
  */
345
- declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeComputedRef<T>, options?: UseIDBOptions): RemovableRef<T>;
352
+ declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeComputedRef<T>, options?: UseIDBOptions): {
353
+ data: RemovableRef<T>;
354
+ isFinished: Ref<boolean>;
355
+ };
346
356
 
347
357
  interface UseJwtOptions<Fallback> {
348
358
  /**
@@ -392,4 +402,19 @@ type UseNProgressReturn = ReturnType<typeof useNProgress>;
392
402
  */
393
403
  declare function useQRCode(text: MaybeComputedRef<string>, options?: QRCode.QRCodeToDataURLOptions): vue_demi.Ref<string>;
394
404
 
395
- export { AsyncValidatorError, ChangeCaseType, EasyUseAxiosReturn, FuseOptions, StrictUseAxiosReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, UseIDBOptions, UseJwtOptions, UseJwtReturn, UseNProgressOptions, UseNProgressReturn, createCookies, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode };
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 };