diff --git a/README-zh_CN.md b/README-zh_CN.md index 71c26a3921a6..1d9e5c6e417c 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -78,6 +78,10 @@ npm install antd --save yarn add antd ``` +```bash +pnpm add antd +``` + ## 🔨 示例 ```jsx diff --git a/README.md b/README.md index 954eb3e7d830..82971f3c6632 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,10 @@ npm install antd yarn add antd ``` +```bash +pnpm add antd +``` + ## 🔨 Usage ```jsx diff --git a/components/avatar/style/index.ts b/components/avatar/style/index.ts index 66f4a9547310..1b363bc3cb5e 100644 --- a/components/avatar/style/index.ts +++ b/components/avatar/style/index.ts @@ -5,8 +5,8 @@ import { genComponentStyleHook, mergeToken } from '../../theme/internal'; export interface ComponentToken { /** - * @desc 头像背景色 - * @descEN Background color of Avatar + * @desc 头像尺寸 + * @descEN Size of Avatar */ containerSize: number; /** diff --git a/components/date-picker/style/index.ts b/components/date-picker/style/index.ts index a6e1917b25e2..932087d11805 100644 --- a/components/date-picker/style/index.ts +++ b/components/date-picker/style/index.ts @@ -1,5 +1,6 @@ import type { CSSObject } from '@ant-design/cssinjs'; import { TinyColor } from '@ctrl/tinycolor'; + import type { SharedComponentToken, SharedInputToken } from '../../input/style'; import { genActiveStyle, @@ -682,7 +683,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => { textAlign: 'center', '&-extra': { - padding: `0 ${paddingSM}`, + padding: `0 ${paddingSM}px`, lineHeight: `${textHeight - 2 * lineWidth}px`, textAlign: 'start', diff --git a/components/modal/ConfirmDialog.tsx b/components/modal/ConfirmDialog.tsx index d3edbb6be92d..8b038f642eed 100644 --- a/components/modal/ConfirmDialog.tsx +++ b/components/modal/ConfirmDialog.tsx @@ -181,6 +181,7 @@ const ConfirmDialog: React.FC = (props) => { closeIcon, modalRender, focusTriggerAfterClose, + onConfirm, } = props; if (process.env.NODE_ENV !== 'production') { @@ -220,7 +221,10 @@ const ConfirmDialog: React.FC = (props) => { { [`${confirmPrefixCls}-centered`]: !!props.centered }, wrapClassName, )} - onCancel={() => close?.({ triggerCancel: true })} + onCancel={() => { + close?.({ triggerCancel: true }); + onConfirm?.(false); + }} open={open} title="" footer={null} diff --git a/components/modal/__tests__/hook.test.tsx b/components/modal/__tests__/hook.test.tsx index afd5ec2a54bf..3ed782691a6a 100644 --- a/components/modal/__tests__/hook.test.tsx +++ b/components/modal/__tests__/hook.test.tsx @@ -1,15 +1,15 @@ +import React from 'react'; import CSSMotion from 'rc-motion'; import { genCSSMotion } from 'rc-motion/lib/CSSMotion'; import KeyCode from 'rc-util/lib/KeyCode'; -import React from 'react'; import { act } from 'react-dom/test-utils'; import Modal from '..'; -import zhCN from '../../locale/zh_CN'; import { fireEvent, render, waitFakeTimer } from '../../../tests/utils'; import Button from '../../button'; import ConfigProvider from '../../config-provider'; import Input from '../../input'; +import zhCN from '../../locale/zh_CN'; import type { ModalFunc } from '../confirm'; jest.mock('rc-util/lib/Portal'); @@ -410,10 +410,55 @@ describe('Modal.hook', () => { 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: , + onOk: async () => { + if (notReady) { + notReady = false; + return Promise.reject(); + } + }, + }); + })(); + }, []); + + return contextHolder; + }; + + render(); + + // 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(); - let notReady = true; let lastResult: boolean | null = null; const Demo: React.FC = () => { @@ -423,12 +468,6 @@ describe('Modal.hook', () => { (async () => { lastResult = await modal.confirm({ content: , - onOk: async () => { - if (notReady) { - notReady = false; - return Promise.reject(); - } - }, }); })(); }, []); @@ -441,16 +480,13 @@ describe('Modal.hook', () => { // 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')!); + // ESC to close + fireEvent.keyDown(document.querySelector('.ant-modal')!, { + key: 'Esc', + keyCode: KeyCode.ESC, + }); await waitFakeTimer(); - expect(lastResult).toBeTruthy(); - jest.useRealTimers(); + expect(lastResult).toBe(false); }); }); diff --git a/components/tree/index.ts b/components/tree/index.ts index dc7b1bbf5de2..993ae886e029 100644 --- a/components/tree/index.ts +++ b/components/tree/index.ts @@ -22,7 +22,7 @@ export type { AntdTreeNodeAttribute, TreeProps, } from './Tree'; -export type { DataNode }; +export type { DataNode, BasicDataNode }; type CompoundedComponent = (( props: React.PropsWithChildren> & { ref?: React.Ref },