Skip to content

Commit 8b6a875

Browse files
authored
Merge branch 'master' into feat-resizable
2 parents 1cb8e69 + 057acc8 commit 8b6a875

53 files changed

Lines changed: 1054 additions & 662 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# rc-table
1+
# @rc-component/table
22

33
React table component with useful functions.
44

55
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
66

7-
[npm-image]: http://img.shields.io/npm/v/rc-table.svg?style=flat-square
8-
[npm-url]: http://npmjs.org/package/rc-table
7+
[npm-image]: http://img.shields.io/npm/v/@rc-component/table.svg?style=flat-square
8+
[npm-url]: http://npmjs.org/package/@rc-component/table
99
[github-actions-image]: https://github.com/react-component/table/workflows/CI/badge.svg
1010
[github-actions-url]: https://github.com/react-component/table/actions
1111
[coveralls-image]: https://img.shields.io/coveralls/react-component/table.svg?style=flat-square
@@ -16,14 +16,14 @@ React table component with useful functions.
1616
[david-image]: https://david-dm.org/react-component/table/status.svg?style=flat-square
1717
[david-dev-url]: https://david-dm.org/react-component/table?type=dev
1818
[david-dev-image]: https://david-dm.org/react-component/table/dev-status.svg?style=flat-square
19-
[download-image]: https://img.shields.io/npm/dm/rc-table.svg?style=flat-square
20-
[download-url]: https://npmjs.org/package/rc-table
21-
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-table
22-
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-table
19+
[download-image]: https://img.shields.io/npm/dm/@rc-component/table.svg?style=flat-square
20+
[download-url]: https://npmjs.org/package/@rc-component/table
21+
[bundlephobia-url]: https://bundlephobia.com/result?p=@rc-component/table
22+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/table
2323

2424
## install
2525

