Skip to content

Commit

Permalink
split type definition, ref #1845
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang740 committed Sep 14, 2017
1 parent c14ccaa commit c30d049
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 90 deletions.
4 changes: 0 additions & 4 deletions components/accordion/PropsType.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
interface AccordionProps {
styles?: any;
style?: any;
/** below web only */
className?: string;
prefixCls?: string;
activeKey?: string | Array<string>;
defaultActiveKey?: string | Array<string>;
openAnimation?: any;
accordion?: boolean;
onChange?: (x: any) => void;
}
Expand Down
8 changes: 7 additions & 1 deletion components/accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react';
import RcCollapse, { Panel } from 'rc-collapse';
import AccordionProps from './PropsType';
import BasePropsType from './PropsType';

export interface AccordionProps extends BasePropsType {
className?: string;
prefixCls?: string;
openAnimation?: any;
}

export default class Accordion extends React.Component<AccordionProps, any> {
static Panel = Panel;
Expand Down
3 changes: 0 additions & 3 deletions components/activity-indicator/PropsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ interface ActivityIndicatorPropTypes {
size?: 'large' | 'small';
text?: string;
styles?: any;
/** web only */
prefixCls?: string;
className?: string;
}

export default ActivityIndicatorPropTypes;
39 changes: 22 additions & 17 deletions components/activity-indicator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* tslint:disable:jsx-no-multiline-js */
import React from 'react';
import classnames from 'classnames';
import ActivityIndicatorProps from './PropsType';
import BasePropsType from './PropsType';

export interface ActivityIndicatorProps extends BasePropsType {
prefixCls?: string;
className?: string;
}

export default class ActivityIndicator extends React.Component<ActivityIndicatorProps, any> {
static defaultProps = {
Expand All @@ -26,18 +31,18 @@ export default class ActivityIndicator extends React.Component<ActivityIndicator
if (toast) {
return (
<div className={wrapClass}>
{
text ? (
<div className={`${prefixCls}-content`}>
<span className={spinnerClass} aria-hidden="true" />
<span className={`${prefixCls}-toast`}>{text}</span>
</div>
) : (
<div className={`${prefixCls}-content`}>
<span className={spinnerClass} aria-label="Loading" />
</div>
)
}
{
text ? (
<div className={`${prefixCls}-content`}>
<span className={spinnerClass} aria-hidden="true" />
<span className={`${prefixCls}-toast`}>{text}</span>
</div>
) : (
<div className={`${prefixCls}-content`}>
<span className={spinnerClass} aria-label="Loading" />
</div>
)
}
</div>
);
} else {
Expand All @@ -47,10 +52,10 @@ export default class ActivityIndicator extends React.Component<ActivityIndicator
<span className={`${prefixCls}-tip`}>{text}</span>
</div>
) : (
<div className={wrapClass}>
<span className={spinnerClass} aria-label="loading" />
</div>
);
<div className={wrapClass}>
<span className={spinnerClass} aria-label="loading" />
</div>
);
}
} else {
return null;
Expand Down
8 changes: 1 addition & 7 deletions components/badge/PropsType.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
interface BadgeProps {
size?: 'large'|'small';
size?: 'large' | 'small';
overflowCount?: number;
corner?: boolean;
dot?: boolean;
text?: any;
style?: any;
/** rn only */
styles?: any;
/** web only */
prefixCls?: string;
className?: string;
hot?: boolean;
}

export default BadgeProps;
8 changes: 7 additions & 1 deletion components/badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react';
import classnames from 'classnames';
import BadgeProps from './PropsType';
import BasePropsType from './PropsType';

export interface BadgeProps extends BasePropsType {
prefixCls?: string;
className?: string;
hot?: boolean;
}

export default class Badge extends React.Component<BadgeProps, any> {
static defaultProps = {
Expand Down
14 changes: 1 addition & 13 deletions components/button/PropsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,13 @@ import React from 'react';
export interface ButtonProps {
type?: 'primary' | 'warning' | 'ghost';
size?: 'large' | 'small';
activeStyle?: boolean|Object;
activeStyle?: boolean | Object;
disabled?: boolean;
onClick?: (x?: any) => void;
loading?: boolean;
delayPressIn?: number;
delayPressOut?: number;
style?: React.CSSProperties;
/* for web */
prefixCls?: string;
className?: string;
role?: string;
inline?: boolean;
icon?: string;
activeClassName?: string;
/* for native */
onPressIn?: (x?: any) => void;
onPressOut?: (x?: any) => void;
onShowUnderlay?: (x?: any) => void;
onHideUnderlay?: (x?: any) => void;
styles?: {
primaryRawText?: {},
warningRawText?: {},
Expand Down
19 changes: 13 additions & 6 deletions components/button/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import React from 'react';
import { TouchableHighlight, Text, StyleSheet, View, ActivityIndicator } from 'react-native';
import buttonStyle from './style/index.native';
import { ButtonProps } from './PropsType';
import { ButtonProps as BasePropsType } from './PropsType';

export interface ButtonProps extends BasePropsType {
onPressIn?: (x?: any) => void;
onPressOut?: (x?: any) => void;
onShowUnderlay?: (x?: any) => void;
onHideUnderlay?: (x?: any) => void;
}

const buttonStyles = StyleSheet.create<any>(buttonStyle);

Expand Down Expand Up @@ -68,11 +75,11 @@ export default class Button extends React.Component<ButtonProps, any> {
const _styles = styles!;

['activeOpacity', 'underlayColor', 'onPress', 'onPressIn',
'onPressOut', 'onShowUnderlay', 'onHideUnderlay'].forEach((prop) => {
if (restProps.hasOwnProperty(prop)) {
delete restProps[prop];
}
});
'onPressOut', 'onShowUnderlay', 'onHideUnderlay'].forEach((prop) => {
if (restProps.hasOwnProperty(prop)) {
delete restProps[prop];
}
});

const textStyle = [
_styles[`${size}RawText`],
Expand Down
11 changes: 10 additions & 1 deletion components/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import React from 'react';
import classnames from 'classnames';
import Icon from '../icon';
import { ButtonProps } from './PropsType';
import { ButtonProps as BasePropsType } from './PropsType';
import TouchFeedback from 'rmc-feedback';

export interface ButtonProps extends BasePropsType {
prefixCls?: string;
className?: string;
role?: string;
inline?: boolean;
icon?: string;
activeClassName?: string;
}

const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
const isTwoCNChar = rxTwoCNChar.test.bind(rxTwoCNChar);
function isString(str) {
Expand Down
6 changes: 5 additions & 1 deletion components/card/CardBody.native.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import { View } from 'react-native';
import { CardBodyProps } from './PropsType';
import { CardBodyProps as BasePropsType } from './PropsType';

export interface CardBodyProps extends BasePropsType {
styles?: any;
}

export default class CardBody extends React.Component<CardBodyProps, any> {
static defaultProps = {
Expand Down
7 changes: 6 additions & 1 deletion components/card/CardBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from 'react';
import classnames from 'classnames';
import { CardBodyProps } from './PropsType';
import { CardBodyProps as BasePropsType } from './PropsType';

export interface CardBodyProps extends BasePropsType {
prefixCls?: string;
className?: string;
}

export default class CardBody extends React.Component<CardBodyProps, any> {
static defaultProps = {
Expand Down
14 changes: 9 additions & 5 deletions components/card/CardFooter.native.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import { View, Text } from 'react-native';
import { CardFooterProps } from './PropsType';
import { CardFooterProps as BasePropsType } from './PropsType';

export interface CardFooterProps extends BasePropsType {
styles?: any;
}

export default class CardFooter extends React.Component<CardFooterProps, any> {
static defaultProps = {
Expand All @@ -13,14 +17,14 @@ export default class CardFooter extends React.Component<CardFooterProps, any> {
const contentDom = React.isValidElement(content) ? (
<View style={{ flex: 1 }}>{content}</View>
) : (
<Text style={styles.footerContent}>{content}</Text>
);
<Text style={styles.footerContent}>{content}</Text>
);

const extraDom = React.isValidElement(extra) ? (
<View style={{ flex: 1 }}>{extra}</View>
) : (
<Text style={[styles.footerExtra]}>{extra}</Text>
);
<Text style={[styles.footerExtra]}>{extra}</Text>
);

return (
<View style={[styles.footerWrap, style]} {...restProps}>
Expand Down
8 changes: 6 additions & 2 deletions components/card/CardFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from 'react';
import classnames from 'classnames';
import { CardFooterProps } from './PropsType';
import { CardFooterProps as BasePropsType } from './PropsType';

export default class CardFooter extends React.Component <CardFooterProps, any> {
export interface CardFooterProps extends BasePropsType {
prefixCls?: string;
}

export default class CardFooter extends React.Component<CardFooterProps, any> {
static defaultProps = {
prefixCls: 'am-card',
};
Expand Down
14 changes: 9 additions & 5 deletions components/card/CardHeader.native.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* tslint:disable:jsx-no-multiline-js */
import React from 'react';
import { View, Text, Image } from 'react-native';
import { CardHeaderProps } from './PropsType';
import { CardHeaderProps as BasePropsType } from './PropsType';

export interface CardHeaderProps extends BasePropsType {
styles?: any;
}

export default class CardHeader extends React.Component<CardHeaderProps, any> {
static defaultProps = {
Expand All @@ -15,14 +19,14 @@ export default class CardHeader extends React.Component<CardHeaderProps, any> {
const titleDom = React.isValidElement(title) ? (
<View style={{ flex: 1 }}>{title}</View>
) : (
<Text style={styles.headerContent}>{title}</Text>
);
<Text style={styles.headerContent}>{title}</Text>
);

const extraDom = React.isValidElement(extra) ? (
<View style={{ flex: 1 }}>{extra}</View>
) : (
<Text style={[styles.headerExtra]}>{extra}</Text>
);
<Text style={[styles.headerExtra]}>{extra}</Text>
);

return (
<View style={[styles.headerWrap, style]} {...restProps}>
Expand Down
9 changes: 7 additions & 2 deletions components/card/CardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import classnames from 'classnames';
import { CardHeaderProps } from './PropsType';
import { CardHeaderProps as BasePropsType } from './PropsType';

export default class CardHeader extends React.Component <CardHeaderProps, any> {
export interface CardHeaderProps extends BasePropsType {
prefixCls?: string;
className?: string;
}

export default class CardHeader extends React.Component<CardHeaderProps, any> {
static defaultProps = {
prefixCls: 'am-card',
thumbStyle: {},
Expand Down
19 changes: 0 additions & 19 deletions components/card/PropsType.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
export interface CardProps {
full?: boolean;
className?: string;
style?: {};
/** web only */
prefixCls?: string;
/** rn only */
styles?: any;
}

export interface CardHeaderProps {
title?: any;
thumb?: string;
extra?: any;
thumbStyle?: {};
className?: string;
style?: any;
/** web only */
prefixCls?: string;
/** rn only */
styles?: any;
}

export interface CardBodyProps {
children?: any;
className?: string;
style?: {};
/** web only */
prefixCls?: string;
/** rn only */
styles?: any;
}

export interface CardFooterProps {
content?: any;
extra?: any;
className?: string;
style?: {};
/** web only */
prefixCls?: string;
/** rn only */
styles?: any;
}
9 changes: 7 additions & 2 deletions components/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import classnames from 'classnames';
import CardHeader from './CardHeader';
import CardBody from './CardBody';
import CardFooter from './CardFooter';
import { CardProps } from './PropsType';
import { CardProps as BasePropsType } from './PropsType';

export default class Card extends React.Component <CardProps, any> {
export interface CardProps extends BasePropsType {
prefixCls?: string;
className?: string;
}

export default class Card extends React.Component<CardProps, any> {
static defaultProps = {
prefixCls: 'am-card',
full: false,
Expand Down

0 comments on commit c30d049

Please sign in to comment.