Skip to content

Commit 3840666

Browse files
author
Andy
committed
Merge branch 'feat-vue3' of https://github.com/vueComponent/ant-design-vue into feat-vue3
2 parents 10e6d99 + 19e4e27 commit 3840666

File tree

142 files changed

+3412
-3454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+3412
-3454
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ es/
77
lib/
88
_site/
99
dist/
10-
package.json

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ custom:
99
[
1010
"https://www.paypal.me/tangjinzhou",
1111
"https://qn.antdv.com/alipay-and-wechat.png",
12+
"https://www.buymeacoffee.com/antdv"
1213
]

.github/ISSUE_TEMPLATE.md

-16
This file was deleted.

.github/ISSUE_TEMPLATE/----please-use-new-issue-ant-design-vue---.md

-11
This file was deleted.

.github/ISSUE_TEMPLATE/config.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Create new issue
4+
url: https://vuecomponent.github.io/issue-helper/
5+
about: Please use the following link to create a new issue.
6+
- name: Patreon
7+
url: https://www.patreon.com/tangjinzhou
8+
about: Love Ant Design Vue? Please consider supporting us via Patreon.
9+
- name: Open Collective
10+
url: https://opencollective.com/ant-design-vue/donate
11+
about: Love Ant Design Vue? Please consider supporting us via Open Collective.
12+
- name: Paypal
13+
url: https://www.paypal.me/tangjinzhou
14+
about: Love Ant Design Vue? Please consider supporting us via Paypal.
15+
- name: 支付宝/微信 赞助
16+
url: https://qn.antdv.com/alipay-and-wechat.png
17+
about: Ant Design Vue 的健康持续发展需要您的支持,🙏

.github/workflows/codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
repository: tangjinzhou/antdv-demo
5151
token: ${{ secrets.ACCESS_TOKEN }}
5252
path: antdv-demo
53+
submodules: true
5354

5455
- name: restore cache from package-lock.json
5556
uses: actions/cache@v1

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
repository: tangjinzhou/antdv-demo
107107
token: ${{ secrets.ACCESS_TOKEN }}
108108
path: antdv-demo
109+
submodules: true
109110

