forked from DTStack/dt-react-component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
24 lines (20 loc) · 744 Bytes
/
index.ts
File metadata and controls
24 lines (20 loc) · 744 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
import React from 'react';
import { AlertProps, TooltipProps } from 'antd';
export type LabelTooltipType = TooltipProps | TooltipProps['title'];
export function toTooltipProps(tooltip: LabelTooltipType): TooltipProps | null {
if (tooltip !== null && typeof tooltip === 'object' && !React.isValidElement(tooltip)) {
return tooltip as TooltipProps;
}
return {
title: tooltip,
};
}
type BannerPropType = AlertProps['message'] | Omit<AlertProps, 'banner'>;
export function isAlertObjectProps(banner: BannerPropType): banner is Omit<AlertProps, 'banner'> {
return (
typeof banner === 'object' &&
banner !== null &&
!React.isValidElement(banner) &&
'message' in banner
);
}