6c286572536e3c01a2d36f9514a404b688cc50c2c26064b6425d01175642ae49b5f68ffbd121c56d366a116234a005949b34bf894bf36097a86e45cfe87129 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { defineComponent, computed, openBlock, createBlock, resolveDynamicComponent, mergeProps, unref, withCtx, createElementBlock, Fragment, renderSlot, normalizeClass, createCommentVNode } from 'vue';
  2. import { ElIcon } from '../../icon/index.mjs';
  3. import { useButton } from './use-button.mjs';
  4. import { buttonProps, buttonEmits } from './button2.mjs';
  5. import { useButtonCustomStyle } from './button-custom.mjs';
  6. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  8. const __default__ = defineComponent({
  9. name: "ElButton"
  10. });
  11. const _sfc_main = /* @__PURE__ */ defineComponent({
  12. ...__default__,
  13. props: buttonProps,
  14. emits: buttonEmits,
  15. setup(__props, { expose, emit }) {
  16. const props = __props;
  17. const buttonStyle = useButtonCustomStyle(props);
  18. const ns = useNamespace("button");
  19. const {
  20. _ref,
  21. _size,
  22. _type,
  23. _disabled,
  24. _props,
  25. _plain,
  26. _round,
  27. _text,
  28. shouldAddSpace,
  29. handleClick
  30. } = useButton(props, emit);
  31. const buttonKls = computed(() => [
  32. ns.b(),
  33. ns.m(_type.value),
  34. ns.m(_size.value),
  35. ns.is("disabled", _disabled.value),
  36. ns.is("loading", props.loading),
  37. ns.is("plain", _plain.value),
  38. ns.is("round", _round.value),
  39. ns.is("circle", props.circle),
  40. ns.is("text", _text.value),
  41. ns.is("link", props.link),
  42. ns.is("has-bg", props.bg)
  43. ]);
  44. expose({
  45. ref: _ref,
  46. size: _size,
  47. type: _type,
  48. disabled: _disabled,
  49. shouldAddSpace
  50. });
  51. return (_ctx, _cache) => {
  52. return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), mergeProps({
  53. ref_key: "_ref",
  54. ref: _ref
  55. }, unref(_props), {
  56. class: unref(buttonKls),
  57. style: unref(buttonStyle),
  58. onClick: unref(handleClick)
  59. }), {
  60. default: withCtx(() => [
  61. _ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
  62. _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
  63. key: 1,
  64. class: normalizeClass(unref(ns).is("loading"))
  65. }, {
  66. default: withCtx(() => [
  67. (openBlock(), createBlock(resolveDynamicComponent(_ctx.loadingIcon)))
  68. ]),
  69. _: 1
  70. }, 8, ["class"]))
  71. ], 64)) : _ctx.icon || _ctx.$slots.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
  72. default: withCtx(() => [
  73. _ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), { key: 0 })) : renderSlot(_ctx.$slots, "icon", { key: 1 })
  74. ]),
  75. _: 3
  76. })) : createCommentVNode("v-if", true),
  77. _ctx.$slots.default ? (openBlock(), createElementBlock("span", {
  78. key: 2,
  79. class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
  80. }, [
  81. renderSlot(_ctx.$slots, "default")
  82. ], 2)) : createCommentVNode("v-if", true)
  83. ]),
  84. _: 3
  85. }, 16, ["class", "style", "onClick"]);
  86. };
  87. }
  88. });
  89. var Button = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "button.vue"]]);
  90. export { Button as default };
  91. //# sourceMappingURL=button.mjs.map