perf: add event props
parent
36ee580f72
commit
532f51fc90
|
@ -1 +1 @@
|
||||||
Subproject commit 60cb5c8b276b8d5a8c7fc9f8cb39053a14e242ee
|
Subproject commit 3978ece8febab44f9007ea66df2adc20d65982c4
|
|
@ -16,6 +16,7 @@ export default {
|
||||||
checked: PropTypes.bool,
|
checked: PropTypes.bool,
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
onClick: PropTypes.func,
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { renderedText, renderedEl, item, lazy, checked, disabled, prefixCls } = this.$props;
|
const { renderedText, renderedEl, item, lazy, checked, disabled, prefixCls } = this.$props;
|
||||||
|
|
|
@ -3,22 +3,26 @@
|
||||||
exports[`Transfer should render correctly 1`] = `
|
exports[`Transfer should render correctly 1`] = `
|
||||||
<div class="ant-transfer">
|
<div class="ant-transfer">
|
||||||
<div class="ant-transfer-list">
|
<div class="ant-transfer-list">
|
||||||
<div class="ant-transfer-list-header"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-checked"><span class="ant-checkbox ant-checkbox-checked"><input type="checkbox" checked="checked" class="ant-checkbox-input"><span class="ant-checkbox-inner"></span></span></label><span class="ant-transfer-list-header-selected"><span>1/2 items</span><span class="ant-transfer-list-header-title"></span></span></div>
|
<div class="ant-transfer-list-header"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-checked"><span class="ant-checkbox ant-checkbox-checked"><input type="checkbox" class="ant-checkbox-input" value=""><span class="ant-checkbox-inner"></span></span><span></span></label><span class="ant-transfer-list-header-selected"><span>1/2 items</span><span class="ant-transfer-list-header-title"></span></span></div>
|
||||||
<div class="ant-transfer-list-body">
|
<div class="ant-transfer-list-body">
|
||||||
|
<!---->
|
||||||
<ul class="ant-transfer-list-content">
|
<ul class="ant-transfer-list-content">
|
||||||
<li class="ant-transfer-list-content-item"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-checked"><span class="ant-checkbox ant-checkbox-checked"><input type="checkbox" checked="checked" class="ant-checkbox-input"><span class="ant-checkbox-inner"></span></span></label><span class="ant-transfer-list-content-item-text"></span></li>
|
<li class="ant-transfer-list-content-item"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-checked"><span class="ant-checkbox ant-checkbox-checked"><input type="checkbox" class="ant-checkbox-input" value=""><span class="ant-checkbox-inner"></span></span><span></span></label><span class="ant-transfer-list-content-item-text"><!----></span></li>
|
||||||
<li class="ant-transfer-list-content-item ant-transfer-list-content-item-disabled"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-disabled"><span class="ant-checkbox ant-checkbox-disabled"><input type="checkbox" disabled="disabled" class="ant-checkbox-input"><span class="ant-checkbox-inner"></span></span></label><span class="ant-transfer-list-content-item-text"></span></li>
|
<li class="ant-transfer-list-content-item ant-transfer-list-content-item-disabled"><label class="ant-checkbox-wrapper ant-checkbox-wrapper-disabled"><span class="ant-checkbox ant-checkbox-disabled"><input type="checkbox" disabled="" class="ant-checkbox-input" value=""><span class="ant-checkbox-inner"></span></span><span></span></label><span class="ant-transfer-list-content-item-text"><!----></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
<div class="ant-transfer-operation"><button type="button" class="ant-btn ant-btn-primary ant-btn-sm ant-btn-icon-only"><span role="img" aria-label="right" class="anticon anticon-right"><svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></button><button disabled="disabled" type="button" class="ant-btn ant-btn-primary ant-btn-sm ant-btn-icon-only"><span role="img" aria-label="left" class="anticon anticon-left"><svg viewBox="64 64 896 896" focusable="false" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg></span></button></div>
|
<div class="ant-transfer-operation"><button class="ant-btn ant-btn-primary ant-btn-sm ant-btn-icon-only" type="button"><span role="img" aria-label="right" class="anticon anticon-right"><svg class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></button><button disabled="" class="ant-btn ant-btn-primary ant-btn-sm ant-btn-icon-only" type="button"><span role="img" aria-label="left" class="anticon anticon-left"><svg class="" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg></span></button></div>
|
||||||
<div class="ant-transfer-list">
|
<div class="ant-transfer-list">
|
||||||
<div class="ant-transfer-list-header"><label class="ant-checkbox-wrapper"><span class="ant-checkbox"><input type="checkbox" class="ant-checkbox-input"><span class="ant-checkbox-inner"></span></span></label><span class="ant-transfer-list-header-selected"><span>1 item</span><span class="ant-transfer-list-header-title"></span></span></div>
|
<div class="ant-transfer-list-header"><label class="ant-checkbox-wrapper"><span class="ant-checkbox"><input type="checkbox" class="ant-checkbox-input" value=""><span class="ant-checkbox-inner"></span></span><span></span></label><span class="ant-transfer-list-header-selected"><span>1 item</span><span class="ant-transfer-list-header-title"></span></span></div>
|
||||||
<div class="ant-transfer-list-body">
|
<div class="ant-transfer-list-body">
|
||||||
|
<!---->
|
||||||
<ul class="ant-transfer-list-content">
|
<ul class="ant-transfer-list-content">
|
||||||
<li class="ant-transfer-list-content-item"><label class="ant-checkbox-wrapper"><span class="ant-checkbox"><input type="checkbox" class="ant-checkbox-input"><span class="ant-checkbox-inner"></span></span></label><span class="ant-transfer-list-content-item-text"></span></li>
|
<li class="ant-transfer-list-content-item"><label class="ant-checkbox-wrapper"><span class="ant-checkbox"><input type="checkbox" class="ant-checkbox-input" value=""><span class="ant-checkbox-inner"></span></span><span></span></label><span class="ant-transfer-list-content-item-text"><!----></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { renderToString } from '@vue/server-test-utils';
|
|
||||||
import Transfer from '..';
|
import Transfer from '..';
|
||||||
import * as Vue from 'vue';
|
import * as Vue from 'vue';
|
||||||
|
import { sleep } from '../../../tests/utils';
|
||||||
import { asyncExpect } from '@/tests/utils';
|
import { asyncExpect } from '@/tests/utils';
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
import mountTest from '../../../tests/shared/mountTest';
|
||||||
|
|
||||||
|
@ -93,24 +93,18 @@ describe('Transfer', () => {
|
||||||
const props = {
|
const props = {
|
||||||
props: listCommonProps,
|
props: listCommonProps,
|
||||||
};
|
};
|
||||||
const wrapper = renderToString(Transfer, props);
|
const wrapper = mount(Transfer, props);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should move selected keys to corresponding list', done => {
|
it('should move selected keys to corresponding list', done => {
|
||||||
const handleChange = jest.fn();
|
const handleChange = jest.fn();
|
||||||
const wrapper = mount(Transfer, {
|
const wrapper = mount(Transfer, {
|
||||||
props: listCommonProps,
|
props: { ...listCommonProps, onChange: handleChange },
|
||||||
listeners: {
|
|
||||||
change: handleChange,
|
|
||||||
},
|
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper.findAll('.ant-btn')[0].trigger('click'); // move selected keys to right list
|
||||||
.findAll('.ant-btn')
|
|
||||||
.at(0)
|
|
||||||
.trigger('click'); // move selected keys to right list
|
|
||||||
expect(handleChange).toHaveBeenCalledWith(['a', 'b'], 'right', ['a']);
|
expect(handleChange).toHaveBeenCalledWith(['a', 'b'], 'right', ['a']);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -118,83 +112,48 @@ describe('Transfer', () => {
|
||||||
it('should move selected keys expect disabled to corresponding list', done => {
|
it('should move selected keys expect disabled to corresponding list', done => {
|
||||||
const handleChange = jest.fn();
|
const handleChange = jest.fn();
|
||||||
const wrapper = mount(Transfer, {
|
const wrapper = mount(Transfer, {
|
||||||
props: listDisabledProps,
|
props: { ...listDisabledProps, onChange: handleChange },
|
||||||
listeners: {
|
|
||||||
change: handleChange,
|
|
||||||
},
|
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper.findAll('.ant-btn')[0].trigger('click');
|
||||||
.findAll('.ant-btn')
|
|
||||||
.at(0)
|
|
||||||
.trigger('click');
|
|
||||||
expect(handleChange).toHaveBeenCalledWith(['b'], 'right', ['b']);
|
expect(handleChange).toHaveBeenCalledWith(['b'], 'right', ['b']);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should uncheck checkbox when click on checked item', done => {
|
it('should uncheck checkbox when click on checked item', async () => {
|
||||||
const handleSelectChange = jest.fn();
|
const handleSelectChange = jest.fn();
|
||||||
const wrapper = mount(Transfer, {
|
const wrapper = mount(Transfer, {
|
||||||
props: listCommonProps,
|
props: { ...listCommonProps, onSelectChange: handleSelectChange },
|
||||||
listeners: {
|
|
||||||
selectChange: handleSelectChange,
|
|
||||||
},
|
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
await sleep();
|
||||||
wrapper
|
wrapper.findAll('.ant-transfer-list-content-item')[0].trigger('click');
|
||||||
.findAll('.ant-transfer-list-content-item')
|
expect(handleSelectChange).toHaveBeenLastCalledWith([], []);
|
||||||
.filter(n => {
|
|
||||||
return n.vnode.data.key === 'a';
|
|
||||||
})
|
|
||||||
.trigger('click');
|
|
||||||
expect(handleSelectChange).toHaveBeenLastCalledWith([], []);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check checkbox when click on unchecked item', done => {
|
fit('should check checkbox when click on unchecked item', async () => {
|
||||||
const handleSelectChange = jest.fn();
|
const handleSelectChange = jest.fn();
|
||||||
const wrapper = mount(Transfer, {
|
const wrapper = mount(Transfer, {
|
||||||
props: listCommonProps,
|
props: { ...listCommonProps, onSelectChange: handleSelectChange },
|
||||||
listeners: {
|
|
||||||
selectChange: handleSelectChange,
|
|
||||||
},
|
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
await sleep();
|
||||||
wrapper
|
wrapper.findAll('.ant-transfer-list-content-item')[2].trigger('click');
|
||||||
.findAll('.ant-transfer-list-content-item')
|
await sleep();
|
||||||
.filter(n => {
|
expect(handleSelectChange).toHaveBeenLastCalledWith(['a'], ['b']);
|
||||||
return n.vnode.data.key === 'b';
|
|
||||||
})
|
|
||||||
.trigger('click');
|
|
||||||
expect(handleSelectChange).toHaveBeenLastCalledWith(['a'], ['b']);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not check checkbox when click on disabled item', done => {
|
it('should not check checkbox when click on disabled item', async () => {
|
||||||
const handleSelectChange = jest.fn();
|
const handleSelectChange = jest.fn();
|
||||||
const wrapper = mount(Transfer, {
|
const wrapper = mount(Transfer, {
|
||||||
props: listCommonProps,
|
props: { ...listCommonProps, onSelectChange: handleSelectChange },
|
||||||
listeners: {
|
|
||||||
selectChange: handleSelectChange,
|
|
||||||
},
|
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
await sleep();
|
||||||
wrapper
|
wrapper.findAll('.ant-transfer-list-content-item')[1].trigger('click');
|
||||||
.findAll('.ant-transfer-list-content-item')
|
expect(handleSelectChange).not.toHaveBeenCalled();
|
||||||
.filter(n => {
|
|
||||||
return n.vnode.data.key === 'c';
|
|
||||||
})
|
|
||||||
.trigger('click');
|
|
||||||
expect(handleSelectChange).not.toHaveBeenCalled();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check all item when click on check all', done => {
|
it('should check all item when click on check all', done => {
|
||||||
|
@ -250,14 +209,13 @@ describe('Transfer', () => {
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input').at(0);
|
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input')[0];
|
||||||
input.element.value = 'a';
|
input.element.value = 'a';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list-content')
|
.findAll('.ant-transfer-list-content')[0]
|
||||||
.at(0)
|
|
||||||
.find('.ant-transfer-list-content-item')
|
.find('.ant-transfer-list-content-item')
|
||||||
.findAll('input[type="checkbox"]'),
|
.findAll('input[type="checkbox"]'),
|
||||||
).toHaveLength(1);
|
).toHaveLength(1);
|
||||||
|
@ -279,16 +237,14 @@ describe('Transfer', () => {
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input').at(0);
|
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input')[0];
|
||||||
input.element.value = 'content2';
|
input.element.value = 'content2';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list')
|
.findAll('.ant-transfer-list')[0]
|
||||||
.at(0)
|
.findAll('.ant-transfer-list-header-selected > span')[0]
|
||||||
.findAll('.ant-transfer-list-header-selected > span')
|
|
||||||
.at(0)
|
|
||||||
.text()
|
.text()
|
||||||
.trim(),
|
.trim(),
|
||||||
).toEqual('1 items');
|
).toEqual('1 items');
|
||||||
|
@ -314,13 +270,12 @@ describe('Transfer', () => {
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input').at(0);
|
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input')[0];
|
||||||
input.element.value = 'content2';
|
input.element.value = 'content2';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list')
|
.findAll('.ant-transfer-list')[0]
|
||||||
.at(0)
|
|
||||||
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
||||||
.filter(n => {
|
.filter(n => {
|
||||||
return !n.vnode.data.domProps.checked;
|
return !n.vnode.data.domProps.checked;
|
||||||
|
@ -355,23 +310,19 @@ describe('Transfer', () => {
|
||||||
sync: false,
|
sync: false,
|
||||||
});
|
});
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input').at(0);
|
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input')[0];
|
||||||
input.element.value = 'content2';
|
input.element.value = 'content2';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list')
|
.findAll('.ant-transfer-list')[0]
|
||||||
.at(0)
|
|
||||||
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
||||||
.filter(n => {
|
.filter(n => {
|
||||||
return !n.vnode.data.domProps.checked;
|
return !n.vnode.data.domProps.checked;
|
||||||
})
|
})
|
||||||
.trigger('change');
|
.trigger('change');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper.findAll('.ant-btn')[0].trigger('click');
|
||||||
.findAll('.ant-btn')
|
|
||||||
.at(0)
|
|
||||||
.trigger('click');
|
|
||||||
expect(handleChange).toHaveBeenCalledWith(['1', '3', '4'], 'right', ['1']);
|
expect(handleChange).toHaveBeenCalledWith(['1', '3', '4'], 'right', ['1']);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -404,20 +355,18 @@ describe('Transfer', () => {
|
||||||
.trigger('click');
|
.trigger('click');
|
||||||
expect(handleSelectChange).toHaveBeenLastCalledWith(['b'], []);
|
expect(handleSelectChange).toHaveBeenLastCalledWith(['b'], []);
|
||||||
|
|
||||||
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input').at(0);
|
const input = wrapper.findAll('.ant-transfer-list-body-search-wrapper input')[0];
|
||||||
input.element.value = 'a';
|
input.element.value = 'a';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list')
|
.findAll('.ant-transfer-list')[0]
|
||||||
.at(0)
|
|
||||||
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
||||||
.trigger('change');
|
.trigger('change');
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
expect(handleSelectChange).toHaveBeenLastCalledWith(['b', 'a'], []);
|
expect(handleSelectChange).toHaveBeenLastCalledWith(['b', 'a'], []);
|
||||||
wrapper
|
wrapper
|
||||||
.findAll('.ant-transfer-list')
|
.findAll('.ant-transfer-list')[0]
|
||||||
.at(0)
|
|
||||||
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
.findAll('.ant-transfer-list-header input[type="checkbox"]')
|
||||||
.trigger('change');
|
.trigger('change');
|
||||||
expect(handleSelectChange).toHaveBeenLastCalledWith(['b'], []);
|
expect(handleSelectChange).toHaveBeenLastCalledWith(['b'], []);
|
||||||
|
@ -453,8 +402,8 @@ describe('Transfer', () => {
|
||||||
render: item => item.title,
|
render: item => item.title,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const wrapper = renderToString(Transfer, props);
|
const wrapper = mount(Transfer, props);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('should add custom styles when their props are provided', async () => {
|
it('should add custom styles when their props are provided', async () => {
|
||||||
const style = {
|
const style = {
|
||||||
|
@ -485,9 +434,9 @@ describe('Transfer', () => {
|
||||||
await asyncExpect(() => {
|
await asyncExpect(() => {
|
||||||
const wrapper = component.find('.ant-transfer');
|
const wrapper = component.find('.ant-transfer');
|
||||||
const list = component.findAll('.ant-transfer-list');
|
const list = component.findAll('.ant-transfer-list');
|
||||||
const listSource = list.at(0);
|
const listSource = list[0];
|
||||||
const listTarget = list.at(list.length - 1);
|
const listTarget = list.at(list.length - 1);
|
||||||
const operation = component.findAll('.ant-transfer-operation').at(0);
|
const operation = component.findAll('.ant-transfer-operation')[0];
|
||||||
expect(wrapper.element.style).toHaveProperty('backgroundColor', 'red');
|
expect(wrapper.element.style).toHaveProperty('backgroundColor', 'red');
|
||||||
expect(listSource.element.style).toHaveProperty('backgroundColor', 'blue');
|
expect(listSource.element.style).toHaveProperty('backgroundColor', 'blue');
|
||||||
expect(listTarget.element.style).toHaveProperty('backgroundColor', 'blue');
|
expect(listTarget.element.style).toHaveProperty('backgroundColor', 'blue');
|
||||||
|
|
|
@ -38,6 +38,11 @@ export const TransferProps = {
|
||||||
lazy: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
|
lazy: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
|
||||||
showSelectAll: PropTypes.bool,
|
showSelectAll: PropTypes.bool,
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
onSelectChange: PropTypes.func,
|
||||||
|
onSearchChange: PropTypes.func,
|
||||||
|
onSearch: PropTypes.func,
|
||||||
|
onScroll: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TransferLocale = {
|
export const TransferLocale = {
|
||||||
|
@ -378,7 +383,7 @@ const Transfer = {
|
||||||
const locale = this.getLocale(transferLocale, renderEmpty);
|
const locale = this.getLocale(transferLocale, renderEmpty);
|
||||||
const { sourceSelectedKeys, targetSelectedKeys, $slots } = this;
|
const { sourceSelectedKeys, targetSelectedKeys, $slots } = this;
|
||||||
const { body, footer } = $slots;
|
const { body, footer } = $slots;
|
||||||
const renderItem = props.render;
|
const renderItem = props.render || this.$slots.render;
|
||||||
const { leftDataSource, rightDataSource } = this.separateDataSource();
|
const { leftDataSource, rightDataSource } = this.separateDataSource();
|
||||||
const leftActive = targetSelectedKeys.length > 0;
|
const leftActive = targetSelectedKeys.length > 0;
|
||||||
const rightActive = sourceSelectedKeys.length > 0;
|
const rightActive = sourceSelectedKeys.length > 0;
|
||||||
|
|
|
@ -48,6 +48,9 @@ export const TransferListProps = {
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
direction: PropTypes.string,
|
direction: PropTypes.string,
|
||||||
showSelectAll: PropTypes.bool,
|
showSelectAll: PropTypes.bool,
|
||||||
|
onItemSelect: PropTypes.func,
|
||||||
|
onItemSelectAll: PropTypes.func,
|
||||||
|
onScroll: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderListNode(renderList, props) {
|
function renderListNode(renderList, props) {
|
||||||
|
|
|
@ -19,12 +19,22 @@ const Operation = (_, { attrs }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={className} style={style}>
|
<div class={className} style={style}>
|
||||||
<Button type="primary" size="small" disabled={disabled || !rightActive} onClick={moveToRight}>
|
<Button
|
||||||
<RightOutlined slot="icon" />
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
disabled={disabled || !rightActive}
|
||||||
|
onClick={moveToRight}
|
||||||
|
icon={<RightOutlined />}
|
||||||
|
>
|
||||||
{rightArrowText}
|
{rightArrowText}
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" size="small" disabled={disabled || !leftActive} onClick={moveToLeft}>
|
<Button
|
||||||
<LeftOutlined slot="icon" />
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
disabled={disabled || !leftActive}
|
||||||
|
onClick={moveToLeft}
|
||||||
|
icon={<LeftOutlined />}
|
||||||
|
>
|
||||||
{leftArrowText}
|
{leftArrowText}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,9 @@ const ListBody = {
|
||||||
lazy: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
lazy: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
||||||
selectedKeys: PropTypes.array,
|
selectedKeys: PropTypes.array,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
onItemSelect: PropTypes.func,
|
||||||
|
onItemSelectAll: PropTypes.func,
|
||||||
|
onScroll: PropTypes.func,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -53,12 +56,12 @@ const ListBody = {
|
||||||
raf.cancel(this.lazyId);
|
raf.cancel(this.lazyId);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onItemSelect(item) {
|
handleItemSelect(item) {
|
||||||
const { selectedKeys } = this.$props;
|
const { selectedKeys } = this.$props;
|
||||||
const checked = selectedKeys.indexOf(item.key) >= 0;
|
const checked = selectedKeys.indexOf(item.key) >= 0;
|
||||||
this.$emit('itemSelect', item.key, !checked);
|
this.$emit('itemSelect', item.key, !checked);
|
||||||
},
|
},
|
||||||
onScroll(e) {
|
handleScroll(e) {
|
||||||
this.$emit('scroll', e);
|
this.$emit('scroll', e);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -85,7 +88,7 @@ const ListBody = {
|
||||||
renderedEl={renderedEl}
|
renderedEl={renderedEl}
|
||||||
checked={checked}
|
checked={checked}
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
onClick={this.onItemSelect}
|
onClick={this.handleItemSelect}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -93,7 +96,7 @@ const ListBody = {
|
||||||
mounted ? `${prefixCls}-content-item-highlight` : '',
|
mounted ? `${prefixCls}-content-item-highlight` : '',
|
||||||
{
|
{
|
||||||
tag: 'ul',
|
tag: 'ul',
|
||||||
onScroll: this.onScroll,
|
onScroll: this.handleScroll,
|
||||||
onLeave: noop,
|
onLeave: noop,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,7 @@ export const TransferSearchProps = {
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
handleClear: PropTypes.func,
|
handleClear: PropTypes.func,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
onChange: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/form/demo/validation';
|
import demo from '../antdv-demo/docs/transfer/demo/basic';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in New Issue