chore: auto merge branches (#49850)

chore: merge master into feature
This commit is contained in:
github-actions[bot] 2024-07-12 20:48:10 +00:00 committed by GitHub
commit d9f70d738c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 186 additions and 90 deletions

View File

@ -50,7 +50,7 @@ Describe changes from the user side, and list all potential break changes or oth
- Use a developer-oriented tone and narrative style.
- Describe the user's first-hand experience of the issue and its impact on developers, rather than your solution approach.
- Refer to: ant.design/changelog
- Refer to: https://ant.design/changelog
| Language | Changelog |
| ---------- | --------- |

View File

@ -50,7 +50,7 @@
- 请用面向开发者的角度和叙述方式撰写 changelog
- 描述用户第一现场的问题,对开发者有哪些影响,而非你的解决方式
- 参考ant.design/changelog-cn
- 参考:https://ant.design/changelog-cn
| 语言 | 更新描述 |
| ------- | -------- |

View File

@ -20,4 +20,17 @@ jobs:
- name: Build
run: npm run build
- run: npx pkg-pr-new publish
# ========== Prepare examples ==========
- name: Clear examples
run: rm -rf examples
- name: Clone examples
uses: actions/checkout@v4
with:
repository: ant-design/ant-design-examples
path: examples
- name: Modify examples
run: npx tsx scripts/prepare-examples.ts
- run: npx pkg-pr-new publish --template './examples/examples/*'

1
.gitignore vendored
View File

@ -76,3 +76,4 @@ __image_snapshots__/
.node
.env
examples/

View File

@ -17,12 +17,12 @@ export interface ComponentToken {
* @desc
* @descEN Height of badge
*/
indicatorHeight: number | string;
indicatorHeight: number;
/**
* @desc
* @descEN Height of small badge
*/
indicatorHeightSM: number | string;
indicatorHeightSM: number;
/**
* @desc
* @descEN Size of dot badge

View File

@ -16,17 +16,17 @@ export interface ComponentToken {
* @desc
* @descEN Width of year select
*/
yearControlWidth: number | string;
yearControlWidth: number;
/**
* @desc
* @descEN Width of month select
*/
monthControlWidth: number | string;
monthControlWidth: number;
/**
* @desc
* @descEN Height of mini calendar content
*/
miniContentHeight: number | string;
miniContentHeight: number;
/**
* @desc
* @descEN Background color of full calendar
@ -46,9 +46,9 @@ export interface ComponentToken {
interface CalendarToken extends FullToken<'Calendar'>, PickerPanelToken, PanelComponentToken {
calendarCls: string;
dateValueHeight: number | string;
weekHeight: number | string;
dateContentHeight: number | string;
dateValueHeight: number;
weekHeight: number;
dateContentHeight: number;
}
export const genCalendarStyles = (token: CalendarToken): CSSObject => {

View File

@ -15,22 +15,22 @@ export interface ComponentToken {
* @desc
* @descEN Font size of card header
*/
headerFontSize: number | string;
headerFontSize: number;
/**
* @desc
* @descEN Font size of small card header
*/
headerFontSizeSM: number | string;
headerFontSizeSM: number;
/**
* @desc
* @descEN Height of card header
*/
headerHeight: number | string;
headerHeight: number;
/**
* @desc
* @descEN Height of small card header
*/
headerHeightSM: number | string;
headerHeightSM: number;
/**
* @desc
* @descEN Background color of card actions

View File

@ -9,12 +9,12 @@ export interface ComponentToken {
* @desc
* @descEN Width of indicator
*/
dotWidth: number | string;
dotWidth: number;
/**
* @desc
* @descEN Height of indicator
*/
dotHeight: number | string;
dotHeight: number;
/**
* @desc
* @descEN gap between indicator
@ -31,7 +31,7 @@ export interface ComponentToken {
* @desc
* @descEN Width of active indicator
*/
dotActiveWidth: number | string;
dotActiveWidth: number;
/**
* @desc
* @descEN Size of arrows

View File

@ -11,17 +11,17 @@ export interface ComponentToken {
* @desc
* @descEN Width of Cascader
*/
controlWidth: number | string;
controlWidth: number;
/**
* @desc
* @descEN Width of item
*/
controlItemWidth: number | string;
controlItemWidth: number;
/**
* @desc
* @descEN Height of dropdown
*/
dropdownHeight: number | string;
dropdownHeight: number;
/**
* @desc
* @descEN Background color of selected item

View File

@ -11,7 +11,7 @@ interface EmptyToken extends FullToken<'Empty'> {
emptyImgCls: string;
emptyImgHeight: number | string;
emptyImgHeightSM: number | string;
emptyImgHeightMD: number | string;
emptyImgHeightMD: number;
}
// ============================== Shared ==============================

View File

@ -29,7 +29,7 @@ export interface ComponentToken {
* @desc
* @descEN Label height
*/
labelHeight: number | string;
labelHeight: number;
/**
* @desc
* @descEN Label colon margin-inline-start

View File

@ -58,7 +58,7 @@ export interface ComponentToken {
* @desc
* @descEN Height of sider trigger
*/
triggerHeight: number | string;
triggerHeight: number;
/**
* @desc
* @descEN Background Color of sider trigger

View File

@ -107,7 +107,7 @@ const InternalItem = React.forwardRef<HTMLDivElement, ListItemProps>((props, ref
};
const prefixCls = getPrefixCls('list', customizePrefixCls);
const actionsContent = actions?.length && (
const actionsContent = (actions && actions.length > 0) && (
<ul
className={classNames(`${prefixCls}-item-action`, moduleClass('actions'))}
key="actions"

View File

@ -11,7 +11,7 @@ export interface ComponentToken {
* @desc
* @descEN Width of content
*/
contentWidth: number | string;
contentWidth: number;
/**
* @desc
* @descEN Padding of large item
@ -66,7 +66,7 @@ export interface ComponentToken {
interface ListToken extends FullToken<'List'> {
listBorderedCls: string;
minHeight: number | string;
minHeight: number;
}
const genBorderedStyle = (token: ListToken): CSSObject => {

View File

@ -27,12 +27,12 @@ export interface ComponentToken extends SharedComponentToken {
* @desc
* @descEN Height of popup
*/
dropdownHeight: number | string;
dropdownHeight: number;
/**
* @desc
* @descEN Height of menu item
*/
controlItemWidth: number | string;
controlItemWidth: number;
}
type MentionsToken = FullToken<'Mentions'> &

View File

@ -19,7 +19,7 @@ export interface ComponentToken {
* @desc
* @descEN Width of popup menu
*/
dropdownWidth: number | string;
dropdownWidth: number;
/**
* @desc z-index
* @descEN z-index of popup menu
@ -205,12 +205,12 @@ export interface ComponentToken {
// Ink Bar
/** @deprecated Use `activeBarWidth` instead */
colorActiveBarWidth: number | string;
colorActiveBarWidth: number;
/**
* @desc
* @descEN Width of menu item active bar
*/
activeBarWidth: number | string;
activeBarWidth: number;
/** @deprecated Use `activeBarHeight` instead */
colorActiveBarHeight: number;
@ -226,7 +226,7 @@ export interface ComponentToken {
* @desc
* @descEN Border width of menu item active bar
*/
activeBarBorderWidth: number | string;
activeBarBorderWidth: number;
/**
* @desc
@ -247,12 +247,12 @@ export interface ComponentToken {
* @desc
* @descEN Height of menu item
*/
itemHeight: number | string;
itemHeight: number;
/**
* @desc
* @descEN Width when collapsed
*/
collapsedWidth: number | string;
collapsedWidth: number;
/**
* @desc
* @descEN Background color of popup
@ -366,7 +366,7 @@ export interface ComponentToken {
*/
darkDangerItemActiveBg: string;
/** @internal */
itemWidth: number | string;
itemWidth: string;
}
export interface MenuToken extends FullToken<'Menu'> {

View File

@ -20,7 +20,7 @@ export interface ComponentToken {
* @desc
* @descEN Line height of title
*/
titleLineHeight: number | string;
titleLineHeight: number;
/**
* @desc
* @descEN Font size of title
@ -73,7 +73,7 @@ export interface ModalToken extends FullToken<'Modal'> {
modalHeaderHeight: number | string;
modalFooterBorderColorSplit: string;
modalFooterBorderStyle: string;
modalFooterBorderWidth: number | string;
modalFooterBorderWidth: number;
modalCloseIconColor: string;
modalCloseIconHoverColor: string;
modalCloseBtnSize: number | string;

View File

@ -20,11 +20,11 @@ export interface ComponentToken {
* @desc
* @descEN Width of Notification
*/
width: number | string;
width: number;
}
export interface NotificationToken extends FullToken<'Notification'> {
animationMaxHeight: number | string;
animationMaxHeight: number;
notificationBg: string;
notificationPadding: string;
notificationPaddingVertical: number;

View File

@ -18,18 +18,18 @@ export interface ComponentToken extends ArrowToken, ArrowOffsetToken {
* @desc
* @descEN Width of Popover
*/
width?: number | string;
width?: number;
/**
* @deprecated Please use `titleMinWidth` instead
* @desc
* @descEN Min width of Popover
*/
minWidth?: number | string;
minWidth?: number;
/**
* @desc
* @descEN Min width of Popover title
*/
titleMinWidth: number | string;
titleMinWidth: number;
/**
* @desc z-index
* @descEN z-index of Popover

View File

@ -29,8 +29,8 @@ export interface ComponentToken {
}
interface ResultToken extends FullToken<'Result'> {
imageWidth: number | string;
imageHeight: number | string;
imageWidth: number;
imageHeight: number;
resultInfoIconColor: string;
resultSuccessIconColor: string;
resultWarningIconColor: string;

View File

@ -24,7 +24,7 @@ export type ComponentToken = {
* @desc
* @descEN Height of title skeleton
*/
titleHeight: number | string;
titleHeight: number;
/**
* @desc
* @descEN Border radius of skeleton

View File

@ -38,12 +38,12 @@ export interface ComponentToken {
* @desc
* @descEN Border width of handle
*/
handleLineWidth: number | string;
handleLineWidth: number;
/**
* @desc
* @descEN Border width of handle when hover
*/
handleLineWidthHover: number | string;
handleLineWidthHover: number;
/**
* @desc
* @descEN Size of dot

View File

@ -10,7 +10,7 @@ export interface ComponentToken {
* @desc
* @descEN Height of content area
*/
contentHeight: number | string;
contentHeight: number;
/**
* @desc
* @descEN Loading icon size

View File

@ -81,7 +81,7 @@ export interface ComponentToken {
* @desc
* @descEN Line height of title
*/
titleLineHeight: number | string;
titleLineHeight: number;
/**
* @internal
*/

View File

@ -11,22 +11,22 @@ export interface ComponentToken {
* @desc
* @descEN Height of Switch
*/
trackHeight: number | string;
trackHeight: number;
/**
* @desc
* @descEN Height of small Switch
*/
trackHeightSM: number | string;
trackHeightSM: number;
/**
* @desc
* @descEN Minimum width of Switch
*/
trackMinWidth: number | string;
trackMinWidth: number;
/**
* @desc
* @descEN Minimum width of small Switch
*/
trackMinWidthSM: number | string;
trackMinWidthSM: number;
/**
* @desc
* @descEN Padding of Switch

View File

@ -166,7 +166,7 @@ export interface ComponentToken {
* @desc
* @descEN Width of selection column
*/
selectionColumnWidth: number | string;
selectionColumnWidth: number;
/**
* @desc Sticky
* @descEN Background of sticky scrollbar
@ -214,14 +214,14 @@ export interface TableToken extends FullToken<'Table'> {
tableFixedHeaderSortActiveBg: string;
tableHeaderFilterActiveBg: string;
tableFilterDropdownBg: string;
tableFilterDropdownHeight: number | string;
tableFilterDropdownHeight: number;
tableRowHoverBg: string;
tableSelectedRowBg: string;
tableSelectedRowHoverBg: string;
tableFontSizeMiddle: number;
tableFontSizeSmall: number;
tableSelectionColumnWidth: number | string;
tableSelectionColumnWidth: number;
tableExpandIconBg: string;
tableExpandColumnWidth: number | string;
tableExpandedRowBg: string;

View File

@ -21,7 +21,7 @@ export interface ComponentToken {
* @desc
* @descEN Height of card tab
*/
cardHeight: number | string;
cardHeight: number;
/**
* @desc
* @descEN Padding of card tab
@ -134,8 +134,8 @@ export interface TabsToken extends FullToken<'Tabs'> {
dropdownEdgeChildVerticalPadding: number;
tabsNavWrapPseudoWidth: number;
tabsActiveTextShadow: string;
tabsDropdownHeight: number | string;
tabsDropdownWidth: number | string;
tabsDropdownHeight: number;
tabsDropdownWidth: number;
tabsHorizontalItemMargin: string;
tabsHorizontalItemMarginRTL: string;
}

View File

@ -15,12 +15,12 @@ export interface ComponentToken {
* @desc
* @descEN Line width
*/
tailWidth: number | string;
tailWidth: number;
/**
* @desc
* @descEN Border width of node
*/
dotBorderWidth: number | string;
dotBorderWidth: number;
/**
* @desc
* @descEN Background color of node

View File

@ -37,8 +37,8 @@ export interface ComponentToken extends ArrowOffsetToken, ArrowToken {
interface TourToken extends FullToken<'Tour'> {
tourZIndexPopup: number;
indicatorWidth: number | string;
indicatorHeight: number | string;
indicatorWidth: number;
indicatorHeight: number;
tourBorderRadius: number;
}

View File

@ -10,32 +10,32 @@ export interface ComponentToken {
* @desc
* @descEN Width of list
*/
listWidth: number | string;
listWidth: number;
/**
* @desc
* @descEN Width of large list
*/
listWidthLG: number | string;
listWidthLG: number;
/**
* @desc
* @descEN Height of list
*/
listHeight: number | string;
listHeight: number;
/**
* @desc
* @descEN Height of list item
*/
itemHeight: number | string;
itemHeight: number;
/**
* @desc
* @descEN Vertical padding of list item
*/
itemPaddingBlock: number | string;
itemPaddingBlock: number;
/**
* @desc
* @descEN Height of header
*/
headerHeight: number | string;
headerHeight: number;
}
interface TransferToken extends FullToken<'Transfer'> {

View File

@ -15,13 +15,13 @@ import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
import { devUseWarning } from '../_util/warning';
import { ConfigContext } from '../config-provider';
import type { Variant } from '../config-provider';
import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import DisabledContext from '../config-provider/DisabledContext';
import useCSSVarCls from '../config-provider/hooks/useCSSVarCls';
import useSize from '../config-provider/hooks/useSize';
import type { SizeType } from '../config-provider/SizeContext';
import { FormItemInputContext } from '../form/context';
import type { Variant } from '../config-provider';
import useVariant from '../form/hooks/useVariants';
import mergedBuiltinPlacements from '../select/mergedBuiltinPlacements';
import useSelectStyle from '../select/style';
@ -264,7 +264,7 @@ const InternalTreeSelect = <
hashId,
);
const renderSwitcherIcon: React.FC<AntTreeNodeProps> = (nodeProps) => (
const renderSwitcherIcon = (nodeProps: AntTreeNodeProps) => (
<SwitcherIconCom
prefixCls={treePrefixCls}
switcherIcon={switcherIcon as SwitcherIcon}

View File

@ -16,6 +16,7 @@ import SwitcherIconCom from './utils/iconUtil';
export type SwitcherIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
export type TreeLeafIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
type TreeIcon = React.ReactNode | ((props: AntdTreeNodeAttribute) => React.ReactNode);
export interface AntdTreeNodeAttribute {
eventKey: string;
@ -42,16 +43,16 @@ export interface AntTreeNodeProps {
checkable?: boolean;
disabled?: boolean;
disableCheckbox?: boolean;
title?: string | React.ReactNode;
title?: React.ReactNode | ((data: DataNode) => React.ReactNode);
key?: Key;
eventKey?: string;
eventKey?: Key;
isLeaf?: boolean;
checked?: boolean;
expanded?: boolean;
loading?: boolean;
selected?: boolean;
selectable?: boolean;
icon?: ((treeNode: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode;
icon?: TreeIcon;
children?: React.ReactNode;
[customProp: string]: any;
}
@ -148,11 +149,8 @@ export interface TreeProps<T extends BasicDataNode = DataNode>
draggable?: DraggableFn | boolean | DraggableConfig;
style?: React.CSSProperties;
showIcon?: boolean;
icon?:
| ((nodeProps: AntdTreeNodeAttribute) => React.ReactNode)
| React.ReactNode
| RcTreeProps<T>['icon'];
switcherIcon?: SwitcherIcon | RcTreeProps<T>['switcherIcon'];
icon?: TreeIcon;
switcherIcon?: SwitcherIcon;
prefixCls?: string;
children?: React.ReactNode;
blockNode?: boolean;
@ -224,10 +222,10 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
return mergedDraggable;
}, [draggable]);
const renderSwitcherIcon: React.FC<AntTreeNodeProps> = (nodeProps) => (
const renderSwitcherIcon = (nodeProps: AntTreeNodeProps) => (
<SwitcherIconCom
prefixCls={prefixCls}
switcherIcon={switcherIcon as SwitcherIcon}
switcherIcon={switcherIcon}
treeNodeProps={nodeProps}
showLine={showLine}
/>
@ -258,7 +256,7 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
direction={direction}
checkable={checkable ? <span className={`${prefixCls}-checkbox-inner`} /> : checkable}
selectable={selectable}
switcherIcon={renderSwitcherIcon as RcTreeProps['switcherIcon']}
switcherIcon={renderSwitcherIcon}
draggable={draggableConfig}
>
{children}

View File

@ -77,7 +77,7 @@ describe('Tree.TypeScript', () => {
expect(container).toBeTruthy();
});
it('draggable params type', () => {
it('draggable/icon/switcherIcon params type', () => {
const { container } = render(
<Tree
treeData={[
@ -93,6 +93,8 @@ describe('Tree.TypeScript', () => {
},
]}
draggable={(node: DataNode) => node.title === 'Little'}
icon={(props) => (props.isLeaf ? 1 : 0)}
switcherIcon={(props) => (props.isLeaf ? 1 : 0)}
/>,
);
expect(container).toBeTruthy();

View File

@ -128,7 +128,7 @@
"rc-motion": "^2.9.2",
"rc-notification": "~5.6.0",
"rc-pagination": "~4.2.0",
"rc-picker": "~4.6.8",
"rc-picker": "~4.6.9",
"rc-progress": "~4.0.0",
"rc-rate": "~2.13.0",
"rc-resize-observer": "^1.4.0",
@ -222,7 +222,6 @@
"cli-progress": "^3.12.0",
"cross-env": "^7.0.3",
"cross-fetch": "^4.0.0",
"crypto": "^1.0.1",
"dekko": "^0.2.1",
"dotenv": "^16.4.5",
"dumi": "~2.4.0",

View File

@ -0,0 +1,81 @@
import fg from 'fast-glob';
import fs from 'fs-extra';
import path from 'path';
import cloneDeep from 'lodash/cloneDeep';
import isPlainObject from 'lodash/isPlainObject';
import rootPkg from '../package.json';
const examples = fg.sync(['examples/examples/**/package.json'], {
cwd: process.cwd(),
onlyFiles: true,
ignore: ['**/node_modules/**', '.git'],
});
const _order = ['dependencies', 'devDependencies', 'peerDependencies'] as const;
function detectRootDepsVersion(pkgName: string) {
const _pkg: any = rootPkg;
for (let i = 0; i < _order.length; i++) {
const depKey = _order[i];
if (_pkg?.[depKey]?.[pkgName]) {
return _pkg[depKey][pkgName];
}
}
}
function syncVersion(pkgJson = {}, deps: string[] = []) {
const _pkgJson: any = cloneDeep(pkgJson);
_order.forEach((key) => {
const _processDeps = _pkgJson[key];
if (isPlainObject(_processDeps)) {
Object.keys(_processDeps).forEach((dep) => {
if (deps.includes(dep)) {
_processDeps[dep] = detectRootDepsVersion(dep) ?? _processDeps[dep];
}
});
}
});
return _pkgJson;
}
function modifyPackageJson(pkgJson: any) {
if (typeof pkgJson === 'object' && pkgJson !== null) {
return {
...syncVersion(
pkgJson,
['@ant-design/cssinjs'], // need to sync version
),
private: true,
author: 'antd GitHub CI',
};
}
}
function main() {
for (let i = 0; i < examples.length; i++) {
const example = examples[i];
const pkgJson = fs.readJsonSync(example);
const newPkgJson = modifyPackageJson(pkgJson) ?? pkgJson;
// unique named package.json
newPkgJson.name = path.basename(path.dirname(example));
const rewritePath = process.env.CI ? example : `${example}.tmp`; // ignored
fs.writeJsonSync(rewritePath, newPkgJson, { spaces: 2 });
globalThis.console.log(`🔮 [prepare-examples] ${pkgJson.name} has been prepared.`);
}
}
/**
* 1. git clone --depth=1 git@github.com:ant-design/ant-design-examples.git examples
* 2. npx tsx scripts/prepare-examples.ts
*/
main();

View File

@ -42,7 +42,7 @@ export default function imageTest(
let container: HTMLDivElement;
beforeAll(async () => {
const dom = new JSDOM('<!DOCTYPE html><body></body></p>', {
const dom = new JSDOM('<!DOCTYPE html><body></body></html>', {
url: 'http://localhost/',
});
const win = dom.window;
@ -121,8 +121,10 @@ export default function imageTest(
const { openTriggerClassName } = options;
const requestListener = (request: any) => onRequestHandle(request as HTTPRequest);
MockDate.set(dayjs('2016-11-22').valueOf());
page.on('request', onRequestHandle);
page.on('request', requestListener);
await page.goto(`file://${process.cwd()}/tests/index.html`);
await page.addStyleTag({ path: `${process.cwd()}/components/style/reset.css` });
await page.addStyleTag({ content: '*{animation: none!important;}' });
@ -194,7 +196,7 @@ export default function imageTest(
},
html,
styleStr,
openTriggerClassName,
openTriggerClassName || '',
);
if (!options.onlyViewport) {
@ -210,7 +212,7 @@ export default function imageTest(
await fse.writeFile(path.join(snapshotPath, `${identifier}${suffix}.png`), image);
MockDate.reset();
page.off('request', onRequestHandle);
page.off('request', requestListener);
});
}