Skip to content

Commit c015c8d

Browse files
committed
cr pxxx to sxxx and tree
1 parent 4ce99b9 commit c015c8d

32 files changed

+380
-82
lines changed

components/_util/props-util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const getComponentFromProp = (instance, prop, options = instance, execute = true
133133
const componentOptions = instance.componentOptions || {};
134134
(componentOptions.children || []).forEach(child => {
135135
if (child.data && child.data.slot === prop) {
136+
delete child.data.slot;
136137
if (child.tag === 'template') {
137138
slotsProp.push(child.children);
138139
} else {

components/progress/circle.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Circle as VCCircle } from '../vc-progress';
22
import { validProgress } from './utils';
3-
import { ProgressProps } from './progress';
43

54
const statusColorMap = {
65
normal: '#108ee9',

components/progress/line.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { validProgress } from './utils';
2-
import { ProgressProps } from './progress';
32

43
const Line = {
54
functional: true,

components/radio/Group.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export default {
1111
prop: 'value',
1212
},
1313
props: {
14-
prefixCls: {
15-
type: String,
16-
},
14+
prefixCls: PropTypes.string,
1715
defaultValue: PropTypes.any,
1816
value: PropTypes.any,
1917
size: {
@@ -103,7 +101,6 @@ export default {
103101
prefixCls={prefixCls}
104102
disabled={props.disabled}
105103
value={option}
106-
onChange={this.onRadioChange}
107104
checked={this.stateValue === option}
108105
>
109106
{option}
@@ -116,7 +113,6 @@ export default {
116113
prefixCls={prefixCls}
117114
disabled={option.disabled || props.disabled}
118115
value={option.value}
119-
onChange={this.onRadioChange}
120116
checked={this.stateValue === option.value}
121117
>
122118
{option.label}

components/radio/Radio.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default {
1212
prop: 'checked',
1313
},
1414
props: {
15-
prefixCls: {
16-
type: String,
17-
},
15+
prefixCls: PropTypes.string,
1816
defaultChecked: Boolean,
1917
checked: { type: Boolean, default: undefined },
2018
disabled: Boolean,
@@ -41,6 +39,12 @@ export default {
4139
blur() {
4240
this.$refs.vcCheckbox.blur();
4341
},
42+
onChange(e) {
43+
this.$emit('change', e);
44+
if (this.radioGroupContext && this.radioGroupContext.onRadioChange) {
45+
this.radioGroupContext.onRadioChange(e);
46+
}
47+
},
4448
},
4549

4650
render() {
@@ -60,7 +64,7 @@ export default {
6064

6165
if (radioGroup) {
6266
radioProps.props.name = radioGroup.name;
63-
radioProps.on.change = radioGroup.onRadioChange;
67+
radioProps.on.change = this.onChange;
6468
radioProps.props.checked = props.value === radioGroup.stateValue;
6569
radioProps.props.disabled = props.disabled || radioGroup.disabled;
6670
} else {

components/radio/RadioButton.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import Radio from './Radio';
2+
import PropTypes from '../_util/vue-types';
23
import { getOptionProps } from '../_util/props-util';
34
import { ConfigConsumerProps } from '../config-provider';
45

56
export default {
67
name: 'ARadioButton',
78
props: {
89
...Radio.props,
9-
prefixCls: {
10-
type: String,
11-
},
1210
},
1311
inject: {
1412
radioGroupContext: { default: undefined },

components/radio/__tests__/group.test.js

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
22
import { asyncExpect } from '@/tests/utils';
33
import Radio from '../Radio';
44
import RadioGroup from '../Group';
5+
import RadioButton from '../radioButton';
56

67
describe('Radio', () => {
78
function createRadioGroup(props, listeners = {}) {
@@ -50,10 +51,16 @@ describe('Radio', () => {
5051
},
5152
});
5253

53-
wrapper.trigger('mouseenter');
54+
wrapper
55+
.findAll('div')
56+
.at(0)
57+
.trigger('mouseenter');
5458
expect(onMouseEnter).toHaveBeenCalled();
5559

56-
wrapper.trigger('mouseleave');
60+
wrapper
61+
.findAll('div')
62+
.at(0)
63+
.trigger('mouseleave');
5764
expect(onMouseLeave).toHaveBeenCalled();
5865
});
5966

@@ -89,6 +96,80 @@ describe('Radio', () => {
8996
});
9097
});
9198

99+
it('both of radio and radioGroup will trigger onchange event when they exists', async () => {
100+
const onChange = jest.fn();
101+
const onChangeRadioGroup = jest.fn();
102+
103+
const wrapper = mount(
104+
{
105+
props: ['value'],
106+
render() {
107+
const groupProps = {};
108+
if (this.value !== undefined) {
109+
groupProps.value = this.value;
110+
}
111+
return (
112+
<RadioGroup ref="radioGroup" {...groupProps} onChange={onChangeRadioGroup}>
113+
<Radio value="A" onChange={onChange}>
114+
A
115+
</Radio>
116+
<Radio value="B" onChange={onChange}>
117+
B
118+
</Radio>
119+
<Radio value="C" onChange={onChange}>
120+
C
121+
</Radio>
122+
</RadioGroup>
123+
);
124+
},
125+
},
126+
{ sync: false },
127+
);
128+
const radios = wrapper.findAll('input');
129+
130+
// uncontrolled component
131+
wrapper.vm.$refs.radioGroup.stateValue = 'B';
132+
radios.at(0).trigger('change');
133+
expect(onChange.mock.calls.length).toBe(1);
134+
expect(onChangeRadioGroup.mock.calls.length).toBe(1);
135+
136+
// controlled component
137+
wrapper.setProps({ value: 'A' });
138+
radios.at(1).trigger('change');
139+
expect(onChange.mock.calls.length).toBe(2);
140+
});
141+
142+
it('Trigger onChange when both of radioButton and radioGroup exists', () => {
143+
const onChange = jest.fn();
144+
const props = {};
145+
const wrapper = mount(
146+
createRadioGroup(props, {
147+
change: onChange,
148+
}),
149+
{ sync: false },
150+
);
151+
const radios = wrapper.findAll('input');
152+
153+
// uncontrolled component
154+
wrapper.vm.$refs.radioGroup.stateValue = 'B';
155+
radios.at(0).trigger('change');
156+
expect(onChange.mock.calls.length).toBe(1);
157+
158+
// controlled component
159+
wrapper.setProps({ value: 'A' });
160+
radios.at(1).trigger('change');
161+
expect(onChange.mock.calls.length).toBe(2);
162+
});
163+
164+
// it('should only trigger once when in group with options', () => {
165+
// const onChange = jest.fn();
166+
// const options = [{ label: 'Bamboo', value: 'Bamboo' }];
167+
// const wrapper = mount(<RadioGroup options={options} onChange={onChange} />);
168+
169+
// wrapper.find('input').trigger('change');
170+
// expect(onChange).toHaveBeenCalledTimes(1);
171+
// });
172+
92173
// it('won\'t fire change events when value not changes', async () => {
93174
// const onChange = jest.fn()
94175

components/radio/__tests__/radio.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ describe('Radio', () => {
2828
{ sync: false },
2929
);
3030
await asyncExpect(() => {
31-
wrapper.trigger('mouseenter');
31+
wrapper.find('label').trigger('mouseenter');
3232
});
3333
await asyncExpect(() => {
3434
expect(onMouseEnter).toHaveBeenCalled();
3535
});
36-
wrapper.trigger('mouseleave');
36+
wrapper.find('label').trigger('mouseleave');
3737
await asyncExpect(() => {
3838
expect(onMouseLeave).toHaveBeenCalled();
3939
});

components/rate/index.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ const Rate = {
4040
characterRender(node, { index }) {
4141
const { tooltips } = this.$props;
4242
if (!tooltips) return node;
43-
const tooltipsProps = {
44-
props: {
45-
title: tooltips[index],
46-
},
47-
};
48-
return <Tooltip {...tooltipsProps}>{node}</Tooltip>;
43+
return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
4944
},
5045
},
5146
render() {

components/select/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warning from 'warning';
1+
import warning from '../_util/warning';
22
import omit from 'omit.js';
33
import PropTypes from '../_util/vue-types';
44
import { Select as VcSelect, Option, OptGroup } from '../vc-select';
@@ -96,7 +96,6 @@ const Select = {
9696
name: 'ASelect',
9797
props: {
9898
...SelectProps,
99-
prefixCls: PropTypes.string,
10099
showSearch: PropTypes.bool.def(false),
101100
transitionName: PropTypes.string.def('slide-up'),
102101
choiceTransitionName: PropTypes.string.def('zoom'),

0 commit comments

Comments
 (0)