@tanstack/react-table 8.2.4 → 8.3.0

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": "cc9e-128"
14
+ "uid": "1937-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "cc9e-130"
18
+ "uid": "1937-134"
19
19
  }
20
20
  ]
21
21
  }
@@ -25,62 +25,62 @@
25
25
  "isRoot": true
26
26
  },
27
27
  "nodeParts": {
28
- "cc9e-128": {
29
- "renderedLength": 135089,
30
- "gzipLength": 23288,
28
+ "1937-132": {
29
+ "renderedLength": 136655,
30
+ "gzipLength": 23722,
31
31
  "brotliLength": 0,
32
- "mainUid": "cc9e-127"
32
+ "mainUid": "1937-131"
33
33
  },
34
- "cc9e-130": {
34
+ "1937-134": {
35
35
  "renderedLength": 1900,
36
36
  "gzipLength": 752,
37
37
  "brotliLength": 0,
38
- "mainUid": "cc9e-129"
38
+ "mainUid": "1937-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "cc9e-127": {
42
+ "1937-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "cc9e-128"
45
+ "index.production.js": "1937-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "cc9e-129"
50
+ "uid": "1937-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "cc9e-129": {
54
+ "1937-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "cc9e-130"
57
+ "index.production.js": "1937-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "cc9e-131"
61
+ "uid": "1937-135"
62
62
  },
63
63
  {
64
- "uid": "cc9e-127"
64
+ "uid": "1937-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "cc9e-131": {
70
+ "1937-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "cc9e-129"
76
+ "uid": "1937-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) {
@@ -983,7 +1000,7 @@
983
1000
  getCanExpand: () => {
984
1001
  var _table$options$getRow, _table$options$enable, _row$subRows;
985
1002
 
986
- return ((_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : true) && ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1003
+ return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
987
1004
  },
988
1005
  getToggleExpandedHandler: () => {
989
1006
  const canExpand = row.getCanExpand();
@@ -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
  },
@@ -3121,6 +3138,52 @@
3121
3138
  return row;
3122
3139
  };
3123
3140
 
3141
+ // type Person = {
3142
+ // firstName: string
3143
+ // lastName: string
3144
+ // age: number
3145
+ // visits: number
3146
+ // status: string
3147
+ // progress: number
3148
+ // nested: {
3149
+ // foo: [
3150
+ // {
3151
+ // bar: 'bar'
3152
+ // }
3153
+ // ]
3154
+ // bar: { subBar: boolean }[]
3155
+ // baz: {
3156
+ // foo: 'foo'
3157
+ // bar: {
3158
+ // baz: 'baz'
3159
+ // }
3160
+ // }
3161
+ // }
3162
+ // }
3163
+ // const test: DeepKeys<Person> = 'nested.foo.0.bar'
3164
+ // const test2: DeepKeys<Person> = 'nested.bar'
3165
+ // const helper = createColumnHelper<Person>()
3166
+ // helper.accessor('nested.foo', {
3167
+ // cell: info => info.getValue(),
3168
+ // })
3169
+ // helper.accessor('nested.foo.0.bar', {
3170
+ // cell: info => info.getValue(),
3171
+ // })
3172
+ // helper.accessor('nested.bar', {
3173
+ // cell: info => info.getValue(),
3174
+ // })
3175
+ function createColumnHelper() {
3176
+ return {
3177
+ accessor: (accessor, column) => {
3178
+ return typeof accessor === 'function' ? { ...column,
3179
+ accessorFn: accessor
3180
+ } : { ...column,
3181
+ accessorKey: accessor
3182
+ };
3183
+ }
3184
+ };
3185
+ }
3186
+
3124
3187
  function getCoreRowModel() {
3125
3188
  return table => memo(() => [table.options.data], data => {
3126
3189
  const rowModel = {
@@ -3883,6 +3946,7 @@
3883
3946
  exports.aggregationFns = aggregationFns;
3884
3947
  exports.buildHeaderGroups = buildHeaderGroups;
3885
3948
  exports.createColumn = createColumn;
3949
+ exports.createColumnHelper = createColumnHelper;
3886
3950
  exports.createRow = createRow;
3887
3951
  exports.createTable = createTable;
3888
3952
  exports.defaultColumnSizing = defaultColumnSizing;