Skip to content

Commit 53c5af0

Browse files
authored
refactor!: upgrade dependencies, add TypeScript support, and restructure build output (#435)
* chore: upgrade dependencies, add TypeScript support, and restructure build output - Upgrade all dev dependencies (ESLint 9, Jest 30, Prettier 3, Husky 9, etc.) - Replace node-sass with sass, react-test-renderer with @testing-library/react - Migrate ESLint from .eslintrc to flat config (eslint.config.mjs) with TS parser - Add TypeScript: convert all src/ and spec/ files from JS to TS/TSX - Keep Babel for JS output, add tsc for type declarations (dist/types/) - Restructure build output into dist/ (cjs, esm, types, styles.css) - Upgrade Gatsby website to v4 + React 18 with updated plugins and examples - Move spec files to dedicated spec/ directory * refactor: improve TypeScript types and remove unnecessary `as any` casts - Move Column static properties (Alignment, FrozenDirection) into class body - Use `keyof TableComponents` for _getComponent instead of untyped string - Add JSDoc comments to ColumnShape and other shared types - Export cloneArray from index.ts - Include LICENSE.md and README.md in published files * chore: bump version to 2.0.0 and update changelog, docs, and propTypes JSDoc - Bump version from 1.13.5 to 2.0.0 - Generate v2.0.0 changelog with breaking changes, features, upgrades, and bug fixes - Update docs (get-started, advance) with new import paths and browser support - Restore JSDoc comments on BaseTable.propTypes for gatsby-transformer-react-docgen
1 parent ef4f9e3 commit 53c5af0

58 files changed

Lines changed: 18632 additions & 23549 deletions

Some content is hidden

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

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
],
99
"@babel/preset-react",
10+
"@babel/preset-typescript",
1011
],
1112
"plugins": [
1213
"@babel/plugin-proposal-class-properties",

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ npm-debug.log.*
1212
yarn-error.log
1313
yarn-error.log.*
1414

15-
styles.css
16-
es/
17-
lib/
15+
dist/
1816
coverage/

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.16.0
1+
24

.prettierrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"semi": true,
32
"singleQuote": true,
4-
"trailingComma": "es5",
5-
"printWidth": 120
3+
"quoteProps": "preserve",
4+
"printWidth": 120,
5+
"arrowParens": "always",
6+
"jsxBracketSameLine": false
67
}

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
# CHANGELOG
22

3-
## NEXT VERSION
3+
## v2.0.0 (2026-04-16)
4+
5+
### Breaking Changes
6+
7+
- **Build output restructured**: `lib/``dist/cjs/`, `es/``dist/esm/`, `types/``dist/types/`, `styles.css``dist/styles.css`
8+
- CSS import changed from `react-base-table/styles.css` to `react-base-table/dist/styles.css`
9+
- SCSS import changed from `~react-base-table/es/_BaseTable.scss` to `react-base-table/dist/esm/_BaseTable.scss`
10+
- **Peer dependency**: requires React >= 17.0.2 (dropped IE11 support)
11+
- **Removed hand-written `types/index.d.ts`**: replaced by auto-generated declarations from TypeScript source
12+
13+
### Features
14+
15+
- **TypeScript**: rewritten all source files (`src/`) and specs (`spec/`) in TypeScript; ships `.d.ts` declarations out of the box
16+
- **Exported types**: `ColumnShape`, `RowData`, `RowKey`, `CellRendererProps`, `HeaderRendererProps`, `RowRendererProps`, `ScrollArgs`, `SortByShape`, `SortState`, `TableComponents`, and more
17+
- **New utility export**: `cloneArray`
18+
19+
### Upgrades
20+
21+
- Upgraded all dev dependencies: ESLint 9, Jest 30, Prettier 3, Husky 9, Sass (Dart), TypeScript 6
22+
- Replaced `node-sass` with `sass` (Dart Sass)
23+
- Replaced `react-test-renderer` with `@testing-library/react`
24+
- Migrated ESLint from `.eslintrc` to flat config (`eslint.config.mjs`) with `@typescript-eslint/parser`
25+
- Moved test files from `src/` to dedicated `spec/` directory
26+
27+
### Bug Fixes
28+
29+
- fix: `_handleRowExpand` expand logic was always true (`!arr.indexOf(x) >= 0``arr.indexOf(x) < 0`)
30+
31+
### Website (Gatsby demo)
32+
33+
- Upgraded Gatsby 2 → 4, React 16 → 18, and all associated plugins
34+
- Migrated `faker``@faker-js/faker` v8
35+
- Fixed navigation links, code block rendering, and live code examples
436

537
## v1.13.5 (2024-05-24)
638

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@ yarn add react-base-table
1919

2020
## Usage
2121

