link2.mjs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, createBlock, withCtx, resolveDynamicComponent, createCommentVNode, renderSlot } from 'vue';
  2. import { ElIcon } from '../../icon/index.mjs';
  3. import { linkProps, linkEmits } from './link.mjs';
  4. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  5. import { useDeprecated } from '../../../hooks/use-deprecated/index.mjs';
  6. import { isBoolean } from '../../../utils/types.mjs';
  7. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  8. const __default__ = defineComponent({
  9. name: "ElLink"
  10. });
  11. const _sfc_main = /* @__PURE__ */ defineComponent({
  12. ...__default__,
  13. props: linkProps,
  14. emits: linkEmits,
  15. setup(__props, { emit }) {
  16. const props = __props;
  17. useDeprecated({
  18. scope: "el-link",
  19. from: "The underline option (boolean)",
  20. replacement: "'always' | 'hover' | 'never'",
  21. version: "3.0.0",
  22. ref: "https://element-plus.org/en-US/component/link.html#underline"
  23. }, computed(() => isBoolean(props.underline)));
  24. const ns = useNamespace("link");
  25. const linkKls = computed(() => [
  26. ns.b(),
  27. ns.m(props.type),
  28. ns.is("disabled", props.disabled),
  29. ns.is("underline", underline.value === "always"),
  30. ns.is("hover-underline", underline.value === "hover" && !props.disabled)
  31. ]);
  32. const underline = computed(() => {
  33. if (isBoolean(props.underline)) {
  34. return props.underline ? "hover" : "never";
  35. } else
  36. return props.underline;
  37. });
  38. function handleClick(event) {
  39. if (!props.disabled)
  40. emit("click", event);
  41. }
  42. return (_ctx, _cache) => {
  43. return openBlock(), createElementBlock("a", {
  44. class: normalizeClass(unref(linkKls)),
  45. href: _ctx.disabled || !_ctx.href ? void 0 : _ctx.href,
  46. target: _ctx.disabled || !_ctx.href ? void 0 : _ctx.target,
  47. onClick: handleClick
  48. }, [
  49. _ctx.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 0 }, {
  50. default: withCtx(() => [
  51. (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
  52. ]),
  53. _: 1
  54. })) : createCommentVNode("v-if", true),
  55. _ctx.$slots.default ? (openBlock(), createElementBlock("span", {
  56. key: 1,
  57. class: normalizeClass(unref(ns).e("inner"))
  58. }, [
  59. renderSlot(_ctx.$slots, "default")
  60. ], 2)) : createCommentVNode("v-if", true),
  61. _ctx.$slots.icon ? renderSlot(_ctx.$slots, "icon", { key: 2 }) : createCommentVNode("v-if", true)
  62. ], 10, ["href", "target"]);
  63. };
  64. }
  65. });
  66. var Link = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "link.vue"]]);
  67. export { Link as default };
  68. //# sourceMappingURL=link2.mjs.map