Skip to content

Commit

Permalink
Merge pull request ant-design#2221 from RaoHai/rewriteCheckboxInTs
Browse files Browse the repository at this point in the history
 Rewrite Checkbox in typescript
  • Loading branch information
yiminghe authored Jul 7, 2016
2 parents 15f1826 + 18f3504 commit 8c7016c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/_util/splitObject.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function splitObject(obj, parts) {
export default function splitObject(obj, parts) : Array<any>{
let left = {};
let right = {};
Object.keys(obj).forEach((k)=> {
Expand Down
30 changes: 28 additions & 2 deletions components/checkbox/Group.tsx
Original file line number Diff line number Diff line change
@@ -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<string>,
/** 指定选中的选项*/
value?:Array<string>,
/** 指定可选项*/
options?:Array<CheckboxOptionType> | Array<string>,
/** 变化时回调函数*/
onChange?:(checkedValue:Array<string>) => void,

disabled?:boolean,

style?:React.CSSProperties
}

interface CheckboxGroupState {
value: any;
}

export default class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupState> {
static defaultProps = {
options: [],
defaultValue: [],
Expand Down
20 changes: 18 additions & 2 deletions components/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -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<CheckboxProps, any> {
static Group = CheckboxGroup;
static defaultProps = {
prefixCls: 'ant-checkbox',
Expand Down
2 changes: 1 addition & 1 deletion components/collapse/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RcCollapse from 'rc-collapse';
import React from 'react';
import * as React from 'react';

export interface CollapseProps {
activeKey?:Array<string> | string,
Expand Down

0 comments on commit 8c7016c

Please sign in to comment.