104 lines
2.9 KiB
JavaScript
104 lines
2.9 KiB
JavaScript
import {
|
|
IN_BROWSER,
|
|
deepEqual,
|
|
getCurrentInstance,
|
|
hasEvent,
|
|
propsFactory
|
|
} from "./chunk-I4KGD5X4.js";
|
|
import {
|
|
computed,
|
|
nextTick,
|
|
onScopeDispose,
|
|
resolveDynamicComponent,
|
|
toRef
|
|
} from "./chunk-PD2AWGJV.js";
|
|
|
|
// node_modules/vuetify/lib/composables/router.mjs
|
|
function useRoute() {
|
|
const vm = getCurrentInstance("useRoute");
|
|
return computed(() => {
|
|
var _a;
|
|
return (_a = vm == null ? void 0 : vm.proxy) == null ? void 0 : _a.$route;
|
|
});
|
|
}
|
|
function useRouter() {
|
|
var _a, _b;
|
|
return (_b = (_a = getCurrentInstance("useRouter")) == null ? void 0 : _a.proxy) == null ? void 0 : _b.$router;
|
|
}
|
|
function useLink(props, attrs) {
|
|
const RouterLink = resolveDynamicComponent("RouterLink");
|
|
const isLink = computed(() => !!(props.href || props.to));
|
|
const isClickable = computed(() => {
|
|
return (isLink == null ? void 0 : isLink.value) || hasEvent(attrs, "click") || hasEvent(props, "click");
|
|
});
|
|
if (typeof RouterLink === "string") {
|
|
return {
|
|
isLink,
|
|
isClickable,
|
|
href: toRef(props, "href")
|
|
};
|
|
}
|
|
const link = props.to ? RouterLink.useLink(props) : void 0;
|
|
const route = useRoute();
|
|
return {
|
|
isLink,
|
|
isClickable,
|
|
route: link == null ? void 0 : link.route,
|
|
navigate: link == null ? void 0 : link.navigate,
|
|
isActive: link && computed(() => {
|
|
var _a, _b, _c;
|
|
if (!props.exact) return (_a = link.isActive) == null ? void 0 : _a.value;
|
|
if (!route.value) return (_b = link.isExactActive) == null ? void 0 : _b.value;
|
|
return ((_c = link.isExactActive) == null ? void 0 : _c.value) && deepEqual(link.route.value.query, route.value.query);
|
|
}),
|
|
href: computed(() => props.to ? link == null ? void 0 : link.route.value.href : props.href)
|
|
};
|
|
}
|
|
var makeRouterProps = propsFactory({
|
|
href: String,
|
|
replace: Boolean,
|
|
to: [String, Object],
|
|
exact: Boolean
|
|
}, "router");
|
|
var inTransition = false;
|
|
function useBackButton(router, cb) {
|
|
let popped = false;
|
|
let removeBefore;
|
|
let removeAfter;
|
|
if (IN_BROWSER) {
|
|
nextTick(() => {
|
|
window.addEventListener("popstate", onPopstate);
|
|
removeBefore = router == null ? void 0 : router.beforeEach((to, from, next) => {
|
|
if (!inTransition) {
|
|
setTimeout(() => popped ? cb(next) : next());
|
|
} else {
|
|
popped ? cb(next) : next();
|
|
}
|
|
inTransition = true;
|
|
});
|
|
removeAfter = router == null ? void 0 : router.afterEach(() => {
|
|
inTransition = false;
|
|
});
|
|
});
|
|
onScopeDispose(() => {
|
|
window.removeEventListener("popstate", onPopstate);
|
|
removeBefore == null ? void 0 : removeBefore();
|
|
removeAfter == null ? void 0 : removeAfter();
|
|
});
|
|
}
|
|
function onPopstate(e) {
|
|
var _a;
|
|
if ((_a = e.state) == null ? void 0 : _a.replaced) return;
|
|
popped = true;
|
|
setTimeout(() => popped = false);
|
|
}
|
|
}
|
|
|
|
export {
|
|
useRouter,
|
|
useLink,
|
|
makeRouterProps,
|
|
useBackButton
|
|
};
|
|
//# sourceMappingURL=chunk-PCNFKUUR.js.map
|