mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
1719748a29
* chore: eslint add consistent-type-imports * fix avatar * Update Item.tsx
29 lines
812 B
TypeScript
29 lines
812 B
TypeScript
/* eslint-disable import/prefer-default-export */
|
|
import type { ColumnType, ColumnTitle, ColumnTitleProps, Key } from './interface';
|
|
|
|
export function getColumnKey<RecordType>(column: ColumnType<RecordType>, defaultKey: string): Key {
|
|
if ('key' in column && column.key !== undefined && column.key !== null) {
|
|
return column.key;
|
|
}
|
|
if (column.dataIndex) {
|
|
return (Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : column.dataIndex) as Key;
|
|
}
|
|
|
|
return defaultKey;
|
|
}
|
|
|
|
export function getColumnPos(index: number, pos?: string) {
|
|
return pos ? `${pos}-${index}` : `${index}`;
|
|
}
|
|
|
|
export function renderColumnTitle<RecordType>(
|
|
title: ColumnTitle<RecordType>,
|
|
props: ColumnTitleProps<RecordType>,
|
|
) {
|
|
if (typeof title === 'function') {
|
|
return title(props);
|
|
}
|
|
|
|
return title;
|
|
}
|