mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-12 11:55:26 +08:00
a2f7d6d062
closes vueComponent/ant-design-vue#5765 Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
51 lines
1.3 KiB
Vue
51 lines
1.3 KiB
Vue
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
|
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
|
|
import Input from '../input';
|
|
import type { ExtractPropTypes } from 'vue';
|
|
import { defineComponent } from 'vue';
|
|
import type { ChangeEvent } from '../_util/EventInterface';
|
|
|
|
export const transferSearchProps = {
|
|
prefixCls: String,
|
|
placeholder: String,
|
|
value: String,
|
|
handleClear: Function,
|
|
disabled: { type: Boolean, default: undefined },
|
|
onChange: Function,
|
|
};
|
|
|
|
export type TransferSearchProps = Partial<ExtractPropTypes<typeof transferSearchProps>>;
|
|
|
|
export default defineComponent({
|
|
compatConfig: { MODE: 3 },
|
|
name: 'Search',
|
|
inheritAttrs: false,
|
|
props: initDefaultProps(transferSearchProps, {
|
|
placeholder: '',
|
|
}),
|
|
emits: ['change'],
|
|
setup(props, { emit }) {
|
|
const handleChange = (e: ChangeEvent) => {
|
|
emit('change', e);
|
|
if (e.target.value === '') {
|
|
props.handleClear?.();
|
|
}
|
|
};
|
|
|
|
return () => {
|
|
const { placeholder, value, prefixCls, disabled } = props;
|
|
return (
|
|
<Input
|
|
placeholder={placeholder}
|
|
class={prefixCls}
|
|
value={value}
|
|
onChange={handleChange}
|
|
disabled={disabled}
|
|
allowClear
|
|
v-slots={{ prefix: () => <SearchOutlined /> }}
|
|
/>
|
|
);
|
|
};
|
|
},
|
|
});
|