Major overhaul to the theme and now functioning.
This commit is contained in:
+118
@@ -0,0 +1,118 @@
|
||||
import {
|
||||
IN_BROWSER,
|
||||
deepEqual,
|
||||
getCurrentInstance,
|
||||
hasEvent,
|
||||
propsFactory
|
||||
} from "./chunk-LZ5T2ERG.js";
|
||||
import {
|
||||
computed,
|
||||
nextTick,
|
||||
onScopeDispose,
|
||||
reactive,
|
||||
resolveDynamicComponent,
|
||||
toRef
|
||||
} from "./chunk-2MKFL3BX.js";
|
||||
|
||||
// node_modules/vuetify/lib/composables/router.js
|
||||
function useRoute() {
|
||||
const vm = getCurrentInstance("useRoute");
|
||||
return computed(() => vm?.proxy?.$route);
|
||||
}
|
||||
function useRouter() {
|
||||
return getCurrentInstance("useRouter")?.proxy?.$router;
|
||||
}
|
||||
function useLink(props, attrs) {
|
||||
const RouterLink = resolveDynamicComponent("RouterLink");
|
||||
const isLink = toRef(() => !!(props.href || props.to));
|
||||
const isClickable = computed(() => {
|
||||
return isLink?.value || hasEvent(attrs, "click") || hasEvent(props, "click");
|
||||
});
|
||||
if (typeof RouterLink === "string" || !("useLink" in RouterLink)) {
|
||||
const href2 = toRef(() => props.href);
|
||||
return {
|
||||
isLink,
|
||||
isRouterLink: toRef(() => false),
|
||||
isClickable,
|
||||
href: href2,
|
||||
linkProps: reactive({
|
||||
href: href2
|
||||
})
|
||||
};
|
||||
}
|
||||
const routerLink = RouterLink.useLink({
|
||||
to: toRef(() => props.to || ""),
|
||||
replace: toRef(() => props.replace)
|
||||
});
|
||||
const link = computed(() => props.to ? routerLink : void 0);
|
||||
const route = useRoute();
|
||||
const isActive = computed(() => {
|
||||
if (!link.value) return false;
|
||||
if (!props.exact) return link.value.isActive?.value ?? false;
|
||||
if (!route.value) return link.value.isExactActive?.value ?? false;
|
||||
return link.value.isExactActive?.value && deepEqual(link.value.route.value.query, route.value.query);
|
||||
});
|
||||
const href = computed(() => props.to ? link.value?.route.value.href : props.href);
|
||||
const isRouterLink = toRef(() => !!props.to);
|
||||
return {
|
||||
isLink,
|
||||
isRouterLink,
|
||||
isClickable,
|
||||
isActive,
|
||||
route: link.value?.route,
|
||||
navigate: link.value?.navigate,
|
||||
href,
|
||||
linkProps: reactive({
|
||||
href,
|
||||
"aria-current": toRef(() => isActive.value ? "page" : void 0),
|
||||
"aria-disabled": toRef(() => props.disabled && isLink.value ? "true" : void 0),
|
||||
tabindex: toRef(() => props.disabled && isLink.value ? "-1" : void 0)
|
||||
})
|
||||
};
|
||||
}
|
||||
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 && router?.beforeEach) {
|
||||
nextTick(() => {
|
||||
window.addEventListener("popstate", onPopstate);
|
||||
removeBefore = router.beforeEach((to, from, next) => {
|
||||
if (!inTransition) {
|
||||
setTimeout(() => popped ? cb(next) : next());
|
||||
} else {
|
||||
popped ? cb(next) : next();
|
||||
}
|
||||
inTransition = true;
|
||||
});
|
||||
removeAfter = router?.afterEach(() => {
|
||||
inTransition = false;
|
||||
});
|
||||
});
|
||||
onScopeDispose(() => {
|
||||
window.removeEventListener("popstate", onPopstate);
|
||||
removeBefore?.();
|
||||
removeAfter?.();
|
||||
});
|
||||
}
|
||||
function onPopstate(e) {
|
||||
if (e.state?.replaced) return;
|
||||
popped = true;
|
||||
setTimeout(() => popped = false);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
useRouter,
|
||||
useLink,
|
||||
makeRouterProps,
|
||||
useBackButton
|
||||
};
|
||||
//# sourceMappingURL=chunk-573D4TYC.js.map
|
||||
Reference in New Issue
Block a user