@vueuse/components 10.7.2 → 10.9.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
@@ -449,26 +449,29 @@ function useStorage(key, defaults, storage, options = {}) {
449
449
  }
450
450
  if (!initOnMounted)
451
451
  update();
452
- return data;
452
+ function dispatchWriteEvent(oldValue, newValue) {
453
+ if (window) {
454
+ window.dispatchEvent(new CustomEvent(customStorageEventName, {
455
+ detail: {
456
+ key,
457
+ oldValue,
458
+ newValue,
459
+ storageArea: storage
460
+ }
461
+ }));
462
+ }
463
+ }
453
464
  function write(v) {
454
465
  try {
466
+ const oldValue = storage.getItem(key);
455
467
  if (v == null) {
468
+ dispatchWriteEvent(oldValue, null);
456
469
  storage.removeItem(key);
457
470
  } else {
458
471
  const serialized = serializer.write(v);
459
- const oldValue = storage.getItem(key);
460
472
  if (oldValue !== serialized) {
461
473
  storage.setItem(key, serialized);
462
- if (window) {
463
- window.dispatchEvent(new CustomEvent(customStorageEventName, {
464
- detail: {
465
- key,
466
- oldValue,
467
- newValue: serialized,
468
- storageArea: storage
469
- }
470
- }));
471
- }
474
+ dispatchWriteEvent(oldValue, serialized);
472
475
  }
473
476
  }
474
477
  } catch (e) {
@@ -494,9 +497,6 @@ function useStorage(key, defaults, storage, options = {}) {
494
497
  return serializer.read(rawValue);
495
498
  }
496
499
  }
497
- function updateFromCustomEvent(event) {
498
- update(event.detail);
499
- }
500
500
  function update(event) {
501
501
  if (event && event.storageArea !== storage)
502
502
  return;
@@ -519,14 +519,19 @@ function useStorage(key, defaults, storage, options = {}) {
519
519
  resumeWatch();
520
520
  }
521
521
  }
522
+ function updateFromCustomEvent(event) {
523
+ update(event.detail);
524
+ }
525
+ return data;
522
526
  }
523
527
 
524
528
  function useMounted() {
525
529
  const isMounted = vueDemi.ref(false);
526
- if (vueDemi.getCurrentInstance()) {
530
+ const instance = vueDemi.getCurrentInstance();
531
+ if (instance) {
527
532
  vueDemi.onMounted(() => {
528
533
  isMounted.value = true;
529
- });
534
+ }, vueDemi.isVue2 ? null : instance);
530
535
  }
531
536
  return isMounted;
532
537
  }
@@ -766,7 +771,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
766
771
  "axis",
767
772
  "onStart",
768
773
  "onMove",
769
- "onEnd"
774
+ "onEnd",
775
+ "disabled"
770
776
  ],
771
777
  setup(props, { slots }) {
772
778
  const target = vueDemi.ref();
@@ -774,6 +780,7 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
774
780
  var _a;
775
781
  return (_a = props.handle) != null ? _a : target.value;
776
782
  });
783
+ const disabled = vueDemi.computed(() => !!props.disabled);
777
784
  const storageValue = props.storageKey && core.useStorage(
778
785
  props.storageKey,
779
786
  shared.toValue(props.initialValue) || { x: 0, y: 0 },
@@ -792,7 +799,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
792
799
  ...props,
793
800
  handle,
794
801
  initialValue,
795
- onEnd
802
+ onEnd,
803
+ disabled
796
804
  }));
797
805
  return () => {
798
806
  if (slots.default)
@@ -883,7 +891,7 @@ function useResizeObserver(target, callback, options = {}) {
883
891
  _el && observer.observe(_el, observerOptions);
884
892
  }
885
893
  },
886
- { immediate: true, flush: "post", deep: true }
894
+ { immediate: true, flush: "post" }
887
895
  );
888
896
  const stop = () => {
889
897
  cleanup();
@@ -1038,7 +1046,7 @@ function useIntersectionObserver(target, callback, options = {}) {
1038
1046
  }
1039
1047
 
1040
1048
  function useElementVisibility(element, options = {}) {
1041
- const { window = defaultWindow, scrollTarget } = options;
1049
+ const { window = defaultWindow, scrollTarget, threshold = 0 } = options;
1042
1050
  const elementIsVisible = vueDemi.ref(false);
1043
1051
  useIntersectionObserver(
1044
1052
  element,
@@ -1056,7 +1064,7 @@ function useElementVisibility(element, options = {}) {
1056
1064
  {
1057
1065
  root: scrollTarget,
1058
1066
  window,
1059
- threshold: 0
1067
+ threshold
1060
1068
  }
1061
1069
  );
1062
1070
  return elementIsVisible;
@@ -1270,7 +1278,10 @@ function useScroll(element, options = {}) {
1270
1278
  passive: true
1271
1279
  },
1272
1280
  behavior = "auto",
1273
- window = defaultWindow
1281
+ window = defaultWindow,
1282
+ onError = (e) => {
1283
+ console.error(e);
1284
+ }
1274
1285
  } = options;
1275
1286
  const internalX = vueDemi.ref(0);
1276
1287
  const internalY = vueDemi.ref(0);
@@ -1331,12 +1342,12 @@ function useScroll(element, options = {}) {
1331
1342
  var _a;
1332
1343
  if (!window)
1333
1344
  return;
1334
- const el = target.document ? target.document.documentElement : (_a = target.documentElement) != null ? _a : target;
1345
+ const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
1335
1346
  const { display, flexDirection } = getComputedStyle(el);
1336
1347
  const scrollLeft = el.scrollLeft;
1337
1348
  directions.left = scrollLeft < internalX.value;
1338
1349
  directions.right = scrollLeft > internalX.value;
1339
- const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
1350
+ const left = Math.abs(scrollLeft) <= (offset.left || 0);
1340
1351
  const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1341
1352
  if (display === "flex" && flexDirection === "row-reverse") {
1342
1353
  arrivedState.left = right;
@@ -1351,7 +1362,7 @@ function useScroll(element, options = {}) {
1351
1362
  scrollTop = window.document.body.scrollTop;
1352
1363
  directions.top = scrollTop < internalY.value;
1353
1364
  directions.bottom = scrollTop > internalY.value;
1354
- const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
1365
+ const top = Math.abs(scrollTop) <= (offset.top || 0);
1355
1366
  const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1356
1367
  if (display === "flex" && flexDirection === "column-reverse") {
1357
1368
  arrivedState.top = bottom;
@@ -1379,10 +1390,14 @@ function useScroll(element, options = {}) {
1379
1390
  eventListenerOptions
1380
1391
  );
1381
1392
  shared.tryOnMounted(() => {
1382
- const _element = shared.toValue(element);
1383
- if (!_element)
1384
- return;
1385
- setArrivedState(_element);
1393
+ try {
1394
+ const _element = shared.toValue(element);
1395
+ if (!_element)
1396
+ return;
1397
+ setArrivedState(_element);
1398
+ } catch (e) {
1399
+ onError(e);
1400
+ }
1386
1401
  });
1387
1402
  useEventListener(
1388
1403
  element,
@@ -1732,16 +1747,21 @@ function useMutationObserver(target, callback, options = {}) {
1732
1747
  observer = void 0;
1733
1748
  }
1734
1749
  };
1750
+ const targets = vueDemi.computed(() => {
1751
+ const value = shared.toValue(target);
1752
+ const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(shared.notNullish);
1753
+ return new Set(items);
1754
+ });
1735
1755
  const stopWatch = vueDemi.watch(
1736
- () => unrefElement(target),
1737
- (el) => {
1756
+ () => targets.value,
1757
+ (targets2) => {
1738
1758
  cleanup();
1739
- if (isSupported.value && window && el) {
1759
+ if (isSupported.value && window && targets2.size) {
1740
1760
  observer = new MutationObserver(callback);
1741
- observer.observe(el, mutationOptions);
1761
+ targets2.forEach((el) => observer.observe(el, mutationOptions));
1742
1762
  }
1743
1763
  },
1744
- { immediate: true }
1764
+ { immediate: true, flush: "post" }
1745
1765
  );
1746
1766
  const takeRecords = () => {
1747
1767
  return observer == null ? void 0 : observer.takeRecords();
@@ -1926,13 +1946,12 @@ const elInitialOverflow = /* @__PURE__ */ new WeakMap();
1926
1946
  function useScrollLock(element, initialState = false) {
1927
1947
  const isLocked = vueDemi.ref(initialState);
1928
1948
  let stopTouchMoveListener = null;
1929
- let initialOverflow;
1930
1949
  vueDemi.watch(shared.toRef(element), (el) => {
1931
1950
  const target = resolveElement(shared.toValue(el));
1932
1951
  if (target) {
1933
1952
  const ele = target;
1934
1953
  if (!elInitialOverflow.get(ele))
1935
- elInitialOverflow.set(ele, initialOverflow);
1954
+ elInitialOverflow.set(ele, ele.style.overflow);
1936
1955
  if (isLocked.value)
1937
1956
  ele.style.overflow = "hidden";
1938
1957
  }
package/index.d.cts CHANGED
@@ -119,14 +119,14 @@ interface UseClipboardProps<Source = string> extends UseClipboardOptions<Source>
119
119
  declare const UseClipboard: vue_demi.DefineComponent<UseClipboardProps<string>, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<UseClipboardProps<string>>, {}, {}>;
120
120
 
121
121
  interface StorageLike {
122
- getItem(key: string): string | null;
123
- setItem(key: string, value: string): void;
124
- removeItem(key: string): void;
122
+ getItem: (key: string) => string | null;
123
+ setItem: (key: string, value: string) => void;
124
+ removeItem: (key: string) => void;
125
125
  }
126
126
 
127
127
  interface Serializer<T> {
128
- read(raw: string): T;
129
- write(value: T): string;
128
+ read: (raw: string) => T;
129
+ write: (value: T) => string;
130
130
  }
131
131
  interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
132
132
  /**
@@ -328,7 +328,28 @@ declare const vElementSize: ObjectDirective<HTMLElement, BindingValueFunction$4
328
328
 
329
329
  declare const UseElementVisibility: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<RenderableComponent>, {}, {}>;
330
330
 
331
- interface UseElementVisibilityOptions extends ConfigurableWindow {
331
+ interface UseIntersectionObserverOptions extends ConfigurableWindow {
332
+ /**
333
+ * Start the IntersectionObserver immediately on creation
334
+ *
335
+ * @default true
336
+ */
337
+ immediate?: boolean;
338
+ /**
339
+ * The Element or Document whose bounds are used as the bounding box when testing for intersection.
340
+ */
341
+ root?: MaybeComputedElementRef;
342
+ /**
343
+ * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
344
+ */
345
+ rootMargin?: string;
346
+ /**
347
+ * Either a single number or an array of numbers between 0.0 and 1.
348
+ */
349
+ threshold?: number | number[];
350
+ }
351
+
352
+ interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'threshold'> {
332
353
  scrollTarget?: MaybeRefOrGetter<HTMLElement | undefined | null>;
333
354
  }
334
355
 
@@ -422,6 +443,12 @@ interface UseScrollOptions extends ConfigurableWindow {
422
443
  * @default 'auto'
423
444
  */
424
445
  behavior?: MaybeRefOrGetter<ScrollBehavior>;
446
+ /**
447
+ * On error callback
448
+ *
449
+ * Default log error to `console.error`
450
+ */
451
+ onError?: (error: unknown) => void;
425
452
  }
426
453
  /**
427
454
  * Reactive scroll.
@@ -490,27 +517,6 @@ type BindingValueFunction$2 = Parameters<typeof useInfiniteScroll>[1];
490
517
  type BindingValueArray$2 = [BindingValueFunction$2, UseInfiniteScrollOptions];
491
518
  declare const vInfiniteScroll: ObjectDirective<HTMLElement, BindingValueFunction$2 | BindingValueArray$2>;
492
519
 
493
- interface UseIntersectionObserverOptions extends ConfigurableWindow {
494
- /**
495
- * Start the IntersectionObserver immediately on creation
496
- *
497
- * @default true
498
- */
499
- immediate?: boolean;
500
- /**
501
- * The Element or Document whose bounds are used as the bounding box when testing for intersection.
502
- */
503
- root?: MaybeComputedElementRef;
504
- /**
505
- * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
506
- */
507
- rootMargin?: string;
508
- /**
509
- * Either a single number or an array of numbers between 0.0 and 1.
510
- */
511
- threshold?: number | number[];
512
- }
513
-
514
520
  type BindingValueFunction$1 = IntersectionObserverCallback;
515
521
  type BindingValueArray$1 = [BindingValueFunction$1, UseIntersectionObserverOptions];
516
522
  declare const vIntersectionObserver: ObjectDirective<HTMLElement, BindingValueFunction$1 | BindingValueArray$1>;
package/index.d.mts CHANGED
@@ -119,14 +119,14 @@ interface UseClipboardProps<Source = string> extends UseClipboardOptions<Source>
119
119
  declare const UseClipboard: vue_demi.DefineComponent<UseClipboardProps<string>, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<UseClipboardProps<string>>, {}, {}>;
120
120
 
121
121
  interface StorageLike {
122
- getItem(key: string): string | null;
123
- setItem(key: string, value: string): void;
124
- removeItem(key: string): void;
122
+ getItem: (key: string) => string | null;
123
+ setItem: (key: string, value: string) => void;
124
+ removeItem: (key: string) => void;
125
125
  }
126
126
 
127
127
  interface Serializer<T> {
128
- read(raw: string): T;
129
- write(value: T): string;
128
+ read: (raw: string) => T;
129
+ write: (value: T) => string;
130
130
  }
131
131
  interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
132
132
  /**
@@ -328,7 +328,28 @@ declare const vElementSize: ObjectDirective<HTMLElement, BindingValueFunction$4
328
328
 
329
329
  declare const UseElementVisibility: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<RenderableComponent>, {}, {}>;
330
330
 
331
- interface UseElementVisibilityOptions extends ConfigurableWindow {
331
+ interface UseIntersectionObserverOptions extends ConfigurableWindow {
332
+ /**
333
+ * Start the IntersectionObserver immediately on creation
334
+ *
335
+ * @default true
336
+ */
337
+ immediate?: boolean;
338
+ /**
339
+ * The Element or Document whose bounds are used as the bounding box when testing for intersection.
340
+ */
341
+ root?: MaybeComputedElementRef;
342
+ /**
343
+ * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
344
+ */
345
+ rootMargin?: string;
346
+ /**
347
+ * Either a single number or an array of numbers between 0.0 and 1.
348
+ */
349
+ threshold?: number | number[];
350
+ }
351
+
352
+ interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'threshold'> {
332
353
  scrollTarget?: MaybeRefOrGetter<HTMLElement | undefined | null>;
333
354
  }
334
355
 
@@ -422,6 +443,12 @@ interface UseScrollOptions extends ConfigurableWindow {
422
443
  * @default 'auto'
423
444
  */
424
445
  behavior?: MaybeRefOrGetter<ScrollBehavior>;
446
+ /**
447
+ * On error callback
448
+ *
449
+ * Default log error to `console.error`
450
+ */
451
+ onError?: (error: unknown) => void;
425
452
  }
426
453
  /**
427
454
  * Reactive scroll.
@@ -490,27 +517,6 @@ type BindingValueFunction$2 = Parameters<typeof useInfiniteScroll>[1];
490
517
  type BindingValueArray$2 = [BindingValueFunction$2, UseInfiniteScrollOptions];
491
518
  declare const vInfiniteScroll: ObjectDirective<HTMLElement, BindingValueFunction$2 | BindingValueArray$2>;
492
519
 
493
- interface UseIntersectionObserverOptions extends ConfigurableWindow {
494
- /**
495
- * Start the IntersectionObserver immediately on creation
496
- *
497
- * @default true
498
- */
499
- immediate?: boolean;
500
- /**
501
- * The Element or Document whose bounds are used as the bounding box when testing for intersection.
502
- */
503
- root?: MaybeComputedElementRef;
504
- /**
505
- * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
506
- */
507
- rootMargin?: string;
508
- /**
509
- * Either a single number or an array of numbers between 0.0 and 1.
510
- */
511
- threshold?: number | number[];
512
- }
513
-
514
520
  type BindingValueFunction$1 = IntersectionObserverCallback;
515
521
  type BindingValueArray$1 = [BindingValueFunction$1, UseIntersectionObserverOptions];
516
522
  declare const vIntersectionObserver: ObjectDirective<HTMLElement, BindingValueFunction$1 | BindingValueArray$1>;
package/index.d.ts CHANGED
@@ -119,14 +119,14 @@ interface UseClipboardProps<Source = string> extends UseClipboardOptions<Source>
119
119
  declare const UseClipboard: vue_demi.DefineComponent<UseClipboardProps<string>, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<UseClipboardProps<string>>, {}, {}>;
120
120
 
121
121
  interface StorageLike {
122
- getItem(key: string): string | null;
123
- setItem(key: string, value: string): void;
124
- removeItem(key: string): void;
122
+ getItem: (key: string) => string | null;
123
+ setItem: (key: string, value: string) => void;
124
+ removeItem: (key: string) => void;
125
125
  }
126
126
 
127
127
  interface Serializer<T> {
128
- read(raw: string): T;
129
- write(value: T): string;
128
+ read: (raw: string) => T;
129
+ write: (value: T) => string;
130
130
  }
131
131
  interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
132
132
  /**
@@ -328,7 +328,28 @@ declare const vElementSize: ObjectDirective<HTMLElement, BindingValueFunction$4
328
328
 
329
329
  declare const UseElementVisibility: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<RenderableComponent>, {}, {}>;
330
330
 
331
- interface UseElementVisibilityOptions extends ConfigurableWindow {
331
+ interface UseIntersectionObserverOptions extends ConfigurableWindow {
332
+ /**
333
+ * Start the IntersectionObserver immediately on creation
334
+ *
335
+ * @default true
336
+ */
337
+ immediate?: boolean;
338
+ /**
339
+ * The Element or Document whose bounds are used as the bounding box when testing for intersection.
340
+ */
341
+ root?: MaybeComputedElementRef;
342
+ /**
343
+ * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
344
+ */
345
+ rootMargin?: string;
346
+ /**
347
+ * Either a single number or an array of numbers between 0.0 and 1.
348
+ */
349
+ threshold?: number | number[];
350
+ }
351
+
352
+ interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'threshold'> {
332
353
  scrollTarget?: MaybeRefOrGetter<HTMLElement | undefined | null>;
333
354
  }
334
355
 
@@ -422,6 +443,12 @@ interface UseScrollOptions extends ConfigurableWindow {
422
443
  * @default 'auto'
423
444
  */
424
445
  behavior?: MaybeRefOrGetter<ScrollBehavior>;
446
+ /**
447
+ * On error callback
448
+ *
449
+ * Default log error to `console.error`
450
+ */
451
+ onError?: (error: unknown) => void;
425
452
  }
426
453
  /**
427
454
  * Reactive scroll.
@@ -490,27 +517,6 @@ type BindingValueFunction$2 = Parameters<typeof useInfiniteScroll>[1];
490
517
  type BindingValueArray$2 = [BindingValueFunction$2, UseInfiniteScrollOptions];
491
518
  declare const vInfiniteScroll: ObjectDirective<HTMLElement, BindingValueFunction$2 | BindingValueArray$2>;
492
519
 
493
- interface UseIntersectionObserverOptions extends ConfigurableWindow {
494
- /**
495
- * Start the IntersectionObserver immediately on creation
496
- *
497
- * @default true
498
- */
499
- immediate?: boolean;
500
- /**
501
- * The Element or Document whose bounds are used as the bounding box when testing for intersection.
502
- */
503
- root?: MaybeComputedElementRef;
504
- /**
505
- * A string which specifies a set of offsets to add to the root's bounding_box when calculating intersections.
506
- */
507
- rootMargin?: string;
508
- /**
509
- * Either a single number or an array of numbers between 0.0 and 1.
510
- */
511
- threshold?: number | number[];
512
- }
513
-
514
520
  type BindingValueFunction$1 = IntersectionObserverCallback;
515
521
  type BindingValueArray$1 = [BindingValueFunction$1, UseIntersectionObserverOptions];
516
522
  declare const vIntersectionObserver: ObjectDirective<HTMLElement, BindingValueFunction$1 | BindingValueArray$1>;
package/index.iife.js CHANGED
@@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
19
19
  VueDemi.Vue2 = Vue
20
20
  VueDemi.version = Vue.version
21
21
  VueDemi.warn = Vue.util.warn
22
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
22
+ VueDemi.hasInjectionContext = function() {
23
+ return !!VueDemi.getCurrentInstance()
24
+ }
23
25
  function createApp(rootComponent, rootProps) {
24
26
  var vm
25
27
  var provide = {}
@@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
72
74
  VueDemi.Vue = Vue
73
75
  VueDemi.Vue2 = Vue
74
76
  VueDemi.version = Vue.version
75
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
77
+ VueDemi.hasInjectionContext = function() {
78
+ return !!VueDemi.getCurrentInstance()
79
+ }
76
80
  } else {
77
81
  console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
78
82
  }
@@ -562,26 +566,29 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
562
566
  }
563
567
  if (!initOnMounted)
564
568
  update();
565
- return data;
569
+ function dispatchWriteEvent(oldValue, newValue) {
570
+ if (window) {
571
+ window.dispatchEvent(new CustomEvent(customStorageEventName, {
572
+ detail: {
573
+ key,
574
+ oldValue,
575
+ newValue,
576
+ storageArea: storage
577
+ }
578
+ }));
579
+ }
580
+ }
566
581
  function write(v) {
567
582
  try {
583
+ const oldValue = storage.getItem(key);
568
584
  if (v == null) {
585
+ dispatchWriteEvent(oldValue, null);
569
586
  storage.removeItem(key);
570
587
  } else {
571
588
  const serialized = serializer.write(v);
572
- const oldValue = storage.getItem(key);
573
589
  if (oldValue !== serialized) {
574
590
  storage.setItem(key, serialized);
575
- if (window) {
576
- window.dispatchEvent(new CustomEvent(customStorageEventName, {
577
- detail: {
578
- key,
579
- oldValue,
580
- newValue: serialized,
581
- storageArea: storage
582
- }
583
- }));
584
- }
591
+ dispatchWriteEvent(oldValue, serialized);
585
592
  }
586
593
  }
587
594
  } catch (e) {
@@ -607,9 +614,6 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
607
614
  return serializer.read(rawValue);
608
615
  }
609
616
  }
610
- function updateFromCustomEvent(event) {
611
- update(event.detail);
612
- }
613
617
  function update(event) {
614
618
  if (event && event.storageArea !== storage)
615
619
  return;
@@ -632,14 +636,19 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
632
636
  resumeWatch();
633
637
  }
634
638
  }
639
+ function updateFromCustomEvent(event) {
640
+ update(event.detail);
641
+ }
642
+ return data;
635
643
  }
636
644
 
637
645
  function useMounted() {
638
646
  const isMounted = vueDemi.ref(false);
639
- if (vueDemi.getCurrentInstance()) {
647
+ const instance = vueDemi.getCurrentInstance();
648
+ if (instance) {
640
649
  vueDemi.onMounted(() => {
641
650
  isMounted.value = true;
642
- });
651
+ }, vueDemi.isVue2 ? null : instance);
643
652
  }
644
653
  return isMounted;
645
654
  }
@@ -879,7 +888,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
879
888
  "axis",
880
889
  "onStart",
881
890
  "onMove",
882
- "onEnd"
891
+ "onEnd",
892
+ "disabled"
883
893
  ],
884
894
  setup(props, { slots }) {
885
895
  const target = vueDemi.ref();
@@ -887,6 +897,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
887
897
  var _a;
888
898
  return (_a = props.handle) != null ? _a : target.value;
889
899
  });
