UNPKG

hongluan-ui

Version:
59 lines (56 loc) 2.36 kB
import { defineComponent, openBlock, createElementBlock, mergeProps, unref, Fragment, renderSlot, createBlock, createCommentVNode } from 'vue'; import '../../../hooks/index.mjs'; import { HlSpinner } from '../../spinner/index.mjs'; import { useButton } from './use-button.mjs'; import { buttonProps, buttonEmits } from './button.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; const __default__ = defineComponent({ name: "Button" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: buttonProps, emits: buttonEmits, setup(__props, { expose, emit }) { const props = __props; const { namespace } = useNamespace("button"); const { _ref, _props, buttonDisabled, buttonSize, handleClick } = useButton(props, emit); expose({ ref: _ref, size: buttonSize, disabled: buttonDisabled }); return (_ctx, _cache) => { return openBlock(), createElementBlock("button", mergeProps({ ref_key: "_ref", ref: _ref, class: [ unref(namespace), _ctx.type ? _ctx.type : "", unref(buttonSize) ? unref(buttonSize) : "", _ctx.iconPosition ? "icon-" + _ctx.iconPosition : "", _ctx.effect ? _ctx.effect : "", { "is-disabled": unref(buttonDisabled), "is-loading": _ctx.loading, "equal": _ctx.equal, "round": _ctx.round, "block": _ctx.block, "no-fill": _ctx.noFill, "rational": _ctx.rational } ] }, unref(_props), { onClick: unref(handleClick) }), [ _ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [ _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(HlSpinner), { key: 1 })) ], 2112)) : createCommentVNode("v-if", true), _ctx.$slots.icon && !_ctx.loading ? renderSlot(_ctx.$slots, "icon", { key: 1 }) : createCommentVNode("v-if", true), _ctx.$slots.default && (_ctx.loading || _ctx.$slots.icon) ? (openBlock(), createElementBlock("span", { key: 2 }, [ renderSlot(_ctx.$slots, "default") ])) : renderSlot(_ctx.$slots, "default", { key: 3 }) ], 16, ["onClick"]); }; } }); export { _sfc_main as default }; //# sourceMappingURL=button2.mjs.map