yanzhen-design-vue
Version:
35 lines (34 loc) • 933 B
JavaScript
import { ref, useAttrs, useModel, computed, mergeProps } from "vue";
import { pick } from "lodash-es";
import { useProxyProps, unref } from "@yanzhen-libs/utils-vue";
import { AntInput } from "./input.mjs";
function useInput(props, emit) {
const _ref = ref(null);
const attrs = useAttrs();
const modelValue = useModel(props, "value");
const config = computed(() => pick(props, ...Object.keys(AntInput.props)));
const proxyProps = useProxyProps(config, AntInput.emits, {
emit,
exclude: ["value"]
// filter: key => {
// switch (key as string) {
// case 'onUpdate:value':
// case 'onUpdate:beginTime':
// case 'onUpdate:endTime':
// return false;
// }
// return true;
// },
});
const propsRef = computed(() => {
return mergeProps(unref(attrs), unref(proxyProps));
});
return {
_ref,
propsRef,
modelValue
};
}
export {
useInput
};