@vueuse/components 10.0.0-beta.1 → 10.0.0-beta.3

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.iife.js CHANGED
@@ -165,14 +165,20 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
165
165
  el.addEventListener(event, listener, options2);
166
166
  return () => el.removeEventListener(event, listener, options2);
167
167
  };
168
- const stopWatch = vueDemi.watch(() => [unrefElement(target), shared.resolveUnref(options)], ([el, options2]) => {
169
- cleanup();
170
- if (!el)
171
- return;
172
- cleanups.push(...events.flatMap((event) => {
173
- return listeners.map((listener) => register(el, event, listener, options2));
174
- }));
175
- }, { immediate: true, flush: "post" });
168
+ const stopWatch = vueDemi.watch(
169
+ () => [unrefElement(target), shared.resolveUnref(options)],
170
+ ([el, options2]) => {
171
+ cleanup();
172
+ if (!el)
173
+ return;
174
+ cleanups.push(
175
+ ...events.flatMap((event) => {
176
+ return listeners.map((listener) => register(el, event, listener, options2));
177
+ })
178
+ );
179
+ },
180
+ { immediate: true, flush: "post" }
181
+ );
176
182
  const stop = () => {
177
183
  stopWatch();
178
184
  cleanup();
@@ -246,7 +252,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
246
252
  }
247
253
  };
248
254
 
249
- const createKeyPredicate = (keyFilter) => {
255
+ function createKeyPredicate(keyFilter) {
250
256
  if (typeof keyFilter === "function")
251
257
  return keyFilter;
252
258
  else if (typeof keyFilter === "string")
@@ -254,7 +260,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
254
260
  else if (Array.isArray(keyFilter))
255
261
  return (event) => keyFilter.includes(event.key);
256
262
  return () => true;
257
- };
263
+ }
258
264
  function onKeyStroke(...args) {
259
265
  let key;
260
266
  let handler;
@@ -276,9 +282,16 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
276
282
  key = true;
277
283
  handler = args[0];
278
284
  }
279
- const { target = defaultWindow, eventName = "keydown", passive = false } = options;
285
+ const {
286
+ target = defaultWindow,
287
+ eventName = "keydown",
288
+ passive = false,
289
+ dedupe = false
290
+ } = options;
280
291
  const predicate = createKeyPredicate(key);
281
292
  const listener = (e) => {
293
+ if (e.repeat && shared.resolveUnref(dedupe))
294
+ return;
282
295
  if (predicate(e))
283
296
  handler(e);
284
297
  };
@@ -338,7 +351,10 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
338
351
  ev.preventDefault();
339
352
  if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
340
353
  ev.stopPropagation();
