From 03fee8d837e463a5bd864c939da5766050dd380d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Tue, 5 Sep 2023 13:43:15 +0800 Subject: [PATCH 1/5] feat: export BasicDataNode type from tree (#44624) --- components/tree/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }, From 49e1efaafc302eb0cfafc69a057fabae9b002219 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Tue, 5 Sep 2023 18:51:51 +0800 Subject: [PATCH 2/5] fix: fix date-picker footer style (#44642) * fix: fix date-picker style * Update index.ts Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> --- components/date-picker/style/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/date-picker/style/index.ts b/components/date-picker/style/index.ts index 62ef3f039d5b..1a79222045b8 100644 --- a/components/date-picker/style/index.ts +++ b/components/date-picker/style/index.ts @@ -625,7 +625,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => { textAlign: 'center', '&-extra': { - padding: `0 ${paddingSM}`, + padding: `0 ${paddingSM}px`, lineHeight: `${pickerTextHeight - 2 * lineWidth}px`, textAlign: 'start', From 1b61870c5d16b93a6176f2c5beb16ab3f23c004f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Tue, 5 Sep 2023 21:36:21 +0800 Subject: [PATCH 3/5] fix: Modal hooks press esc can not trigger await (#44646) * test: test driven * fix: await missing esc --- components/modal/ConfirmDialog.tsx | 11 +++- components/modal/__tests__/hook.test.tsx | 74 ++++++++++++++++++------ 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/components/modal/ConfirmDialog.tsx b/components/modal/ConfirmDialog.tsx index ca9dd2f7db14..cd014a0f4cdb 100644 --- a/components/modal/ConfirmDialog.tsx +++ b/components/modal/ConfirmDialog.tsx @@ -1,17 +1,18 @@ +import * as React from 'react'; import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled'; import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled'; import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled'; import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled'; import classNames from 'classnames'; -import * as React from 'react'; + import ActionButton from '../_util/ActionButton'; import { getTransitionName } from '../_util/motion'; import warning from '../_util/warning'; import type { ThemeConfig } from '../config-provider'; import ConfigProvider from '../config-provider'; import { useLocale } from '../locale'; -import Dialog from './Modal'; import type { ModalFuncProps, ModalLocale } from './interface'; +import Dialog from './Modal'; interface ConfirmDialogProps extends ModalFuncProps { afterClose?: () => void; @@ -172,6 +173,7 @@ const ConfirmDialog: React.FC = (props) => { closeIcon, modalRender, focusTriggerAfterClose, + onConfirm, } = props; if (process.env.NODE_ENV !== 'production') { @@ -211,7 +213,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); }); }); From 002382c85f385a1ae0b728daf4ee815269614d7c Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 5 Sep 2023 23:15:20 +0800 Subject: [PATCH 4/5] chore: install using pnpm (#44639) --- README-zh_CN.md | 4 ++++ README.md | 4 ++++ 2 files changed, 8 insertions(+) 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 From dff3c63e1cd9bb000a5595ba44ef738874936432 Mon Sep 17 00:00:00 2001 From: Victor Ye Date: Tue, 5 Sep 2023 23:19:06 +0800 Subject: [PATCH 5/5] docs: fix wrong description about Avatar's Design Token (#44634) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 叶宇轩 <--global> --- components/avatar/style/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; /**