22-
```js
22+
```tsx
2323
import BaseTable, { Column } from 'react-base-table'
24-
import 'react-base-table/styles.css'
25-
// Important: if you fail to import react-base-table/styles.css then
26-
// BaseTable will not render as advertised in the included examples.
27-
// For advanced styling see link below:
28-
// https://github.com/Autodesk/react-base-table#advance
29-
...
24+
import 'react-base-table/dist/styles.css'
25+
3026
<BaseTable data={data} width={600} height={400}>
3127
<Column key="col0" dataKey="col0" width={100} />
3228
<Column key="col1" dataKey="col1" width={100} />
3329
...
3430
</BaseTable>
35-
...
3631
```
3732

33+
> **Note:** You must import the stylesheet for BaseTable to render correctly. For advanced styling see [below](#advance).
34+
3835
Learn more at the [website](https://autodesk.github.io/react-base-table/)
3936

4037
### unique key
@@ -64,11 +61,17 @@ Things getting worse with the introduction of React hooks, we use primitive stat
6461

6562
Here is an [example](https://autodesk.github.io/react-base-table/playground#MYewdgzgLgBKA2BXAtpGBeGBzApmHATgIZQ4DCISqEAFAIwAMAlAFCiSwAmJRG2ehEjgAiPGghSQANDABMDZixY4AHgAcQBLjgBmRRPFg0mGAHwwA3ixhxw0GAG1QiMKQIyIOKBRduAunwASjhEwFAAdIieAMpQQjSKNuz2DgCWWGCaOABiLmGp4B5eAJIZWblg+eABmMGhEVE4sfFQBIg4rEl2sGlgAFY4YRRUYEVQxf2D3pSSNTB1YZExcaQ0evCenTAEXogEYDA01jYwADymxydnnKkAbjDQAJ7wOOgWFjBqRJw3YFgAXDAACwyG4QNTwIiPQEAch0LxUMJkfSiUFSOkeFFceCgsPBoRwAFoAEZeADuODwMJgAF8aRcrldTsTEFAoOAYOAyPBUsAANZvYxmB5eHzYgjiEC+QgwADUMDoTHpstOAHoWWzwAzGTZTpDSfBtTrdakwGpWZdjTYoI81K8AETAAAWgz5xJAKntlqtztdOE4b3SmR2FSqYBp3uNXKdRD+rwsOGFnnGZRDeTR4BoOHCcQIuAivv5-qVkauqqNxtKwcTOnTBQOptsI1syC+O1LZ1V+pwho7eqIBorOtOpvNUA7VxtdvQjpd-PdnonJ0LfP9gcmQxmqAjVqu0djuDeifQ5mTEwGm5GWZzRDzXnCK+LO935aX56mMFUrV43DiMHZTaSDAnC6KaqQZmAfZdgOPZDp2Ny3HBpwACoDi8MA6KkKj+sBPBvL+RA0jAQblHW4ATMMkgUK2t7xiRaaVBB9J9pRqBLhY4ScRI1AOAwfjPlaBEAOJeG4gomCetjSgQAnGs44rrhe0zNgA-FJ4owICLggZh+CcLJZZwbqrEHBxXFbpADh0PxMCvlapwmZYnEPhZEAOLINl2caDkWU55kjG5ADMnlGWcjlmS5AUOECIWRmqqHEi8FZqtqrARkAA) to demonstrate
6663

67-
## Browser Support
64+
## TypeScript
65+
66+
This package is written in TypeScript and ships type declarations out of the box. All public types are exported from the main entry point:
67+
68+
```ts
69+
import type { ColumnShape, RowData, SortOrderValue } from 'react-base-table'
70+
```
6871

69-
`BaseTable` is well tested on all modern browsers and IE11. _You have to polyfill `Array.prototype.findIndex` to make it works on IE_
72+
## Browser Support
7073

71-
**The [examples](https://autodesk.github.io/react-base-table/examples) don't work on IE as they are powered by [react-runner](https://github.com/nihgwu/react-runner) which is a `react-live` like library but only for modern browsers.**
74+
`BaseTable` is tested on all modern browsers (Chrome, Firefox, Safari, Edge). IE is no longer supported.
7275

7376
## Advance
7477

@@ -90,7 +93,7 @@ $column-padding: 7.5px;
9093
$show-frozen-rows-shadow: false;
9194
$show-frozen-columns-shadow: true;
9295

93-
@import '~react-base-table/es/_BaseTable.scss';
96+
@import 'react-base-table/dist/esm/_BaseTable.scss';
9497

9598
.#{$table-prefix} {
9699
&:not(.#{$table-prefix}--show-left-shadow) {
@@ -140,7 +143,16 @@ We are using a advanced table component based on `BaseTable` internally, with mu
140143

141144
## Development
142145

143-
We use `Yarn` as the package manager, checkout this repo and run `yarn` under both root folder and `website` folder in install packages, then run `yarn start` to start the demo site powered by `Gatsby`
146+
Requires **Node.js >= 18** (Node 24 recommended). We use `Yarn` as the package manager.
147+
148+
```bash
149+
yarn install --ignore-scripts
150+
cd website && yarn install
151+
cd ..
152+
yarn start
153+
```
154+
155+
This starts the demo site powered by Gatsby.
144156

145157
## Contributing
146158

docs/advance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $column-padding: 7.5px;
1818
$show-frozen-rows-shadow: false;
1919
$show-frozen-columns-shadow: true;
2020

21-
@import '~react-base-table/es/_BaseTable.scss';
21+
@import 'react-base-table/dist/esm/_BaseTable.scss';
2222

2323
.#{$table-prefix} {
2424
&:not(.#{$table-prefix}--show-left-shadow) {

0 commit comments

Comments
 (0)