Просмотр исходного кода

Support typescript (#341)

* fix some errors found during use

* fix some errors found during use

* Replace  "string | React.ReactNode" with  React.ReactNode

* replace with * as React

* remove excess property
陈帅 8 лет назад
Родитель
Сommit
8feaa32bb3

+ 1 - 1
src/components/AvatarList/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface AvatarItemProps {
   tips: React.ReactNode;
   src: string;

+ 2 - 2
src/components/Charts/Bar/index.d.ts

@@ -1,6 +1,6 @@
-import React from "react";
+import * as React from "react";
 export interface BarProps {
-  title: string | React.ReactNode;
+  title: React.ReactNode;
   color?: string;
   margin?: [number, number, number, number];
   height: number;

+ 3 - 3
src/components/Charts/ChartCard/index.d.ts

@@ -1,10 +1,10 @@
-import React from "react";
+import * as React from "react";
 export interface ChartCardProps {
-  title: string | React.ReactNode;
+  title: React.ReactNode;
   action?: React.ReactNode;
   total?: React.ReactNode | number;
   footer?: React.ReactNode;
-  contentHeight: number;
+  contentHeight?: number;
   avatar?: React.ReactNode;
 }
 

+ 3 - 3
src/components/Charts/Field/index.d.ts

@@ -1,7 +1,7 @@
-import React from "react";
+import * as React from "react";
 export interface FieldProps {
-  label: string | React.ReactNode;
-  value: string | React.ReactNode;
+  label: React.ReactNode;
+  value: React.ReactNode;
 }
 
 export default class Field extends React.Component<FieldProps, any> {}

+ 2 - 2
src/components/Charts/Gauge/index.d.ts

@@ -1,6 +1,6 @@
-import React from "react";
+import * as React from "react";
 export interface GaugeProps {
-  title: string | React.ReactNode;
+  title: React.ReactNode;
   color?: string;
   height: number;
   bgColor?: number;

+ 1 - 1
src/components/Charts/MiniArea/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 
 // g2已经更新到3.0
 // 不带的写了

+ 1 - 1
src/components/Charts/MiniBar/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface MiniBarProps {
   color?: string;
   height: number;

+ 3 - 3
src/components/Charts/MiniProgress/index.d.ts

@@ -1,9 +1,9 @@
-import React from "react";
+import * as React from "react";
 export interface MiniProgressProps {
   target: number;
   color?: string;
-  strokeWidth: number;
-  percent: number;
+  strokeWidth?: number;
+  percent?: number;
 }
 
 export default class MiniProgress extends React.Component<

+ 3 - 3
src/components/Charts/Pie/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface PieProps {
   animate?: boolean;
   color?: string;
@@ -11,10 +11,10 @@ export interface PieProps {
     y: number;
   }>;
   total?: string;
-  title?: string | React.ReactNode;
+  title?: React.ReactNode;
   tooltip?: boolean;
   valueFormat?: (value: string) => string;
-  subTitle?: string | React.ReactNode;
+  subTitle?: React.ReactNode;
 }
 
 export default class Pie extends React.Component<PieProps, any> {}

+ 2 - 2
src/components/Charts/Radar/index.d.ts

@@ -1,6 +1,6 @@
-import React from "react";
+import * as React from "react";
 export interface RadarProps {
-  title?: string | React.ReactNode;
+  title?: React.ReactNode;
   height: number;
   margin?: [number, number, number, number];
   hasLegend?: boolean;

+ 1 - 1
src/components/Charts/TagCloud/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface TagCloudProps {
   data: Array<{
     name: string;

+ 1 - 1
src/components/Charts/TimelineChart/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface TimelineChartProps {
   data: Array<{
     x: string;

+ 2 - 2
src/components/Charts/WaterWave/index.d.ts

@@ -1,6 +1,6 @@
-import React from "react";
+import * as React from "react";
 export interface WaterWaveProps {
-  title: string | React.ReactNode;
+  title: React.ReactNode;
   color?: string;
   height: number;
   percent: number;

+ 1 - 1
src/components/CountDown/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface CountDownProps {
   format?: (time: number) => void;
   target: Date | number;

+ 1 - 1
src/components/DescriptionList/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface DescriptionListProps {
   layout?: "horizontal" | "vertical";
   col?: number;

+ 1 - 1
src/components/Ellipsis/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface EllipsisProps {
   tooltip?: boolean;
   length?: number;

+ 2 - 2
src/components/Exception/index.d.ts

@@ -1,11 +1,11 @@
-import React from "react";
+import * as React from "react";
 export interface ExceptionProps {
   type?: "403" | "404" | "500";
   title?: React.ReactNode;
   desc?: React.ReactNode;
   img?: string;
   actions?: React.ReactNode;
-  linkElement?: string | React.ReactNode;
+  linkElement?: React.ReactNode;
 }
 
 export default class Exception extends React.Component<ExceptionProps, any> {}

+ 1 - 1
src/components/FooterToolbar/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface FooterToolbarProps {
   extra: React.ReactNode;
 }

+ 2 - 2
src/components/GlobalFooter/index.d.ts

@@ -1,7 +1,7 @@
-import React from "react";
+import * as React from "react";
 export interface GlobalFooterProps {
   links: Array<{
-    title: string | React.ReactNode;
+    title: React.ReactNode;
     href: string;
     blankTarget?: boolean;
   }>;

+ 1 - 1
src/components/HeaderSearch/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface HeaderSearchProps {
   placeholder?: string;
   dataSource?: Array<string>;

+ 1 - 1
src/components/NoticeIcon/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface NoticeIconData {
   avatar: string;
   title: React.ReactNode;

+ 8 - 7
src/components/NumberInfo/index.d.ts

@@ -1,11 +1,12 @@
-import React from "react";
+import * as React from "react";
 export interface NumberInfoProps {
-  title: React.ReactNode | string;
-  subTitle: React.ReactNode | string;
-  total: React.ReactNode | string;
-  status: "up" | "down";
-  theme: string;
-  gap: number;
+  title?: React.ReactNode | string;
+  subTitle?: React.ReactNode | string;
+  total?: React.ReactNode | string;
+  status?: "up" | "down";
+  theme?: string;
+  gap?: number;
+  subTotal?: number;
 }
 
 export default class NumberInfo extends React.Component<NumberInfoProps, any> {}

+ 1 - 0
src/components/NumberInfo/index.md

@@ -16,6 +16,7 @@ order: 10
 title | 标题 | ReactNode\|string | -
 subTitle | 子标题 | ReactNode\|string | -
 total | 总量 | ReactNode\|string | -
+subTotal | 子总量 | ReactNode\|string | -
 status | 增加状态 | 'up \| down' | -
 theme | 状态样式 | string | 'light'
 gap | 设置数字和描述直接的间距(像素) | number | 8

+ 3 - 3
src/components/PageHeader/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface PageHeaderProps {
   title?: React.ReactNode | string;
   logo?: React.ReactNode | string;
@@ -6,11 +6,11 @@ export interface PageHeaderProps {
   content?: React.ReactNode;
   extraContent?: React.ReactNode;
   routes?: Array<any>;
-  params: any;
+  params?: any;
   breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>;
   tabList?: Array<{ key: string; tab: React.ReactNode }>;
   onTabChange?: (key: string) => void;
-  linkElement?: string | React.ReactNode;
+  linkElement?: React.ReactNode;
 }
 
 export default class PageHeader extends React.Component<PageHeaderProps, any> {}

+ 1 - 1
src/components/Result/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface ResultProps {
   type: "success" | "error";
   title: React.ReactNode;

+ 1 - 1
src/components/TagSelect/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 export interface TagSelectProps {
   onChange?: (value: Array<string>) => void;
   expandable?: boolean;

+ 1 - 1
src/components/Trend/index.d.ts

@@ -1,4 +1,4 @@
-import React from "react";
+import * as React from "react";
 
 export interface TrendProps {
   colorful?: boolean;