Skip to content

Commit

Permalink
prettier code style
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Sep 14, 2020
1 parent 1a62d2c commit 4399cbb
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 370 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.doc
.storybook
es
lib
5 changes: 3 additions & 2 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# History
----

---

## 6.9.0 / 2019-10-18

Expand Down Expand Up @@ -104,7 +105,7 @@ Fix https://github.com/ant-design/ant-design/issues/2625

## 4.4.1 / 2016-07-24

- Fix row expand of key 0 record. (ant-design/ant-design#2471)
- Fix row expand of key 0 record. (ant-design/ant-design#2471)

## 4.4.0 / 2016-07-19

Expand Down
19 changes: 3 additions & 16 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@ MIT LICENSE

Copyright (c) 2015-present Alipay.com, https://www.alipay.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

React table component with useful functions.

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![Dependencies][david-image]][david-url]
[![DevDependencies][david-dev-image]][david-dev-url]
[![npm download][download-image]][download-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]

[npm-image]: http://img.shields.io/npm/v/rc-table.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-table
Expand Down
5 changes: 4 additions & 1 deletion examples/react-dnd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ class Demo extends React.Component {
this.setState(prevState =>
update(prevState, {
data: {
$splice: [[dragIndex, 1], [hoverIndex, 0, dragRow]],
$splice: [
[dragIndex, 1],
[hoverIndex, 0, dragRow],
],
},
}),
);
Expand Down
28 changes: 14 additions & 14 deletions examples/title-and-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ const Demo = () => {
title={currentData => <div>Title: {currentData.length} items</div>}
footer={currentData => <div>Footer: {currentData.length} items</div>}
summary={currentData => (
<>
<tr>
<th colSpan={6}>Summary</th>
</tr>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
<td>{currentData.reduce((total, item) => total + item.value, 0)}</td>
<td>{currentData.reduce((total, item) => total + item.value2, 0)}</td>
<td>-</td>
</tr>
</>
)}
<>
<tr>
<th colSpan={6}>Summary</th>
</tr>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
<td>{currentData.reduce((total, item) => total + item.value, 0)}</td>
<td>{currentData.reduce((total, item) => total + item.value2, 0)}</td>
<td>-</td>
</tr>
</>
)}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion src/Header/HeaderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ function HeaderRow<RecordType>({

let rowProps: React.HTMLAttributes<HTMLElement>;
if (onHeaderRow) {
rowProps = onHeaderRow(cells.map(cell => cell.column), index);
rowProps = onHeaderRow(
cells.map(cell => cell.column),
index,
);
}

const columnsKey = getColumnsKey(cells.map(cell => cell.column));
Expand Down
3 changes: 2 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export interface ColumnType<RecordType> extends ColumnSharedType<RecordType> {

export type ColumnsType<RecordType = unknown> = (
| ColumnGroupType<RecordType>
| ColumnType<RecordType>)[];
| ColumnType<RecordType>
)[];

export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;

Expand Down
127 changes: 25 additions & 102 deletions tests/ExpandRow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('Table.Expand', () => {
{ title: 'Age', dataIndex: 'age', key: 'age' },
];

const sampleData = [{ key: 0, name: 'Lucy', age: 27 }, { key: 1, name: 'Jack', age: 28 }];
const sampleData = [
{ key: 0, name: 'Lucy', age: 27 },
{ key: 1, name: 'Jack', age: 28 },
];

const createTable = props => <Table columns={sampleColumns} data={sampleData} {...props} />;

Expand Down Expand Up @@ -130,11 +133,7 @@ describe('Table.Expand', () => {
}),
);
act(() => {
wrapper
.find('ResizeObserver')
.first()
.props()
.onResize({ width: 1128 });
wrapper.find('ResizeObserver').first().props().onResize({ width: 1128 });
});
wrapper.update();
expect(wrapper.render()).toMatchSnapshot();
Expand All @@ -151,10 +150,7 @@ describe('Table.Expand', () => {
}),
);
expect(
wrapper
.find('tbody tr td')
.at(1)
.hasClass('rc-table-row-expand-icon-cell'),
wrapper.find('tbody tr td').at(1).hasClass('rc-table-row-expand-icon-cell'),
).toBeTruthy();
});

