MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / composeTitle

Function composeTitle

packages/editor-skeleton/src/widget/utils.ts:5–53  ·  view source on GitHub ↗
(title?: IPublicTypeTitleContent, icon?: IPublicTypeIconType, tip?: TipContent, tipAsTitle?: boolean, noIcon?: boolean)

Source from the content-addressed store, hash-verified

3import { isValidElement } from 'react';
4
5export 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}

Callers 4

DockViewFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
utils.test.tsFile · 0.90

Calls 2

isI18nDataFunction · 0.50
isTitleConfigFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…