1 | import * as React from 'react';
|
2 | import type { RenderEmptyHandler } from '../config-provider';
|
3 | import type { InputStatus } from '../_util/statusUtils';
|
4 | import type { PaginationType } from './interface';
|
5 | import type { TransferListProps } from './list';
|
6 | import List from './list';
|
7 | import type { TransferListBodyProps } from './ListBody';
|
8 | import Search from './search';
|
9 | export type { TransferListProps } from './list';
|
10 | export type { TransferOperationProps } from './operation';
|
11 | export type { TransferSearchProps } from './search';
|
12 | export type TransferDirection = 'left' | 'right';
|
13 | export interface RenderResultObject {
|
14 | label: React.ReactElement;
|
15 | value: string;
|
16 | }
|
17 | export type RenderResult = React.ReactElement | RenderResultObject | string | null;
|
18 | export interface TransferItem {
|
19 | key?: string;
|
20 | title?: string;
|
21 | description?: string;
|
22 | disabled?: boolean;
|
23 | [name: string]: any;
|
24 | }
|
25 | export type KeyWise<T> = T & {
|
26 | key: string;
|
27 | };
|
28 | export type KeyWiseTransferItem = KeyWise<TransferItem>;
|
29 | type TransferRender<RecordType> = (item: RecordType) => RenderResult;
|
30 | export interface ListStyle {
|
31 | direction: TransferDirection;
|
32 | }
|
33 | export type SelectAllLabel = React.ReactNode | ((info: {
|
34 | selectedCount: number;
|
35 | totalCount: number;
|
36 | }) => React.ReactNode);
|
37 | export interface TransferLocale {
|
38 | titles?: React.ReactNode[];
|
39 | notFoundContent?: React.ReactNode | React.ReactNode[];
|
40 | searchPlaceholder: string;
|
41 | itemUnit: string;
|
42 | itemsUnit: string;
|
43 | remove?: string;
|
44 | selectAll?: string;
|
45 | selectCurrent?: string;
|
46 | selectInvert?: string;
|
47 | removeAll?: string;
|
48 | removeCurrent?: string;
|
49 | }
|
50 | export interface TransferProps<RecordType> {
|
51 | prefixCls?: string;
|
52 | className?: string;
|
53 | disabled?: boolean;
|
54 | dataSource?: RecordType[];
|
55 | targetKeys?: string[];
|
56 | selectedKeys?: string[];
|
57 | render?: TransferRender<RecordType>;
|
58 | onChange?: (targetKeys: string[], direction: TransferDirection, moveKeys: string[]) => void;
|
59 | onSelectChange?: (sourceSelectedKeys: string[], targetSelectedKeys: string[]) => void;
|
60 | style?: React.CSSProperties;
|
61 | listStyle?: ((style: ListStyle) => React.CSSProperties) | React.CSSProperties;
|
62 | operationStyle?: React.CSSProperties;
|
63 | titles?: React.ReactNode[];
|
64 | operations?: string[];
|
65 | showSearch?: boolean;
|
66 | filterOption?: (inputValue: string, item: RecordType) => boolean;
|
67 | locale?: Partial<TransferLocale>;
|
68 | footer?: (props: TransferListProps<RecordType>, info?: {
|
69 | direction: TransferDirection;
|
70 | }) => React.ReactNode;
|
71 | rowKey?: (record: RecordType) => string;
|
72 | onSearch?: (direction: TransferDirection, value: string) => void;
|
73 | onScroll?: (direction: TransferDirection, e: React.SyntheticEvent<HTMLUListElement>) => void;
|
74 | children?: (props: TransferListBodyProps<RecordType>) => React.ReactNode;
|
75 | showSelectAll?: boolean;
|
76 | selectAllLabels?: SelectAllLabel[];
|
77 | oneWay?: boolean;
|
78 | pagination?: PaginationType;
|
79 | status?: InputStatus;
|
80 | }
|
81 | interface TransferState {
|
82 | sourceSelectedKeys: string[];
|
83 | targetSelectedKeys: string[];
|
84 | }
|
85 | declare class Transfer<RecordType extends TransferItem = TransferItem> extends React.Component<TransferProps<RecordType>, TransferState> {
|
86 | static List: typeof List;
|
87 | static Operation: ({ disabled, moveToLeft, moveToRight, leftArrowText, rightArrowText, leftActive, rightActive, className, style, direction, oneWay, }: import("./operation").TransferOperationProps) => JSX.Element;
|
88 | static Search: typeof Search;
|
89 | static getDerivedStateFromProps<T>({ selectedKeys, targetKeys, pagination, children, }: TransferProps<T>): {
|
90 | sourceSelectedKeys: string[];
|
91 | targetSelectedKeys: string[];
|
92 | } | null;
|
93 | separatedDataSource: {
|
94 | leftDataSource: RecordType[];
|
95 | rightDataSource: RecordType[];
|
96 | } | null;
|
97 | constructor(props: TransferProps<RecordType>);
|
98 | setStateKeys: (direction: TransferDirection, keys: string[] | ((prevKeys: string[]) => string[])) => void;
|
99 | getTitles(transferLocale: TransferLocale): React.ReactNode[];
|
100 | getLocale: (transferLocale: TransferLocale, renderEmpty: RenderEmptyHandler) => {
|
101 | titles?: React.ReactNode[] | undefined;
|
102 | notFoundContent: React.ReactNode;
|
103 | searchPlaceholder: string;
|
104 | itemUnit: string;
|
105 | itemsUnit: string;
|
106 | remove?: string | undefined;
|
107 | selectAll?: string | undefined;
|
108 | selectCurrent?: string | undefined;
|
109 | selectInvert?: string | undefined;
|
110 | removeAll?: string | undefined;
|
111 | removeCurrent?: string | undefined;
|
112 | };
|
113 | moveTo: (direction: TransferDirection) => void;
|
114 | moveToLeft: () => void;
|
115 | moveToRight: () => void;
|
116 | onItemSelectAll: (direction: TransferDirection, selectedKeys: string[], checkAll: boolean) => void;
|
117 | onLeftItemSelectAll: (selectedKeys: string[], checkAll: boolean) => void;
|
118 | onRightItemSelectAll: (selectedKeys: string[], checkAll: boolean) => void;
|
119 | handleFilter: (direction: TransferDirection, e: React.ChangeEvent<HTMLInputElement>) => void;
|
120 | handleLeftFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
121 | handleRightFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
122 | handleClear: (direction: TransferDirection) => void;
|
123 | handleLeftClear: () => void;
|
124 | handleRightClear: () => void;
|
125 | onItemSelect: (direction: TransferDirection, selectedKey: string, checked: boolean) => void;
|
126 | onLeftItemSelect: (selectedKey: string, checked: boolean) => void;
|
127 | onRightItemSelect: (selectedKey: string, checked: boolean) => void;
|
128 | onRightItemRemove: (selectedKeys: string[]) => void;
|
129 | handleScroll: (direction: TransferDirection, e: React.SyntheticEvent<HTMLUListElement>) => void;
|
130 | handleLeftScroll: (e: React.SyntheticEvent<HTMLUListElement>) => void;
|
131 | handleRightScroll: (e: React.SyntheticEvent<HTMLUListElement>) => void;
|
132 | handleSelectChange(direction: TransferDirection, holder: string[]): void;
|
133 | handleListStyle: (listStyle: TransferProps<RecordType>['listStyle'], direction: TransferDirection) => React.CSSProperties | undefined;
|
134 | separateDataSource(): {
|
135 | leftDataSource: KeyWise<RecordType>[];
|
136 | rightDataSource: KeyWise<RecordType>[];
|
137 | };
|
138 | render(): JSX.Element;
|
139 | }
|
140 | export default Transfer;
|