Skip to content

Commit eff286d

Browse files
committed
Merge remote-tracking branch 'origin/next' into refactor-tree
2 parents d5fc13b + 381636f commit eff286d

File tree

10 files changed

+78
-39
lines changed

10 files changed

+78
-39
lines changed

components/auto-complete/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const AutoComplete = defineComponent({
3333
inheritAttrs: false,
3434
props: {
3535
...autoCompleteProps,
36-
prefixCls: PropTypes.string.def('ant-select'),
36+
prefixCls: PropTypes.string,
3737
showSearch: PropTypes.looseBool,
3838
transitionName: PropTypes.string.def('slide-up'),
3939
choiceTransitionName: PropTypes.string.def('zoom'),

components/form/Form.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,16 @@ const Form = defineComponent({
318318
e.preventDefault();
319319
e.stopPropagation();
320320
emit('submit', e);
321-
const res = validateFields();
322-
res
323-
.then(values => {
324-
emit('finish', values);
325-
})
326-
.catch(errors => {
327-
handleFinishFailed(errors);
328-
});
321+
if (props.model) {
322+
const res = validateFields();
323+
res
324+
.then(values => {
325+
emit('finish', values);
326+
})
327+
.catch(errors => {
328+
handleFinishFailed(errors);
329+
});
330+
}
329331
};
330332

331333
expose({

components/form/useForm.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ function useForm(
107107
validateInfos: validateInfos;
108108
resetFields: (newValues?: Props) => void;
109109
validate: <T = any>(names?: namesType, option?: validateOptions) => Promise<T>;
110+
111+
/** This is an internal usage. Do not use in your prod */
110112
validateField: (
111113
name: string,
112114
value: any,
@@ -117,19 +119,33 @@ function useForm(
117119
clearValidate: (names?: namesType) => void;
118120
} {
119121
const initialModel = cloneDeep(unref(modelRef));
120-
let validateInfos: validateInfos = {};
122+
const validateInfos = reactive<validateInfos>({});
121123

122124
const rulesKeys = computed(() => {
123125
return Object.keys(unref(rulesRef));
124126
});
125127

126-
rulesKeys.value.forEach(key => {
127-
validateInfos[key] = {
128-
autoLink: false,
129-
required: isRequired(unref(rulesRef)[key]),
130-
};
131-
});
132-
validateInfos = reactive(validateInfos);
128+
watch(
129+
rulesKeys,
130+
() => {
131+
const newValidateInfos = {};
132+
rulesKeys.value.forEach(key => {
133+
newValidateInfos[key] = validateInfos[key] || {
134+
autoLink: false,
135+
required: isRequired(unref(rulesRef)[key]),
136+
};
137+
delete validateInfos[key];
138+
});
139+
for (const key in validateInfos) {
140+
if (Object.prototype.hasOwnProperty.call(validateInfos, key)) {
141+
delete validateInfos[key];
142+
}
143+
}
144+
Object.assign(validateInfos, newValidateInfos);
145+
},
146+
{ immediate: true },
147+
);
148+
133149
const resetFields = (newValues: Props) => {
134150
Object.assign(unref(modelRef), {
135151
...cloneDeep(initialModel),
@@ -249,6 +265,9 @@ function useForm(
249265
},
250266
!!option.validateFirst,
251267
);
268+
if (!validateInfos[name]) {
269+
return promise.catch((e: any) => e);
270+
}
252271
validateInfos[name].validateStatus = 'validating';
253272
promise
254273
.catch((e: any) => e)
@@ -325,7 +344,9 @@ function useForm(
325344
validate(names, { trigger: 'change' });
326345
oldModel = cloneDeep(model);
327346
};
347+
328348
const debounceOptions = options?.debounce;
349+
329350
watch(
330351
modelRef,
331352
debounceOptions && debounceOptions.wait

components/style/mixins/clearfix.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// mixins for clearfix
22
// ------------------------
33
.clearfix() {
4-
zoom: 1;
4+
55
&::before,
66
&::after {
77
display: table;

components/switch/__tests__/index.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,35 @@ describe('Switch', () => {
7070
});
7171
expect(checked.value).toBe(1);
7272
});
73+
74+
it('customize checked value and children should work', async () => {
75+
resetWarned();
76+
const checked = ref(1);
77+
const onUpdate = val => (checked.value = val);
78+
const wrapper = mount({
79+
render() {
80+
return (
81+
<Switch
82+
{...{ 'onUpdate:checked': onUpdate }}
83+
checked={checked.value}
84+
unCheckedValue={1}
85+
checkedValue={2}
86+
checkedChildren="on"
87+
unCheckedChildren="off"
88+
/>
89+
);
90+
},
91+
});
92+
await asyncExpect(() => {
93+
wrapper.find('button').trigger('click');
94+
});
95+
expect(checked.value).toBe(2);
96+
expect(wrapper.find('.ant-switch-inner').text()).toBe('on');
97+
98+
await asyncExpect(() => {
99+
wrapper.find('button').trigger('click');
100+
});
101+
expect(checked.value).toBe(1);
102+
expect(wrapper.find('.ant-switch-inner').text()).toBe('off');
103+
});
73104
});

components/switch/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const Switch = defineComponent({
134134
[`${prefixCls.value}-disabled`]: props.disabled,
135135
[prefixCls.value]: true,
136136
}));
137+
137138
return () => (
138139
<Wave insertExtraNode>
139140
<button
@@ -160,7 +161,7 @@ const Switch = defineComponent({
160161
>
161162
{props.loading ? <LoadingOutlined class={`${prefixCls.value}-loading-icon`} /> : null}
162163
<span class={`${prefixCls.value}-inner`}>
163-
{checked.value
164+
{checkedStatus.value
164165
? getPropsSlot(slots, props, 'checkedChildren')
165166
: getPropsSlot(slots, props, 'unCheckedChildren')}
166167
</span>

components/vc-mentions/src/Mentions.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ const Mentions = {
115115
const { measureText: prevMeasureText, measuring } = this.$data;
116116
const { prefix = '', validateSearch } = this.$props;
117117
const target = event.target;
118+
if (target.composing) {
119+
return;
120+
}
118121
const selectionStartText = getBeforeSelectionText(target);
119122
const { location: measureIndex, prefix: measurePrefix } = getLastMeasureIndex(
120123
selectionStartText,

components/vc-select/utils/warningPropsUtil.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import warning, { noteOnce } from '../../vc-util/warning';
22
import type { SelectProps } from '..';
33
import { convertChildrenToData } from './legacyUtil';
4-
import type { OptionData } from '../interface';
54
import { toArray } from './commonUtil';
65
import type { RawValueType, LabelValueType } from '../interface/generator';
76
import { isValidElement } from '../../_util/props-util';
@@ -36,23 +35,6 @@ function warningProps(props: SelectProps) {
3635
'Please avoid setting option to disabled in tags mode since user can always type text as tag.',
3736
);
3837

39-
// `combobox` & `tags` should option be `string` type
40-
if (mode === 'tags' || mode === 'combobox') {
41-
const hasNumberValue = mergedOptions.some(item => {
42-
if (item.options) {
43-
return item.options.some(
44-
(opt: OptionData) => typeof ('value' in opt ? opt.value : opt.key) === 'number',
45-
);
46-
}
47-
return typeof ('value' in item ? item.value : item.key) === 'number';
48-
});
49-
50-
warning(
51-
!hasNumberValue,
52-
'`value` of Option should not use number type when `mode` is `tags` or `combobox`.',
53-
);
54-
}
55-
5638
// `combobox` should not use `optionLabelProp`
5739
warning(
5840
mode !== 'combobox' || !optionLabelProp,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
"webpack": "^5.0.0",
197197
"webpack-bundle-analyzer": "^4.0.0",
198198
"webpack-cli": "^4.6.0",
199-
"webpack-dev-server": "^3.1.14",
199+
"webpack-dev-server": "^4.0.0",
200200
"webpack-merge": "^5.0.0",
201201
"webpackbar": "^5.0.0-3",
202202
"xhr-mock": "^2.5.1"

webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ module.exports = {
130130
historyApiFallback: {
131131
rewrites: [{ from: /./, to: '/index.html' }],
132132
},
133-
disableHostCheck: true,
134133
hot: true,
135134
open: true,
136135
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy