UNPKG

@fifteen/design-system-vue

Version:

Vue 3 (Composition API + Typescript) implementation of the Fifteen Design System

37 lines (36 loc) 926 B
import { useRoute as u } from "vue-router"; import { computed as o } from "vue"; function g(t) { const l = u(), c = o( () => !!t.location && /^(https?:\/\/|mailto:|tel:)/.test(t.location) ), i = o( () => !!t.location && (c.value || /^#/.test(t.location)) ); return { isExternal: c, isHref: i, getProps: (e) => { const { location: n, replace: s, ...a } = t; return n ? i.value ? { ...a, hreflang: t.hreflang, href: n, target: t.target ?? (c.value ? "_blank" : null) } : { ...a, hreflang: t.hreflang, href: e } : a; }, getClasses: (e) => { const n = t.activeClass ?? "link--active", s = t.exactActiveClass ?? "link--exactActive", a = e && l?.path.startsWith(e) || !1, r = e === l?.path.replace(/\/$/, ""); return { [n]: a, [s]: r }; } }; } export { g as useSmartLink };