Browse Source

change and undocument onSelectMultiple cause it need more disscuss

pull/11472/merge
afc163 6 years ago
committed by 偏右
parent
commit
bead75021b
  1. 6
      components/table/Table.tsx
  2. 2
      components/table/__tests__/Table.rowSelection.test.js
  3. 1
      components/table/index.en-US.md
  4. 4
      components/table/interface.tsx

6
components/table/Table.tsx

@ -251,11 +251,11 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
}
if (selectWay === 'onSelect' && rowSelection.onSelect) {
rowSelection.onSelect(record!, checked!, selectedRows, nativeEvent!);
} else if (selectWay === 'onSelectMulti' && rowSelection.onSelectMulti) {
} else if (selectWay === 'onSelectMultiple' && rowSelection.onSelectMultiple) {
const changeRows = data.filter(
(row, i) => changeRowKeys!.indexOf(this.getRecordKey(row, i)) >= 0,
);
rowSelection.onSelectMulti(checked!, selectedRows, changeRows);
rowSelection.onSelectMultiple(checked!, selectedRows, changeRows);
} else if (selectWay === 'onSelectAll' && rowSelection.onSelectAll) {
const changeRows = data.filter(
(row, i) => changeRowKeys!.indexOf(this.getRecordKey(row, i)) >= 0,
@ -498,7 +498,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
selectionDirty: true,
});
this.setSelectedRowKeys(selectedRowKeys, {
selectWay: 'onSelectMulti',
selectWay: 'onSelectMultiple',
record,
checked,
changeRowKeys,

2
components/table/__tests__/Table.rowSelection.test.js

@ -167,7 +167,7 @@ describe('Table.rowSelection', () => {
const handleSelect = jest.fn();
const rowSelection = {
onSelect: handleSelect,
onSelectMulti: handleSelectMulti,
onSelectMultiple: handleSelectMulti,
};
const wrapper = mount(createTable({ rowSelection }));

1
components/table/index.en-US.md

@ -163,7 +163,6 @@ Properties for row selection.
| type | `checkbox` or `radio` | `checkbox` \| `radio` | `checkbox` |
| onChange | Callback executed when selected rows change | Function(selectedRowKeys, selectedRows) | - |
| onSelect | Callback executed when select/deselect one row | Function(record, selected, selectedRows, nativeEvent) | - |
| onSelectMulti | Callback executed when multiple rows are selected/unselected | Function(selected, selectedRows, changeRows) | - |
| onSelectAll | Callback executed when select/deselect all rows | Function(selected, selectedRows, changeRows) | - |
| onSelectInvert | Callback executed when row selection is inverted | Function(selectedRows) | - |

4
components/table/interface.tsx

@ -62,7 +62,7 @@ export interface TableLocale {
export type RowSelectionType = 'checkbox' | 'radio';
export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any;
export type TableSelectWay = 'onSelect' | 'onSelectMulti' | 'onSelectAll' | 'onSelectInvert';
export type TableSelectWay = 'onSelect' | 'onSelectMultiple' | 'onSelectAll' | 'onSelectInvert';
export interface TableRowSelection<T> {
type?: RowSelectionType;
@ -70,7 +70,7 @@ export interface TableRowSelection<T> {
onChange?: (selectedRowKeys: string[] | number[], selectedRows: Object[]) => void;
getCheckboxProps?: (record: T) => Object;
onSelect?: SelectionSelectFn<T>;
onSelectMulti?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => void;
onSelectMultiple?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => void;
onSelectAll?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => void;
onSelectInvert?: (selectedRows: Object[]) => void;
selections?: SelectionItem[] | boolean;

Loading…
Cancel
Save