2023-01-02 18:10:37 +08:00
|
|
|
/* eslint-disable @typescript-eslint/no-shadow */
|
2020-05-26 12:38:08 +08:00
|
|
|
import DownOutlined from '@ant-design/icons/DownOutlined';
|
2022-06-22 14:57:09 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import omit from 'rc-util/lib/omit';
|
|
|
|
import * as React from 'react';
|
2017-03-17 15:23:25 +08:00
|
|
|
import Checkbox from '../checkbox';
|
2020-05-13 19:15:40 +08:00
|
|
|
import Dropdown from '../dropdown';
|
2022-10-23 00:33:45 +08:00
|
|
|
import type { MenuProps } from '../menu';
|
2022-06-22 14:57:09 +08:00
|
|
|
import { isValidElement } from '../_util/reactNode';
|
2022-12-25 15:21:21 +08:00
|
|
|
import { groupKeysMap } from '../_util/transKeys';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type {
|
2022-06-22 14:57:09 +08:00
|
|
|
KeyWiseTransferItem,
|
2020-02-04 10:16:23 +08:00
|
|
|
RenderResult,
|
|
|
|
RenderResultObject,
|
|
|
|
SelectAllLabel,
|
2022-06-22 14:57:09 +08:00
|
|
|
TransferDirection,
|
2020-05-13 19:15:40 +08:00
|
|
|
TransferLocale,
|
2020-02-04 10:16:23 +08:00
|
|
|
} from './index';
|
2022-06-22 14:57:09 +08:00
|
|
|
import type { PaginationType } from './interface';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { TransferListBodyProps } from './ListBody';
|
|
|
|
import DefaultListBody, { OmitProps } from './ListBody';
|
2022-06-22 14:57:09 +08:00
|
|
|
import Search from './search';
|
2015-12-24 17:44:54 +08:00
|
|
|
|
2019-05-07 17:10:42 +08:00
|
|
|
const defaultRender = () => null;
|
2015-11-25 23:17:06 +08:00
|
|
|
|
2022-04-08 22:55:42 +08:00
|
|
|
function isRenderResultPlainObject(result: RenderResult): result is RenderResultObject {
|
|
|
|
return !!(
|
2018-12-07 16:17:45 +08:00
|
|
|
result &&
|
2020-05-14 20:54:49 +08:00
|
|
|
!isValidElement(result) &&
|
2018-12-07 16:17:45 +08:00
|
|
|
Object.prototype.toString.call(result) === '[object Object]'
|
|
|
|
);
|
2017-01-27 17:08:12 +08:00
|
|
|
}
|
|
|
|
|
2020-11-08 15:28:03 +08:00
|
|
|
function getEnabledItemKeys<RecordType extends KeyWiseTransferItem>(items: RecordType[]) {
|
2022-11-19 13:47:33 +08:00
|
|
|
return items.filter((data) => !data.disabled).map((data) => data.key);
|
2020-05-13 19:15:40 +08:00
|
|
|
}
|
|
|
|
|
2020-11-08 15:28:03 +08:00
|
|
|
export interface RenderedItem<RecordType> {
|
2019-05-07 17:10:42 +08:00
|
|
|
renderedText: string;
|
|
|
|
renderedEl: React.ReactNode;
|
2020-11-08 15:28:03 +08:00
|
|
|
item: RecordType;
|
2019-05-07 17:10:42 +08:00
|
|
|
}
|
|
|
|
|
2020-11-08 15:28:03 +08:00
|
|
|
type RenderListFunction<T> = (props: TransferListBodyProps<T>) => React.ReactNode;
|
2021-02-28 11:00:44 +08:00
|
|
|
|
2020-11-08 15:28:03 +08:00
|
|
|
export interface TransferListProps<RecordType> extends TransferLocale {
|
2016-10-24 16:30:38 +08:00
|
|
|
prefixCls: string;
|
2020-12-11 23:23:49 +08:00
|
|
|
titleText: React.ReactNode;
|
2020-11-08 15:28:03 +08:00
|
|
|
dataSource: RecordType[];
|
|
|
|
filterOption?: (filterText: string, item: RecordType) => boolean;
|
2016-07-13 11:14:24 +08:00
|
|
|
style?: React.CSSProperties;
|
2017-03-17 15:23:25 +08:00
|
|
|
checkedKeys: string[];
|
2019-05-07 17:10:42 +08:00
|
|
|
handleFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
|
|
onItemSelect: (key: string, check: boolean) => void;
|
|
|
|
onItemSelectAll: (dataSource: string[], checkAll: boolean) => void;
|
2020-05-13 19:15:40 +08:00
|
|
|
onItemRemove?: (keys: string[]) => void;
|
2016-10-24 16:30:38 +08:00
|
|
|
handleClear: () => void;
|
2020-12-28 15:30:18 +08:00
|
|
|
/** Render item */
|
2020-11-08 15:28:03 +08:00
|
|
|
render?: (item: RecordType) => RenderResult;
|
2017-03-17 15:23:25 +08:00
|
|
|
showSearch?: boolean;
|
|
|
|
searchPlaceholder: string;
|
|
|
|
itemUnit: string;
|
|
|
|
itemsUnit: string;
|
2020-11-08 15:28:03 +08:00
|
|
|
renderList?: RenderListFunction<RecordType>;
|
2021-06-30 12:10:23 +08:00
|
|
|
footer?: (
|
|
|
|
props: TransferListProps<RecordType>,
|
|
|
|
info?: { direction: TransferDirection },
|
|
|
|
) => React.ReactNode;
|
2019-12-23 18:33:08 +08:00
|
|
|
onScroll: (e: React.UIEvent<HTMLUListElement>) => void;
|
2018-09-15 15:18:59 +08:00
|
|
|
disabled?: boolean;
|
2019-05-07 17:10:42 +08:00
|
|
|
direction: TransferDirection;
|
|
|
|
showSelectAll?: boolean;
|
2020-02-04 10:16:23 +08:00
|
|
|
selectAllLabel?: SelectAllLabel;
|
2020-05-13 19:15:40 +08:00
|
|
|
showRemove?: boolean;
|
|
|
|
pagination?: PaginationType;
|
2019-05-07 17:10:42 +08:00
|
|
|
}
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const TransferList = <RecordType extends KeyWiseTransferItem>(
|
|
|
|
props: TransferListProps<RecordType>,
|
|
|
|
) => {
|
|
|
|
const {
|
|
|
|
prefixCls,
|
|
|
|
dataSource = [],
|
|
|
|
titleText = '',
|
|
|
|
checkedKeys,
|
|
|
|
disabled,
|
|
|
|
showSearch = false,
|
|
|
|
style,
|
|
|
|
searchPlaceholder,
|
|
|
|
notFoundContent,
|
|
|
|
selectAll,
|
|
|
|
selectCurrent,
|
|
|
|
selectInvert,
|
|
|
|
removeAll,
|
|
|
|
removeCurrent,
|
|
|
|
showSelectAll = true,
|
|
|
|
showRemove,
|
|
|
|
pagination,
|
|
|
|
direction,
|
|
|
|
itemsUnit,
|
|
|
|
itemUnit,
|
|
|
|
selectAllLabel,
|
|
|
|
footer,
|
|
|
|
renderList,
|
|
|
|
onItemSelectAll,
|
|
|
|
onItemRemove,
|
|
|
|
handleFilter,
|
|
|
|
handleClear,
|
|
|
|
filterOption,
|
|
|
|
render = defaultRender,
|
|
|
|
} = props;
|
2019-08-05 18:38:10 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const [filterValue, setFilterValue] = React.useState<string>('');
|
2016-08-08 14:42:29 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const defaultListBodyRef = React.useRef<DefaultListBody<RecordType>>(null);
|
2020-05-13 19:15:40 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const getCheckStatus = (filteredItems: RecordType[]) => {
|
2016-07-15 15:07:31 +08:00
|
|
|
if (checkedKeys.length === 0) {
|
|
|
|
return 'none';
|
2019-08-05 18:38:10 +08:00
|
|
|
}
|
2022-12-25 15:21:21 +08:00
|
|
|
const checkedKeysMap = groupKeysMap(checkedKeys);
|
|
|
|
if (filteredItems.every((item) => checkedKeysMap.has(item.key) || !!item.disabled)) {
|
2016-07-15 15:07:31 +08:00
|
|
|
return 'all';
|
|
|
|
}
|
|
|
|
return 'part';
|
2023-01-02 18:10:37 +08:00
|
|
|
};
|
2019-05-09 12:27:35 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const internalHandleFilter = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
setFilterValue(e.target.value);
|
2020-05-13 19:15:40 +08:00
|
|
|
handleFilter(e);
|
|
|
|
};
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const internalHandleClear = () => {
|
|
|
|
setFilterValue('');
|
2020-05-13 19:15:40 +08:00
|
|
|
handleClear();
|
|
|
|
};
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const matchFilter = (text: string, item: RecordType) => {
|
2020-05-13 19:15:40 +08:00
|
|
|
if (filterOption) {
|
|
|
|
return filterOption(filterValue, item);
|
|
|
|
}
|
2022-10-21 11:45:55 +08:00
|
|
|
return text.includes(filterValue);
|
2020-05-13 19:15:40 +08:00
|
|
|
};
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const renderListBody = (
|
2020-11-08 15:28:03 +08:00
|
|
|
renderList: RenderListFunction<RecordType> | undefined,
|
|
|
|
props: TransferListBodyProps<RecordType>,
|
|
|
|
) => {
|
2020-05-13 19:15:40 +08:00
|
|
|
let bodyContent: React.ReactNode = renderList ? renderList(props) : null;
|
|
|
|
const customize: boolean = !!bodyContent;
|
|
|
|
if (!customize) {
|
2023-01-02 18:10:37 +08:00
|
|
|
bodyContent = <DefaultListBody ref={defaultListBodyRef} {...props} />;
|
2020-05-13 19:15:40 +08:00
|
|
|
}
|
2023-01-02 18:10:37 +08:00
|
|
|
return { customize, bodyContent };
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderItem = (item: RecordType): RenderedItem<RecordType> => {
|
|
|
|
const renderResult = render(item);
|
|
|
|
const isRenderResultPlain = isRenderResultPlainObject(renderResult);
|
2020-05-13 19:15:40 +08:00
|
|
|
return {
|
2023-01-02 18:10:37 +08:00
|
|
|
renderedText: isRenderResultPlain
|
|
|
|
? (renderResult as RenderResultObject).value
|
|
|
|
: (renderResult as string),
|
|
|
|
renderedEl: isRenderResultPlain ? (renderResult as RenderResultObject).label : renderResult,
|
|
|
|
item,
|
2020-05-13 19:15:40 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const getFilteredItems = (
|
|
|
|
dataSource: RecordType[],
|
|
|
|
filterValue: string,
|
|
|
|
): {
|
|
|
|
filteredItems: RecordType[];
|
|
|
|
filteredRenderItems: RenderedItem<RecordType>[];
|
|
|
|
} => {
|
|
|
|
const filteredItems: RecordType[] = [];
|
|
|
|
const filteredRenderItems: RenderedItem<RecordType>[] = [];
|
|
|
|
|
|
|
|
dataSource.forEach((item) => {
|
|
|
|
const renderedItem = renderItem(item);
|
|
|
|
const { renderedText } = renderedItem;
|
|
|
|
|
|
|
|
// Filter skip
|
|
|
|
if (filterValue && !matchFilter(renderedText, item)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
filteredItems.push(item);
|
|
|
|
filteredRenderItems.push(renderedItem);
|
|
|
|
});
|
|
|
|
return { filteredItems, filteredRenderItems };
|
|
|
|
};
|
|
|
|
|
|
|
|
const getListBody = (
|
2019-05-09 12:27:35 +08:00
|
|
|
prefixCls: string,
|
|
|
|
searchPlaceholder: string,
|
|
|
|
filterValue: string,
|
2020-11-08 15:28:03 +08:00
|
|
|
filteredItems: RecordType[],
|
2023-01-02 18:10:37 +08:00
|
|
|
notFoundContent: React.ReactNode | React.ReactNode[],
|
2020-11-08 15:28:03 +08:00
|
|
|
filteredRenderItems: RenderedItem<RecordType>[],
|
2019-05-09 12:27:35 +08:00
|
|
|
checkedKeys: string[],
|
2020-11-08 15:28:03 +08:00
|
|
|
renderList?: RenderListFunction<RecordType>,
|
2019-05-09 12:27:35 +08:00
|
|
|
showSearch?: boolean,
|
|
|
|
disabled?: boolean,
|
2023-01-02 18:10:37 +08:00
|
|
|
): React.ReactNode => {
|
2019-05-09 12:27:35 +08:00
|
|
|
const search = showSearch ? (
|
|
|
|
<div className={`${prefixCls}-body-search-wrapper`}>
|
|
|
|
<Search
|
|
|
|
prefixCls={`${prefixCls}-search`}
|
2023-01-02 18:10:37 +08:00
|
|
|
onChange={internalHandleFilter}
|
|
|
|
handleClear={internalHandleClear}
|
2019-05-09 12:27:35 +08:00
|
|
|
placeholder={searchPlaceholder}
|
|
|
|
value={filterValue}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) : null;
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const { bodyContent, customize } = renderListBody(renderList, {
|
|
|
|
...omit(props, OmitProps),
|
2019-07-09 11:46:21 +08:00
|
|
|
filteredItems,
|
|
|
|
filteredRenderItems,
|
|
|
|
selectedKeys: checkedKeys,
|
|
|
|
});
|
2019-05-09 12:27:35 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const getNotFoundContent = () =>
|
|
|
|
Array.isArray(notFoundContent)
|
|
|
|
? notFoundContent[direction === 'left' ? 0 : 1]
|
|
|
|
: notFoundContent;
|
2021-06-23 17:38:16 +08:00
|
|
|
|
2019-07-09 11:46:21 +08:00
|
|
|
let bodyNode: React.ReactNode;
|
|
|
|
// We should wrap customize list body in a classNamed div to use flex layout.
|
|
|
|
if (customize) {
|
|
|
|
bodyNode = <div className={`${prefixCls}-body-customize-wrapper`}>{bodyContent}</div>;
|
|
|
|
} else {
|
|
|
|
bodyNode = filteredItems.length ? (
|
|
|
|
bodyContent
|
|
|
|
) : (
|
2021-06-23 17:38:16 +08:00
|
|
|
<div className={`${prefixCls}-body-not-found`}>{getNotFoundContent()}</div>
|
2019-05-09 12:27:35 +08:00
|
|
|
);
|
|
|
|
}
|
2019-07-09 11:46:21 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
showSearch ? `${prefixCls}-body ${prefixCls}-body-with-search` : `${prefixCls}-body`,
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{search}
|
|
|
|
{bodyNode}
|
|
|
|
</div>
|
|
|
|
);
|
2023-01-02 18:10:37 +08:00
|
|
|
};
|
2019-05-09 12:27:35 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const getCheckBox = ({
|
2021-08-10 19:20:53 +08:00
|
|
|
filteredItems,
|
|
|
|
onItemSelectAll,
|
|
|
|
disabled,
|
|
|
|
prefixCls,
|
|
|
|
}: {
|
|
|
|
filteredItems: RecordType[];
|
|
|
|
onItemSelectAll: (dataSource: string[], checkAll: boolean) => void;
|
|
|
|
disabled?: boolean;
|
|
|
|
prefixCls?: string;
|
2023-01-02 18:10:37 +08:00
|
|
|
}): false | React.ReactNode => {
|
|
|
|
const checkStatus = getCheckStatus(filteredItems);
|
2019-05-09 12:27:35 +08:00
|
|
|
const checkedAll = checkStatus === 'all';
|
2023-01-02 18:10:37 +08:00
|
|
|
const checkAllCheckbox: React.ReactNode = (
|
2019-05-09 12:27:35 +08:00
|
|
|
<Checkbox
|
|
|
|
disabled={disabled}
|
|
|
|
checked={checkedAll}
|
|
|
|
indeterminate={checkStatus === 'part'}
|
2021-03-17 14:56:32 +08:00
|
|
|
className={`${prefixCls}-checkbox`}
|
2019-05-09 12:27:35 +08:00
|
|
|
onChange={() => {
|
|
|
|
// Only select enabled items
|
|
|
|
onItemSelectAll(
|
2022-11-19 13:47:33 +08:00
|
|
|
filteredItems.filter((item) => !item.disabled).map(({ key }) => key),
|
2019-05-09 12:27:35 +08:00
|
|
|
!checkedAll,
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
return checkAllCheckbox;
|
2018-12-07 16:17:45 +08:00
|
|
|
};
|
2017-01-27 17:08:12 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const getSelectAllLabel = (selectedCount: number, totalCount: number): React.ReactNode => {
|
2020-02-04 10:16:23 +08:00
|
|
|
if (selectAllLabel) {
|
|
|
|
return typeof selectAllLabel === 'function'
|
|
|
|
? selectAllLabel({ selectedCount, totalCount })
|
|
|
|
: selectAllLabel;
|
|
|
|
}
|
|
|
|
const unit = totalCount > 1 ? itemsUnit : itemUnit;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{(selectedCount > 0 ? `${selectedCount}/` : '') + totalCount} {unit}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
// Custom Layout
|
|
|
|
const footerDom = footer && (footer.length < 2 ? footer(props) : footer(props, { direction }));
|
2015-12-24 17:44:54 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const listCls = classNames(prefixCls, {
|
|
|
|
[`${prefixCls}-with-pagination`]: !!pagination,
|
|
|
|
[`${prefixCls}-with-footer`]: !!footerDom,
|
|
|
|
});
|
2017-01-27 17:08:12 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
// ====================== Get filtered, checked item list ======================
|
2016-01-13 16:28:36 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const { filteredItems, filteredRenderItems } = getFilteredItems(dataSource, filterValue);
|
2016-03-07 14:52:14 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const listBody = getListBody(
|
|
|
|
prefixCls,
|
|
|
|
searchPlaceholder,
|
|
|
|
filterValue,
|
|
|
|
filteredItems,
|
|
|
|
notFoundContent,
|
|
|
|
filteredRenderItems,
|
|
|
|
checkedKeys,
|
|
|
|
renderList,
|
|
|
|
showSearch,
|
|
|
|
disabled,
|
|
|
|
);
|
2018-12-21 11:41:11 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const listFooter = footerDom ? <div className={`${prefixCls}-footer`}>{footerDom}</div> : null;
|
|
|
|
|
|
|
|
const checkAllCheckbox =
|
|
|
|
!showRemove &&
|
|
|
|
!pagination &&
|
|
|
|
getCheckBox({ filteredItems, onItemSelectAll, disabled, prefixCls });
|
|
|
|
|
|
|
|
let items: MenuProps['items'];
|
|
|
|
|
|
|
|
if (showRemove) {
|
|
|
|
items = [
|
|
|
|
/* Remove Current Page */
|
|
|
|
pagination
|
|
|
|
? {
|
|
|
|
key: 'removeCurrent',
|
|
|
|
label: removeCurrent,
|
|
|
|
onClick() {
|
|
|
|
const pageKeys = getEnabledItemKeys(
|
|
|
|
(defaultListBodyRef.current?.getItems() || []).map((entity) => entity.item),
|
|
|
|
);
|
|
|
|
onItemRemove?.(pageKeys);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
/* Remove All */
|
|
|
|
{
|
|
|
|
key: 'removeAll',
|
|
|
|
label: removeAll,
|
|
|
|
onClick() {
|
|
|
|
onItemRemove?.(getEnabledItemKeys(filteredItems));
|
2022-03-18 15:20:35 +08:00
|
|
|
},
|
2023-01-02 18:10:37 +08:00
|
|
|
},
|
|
|
|
].filter(Boolean);
|
|
|
|
} else {
|
|
|
|
items = [
|
|
|
|
{
|
|
|
|
key: 'selectAll',
|
|
|
|
label: selectAll,
|
|
|
|
onClick() {
|
|
|
|
const keys = getEnabledItemKeys(filteredItems);
|
|
|
|
onItemSelectAll(keys, keys.length !== checkedKeys.length);
|
2022-03-18 15:20:35 +08:00
|
|
|
},
|
2023-01-02 18:10:37 +08:00
|
|
|
},
|
|
|
|
pagination
|
|
|
|
? {
|
|
|
|
key: 'selectCurrent',
|
|
|
|
label: selectCurrent,
|
|
|
|
onClick() {
|
|
|
|
const pageItems = defaultListBodyRef.current?.getItems() || [];
|
|
|
|
onItemSelectAll(getEnabledItemKeys(pageItems.map((entity) => entity.item)), true);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
{
|
|
|
|
key: 'selectInvert',
|
|
|
|
label: selectInvert,
|
|
|
|
onClick() {
|
|
|
|
const availableKeys = getEnabledItemKeys(
|
|
|
|
pagination
|
|
|
|
? (defaultListBodyRef.current?.getItems() || []).map((entity) => entity.item)
|
|
|
|
: filteredItems,
|
|
|
|
);
|
|
|
|
const checkedKeySet = new Set<string>(checkedKeys);
|
|
|
|
const newCheckedKeys: string[] = [];
|
|
|
|
const newUnCheckedKeys: string[] = [];
|
|
|
|
availableKeys.forEach((key) => {
|
|
|
|
if (checkedKeySet.has(key)) {
|
|
|
|
newUnCheckedKeys.push(key);
|
2022-03-18 15:20:35 +08:00
|
|
|
} else {
|
2023-01-02 18:10:37 +08:00
|
|
|
newCheckedKeys.push(key);
|
2022-03-18 15:20:35 +08:00
|
|
|
}
|
2023-01-02 18:10:37 +08:00
|
|
|
});
|
|
|
|
onItemSelectAll(newCheckedKeys, true);
|
|
|
|
onItemSelectAll(newUnCheckedKeys, false);
|
2022-03-18 15:20:35 +08:00
|
|
|
},
|
2023-01-02 18:10:37 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
2020-05-13 19:15:40 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
const dropdown = (
|
|
|
|
<Dropdown className={`${prefixCls}-header-dropdown`} menu={{ items }} disabled={disabled}>
|
|
|
|
<DownOutlined />
|
|
|
|
</Dropdown>
|
|
|
|
);
|
2016-11-28 19:14:43 +08:00
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
return (
|
|
|
|
<div className={listCls} style={style}>
|
|
|
|
{/* Header */}
|
|
|
|
<div className={`${prefixCls}-header`}>
|
|
|
|
{showSelectAll ? (
|
|
|
|
<>
|
|
|
|
{checkAllCheckbox}
|
|
|
|
{dropdown}
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
<span className={`${prefixCls}-header-selected`}>
|
|
|
|
{getSelectAllLabel(checkedKeys.length, filteredItems.length)}
|
|
|
|
</span>
|
|
|
|
<span className={`${prefixCls}-header-title`}>{titleText}</span>
|
2016-01-07 14:21:29 +08:00
|
|
|
</div>
|
2023-01-02 18:10:37 +08:00
|
|
|
{listBody}
|
|
|
|
{listFooter}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-01-04 15:09:03 +08:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
TransferList.displayName = 'TransferList';
|
|
|
|
}
|
|
|
|
|
2023-01-02 18:10:37 +08:00
|
|
|
export default TransferList;
|