import React from "react"; import classNames from "classnames"; import { StyledProps } from "../_type"; import { Icon } from "../icon"; import { Text } from "../text"; import { useConfig } from "../_util/config-context"; import { forwardRefWithStatics } from "../_util/forward-ref-with-statics"; import { Bubble, BubbleProps } from "../bubble"; interface TransferCellProps extends StyledProps { /** * Cell 标题 */ title?: React.ReactNode; /** * Cell 内容区头部内容 */ header?: React.ReactNode; /** * Cell 底部提示 */ tip?: React.ReactNode; /** * Cell 内容 */ children: React.ReactNode; /** * Cell 内容区是否垂直可滚动 * * 需要实现内容内部滚动时(如 Table),可禁用此选项 * * @default true */ scrollable?: boolean; } export const TransferCell = React.forwardRef(function TransferCell( { title, tip, header, children, scrollable = true, className, ...props }: TransferCellProps, ref: React.Ref ) { const { classPrefix } = useConfig(); return (
{typeof title !== "undefined" && (
{typeof title === "string" ?

{title}

: title}
)}
{header}
{children}
{typeof tip === "string" ? {tip} : tip}
); }); TransferCell.displayName = "TransferCell"; export interface TransferOperation extends StyledProps { /** * 点击回调 */ onClick?: (event: React.MouseEvent) => void; /** * 是否禁用 * @default false */ disabled?: boolean; /** * 是否为加载中状态 * @default false */ loading?: boolean; /** * 气泡提示内容 */ bubble?: React.ReactNode; } export interface TransferProps extends StyledProps { /** * 头部内容 */ header?: React.ReactNode; /** * 左侧 TransferCell * @docType React.ReactElement */ leftCell: React.ReactElement; /** * 右侧 TransferCell * @docType React.ReactElement */ rightCell: React.ReactElement; /** * 操作按钮配置 * @default [false, false] * @since 2.7.0 */ operations?: [false | TransferOperation, false | TransferOperation]; } function TransferButton({ icon, className, disabled, loading, onClick, bubble, bubblePlacement, ...props }: TransferOperation & { icon: string; bubblePlacement?: BubbleProps["placement"]; }) { const { classPrefix } = useConfig(); return ( { if (!disabled && !loading) { onClick(event); } }} {...props} > ); } TransferButton.displayName = "TransferButton"; export const Transfer = forwardRefWithStatics( function Transfer( { header, leftCell, rightCell, className, operations = [false, false], ...props }: TransferProps, ref: React.Ref ) { const { classPrefix } = useConfig(); const [left, right] = operations; return (
{header && (
{header}
)}
{leftCell}
{!left && !right ? ( ) : (
{left && ( )} {right && ( )}
)}
{rightCell}
); }, { Cell: TransferCell, } ); Transfer.displayName = "Transfer";