@vueuse/components 10.0.1 → 10.1.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 +201 -126
- package/index.d.ts +9 -6
- package/index.iife.js +203 -127
- package/index.iife.min.js +1 -1
- package/index.mjs +202 -127
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var vueDemi = require('vue-demi');
|
|
4
4
|
var core = require('@vueuse/core');
|
|
5
5
|
var shared = require('@vueuse/shared');
|
|
6
|
-
var reactivity = require('@vue/reactivity');
|
|
7
6
|
|
|
8
7
|
const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
9
8
|
name: "OnClickOutside",
|
|
@@ -188,19 +187,19 @@ function onKeyStroke(...args) {
|
|
|
188
187
|
return useEventListener(target, eventName, listener, passive);
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
var __defProp$
|
|
192
|
-
var __getOwnPropSymbols$
|
|
193
|
-
var __hasOwnProp$
|
|
194
|
-
var __propIsEnum$
|
|
195
|
-
var __defNormalProp$
|
|
196
|
-
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) => {
|
|
197
196
|
for (var prop in b || (b = {}))
|
|
198
|
-
if (__hasOwnProp$
|
|
199
|
-
__defNormalProp$
|
|
200
|
-
if (__getOwnPropSymbols$
|
|
201
|
-
for (var prop of __getOwnPropSymbols$
|
|
202
|
-
if (__propIsEnum$
|
|
203
|
-
__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]);
|
|
204
203
|
}
|
|
205
204
|
return a;
|
|
206
205
|
};
|
|
@@ -214,7 +213,7 @@ const vOnKeyStroke = {
|
|
|
214
213
|
});
|
|
215
214
|
} else {
|
|
216
215
|
const [handler, options] = binding.value;
|
|
217
|
-
onKeyStroke(keys, handler, __spreadValues$
|
|
216
|
+
onKeyStroke(keys, handler, __spreadValues$e({
|
|
218
217
|
target: el
|
|
219
218
|
}, options));
|
|
220
219
|
}
|
|
@@ -335,19 +334,19 @@ function guessSerializerType(rawInit) {
|
|
|
335
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";
|
|
336
335
|
}
|
|
337
336
|
|
|
338
|
-
var __defProp$
|
|
339
|
-
var __getOwnPropSymbols$
|
|
340
|
-
var __hasOwnProp$
|
|
341
|
-
var __propIsEnum$
|
|
342
|
-
var __defNormalProp$
|
|
343
|
-
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) => {
|
|
344
343
|
for (var prop in b || (b = {}))
|
|
345
|
-
if (__hasOwnProp$
|
|
346
|
-
__defNormalProp$
|
|
347
|
-
if (__getOwnPropSymbols$
|
|
348
|
-
for (var prop of __getOwnPropSymbols$
|
|
349
|
-
if (__propIsEnum$
|
|
350
|
-
__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]);
|
|
351
350
|
}
|
|
352
351
|
return a;
|
|
353
352
|
};
|
|
@@ -464,7 +463,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
464
463
|
if (typeof mergeDefaults === "function")
|
|
465
464
|
return mergeDefaults(value, rawInit);
|
|
466
465
|
else if (type === "object" && !Array.isArray(value))
|
|
467
|
-
return __spreadValues$
|
|
466
|
+
return __spreadValues$d(__spreadValues$d({}, rawInit), value);
|
|
468
467
|
return value;
|
|
469
468
|
} else if (typeof rawValue !== "string") {
|
|
470
469
|
return rawValue;
|
|
@@ -551,19 +550,19 @@ function usePreferredDark(options) {
|
|
|
551
550
|
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
552
551
|
}
|
|
553
552
|
|
|
554
|
-
var __defProp$
|
|
555
|
-
var __getOwnPropSymbols$
|
|
556
|
-
var __hasOwnProp$
|
|
557
|
-
var __propIsEnum$
|
|
558
|
-
var __defNormalProp$
|
|
559
|
-
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) => {
|
|
560
559
|
for (var prop in b || (b = {}))
|
|
561
|
-
if (__hasOwnProp$
|
|
562
|
-
__defNormalProp$
|
|
563
|
-
if (__getOwnPropSymbols$
|
|
564
|
-
for (var prop of __getOwnPropSymbols$
|
|
565
|
-
if (__propIsEnum$
|
|
566
|
-
__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]);
|
|
567
566
|
}
|
|
568
567
|
return a;
|
|
569
568
|
};
|
|
@@ -580,26 +579,21 @@ function useColorMode(options = {}) {
|
|
|
580
579
|
emitAuto,
|
|
581
580
|
disableTransition = true
|
|
582
581
|
} = options;
|
|
583
|
-
const modes = __spreadValues$
|
|
582
|
+
const modes = __spreadValues$c({
|
|
584
583
|
auto: "",
|
|
585
584
|
light: "light",
|
|
586
585
|
dark: "dark"
|
|
587
586
|
}, options.modes || {});
|
|
588
587
|
const preferredDark = usePreferredDark({ window });
|
|
589
588
|
const system = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
|
|
590
|
-
const store = storageRef || (storageKey == null ?
|
|
591
|
-
const state = vueDemi.computed(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
},
|
|
595
|
-
set(v) {
|
|
596
|
-
store.value = v;
|
|
597
|
-
}
|
|
598
|
-
});
|
|
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
|
+
);
|
|
599
593
|
const updateHTMLAttrs = getSSRHandler(
|
|
600
594
|
"updateHTMLAttrs",
|
|
601
595
|
(selector2, attribute2, value) => {
|
|
602
|
-
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);
|
|
603
597
|
if (!el)
|
|
604
598
|
return;
|
|
605
599
|
let style;
|
|
@@ -627,8 +621,7 @@ function useColorMode(options = {}) {
|
|
|
627
621
|
);
|
|
628
622
|
function defaultOnChanged(mode) {
|
|
629
623
|
var _a;
|
|
630
|
-
|
|
631
|
-
updateHTMLAttrs(selector, attribute, (_a = modes[resolvedMode]) != null ? _a : resolvedMode);
|
|
624
|
+
updateHTMLAttrs(selector, attribute, (_a = modes[mode]) != null ? _a : mode);
|
|
632
625
|
}
|
|
633
626
|
function onChanged(mode) {
|
|
634
627
|
if (options.onChanged)
|
|
@@ -637,13 +630,19 @@ function useColorMode(options = {}) {
|
|
|
637
630
|
defaultOnChanged(mode);
|
|
638
631
|
}
|
|
639
632
|
vueDemi.watch(state, onChanged, { flush: "post", immediate: true });
|
|
640
|
-
if (emitAuto)
|
|
641
|
-
vueDemi.watch(system, () => onChanged(state.value), { flush: "post" });
|
|
642
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
|
+
});
|
|
643
642
|
try {
|
|
644
|
-
return Object.assign(
|
|
643
|
+
return Object.assign(auto, { store, system, state });
|
|
645
644
|
} catch (e) {
|
|
646
|
-
return
|
|
645
|
+
return auto;
|
|
647
646
|
}
|
|
648
647
|
}
|
|
649
648
|
|
|
@@ -740,25 +739,25 @@ const UseDocumentVisibility = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComp
|
|
|
740
739
|
}
|
|
741
740
|
});
|
|
742
741
|
|
|
743
|
-
var __defProp$
|
|
744
|
-
var __defProps$
|
|
745
|
-
var __getOwnPropDescs$
|
|
746
|
-
var __getOwnPropSymbols$
|
|
747
|
-
var __hasOwnProp$
|
|
748
|
-
var __propIsEnum$
|
|
749
|
-
var __defNormalProp$
|
|
750
|
-
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) => {
|
|
751
750
|
for (var prop in b || (b = {}))
|
|
752
|
-
if (__hasOwnProp$
|
|
753
|
-
__defNormalProp$
|
|
754
|
-
if (__getOwnPropSymbols$
|
|
755
|
-
for (var prop of __getOwnPropSymbols$
|
|
756
|
-
if (__propIsEnum$
|
|
757
|
-
__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]);
|
|
758
757
|
}
|
|
759
758
|
return a;
|
|
760
759
|
};
|
|
761
|
-
var __spreadProps$
|
|
760
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
762
761
|
const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
763
762
|
name: "UseDraggable",
|
|
764
763
|
props: [
|
|
@@ -791,7 +790,7 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
791
790
|
storageValue.value.x = position.x;
|
|
792
791
|
storageValue.value.y = position.y;
|
|
793
792
|
};
|
|
794
|
-
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$
|
|
793
|
+
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$9(__spreadValues$b({}, props), {
|
|
795
794
|
handle,
|
|
796
795
|
initialValue,
|
|
797
796
|
onEnd
|
|
@@ -864,23 +863,23 @@ const UseElementSize = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
864
863
|
}
|
|
865
864
|
});
|
|
866
865
|
|
|
867
|
-
var __getOwnPropSymbols$
|
|
868
|
-
var __hasOwnProp$
|
|
869
|
-
var __propIsEnum$
|
|
870
|
-
var __objRest = (source, exclude) => {
|
|
866
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
867
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
868
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
869
|
+
var __objRest$1 = (source, exclude) => {
|
|
871
870
|
var target = {};
|
|
872
871
|
for (var prop in source)
|
|
873
|
-
if (__hasOwnProp$
|
|
872
|
+
if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
874
873
|
target[prop] = source[prop];
|
|
875
|
-
if (source != null && __getOwnPropSymbols$
|
|
876
|
-
for (var prop of __getOwnPropSymbols$
|
|
877
|
-
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))
|
|
878
877
|
target[prop] = source[prop];
|
|
879
878
|
}
|
|
880
879
|
return target;
|
|
881
880
|
};
|
|
882
881
|
function useResizeObserver(target, callback, options = {}) {
|
|
883
|
-
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest(_a, ["window"]);
|
|
882
|
+
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$1(_a, ["window"]);
|
|
884
883
|
let observer;
|
|
885
884
|
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
886
885
|
const cleanup = () => {
|
|
@@ -994,7 +993,7 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
994
993
|
immediate = true
|
|
995
994
|
} = options;
|
|
996
995
|
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
997
|
-
const targets =
|
|
996
|
+
const targets = vueDemi.computed(() => {
|
|
998
997
|
const _target = shared.toValue(target);
|
|
999
998
|
return (Array.isArray(_target) ? _target : [_target]).map(unrefElement).filter(shared.notNullish);
|
|
1000
999
|
});
|
|
@@ -1124,6 +1123,25 @@ const UseIdle = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1124
1123
|
}
|
|
1125
1124
|
});
|
|
1126
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));
|
|
1127
1145
|
function useAsyncState(promise, initialState, options) {
|
|
1128
1146
|
const {
|
|
1129
1147
|
immediate = true,
|
|
@@ -1164,27 +1182,37 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1164
1182
|
}
|
|
1165
1183
|
if (immediate)
|
|
1166
1184
|
execute(delay);
|
|
1167
|
-
|
|
1185
|
+
const shell = {
|
|
1168
1186
|
state,
|
|
1169
1187
|
isReady,
|
|
1170
1188
|
isLoading,
|
|
1171
1189
|
error,
|
|
1172
1190
|
execute
|
|
1173
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
|
+
});
|
|
1174
1202
|
}
|
|
1175
1203
|
|
|
1176
1204
|
var __defProp$9 = Object.defineProperty;
|
|
1177
|
-
var __getOwnPropSymbols$
|
|
1178
|
-
var __hasOwnProp$
|
|
1179
|
-
var __propIsEnum$
|
|
1205
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
1206
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
1207
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
1180
1208
|
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1181
1209
|
var __spreadValues$9 = (a, b) => {
|
|
1182
1210
|
for (var prop in b || (b = {}))
|
|
1183
|
-
if (__hasOwnProp$
|
|
1211
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
1184
1212
|
__defNormalProp$9(a, prop, b[prop]);
|
|
1185
|
-
if (__getOwnPropSymbols$
|
|
1186
|
-
for (var prop of __getOwnPropSymbols$
|
|
1187
|
-
if (__propIsEnum$
|
|
1213
|
+
if (__getOwnPropSymbols$a)
|
|
1214
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
1215
|
+
if (__propIsEnum$a.call(b, prop))
|
|
1188
1216
|
__defNormalProp$9(a, prop, b[prop]);
|
|
1189
1217
|
}
|
|
1190
1218
|
return a;
|
|
@@ -1371,17 +1399,17 @@ function useScroll(element, options = {}) {
|
|
|
1371
1399
|
var __defProp$8 = Object.defineProperty;
|
|
1372
1400
|
var __defProps$7 = Object.defineProperties;
|
|
1373
1401
|
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
1374
|
-
var __getOwnPropSymbols$
|
|
1375
|
-
var __hasOwnProp$
|
|
1376
|
-
var __propIsEnum$
|
|
1402
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
1403
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
1404
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
1377
1405
|
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1378
1406
|
var __spreadValues$8 = (a, b) => {
|
|
1379
1407
|
for (var prop in b || (b = {}))
|
|
1380
|
-
if (__hasOwnProp$
|
|
1408
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
1381
1409
|
__defNormalProp$8(a, prop, b[prop]);
|
|
1382
|
-
if (__getOwnPropSymbols$
|
|
1383
|
-
for (var prop of __getOwnPropSymbols$
|
|
1384
|
-
if (__propIsEnum$
|
|
1410
|
+
if (__getOwnPropSymbols$9)
|
|
1411
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
1412
|
+
if (__propIsEnum$9.call(b, prop))
|
|
1385
1413
|
__defNormalProp$8(a, prop, b[prop]);
|
|
1386
1414
|
}
|
|
1387
1415
|
return a;
|
|
@@ -1476,17 +1504,17 @@ const UseMouseInElement = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponen
|
|
|
1476
1504
|
var __defProp$7 = Object.defineProperty;
|
|
1477
1505
|
var __defProps$6 = Object.defineProperties;
|
|
1478
1506
|
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
1479
|
-
var __getOwnPropSymbols$
|
|
1480
|
-
var __hasOwnProp$
|
|
1481
|
-
var __propIsEnum$
|
|
1507
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
1508
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
1509
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
1482
1510
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1483
1511
|
var __spreadValues$7 = (a, b) => {
|
|
1484
1512
|
for (var prop in b || (b = {}))
|
|
1485
|
-
if (__hasOwnProp$
|
|
1513
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
1486
1514
|
__defNormalProp$7(a, prop, b[prop]);
|
|
1487
|
-
if (__getOwnPropSymbols$
|
|
1488
|
-
for (var prop of __getOwnPropSymbols$
|
|
1489
|
-
if (__propIsEnum$
|
|
1515
|
+
if (__getOwnPropSymbols$8)
|
|
1516
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
1517
|
+
if (__propIsEnum$8.call(b, prop))
|
|
1490
1518
|
__defNormalProp$7(a, prop, b[prop]);
|
|
1491
1519
|
}
|
|
1492
1520
|
return a;
|
|
@@ -1519,17 +1547,17 @@ const UseNetwork = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1519
1547
|
var __defProp$6 = Object.defineProperty;
|
|
1520
1548
|
var __defProps$5 = Object.defineProperties;
|
|
1521
1549
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
1522
|
-
var __getOwnPropSymbols$
|
|
1523
|
-
var __hasOwnProp$
|
|
1524
|
-
var __propIsEnum$
|
|
1550
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
1551
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
1552
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
1525
1553
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1526
1554
|
var __spreadValues$6 = (a, b) => {
|
|
1527
1555
|
for (var prop in b || (b = {}))
|
|
1528
|
-
if (__hasOwnProp$
|
|
1556
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
1529
1557
|
__defNormalProp$6(a, prop, b[prop]);
|
|
1530
|
-
if (__getOwnPropSymbols$
|
|
1531
|
-
for (var prop of __getOwnPropSymbols$
|
|
1532
|
-
if (__propIsEnum$
|
|
1558
|
+
if (__getOwnPropSymbols$7)
|
|
1559
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
1560
|
+
if (__propIsEnum$7.call(b, prop))
|
|
1533
1561
|
__defNormalProp$6(a, prop, b[prop]);
|
|
1534
1562
|
}
|
|
1535
1563
|
return a;
|
|
@@ -1565,17 +1593,17 @@ const UseObjectUrl = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1565
1593
|
var __defProp$5 = Object.defineProperty;
|
|
1566
1594
|
var __defProps$4 = Object.defineProperties;
|
|
1567
1595
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1568
|
-
var __getOwnPropSymbols$
|
|
1569
|
-
var __hasOwnProp$
|
|
1570
|
-
var __propIsEnum$
|
|
1596
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1597
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1598
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1571
1599
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1572
1600
|
var __spreadValues$5 = (a, b) => {
|
|
1573
1601
|
for (var prop in b || (b = {}))
|
|
1574
|
-
if (__hasOwnProp$
|
|
1602
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1575
1603
|
__defNormalProp$5(a, prop, b[prop]);
|
|
1576
|
-
if (__getOwnPropSymbols$
|
|
1577
|
-
for (var prop of __getOwnPropSymbols$
|
|
1578
|
-
if (__propIsEnum$
|
|
1604
|
+
if (__getOwnPropSymbols$6)
|
|
1605
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1606
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1579
1607
|
__defNormalProp$5(a, prop, b[prop]);
|
|
1580
1608
|
}
|
|
1581
1609
|
return a;
|
|
@@ -1650,17 +1678,17 @@ const UsePageLeave = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1650
1678
|
var __defProp$4 = Object.defineProperty;
|
|
1651
1679
|
var __defProps$3 = Object.defineProperties;
|
|
1652
1680
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1653
|
-
var __getOwnPropSymbols$
|
|
1654
|
-
var __hasOwnProp$
|
|
1655
|
-
var __propIsEnum$
|
|
1681
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1682
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1683
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1656
1684
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1657
1685
|
var __spreadValues$4 = (a, b) => {
|
|
1658
1686
|
for (var prop in b || (b = {}))
|
|
1659
|
-
if (__hasOwnProp$
|
|
1687
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1660
1688
|
__defNormalProp$4(a, prop, b[prop]);
|
|
1661
|
-
if (__getOwnPropSymbols$
|
|
1662
|
-
for (var prop of __getOwnPropSymbols$
|
|
1663
|
-
if (__propIsEnum$
|
|
1689
|
+
if (__getOwnPropSymbols$5)
|
|
1690
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1691
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1664
1692
|
__defNormalProp$4(a, prop, b[prop]);
|
|
1665
1693
|
}
|
|
1666
1694
|
return a;
|
|
@@ -1763,6 +1791,53 @@ const UsePreferredReducedMotion = /* @__PURE__ */ /* #__PURE__ */ vueDemi.define
|
|
|
1763
1791
|
}
|
|
1764
1792
|
});
|
|
1765
1793
|
|
|
1794
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1795
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1796
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1797
|
+
var __objRest = (source, exclude) => {
|
|
1798
|
+
var target = {};
|
|
1799
|
+
for (var prop in source)
|
|
1800
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1801
|
+
target[prop] = source[prop];
|
|
1802
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
1803
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
1804
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
1805
|
+
target[prop] = source[prop];
|
|
1806
|
+
}
|
|
1807
|
+
return target;
|
|
1808
|
+
};
|
|
1809
|
+
function useMutationObserver(target, callback, options = {}) {
|
|
1810
|
+
const _a = options, { window = defaultWindow } = _a, mutationOptions = __objRest(_a, ["window"]);
|
|
1811
|
+
let observer;
|
|
1812
|
+
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
1813
|
+
const cleanup = () => {
|
|
1814
|
+
if (observer) {
|
|
1815
|
+
observer.disconnect();
|
|
1816
|
+
observer = void 0;
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
const stopWatch = vueDemi.watch(
|
|
1820
|
+
() => unrefElement(target),
|
|
1821
|
+
(el) => {
|
|
1822
|
+
cleanup();
|
|
1823
|
+
if (isSupported.value && window && el) {
|
|
1824
|
+
observer = new MutationObserver(callback);
|
|
1825
|
+
observer.observe(el, mutationOptions);
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
{ immediate: true }
|
|
1829
|
+
);
|
|
1830
|
+
const stop = () => {
|
|
1831
|
+
cleanup();
|
|
1832
|
+
stopWatch();
|
|
1833
|
+
};
|
|
1834
|
+
shared.tryOnScopeDispose(stop);
|
|
1835
|
+
return {
|
|
1836
|
+
isSupported,
|
|
1837
|
+
stop
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1766
1841
|
function useCssVar(prop, target, options = {}) {
|
|
1767
1842
|
const { window = defaultWindow, initialValue = "", observe = false } = options;
|
|
1768
1843
|
const variable = vueDemi.ref(initialValue);
|
|
@@ -1780,7 +1855,7 @@ function useCssVar(prop, target, options = {}) {
|
|
|
1780
1855
|
}
|
|
1781
1856
|
}
|
|
1782
1857
|
if (observe) {
|
|
1783
|
-
|
|
1858
|
+
useMutationObserver(elRef, updateCssVar, {
|
|
1784
1859
|
attributes: true,
|
|
1785
1860
|
window
|
|
1786
1861
|
});
|
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
|
|