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 // Transfer
export interface TransferProps { export interface TransferProps {
/** 数据源 */
dataSource: Array<TransferItem>; dataSource: Array<TransferItem>;
/** 每行数据渲染函数 */
render?: (record: TransferItem) => any; render?: (record: TransferItem) => any;
/** 显示在右侧框数据的key集合 */
targetKeys: Array<string>; targetKeys: Array<string>;
/** 变化时回调函数 */
onChange?: (targetKeys: Array<TransferItem>, direction: string, moveKeys: any) => void; onChange?: (targetKeys: Array<TransferItem>, direction: string, moveKeys: any) => void;
/** 两个穿梭框的自定义样式 */
listStyle?: React.CSSProperties; listStyle?: React.CSSProperties;
/** 自定义类*/
className?: string; className?: string;
/** 标题集合,顺序从左至右 */ prefixCls?: string;
titles?: Array<string>; titles?: Array<string>;
/** 操作文案集合,顺序从上至下 */
operations?: Array<string>; operations?: Array<string>;
/** 是否显示搜索框 */
showSearch?: boolean; showSearch?: boolean;
/** 搜索框的默认值 */
searchPlaceholder?: string; searchPlaceholder?: string;
/** 当列表为空时显示的内容 */
notFoundContent?: React.ReactNode | string; notFoundContent?: React.ReactNode | string;
/** 底部渲染函数 */
footer?: (props: any) => any; footer?: (props: any) => any;
style?: React.CSSProperties; style?: React.CSSProperties;
filterOption: (filterText: any, item: any) => boolean;
body?: (props: any) => any;
} }
export default class Transfer extends React.Component<TransferProps, 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, rowKey: PropTypes.func,
}; };
splitedDataSource: any;
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -176,8 +169,12 @@ export default class Transfer extends React.Component<TransferProps, any> {
}); });
} }
handleLeftSelectAll = (...args) => this.handleSelectAll('left', ...args) handleLeftSelectAll = (filteredDataSource, checkAll) => (
handleRightSelectAll = (...args) => this.handleSelectAll('right', ...args) this.handleSelectAll('left', filteredDataSource, checkAll)
)
handleRightSelectAll = (filteredDataSource, checkAll) => (
this.handleSelectAll('right', filteredDataSource, checkAll)
)
handleFilter = (direction, e) => { handleFilter = (direction, e) => {
this.setState({ this.setState({

35
components/transfer/list.tsx

@ -18,31 +18,30 @@ export function isRenderResultPlainObject(result) {
export interface TransferListProps { export interface TransferListProps {
prefixCls?: string; prefixCls?: string;
/** 数据源 */
dataSource: Array<TransferItem>; dataSource: Array<TransferItem>;
filter?: TransferItem; filter?: string;
/** 是否显示搜索框 */
showSearch?: boolean; showSearch?: boolean;
/** 搜索框的默认值 */
searchPlaceholder?: string; searchPlaceholder?: string;
/** 标题 */
titleText?: string; titleText?: string;
style?: React.CSSProperties; style?: React.CSSProperties;
handleFilter?: () => void; handleFilter?: (e: any) => void;
handleSelect?: () => void; handleSelect?: (selectedItem: any, checked: boolean) => void;
handleSelectAll?: () => void; handleSelectAll?: (dataSource: any[], checkAll: boolean) => void;
handleClear?: () => void; handleClear?: () => void;
/** 每行渲染函数 */ render?: (...any) => any;
render?: () => void; body?: (props: any) => any;
/** 主体渲染函数 */ footer?: (props: any) => void;
body?: () => void; checkedKeys?: any[];
/** 底部渲染函数 */
footer?: () => void;
/** 选中项 */
checkedKeys?: Array<TransferItem>;
checkStatus?: boolean; checkStatus?: boolean;
position?: string; position?: string;
notFoundContent?: React.ReactNode | 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> { 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, antLocale: React.PropTypes.object,
}; };
context: TransferContext;
timer: any;
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -224,6 +226,7 @@ export default class TransferList extends React.Component<TransferListProps, any
checkPart: checkStatus === 'part', checkPart: checkStatus === 'part',
checkable: <span className={'ant-transfer-checkbox-inner'}></span>, checkable: <span className={'ant-transfer-checkbox-inner'}></span>,
filteredDataSource, filteredDataSource,
disabled: false,
})} })}
<span className={`${prefixCls}-header-selected`}> <span className={`${prefixCls}-header-selected`}>
<span> <span>

4
components/transfer/operation.tsx

@ -9,8 +9,8 @@ export interface TransferOperationProps {
className?: string; className?: string;
leftArrowText?: string; leftArrowText?: string;
rightArrowText?: string; rightArrowText?: string;
moveToLeft?: Function; moveToLeft?: React.FormEventHandler;
moveToRight?: Function; moveToRight?: React.FormEventHandler;
leftActive?: boolean; leftActive?: boolean;
rightActive?: boolean; rightActive?: boolean;
} }

5
custom-typings.d.ts

@ -2,6 +2,11 @@ declare module 'classnames' {
export default function({}): string; export default function({}): string;
} }
declare module 'react-addons-pure-render-mixin' {
var exports: any;
export default exports;
}
declare module 'gregorian-calendar-format' { declare module 'gregorian-calendar-format' {
export default function({}): string; export default function({}): string;
} }

1
typings.json

@ -4,7 +4,6 @@
"object-assign": "file:custom-typings/object-assign.d.ts", "object-assign": "file:custom-typings/object-assign.d.ts",
"rc-util/lib/Dom/addEventListener": "file:custom-typings/rc-util.d.ts", "rc-util/lib/Dom/addEventListener": "file:custom-typings/rc-util.d.ts",
"react": "registry:dt/react#0.14.0+20160720060442", "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", "react-dom": "registry:dt/react-dom#0.14.0+20160412154040",
"shallowequal": "file:custom-typings/shallowequal.d.ts", "shallowequal": "file:custom-typings/shallowequal.d.ts",
"warning": "file:custom-typings/warning.d.ts" "warning": "file:custom-typings/warning.d.ts"

Loading…
Cancel
Save