diff --git a/CHANGELOG.md b/CHANGELOG.md index f261f74..21e458e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [5.18.0](https://github.com/rsuite/rsuite-table/compare/5.17.0...5.18.0) (2023-11-24) + +### Features + +* **Table:** add support function type for children prop ([#474](https://github.com/rsuite/rsuite-table/pull/474)) + # [5.17.0](https://github.com/rsuite/rsuite-table/compare/5.16.0...5.17.0) (2023-11-17) diff --git a/README.md b/README.md index 0b9250b..d300dba 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,17 @@ A React table component. ## Install ```sh -npm i rsuite-table --save +# use npm +npm i rsuite-table + +# or use yarn +yarn add rsuite-table + +# or use pnpm +pnpm add rsuite-table ``` -### Usage +## Usage ```tsx import { Table, Column, HeaderCell, Cell } from 'rsuite-table'; @@ -233,13 +240,6 @@ const NameCell = ({ rowData, ...props }) => ( | scrollPosition | {top:number,left:number} | The scroll position of the table | | scrollTop | (top:number)=>void | Set the number of pixels for vertical scrolling of the table | -[npm-badge]: https://img.shields.io/npm/v/rsuite-table.svg?style=flat-square -[npm]: https://www.npmjs.com/package/rsuite-table -[coverage-badge]: https://img.shields.io/coveralls/rsuite/rsuite-table.svg?style=flat-square -[coverage]: https://coveralls.io/github/rsuite/rsuite-table -[actions-svg]: https://github.com/rsuite/rsuite-table/workflows/Node.js%20CI/badge.svg?branch=main -[actions-home]: https://github.com/rsuite/rsuite-table/actions?query=branch%3Amain+workflow%3A%22Node.js+CI%22 - ### Type safety We can pass generic type parameters to Table, Cell etc. for better type-safety when using typescript. @@ -248,7 +248,7 @@ Passing a render prop to Table is recommended when using TS, as this will ensure the right generic type parameter is automatically propagated to the Cell component. ```ts -const products: Product[] = [{ name: "Pineapple" }]; +const products: Product[] = [{ name: 'Pineapple' }]; ref={table} data={products}> {({ Column, HeaderCell, Cell }) => ( @@ -266,7 +266,7 @@ const products: Product[] = [{ name: "Pineapple" }]; In fact, the type parameter from table can be inferred from the data passed to it, so the type parameter to Table can also be skipped. ```ts -const products: Product[] = [{ name: "Pineapple" }]; +const products: Product[] = [{ name: 'Pineapple' }]; {({ Column, HeaderCell, Cell }) => ( @@ -284,16 +284,25 @@ When writing reusable components, it is recommended to make your components gene ```ts interface ImageCellProps> { - rowData: TRow, - dataKey: TKey, + rowData: TRow; + dataKey: TKey; // ... any other props } -const ImageCell = >( - { rowData, dataKey, ...rest }: ImageCellProps -) => ( +const ImageCell = >({ + rowData, + dataKey, + ...rest +}: ImageCellProps) => ( {...rest}> ); ``` + +[npm-badge]: https://img.shields.io/npm/v/rsuite-table.svg?style=flat-square +[npm]: https://www.npmjs.com/package/rsuite-table +[coverage-badge]: https://img.shields.io/coveralls/rsuite/rsuite-table.svg?style=flat-square +[coverage]: https://coveralls.io/github/rsuite/rsuite-table +[actions-svg]: https://github.com/rsuite/rsuite-table/workflows/Node.js%20CI/badge.svg?branch=main +[actions-home]: https://github.com/rsuite/rsuite-table/actions?query=branch%3Amain+workflow%3A%22Node.js+CI%22 diff --git a/package.json b/package.json index ec3c4ab..7e61cb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsuite-table", - "version": "5.17.0", + "version": "5.18.0", "description": "A React table component", "main": "lib/index.js", "typings": "lib/index.d.ts",