ba3291c349821cb739357b653408cb0d3c09d62a15c7375d3b3fb0165800c2363ef510a43aef3704ef5b674c79f0be35ccf3a673ac0a95a22a226fd7acc9ef 3.1 KB

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