@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
63 lines (62 loc) • 2.15 kB
JavaScript
import { defineComponent as y, ref as k, useAttrs as v, computed as n } from "vue";
import { NeonOutlineStyle as S } from "../../../model/common/accessibility/NeonOutlineStyle.es.js";
import x from "../../presentation/icon/NeonIcon.vue.es.js";
import { useRouter as C, useRoute as N } from "vue-router";
const z = y({
name: "NeonLink",
components: {
NeonIcon: x
},
props: {
/**
* The href of the link, this can be an internal (relative or absolute) or an external link.
*/
href: { type: String, default: null },
/**
* set to true if you would like a completely unstyled link. This is useful for creating a complex component which may use NeonLink.
*/
noStyle: { type: Boolean, default: !1 },
/**
* Style of the outline to use when the link has focus, use this in combination with the <em>no-style</em> flag to
* style the outline of non-text links.
*/
outlineStyle: { type: String, default: S.None },
/**
* Display an external link icon to the right of the link indicating clicking it will take the user to another site.
*/
externalIndicator: { type: Boolean, default: !1 }
},
emits: [
/**
* Emitted when the user triggers the link by clicking on it or hitting Enter or Space when the link has focus.
* @type {void}
*/
"click"
],
setup(e, { emit: u, expose: c }) {
const l = k(null), f = v(), s = C(), i = N(), t = n(() => {
var o;
return ((o = e.href) == null ? void 0 : o.indexOf("/")) === 0 ? e.href : void 0;
}), r = n(() => t.value && i.fullPath.indexOf(t.value) === 0), d = n(() => r.value && e.href === i.fullPath), m = n(() => {
const { onClick: o, ...p } = f;
return p;
}), a = () => {
u("click");
}, h = async () => {
a(), t.value ? await s.push(e.href) : e.href && window.location.replace(e.href);
};
return c({ neonLink: l }), {
neonLink: l,
routerUrl: t,
sanitizedAttributes: m,
activeRoute: r,
exactRoute: d,
onClick: a,
onSpace: h
};
}
});
export {
z as default
};
//# sourceMappingURL=NeonLink.es.js.map