Browse Source

Fix ts errors in Transfer

pull/2639/head
afc163 8 years ago
parent
commit
7e77489c8e
  1. 25
      components/transfer/index.tsx
  2. 35
      components/transfer/list.tsx
  3. 4
      components/transfer/operation.tsx
  4. 5
      custom-typings.d.ts
  5. 1
      typings.json

25
components/transfer/index.tsx

@ -17,31 +17,22 @@ export interface TransferItem {
// Transfer
export interface TransferProps {
/** 数据源 */
dataSource: Array<TransferItem>;
/** 每行数据渲染函数 */
render?: (record: TransferItem) => any;
/** 显示在右侧框数据的key集合 */
targetKeys: Array<string>;
/** 变化时回调函数 */
onChange?: (targetKeys: Array<TransferItem>, direction: string, moveKeys: any) => void;
/** 两个穿梭框的自定义样式 */
listStyle?: React.CSSProperties;
/** 自定义类*/
className?: string;
/** 标题集合,顺序从左至右 */
prefixCls?: string;
titles?: Array<string>;
/** 操作文案集合,顺序从上至下 */
operations?: Array<string>;
/** 是否显示搜索框 */
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<TransferProps, any> {
@ -82,6 +73,8 @@ export default class Transfer extends React.Component<TransferProps, any> {
rowKey: PropTypes.func,
};
splitedDataSource: any;
constructor(props) {
super(props);
this.state = {
@ -176,8 +169,12 @@ export default class Transfer extends React.Component<TransferProps, any> {
});
}
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({

35
components/transfer/list.tsx

@ -18,31 +18,30 @@ export function isRenderResultPlainObject(result) {
export interface TransferListProps {
prefixCls?: string;
/** 数据源 */
dataSource: Array<TransferItem>;
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<TransferItem>;
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<TransferListProps, any> {
@ -81,6 +80,9 @@ export default class TransferList extends React.Component<TransferListProps, any
antLocale: React.PropTypes.object,
};
context: TransferContext;
timer: any;
constructor(props) {
super(props);
this.state = {
@ -224,6 +226,7 @@ export default class TransferList extends React.Component<TransferListProps, any
checkPart: checkStatus === 'part',
checkable: <span className={'ant-transfer-checkbox-inner'}></span>,
filteredDataSource,
disabled: false,
})}
<span className={`${prefixCls}-header-selected`}>
<span>

4
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;
}

5
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;
}

1
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"

Loading…
Cancel
Save