26-
[![rc-table](https://nodei.co/npm/rc-table.png)](https://npmjs.org/package/rc-table)
26+
[![@rc-component/table](https://nodei.co/npm/@rc-component/table.png)](https://npmjs.org/package/@rc-component/table)
2727

2828
## Development
2929

@@ -39,7 +39,7 @@ https://table-react-component.vercel.app/
3939
## Usage
4040

4141
```js
42-
import Table from 'rc-table';
42+
import Table from '@rc-component/table';
4343

4444
const columns = [
4545
{
@@ -83,7 +83,7 @@ React.render(<Table columns={columns} data={data} />, mountNode);
8383
| Name | Type | Default | Description |
8484
| --- | --- | --- | --- |
8585
| tableLayout | `auto` \| `fixed` | `auto` \| `fixed` for any columns is fixed or ellipsis or header is fixed | https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout |
86-
| prefixCls | String | rc-table | |
86+
| prefixCls | String | `rc-table` | |
8787
| className | String | | additional className |
8888
| id | String | | identifier of the container div |
8989
| useFixedHeader | Boolean | false | whether use separator table for header. better set width for columns |
@@ -159,4 +159,4 @@ React.render(<Table columns={columns} data={data} />, mountNode);
159159

160160
## License
161161

162-
rc-table is released under the MIT license.
162+
@rc-component/table is released under the MIT license.

assets/index.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
padding: @cell-padding;
4646
white-space: normal;
47-
word-break: break-word;
4847
border: @border;
4948
border-top: 0;
5049
border-left: 0;

docs/demo/measureRowRender.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: measureRowRender
3+
nav:
4+
title: measureRowRender
5+
path: /demo
6+
---
7+
8+
<code src="../examples/measureRowRender.tsx"></code>

docs/examples/animation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import CSSMotionList from 'rc-animate/lib/CSSMotionList';
3-
import classNames from 'classnames';
3+
import { clsx } from 'clsx';
44
import toArray from '@rc-component/util/lib/Children/toArray';
55
import type { TableProps } from 'rc-table';
66
import Table from 'rc-table';
@@ -11,7 +11,7 @@ type MotionBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;
1111

1212
const MotionBody: React.FC<MotionBodyProps> = ({ children, ...props }) => {
1313
const nodeList = toArray(children);
14-
const nodesRef = React.useRef<Record<string, React.ReactElement>>({});
14+
const nodesRef = React.useRef<Record<string, React.ReactElement<any>>>({});
1515

1616
// Better apply clean up logic to avoid OOM
1717
const keys: React.Key[] = [];
@@ -26,8 +26,8 @@ const MotionBody: React.FC<MotionBodyProps> = ({ children, ...props }) => {
2626
<CSSMotionList keys={keys} component={false} motionName="move">
2727
{({ key, className }) => {
2828
const node = nodesRef.current[key];
29-
return React.cloneElement(node, {
30-
className: classNames(node.props.className, className),
29+
return React.cloneElement<any>(node, {
30+
className: clsx(node.props.className, className),
3131
});
3232
}}
3333
</CSSMotionList>

docs/examples/fixedColumnsAndHeaderRtl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useColumn = (
3737
ellipsis: boolean,
3838
percentage: boolean,
3939
) => {
40-
const columns: ColumnsType<RecordType> = React.useMemo(
40+
const columns = React.useMemo<ColumnsType<RecordType>>(
4141
() => [
4242
{
4343
title: 'title1',

docs/examples/jsx.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-named-as-default-member */
21
import React from 'react';
32
import Table from 'rc-table';
43
import '../../assets/index.less';

docs/examples/measureRowRender.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from 'react';
2+
import Table from 'rc-table';
3+
import type { TableProps } from 'rc-table';
4+
5+
const columns = [
6+
{
7+
title: (
8+
<div>
9+
Name
10+
<div className="filter-dropdown" style={{ display: 'none' }}>
11+
Filter Content
12+
</div>
13+
</div>
14+
),
15+
dataIndex: 'name',
16+
key: 'name',
17+
width: 100,
18+
},
19+
{
20+
title: 'Age',
21+
dataIndex: 'age',
22+
key: 'age',
23+
width: 80,
24+
},
25+
];
26+
27+
const data = [
28+
{ key: 1, name: 'John', age: 25 },
29+
{ key: 2, name: 'Jane', age: 30 },
30+
{ key: 3, name: 'Jime', age: 35 },
31+
];
32+
33+
// 自定义 MeasureRow 渲染,隐藏弹层内容
34+
const measureRowRender: TableProps['measureRowRender'] = measureRow => {
35+
if (React.isValidElement(measureRow)) {
36+
return React.cloneElement<any>(measureRow, {
37+
style: { ...(measureRow.props as any).style, display: 'none' },
38+
});
39+
}
40+
return measureRow;
41+
};
42+
43+
// 示例:使用 measureRowRender 来隐藏 MeasureRow 中的弹层
44+
const MeasureRowRenderExample: React.FC = () => {
45+
return (
46+
<Table
47+
columns={columns}
48+
data={data}
49+
sticky
50+
scroll={{ x: true }}
51+
measureRowRender={measureRowRender}
52+
/>
53+
);
54+
};
55+
56+
export default MeasureRowRenderExample;

docs/examples/scrollY.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ for (let i = 0; i < 20; i += 1) {
1313
}
1414

1515
const Test = () => {
16-
const tblRef = React.useRef<Reference>();
16+
const tblRef = React.useRef<Reference>(null);
1717
const [showBody, setShowBody] = React.useState(true);
1818

1919
const toggleBody = () => {
@@ -94,8 +94,11 @@ const Test = () => {
9494
data={data}
9595
scroll={{ y: 300 }}
9696
rowKey={record => record.key}
97-
onRow={(record, index) => ({ style: { backgroundColor: 'red' } })}
97+
onRow={() => ({ style: { backgroundColor: 'red' } })}
9898
/>
99+
<h3>Column align issue</h3>
100+
<p>https://github.com/ant-design/ant-design/issues/54889</p>
101+
<Table columns={columns} data={data} sticky scroll={{ y: 300, x: 2000 }} />
99102
</div>
100103
);
101104
};

docs/examples/shadow.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import type { TableProps } from 'rc-table';
32
import Table from 'rc-table';
43
import '../../assets/index.less';
54
import type { ColumnsType } from '@/interface';

0 commit comments

Comments
 (0)