@vueuse/shared 10.2.1 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -2,33 +2,14 @@
2
2
 
3
3
  var vueDemi = require('vue-demi');
4
4
 
5
- var __defProp$b = Object.defineProperty;
6
- var __defProps$8 = Object.defineProperties;
7
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
8
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
9
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
10
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues$b = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp$d.call(b, prop))
15
- __defNormalProp$b(a, prop, b[prop]);
16
- if (__getOwnPropSymbols$d)
17
- for (var prop of __getOwnPropSymbols$d(b)) {
18
- if (__propIsEnum$d.call(b, prop))
19
- __defNormalProp$b(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
24
5
  function computedEager(fn, options) {
25
- var _a;
26
6
  const result = vueDemi.shallowRef();
27
7
  vueDemi.watchEffect(() => {
28
8
  result.value = fn();
29
- }, __spreadProps$8(__spreadValues$b({}, options), {
30
- flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
31
- }));
9
+ }, {
10
+ ...options,
11
+ flush: options?.flush ?? "sync"
12
+ });
32
13
  return vueDemi.readonly(result);
33
14
  }
34
15
 
@@ -57,7 +38,7 @@ function computedWithControl(source, fn) {
57
38
  return v;
58
39
  },
59
40
  set(v2) {
60
- set == null ? void 0 : set(v2);
41
+ set?.(v2);
61
42
  }
62
43
  };
63
44
  });
@@ -180,25 +161,9 @@ function isDefined(v) {
180
161
  return vueDemi.unref(v) != null;
181
162
  }
182
163
 
