mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-21 09:20:22 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e6952db93 | ||
|
|
ac43ef2e38 | ||
|
|
9de699bfd3 | ||
|
|
38d82a0397 | ||
|
|
863bf50206 | ||
|
|
492ba8a4f9 | ||
|
|
e0ad323bd8 | ||
|
|
c1e4fb8956 |
+7
-7
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"dist/index.js": {
|
||||
"bundled": 100428,
|
||||
"minified": 47447,
|
||||
"gzipped": 12335
|
||||
"bundled": 103833,
|
||||
"minified": 48853,
|
||||
"gzipped": 12789
|
||||
},
|
||||
"dist/index.es.js": {
|
||||
"bundled": 99612,
|
||||
"minified": 46722,
|
||||
"gzipped": 12189,
|
||||
"bundled": 102990,
|
||||
"minified": 48103,
|
||||
"gzipped": 12638,
|
||||
"treeshaked": {
|
||||
"rollup": {
|
||||
"code": 80,
|
||||
"import_statements": 21
|
||||
},
|
||||
"webpack": {
|
||||
"code": 8457
|
||||
"code": 8444
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
## 7.0.0-rc.6
|
||||
|
||||
- The `columnsBeforeHeaderGroups` and `columnsBeforeHeaderGroupsDeps` hooks have been renamed to `flatColumns` and `flatColumnsDeps` respectively, which better reflects what they are used for, rather than their order, which can remain implicit.
|
||||
- Added `headerGroups` and `headerGroupDeps` hooks, which, similar to `flatColumns`, allow you to decorate (and trigger) the memoized header group generation.
|
||||
- Added `columns` and `columnsDeps` hooks, which, similar to `flatColumns` and `headerGroups`, allow you to decorate (and trigger) the memoized column generation/decoration.
|
||||
- The new hook order is as follows: `columns/columnsDeps` => `flatColumns/flatColumnsDeps` => `headerGroups/headerGroupsDeps`
|
||||
- `useColumnVisibility` now uses the new `headerGroupsDeps` hook to trigger header group regeneration when visibility changes
|
||||
|
||||
## 7.0.0-rc.5
|
||||
|
||||
- Fixed an issue where the exported `useAsyncDebounce` method would crash if its promise throw an error.
|
||||
|
||||
## 7.0.0-rc.4
|
||||
|
||||
- A maintenance release, purely intended to update the @latest tag (which was overwritten by a v6 publish)
|
||||
|
||||
## 7.0.0-rc.3
|
||||
|
||||
- Fixed an issue where `column.clearSortBy` would crash
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-table",
|
||||
"version": "7.0.0-rc.3",
|
||||
"version": "7.0.0-rc.6",
|
||||
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1575859193604,
|
||||
"files": [
|
||||
{
|
||||
"filename": "index.js",
|
||||
"size": 21589,
|
||||
"delta": 563
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1575690248030,
|
||||
"files": [
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1575859200604,
|
||||
"files": [
|
||||
{
|
||||
"filename": "index.es.js",
|
||||
"size": 21403,
|
||||
"delta": 561
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1575675317538,
|
||||
"files": [
|
||||
|
||||
@@ -19,7 +19,7 @@ export const useColumnVisibility = hooks => {
|
||||
|
||||
hooks.stateReducers.push(reducer)
|
||||
hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions)
|
||||
hooks.columnsBeforeHeaderGroupsDeps.push((deps, instance) => [
|
||||
hooks.headerGroupsDeps.push((deps, instance) => [
|
||||
...deps,
|
||||
instance.state.hiddenColumns,
|
||||
])
|
||||
|
||||
+81
-33
@@ -49,8 +49,12 @@ export const useTable = (props, ...plugins) => {
|
||||
data,
|
||||
hooks: {
|
||||
stateReducers: [],
|
||||
columnsBeforeHeaderGroups: [],
|
||||
columnsBeforeHeaderGroupsDeps: [],
|
||||
columns: [],
|
||||
columnsDeps: [],
|
||||
flatColumns: [],
|
||||
flatColumnsDeps: [],
|
||||
headerGroups: [],
|
||||
headerGroupsDeps: [],
|
||||
useInstanceBeforeDimensions: [],
|
||||
useInstance: [],
|
||||
useRows: [],
|
||||
@@ -117,58 +121,102 @@ export const useTable = (props, ...plugins) => {
|
||||
dispatch, // The resolved table state
|
||||
})
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getColumns = useConsumeHookGetter(instanceRef.current.hooks, 'columns')
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getColumnsDeps = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'columnsDeps'
|
||||
)
|
||||
|
||||
// Decorate All the columns
|
||||
let columns = React.useMemo(
|
||||
() => decorateColumnTree(userColumns, defaultColumn),
|
||||
[defaultColumn, userColumns]
|
||||
() =>
|
||||
applyHooks(
|
||||
getColumns(),
|
||||
decorateColumnTree(userColumns, defaultColumn),
|
||||
instanceRef.current
|
||||
),
|
||||
[
|
||||
defaultColumn,
|
||||
getColumns,
|
||||
userColumns,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
...getColumnsDeps(instanceRef.current),
|
||||
]
|
||||
)
|
||||
|
||||
instanceRef.current.columns = columns
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getFlatColumns = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'flatColumns'
|
||||
)
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getColumnsBeforeHeaderGroups = useConsumeHookGetter(
|
||||
const getFlatColumnsDeps = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'columnsBeforeHeaderGroups'
|
||||
)
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getColumnsBeforeHeaderGroupsDeps = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'columnsBeforeHeaderGroupsDeps'
|
||||
'flatColumnsDeps'
|
||||
)
|
||||
|
||||
// Get the flat list of all columns and allow hooks to decorate
|
||||
// those columns (and trigger this memoization via deps)
|
||||
let flatColumns = React.useMemo(() => {
|
||||
let newColumns = applyHooks(
|
||||
getColumnsBeforeHeaderGroups(),
|
||||
flattenBy(columns, 'columns'),
|
||||
instanceRef.current
|
||||
)
|
||||
let flatColumns = React.useMemo(
|
||||
() =>
|
||||
applyHooks(
|
||||
getFlatColumns(),
|
||||
flattenBy(columns, 'columns'),
|
||||
instanceRef.current
|
||||
),
|
||||
[
|
||||
columns,
|
||||
getFlatColumns,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
...getFlatColumnsDeps(instanceRef.current),
|
||||
]
|
||||
)
|
||||
|
||||
return newColumns
|
||||
}, [
|
||||
columns,
|
||||
getColumnsBeforeHeaderGroups,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
...getColumnsBeforeHeaderGroupsDeps(),
|
||||
])
|
||||
instanceRef.current.flatColumns = flatColumns
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getHeaderGroups = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'headerGroups'
|
||||
)
|
||||
|
||||
// Snapshot hook and disallow more from being added
|
||||
const getHeaderGroupsDeps = useConsumeHookGetter(
|
||||
instanceRef.current.hooks,
|
||||
'headerGroupsDeps'
|
||||
)
|
||||
|
||||
// Make the headerGroups
|
||||
const headerGroups = React.useMemo(
|
||||
() => makeHeaderGroups(flatColumns, defaultColumn),
|
||||
[defaultColumn, flatColumns]
|
||||
() =>
|
||||
applyHooks(
|
||||
getHeaderGroups(),
|
||||
makeHeaderGroups(flatColumns, defaultColumn),
|
||||
instanceRef.current
|
||||
),
|
||||
[
|
||||
defaultColumn,
|
||||
flatColumns,
|
||||
getHeaderGroups,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
...getHeaderGroupsDeps(),
|
||||
]
|
||||
)
|
||||
|
||||
instanceRef.current.headerGroups = headerGroups
|
||||
|
||||
const headers = React.useMemo(
|
||||
() => (headerGroups.length ? headerGroups[0].headers : []),
|
||||
[headerGroups]
|
||||
)
|
||||
|
||||
Object.assign(instanceRef.current, {
|
||||
columns,
|
||||
flatColumns,
|
||||
headerGroups,
|
||||
headers,
|
||||
})
|
||||
instanceRef.current.headers = headers
|
||||
|
||||
// Access the row model
|
||||
const [rows, flatRows] = React.useMemo(() => {
|
||||
|
||||
@@ -8,10 +8,10 @@ actions.setColumnOrder = 'setColumnOrder'
|
||||
|
||||
export const useColumnOrder = hooks => {
|
||||
hooks.stateReducers.push(reducer)
|
||||
hooks.columnsBeforeHeaderGroupsDeps.push((deps, instance) => {
|
||||
hooks.flatColumnsDeps.push((deps, instance) => {
|
||||
return [...deps, instance.state.columnOrder]
|
||||
})
|
||||
hooks.columnsBeforeHeaderGroups.push(columnsBeforeHeaderGroups)
|
||||
hooks.flatColumns.push(flatColumns)
|
||||
hooks.useInstance.push(useInstance)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ function reducer(state, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function columnsBeforeHeaderGroups(columns, instance) {
|
||||
function flatColumns(columns, instance) {
|
||||
const {
|
||||
state: { columnOrder },
|
||||
} = instance
|
||||
|
||||
@@ -18,11 +18,11 @@ actions.toggleGroupBy = 'toggleGroupBy'
|
||||
|
||||
export const useGroupBy = hooks => {
|
||||
hooks.stateReducers.push(reducer)
|
||||
hooks.columnsBeforeHeaderGroupsDeps.push((deps, instance) => [
|
||||
hooks.flatColumnsDeps.push((deps, instance) => [
|
||||
...deps,
|
||||
instance.state.groupBy,
|
||||
])
|
||||
hooks.columnsBeforeHeaderGroups.push(columnsBeforeHeaderGroups)
|
||||
hooks.flatColumns.push(flatColumns)
|
||||
hooks.useInstance.push(useInstance)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ function reducer(state, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function columnsBeforeHeaderGroups(flatColumns, { state: { groupBy } }) {
|
||||
function flatColumns(flatColumns, { state: { groupBy } }) {
|
||||
// Sort grouped columns to the start of the column list
|
||||
// before the headers are built
|
||||
|
||||
|
||||
+3
-2
@@ -133,7 +133,7 @@ export function useMountedLayoutEffect(fn, deps) {
|
||||
}, deps)
|
||||
}
|
||||
|
||||
export default function useAsyncDebounce(defaultFn, defaultWait = 0) {
|
||||
export function useAsyncDebounce(defaultFn, defaultWait = 0) {
|
||||
const debounceRef = React.useRef({})
|
||||
debounceRef.current.defaultFn = defaultFn
|
||||
debounceRef.current.defaultWait = defaultWait
|
||||
@@ -144,8 +144,9 @@ export default function useAsyncDebounce(defaultFn, defaultWait = 0) {
|
||||
wait = debounceRef.current.defaultWait
|
||||
) => {
|
||||
if (!debounceRef.current.promise) {
|
||||
debounceRef.current.promise = new Promise(resolve => {
|
||||
debounceRef.current.promise = new Promise((resolve, reject) => {
|
||||
debounceRef.current.resolve = resolve
|
||||
debounceRef.current.reject = reject
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user