import React from 'react'; import styles from './index.less'; import { Statistic, Tabs } from 'antd'; import IconFont from '@sensoro/library/lib/components/icon-font'; import classnames from 'classnames'; import { NoField } from '@sensoro/sensoro-design'; import { formatNumber } from '@/utils'; const { TabPane } = Tabs; interface CardProps { title: string; extra?: React.ReactNode | string; } export const Card: React.FC = props => { const { title, extra, children } = props; return (
{title} {extra}
{children}
); }; // 把number按size分组,返回最后一组的最小值 function getFlagNumber(number: number, size: number) { let res = -1; for (let i = number; i > 0; --i) { if (i % size === 0) { res = i; if (i === number) { continue; } else { res = i; break; } } } return res; } interface DescriptionsProps { column?: number; title?: string | React.ReactNode; style?: React.CSSProperties; offset?: number | { x: number; y: number }; } export const Descriptions: React.FC = props => { const { column = 1, title, style, offset, children } = props; const offsetX = (typeof offset === 'number' ? offset : offset?.x) ?? 0; const offsetY = (typeof offset === 'number' ? offset : offset?.y) ?? 0; const itemWidth = `calc(${100 / column}% - ${(offsetX * (column - 1)) / column}px)`; const childCount = React.Children.count(children); const flagNumber = getFlagNumber(childCount, column); return (
{title &&
{title}
}
{children && //@ts-ignore React.Children.map(children, i => i) .filter((i: any) => i) .map((child: any, idx: number) => (
{child}
))}
); }; Descriptions.defaultProps = { column: 1, offset: 16, }; interface DescriptionsItemProps { label: string | React.ReactNode; placeHolder?: string | React.ReactNode; } export const DescriptionsItem: React.FC = props => { const { label, children, placeHolder } = props; // const childCount = React.Children.count(children); return ( <> {label}
{children || placeHolder}
); }; DescriptionsItem.defaultProps = { placeHolder: , }; interface DescriptionsBorderItemProps { label: string; value: number; icon?: string; } export const DescriptionsBorderItem: React.FC = props => { const { label, value, icon } = props; return (
{formatNumber(value)}
{label}
{/* */} {icon && (
)}
); }; DescriptionsBorderItem.defaultProps = { precision: 2, }; export const TabsView: React.FC = props => { const { title, children, ...rest } = props; return (
{children}
{title}
); }; export const TabViewPane: React.FC = props => { const { children, ...rest } = props; return (
{children}
); }; export const ContentHeader: React.FC = props => { const { style, title, children } = props; return (
{title}
{children}
); };