Extend CardProps from native div element attributes

Close #9933
This commit is contained in:
Wei Zhu 2018-04-11 19:40:31 +08:00
parent f9b8bf7e4d
commit 82b721a432
3 changed files with 6 additions and 5 deletions

3
components/_util/type.ts Normal file
View File

@ -0,0 +1,3 @@
export type Diff<T extends string, U extends string> = ({ [P in T]: P } &
{ [P in U]: never } & { [x: string]: never })[T];
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;

View File

@ -7,6 +7,7 @@ import Meta from './Meta';
import Tabs from '../tabs'; import Tabs from '../tabs';
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame'; import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';
import warning from '../_util/warning'; import warning from '../_util/warning';
import { Omit } from '../_util/type';
export { CardGridProps } from './Grid'; export { CardGridProps } from './Grid';
export { CardMetaProps } from './Meta'; export { CardMetaProps } from './Meta';
@ -18,7 +19,7 @@ export interface CardTabListType {
tab: React.ReactNode; tab: React.ReactNode;
} }
export interface CardProps { export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
prefixCls?: string; prefixCls?: string;
title?: React.ReactNode; title?: React.ReactNode;
extra?: React.ReactNode; extra?: React.ReactNode;

View File

@ -8,6 +8,7 @@ import omit from 'omit.js';
import warning from '../_util/warning'; import warning from '../_util/warning';
import FormItem from './FormItem'; import FormItem from './FormItem';
import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants'; import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
import { Omit } from '../_util/type';
export interface FormCreateOption<T> { export interface FormCreateOption<T> {
onFieldsChange?: (props: T, fields: Array<any>) => void; onFieldsChange?: (props: T, fields: Array<any>) => void;
@ -113,10 +114,6 @@ export interface FormComponentProps {
form: WrappedFormUtils; form: WrappedFormUtils;
} }
export type Diff<T extends string, U extends string> =
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
export interface ComponentDecorator { export interface ComponentDecorator {
<P extends FormComponentProps>( <P extends FormComponentProps>(
component: React.ComponentClass<P> | React.SFC<P>, component: React.ComponentClass<P> | React.SFC<P>,