900
+ const disabled = vueDemi.computed(() => !!props.disabled);
890
901
  const storageValue = props.storageKey && core.useStorage(
891
902
  props.storageKey,
892
903
  shared.toValue(props.initialValue) || { x: 0, y: 0 },
@@ -905,7 +916,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
905
916
  ...props,
906
917
  handle,
907
918
  initialValue,
908
- onEnd
919
+ onEnd,
920
+ disabled
909
921
  }));
910
922
  return () => {
911
923
  if (slots.default)
@@ -996,7 +1008,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
996
1008
  _el && observer.observe(_el, observerOptions);
997
1009
  }
998
1010
  },
999
- { immediate: true, flush: "post", deep: true }
1011
+ { immediate: true, flush: "post" }
1000
1012
  );
1001
1013
  const stop = () => {
1002
1014
  cleanup();
@@ -1151,7 +1163,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1151
1163
  }
1152
1164
 
1153
1165
  function useElementVisibility(element, options = {}) {
1154
- const { window = defaultWindow, scrollTarget } = options;
1166
+ const { window = defaultWindow, scrollTarget, threshold = 0 } = options;
1155
1167
  const elementIsVisible = vueDemi.ref(false);
1156
1168
  useIntersectionObserver(
1157
1169
  element,
@@ -1169,7 +1181,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1169
1181
  {
1170
1182
  root: scrollTarget,
1171
1183
  window,
1172
- threshold: 0
1184
+ threshold
1173
1185
  }
1174
1186
  );
1175
1187
  return elementIsVisible;
@@ -1383,7 +1395,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1383
1395
  passive: true
1384
1396
  },
1385
1397
  behavior = "auto",
1386
- window = defaultWindow
1398
+ window = defaultWindow,
1399
+ onError = (e) => {
1400
+ console.error(e);
1401
+ }
1387
1402
  } = options;
1388
1403
  const internalX = vueDemi.ref(0);
1389
1404
  const internalY = vueDemi.ref(0);
@@ -1444,12 +1459,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1444
1459
  var _a;
1445
1460
  if (!window)
1446
1461
  return;
1447
- const el = target.document ? target.document.documentElement : (_a = target.documentElement) != null ? _a : target;
1462
+ const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
1448
1463
  const { display, flexDirection } = getComputedStyle(el);
1449
1464
  const scrollLeft = el.scrollLeft;
1450
1465
  directions.left = scrollLeft < internalX.value;
1451
1466
  directions.right = scrollLeft > internalX.value;
1452
- const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
1467
+ const left = Math.abs(scrollLeft) <= (offset.left || 0);
1453
1468
  const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1454
1469
  if (display === "flex" && flexDirection === "row-reverse") {
1455
1470
  arrivedState.left = right;
@@ -1464,7 +1479,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1464
1479
  scrollTop = window.document.body.scrollTop;
1465
1480
  directions.top = scrollTop < internalY.value;
1466
1481
  directions.bottom = scrollTop > internalY.value;
1467
- const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
1482
+ const top = Math.abs(scrollTop) <= (offset.top || 0);
1468
1483
  const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1469
1484
  if (display === "flex" && flexDirection === "column-reverse") {
1470
1485
  arrivedState.top = bottom;
@@ -1492,10 +1507,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1492
1507
  eventListenerOptions
1493
1508
  );
1494
1509
  shared.tryOnMounted(() => {
1495
- const _element = shared.toValue(element);
1496
- if (!_element)
1497
- return;
1498
- setArrivedState(_element);
1510
+ try {
1511
+ const _element = shared.toValue(element);
1512
+ if (!_element)
1513
+ return;
1514
+ setArrivedState(_element);
1515
+ } catch (e) {
1516
+ onError(e);
1517
+ }
1499
1518
  });
1500
1519
  useEventListener(
1501
1520
  element,
@@ -1845,16 +1864,21 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1845
1864
  observer = void 0;
1846
1865
  }
1847
1866
  };
