yanzhen-design-vue
Version:
40 lines (39 loc) • 889 B
JavaScript
import { useSlots, ref, computed } from "vue";
import { pick } from "lodash-es";
import { AntButton } from "./button.mjs";
function useButton(props, emit) {
const slots = useSlots();
const _ref = ref();
const _disabled = computed(() => {
return props.disabled;
});
const _text = computed(() => {
return slots.text ?? props.text;
});
const _props = computed(() => {
const _props2 = pick(props, ...Object.keys(AntButton.props));
return {
..._props2,
icon: slots.icon ?? props.icon,
ariaDisabled: _disabled.value || props.loading,
disabled: _disabled.value || props.loading
};
});
const handleClick = (e) => {
emit("click", e);
};
const handleMousedown = (e) => {
emit("mousedown", e);
};
return {
_ref,
_text,
_disabled,
_props,
handleClick,
handleMousedown
};
}
export {
useButton
};