Compare commits

...
Author SHA1 Message Date
Tanner Linsley c6dc78e2d1 v7.0.0-beta.20 2019-12-02 01:28:05 -07:00
Tanner Linsley dac4744727 v7.0.0-beta.19 2019-12-01 00:23:42 -07:00
5 changed files with 28 additions and 14 deletions
+6 -6
View File
@@ -1,13 +1,13 @@
{
"dist/index.js": {
"bundled": 90278,
"minified": 43057,
"gzipped": 11502
"bundled": 90287,
"minified": 43056,
"gzipped": 11505
},
"dist/index.es.js": {
"bundled": 89695,
"minified": 42549,
"gzipped": 11382,
"bundled": 89704,
"minified": 42548,
"gzipped": 11385,
"treeshaked": {
"rollup": {
"code": 450,
+11
View File
@@ -1,3 +1,14 @@
## 7.0.0-beta.19
- Added an `isAggregated` boolean parameter to the `aggregate` function signature
## 7.0.0-beta.16
- Removed service workers from examples
- Fixed a memory leak when `instance` was referenced in function closures
- Fixed an issue where the table would infinitely rerender due to incorrect effect dependencies
- Fixed an issue where row grouping and row selection would not work properly together.
## 7.0.0-beta.15
- Fixed an issue where `defaultGetResetPageDeps` was using `data` instead of `rows`
+6
View File
@@ -601,6 +601,12 @@ The following options are supported on any `Column` object passed to the `column
- Receives the table instance and cell model as props
- Must return valid JSX
- This function (or component) formats this column's value when it is being grouped and aggregated, eg. If this column was showing the number of visits for a user to a website and it was currently being grouped to show an **average** of the values, the `Aggregated` function for this column could format that value to `1,000 Avg. Visits`
- `aggregate: String | [String, String] | Function(values, rows, isAggregated: Bool) => any`
- If a single `String` is passed, it must be the key of either a user defined or predefined `aggregations` function.
- If a tuple array of `[String, String]` is passed, both must be a key of either a user defined or predefined `aggregations` function.
- The first is used to aggregate raw values, eg. `sum`-ing raw values together
- The second is used to aggregate values that have already been aggregated, eg. `average`-ing the sums produced by the raw aggregation level
- If a `Function` is passed, this function will receive the `values`, original `rows` of those values, and an `isAggregated` `Bool` of whether or not the values and rows have already been aggregated.
- `disableGroupBy: Boolean`
- Defaults to `false`
- If `true`, will disable grouping for this column.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "7.0.0-beta.17",
"version": "7.0.0-beta.20",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
+4 -7
View File
@@ -163,7 +163,7 @@ function useMain(instance) {
// Find the columns that can or are aggregating
// Uses each column to aggregate rows into a single value
const aggregateRowsToValues = (rows, isSourceRows) => {
const aggregateRowsToValues = (rows, isAggregated) => {
const values = {}
flatColumns.forEach(column => {
@@ -184,7 +184,7 @@ function useMain(instance) {
`React Table: Complex aggregators must have 2 values, eg. aggregate: ['sum', 'count']. More info above...`
)
}
if (isSourceRows) {
if (isAggregated) {
aggregator = aggregator[1]
} else {
aggregator = aggregator[0]
@@ -197,7 +197,7 @@ function useMain(instance) {
: userAggregations[aggregator] || aggregations[aggregator]
if (aggregateFn) {
values[column.id] = aggregateFn(columnValues, rows)
values[column.id] = aggregateFn(columnValues, rows, isAggregated)
} else if (aggregator) {
console.info({ column })
throw new Error(
@@ -235,10 +235,7 @@ function useMain(instance) {
subRows = groupRecursively(subRows, depth + 1, path)
const values = aggregateRowsToValues(
subRows,
depth + 1 >= groupBy.length
)
const values = aggregateRowsToValues(subRows, depth < groupBy.length)
const row = {
isAggregated: true,