@vueuse/shared 6.7.6 → 6.9.2
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 +196 -150
- package/index.d.ts +62 -35
- package/index.iife.js +196 -150
- package/index.iife.min.js +1 -1
- package/index.mjs +194 -151
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -166,6 +166,12 @@ function createGlobalState(stateFactory) {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
function reactify(fn) {
|
|
170
|
+
return function(...args) {
|
|
171
|
+
return vueDemi.computed(() => fn.apply(this, args.map((i) => vueDemi.unref(i))));
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
169
175
|
function tryOnScopeDispose(fn) {
|
|
170
176
|
if (vueDemi.getCurrentScope()) {
|
|
171
177
|
vueDemi.onScopeDispose(fn);
|
|
@@ -230,15 +236,35 @@ function createFilterWrapper(filter, fn) {
|
|
|
230
236
|
const bypassFilter = (invoke) => {
|
|
231
237
|
return invoke();
|
|
232
238
|
};
|
|
233
|
-
function debounceFilter(ms) {
|
|
239
|
+
function debounceFilter(ms, options = {}) {
|
|
234
240
|
let timer;
|
|
241
|
+
let maxTimer;
|
|
235
242
|
const filter = (invoke) => {
|
|
236
243
|
const duration = vueDemi.unref(ms);
|
|
244
|
+
const maxDuration = vueDemi.unref(options.maxWait);
|
|
237
245
|
if (timer)
|
|
238
246
|
clearTimeout(timer);
|
|
239
|
-
if (duration <= 0)
|
|
247
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
248
|
+
if (maxTimer) {
|
|
249
|
+
clearTimeout(maxTimer);
|
|
250
|
+
maxTimer = null;
|
|
251
|
+
}
|
|
240
252
|
return invoke();
|
|
241
|
-
|
|
253
|
+
}
|
|
254
|
+
if (maxDuration && !maxTimer) {
|
|
255
|
+
maxTimer = setTimeout(() => {
|
|
256
|
+
if (timer)
|
|
257
|
+
clearTimeout(timer);
|
|
258
|
+
maxTimer = null;
|
|
259
|
+
invoke();
|
|
260
|
+
}, maxDuration);
|
|
261
|
+
}
|
|
262
|
+
timer = setTimeout(() => {
|
|
263
|
+
if (maxTimer)
|
|
264
|
+
clearTimeout(maxTimer);
|
|
265
|
+
maxTimer = null;
|
|
266
|
+
invoke();
|
|
267
|
+
}, duration);
|
|
242
268
|
};
|
|
243
269
|
return filter;
|
|
244
270
|
}
|
|
@@ -348,17 +374,32 @@ function objectPick(obj, keys, omitUndefined = false) {
|
|
|
348
374
|
}, {});
|
|
349
375
|
}
|
|
350
376
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
377
|
+
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
378
|
+
return createFilterWrapper(debounceFilter(ms, options), fn);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function useDebounce(value, ms = 200, options = {}) {
|
|
382
|
+
if (ms <= 0)
|
|
383
|
+
return value;
|
|
384
|
+
const debounced = vueDemi.ref(value.value);
|
|
385
|
+
const updater = useDebounceFn(() => {
|
|
386
|
+
debounced.value = value.value;
|
|
387
|
+
}, ms, options);
|
|
388
|
+
vueDemi.watch(value, () => updater());
|
|
389
|
+
return debounced;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
393
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
394
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
354
395
|
var __objRest$5 = (source, exclude) => {
|
|
355
396
|
var target = {};
|
|
356
397
|
for (var prop in source)
|
|
357
|
-
if (__hasOwnProp$
|
|
398
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
358
399
|
target[prop] = source[prop];
|
|
359
|
-
if (source != null && __getOwnPropSymbols$
|
|
360
|
-
for (var prop of __getOwnPropSymbols$
|
|
361
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
400
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
401
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
402
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
362
403
|
target[prop] = source[prop];
|
|
363
404
|
}
|
|
364
405
|
return target;
|
|
@@ -372,33 +413,33 @@ function watchWithFilter(source, cb, options = {}) {
|
|
|
372
413
|
return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
|
|
373
414
|
}
|
|
374
415
|
|
|
375
|
-
var __defProp$
|
|
376
|
-
var __defProps$
|
|
377
|
-
var __getOwnPropDescs$
|
|
378
|
-
var __getOwnPropSymbols$
|
|
379
|
-
var __hasOwnProp$
|
|
380
|
-
var __propIsEnum$
|
|
381
|
-
var __defNormalProp$
|
|
382
|
-
var __spreadValues$
|
|
416
|
+
var __defProp$7 = Object.defineProperty;
|
|
417
|
+
var __defProps$4 = Object.defineProperties;
|
|
418
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
419
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
420
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
421
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
422
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
423
|
+
var __spreadValues$7 = (a, b) => {
|
|
383
424
|
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$
|
|
425
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
426
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
427
|
+
if (__getOwnPropSymbols$8)
|
|
428
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
429
|
+
if (__propIsEnum$8.call(b, prop))
|
|
430
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
390
431
|
}
|
|
391
432
|
return a;
|
|
392
433
|
};
|
|
393
|
-
var __spreadProps$
|
|
434
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
394
435
|
var __objRest$4 = (source, exclude) => {
|
|
395
436
|
var target = {};
|
|
396
437
|
for (var prop in source)
|
|
397
|
-
if (__hasOwnProp$
|
|
438
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
398
439
|
target[prop] = source[prop];
|
|
399
|
-
if (source != null && __getOwnPropSymbols$
|
|
400
|
-
for (var prop of __getOwnPropSymbols$
|
|
401
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
440
|
+
if (source != null && __getOwnPropSymbols$8)
|
|
441
|
+
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
442
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
402
443
|
target[prop] = source[prop];
|
|
403
444
|
}
|
|
404
445
|
return target;
|
|
@@ -409,7 +450,7 @@ function debouncedWatch(source, cb, options = {}) {
|
|
|
409
450
|
} = _a, watchOptions = __objRest$4(_a, [
|
|
410
451
|
"debounce"
|
|
411
452
|
]);
|
|
412
|
-
return watchWithFilter(source, cb, __spreadProps$
|
|
453
|
+
return watchWithFilter(source, cb, __spreadProps$4(__spreadValues$7({}, watchOptions), {
|
|
413
454
|
eventFilter: debounceFilter(debounce)
|
|
414
455
|
}));
|
|
415
456
|
}
|
|
@@ -428,33 +469,33 @@ function get(obj, key) {
|
|
|
428
469
|
return vueDemi.unref(obj)[key];
|
|
429
470
|
}
|
|
430
471
|
|
|
431
|
-
var __defProp$
|
|
432
|
-
var __defProps$
|
|
433
|
-
var __getOwnPropDescs$
|
|
434
|
-
var __getOwnPropSymbols$
|
|
435
|
-
var __hasOwnProp$
|
|
436
|
-
var __propIsEnum$
|
|
437
|
-
var __defNormalProp$
|
|
438
|
-
var __spreadValues$
|
|
472
|
+
var __defProp$6 = Object.defineProperty;
|
|
473
|
+
var __defProps$3 = Object.defineProperties;
|
|
474
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
475
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
476
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
477
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
478
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
479
|
+
var __spreadValues$6 = (a, b) => {
|
|
439
480
|
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$
|
|
481
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
482
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
483
|
+
if (__getOwnPropSymbols$7)
|
|
484
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
485
|
+
if (__propIsEnum$7.call(b, prop))
|
|
486
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
446
487
|
}
|
|
447
488
|
return a;
|
|
448
489
|
};
|
|
449
|
-
var __spreadProps$
|
|
490
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
450
491
|
var __objRest$3 = (source, exclude) => {
|
|
451
492
|
var target = {};
|
|
452
493
|
for (var prop in source)
|
|
453
|
-
if (__hasOwnProp$
|
|
494
|
+
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
454
495
|
target[prop] = source[prop];
|
|
455
|
-
if (source != null && __getOwnPropSymbols$
|
|
456
|
-
for (var prop of __getOwnPropSymbols$
|
|
457
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
496
|
+
if (source != null && __getOwnPropSymbols$7)
|
|
497
|
+
for (var prop of __getOwnPropSymbols$7(source)) {
|
|
498
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
|
|
458
499
|
target[prop] = source[prop];
|
|
459
500
|
}
|
|
460
501
|
return target;
|
|
@@ -491,7 +532,7 @@ function ignorableWatch(source, cb, options = {}) {
|
|
|
491
532
|
};
|
|
492
533
|
disposables.push(vueDemi.watch(source, () => {
|
|
493
534
|
syncCounter.value++;
|
|
494
|
-
}, __spreadProps$
|
|
535
|
+
}, __spreadProps$3(__spreadValues$6({}, watchOptions), { flush: "sync" })));
|
|
495
536
|
ignoreUpdates = (updater) => {
|
|
496
537
|
const syncCounterPrev = syncCounter.value;
|
|
497
538
|
updater();
|
|
@@ -516,25 +557,25 @@ function isDefined(v) {
|
|
|
516
557
|
return vueDemi.unref(v) != null;
|
|
517
558
|
}
|
|
518
559
|
|
|
519
|
-
var __defProp$
|
|
520
|
-
var __getOwnPropSymbols$
|
|
521
|
-
var __hasOwnProp$
|
|
522
|
-
var __propIsEnum$
|
|
523
|
-
var __defNormalProp$
|
|
524
|
-
var __spreadValues$
|
|
560
|
+
var __defProp$5 = Object.defineProperty;
|
|
561
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
562
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
563
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
564
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
565
|
+
var __spreadValues$5 = (a, b) => {
|
|
525
566
|
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$
|
|
567
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
568
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
569
|
+
if (__getOwnPropSymbols$6)
|
|
570
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
571
|
+
if (__propIsEnum$6.call(b, prop))
|
|
572
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
532
573
|
}
|
|
533
574
|
return a;
|
|
534
575
|
};
|
|
535
576
|
function makeDestructurable(obj, arr) {
|
|
536
577
|
if (typeof Symbol !== "undefined") {
|
|
537
|
-
const clone = __spreadValues$
|
|
578
|
+
const clone = __spreadValues$5({}, obj);
|
|
538
579
|
Object.defineProperty(clone, Symbol.iterator, {
|
|
539
580
|
enumerable: false,
|
|
540
581
|
value() {
|
|
@@ -561,33 +602,33 @@ function or(...args) {
|
|
|
561
602
|
return vueDemi.computed(() => args.some((i) => vueDemi.unref(i)));
|
|
562
603
|
}
|
|
563
604
|
|
|
564
|
-
var __defProp$
|
|
565
|
-
var __defProps$
|
|
566
|
-
var __getOwnPropDescs$
|
|
567
|
-
var __getOwnPropSymbols$
|
|
568
|
-
var __hasOwnProp$
|
|
569
|
-
var __propIsEnum$
|
|
570
|
-
var __defNormalProp$
|
|
571
|
-
var __spreadValues$
|
|
605
|
+
var __defProp$4 = Object.defineProperty;
|
|
606
|
+
var __defProps$2 = Object.defineProperties;
|
|
607
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
608
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
609
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
610
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
611
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
612
|
+
var __spreadValues$4 = (a, b) => {
|
|
572
613
|
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$
|
|
614
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
615
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
616
|
+
if (__getOwnPropSymbols$5)
|
|
617
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
618
|
+
if (__propIsEnum$5.call(b, prop))
|
|
619
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
579
620
|
}
|
|
580
621
|
return a;
|
|
581
622
|
};
|
|
582
|
-
var __spreadProps$
|
|
623
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
583
624
|
var __objRest$2 = (source, exclude) => {
|
|
584
625
|
var target = {};
|
|
585
626
|
for (var prop in source)
|
|
586
|
-
if (__hasOwnProp$
|
|
627
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
587
628
|
target[prop] = source[prop];
|
|
588
|
-
if (source != null && __getOwnPropSymbols$
|
|
589
|
-
for (var prop of __getOwnPropSymbols$
|
|
590
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
629
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
630
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
631
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
591
632
|
target[prop] = source[prop];
|
|
592
633
|
}
|
|
593
634
|
return target;
|
|
@@ -599,18 +640,12 @@ function pausableWatch(source, cb, options = {}) {
|
|
|
599
640
|
"eventFilter"
|
|
600
641
|
]);
|
|
601
642
|
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
|
|
602
|
-
const stop = watchWithFilter(source, cb, __spreadProps$
|
|
643
|
+
const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$4({}, watchOptions), {
|
|
603
644
|
eventFilter
|
|
604
645
|
}));
|
|
605
646
|
return { stop, pause, resume, isActive };
|
|
606
647
|
}
|
|
607
648
|
|
|
608
|
-
function reactify(fn) {
|
|
609
|
-
return function(...args) {
|
|
610
|
-
return vueDemi.computed(() => fn.apply(this, args.map((i) => vueDemi.unref(i))));
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
|
|
614
649
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
615
650
|
let keys = [];
|
|
616
651
|
if (Array.isArray(optionsOrKeys)) {
|
|
@@ -668,42 +703,51 @@ function syncRef(source, targets, {
|
|
|
668
703
|
} = {}) {
|
|
669
704
|
if (!Array.isArray(targets))
|
|
670
705
|
targets = [targets];
|
|
671
|
-
return vueDemi.watch(source, (newValue) => {
|
|
672
|
-
targets.forEach((target) => target.value = newValue);
|
|
673
|
-
}, {
|
|
674
|
-
flush,
|
|
675
|
-
deep,
|
|
676
|
-
immediate
|
|
677
|
-
});
|
|
706
|
+
return vueDemi.watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
|
|
678
707
|
}
|
|
679
708
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
709
|
+
function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
|
|
710
|
+
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function useThrottle(value, delay = 200, trailing = true, leading = true) {
|
|
714
|
+
if (delay <= 0)
|
|
715
|
+
return value;
|
|
716
|
+
const throttled = vueDemi.ref(value.value);
|
|
717
|
+
const updater = useThrottleFn(() => {
|
|
718
|
+
throttled.value = value.value;
|
|
719
|
+
}, delay, trailing, leading);
|
|
720
|
+
vueDemi.watch(value, () => updater());
|
|
721
|
+
return throttled;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
var __defProp$3 = Object.defineProperty;
|
|
725
|
+
var __defProps$1 = Object.defineProperties;
|
|
726
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
727
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
728
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
729
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
730
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
731
|
+
var __spreadValues$3 = (a, b) => {
|
|
688
732
|
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$
|
|
733
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
734
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
735
|
+
if (__getOwnPropSymbols$4)
|
|
736
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
737
|
+
if (__propIsEnum$4.call(b, prop))
|
|
738
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
695
739
|
}
|
|
696
740
|
return a;
|
|
697
741
|
};
|
|
698
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
742
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
699
743
|
var __objRest$1 = (source, exclude) => {
|
|
700
744
|
var target = {};
|
|
701
745
|
for (var prop in source)
|
|
702
|
-
if (__hasOwnProp$
|
|
746
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
703
747
|
target[prop] = source[prop];
|
|
704
|
-
if (source != null && __getOwnPropSymbols$
|
|
705
|
-
for (var prop of __getOwnPropSymbols$
|
|
706
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
748
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
749
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
750
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
707
751
|
target[prop] = source[prop];
|
|
708
752
|
}
|
|
709
753
|
return target;
|
|
@@ -718,7 +762,7 @@ function throttledWatch(source, cb, options = {}) {
|
|
|
718
762
|
"trailing",
|
|
719
763
|
"leading"
|
|
720
764
|
]);
|
|
721
|
-
return watchWithFilter(source, cb, __spreadProps(__spreadValues$
|
|
765
|
+
return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$3({}, watchOptions), {
|
|
722
766
|
eventFilter: throttleFilter(throttle, trailing, leading)
|
|
723
767
|
}));
|
|
724
768
|
}
|
|
@@ -753,6 +797,25 @@ function toReactive(objectRef) {
|
|
|
753
797
|
return vueDemi.reactive(proxy);
|
|
754
798
|
}
|
|
755
799
|
|
|
800
|
+
var __defProp$2 = Object.defineProperty;
|
|
801
|
+
var __defProps = Object.defineProperties;
|
|
802
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
803
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
804
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
805
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
806
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
807
|
+
var __spreadValues$2 = (a, b) => {
|
|
808
|
+
for (var prop in b || (b = {}))
|
|
809
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
810
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
811
|
+
if (__getOwnPropSymbols$3)
|
|
812
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
813
|
+
if (__propIsEnum$3.call(b, prop))
|
|
814
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
815
|
+
}
|
|
816
|
+
return a;
|
|
817
|
+
};
|
|
818
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
756
819
|
function toRefs(objectRef) {
|
|
757
820
|
if (!vueDemi.isRef(objectRef))
|
|
758
821
|
return vueDemi.toRefs(objectRef);
|
|
@@ -763,7 +826,13 @@ function toRefs(objectRef) {
|
|
|
763
826
|
return objectRef.value[key];
|
|
764
827
|
},
|
|
765
828
|
set(v) {
|
|
766
|
-
objectRef.value
|
|
829
|
+
if (Array.isArray(objectRef.value)) {
|
|
830
|
+
const copy = [...objectRef.value];
|
|
831
|
+
copy[key] = v;
|
|
832
|
+
objectRef.value = copy;
|
|
833
|
+
} else {
|
|
834
|
+
objectRef.value = __spreadProps(__spreadValues$2({}, objectRef.value), { [key]: v });
|
|
835
|
+
}
|
|
767
836
|
}
|
|
768
837
|
}));
|
|
769
838
|
}
|
|
@@ -875,10 +944,14 @@ function until(r) {
|
|
|
875
944
|
}
|
|
876
945
|
}
|
|
877
946
|
|
|
878
|
-
function useCounter(initialValue = 0) {
|
|
947
|
+
function useCounter(initialValue = 0, options = {}) {
|
|
879
948
|
const count = vueDemi.ref(initialValue);
|
|
880
|
-
const
|
|
881
|
-
|
|
949
|
+
const {
|
|
950
|
+
max = Infinity,
|
|
951
|
+
min = -Infinity
|
|
952
|
+
} = options;
|
|
953
|
+
const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
|
|
954
|
+
const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
|
|
882
955
|
const get = () => count.value;
|
|
883
956
|
const set = (val) => count.value = val;
|
|
884
957
|
const reset = (val = initialValue) => {
|
|
@@ -888,21 +961,6 @@ function useCounter(initialValue = 0) {
|
|
|
888
961
|
return { count, inc, dec, get, set, reset };
|
|
889
962
|
}
|
|
890
963
|
|
|
891
|
-
function useDebounceFn(fn, ms = 200) {
|
|
892
|
-
return createFilterWrapper(debounceFilter(ms), fn);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
function useDebounce(value, ms = 200) {
|
|
896
|
-
if (ms <= 0)
|
|
897
|
-
return value;
|
|
898
|
-
const debounced = vueDemi.ref(value.value);
|
|
899
|
-
const updater = useDebounceFn(() => {
|
|
900
|
-
debounced.value = value.value;
|
|
901
|
-
}, ms);
|
|
902
|
-
vueDemi.watch(value, () => updater());
|
|
903
|
-
return debounced;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
964
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
907
965
|
const {
|
|
908
966
|
immediate = true,
|
|
@@ -978,21 +1036,6 @@ function useLastChanged(source, options = {}) {
|
|
|
978
1036
|
return ms;
|
|
979
1037
|
}
|
|
980
1038
|
|
|
981
|
-
function useThrottleFn(fn, ms = 200, trailing = true, leading = true) {
|
|
982
|
-
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
function useThrottle(value, delay = 200, trailing = true, leading = true) {
|
|
986
|
-
if (delay <= 0)
|
|
987
|
-
return value;
|
|
988
|
-
const throttled = vueDemi.ref(value.value);
|
|
989
|
-
const updater = useThrottleFn(() => {
|
|
990
|
-
throttled.value = value.value;
|
|
991
|
-
}, delay, trailing, leading);
|
|
992
|
-
vueDemi.watch(value, () => updater());
|
|
993
|
-
return throttled;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
1039
|
function useTimeoutFn(cb, interval, options = {}) {
|
|
997
1040
|
const {
|
|
998
1041
|
immediate = true
|
|
@@ -1132,9 +1175,11 @@ exports.controlledRef = controlledRef;
|
|
|
1132
1175
|
exports.createEventHook = createEventHook;
|
|
1133
1176
|
exports.createFilterWrapper = createFilterWrapper;
|
|
1134
1177
|
exports.createGlobalState = createGlobalState;
|
|
1178
|
+
exports.createReactiveFn = reactify;
|
|
1135
1179
|
exports.createSharedComposable = createSharedComposable;
|
|
1136
1180
|
exports.createSingletonPromise = createSingletonPromise;
|
|
1137
1181
|
exports.debounceFilter = debounceFilter;
|
|
1182
|
+
exports.debouncedRef = useDebounce;
|
|
1138
1183
|
exports.debouncedWatch = debouncedWatch;
|
|
1139
1184
|
exports.eagerComputed = eagerComputed;
|
|
1140
1185
|
exports.extendRef = extendRef;
|
|
@@ -1169,6 +1214,7 @@ exports.refDefault = refDefault;
|
|
|
1169
1214
|
exports.set = set;
|
|
1170
1215
|
exports.syncRef = syncRef;
|
|
1171
1216
|
exports.throttleFilter = throttleFilter;
|
|
1217
|
+
exports.throttledRef = useThrottle;
|
|
1172
1218
|
exports.throttledWatch = throttledWatch;
|
|
1173
1219
|
exports.timestamp = timestamp;
|
|
1174
1220
|
exports.toReactive = toReactive;
|