341
- timeout = setTimeout(() => handler(ev), (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY);
354
+ timeout = setTimeout(
355
+ () => handler(ev),
356
+ (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
357
+ );
342
358
  }
343
359
  const listenerOptions = {
344
360
  capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
@@ -355,9 +371,13 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
355
371
  emits: ["trigger"],
356
372
  setup(props, { slots, emit }) {
357
373
  const target = vueDemi.ref();
358
- onLongPress(target, (e) => {
359
- emit("trigger", e);
360
- }, props.options);
374
+ onLongPress(
375
+ target,
376
+ (e) => {
377
+ emit("trigger", e);
378
+ },
379
+ props.options
380
+ );
361
381
  return () => {
362
382
  if (slots.default)
363
383
  return vueDemi.h(props.as || "div", { ref: target }, slots.default());
@@ -503,7 +523,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
503
523
  const rawInit = shared.resolveUnref(defaults);
504
524
  const type = guessSerializerType(rawInit);
505
525
  const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
506
- const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(data, () => write(data.value), { flush, deep, eventFilter });
526
+ const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(
527
+ data,
528
+ () => write(data.value),
529
+ { flush, deep, eventFilter }
530
+ );
507
531
  if (window && listenToStorageChanges) {
508
532
  useEventListener(window, "storage", update);
509
533
  useEventListener(window, customStorageEventName, updateFromCustomEvent);
@@ -580,12 +604,22 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
580
604
  }
581
605
  }
582
606
 
583
- function useSupported(callback, sync = false) {
584
- const isSupported = vueDemi.ref();
585
- const update = () => isSupported.value = Boolean(callback());
586
- update();
587
- shared.tryOnMounted(update, sync);
588
- return isSupported;
607
+ function useMounted() {
608
+ const isMounted = vueDemi.ref(false);
609
+ if (vueDemi.getCurrentInstance()) {
610
+ vueDemi.onMounted(() => {
611
+ isMounted.value = true;
612
+ });
613
+ }
614
+ return isMounted;
615
+ }
616
+
617
+ function useSupported(callback) {
618
+ const isMounted = useMounted();
619
+ return vueDemi.computed(() => {
620
+ isMounted.value;
621
+ return Boolean(callback());
622
+ });
589
623
  }
590
624
 
591
625
  function useMediaQuery(query, options = {}) {
@@ -606,7 +640,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
606
640
  return;
607
641
  cleanup();
608
642
  mediaQuery = window.matchMedia(shared.resolveRef(query).value);
609
- matches.value = mediaQuery.matches;
643
+ matches.value = !!(mediaQuery == null ? void 0 : mediaQuery.matches);
644
+ if (!mediaQuery)
645
+ return;
610
646
  if ("addEventListener" in mediaQuery)
611
647
  mediaQuery.addEventListener("change", update);
612
648
  else
@@ -648,6 +684,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
648
684
  listenToStorageChanges = true,
649
685
  storageRef,
650
686
  emitAuto,
687
+ // TODO: switch to true in v10
651
688
  disableTransition = false
652
689
  } = options;
653
690
  const modes = __spreadValues$b({
@@ -666,33 +703,36 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
666
703
  store.value = v;
667
704
  }
668
705
  });
669
- const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => {
670
- const el = window == null ? void 0 : window.document.querySelector(selector2);
671
- if (!el)
672
- return;
673
- let style;
674
- if (disableTransition) {
675
- style = window.document.createElement("style");
676
- style.type = "text/css";
677
- style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
678
- window.document.head.appendChild(style);
679
- }
680
- if (attribute2 === "class") {
681
- const current = value.split(/\s/g);
682
- Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
683
- if (current.includes(v))
684
- el.classList.add(v);
685
- else
686
- el.classList.remove(v);
687
- });
688
- } else {
689
- el.setAttribute(attribute2, value);
690
- }
691
- if (disableTransition) {
692
- window.getComputedStyle(style).opacity;
693
- document.head.removeChild(style);
706
+ const updateHTMLAttrs = getSSRHandler(
707
+ "updateHTMLAttrs",
708
+ (selector2, attribute2, value) => {
709
+ const el = window == null ? void 0 : window.document.querySelector(selector2);
710
+ if (!el)
711
+ return;
712
+ let style;
713
+ if (disableTransition) {
714
+ style = window.document.createElement("style");
715
+ style.type = "text/css";
716
+ style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
717
+ window.document.head.appendChild(style);
718
+ }
719
+ if (attribute2 === "class") {
720
+ const current = value.split(/\s/g);
721
+ Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
722
+ if (current.includes(v))
723
+ el.classList.add(v);
724
+ else
725
+ el.classList.remove(v);
726
+ });
727
+ } else {
728
+ el.setAttribute(attribute2, value);
729
+ }
730
+ if (disableTransition) {
731
+ window.getComputedStyle(style).opacity;
732
+ document.head.removeChild(style);
733
+ }
694
734
  }
695
- });
735
+ );
696
736
  function defaultOnChanged(mode) {
697
737
  var _a;
698
738
  const resolvedMode = mode === "auto" ? preferredMode.value : mode;
@@ -832,7 +872,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
832
872
  "stopPropagation",
833
873
  "pointerTypes",
834
874
  "as",
835
- "handle"
875
+ "handle",
876
+ "axis"
836
877
  ],
