UNPKG

maz-ui

Version:

A standalone components library for Vue.Js 3 & Nuxt.Js 3

80 lines (79 loc) 3.69 kB
import { defineComponent, defineAsyncComponent, computed, createBlock, openBlock, resolveDynamicComponent, mergeProps, unref, withCtx, renderSlot, createCommentVNode, createVNode } from "vue"; import { MazArrowTopRightOnSquare } from "@maz-ui/icons"; import { g as getColor } from "../chunks/types.D0Bp_UhS.js"; import { useInstanceUniqId } from "../composables/useInstanceUniqId.js"; import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js"; import '../assets/MazLink.D-fVSh3z.css';const _sfc_main = /* @__PURE__ */ defineComponent({ inheritAttrs: !1, __name: "MazLink", props: { class: {}, style: {}, as: {}, id: {}, title: {}, href: {}, to: {}, color: { default: "primary" }, target: { default: "_self" }, download: {}, rel: {}, ariaLabel: {}, underline: { type: Boolean, default: !1 }, underlineHover: { type: Boolean, default: !0 }, autoExternal: { type: Boolean, default: !0 }, leftIcon: { type: [String, Function, Object] }, rightIcon: { type: [String, Function, Object] }, disabled: { type: Boolean } }, setup(__props) { const MazIcon = defineAsyncComponent(() => import("./MazIcon.js")), instanceId = useInstanceUniqId({ componentName: "MazLink", providedId: __props.id }), component = computed(() => __props.as ? __props.as : __props.to ? "router-link" : __props.href ? "a" : "button"), isButton = computed(() => component.value === "button"); return (_ctx, _cache) => (openBlock(), createBlock(resolveDynamicComponent(component.value), mergeProps({ id: unref(instanceId), class: ["m-link m-reset-css", [ { "--underline": __props.underline, "--underline-hover": !__props.underline && __props.underlineHover }, __props.color !== "inherit" && `--${unref(getColor)(__props.color)}`, __props.class ]], to: __props.to, href: __props.href, title: __props.title, target: !isButton.value && __props.target, rel: !isButton.value && __props.rel, download: !isButton.value && __props.download, "aria-label": !isButton.value && __props.ariaLabel, type: isButton.value && "button", disabled: isButton.value && __props.disabled, style: __props.style }, _ctx.$attrs), { default: withCtx(() => [ renderSlot(_ctx.$slots, "left-icon", {}, () => [ typeof __props.leftIcon == "string" ? (openBlock(), createBlock(unref(MazIcon), { key: 0, name: __props.leftIcon }, null, 8, ["name"])) : __props.leftIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.leftIcon), { key: 1 })) : createCommentVNode("", !0) ], !0), renderSlot(_ctx.$slots, "default", {}, void 0, !0), renderSlot(_ctx.$slots, "right-icon", {}, () => [ typeof __props.rightIcon == "string" ? (openBlock(), createBlock(unref(MazIcon), { key: 0, name: __props.rightIcon }, null, 8, ["name"])) : __props.rightIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.rightIcon), { key: 1 })) : createCommentVNode("", !0) ], !0), __props.autoExternal && __props.target === "_blank" ? renderSlot(_ctx.$slots, "external-icon", { key: 0 }, () => [ createVNode(unref(MazArrowTopRightOnSquare)) ], !0) : createCommentVNode("", !0) ]), _: 3 }, 16, ["id", "class", "to", "href", "title", "target", "rel", "download", "aria-label", "type", "disabled", "style"])); } }), MazLink = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4f0a4e08"]]); export { MazLink as default };