1867
+ const targets = vueDemi.computed(() => {
1868
+ const value = shared.toValue(target);
1869
+ const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(shared.notNullish);
1870
+ return new Set(items);
1871
+ });
1848
1872
  const stopWatch = vueDemi.watch(
1849
- () => unrefElement(target),
1850
- (el) => {
1873
+ () => targets.value,
1874
+ (targets2) => {
1851
1875
  cleanup();
1852
- if (isSupported.value && window && el) {
1876
+ if (isSupported.value && window && targets2.size) {
1853
1877
  observer = new MutationObserver(callback);
1854
- observer.observe(el, mutationOptions);
1878
+ targets2.forEach((el) => observer.observe(el, mutationOptions));
1855
1879
  }
1856
1880
  },
1857
- { immediate: true }
1881
+ { immediate: true, flush: "post" }
1858
1882
  );
1859
1883
  const takeRecords = () => {
1860
1884
  return observer == null ? void 0 : observer.takeRecords();
@@ -2039,13 +2063,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
2039
2063
  function useScrollLock(element, initialState = false) {
2040
2064
  const isLocked = vueDemi.ref(initialState);
2041
2065
  let stopTouchMoveListener = null;
2042
- let initialOverflow;
2043
2066
  vueDemi.watch(shared.toRef(element), (el) => {
2044
2067
  const target = resolveElement(shared.toValue(el));
2045
2068
  if (target) {
2046
2069
  const ele = target;
2047
2070
  if (!elInitialOverflow.get(ele))
2048
- elInitialOverflow.set(ele, initialOverflow);
2071
+ elInitialOverflow.set(ele, ele.style.overflow);
2049
2072
  if (isLocked.value)
2050
2073
  ele.style.overflow = "hidden";
2051
2074
  }
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- var VueDemi=function(i,o,h){if(i.install)return i;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),i;if(o.version.slice(0,4)==="2.7."){let C=function(P,A){var I,W={},B={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(z,H){return W[z]=H,this},directive:function(z,H){return H?(o.directive(z,H),B):o.directive(z)},mount:function(z,H){return I||(I=new o(Object.assign({propsData:A},P,{provide:Object.assign(W,P.provide)})),I.$mount(z,H),I)},unmount:function(){I&&(I.$destroy(),I=void 0)}};return B};var Z=C;for(var u in o)i[u]=o[u];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version,i.warn=o.util.warn,i.hasInjectionContext=()=>!!i.getCurrentInstance(),i.createApp=C}else if(o.version.slice(0,2)==="2.")if(h){for(var u in h)i[u]=h[u];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version,i.hasInjectionContext=()=>!!i.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var u in o)i[u]=o[u];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=o,i.Vue2=void 0,i.version=o.version,i.set=function(C,P,A){return Array.isArray(C)?(C.length=Math.max(C.length,P),C.splice(P,1,A),A):(C[P]=A,A)},i.del=function(C,P){if(Array.isArray(C)){C.splice(P,1);return}delete C[P]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return i}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(i,o,h,u){"use strict";const Z=o.defineComponent({name:"OnClickOutside",props:["as","options"],emits:["trigger"],setup(e,{slots:t,emit:n}){const r=o.ref();return h.onClickOutside(r,a=>{n("trigger",a)},e.options),()=>{if(t.default)return o.h(e.as||"div",{ref:r},t.default())}}});function C(e){var t;const n=u.toValue(e);return(t=n?.$el)!=null?t:n}const P=u.isClient?window:void 0;function A(...e){let t,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,t=P):[t,n,r,a]=e,!t)return u.noop;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const s=[],c=()=>{s.forEach(p=>p()),s.length=0},l=(p,d,g,y)=>(p.addEventListener(d,g,y),()=>p.removeEventListener(d,g,y)),f=o.watch(()=>[C(t),u.toValue(a)],([p,d])=>{if(c(),!p)return;const g=u.isObject(d)?{...d}:d;s.push(...n.flatMap(y=>r.map(v=>l(p,y,v,g))))},{immediate:!0,flush:"post"}),m=()=>{f(),c()};return u.tryOnScopeDispose(m),m}let I=!1;function W(e,t,n={}){const{window:r=P,ignore:a=[],capture:s=!0,detectIframe:c=!1}=n;if(!r)return u.noop;u.isIOS&&!I&&(I=!0,Array.from(r.document.body.children).forEach(g=>g.addEventListener("click",u.noop)),r.document.documentElement.addEventListener("click",u.noop));let l=!0;const f=g=>a.some(y=>{if(typeof y=="string")return Array.from(r.document.querySelectorAll(y)).some(v=>v===g.target||g.composedPath().includes(v));{const v=C(y);return v&&(g.target===v||g.composedPath().includes(v))}}),p=[A(r,"click",g=>{const y=C(e);if(!(!y||y===g.target||g.composedPath().includes(y))){if(g.detail===0&&(l=!f(g)),!l){l=!0;return}t(g)}},{passive:!0,capture:s}),A(r,"pointerdown",g=>{const y=C(e);l=!f(g)&&!!(y&&!g.composedPath().includes(y))},{passive:!0}),c&&A(r,"blur",g=>{setTimeout(()=>{var y;const v=C(e);((y=r.document.activeElement)==null?void 0:y.tagName)==="IFRAME"&&!v?.contains(r.document.activeElement)&&t(g)},0)})].filter(Boolean);return()=>p.forEach(g=>g())}const B={[u.directiveHooks.mounted](e,t){const n=!t.modifiers.bubble;if(typeof t.value=="function")e.__onClickOutside_stop=W(e,t.value,{capture:n});else{const[r,a]=t.value;e.__onClickOutside_stop=W(e,r,Object.assign({capture:n},a))}},[u.directiveHooks.unmounted](e){e.__onClickOutside_stop()}};function z(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function H(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);const{target:a=P,eventName:s="keydown",passive:c=!1,dedupe:l=!1}=r,f=z(t);return A(a,s,p=>{p.repeat&&u.toValue(l)||f(p)&&n(p)},c)}const pe={[u.directiveHooks.mounted](e,t){var n,r;const a=(r=(n=t.arg)==null?void 0:n.split(","))!=null?r:!0;if(typeof t.value=="function")H(a,t.value,{target:e});else{const[s,c]=t.value;H(a,s,{target:e,...c})}}},ve=500,ge=10;function q(e,t,n){var r,a;const s=o.computed(()=>C(e));let c,l;function f(){c&&(clearTimeout(c),c=void 0),l=void 0}function m(v){var U,S,b,L;(U=n?.modifiers)!=null&&U.self&&v.target!==s.value||(f(),(S=n?.modifiers)!=null&&S.prevent&&v.preventDefault(),(b=n?.modifiers)!=null&&b.stop&&v.stopPropagation(),l={x:v.x,y:v.y},c=setTimeout(()=>t(v),(L=n?.delay)!=null?L:ve))}function p(v){var U,S,b,L;if((U=n?.modifiers)!=null&&U.self&&v.target!==s.value||!l||n?.distanceThreshold===!1)return;(S=n?.modifiers)!=null&&S.prevent&&v.preventDefault(),(b=n?.modifiers)!=null&&b.stop&&v.stopPropagation();const V=v.x-l.x,O=v.y-l.y;Math.sqrt(V*V+O*O)>=((L=n?.distanceThreshold)!=null?L:ge)&&f()}const d={capture:(r=n?.modifiers)==null?void 0:r.capture,once:(a=n?.modifiers)==null?void 0:a.once},g=[A(s,"pointerdown",m,d),A(s,"pointermove",p,d),A(s,["pointerup","pointerleave"],f,d)];return()=>g.forEach(v=>v())}const me=o.defineComponent({name:"OnLongPress",props:["as","options"],emits:["trigger"],setup(e,{slots:t,emit:n}){const r=o.ref();return q(r,a=>{n("trigger",a)},e.options),()=>{if(t.default)return o.h(e.as||"div",{ref:r},t.default())}}}),D={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?q(e,t.value,{modifiers:t.modifiers}):q(e,...t.value)}},he=o.defineComponent({name:"UseActiveElement",setup(e,{slots:t}){const n=o.reactive({element:h.useActiveElement()});return()=>{if(t.default)return t.default(n)}}}),ye=o.defineComponent({name:"UseBattery",setup(e,{slots:t}){const n=o.reactive(h.useBattery(e));return()=>{if(t.default)return t.default(n)}}}),we=o.defineComponent({name:"UseBrowserLocation",setup(e,{slots:t}){const n=o.reactive(h.useBrowserLocation());return()=>{if(t.default)return t.default(n)}}}),Ue=o.defineComponent({name:"UseClipboard",props:["source","read","navigator","copiedDuring","legacy"],setup(e,{slots:t}){const n=o.reactive(h.useClipboard(e));return()=>{var r;return(r=t.default)==null?void 0:r.call(t,n)}}}),j=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F="__vueuse_ssr_handlers__",be=Se();function Se(){return F in j||(j[F]=j[F]||{}),j[F]}function ee(e,t){return be[e]||t}function Ce(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}const Oe={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},te="vueuse-storage";function Ee(e,t,n,r={}){var a;const{flush:s="pre",deep:c=!0,listenToStorageChanges:l=!0,writeDefaults:f=!0,mergeDefaults:m=!1,shallow:p,window:d=P,eventFilter:g,onError:y=w=>{console.error(w)},initOnMounted:v}=r,U=(p?o.shallowRef:o.ref)(typeof t=="function"?t():t);if(!n)try{n=ee("getDefaultStorage",()=>{var w;return(w=P)==null?void 0:w.localStorage})()}catch(w){y(w)}if(!n)return U;const S=u.toValue(t),b=Ce(S),L=(a=r.serializer)!=null?a:Oe[b],{pause:V,resume:O}=u.pausableWatch(U,()=>R(U.value),{flush:s,deep:c,eventFilter:g});return d&&l&&u.tryOnMounted(()=>{A(d,"storage",k),A(d,te,T),v&&k()}),v||k(),U;function R(w){try{if(w==null)n.removeItem(e);else{const _=L.write(w),M=n.getItem(e);M!==_&&(n.setItem(e,_),d&&d.dispatchEvent(new CustomEvent(te,{detail:{key:e,oldValue:M,newValue:_,storageArea:n}})))}}catch(_){y(_)}}function E(w){const _=w?w.newValue:n.getItem(e);if(_==null)return f&&S!=null&&n.setItem(e,L.write(S)),S;if(!w&&m){const M=L.read(_);return typeof m=="function"?m(M,S):b==="object"&&!Array.isArray(M)?{...S,...M}:M}else return typeof _!="string"?_:L.read(_)}function T(w){k(w.detail)}function k(w){if(!(w&&w.storageArea!==n)){if(w&&w.key==null){U.value=S;return}if(!(w&&w.key!==e)){V();try{w?.newValue!==L.write(U.value)&&(U.value=E(w))}catch(_){y(_)}finally{w?o.nextTick(O):O()}}}}}function Pe(){const e=o.ref(!1);return o.getCurrentInstance()&&o.onMounted(()=>{e.value=!0}),e}function K(e){const t=Pe();return o.computed(()=>(t.value,!!e()))}function Le(e,t={}){const{window:n=P}=t,r=K(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let a;const s=o.ref(!1),c=m=>{s.value=m.matches},l=()=>{a&&("removeEventListener"in a?a.removeEventListener("change",c):a.removeListener(c))},f=o.watchEffect(()=>{r.value&&(l(),a=n.matchMedia(u.toValue(e)),"addEventListener"in a?a.addEventListener("change",c):a.addListener(c),s.value=a.matches)});return u.tryOnScopeDispose(()=>{f(),l(),a=void 0}),s}function _e(e){return Le("(prefers-color-scheme: dark)",e)}function ke(e={}){const{selector:t="html",attribute:n="class",initialValue:r="auto",window:a=P,storage:s,storageKey:c="vueuse-color-scheme",listenToStorageChanges:l=!0,storageRef:f,emitAuto:m,disableTransition:p=!0}=e,d={auto:"",light:"light",dark:"dark",...e.modes||{}},g=_e({window:a}),y=o.computed(()=>g.value?"dark":"light"),v=f||(c==null?u.toRef(r):Ee(c,r,s,{window:a,listenToStorageChanges:l})),U=o.computed(()=>v.value==="auto"?y.value:v.value),S=ee("updateHTMLAttrs",(O,R,E)=>{const T=typeof O=="string"?a?.document.querySelector(O):C(O);if(!T)return;let k;if(p&&(k=a.document.createElement("style"),k.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),a.document.head.appendChild(k)),R==="class"){const w=E.split(/\s/g);Object.values(d).flatMap(_=>(_||"").split(/\s/g)).filter(Boolean).forEach(_=>{w.includes(_)?T.classList.add(_):T.classList.remove(_)})}else T.setAttribute(R,E);p&&(a.getComputedStyle(k).opacity,document.head.removeChild(k))});function b(O){var R;S(t,n,(R=d[O])!=null?R:O)}function L(O){e.onChanged?e.onChanged(O,b):b(O)}o.watch(U,L,{flush:"post",immediate:!0}),u.tryOnMounted(()=>L(U.value));const V=o.computed({get(){return m?v.value:U.value},set(O){v.value=O}});try{return Object.assign(V,{store:v,system:y,state:U})}catch{return V}}const Ae=o.defineComponent({name:"UseColorMode",props:["selector","attribute","modes","onChanged","storageKey","storage","emitAuto"],setup(e,{slots:t}){const n=ke(e),r=o.reactive({mode:n,system:n.system,store:n.store});return()=>{if(t.default)return t.default(r)}}}),Me=o.defineComponent({name:"UseDark",props:["selector","attribute","valueDark","valueLight","onChanged","storageKey","storage"],setup(e,{slots:t}){const n=h.useDark(e),r=o.reactive({isDark:n,toggleDark:u.useToggle(n)});return()=>{if(t.default)return t.default(r)}}}),Te=o.defineComponent({name:"UseDeviceMotion",setup(e,{slots:t}){const n=o.reactive(h.useDeviceMotion());return()=>{if(t.default)return t.default(n)}}}),Ie=o.defineComponent({name:"UseDeviceOrientation",setup(e,{slots:t}){const n=o.reactive(h.useDeviceOrientation());return()=>{if(t.default)return t.default(n)}}}),Ve=o.defineComponent({name:"UseDevicePixelRatio",setup(e,{slots:t}){const n=o.reactive({pixelRatio:h.useDevicePixelRatio()});return()=>{if(t.default)return t.default(n)}}}),Re=o.defineComponent({name:"UseDevicesList",props:["onUpdated","requestPermissions","constraints"],setup(e,{slots:t}){const n=o.reactive(h.useDevicesList(e));return()=>{if(t.default)return t.default(n)}}}),He=o.defineComponent({name:"UseDocumentVisibility",setup(e,{slots:t}){const n=o.reactive({visibility:h.useDocumentVisibility()});return()=>{if(t.default)return t.default(n)}}}),ze=o.defineComponent({name:"UseDraggable",props:["storageKey","storageType","initialValue","exact","preventDefault","stopPropagation","pointerTypes","as","handle","axis","onStart","onMove","onEnd"],setup(e,{slots:t}){const n=o.ref(),r=o.computed(()=>{var f;return(f=e.handle)!=null?f:n.value}),a=e.storageKey&&h.useStorage(e.storageKey,u.toValue(e.initialValue)||{x:0,y:0},h.isClient?e.storageType==="session"?sessionStorage:localStorage:void 0),s=a||e.initialValue||{x:0,y:0},c=(f,m)=>{var p;(p=e.onEnd)==null||p.call(e,f,m),a&&(a.value.x=f.x,a.value.y=f.y)},l=o.reactive(h.useDraggable(n,{...e,handle:r,initialValue:s,onEnd:c}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n,style:`touch-action:none;${l.style}`},t.default(l))}}}),Ne=o.defineComponent({name:"UseElementBounding",props:["box","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.useElementBounding(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function We(e,t={}){const{delayEnter:n=0,delayLeave:r=0,window:a=P}=t,s=o.ref(!1);let c;const l=f=>{const m=f?n:r;c&&(clearTimeout(c),c=void 0),m?c=setTimeout(()=>s.value=f,m):s.value=f};return a&&(A(e,"mouseenter",()=>l(!0),{passive:!0}),A(e,"mouseleave",()=>l(!1),{passive:!0})),s}const Be={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=We(e);o.watch(n,r=>t.value(r))}}},je=o.defineComponent({name:"UseElementSize",props:["width","height","box","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.useElementSize(n,{width:e.width,height:e.height},{box:e.box}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function Fe(e,t,n={}){const{window:r=P,...a}=n;let s;const c=K(()=>r&&"ResizeObserver"in r),l=()=>{s&&(s.disconnect(),s=void 0)},f=o.computed(()=>Array.isArray(e)?e.map(d=>C(d)):[C(e)]),m=o.watch(f,d=>{if(l(),c.value&&r){s=new ResizeObserver(t);for(const g of d)g&&s.observe(g,a)}},{immediate:!0,flush:"post",deep:!0}),p=()=>{l(),m()};return u.tryOnScopeDispose(p),{isSupported:c,stop:p}}function Ke(e,t={width:0,height:0},n={}){const{window:r=P,box:a="content-box"}=n,s=o.computed(()=>{var d,g;return(g=(d=C(e))==null?void 0:d.namespaceURI)==null?void 0:g.includes("svg")}),c=o.ref(t.width),l=o.ref(t.height),{stop:f}=Fe(e,([d])=>{const g=a==="border-box"?d.borderBoxSize:a==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(r&&s.value){const y=C(e);if(y){const v=r.getComputedStyle(y);c.value=Number.parseFloat(v.width),l.value=Number.parseFloat(v.height)}}else if(g){const y=Array.isArray(g)?g:[g];c.value=y.reduce((v,{inlineSize:U})=>v+U,0),l.value=y.reduce((v,{blockSize:U})=>v+U,0)}else c.value=d.contentRect.width,l.value=d.contentRect.height},n);u.tryOnMounted(()=>{const d=C(e);d&&(c.value="offsetWidth"in d?d.offsetWidth:t.width,l.value="offsetHeight"in d?d.offsetHeight:t.height)});const m=o.watch(()=>C(e),d=>{c.value=d?t.width:0,l.value=d?t.height:0});function p(){f(),m()}return{width:c,height:l,stop:p}}const Ge={[u.directiveHooks.mounted](e,t){var n;const r=typeof t.value=="function"?t.value:(n=t.value)==null?void 0:n[0],a=typeof t.value=="function"?[]:t.value.slice(1),{width:s,height:c}=Ke(e,...a);o.watch([s,c],([l,f])=>r({width:l,height:f}))}},Je=o.defineComponent({name:"UseElementVisibility",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive({isVisible:h.useElementVisibility(n)});return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function x(e,t,n={}){const{root:r,rootMargin:a="0px",threshold:s=.1,window:c=P,immediate:l=!0}=n,f=K(()=>c&&"IntersectionObserver"in c),m=o.computed(()=>{const v=u.toValue(e);return(Array.isArray(v)?v:[v]).map(C).filter(u.notNullish)});let p=u.noop;const d=o.ref(l),g=f.value?o.watch(()=>[m.value,C(r),d.value],([v,U])=>{if(p(),!d.value||!v.length)return;const S=new IntersectionObserver(t,{root:C(U),rootMargin:a,threshold:s});v.forEach(b=>b&&S.observe(b)),p=()=>{S.disconnect(),p=u.noop}},{immediate:l,flush:"post"}):u.noop,y=()=>{p(),g(),d.value=!1};return u.tryOnScopeDispose(y),{isSupported:f,isActive:d,pause(){p(),d.value=!1},resume(){d.value=!0},stop:y}}function X(e,t={}){const{window:n=P,scrollTarget:r}=t,a=o.ref(!1);return x(e,s=>{let c=a.value,l=0;for(const f of s)f.time>=l&&(l=f.time,c=f.isIntersecting);a.value=c},{root:r,window:n,threshold:0}),a}const Ye={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=t.value,r=X(e);o.watch(r,a=>n(a),{immediate:!0})}else{const[n,r]=t.value,a=X(e,r);o.watch(a,s=>n(s),{immediate:!0})}}},$e=o.defineComponent({name:"UseEyeDropper",props:{sRGBHex:String},setup(e,{slots:t}){const n=o.reactive(h.useEyeDropper());return()=>{if(t.default)return t.default(n)}}}),qe=o.defineComponent({name:"UseFullscreen",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.useFullscreen(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),xe=o.defineComponent({name:"UseGeolocation",props:["enableHighAccuracy","maximumAge","timeout","navigator"],setup(e,{slots:t}){const n=o.reactive(h.useGeolocation(e));return()=>{if(t.default)return t.default(n)}}}),Xe=o.defineComponent({name:"UseIdle",props:["timeout","events","listenForVisibilityChange","initialState"],setup(e,{slots:t}){const n=o.reactive(h.useIdle(e.timeout,e));return()=>{if(t.default)return t.default(n)}}});function Qe(e,t,n){const{immediate:r=!0,delay:a=0,onError:s=u.noop,onSuccess:c=u.noop,resetOnExecute:l=!0,shallow:f=!0,throwError:m}=n??{},p=f?o.shallowRef(t):o.ref(t),d=o.ref(!1),g=o.ref(!1),y=o.shallowRef(void 0);async function v(b=0,...L){l&&(p.value=t),y.value=void 0,d.value=!1,g.value=!0,b>0&&await u.promiseTimeout(b);const V=typeof e=="function"?e(...L):e;try{const O=await V;p.value=O,d.value=!0,c(O)}catch(O){if(y.value=O,s(O),m)throw O}finally{g.value=!1}return p.value}r&&v(a);const U={state:p,isReady:d,isLoading:g,error:y,execute:v};function S(){return new Promise((b,L)=>{u.until(g).toBe(!1).then(()=>b(U)).catch(L)})}return{...U,then(b,L){return S().then(b,L)}}}async function Ze(e){return new Promise((t,n)=>{const r=new Image,{src:a,srcset:s,sizes:c,class:l,loading:f,crossorigin:m,referrerPolicy:p}=e;r.src=a,s&&(r.srcset=s),c&&(r.sizes=c),l&&(r.className=l),f&&(r.loading=f),m&&(r.crossOrigin=m),p&&(r.referrerPolicy=p),r.onload=()=>t(r),r.onerror=n})}function De(e,t={}){const n=Qe(()=>Ze(u.toValue(e)),void 0,{resetOnExecute:!0,...t});return o.watch(()=>u.toValue(e),()=>n.execute(t.delay),{deep:!0}),n}const et=o.defineComponent({name:"UseImage",props:["src","srcset","sizes","as","alt","class","loading","crossorigin","referrerPolicy"],setup(e,{slots:t}){const n=o.reactive(De(e));return()=>n.isLoading&&t.loading?t.loading(n):n.error&&t.error?t.error(n.error):t.default?t.default(n):o.h(e.as||"img",e)}}),ne=1;function Q(e,t={}){const{throttle:n=0,idle:r=200,onStop:a=u.noop,onScroll:s=u.noop,offset:c={left:0,right:0,top:0,bottom:0},eventListenerOptions:l={capture:!1,passive:!0},behavior:f="auto",window:m=P}=t,p=o.ref(0),d=o.ref(0),g=o.computed({get(){return p.value},set(E){v(E,void 0)}}),y=o.computed({get(){return d.value},set(E){v(void 0,E)}});function v(E,T){var k,w,_;if(!m)return;const M=u.toValue(e);M&&((_=M instanceof Document?m.document.body:M)==null||_.scrollTo({top:(k=u.toValue(T))!=null?k:y.value,left:(w=u.toValue(E))!=null?w:g.value,behavior:u.toValue(f)}))}const U=o.ref(!1),S=o.reactive({left:!0,right:!1,top:!0,bottom:!1}),b=o.reactive({left:!1,right:!1,top:!1,bottom:!1}),L=E=>{U.value&&(U.value=!1,b.left=!1,b.right=!1,b.top=!1,b.bottom=!1,a(E))},V=u.useDebounceFn(L,n+r),O=E=>{var T;if(!m)return;const k=E.document?E.document.documentElement:(T=E.documentElement)!=null?T:E,{display:w,flexDirection:_}=getComputedStyle(k),M=k.scrollLeft;b.left=M<p.value,b.right=M>p.value;const ue=Math.abs(M)<=0+(c.left||0),ce=Math.abs(M)+k.clientWidth>=k.scrollWidth-(c.right||0)-ne;w==="flex"&&_==="row-reverse"?(S.left=ce,S.right=ue):(S.left=ue,S.right=ce),p.value=M;let N=k.scrollTop;E===m.document&&!N&&(N=m.document.body.scrollTop),b.top=N<d.value,b.bottom=N>d.value;const fe=Math.abs(N)<=0+(c.top||0),de=Math.abs(N)+k.clientHeight>=k.scrollHeight-(c.bottom||0)-ne;w==="flex"&&_==="column-reverse"?(S.top=de,S.bottom=fe):(S.top=fe,S.bottom=de),d.value=N},R=E=>{var T;if(!m)return;const k=(T=E.target.documentElement)!=null?T:E.target;O(k),U.value=!0,V(E),s(E)};return A(e,"scroll",n?u.useThrottleFn(R,n,!0,!1):R,l),u.tryOnMounted(()=>{const E=u.toValue(e);E&&O(E)}),A(e,"scrollend",L,l),{x:g,y,isScrolling:U,arrivedState:S,directions:b,measure(){const E=u.toValue(e);m&&E&&O(E)}}}function G(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function oe(e,t,n={}){var r;const{direction:a="bottom",interval:s=100,canLoadMore:c=()=>!0}=n,l=o.reactive(Q(e,{...n,offset:{[a]:(r=n.distance)!=null?r:0,...n.offset}})),f=o.ref(),m=o.computed(()=>!!f.value),p=o.computed(()=>G(u.toValue(e))),d=X(p);function g(){if(l.measure(),!p.value||!d.value||!c(p.value))return;const{scrollHeight:y,clientHeight:v,scrollWidth:U,clientWidth:S}=p.value,b=a==="bottom"||a==="top"?y<=v:U<=S;(l.arrivedState[a]||b)&&(f.value||(f.value=Promise.all([t(l),new Promise(L=>setTimeout(L,s))]).finally(()=>{f.value=null,o.nextTick(()=>g())})))}return o.watch(()=>[l.arrivedState[a],d.value],g,{immediate:!0}),{isLoading:m}}const tt={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?oe(e,t.value):oe(e,...t.value)}},nt={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?x(e,t.value):x(e,...t.value)}},ot=o.defineComponent({name:"UseMouse",props:["touch","resetOnTouchEnds","initialValue"],setup(e,{slots:t}){const n=o.reactive(h.useMouse(e));return()=>{if(t.default)return t.default(n)}}}),rt=o.defineComponent({name:"UseMouseElement",props:["handleOutside","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.useMouseInElement(n,e));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),at=o.defineComponent({name:"UseMousePressed",props:["touch","initialValue","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.useMousePressed({...e,target:n}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),st=o.defineComponent({name:"UseNetwork",setup(e,{slots:t}){const n=o.reactive(h.useNetwork());return()=>{if(t.default)return t.default(n)}}}),it=o.defineComponent({name:"UseNow",props:["interval"],setup(e,{slots:t}){const n=o.reactive(h.useNow({...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),lt=o.defineComponent({name:"UseObjectUrl",props:["object"],setup(e,{slots:t}){const n=u.toRef(e,"object"),r=h.useObjectUrl(n);return()=>{if(t.default&&r.value)return t.default(r)}}}),ut=o.defineComponent({name:"UseOffsetPagination",props:["total","page","pageSize","onPageChange","onPageSizeChange","onPageCountChange"],emits:["page-change","page-size-change","page-count-change"],setup(e,{slots:t,emit:n}){const r=o.reactive(h.useOffsetPagination({...e,onPageChange(...a){var s;(s=e.onPageChange)==null||s.call(e,...a),n("page-change",...a)},onPageSizeChange(...a){var s;(s=e.onPageSizeChange)==null||s.call(e,...a),n("page-size-change",...a)},onPageCountChange(...a){var s;(s=e.onPageCountChange)==null||s.call(e,...a),n("page-count-change",...a)}}));return()=>{if(t.default)return t.default(r)}}}),ct=o.defineComponent({name:"UseOnline",setup(e,{slots:t}){const n=o.reactive({isOnline:h.useOnline()});return()=>{if(t.default)return t.default(n)}}}),ft=o.defineComponent({name:"UsePageLeave",setup(e,{slots:t}){const n=o.reactive({isLeft:h.usePageLeave()});return()=>{if(t.default)return t.default(n)}}}),dt=o.defineComponent({name:"UsePointer",props:["pointerTypes","initialValue","target"],setup(e,{slots:t}){const n=o.ref(null),r=o.reactive(h.usePointer({...e,target:e.target==="self"?n:P}));return()=>{if(t.default)return t.default(r,{ref:n})}}}),pt=o.defineComponent({name:"UsePointerLock",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(h.usePointerLock(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),vt=o.defineComponent({name:"UsePreferredColorScheme",setup(e,{slots:t}){const n=o.reactive({colorScheme:h.usePreferredColorScheme()});return()=>{if(t.default)return t.default(n)}}}),gt=o.defineComponent({name:"UsePreferredContrast",setup(e,{slots:t}){const n=o.reactive({contrast:h.usePreferredContrast()});return()=>{if(t.default)return t.default(n)}}}),mt=o.defineComponent({name:"UsePreferredDark",setup(e,{slots:t}){const n=o.reactive({prefersDark:h.usePreferredDark()});return()=>{if(t.default)return t.default(n)}}}),ht=o.defineComponent({name:"UsePreferredLanguages",setup(e,{slots:t}){const n=o.reactive({languages:h.usePreferredLanguages()});return()=>{if(t.default)return t.default(n)}}}),yt=o.defineComponent({name:"UsePreferredReducedMotion",setup(e,{slots:t}){const n=o.reactive({motion:h.usePreferredReducedMotion()});return()=>{if(t.default)return t.default(n)}}});function wt(e,t,n={}){const{window:r=P,...a}=n;let s;const c=K(()=>r&&"MutationObserver"in r),l=()=>{s&&(s.disconnect(),s=void 0)},f=o.watch(()=>C(e),d=>{l(),c.value&&r&&d&&(s=new MutationObserver(t),s.observe(d,a))},{immediate:!0}),m=()=>s?.takeRecords(),p=()=>{l(),f()};return u.tryOnScopeDispose(p),{isSupported:c,stop:p,takeRecords:m}}function J(e,t,n={}){const{window:r=P,initialValue:a="",observe:s=!1}=n,c=o.ref(a),l=o.computed(()=>{var m;return C(t)||((m=r?.document)==null?void 0:m.documentElement)});function f(){var m;const p=u.toValue(e),d=u.toValue(l);if(d&&r){const g=(m=r.getComputedStyle(d).getPropertyValue(p))==null?void 0:m.trim();c.value=g||a}}return s&&wt(l,f,{attributeFilter:["style","class"],window:r}),o.watch([l,()=>u.toValue(e)],f,{immediate:!0}),o.watch(c,m=>{var p;(p=l.value)!=null&&p.style&&l.value.style.setProperty(u.toValue(e),m)}),c}const re="--vueuse-safe-area-top",ae="--vueuse-safe-area-right",se="--vueuse-safe-area-bottom",ie="--vueuse-safe-area-left";function Ut(){const e=o.ref(""),t=o.ref(""),n=o.ref(""),r=o.ref("");if(u.isClient){const s=J(re),c=J(ae),l=J(se),f=J(ie);s.value="env(safe-area-inset-top, 0px)",c.value="env(safe-area-inset-right, 0px)",l.value="env(safe-area-inset-bottom, 0px)",f.value="env(safe-area-inset-left, 0px)",a(),A("resize",u.useDebounceFn(a))}function a(){e.value=Y(re),t.value=Y(ae),n.value=Y(se),r.value=Y(ie)}return{top:e,right:t,bottom:n,left:r,update:a}}function Y(e){return getComputedStyle(document.documentElement).getPropertyValue(e)}const bt=o.defineComponent({name:"UseScreenSafeArea",props:{top:Boolean,right:Boolean,bottom:Boolean,left:Boolean},setup(e,{slots:t}){const{top:n,right:r,bottom:a,left:s}=Ut();return()=>{if(t.default)return o.h("div",{style:{paddingTop:e.top?n.value:"",paddingRight:e.right?r.value:"",paddingBottom:e.bottom?a.value:"",paddingLeft:e.left?s.value:"",boxSizing:"border-box",maxHeight:"100vh",maxWidth:"100vw",overflow:"auto"}},t.default())}}}),St={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=t.value,r=Q(e,{onScroll(){n(r)},onStop(){n(r)}})}else{const[n,r]=t.value,a=Q(e,{...r,onScroll(s){var c;(c=r.onScroll)==null||c.call(r,s),n(a)},onStop(s){var c;(c=r.onStop)==null||c.call(r,s),n(a)}})}}};function le(e){const t=window.getComputedStyle(e);if(t.overflowX==="scroll"||t.overflowY==="scroll"||t.overflowX==="auto"&&e.clientWidth<e.scrollWidth||t.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const n=e.parentNode;return!n||n.tagName==="BODY"?!1:le(n)}}function Ct(e){const t=e||window.event,n=t.target;return le(n)?!1:t.touches.length>1?!0:(t.preventDefault&&t.preventDefault(),!1)}const $=new WeakMap;function Ot(e,t=!1){const n=o.ref(t);let r=null,a;o.watch(u.toRef(e),l=>{const f=G(u.toValue(l));if(f){const m=f;$.get(m)||$.set(m,a),n.value&&(m.style.overflow="hidden")}},{immediate:!0});const s=()=>{const l=G(u.toValue(e));!l||n.value||(u.isIOS&&(r=A(l,"touchmove",f=>{Ct(f)},{passive:!1})),l.style.overflow="hidden",n.value=!0)},c=()=>{var l;const f=G(u.toValue(e));!f||!n.value||(u.isIOS&&r?.(),f.style.overflow=(l=$.get(f))!=null?l:"",$.delete(f),n.value=!1)};return u.tryOnScopeDispose(c),o.computed({get(){return n.value},set(l){l?s():c()}})}function Et(){let e=!1;const t=o.ref(!1);return(n,r)=>{if(t.value=r.value,e)return;e=!0;const a=Ot(n,r.value);o.watch(t,s=>a.value=s)}}const Pt=Et(),Lt=o.defineComponent({name:"UseTimeAgo",props:["time","updateInterval","max","fullDateFormatter","messages","showSecond"],setup(e,{slots:t}){const n=o.reactive(h.useTimeAgo(()=>e.time,{...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),_t=o.defineComponent({name:"UseTimestamp",props:["immediate","interval","offset"],setup(e,{slots:t}){const n=o.reactive(h.useTimestamp({...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),kt=o.defineComponent({name:"UseVirtualList",props:["list","options","height"],setup(e,{slots:t,expose:n}){const{list:r}=o.toRefs(e),{list:a,containerProps:s,wrapperProps:c,scrollTo:l}=h.useVirtualList(r,e.options);return n({scrollTo:l}),s.style&&typeof s.style=="object"&&!Array.isArray(s.style)&&(s.style.height=e.height||"300px"),()=>o.h("div",{...s},[o.h("div",{...c.value},a.value.map(f=>o.h("div",{style:{overflow:"hidden",height:f.height}},t.default?t.default(f):"Please set content!")))])}}),At=o.defineComponent({name:"UseWindowFocus",setup(e,{slots:t}){const n=o.reactive({focused:h.useWindowFocus()});return()=>{if(t.default)return t.default(n)}}}),Mt=o.defineComponent({name:"UseWindowSize",props:["initialWidth","initialHeight"],setup(e,{slots:t}){const n=o.reactive(h.useWindowSize(e));return()=>{if(t.default)return t.default(n)}}});i.OnClickOutside=Z,i.OnLongPress=me,i.UseActiveElement=he,i.UseBattery=ye,i.UseBrowserLocation=we,i.UseClipboard=Ue,i.UseColorMode=Ae,i.UseDark=Me,i.UseDeviceMotion=Te,i.UseDeviceOrientation=Ie,i.UseDevicePixelRatio=Ve,i.UseDevicesList=Re,i.UseDocumentVisibility=He,i.UseDraggable=ze,i.UseElementBounding=Ne,i.UseElementSize=je,i.UseElementVisibility=Je,i.UseEyeDropper=$e,i.UseFullscreen=qe,i.UseGeolocation=xe,i.UseIdle=Xe,i.UseImage=et,i.UseMouse=ot,i.UseMouseInElement=rt,i.UseMousePressed=at,i.UseNetwork=st,i.UseNow=it,i.UseObjectUrl=lt,i.UseOffsetPagination=ut,i.UseOnline=ct,i.UsePageLeave=ft,i.UsePointer=dt,i.UsePointerLock=pt,i.UsePreferredColorScheme=vt,i.UsePreferredContrast=gt,i.UsePreferredDark=mt,i.UsePreferredLanguages=ht,i.UsePreferredReducedMotion=yt,i.UseScreenSafeArea=bt,i.UseTimeAgo=Lt,i.UseTimestamp=_t,i.UseVirtualList=kt,i.UseWindowFocus=At,i.UseWindowSize=Mt,i.VOnClickOutside=B,i.VOnLongPress=D,i.vElementHover=Be,i.vElementSize=Ge,i.vElementVisibility=Ye,i.vInfiniteScroll=tt,i.vIntersectionObserver=nt,i.vOnClickOutside=B,i.vOnKeyStroke=pe,i.vOnLongPress=D,i.vScroll=St,i.vScrollLock=Pt})(this.VueUse=this.VueUse||{},VueDemi,VueUse,VueUse);
1
+ var VueDemi=function(i,o,y){if(i.install)return i;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),i;if(o.version.slice(0,4)==="2.7."){let S=function(L,_){var R,B={},j={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(z,H){return B[z]=H,this},directive:function(z,H){return H?(o.directive(z,H),j):o.directive(z)},mount:function(z,H){return R||(R=new o(Object.assign({propsData:_},L,{provide:Object.assign(B,L.provide)})),R.$mount(z,H),R)},unmount:function(){R&&(R.$destroy(),R=void 0)}};return j};var D=S;for(var u in o)i[u]=o[u];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version,i.warn=o.util.warn,i.hasInjectionContext=function(){return!!i.getCurrentInstance()},i.createApp=S}else if(o.version.slice(0,2)==="2.")if(y){for(var u in y)i[u]=y[u];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version,i.hasInjectionContext=function(){return!!i.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var u in o)i[u]=o[u];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=o,i.Vue2=void 0,i.version=o.version,i.set=function(S,L,_){return Array.isArray(S)?(S.length=Math.max(S.length,L),S.splice(L,1,_),_):(S[L]=_,_)},i.del=function(S,L){if(Array.isArray(S)){S.splice(L,1);return}delete S[L]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return i}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(i,o,y,u){"use strict";const D=o.defineComponent({name:"OnClickOutside",props:["as","options"],emits:["trigger"],setup(e,{slots:t,emit:n}){const r=o.ref();return y.onClickOutside(r,a=>{n("trigger",a)},e.options),()=>{if(t.default)return o.h(e.as||"div",{ref:r},t.default())}}});function S(e){var t;const n=u.toValue(e);return(t=n?.$el)!=null?t:n}const L=u.isClient?window:void 0;function _(...e){let t,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,t=L):[t,n,r,a]=e,!t)return u.noop;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const s=[],l=()=>{s.forEach(m=>m()),s.length=0},c=(m,f,d,h)=>(m.addEventListener(f,d,h),()=>m.removeEventListener(f,d,h)),p=o.watch(()=>[S(t),u.toValue(a)],([m,f])=>{if(l(),!m)return;const d=u.isObject(f)?{...f}:f;s.push(...n.flatMap(h=>r.map(g=>c(m,h,g,d))))},{immediate:!0,flush:"post"}),v=()=>{p(),l()};return u.tryOnScopeDispose(v),v}let R=!1;function B(e,t,n={}){const{window:r=L,ignore:a=[],capture:s=!0,detectIframe:l=!1}=n;if(!r)return u.noop;u.isIOS&&!R&&(R=!0,Array.from(r.document.body.children).forEach(d=>d.addEventListener("click",u.noop)),r.document.documentElement.addEventListener("click",u.noop));let c=!0;const p=d=>a.some(h=>{if(typeof h=="string")return Array.from(r.document.querySelectorAll(h)).some(g=>g===d.target||d.composedPath().includes(g));{const g=S(h);return g&&(d.target===g||d.composedPath().includes(g))}}),m=[_(r,"click",d=>{const h=S(e);if(!(!h||h===d.target||d.composedPath().includes(h))){if(d.detail===0&&(c=!p(d)),!c){c=!0;return}t(d)}},{passive:!0,capture:s}),_(r,"pointerdown",d=>{const h=S(e);c=!p(d)&&!!(h&&!d.composedPath().includes(h))},{passive:!0}),l&&_(r,"blur",d=>{setTimeout(()=>{var h;const g=S(e);((h=r.document.activeElement)==null?void 0:h.tagName)==="IFRAME"&&!g?.contains(r.document.activeElement)&&t(d)},0)})].filter(Boolean);return()=>m.forEach(d=>d())}const j={[u.directiveHooks.mounted](e,t){const n=!t.modifiers.bubble;if(typeof t.value=="function")e.__onClickOutside_stop=B(e,t.value,{capture:n});else{const[r,a]=t.value;e.__onClickOutside_stop=B(e,r,Object.assign({capture:n},a))}},[u.directiveHooks.unmounted](e){e.__onClickOutside_stop()}};function z(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function H(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);const{target:a=L,eventName:s="keydown",passive:l=!1,dedupe:c=!1}=r,p=z(t);return _(a,s,m=>{m.repeat&&u.toValue(c)||p(m)&&n(m)},l)}const ve={[u.directiveHooks.mounted](e,t){var n,r;const a=(r=(n=t.arg)==null?void 0:n.split(","))!=null?r:!0;if(typeof t.value=="function")H(a,t.value,{target:e});else{const[s,l]=t.value;H(a,s,{target:e,...l})}}},ge=500,me=10;function x(e,t,n){var r,a;const s=o.computed(()=>S(e));let l,c;function p(){l&&(clearTimeout(l),l=void 0),c=void 0}function v(g){var C,E,b,O;(C=n?.modifiers)!=null&&C.self&&g.target!==s.value||(p(),(E=n?.modifiers)!=null&&E.prevent&&g.preventDefault(),(b=n?.modifiers)!=null&&b.stop&&g.stopPropagation(),c={x:g.x,y:g.y},l=setTimeout(()=>t(g),(O=n?.delay)!=null?O:ge))}function m(g){var C,E,b,O;if((C=n?.modifiers)!=null&&C.self&&g.target!==s.value||!c||n?.distanceThreshold===!1)return;(E=n?.modifiers)!=null&&E.prevent&&g.preventDefault(),(b=n?.modifiers)!=null&&b.stop&&g.stopPropagation();const I=g.x-c.x,P=g.y-c.y;Math.sqrt(I*I+P*P)>=((O=n?.distanceThreshold)!=null?O:me)&&p()}const f={capture:(r=n?.modifiers)==null?void 0:r.capture,once:(a=n?.modifiers)==null?void 0:a.once},d=[_(s,"pointerdown",v,f),_(s,"pointermove",m,f),_(s,["pointerup","pointerleave"],p,f)];return()=>d.forEach(g=>g())}const he=o.defineComponent({name:"OnLongPress",props:["as","options"],emits:["trigger"],setup(e,{slots:t,emit:n}){const r=o.ref();return x(r,a=>{n("trigger",a)},e.options),()=>{if(t.default)return o.h(e.as||"div",{ref:r},t.default())}}}),ee={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?x(e,t.value,{modifiers:t.modifiers}):x(e,...t.value)}},ye=o.defineComponent({name:"UseActiveElement",setup(e,{slots:t}){const n=o.reactive({element:y.useActiveElement()});return()=>{if(t.default)return t.default(n)}}}),we=o.defineComponent({name:"UseBattery",setup(e,{slots:t}){const n=o.reactive(y.useBattery(e));return()=>{if(t.default)return t.default(n)}}}),Ue=o.defineComponent({name:"UseBrowserLocation",setup(e,{slots:t}){const n=o.reactive(y.useBrowserLocation());return()=>{if(t.default)return t.default(n)}}}),be=o.defineComponent({name:"UseClipboard",props:["source","read","navigator","copiedDuring","legacy"],setup(e,{slots:t}){const n=o.reactive(y.useClipboard(e));return()=>{var r;return(r=t.default)==null?void 0:r.call(t,n)}}}),F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},K="__vueuse_ssr_handlers__",Se=Ce();function Ce(){return K in F||(F[K]=F[K]||{}),F[K]}function te(e,t){return Se[e]||t}function Oe(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}const Ee={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},ne="vueuse-storage";function Pe(e,t,n,r={}){var a;const{flush:s="pre",deep:l=!0,listenToStorageChanges:c=!0,writeDefaults:p=!0,mergeDefaults:v=!1,shallow:m,window:f=L,eventFilter:d,onError:h=w=>{console.error(w)},initOnMounted:g}=r,C=(m?o.shallowRef:o.ref)(typeof t=="function"?t():t);if(!n)try{n=te("getDefaultStorage",()=>{var w;return(w=L)==null?void 0:w.localStorage})()}catch(w){h(w)}if(!n)return C;const E=u.toValue(t),b=Oe(E),O=(a=r.serializer)!=null?a:Ee[b],{pause:I,resume:P}=u.pausableWatch(C,()=>N(C.value),{flush:s,deep:l,eventFilter:d});f&&c&&u.tryOnMounted(()=>{_(f,"storage",A),_(f,ne,T),g&&A()}),g||A();function V(w,k){f&&f.dispatchEvent(new CustomEvent(ne,{detail:{key:e,oldValue:w,newValue:k,storageArea:n}}))}function N(w){try{const k=n.getItem(e);if(w==null)V(k,null),n.removeItem(e);else{const M=O.write(w);k!==M&&(n.setItem(e,M),V(k,M))}}catch(k){h(k)}}function U(w){const k=w?w.newValue:n.getItem(e);if(k==null)return p&&E!=null&&n.setItem(e,O.write(E)),E;if(!w&&v){const M=O.read(k);return typeof v=="function"?v(M,E):b==="object"&&!Array.isArray(M)?{...E,...M}:M}else return typeof k!="string"?k:O.read(k)}function A(w){if(!(w&&w.storageArea!==n)){if(w&&w.key==null){C.value=E;return}if(!(w&&w.key!==e)){I();try{w?.newValue!==O.write(C.value)&&(C.value=U(w))}catch(k){h(k)}finally{w?o.nextTick(P):P()}}}}function T(w){A(w.detail)}return C}function Le(){const e=o.ref(!1),t=o.getCurrentInstance();return t&&o.onMounted(()=>{e.value=!0},o.isVue2?null:t),e}function G(e){const t=Le();return o.computed(()=>(t.value,!!e()))}function _e(e,t={}){const{window:n=L}=t,r=G(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let a;const s=o.ref(!1),l=v=>{s.value=v.matches},c=()=>{a&&("removeEventListener"in a?a.removeEventListener("change",l):a.removeListener(l))},p=o.watchEffect(()=>{r.value&&(c(),a=n.matchMedia(u.toValue(e)),"addEventListener"in a?a.addEventListener("change",l):a.addListener(l),s.value=a.matches)});return u.tryOnScopeDispose(()=>{p(),c(),a=void 0}),s}function ke(e){return _e("(prefers-color-scheme: dark)",e)}function Ae(e={}){const{selector:t="html",attribute:n="class",initialValue:r="auto",window:a=L,storage:s,storageKey:l="vueuse-color-scheme",listenToStorageChanges:c=!0,storageRef:p,emitAuto:v,disableTransition:m=!0}=e,f={auto:"",light:"light",dark:"dark",...e.modes||{}},d=ke({window:a}),h=o.computed(()=>d.value?"dark":"light"),g=p||(l==null?u.toRef(r):Pe(l,r,s,{window:a,listenToStorageChanges:c})),C=o.computed(()=>g.value==="auto"?h.value:g.value),E=te("updateHTMLAttrs",(P,V,N)=>{const U=typeof P=="string"?a?.document.querySelector(P):S(P);if(!U)return;let A;if(m&&(A=a.document.createElement("style"),A.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),a.document.head.appendChild(A)),V==="class"){const T=N.split(/\s/g);Object.values(f).flatMap(w=>(w||"").split(/\s/g)).filter(Boolean).forEach(w=>{T.includes(w)?U.classList.add(w):U.classList.remove(w)})}else U.setAttribute(V,N);m&&(a.getComputedStyle(A).opacity,document.head.removeChild(A))});function b(P){var V;E(t,n,(V=f[P])!=null?V:P)}function O(P){e.onChanged?e.onChanged(P,b):b(P)}o.watch(C,O,{flush:"post",immediate:!0}),u.tryOnMounted(()=>O(C.value));const I=o.computed({get(){return v?g.value:C.value},set(P){g.value=P}});try{return Object.assign(I,{store:g,system:h,state:C})}catch{return I}}const Me=o.defineComponent({name:"UseColorMode",props:["selector","attribute","modes","onChanged","storageKey","storage","emitAuto"],setup(e,{slots:t}){const n=Ae(e),r=o.reactive({mode:n,system:n.system,store:n.store});return()=>{if(t.default)return t.default(r)}}}),Te=o.defineComponent({name:"UseDark",props:["selector","attribute","valueDark","valueLight","onChanged","storageKey","storage"],setup(e,{slots:t}){const n=y.useDark(e),r=o.reactive({isDark:n,toggleDark:u.useToggle(n)});return()=>{if(t.default)return t.default(r)}}}),Ve=o.defineComponent({name:"UseDeviceMotion",setup(e,{slots:t}){const n=o.reactive(y.useDeviceMotion());return()=>{if(t.default)return t.default(n)}}}),Ie=o.defineComponent({name:"UseDeviceOrientation",setup(e,{slots:t}){const n=o.reactive(y.useDeviceOrientation());return()=>{if(t.default)return t.default(n)}}}),Re=o.defineComponent({name:"UseDevicePixelRatio",setup(e,{slots:t}){const n=o.reactive({pixelRatio:y.useDevicePixelRatio()});return()=>{if(t.default)return t.default(n)}}}),He=o.defineComponent({name:"UseDevicesList",props:["onUpdated","requestPermissions","constraints"],setup(e,{slots:t}){const n=o.reactive(y.useDevicesList(e));return()=>{if(t.default)return t.default(n)}}}),ze=o.defineComponent({name:"UseDocumentVisibility",setup(e,{slots:t}){const n=o.reactive({visibility:y.useDocumentVisibility()});return()=>{if(t.default)return t.default(n)}}}),Ne=o.defineComponent({name:"UseDraggable",props:["storageKey","storageType","initialValue","exact","preventDefault","stopPropagation","pointerTypes","as","handle","axis","onStart","onMove","onEnd","disabled"],setup(e,{slots:t}){const n=o.ref(),r=o.computed(()=>{var v;return(v=e.handle)!=null?v:n.value}),a=o.computed(()=>!!e.disabled),s=e.storageKey&&y.useStorage(e.storageKey,u.toValue(e.initialValue)||{x:0,y:0},y.isClient?e.storageType==="session"?sessionStorage:localStorage:void 0),l=s||e.initialValue||{x:0,y:0},c=(v,m)=>{var f;(f=e.onEnd)==null||f.call(e,v,m),s&&(s.value.x=v.x,s.value.y=v.y)},p=o.reactive(y.useDraggable(n,{...e,handle:r,initialValue:l,onEnd:c,disabled:a}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n,style:`touch-action:none;${p.style}`},t.default(p))}}}),We=o.defineComponent({name:"UseElementBounding",props:["box","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.useElementBounding(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function Be(e,t={}){const{delayEnter:n=0,delayLeave:r=0,window:a=L}=t,s=o.ref(!1);let l;const c=p=>{const v=p?n:r;l&&(clearTimeout(l),l=void 0),v?l=setTimeout(()=>s.value=p,v):s.value=p};return a&&(_(e,"mouseenter",()=>c(!0),{passive:!0}),_(e,"mouseleave",()=>c(!1),{passive:!0})),s}const je={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=Be(e);o.watch(n,r=>t.value(r))}}},Fe=o.defineComponent({name:"UseElementSize",props:["width","height","box","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.useElementSize(n,{width:e.width,height:e.height},{box:e.box}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function Ke(e,t,n={}){const{window:r=L,...a}=n;let s;const l=G(()=>r&&"ResizeObserver"in r),c=()=>{s&&(s.disconnect(),s=void 0)},p=o.computed(()=>Array.isArray(e)?e.map(f=>S(f)):[S(e)]),v=o.watch(p,f=>{if(c(),l.value&&r){s=new ResizeObserver(t);for(const d of f)d&&s.observe(d,a)}},{immediate:!0,flush:"post"}),m=()=>{c(),v()};return u.tryOnScopeDispose(m),{isSupported:l,stop:m}}function Ge(e,t={width:0,height:0},n={}){const{window:r=L,box:a="content-box"}=n,s=o.computed(()=>{var f,d;return(d=(f=S(e))==null?void 0:f.namespaceURI)==null?void 0:d.includes("svg")}),l=o.ref(t.width),c=o.ref(t.height),{stop:p}=Ke(e,([f])=>{const d=a==="border-box"?f.borderBoxSize:a==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(r&&s.value){const h=S(e);if(h){const g=r.getComputedStyle(h);l.value=Number.parseFloat(g.width),c.value=Number.parseFloat(g.height)}}else if(d){const h=Array.isArray(d)?d:[d];l.value=h.reduce((g,{inlineSize:C})=>g+C,0),c.value=h.reduce((g,{blockSize:C})=>g+C,0)}else l.value=f.contentRect.width,c.value=f.contentRect.height},n);u.tryOnMounted(()=>{const f=S(e);f&&(l.value="offsetWidth"in f?f.offsetWidth:t.width,c.value="offsetHeight"in f?f.offsetHeight:t.height)});const v=o.watch(()=>S(e),f=>{l.value=f?t.width:0,c.value=f?t.height:0});function m(){p(),v()}return{width:l,height:c,stop:m}}const Je={[u.directiveHooks.mounted](e,t){var n;const r=typeof t.value=="function"?t.value:(n=t.value)==null?void 0:n[0],a=typeof t.value=="function"?[]:t.value.slice(1),{width:s,height:l}=Ge(e,...a);o.watch([s,l],([c,p])=>r({width:c,height:p}))}},Ye=o.defineComponent({name:"UseElementVisibility",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive({isVisible:y.useElementVisibility(n)});return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}});function X(e,t,n={}){const{root:r,rootMargin:a="0px",threshold:s=.1,window:l=L,immediate:c=!0}=n,p=G(()=>l&&"IntersectionObserver"in l),v=o.computed(()=>{const g=u.toValue(e);return(Array.isArray(g)?g:[g]).map(S).filter(u.notNullish)});let m=u.noop;const f=o.ref(c),d=p.value?o.watch(()=>[v.value,S(r),f.value],([g,C])=>{if(m(),!f.value||!g.length)return;const E=new IntersectionObserver(t,{root:S(C),rootMargin:a,threshold:s});g.forEach(b=>b&&E.observe(b)),m=()=>{E.disconnect(),m=u.noop}},{immediate:c,flush:"post"}):u.noop,h=()=>{m(),d(),f.value=!1};return u.tryOnScopeDispose(h),{isSupported:p,isActive:f,pause(){m(),f.value=!1},resume(){f.value=!0},stop:h}}function Q(e,t={}){const{window:n=L,scrollTarget:r,threshold:a=0}=t,s=o.ref(!1);return X(e,l=>{let c=s.value,p=0;for(const v of l)v.time>=p&&(p=v.time,c=v.isIntersecting);s.value=c},{root:r,window:n,threshold:a}),s}const $e={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=t.value,r=Q(e);o.watch(r,a=>n(a),{immediate:!0})}else{const[n,r]=t.value,a=Q(e,r);o.watch(a,s=>n(s),{immediate:!0})}}},qe=o.defineComponent({name:"UseEyeDropper",props:{sRGBHex:String},setup(e,{slots:t}){const n=o.reactive(y.useEyeDropper());return()=>{if(t.default)return t.default(n)}}}),xe=o.defineComponent({name:"UseFullscreen",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.useFullscreen(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),Xe=o.defineComponent({name:"UseGeolocation",props:["enableHighAccuracy","maximumAge","timeout","navigator"],setup(e,{slots:t}){const n=o.reactive(y.useGeolocation(e));return()=>{if(t.default)return t.default(n)}}}),Qe=o.defineComponent({name:"UseIdle",props:["timeout","events","listenForVisibilityChange","initialState"],setup(e,{slots:t}){const n=o.reactive(y.useIdle(e.timeout,e));return()=>{if(t.default)return t.default(n)}}});function Ze(e,t,n){const{immediate:r=!0,delay:a=0,onError:s=u.noop,onSuccess:l=u.noop,resetOnExecute:c=!0,shallow:p=!0,throwError:v}=n??{},m=p?o.shallowRef(t):o.ref(t),f=o.ref(!1),d=o.ref(!1),h=o.shallowRef(void 0);async function g(b=0,...O){c&&(m.value=t),h.value=void 0,f.value=!1,d.value=!0,b>0&&await u.promiseTimeout(b);const I=typeof e=="function"?e(...O):e;try{const P=await I;m.value=P,f.value=!0,l(P)}catch(P){if(h.value=P,s(P),v)throw P}finally{d.value=!1}return m.value}r&&g(a);const C={state:m,isReady:f,isLoading:d,error:h,execute:g};function E(){return new Promise((b,O)=>{u.until(d).toBe(!1).then(()=>b(C)).catch(O)})}return{...C,then(b,O){return E().then(b,O)}}}async function De(e){return new Promise((t,n)=>{const r=new Image,{src:a,srcset:s,sizes:l,class:c,loading:p,crossorigin:v,referrerPolicy:m}=e;r.src=a,s&&(r.srcset=s),l&&(r.sizes=l),c&&(r.className=c),p&&(r.loading=p),v&&(r.crossOrigin=v),m&&(r.referrerPolicy=m),r.onload=()=>t(r),r.onerror=n})}function et(e,t={}){const n=Ze(()=>De(u.toValue(e)),void 0,{resetOnExecute:!0,...t});return o.watch(()=>u.toValue(e),()=>n.execute(t.delay),{deep:!0}),n}const tt=o.defineComponent({name:"UseImage",props:["src","srcset","sizes","as","alt","class","loading","crossorigin","referrerPolicy"],setup(e,{slots:t}){const n=o.reactive(et(e));return()=>n.isLoading&&t.loading?t.loading(n):n.error&&t.error?t.error(n.error):t.default?t.default(n):o.h(e.as||"img",e)}}),oe=1;function Z(e,t={}){const{throttle:n=0,idle:r=200,onStop:a=u.noop,onScroll:s=u.noop,offset:l={left:0,right:0,top:0,bottom:0},eventListenerOptions:c={capture:!1,passive:!0},behavior:p="auto",window:v=L,onError:m=U=>{console.error(U)}}=t,f=o.ref(0),d=o.ref(0),h=o.computed({get(){return f.value},set(U){C(U,void 0)}}),g=o.computed({get(){return d.value},set(U){C(void 0,U)}});function C(U,A){var T,w,k;if(!v)return;const M=u.toValue(e);M&&((k=M instanceof Document?v.document.body:M)==null||k.scrollTo({top:(T=u.toValue(A))!=null?T:g.value,left:(w=u.toValue(U))!=null?w:h.value,behavior:u.toValue(p)}))}const E=o.ref(!1),b=o.reactive({left:!0,right:!1,top:!0,bottom:!1}),O=o.reactive({left:!1,right:!1,top:!1,bottom:!1}),I=U=>{E.value&&(E.value=!1,O.left=!1,O.right=!1,O.top=!1,O.bottom=!1,a(U))},P=u.useDebounceFn(I,n+r),V=U=>{var A;if(!v)return;const T=((A=U?.document)==null?void 0:A.documentElement)||U?.documentElement||S(U),{display:w,flexDirection:k}=getComputedStyle(T),M=T.scrollLeft;O.left=M<f.value,O.right=M>f.value;const ce=Math.abs(M)<=(l.left||0),fe=Math.abs(M)+T.clientWidth>=T.scrollWidth-(l.right||0)-oe;w==="flex"&&k==="row-reverse"?(b.left=fe,b.right=ce):(b.left=ce,b.right=fe),f.value=M;let W=T.scrollTop;U===v.document&&!W&&(W=v.document.body.scrollTop),O.top=W<d.value,O.bottom=W>d.value;const de=Math.abs(W)<=(l.top||0),pe=Math.abs(W)+T.clientHeight>=T.scrollHeight-(l.bottom||0)-oe;w==="flex"&&k==="column-reverse"?(b.top=pe,b.bottom=de):(b.top=de,b.bottom=pe),d.value=W},N=U=>{var A;if(!v)return;const T=(A=U.target.documentElement)!=null?A:U.target;V(T),E.value=!0,P(U),s(U)};return _(e,"scroll",n?u.useThrottleFn(N,n,!0,!1):N,c),u.tryOnMounted(()=>{try{const U=u.toValue(e);if(!U)return;V(U)}catch(U){m(U)}}),_(e,"scrollend",I,c),{x:h,y:g,isScrolling:E,arrivedState:b,directions:O,measure(){const U=u.toValue(e);v&&U&&V(U)}}}function J(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function re(e,t,n={}){var r;const{direction:a="bottom",interval:s=100,canLoadMore:l=()=>!0}=n,c=o.reactive(Z(e,{...n,offset:{[a]:(r=n.distance)!=null?r:0,...n.offset}})),p=o.ref(),v=o.computed(()=>!!p.value),m=o.computed(()=>J(u.toValue(e))),f=Q(m);function d(){if(c.measure(),!m.value||!f.value||!l(m.value))return;const{scrollHeight:h,clientHeight:g,scrollWidth:C,clientWidth:E}=m.value,b=a==="bottom"||a==="top"?h<=g:C<=E;(c.arrivedState[a]||b)&&(p.value||(p.value=Promise.all([t(c),new Promise(O=>setTimeout(O,s))]).finally(()=>{p.value=null,o.nextTick(()=>d())})))}return o.watch(()=>[c.arrivedState[a],f.value],d,{immediate:!0}),{isLoading:v}}const nt={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?re(e,t.value):re(e,...t.value)}},ot={[u.directiveHooks.mounted](e,t){typeof t.value=="function"?X(e,t.value):X(e,...t.value)}},rt=o.defineComponent({name:"UseMouse",props:["touch","resetOnTouchEnds","initialValue"],setup(e,{slots:t}){const n=o.reactive(y.useMouse(e));return()=>{if(t.default)return t.default(n)}}}),at=o.defineComponent({name:"UseMouseElement",props:["handleOutside","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.useMouseInElement(n,e));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),st=o.defineComponent({name:"UseMousePressed",props:["touch","initialValue","as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.useMousePressed({...e,target:n}));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),it=o.defineComponent({name:"UseNetwork",setup(e,{slots:t}){const n=o.reactive(y.useNetwork());return()=>{if(t.default)return t.default(n)}}}),lt=o.defineComponent({name:"UseNow",props:["interval"],setup(e,{slots:t}){const n=o.reactive(y.useNow({...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),ut=o.defineComponent({name:"UseObjectUrl",props:["object"],setup(e,{slots:t}){const n=u.toRef(e,"object"),r=y.useObjectUrl(n);return()=>{if(t.default&&r.value)return t.default(r)}}}),ct=o.defineComponent({name:"UseOffsetPagination",props:["total","page","pageSize","onPageChange","onPageSizeChange","onPageCountChange"],emits:["page-change","page-size-change","page-count-change"],setup(e,{slots:t,emit:n}){const r=o.reactive(y.useOffsetPagination({...e,onPageChange(...a){var s;(s=e.onPageChange)==null||s.call(e,...a),n("page-change",...a)},onPageSizeChange(...a){var s;(s=e.onPageSizeChange)==null||s.call(e,...a),n("page-size-change",...a)},onPageCountChange(...a){var s;(s=e.onPageCountChange)==null||s.call(e,...a),n("page-count-change",...a)}}));return()=>{if(t.default)return t.default(r)}}}),ft=o.defineComponent({name:"UseOnline",setup(e,{slots:t}){const n=o.reactive({isOnline:y.useOnline()});return()=>{if(t.default)return t.default(n)}}}),dt=o.defineComponent({name:"UsePageLeave",setup(e,{slots:t}){const n=o.reactive({isLeft:y.usePageLeave()});return()=>{if(t.default)return t.default(n)}}}),pt=o.defineComponent({name:"UsePointer",props:["pointerTypes","initialValue","target"],setup(e,{slots:t}){const n=o.ref(null),r=o.reactive(y.usePointer({...e,target:e.target==="self"?n:L}));return()=>{if(t.default)return t.default(r,{ref:n})}}}),vt=o.defineComponent({name:"UsePointerLock",props:["as"],setup(e,{slots:t}){const n=o.ref(),r=o.reactive(y.usePointerLock(n));return()=>{if(t.default)return o.h(e.as||"div",{ref:n},t.default(r))}}}),gt=o.defineComponent({name:"UsePreferredColorScheme",setup(e,{slots:t}){const n=o.reactive({colorScheme:y.usePreferredColorScheme()});return()=>{if(t.default)return t.default(n)}}}),mt=o.defineComponent({name:"UsePreferredContrast",setup(e,{slots:t}){const n=o.reactive({contrast:y.usePreferredContrast()});return()=>{if(t.default)return t.default(n)}}}),ht=o.defineComponent({name:"UsePreferredDark",setup(e,{slots:t}){const n=o.reactive({prefersDark:y.usePreferredDark()});return()=>{if(t.default)return t.default(n)}}}),yt=o.defineComponent({name:"UsePreferredLanguages",setup(e,{slots:t}){const n=o.reactive({languages:y.usePreferredLanguages()});return()=>{if(t.default)return t.default(n)}}}),wt=o.defineComponent({name:"UsePreferredReducedMotion",setup(e,{slots:t}){const n=o.reactive({motion:y.usePreferredReducedMotion()});return()=>{if(t.default)return t.default(n)}}});function Ut(e,t,n={}){const{window:r=L,...a}=n;let s;const l=G(()=>r&&"MutationObserver"in r),c=()=>{s&&(s.disconnect(),s=void 0)},p=o.computed(()=>{const d=u.toValue(e),h=(Array.isArray(d)?d:[d]).map(S).filter(u.notNullish);return new Set(h)}),v=o.watch(()=>p.value,d=>{c(),l.value&&r&&d.size&&(s=new MutationObserver(t),d.forEach(h=>s.observe(h,a)))},{immediate:!0,flush:"post"}),m=()=>s?.takeRecords(),f=()=>{c(),v()};return u.tryOnScopeDispose(f),{isSupported:l,stop:f,takeRecords:m}}function Y(e,t,n={}){const{window:r=L,initialValue:a="",observe:s=!1}=n,l=o.ref(a),c=o.computed(()=>{var v;return S(t)||((v=r?.document)==null?void 0:v.documentElement)});function p(){var v;const m=u.toValue(e),f=u.toValue(c);if(f&&r){const d=(v=r.getComputedStyle(f).getPropertyValue(m))==null?void 0:v.trim();l.value=d||a}}return s&&Ut(c,p,{attributeFilter:["style","class"],window:r}),o.watch([c,()=>u.toValue(e)],p,{immediate:!0}),o.watch(l,v=>{var m;(m=c.value)!=null&&m.style&&c.value.style.setProperty(u.toValue(e),v)}),l}const ae="--vueuse-safe-area-top",se="--vueuse-safe-area-right",ie="--vueuse-safe-area-bottom",le="--vueuse-safe-area-left";function bt(){const e=o.ref(""),t=o.ref(""),n=o.ref(""),r=o.ref("");if(u.isClient){const s=Y(ae),l=Y(se),c=Y(ie),p=Y(le);s.value="env(safe-area-inset-top, 0px)",l.value="env(safe-area-inset-right, 0px)",c.value="env(safe-area-inset-bottom, 0px)",p.value="env(safe-area-inset-left, 0px)",a(),_("resize",u.useDebounceFn(a))}function a(){e.value=$(ae),t.value=$(se),n.value=$(ie),r.value=$(le)}return{top:e,right:t,bottom:n,left:r,update:a}}function $(e){return getComputedStyle(document.documentElement).getPropertyValue(e)}const St=o.defineComponent({name:"UseScreenSafeArea",props:{top:Boolean,right:Boolean,bottom:Boolean,left:Boolean},setup(e,{slots:t}){const{top:n,right:r,bottom:a,left:s}=bt();return()=>{if(t.default)return o.h("div",{style:{paddingTop:e.top?n.value:"",paddingRight:e.right?r.value:"",paddingBottom:e.bottom?a.value:"",paddingLeft:e.left?s.value:"",boxSizing:"border-box",maxHeight:"100vh",maxWidth:"100vw",overflow:"auto"}},t.default())}}}),Ct={[u.directiveHooks.mounted](e,t){if(typeof t.value=="function"){const n=t.value,r=Z(e,{onScroll(){n(r)},onStop(){n(r)}})}else{const[n,r]=t.value,a=Z(e,{...r,onScroll(s){var l;(l=r.onScroll)==null||l.call(r,s),n(a)},onStop(s){var l;(l=r.onStop)==null||l.call(r,s),n(a)}})}}};function ue(e){const t=window.getComputedStyle(e);if(t.overflowX==="scroll"||t.overflowY==="scroll"||t.overflowX==="auto"&&e.clientWidth<e.scrollWidth||t.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const n=e.parentNode;return!n||n.tagName==="BODY"?!1:ue(n)}}function Ot(e){const t=e||window.event,n=t.target;return ue(n)?!1:t.touches.length>1?!0:(t.preventDefault&&t.preventDefault(),!1)}const q=new WeakMap;function Et(e,t=!1){const n=o.ref(t);let r=null;o.watch(u.toRef(e),l=>{const c=J(u.toValue(l));if(c){const p=c;q.get(p)||q.set(p,p.style.overflow),n.value&&(p.style.overflow="hidden")}},{immediate:!0});const a=()=>{const l=J(u.toValue(e));!l||n.value||(u.isIOS&&(r=_(l,"touchmove",c=>{Ot(c)},{passive:!1})),l.style.overflow="hidden",n.value=!0)},s=()=>{var l;const c=J(u.toValue(e));!c||!n.value||(u.isIOS&&r?.(),c.style.overflow=(l=q.get(c))!=null?l:"",q.delete(c),n.value=!1)};return u.tryOnScopeDispose(s),o.computed({get(){return n.value},set(l){l?a():s()}})}function Pt(){let e=!1;const t=o.ref(!1);return(n,r)=>{if(t.value=r.value,e)return;e=!0;const a=Et(n,r.value);o.watch(t,s=>a.value=s)}}const Lt=Pt(),_t=o.defineComponent({name:"UseTimeAgo",props:["time","updateInterval","max","fullDateFormatter","messages","showSecond"],setup(e,{slots:t}){const n=o.reactive(y.useTimeAgo(()=>e.time,{...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),kt=o.defineComponent({name:"UseTimestamp",props:["immediate","interval","offset"],setup(e,{slots:t}){const n=o.reactive(y.useTimestamp({...e,controls:!0}));return()=>{if(t.default)return t.default(n)}}}),At=o.defineComponent({name:"UseVirtualList",props:["list","options","height"],setup(e,{slots:t,expose:n}){const{list:r}=o.toRefs(e),{list:a,containerProps:s,wrapperProps:l,scrollTo:c}=y.useVirtualList(r,e.options);return n({scrollTo:c}),s.style&&typeof s.style=="object"&&!Array.isArray(s.style)&&(s.style.height=e.height||"300px"),()=>o.h("div",{...s},[o.h("div",{...l.value},a.value.map(p=>o.h("div",{style:{overflow:"hidden",height:p.height}},t.default?t.default(p):"Please set content!")))])}}),Mt=o.defineComponent({name:"UseWindowFocus",setup(e,{slots:t}){const n=o.reactive({focused:y.useWindowFocus()});return()=>{if(t.default)return t.default(n)}}}),Tt=o.defineComponent({name:"UseWindowSize",props:["initialWidth","initialHeight"],setup(e,{slots:t}){const n=o.reactive(y.useWindowSize(e));return()=>{if(t.default)return t.default(n)}}});i.OnClickOutside=D,i.OnLongPress=he,i.UseActiveElement=ye,i.UseBattery=we,i.UseBrowserLocation=Ue,i.UseClipboard=be,i.UseColorMode=Me,i.UseDark=Te,i.UseDeviceMotion=Ve,i.UseDeviceOrientation=Ie,i.UseDevicePixelRatio=Re,i.UseDevicesList=He,i.UseDocumentVisibility=ze,i.UseDraggable=Ne,i.UseElementBounding=We,i.UseElementSize=Fe,i.UseElementVisibility=Ye,i.UseEyeDropper=qe,i.UseFullscreen=xe,i.UseGeolocation=Xe,i.UseIdle=Qe,i.UseImage=tt,i.UseMouse=rt,i.UseMouseInElement=at,i.UseMousePressed=st,i.UseNetwork=it,i.UseNow=lt,i.UseObjectUrl=ut,i.UseOffsetPagination=ct,i.UseOnline=ft,i.UsePageLeave=dt,i.UsePointer=pt,i.UsePointerLock=vt,i.UsePreferredColorScheme=gt,i.UsePreferredContrast=mt,i.UsePreferredDark=ht,i.UsePreferredLanguages=yt,i.UsePreferredReducedMotion=wt,i.UseScreenSafeArea=St,i.UseTimeAgo=_t,i.UseTimestamp=kt,i.UseVirtualList=At,i.UseWindowFocus=Mt,i.UseWindowSize=Tt,i.VOnClickOutside=j,i.VOnLongPress=ee,i.vElementHover=je,i.vElementSize=Je,i.vElementVisibility=$e,i.vInfiniteScroll=nt,i.vIntersectionObserver=ot,i.vOnClickOutside=j,i.vOnKeyStroke=ve,i.vOnLongPress=ee,i.vScroll=Ct,i.vScrollLock=Lt})(this.VueUse=this.VueUse||{},VueDemi,VueUse,VueUse);
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, h, watch, computed, reactive, shallowRef, nextTick, getCurrentInstance, onMounted, watchEffect, toRefs } from 'vue-demi';
1
+ import { defineComponent, ref, h, watch, computed, reactive, shallowRef, nextTick, getCurrentInstance, onMounted, isVue2, watchEffect, toRefs } from 'vue-demi';
2
2
  import { onClickOutside as onClickOutside$1, useActiveElement, useBattery, useBrowserLocation, useClipboard, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding, useElementSize as useElementSize$1, useElementVisibility as useElementVisibility$1, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, usePointer, usePointerLock, usePreferredColorScheme, usePreferredContrast, usePreferredDark as usePreferredDark$1, usePreferredLanguages, usePreferredReducedMotion, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
3
3
  import { toValue, isClient, noop, isObject, tryOnScopeDispose, isIOS, directiveHooks, pausableWatch, tryOnMounted, toRef, useToggle, notNullish, promiseTimeout, until, useDebounceFn, useThrottleFn } from '@vueuse/shared';
4
4
 
@@ -447,26 +447,29 @@ function useStorage(key, defaults, storage, options = {}) {
447
447
  }
448
448
  if (!initOnMounted)
449
449
  update();
450
- return data;
450
+ function dispatchWriteEvent(oldValue, newValue) {
451
+ if (window) {
452
+ window.dispatchEvent(new CustomEvent(customStorageEventName, {
453
+ detail: {
454
+ key,
455
+ oldValue,
456
+ newValue,
457
+ storageArea: storage
458
+ }
459
+ }));
460
+ }
461
+ }
451
462
  function write(v) {
452
463
  try {
464
+ const oldValue = storage.getItem(key);
453
465
  if (v == null) {
466
+ dispatchWriteEvent(oldValue, null);
454
467
  storage.removeItem(key);
455
468
  } else {
456
469
  const serialized = serializer.write(v);
457
- const oldValue = storage.getItem(key);
458
470
  if (oldValue !== serialized) {
459
471
  storage.setItem(key, serialized);
460
- if (window) {
461
- window.dispatchEvent(new CustomEvent(customStorageEventName, {
462
- detail: {
463
- key,
464
- oldValue,
465
- newValue: serialized,
466
- storageArea: storage
467
- }
468
- }));
469
- }
472
+ dispatchWriteEvent(oldValue, serialized);
470
473
  }
471
474
  }
472
475
  } catch (e) {
@@ -492,9 +495,6 @@ function useStorage(key, defaults, storage, options = {}) {
492
495
  return serializer.read(rawValue);
493
496
  }
494
497
  }
495
- function updateFromCustomEvent(event) {
496
- update(event.detail);
497
- }
498
498
  function update(event) {
499
499
  if (event && event.storageArea !== storage)
500
500
  return;
@@ -517,14 +517,19 @@ function useStorage(key, defaults, storage, options = {}) {
517
517
  resumeWatch();
518
518
  }
519
519
  }
520
+ function updateFromCustomEvent(event) {
521
+ update(event.detail);
522
+ }
523
+ return data;
520
524
  }
521
525
 
522
526
  function useMounted() {
523
527
  const isMounted = ref(false);
524
- if (getCurrentInstance()) {
528
+ const instance = getCurrentInstance();
529
+ if (instance) {
525
530
  onMounted(() => {
526
531
  isMounted.value = true;
527
- });
532
+ }, isVue2 ? null : instance);
528
533
  }
529
534
  return isMounted;
530
535
  }
@@ -764,7 +769,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
764
769
  "axis",
765
770
  "onStart",
766
771
  "onMove",
767
- "onEnd"
772
+ "onEnd",
773
+ "disabled"
768
774
  ],
769
775
  setup(props, { slots }) {
770
776
  const target = ref();
@@ -772,6 +778,7 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
772
778
  var _a;
773
779
  return (_a = props.handle) != null ? _a : target.value;
774
780
  });
781
+ const disabled = computed(() => !!props.disabled);
775
782
  const storageValue = props.storageKey && useStorage$1(
776
783
  props.storageKey,
777
784
  toValue(props.initialValue) || { x: 0, y: 0 },
@@ -790,7 +797,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
790
797
  ...props,
791
798
  handle,
792
799
  initialValue,
793
- onEnd
800
+ onEnd,
801
+ disabled
794
802
  }));
795
803
  return () => {
796
804
  if (slots.default)
@@ -881,7 +889,7 @@ function useResizeObserver(target, callback, options = {}) {
881
889
  _el && observer.observe(_el, observerOptions);
882
890
  }
883
891
  },
884
- { immediate: true, flush: "post", deep: true }
892
+ { immediate: true, flush: "post" }
885
893
  );
886
894
  const stop = () => {
887
895
  cleanup();
@@ -1036,7 +1044,7 @@ function useIntersectionObserver(target, callback, options = {}) {
1036
1044
  }
1037
1045
 
1038
1046
  function useElementVisibility(element, options = {}) {
1039
- const { window = defaultWindow, scrollTarget } = options;
1047
+ const { window = defaultWindow, scrollTarget, threshold = 0 } = options;
1040
1048
  const elementIsVisible = ref(false);
1041
1049
  useIntersectionObserver(
1042
1050
  element,
@@ -1054,7 +1062,7 @@ function useElementVisibility(element, options = {}) {
1054
1062
  {
1055
1063
  root: scrollTarget,
1056
1064
  window,
1057
- threshold: 0
1065
+ threshold
1058
1066
  }
1059
1067
  );
1060
1068
  return elementIsVisible;
@@ -1268,7 +1276,10 @@ function useScroll(element, options = {}) {
1268
1276
  passive: true
1269
1277
  },
1270
1278
  behavior = "auto",
1271
- window = defaultWindow
1279
+ window = defaultWindow,
1280
+ onError = (e) => {
1281
+ console.error(e);
1282
+ }
1272
1283
  } = options;
1273
1284
  const internalX = ref(0);
1274
1285
  const internalY = ref(0);
@@ -1329,12 +1340,12 @@ function useScroll(element, options = {}) {
1329
1340
  var _a;
1330
1341
  if (!window)
1331
1342
  return;
1332
- const el = target.document ? target.document.documentElement : (_a = target.documentElement) != null ? _a : target;
1343
+ const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
1333
1344
  const { display, flexDirection } = getComputedStyle(el);
1334
1345
  const scrollLeft = el.scrollLeft;
1335
1346
  directions.left = scrollLeft < internalX.value;
1336
1347
  directions.right = scrollLeft > internalX.value;
1337
- const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
1348
+ const left = Math.abs(scrollLeft) <= (offset.left || 0);
1338
1349
  const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1339
1350
  if (display === "flex" && flexDirection === "row-reverse") {
1340
1351
  arrivedState.left = right;
@@ -1349,7 +1360,7 @@ function useScroll(element, options = {}) {
1349
1360
  scrollTop = window.document.body.scrollTop;
1350
1361
  directions.top = scrollTop < internalY.value;
1351
1362
  directions.bottom = scrollTop > internalY.value;
1352
- const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
1363
+ const top = Math.abs(scrollTop) <= (offset.top || 0);
1353
1364
  const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1354
1365
  if (display === "flex" && flexDirection === "column-reverse") {
1355
1366
  arrivedState.top = bottom;
@@ -1377,10 +1388,14 @@ function useScroll(element, options = {}) {
1377
1388
  eventListenerOptions
1378
1389
  );
1379
1390
  tryOnMounted(() => {
1380
- const _element = toValue(element);
1381
- if (!_element)
1382
- return;
1383
- setArrivedState(_element);
1391
+ try {
1392
+ const _element = toValue(element);
1393
+ if (!_element)
1394
+ return;
1395
+ setArrivedState(_element);
1396
+ } catch (e) {
1397
+ onError(e);
1398
+ }
1384
1399
  });
1385
1400
  useEventListener(
1386
1401
  element,
@@ -1730,16 +1745,21 @@ function useMutationObserver(target, callback, options = {}) {
1730
1745
  observer = void 0;
1731
1746
  }
1732
1747
  };
1748
+ const targets = computed(() => {
1749
+ const value = toValue(target);
1750
+ const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(notNullish);
1751
+ return new Set(items);
1752
+ });
1733
1753
  const stopWatch = watch(
1734
- () => unrefElement(target),
1735
- (el) => {
1754
+ () => targets.value,
1755
+ (targets2) => {
1736
1756
  cleanup();
1737
- if (isSupported.value && window && el) {
1757
+ if (isSupported.value && window && targets2.size) {
1738
1758
  observer = new MutationObserver(callback);
1739
- observer.observe(el, mutationOptions);
1759
+ targets2.forEach((el) => observer.observe(el, mutationOptions));
1740
1760
  }
1741
1761
  },
1742
- { immediate: true }
1762
+ { immediate: true, flush: "post" }
1743
1763
  );
1744
1764
  const takeRecords = () => {
1745
1765
  return observer == null ? void 0 : observer.takeRecords();
@@ -1924,13 +1944,12 @@ const elInitialOverflow = /* @__PURE__ */ new WeakMap();
1924
1944
  function useScrollLock(element, initialState = false) {
1925
1945
  const isLocked = ref(initialState);
1926
1946
  let stopTouchMoveListener = null;
1927
- let initialOverflow;
1928
1947
  watch(toRef(element), (el) => {
1929
1948
  const target = resolveElement(toValue(el));
1930
1949
  if (target) {
1931
1950
  const ele = target;
1932
1951
  if (!elInitialOverflow.get(ele))
1933
- elInitialOverflow.set(ele, initialOverflow);
1952
+ elInitialOverflow.set(ele, ele.style.overflow);
1934
1953
  if (isLocked.value)
1935
1954
  ele.style.overflow = "hidden";
1936
1955
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/components",
3
- "version": "10.7.2",
3
+ "version": "10.9.0",
4
4
  "description": "Renderless components for VueUse",
5
5
  "author": "Jacob Clevenger<https://github.com/wheatjs>",
6
6
  "license": "MIT",
@@ -32,8 +32,8 @@
32
32
  "jsdelivr": "./index.iife.min.js",
33
33
  "types": "./index.d.cts",
34
34
  "dependencies": {
35
- "@vueuse/core": "10.7.2",
36
- "@vueuse/shared": "10.7.2",
37
- "vue-demi": ">=0.14.6"
35
+ "@vueuse/core": "10.9.0",
36
+ "@vueuse/shared": "10.9.0",
37
+ "vue-demi": ">=0.14.7"
38
38
  }
39
39
  }