@vueuse/components 10.0.2 → 10.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +139 -90
- package/index.d.ts +18 -6
- package/index.iife.js +139 -90
- package/index.iife.min.js +1 -1
- package/index.mjs +140 -91
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -187,19 +187,19 @@ function onKeyStroke(...args) {
|
|
|
187
187
|
return useEventListener(target, eventName, listener, passive);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
var __defProp$
|
|
191
|
-
var __getOwnPropSymbols$
|
|
192
|
-
var __hasOwnProp$
|
|
193
|
-
var __propIsEnum$
|
|
194
|
-
var __defNormalProp$
|
|
195
|
-
var __spreadValues$
|
|
190
|
+
var __defProp$e = Object.defineProperty;
|
|
191
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
192
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
193
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
194
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
195
|
+
var __spreadValues$e = (a, b) => {
|
|
196
196
|
for (var prop in b || (b = {}))
|
|
197
|
-
if (__hasOwnProp$
|
|
198
|
-
__defNormalProp$
|
|
199
|
-
if (__getOwnPropSymbols$
|
|
200
|
-
for (var prop of __getOwnPropSymbols$
|
|
201
|
-
if (__propIsEnum$
|
|
202
|
-
__defNormalProp$
|
|
197
|
+
if (__hasOwnProp$g.call(b, prop))
|
|
198
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
199
|
+
if (__getOwnPropSymbols$g)
|
|
200
|
+
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
201
|
+
if (__propIsEnum$g.call(b, prop))
|
|
202
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
203
203
|
}
|
|
204
204
|
return a;
|
|
205
205
|
};
|
|
@@ -213,7 +213,7 @@ const vOnKeyStroke = {
|
|
|
213
213
|
});
|
|
214
214
|
} else {
|
|
215
215
|
const [handler, options] = binding.value;
|
|
216
|
-
onKeyStroke(keys, handler, __spreadValues$
|
|
216
|
+
onKeyStroke(keys, handler, __spreadValues$e({
|
|
217
217
|
target: el
|
|
218
218
|
}, options));
|
|
219
219
|
}
|
|
@@ -334,19 +334,19 @@ function guessSerializerType(rawInit) {
|
|
|
334
334
|
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
var __defProp$
|
|
338
|
-
var __getOwnPropSymbols$
|
|
339
|
-
var __hasOwnProp$
|
|
340
|
-
var __propIsEnum$
|
|
341
|
-
var __defNormalProp$
|
|
342
|
-
var __spreadValues$
|
|
337
|
+
var __defProp$d = Object.defineProperty;
|
|
338
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
339
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
340
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
341
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
342
|
+
var __spreadValues$d = (a, b) => {
|
|
343
343
|
for (var prop in b || (b = {}))
|
|
344
|
-
if (__hasOwnProp$
|
|
345
|
-
__defNormalProp$
|
|
346
|
-
if (__getOwnPropSymbols$
|
|
347
|
-
for (var prop of __getOwnPropSymbols$
|
|
348
|
-
if (__propIsEnum$
|
|
349
|
-
__defNormalProp$
|
|
344
|
+
if (__hasOwnProp$f.call(b, prop))
|
|
345
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
346
|
+
if (__getOwnPropSymbols$f)
|
|
347
|
+
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
348
|
+
if (__propIsEnum$f.call(b, prop))
|
|
349
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
350
350
|
}
|
|
351
351
|
return a;
|
|
352
352
|
};
|
|
@@ -463,7 +463,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
463
463
|
if (typeof mergeDefaults === "function")
|
|
464
464
|
return mergeDefaults(value, rawInit);
|
|
465
465
|
else if (type === "object" && !Array.isArray(value))
|
|
466
|
-
return __spreadValues$
|
|
466
|
+
return __spreadValues$d(__spreadValues$d({}, rawInit), value);
|
|
467
467
|
return value;
|
|
468
468
|
} else if (typeof rawValue !== "string") {
|
|
469
469
|
return rawValue;
|
|
@@ -550,19 +550,19 @@ function usePreferredDark(options) {
|
|
|
550
550
|
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
var __defProp$
|
|
554
|
-
var __getOwnPropSymbols$
|
|
555
|
-
var __hasOwnProp$
|
|
556
|
-
var __propIsEnum$
|
|
557
|
-
var __defNormalProp$
|
|
558
|
-
var __spreadValues$
|
|
553
|
+
var __defProp$c = Object.defineProperty;
|
|
554
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
555
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
556
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
557
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
558
|
+
var __spreadValues$c = (a, b) => {
|
|
559
559
|
for (var prop in b || (b = {}))
|
|
560
|
-
if (__hasOwnProp$
|
|
561
|
-
__defNormalProp$
|
|
562
|
-
if (__getOwnPropSymbols$
|
|
563
|
-
for (var prop of __getOwnPropSymbols$
|
|
564
|
-
if (__propIsEnum$
|
|
565
|
-
__defNormalProp$
|
|
560
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
561
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
562
|
+
if (__getOwnPropSymbols$e)
|
|
563
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
564
|
+
if (__propIsEnum$e.call(b, prop))
|
|
565
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
566
566
|
}
|
|
567
567
|
return a;
|
|
568
568
|
};
|
|
@@ -579,26 +579,21 @@ function useColorMode(options = {}) {
|
|
|
579
579
|
emitAuto,
|
|
580
580
|
disableTransition = true
|
|
581
581
|
} = options;
|
|
582
|
-
const modes = __spreadValues$
|
|
582
|
+
const modes = __spreadValues$c({
|
|
583
583
|
auto: "",
|
|
584
584
|
light: "light",
|
|
585
585
|
dark: "dark"
|
|
586
586
|
}, options.modes || {});
|
|
587
587
|
const preferredDark = usePreferredDark({ window });
|
|
588
588
|
const system = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
|
|
589
|
-
const store = storageRef || (storageKey == null ?
|
|
590
|
-
const state = vueDemi.computed(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
},
|
|
594
|
-
set(v) {
|
|
595
|
-
store.value = v;
|
|
596
|
-
}
|
|
597
|
-
});
|
|
589
|
+
const store = storageRef || (storageKey == null ? shared.toRef(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
|
|
590
|
+
const state = vueDemi.computed(
|
|
591
|
+
() => store.value === "auto" ? system.value : store.value
|
|
592
|
+
);
|
|
598
593
|
const updateHTMLAttrs = getSSRHandler(
|
|
599
594
|
"updateHTMLAttrs",
|
|
600
595
|
(selector2, attribute2, value) => {
|
|
601
|
-
const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) :
|
|
596
|
+
const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
|
|
602
597
|
if (!el)
|
|
603
598
|
return;
|
|
604
599
|
let style;
|
|
@@ -626,8 +621,7 @@ function useColorMode(options = {}) {
|
|
|
626
621
|
);
|
|
627
622
|
function defaultOnChanged(mode) {
|
|
628
623
|
var _a;
|
|
629
|
-
|
|
630
|
-
updateHTMLAttrs(selector, attribute, (_a = modes[resolvedMode]) != null ? _a : resolvedMode);
|
|
624
|
+
updateHTMLAttrs(selector, attribute, (_a = modes[mode]) != null ? _a : mode);
|
|
631
625
|
}
|
|
632
626
|
function onChanged(mode) {
|
|
633
627
|
if (options.onChanged)
|
|
@@ -636,13 +630,19 @@ function useColorMode(options = {}) {
|
|
|
636
630
|
defaultOnChanged(mode);
|
|
637
631
|
}
|
|
638
632
|
vueDemi.watch(state, onChanged, { flush: "post", immediate: true });
|
|
639
|
-
if (emitAuto)
|
|
640
|
-
vueDemi.watch(system, () => onChanged(state.value), { flush: "post" });
|
|
641
633
|
shared.tryOnMounted(() => onChanged(state.value));
|
|
634
|
+
const auto = vueDemi.computed({
|
|
635
|
+
get() {
|
|
636
|
+
return emitAuto ? store.value : state.value;
|
|
637
|
+
},
|
|
638
|
+
set(v) {
|
|
639
|
+
store.value = v;
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
642
|
try {
|
|
643
|
-
return Object.assign(
|
|
643
|
+
return Object.assign(auto, { store, system, state });
|
|
644
644
|
} catch (e) {
|
|
645
|
-
return
|
|
645
|
+
return auto;
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
@@ -739,25 +739,25 @@ const UseDocumentVisibility = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComp
|
|
|
739
739
|
}
|
|
740
740
|
});
|
|
741
741
|
|
|
742
|
-
var __defProp$
|
|
743
|
-
var __defProps$
|
|
744
|
-
var __getOwnPropDescs$
|
|
745
|
-
var __getOwnPropSymbols$
|
|
746
|
-
var __hasOwnProp$
|
|
747
|
-
var __propIsEnum$
|
|
748
|
-
var __defNormalProp$
|
|
749
|
-
var __spreadValues$
|
|
742
|
+
var __defProp$b = Object.defineProperty;
|
|
743
|
+
var __defProps$9 = Object.defineProperties;
|
|
744
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
745
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
746
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
747
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
748
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
749
|
+
var __spreadValues$b = (a, b) => {
|
|
750
750
|
for (var prop in b || (b = {}))
|
|
751
|
-
if (__hasOwnProp$
|
|
752
|
-
__defNormalProp$
|
|
753
|
-
if (__getOwnPropSymbols$
|
|
754
|
-
for (var prop of __getOwnPropSymbols$
|
|
755
|
-
if (__propIsEnum$
|
|
756
|
-
__defNormalProp$
|
|
751
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
752
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
753
|
+
if (__getOwnPropSymbols$d)
|
|
754
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
755
|
+
if (__propIsEnum$d.call(b, prop))
|
|
756
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
757
757
|
}
|
|
758
758
|
return a;
|
|
759
759
|
};
|
|
760
|
-
var __spreadProps$
|
|
760
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
761
761
|
const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
762
762
|
name: "UseDraggable",
|
|
763
763
|
props: [
|
|
@@ -790,7 +790,7 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
790
790
|
storageValue.value.x = position.x;
|
|
791
791
|
storageValue.value.y = position.y;
|
|
792
792
|
};
|
|
793
|
-
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$
|
|
793
|
+
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$9(__spreadValues$b({}, props), {
|
|
794
794
|
handle,
|
|
795
795
|
initialValue,
|
|
796
796
|
onEnd
|
|
@@ -863,17 +863,17 @@ const UseElementSize = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
863
863
|
}
|
|
864
864
|
});
|
|
865
865
|
|
|
866
|
-
var __getOwnPropSymbols$
|
|
867
|
-
var __hasOwnProp$
|
|
868
|
-
var __propIsEnum$
|
|
866
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
867
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
868
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
869
869
|
var __objRest$1 = (source, exclude) => {
|
|
870
870
|
var target = {};
|
|
871
871
|
for (var prop in source)
|
|
872
|
-
if (__hasOwnProp$
|
|
872
|
+
if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
873
873
|
target[prop] = source[prop];
|
|
874
|
-
if (source != null && __getOwnPropSymbols$
|
|
875
|
-
for (var prop of __getOwnPropSymbols$
|
|
876
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
874
|
+
if (source != null && __getOwnPropSymbols$c)
|
|
875
|
+
for (var prop of __getOwnPropSymbols$c(source)) {
|
|
876
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
|
|
877
877
|
target[prop] = source[prop];
|
|
878
878
|
}
|
|
879
879
|
return target;
|
|
@@ -1123,6 +1123,25 @@ const UseIdle = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1123
1123
|
}
|
|
1124
1124
|
});
|
|
1125
1125
|
|
|
1126
|
+
var __defProp$a = Object.defineProperty;
|
|
1127
|
+
var __defProps$8 = Object.defineProperties;
|
|
1128
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
1129
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
1130
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
1131
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
1132
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1133
|
+
var __spreadValues$a = (a, b) => {
|
|
1134
|
+
for (var prop in b || (b = {}))
|
|
1135
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
1136
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
1137
|
+
if (__getOwnPropSymbols$b)
|
|
1138
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
1139
|
+
if (__propIsEnum$b.call(b, prop))
|
|
1140
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
1141
|
+
}
|
|
1142
|
+
return a;
|
|
1143
|
+
};
|
|
1144
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
1126
1145
|
function useAsyncState(promise, initialState, options) {
|
|
1127
1146
|
const {
|
|
1128
1147
|
immediate = true,
|
|
@@ -1163,13 +1182,23 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1163
1182
|
}
|
|
1164
1183
|
if (immediate)
|
|
1165
1184
|
execute(delay);
|
|
1166
|
-
|
|
1185
|
+
const shell = {
|
|
1167
1186
|
state,
|
|
1168
1187
|
isReady,
|
|
1169
1188
|
isLoading,
|
|
1170
1189
|
error,
|
|
1171
1190
|
execute
|
|
1172
1191
|
};
|
|
1192
|
+
function waitUntilIsLoaded() {
|
|
1193
|
+
return new Promise((resolve, reject) => {
|
|
1194
|
+
shared.until(isLoading).toBe(false).then(() => resolve(shell)).catch(reject);
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return __spreadProps$8(__spreadValues$a({}, shell), {
|
|
1198
|
+
then(onFulfilled, onRejected) {
|
|
1199
|
+
return waitUntilIsLoaded().then(onFulfilled, onRejected);
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1173
1202
|
}
|
|
1174
1203
|
|
|
1175
1204
|
var __defProp$9 = Object.defineProperty;
|
|
@@ -1191,12 +1220,18 @@ var __spreadValues$9 = (a, b) => {
|
|
|
1191
1220
|
async function loadImage(options) {
|
|
1192
1221
|
return new Promise((resolve, reject) => {
|
|
1193
1222
|
const img = new Image();
|
|
1194
|
-
const { src, srcset, sizes } = options;
|
|
1223
|
+
const { src, srcset, sizes, class: clazz, loading, crossorigin } = options;
|
|
1195
1224
|
img.src = src;
|
|
1196
1225
|
if (srcset)
|
|
1197
1226
|
img.srcset = srcset;
|
|
1198
1227
|
if (sizes)
|
|
1199
1228
|
img.sizes = sizes;
|
|
1229
|
+
if (clazz)
|
|
1230
|
+
img.className = clazz;
|
|
1231
|
+
if (loading)
|
|
1232
|
+
img.loading = loading;
|
|
1233
|
+
if (crossorigin)
|
|
1234
|
+
img.crossOrigin = crossorigin;
|
|
1200
1235
|
img.onload = () => resolve(img);
|
|
1201
1236
|
img.onerror = reject;
|
|
1202
1237
|
});
|
|
@@ -1223,7 +1258,11 @@ const UseImage = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1223
1258
|
"src",
|
|
1224
1259
|
"srcset",
|
|
1225
1260
|
"sizes",
|
|
1226
|
-
"as"
|
|
1261
|
+
"as",
|
|
1262
|
+
"alt",
|
|
1263
|
+
"class",
|
|
1264
|
+
"loading",
|
|
1265
|
+
"crossorigin"
|
|
1227
1266
|
],
|
|
1228
1267
|
setup(props, { slots }) {
|
|
1229
1268
|
const data = vueDemi.reactive(useImage(props));
|
|
@@ -1311,14 +1350,14 @@ function useScroll(element, options = {}) {
|
|
|
1311
1350
|
onStop(e);
|
|
1312
1351
|
};
|
|
1313
1352
|
const onScrollEndDebounced = shared.useDebounceFn(onScrollEnd, throttle + idle);
|
|
1314
|
-
const
|
|
1315
|
-
const
|
|
1316
|
-
const { display, flexDirection } = getComputedStyle(
|
|
1317
|
-
const scrollLeft =
|
|
1353
|
+
const setArrivedState = (target) => {
|
|
1354
|
+
const el = target === document ? target.documentElement : target;
|
|
1355
|
+
const { display, flexDirection } = getComputedStyle(el);
|
|
1356
|
+
const scrollLeft = el.scrollLeft;
|
|
1318
1357
|
directions.left = scrollLeft < internalX.value;
|
|
1319
1358
|
directions.right = scrollLeft > internalX.value;
|
|
1320
1359
|
const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
|
|
1321
|
-
const right = Math.abs(scrollLeft) +
|
|
1360
|
+
const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1322
1361
|
if (display === "flex" && flexDirection === "row-reverse") {
|
|
1323
1362
|
arrivedState.left = right;
|
|
1324
1363
|
arrivedState.right = left;
|
|
@@ -1327,13 +1366,13 @@ function useScroll(element, options = {}) {
|
|
|
1327
1366
|
arrivedState.right = right;
|
|
1328
1367
|
}
|
|
1329
1368
|
internalX.value = scrollLeft;
|
|
1330
|
-
let scrollTop =
|
|
1331
|
-
if (
|
|
1369
|
+
let scrollTop = el.scrollTop;
|
|
1370
|
+
if (target === document && !scrollTop)
|
|
1332
1371
|
scrollTop = document.body.scrollTop;
|
|
1333
1372
|
directions.top = scrollTop < internalY.value;
|
|
1334
1373
|
directions.bottom = scrollTop > internalY.value;
|
|
1335
1374
|
const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
|
|
1336
|
-
const bottom = Math.abs(scrollTop) +
|
|
1375
|
+
const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1337
1376
|
if (display === "flex" && flexDirection === "column-reverse") {
|
|
1338
1377
|
arrivedState.top = bottom;
|
|
1339
1378
|
arrivedState.bottom = top;
|
|
@@ -1342,6 +1381,10 @@ function useScroll(element, options = {}) {
|
|
|
1342
1381
|
arrivedState.bottom = bottom;
|
|
1343
1382
|
}
|
|
1344
1383
|
internalY.value = scrollTop;
|
|
1384
|
+
};
|
|
1385
|
+
const onScrollHandler = (e) => {
|
|
1386
|
+
const eventTarget = e.target === document ? e.target.documentElement : e.target;
|
|
1387
|
+
setArrivedState(eventTarget);
|
|
1345
1388
|
isScrolling.value = true;
|
|
1346
1389
|
onScrollEndDebounced(e);
|
|
1347
1390
|
onScroll(e);
|
|
@@ -1363,7 +1406,12 @@ function useScroll(element, options = {}) {
|
|
|
1363
1406
|
y,
|
|
1364
1407
|
isScrolling,
|
|
1365
1408
|
arrivedState,
|
|
1366
|
-
directions
|
|
1409
|
+
directions,
|
|
1410
|
+
measure() {
|
|
1411
|
+
const _element = shared.toValue(element);
|
|
1412
|
+
if (_element)
|
|
1413
|
+
setArrivedState(_element);
|
|
1414
|
+
}
|
|
1367
1415
|
};
|
|
1368
1416
|
}
|
|
1369
1417
|
|
|
@@ -1403,6 +1451,7 @@ function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
|
1403
1451
|
const promise = vueDemi.ref();
|
|
1404
1452
|
const isLoading = vueDemi.computed(() => !!promise.value);
|
|
1405
1453
|
function checkAndLoad() {
|
|
1454
|
+
state.measure();
|
|
1406
1455
|
const el = shared.toValue(element);
|
|
1407
1456
|
if (!el)
|
|
1408
1457
|
return;
|
package/index.d.ts
CHANGED
|
@@ -164,14 +164,15 @@ interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWind
|
|
|
164
164
|
shallow?: boolean;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
type
|
|
168
|
-
|
|
167
|
+
type BasicColorMode = 'light' | 'dark';
|
|
168
|
+
type BasicColorSchema = BasicColorMode | 'auto';
|
|
169
|
+
interface UseColorModeOptions<T extends string = BasicColorMode> extends UseStorageOptions<T | BasicColorMode> {
|
|
169
170
|
/**
|
|
170
171
|
* CSS Selector for the target element applying to
|
|
171
172
|
*
|
|
172
173
|
* @default 'html'
|
|
173
174
|
*/
|
|
174
|
-
selector?: string |
|
|
175
|
+
selector?: string | MaybeElementRef;
|
|
175
176
|
/**
|
|
176
177
|
* HTML attribute applying the target element
|
|
177
178
|
*
|
|
@@ -183,7 +184,7 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
183
184
|
*
|
|
184
185
|
* @default 'auto'
|
|
185
186
|
*/
|
|
186
|
-
initialValue?: T | BasicColorSchema
|
|
187
|
+
initialValue?: MaybeRefOrGetter<T | BasicColorSchema>;
|
|
187
188
|
/**
|
|
188
189
|
* Prefix when adding value to the attribute
|
|
189
190
|
*/
|
|
@@ -194,7 +195,7 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
194
195
|
*
|
|
195
196
|
* @default undefined
|
|
196
197
|
*/
|
|
197
|
-
onChanged?: (mode: T |
|
|
198
|
+
onChanged?: (mode: T | BasicColorMode, defaultHandler: ((mode: T | BasicColorMode) => void)) => void;
|
|
198
199
|
/**
|
|
199
200
|
* Custom storage ref
|
|
200
201
|
*
|
|
@@ -222,6 +223,8 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
222
223
|
* This is useful when the fact that `auto` mode was selected needs to be known.
|
|
223
224
|
*
|
|
224
225
|
* @default undefined
|
|
226
|
+
* @deprecated use `store.value` when `auto` mode needs to be known
|
|
227
|
+
* @see https://vueuse.org/core/useColorMode/#advanced-usage
|
|
225
228
|
*/
|
|
226
229
|
emitAuto?: boolean;
|
|
227
230
|
/**
|
|
@@ -233,7 +236,7 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
233
236
|
disableTransition?: boolean;
|
|
234
237
|
}
|
|
235
238
|
|
|
236
|
-
declare const UseColorMode: vue_demi.DefineComponent<UseColorModeOptions<
|
|
239
|
+
declare const UseColorMode: vue_demi.DefineComponent<UseColorModeOptions<BasicColorMode>, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseColorModeOptions<BasicColorMode>>, {}>;
|
|
237
240
|
|
|
238
241
|
declare const UseDark: vue_demi.DefineComponent<UseDarkOptions, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseDarkOptions>, {}>;
|
|
239
242
|
|
|
@@ -344,6 +347,14 @@ interface UseImageOptions {
|
|
|
344
347
|
srcset?: string;
|
|
345
348
|
/** Image sizes for different page layouts */
|
|
346
349
|
sizes?: string;
|
|
350
|
+
/** Image alternative information */
|
|
351
|
+
alt?: string;
|
|
352
|
+
/** Image classes */
|
|
353
|
+
class?: string;
|
|
354
|
+
/** Image loading */
|
|
355
|
+
loading?: HTMLImageElement['loading'];
|
|
356
|
+
/** Image CORS settings */
|
|
357
|
+
crossorigin?: string;
|
|
347
358
|
}
|
|
348
359
|
|
|
349
360
|
declare const UseImage: vue_demi.DefineComponent<UseImageOptions & RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseImageOptions & RenderableComponent>, {}>;
|
|
@@ -419,6 +430,7 @@ declare function useScroll(element: MaybeRefOrGetter<HTMLElement | SVGElement |
|
|
|
419
430
|
top: boolean;
|
|
420
431
|
bottom: boolean;
|
|
421
432
|
};
|
|
433
|
+
measure(): void;
|
|
422
434
|
};
|
|
423
435
|
type UseScrollReturn = ReturnType<typeof useScroll>;
|
|
424
436
|
|