mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 21:50:07 +08:00
4ab7a681a7
* fix: update alert code * chore: declare link type * chore: declare auto-complete type * chore: declare Badge type * chore: declare Breadcrumb type * chore: declare Calendar type * chore: declare Card type * chore: declare Checkbox type * chore: declare Descriptions type * chore: declare Dropdown * chore: declare Form type * chore: declare Mentions type * chore: declare Menu type * chore: declare popconfirm type * chore: update Radio typescript * chore: declare Rate type * chore: declare Transfer type * fix: update Transfer type * fix: update type * fix: update type
63 lines
1.6 KiB
Vue
63 lines
1.6 KiB
Vue
import PropTypes from '../_util/vue-types';
|
|
import { getOptionProps } from '../_util/props-util';
|
|
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
|
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
|
|
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
|
|
import Input from '../input';
|
|
import { defineComponent } from 'vue';
|
|
|
|
export const TransferSearchProps = {
|
|
prefixCls: PropTypes.string,
|
|
placeholder: PropTypes.string,
|
|
value: PropTypes.any,
|
|
handleClear: PropTypes.func,
|
|
disabled: PropTypes.looseBool,
|
|
onChange: PropTypes.func,
|
|
};
|
|
|
|
export default defineComponent({
|
|
name: 'Search',
|
|
inheritAttrs: false,
|
|
props: initDefaultProps(TransferSearchProps, {
|
|
placeholder: '',
|
|
}),
|
|
methods: {
|
|
handleChange(e: Event) {
|
|
this.$emit('change', e);
|
|
},
|
|
handleClear2(e: Event) {
|
|
e.preventDefault();
|
|
const { handleClear, disabled } = this.$props;
|
|
if (!disabled && handleClear) {
|
|
handleClear(e);
|
|
}
|
|
},
|
|
},
|
|
render() {
|
|
const { placeholder, value, prefixCls, disabled } = getOptionProps(this);
|
|
const icon =
|
|
value && value.length > 0 ? (
|
|
<a href="#" class={`${prefixCls}-action`} onClick={this.handleClear2}>
|
|
<CloseCircleFilled />
|
|
</a>
|
|
) : (
|
|
<span class={`${prefixCls}-action`}>
|
|
<SearchOutlined />
|
|
</span>
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Input
|
|
placeholder={placeholder}
|
|
class={prefixCls}
|
|
value={value}
|
|
onChange={this.handleChange}
|
|
disabled={disabled}
|
|
/>
|
|
{icon}
|
|
</>
|
|
);
|
|
},
|
|
});
|