Skip to content

Commit a6f37de

Browse files
committed
Merge remote-tracking branch 'origin/next' into v2.3
2 parents e9010e1 + 752642a commit a6f37de

File tree

16 files changed

+118
-64
lines changed

16 files changed

+118
-64
lines changed

CHANGELOG.en-US.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010

1111
---
1212

13+
## 2.2.7
14+
15+
`2021-09-08`
16+
17+
- 🌟 Menu supports overflowedIndicator slot [#4515](https://github.com/vueComponent/ant-design-vue/issues/4515)
18+
- 🌟 useForm supports dynamic rule [#4498](https://github.com/vueComponent/ant-design-vue/issues/4498)
19+
- 🌟 Select supports Number type [#4570](https://github.com/vueComponent/ant-design-vue/issues/4570)
20+
- 🐞 Fix the warning problem caused by css zoom [#4554](https://github.com/vueComponent/ant-design-vue/issues/4554)
21+
- 🐞 Fix Mentions input Chinese error report [#4524](https://github.com/vueComponent/ant-design-vue/issues/4524)
22+
- 🐞 Fix the issue that AutoComplete does not support global prefixCls [#4566](https://github.com/vueComponent/ant-design-vue/issues/4566)
23+
- 🐞 Fix Table nested table error report [#4600](https://github.com/vueComponent/ant-design-vue/issues/4600)
24+
- 🐞 Fix MenuItem danger property under Dropdown has no style problem [#4618](https://github.com/vueComponent/ant-design-vue/issues/4618)
25+
- 🐞 Fix Modal.xxx and other methods passing appContext invalid problem [#4627](https://github.com/vueComponent/ant-design-vue/issues/4627)
26+
- 🐞 Fix some TS type errors
27+
1328
## 2.2.6
1429

1530
`2021-08-12`

CHANGELOG.zh-CN.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010

1111
---
1212

13+
## 2.2.7
14+
15+
`2021-09-08`
16+
17+
- 🌟 Menu 支持 overflowedIndicator 插槽 [#4515](https://github.com/vueComponent/ant-design-vue/issues/4515)
18+
- 🌟 useForm 支持动态 rule [#4498](https://github.com/vueComponent/ant-design-vue/issues/4498)
19+
- 🌟 Select 支持 Number 类型 [#4570](https://github.com/vueComponent/ant-design-vue/issues/4570)
20+
- 🐞 修复 css zoom 引起的 warning 问题 [#4554](https://github.com/vueComponent/ant-design-vue/issues/4554)
21+
- 🐞 修复 Mentions 输入中文报错问题 [#4524](https://github.com/vueComponent/ant-design-vue/issues/4524)
22+
- 🐞 修复 AutoComplete 不支持全局 prefixCls 问题 [#4566](https://github.com/vueComponent/ant-design-vue/issues/4566)
23+
- 🐞 修复 Table 嵌套表格报错问题 [#4600](https://github.com/vueComponent/ant-design-vue/issues/4600)
24+
- 🐞 修复 Dropdown 下的 MenuItem danger 属性无样式问题 [#4618](https://github.com/vueComponent/ant-design-vue/issues/4618)
25+
- 🐞 修复 Modal.xxx 等方法传递 appContext 失效问题 [#4627](https://github.com/vueComponent/ant-design-vue/issues/4627)
26+
- 🐞 修复一些 TS 类型错误
27+
1328
## 2.2.6
1429

1530
`2021-08-12`

components/_util/props-util/initDefaultProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const initDefaultProps = <T>(
1313
: any;
1414
},
1515
): T => {
16-
const propTypes: T = { ...types } as T;
16+
const propTypes: T = { ...types };
1717
Object.keys(defaultProps).forEach(k => {
1818
const prop = propTypes[k] as VueTypeValidableDef;
1919
if (prop) {

components/button/buttonTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const buttonProps = () => ({
2929
type: String as PropType<SizeType>,
3030
},
3131
loading: {
32-
type: [Boolean, Object],
32+
type: [Boolean, Object] as PropType<boolean | { delay?: number }>,
3333
default: (): boolean | { delay?: number } => false,
3434
},
3535
disabled: PropTypes.looseBool,

components/form/useForm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function useForm(
122122
const validateInfos = reactive<validateInfos>({});
123123

124124
const rulesKeys = computed(() => {
125-
return Object.keys(unref(rulesRef));
125+
return rulesRef ? Object.keys(unref(rulesRef)) : [];
126126
});
127127

128128
watch(

components/list/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type { ListItemMetaProps } from './ItemMeta';
2424
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
2525

2626
export const ListGridType = {
27-
gutter: PropTypes.number,
27+
gutter: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(Number)]),
2828
column: PropTypes.number,
2929
xs: PropTypes.number,
3030
sm: PropTypes.number,

components/modal/ConfirmDialog.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ import type { ModalFuncProps } from './Modal';
33
import Dialog from './Modal';
44
import ActionButton from './ActionButton';
55
import { getConfirmLocale } from './locale';
6-
import type { FunctionalComponent } from 'vue';
6+
import { FunctionalComponent } from 'vue';
77

88
interface ConfirmDialogProps extends ModalFuncProps {
99
afterClose?: () => void;
10-
close: (...args: any[]) => void;
10+
close?: (...args: any[]) => void;
1111
autoFocusButton?: null | 'ok' | 'cancel';
1212
}
1313

14+
function renderSomeContent(_name, someContent) {
15+
if (typeof someContent === 'function') {
16+
return someContent();
17+
}
18+
return someContent;
19+
}
20+
1421
const ConfirmDialog: FunctionalComponent<ConfirmDialogProps> = props => {
1522
const {
1623
icon,
@@ -40,8 +47,10 @@ const ConfirmDialog: FunctionalComponent<ConfirmDialogProps> = props => {
4047
// 默认为 false,保持旧版默认行为
4148
const maskClosable = props.maskClosable === undefined ? false : props.maskClosable;
4249
const runtimeLocale = getConfirmLocale();
43-
const okText = props.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
44-
const cancelText = props.cancelText || runtimeLocale.cancelText;
50+
const okText =
51+
renderSomeContent('okText', props.okText) ||
52+
(okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
53+
const cancelText = renderSomeContent('cancelText', props.cancelText) || runtimeLocale.cancelText;
4554
const autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok';
4655
const transitionName = props.transitionName || 'zoom';
4756
const maskTransitionName = props.maskTransitionName || 'fade';
@@ -89,11 +98,15 @@ const ConfirmDialog: FunctionalComponent<ConfirmDialogProps> = props => {
8998
>
9099
<div class={`${contentPrefixCls}-body-wrapper`}>
91100
<div class={`${contentPrefixCls}-body`}>
92-
{icon}
101+
{renderSomeContent('icon', icon)}
93102
{props.title === undefined ? null : (
94-
<span class={`${contentPrefixCls}-title`}>{props.title}</span>
103+
<span class={`${contentPrefixCls}-title`}>
104+
{renderSomeContent('title', props.title)}
105+
</span>
95106
)}
96-
<div class={`${contentPrefixCls}-content`}>{props.content}</div>
107+
<div class={`${contentPrefixCls}-content`}>
108+
{renderSomeContent('content', props.content)}
109+
</div>
97110
</div>
98111
<div class={`${contentPrefixCls}-btns`}>
99112
{cancelButton}

components/modal/Modal.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ export interface ModalFuncProps {
9595
prefixCls?: string;
9696
class?: string;
9797
visible?: boolean;
98-
title?: VNodeTypes;
98+
title?: (() => VNodeTypes) | VNodeTypes;
9999
closable?: boolean;
100-
content?: VNodeTypes;
100+
content?: (() => VNodeTypes) | VNodeTypes;
101101
// TODO: find out exact types
102102
onOk?: (...args: any[]) => any;
103103
onCancel?: (...args: any[]) => any;
104104
okButtonProps?: ButtonPropsType;
105105
cancelButtonProps?: ButtonPropsType;
106106
centered?: boolean;
107107
width?: string | number;
108-
okText?: VNodeTypes;
108+
okText?: (() => VNodeTypes) | VNodeTypes;
109109
okType?: LegacyButtonType;
110-
cancelText?: VNodeTypes;
111-
icon?: VNodeTypes;
110+
cancelText?: (() => VNodeTypes) | VNodeTypes;
111+
icon?: (() => VNodeTypes) | VNodeTypes;
112112
/* Deprecated */
113113
iconType?: string;
114114
mask?: boolean;
@@ -123,7 +123,10 @@ export interface ModalFuncProps {
123123
autoFocusButton?: null | 'ok' | 'cancel';
124124
transitionName?: string;
125125
maskTransitionName?: string;
126+
127+
/** @deprecated please use `appContext` instead */
126128
parentContext?: any;
129+
appContext?: any;
127130
}
128131

129132
type getContainerFunc = () => HTMLElement;

components/modal/confirm.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import { createApp } from 'vue';
1+
import { createVNode, render as vueRender } from 'vue';
22
import ConfirmDialog from './ConfirmDialog';
33
import type { ModalFuncProps } from './Modal';
44
import { destroyFns } from './Modal';
55

66
import Omit from 'omit.js';
77

8-
export default function confirm(config: ModalFuncProps) {
8+
const confirm = (config: ModalFuncProps) => {
99
const div = document.createElement('div');
1010
document.body.appendChild(div);
11-
let currentConfig = { ...Omit(config, ['parentContext']), close, visible: true } as any;
11+
let currentConfig = {
12+
...Omit(config, ['parentContext', 'appContext']),
13+
close,
14+
visible: true,
15+
} as any;
1216

1317
let confirmDialogInstance = null;
14-
let confirmDialogProps = {};
1518
function close(this: typeof close, ...args: any[]) {
1619
currentConfig = {
1720
...currentConfig,
@@ -25,12 +28,15 @@ export default function confirm(config: ModalFuncProps) {
2528
...currentConfig,
2629
...newConfig,
2730
};
28-
confirmDialogInstance &&
29-
Object.assign(confirmDialogInstance, { confirmDialogProps: currentConfig });
31+
if (confirmDialogInstance) {
32+
Object.assign(confirmDialogInstance.component.props, currentConfig);
33+
confirmDialogInstance.component.update();
34+
}
3035
}
3136
function destroy(...args: any[]) {
3237
if (confirmDialogInstance && div.parentNode) {
33-
confirmDialogInstance.vIf = false; // hack destroy
38+
Object.assign(confirmDialogInstance.component.props, { vIf: false }); // hack destroy
39+
confirmDialogInstance.component.update();
3440
confirmDialogInstance = null;
3541
div.parentNode.removeChild(div);
3642
}
@@ -46,20 +52,14 @@ export default function confirm(config: ModalFuncProps) {
4652
}
4753
}
4854
}
49-
55+
const Wrapper = p => {
56+
return p.vIf ? <ConfirmDialog {...p}></ConfirmDialog> : null;
57+
};
5058
function render(props: ModalFuncProps) {
51-
confirmDialogProps = props;
52-
return createApp({
53-
parent: (config as any).parentContext,
54-
data() {
55-
return { confirmDialogProps, vIf: true };
56-
},
57-
render() {
58-
// 先解构,避免报错,原因不详
59-
const cdProps = { ...this.confirmDialogProps };
60-
return this.vIf ? <ConfirmDialog {...cdProps} /> : null;
61-
},
62-
}).mount(div);
59+
const vm = createVNode(Wrapper, { ...props, vIf: true });
60+
vm.appContext = config.parentContext || config.appContext || vm.appContext;
61+
vueRender(vm, div);
62+
return vm;
6363
}
6464

6565
confirmDialogInstance = render(currentConfig);
@@ -68,4 +68,6 @@ export default function confirm(config: ModalFuncProps) {
6868
destroy: close,
6969
update,
7070
};
71-
}
71+
};
72+
73+
export default confirm;

components/modal/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type { ModalProps, ModalFuncProps } from './Modal';
1313
const info = function (props: ModalFuncProps) {
1414
const config = {
1515
type: 'info',
16-
icon: <InfoCircleOutlined />,
16+
icon: () => <InfoCircleOutlined />,
1717
okCancel: false,
1818
...props,
1919
};
@@ -23,7 +23,7 @@ const info = function (props: ModalFuncProps) {
2323
const success = function (props: ModalFuncProps) {
2424
const config = {
2525
type: 'success',
26-
icon: <CheckCircleOutlined />,
26+
icon: () => <CheckCircleOutlined />,
2727
okCancel: false,
2828
...props,
2929
};
@@ -33,7 +33,7 @@ const success = function (props: ModalFuncProps) {
3333
const error = function (props: ModalFuncProps) {
3434
const config = {
3535
type: 'error',
36-
icon: <CloseCircleOutlined />,
36+
icon: () => <CloseCircleOutlined />,
3737
okCancel: false,
3838
...props,
3939
};
@@ -43,7 +43,7 @@ const error = function (props: ModalFuncProps) {
4343
const warning = function (props: ModalFuncProps) {
4444
const config = {
4545
type: 'warning',
46-
icon: <ExclamationCircleOutlined />,
46+
icon: () => <ExclamationCircleOutlined />,
4747
okCancel: false,
4848
...props,
4949
};

0 commit comments

Comments
 (0)