mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 21:20:28 +00:00
29 lines
645 B
TypeScript
29 lines
645 B
TypeScript
import { IconType, TitleContent, isI18nData, TipContent } from '@ali/lowcode-types';
|
|
import { isValidElement } from 'react';
|
|
|
|
export function composeTitle(title?: TitleContent, icon?: IconType, tip?: TipContent, tipAsTitle?: boolean) {
|
|
if (!title) {
|
|
title = {};
|
|
if (!icon || tipAsTitle) {
|
|
title.label = tip;
|
|
tip = undefined;
|
|
}
|
|
}
|
|
if (icon || tip) {
|
|
if (typeof title !== 'object' || isValidElement(title) || isI18nData(title)) {
|
|
title = {
|
|
label: title,
|
|
icon,
|
|
tip,
|
|
};
|
|
} else {
|
|
title = {
|
|
...title,
|
|
icon,
|
|
tip
|
|
};
|
|
}
|
|
}
|
|
return title;
|
|
}
|