837
878
  setup(props, { slots }) {
838
879
  const target = vueDemi.ref();
@@ -840,7 +881,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
840
881
  var _a;
841
882
  return (_a = props.handle) != null ? _a : target.value;
842
883
  });
843
- const storageValue = props.storageKey && core.useStorage(props.storageKey, shared.resolveUnref(props.initialValue) || { x: 0, y: 0 }, core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0);
884
+ const storageValue = props.storageKey && core.useStorage(
885
+ props.storageKey,
886
+ shared.resolveUnref(props.initialValue) || { x: 0, y: 0 },
887
+ core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0
888
+ );
844
889
  const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
845
890
  const onEnd = (position) => {
846
891
  if (!storageValue)
@@ -946,13 +991,21 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
946
991
  observer = void 0;
947
992
  }
948
993
  };
949
- const stopWatch = vueDemi.watch(() => unrefElement(target), (el) => {
950
- cleanup();
951
- if (isSupported.value && window && el) {
952
- observer = new ResizeObserver(callback);
953
- observer.observe(el, observerOptions);
954
- }
955
- }, { immediate: true, flush: "post" });
994
+ const targets = vueDemi.computed(
995
+ () => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]
996
+ );
997
+ const stopWatch = vueDemi.watch(
998
+ targets,
999
+ (els) => {
1000
+ cleanup();
1001
+ if (isSupported.value && window) {
1002
+ observer = new ResizeObserver(callback);
1003
+ for (const _el of els)
1004
+ _el && observer.observe(_el, observerOptions);
1005
+ }
1006
+ },
1007
+ { immediate: true, flush: "post", deep: true }
1008
+ );
956
1009
  const stop = () => {
957
1010
  cleanup();
958
1011
  stopWatch();
@@ -972,30 +1025,37 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
972
1025
  });
973
1026
  const width = vueDemi.ref(initialSize.width);
974
1027
  const height = vueDemi.ref(initialSize.height);
975
- useResizeObserver(target, ([entry]) => {
976
- const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
977
- if (window && isSVG.value) {
978
- const $elem = unrefElement(target);
979
- if ($elem) {
980
- const styles = window.getComputedStyle($elem);
981
- width.value = parseFloat(styles.width);
982
- height.value = parseFloat(styles.height);
983
- }
984
- } else {
985
- if (boxSize) {
986
- const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
987
- width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
988
- height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
1028
+ useResizeObserver(
1029
+ target,
1030
+ ([entry]) => {
1031
+ const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
1032
+ if (window && isSVG.value) {
1033
+ const $elem = unrefElement(target);
1034
+ if ($elem) {
1035
+ const styles = window.getComputedStyle($elem);
1036
+ width.value = parseFloat(styles.width);
1037
+ height.value = parseFloat(styles.height);
1038
+ }
989
1039
  } else {
990
- width.value = entry.contentRect.width;
991
- height.value = entry.contentRect.height;
1040
+ if (boxSize) {
1041
+ const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
1042
+ width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
1043
+ height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
1044
+ } else {
1045
+ width.value = entry.contentRect.width;
1046
+ height.value = entry.contentRect.height;
1047
+ }
992
1048
  }
1049
+ },
1050
+ options
1051
+ );
1052
+ vueDemi.watch(
1053
+ () => unrefElement(target),
1054
+ (ele) => {
1055
+ width.value = ele ? initialSize.width : 0;
1056
+ height.value = ele ? initialSize.height : 0;
993
1057
  }
994
- }, options);
995
- vueDemi.watch(() => unrefElement(target), (ele) => {
996
- width.value = ele ? initialSize.width : 0;
997
- height.value = ele ? initialSize.height : 0;
998
- });
1058
+ );
999
1059
  return {
1000
1060
  width,
1001
1061
  height
@@ -1027,27 +1087,63 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1027
1087
  }
1028
1088
  });
1029
1089
 
