antd
Version:
An enterprise-class UI design language and React components implementation
44 lines (43 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getColumnKey = void 0;
exports.getColumnPos = getColumnPos;
exports.safeColumnTitle = exports.renderColumnTitle = void 0;
var _is = require("../_util/is");
const getColumnKey = (column, defaultKey) => {
if ('key' in column && (0, _is.isNonNullable)(column.key)) {
return column.key;
}
if (column.dataIndex) {
return Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : column.dataIndex;
}
return defaultKey;
};
exports.getColumnKey = getColumnKey;
function getColumnPos(index, pos) {
return pos ? `${pos}-${index}` : `${index}`;
}
const renderColumnTitle = (title, props) => {
if ((0, _is.isFunction)(title)) {
return title(props);
}
return title;
};
/**
* Safe get column title
*
* Should filter object
*
* @param title
*/
exports.renderColumnTitle = renderColumnTitle;
const safeColumnTitle = (title, props) => {
const result = renderColumnTitle(title, props);
if ((0, _is.isPlainObject)(result) || Array.isArray(result)) {
return '';
}
return result;
};
exports.safeColumnTitle = safeColumnTitle;