mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-19 08:20:30 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbb18368b2 | ||
|
|
4842bc061d | ||
|
|
0477ef26ca | ||
|
|
280ef16a75 |
+5
-2
@@ -527,9 +527,12 @@ The following properties are available on every `Column` object returned by the
|
||||
- An column-level function used to update the filter value for this column
|
||||
- `filterValue: any`
|
||||
- The current filter value for this column, resolved from the table state's `filters` object
|
||||
- `preFilteredColumnRows: Array<row>`
|
||||
- `preFilteredRows: Array<row>`
|
||||
- The array of rows that were originally passed to this columns filter **before** they were filtered.
|
||||
- This array of rows can be useful if building faceted filter options.
|
||||
- `filteredRows: Array<row>`
|
||||
- The resulting array of rows received from this columns filter **after** they were filtered.
|
||||
- This array of rows can be useful if building faceted filter options.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -810,7 +813,7 @@ The following values are provided to the table `instance`:
|
||||
|
||||
The following options are supported via the main options object passed to `useTable(options)`
|
||||
|
||||
- `state.selectedRowsPaths: Array<RowPathKey>`
|
||||
- `state.selectedRowPaths: Array<RowPathKey>`
|
||||
- Optional
|
||||
- Defaults to `[]`
|
||||
- If a row's path key (eg. a row path of `[1, 3, 2]` would have a path key of `1.3.2`) is found in this array, it will have a selected state.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-table",
|
||||
"version": "7.0.0-beta.9",
|
||||
"version": "7.0.0-beta.10",
|
||||
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
||||
|
||||
+5
-1
@@ -44,7 +44,11 @@ includes.autoRemove = val => !val || !val.length
|
||||
export const includesAll = (rows, id, filterValue) => {
|
||||
return rows.filter(row => {
|
||||
const rowValue = row.values[id]
|
||||
return filterValue.every(val => rowValue.includes(val))
|
||||
return (
|
||||
rowValue &&
|
||||
rowValue.length &&
|
||||
filterValue.every(val => rowValue.includes(val))
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,14 @@ function useMain(instance) {
|
||||
|
||||
// Pass the rows, id, filterValue and column to the filterMethod
|
||||
// to get the filtered rows back
|
||||
return filterMethod(filteredSoFar, columnID, filterValue, column)
|
||||
column.filteredRows = filterMethod(
|
||||
filteredSoFar,
|
||||
columnID,
|
||||
filterValue,
|
||||
column
|
||||
)
|
||||
|
||||
return column.filteredRows
|
||||
},
|
||||
rows
|
||||
)
|
||||
@@ -228,6 +235,7 @@ function useMain(instance) {
|
||||
// using every column's preFilteredRows value
|
||||
nonFilteredColumns.forEach(column => {
|
||||
column.preFilteredRows = filteredRows
|
||||
column.filteredRows = filteredRows
|
||||
})
|
||||
}, [filteredRows, filters, flatColumns])
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { mergeProps, applyPropHooks, ensurePluginOrder } from '../utils'
|
||||
import {
|
||||
mergeProps,
|
||||
applyPropHooks,
|
||||
ensurePluginOrder,
|
||||
safeUseLayoutEffect,
|
||||
} from '../utils'
|
||||
import { addActions, actions } from '../actions'
|
||||
import { defaultState } from '../hooks/useTable'
|
||||
|
||||
@@ -57,8 +62,10 @@ function useMain(instance) {
|
||||
const {
|
||||
hooks,
|
||||
manualRowSelectedKey = 'isSelected',
|
||||
disableSelectedRowsResetOnDataChange,
|
||||
plugins,
|
||||
flatRows,
|
||||
data,
|
||||
state: { selectedRowPaths },
|
||||
setState,
|
||||
} = instance
|
||||
@@ -80,6 +87,28 @@ function useMain(instance) {
|
||||
}
|
||||
}
|
||||
|
||||
const isRowSelectedMountedRef = React.useRef()
|
||||
|
||||
// Bypass any effects from firing when this changes
|
||||
const disableSelectedRowsResetOnDataChangeRef = React.useRef()
|
||||
disableSelectedRowsResetOnDataChangeRef.current = disableSelectedRowsResetOnDataChange
|
||||
|
||||
safeUseLayoutEffect(() => {
|
||||
if (
|
||||
isRowSelectedMountedRef.current &&
|
||||
!disableSelectedRowsResetOnDataChangeRef.current
|
||||
) {
|
||||
setState(
|
||||
old => ({
|
||||
...old,
|
||||
selectedRowPaths: [],
|
||||
}),
|
||||
actions.pageChange
|
||||
)
|
||||
}
|
||||
isRowSelectedMountedRef.current = true
|
||||
}, [setState, data])
|
||||
|
||||
const toggleRowSelectedAll = set => {
|
||||
setState(old => {
|
||||
const selectAll = typeof set !== 'undefined' ? set : !isAllRowsSelected
|
||||
|
||||
Reference in New Issue
Block a user