1090
+ function useIntersectionObserver(target, callback, options = {}) {
1091
+ const {
1092
+ root,
1093
+ rootMargin = "0px",
1094
+ threshold = 0.1,
1095
+ window = defaultWindow
1096
+ } = options;
1097
+ const isSupported = useSupported(() => window && "IntersectionObserver" in window);
1098
+ let cleanup = shared.noop;
1099
+ const stopWatch = isSupported.value ? vueDemi.watch(
1100
+ () => ({
1101
+ el: unrefElement(target),
1102
+ root: unrefElement(root)
1103
+ }),
1104
+ ({ el, root: root2 }) => {
1105
+ cleanup();
1106
+ if (!el)
1107
+ return;
1108
+ const observer = new IntersectionObserver(
1109
+ callback,
1110
+ {
1111
+ root: root2,
1112
+ rootMargin,
1113
+ threshold
1114
+ }
1115
+ );
1116
+ observer.observe(el);
1117
+ cleanup = () => {
1118
+ observer.disconnect();
1119
+ cleanup = shared.noop;
1120
+ };
1121
+ },
1122
+ { immediate: true, flush: "post" }
1123
+ ) : shared.noop;
1124
+ const stop = () => {
1125
+ cleanup();
1126
+ stopWatch();
1127
+ };
1128
+ shared.tryOnScopeDispose(stop);
1129
+ return {
1130
+ isSupported,
1131
+ stop
1132
+ };
1133
+ }
1134
+
1030
1135
  function useElementVisibility(element, { window = defaultWindow, scrollTarget } = {}) {
1031
1136
  const elementIsVisible = vueDemi.ref(false);
1032
- const testBounding = () => {
1033
- if (!window)
1034
- return;
1035
- const document = window.document;
1036
- const el = unrefElement(element);
1037
- if (!el) {
1038
- elementIsVisible.value = false;
1039
- } else {
1040
- const rect = el.getBoundingClientRect();
1041
- elementIsVisible.value = rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
1137
+ useIntersectionObserver(
1138
+ element,
1139
+ ([{ isIntersecting }]) => {
1140
+ elementIsVisible.value = isIntersecting;
1141
+ },
1142
+ {
1143
+ root: scrollTarget,
1144
+ window
1042
1145
  }
1043
- };
1044
- vueDemi.watch(() => unrefElement(element), () => testBounding(), { immediate: true, flush: "post" });
1045
- if (window) {
1046
- useEventListener(scrollTarget || window, "scroll", testBounding, {
1047
- capture: false,
1048
- passive: true
1049
- });
1050
- }
1146
+ );
1051
1147
  return elementIsVisible;
1052
1148
  }
1053
1149
 
@@ -1194,13 +1290,21 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1194
1290
  img.onerror = reject;
1195
1291
  });
1196
1292
  }
1197
- const useImage = (options, asyncStateOptions = {}) => {
1198
- const state = useAsyncState(() => loadImage(shared.resolveUnref(options)), void 0, __spreadValues$9({
1199
- resetOnExecute: true
1200
- }, asyncStateOptions));
1201
- vueDemi.watch(() => shared.resolveUnref(options), () => state.execute(asyncStateOptions.delay), { deep: true });
1293
+ function useImage(options, asyncStateOptions = {}) {
1294
+ const state = useAsyncState(
1295
+ () => loadImage(shared.resolveUnref(options)),
1296
+ void 0,
1297
+ __spreadValues$9({
1298
+ resetOnExecute: true
1299
+ }, asyncStateOptions)
1300
+ );
1301
+ vueDemi.watch(
1302
+ () => shared.resolveUnref(options),
1303
+ () => state.execute(asyncStateOptions.delay),
1304
+ { deep: true }
1305
+ );
1202
1306
  return state;
1203
- };
1307
+ }
1204
1308
 
1205
1309
  const UseImage = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
1206
1310
  name: "UseImage",
@@ -1316,8 +1420,18 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1316
1420
  onScrollEndDebounced(e);
1317
1421
  onScroll(e);
1318
1422
  };
