UNPKG

@fifteen/design-system-vue

Version:

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

2 lines (1 loc) 716 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue-router"),r=require("vue");function v(t){const i=o.useRoute(),c=r.computed(()=>!!t.location&&/^(https?:\/\/|mailto:|tel:)/.test(t.location)),l=r.computed(()=>!!t.location&&(c.value||/^#/.test(t.location)));return{isExternal:c,isHref:l,getProps:e=>{const{location:n,replace:s,...a}=t;return n?l.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&&i?.path.startsWith(e)||!1,u=e===i?.path.replace(/\/$/,"");return{[n]:a,[s]:u}}}}exports.useSmartLink=v;