Expand Down Expand Up @@ -212,12 +208,7 @@ describe('Table.Expand', () => {
}),
);
expect(wrapper.find('tbody tr')).toHaveLength(3);
expect(
wrapper
.find('tbody tr')
.at(2)
.hasClass('rc-table-expanded-row'),
).toBeTruthy();
expect(wrapper.find('tbody tr').at(2).hasClass('rc-table-expanded-row')).toBeTruthy();
});

it('controlled by expandedRowKeys', () => {
Expand All @@ -228,33 +219,13 @@ describe('Table.Expand', () => {
}),
);
expect(wrapper.find('tbody tr')).toHaveLength(3);
expect(
wrapper
.find('tbody tr')
.at(1)
.hasClass('rc-table-expanded-row'),
).toBeTruthy();
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();

wrapper.setProps({ expandedRowKeys: [1] });
expect(wrapper.find('tbody tr')).toHaveLength(4);
expect(
wrapper
.find('tbody tr')
.at(1)
.hasClass('rc-table-expanded-row'),
).toBeTruthy();
expect(
wrapper
.find('tbody tr')
.at(1)
.props().style.display,
).toEqual('none');
expect(
wrapper
.find('tbody tr')
.at(3)
.hasClass('rc-table-expanded-row'),
).toBeTruthy();
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();
expect(wrapper.find('tbody tr').at(1).props().style.display).toEqual('none');
expect(wrapper.find('tbody tr').at(3).hasClass('rc-table-expanded-row')).toBeTruthy();
});

it('renders expend row class correctly', () => {
Expand All @@ -269,12 +240,7 @@ describe('Table.Expand', () => {
}),
);

expect(
wrapper
.find('tbody tr')
.at(1)
.hasClass('expand-row-test-class-name'),
).toBeTruthy();
expect(wrapper.find('tbody tr').at(1).hasClass('expand-row-test-class-name')).toBeTruthy();
});

it('fires expand change event', () => {
Expand All @@ -287,16 +253,10 @@ describe('Table.Expand', () => {
},
}),
);
wrapper
.find('.rc-table-row-expand-icon')
.first()
.simulate('click');
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]);

wrapper
.find('.rc-table-row-expand-icon')
.first()
.simulate('click');
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]);
});

Expand All @@ -308,10 +268,7 @@ describe('Table.Expand', () => {
onExpandedRowsChange,
}),
);
wrapper
.find('.rc-table-row-expand-icon')
.first()
.simulate('click');
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
expect(onExpandedRowsChange).toHaveBeenCalledWith([0]);
});

Expand Down Expand Up @@ -339,16 +296,10 @@ describe('Table.Expand', () => {
},
}),
);
wrapper
.find('tbody tr')
.first()
.simulate('click');
wrapper.find('tbody tr').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]);

wrapper
.find('tbody tr')
.first()
.simulate('click');
wrapper.find('tbody tr').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]);
});

Expand Down Expand Up @@ -410,30 +361,14 @@ describe('Table.Expand', () => {
}),
);
expect(wrapper.find('.rc-table-expanded-row').length).toBe(0);
wrapper
.find('.custom-expand-icon')
.first()
.simulate('click');
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
expect(onExpand).toHaveBeenCalledTimes(1);
expect(
wrapper
.find('.rc-table-expanded-row')
.first()
.getDOMNode().style.display,
).toBe('');
wrapper
.find('.custom-expand-icon')
.first()
.simulate('click');
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('');
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
expect(onExpand).toHaveBeenCalledTimes(2);
expect(
wrapper
.find('.rc-table-expanded-row')
.first()
.getDOMNode().style.display,
).toBe('none');
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('none');
});

// https://github.com/ant-design/ant-design/issues/23894
Expand All @@ -450,16 +385,10 @@ describe('Table.Expand', () => {
data,
}),
);
wrapper
.find('.rc-table-row-expand-icon')
.first()
.simulate('click');
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
expect(onExpand).toHaveBeenCalledTimes(1);
wrapper
.find('.rc-table-row-expand-icon')
.first()
.simulate('click');
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
expect(onExpand).toHaveBeenCalledTimes(2);
});
Expand All @@ -486,16 +415,10 @@ describe('Table.Expand', () => {
data,
}),
);
wrapper
.find('.custom-expand-icon')
.first()
.simulate('click');
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
expect(onExpand).toHaveBeenCalledTimes(1);
wrapper
.find('.custom-expand-icon')
.first()
.simulate('click');
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
expect(onExpand).toHaveBeenCalledTimes(2);
});
Expand Down
Loading

0 comments on commit 4399cbb

Please sign in to comment.