UNPKG

@alilc/lowcode-editor-skeleton

Version:

alibaba lowcode editor skeleton

55 lines (54 loc) 1.47 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.composeTitle = composeTitle; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _lowcodeUtils = require("@alilc/lowcode-utils"); var _react = require("react"); 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__*/(0, _react.isValidElement)(_title) || (0, _lowcodeUtils.isI18nData)(_title)) { if (/*#__PURE__*/(0, _react.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 = (0, _extends2["default"])({}, _title, { icon: icon, tip: tip }); } } if ((0, _lowcodeUtils.isTitleConfig)(_title) && noIcon) { if (! /*#__PURE__*/(0, _react.isValidElement)(_title)) { _title.icon = undefined; } } return _title; }