From 7e77489c8eccd15f0869beebc76c7861cb44b221 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 8 Aug 2016 14:42:29 +0800 Subject: [PATCH] Fix ts errors in Transfer --- components/transfer/index.tsx | 25 ++++++++++------------ components/transfer/list.tsx | 35 +++++++++++++++++-------------- components/transfer/operation.tsx | 4 ++-- custom-typings.d.ts | 5 +++++ typings.json | 1 - 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index bd343bab6a..90bfdfef16 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -17,31 +17,22 @@ export interface TransferItem { // Transfer export interface TransferProps { - /** 数据源 */ dataSource: Array; - /** 每行数据渲染函数 */ render?: (record: TransferItem) => any; - /** 显示在右侧框数据的key集合 */ targetKeys: Array; - /** 变化时回调函数 */ onChange?: (targetKeys: Array, direction: string, moveKeys: any) => void; - /** 两个穿梭框的自定义样式 */ listStyle?: React.CSSProperties; - /** 自定义类*/ className?: string; - /** 标题集合,顺序从左至右 */ + prefixCls?: string; titles?: Array; - /** 操作文案集合,顺序从上至下 */ operations?: Array; - /** 是否显示搜索框 */ showSearch?: boolean; - /** 搜索框的默认值 */ searchPlaceholder?: string; - /** 当列表为空时显示的内容 */ notFoundContent?: React.ReactNode | string; - /** 底部渲染函数 */ footer?: (props: any) => any; style?: React.CSSProperties; + filterOption: (filterText: any, item: any) => boolean; + body?: (props: any) => any; } export default class Transfer extends React.Component { @@ -82,6 +73,8 @@ export default class Transfer extends React.Component { rowKey: PropTypes.func, }; + splitedDataSource: any; + constructor(props) { super(props); this.state = { @@ -176,8 +169,12 @@ export default class Transfer extends React.Component { }); } - handleLeftSelectAll = (...args) => this.handleSelectAll('left', ...args) - handleRightSelectAll = (...args) => this.handleSelectAll('right', ...args) + handleLeftSelectAll = (filteredDataSource, checkAll) => ( + this.handleSelectAll('left', filteredDataSource, checkAll) + ) + handleRightSelectAll = (filteredDataSource, checkAll) => ( + this.handleSelectAll('right', filteredDataSource, checkAll) + ) handleFilter = (direction, e) => { this.setState({ diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index 67f26e34af..77b6c459e1 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -18,31 +18,30 @@ export function isRenderResultPlainObject(result) { export interface TransferListProps { prefixCls?: string; - /** 数据源 */ dataSource: Array; - filter?: TransferItem; - /** 是否显示搜索框 */ + filter?: string; showSearch?: boolean; - /** 搜索框的默认值 */ searchPlaceholder?: string; - /** 标题 */ titleText?: string; style?: React.CSSProperties; - handleFilter?: () => void; - handleSelect?: () => void; - handleSelectAll?: () => void; + handleFilter?: (e: any) => void; + handleSelect?: (selectedItem: any, checked: boolean) => void; + handleSelectAll?: (dataSource: any[], checkAll: boolean) => void; handleClear?: () => void; - /** 每行渲染函数 */ - render?: () => void; - /** 主体渲染函数 */ - body?: () => void; - /** 底部渲染函数 */ - footer?: () => void; - /** 选中项 */ - checkedKeys?: Array; + render?: (...any) => any; + body?: (props: any) => any; + footer?: (props: any) => void; + checkedKeys?: any[]; checkStatus?: boolean; position?: string; notFoundContent?: React.ReactNode | string; + filterOption: (filterText: any, item: any) => boolean; +} + +export interface TransferContext { + antLocale?: { + Transfer?: any, + }; } export default class TransferList extends React.Component { @@ -81,6 +80,9 @@ export default class TransferList extends React.Component, filteredDataSource, + disabled: false, })} diff --git a/components/transfer/operation.tsx b/components/transfer/operation.tsx index 64b70ed8b7..b516f97293 100644 --- a/components/transfer/operation.tsx +++ b/components/transfer/operation.tsx @@ -9,8 +9,8 @@ export interface TransferOperationProps { className?: string; leftArrowText?: string; rightArrowText?: string; - moveToLeft?: Function; - moveToRight?: Function; + moveToLeft?: React.FormEventHandler; + moveToRight?: React.FormEventHandler; leftActive?: boolean; rightActive?: boolean; } diff --git a/custom-typings.d.ts b/custom-typings.d.ts index 00e0bd4e06..6965046733 100644 --- a/custom-typings.d.ts +++ b/custom-typings.d.ts @@ -2,6 +2,11 @@ declare module 'classnames' { export default function({}): string; } +declare module 'react-addons-pure-render-mixin' { + var exports: any; + export default exports; +} + declare module 'gregorian-calendar-format' { export default function({}): string; } diff --git a/typings.json b/typings.json index 4369c015c3..4456b2ab6b 100644 --- a/typings.json +++ b/typings.json @@ -4,7 +4,6 @@ "object-assign": "file:custom-typings/object-assign.d.ts", "rc-util/lib/Dom/addEventListener": "file:custom-typings/rc-util.d.ts", "react": "registry:dt/react#0.14.0+20160720060442", - "react-addons-pure-render-mixin": "registry:dt/react-addons-pure-render-mixin#0.14.0+20160316155526", "react-dom": "registry:dt/react-dom#0.14.0+20160412154040", "shallowequal": "file:custom-typings/shallowequal.d.ts", "warning": "file:custom-typings/warning.d.ts"