183
- var __defProp$a = Object.defineProperty;
184
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
185
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
186
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
187
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
188
- var __spreadValues$a = (a, b) => {
189
- for (var prop in b || (b = {}))
190
- if (__hasOwnProp$c.call(b, prop))
191
- __defNormalProp$a(a, prop, b[prop]);
192
- if (__getOwnPropSymbols$c)
193
- for (var prop of __getOwnPropSymbols$c(b)) {
194
- if (__propIsEnum$c.call(b, prop))
195
- __defNormalProp$a(a, prop, b[prop]);
196
- }
197
- return a;
198
- };
199
164
  function makeDestructurable(obj, arr) {
200
165
  if (typeof Symbol !== "undefined") {
201
- const clone = __spreadValues$a({}, obj);
166
+ const clone = { ...obj };
202
167
  Object.defineProperty(clone, Symbol.iterator, {
203
168
  enumerable: false,
204
169
  value() {
@@ -223,7 +188,7 @@ function toValue(r) {
223
188
  const resolveUnref = toValue;
224
189
 
225
190
  function reactify(fn, options) {
226
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
191
+ const unrefFn = options?.computedGetter === false ? vueDemi.unref : toValue;
227
192
  return function(...args) {
228
193
  return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
229
194
  };
@@ -297,7 +262,7 @@ function reactiveOmit(obj, ...keys) {
297
262
  );
298
263
  }
299
264
 
300
- const isClient = typeof window !== "undefined";
265
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
301
266
  const isDef = (val) => typeof val !== "undefined";
302
267
  const notNullish = (val) => val != null;
303
268
  const assert = (condition, ...infos) => {
@@ -319,8 +284,7 @@ const rand = (min, max) => {
319
284
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
320
285
  const isIOS = /* @__PURE__ */ getIsIOS();
321
286
  function getIsIOS() {
322
- var _a;
323
- return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
287
+ return isClient && window?.navigator?.userAgent && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
324
288
  }
325
289
 
326
290
  function createFilterWrapper(filter, fn) {
@@ -442,6 +406,22 @@ const directiveHooks = {
442
406
  unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
443
407
  };
444
408
 
409
+ function cacheStringFunction(fn) {
410
+ const cache = /* @__PURE__ */ Object.create(null);
411
+ return (str) => {
412
+ const hit = cache[str];
413
+ return hit || (cache[str] = fn(str));
414
+ };
415
+ }
416
+ const hyphenateRE = /\B([A-Z])/g;
417
+ const hyphenate = cacheStringFunction(
418
+ (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
419
+ );
420
+ const camelizeRE = /-(\w)/g;
421
+ const camelize = cacheStringFunction((str) => {
422
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
423
+ });
424
+
445
425
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
446
426
  return new Promise((resolve, reject) => {
447
427
  if (throwOnTimeout)
@@ -475,10 +455,9 @@ function containsProp(obj, ...props) {
475
455
  return props.some((k) => k in obj);
476
456
  }
477
457
  function increaseWithUnit(target, delta) {
478
- var _a;
479
458
  if (typeof target === "number")
480
459
  return target + delta;
481
- const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
460
+ const value = target.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
482
461
  const unit = target.slice(value.length);
483
462
  const result = Number.parseFloat(value) + delta;
484
463
  if (Number.isNaN(result))
@@ -519,10 +498,10 @@ function reactivePick(obj, ...keys) {
519
498
 
520
499
  function refAutoReset(defaultValue, afterMs = 1e4) {
521
500
  return vueDemi.customRef((track, trigger) => {
522
- let value = defaultValue;
501
+ let value = toValue(defaultValue);
523
502
  let timer;
524
503
  const resetAfter = () => setTimeout(() => {
525
- value = defaultValue;
504
+ value = toValue(defaultValue);
526
505
  trigger();
527
506
  }, toValue(afterMs));
528
507
  tryOnScopeDispose(() => {
@@ -562,8 +541,7 @@ function refDebounced(value, ms = 200, options = {}) {
562
541
  function refDefault(source, defaultValue) {
563
542
  return vueDemi.computed({
564
543
  get() {
565
- var _a;
566
- return (_a = source.value) != null ? _a : defaultValue;
544
+ return source.value ?? defaultValue;
567
545
  },
568
546
  set(value) {
569
547
  source.value = value;
@@ -611,14 +589,13 @@ function refWithControl(initial, options = {}) {
611
589
  return source;
612
590
  }
613
591
  function set(value, triggering = true) {
614
- var _a, _b;
615
592
  if (value === source)
616
593
  return;
617
594
  const old = source;
618
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
595
+ if (options.onBeforeChange?.(value, old) === false)
619
596
  return;
620
597
  source = value;
621
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
598
+ options.onChanged?.(value, old);
622
599
  if (triggering)
623
600
  trigger();
624
601
  }
@@ -656,8 +633,39 @@ function set(...args) {
656
633
  }
657
634
  }
658
635
 
636
+ function watchWithFilter(source, cb, options = {}) {
637
+ const {
638
+ eventFilter = bypassFilter,
639
+ ...watchOptions
640
+ } = options;
641
+ return vueDemi.watch(
642
+ source,
643
+ createFilterWrapper(
644
+ eventFilter,
645
+ cb
646
+ ),
647
+ watchOptions
648
+ );
649
+ }
650
+
651
+ function watchPausable(source, cb, options = {}) {
652
+ const {
653
+ eventFilter: filter,
654
+ ...watchOptions
655
+ } = options;
656
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
657
+ const stop = watchWithFilter(
658
+ source,
659
+ cb,
660
+ {
661
+ ...watchOptions,
662
+ eventFilter
663
+ }
664
+ );
665
+ return { stop, pause, resume, isActive };
666
+ }
667
+
659
668
  function syncRef(left, right, options = {}) {
660
- var _a, _b;
661
669
  const {
662
670
  flush = "sync",
663
671
  deep = false,
@@ -665,28 +673,35 @@ function syncRef(left, right, options = {}) {
665
673
  direction = "both",
666
674
  transform = {}
667
675
  } = options;
668
- let watchLeft;
669
- let watchRight;
670
- const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
671
- const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
676
+ const watchers = [];
677
+ const transformLTR = transform.ltr ?? ((v) => v);
678
+ const transformRTL = transform.rtl ?? ((v) => v);
672
679
  if (direction === "both" || direction === "ltr") {
673
- watchLeft = vueDemi.watch(
680
+ watchers.push(watchPausable(
674
681
  left,
675
- (newValue) => right.value = transformLTR(newValue),
682
+ (newValue) => {
683
+ watchers.forEach((w) => w.pause());
684
+ right.value = transformLTR(newValue);
685
+ watchers.forEach((w) => w.resume());
686
+ },
676
687
  { flush, deep, immediate }
677
- );
688
+ ));
678
689
  }
679
690
  if (direction === "both" || direction === "rtl") {
680
- watchRight = vueDemi.watch(
691
+ watchers.push(watchPausable(
681
692
  right,
682
- (newValue) => left.value = transformRTL(newValue),
693
+ (newValue) => {
694
+ watchers.forEach((w) => w.pause());
695
+ left.value = transformRTL(newValue);
696
+ watchers.forEach((w) => w.resume());
697
+ },
683
698
  { flush, deep, immediate }
684
- );
699
+ ));
685
700
  }
686
- return () => {
687
- watchLeft == null ? void 0 : watchLeft();
688
- watchRight == null ? void 0 : watchRight();
701
+ const stop = () => {
702
+ watchers.forEach((w) => w.stop());
689
703
  };
704
+ return stop;
690
705
  }
691
706
 
692
707
  function syncRefs(source, targets, options = {}) {
@@ -704,43 +719,29 @@ function syncRefs(source, targets, options = {}) {
704
719
  );
705
720
  }
706
721
 
707
- var __defProp$9 = Object.defineProperty;
708
- var __defProps$7 = Object.defineProperties;
709
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
710
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
711
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
712
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
713
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
714
- var __spreadValues$9 = (a, b) => {
715
- for (var prop in b || (b = {}))
716
- if (__hasOwnProp$b.call(b, prop))
717
- __defNormalProp$9(a, prop, b[prop]);
718
- if (__getOwnPropSymbols$b)
719
- for (var prop of __getOwnPropSymbols$b(b)) {
720
- if (__propIsEnum$b.call(b, prop))
721
- __defNormalProp$9(a, prop, b[prop]);
722
- }
723
- return a;
724
- };
725
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
726
- function toRefs(objectRef) {
722
+ function toRefs(objectRef, options = {}) {
727
723
  if (!vueDemi.isRef(objectRef))
728
724
  return vueDemi.toRefs(objectRef);
729
- const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
725
+ const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
730
726
  for (const key in objectRef.value) {
731
727
  result[key] = vueDemi.customRef(() => ({
732
728
  get() {
733
729
  return objectRef.value[key];
734
730
  },
735
731
  set(v) {
736
- if (Array.isArray(objectRef.value)) {
737
- const copy = [...objectRef.value];
738
- copy[key] = v;
739
- objectRef.value = copy;
732
+ const replaceRef = toValue(options.replaceRef) ?? true;
733
+ if (replaceRef) {
734
+ if (Array.isArray(objectRef.value)) {
735
+ const copy = [...objectRef.value];
736
+ copy[key] = v;
737
+ objectRef.value = copy;
738
+ } else {
739
+ const newObject = { ...objectRef.value, [key]: v };
740
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
741
+ objectRef.value = newObject;
742
+ }
740
743
  } else {
741
- const newObject = __spreadProps$7(__spreadValues$9({}, objectRef.value), { [key]: v });
742
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
743
- objectRef.value = newObject;
744
+ objectRef.value[key] = v;
744
745
  }
745
746
  }
746
747
  }));
@@ -784,7 +785,7 @@ function createUntil(r, isNot = false) {
784
785
  r,
785
786
  (v) => {
786
787
  if (condition(v) !== isNot) {
787
- stop == null ? void 0 : stop();
788
+ stop?.();
788
789
  resolve(v);
789
790
  }
790
791
  },
@@ -798,7 +799,7 @@ function createUntil(r, isNot = false) {
798
799
  const promises = [watcher];
799
800
  if (timeout != null) {
800
801
  promises.push(
801
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
802
+ promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop?.())
802
803
  );
803
804
  }
804
805
  return Promise.race(promises);
@@ -806,14 +807,14 @@ function createUntil(r, isNot = false) {
806
807
  function toBe(value, options) {
807
808
  if (!vueDemi.isRef(value))
808
809
  return toMatch((v) => v === value, options);
809
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
810
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options ?? {};
810
811
  let stop = null;
811
812
  const watcher = new Promise((resolve) => {
812
813
  stop = vueDemi.watch(
813
814
  [r, value],
814
815
  ([v1, v2]) => {
815
816
  if (isNot !== (v1 === v2)) {
816
- stop == null ? void 0 : stop();
817
+ stop?.();
817
818
  resolve(v1);
818
819
  }
819
820
  },
@@ -828,7 +829,7 @@ function createUntil(r, isNot = false) {
828
829
  if (timeout != null) {
829
830
  promises.push(
830
831
  promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
831
- stop == null ? void 0 : stop();
832
+ stop?.();
832
833
  return toValue(r);
833
834
  })
834
835
  );
@@ -899,10 +900,9 @@ function defaultComparator(value, othVal) {
899
900
  return value === othVal;
900
901
  }
901
902
  function useArrayDifference(...args) {
902
- var _a;
903
903
  const list = args[0];
904
904
  const values = args[1];
905
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
905
+ let compareFn = args[2] ?? defaultComparator;
906
906
  if (typeof compareFn === "string") {
907
907
  const key = compareFn;
908
908
  compareFn = (value, othVal) => value[key] === othVal[key];
@@ -950,20 +950,19 @@ function isArrayIncludesOptions(obj) {
950
950
  return isObject(obj) && containsProp(obj, "formIndex", "comparator");
951
951
  }
952
952
  function useArrayIncludes(...args) {
953
- var _a;
954
953
  const list = args[0];
955
954
  const value = args[1];
956
955
  let comparator = args[2];
957
956
  let formIndex = 0;
958
957
  if (isArrayIncludesOptions(comparator)) {
959
- formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
958
+ formIndex = comparator.fromIndex ?? 0;
960
959
  comparator = comparator.comparator;
961
960
  }
962
961
  if (typeof comparator === "string") {
963
962
  const key = comparator;
964
963
  comparator = (element, value2) => element[key] === toValue(value2);
965
964
  }
966
- comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
965
+ comparator = comparator ?? ((element, value2) => element === toValue(value2));
967
966
  return vueDemi.computed(
968
967
  () => toValue(list).slice(formIndex).some(
969
968
  (element, index, array) => comparator(toValue(element), toValue(value), index, toValue(array))
@@ -1009,17 +1008,18 @@ function useArrayUnique(list, compareFn) {
1009
1008
  }
1010
1009
 
1011
1010
  function useCounter(initialValue = 0, options = {}) {
1011
+ let _initialValue = vueDemi.unref(initialValue);
1012
1012
  const count = vueDemi.ref(initialValue);
1013
1013
  const {
1014
- max = Infinity,
1015
- min = -Infinity
1014
+ max = Number.POSITIVE_INFINITY,
1015
+ min = Number.NEGATIVE_INFINITY
1016
1016
  } = options;
1017
1017
  const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1018
1018
  const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1019
1019
  const get = () => count.value;
1020
1020
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1021
- const reset = (val = initialValue) => {
1022
- initialValue = val;
1021
+ const reset = (val = _initialValue) => {
1022
+ _initialValue = val;
1023
1023
  return set(val);
1024
1024
  };
1025
1025
  return { count, inc, dec, get, set, reset };
@@ -1034,7 +1034,6 @@ function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1034
1034
  return isLowercase ? m.toLowerCase() : m;
1035
1035
  }
1036
1036
  function formatDate(date, formatStr, options = {}) {
1037
- var _a;
1038
1037
  const years = date.getFullYear();
1039
1038
  const month = date.getMonth();
1040
1039
  const days = date.getDate();
@@ -1043,7 +1042,7 @@ function formatDate(date, formatStr, options = {}) {
1043
1042
  const seconds = date.getSeconds();
1044
1043
  const milliseconds = date.getMilliseconds();
1045
1044
  const day = date.getDay();
1046
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
1045
+ const meridiem = options.customMeridiem ?? defaultMeridiem;
1047
1046
  const matches = {
1048
1047
  YY: () => String(years).slice(-2),
1049
1048
  YYYY: () => years,
@@ -1071,14 +1070,11 @@ function formatDate(date, formatStr, options = {}) {
1071
1070
  a: () => meridiem(hours, minutes, true),
1072
1071
  aa: () => meridiem(hours, minutes, true, true)
1073
1072
  };
1074
- return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1075
- var _a2;
1076
- return $1 || ((_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) || match;
1077
- });
1073
+ return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 ?? matches[match]?.() ?? match);
1078
1074
  }
1079
1075
  function normalizeDate(date) {
1080
1076
  if (date === null)
1081
- return /* @__PURE__ */ new Date(NaN);
1077
+ return new Date(Number.NaN);
1082
1078
  if (date === void 0)
1083
1079
  return /* @__PURE__ */ new Date();
1084
1080
  if (date instanceof Date)
@@ -1141,22 +1137,6 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1141
1137
  };
1142
1138
  }
1143
1139
 
1144
- var __defProp$8 = Object.defineProperty;
1145
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1146
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1147
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1148
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1149
- var __spreadValues$8 = (a, b) => {
1150
- for (var prop in b || (b = {}))
1151
- if (__hasOwnProp$a.call(b, prop))
1152
- __defNormalProp$8(a, prop, b[prop]);
1153
- if (__getOwnPropSymbols$a)
1154
- for (var prop of __getOwnPropSymbols$a(b)) {
1155
- if (__propIsEnum$a.call(b, prop))
1156
- __defNormalProp$8(a, prop, b[prop]);
1157
- }
1158
- return a;
1159
- };
1160
1140
  function useInterval(interval = 1e3, options = {}) {
1161
1141
  const {
1162
1142
  controls: exposeControls = false,
@@ -1177,18 +1157,18 @@ function useInterval(interval = 1e3, options = {}) {
1177
1157
  { immediate }
1178
1158
  );
1179
1159
  if (exposeControls) {
1180
- return __spreadValues$8({
1160
+ return {
1181
1161
  counter,
1182
- reset
1183
- }, controls);
1162
+ reset,
1163
+ ...controls
1164
+ };
1184
1165
  } else {
1185
1166
  return counter;
1186
1167
  }
1187
1168
  }
1188
1169
 
1189
1170
  function useLastChanged(source, options = {}) {
1190
- var _a;
1191
- const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
1171
+ const ms = vueDemi.ref(options.initialValue ?? null);
1192
1172
  vueDemi.watch(
1193
1173
  source,
1194
1174
  () => ms.value = timestamp(),
@@ -1235,37 +1215,22 @@ function useTimeoutFn(cb, interval, options = {}) {
1235
1215
  };
1236
1216
  }
1237
1217
 
1238
- var __defProp$7 = Object.defineProperty;
1239
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1240
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1241
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1242
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1243
- var __spreadValues$7 = (a, b) => {
1244
- for (var prop in b || (b = {}))
1245
- if (__hasOwnProp$9.call(b, prop))
1246
- __defNormalProp$7(a, prop, b[prop]);
1247
- if (__getOwnPropSymbols$9)
1248
- for (var prop of __getOwnPropSymbols$9(b)) {
1249
- if (__propIsEnum$9.call(b, prop))
1250
- __defNormalProp$7(a, prop, b[prop]);
1251
- }
1252
- return a;
1253
- };
1254
1218
  function useTimeout(interval = 1e3, options = {}) {
1255
1219
  const {
1256
1220
  controls: exposeControls = false,
1257
1221
  callback
1258
1222
  } = options;
1259
1223
  const controls = useTimeoutFn(
1260
- callback != null ? callback : noop,
1224
+ callback ?? noop,
1261
1225
  interval,
1262
1226
  options
1263
1227
  );
1264
1228
  const ready = vueDemi.computed(() => !controls.isPending.value);
1265
1229
  if (exposeControls) {
1266
- return __spreadValues$7({
1267
- ready
1268
- }, controls);
1230
+ return {
1231
+ ready,
1232
+ ...controls
1233
+ };
1269
1234
  } else {
1270
1235
  return ready;
1271
1236
  }
@@ -1315,11 +1280,11 @@ function useToggle(initialValue = false, options = {}) {
1315
1280
  }
1316
1281
 
1317
1282
  function watchArray(source, cb, options) {
1318
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [
1283
+ let oldList = options?.immediate ? [] : [
1319
1284
  ...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
1320
1285
  ];
1321
1286
  return vueDemi.watch(source, (newList, _, onCleanup) => {
1322
- const oldListRemains = new Array(oldList.length);
1287
+ const oldListRemains = Array.from({ length: oldList.length });
1323
1288
  const added = [];
1324
1289
  for (const obj of newList) {
1325
1290
  let found = false;
@@ -1339,58 +1304,11 @@ function watchArray(source, cb, options) {
1339
1304
  }, options);
1340
1305
  }
1341
1306
 
1342
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1343
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1344
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1345
- var __objRest$5 = (source, exclude) => {
1346
- var target = {};
1347
- for (var prop in source)
1348
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
1349
- target[prop] = source[prop];
1350
- if (source != null && __getOwnPropSymbols$8)
1351
- for (var prop of __getOwnPropSymbols$8(source)) {
1352
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
1353
- target[prop] = source[prop];
1354
- }
1355
- return target;
1356
- };
1357
- function watchWithFilter(source, cb, options = {}) {
1358
- const _a = options, {
1359
- eventFilter = bypassFilter
1360
- } = _a, watchOptions = __objRest$5(_a, [
1361
- "eventFilter"
1362
- ]);
1363
- return vueDemi.watch(
1364
- source,
1365
- createFilterWrapper(
1366
- eventFilter,
1367
- cb
1368
- ),
1369
- watchOptions
1370
- );
1371
- }
1372
-
1373
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1374
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1375
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1376
- var __objRest$4 = (source, exclude) => {
1377
- var target = {};
1378
- for (var prop in source)
1379
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1380
- target[prop] = source[prop];
1381
- if (source != null && __getOwnPropSymbols$7)
1382
- for (var prop of __getOwnPropSymbols$7(source)) {
1383
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
1384
- target[prop] = source[prop];
1385
- }
1386
- return target;
1387
- };
1388
1307
  function watchAtMost(source, cb, options) {
1389
- const _a = options, {
1390
- count
1391
- } = _a, watchOptions = __objRest$4(_a, [
1392
- "count"
1393
- ]);
1308
+ const {
1309
+ count,
1310
+ ...watchOptions
1311
+ } = options;
1394
1312
  const current = vueDemi.ref(0);
1395
1313
  const stop = watchWithFilter(
1396
1314
  source,
@@ -1405,120 +1323,38 @@ function watchAtMost(source, cb, options) {
1405
1323
  return { count: current, stop };
1406
1324
  }
1407
1325
 
1408
- var __defProp$6 = Object.defineProperty;
1409
- var __defProps$6 = Object.defineProperties;
1410
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1411
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1412
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1413
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1414
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1415
- var __spreadValues$6 = (a, b) => {
1416
- for (var prop in b || (b = {}))
1417
- if (__hasOwnProp$6.call(b, prop))
1418
- __defNormalProp$6(a, prop, b[prop]);
1419
- if (__getOwnPropSymbols$6)
1420
- for (var prop of __getOwnPropSymbols$6(b)) {
1421
- if (__propIsEnum$6.call(b, prop))
1422
- __defNormalProp$6(a, prop, b[prop]);
1423
- }
1424
- return a;
1425
- };
1426
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1427
- var __objRest$3 = (source, exclude) => {
1428
- var target = {};
1429
- for (var prop in source)
1430
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1431
- target[prop] = source[prop];
1432
- if (source != null && __getOwnPropSymbols$6)
1433
- for (var prop of __getOwnPropSymbols$6(source)) {
1434
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1435
- target[prop] = source[prop];
1436
- }
1437
- return target;
1438
- };
1439
1326
  function watchDebounced(source, cb, options = {}) {
1440
- const _a = options, {
1327
+ const {
1441
1328
  debounce = 0,
1442
- maxWait = void 0
1443
- } = _a, watchOptions = __objRest$3(_a, [
1444
- "debounce",
1445
- "maxWait"
1446
- ]);
1329
+ maxWait = void 0,
1330
+ ...watchOptions
1331
+ } = options;
1447
1332
  return watchWithFilter(
1448
1333
  source,
1449
1334
  cb,
1450
- __spreadProps$6(__spreadValues$6({}, watchOptions), {
1335
+ {
1336
+ ...watchOptions,
1451
1337
  eventFilter: debounceFilter(debounce, { maxWait })
1452
- })
1338
+ }
1453
1339
  );
1454
1340
  }
1455
1341
 
1456
- var __defProp$5 = Object.defineProperty;
1457
- var __defProps$5 = Object.defineProperties;
1458
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1459
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1460
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1461
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1462
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1463
- var __spreadValues$5 = (a, b) => {
1464
- for (var prop in b || (b = {}))
1465
- if (__hasOwnProp$5.call(b, prop))
1466
- __defNormalProp$5(a, prop, b[prop]);
1467
- if (__getOwnPropSymbols$5)
1468
- for (var prop of __getOwnPropSymbols$5(b)) {
1469
- if (__propIsEnum$5.call(b, prop))
1470
- __defNormalProp$5(a, prop, b[prop]);
1471
- }
1472
- return a;
1473
- };
1474
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1475
1342
  function watchDeep(source, cb, options) {
1476
1343
  return vueDemi.watch(
1477
1344
  source,
1478
1345
  cb,
1479
- __spreadProps$5(__spreadValues$5({}, options), {
1346
+ {
1347
+ ...options,
1480
1348
  deep: true
1481
- })
1349
+ }
1482
1350
  );
1483
1351
  }
1484
1352
 
1485
- var __defProp$4 = Object.defineProperty;
1486
- var __defProps$4 = Object.defineProperties;
1487
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1488
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1489
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1490
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1491
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1492
- var __spreadValues$4 = (a, b) => {
1493
- for (var prop in b || (b = {}))
1494
- if (__hasOwnProp$4.call(b, prop))
1495
- __defNormalProp$4(a, prop, b[prop]);
1496
- if (__getOwnPropSymbols$4)
1497
- for (var prop of __getOwnPropSymbols$4(b)) {
1498
- if (__propIsEnum$4.call(b, prop))
1499
- __defNormalProp$4(a, prop, b[prop]);
1500
- }
1501
- return a;
1502
- };
1503
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1504
- var __objRest$2 = (source, exclude) => {
1505
- var target = {};
1506
- for (var prop in source)
1507
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1508
- target[prop] = source[prop];
1509
- if (source != null && __getOwnPropSymbols$4)
1510
- for (var prop of __getOwnPropSymbols$4(source)) {
1511
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1512
- target[prop] = source[prop];
1513
- }
1514
- return target;
1515
- };
1516
1353
  function watchIgnorable(source, cb, options = {}) {
1517
- const _a = options, {
1518
- eventFilter = bypassFilter
1519
- } = _a, watchOptions = __objRest$2(_a, [
1520
- "eventFilter"
1521
- ]);
1354
+ const {
1355
+ eventFilter = bypassFilter,
1356
+ ...watchOptions
1357
+ } = options;
1522
1358
  const filteredCb = createFilterWrapper(
1523
1359
  eventFilter,
1524
1360
  cb
@@ -1556,7 +1392,7 @@ function watchIgnorable(source, cb, options = {}) {
1556
1392
  () => {
1557
1393
  syncCounter.value++;
1558
1394
  },
1559
- __spreadProps$4(__spreadValues$4({}, watchOptions), { flush: "sync" })
1395
+ { ...watchOptions, flush: "sync" }
1560
1396
  )
1561
1397
  );
1562
1398
  ignoreUpdates = (updater) => {
@@ -1585,32 +1421,14 @@ function watchIgnorable(source, cb, options = {}) {
1585
1421
  return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1586
1422
  }
1587
1423
 
1588
- var __defProp$3 = Object.defineProperty;
1589
- var __defProps$3 = Object.defineProperties;
1590
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1591
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1592
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1593
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1594
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1595
- var __spreadValues$3 = (a, b) => {
1596
- for (var prop in b || (b = {}))
1597
- if (__hasOwnProp$3.call(b, prop))
1598
- __defNormalProp$3(a, prop, b[prop]);
1599
- if (__getOwnPropSymbols$3)
1600
- for (var prop of __getOwnPropSymbols$3(b)) {
1601
- if (__propIsEnum$3.call(b, prop))
1602
- __defNormalProp$3(a, prop, b[prop]);
1603
- }
1604
- return a;
1605
- };
1606
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1607
1424
  function watchImmediate(source, cb, options) {
1608
1425
  return vueDemi.watch(
1609
1426
  source,
1610
1427
  cb,
1611
- __spreadProps$3(__spreadValues$3({}, options), {
1428
+ {
1429
+ ...options,
1612
1430
  immediate: true
1613
- })
1431
+ }
1614
1432
  );
1615
1433
  }
1616
1434
 
@@ -1621,123 +1439,23 @@ function watchOnce(source, cb, options) {
1621
1439
  }, options);
1622
1440
  }
1623
1441
 
1624
- var __defProp$2 = Object.defineProperty;
1625
- var __defProps$2 = Object.defineProperties;
1626
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1627
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1628
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1629
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1630
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1631
- var __spreadValues$2 = (a, b) => {
1632
- for (var prop in b || (b = {}))
1633
- if (__hasOwnProp$2.call(b, prop))
1634
- __defNormalProp$2(a, prop, b[prop]);
1635
- if (__getOwnPropSymbols$2)
1636
- for (var prop of __getOwnPropSymbols$2(b)) {
1637
- if (__propIsEnum$2.call(b, prop))
1638
- __defNormalProp$2(a, prop, b[prop]);
1639
- }
1640
- return a;
1641
- };
1642
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1643
- var __objRest$1 = (source, exclude) => {
1644
- var target = {};
1645
- for (var prop in source)
1646
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1647
- target[prop] = source[prop];
1648
- if (source != null && __getOwnPropSymbols$2)
1649
- for (var prop of __getOwnPropSymbols$2(source)) {
1650
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1651
- target[prop] = source[prop];
1652
- }
1653
- return target;
1654
- };
1655
- function watchPausable(source, cb, options = {}) {
1656
- const _a = options, {
1657
- eventFilter: filter
1658
- } = _a, watchOptions = __objRest$1(_a, [
1659
- "eventFilter"
1660
- ]);
1661
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
1662
- const stop = watchWithFilter(
1663
- source,
1664
- cb,
1665
- __spreadProps$2(__spreadValues$2({}, watchOptions), {
1666
- eventFilter
1667
- })
1668
- );
1669
- return { stop, pause, resume, isActive };
1670
- }
1671
-
1672
- var __defProp$1 = Object.defineProperty;
1673
- var __defProps$1 = Object.defineProperties;
1674
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1675
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1676
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1677
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1678
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1679
- var __spreadValues$1 = (a, b) => {
1680
- for (var prop in b || (b = {}))
1681
- if (__hasOwnProp$1.call(b, prop))
1682
- __defNormalProp$1(a, prop, b[prop]);
1683
- if (__getOwnPropSymbols$1)
1684
- for (var prop of __getOwnPropSymbols$1(b)) {
1685
- if (__propIsEnum$1.call(b, prop))
1686
- __defNormalProp$1(a, prop, b[prop]);
1687
- }
1688
- return a;
1689
- };
1690
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1691
- var __objRest = (source, exclude) => {
1692
- var target = {};
1693
- for (var prop in source)
1694
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1695
- target[prop] = source[prop];
1696
- if (source != null && __getOwnPropSymbols$1)
1697
- for (var prop of __getOwnPropSymbols$1(source)) {
1698
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1699
- target[prop] = source[prop];
1700
- }
1701
- return target;
1702
- };
1703
1442
  function watchThrottled(source, cb, options = {}) {
1704
- const _a = options, {
1443
+ const {
1705
1444
  throttle = 0,
1706
1445
  trailing = true,
1707
- leading = true
1708
- } = _a, watchOptions = __objRest(_a, [
1709
- "throttle",
1710
- "trailing",
1711
- "leading"
1712
- ]);
1446
+ leading = true,
1447
+ ...watchOptions
1448
+ } = options;
1713
1449
  return watchWithFilter(
1714
1450
  source,
1715
1451
  cb,
1716
- __spreadProps$1(__spreadValues$1({}, watchOptions), {
1452
+ {
1453
+ ...watchOptions,
1717
1454
  eventFilter: throttleFilter(throttle, trailing, leading)
1718
- })
1455
+ }
1719
1456
  );
1720
1457
  }
1721
1458
 
1722
- var __defProp = Object.defineProperty;
1723
- var __defProps = Object.defineProperties;
1724
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1725
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1726
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1727
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1728
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1729
- var __spreadValues = (a, b) => {
1730
- for (var prop in b || (b = {}))
1731
- if (__hasOwnProp.call(b, prop))
1732
- __defNormalProp(a, prop, b[prop]);
1733
- if (__getOwnPropSymbols)
1734
- for (var prop of __getOwnPropSymbols(b)) {
1735
- if (__propIsEnum.call(b, prop))
1736
- __defNormalProp(a, prop, b[prop]);
1737
- }
1738
- return a;
1739
- };
1740
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1741
1459
  function watchTriggerable(source, cb, options = {}) {
1742
1460
  let cleanupFn;
1743
1461
  function onEffect() {
@@ -1763,9 +1481,10 @@ function watchTriggerable(source, cb, options = {}) {
1763
1481
  });
1764
1482
  return res2;
1765
1483
  };
1766
- return __spreadProps(__spreadValues({}, res), {
1484
+ return {
1485
+ ...res,
1767
1486
  trigger
1768
- });
1487
+ };
1769
1488
  }
1770
1489
  function getWatchSources(sources) {
1771
1490
  if (vueDemi.isReactive(sources))
@@ -1792,6 +1511,7 @@ function whenever(source, cb, options) {
1792
1511
  exports.assert = assert;
1793
1512
  exports.autoResetRef = refAutoReset;
1794
1513
  exports.bypassFilter = bypassFilter;
1514
+ exports.camelize = camelize;
1795
1515
  exports.clamp = clamp;
1796
1516
  exports.computedEager = computedEager;
1797
1517
  exports.computedWithControl = computedWithControl;
@@ -1814,6 +1534,7 @@ exports.extendRef = extendRef;
1814
1534
  exports.formatDate = formatDate;
1815
1535
  exports.get = get;
1816
1536
  exports.hasOwn = hasOwn;
1537
+ exports.hyphenate = hyphenate;
1817
1538
  exports.identity = identity;
1818
1539
  exports.ignorableWatch = watchIgnorable;
1819
1540
  exports.increaseWithUnit = increaseWithUnit;