Skip to content

Commit

Permalink
feat: CP support Transfer selectionsIcon (#47301)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Feb 2, 2024
1 parent 326ae98 commit 0e28360
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions components/config-provider/__tests__/style.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1230,13 +1230,15 @@ describe('ConfigProvider support style and className props', () => {
<ConfigProvider
transfer={{
className: 'test-class',
selectionsIcon: <span className="cp-test-selectionsIcon">cp-test-selectionsIcon</span>,
}}
>
<Transfer dataSource={mockData} />
</ConfigProvider>,
);

expect(container.querySelector('.ant-transfer')).toHaveClass('test-class');
expect(container.querySelector<HTMLSpanElement>('.cp-test-selectionsIcon')).toBeTruthy();
});

it('Should Transfer style works', () => {
Expand Down
5 changes: 4 additions & 1 deletion components/config-provider/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { TabsProps } from '../tabs';
import type { TagProps } from '../tag';
import type { AliasToken, MappingAlgorithm, OverrideToken } from '../theme/interface';
import type { TourProps } from '../tour/interface';
import type { TransferProps } from '../transfer';
import type { RenderEmptyHandler } from './defaultRenderEmpty';

export const defaultIconPrefixCls = 'anticon';
Expand Down Expand Up @@ -109,6 +110,8 @@ export type DrawerConfig = ComponentStyleConfig &

export type FlexConfig = ComponentStyleConfig & Pick<FlexProps, 'vertical'>;

export type TransferConfig = ComponentStyleConfig & Pick<TransferProps, 'selectionsIcon'>;

export type PopupOverflow = 'viewport' | 'scroll';

export interface WaveConfig {
Expand Down Expand Up @@ -169,7 +172,7 @@ export interface ConfigConsumerProps {
radio?: ComponentStyleConfig;
rate?: ComponentStyleConfig;
switch?: ComponentStyleConfig;
transfer?: ComponentStyleConfig;
transfer?: TransferConfig;
avatar?: ComponentStyleConfig;
message?: ComponentStyleConfig;
tag?: TagConfig;
Expand Down
2 changes: 1 addition & 1 deletion components/config-provider/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const {
| timeline | Set Timeline common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| timePicker | Set TimePicker common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| tour | Set Tour common props | { closeIcon?: React.ReactNode } | - | 5.14.0 |
| transfer | Set Transfer common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| transfer | Set Transfer common props | { className?: string, style?: React.CSSProperties, selectionsIcon?: React.ReactNode } | - | 5.7.0, selectionsIcon: 5.14.0 |
| tree | Set Tree common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| typography | Set Typography common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| upload | Set Upload common props | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
Expand Down
3 changes: 2 additions & 1 deletion components/config-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import type {
Theme,
ThemeConfig,
TourConfig,
TransferConfig,
WaveConfig,
} from './context';
import { ConfigConsumer, ConfigContext, defaultIconPrefixCls } from './context';
Expand Down Expand Up @@ -167,7 +168,7 @@ export interface ConfigProviderProps {
radio?: ComponentStyleConfig;
rate?: ComponentStyleConfig;
switch?: ComponentStyleConfig;
transfer?: ComponentStyleConfig;
transfer?: TransferConfig;
avatar?: ComponentStyleConfig;
message?: ComponentStyleConfig;
tag?: TagConfig;
Expand Down
2 changes: 1 addition & 1 deletion components/config-provider/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const {
| timeline | 设置 Timeline 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| timePicker | 设置 TimePicker 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| tour | 设置 Tour 组件的通用属性 | { closeIcon?: React.ReactNode } | - | 5.14.0 |
| transfer | 设置 Transfer 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| transfer | 设置 Transfer 组件的通用属性 | { className?: string, style?: React.CSSProperties, selectionsIcon?: React.ReactNode } | - | 5.7.0, selectionsIcon: 5.14.0 |
| tree | 设置 Tree 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| typography | 设置 Typography 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
| upload | 设置 Upload 组件的通用属性 | { className?: string, style?: React.CSSProperties } | - | 5.7.0 |
Expand Down
6 changes: 4 additions & 2 deletions components/transfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(

const [leftTitle, rightTitle] = getTitles(listLocale);

const mergedSelectionsIcon = selectionsIcon ?? transfer?.selectionsIcon;

return wrapCSSVar(
<div className={cls} style={{ ...transfer?.style, ...style }}>
<List<KeyWise<RecordType>>
Expand All @@ -443,7 +445,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
showSelectAll={showSelectAll}
selectAllLabel={selectAllLabels[0]}
pagination={mergedPagination}
selectionsIcon={selectionsIcon}
selectionsIcon={mergedSelectionsIcon}
{...listLocale}
/>
<Operation
Expand Down Expand Up @@ -482,7 +484,7 @@ const Transfer = <RecordType extends TransferItem = TransferItem>(
selectAllLabel={selectAllLabels[1]}
showRemove={oneWay}
pagination={mergedPagination}
selectionsIcon={selectionsIcon}
selectionsIcon={mergedSelectionsIcon}
{...listLocale}
/>
</div>,
Expand Down

0 comments on commit 0e28360

Please sign in to comment.