chore: auto merge branches (#49137)

chore: feature merge master
This commit is contained in:
github-actions[bot] 2024-05-30 10:45:03 +00:00 committed by GitHub
commit d4c5cb66de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 1006 additions and 53 deletions

View File

@ -91,13 +91,16 @@ const useStyle = createStyles(({ token, css }) => {
}
.dumi-default-search-popover {
inset-inline-start: 11px;
inset-inline-start: ${token.paddingSM}px;
inset-inline-end: unset;
&::before {
inset-inline-start: 100px;
inset-inline-end: unset;
}
& > section {
scrollbar-width: thin;
scrollbar-color: unset;
}
}
}
`,

View File

@ -4,6 +4,9 @@ name: ✅ test
on: [push, pull_request]
env:
TZ: Asia/Shanghai
# Cancel prev CI if new commit come
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

View File

@ -7,6 +7,9 @@ on:
branches: [master, feature]
types: [opened, synchronize, reopened]
env:
TZ: Asia/Shanghai
# Cancel prev CI if new commit come
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

View File

@ -16,6 +16,18 @@ tag: vVERSION
---
## 5.17.4
`2024-05-27`
- 🐞 Fix Modal with `confirm` would not close correctly when returning `true` in `onOk` or `onCancel`. [#49054](https://github.com/ant-design/ant-design/pull/49054) [@wanpan11](https://github.com/wanpan11)
- 🐞 Fix Carousel was warned about having non-standard DOM attributes by React. [#49031](https://github.com/ant-design/ant-design/pull/49031)
- 🐞 Fix Form prop of `scrollToFirstError` not working for InputNumber. [#48989](https://github.com/ant-design/ant-design/pull/48989) [@Wxh16144](https://github.com/Wxh16144)
- TypeScript
- 🤖 Fix Modal missing `styles.wrapper` type. [#49055](https://github.com/ant-design/ant-design/pull/49055)
- 🤖 Enhance Spin component TypeScript definitions and documentation. [#49036](https://github.com/ant-design/ant-design/pull/49036) [@arvinxx](https://github.com/arvinxx)
- 🤖 Enhance Checkbox.Group TypeScript generic limitation. [#49073](https://github.com/ant-design/ant-design/pull/49073)
## 5.17.3
`2024-05-19`

View File

@ -15,6 +15,18 @@ tag: vVERSION
---
## 5.17.4
`2024-05-27`
- 🐞 修复 Modal 的 `confirm``onOk``onCancel` 中返回 `true` 时,窗体不会正确关闭的问题。[#49054](https://github.com/ant-design/ant-design/pull/49054) [@wanpan11](https://github.com/wanpan11)
- 🐞 修复 Carousel 会被提示存在非标准 dom 属性的问题。[#49031](https://github.com/ant-design/ant-design/pull/49031)
- 🐞 修复 Form 的 `scrollToFirstError` 对 InputNumber 无效的问题。[#48989](https://github.com/ant-design/ant-design/pull/48989) [@Wxh16144](https://github.com/Wxh16144)
- TypeScript
- 🤖 修复 Modal `styles.wrapper` TS 定义丢失的问题。[#49055](https://github.com/ant-design/ant-design/pull/49055)
- 🤖 优化 Spin 的 TypeScript 定义并提供更详细的描述信息。[#49036](https://github.com/ant-design/ant-design/pull/49036) [@arvinxx](https://github.com/arvinxx)
- 🤖 优化 Checkbox.Group 的 TypeScript 类型约束。[#49073](https://github.com/ant-design/ant-design/pull/49073)
## 5.17.3
`2024-05-19`

View File

@ -10,9 +10,7 @@ import type { CheckboxGroupContext } from './GroupContext';
import GroupContext from './GroupContext';
import useStyle from './style';
export type CheckboxValueType = string | number | boolean;
export interface CheckboxOptionType<T extends CheckboxValueType = CheckboxValueType> {
export interface CheckboxOptionType<T = any> {
label: React.ReactNode;
value: T;
style?: React.CSSProperties;
@ -23,7 +21,7 @@ export interface CheckboxOptionType<T extends CheckboxValueType = CheckboxValueT
required?: boolean;
}
export interface AbstractCheckboxGroupProps<T extends CheckboxValueType = CheckboxValueType> {
export interface AbstractCheckboxGroupProps<T = any> {
prefixCls?: string;
className?: string;
rootClassName?: string;
@ -32,8 +30,7 @@ export interface AbstractCheckboxGroupProps<T extends CheckboxValueType = Checkb
style?: React.CSSProperties;
}
export interface CheckboxGroupProps<T extends CheckboxValueType = CheckboxValueType>
extends AbstractCheckboxGroupProps<T> {
export interface CheckboxGroupProps<T = any> extends AbstractCheckboxGroupProps<T> {
name?: string;
defaultValue?: T[];
value?: T[];
@ -41,8 +38,10 @@ export interface CheckboxGroupProps<T extends CheckboxValueType = CheckboxValueT
children?: React.ReactNode;
}
type InternalCheckboxValueType = string | number | boolean;
const CheckboxGroup = React.forwardRef(
<T extends CheckboxValueType = CheckboxValueType>(
<T extends InternalCheckboxValueType = InternalCheckboxValueType>(
props: CheckboxGroupProps<T>,
ref: React.ForwardedRef<HTMLDivElement>,
) => {
@ -168,6 +167,6 @@ const CheckboxGroup = React.forwardRef(
export type { CheckboxGroupContext } from './GroupContext';
export { GroupContext };
export default CheckboxGroup as <T extends CheckboxValueType = CheckboxValueType>(
export default CheckboxGroup as <T = any>(
props: CheckboxGroupProps<T> & React.RefAttributes<HTMLDivElement>,
) => React.ReactElement;

View File

@ -1,8 +1,8 @@
import React from 'react';
import type { CheckboxOptionType, CheckboxValueType } from './Group';
import type { CheckboxOptionType } from './Group';
export interface CheckboxGroupContext<T extends CheckboxValueType = CheckboxValueType> {
export interface CheckboxGroupContext<T = any> {
name?: string;
toggleOption?: (option: CheckboxOptionType<T>) => void;
value?: any;

View File

@ -6,7 +6,6 @@ import { fireEvent, render } from '../../../tests/utils';
import Collapse from '../../collapse';
import Input from '../../input';
import Table from '../../table';
import type { CheckboxValueType } from '../Group';
import type { CheckboxGroupProps } from '../index';
import Checkbox from '../index';
@ -89,7 +88,7 @@ describe('CheckboxGroup', () => {
const renderCheckbox = (props: CheckboxGroupProps) => <Checkbox.Group {...props} />;
const { container, rerender } = render(renderCheckbox({ options }));
expect(container.querySelectorAll('.ant-checkbox-checked').length).toBe(0);
rerender(renderCheckbox({ options, value: 'Apple' as unknown as CheckboxValueType[] }));
rerender(renderCheckbox({ options, value: 'Apple' as any }));
expect(container.querySelectorAll('.ant-checkbox-checked').length).toBe(1);
});

View File

@ -27,4 +27,11 @@ describe('Checkbox.typescript', () => {
);
expect(group).toBeTruthy();
});
it('Checkbox.Group defaultValue', () => {
const defaultValue: React.Key[] = ['1'];
const group = (
<Checkbox.Group options={[{ label: 'test', value: '1' }]} defaultValue={defaultValue} />
);
expect(group).toBeTruthy();
});
});

View File

@ -1,8 +1,6 @@
import React, { useState } from 'react';
import { Checkbox, Divider } from 'antd';
import type { CheckboxProps, GetProp } from 'antd';
type CheckboxValueType = GetProp<typeof Checkbox.Group, 'value'>[number];
import type { CheckboxProps } from 'antd';
const CheckboxGroup = Checkbox.Group;
@ -10,12 +8,12 @@ const plainOptions = ['Apple', 'Pear', 'Orange'];
const defaultCheckedList = ['Apple', 'Orange'];
const App: React.FC = () => {
const [checkedList, setCheckedList] = useState<CheckboxValueType[]>(defaultCheckedList);
const [checkedList, setCheckedList] = useState<string[]>(defaultCheckedList);
const checkAll = plainOptions.length === checkedList.length;
const indeterminate = checkedList.length > 0 && checkedList.length < plainOptions.length;
const onChange = (list: CheckboxValueType[]) => {
const onChange = (list: string[]) => {
setCheckedList(list);
};

View File

@ -51,7 +51,7 @@ Common props ref[Common props](/docs/react/common-props)
| name | The `name` property of all `input[type="checkbox"]` children | string | - | |
| options | Specifies options | string\[] \| number\[] \| Option\[] | \[] | |
| value | Used for setting the currently selected value | (string \| number \| boolean)\[] | \[] | |
| onChange | The callback function that is triggered when the state changes | (checkedValue: CheckboxValueType[]) => void | - | |
| onChange | The callback function that is triggered when the state changes | (checkedValue: T[]) => void | - | |
##### Option

View File

@ -52,7 +52,7 @@ demo:
| name | CheckboxGroup 下所有 `input[type="checkbox"]``name` 属性 | string | - | |
| options | 指定可选项 | string\[] \| number\[] \| Option\[] | \[] | |
| value | 指定选中的选项 | (string \| number \| boolean)\[] | \[] | |
| onChange | 变化时的回调函数 | (checkedValue: CheckboxValueType[]) => void | - | |
| onChange | 变化时的回调函数 | (checkedValue: T[]) => void | - | |
##### Option

View File

@ -7413,6 +7413,711 @@ exports[`renders components/form/demo/form-item-path.tsx extend context correctl
exports[`renders components/form/demo/form-item-path.tsx extend context correctly 2`] = `[]`;
exports[`renders components/form/demo/getValueProps-normalize.tsx extend context correctly 1`] = `
<form
autocomplete="off"
class="ant-form ant-form-horizontal"
id="getValueProps"
style="max-width: 600px;"
>
<div
class="ant-form-item"
>
<div
class="ant-row ant-form-item-row"
>
<div
class="ant-col ant-col-8 ant-form-item-label"
>
<label
class="ant-form-item-required"
for="getValueProps_date"
title="Date"
>
Date
</label>
</div>
<div
class="ant-col ant-col-16 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<div
class="ant-picker ant-picker-outlined"
>
<div
class="ant-picker-input"
>
<input
aria-invalid="false"
aria-required="true"
autocomplete="off"
id="getValueProps_date"
placeholder="Select date"
size="12"
value="2024-05-11"
/>
<span
class="ant-picker-suffix"
>
<span
aria-label="calendar"
class="anticon anticon-calendar"
role="img"
>
<svg
aria-hidden="true"
data-icon="calendar"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"
/>
</svg>
</span>
</span>
<span
class="ant-picker-clear"
role="button"
>
<span
aria-label="close-circle"
class="anticon anticon-close-circle"
role="img"
>
<svg
aria-hidden="true"
data-icon="close-circle"
fill="currentColor"
fill-rule="evenodd"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"
/>
</svg>
</span>
</span>
</div>
</div>
<div
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-picker-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-picker-panel-container ant-picker-date-panel-container"
style="margin-left: 0px; margin-right: auto;"
tabindex="-1"
>
<div
class="ant-picker-panel-layout"
>
<div>
<div
class="ant-picker-panel"
tabindex="0"
>
<div
class="ant-picker-date-panel"
>
<div
class="ant-picker-header"
>
<button
class="ant-picker-header-super-prev-btn"
tabindex="-1"
type="button"
>
<span
class="ant-picker-super-prev-icon"
/>
</button>
<button
class="ant-picker-header-prev-btn"
tabindex="-1"
type="button"
>
<span
class="ant-picker-prev-icon"
/>
</button>
<div
class="ant-picker-header-view"
>
<button
class="ant-picker-month-btn"
tabindex="-1"
type="button"
>
May
</button>
<button
class="ant-picker-year-btn"
tabindex="-1"
type="button"
>
2024
</button>
</div>
<button
class="ant-picker-header-next-btn"
tabindex="-1"
type="button"
>
<span
class="ant-picker-next-icon"
/>
</button>
<button
class="ant-picker-header-super-next-btn"
tabindex="-1"
type="button"
>
<span
class="ant-picker-super-next-icon"
/>
</button>
</div>
<div
class="ant-picker-body"
>
<table
class="ant-picker-content"
>
<thead>
<tr>
<th>
Su
</th>
<th>
Mo
</th>
<th>
Tu
</th>
<th>
We
</th>
<th>
Th
</th>
<th>
Fr
</th>
<th>
Sa
</th>
</tr>
</thead>
<tbody>
<tr>
<td
class="ant-picker-cell"
title="2024-04-28"
>
<div
class="ant-picker-cell-inner"
>
28
</div>
</td>
<td
class="ant-picker-cell"
title="2024-04-29"
>
<div
class="ant-picker-cell-inner"
>
29
</div>
</td>
<td
class="ant-picker-cell"
title="2024-04-30"
>
<div
class="ant-picker-cell-inner"
>
30
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-01"
>
<div
class="ant-picker-cell-inner"
>
1
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-02"
>
<div
class="ant-picker-cell-inner"
>
2
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-03"
>
<div
class="ant-picker-cell-inner"
>
3
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-04"
>
<div
class="ant-picker-cell-inner"
>
4
</div>
</td>
</tr>
<tr>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-05"
>
<div
class="ant-picker-cell-inner"
>
5
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-06"
>
<div
class="ant-picker-cell-inner"
>
6
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-07"
>
<div
class="ant-picker-cell-inner"
>
7
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-08"
>
<div
class="ant-picker-cell-inner"
>
8
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-09"
>
<div
class="ant-picker-cell-inner"
>
9
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-10"
>
<div
class="ant-picker-cell-inner"
>
10
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-hover ant-picker-cell-selected ant-picker-cell-in-view"
title="2024-05-11"
>
<div
class="ant-picker-cell-inner"
>
11
</div>
</td>
</tr>
<tr>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-12"
>
<div
class="ant-picker-cell-inner"
>
12
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-13"
>
<div
class="ant-picker-cell-inner"
>
13
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-14"
>
<div
class="ant-picker-cell-inner"
>
14
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-15"
>
<div
class="ant-picker-cell-inner"
>
15
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-16"
>
<div
class="ant-picker-cell-inner"
>
16
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-17"
>
<div
class="ant-picker-cell-inner"
>
17
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-18"
>
<div
class="ant-picker-cell-inner"
>
18
</div>
</td>
</tr>
<tr>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-19"
>
<div
class="ant-picker-cell-inner"
>
19
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-20"
>
<div
class="ant-picker-cell-inner"
>
20
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-21"
>
<div
class="ant-picker-cell-inner"
>
21
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-22"
>
<div
class="ant-picker-cell-inner"
>
22
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-23"
>
<div
class="ant-picker-cell-inner"
>
23
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-24"
>
<div
class="ant-picker-cell-inner"
>
24
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-25"
>
<div
class="ant-picker-cell-inner"
>
25
</div>
</td>
</tr>
<tr>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-26"
>
<div
class="ant-picker-cell-inner"
>
26
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-27"
>
<div
class="ant-picker-cell-inner"
>
27
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-28"
>
<div
class="ant-picker-cell-inner"
>
28
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-29"
>
<div
class="ant-picker-cell-inner"
>
29
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-30"
>
<div
class="ant-picker-cell-inner"
>
30
</div>
</td>
<td
class="ant-picker-cell ant-picker-cell-in-view"
title="2024-05-31"
>
<div
class="ant-picker-cell-inner"
>
31
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-01"
>
<div
class="ant-picker-cell-inner"
>
1
</div>
</td>
</tr>
<tr>
<td
class="ant-picker-cell"
title="2024-06-02"
>
<div
class="ant-picker-cell-inner"
>
2
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-03"
>
<div
class="ant-picker-cell-inner"
>
3
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-04"
>
<div
class="ant-picker-cell-inner"
>
4
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-05"
>
<div
class="ant-picker-cell-inner"
>
5
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-06"
>
<div
class="ant-picker-cell-inner"
>
6
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-07"
>
<div
class="ant-picker-cell-inner"
>
7
</div>
</td>
<td
class="ant-picker-cell"
title="2024-06-08"
>
<div
class="ant-picker-cell-inner"
>
8
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class="ant-picker-footer"
>
<ul
class="ant-picker-ranges"
>
<li
class="ant-picker-now"
>
<a
aria-disabled="false"
class="ant-picker-now-btn"
>
Today
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="ant-form-item"
>
<div
class="ant-row ant-form-item-row"
>
<div
class="ant-col ant-col-16 ant-col-offset-8 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<button
class="ant-btn ant-btn-primary"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</form>
`;
exports[`renders components/form/demo/getValueProps-normalize.tsx extend context correctly 2`] = `[]`;
exports[`renders components/form/demo/global-state.tsx extend context correctly 1`] = `
Array [
<form

View File

@ -4340,6 +4340,140 @@ exports[`renders components/form/demo/form-item-path.tsx correctly 1`] = `
</form>
`;
exports[`renders components/form/demo/getValueProps-normalize.tsx correctly 1`] = `
<form
autocomplete="off"
class="ant-form ant-form-horizontal"
id="getValueProps"
style="max-width:600px"
>
<div
class="ant-form-item"
>
<div
class="ant-row ant-form-item-row"
>
<div
class="ant-col ant-col-8 ant-form-item-label"
>
<label
class="ant-form-item-required"
for="getValueProps_date"
title="Date"
>
Date
</label>
</div>
<div
class="ant-col ant-col-16 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<div
class="ant-picker ant-picker-outlined"
>
<div
class="ant-picker-input"
>
<input
aria-invalid="false"
aria-required="true"
autocomplete="off"
id="getValueProps_date"
placeholder="Select date"
size="12"
value="2024-05-11"
/>
<span
class="ant-picker-suffix"
>
<span
aria-label="calendar"
class="anticon anticon-calendar"
role="img"
>
<svg
aria-hidden="true"
data-icon="calendar"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"
/>
</svg>
</span>
</span>
<span
class="ant-picker-clear"
role="button"
>
<span
aria-label="close-circle"
class="anticon anticon-close-circle"
role="img"
>
<svg
aria-hidden="true"
data-icon="close-circle"
fill="currentColor"
fill-rule="evenodd"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"
/>
</svg>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="ant-form-item"
>
<div
class="ant-row ant-form-item-row"
>
<div
class="ant-col ant-col-16 ant-col-offset-8 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<button
class="ant-btn ant-btn-primary"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</form>
`;
exports[`renders components/form/demo/global-state.tsx correctly 1`] = `
Array [
<form

View File

@ -0,0 +1,7 @@
## zh-CN
配合 `getValueProps``normalize`,可以转换 `value` 的格式,如将时间戳转成 `dayjs` 对象再传给 `DatePicker`
## en-US
By combining `getValueProps` and `normalize`, it is possible to convert the format of `value`, such as converting the timestamp into a `dayjs` object and then passing it to the `DatePicker`.

View File

@ -0,0 +1,42 @@
import React from 'react';
import type { FormProps } from 'antd';
import { Button, DatePicker, Form } from 'antd';
import dayjs from 'dayjs';
type FieldType = {
date?: string;
};
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
console.log('Success:', values);
};
const App: React.FC = () => (
<Form
name="getValueProps"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
style={{ maxWidth: 600 }}
initialValues={{ date: '1715356800000' }}
onFinish={onFinish}
autoComplete="off"
>
<Form.Item<FieldType>
label="Date"
name="date"
rules={[{ required: true }]}
getValueProps={(value) => ({ value: value && dayjs(Number(value)) })}
normalize={(value) => value && `${dayjs(value).valueOf()}`}
>
<DatePicker />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
);
export default App;

View File

@ -47,6 +47,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ylFATY6w-ygAAA
<code src="./demo/validate-static.tsx">Customized Validation</code>
<code src="./demo/dynamic-rule.tsx">Dynamic Rules</code>
<code src="./demo/form-dependencies.tsx">Dependencies</code>
<code src="./demo/getValueProps-normalize.tsx">getValueProps + normalize</code>
<code src="./demo/validate-scroll-to-field.tsx" iframe="360">Slide to error field</code>
<code src="./demo/validate-other.tsx">Other Form Controls</code>
<code src="./demo/disabled-input-debug.tsx" debug>Disabled Input Debug</code>

View File

@ -50,6 +50,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ylFATY6w-ygAAA
<code src="./demo/form-dependencies.tsx">校验与更新依赖</code>
<code src="./demo/validate-scroll-to-field.tsx" iframe="360">滑动到错误字段</code>
<code src="./demo/validate-other.tsx">校验其他组件</code>
<code src="./demo/getValueProps-normalize.tsx">getValueProps + normalize</code>
<code src="./demo/disabled-input-debug.tsx" debug>Disabled Input Debug</code>
<code src="./demo/label-debug.tsx" debug>测试 label 省略</code>
<code src="./demo/col-24-debug.tsx" debug>测试特殊 col 24 用法</code>

View File

@ -57,7 +57,7 @@ return (
<code src="./demo/variant.tsx" version="5.13.0">Variants</code>
<code src="./demo/filled-debug.tsx" debug>Filled debug</code>
<code src="./demo/custom-tag-render.tsx">Custom Tag Render</code>
<code src="./demo/custom-label-render.tsx">Custom selectd Label render</code>
<code src="./demo/custom-label-render.tsx">Custom Selected Label Render</code>
<code src="./demo/responsive.tsx">Responsive maxTagCount</code>
<code src="./demo/big-data.tsx">Big Data</code>
<code src="./demo/status.tsx">Status</code>

View File

@ -565,6 +565,31 @@ describe('Tour', () => {
expect(document.querySelector('.should-be-primary')).toHaveClass('ant-tour-primary');
});
// https://github.com/ant-design/ant-design/issues/49117
it('onClose current is correct', () => {
const onClose = jest.fn();
const { container } = render(
<Tour
onClose={onClose}
open
steps={[
{
title: '',
description: '',
type: 'primary',
className: 'should-be-primary',
},
{
title: '',
},
]}
/>,
);
fireEvent.click(container.querySelector('.ant-tour-next-btn')!);
fireEvent.click(container.querySelector('.ant-tour-close-icon')!);
expect(onClose).toHaveBeenLastCalledWith(1);
});
// This test is for PurePanel which means safe to remove.
describe('PurePanel', () => {
const PurePanel = Tour._InternalPanelDoNotUseOrYouWillBeFired;

View File

@ -44,19 +44,11 @@ const TourPanel: React.FC<TourPanelProps> = (props) => {
const mergedType = stepType ?? type;
const mergedCloseIcon = React.useMemo(() => {
let defaultCloseIcon: React.ReactNode = <CloseOutlined className={`${prefixCls}-close-icon`} />;
if (closable && closable.closeIcon) {
defaultCloseIcon = closable.closeIcon;
}
return (
<button type="button" onClick={onClose} className={`${prefixCls}-close`}>
{defaultCloseIcon}
</button>
);
}, [closable]);
const mergedCloseIcon = (
<button type="button" onClick={onClose} className={`${prefixCls}-close`}>
{closable?.closeIcon || <CloseOutlined className={`${prefixCls}-close-icon`} />}
</button>
);
const isLastStep = current === total - 1;

View File

@ -105,21 +105,16 @@ antd 内部会对 props 进行浅比较实现性能优化。当状态变更,
## `antd` 是否有国内镜像?
有的,你可以访问 https://ant-design.antgroup.com/index-cn 或 https://ant-design.gitee.io/index-cn
有的,你可以访问 https://ant-design.antgroup.com/index-cn 。
| 产品/版本 | 地址 |
| --- | --- |
| Ant Design 5.x | https://ant-design.antgroup.com <br /> https://ant-design.gitee.io |
| Ant Design 5.x | https://ant-design.antgroup.com |
| Ant Design 4.x | https://4x-ant-design.antgroup.com |
| Ant Design 3.x | https://ant-design-3x.gitee.io |
| Ant Design 2.x | https://ant-design-2x.gitee.io |
| Ant Design 1.x | https://ant-design-1x.gitee.io |
| Ant Design Pro | https://ant-design-pro.gitee.io/ |
| Ant Design Mobile | https://ant-design-mobile.antgroup.com/zh <br /> https://antd-mobile.gitee.io/ |
| Ant Design Mini | https://ant-design-mini.antgroup.com <br /> https://antd-mobile.gitee.io/ |
| Ant Design Charts | https://ant-design-charts.antgroup.com<br /> https://antd-mobile.gitee.io/ |
| Ant Design Mobile | https://ant-design-mobile.antgroup.com/zh |
| Ant Design Mini | https://ant-design-mini.antgroup.com |
| Ant Design Charts | https://ant-design-charts.antgroup.com |
| AntV | https://antv.antgroup.com |
| Ant Motion | https://ant-motion.gitee.io |
## `antd` 可以像 `React` 那样使用单文件引入吗?

View File

@ -135,4 +135,4 @@ return (
## i18n 项目示例
你可以参考 [Ant Design Pro 国际化文档](https://pro.ant.design/docs/i18n-cn) 查看完整的国际化项目示例。
你可以参考 [Ant Design Pro 国际化文档](https://pro.ant.design/zh-CN/docs/i18n) 查看完整的国际化项目示例。

View File

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "5.17.3",
"version": "5.17.4",
"description": "An enterprise-class UI design language and React components implementation",
"keywords": [
"ant",
@ -26,13 +26,23 @@
"url": "https://opencollective.com/ant-design"
},
"license": "MIT",
"contributors": ["ant"],
"sideEffects": ["*.css"],
"contributors": [
"ant"
],
"sideEffects": [
"*.css"
],
"main": "lib/index.js",
"unpkg": "dist/antd.min.js",
"module": "es/index.js",
"typings": "es/index.d.ts",
"files": ["dist", "es", "lib", "locale", "BUG_VERSIONS.json"],
"files": [
"dist",
"es",
"lib",
"locale",
"BUG_VERSIONS.json"
],
"scripts": {
"api-collection": "antd-tools run api-collection",
"authors": "tsx scripts/generate-authors.ts",
@ -99,7 +109,12 @@
"*.{ts,tsx,js,jsx}": "biome format --write",
"*.{json,less,md}": "prettier --ignore-unknown --write"
},
"browserslist": ["> 0.5%", "last 2 versions", "Firefox ESR", "not dead"],
"browserslist": [
"> 0.5%",
"last 2 versions",
"Firefox ESR",
"not dead"
],
"dependencies": {
"@ant-design/colors": "^7.0.2",
"@ant-design/cssinjs": "^1.19.1",
@ -110,7 +125,7 @@
"@rc-component/color-picker": "~1.5.3",
"@rc-component/mutate-observer": "^1.1.0",
"@rc-component/tour": "~1.15.0",
"@rc-component/trigger": "^2.1.1",
"@rc-component/trigger": "^2.2.0",
"classnames": "^2.5.1",
"copy-to-clipboard": "^3.3.3",
"dayjs": "^1.11.10",
@ -139,7 +154,7 @@
"rc-slider": "~10.6.2",
"rc-steps": "~6.0.1",
"rc-switch": "~4.1.0",
"rc-table": "~7.45.6",
"rc-table": "~7.45.7",
"rc-tabs": "~15.1.0",
"rc-textarea": "~1.7.0",
"rc-tooltip": "~6.2.0",