113 lines
3.7 KiB
JavaScript
113 lines
3.7 KiB
JavaScript
import { buttonEmits, buttonProps } from './button.mjs';
|
|
import { defineComponent, computed, createBlock, openBlock, resolveDynamicComponent, mergeProps, unref, withCtx, createElementBlock, createCommentVNode, Fragment, renderSlot, normalizeClass } from 'vue';
|
|
import { ElIcon } from '../../icon/index.mjs';
|
|
import { useButton } from './use-button.mjs';
|
|
import { useButtonCustomStyle } from './button-custom.mjs';
|
|
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
|
|
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
...{
|
|
name: "ElButton"
|
|
},
|
|
__name: "button",
|
|
props: buttonProps,
|
|
emits: buttonEmits,
|
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
const props = __props;
|
|
const emit = __emit;
|
|
const buttonStyle = useButtonCustomStyle(props);
|
|
const ns = useNamespace("button");
|
|
const {
|
|
_ref,
|
|
_size,
|
|
_type,
|
|
_disabled,
|
|
_props,
|
|
_plain,
|
|
_round,
|
|
_text,
|
|
shouldAddSpace,
|
|
handleClick
|
|
} = useButton(props, emit);
|
|
const buttonKls = computed(() => [
|
|
ns.b(),
|
|
ns.m(_type.value),
|
|
ns.m(_size.value),
|
|
ns.is("disabled", _disabled.value),
|
|
ns.is("loading", props.loading),
|
|
ns.is("plain", _plain.value),
|
|
ns.is("round", _round.value),
|
|
ns.is("circle", props.circle),
|
|
ns.is("text", _text.value),
|
|
ns.is("link", props.link),
|
|
ns.is("has-bg", props.bg)
|
|
]);
|
|
__expose({
|
|
/** @description button html element */
|
|
ref: _ref,
|
|
/** @description button size */
|
|
size: _size,
|
|
/** @description button type */
|
|
type: _type,
|
|
/** @description button disabled */
|
|
disabled: _disabled,
|
|
/** @description whether adding space */
|
|
shouldAddSpace
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), mergeProps({
|
|
ref_key: "_ref",
|
|
ref: _ref
|
|
}, unref(_props), {
|
|
class: buttonKls.value,
|
|
style: unref(buttonStyle),
|
|
onClick: unref(handleClick)
|
|
}), {
|
|
default: withCtx(() => [
|
|
__props.loading ? (openBlock(), createElementBlock(
|
|
Fragment,
|
|
{ key: 0 },
|
|
[
|
|
_ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
|
|
key: 1,
|
|
class: normalizeClass(unref(ns).is("loading"))
|
|
}, {
|
|
default: withCtx(() => [
|
|
(openBlock(), createBlock(resolveDynamicComponent(__props.loadingIcon)))
|
|
]),
|
|
_: 1
|
|
/* STABLE */
|
|
}, 8, ["class"]))
|
|
],
|
|
64
|
|
/* STABLE_FRAGMENT */
|
|
)) : __props.icon || _ctx.$slots.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
|
|
default: withCtx(() => [
|
|
__props.icon ? (openBlock(), createBlock(resolveDynamicComponent(__props.icon), { key: 0 })) : renderSlot(_ctx.$slots, "icon", { key: 1 })
|
|
]),
|
|
_: 3
|
|
/* FORWARDED */
|
|
})) : createCommentVNode("v-if", true),
|
|
_ctx.$slots.default ? (openBlock(), createElementBlock(
|
|
"span",
|
|
{
|
|
key: 2,
|
|
class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
|
|
},
|
|
[
|
|
renderSlot(_ctx.$slots, "default")
|
|
],
|
|
2
|
|
/* CLASS */
|
|
)) : createCommentVNode("v-if", true)
|
|
]),
|
|
_: 3
|
|
/* FORWARDED */
|
|
}, 16, ["class", "style", "onClick"]);
|
|
};
|
|
}
|
|
});
|
|
|
|
export { _sfc_main as default };
|
|
//# sourceMappingURL=button.vue2.mjs.map
|