chore: auto merge branches (#41692)

chore: merge master into feature
This commit is contained in:
github-actions[bot] 2023-04-07 02:45:51 +00:00 committed by GitHub
commit d7bafd4f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 982 additions and 86 deletions

View File

@ -1964,7 +1964,11 @@ exports[`renders components/badge/demo/ribbon.tsx extend context correctly 1`] =
<span
class="ant-ribbon-text"
>
Hippies
<div>
Hippies
<br />
Happy
</div>
</span>
<div
class="ant-ribbon-corner"

View File

@ -1965,7 +1965,11 @@ exports[`renders components/badge/demo/ribbon.tsx correctly 1`] = `
<span
class="ant-ribbon-text"
>
Hippies
<div>
Hippies
<br />
Happy
</div>
</span>
<div
class="ant-ribbon-corner"

View File

@ -8,7 +8,12 @@ const App: React.FC = () => (
and raises the spyglass.
</Card>
</Badge.Ribbon>
<Badge.Ribbon text="Hippies" color="pink">
<Badge.Ribbon text={
<div>
Hippies <br />
Happy
</div>
} color="pink">
<Card title="Pushes open the window" size="small">
and raises the spyglass.
</Card>

View File

@ -284,7 +284,6 @@ const genSharedBadgeStyle: GenerateStyle<BadgeToken> = (token: BadgeToken): CSSO
...resetComponent(token),
position: 'absolute',
top: marginXS,
height: badgeFontHeight,
padding: `0 ${token.paddingXS}px`,
color: token.colorPrimary,
lineHeight: `${badgeFontHeight}px`,

View File

@ -2,19 +2,18 @@
import classNames from 'classnames';
import omit from 'rc-util/lib/omit';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import DisabledContext from '../config-provider/DisabledContext';
import SizeContext from '../config-provider/SizeContext';
import { useCompactItemContext } from '../space/Compact';
import warning from '../_util/warning';
import Wave from '../_util/wave';
import Group, { GroupSizeContext } from './button-group';
import { isTwoCNChar, isUnBorderedButtonType, spaceChildren } from './buttonHelpers';
import LoadingIcon from './LoadingIcon';
import useStyle from './style';
import { ConfigContext } from '../config-provider';
import DisabledContext from '../config-provider/DisabledContext';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import { useCompactItemContext } from '../space/Compact';
import LoadingIcon from './LoadingIcon';
import Group, { GroupSizeContext } from './button-group';
import type { ButtonHTMLType, ButtonShape, ButtonType } from './buttonHelpers';
import { isTwoCNChar, isUnBorderedButtonType, spaceChildren } from './buttonHelpers';
import useStyle from './style';
export type LegacyButtonType = ButtonType | 'danger';
@ -39,6 +38,7 @@ export interface BaseButtonProps {
danger?: boolean;
block?: boolean;
children?: React.ReactNode;
[key: `data-${string}`]: string;
}
export type AnchorButtonProps = {
@ -201,7 +201,7 @@ const InternalButton: React.ForwardRefRenderFunction<
const iconType = innerLoading ? 'loading' : icon;
const linkButtonRestProps = omit(rest as AnchorButtonProps & { navigate: any }, ['navigate']);
const linkButtonRestProps = omit(rest as ButtonProps & { navigate: any }, ['navigate']);
const hrefAndDisabled = linkButtonRestProps.href !== undefined && mergedDisabled;

View File

@ -52,6 +52,7 @@ export default function ItemHolder(props: ItemHolderProps) {
hidden,
children,
fieldId,
required,
isRequired,
onSubItemMetaChange,
...restProps
@ -171,7 +172,6 @@ export default function ItemHolder(props: ItemHolderProps) {
'normalize',
'noStyle',
'preserve',
'required',
'requiredMark',
'rules',
'shouldUpdate',
@ -186,9 +186,9 @@ export default function ItemHolder(props: ItemHolderProps) {
{/* Label */}
<FormItemLabel
htmlFor={fieldId}
required={isRequired}
requiredMark={requiredMark}
{...props}
required={required ?? isRequired}
prefixCls={prefixCls}
/>
{/* Input Group */}

View File

@ -1736,6 +1736,20 @@ describe('Form', () => {
expect(container.querySelector('.ant-form-item-has-error')).toBeTruthy();
});
// https://github.com/ant-design/ant-design/issues/41621
it('should not override value when pass `undefined` to require', async () => {
// When require is `undefined`, the `isRequire` calculation logic should be preserved
const { container } = render(
<Form>
<Form.Item label="test" name="success" required={undefined} rules={[{ required: true }]}>
<Input />
</Form.Item>
</Form>,
);
expect(container.querySelector('.ant-form-item-required')).toBeTruthy();
});
it('validate status should be change in order', async () => {
const onChange = jest.fn();

View File

@ -3,8 +3,8 @@ import { act } from 'react-dom/test-utils';
import { Col, Row } from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { fireEvent, render } from '../../../tests/utils';
import useBreakpoint from '../hooks/useBreakpoint';
import { render, fireEvent } from '../../../tests/utils';
// Mock for `responsiveObserve` to test `unsubscribe` call
jest.mock('../../_util/responsiveObserver', () => {
@ -232,4 +232,17 @@ describe('Grid', () => {
});
expect(container.innerHTML).toContain('ant-row-end');
});
it('The column spacing should be evenly spaced', () => {
const { container } = render(
<Row justify="space-evenly">
<Col span={4}>col-1</Col>
<Col span={4}>col-2</Col>
</Row>,
);
const row = container.querySelector('.ant-row-space-evenly');
expect(row).toBeTruthy();
expect(row && getComputedStyle(row).justifyContent).toEqual('space-evenly');
});
});

View File

@ -46,10 +46,14 @@ const genGridRowStyle: GenerateStyle<GridRowToken> = (token): CSSObject => {
justifyContent: 'space-between',
},
'&-space-around ': {
'&-space-around': {
justifyContent: 'space-around',
},
'&-space-evenly': {
justifyContent: 'space-evenly',
},
// Align at the top
'&-top': {
alignItems: 'flex-start',

View File

@ -33,6 +33,8 @@ const genMentionsStyle: GenerateStyle<MentionsToken> = (token) => {
inputPaddingVertical,
fontSize,
colorBgElevated,
paddingXXS,
borderRadius,
borderRadiusLG,
boxShadowSecondary,
} = token;
@ -143,6 +145,7 @@ const genMentionsStyle: GenerateStyle<MentionsToken> = (token) => {
boxSizing: 'border-box',
fontSize,
fontVariant: 'initial',
padding: paddingXXS,
backgroundColor: colorBgElevated,
borderRadius: borderRadiusLG,
outline: 'none',
@ -154,7 +157,7 @@ const genMentionsStyle: GenerateStyle<MentionsToken> = (token) => {
[`${componentCls}-dropdown-menu`]: {
maxHeight: token.dropdownHeight,
marginBottom: 0,
margin: 0,
paddingInlineStart: 0, // Override default ul/ol
overflow: 'auto',
listStyle: 'none',
@ -167,6 +170,7 @@ const genMentionsStyle: GenerateStyle<MentionsToken> = (token) => {
minWidth: token.controlItemWidth,
padding: `${itemPaddingVertical}px ${controlPaddingHorizontal}px`,
color: colorText,
borderRadius,
fontWeight: 'normal',
lineHeight,
cursor: 'pointer',
@ -176,20 +180,6 @@ const genMentionsStyle: GenerateStyle<MentionsToken> = (token) => {
backgroundColor: controlItemBgHover,
},
'&:first-child': {
borderStartStartRadius: borderRadiusLG,
borderStartEndRadius: borderRadiusLG,
borderEndStartRadius: 0,
borderEndEndRadius: 0,
},
'&:last-child': {
borderStartStartRadius: 0,
borderStartEndRadius: 0,
borderEndStartRadius: borderRadiusLG,
borderEndEndRadius: borderRadiusLG,
},
'&-disabled': {
color: colorTextDisabled,
cursor: 'not-allowed',

View File

@ -5,7 +5,7 @@ import Draggable from 'react-draggable';
const App: React.FC = () => {
const [open, setOpen] = useState(false);
const [disabled, setDisabled] = useState(false);
const [disabled, setDisabled] = useState(true);
const [bounds, setBounds] = useState({ left: 0, top: 0, bottom: 0, right: 0 });
const draggleRef = useRef<HTMLDivElement>(null);

View File

@ -61,7 +61,7 @@ The properties of config are as follows:
| top | Distance from the top of the viewport, when `placement` is `topRight` or `topLeft` (unit: pixels) | number | 24 |
| onClick | Specify a function that will be called when the notification is clicked | function | - |
| onClose | Trigger when notification closed | function | - |
| props | Props passed down | Object | An object that can contain `data-*`, `aria-*`, or `role` props, to be put on the notification `div`. This currently only allows `data-testid` instead of `data-*` in TypeScript. See https://github.com/microsoft/TypeScript/issues/28960. |
| props | An object that can contain `data-*`, `aria-*`, or `role` props, to be put on the notification `div`. This currently only allows `data-testid` instead of `data-*` in TypeScript. See https://github.com/microsoft/TypeScript/issues/28960. | Object | - |
`notification` also provides a global `config()` method that can be used for specifying the default options. Once this method is used, all the notification boxes will take into account these globally defined options when displaying.

View File

@ -62,6 +62,7 @@ config 参数如下:
| top | 消息从顶部弹出时,距离顶部的位置,单位像素 | number | 24 |
| onClick | 点击通知时触发的回调函数 | function | - |
| onClose | 当通知关闭时触发 | function | - |
| props | 透传至通知 `div` 上的 props 对象,支持传入 `data-*` `aria-*``role` 作为对象的属性。需要注意的是,虽然在 TypeScript 类型中声明的类型支持传入 `data-*` 作为对象的属性,但目前只允许传入 `data-testid` 作为对象的属性。 详见 https://github.com/microsoft/TypeScript/issues/28960 | Object | - |
### 全局配置

View File

@ -1,24 +1,26 @@
import classNames from 'classnames';
import { convertChildrenToColumns } from 'rc-table/lib/hooks/useColumns';
import type { TableProps as RcTableProps } from 'rc-table/lib/Table';
import { INTERNAL_HOOKS } from 'rc-table/lib/Table';
import { convertChildrenToColumns } from 'rc-table/lib/hooks/useColumns';
import omit from 'rc-util/lib/omit';
import * as React from 'react';
import type { Breakpoint } from '../_util/responsiveObserver';
import scrollTo from '../_util/scrollTo';
import warning from '../_util/warning';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import type { ConfigConsumerProps } from '../config-provider/context';
import { ConfigContext } from '../config-provider/context';
import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import useBreakpoint from '../grid/hooks/useBreakpoint';
import defaultLocale from '../locale/en_US';
import Pagination from '../pagination';
import type { SpinProps } from '../spin';
import Spin from '../spin';
import type { TooltipProps } from '../tooltip';
import type { Breakpoint } from '../_util/responsiveObserver';
import scrollTo from '../_util/scrollTo';
import warning from '../_util/warning';
import renderExpandIcon from './ExpandIcon';
import RcTable from './RcTable';
import type { AnyObject } from './Table';
import type { FilterState } from './hooks/useFilter';
import useFilter, { getFilterData } from './hooks/useFilter';
import useLazyKVMap from './hooks/useLazyKVMap';
@ -28,25 +30,23 @@ import type { SortState } from './hooks/useSorter';
import useSorter, { getSortData } from './hooks/useSorter';
import useTitleColumns from './hooks/useTitleColumns';
import type {
ColumnsType,
ColumnTitleProps,
ColumnType,
ExpandableConfig,
ColumnsType,
ExpandType,
ExpandableConfig,
FilterValue,
GetPopupContainer,
GetRowKey,
RefInternalTable,
SorterResult,
SortOrder,
SorterResult,
TableAction,
TableCurrentDataSource,
TableLocale,
TablePaginationConfig,
TableRowSelection,
} from './interface';
import RcTable from './RcTable';
import useStyle from './style';
export type { ColumnsType, TablePaginationConfig };
@ -110,11 +110,10 @@ export interface TableProps<RecordType>
showSorterTooltip?: boolean | TooltipProps;
}
function InternalTable<RecordType extends object = any>(
const InternalTable = <RecordType extends AnyObject = any>(
props: InternalTableProps<RecordType>,
ref: React.MutableRefObject<HTMLDivElement>,
) {
const { getPopupContainer: getContextPopupContainer } = React.useContext(ConfigContext);
) => {
const {
prefixCls: customizePrefixCls,
className,
@ -181,6 +180,7 @@ function InternalTable<RecordType extends object = any>(
direction,
renderEmpty,
getPrefixCls,
getPopupContainer: getContextPopupContainer,
} = React.useContext<ConfigConsumerProps>(ConfigContext);
const mergedSize = customizeSize || size;
@ -560,6 +560,6 @@ function InternalTable<RecordType extends object = any>(
</Spin>
</div>,
);
}
};
export default React.forwardRef(InternalTable) as RefInternalTable;

View File

@ -1,28 +1,29 @@
import { EXPAND_COLUMN, Summary } from 'rc-table';
import * as React from 'react';
import { Summary, EXPAND_COLUMN } from 'rc-table';
import Column from './Column';
import ColumnGroup from './ColumnGroup';
import InternalTable from './InternalTable';
import type { TableProps } from './InternalTable';
import type { RefTable } from './interface';
import InternalTable from './InternalTable';
import {
SELECTION_ALL,
SELECTION_COLUMN,
SELECTION_INVERT,
SELECTION_NONE,
} from './hooks/useSelection';
import type { RefTable } from './interface';
function Table<RecordType extends object = any>(
export type AnyObject = Record<PropertyKey, any>;
const Table = <RecordType extends AnyObject = any>(
props: TableProps<RecordType>,
ref: React.Ref<HTMLDivElement>,
) {
) => {
const renderTimesRef = React.useRef(0);
renderTimesRef.current += 1;
return <InternalTable<RecordType> {...props} ref={ref} _renderTimes={renderTimesRef.current} />;
}
};
const ForwardTable = React.forwardRef(Table) as any as RefTable & {
const ForwardTable = React.forwardRef(Table) as unknown as RefTable & {
SELECTION_COLUMN: typeof SELECTION_COLUMN;
EXPAND_COLUMN: typeof EXPAND_COLUMN;
SELECTION_ALL: typeof SELECTION_ALL;

View File

@ -25853,6 +25853,475 @@ Array [
]
`;
exports[`renders components/table/demo/selections-debug.tsx extend context correctly 1`] = `
<div
class="ant-table-wrapper"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-table ant-table-bordered"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
>
<table
style="table-layout: auto;"
>
<colgroup>
<col
class="ant-table-selection-col ant-table-selection-col-with-dropdown"
/>
</colgroup>
<thead
class="ant-table-thead"
>
<tr>
<th
class="ant-table-cell ant-table-selection-column"
scope="col"
>
<div
class="ant-table-selection"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
aria-label="Custom selection"
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<div
class="ant-table-selection-extra"
>
<span
class="ant-dropdown-trigger"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</span>
<div>
<div
class="ant-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up"
style="opacity: 0;"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
data-menu-list="true"
role="menu"
tabindex="0"
>
<li
class="ant-dropdown-menu-item ant-dropdown-menu-item-only-child"
data-menu-id="rc-menu-uuid-test-all"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
Select all data
</span>
</li>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
<li
class="ant-dropdown-menu-item ant-dropdown-menu-item-only-child"
data-menu-id="rc-menu-uuid-test-invert"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
Invert current page
</span>
</li>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
<li
class="ant-dropdown-menu-item ant-dropdown-menu-item-only-child"
data-menu-id="rc-menu-uuid-test-none"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
Clear all data
</span>
</li>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</ul>
<div
aria-hidden="true"
style="display: none;"
>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-dropdown-menu-inline-collapsed-tooltip ant-tooltip-placement-right"
style="left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; top: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</th>
<th
class="ant-table-cell"
scope="col"
>
Name
</th>
<th
class="ant-table-cell"
scope="col"
>
Age
</th>
<th
class="ant-table-cell"
scope="col"
>
Address
</th>
</tr>
</thead>
<tbody
class="ant-table-tbody"
>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="1"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
John Brown
</td>
<td
class="ant-table-cell"
>
32
</td>
<td
class="ant-table-cell"
>
New York No. 1 Lake Park
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="2"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
Jim Green
</td>
<td
class="ant-table-cell"
>
42
</td>
<td
class="ant-table-cell"
>
London No. 1 Lake Park
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="3"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
Joe Black
</td>
<td
class="ant-table-cell"
>
32
</td>
<td
class="ant-table-cell"
>
Sydney No. 1 Lake Park
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<ul
class="ant-pagination ant-table-pagination ant-table-pagination-right"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
aria-disabled="true"
class="ant-pagination-next ant-pagination-disabled"
title="Next Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>
</div>
</div>
</div>
`;
exports[`renders components/table/demo/size.tsx extend context correctly 1`] = `
Array [
<div

View File

@ -20857,6 +20857,318 @@ Array [
]
`;
exports[`renders components/table/demo/selections-debug.tsx correctly 1`] = `
<div
class="ant-table-wrapper"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="ant-table ant-table-bordered"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
>
<table
style="table-layout:auto"
>
<colgroup>
<col
class="ant-table-selection-col ant-table-selection-col-with-dropdown"
/>
</colgroup>
<thead
class="ant-table-thead"
>
<tr>
<th
class="ant-table-cell ant-table-selection-column"
scope="col"
>
<div
class="ant-table-selection"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
aria-label="Custom selection"
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<div
class="ant-table-selection-extra"
>
<span
class="ant-dropdown-trigger"
>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</span>
</div>
</div>
</th>
<th
class="ant-table-cell"
scope="col"
>
Name
</th>
<th
class="ant-table-cell"
scope="col"
>
Age
</th>
<th
class="ant-table-cell"
scope="col"
>
Address
</th>
</tr>
</thead>
<tbody
class="ant-table-tbody"
>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="1"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
John Brown
</td>
<td
class="ant-table-cell"
>
32
</td>
<td
class="ant-table-cell"
>
New York No. 1 Lake Park
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="2"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
Jim Green
</td>
<td
class="ant-table-cell"
>
42
</td>
<td
class="ant-table-cell"
>
London No. 1 Lake Park
</td>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="3"
>
<td
class="ant-table-cell ant-table-selection-column"
>
<label
class="ant-checkbox-wrapper"
>
<span
class="ant-checkbox"
>
<input
class="ant-checkbox-input"
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</td>
<td
class="ant-table-cell"
>
Joe Black
</td>
<td
class="ant-table-cell"
>
32
</td>
<td
class="ant-table-cell"
>
Sydney No. 1 Lake Park
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<ul
class="ant-pagination ant-table-pagination ant-table-pagination-right"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
aria-disabled="true"
class="ant-pagination-next ant-pagination-disabled"
title="Next Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>
</div>
</div>
</div>
`;
exports[`renders components/table/demo/size.tsx correctly 1`] = `
Array [
<div

View File

@ -0,0 +1,7 @@
## zh-CN
调试使用。
## en-US
debug use.

View File

@ -0,0 +1,57 @@
import { Table } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import React from 'react';
interface DataType {
key: React.Key;
name: string;
age: number;
address: string;
}
const columns: ColumnsType<DataType> = [
{
title: 'Name',
dataIndex: 'name',
},
{
title: 'Age',
dataIndex: 'age',
},
{
title: 'Address',
dataIndex: 'address',
},
];
const data: DataType[] = [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sydney No. 1 Lake Park',
},
];
const App: React.FC = () => (
<Table
bordered
rowSelection={{ type: 'checkbox', selections: true }}
columns={columns}
dataSource={data}
/>
);
export default App;

View File

@ -1,4 +1,5 @@
import DownOutlined from '@ant-design/icons/DownOutlined';
import classNames from 'classnames';
import { INTERNAL_COL_DEFINE } from 'rc-table';
import type { FixedType } from 'rc-table/lib/interface';
import type { DataNode, GetCheckDisabled } from 'rc-tree/lib/interface';
@ -8,14 +9,15 @@ import { convertDataToEntities } from 'rc-tree/lib/utils/treeUtil';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import * as React from 'react';
import { useCallback, useMemo, useState } from 'react';
import warning from '../../_util/warning';
import type { CheckboxProps } from '../../checkbox';
import Checkbox from '../../checkbox';
import Dropdown from '../../dropdown';
import Radio from '../../radio';
import warning from '../../_util/warning';
import type { AnyObject } from '../Table';
import type {
ColumnsType,
ColumnType,
ColumnsType,
ExpandType,
GetPopupContainer,
GetRowKey,
@ -36,7 +38,7 @@ export const SELECTION_NONE = 'SELECT_NONE' as const;
const EMPTY_LIST: React.Key[] = [];
interface UseSelectionConfig<RecordType> {
interface UseSelectionConfig<RecordType extends AnyObject = any> {
prefixCls: string;
pageData: RecordType[];
data: RecordType[];
@ -54,24 +56,24 @@ export type INTERNAL_SELECTION_ITEM =
| typeof SELECTION_INVERT
| typeof SELECTION_NONE;
function flattenData<RecordType>(childrenColumnName: string, data?: RecordType[]): RecordType[] {
const flattenData = <RecordType extends AnyObject = any>(
childrenColumnName: keyof RecordType,
data?: RecordType[],
): RecordType[] => {
let list: RecordType[] = [];
(data || []).forEach((record) => {
list.push(record);
if (record && typeof record === 'object' && childrenColumnName in record) {
list = [
...list,
...flattenData<RecordType>(childrenColumnName, (record as any)[childrenColumnName]),
];
list = [...list, ...flattenData<RecordType>(childrenColumnName, record[childrenColumnName])];
}
});
return list;
}
};
function useSelection<RecordType>(
const useSelection = <RecordType extends AnyObject = any>(
config: UseSelectionConfig<RecordType>,
rowSelection?: TableRowSelection<RecordType>,
): readonly [TransformColumns<RecordType>, Set<Key>] {
): readonly [TransformColumns<RecordType>, Set<Key>] => {
const {
preserveSelectedRowKeys,
selectedRowKeys,
@ -155,7 +157,7 @@ function useSelection<RecordType>(
// Get flatten data
const flattedData = useMemo(
() => flattenData(childrenColumnName, pageData),
[pageData, childrenColumnName],
[childrenColumnName, pageData],
);
// Get all checkbox props
@ -193,11 +195,12 @@ function useSelection<RecordType>(
return [checkedKeys || [], halfCheckedKeys];
}, [mergedSelectedKeys, checkStrictly, keyEntities, isCheckboxDisabled]);
const derivedSelectedKeySet: Set<Key> = useMemo(() => {
const derivedSelectedKeySet = useMemo<Set<Key>>(() => {
const keys = selectionType === 'radio' ? derivedSelectedKeys.slice(0, 1) : derivedSelectedKeys;
return new Set(keys);
}, [derivedSelectedKeys, selectionType]);
const derivedHalfSelectedKeySet = useMemo(
const derivedHalfSelectedKeySet = useMemo<Set<Key>>(
() => (selectionType === 'radio' ? new Set() : new Set(derivedHalfSelectedKeys)),
[derivedHalfSelectedKeys, selectionType],
);
@ -410,7 +413,7 @@ function useSelection<RecordType>(
const { key, text, onSelect: onSelectionClick } = selection;
return {
key: key || index,
key: key ?? index,
onClick: () => {
onSelectionClick?.(recordKeys);
},
@ -684,6 +687,10 @@ function useSelection<RecordType>(
prevCol.fixed = mergedFixed;
}
const columnCls = classNames(`${prefixCls}-selection-col`, {
[`${prefixCls}-selection-col-with-dropdown`]: selections && selectionType === 'checkbox',
});
// Replace with real selection column
const selectionColumn = {
fixed: mergedFixed,
@ -691,9 +698,7 @@ function useSelection<RecordType>(
className: `${prefixCls}-selection-column`,
title: rowSelection.columnTitle || title,
render: renderSelectionCell,
[INTERNAL_COL_DEFINE]: {
className: `${prefixCls}-selection-col`,
},
[INTERNAL_COL_DEFINE]: { className: columnCls },
};
return cloneColumns.map((col) => (col === SELECTION_COLUMN ? selectionColumn : col));
@ -717,6 +722,6 @@ function useSelection<RecordType>(
);
return [transformColumns, derivedSelectedKeySet] as const;
}
};
export default useSelection;

View File

@ -104,6 +104,7 @@ const columns = [
<code src="./demo/row-selection-custom-debug.tsx" debug>Custom selection group</code>
<code src="./demo/sticky.tsx">Fixed header and scroll bar with the page</code>
<code src="./demo/dynamic-settings.tsx">Dynamic Settings</code>
<code src="./demo/selections-debug.tsx" debug>selections with icon</code>
## API

View File

@ -105,6 +105,7 @@ const columns = [
<code src="./demo/row-selection-custom-debug.tsx" debug>自定义选择项组</code>
<code src="./demo/sticky.tsx">随页面滚动的固定表头和滚动条</code>
<code src="./demo/dynamic-settings.tsx">动态控制表格属性</code>
<code src="./demo/selections-debug.tsx" debug>带下拉箭头的表头</code>
## API

View File

@ -8,19 +8,28 @@ const genSelectionStyle: GenerateStyle<TableToken, CSSObject> = (token) => {
antCls,
iconCls,
fontSizeIcon,
padding,
paddingXS,
tableHeaderIconColor,
tableHeaderIconColorHover,
tableSelectionColumnWidth,
} = token;
return {
[`${componentCls}-wrapper`]: {
// ========================== Selections ==========================
[`${componentCls}-selection-col`]: {
width: token.tableSelectionColumnWidth,
width: tableSelectionColumnWidth,
[`&${componentCls}-selection-col-with-dropdown`]: {
width: tableSelectionColumnWidth + fontSizeIcon + padding / 4,
},
},
[`${componentCls}-bordered ${componentCls}-selection-col`]: {
width: token.tableSelectionColumnWidth + paddingXS * 2,
width: tableSelectionColumnWidth + paddingXS * 2,
[`&${componentCls}-selection-col-with-dropdown`]: {
width: tableSelectionColumnWidth + fontSizeIcon + padding / 4 + paddingXS * 2,
},
},
[`

View File

@ -36,10 +36,10 @@ Create `src/components/TimePicker.tsx`.
For example:
```tsx
import { DatePicker } from 'antd';
import type { PickerTimeProps } from 'antd/es/date-picker/generatePicker';
import type { Moment } from 'moment';
import * as React from 'react';
import DatePicker from './DatePicker';
export interface TimePickerProps extends Omit<PickerTimeProps<Moment>, 'picker'> {}

View File

@ -34,10 +34,10 @@ export default DatePicker;
编写如下代码:
```tsx
import { DatePicker } from 'antd';
import type { PickerTimeProps } from 'antd/es/date-picker/generatePicker';
import type { Moment } from 'moment';
import * as React from 'react';
import DatePicker from './DatePicker';
export interface TimePickerProps extends Omit<PickerTimeProps<Moment>, 'picker'> {}
@ -145,9 +145,9 @@ export default DatePicker;
### 与 dayjs 的差异
luxon 用户应该悉知,它不附带用于本地化的自定义实现。 相反,它依赖于浏览器的本机 [Intl API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)。
luxon 用户应该悉知,它本身没有 local 的实现。相反,它依赖于原生浏览器的 [Intl](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Intl)。
这导致了与其他日期库的一些差异, 主要区别是:
这导致了与其他日期库的一些差异,主要区别是:
- 无论语言环境如何,一周的第一天总是星期一。
- 一年中的周数有时不同ISO 周规则用于确定它)。

