mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
chore: merge master into feature
This commit is contained in:
commit
70466b0ebb
@ -78,6 +78,10 @@ npm install antd --save
|
|||||||
yarn add antd
|
yarn add antd
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add antd
|
||||||
|
```
|
||||||
|
|
||||||
## 🔨 示例
|
## 🔨 示例
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
@ -78,6 +78,10 @@ npm install antd
|
|||||||
yarn add antd
|
yarn add antd
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add antd
|
||||||
|
```
|
||||||
|
|
||||||
## 🔨 Usage
|
## 🔨 Usage
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
@ -5,8 +5,8 @@ import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
|||||||
|
|
||||||
export interface ComponentToken {
|
export interface ComponentToken {
|
||||||
/**
|
/**
|
||||||
* @desc 头像背景色
|
* @desc 头像尺寸
|
||||||
* @descEN Background color of Avatar
|
* @descEN Size of Avatar
|
||||||
*/
|
*/
|
||||||
containerSize: number;
|
containerSize: number;
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { CSSObject } from '@ant-design/cssinjs';
|
import type { CSSObject } from '@ant-design/cssinjs';
|
||||||
import { TinyColor } from '@ctrl/tinycolor';
|
import { TinyColor } from '@ctrl/tinycolor';
|
||||||
|
|
||||||
import type { SharedComponentToken, SharedInputToken } from '../../input/style';
|
import type { SharedComponentToken, SharedInputToken } from '../../input/style';
|
||||||
import {
|
import {
|
||||||
genActiveStyle,
|
genActiveStyle,
|
||||||
@ -682,7 +683,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
|
||||||
'&-extra': {
|
'&-extra': {
|
||||||
padding: `0 ${paddingSM}`,
|
padding: `0 ${paddingSM}px`,
|
||||||
lineHeight: `${textHeight - 2 * lineWidth}px`,
|
lineHeight: `${textHeight - 2 * lineWidth}px`,
|
||||||
textAlign: 'start',
|
textAlign: 'start',
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ const ConfirmDialog: React.FC<ConfirmDialogProps> = (props) => {
|
|||||||
closeIcon,
|
closeIcon,
|
||||||
modalRender,
|
modalRender,
|
||||||
focusTriggerAfterClose,
|
focusTriggerAfterClose,
|
||||||
|
onConfirm,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
@ -220,7 +221,10 @@ const ConfirmDialog: React.FC<ConfirmDialogProps> = (props) => {
|
|||||||
{ [`${confirmPrefixCls}-centered`]: !!props.centered },
|
{ [`${confirmPrefixCls}-centered`]: !!props.centered },
|
||||||
wrapClassName,
|
wrapClassName,
|
||||||
)}
|
)}
|
||||||
onCancel={() => close?.({ triggerCancel: true })}
|
onCancel={() => {
|
||||||
|
close?.({ triggerCancel: true });
|
||||||
|
onConfirm?.(false);
|
||||||
|
}}
|
||||||
open={open}
|
open={open}
|
||||||
title=""
|
title=""
|
||||||
footer={null}
|
footer={null}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
import CSSMotion from 'rc-motion';
|
import CSSMotion from 'rc-motion';
|
||||||
import { genCSSMotion } from 'rc-motion/lib/CSSMotion';
|
import { genCSSMotion } from 'rc-motion/lib/CSSMotion';
|
||||||
import KeyCode from 'rc-util/lib/KeyCode';
|
import KeyCode from 'rc-util/lib/KeyCode';
|
||||||
import React from 'react';
|
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
|
|
||||||
import Modal from '..';
|
import Modal from '..';
|
||||||
import zhCN from '../../locale/zh_CN';
|
|
||||||
import { fireEvent, render, waitFakeTimer } from '../../../tests/utils';
|
import { fireEvent, render, waitFakeTimer } from '../../../tests/utils';
|
||||||
import Button from '../../button';
|
import Button from '../../button';
|
||||||
import ConfigProvider from '../../config-provider';
|
import ConfigProvider from '../../config-provider';
|
||||||
import Input from '../../input';
|
import Input from '../../input';
|
||||||
|
import zhCN from '../../locale/zh_CN';
|
||||||
import type { ModalFunc } from '../confirm';
|
import type { ModalFunc } from '../confirm';
|
||||||
|
|
||||||
jest.mock('rc-util/lib/Portal');
|
jest.mock('rc-util/lib/Portal');
|
||||||
@ -410,10 +410,55 @@ describe('Modal.hook', () => {
|
|||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('support await', async () => {
|
describe('support await', () => {
|
||||||
|
it('click', async () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
let notReady = true;
|
||||||
|
let lastResult: boolean | null = null;
|
||||||
|
|
||||||
|
const Demo: React.FC = () => {
|
||||||
|
const [modal, contextHolder] = Modal.useModal();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
lastResult = await modal.confirm({
|
||||||
|
content: <Input />,
|
||||||
|
onOk: async () => {
|
||||||
|
if (notReady) {
|
||||||
|
notReady = false;
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return contextHolder;
|
||||||
|
};
|
||||||
|
|
||||||
|
render(<Demo />);
|
||||||
|
|
||||||
|
// Wait for modal show
|
||||||
|
await waitFakeTimer();
|
||||||
|
|
||||||
|
// First time click should not close
|
||||||
|
fireEvent.click(document.querySelector('.ant-btn-primary')!);
|
||||||
|
await waitFakeTimer();
|
||||||
|
expect(lastResult).toBeFalsy();
|
||||||
|
|
||||||
|
// Second time click to close
|
||||||
|
fireEvent.click(document.querySelector('.ant-btn-primary')!);
|
||||||
|
await waitFakeTimer();
|
||||||
|
expect(lastResult).toBeTruthy();
|
||||||
|
|
||||||
|
jest.useRealTimers();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('esc', async () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
let notReady = true;
|
|
||||||
let lastResult: boolean | null = null;
|
let lastResult: boolean | null = null;
|
||||||
|
|
||||||
const Demo: React.FC = () => {
|
const Demo: React.FC = () => {
|
||||||
@ -423,12 +468,6 @@ describe('Modal.hook', () => {
|
|||||||
(async () => {
|
(async () => {
|
||||||
lastResult = await modal.confirm({
|
lastResult = await modal.confirm({
|
||||||
content: <Input />,
|
content: <Input />,
|
||||||
onOk: async () => {
|
|
||||||
if (notReady) {
|
|
||||||
notReady = false;
|
|
||||||
return Promise.reject();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
@ -441,16 +480,13 @@ describe('Modal.hook', () => {
|
|||||||
// Wait for modal show
|
// Wait for modal show
|
||||||
await waitFakeTimer();
|
await waitFakeTimer();
|
||||||
|
|
||||||
// First time click should not close
|
// ESC to close
|
||||||
fireEvent.click(document.querySelector('.ant-btn-primary')!);
|
fireEvent.keyDown(document.querySelector('.ant-modal')!, {
|
||||||
|
key: 'Esc',
|
||||||
|
keyCode: KeyCode.ESC,
|
||||||
|
});
|
||||||
await waitFakeTimer();
|
await waitFakeTimer();
|
||||||
expect(lastResult).toBeFalsy();
|
|
||||||
|
|
||||||
// Second time click to close
|
expect(lastResult).toBe(false);
|
||||||
fireEvent.click(document.querySelector('.ant-btn-primary')!);
|
|
||||||
await waitFakeTimer();
|
|
||||||
expect(lastResult).toBeTruthy();
|
|
||||||
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ export type {
|
|||||||
AntdTreeNodeAttribute,
|
AntdTreeNodeAttribute,
|
||||||
TreeProps,
|
TreeProps,
|
||||||
} from './Tree';
|
} from './Tree';
|
||||||
export type { DataNode };
|
export type { DataNode, BasicDataNode };
|
||||||
|
|
||||||
type CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
|
type CompoundedComponent = (<T extends BasicDataNode | DataNode = DataNode>(
|
||||||
props: React.PropsWithChildren<TreeProps<T>> & { ref?: React.Ref<RcTree> },
|
props: React.PropsWithChildren<TreeProps<T>> & { ref?: React.Ref<RcTree> },
|
||||||
|
Loading…
Reference in New Issue
Block a user