(title?: IPublicTypeTitleContent, icon?: IPublicTypeIconType, tip?: TipContent, tipAsTitle?: boolean, noIcon?: boolean)
| 3 | import { isValidElement } from 'react'; |
| 4 | |
| 5 | export function composeTitle(title?: IPublicTypeTitleContent, icon?: IPublicTypeIconType, tip?: TipContent, tipAsTitle?: boolean, noIcon?: boolean) { |
| 6 | let _title: IPublicTypeTitleContent | undefined; |
| 7 | if (!title) { |
| 8 | _title = {}; |
| 9 | if (!icon || tipAsTitle) { |
| 10 | _title = { |
| 11 | label: tip, |
| 12 | }; |
| 13 | tip = undefined; |
| 14 | } |
| 15 | } else { |
| 16 | _title = title; |
| 17 | } |
| 18 | |
| 19 | if (icon || tip) { |
| 20 | if (typeof _title !== 'object' || isValidElement(_title) || isI18nData(_title)) { |
| 21 | if (isValidElement(_title)) { |
| 22 | if (_title.type === 'svg' || _title.type.getIcon) { |
| 23 | if (!icon) { |
| 24 | icon = _title; |
| 25 | } |
| 26 | if (tipAsTitle) { |
| 27 | _title = tip; |
| 28 | tip = null; |
| 29 | } else { |
| 30 | _title = undefined; |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | _title = { |
| 35 | label: _title, |
| 36 | icon, |
| 37 | tip, |
| 38 | }; |
| 39 | } else { |
| 40 | _title = { |
| 41 | ..._title, |
| 42 | icon, |
| 43 | tip, |
| 44 | }; |
| 45 | } |
| 46 | } |
| 47 | if (isTitleConfig(_title) && noIcon) { |
| 48 | if (!isValidElement(_title)) { |
| 49 | _title.icon = undefined; |
| 50 | } |
| 51 | } |
| 52 | return _title; |
| 53 | } |
no test coverage detected
searching dependent graphs…