@tanstack/react-table 0.0.1-alpha.8 → 8.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +112 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/cjs/aggregationTypes.js +130 -0
- package/build/cjs/aggregationTypes.js.map +1 -0
- package/build/cjs/core.js +519 -0
- package/build/cjs/core.js.map +1 -0
- package/build/cjs/createTable.js +103 -0
- package/build/cjs/createTable.js.map +1 -0
- package/build/cjs/features/ColumnSizing.js +331 -0
- package/build/cjs/features/ColumnSizing.js.map +1 -0
- package/build/cjs/features/Expanding.js +234 -0
- package/build/cjs/features/Expanding.js.map +1 -0
- package/build/cjs/features/Filters.js +396 -0
- package/build/cjs/features/Filters.js.map +1 -0
- package/build/cjs/features/Grouping.js +228 -0
- package/build/cjs/features/Grouping.js.map +1 -0
- package/build/cjs/features/Headers.js +486 -0
- package/build/cjs/features/Headers.js.map +1 -0
- package/build/cjs/features/Ordering.js +83 -0
- package/build/cjs/features/Ordering.js.map +1 -0
- package/build/cjs/features/Pinning.js +163 -0
- package/build/cjs/features/Pinning.js.map +1 -0
- package/build/cjs/features/Sorting.js +269 -0
- package/build/cjs/features/Sorting.js.map +1 -0
- package/build/cjs/features/Visibility.js +160 -0
- package/build/cjs/features/Visibility.js.map +1 -0
- package/build/cjs/filterTypes.js +172 -0
- package/build/cjs/filterTypes.js.map +1 -0
- package/build/cjs/index.js +30 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/sortTypes.js +121 -0
- package/build/cjs/sortTypes.js.map +1 -0
- package/build/cjs/utils/columnFilterRowsFn.js +130 -0
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -0
- package/build/cjs/utils/expandRowsFn.js +38 -0
- package/build/cjs/utils/expandRowsFn.js.map +1 -0
- package/build/cjs/utils/globalFilterRowsFn.js +100 -0
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -0
- package/build/cjs/utils/groupRowsFn.js +154 -0
- package/build/cjs/utils/groupRowsFn.js.map +1 -0
- package/build/cjs/utils/sortRowsFn.js +93 -0
- package/build/cjs/utils/sortRowsFn.js.map +1 -0
- package/build/cjs/utils.js +143 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +3722 -0
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/stats-react.json +747 -0
- package/build/types/aggregationTypes.d.ts +22 -0
- package/build/types/core.d.ts +126 -0
- package/build/types/createTable.d.ts +35 -0
- package/build/types/features/ColumnSizing.d.ts +73 -0
- package/build/types/features/Expanding.d.ts +52 -0
- package/build/types/features/Filters.d.ts +93 -0
- package/build/types/features/Grouping.d.ts +82 -0
- package/build/types/features/Headers.d.ts +41 -0
- package/build/types/features/Ordering.d.ts +19 -0
- package/build/types/features/Pinning.d.ts +39 -0
- package/build/types/features/Sorting.d.ts +75 -0
- package/build/types/features/Visibility.d.ts +47 -0
- package/build/types/filterTypes.d.ts +50 -0
- package/build/types/index.d.ts +7 -0
- package/build/types/sortTypes.d.ts +17 -0
- package/build/types/types.d.ts +124 -0
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -0
- package/build/types/utils/expandRowsFn.d.ts +2 -0
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -0
- package/build/types/utils/groupRowsFn.d.ts +2 -0
- package/build/types/utils/sortRowsFn.d.ts +2 -0
- package/build/types/utils.d.ts +24 -0
- package/{dist/react-table.development.js → build/umd/index.development.js} +372 -29
- package/build/umd/index.development.js.map +1 -0
- package/build/umd/index.production.js +12 -0
- package/build/umd/index.production.js.map +1 -0
- package/package.json +9 -94
- package/src/core.tsx +43 -5
- package/src/createTable.tsx +1 -1
- package/src/features/ColumnSizing.ts +482 -0
- package/src/features/Filters.ts +1 -1
- package/src/features/Headers.ts +43 -6
- package/src/features/{withPagination.ts → withPagination.oldts} +0 -0
- package/src/features/{withRowSelection.ts → withRowSelection.oldts} +0 -0
- package/src/types.ts +35 -6
- package/src/utils.tsx +8 -2
- package/dist/react-table.development.js.map +0 -1
- package/dist/react-table.production.min.js +0 -2
- package/dist/react-table.production.min.js.map +0 -1
- package/lib/index.js +0 -65
- package/src/features/notest/useAbsoluteLayout.test.js +0 -152
- package/src/features/notest/useBlockLayout.test.js +0 -158
- package/src/features/notest/useColumnOrder.test.js +0 -186
- package/src/features/notest/useExpanded.test.js +0 -125
- package/src/features/notest/useFilters.test.js +0 -393
- package/src/features/notest/useFiltersAndRowSelect.test.js +0 -256
- package/src/features/notest/useFlexLayout.test.js +0 -152
- package/src/features/notest/useGroupBy.test.js +0 -259
- package/src/features/notest/usePagination.test.js +0 -231
- package/src/features/notest/useResizeColumns.test.js +0 -229
- package/src/features/notest/useRowSelect.test.js +0 -250
- package/src/features/notest/useRowState.test.js +0 -178
- package/src/features/tests/Visibility.test.tsx +0 -225
- package/src/features/tests/__snapshots__/Visibility.test.tsx.snap +0 -390
- package/src/features/tests/withSorting.notest.tsx +0 -341
- package/src/features/withColumnResizing.ts +0 -281
- package/src/test-utils/makeTestData.ts +0 -41
- package/src/tests/__snapshots__/core.test.tsx.snap +0 -148
- package/src/tests/core.test.tsx +0 -241
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-table",
|
|
3
|
-
"
|
|
3
|
+
"author": "Tanner Linsley",
|
|
4
|
+
"version": "8.0.0-alpha.2",
|
|
4
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
5
6
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://github.com/
|
|
7
|
+
"homepage": "https://github.com/tanstack/react-table#readme",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/tanstack/react-table.git"
|
|
10
11
|
},
|
|
11
12
|
"publishConfig": {
|
|
12
13
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,105 +22,19 @@
|
|
|
21
22
|
"type": "github",
|
|
22
23
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"test": "(is-ci && yarn test:ci) || yarn test:dev",
|
|
29
|
-
"test:dev": "jest --watch",
|
|
30
|
-
"test:ci": "jest",
|
|
31
|
-
"test:coverage": "yarn test:ci; open coverage/lcov-report/index.html",
|
|
32
|
-
"build": "yarn format && yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:types",
|
|
33
|
-
"build:commonjs": "rimraf ./lib && cross-env BABEL_ENV=commonjs babel --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir lib",
|
|
34
|
-
"build:es": "rimraf ./es && babel --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir es",
|
|
35
|
-
"build:umd": "rimraf ./dist && cross-env NODE_ENV=production rollup -c && rollup-plugin-visualizer stats-react.json",
|
|
36
|
-
"build:types": "rimraf ./types && tsc --project ./tsconfig.types.json && replace 'import type' 'import' ./types -r --silent && replace 'export type' 'export' ./types -r --silent",
|
|
37
|
-
"watch": "yarn watch:commonjs & yarn watch:es & yarn watch:umd & yarn watch:types",
|
|
38
|
-
"watch:commonjs": "rimraf ./lib && cross-env BABEL_ENV=commonjs babel --watch --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir lib",
|
|
39
|
-
"watch:es": "rimraf ./es && babel --watch --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir es",
|
|
40
|
-
"watch:umd": "rimraf ./dist && cross-env NODE_ENV=production rollup -w -c && rollup-plugin-visualizer stats-react.json",
|
|
41
|
-
"watch:types": "rimraf ./types && tsc --watch --project ./tsconfig.types.json && replace 'import type' 'import' ./types -r --silent && replace 'export type' 'export' ./types -r --silent",
|
|
42
|
-
"now-build": "yarn && cd www && yarn && yarn build",
|
|
43
|
-
"prettier": "prettier \"{.,src,src/**,example/src,example/src/**}/*.{md,js,jsx,ts,tsx,json}\"",
|
|
44
|
-
"start": "yarn watch",
|
|
45
|
-
"format": "yarn prettier --write",
|
|
46
|
-
"stats": "open ./stats.html",
|
|
47
|
-
"doctoc": "doctoc README.md"
|
|
48
|
-
},
|
|
25
|
+
"module": "build/esm/index.js",
|
|
26
|
+
"main": "build/cjs/index.js",
|
|
27
|
+
"browser": "build/umd/index.production.min.js",
|
|
28
|
+
"types": "build/types/index.d.ts",
|
|
49
29
|
"engines": {
|
|
50
30
|
"node": ">=12"
|
|
51
31
|
},
|
|
52
|
-
"release": {
|
|
53
|
-
"branches": [
|
|
54
|
-
"master",
|
|
55
|
-
{
|
|
56
|
-
"name": "beta",
|
|
57
|
-
"prerelease": true
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
32
|
"files": [
|
|
62
|
-
"
|
|
33
|
+
"build",
|
|
63
34
|
"src"
|
|
64
35
|
],
|
|
65
|
-
"browserslist": [
|
|
66
|
-
"last 2 versions",
|
|
67
|
-
"> 0.2%"
|
|
68
|
-
],
|
|
69
36
|
"peerDependencies": {
|
|
70
37
|
"react": ">=16",
|
|
71
38
|
"react-dom": ">=16"
|
|
72
|
-
},
|
|
73
|
-
"dependencies": {
|
|
74
|
-
"ts-toolbelt": "^9.6.0"
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"@babel/cli": "^7.15.7",
|
|
78
|
-
"@babel/core": "^7.15.8",
|
|
79
|
-
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
80
|
-
"@babel/preset-env": "^7.15.8",
|
|
81
|
-
"@babel/preset-react": "^7.14.5",
|
|
82
|
-
"@babel/preset-typescript": "^7.15.0",
|
|
83
|
-
"@rollup/plugin-replace": "^3.0.0",
|
|
84
|
-
"@testing-library/jest-dom": "^5.14.1",
|
|
85
|
-
"@testing-library/react": "^12.1.2",
|
|
86
|
-
"@testing-library/react-hooks": "^7.0.2",
|
|
87
|
-
"@types/react": "^17.0.27",
|
|
88
|
-
"@types/react-dom": "^17.0.9",
|
|
89
|
-
"@types/semver": "^7.3.9",
|
|
90
|
-
"babel-plugin-const-enum": "^1.1.0",
|
|
91
|
-
"babel-plugin-dev-expression": "^0.2.2",
|
|
92
|
-
"babel-plugin-transform-async-to-promises": "^0.8.15",
|
|
93
|
-
"conventional-changelog-angular": "^5.0.13",
|
|
94
|
-
"cross-env": "^7.0.3",
|
|
95
|
-
"current-git-branch": "^1.1.0",
|
|
96
|
-
"doctoc": "^2.1.0",
|
|
97
|
-
"fast-async": "^6.3.8",
|
|
98
|
-
"git-log-parser": "^1.2.0",
|
|
99
|
-
"is-ci": "^3.0.0",
|
|
100
|
-
"jest": "^27.4.5",
|
|
101
|
-
"jsonfile": "^6.1.0",
|
|
102
|
-
"lerna": "^4.0.0",
|
|
103
|
-
"prettier": "^2.4.1",
|
|
104
|
-
"prompt-confirm": "^2.0.4",
|
|
105
|
-
"react": "^17.0.2",
|
|
106
|
-
"react-dom": "^17.0.2",
|
|
107
|
-
"react-test-renderer": "^17.0.2",
|
|
108
|
-
"replace": "^1.2.1",
|
|
109
|
-
"rimraf": "^3.0.2",
|
|
110
|
-
"rollup": "^2.16.1",
|
|
111
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
112
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
|
113
|
-
"rollup-plugin-jscc": "^1.0.0",
|
|
114
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
115
|
-
"rollup-plugin-peer-deps-external": "^2.2.2",
|
|
116
|
-
"rollup-plugin-prettier": "^2.1.0",
|
|
117
|
-
"rollup-plugin-size": "^0.2.2",
|
|
118
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
119
|
-
"rollup-plugin-visualizer": "^5.5.2",
|
|
120
|
-
"stream-to-array": "^2.3.0",
|
|
121
|
-
"ts-node": "^10.3.0",
|
|
122
|
-
"tslib": "^2.3.1",
|
|
123
|
-
"typescript": "^4.4.3"
|
|
124
39
|
}
|
|
125
40
|
}
|
package/src/core.tsx
CHANGED
|
@@ -38,6 +38,7 @@ import * as Filters from './features/Filters'
|
|
|
38
38
|
import * as Sorting from './features/Sorting'
|
|
39
39
|
import * as Grouping from './features/Grouping'
|
|
40
40
|
import * as Expanding from './features/Expanding'
|
|
41
|
+
import * as ColumnSizing from './features/ColumnSizing'
|
|
41
42
|
import { RowModel } from '.'
|
|
42
43
|
|
|
43
44
|
// import './features/withColumnResizing';
|
|
@@ -225,6 +226,10 @@ export type TableCore<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> =
|
|
|
225
226
|
columnId: string,
|
|
226
227
|
userProps?: TGetter
|
|
227
228
|
) => undefined | PropGetterValue<CellProps, TGetter>
|
|
229
|
+
getTableWidth: () => number
|
|
230
|
+
getLeftTableWidth: () => number
|
|
231
|
+
getCenterTableWidth: () => number
|
|
232
|
+
getRightTableWidth: () => number
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
export type CoreRow<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> = {
|
|
@@ -410,6 +415,7 @@ export function createTableInstance<
|
|
|
410
415
|
...Sorting.getDefaultOptions(instance),
|
|
411
416
|
...Grouping.getDefaultOptions(instance),
|
|
412
417
|
...Expanding.getDefaultOptions(instance),
|
|
418
|
+
...ColumnSizing.getDefaultOptions(instance),
|
|
413
419
|
}
|
|
414
420
|
|
|
415
421
|
const defaultState = {}
|
|
@@ -432,6 +438,7 @@ export function createTableInstance<
|
|
|
432
438
|
...Sorting.getInitialState(),
|
|
433
439
|
...Grouping.getInitialState(),
|
|
434
440
|
...Expanding.getInitialState(),
|
|
441
|
+
...ColumnSizing.getInitialState(),
|
|
435
442
|
...(options.initialState ?? {}),
|
|
436
443
|
}
|
|
437
444
|
|
|
@@ -451,6 +458,7 @@ export function createTableInstance<
|
|
|
451
458
|
...Sorting.getInstance(instance),
|
|
452
459
|
...Grouping.getInstance(instance),
|
|
453
460
|
...Expanding.getInstance(instance),
|
|
461
|
+
...ColumnSizing.getInstance(instance),
|
|
454
462
|
rerender,
|
|
455
463
|
initialState,
|
|
456
464
|
internalState: initialState,
|
|
@@ -563,9 +571,7 @@ export function createTableInstance<
|
|
|
563
571
|
TSortingFns,
|
|
564
572
|
TAggregationFns
|
|
565
573
|
> = {
|
|
566
|
-
|
|
567
|
-
minWidth: 20,
|
|
568
|
-
maxWidth: Number.MAX_SAFE_INTEGER,
|
|
574
|
+
...ColumnSizing.defaultColumnSizing,
|
|
569
575
|
...defaultColumn,
|
|
570
576
|
...columnDef,
|
|
571
577
|
id: `${id}`,
|
|
@@ -669,6 +675,16 @@ export function createTableInstance<
|
|
|
669
675
|
TAggregationFns
|
|
670
676
|
>,
|
|
671
677
|
instance
|
|
678
|
+
),
|
|
679
|
+
ColumnSizing.createColumn(
|
|
680
|
+
column as Column<
|
|
681
|
+
TData,
|
|
682
|
+
TValue,
|
|
683
|
+
TFilterFns,
|
|
684
|
+
TSortingFns,
|
|
685
|
+
TAggregationFns
|
|
686
|
+
>,
|
|
687
|
+
instance
|
|
672
688
|
)
|
|
673
689
|
)
|
|
674
690
|
|
|
@@ -783,9 +799,14 @@ export function createTableInstance<
|
|
|
783
799
|
throw new Error()
|
|
784
800
|
}
|
|
785
801
|
|
|
802
|
+
const columnSize = instance.getState().columnSizing[column.id]
|
|
803
|
+
|
|
786
804
|
return Math.min(
|
|
787
|
-
Math.max(
|
|
788
|
-
|
|
805
|
+
Math.max(
|
|
806
|
+
column.minWidth ?? ColumnSizing.defaultColumnSizing.minWidth,
|
|
807
|
+
columnSize ?? column.width ?? ColumnSizing.defaultColumnSizing.width
|
|
808
|
+
),
|
|
809
|
+
column.maxWidth ?? ColumnSizing.defaultColumnSizing.maxWidth
|
|
789
810
|
)
|
|
790
811
|
},
|
|
791
812
|
|
|
@@ -1188,6 +1209,23 @@ export function createTableInstance<
|
|
|
1188
1209
|
userProps
|
|
1189
1210
|
)
|
|
1190
1211
|
},
|
|
1212
|
+
|
|
1213
|
+
getTableWidth: () =>
|
|
1214
|
+
instance.getHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1215
|
+
return sum + header.getWidth()
|
|
1216
|
+
}, 0) ?? 0,
|
|
1217
|
+
getLeftTableWidth: () =>
|
|
1218
|
+
instance.getLeftHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1219
|
+
return sum + header.getWidth()
|
|
1220
|
+
}, 0) ?? 0,
|
|
1221
|
+
getCenterTableWidth: () =>
|
|
1222
|
+
instance.getCenterHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1223
|
+
return sum + header.getWidth()
|
|
1224
|
+
}, 0) ?? 0,
|
|
1225
|
+
getRightTableWidth: () =>
|
|
1226
|
+
instance.getRightHeaderGroups()[0]?.headers.reduce((sum, header) => {
|
|
1227
|
+
return sum + header.getWidth()
|
|
1228
|
+
}, 0) ?? 0,
|
|
1191
1229
|
}
|
|
1192
1230
|
|
|
1193
1231
|
return Object.assign(instance, finalInstance)
|
package/src/createTable.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { ReactTable, ColumnDef, AccessorFn, Options } from './types'
|
|
|
5
5
|
import { Overwrite } from './utils'
|
|
6
6
|
|
|
7
7
|
type TableHelper<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> = {
|
|
8
|
-
RowType
|
|
8
|
+
RowType<TTData>(): TableHelper<
|
|
9
9
|
TTData,
|
|
10
10
|
TValue,
|
|
11
11
|
TFilterFns,
|