UNPKG

@alilc/lowcode-editor-skeleton

Version:

alibaba lowcode editor skeleton

50 lines 1.21 kB
import _extends from "@babel/runtime/helpers/extends"; import { isI18nData, isTitleConfig } from '@alilc/lowcode-utils'; import { isValidElement } from 'react'; export function composeTitle(title, icon, tip, tipAsTitle, noIcon) { var _title; if (!title) { _title = {}; if (!icon || tipAsTitle) { _title = { label: tip }; tip = undefined; } } else { _title = title; } if (icon || tip) { if (typeof _title !== 'object' || /*#__PURE__*/isValidElement(_title) || isI18nData(_title)) { if (/*#__PURE__*/isValidElement(_title)) { if (_title.type === 'svg' || _title.type.getIcon) { if (!icon) { icon = _title; } if (tipAsTitle) { _title = tip; tip = null; } else { _title = undefined; } } } _title = { label: _title, icon: icon, tip: tip }; } else { _title = _extends({}, _title, { icon: icon, tip: tip }); } } if (isTitleConfig(_title) && noIcon) { if (! /*#__PURE__*/isValidElement(_title)) { _title.icon = undefined; } } return _title; }