forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtitle.ts
More file actions
44 lines (40 loc) · 983 Bytes
/
title.ts
File metadata and controls
44 lines (40 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { ReactElement, ReactNode } from 'react';
import { I18nData, isI18nData } from './i18n';
import { TipContent } from './tip';
import { IconType } from './icon';
/**
* 描述 props 的 setter title
*/
export interface TitleConfig {
/**
* 文字描述
*/
label?: I18nData | ReactNode;
/**
* hover 后的展现内容
*/
tip?: TipContent;
/**
* 文档链接,暂未实现
*/
docUrl?: string;
/**
* 图标
*/
icon?: IconType;
/**
* CSS 类
*/
className?: string;
}
export type TitleContent = string | I18nData | ReactElement | TitleConfig;
function isPlainObject(value: any): value is Record<string, unknown> {
if (typeof value !== 'object') {
return false;
}
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null;
}
export function isTitleConfig(obj: any): obj is TitleConfig {
return isPlainObject(obj) && !isI18nData(obj);
}