1319
- useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions);
1320
- useEventListener(element, "scrollend", onScrollEnd, eventListenerOptions);
1423
+ useEventListener(
1424
+ element,
1425
+ "scroll",
1426
+ throttle ? shared.useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
1427
+ eventListenerOptions
1428
+ );
1429
+ useEventListener(
1430
+ element,
1431
+ "scrollend",
1432
+ onScrollEnd,
1433
+ eventListenerOptions
1434
+ );
1321
1435
  return {
1322
1436
  x,
1323
1437
  y,
@@ -1349,30 +1463,36 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1349
1463
  function useInfiniteScroll(element, onLoadMore, options = {}) {
1350
1464
  var _a, _b;
1351
1465
  const direction = (_a = options.direction) != null ? _a : "bottom";
1352
- const state = vueDemi.reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
1353
- offset: __spreadValues$8({
1354
- [direction]: (_b = options.distance) != null ? _b : 0
1355
- }, options.offset)
1356
- })));
1357
- vueDemi.watch(() => state.arrivedState[direction], async (v) => {
1358
- var _a2, _b2;
1359
- if (v) {
1360
- const elem = shared.resolveUnref(element);
1361
- const previous = {
1362
- height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
1363
- width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
1364
- };
1365
- await onLoadMore(state);
1366
- if (options.preserveScrollPosition && elem) {
1367
- vueDemi.nextTick(() => {
1368
- elem.scrollTo({
1369
- top: elem.scrollHeight - previous.height,
1370
- left: elem.scrollWidth - previous.width
1466
+ const state = vueDemi.reactive(useScroll(
1467
+ element,
1468
+ __spreadProps$7(__spreadValues$8({}, options), {
1469
+ offset: __spreadValues$8({
1470
+ [direction]: (_b = options.distance) != null ? _b : 0
1471
+ }, options.offset)
1472
+ })
1473
+ ));
1474
+ vueDemi.watch(
1475
+ () => state.arrivedState[direction],
1476
+ async (v) => {
1477
+ var _a2, _b2;
1478
+ if (v) {
1479
+ const elem = shared.resolveUnref(element);
1480
+ const previous = {
1481
+ height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
1482
+ width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
1483
+ };
1484
+ await onLoadMore(state);
1485
+ if (options.preserveScrollPosition && elem) {
1486
+ vueDemi.nextTick(() => {
1487
+ elem.scrollTo({
1488
+ top: elem.scrollHeight - previous.height,
1489
+ left: elem.scrollWidth - previous.width
1490
+ });
1371
1491
  });
1372
- });
1492
+ }
1373
1493
  }
1374
1494
  }
1375
- });
1495
+ );
1376
1496
  }
1377
1497
 
1378
1498
  const vInfiniteScroll = {
@@ -1384,44 +1504,6 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1384
1504
  }
1385
1505
  };
1386
1506
 
1387
- function useIntersectionObserver(target, callback, options = {}) {
1388
- const {
1389
- root,
1390
- rootMargin = "0px",
1391
- threshold = 0.1,
1392
- window = defaultWindow
1393
- } = options;
1394
- const isSupported = useSupported(() => window && "IntersectionObserver" in window);
1395
- let cleanup = shared.noop;
1396
- const stopWatch = isSupported.value ? vueDemi.watch(() => ({
1397
- el: unrefElement(target),
1398
- root: unrefElement(root)
1399
- }), ({ el, root: root2 }) => {
1400
- cleanup();
1401
- if (!el)
1402
- return;
1403
- const observer = new IntersectionObserver(callback, {
1404
- root: root2,
1405
- rootMargin,
1406
- threshold
1407
- });
1408
- observer.observe(el);
1409
- cleanup = () => {
1410
- observer.disconnect();
1411
- cleanup = shared.noop;
1412
- };
1413
- }, { immediate: true, flush: "post" }) : shared.noop;
1414
- const stop = () => {
1415
- cleanup();
1416
- stopWatch();
1417
- };
1418
- shared.tryOnScopeDispose(stop);
1419
- return {
1420
- isSupported,
1421
- stop
1422
- };
1423
- }
1424
-
1425
1507
  const vIntersectionObserver = {
1426
1508
  [shared.directiveHooks.mounted](el, binding) {
1427
1509
  if (typeof binding.value === "function")
@@ -1768,12 +1850,19 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1768
1850
  window
1769
1851
  });
1770
1852
  }
1771
- vueDemi.watch([elRef, () => shared.resolveUnref(prop)], updateCssVar, { immediate: true });
1772
- vueDemi.watch(variable, (val) => {
1773
- var _a;
1774
- if ((_a = elRef.value) == null ? void 0 : _a.style)
1775
- elRef.value.style.setProperty(shared.resolveUnref(prop), val);
1776
- });
1853
+ vueDemi.watch(
1854
+ [elRef, () => shared.resolveUnref(prop)],
1855
+ updateCssVar,
1856
+ { immediate: true }
1857
+ );
1858
+ vueDemi.watch(
1859
+ variable,
1860
+ (val) => {
1861
+ var _a;
1862
+ if ((_a = elRef.value) == null ? void 0 : _a.style)
1863
+ elRef.value.style.setProperty(shared.resolveUnref(prop), val);
1864
+ }
1865
+ );
1777
1866
  return variable;
1778
1867
  }
