mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
1444043fd8
This reverts commit ce17f19ca0
.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { TableLocale } from './interface';
|
|
|
|
interface DefaultExpandIconProps<RecordType> {
|
|
prefixCls: string;
|
|
onExpand: (record: RecordType, e: React.MouseEvent<HTMLElement>) => void;
|
|
record: RecordType;
|
|
expanded: boolean;
|
|
expandable: boolean;
|
|
}
|
|
|
|
function renderExpandIcon(locale: TableLocale) {
|
|
return function expandIcon<RecordType>({
|
|
prefixCls,
|
|
onExpand,
|
|
record,
|
|
expanded,
|
|
expandable,
|
|
}: DefaultExpandIconProps<RecordType>) {
|
|
const iconPrefix = `${prefixCls}-row-expand-icon`;
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={e => {
|
|
onExpand(record, e!);
|
|
e.stopPropagation();
|
|
}}
|
|
className={classNames(iconPrefix, {
|
|
[`${iconPrefix}-spaced`]: !expandable,
|
|
[`${iconPrefix}-expanded`]: expandable && expanded,
|
|
[`${iconPrefix}-collapsed`]: expandable && !expanded,
|
|
})}
|
|
aria-label={expanded ? locale.collapse : locale.expand}
|
|
/>
|
|
);
|
|
};
|
|
}
|
|
|
|
export default renderExpandIcon;
|