()
| 81 | }; |
| 82 | |
| 83 | render() { |
| 84 | // eslint-disable-next-line prefer-const |
| 85 | const { title, className } = this.props; |
| 86 | let _title: IPublicTypeTitleConfig; |
| 87 | if (title == null) { |
| 88 | return null; |
| 89 | } |
| 90 | if (isValidElement(title)) { |
| 91 | return title; |
| 92 | } |
| 93 | if (typeof title === 'string' || isI18nData(title)) { |
| 94 | _title = { label: title }; |
| 95 | } else if (isTitleConfig(title)) { |
| 96 | _title = title; |
| 97 | } else { |
| 98 | _title = { |
| 99 | label: title, |
| 100 | }; |
| 101 | } |
| 102 | |
| 103 | const icon = _title.icon ? createIcon(_title.icon, { size: 20 }) : null; |
| 104 | |
| 105 | let tip: any = null; |
| 106 | if (_title.tip) { |
| 107 | if (isValidElement(_title.tip) && _title.tip.type === Tip) { |
| 108 | tip = _title.tip; |
| 109 | } else { |
| 110 | const tipProps = |
| 111 | typeof _title.tip === 'object' && !(isValidElement(_title.tip) || isI18nData(_title.tip)) |
| 112 | ? _title.tip |
| 113 | : { children: _title.tip }; |
| 114 | tip = <Tip {...tipProps} />; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return ( |
| 119 | <span |
| 120 | className={classNames('lc-title', className, _title.className, { |
| 121 | 'has-tip': !!tip, |
| 122 | 'only-icon': !_title.label, |
| 123 | })} |
| 124 | onClick={this.handleClick} |
| 125 | > |
| 126 | {icon ? <b className="lc-title-icon">{icon}</b> : null} |
| 127 | {this.renderLabel(_title.label)} |
| 128 | {tip} |
| 129 | </span> |
| 130 | ); |
| 131 | } |
| 132 | } |
nothing calls this directly
no test coverage detected