1779
1868
 
@@ -1940,9 +2029,14 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1940
2029
  if (!ele || isLocked.value)
1941
2030
  return;
1942
2031
  if (shared.isIOS) {
1943
- stopTouchMoveListener = useEventListener(ele, "touchmove", (e) => {
1944
- preventDefault(e);
1945
- }, { passive: false });
2032
+ stopTouchMoveListener = useEventListener(
2033
+ ele,
2034
+ "touchmove",
2035
+ (e) => {
2036
+ preventDefault(e);
2037
+ },
2038
+ { passive: false }
2039
+ );
1946
2040
  }
1947
2041
  ele.style.overflow = "hidden";
1948
2042
  isLocked.value = true;
@@ -1969,7 +2063,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1969
2063
  });
1970
2064
  }
1971
2065
 
1972
- const onScrollLock = () => {
2066
+ function onScrollLock() {
1973
2067
  let isMounted = false;
1974
2068
  const state = vueDemi.ref(false);
1975
2069
  return (el, binding) => {
@@ -1980,7 +2074,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1980
2074
  const isLocked = useScrollLock(el, binding.value);
1981
2075
  vueDemi.watch(state, (v) => isLocked.value = v);
1982
2076
  };
1983
- };
2077
+ }
1984
2078
  const vScrollLock = onScrollLock();
1985
2079
 
1986
2080
  var __defProp$2 = Object.defineProperty;
@@ -2073,9 +2167,21 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
2073
2167
  const { list, containerProps, wrapperProps, scrollTo } = core.useVirtualList(listRef, props.options);
2074
2168
  expose({ scrollTo });
2075
2169
  typeof containerProps.style === "object" && !Array.isArray(containerProps.style) && (containerProps.style.height = props.height || "300px");
2076
- return () => vueDemi.h("div", __spreadValues({}, containerProps), [
2077
- vueDemi.h("div", __spreadValues({}, wrapperProps.value), list.value.map((item) => vueDemi.h("div", { style: { overFlow: "hidden", height: item.height } }, slots.default ? slots.default(item) : "Please set content!")))
2078
- ]);
2170
+ return () => vueDemi.h(
2171
+ "div",
2172
+ __spreadValues({}, containerProps),
2173
+ [
2174
+ vueDemi.h(
2175
+ "div",
2176
+ __spreadValues({}, wrapperProps.value),
2177
+ list.value.map((item) => vueDemi.h(
2178
+ "div",
2179
+ { style: { overFlow: "hidden", height: item.height } },
2180
+ slots.default ? slots.default(item) : "Please set content!"
2181
+ ))
2182
+ )
2183
+ ]
2184
+ );
2079
2185
  }
2080
2186
  });
2081
2187