110111
- name: restore cache from package-lock.json
111112
uses: actions/cache@v1

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
**/*.svg
2-
package.json
32
lib/
43
es/
54
dist/

antdv-demo

breakChange-2.x.md

+48
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,51 @@ v-model -> v-model:visible
2929
## Tooltip
3030

3131
v-model -> v-model:visible
32+
33+
## Modal
34+
35+
v-model -> v-model:visible
36+
37+
okButtonProps、cancelButtonProps 扁平化处理
38+
39+
## Mentions
40+
41+
v-model -> v-model:value
42+
43+
## menu
44+
45+
v-model -> v-model:selectedKeys :openKeys.sync -> v-mdoel:openKeys
46+
47+
## dropdown
48+
49+
v-model -> v-model:visible
50+
51+
## Steps
52+
53+
v-model -> v-model:current
54+
55+
## checkbox
56+
57+
v-model -> v-model:checked
58+
59+
checkboxGroup
60+
61+
v-model -> v-model:value
62+
63+
## Switch
64+
65+
v-model -> v-model:checked
66+
67+
## tabs
68+
69+
v-model -> v-model:activeKey
70+
71+
renderTabBar({props, on, style, class}, DefaultTabBar) -> {DefaultTabBar, ...props} 多参数改成单参数并且扁平化处理
72+
73+
## card
74+
75+
tabList[{scopedSlots}] -> tabList[{slots}]
76+
77+
## rate
78+
79+
v-model -> v-model:value

components/_util/BaseMixin.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getOptionProps } from './props-util';
2+
import { isOn } from './util';
23

34
export default {
45
methods: {
@@ -26,7 +27,9 @@ export default {
2627
const args = [].slice.call(arguments, 0);
2728
let eventName = args[0];
2829
// TODO: 后续统一改成onXxxx,不在运行时转,提升性能
29-
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
30+
eventName = isOn(eventName)
31+
? eventName
32+
: `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
3033
const event = this.$props[eventName] || this.$attrs[eventName];
3134
if (args.length && event) {
3235
if (Array.isArray(event)) {

components/_util/PortalWrapper.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PropTypes from './vue-types';
22
import switchScrollingEffect from './switchScrollingEffect';
33
import setStyle from './setStyle';
44
import Portal from './Portal';
5-
import createRefHooks from './createRefHooks';
65

76
let openCount = 0;
87
const windowIsUndefined = !(
@@ -142,7 +141,7 @@ export default {
142141
<Portal
143142
getContainer={this.getDomContainer}
144143
children={children(childProps)}
145-
{...createRefHooks(this.savePortal)}
144+
ref={this.savePortal}
146145
></Portal>
147146
);
148147
}

components/_util/createRefHooks.js

-14
This file was deleted.

components/_util/openAnimation.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ function animate(node, show, done) {
5454
}
5555

5656
const animation = {
57-
enter(node, done) {
57+
onEnter(node, done) {
5858
nextTick(() => {
5959
animate(node, true, done);
6060
});
6161
},
62-
leave(node, done) {
62+
onLeave(node, done) {
6363
return animate(node, false, done);
6464
},
6565
};

components/_util/props-util.js

+75-35
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ const getSlots = ele => {
6969
};
7070
const getSlot = (self, name = 'default', options = {}) => {
7171
let res = self.$slots[name] && self.$slots[name](options);
72-
while (res && res.length === 1 && res[0].type === Fragment) {
73-
res = res[0].children;
72+
while (res && res.length === 1 && (res[0].type === Fragment || Array.isArray(res[0]))) {
73+
res = res[0].children || res[0];
7474
}
75-
return res;
75+
return res && res.__v_isVNode ? [res] : res;
7676
};
7777

7878
const getAllChildren = ele => {
@@ -93,6 +93,13 @@ const getSlotOptions = ele => {
9393
}
9494
return componentOptions ? componentOptions.Ctor.options || {} : {};
9595
};
96+
const findDOMNode = instance => {
97+
let node = instance.$el;
98+
while (!node.tagName) {
99+
node = node.nextSibling;
100+
}
101+
return node;
102+
};
96103
const getOptionProps = instance => {
97104
const res = {};
98105
if (instance.$ && instance.$.vnode) {
@@ -105,27 +112,42 @@ const getOptionProps = instance => {
105112
}
106113
});
107114
} else if (isVNode(instance) && typeof instance.type === 'object') {
108-
const props = instance.props || {};
115+
const originProps = instance.props || {};
116+
const props = {};
117+
Object.keys(originProps).forEach(key => {
118+
props[camelize(key)] = originProps[key];
119+
});
109120
const options = instance.type.props;
110121
Object.keys(options).forEach(k => {
111-
const hyphenateKey = hyphenate(k);
112-
const v = resolvePropValue(options, props, k, props[hyphenateKey], hyphenateKey);
113-
if (v !== undefined || hyphenateKey in props) {
122+
const v = resolvePropValue(options, props, k, props[k]);
123+
if (v !== undefined || k in props) {
114124
res[k] = v;
115125
}
116126
});
117127
}
118128
return res;
119129
};
120130
const getComponent = (instance, prop, options = instance, execute = true) => {
121-
const temp = instance[prop];
122-
if (temp !== undefined) {
123-
return typeof temp === 'function' && execute ? temp(options) : temp;
124-
} else {
125-
let com = instance.$slots[prop];
126-
com = execute && com ? com(options) : com;
127-
return Array.isArray(com) && com.length === 1 ? com[0] : com;
131+
if (instance.$) {
132+
const temp = instance[prop];
133+
if (temp !== undefined) {
134+
return typeof temp === 'function' && execute ? temp(options) : temp;
135+
} else {
136+
let com = instance.$slots[prop];
137+
com = execute && com ? com(options) : com;
138+
return Array.isArray(com) && com.length === 1 ? com[0] : com;
139+
}
140+
} else if (isVNode(instance)) {
141+
const temp = instance.props && instance.props[prop];
142+
if (temp !== undefined) {
143+
return typeof temp === 'function' && execute ? temp(options) : temp;
144+
} else if (instance.children && instance.children[prop]) {
145+
let com = instance.children[prop];
146+
com = execute && com ? com(options) : com;
147+
return Array.isArray(com) && com.length === 1 ? com[0] : com;
148+
}
128149
}
150+
return undefined;
129151
};
130152
const getComponentFromProp = (instance, prop, options = instance, execute = true) => {
131153
if (instance.$createElement) {
@@ -169,19 +191,31 @@ const getComponentFromProp = (instance, prop, options = instance, execute = true
169191
};
170192

171193
const getAllProps = ele => {
172-
let data = ele.data || {};
173-
let componentOptions = ele.componentOptions || {};
174-
if (ele.$vnode) {
175-
data = ele.$vnode.data || {};
176-
componentOptions = ele.$vnode.componentOptions || {};
194+
let props = getOptionProps(ele);
195+
if (ele.$) {
196+
props = { ...props, ...this.$attrs };
197+
} else {
198+
props = { ...ele.props, ...props };
177199
}
178-
return { ...data.props, ...data.attrs, ...componentOptions.propsData };
200+
return props;
179201
};
180202

181-
// 使用 getOptionProps 替换 ,待测试
182-
const getPropsData = ele => {
183-
return getOptionProps(ele);
184-
//return ele.props || {};
203+
const getPropsData = vnode => {
204+
const res = {};
205+
const originProps = vnode.props || {};
206+
const props = {};
207+
Object.keys(originProps).forEach(key => {
208+
props[camelize(key)] = originProps[key];
209+
});
210+
const options = isPlainObject(vnode.type) ? vnode.type.props : {};
211+
Object.keys(options).forEach(k => {
212+
const v = resolvePropValue(options, props, k, props[k]);
213+
if (k in props) {
214+
// 仅包含 props,不包含默认值
215+
res[k] = v;
216+
}
217+
});
218+
return { ...props, ...res }; // 合并事件、未声明属性等
185219
};
186220
const getValueByProp = (ele, prop) => {
187221
return getPropsData(ele)[prop];
@@ -203,18 +237,16 @@ const getKey = ele => {
203237
return key;
204238
};
205239

206-
export function getEvents(child) {
207-
const { $attrs } = child;
208-
return splitAttrs($attrs).events;
209-
210-
// let events = {};
211-
// if (child.componentOptions && child.componentOptions.listeners) {
212-
// events = child.componentOptions.listeners;
213-
// } else if (child.data && child.data.on) {
214-
// events = child.data.on;
215-
// }
216-
// return { ...events };
240+
export function getEvents(ele, on = true) {
241+
let props = {};
242+
if (ele.$) {
243+
props = { ...props, ...ele.$attrs };
244+
} else {
245+
props = { ...props, ...ele.props };
246+
}
247+
return splitAttrs(props)[on ? 'onEvents' : 'events'];
217248
}
249+
218250
export function getEvent(child, event) {
219251
return child.props && child.props[event];
220252
}
@@ -270,6 +302,10 @@ export function getComponentName(opts) {
270302
return opts && (opts.Ctor.options.name || opts.tag);
271303
}
272304

305+
export function isFragment(c) {
306+
return c.length === 1 && c[0].type === Fragment;
307+
}
308+
273309
export function isEmptyElement(c) {
274310
return c.type === Comment || (c.type === Text && c.children.trim() === '');
275311
}
@@ -279,6 +315,9 @@ export function isStringElement(c) {
279315
}
280316

281317
export function filterEmpty(children = []) {
318+
if (isFragment(children)) {
319+
return children[0].children.filter(c => !isEmptyElement(c));
320+
}
282321
return children.filter(c => !isEmptyElement(c));
283322
}
284323
const initDefaultProps = (propTypes, defaultProps) => {
@@ -332,5 +371,6 @@ export {
332371
getSlot,
333372
getAllProps,
334373
getAllChildren,
374+
findDOMNode,
335375
};
336376
export default hasProp;

0 commit comments

Comments
 (0)