View File

@ -15,7 +15,7 @@ Please find below some of the design resources and tools about Ant Design that w
- Sketch Symbols
- https://gw.alipayobjects.com/zos/basement_prod/048ee28f-2c80-4d15-9aa3-4f5ddac50465.svg
- Sketch Symbols for Desktop
- https://gw.alipayobjects.com/os/hitu-asset/5217de80-7a3e-413f-809e-20ecede4f3f3/hitu-1669000735416-5000001.sketch
- https://github.com/ant-design/ant-design/releases/download/resource/Ant.Design.Components.5.0.Beta.sketch
- Official
- Mobile Components
- https://gw.alipayobjects.com/zos/basement_prod/c0c3852c-d245-4330-886b-cb02ef49eb6d.svg

View File

@ -15,7 +15,7 @@ toc: false
- Sketch 组件包
- https://gw.alipayobjects.com/zos/basement_prod/048ee28f-2c80-4d15-9aa3-4f5ddac50465.svg
- 桌面组件 Sketch 模板包
- https://gw.alipayobjects.com/os/hitu-asset/5217de80-7a3e-413f-809e-20ecede4f3f3/hitu-1669000735416-5000001.sketch
- https://github.com/ant-design/ant-design/releases/download/resource/Ant.Design.Components.5.0.Beta.sketch
- 官方
- Mobile Components
- https://gw.alipayobjects.com/zos/basement_prod/c0c3852c-d245-4330-886b-cb02ef49eb6d.svg

View File

@ -197,7 +197,7 @@
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"antd-img-crop": "^4.9.0",
"antd-style": "^2.0.2",
"antd-style": "^3.0.0",
"antd-token-previewer": "^1.1.0-21",
"chalk": "^4.0.0",
"cheerio": "1.0.0-rc.12",