index.d.ts 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import type { CSSProperties } from 'react';
  2. import React from 'react';
  3. import type { InputStatus } from '../_util/statusUtils';
  4. import type { PaginationType, TransferKey } from './interface';
  5. import type { TransferCustomListBodyProps, TransferListProps } from './list';
  6. export type { TransferListProps } from './list';
  7. export type { TransferOperationProps } from './operation';
  8. export type { TransferSearchProps } from './search';
  9. export type TransferDirection = 'left' | 'right';
  10. export interface RenderResultObject {
  11. label: React.ReactElement;
  12. value: string;
  13. }
  14. export type RenderResult = React.ReactElement | RenderResultObject | string | null;
  15. export interface TransferItem {
  16. key?: TransferKey;
  17. title?: string;
  18. description?: string;
  19. disabled?: boolean;
  20. [name: string]: any;
  21. }
  22. export type KeyWise<T> = T & {
  23. key: TransferKey;
  24. };
  25. export type KeyWiseTransferItem = KeyWise<TransferItem>;
  26. type TransferRender<RecordType> = (item: RecordType) => RenderResult;
  27. export interface ListStyle {
  28. direction: TransferDirection;
  29. }
  30. export type SelectAllLabel = React.ReactNode | ((info: {
  31. selectedCount: number;
  32. totalCount: number;
  33. }) => React.ReactNode);
  34. export interface TransferLocale {
  35. titles?: React.ReactNode[];
  36. notFoundContent?: React.ReactNode | React.ReactNode[];
  37. searchPlaceholder: string;
  38. itemUnit: string;
  39. itemsUnit: string;
  40. remove?: string;
  41. selectAll?: string;
  42. deselectAll?: string;
  43. selectCurrent?: string;
  44. selectInvert?: string;
  45. removeAll?: string;
  46. removeCurrent?: string;
  47. }
  48. export interface TransferSearchOption {
  49. placeholder?: string;
  50. defaultValue?: string;
  51. }
  52. export interface TransferProps<RecordType = any> {
  53. prefixCls?: string;
  54. className?: string;
  55. rootClassName?: string;
  56. disabled?: boolean;
  57. dataSource?: RecordType[];
  58. targetKeys?: TransferKey[];
  59. selectedKeys?: TransferKey[];
  60. render?: TransferRender<RecordType>;
  61. onChange?: (targetKeys: TransferKey[], direction: TransferDirection, moveKeys: TransferKey[]) => void;
  62. onSelectChange?: (sourceSelectedKeys: TransferKey[], targetSelectedKeys: TransferKey[]) => void;
  63. style?: React.CSSProperties;
  64. listStyle?: ((style: ListStyle) => CSSProperties) | CSSProperties;
  65. operationStyle?: CSSProperties;
  66. titles?: React.ReactNode[];
  67. operations?: string[];
  68. showSearch?: boolean | TransferSearchOption;
  69. filterOption?: (inputValue: string, item: RecordType, direction: TransferDirection) => boolean;
  70. locale?: Partial<TransferLocale>;
  71. footer?: (props: TransferListProps<RecordType>, info?: {
  72. direction: TransferDirection;
  73. }) => React.ReactNode;
  74. rowKey?: (record: RecordType) => TransferKey;
  75. onSearch?: (direction: TransferDirection, value: string) => void;
  76. onScroll?: (direction: TransferDirection, e: React.SyntheticEvent<HTMLUListElement>) => void;
  77. children?: (props: TransferCustomListBodyProps<RecordType>) => React.ReactNode;
  78. showSelectAll?: boolean;
  79. selectAllLabels?: SelectAllLabel[];
  80. oneWay?: boolean;
  81. pagination?: PaginationType;
  82. status?: InputStatus;
  83. selectionsIcon?: React.ReactNode;
  84. }
  85. declare const Transfer: {
  86. <RecordType extends TransferItem = TransferItem>(props: TransferProps<RecordType>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
  87. displayName: string;
  88. List: {
  89. <RecordType extends KeyWiseTransferItem>(props: TransferListProps<RecordType>): React.JSX.Element;
  90. displayName: string;
  91. };
  92. Search: React.FC<import("./search").TransferSearchProps>;
  93. Operation: React.FC<import("./operation").TransferOperationProps>;
  94. };
  95. export default Transfer;