UNPKG

winbox-ui-next

Version:

We Design Vue 2.0: A Vue.js 3 UI Library

77 lines (76 loc) 2.34 kB
"use strict"; var vue = require("vue"); var globalConfig = require("../_utils/global-config.js"); var constant = require("../_utils/constant.js"); var index = require("../icon/icon-link/index.js"); var usePropOrSlot = require("../_utils/use-prop-or-slot.js"); var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper"); const _sfc_main = vue.defineComponent({ name: "Link", components: { IconLink: index }, props: { href: String, type: { type: String, default: "normal", validator: (value) => { return constant.STATUSES.includes(value); } }, hoverable: { type: Boolean, default: false }, icon: Boolean, disabled: Boolean, onClick: { type: [Function, Array] } }, emits: ["click"], setup(props, { slots, emit }) { const prefixCls = globalConfig.getPrefixCls("link"); const showIcon = usePropOrSlot.hasPropOrSlot(props, slots, "icon"); const handleClick = (ev) => { if (!props.disabled) { emit("click", ev); } }; const cls = vue.computed(() => [ prefixCls, `${prefixCls}-status-${props.type}`, { [`${prefixCls}-disabled`]: props.disabled, [`${prefixCls}-hoverless`]: !props.hoverable, [`${prefixCls}-with-icon`]: showIcon.value } ]); return { cls, prefixCls, showIcon, handleClick }; } }); const _hoisted_1 = ["href"]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_icon_link = vue.resolveComponent("icon-link"); return vue.openBlock(), vue.createElementBlock("a", { href: _ctx.disabled ? void 0 : _ctx.href, class: vue.normalizeClass(_ctx.cls), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)) }, [ _ctx.showIcon ? (vue.openBlock(), vue.createElementBlock("span", { key: 0, class: vue.normalizeClass(`${_ctx.prefixCls}-icon`) }, [ vue.renderSlot(_ctx.$slots, "icon", {}, () => [ vue.createVNode(_component_icon_link) ]) ], 2)) : vue.createCommentVNode("v-if", true), vue.renderSlot(_ctx.$slots, "default") ], 10, _hoisted_1); } var _Link = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]); module.exports = _Link;