@tanstack/react-table 8.2.5 → 8.3.1

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.
@@ -11,11 +11,11 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "3cee-128"
14
+ "uid": "d409-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "3cee-130"
18
+ "uid": "d409-134"
19
19
  }
20
20
  ]
21
21
  }
@@ -25,62 +25,62 @@
25
25
  "isRoot": true
26
26
  },
27
27
  "nodeParts": {
28
- "3cee-128": {
29
- "renderedLength": 135079,
30
- "gzipLength": 23290,
28
+ "d409-132": {
29
+ "renderedLength": 136731,
30
+ "gzipLength": 23744,
31
31
  "brotliLength": 0,
32
- "mainUid": "3cee-127"
32
+ "mainUid": "d409-131"
33
33
  },
34
- "3cee-130": {
34
+ "d409-134": {
35
35
  "renderedLength": 1900,
36
36
  "gzipLength": 752,
37
37
  "brotliLength": 0,
38
- "mainUid": "3cee-129"
38
+ "mainUid": "d409-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "3cee-127": {
42
+ "d409-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "3cee-128"
45
+ "index.production.js": "d409-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "3cee-129"
50
+ "uid": "d409-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "3cee-129": {
54
+ "d409-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "3cee-130"
57
+ "index.production.js": "d409-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "3cee-131"
61
+ "uid": "d409-135"
62
62
  },
63
63
  {
64
- "uid": "3cee-127"
64
+ "uid": "d409-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "3cee-131": {
70
+ "d409-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "3cee-129"
76
+ "uid": "d409-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
80
80
  }
81
81
  },
82
82
  "env": {
83
- "rollup": "2.76.0"
83
+ "rollup": "2.77.0"
84
84
  },
85
85
  "options": {
86
86
  "gzip": true,
@@ -44,6 +44,9 @@
44
44
  *
45
45
  * @license MIT
46
46
  */
47
+ // Is this type a tuple?
48
+ // If this type is a tuple, what indices are allowed?
49
+ ///
47
50
  function functionalUpdate(updater, input) {
48
51
  return typeof updater === 'function' ? updater(input) : updater;
49
52
  }
@@ -129,13 +132,27 @@
129
132
  const resolvedColumnDef = { ...defaultColumn,
130
133
  ...columnDef
131
134
  };
132
- let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : resolvedColumnDef.accessorKey) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
135
+ const accessorKey = resolvedColumnDef.accessorKey;
136
+ let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.replace('.', '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
133
137
  let accessorFn;
134
138
 
135
139
  if (resolvedColumnDef.accessorFn) {
136
140
  accessorFn = resolvedColumnDef.accessorFn;
137
- } else if (resolvedColumnDef.accessorKey) {
138
- accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
141
+ } else if (accessorKey) {
142
+ // Support deep accessor keys
143
+ if (accessorKey.includes('.')) {
144
+ accessorFn = originalRow => {
145
+ let result = originalRow;
146
+
147
+ for (const key of accessorKey.split('.')) {
148
+ result = result[key];
149
+ }
150
+
151
+ return result;
152
+ };
153
+ } else {
154
+ accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
155
+ }
139
156
  }
140
157
 
141
158
  if (!id) {
@@ -1129,7 +1146,7 @@
1129
1146
  var _table$getCoreRowMode, _table$getCoreRowMode2;
1130
1147
 
1131
1148
  const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null ? void 0 : (_table$getCoreRowMode2 = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode2.getValue();
1132
- return typeof value === 'string';
1149
+ return typeof value === 'string' || typeof value === 'number';
1133
1150
  }
1134
1151
  };
1135
1152
  },
@@ -2161,7 +2178,7 @@
2161
2178
  let isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
2162
2179
 
2163
2180
  if (isAllRowsSelected) {
2164
- if (preFilteredFlatRows.some(row => !rowSelection[row.id])) {
2181
+ if (preFilteredFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
2165
2182
  isAllRowsSelected = false;
2166
2183
  }
2167
2184
  }
@@ -2184,7 +2201,8 @@
2184
2201
  getIsSomeRowsSelected: () => {
2185
2202
  var _table$getState$rowSe;
2186
2203
 
2187
- return !table.getIsAllRowsSelected() && !!Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2204
+ const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2205
+ return totalSelected < table.getCoreRowModel().flatRows.length;
2188
2206
  },
2189
2207
  getIsSomePageRowsSelected: () => {
2190
2208
  const paginationFlatRows = table.getPaginationRowModel().flatRows;
@@ -3121,6 +3139,52 @@
3121
3139
  return row;
3122
3140
  };
3123
3141
 
3142
+ // type Person = {
3143
+ // firstName: string
3144
+ // lastName: string
3145
+ // age: number
3146
+ // visits: number
3147
+ // status: string
3148
+ // progress: number
3149
+ // nested: {
3150
+ // foo: [
3151
+ // {
3152
+ // bar: 'bar'
3153
+ // }
3154
+ // ]
3155
+ // bar: { subBar: boolean }[]
3156
+ // baz: {
3157
+ // foo: 'foo'
3158
+ // bar: {
3159
+ // baz: 'baz'
3160
+ // }
3161
+ // }
3162
+ // }
3163
+ // }
3164
+ // const test: DeepKeys<Person> = 'nested.foo.0.bar'
3165
+ // const test2: DeepKeys<Person> = 'nested.bar'
3166
+ // const helper = createColumnHelper<Person>()
3167
+ // helper.accessor('nested.foo', {
3168
+ // cell: info => info.getValue(),
3169
+ // })
3170
+ // helper.accessor('nested.foo.0.bar', {
3171
+ // cell: info => info.getValue(),
3172
+ // })
3173
+ // helper.accessor('nested.bar', {
3174
+ // cell: info => info.getValue(),
3175
+ // })
3176
+ function createColumnHelper() {
3177
+ return {
3178
+ accessor: (accessor, column) => {
3179
+ return typeof accessor === 'function' ? { ...column,
3180
+ accessorFn: accessor
3181
+ } : { ...column,
3182
+ accessorKey: accessor
3183
+ };
3184
+ }
3185
+ };
3186
+ }
3187
+
3124
3188
  function getCoreRowModel() {
3125
3189
  return table => memo(() => [table.options.data], data => {
3126
3190
  const rowModel = {
@@ -3883,6 +3947,7 @@
3883
3947
  exports.aggregationFns = aggregationFns;
3884
3948
  exports.buildHeaderGroups = buildHeaderGroups;
3885
3949
  exports.createColumn = createColumn;
3950
+ exports.createColumnHelper = createColumnHelper;
3886
3951
  exports.createRow = createRow;
3887
3952
  exports.createTable = createTable;
3888
3953
  exports.defaultColumnSizing = defaultColumnSizing;