From 2baef5e8e39bc1137c70327310f35da3490f2b61 Mon Sep 17 00:00:00 2001 From: jim Date: Thu, 11 Jan 2018 22:47:23 +0800 Subject: [PATCH] support typescript --- src/components/Authorized/index.d.ts | 29 +++++++++--------- src/components/Charts/Bar/index.d.ts | 1 + src/components/Charts/ChartCard/index.d.ts | 1 + src/components/Charts/Field/index.d.ts | 1 + src/components/Charts/Gauge/index.d.ts | 1 + src/components/Charts/MiniBar/index.d.ts | 5 ++-- src/components/Charts/MiniProgress/index.d.ts | 1 + src/components/Charts/Pie/index.d.ts | 4 +-- src/components/Charts/Radar/index.d.ts | 1 + src/components/Charts/TagCloud/index.d.ts | 1 + .../Charts/TimelineChart/index.d.ts | 1 + src/components/Charts/WaterWave/index.d.ts | 3 +- src/components/Charts/index.d.ts | 26 ++++++++-------- src/components/DescriptionList/index.d.ts | 8 +++-- src/components/Ellipsis/index.d.ts | 1 + src/components/Exception/index.d.ts | 1 + src/components/FooterToolbar/index.d.ts | 3 +- src/components/GlobalFooter/index.d.ts | 5 ++-- src/components/HeaderSearch/index.d.ts | 3 +- src/components/Login/index.d.ts | 30 +++++++++++++++++++ src/components/NoticeIcon/index.d.ts | 17 ++++++----- src/components/NumberInfo/index.d.ts | 5 ++-- src/components/PageHeader/index.d.ts | 3 +- src/components/Result/index.d.ts | 5 ++-- src/components/TagSelect/index.d.ts | 4 ++- src/components/Trend/index.d.ts | 5 ++-- 26 files changed, 110 insertions(+), 55 deletions(-) create mode 100644 src/components/Login/index.d.ts diff --git a/src/components/Authorized/index.d.ts b/src/components/Authorized/index.d.ts index 6b073a65..45df4e8b 100644 --- a/src/components/Authorized/index.d.ts +++ b/src/components/Authorized/index.d.ts @@ -1,15 +1,19 @@ -import * as React from "react"; -import * as H from "history"; -import { RouteProps } from "react-router"; +import * as React from 'react'; +import { RouteProps } from 'react-router'; type authorityFN = () => string; type authority = string | Array | authorityFN | Promise; +export type IReactComponent

= + | React.StatelessComponent

+ | React.ComponentClass

+ | React.ClassicComponentClass

