From 18f35047ec6ff715e4fd26e06c2a4b31f8694f40 Mon Sep 17 00:00:00 2001 From: RaoHai Date: Thu, 30 Jun 2016 10:05:29 +0800 Subject: [PATCH 1/2] Rewrite Checkbox in typescript + add return type of splitObject + rewrite `import React from 'react'` to `import * as React from 'react'` + rewrite Checkbox in typescript --- components/_util/splitObject.tsx | 2 +- components/checkbox/Group.tsx | 30 ++++++++++++++++++++++++++++-- components/checkbox/index.tsx | 20 ++++++++++++++++++-- components/collapse/index.tsx | 2 +- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/components/_util/splitObject.tsx b/components/_util/splitObject.tsx index 1a3de48eb7..58884b0188 100644 --- a/components/_util/splitObject.tsx +++ b/components/_util/splitObject.tsx @@ -1,4 +1,4 @@ -export default function splitObject(obj, parts) { +export default function splitObject(obj, parts) : Array{ let left = {}; let right = {}; Object.keys(obj).forEach((k)=> { diff --git a/components/checkbox/Group.tsx b/components/checkbox/Group.tsx index d37c3cc24e..2e5bfcad3b 100644 --- a/components/checkbox/Group.tsx +++ b/components/checkbox/Group.tsx @@ -1,8 +1,34 @@ -import React from 'react'; +import * as React from 'react'; import Checkbox from './index'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import assign from 'object-assign'; -export default class CheckboxGroup extends React.Component { + +export interface CheckboxOptionType { + label:string, + value:string, + disabled?:boolean +} + +interface CheckboxGroupProps { + /** 默认选中的选项*/ + defaultValue?:Array, + /** 指定选中的选项*/ + value?:Array, + /** 指定可选项*/ + options?:Array | Array, + /** 变化时回调函数*/ + onChange?:(checkedValue:Array) => void, + + disabled?:boolean, + + style?:React.CSSProperties +} + +interface CheckboxGroupState { + value: any; +} + +export default class CheckboxGroup extends React.Component { static defaultProps = { options: [], defaultValue: [], diff --git a/components/checkbox/index.tsx b/components/checkbox/index.tsx index 76c388ddf1..f83844aeed 100644 --- a/components/checkbox/index.tsx +++ b/components/checkbox/index.tsx @@ -1,10 +1,26 @@ import RcCheckbox from 'rc-checkbox'; -import React from 'react'; +import * as React from 'react'; import CheckboxGroup from './Group'; import classNames from 'classnames'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import splitObject from '../_util/splitObject'; -export default class Checkbox extends React.Component { + +interface CheckboxProps { + /** 指定当前是否选中*/ + checked?:boolean, + /** 初始是否选中*/ + defaultChecked?:boolean, + /** 变化时回调函数*/ + onChange?:React.FormEventHandler, + + style?:React.CSSProperties, + + disabled?: boolean, + + className?: string, +} + +export default class Checkbox extends React.Component { static Group = CheckboxGroup; static defaultProps = { prefixCls: 'ant-checkbox', diff --git a/components/collapse/index.tsx b/components/collapse/index.tsx index 82e5d0a978..3a2538aace 100644 --- a/components/collapse/index.tsx +++ b/components/collapse/index.tsx @@ -1,5 +1,5 @@ import RcCollapse from 'rc-collapse'; -import React from 'react'; +import * as React from 'react'; export interface CollapseProps { activeKey?:Array | string, From fe92f4dc851835b6691f653be915c19fc942099b Mon Sep 17 00:00:00 2001 From: Rrrandom Date: Wed, 6 Jul 2016 14:00:09 +0800 Subject: [PATCH 2/2] typo in tooltip demo --- components/tooltip/demo/placement.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/tooltip/demo/placement.md b/components/tooltip/demo/placement.md index 1e58a73ce3..b885510f3c 100644 --- a/components/tooltip/demo/placement.md +++ b/components/tooltip/demo/placement.md @@ -46,7 +46,7 @@ ReactDOM.render(