@vueuse/shared 6.7.6 → 6.8.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 +153 -108
- package/index.d.ts +13 -4
- package/index.iife.js +153 -108
- package/index.iife.min.js +1 -1
- package/index.mjs +153 -108
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -230,15 +230,35 @@ function createFilterWrapper(filter, fn) {
|
|
|
230
230
|
const bypassFilter = (invoke) => {
|
|
231
231
|
return invoke();
|
|
232
232
|
};
|
|
233
|
-
function debounceFilter(ms) {
|
|
233
|
+
function debounceFilter(ms, options = {}) {
|
|
234
234
|
let timer;
|
|
235
|
+
let maxTimer;
|
|
235
236
|
const filter = (invoke) => {
|
|
236
237
|
const duration = vueDemi.unref(ms);
|
|
238
|
+
const maxDuration = vueDemi.unref(options.maxWait);
|
|
237
239
|
if (timer)
|
|
238
240
|
clearTimeout(timer);
|
|
239
|
-
if (duration <= 0)
|
|
241
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
242
|
+
if (maxTimer) {
|
|
243
|
+
clearTimeout(maxTimer);
|
|
244
|
+
maxTimer = null;
|
|
245
|
+
}
|
|
240
246
|
return invoke();
|
|
241
|
-
|
|
247
|
+
}
|
|
248
|
+
if (maxDuration && !maxTimer) {
|
|
249
|
+
maxTimer = setTimeout(() => {
|
|
250
|
+
if (timer)
|
|
251
|
+
clearTimeout(timer);
|
|
252
|
+
maxTimer = null;
|
|
253
|
+
invoke();
|
|
254
|
+
}, maxDuration);
|
|
255
|
+
}
|
|
256
|
+
timer = setTimeout(() => {
|
|
257
|
+
if (maxTimer)
|
|
258
|
+
clearTimeout(maxTimer);
|
|
259
|
+
maxTimer = null;
|
|
260
|
+
invoke();
|
|
261
|
+
}, duration);
|
|
242
262
|
};
|
|
243
263
|
return filter;
|
|
244
264
|
}
|
|
@@ -348,17 +368,17 @@ function objectPick(obj, keys, omitUndefined = false) {
|
|
|
348
368
|
}, {});
|
|
349
369
|
}
|
|
350
370
|
|
|
351
|
-
var __getOwnPropSymbols$
|
|
352
|
-
var __hasOwnProp$
|
|
353
|
-
var __propIsEnum$
|
|
371
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
372
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
373
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
354
374
|
var __objRest$5 = (source, exclude) => {
|
|
355
375
|
var target = {};
|
|
356
376
|
for (var prop in source)
|
|
357
|
-
if (__hasOwnProp$
|
|
377
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
358
378
|
target[prop] = source[prop];
|
|
359
|
-
if (source != null && __getOwnPropSymbols$
|
|
360
|
-
for (var prop of __getOwnPropSymbols$
|
|
361
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
379
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
380
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
381
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
362
382
|
target[prop] = source[prop];
|
|
363
383
|
}
|
|
364
384
|
return target;
|
|
@@ -372,33 +392,33 @@ function watchWithFilter(source, cb, options = {}) {
|
|
|
372
392
|
return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
|
|
373
393
|
}
|
|
374
394
|
|
|
375
|
-
var __defProp$
|
|
376
|
-
var __defProps$
|
|
377
|
-
var __getOwnPropDescs$
|
|
378
|
-
var __getOwnPropSymbols$
|
|
379
|
-
var __hasOwnProp$
|
|
380
|
-
var __propIsEnum$
|
|
381
|
-
var __defNormalProp$
|
|
382
|
-
var __spreadValues$
|
|
395
|
+
var __defProp$7 = Object.defineProperty;
|
|
396
|
+
var __defProps$4 = Object.defineProperties;
|
|
397
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
398
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
399
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
400
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
401
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
402
|
+
var __spreadValues$7 = (a, b) => {
|
|
383
403
|
for (var prop in b || (b = {}))
|
|
384
|
-
if (__hasOwnProp$
|
|
385
|
-
__defNormalProp$
|
|
386
|
-
if (__getOwnPropSymbols$
|
|
387
|
-
for (var prop of __getOwnPropSymbols$
|
|
388
|
-
if (__propIsEnum$
|
|
389
|
-
__defNormalProp$
|
|
404
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
405
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
406
|
+
if (__getOwnPropSymbols$8)
|
|
407
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
408
|
+
if (__propIsEnum$8.call(b, prop))
|
|
409
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
390
410
|
}
|
|
391
411
|
return a;
|
|
392
412
|
};
|
|
393
|
-
var __spreadProps$
|
|
413
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
394
414
|
var __objRest$4 = (source, exclude) => {
|
|
395
415
|
var target = {};
|
|
396
416
|
for (var prop in source)
|
|
397
|
-
if (__hasOwnProp$
|
|
417
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
398
418
|
target[prop] = source[prop];
|
|
399
|
-
if (source != null && __getOwnPropSymbols$
|
|
400
|
-
for (var prop of __getOwnPropSymbols$
|
|
401
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
419
|
+
if (source != null && __getOwnPropSymbols$8)
|
|
420
|
+
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
421
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
402
422
|
target[prop] = source[prop];
|
|
403
423
|
}
|
|
404
424
|
return target;
|
|
@@ -409,7 +429,7 @@ function debouncedWatch(source, cb, options = {}) {
|
|
|
409
429
|
} = _a, watchOptions = __objRest$4(_a, [
|
|
410
430
|
"debounce"
|
|
411
431
|
]);
|
|
412
|
-
return watchWithFilter(source, cb, __spreadProps$
|
|
432
|
+
return watchWithFilter(source, cb, __spreadProps$4(__spreadValues$7({}, watchOptions), {
|
|
413
433
|
eventFilter: debounceFilter(debounce)
|
|
414
434
|
}));
|
|
415
435
|
}
|
|
@@ -428,33 +448,33 @@ function get(obj, key) {
|
|
|
428
448
|
return vueDemi.unref(obj)[key];
|
|
429
449
|
}
|
|
430
450
|
|
|
431
|
-
var __defProp$
|
|
432
|
-
var __defProps$
|
|
433
|
-
var __getOwnPropDescs$
|
|
434
|
-
var __getOwnPropSymbols$
|
|
435
|
-
var __hasOwnProp$
|
|
436
|
-
var __propIsEnum$
|
|
437
|
-
var __defNormalProp$
|
|
438
|
-
var __spreadValues$
|
|
451
|
+
var __defProp$6 = Object.defineProperty;
|
|
452
|
+
var __defProps$3 = Object.defineProperties;
|
|
453
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
454
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
455
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
456
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
457
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
458
|
+
var __spreadValues$6 = (a, b) => {
|
|
439
459
|
for (var prop in b || (b = {}))
|
|
440
|
-
if (__hasOwnProp$
|
|
441
|
-
__defNormalProp$
|
|
442
|
-
if (__getOwnPropSymbols$
|
|
443
|
-
for (var prop of __getOwnPropSymbols$
|
|
444
|
-
if (__propIsEnum$
|
|
445
|
-
__defNormalProp$
|
|
460
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
461
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
462
|
+
if (__getOwnPropSymbols$7)
|
|
463
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
464
|
+
if (__propIsEnum$7.call(b, prop))
|
|
465
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
446
466
|
}
|
|
447
467
|
return a;
|
|
448
468
|
};
|
|
449
|
-
var __spreadProps$
|
|
469
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
450
470
|
var __objRest$3 = (source, exclude) => {
|
|
451
471
|
var target = {};
|
|
452
472
|
for (var prop in source)
|
|
453
|
-
if (__hasOwnProp$
|
|
473
|
+
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
454
474
|
target[prop] = source[prop];
|
|
455
|
-
if (source != null && __getOwnPropSymbols$
|
|
456
|
-
for (var prop of __getOwnPropSymbols$
|
|
457
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
475
|
+
if (source != null && __getOwnPropSymbols$7)
|
|
476
|
+
for (var prop of __getOwnPropSymbols$7(source)) {
|
|
477
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
|
|
458
478
|
target[prop] = source[prop];
|
|
459
479
|
}
|
|
460
480
|
return target;
|
|
@@ -491,7 +511,7 @@ function ignorableWatch(source, cb, options = {}) {
|
|
|
491
511
|
};
|
|
492
512
|
disposables.push(vueDemi.watch(source, () => {
|
|
493
513
|
syncCounter.value++;
|
|
494
|
-
}, __spreadProps$
|
|
514
|
+
}, __spreadProps$3(__spreadValues$6({}, watchOptions), { flush: "sync" })));
|
|
495
515
|
ignoreUpdates = (updater) => {
|
|
496
516
|
const syncCounterPrev = syncCounter.value;
|
|
497
517
|
updater();
|
|
@@ -516,25 +536,25 @@ function isDefined(v) {
|
|
|
516
536
|
return vueDemi.unref(v) != null;
|
|
517
537
|
}
|
|
518
538
|
|
|
519
|
-
var __defProp$
|
|
520
|
-
var __getOwnPropSymbols$
|
|
521
|
-
var __hasOwnProp$
|
|
522
|
-
var __propIsEnum$
|
|
523
|
-
var __defNormalProp$
|
|
524
|
-
var __spreadValues$
|
|
539
|
+
var __defProp$5 = Object.defineProperty;
|
|
540
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
541
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
542
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
543
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
544
|
+
var __spreadValues$5 = (a, b) => {
|
|
525
545
|
for (var prop in b || (b = {}))
|
|
526
|
-
if (__hasOwnProp$
|
|
527
|
-
__defNormalProp$
|
|
528
|
-
if (__getOwnPropSymbols$
|
|
529
|
-
for (var prop of __getOwnPropSymbols$
|
|
530
|
-
if (__propIsEnum$
|
|
531
|
-
__defNormalProp$
|
|
546
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
547
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
548
|
+
if (__getOwnPropSymbols$6)
|
|
549
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
550
|
+
if (__propIsEnum$6.call(b, prop))
|
|
551
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
532
552
|
}
|
|
533
553
|
return a;
|
|
534
554
|
};
|
|
535
555
|
function makeDestructurable(obj, arr) {
|
|
536
556
|
if (typeof Symbol !== "undefined") {
|
|
537
|
-
const clone = __spreadValues$
|
|
557
|
+
const clone = __spreadValues$5({}, obj);
|
|
538
558
|
Object.defineProperty(clone, Symbol.iterator, {
|
|
539
559
|
enumerable: false,
|
|
540
560
|
value() {
|
|
@@ -561,33 +581,33 @@ function or(...args) {
|
|
|
561
581
|
return vueDemi.computed(() => args.some((i) => vueDemi.unref(i)));
|
|
562
582
|
}
|
|
563
583
|
|
|
564
|
-
var __defProp$
|
|
565
|
-
var __defProps$
|
|
566
|
-
var __getOwnPropDescs$
|
|
567
|
-
var __getOwnPropSymbols$
|
|
568
|
-
var __hasOwnProp$
|
|
569
|
-
var __propIsEnum$
|
|
570
|
-
var __defNormalProp$
|
|
571
|
-
var __spreadValues$
|
|
584
|
+
var __defProp$4 = Object.defineProperty;
|
|
585
|
+
var __defProps$2 = Object.defineProperties;
|
|
586
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
587
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
588
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
589
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
590
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
591
|
+
var __spreadValues$4 = (a, b) => {
|
|
572
592
|
for (var prop in b || (b = {}))
|
|
573
|
-
if (__hasOwnProp$
|
|
574
|
-
__defNormalProp$
|
|
575
|
-
if (__getOwnPropSymbols$
|
|
576
|
-
for (var prop of __getOwnPropSymbols$
|
|
577
|
-
if (__propIsEnum$
|
|
578
|
-
__defNormalProp$
|
|
593
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
594
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
595
|
+
if (__getOwnPropSymbols$5)
|
|
596
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
597
|
+
if (__propIsEnum$5.call(b, prop))
|
|
598
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
579
599
|
}
|
|
580
600
|
return a;
|
|
581
601
|
};
|
|
582
|
-
var __spreadProps$
|
|
602
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
583
603
|
var __objRest$2 = (source, exclude) => {
|
|
584
604
|
var target = {};
|
|
585
605
|
for (var prop in source)
|
|
586
|
-
if (__hasOwnProp$
|
|
606
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
587
607
|
target[prop] = source[prop];
|
|
588
|
-
if (source != null && __getOwnPropSymbols$
|
|
589
|
-
for (var prop of __getOwnPropSymbols$
|
|
590
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
608
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
609
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
610
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
591
611
|
target[prop] = source[prop];
|
|
592
612
|
}
|
|
593
613
|
return target;
|
|
@@ -599,7 +619,7 @@ function pausableWatch(source, cb, options = {}) {
|
|
|
599
619
|
"eventFilter"
|
|
600
620
|
]);
|
|
601
621
|
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
|
|
602
|
-
const stop = watchWithFilter(source, cb, __spreadProps$
|
|
622
|
+
const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$4({}, watchOptions), {
|
|
603
623
|
eventFilter
|
|
604
624
|
}));
|
|
605
625
|
return { stop, pause, resume, isActive };
|
|
@@ -677,33 +697,33 @@ function syncRef(source, targets, {
|
|
|
677
697
|
});
|
|
678
698
|
}
|
|
679
699
|
|
|
680
|
-
var __defProp$
|
|
681
|
-
var __defProps = Object.defineProperties;
|
|
682
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
683
|
-
var __getOwnPropSymbols$
|
|
684
|
-
var __hasOwnProp$
|
|
685
|
-
var __propIsEnum$
|
|
686
|
-
var __defNormalProp$
|
|
687
|
-
var __spreadValues$
|
|
700
|
+
var __defProp$3 = Object.defineProperty;
|
|
701
|
+
var __defProps$1 = Object.defineProperties;
|
|
702
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
703
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
704
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
705
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
706
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
707
|
+
var __spreadValues$3 = (a, b) => {
|
|
688
708
|
for (var prop in b || (b = {}))
|
|
689
|
-
if (__hasOwnProp$
|
|
690
|
-
__defNormalProp$
|
|
691
|
-
if (__getOwnPropSymbols$
|
|
692
|
-
for (var prop of __getOwnPropSymbols$
|
|
693
|
-
if (__propIsEnum$
|
|
694
|
-
__defNormalProp$
|
|
709
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
710
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
711
|
+
if (__getOwnPropSymbols$4)
|
|
712
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
713
|
+
if (__propIsEnum$4.call(b, prop))
|
|
714
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
695
715
|
}
|
|
696
716
|
return a;
|
|
697
717
|
};
|
|
698
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
718
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
699
719
|
var __objRest$1 = (source, exclude) => {
|
|
700
720
|
var target = {};
|
|
701
721
|
for (var prop in source)
|
|
702
|
-
if (__hasOwnProp$
|
|
722
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
703
723
|
target[prop] = source[prop];
|
|
704
|
-
if (source != null && __getOwnPropSymbols$
|
|
705
|
-
for (var prop of __getOwnPropSymbols$
|
|
706
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
724
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
725
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
726
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
707
727
|
target[prop] = source[prop];
|
|
708
728
|
}
|
|
709
729
|
return target;
|
|
@@ -718,7 +738,7 @@ function throttledWatch(source, cb, options = {}) {
|
|
|
718
738
|
"trailing",
|
|
719
739
|
"leading"
|
|
720
740
|
]);
|
|
721
|
-
return watchWithFilter(source, cb, __spreadProps(__spreadValues$
|
|
741
|
+
return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$3({}, watchOptions), {
|
|
722
742
|
eventFilter: throttleFilter(throttle, trailing, leading)
|
|
723
743
|
}));
|
|
724
744
|
}
|
|
@@ -753,6 +773,25 @@ function toReactive(objectRef) {
|
|
|
753
773
|
return vueDemi.reactive(proxy);
|
|
754
774
|
}
|
|
755
775
|
|
|
776
|
+
var __defProp$2 = Object.defineProperty;
|
|
777
|
+
var __defProps = Object.defineProperties;
|
|
778
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
779
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
780
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
781
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
782
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
783
|
+
var __spreadValues$2 = (a, b) => {
|
|
784
|
+
for (var prop in b || (b = {}))
|
|
785
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
786
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
787
|
+
if (__getOwnPropSymbols$3)
|
|
788
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
789
|
+
if (__propIsEnum$3.call(b, prop))
|
|
790
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
791
|
+
}
|
|
792
|
+
return a;
|
|
793
|
+
};
|
|
794
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
756
795
|
function toRefs(objectRef) {
|
|
757
796
|
if (!vueDemi.isRef(objectRef))
|
|
758
797
|
return vueDemi.toRefs(objectRef);
|
|
@@ -763,7 +802,13 @@ function toRefs(objectRef) {
|
|
|
763
802
|
return objectRef.value[key];
|
|
764
803
|
},
|
|
765
804
|
set(v) {
|
|
766
|
-
objectRef.value
|
|
805
|
+
if (Array.isArray(objectRef.value)) {
|
|
806
|
+
const copy = [...objectRef.value];
|
|
807
|
+
copy[key] = v;
|
|
808
|
+
objectRef.value = copy;
|
|
809
|
+
} else {
|
|
810
|
+
objectRef.value = __spreadProps(__spreadValues$2({}, objectRef.value), { [key]: v });
|
|
811
|
+
}
|
|
767
812
|
}
|
|
768
813
|
}));
|
|
769
814
|
}
|
|
@@ -888,17 +933,17 @@ function useCounter(initialValue = 0) {
|
|
|
888
933
|
return { count, inc, dec, get, set, reset };
|
|
889
934
|
}
|
|
890
935
|
|
|
891
|
-
function useDebounceFn(fn, ms = 200) {
|
|
892
|
-
return createFilterWrapper(debounceFilter(ms), fn);
|
|
936
|
+
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
937
|
+
return createFilterWrapper(debounceFilter(ms, options), fn);
|
|
893
938
|
}
|
|
894
939
|
|
|
895
|
-
function useDebounce(value, ms = 200) {
|
|
940
|
+
function useDebounce(value, ms = 200, options = {}) {
|
|
896
941
|
if (ms <= 0)
|
|
897
942
|
return value;
|
|
898
943
|
const debounced = vueDemi.ref(value.value);
|
|
899
944
|
const updater = useDebounceFn(() => {
|
|
900
945
|
debounced.value = value.value;
|
|
901
|
-
}, ms);
|
|
946
|
+
}, ms, options);
|
|
902
947
|
vueDemi.watch(value, () => updater());
|
|
903
948
|
return debounced;
|
|
904
949
|
}
|
package/index.d.ts
CHANGED
|
@@ -119,6 +119,13 @@ interface ConfigurableEventFilter {
|
|
|
119
119
|
*/
|
|
120
120
|
eventFilter?: EventFilter;
|
|
121
121
|
}
|
|
122
|
+
interface DebounceFilterOptions {
|
|
123
|
+
/**
|
|
124
|
+
* The maximum time allowed to be delayed before it's invoked.
|
|
125
|
+
* In milliseconds.
|
|
126
|
+
*/
|
|
127
|
+
maxWait?: number;
|
|
128
|
+
}
|
|
122
129
|
/**
|
|
123
130
|
* @internal
|
|
124
131
|
*/
|
|
@@ -128,8 +135,9 @@ declare const bypassFilter: EventFilter;
|
|
|
128
135
|
* Create an EventFilter that debounce the events
|
|
129
136
|
*
|
|
130
137
|
* @param ms
|
|
138
|
+
* @param [maxWait=null]
|
|
131
139
|
*/
|
|
132
|
-
declare function debounceFilter(ms: MaybeRef<number
|
|
140
|
+
declare function debounceFilter(ms: MaybeRef<number>, options?: DebounceFilterOptions): EventFilter<any[], any>;
|
|
133
141
|
/**
|
|
134
142
|
* Create an EventFilter that throttle the events
|
|
135
143
|
*
|
|
@@ -559,17 +567,18 @@ declare function useCounter(initialValue?: number): {
|
|
|
559
567
|
reset: (val?: number) => number;
|
|
560
568
|
};
|
|
561
569
|
|
|
562
|
-
declare function useDebounce<T>(value: Ref<T>, ms?: number): Readonly<Ref<T>>;
|
|
570
|
+
declare function useDebounce<T>(value: Ref<T>, ms?: number, options?: DebounceFilterOptions): Readonly<Ref<T>>;
|
|
563
571
|
|
|
564
572
|
/**
|
|
565
573
|
* Debounce execution of a function.
|
|
566
574
|
*
|
|
567
575
|
* @param fn A function to be executed after delay milliseconds debounced.
|
|
568
576
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
577
|
+
* @param opts options
|
|
569
578
|
*
|
|
570
579
|
* @return A new, debounce, function.
|
|
571
580
|
*/
|
|
572
|
-
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRef<number
|
|
581
|
+
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRef<number>, options?: DebounceFilterOptions): T;
|
|
573
582
|
|
|
574
583
|
interface IntervalOptions<Controls extends boolean> {
|
|
575
584
|
/**
|
|
@@ -720,4 +729,4 @@ declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sourc
|
|
|
720
729
|
*/
|
|
721
730
|
declare function whenever<T>(source: WatchSource<T>, cb: WatchCallback, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
722
731
|
|
|
723
|
-
export { ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, SyncRefOptions, ThrottledWatchOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseLastChangedOptions, WatchAtMostOptions, WatchAtMostReturn, WatchWithFilterOptions, and, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createSharedComposable, createSingletonPromise, debounceFilter, debouncedWatch, eagerComputed, extendRef, get, identity, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, not, now, objectPick, or, pausableFilter, pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactivePick, refDefault, set, syncRef, throttleFilter, throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchOnce, watchWithFilter, whenever };
|
|
732
|
+
export { ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DebounceFilterOptions, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, SyncRefOptions, ThrottledWatchOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseLastChangedOptions, WatchAtMostOptions, WatchAtMostReturn, WatchWithFilterOptions, and, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createSharedComposable, createSingletonPromise, debounceFilter, debouncedWatch, eagerComputed, extendRef, get, identity, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, not, now, objectPick, or, pausableFilter, pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactivePick, refDefault, set, syncRef, throttleFilter, throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchOnce, watchWithFilter, whenever };
|