; + interface Secured { - (authority: authority, error?: React.ReactNode): ( - target: React.ReactNode - ) => React.ReactNode; + (authority: authority, error?: React.ReactNode): ( + target: T, + ) => T; } export interface AuthorizedRouteProps extends RouteProps { @@ -18,16 +22,14 @@ export interface AuthorizedRouteProps extends RouteProps { export class AuthorizedRoute extends React.Component< AuthorizedRouteProps, any -> { - constructor(props: AuthorizedRouteProps); -} +> {} interface check { - ( + ( authority: authority, - target: React.ReactNode, - Exception: React.ReactNode - ): React.ReactNode; + target: T, + Exception: S, + ): T | S; } interface AuthorizedProps { @@ -39,7 +41,6 @@ export class Authorized extends React.Component { static Secured: Secured; static AuthorizedRoute: typeof AuthorizedRoute; static check: check; - constructor(props: AuthorizedProps); } declare function renderAuthorize(currentAuthority: string): typeof Authorized; diff --git a/src/components/Charts/Bar/index.d.ts b/src/components/Charts/Bar/index.d.ts index b79630ab..7be2a1a7 100644 --- a/src/components/Charts/Bar/index.d.ts +++ b/src/components/Charts/Bar/index.d.ts @@ -9,6 +9,7 @@ export interface BarProps { y: number; }>; autoLabel?: boolean; + style?: React.CSSProperties; } export default class Bar extends React.Component {} diff --git a/src/components/Charts/ChartCard/index.d.ts b/src/components/Charts/ChartCard/index.d.ts index 21d2be34..35a5852e 100644 --- a/src/components/Charts/ChartCard/index.d.ts +++ b/src/components/Charts/ChartCard/index.d.ts @@ -6,6 +6,7 @@ export interface ChartCardProps { footer?: React.ReactNode; contentHeight?: number; avatar?: React.ReactNode; + style?: React.CSSProperties; } export default class ChartCard extends React.Component {} diff --git a/src/components/Charts/Field/index.d.ts b/src/components/Charts/Field/index.d.ts index 7fa13282..b1f779cd 100644 --- a/src/components/Charts/Field/index.d.ts +++ b/src/components/Charts/Field/index.d.ts @@ -2,6 +2,7 @@ import * as React from "react"; export interface FieldProps { label: React.ReactNode; value: React.ReactNode; + style?: React.CSSProperties; } export default class Field extends React.Component {} diff --git a/src/components/Charts/Gauge/index.d.ts b/src/components/Charts/Gauge/index.d.ts index 7f196aed..218fccf3 100644 --- a/src/components/Charts/Gauge/index.d.ts +++ b/src/components/Charts/Gauge/index.d.ts @@ -5,6 +5,7 @@ export interface GaugeProps { height: number; bgColor?: number; percent: number; + style?: React.CSSProperties; } export default class Gauge extends React.Component {} diff --git a/src/components/Charts/MiniBar/index.d.ts b/src/components/Charts/MiniBar/index.d.ts index 09bd761f..3e2f1ec2 100644 --- a/src/components/Charts/MiniBar/index.d.ts +++ b/src/components/Charts/MiniBar/index.d.ts @@ -1,11 +1,12 @@ -import * as React from "react"; +import * as React from 'react'; export interface MiniBarProps { color?: string; height: number; data: Array<{ - x: number; + x: number | string; y: number; }>; + style?: React.CSSProperties; } export default class MiniBar extends React.Component {} diff --git a/src/components/Charts/MiniProgress/index.d.ts b/src/components/Charts/MiniProgress/index.d.ts index a80b935d..4dde6052 100644 --- a/src/components/Charts/MiniProgress/index.d.ts +++ b/src/components/Charts/MiniProgress/index.d.ts @@ -4,6 +4,7 @@ export interface MiniProgressProps { color?: string; strokeWidth?: number; percent?: number; + style?: React.CSSProperties; } export default class MiniProgress extends React.Component< diff --git a/src/components/Charts/Pie/index.d.ts b/src/components/Charts/Pie/index.d.ts index c029e79c..fe2e2a8e 100644 --- a/src/components/Charts/Pie/index.d.ts +++ b/src/components/Charts/Pie/index.d.ts @@ -1,4 +1,4 @@ -import * as React from "react"; +import * as React from 'react'; export interface PieProps { animate?: boolean; color?: string; @@ -7,7 +7,7 @@ export interface PieProps { padding?: [number, number, number, number]; percent?: number; data?: Array<{ - x: string; + x: string | string; y: number; }>; total?: string; diff --git a/src/components/Charts/Radar/index.d.ts b/src/components/Charts/Radar/index.d.ts index b1707bf9..772cbf02 100644 --- a/src/components/Charts/Radar/index.d.ts +++ b/src/components/Charts/Radar/index.d.ts @@ -9,6 +9,7 @@ export interface RadarProps { label: string; value: string; }>; + style?: React.CSSProperties; } export default class Radar extends React.Component {} diff --git a/src/components/Charts/TagCloud/index.d.ts b/src/components/Charts/TagCloud/index.d.ts index e7832132..e2dcc794 100644 --- a/src/components/Charts/TagCloud/index.d.ts +++ b/src/components/Charts/TagCloud/index.d.ts @@ -5,6 +5,7 @@ export interface TagCloudProps { value: number; }>; height: number; + style?: React.CSSProperties; } export default class TagCloud extends React.Component {} diff --git a/src/components/Charts/TimelineChart/index.d.ts b/src/components/Charts/TimelineChart/index.d.ts index 212b69e4..f9241fa2 100644 --- a/src/components/Charts/TimelineChart/index.d.ts +++ b/src/components/Charts/TimelineChart/index.d.ts @@ -8,6 +8,7 @@ export interface TimelineChartProps { titleMap: { y1: string; y2: string }; padding?: [number, number, number, number]; height?: number; + style?: React.CSSProperties; } export default class TimelineChart extends React.Component< diff --git a/src/components/Charts/WaterWave/index.d.ts b/src/components/Charts/WaterWave/index.d.ts index 0fefbea1..309db7b5 100644 --- a/src/components/Charts/WaterWave/index.d.ts +++ b/src/components/Charts/WaterWave/index.d.ts @@ -1,9 +1,10 @@ -import * as React from "react"; +import * as React from 'react'; export interface WaterWaveProps { title: React.ReactNode; color?: string; height: number; percent: number; + style?: React.CSSProperties; } export default class WaterWave extends React.Component {} diff --git a/src/components/Charts/index.d.ts b/src/components/Charts/index.d.ts index e47b947f..1ff27af2 100644 --- a/src/components/Charts/index.d.ts +++ b/src/components/Charts/index.d.ts @@ -1,16 +1,16 @@ -export { default as numeral } from "numeral"; -export { default as ChartCard } from "./ChartCard"; -export { default as Bar } from "./Bar"; -export { default as Pie } from "./Pie"; -export { default as Radar } from "./Radar"; -export { default as Gauge } from "./Gauge"; -export { default as MiniArea } from "./MiniArea"; -export { default as MiniBar } from "./MiniBar"; -export { default as MiniProgress } from "./MiniProgress"; -export { default as Field } from "./Field"; -export { default as WaterWave } from "./WaterWave"; -export { default as TagCloud } from "./TagCloud"; -export { default as TimelineChart } from "./TimelineChart"; +import * as numeral from 'numeral'; +export { default as ChartCard } from './ChartCard'; +export { default as Bar } from './Bar'; +export { default as Pie } from './Pie'; +export { default as Radar } from './Radar'; +export { default as Gauge } from './Gauge'; +export { default as MiniArea } from './MiniArea'; +export { default as MiniBar } from './MiniBar'; +export { default as MiniProgress } from './MiniProgress'; +export { default as Field } from './Field'; +export { default as WaterWave } from './WaterWave'; +export { default as TagCloud } from './TagCloud'; +export { default as TimelineChart } from './TimelineChart'; declare const yuan: (value: number | string) => string; diff --git a/src/components/DescriptionList/index.d.ts b/src/components/DescriptionList/index.d.ts index b13c6301..fe64433a 100644 --- a/src/components/DescriptionList/index.d.ts +++ b/src/components/DescriptionList/index.d.ts @@ -1,15 +1,17 @@ -import * as React from "react"; +import * as React from 'react'; export interface DescriptionListProps { - layout?: "horizontal" | "vertical"; + layout?: 'horizontal' | 'vertical'; col?: number; title: React.ReactNode; gutter?: number; - size?: "large" | "small"; + size?: 'large' | 'small'; + style?: React.CSSProperties; } declare class Description extends React.Component< { term: React.ReactNode; + style?: React.CSSProperties; }, any > {} diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index 66f1de3e..8421b951 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -3,6 +3,7 @@ export interface EllipsisProps { tooltip?: boolean; length?: number; lines?: number; + style?: React.CSSProperties; } export default class Ellipsis extends React.Component< diff --git a/src/components/Exception/index.d.ts b/src/components/Exception/index.d.ts index def4034e..037f866d 100644 --- a/src/components/Exception/index.d.ts +++ b/src/components/Exception/index.d.ts @@ -6,6 +6,7 @@ export interface ExceptionProps { img?: string; actions?: React.ReactNode; linkElement?: React.ReactNode; + style?: React.CSSProperties; } export default class Exception extends React.Component {} diff --git a/src/components/FooterToolbar/index.d.ts b/src/components/FooterToolbar/index.d.ts index 2bc13358..637bd4b8 100644 --- a/src/components/FooterToolbar/index.d.ts +++ b/src/components/FooterToolbar/index.d.ts @@ -1,6 +1,7 @@ -import * as React from "react"; +import * as React from 'react'; export interface FooterToolbarProps { extra: React.ReactNode; + style?: React.CSSProperties; } export default class FooterToolbar extends React.Component< diff --git a/src/components/GlobalFooter/index.d.ts b/src/components/GlobalFooter/index.d.ts index 26f0c115..faf633b9 100644 --- a/src/components/GlobalFooter/index.d.ts +++ b/src/components/GlobalFooter/index.d.ts @@ -1,11 +1,12 @@ import * as React from "react"; export interface GlobalFooterProps { - links: Array<{ + links?: Array<{ title: React.ReactNode; href: string; blankTarget?: boolean; }>; - copyright: React.ReactNode; + copyright?: React.ReactNode; + style?: React.CSSProperties; } export default class GlobalFooter extends React.Component< diff --git a/src/components/HeaderSearch/index.d.ts b/src/components/HeaderSearch/index.d.ts index 2587891d..58316dfc 100644 --- a/src/components/HeaderSearch/index.d.ts +++ b/src/components/HeaderSearch/index.d.ts @@ -1,10 +1,11 @@ -import * as React from "react"; +import * as React from 'react'; export interface HeaderSearchProps { placeholder?: string; dataSource?: Array; onSearch?: (value: string) => void; onChange?: (value: string) => void; onPressEnter?: (value: string) => void; + style?: React.CSSProperties; } export default class HeaderSearch extends React.Component< diff --git a/src/components/Login/index.d.ts b/src/components/Login/index.d.ts new file mode 100644 index 00000000..8c792b08 --- /dev/null +++ b/src/components/Login/index.d.ts @@ -0,0 +1,30 @@ +import * as React from 'react'; +import Button from 'antd/lib/button'; +export interface LoginProps { + defaultActiveKey?: string; + onTabChange?: (key: string) => void; + onSubmit?: (error: any, values: any) => void; +} + +export interface TabProps { + key?: string; + tab?: React.ReactNode; +} +export class Tab extends React.Component {} + +export interface LoginItemProps { + name?: string; + rules?: any[]; + onGetCaptcha?: () => void; +} + +export class LoginItem extends React.Component {} + +export default class Login extends React.Component { + static Tab: typeof Tab; + static UserName: typeof LoginItem; + static Password: typeof LoginItem; + static Mobile: typeof LoginItem; + static Captcha: typeof LoginItem; + static Submit: typeof Button; +} diff --git a/src/components/NoticeIcon/index.d.ts b/src/components/NoticeIcon/index.d.ts index b35c1624..d8f21680 100644 --- a/src/components/NoticeIcon/index.d.ts +++ b/src/components/NoticeIcon/index.d.ts @@ -1,10 +1,11 @@ -import * as React from "react"; +import * as React from 'react'; export interface NoticeIconData { - avatar: string; - title: React.ReactNode; - description: React.ReactNode; - datetime: React.ReactNode; - extra: React.ReactNode; + avatar?: string; + title?: React.ReactNode; + description?: React.ReactNode; + datetime?: React.ReactNode; + extra?: React.ReactNode; + style?: React.CSSProperties; } export interface NoticeIconProps { @@ -29,8 +30,8 @@ export interface NoticeIconProps { } export interface NoticeIconTabProps { - list: Array; - title: string; + list?: Array; + title?: string; emptyText?: React.ReactNode; emptyImage?: string; } diff --git a/src/components/NumberInfo/index.d.ts b/src/components/NumberInfo/index.d.ts index e0b7e5a5..2370ec6d 100644 --- a/src/components/NumberInfo/index.d.ts +++ b/src/components/NumberInfo/index.d.ts @@ -1,12 +1,13 @@ -import * as 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"; + status?: 'up' | 'down'; theme?: string; gap?: number; subTotal?: number; + style?: React.CSSProperties; } export default class NumberInfo extends React.Component {} diff --git a/src/components/PageHeader/index.d.ts b/src/components/PageHeader/index.d.ts index ca2cf565..40c80a49 100644 --- a/src/components/PageHeader/index.d.ts +++ b/src/components/PageHeader/index.d.ts @@ -1,4 +1,4 @@ -import * as React from "react"; +import * as React from 'react'; export interface PageHeaderProps { title?: React.ReactNode | string; logo?: React.ReactNode | string; @@ -12,6 +12,7 @@ export interface PageHeaderProps { tabActiveKey?: string; onTabChange?: (key: string) => void; linkElement?: React.ReactNode; + style?: React.CSSProperties; } export default class PageHeader extends React.Component {} diff --git a/src/components/Result/index.d.ts b/src/components/Result/index.d.ts index c4fef0b3..a316332e 100644 --- a/src/components/Result/index.d.ts +++ b/src/components/Result/index.d.ts @@ -1,10 +1,11 @@ -import * as React from "react"; +import * as React from 'react'; export interface ResultProps { - type: "success" | "error"; + type: 'success' | 'error'; title: React.ReactNode; description?: React.ReactNode; extra?: React.ReactNode; actions?: React.ReactNode; + style?: React.CSSProperties; } export default class Result extends React.Component {} diff --git a/src/components/TagSelect/index.d.ts b/src/components/TagSelect/index.d.ts index 516220b6..632e556a 100644 --- a/src/components/TagSelect/index.d.ts +++ b/src/components/TagSelect/index.d.ts @@ -1,10 +1,12 @@ -import * as React from "react"; +import * as React from 'react'; export interface TagSelectProps { onChange?: (value: Array) => void; expandable?: boolean; + style?: React.CSSProperties; } export interface TagSelectOptionProps { value: string; + style?: React.CSSProperties; } export class TagSelectOption extends React.Component< diff --git a/src/components/Trend/index.d.ts b/src/components/Trend/index.d.ts index 698a49d8..bb2b2a2b 100644 --- a/src/components/Trend/index.d.ts +++ b/src/components/Trend/index.d.ts @@ -1,8 +1,9 @@ -import * as React from "react"; +import * as React from 'react'; export interface TrendProps { colorful?: boolean; - flag: "up" | "down"; + flag: 'up' | 'down'; + style?: React.CSSProperties; } export default class Trend extends React.Component {} -- GitLab