vue-admin-core
Version:
A Component Library for Vue 3
71 lines (68 loc) • 1.72 kB
JavaScript
import { useParentForm, h } from '@formily/vue';
import { observer } from '@formily/reactive-vue';
import { defineComponent, toRef } from 'vue';
import { buttonProps, ElButton } from 'element-plus';
import { buildProps } from 'element-plus/es/utils/index';
const resetProps = buildProps({
forceClear: {
type: Boolean,
default: false
},
validate: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
onClick: {
type: Function,
default: () => {
}
},
resetValidateSuccess: {
type: Function,
default: () => {
}
},
resetValidateFailed: {
type: Function,
default: () => {
}
}
});
const Reset = observer(
defineComponent({
name: "FReset",
props: { ...buttonProps, ...resetProps },
setup(props, { slots }) {
const formRef = useParentForm();
const { forceClear, validate, resetValidateFailed, resetValidateSuccess, ...reset } = props;
const loading = toRef(props, "loading");
return () => {
const form = formRef == null ? void 0 : formRef.value;
return h(
ElButton,
{
...reset,
loading: loading.value,
onClick: (e) => {
if (props == null ? void 0 : props.onClick) {
if (props.onClick(e) === false)
return;
}
form == null ? void 0 : form.reset("*", {
forceClear,
validate
}).then(resetValidateSuccess).catch(resetValidateFailed);
}
},
slots
);
};
}
})
);
export { Reset, Reset as default, resetProps };
//# sourceMappingURL=index.mjs.map