-
diff --git a/components/tour/__tests__/__snapshots__/index.test.tsx.snap b/components/tour/__tests__/__snapshots__/index.test.tsx.snap
index 61bfbbfd7c..244569682a 100644
--- a/components/tour/__tests__/__snapshots__/index.test.tsx.snap
+++ b/components/tour/__tests__/__snapshots__/index.test.tsx.snap
@@ -20,9 +20,6 @@ exports[`Tour Primary 1`] = `
-
@@ -305,9 +302,6 @@ exports[`Tour single 1`] = `
-
@@ -467,9 +461,6 @@ exports[`Tour step support Primary 1`] = `
-
diff --git a/components/tour/panelRender.tsx b/components/tour/panelRender.tsx
index 94e31028cf..efcca0563d 100644
--- a/components/tour/panelRender.tsx
+++ b/components/tour/panelRender.tsx
@@ -33,7 +33,6 @@ const TourPanel: React.FC
= ({ stepProps, current, type, indicat
nextButtonProps,
prevButtonProps,
type: stepType,
- arrow,
className,
} = stepProps;
@@ -102,7 +101,6 @@ const TourPanel: React.FC = ({ stepProps, current, type, indicat
`${prefixCls}-content`,
)}
>
- {arrow && }
{coverNode}
diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx
index 90bd4e76ca..1176953514 100644
--- a/components/tree-select/index.tsx
+++ b/components/tree-select/index.tsx
@@ -1,32 +1,31 @@
import classNames from 'classnames';
import type { BaseSelectRef } from 'rc-select';
+import type { Placement } from 'rc-select/lib/BaseSelect';
import type { TreeSelectProps as RcTreeSelectProps } from 'rc-tree-select';
import RcTreeSelect, { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode } from 'rc-tree-select';
import type { BaseOptionType, DefaultOptionType } from 'rc-tree-select/lib/TreeSelect';
import omit from 'rc-util/lib/omit';
import * as React from 'react';
-import type { Placement } from 'rc-select/lib/BaseSelect';
-import { ConfigContext } from '../config-provider';
-import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
-import DisabledContext from '../config-provider/DisabledContext';
-import type { SizeType } from '../config-provider/SizeContext';
-import SizeContext from '../config-provider/SizeContext';
-import { FormItemInputContext } from '../form/context';
import genPurePanel from '../_util/PurePanel';
-import useSelectStyle from '../select/style';
-import getIcons from '../select/utils/iconUtil';
-import type { AntTreeNodeProps, TreeProps } from '../tree';
-import type { SwitcherIcon } from '../tree/Tree';
-import renderSwitcherIcon from '../tree/utils/iconUtil';
import type { SelectCommonPlacement } from '../_util/motion';
import { getTransitionDirection, getTransitionName } from '../_util/motion';
import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
-import { useCompactItemContext } from '../space/Compact';
import warning from '../_util/warning';
-
-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 DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';
+import { FormItemInputContext } from '../form/context';
+import useSelectStyle from '../select/style';
import useShowArrow from '../select/useShowArrow';
+import getIcons from '../select/utils/iconUtil';
+import { useCompactItemContext } from '../space/Compact';
+import type { AntTreeNodeProps, TreeProps } from '../tree';
+import type { SwitcherIcon } from '../tree/Tree';
+import SwitcherIconCom from '../tree/utils/iconUtil';
+import useStyle from './style';
type RawValue = string | number;
@@ -209,13 +208,22 @@ const InternalTreeSelect = <
hashId,
);
+ const renderSwitcherIcon = (nodeProps: AntTreeNodeProps) => (
+
+ );
+
const returnNode = (
- renderSwitcherIcon(treePrefixCls, switcherIcon, nodeProps, treeLine)
- }
+ switcherIcon={renderSwitcherIcon}
showTreeIcon={treeIcon as any}
notFoundContent={mergedNotFound}
getPopupContainer={getPopupContainer || getContextPopupContainer}
diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx
index 79732e61a9..b20ff29913 100644
--- a/components/tree/Tree.tsx
+++ b/components/tree/Tree.tsx
@@ -5,12 +5,11 @@ import RcTree from 'rc-tree';
import type { DataNode, Key } from 'rc-tree/lib/interface';
import type { Component } from 'react';
import React from 'react';
-import { ConfigContext } from '../config-provider';
import initCollapseMotion from '../_util/motion';
-import dropIndicatorRender from './utils/dropIndicator';
-import renderSwitcherIcon from './utils/iconUtil';
-
+import { ConfigContext } from '../config-provider';
import useStyle from './style';
+import dropIndicatorRender from './utils/dropIndicator';
+import SwitcherIconCom from './utils/iconUtil';
export type SwitcherIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
export type TreeLeafIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
@@ -218,6 +217,15 @@ const Tree = React.forwardRef((props, ref) => {
return mergedDraggable;
}, [draggable]);
+ const renderSwitcherIcon = (nodeProps: AntTreeNodeProps) => (
+
+ );
+
return wrapSSR(
((props, ref) => {
direction={direction}
checkable={checkable ? : checkable}
selectable={selectable}
- switcherIcon={(nodeProps: AntTreeNodeProps) =>
- renderSwitcherIcon(prefixCls, switcherIcon, nodeProps, showLine)
- }
+ switcherIcon={renderSwitcherIcon}
draggable={draggableConfig}
>
{children}
diff --git a/components/tree/__tests__/util.test.tsx b/components/tree/__tests__/util.test.tsx
index 7ef6180c6f..81b7947281 100644
--- a/components/tree/__tests__/util.test.tsx
+++ b/components/tree/__tests__/util.test.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
import { render, screen } from '@testing-library/react';
+import React from 'react';
import { calcRangeKeys } from '../utils/dictUtil';
-import renderSwitcherIcon from '../utils/iconUtil';
+import SwitcherIconCom from '../utils/iconUtil';
describe('Tree util', () => {
describe('calcRangeKeys', () => {
@@ -38,20 +38,16 @@ describe('Tree util', () => {
});
it('return empty array without startKey and endKey', () => {
- const keys = calcRangeKeys({
- treeData,
- expandedKeys: ['0-0', '0-2', '0-2-0'],
- });
+ const keys = calcRangeKeys({ treeData, expandedKeys: ['0-0', '0-2', '0-2-0'] });
expect(keys).toEqual([]);
});
});
- describe('renderSwitcherIcon', () => {
+ describe('SwitcherIconCom', () => {
const prefixCls = 'tree';
-
it('returns a loading icon when loading', () => {
const { container } = render(
- <>{renderSwitcherIcon(prefixCls, undefined, { loading: true }, true)}>,
+ ,
);
expect(container.getElementsByClassName(`${prefixCls}-switcher-loading-icon`)).toHaveLength(
1,
@@ -60,7 +56,11 @@ describe('Tree util', () => {
it('returns nothing when node is a leaf without showLine', () => {
const { container } = render(
- <>{renderSwitcherIcon(prefixCls, undefined, { loading: false, isLeaf: true }, false)}>,
+ ,
);
expect(container).toBeEmptyDOMElement();
});
@@ -69,16 +69,12 @@ describe('Tree util', () => {
const testId = 'custom-icon';
const customLeafIcon = ;
const { container } = render(
- <>
- {renderSwitcherIcon(
- prefixCls,
- undefined,
- { loading: false, isLeaf: true },
- { showLeafIcon: customLeafIcon },
- )}
- >,
+ ,
);
-
expect(screen.getByTestId(testId)).toBeVisible();
expect(
container.getElementsByClassName(`${prefixCls}-switcher-line-custom-icon`),
@@ -90,16 +86,12 @@ describe('Tree util', () => {
[`${prefixCls}-switcher-leaf-line`, false],
])('returns %p element when showLeafIcon is %p', (expectedClassName, showLeafIcon) => {
const { container } = render(
- <>
- {renderSwitcherIcon(
- prefixCls,
- undefined,
- { loading: false, isLeaf: true },
- { showLeafIcon },
- )}
- >,
+ ,
);
-
expect(container.getElementsByClassName(expectedClassName)).toHaveLength(1);
});
});
diff --git a/components/tree/utils/iconUtil.tsx b/components/tree/utils/iconUtil.tsx
index aa34de5498..35fe64fca5 100644
--- a/components/tree/utils/iconUtil.tsx
+++ b/components/tree/utils/iconUtil.tsx
@@ -6,14 +6,18 @@ import PlusSquareOutlined from '@ant-design/icons/PlusSquareOutlined';
import classNames from 'classnames';
import * as React from 'react';
import { cloneElement, isValidElement } from '../../_util/reactNode';
-import type { AntTreeNodeProps, TreeLeafIcon, SwitcherIcon } from '../Tree';
+import type { AntTreeNodeProps, SwitcherIcon, TreeLeafIcon } from '../Tree';
+
+interface SwitcherIconProps {
+ prefixCls: string;
+ treeNodeProps: AntTreeNodeProps;
+ switcherIcon?: SwitcherIcon;
+ showLine?: boolean | { showLeafIcon: boolean | TreeLeafIcon };
+}
+
+const SwitcherIconCom: React.FC = (props) => {
+ const { prefixCls, switcherIcon, treeNodeProps, showLine } = props;
-export default function renderSwitcherIcon(
- prefixCls: string,
- switcherIcon: SwitcherIcon,
- treeNodeProps: AntTreeNodeProps,
- showLine?: boolean | { showLeafIcon: boolean | TreeLeafIcon },
-): React.ReactNode {
const { isLeaf, expanded, loading } = treeNodeProps;
if (loading) {
@@ -40,7 +44,7 @@ export default function renderSwitcherIcon(
});
}
- return leafIcon;
+ return leafIcon as unknown as React.ReactElement;
}
return showLeafIcon ? (
@@ -61,7 +65,7 @@ export default function renderSwitcherIcon(
}
if (switcher) {
- return switcher;
+ return switcher as unknown as React.ReactElement;
}
if (showLine) {
@@ -72,4 +76,6 @@ export default function renderSwitcherIcon(
);
}
return ;
-}
+};
+
+export default SwitcherIconCom;
diff --git a/package.json b/package.json
index 5a469eeec0..c667460321 100644
--- a/package.json
+++ b/package.json
@@ -272,7 +272,7 @@
"remark-cli": "^11.0.0",
"remark-lint": "^9.0.0",
"remark-preset-lint-recommended": "^6.0.0",
- "rome": "^11.0.0",
+ "rome": "^12.0.0",
"semver": "^7.3.5",
"simple-git": "^3.0.0",
"size-limit": "^8.1.0",
diff --git a/tests/shared/demoTest.tsx b/tests/shared/demoTest.tsx
index 950bfa661d..c10872d7a3 100644
--- a/tests/shared/demoTest.tsx
+++ b/tests/shared/demoTest.tsx
@@ -1,6 +1,7 @@
/* eslint-disable react/jsx-no-constructed-context-values */
import { createCache, StyleProvider } from '@ant-design/cssinjs';
import glob from 'glob';
+import path from 'path';
import * as React from 'react';
import { renderToString } from 'react-dom/server';
import { render } from '../utils';
@@ -20,8 +21,9 @@ export type Options = {
function baseText(doInject: boolean, component: string, options: Options = {}) {
const files = glob.globSync(`./components/${component}/demo/*.tsx`);
-
files.forEach((file) => {
+ // to compatible windows path
+ file = file.split(path.sep).join('/');
const testMethod =
options.skip === true ||
(Array.isArray(options.skip) && options.skip.some((c) => file.includes(c)))