@geneui/components 3.0.0-next-34c3d98-08042026 → 3.0.0-next-e10ab23-21042026

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.
@@ -0,0 +1,3135 @@
1
+ import * as React from 'react';
2
+ import React__default, { memo as memo$1 } from 'react';
3
+ import { s as styleInject } from './style-inject.es-746bb8ed.js';
4
+
5
+ /**
6
+ * table-core
7
+ *
8
+ * Copyright (c) TanStack
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE.md file in the root directory of this source tree.
12
+ *
13
+ * @license MIT
14
+ */
15
+ // type Person = {
16
+ // firstName: string
17
+ // lastName: string
18
+ // age: number
19
+ // visits: number
20
+ // status: string
21
+ // progress: number
22
+ // createdAt: Date
23
+ // nested: {
24
+ // foo: [
25
+ // {
26
+ // bar: 'bar'
27
+ // }
28
+ // ]
29
+ // bar: { subBar: boolean }[]
30
+ // baz: {
31
+ // foo: 'foo'
32
+ // bar: {
33
+ // baz: 'baz'
34
+ // }
35
+ // }
36
+ // }
37
+ // }
38
+
39
+
40
+ // Is this type a tuple?
41
+
42
+ // If this type is a tuple, what indices are allowed?
43
+
44
+ ///
45
+
46
+ function functionalUpdate(updater, input) {
47
+ return typeof updater === 'function' ? updater(input) : updater;
48
+ }
49
+ function makeStateUpdater(key, instance) {
50
+ return updater => {
51
+ instance.setState(old => {
52
+ return {
53
+ ...old,
54
+ [key]: functionalUpdate(updater, old[key])
55
+ };
56
+ });
57
+ };
58
+ }
59
+ function isFunction(d) {
60
+ return d instanceof Function;
61
+ }
62
+ function isNumberArray(d) {
63
+ return Array.isArray(d) && d.every(val => typeof val === 'number');
64
+ }
65
+ function flattenBy(arr, getChildren) {
66
+ const flat = [];
67
+ const recurse = subArr => {
68
+ subArr.forEach(item => {
69
+ flat.push(item);
70
+ const children = getChildren(item);
71
+ if (children != null && children.length) {
72
+ recurse(children);
73
+ }
74
+ });
75
+ };
76
+ recurse(arr);
77
+ return flat;
78
+ }
79
+ function memo(getDeps, fn, opts) {
80
+ let deps = [];
81
+ let result;
82
+ return depArgs => {
83
+ let depTime;
84
+ if (opts.key && opts.debug) depTime = Date.now();
85
+ const newDeps = getDeps(depArgs);
86
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
87
+ if (!depsChanged) {
88
+ return result;
89
+ }
90
+ deps = newDeps;
91
+ let resultTime;
92
+ if (opts.key && opts.debug) resultTime = Date.now();
93
+ result = fn(...newDeps);
94
+ opts == null || opts.onChange == null || opts.onChange(result);
95
+ if (opts.key && opts.debug) {
96
+ if (opts != null && opts.debug()) {
97
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
98
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
99
+ const resultFpsPercentage = resultEndTime / 16;
100
+ const pad = (str, num) => {
101
+ str = String(str);
102
+ while (str.length < num) {
103
+ str = ' ' + str;
104
+ }
105
+ return str;
106
+ };
107
+ console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
108
+ font-size: .6rem;
109
+ font-weight: bold;
110
+ color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
111
+ }
112
+ }
113
+ return result;
114
+ };
115
+ }
116
+ function getMemoOptions(tableOptions, debugLevel, key, onChange) {
117
+ return {
118
+ debug: () => {
119
+ var _tableOptions$debugAl;
120
+ return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
121
+ },
122
+ key: process.env.NODE_ENV === 'development' && key,
123
+ onChange
124
+ };
125
+ }
126
+
127
+ function createCell(table, row, column, columnId) {
128
+ const getRenderValue = () => {
129
+ var _cell$getValue;
130
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
131
+ };
132
+ const cell = {
133
+ id: `${row.id}_${column.id}`,
134
+ row,
135
+ column,
136
+ getValue: () => row.getValue(columnId),
137
+ renderValue: getRenderValue,
138
+ getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
139
+ table,
140
+ column,
141
+ row,
142
+ cell: cell,
143
+ getValue: cell.getValue,
144
+ renderValue: cell.renderValue
145
+ }), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
146
+ };
147
+ table._features.forEach(feature => {
148
+ feature.createCell == null || feature.createCell(cell, column, row, table);
149
+ }, {});
150
+ return cell;
151
+ }
152
+
153
+ function createColumn(table, columnDef, depth, parent) {
154
+ var _ref, _resolvedColumnDef$id;
155
+ const defaultColumn = table._getDefaultColumnDef();
156
+ const resolvedColumnDef = {
157
+ ...defaultColumn,
158
+ ...columnDef
159
+ };
160
+ const accessorKey = resolvedColumnDef.accessorKey;
161
+ let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
162
+ let accessorFn;
163
+ if (resolvedColumnDef.accessorFn) {
164
+ accessorFn = resolvedColumnDef.accessorFn;
165
+ } else if (accessorKey) {
166
+ // Support deep accessor keys
167
+ if (accessorKey.includes('.')) {
168
+ accessorFn = originalRow => {
169
+ let result = originalRow;
170
+ for (const key of accessorKey.split('.')) {
171
+ var _result;
172
+ result = (_result = result) == null ? void 0 : _result[key];
173
+ if (process.env.NODE_ENV !== 'production' && result === undefined) {
174
+ console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
175
+ }
176
+ }
177
+ return result;
178
+ };
179
+ } else {
180
+ accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
181
+ }
182
+ }
183
+ if (!id) {
184
+ if (process.env.NODE_ENV !== 'production') {
185
+ throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
186
+ }
187
+ throw new Error();
188
+ }
189
+ let column = {
190
+ id: `${String(id)}`,
191
+ accessorFn,
192
+ parent: parent,
193
+ depth,
194
+ columnDef: resolvedColumnDef,
195
+ columns: [],
196
+ getFlatColumns: memo(() => [true], () => {
197
+ var _column$columns;
198
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
199
+ }, getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')),
200
+ getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
201
+ var _column$columns2;
202
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
203
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
204
+ return orderColumns(leafColumns);
205
+ }
206
+ return [column];
207
+ }, getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns'))
208
+ };
209
+ for (const feature of table._features) {
210
+ feature.createColumn == null || feature.createColumn(column, table);
211
+ }
212
+
213
+ // Yes, we have to convert table to unknown, because we know more than the compiler here.
214
+ return column;
215
+ }
216
+
217
+ const debug = 'debugHeaders';
218
+ //
219
+
220
+ function createHeader(table, column, options) {
221
+ var _options$id;
222
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
223
+ let header = {
224
+ id,
225
+ column,
226
+ index: options.index,
227
+ isPlaceholder: !!options.isPlaceholder,
228
+ placeholderId: options.placeholderId,
229
+ depth: options.depth,
230
+ subHeaders: [],
231
+ colSpan: 0,
232
+ rowSpan: 0,
233
+ headerGroup: null,
234
+ getLeafHeaders: () => {
235
+ const leafHeaders = [];
236
+ const recurseHeader = h => {
237
+ if (h.subHeaders && h.subHeaders.length) {
238
+ h.subHeaders.map(recurseHeader);
239
+ }
240
+ leafHeaders.push(h);
241
+ };
242
+ recurseHeader(header);
243
+ return leafHeaders;
244
+ },
245
+ getContext: () => ({
246
+ table,
247
+ header: header,
248
+ column
249
+ })
250
+ };
251
+ table._features.forEach(feature => {
252
+ feature.createHeader == null || feature.createHeader(header, table);
253
+ });
254
+ return header;
255
+ }
256
+ const Headers = {
257
+ createTable: table => {
258
+ // Header Groups
259
+
260
+ table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
261
+ var _left$map$filter, _right$map$filter;
262
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
263
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
264
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
265
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
266
+ return headerGroups;
267
+ }, getMemoOptions(table.options, debug, 'getHeaderGroups'));
268
+ table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
269
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
270
+ return buildHeaderGroups(allColumns, leafColumns, table, 'center');
271
+ }, getMemoOptions(table.options, debug, 'getCenterHeaderGroups'));
272
+ table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
273
+ var _left$map$filter2;
274
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
275
+ return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
276
+ }, getMemoOptions(table.options, debug, 'getLeftHeaderGroups'));
277
+ table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
278
+ var _right$map$filter2;
279
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
280
+ return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
281
+ }, getMemoOptions(table.options, debug, 'getRightHeaderGroups'));
282
+
283
+ // Footer Groups
284
+
285
+ table.getFooterGroups = memo(() => [table.getHeaderGroups()], headerGroups => {
286
+ return [...headerGroups].reverse();
287
+ }, getMemoOptions(table.options, debug, 'getFooterGroups'));
288
+ table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], headerGroups => {
289
+ return [...headerGroups].reverse();
290
+ }, getMemoOptions(table.options, debug, 'getLeftFooterGroups'));
291
+ table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], headerGroups => {
292
+ return [...headerGroups].reverse();
293
+ }, getMemoOptions(table.options, debug, 'getCenterFooterGroups'));
294
+ table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], headerGroups => {
295
+ return [...headerGroups].reverse();
296
+ }, getMemoOptions(table.options, debug, 'getRightFooterGroups'));
297
+
298
+ // Flat Headers
299
+
300
+ table.getFlatHeaders = memo(() => [table.getHeaderGroups()], headerGroups => {
301
+ return headerGroups.map(headerGroup => {
302
+ return headerGroup.headers;
303
+ }).flat();
304
+ }, getMemoOptions(table.options, debug, 'getFlatHeaders'));
305
+ table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], left => {
306
+ return left.map(headerGroup => {
307
+ return headerGroup.headers;
308
+ }).flat();
309
+ }, getMemoOptions(table.options, debug, 'getLeftFlatHeaders'));
310
+ table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], left => {
311
+ return left.map(headerGroup => {
312
+ return headerGroup.headers;
313
+ }).flat();
314
+ }, getMemoOptions(table.options, debug, 'getCenterFlatHeaders'));
315
+ table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], left => {
316
+ return left.map(headerGroup => {
317
+ return headerGroup.headers;
318
+ }).flat();
319
+ }, getMemoOptions(table.options, debug, 'getRightFlatHeaders'));
320
+
321
+ // Leaf Headers
322
+
323
+ table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
324
+ return flatHeaders.filter(header => {
325
+ var _header$subHeaders;
326
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
327
+ });
328
+ }, getMemoOptions(table.options, debug, 'getCenterLeafHeaders'));
329
+ table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
330
+ return flatHeaders.filter(header => {
331
+ var _header$subHeaders2;
332
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
333
+ });
334
+ }, getMemoOptions(table.options, debug, 'getLeftLeafHeaders'));
335
+ table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], flatHeaders => {
336
+ return flatHeaders.filter(header => {
337
+ var _header$subHeaders3;
338
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
339
+ });
340
+ }, getMemoOptions(table.options, debug, 'getRightLeafHeaders'));
341
+ table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
342
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
343
+ return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
344
+ return header.getLeafHeaders();
345
+ }).flat();
346
+ }, getMemoOptions(table.options, debug, 'getLeafHeaders'));
347
+ }
348
+ };
349
+ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
350
+ var _headerGroups$0$heade, _headerGroups$;
351
+ // Find the max depth of the columns:
352
+ // build the leaf column row
353
+ // build each buffer row going up
354
+ // placeholder for non-existent level
355
+ // real column for existing level
356
+
357
+ let maxDepth = 0;
358
+ const findMaxDepth = function (columns, depth) {
359
+ if (depth === void 0) {
360
+ depth = 1;
361
+ }
362
+ maxDepth = Math.max(maxDepth, depth);
363
+ columns.filter(column => column.getIsVisible()).forEach(column => {
364
+ var _column$columns;
365
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
366
+ findMaxDepth(column.columns, depth + 1);
367
+ }
368
+ }, 0);
369
+ };
370
+ findMaxDepth(allColumns);
371
+ let headerGroups = [];
372
+ const createHeaderGroup = (headersToGroup, depth) => {
373
+ // The header group we are creating
374
+ const headerGroup = {
375
+ depth,
376
+ id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
377
+ headers: []
378
+ };
379
+
380
+ // The parent columns we're going to scan next
381
+ const pendingParentHeaders = [];
382
+
383
+ // Scan each column for parents
384
+ headersToGroup.forEach(headerToGroup => {
385
+ // What is the latest (last) parent column?
386
+
387
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
388
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
389
+ let column;
390
+ let isPlaceholder = false;
391
+ if (isLeafHeader && headerToGroup.column.parent) {
392
+ // The parent header is new
393
+ column = headerToGroup.column.parent;
394
+ } else {
395
+ // The parent header is repeated
396
+ column = headerToGroup.column;
397
+ isPlaceholder = true;
398
+ }
399
+ if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
400
+ // This column is repeated. Add it as a sub header to the next batch
401
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
402
+ } else {
403
+ // This is a new header. Let's create it
404
+ const header = createHeader(table, column, {
405
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
406
+ isPlaceholder,
407
+ placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
408
+ depth,
409
+ index: pendingParentHeaders.length
410
+ });
411
+
412
+ // Add the headerToGroup as a subHeader of the new header
413
+ header.subHeaders.push(headerToGroup);
414
+ // Add the new header to the pendingParentHeaders to get grouped
415
+ // in the next batch
416
+ pendingParentHeaders.push(header);
417
+ }
418
+ headerGroup.headers.push(headerToGroup);
419
+ headerToGroup.headerGroup = headerGroup;
420
+ });
421
+ headerGroups.push(headerGroup);
422
+ if (depth > 0) {
423
+ createHeaderGroup(pendingParentHeaders, depth - 1);
424
+ }
425
+ };
426
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
427
+ depth: maxDepth,
428
+ index
429
+ }));
430
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
431
+ headerGroups.reverse();
432
+
433
+ // headerGroups = headerGroups.filter(headerGroup => {
434
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
435
+ // })
436
+
437
+ const recurseHeadersForSpans = headers => {
438
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
439
+ return filteredHeaders.map(header => {
440
+ let colSpan = 0;
441
+ let rowSpan = 0;
442
+ let childRowSpans = [0];
443
+ if (header.subHeaders && header.subHeaders.length) {
444
+ childRowSpans = [];
445
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
446
+ let {
447
+ colSpan: childColSpan,
448
+ rowSpan: childRowSpan
449
+ } = _ref;
450
+ colSpan += childColSpan;
451
+ childRowSpans.push(childRowSpan);
452
+ });
453
+ } else {
454
+ colSpan = 1;
455
+ }
456
+ const minChildRowSpan = Math.min(...childRowSpans);
457
+ rowSpan = rowSpan + minChildRowSpan;
458
+ header.colSpan = colSpan;
459
+ header.rowSpan = rowSpan;
460
+ return {
461
+ colSpan,
462
+ rowSpan
463
+ };
464
+ });
465
+ };
466
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
467
+ return headerGroups;
468
+ }
469
+
470
+ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
471
+ let row = {
472
+ id,
473
+ index: rowIndex,
474
+ original,
475
+ depth,
476
+ parentId,
477
+ _valuesCache: {},
478
+ _uniqueValuesCache: {},
479
+ getValue: columnId => {
480
+ if (row._valuesCache.hasOwnProperty(columnId)) {
481
+ return row._valuesCache[columnId];
482
+ }
483
+ const column = table.getColumn(columnId);
484
+ if (!(column != null && column.accessorFn)) {
485
+ return undefined;
486
+ }
487
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
488
+ return row._valuesCache[columnId];
489
+ },
490
+ getUniqueValues: columnId => {
491
+ if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
492
+ return row._uniqueValuesCache[columnId];
493
+ }
494
+ const column = table.getColumn(columnId);
495
+ if (!(column != null && column.accessorFn)) {
496
+ return undefined;
497
+ }
498
+ if (!column.columnDef.getUniqueValues) {
499
+ row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
500
+ return row._uniqueValuesCache[columnId];
501
+ }
502
+ row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
503
+ return row._uniqueValuesCache[columnId];
504
+ },
505
+ renderValue: columnId => {
506
+ var _row$getValue;
507
+ return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
508
+ },
509
+ subRows: subRows != null ? subRows : [],
510
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
511
+ getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
512
+ getParentRows: () => {
513
+ let parentRows = [];
514
+ let currentRow = row;
515
+ while (true) {
516
+ const parentRow = currentRow.getParentRow();
517
+ if (!parentRow) break;
518
+ parentRows.push(parentRow);
519
+ currentRow = parentRow;
520
+ }
521
+ return parentRows.reverse();
522
+ },
523
+ getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
524
+ return leafColumns.map(column => {
525
+ return createCell(table, row, column, column.id);
526
+ });
527
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
528
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
529
+ return allCells.reduce((acc, cell) => {
530
+ acc[cell.column.id] = cell;
531
+ return acc;
532
+ }, {});
533
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
534
+ };
535
+ for (let i = 0; i < table._features.length; i++) {
536
+ const feature = table._features[i];
537
+ feature == null || feature.createRow == null || feature.createRow(row, table);
538
+ }
539
+ return row;
540
+ };
541
+
542
+ //
543
+
544
+ const ColumnFaceting = {
545
+ createColumn: (column, table) => {
546
+ column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
547
+ column.getFacetedRowModel = () => {
548
+ if (!column._getFacetedRowModel) {
549
+ return table.getPreFilteredRowModel();
550
+ }
551
+ return column._getFacetedRowModel();
552
+ };
553
+ column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
554
+ column.getFacetedUniqueValues = () => {
555
+ if (!column._getFacetedUniqueValues) {
556
+ return new Map();
557
+ }
558
+ return column._getFacetedUniqueValues();
559
+ };
560
+ column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
561
+ column.getFacetedMinMaxValues = () => {
562
+ if (!column._getFacetedMinMaxValues) {
563
+ return undefined;
564
+ }
565
+ return column._getFacetedMinMaxValues();
566
+ };
567
+ }
568
+ };
569
+
570
+ const includesString = (row, columnId, filterValue) => {
571
+ var _filterValue$toString, _row$getValue;
572
+ const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
573
+ return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
574
+ };
575
+ includesString.autoRemove = val => testFalsey(val);
576
+ const includesStringSensitive = (row, columnId, filterValue) => {
577
+ var _row$getValue2;
578
+ return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
579
+ };
580
+ includesStringSensitive.autoRemove = val => testFalsey(val);
581
+ const equalsString = (row, columnId, filterValue) => {
582
+ var _row$getValue3;
583
+ return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
584
+ };
585
+ equalsString.autoRemove = val => testFalsey(val);
586
+ const arrIncludes = (row, columnId, filterValue) => {
587
+ var _row$getValue4;
588
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
589
+ };
590
+ arrIncludes.autoRemove = val => testFalsey(val);
591
+ const arrIncludesAll = (row, columnId, filterValue) => {
592
+ return !filterValue.some(val => {
593
+ var _row$getValue5;
594
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
595
+ });
596
+ };
597
+ arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
598
+ const arrIncludesSome = (row, columnId, filterValue) => {
599
+ return filterValue.some(val => {
600
+ var _row$getValue6;
601
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
602
+ });
603
+ };
604
+ arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
605
+ const equals = (row, columnId, filterValue) => {
606
+ return row.getValue(columnId) === filterValue;
607
+ };
608
+ equals.autoRemove = val => testFalsey(val);
609
+ const weakEquals = (row, columnId, filterValue) => {
610
+ return row.getValue(columnId) == filterValue;
611
+ };
612
+ weakEquals.autoRemove = val => testFalsey(val);
613
+ const inNumberRange = (row, columnId, filterValue) => {
614
+ let [min, max] = filterValue;
615
+ const rowValue = row.getValue(columnId);
616
+ return rowValue >= min && rowValue <= max;
617
+ };
618
+ inNumberRange.resolveFilterValue = val => {
619
+ let [unsafeMin, unsafeMax] = val;
620
+ let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
621
+ let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
622
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
623
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
624
+ if (min > max) {
625
+ const temp = min;
626
+ min = max;
627
+ max = temp;
628
+ }
629
+ return [min, max];
630
+ };
631
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
632
+
633
+ // Export
634
+
635
+ const filterFns = {
636
+ includesString,
637
+ includesStringSensitive,
638
+ equalsString,
639
+ arrIncludes,
640
+ arrIncludesAll,
641
+ arrIncludesSome,
642
+ equals,
643
+ weakEquals,
644
+ inNumberRange
645
+ };
646
+ // Utils
647
+
648
+ function testFalsey(val) {
649
+ return val === undefined || val === null || val === '';
650
+ }
651
+
652
+ //
653
+
654
+ const ColumnFiltering = {
655
+ getDefaultColumnDef: () => {
656
+ return {
657
+ filterFn: 'auto'
658
+ };
659
+ },
660
+ getInitialState: state => {
661
+ return {
662
+ columnFilters: [],
663
+ ...state
664
+ };
665
+ },
666
+ getDefaultOptions: table => {
667
+ return {
668
+ onColumnFiltersChange: makeStateUpdater('columnFilters', table),
669
+ filterFromLeafRows: false,
670
+ maxLeafRowFilterDepth: 100
671
+ };
672
+ },
673
+ createColumn: (column, table) => {
674
+ column.getAutoFilterFn = () => {
675
+ const firstRow = table.getCoreRowModel().flatRows[0];
676
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
677
+ if (typeof value === 'string') {
678
+ return filterFns.includesString;
679
+ }
680
+ if (typeof value === 'number') {
681
+ return filterFns.inNumberRange;
682
+ }
683
+ if (typeof value === 'boolean') {
684
+ return filterFns.equals;
685
+ }
686
+ if (value !== null && typeof value === 'object') {
687
+ return filterFns.equals;
688
+ }
689
+ if (Array.isArray(value)) {
690
+ return filterFns.arrIncludes;
691
+ }
692
+ return filterFns.weakEquals;
693
+ };
694
+ column.getFilterFn = () => {
695
+ var _table$options$filter, _table$options$filter2;
696
+ return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
697
+ (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
698
+ };
699
+ column.getCanFilter = () => {
700
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
701
+ return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
702
+ };
703
+ column.getIsFiltered = () => column.getFilterIndex() > -1;
704
+ column.getFilterValue = () => {
705
+ var _table$getState$colum;
706
+ return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
707
+ };
708
+ column.getFilterIndex = () => {
709
+ var _table$getState$colum2, _table$getState$colum3;
710
+ return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
711
+ };
712
+ column.setFilterValue = value => {
713
+ table.setColumnFilters(old => {
714
+ const filterFn = column.getFilterFn();
715
+ const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
716
+ const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
717
+
718
+ //
719
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
720
+ var _old$filter;
721
+ return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
722
+ }
723
+ const newFilterObj = {
724
+ id: column.id,
725
+ value: newFilter
726
+ };
727
+ if (previousFilter) {
728
+ var _old$map;
729
+ return (_old$map = old == null ? void 0 : old.map(d => {
730
+ if (d.id === column.id) {
731
+ return newFilterObj;
732
+ }
733
+ return d;
734
+ })) != null ? _old$map : [];
735
+ }
736
+ if (old != null && old.length) {
737
+ return [...old, newFilterObj];
738
+ }
739
+ return [newFilterObj];
740
+ });
741
+ };
742
+ },
743
+ createRow: (row, _table) => {
744
+ row.columnFilters = {};
745
+ row.columnFiltersMeta = {};
746
+ },
747
+ createTable: table => {
748
+ table.setColumnFilters = updater => {
749
+ const leafColumns = table.getAllLeafColumns();
750
+ const updateFn = old => {
751
+ var _functionalUpdate;
752
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
753
+ const column = leafColumns.find(d => d.id === filter.id);
754
+ if (column) {
755
+ const filterFn = column.getFilterFn();
756
+ if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
757
+ return false;
758
+ }
759
+ }
760
+ return true;
761
+ });
762
+ };
763
+ table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
764
+ };
765
+ table.resetColumnFilters = defaultState => {
766
+ var _table$initialState$c, _table$initialState;
767
+ table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
768
+ };
769
+ table.getPreFilteredRowModel = () => table.getCoreRowModel();
770
+ table.getFilteredRowModel = () => {
771
+ if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
772
+ table._getFilteredRowModel = table.options.getFilteredRowModel(table);
773
+ }
774
+ if (table.options.manualFiltering || !table._getFilteredRowModel) {
775
+ return table.getPreFilteredRowModel();
776
+ }
777
+ return table._getFilteredRowModel();
778
+ };
779
+ }
780
+ };
781
+ function shouldAutoRemoveFilter(filterFn, value, column) {
782
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
783
+ }
784
+
785
+ const sum = (columnId, _leafRows, childRows) => {
786
+ // It's faster to just add the aggregations together instead of
787
+ // process leaf nodes individually
788
+ return childRows.reduce((sum, next) => {
789
+ const nextValue = next.getValue(columnId);
790
+ return sum + (typeof nextValue === 'number' ? nextValue : 0);
791
+ }, 0);
792
+ };
793
+ const min = (columnId, _leafRows, childRows) => {
794
+ let min;
795
+ childRows.forEach(row => {
796
+ const value = row.getValue(columnId);
797
+ if (value != null && (min > value || min === undefined && value >= value)) {
798
+ min = value;
799
+ }
800
+ });
801
+ return min;
802
+ };
803
+ const max = (columnId, _leafRows, childRows) => {
804
+ let max;
805
+ childRows.forEach(row => {
806
+ const value = row.getValue(columnId);
807
+ if (value != null && (max < value || max === undefined && value >= value)) {
808
+ max = value;
809
+ }
810
+ });
811
+ return max;
812
+ };
813
+ const extent = (columnId, _leafRows, childRows) => {
814
+ let min;
815
+ let max;
816
+ childRows.forEach(row => {
817
+ const value = row.getValue(columnId);
818
+ if (value != null) {
819
+ if (min === undefined) {
820
+ if (value >= value) min = max = value;
821
+ } else {
822
+ if (min > value) min = value;
823
+ if (max < value) max = value;
824
+ }
825
+ }
826
+ });
827
+ return [min, max];
828
+ };
829
+ const mean = (columnId, leafRows) => {
830
+ let count = 0;
831
+ let sum = 0;
832
+ leafRows.forEach(row => {
833
+ let value = row.getValue(columnId);
834
+ if (value != null && (value = +value) >= value) {
835
+ ++count, sum += value;
836
+ }
837
+ });
838
+ if (count) return sum / count;
839
+ return;
840
+ };
841
+ const median = (columnId, leafRows) => {
842
+ if (!leafRows.length) {
843
+ return;
844
+ }
845
+ const values = leafRows.map(row => row.getValue(columnId));
846
+ if (!isNumberArray(values)) {
847
+ return;
848
+ }
849
+ if (values.length === 1) {
850
+ return values[0];
851
+ }
852
+ const mid = Math.floor(values.length / 2);
853
+ const nums = values.sort((a, b) => a - b);
854
+ return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
855
+ };
856
+ const unique = (columnId, leafRows) => {
857
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
858
+ };
859
+ const uniqueCount = (columnId, leafRows) => {
860
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
861
+ };
862
+ const count = (_columnId, leafRows) => {
863
+ return leafRows.length;
864
+ };
865
+ const aggregationFns = {
866
+ sum,
867
+ min,
868
+ max,
869
+ extent,
870
+ mean,
871
+ median,
872
+ unique,
873
+ uniqueCount,
874
+ count
875
+ };
876
+
877
+ //
878
+
879
+ const ColumnGrouping = {
880
+ getDefaultColumnDef: () => {
881
+ return {
882
+ aggregatedCell: props => {
883
+ var _toString, _props$getValue;
884
+ return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
885
+ },
886
+ aggregationFn: 'auto'
887
+ };
888
+ },
889
+ getInitialState: state => {
890
+ return {
891
+ grouping: [],
892
+ ...state
893
+ };
894
+ },
895
+ getDefaultOptions: table => {
896
+ return {
897
+ onGroupingChange: makeStateUpdater('grouping', table),
898
+ groupedColumnMode: 'reorder'
899
+ };
900
+ },
901
+ createColumn: (column, table) => {
902
+ column.toggleGrouping = () => {
903
+ table.setGrouping(old => {
904
+ // Find any existing grouping for this column
905
+ if (old != null && old.includes(column.id)) {
906
+ return old.filter(d => d !== column.id);
907
+ }
908
+ return [...(old != null ? old : []), column.id];
909
+ });
910
+ };
911
+ column.getCanGroup = () => {
912
+ var _column$columnDef$ena, _table$options$enable;
913
+ return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
914
+ };
915
+ column.getIsGrouped = () => {
916
+ var _table$getState$group;
917
+ return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
918
+ };
919
+ column.getGroupedIndex = () => {
920
+ var _table$getState$group2;
921
+ return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
922
+ };
923
+ column.getToggleGroupingHandler = () => {
924
+ const canGroup = column.getCanGroup();
925
+ return () => {
926
+ if (!canGroup) return;
927
+ column.toggleGrouping();
928
+ };
929
+ };
930
+ column.getAutoAggregationFn = () => {
931
+ const firstRow = table.getCoreRowModel().flatRows[0];
932
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
933
+ if (typeof value === 'number') {
934
+ return aggregationFns.sum;
935
+ }
936
+ if (Object.prototype.toString.call(value) === '[object Date]') {
937
+ return aggregationFns.extent;
938
+ }
939
+ };
940
+ column.getAggregationFn = () => {
941
+ var _table$options$aggreg, _table$options$aggreg2;
942
+ if (!column) {
943
+ throw new Error();
944
+ }
945
+ return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
946
+ };
947
+ },
948
+ createTable: table => {
949
+ table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
950
+ table.resetGrouping = defaultState => {
951
+ var _table$initialState$g, _table$initialState;
952
+ table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
953
+ };
954
+ table.getPreGroupedRowModel = () => table.getFilteredRowModel();
955
+ table.getGroupedRowModel = () => {
956
+ if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
957
+ table._getGroupedRowModel = table.options.getGroupedRowModel(table);
958
+ }
959
+ if (table.options.manualGrouping || !table._getGroupedRowModel) {
960
+ return table.getPreGroupedRowModel();
961
+ }
962
+ return table._getGroupedRowModel();
963
+ };
964
+ },
965
+ createRow: (row, table) => {
966
+ row.getIsGrouped = () => !!row.groupingColumnId;
967
+ row.getGroupingValue = columnId => {
968
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
969
+ return row._groupingValuesCache[columnId];
970
+ }
971
+ const column = table.getColumn(columnId);
972
+ if (!(column != null && column.columnDef.getGroupingValue)) {
973
+ return row.getValue(columnId);
974
+ }
975
+ row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
976
+ return row._groupingValuesCache[columnId];
977
+ };
978
+ row._groupingValuesCache = {};
979
+ },
980
+ createCell: (cell, column, row, table) => {
981
+ cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
982
+ cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
983
+ cell.getIsAggregated = () => {
984
+ var _row$subRows;
985
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
986
+ };
987
+ }
988
+ };
989
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
990
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) {
991
+ return leafColumns;
992
+ }
993
+ const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
994
+ if (groupedColumnMode === 'remove') {
995
+ return nonGroupingColumns;
996
+ }
997
+ const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
998
+ return [...groupingColumns, ...nonGroupingColumns];
999
+ }
1000
+
1001
+ //
1002
+
1003
+ const ColumnOrdering = {
1004
+ getInitialState: state => {
1005
+ return {
1006
+ columnOrder: [],
1007
+ ...state
1008
+ };
1009
+ },
1010
+ getDefaultOptions: table => {
1011
+ return {
1012
+ onColumnOrderChange: makeStateUpdater('columnOrder', table)
1013
+ };
1014
+ },
1015
+ createColumn: (column, table) => {
1016
+ column.getIndex = memo(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
1017
+ column.getIsFirstColumn = position => {
1018
+ var _columns$;
1019
+ const columns = _getVisibleLeafColumns(table, position);
1020
+ return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
1021
+ };
1022
+ column.getIsLastColumn = position => {
1023
+ var _columns;
1024
+ const columns = _getVisibleLeafColumns(table, position);
1025
+ return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
1026
+ };
1027
+ },
1028
+ createTable: table => {
1029
+ table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
1030
+ table.resetColumnOrder = defaultState => {
1031
+ var _table$initialState$c;
1032
+ table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
1033
+ };
1034
+ table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
1035
+ // Sort grouped columns to the start of the column list
1036
+ // before the headers are built
1037
+ let orderedColumns = [];
1038
+
1039
+ // If there is no order, return the normal columns
1040
+ if (!(columnOrder != null && columnOrder.length)) {
1041
+ orderedColumns = columns;
1042
+ } else {
1043
+ const columnOrderCopy = [...columnOrder];
1044
+
1045
+ // If there is an order, make a copy of the columns
1046
+ const columnsCopy = [...columns];
1047
+
1048
+ // And make a new ordered array of the columns
1049
+
1050
+ // Loop over the columns and place them in order into the new array
1051
+ while (columnsCopy.length && columnOrderCopy.length) {
1052
+ const targetColumnId = columnOrderCopy.shift();
1053
+ const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
1054
+ if (foundIndex > -1) {
1055
+ orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
1056
+ }
1057
+ }
1058
+
1059
+ // If there are any columns left, add them to the end
1060
+ orderedColumns = [...orderedColumns, ...columnsCopy];
1061
+ }
1062
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
1063
+ }, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
1064
+ }
1065
+ };
1066
+
1067
+ //
1068
+
1069
+ const getDefaultColumnPinningState = () => ({
1070
+ left: [],
1071
+ right: []
1072
+ });
1073
+ const ColumnPinning = {
1074
+ getInitialState: state => {
1075
+ return {
1076
+ columnPinning: getDefaultColumnPinningState(),
1077
+ ...state
1078
+ };
1079
+ },
1080
+ getDefaultOptions: table => {
1081
+ return {
1082
+ onColumnPinningChange: makeStateUpdater('columnPinning', table)
1083
+ };
1084
+ },
1085
+ createColumn: (column, table) => {
1086
+ column.pin = position => {
1087
+ const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
1088
+ table.setColumnPinning(old => {
1089
+ var _old$left3, _old$right3;
1090
+ if (position === 'right') {
1091
+ var _old$left, _old$right;
1092
+ return {
1093
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1094
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
1095
+ };
1096
+ }
1097
+ if (position === 'left') {
1098
+ var _old$left2, _old$right2;
1099
+ return {
1100
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
1101
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1102
+ };
1103
+ }
1104
+ return {
1105
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1106
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1107
+ };
1108
+ });
1109
+ };
1110
+ column.getCanPin = () => {
1111
+ const leafColumns = column.getLeafColumns();
1112
+ return leafColumns.some(d => {
1113
+ var _d$columnDef$enablePi, _ref, _table$options$enable;
1114
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
1115
+ });
1116
+ };
1117
+ column.getIsPinned = () => {
1118
+ const leafColumnIds = column.getLeafColumns().map(d => d.id);
1119
+ const {
1120
+ left,
1121
+ right
1122
+ } = table.getState().columnPinning;
1123
+ const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
1124
+ const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
1125
+ return isLeft ? 'left' : isRight ? 'right' : false;
1126
+ };
1127
+ column.getPinnedIndex = () => {
1128
+ var _table$getState$colum, _table$getState$colum2;
1129
+ const position = column.getIsPinned();
1130
+ return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
1131
+ };
1132
+ },
1133
+ createRow: (row, table) => {
1134
+ row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
1135
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1136
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1137
+ }, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
1138
+ row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
1139
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1140
+ ...d,
1141
+ position: 'left'
1142
+ }));
1143
+ return cells;
1144
+ }, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
1145
+ row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
1146
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1147
+ ...d,
1148
+ position: 'right'
1149
+ }));
1150
+ return cells;
1151
+ }, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
1152
+ },
1153
+ createTable: table => {
1154
+ table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
1155
+ table.resetColumnPinning = defaultState => {
1156
+ var _table$initialState$c, _table$initialState;
1157
+ return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
1158
+ };
1159
+ table.getIsSomeColumnsPinned = position => {
1160
+ var _pinningState$positio;
1161
+ const pinningState = table.getState().columnPinning;
1162
+ if (!position) {
1163
+ var _pinningState$left, _pinningState$right;
1164
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1165
+ }
1166
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1167
+ };
1168
+ table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
1169
+ return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1170
+ }, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
1171
+ table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
1172
+ return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1173
+ }, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
1174
+ table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
1175
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1176
+ return allColumns.filter(d => !leftAndRight.includes(d.id));
1177
+ }, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
1178
+ }
1179
+ };
1180
+
1181
+ function safelyAccessDocument(_document) {
1182
+ return _document || (typeof document !== 'undefined' ? document : null);
1183
+ }
1184
+
1185
+ //
1186
+
1187
+ //
1188
+
1189
+ const defaultColumnSizing = {
1190
+ size: 150,
1191
+ minSize: 20,
1192
+ maxSize: Number.MAX_SAFE_INTEGER
1193
+ };
1194
+ const getDefaultColumnSizingInfoState = () => ({
1195
+ startOffset: null,
1196
+ startSize: null,
1197
+ deltaOffset: null,
1198
+ deltaPercentage: null,
1199
+ isResizingColumn: false,
1200
+ columnSizingStart: []
1201
+ });
1202
+ const ColumnSizing = {
1203
+ getDefaultColumnDef: () => {
1204
+ return defaultColumnSizing;
1205
+ },
1206
+ getInitialState: state => {
1207
+ return {
1208
+ columnSizing: {},
1209
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
1210
+ ...state
1211
+ };
1212
+ },
1213
+ getDefaultOptions: table => {
1214
+ return {
1215
+ columnResizeMode: 'onEnd',
1216
+ columnResizeDirection: 'ltr',
1217
+ onColumnSizingChange: makeStateUpdater('columnSizing', table),
1218
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
1219
+ };
1220
+ },
1221
+ createColumn: (column, table) => {
1222
+ column.getSize = () => {
1223
+ var _column$columnDef$min, _ref, _column$columnDef$max;
1224
+ const columnSize = table.getState().columnSizing[column.id];
1225
+ return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
1226
+ };
1227
+ column.getStart = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getStart'));
1228
+ column.getAfter = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
1229
+ column.resetSize = () => {
1230
+ table.setColumnSizing(_ref2 => {
1231
+ let {
1232
+ [column.id]: _,
1233
+ ...rest
1234
+ } = _ref2;
1235
+ return rest;
1236
+ });
1237
+ };
1238
+ column.getCanResize = () => {
1239
+ var _column$columnDef$ena, _table$options$enable;
1240
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
1241
+ };
1242
+ column.getIsResizing = () => {
1243
+ return table.getState().columnSizingInfo.isResizingColumn === column.id;
1244
+ };
1245
+ },
1246
+ createHeader: (header, table) => {
1247
+ header.getSize = () => {
1248
+ let sum = 0;
1249
+ const recurse = header => {
1250
+ if (header.subHeaders.length) {
1251
+ header.subHeaders.forEach(recurse);
1252
+ } else {
1253
+ var _header$column$getSiz;
1254
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
1255
+ }
1256
+ };
1257
+ recurse(header);
1258
+ return sum;
1259
+ };
1260
+ header.getStart = () => {
1261
+ if (header.index > 0) {
1262
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
1263
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
1264
+ }
1265
+ return 0;
1266
+ };
1267
+ header.getResizeHandler = _contextDocument => {
1268
+ const column = table.getColumn(header.column.id);
1269
+ const canResize = column == null ? void 0 : column.getCanResize();
1270
+ return e => {
1271
+ if (!column || !canResize) {
1272
+ return;
1273
+ }
1274
+ e.persist == null || e.persist();
1275
+ if (isTouchStartEvent(e)) {
1276
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
1277
+ if (e.touches && e.touches.length > 1) {
1278
+ return;
1279
+ }
1280
+ }
1281
+ const startSize = header.getSize();
1282
+ const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
1283
+ const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1284
+ const newColumnSizing = {};
1285
+ const updateOffset = (eventType, clientXPos) => {
1286
+ if (typeof clientXPos !== 'number') {
1287
+ return;
1288
+ }
1289
+ table.setColumnSizingInfo(old => {
1290
+ var _old$startOffset, _old$startSize;
1291
+ const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
1292
+ const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
1293
+ const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
1294
+ old.columnSizingStart.forEach(_ref3 => {
1295
+ let [columnId, headerSize] = _ref3;
1296
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
1297
+ });
1298
+ return {
1299
+ ...old,
1300
+ deltaOffset,
1301
+ deltaPercentage
1302
+ };
1303
+ });
1304
+ if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
1305
+ table.setColumnSizing(old => ({
1306
+ ...old,
1307
+ ...newColumnSizing
1308
+ }));
1309
+ }
1310
+ };
1311
+ const onMove = clientXPos => updateOffset('move', clientXPos);
1312
+ const onEnd = clientXPos => {
1313
+ updateOffset('end', clientXPos);
1314
+ table.setColumnSizingInfo(old => ({
1315
+ ...old,
1316
+ isResizingColumn: false,
1317
+ startOffset: null,
1318
+ startSize: null,
1319
+ deltaOffset: null,
1320
+ deltaPercentage: null,
1321
+ columnSizingStart: []
1322
+ }));
1323
+ };
1324
+ const contextDocument = safelyAccessDocument(_contextDocument);
1325
+ const mouseEvents = {
1326
+ moveHandler: e => onMove(e.clientX),
1327
+ upHandler: e => {
1328
+ contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
1329
+ contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
1330
+ onEnd(e.clientX);
1331
+ }
1332
+ };
1333
+ const touchEvents = {
1334
+ moveHandler: e => {
1335
+ if (e.cancelable) {
1336
+ e.preventDefault();
1337
+ e.stopPropagation();
1338
+ }
1339
+ onMove(e.touches[0].clientX);
1340
+ return false;
1341
+ },
1342
+ upHandler: e => {
1343
+ var _e$touches$;
1344
+ contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
1345
+ contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
1346
+ if (e.cancelable) {
1347
+ e.preventDefault();
1348
+ e.stopPropagation();
1349
+ }
1350
+ onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
1351
+ }
1352
+ };
1353
+ const passiveIfSupported = passiveEventSupported() ? {
1354
+ passive: false
1355
+ } : false;
1356
+ if (isTouchStartEvent(e)) {
1357
+ contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
1358
+ contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
1359
+ } else {
1360
+ contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
1361
+ contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
1362
+ }
1363
+ table.setColumnSizingInfo(old => ({
1364
+ ...old,
1365
+ startOffset: clientX,
1366
+ startSize,
1367
+ deltaOffset: 0,
1368
+ deltaPercentage: 0,
1369
+ columnSizingStart,
1370
+ isResizingColumn: column.id
1371
+ }));
1372
+ };
1373
+ };
1374
+ },
1375
+ createTable: table => {
1376
+ table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
1377
+ table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
1378
+ table.resetColumnSizing = defaultState => {
1379
+ var _table$initialState$c;
1380
+ table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
1381
+ };
1382
+ table.resetHeaderSizeInfo = defaultState => {
1383
+ var _table$initialState$c2;
1384
+ table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
1385
+ };
1386
+ table.getTotalSize = () => {
1387
+ var _table$getHeaderGroup, _table$getHeaderGroup2;
1388
+ return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
1389
+ return sum + header.getSize();
1390
+ }, 0)) != null ? _table$getHeaderGroup : 0;
1391
+ };
1392
+ table.getLeftTotalSize = () => {
1393
+ var _table$getLeftHeaderG, _table$getLeftHeaderG2;
1394
+ return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
1395
+ return sum + header.getSize();
1396
+ }, 0)) != null ? _table$getLeftHeaderG : 0;
1397
+ };
1398
+ table.getCenterTotalSize = () => {
1399
+ var _table$getCenterHeade, _table$getCenterHeade2;
1400
+ return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
1401
+ return sum + header.getSize();
1402
+ }, 0)) != null ? _table$getCenterHeade : 0;
1403
+ };
1404
+ table.getRightTotalSize = () => {
1405
+ var _table$getRightHeader, _table$getRightHeader2;
1406
+ return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
1407
+ return sum + header.getSize();
1408
+ }, 0)) != null ? _table$getRightHeader : 0;
1409
+ };
1410
+ }
1411
+ };
1412
+ let passiveSupported = null;
1413
+ function passiveEventSupported() {
1414
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
1415
+ let supported = false;
1416
+ try {
1417
+ const options = {
1418
+ get passive() {
1419
+ supported = true;
1420
+ return false;
1421
+ }
1422
+ };
1423
+ const noop = () => {};
1424
+ window.addEventListener('test', noop, options);
1425
+ window.removeEventListener('test', noop);
1426
+ } catch (err) {
1427
+ supported = false;
1428
+ }
1429
+ passiveSupported = supported;
1430
+ return passiveSupported;
1431
+ }
1432
+ function isTouchStartEvent(e) {
1433
+ return e.type === 'touchstart';
1434
+ }
1435
+
1436
+ //
1437
+
1438
+ const ColumnVisibility = {
1439
+ getInitialState: state => {
1440
+ return {
1441
+ columnVisibility: {},
1442
+ ...state
1443
+ };
1444
+ },
1445
+ getDefaultOptions: table => {
1446
+ return {
1447
+ onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
1448
+ };
1449
+ },
1450
+ createColumn: (column, table) => {
1451
+ column.toggleVisibility = value => {
1452
+ if (column.getCanHide()) {
1453
+ table.setColumnVisibility(old => ({
1454
+ ...old,
1455
+ [column.id]: value != null ? value : !column.getIsVisible()
1456
+ }));
1457
+ }
1458
+ };
1459
+ column.getIsVisible = () => {
1460
+ var _ref, _table$getState$colum;
1461
+ const childColumns = column.columns;
1462
+ return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
1463
+ };
1464
+ column.getCanHide = () => {
1465
+ var _column$columnDef$ena, _table$options$enable;
1466
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
1467
+ };
1468
+ column.getToggleVisibilityHandler = () => {
1469
+ return e => {
1470
+ column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
1471
+ };
1472
+ };
1473
+ },
1474
+ createRow: (row, table) => {
1475
+ row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
1476
+ return cells.filter(cell => cell.column.getIsVisible());
1477
+ }, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
1478
+ row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
1479
+ },
1480
+ createTable: table => {
1481
+ const makeVisibleColumnsMethod = (key, getColumns) => {
1482
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
1483
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
1484
+ }, getMemoOptions(table.options, 'debugColumns', key));
1485
+ };
1486
+ table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
1487
+ table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
1488
+ table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
1489
+ table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
1490
+ table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
1491
+ table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
1492
+ table.resetColumnVisibility = defaultState => {
1493
+ var _table$initialState$c;
1494
+ table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
1495
+ };
1496
+ table.toggleAllColumnsVisible = value => {
1497
+ var _value;
1498
+ value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
1499
+ table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
1500
+ ...obj,
1501
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
1502
+ }), {}));
1503
+ };
1504
+ table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
1505
+ table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
1506
+ table.getToggleAllColumnsVisibilityHandler = () => {
1507
+ return e => {
1508
+ var _target;
1509
+ table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
1510
+ };
1511
+ };
1512
+ }
1513
+ };
1514
+ function _getVisibleLeafColumns(table, position) {
1515
+ return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
1516
+ }
1517
+
1518
+ //
1519
+
1520
+ const GlobalFaceting = {
1521
+ createTable: table => {
1522
+ table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
1523
+ table.getGlobalFacetedRowModel = () => {
1524
+ if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
1525
+ return table.getPreFilteredRowModel();
1526
+ }
1527
+ return table._getGlobalFacetedRowModel();
1528
+ };
1529
+ table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
1530
+ table.getGlobalFacetedUniqueValues = () => {
1531
+ if (!table._getGlobalFacetedUniqueValues) {
1532
+ return new Map();
1533
+ }
1534
+ return table._getGlobalFacetedUniqueValues();
1535
+ };
1536
+ table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
1537
+ table.getGlobalFacetedMinMaxValues = () => {
1538
+ if (!table._getGlobalFacetedMinMaxValues) {
1539
+ return;
1540
+ }
1541
+ return table._getGlobalFacetedMinMaxValues();
1542
+ };
1543
+ }
1544
+ };
1545
+
1546
+ //
1547
+
1548
+ const GlobalFiltering = {
1549
+ getInitialState: state => {
1550
+ return {
1551
+ globalFilter: undefined,
1552
+ ...state
1553
+ };
1554
+ },
1555
+ getDefaultOptions: table => {
1556
+ return {
1557
+ onGlobalFilterChange: makeStateUpdater('globalFilter', table),
1558
+ globalFilterFn: 'auto',
1559
+ getColumnCanGlobalFilter: column => {
1560
+ var _table$getCoreRowMode;
1561
+ const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
1562
+ return typeof value === 'string' || typeof value === 'number';
1563
+ }
1564
+ };
1565
+ },
1566
+ createColumn: (column, table) => {
1567
+ column.getCanGlobalFilter = () => {
1568
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
1569
+ return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
1570
+ };
1571
+ },
1572
+ createTable: table => {
1573
+ table.getGlobalAutoFilterFn = () => {
1574
+ return filterFns.includesString;
1575
+ };
1576
+ table.getGlobalFilterFn = () => {
1577
+ var _table$options$filter, _table$options$filter2;
1578
+ const {
1579
+ globalFilterFn: globalFilterFn
1580
+ } = table.options;
1581
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
1582
+ };
1583
+ table.setGlobalFilter = updater => {
1584
+ table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
1585
+ };
1586
+ table.resetGlobalFilter = defaultState => {
1587
+ table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
1588
+ };
1589
+ }
1590
+ };
1591
+
1592
+ //
1593
+
1594
+ const RowExpanding = {
1595
+ getInitialState: state => {
1596
+ return {
1597
+ expanded: {},
1598
+ ...state
1599
+ };
1600
+ },
1601
+ getDefaultOptions: table => {
1602
+ return {
1603
+ onExpandedChange: makeStateUpdater('expanded', table),
1604
+ paginateExpandedRows: true
1605
+ };
1606
+ },
1607
+ createTable: table => {
1608
+ let registered = false;
1609
+ let queued = false;
1610
+ table._autoResetExpanded = () => {
1611
+ var _ref, _table$options$autoRe;
1612
+ if (!registered) {
1613
+ table._queue(() => {
1614
+ registered = true;
1615
+ });
1616
+ return;
1617
+ }
1618
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
1619
+ if (queued) return;
1620
+ queued = true;
1621
+ table._queue(() => {
1622
+ table.resetExpanded();
1623
+ queued = false;
1624
+ });
1625
+ }
1626
+ };
1627
+ table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
1628
+ table.toggleAllRowsExpanded = expanded => {
1629
+ if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
1630
+ table.setExpanded(true);
1631
+ } else {
1632
+ table.setExpanded({});
1633
+ }
1634
+ };
1635
+ table.resetExpanded = defaultState => {
1636
+ var _table$initialState$e, _table$initialState;
1637
+ table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
1638
+ };
1639
+ table.getCanSomeRowsExpand = () => {
1640
+ return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
1641
+ };
1642
+ table.getToggleAllRowsExpandedHandler = () => {
1643
+ return e => {
1644
+ e.persist == null || e.persist();
1645
+ table.toggleAllRowsExpanded();
1646
+ };
1647
+ };
1648
+ table.getIsSomeRowsExpanded = () => {
1649
+ const expanded = table.getState().expanded;
1650
+ return expanded === true || Object.values(expanded).some(Boolean);
1651
+ };
1652
+ table.getIsAllRowsExpanded = () => {
1653
+ const expanded = table.getState().expanded;
1654
+
1655
+ // If expanded is true, save some cycles and return true
1656
+ if (typeof expanded === 'boolean') {
1657
+ return expanded === true;
1658
+ }
1659
+ if (!Object.keys(expanded).length) {
1660
+ return false;
1661
+ }
1662
+
1663
+ // If any row is not expanded, return false
1664
+ if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
1665
+ return false;
1666
+ }
1667
+
1668
+ // They must all be expanded :shrug:
1669
+ return true;
1670
+ };
1671
+ table.getExpandedDepth = () => {
1672
+ let maxDepth = 0;
1673
+ const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
1674
+ rowIds.forEach(id => {
1675
+ const splitId = id.split('.');
1676
+ maxDepth = Math.max(maxDepth, splitId.length);
1677
+ });
1678
+ return maxDepth;
1679
+ };
1680
+ table.getPreExpandedRowModel = () => table.getSortedRowModel();
1681
+ table.getExpandedRowModel = () => {
1682
+ if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
1683
+ table._getExpandedRowModel = table.options.getExpandedRowModel(table);
1684
+ }
1685
+ if (table.options.manualExpanding || !table._getExpandedRowModel) {
1686
+ return table.getPreExpandedRowModel();
1687
+ }
1688
+ return table._getExpandedRowModel();
1689
+ };
1690
+ },
1691
+ createRow: (row, table) => {
1692
+ row.toggleExpanded = expanded => {
1693
+ table.setExpanded(old => {
1694
+ var _expanded;
1695
+ const exists = old === true ? true : !!(old != null && old[row.id]);
1696
+ let oldExpanded = {};
1697
+ if (old === true) {
1698
+ Object.keys(table.getRowModel().rowsById).forEach(rowId => {
1699
+ oldExpanded[rowId] = true;
1700
+ });
1701
+ } else {
1702
+ oldExpanded = old;
1703
+ }
1704
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
1705
+ if (!exists && expanded) {
1706
+ return {
1707
+ ...oldExpanded,
1708
+ [row.id]: true
1709
+ };
1710
+ }
1711
+ if (exists && !expanded) {
1712
+ const {
1713
+ [row.id]: _,
1714
+ ...rest
1715
+ } = oldExpanded;
1716
+ return rest;
1717
+ }
1718
+ return old;
1719
+ });
1720
+ };
1721
+ row.getIsExpanded = () => {
1722
+ var _table$options$getIsR;
1723
+ const expanded = table.getState().expanded;
1724
+ return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
1725
+ };
1726
+ row.getCanExpand = () => {
1727
+ var _table$options$getRow, _table$options$enable, _row$subRows;
1728
+ 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);
1729
+ };
1730
+ row.getIsAllParentsExpanded = () => {
1731
+ let isFullyExpanded = true;
1732
+ let currentRow = row;
1733
+ while (isFullyExpanded && currentRow.parentId) {
1734
+ currentRow = table.getRow(currentRow.parentId, true);
1735
+ isFullyExpanded = currentRow.getIsExpanded();
1736
+ }
1737
+ return isFullyExpanded;
1738
+ };
1739
+ row.getToggleExpandedHandler = () => {
1740
+ const canExpand = row.getCanExpand();
1741
+ return () => {
1742
+ if (!canExpand) return;
1743
+ row.toggleExpanded();
1744
+ };
1745
+ };
1746
+ }
1747
+ };
1748
+
1749
+ //
1750
+
1751
+ const defaultPageIndex = 0;
1752
+ const defaultPageSize = 10;
1753
+ const getDefaultPaginationState = () => ({
1754
+ pageIndex: defaultPageIndex,
1755
+ pageSize: defaultPageSize
1756
+ });
1757
+ const RowPagination = {
1758
+ getInitialState: state => {
1759
+ return {
1760
+ ...state,
1761
+ pagination: {
1762
+ ...getDefaultPaginationState(),
1763
+ ...(state == null ? void 0 : state.pagination)
1764
+ }
1765
+ };
1766
+ },
1767
+ getDefaultOptions: table => {
1768
+ return {
1769
+ onPaginationChange: makeStateUpdater('pagination', table)
1770
+ };
1771
+ },
1772
+ createTable: table => {
1773
+ let registered = false;
1774
+ let queued = false;
1775
+ table._autoResetPageIndex = () => {
1776
+ var _ref, _table$options$autoRe;
1777
+ if (!registered) {
1778
+ table._queue(() => {
1779
+ registered = true;
1780
+ });
1781
+ return;
1782
+ }
1783
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
1784
+ if (queued) return;
1785
+ queued = true;
1786
+ table._queue(() => {
1787
+ table.resetPageIndex();
1788
+ queued = false;
1789
+ });
1790
+ }
1791
+ };
1792
+ table.setPagination = updater => {
1793
+ const safeUpdater = old => {
1794
+ let newState = functionalUpdate(updater, old);
1795
+ return newState;
1796
+ };
1797
+ return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
1798
+ };
1799
+ table.resetPagination = defaultState => {
1800
+ var _table$initialState$p;
1801
+ table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
1802
+ };
1803
+ table.setPageIndex = updater => {
1804
+ table.setPagination(old => {
1805
+ let pageIndex = functionalUpdate(updater, old.pageIndex);
1806
+ const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
1807
+ pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
1808
+ return {
1809
+ ...old,
1810
+ pageIndex
1811
+ };
1812
+ });
1813
+ };
1814
+ table.resetPageIndex = defaultState => {
1815
+ var _table$initialState$p2, _table$initialState;
1816
+ table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
1817
+ };
1818
+ table.resetPageSize = defaultState => {
1819
+ var _table$initialState$p3, _table$initialState2;
1820
+ table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
1821
+ };
1822
+ table.setPageSize = updater => {
1823
+ table.setPagination(old => {
1824
+ const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1825
+ const topRowIndex = old.pageSize * old.pageIndex;
1826
+ const pageIndex = Math.floor(topRowIndex / pageSize);
1827
+ return {
1828
+ ...old,
1829
+ pageIndex,
1830
+ pageSize
1831
+ };
1832
+ });
1833
+ };
1834
+ //deprecated
1835
+ table.setPageCount = updater => table.setPagination(old => {
1836
+ var _table$options$pageCo;
1837
+ let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
1838
+ if (typeof newPageCount === 'number') {
1839
+ newPageCount = Math.max(-1, newPageCount);
1840
+ }
1841
+ return {
1842
+ ...old,
1843
+ pageCount: newPageCount
1844
+ };
1845
+ });
1846
+ table.getPageOptions = memo(() => [table.getPageCount()], pageCount => {
1847
+ let pageOptions = [];
1848
+ if (pageCount && pageCount > 0) {
1849
+ pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1850
+ }
1851
+ return pageOptions;
1852
+ }, getMemoOptions(table.options, 'debugTable', 'getPageOptions'));
1853
+ table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
1854
+ table.getCanNextPage = () => {
1855
+ const {
1856
+ pageIndex
1857
+ } = table.getState().pagination;
1858
+ const pageCount = table.getPageCount();
1859
+ if (pageCount === -1) {
1860
+ return true;
1861
+ }
1862
+ if (pageCount === 0) {
1863
+ return false;
1864
+ }
1865
+ return pageIndex < pageCount - 1;
1866
+ };
1867
+ table.previousPage = () => {
1868
+ return table.setPageIndex(old => old - 1);
1869
+ };
1870
+ table.nextPage = () => {
1871
+ return table.setPageIndex(old => {
1872
+ return old + 1;
1873
+ });
1874
+ };
1875
+ table.firstPage = () => {
1876
+ return table.setPageIndex(0);
1877
+ };
1878
+ table.lastPage = () => {
1879
+ return table.setPageIndex(table.getPageCount() - 1);
1880
+ };
1881
+ table.getPrePaginationRowModel = () => table.getExpandedRowModel();
1882
+ table.getPaginationRowModel = () => {
1883
+ if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
1884
+ table._getPaginationRowModel = table.options.getPaginationRowModel(table);
1885
+ }
1886
+ if (table.options.manualPagination || !table._getPaginationRowModel) {
1887
+ return table.getPrePaginationRowModel();
1888
+ }
1889
+ return table._getPaginationRowModel();
1890
+ };
1891
+ table.getPageCount = () => {
1892
+ var _table$options$pageCo2;
1893
+ return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
1894
+ };
1895
+ table.getRowCount = () => {
1896
+ var _table$options$rowCou;
1897
+ return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
1898
+ };
1899
+ }
1900
+ };
1901
+
1902
+ //
1903
+
1904
+ const getDefaultRowPinningState = () => ({
1905
+ top: [],
1906
+ bottom: []
1907
+ });
1908
+ const RowPinning = {
1909
+ getInitialState: state => {
1910
+ return {
1911
+ rowPinning: getDefaultRowPinningState(),
1912
+ ...state
1913
+ };
1914
+ },
1915
+ getDefaultOptions: table => {
1916
+ return {
1917
+ onRowPinningChange: makeStateUpdater('rowPinning', table)
1918
+ };
1919
+ },
1920
+ createRow: (row, table) => {
1921
+ row.pin = (position, includeLeafRows, includeParentRows) => {
1922
+ const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
1923
+ let {
1924
+ id
1925
+ } = _ref;
1926
+ return id;
1927
+ }) : [];
1928
+ const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
1929
+ let {
1930
+ id
1931
+ } = _ref2;
1932
+ return id;
1933
+ }) : [];
1934
+ const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
1935
+ table.setRowPinning(old => {
1936
+ var _old$top3, _old$bottom3;
1937
+ if (position === 'bottom') {
1938
+ var _old$top, _old$bottom;
1939
+ return {
1940
+ top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter(d => !(rowIds != null && rowIds.has(d))),
1941
+ bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
1942
+ };
1943
+ }
1944
+ if (position === 'top') {
1945
+ var _old$top2, _old$bottom2;
1946
+ return {
1947
+ top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
1948
+ bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter(d => !(rowIds != null && rowIds.has(d)))
1949
+ };
1950
+ }
1951
+ return {
1952
+ top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter(d => !(rowIds != null && rowIds.has(d))),
1953
+ bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter(d => !(rowIds != null && rowIds.has(d)))
1954
+ };
1955
+ });
1956
+ };
1957
+ row.getCanPin = () => {
1958
+ var _ref3;
1959
+ const {
1960
+ enableRowPinning,
1961
+ enablePinning
1962
+ } = table.options;
1963
+ if (typeof enableRowPinning === 'function') {
1964
+ return enableRowPinning(row);
1965
+ }
1966
+ return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
1967
+ };
1968
+ row.getIsPinned = () => {
1969
+ const rowIds = [row.id];
1970
+ const {
1971
+ top,
1972
+ bottom
1973
+ } = table.getState().rowPinning;
1974
+ const isTop = rowIds.some(d => top == null ? void 0 : top.includes(d));
1975
+ const isBottom = rowIds.some(d => bottom == null ? void 0 : bottom.includes(d));
1976
+ return isTop ? 'top' : isBottom ? 'bottom' : false;
1977
+ };
1978
+ row.getPinnedIndex = () => {
1979
+ var _ref4, _visiblePinnedRowIds$;
1980
+ const position = row.getIsPinned();
1981
+ if (!position) return -1;
1982
+ const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
1983
+ let {
1984
+ id
1985
+ } = _ref5;
1986
+ return id;
1987
+ });
1988
+ return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
1989
+ };
1990
+ },
1991
+ createTable: table => {
1992
+ table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
1993
+ table.resetRowPinning = defaultState => {
1994
+ var _table$initialState$r, _table$initialState;
1995
+ return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
1996
+ };
1997
+ table.getIsSomeRowsPinned = position => {
1998
+ var _pinningState$positio;
1999
+ const pinningState = table.getState().rowPinning;
2000
+ if (!position) {
2001
+ var _pinningState$top, _pinningState$bottom;
2002
+ return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
2003
+ }
2004
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
2005
+ };
2006
+ table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
2007
+ var _table$options$keepPi;
2008
+ const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
2009
+ //get all rows that are pinned even if they would not be otherwise visible
2010
+ //account for expanded parent rows, but not pagination or filtering
2011
+ (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => {
2012
+ const row = table.getRow(rowId, true);
2013
+ return row.getIsAllParentsExpanded() ? row : null;
2014
+ }) :
2015
+ //else get only visible rows that are pinned
2016
+ (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => visibleRows.find(row => row.id === rowId));
2017
+ return rows.filter(Boolean).map(d => ({
2018
+ ...d,
2019
+ position
2020
+ }));
2021
+ };
2022
+ table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
2023
+ table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
2024
+ table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
2025
+ const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
2026
+ return allRows.filter(d => !topAndBottom.has(d.id));
2027
+ }, getMemoOptions(table.options, 'debugRows', 'getCenterRows'));
2028
+ }
2029
+ };
2030
+
2031
+ //
2032
+
2033
+ const RowSelection = {
2034
+ getInitialState: state => {
2035
+ return {
2036
+ rowSelection: {},
2037
+ ...state
2038
+ };
2039
+ },
2040
+ getDefaultOptions: table => {
2041
+ return {
2042
+ onRowSelectionChange: makeStateUpdater('rowSelection', table),
2043
+ enableRowSelection: true,
2044
+ enableMultiRowSelection: true,
2045
+ enableSubRowSelection: true
2046
+ // enableGroupingRowSelection: false,
2047
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
2048
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
2049
+ };
2050
+ },
2051
+ createTable: table => {
2052
+ table.setRowSelection = updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
2053
+ table.resetRowSelection = defaultState => {
2054
+ var _table$initialState$r;
2055
+ return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
2056
+ };
2057
+ table.toggleAllRowsSelected = value => {
2058
+ table.setRowSelection(old => {
2059
+ value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
2060
+ const rowSelection = {
2061
+ ...old
2062
+ };
2063
+ const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
2064
+
2065
+ // We don't use `mutateRowIsSelected` here for performance reasons.
2066
+ // All of the rows are flat already, so it wouldn't be worth it
2067
+ if (value) {
2068
+ preGroupedFlatRows.forEach(row => {
2069
+ if (!row.getCanSelect()) {
2070
+ return;
2071
+ }
2072
+ rowSelection[row.id] = true;
2073
+ });
2074
+ } else {
2075
+ preGroupedFlatRows.forEach(row => {
2076
+ delete rowSelection[row.id];
2077
+ });
2078
+ }
2079
+ return rowSelection;
2080
+ });
2081
+ };
2082
+ table.toggleAllPageRowsSelected = value => table.setRowSelection(old => {
2083
+ const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
2084
+ const rowSelection = {
2085
+ ...old
2086
+ };
2087
+ table.getRowModel().rows.forEach(row => {
2088
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
2089
+ });
2090
+ return rowSelection;
2091
+ });
2092
+
2093
+ // addRowSelectionRange: rowId => {
2094
+ // const {
2095
+ // rows,
2096
+ // rowsById,
2097
+ // options: { selectGroupingRows, selectSubRows },
2098
+ // } = table
2099
+
2100
+ // const findSelectedRow = (rows: Row[]) => {
2101
+ // let found
2102
+ // rows.find(d => {
2103
+ // if (d.getIsSelected()) {
2104
+ // found = d
2105
+ // return true
2106
+ // }
2107
+ // const subFound = findSelectedRow(d.subRows || [])
2108
+ // if (subFound) {
2109
+ // found = subFound
2110
+ // return true
2111
+ // }
2112
+ // return false
2113
+ // })
2114
+ // return found
2115
+ // }
2116
+
2117
+ // const firstRow = findSelectedRow(rows) || rows[0]
2118
+ // const lastRow = rowsById[rowId]
2119
+
2120
+ // let include = false
2121
+ // const selectedRowIds = {}
2122
+
2123
+ // const addRow = (row: Row) => {
2124
+ // mutateRowIsSelected(selectedRowIds, row.id, true, {
2125
+ // rowsById,
2126
+ // selectGroupingRows: selectGroupingRows!,
2127
+ // selectSubRows: selectSubRows!,
2128
+ // })
2129
+ // }
2130
+
2131
+ // table.rows.forEach(row => {
2132
+ // const isFirstRow = row.id === firstRow.id
2133
+ // const isLastRow = row.id === lastRow.id
2134
+
2135
+ // if (isFirstRow || isLastRow) {
2136
+ // if (!include) {
2137
+ // include = true
2138
+ // } else if (include) {
2139
+ // addRow(row)
2140
+ // include = false
2141
+ // }
2142
+ // }
2143
+
2144
+ // if (include) {
2145
+ // addRow(row)
2146
+ // }
2147
+ // })
2148
+
2149
+ // table.setRowSelection(selectedRowIds)
2150
+ // },
2151
+ table.getPreSelectedRowModel = () => table.getCoreRowModel();
2152
+ table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
2153
+ if (!Object.keys(rowSelection).length) {
2154
+ return {
2155
+ rows: [],
2156
+ flatRows: [],
2157
+ rowsById: {}
2158
+ };
2159
+ }
2160
+ return selectRowsFn(table, rowModel);
2161
+ }, getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel'));
2162
+ table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
2163
+ if (!Object.keys(rowSelection).length) {
2164
+ return {
2165
+ rows: [],
2166
+ flatRows: [],
2167
+ rowsById: {}
2168
+ };
2169
+ }
2170
+ return selectRowsFn(table, rowModel);
2171
+ }, getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel'));
2172
+ table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
2173
+ if (!Object.keys(rowSelection).length) {
2174
+ return {
2175
+ rows: [],
2176
+ flatRows: [],
2177
+ rowsById: {}
2178
+ };
2179
+ }
2180
+ return selectRowsFn(table, rowModel);
2181
+ }, getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel'));
2182
+
2183
+ ///
2184
+
2185
+ // getGroupingRowCanSelect: rowId => {
2186
+ // const row = table.getRow(rowId)
2187
+
2188
+ // if (!row) {
2189
+ // throw new Error()
2190
+ // }
2191
+
2192
+ // if (typeof table.options.enableGroupingRowSelection === 'function') {
2193
+ // return table.options.enableGroupingRowSelection(row)
2194
+ // }
2195
+
2196
+ // return table.options.enableGroupingRowSelection ?? false
2197
+ // },
2198
+
2199
+ table.getIsAllRowsSelected = () => {
2200
+ const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
2201
+ const {
2202
+ rowSelection
2203
+ } = table.getState();
2204
+ let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
2205
+ if (isAllRowsSelected) {
2206
+ if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
2207
+ isAllRowsSelected = false;
2208
+ }
2209
+ }
2210
+ return isAllRowsSelected;
2211
+ };
2212
+ table.getIsAllPageRowsSelected = () => {
2213
+ const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
2214
+ const {
2215
+ rowSelection
2216
+ } = table.getState();
2217
+ let isAllPageRowsSelected = !!paginationFlatRows.length;
2218
+ if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
2219
+ isAllPageRowsSelected = false;
2220
+ }
2221
+ return isAllPageRowsSelected;
2222
+ };
2223
+ table.getIsSomeRowsSelected = () => {
2224
+ var _table$getState$rowSe;
2225
+ const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2226
+ return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
2227
+ };
2228
+ table.getIsSomePageRowsSelected = () => {
2229
+ const paginationFlatRows = table.getPaginationRowModel().flatRows;
2230
+ return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
2231
+ };
2232
+ table.getToggleAllRowsSelectedHandler = () => {
2233
+ return e => {
2234
+ table.toggleAllRowsSelected(e.target.checked);
2235
+ };
2236
+ };
2237
+ table.getToggleAllPageRowsSelectedHandler = () => {
2238
+ return e => {
2239
+ table.toggleAllPageRowsSelected(e.target.checked);
2240
+ };
2241
+ };
2242
+ },
2243
+ createRow: (row, table) => {
2244
+ row.toggleSelected = (value, opts) => {
2245
+ const isSelected = row.getIsSelected();
2246
+ table.setRowSelection(old => {
2247
+ var _opts$selectChildren;
2248
+ value = typeof value !== 'undefined' ? value : !isSelected;
2249
+ if (row.getCanSelect() && isSelected === value) {
2250
+ return old;
2251
+ }
2252
+ const selectedRowIds = {
2253
+ ...old
2254
+ };
2255
+ mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
2256
+ return selectedRowIds;
2257
+ });
2258
+ };
2259
+ row.getIsSelected = () => {
2260
+ const {
2261
+ rowSelection
2262
+ } = table.getState();
2263
+ return isRowSelected(row, rowSelection);
2264
+ };
2265
+ row.getIsSomeSelected = () => {
2266
+ const {
2267
+ rowSelection
2268
+ } = table.getState();
2269
+ return isSubRowSelected(row, rowSelection) === 'some';
2270
+ };
2271
+ row.getIsAllSubRowsSelected = () => {
2272
+ const {
2273
+ rowSelection
2274
+ } = table.getState();
2275
+ return isSubRowSelected(row, rowSelection) === 'all';
2276
+ };
2277
+ row.getCanSelect = () => {
2278
+ var _table$options$enable;
2279
+ if (typeof table.options.enableRowSelection === 'function') {
2280
+ return table.options.enableRowSelection(row);
2281
+ }
2282
+ return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
2283
+ };
2284
+ row.getCanSelectSubRows = () => {
2285
+ var _table$options$enable2;
2286
+ if (typeof table.options.enableSubRowSelection === 'function') {
2287
+ return table.options.enableSubRowSelection(row);
2288
+ }
2289
+ return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
2290
+ };
2291
+ row.getCanMultiSelect = () => {
2292
+ var _table$options$enable3;
2293
+ if (typeof table.options.enableMultiRowSelection === 'function') {
2294
+ return table.options.enableMultiRowSelection(row);
2295
+ }
2296
+ return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
2297
+ };
2298
+ row.getToggleSelectedHandler = () => {
2299
+ const canSelect = row.getCanSelect();
2300
+ return e => {
2301
+ var _target;
2302
+ if (!canSelect) return;
2303
+ row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2304
+ };
2305
+ };
2306
+ }
2307
+ };
2308
+ const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
2309
+ var _row$subRows;
2310
+ const row = table.getRow(id, true);
2311
+
2312
+ // const isGrouped = row.getIsGrouped()
2313
+
2314
+ // if ( // TODO: enforce grouping row selection rules
2315
+ // !isGrouped ||
2316
+ // (isGrouped && table.options.enableGroupingRowSelection)
2317
+ // ) {
2318
+ if (value) {
2319
+ if (!row.getCanMultiSelect()) {
2320
+ Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
2321
+ }
2322
+ if (row.getCanSelect()) {
2323
+ selectedRowIds[id] = true;
2324
+ }
2325
+ } else {
2326
+ delete selectedRowIds[id];
2327
+ }
2328
+ // }
2329
+
2330
+ if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2331
+ row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
2332
+ }
2333
+ };
2334
+ function selectRowsFn(table, rowModel) {
2335
+ const rowSelection = table.getState().rowSelection;
2336
+ const newSelectedFlatRows = [];
2337
+ const newSelectedRowsById = {};
2338
+
2339
+ // Filters top level and nested rows
2340
+ const recurseRows = function (rows, depth) {
2341
+ return rows.map(row => {
2342
+ var _row$subRows2;
2343
+ const isSelected = isRowSelected(row, rowSelection);
2344
+ if (isSelected) {
2345
+ newSelectedFlatRows.push(row);
2346
+ newSelectedRowsById[row.id] = row;
2347
+ }
2348
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2349
+ row = {
2350
+ ...row,
2351
+ subRows: recurseRows(row.subRows)
2352
+ };
2353
+ }
2354
+ if (isSelected) {
2355
+ return row;
2356
+ }
2357
+ }).filter(Boolean);
2358
+ };
2359
+ return {
2360
+ rows: recurseRows(rowModel.rows),
2361
+ flatRows: newSelectedFlatRows,
2362
+ rowsById: newSelectedRowsById
2363
+ };
2364
+ }
2365
+ function isRowSelected(row, selection) {
2366
+ var _selection$row$id;
2367
+ return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
2368
+ }
2369
+ function isSubRowSelected(row, selection, table) {
2370
+ var _row$subRows3;
2371
+ if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
2372
+ let allChildrenSelected = true;
2373
+ let someSelected = false;
2374
+ row.subRows.forEach(subRow => {
2375
+ // Bail out early if we know both of these
2376
+ if (someSelected && !allChildrenSelected) {
2377
+ return;
2378
+ }
2379
+ if (subRow.getCanSelect()) {
2380
+ if (isRowSelected(subRow, selection)) {
2381
+ someSelected = true;
2382
+ } else {
2383
+ allChildrenSelected = false;
2384
+ }
2385
+ }
2386
+
2387
+ // Check row selection of nested subrows
2388
+ if (subRow.subRows && subRow.subRows.length) {
2389
+ const subRowChildrenSelected = isSubRowSelected(subRow, selection);
2390
+ if (subRowChildrenSelected === 'all') {
2391
+ someSelected = true;
2392
+ } else if (subRowChildrenSelected === 'some') {
2393
+ someSelected = true;
2394
+ allChildrenSelected = false;
2395
+ } else {
2396
+ allChildrenSelected = false;
2397
+ }
2398
+ }
2399
+ });
2400
+ return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
2401
+ }
2402
+
2403
+ const reSplitAlphaNumeric = /([0-9]+)/gm;
2404
+ const alphanumeric = (rowA, rowB, columnId) => {
2405
+ return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2406
+ };
2407
+ const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
2408
+ return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2409
+ };
2410
+
2411
+ // The text filter is more basic (less numeric support)
2412
+ // but is much faster
2413
+ const text = (rowA, rowB, columnId) => {
2414
+ return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2415
+ };
2416
+
2417
+ // The text filter is more basic (less numeric support)
2418
+ // but is much faster
2419
+ const textCaseSensitive = (rowA, rowB, columnId) => {
2420
+ return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2421
+ };
2422
+ const datetime = (rowA, rowB, columnId) => {
2423
+ const a = rowA.getValue(columnId);
2424
+ const b = rowB.getValue(columnId);
2425
+
2426
+ // Can handle nullish values
2427
+ // Use > and < because == (and ===) doesn't work with
2428
+ // Date objects (would require calling getTime()).
2429
+ return a > b ? 1 : a < b ? -1 : 0;
2430
+ };
2431
+ const basic = (rowA, rowB, columnId) => {
2432
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2433
+ };
2434
+
2435
+ // Utils
2436
+
2437
+ function compareBasic(a, b) {
2438
+ return a === b ? 0 : a > b ? 1 : -1;
2439
+ }
2440
+ function toString(a) {
2441
+ if (typeof a === 'number') {
2442
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
2443
+ return '';
2444
+ }
2445
+ return String(a);
2446
+ }
2447
+ if (typeof a === 'string') {
2448
+ return a;
2449
+ }
2450
+ return '';
2451
+ }
2452
+
2453
+ // Mixed sorting is slow, but very inclusive of many edge cases.
2454
+ // It handles numbers, mixed alphanumeric combinations, and even
2455
+ // null, undefined, and Infinity
2456
+ function compareAlphanumeric(aStr, bStr) {
2457
+ // Split on number groups, but keep the delimiter
2458
+ // Then remove falsey split values
2459
+ const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2460
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
2461
+
2462
+ // While
2463
+ while (a.length && b.length) {
2464
+ const aa = a.shift();
2465
+ const bb = b.shift();
2466
+ const an = parseInt(aa, 10);
2467
+ const bn = parseInt(bb, 10);
2468
+ const combo = [an, bn].sort();
2469
+
2470
+ // Both are string
2471
+ if (isNaN(combo[0])) {
2472
+ if (aa > bb) {
2473
+ return 1;
2474
+ }
2475
+ if (bb > aa) {
2476
+ return -1;
2477
+ }
2478
+ continue;
2479
+ }
2480
+
2481
+ // One is a string, one is a number
2482
+ if (isNaN(combo[1])) {
2483
+ return isNaN(an) ? -1 : 1;
2484
+ }
2485
+
2486
+ // Both are numbers
2487
+ if (an > bn) {
2488
+ return 1;
2489
+ }
2490
+ if (bn > an) {
2491
+ return -1;
2492
+ }
2493
+ }
2494
+ return a.length - b.length;
2495
+ }
2496
+
2497
+ // Exports
2498
+
2499
+ const sortingFns = {
2500
+ alphanumeric,
2501
+ alphanumericCaseSensitive,
2502
+ text,
2503
+ textCaseSensitive,
2504
+ datetime,
2505
+ basic
2506
+ };
2507
+
2508
+ //
2509
+
2510
+ const RowSorting = {
2511
+ getInitialState: state => {
2512
+ return {
2513
+ sorting: [],
2514
+ ...state
2515
+ };
2516
+ },
2517
+ getDefaultColumnDef: () => {
2518
+ return {
2519
+ sortingFn: 'auto',
2520
+ sortUndefined: 1
2521
+ };
2522
+ },
2523
+ getDefaultOptions: table => {
2524
+ return {
2525
+ onSortingChange: makeStateUpdater('sorting', table),
2526
+ isMultiSortEvent: e => {
2527
+ return e.shiftKey;
2528
+ }
2529
+ };
2530
+ },
2531
+ createColumn: (column, table) => {
2532
+ column.getAutoSortingFn = () => {
2533
+ const firstRows = table.getFilteredRowModel().flatRows.slice(10);
2534
+ let isString = false;
2535
+ for (const row of firstRows) {
2536
+ const value = row == null ? void 0 : row.getValue(column.id);
2537
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2538
+ return sortingFns.datetime;
2539
+ }
2540
+ if (typeof value === 'string') {
2541
+ isString = true;
2542
+ if (value.split(reSplitAlphaNumeric).length > 1) {
2543
+ return sortingFns.alphanumeric;
2544
+ }
2545
+ }
2546
+ }
2547
+ if (isString) {
2548
+ return sortingFns.text;
2549
+ }
2550
+ return sortingFns.basic;
2551
+ };
2552
+ column.getAutoSortDir = () => {
2553
+ const firstRow = table.getFilteredRowModel().flatRows[0];
2554
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2555
+ if (typeof value === 'string') {
2556
+ return 'asc';
2557
+ }
2558
+ return 'desc';
2559
+ };
2560
+ column.getSortingFn = () => {
2561
+ var _table$options$sortin, _table$options$sortin2;
2562
+ if (!column) {
2563
+ throw new Error();
2564
+ }
2565
+ return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
2566
+ };
2567
+ column.toggleSorting = (desc, multi) => {
2568
+ // if (column.columns.length) {
2569
+ // column.columns.forEach((c, i) => {
2570
+ // if (c.id) {
2571
+ // table.toggleColumnSorting(c.id, undefined, multi || !!i)
2572
+ // }
2573
+ // })
2574
+ // return
2575
+ // }
2576
+
2577
+ // this needs to be outside of table.setSorting to be in sync with rerender
2578
+ const nextSortingOrder = column.getNextSortingOrder();
2579
+ const hasManualValue = typeof desc !== 'undefined' && desc !== null;
2580
+ table.setSorting(old => {
2581
+ // Find any existing sorting for this column
2582
+ const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2583
+ const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2584
+ let newSorting = [];
2585
+
2586
+ // What should we do with this sort action?
2587
+ let sortAction;
2588
+ let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
2589
+
2590
+ // Multi-mode
2591
+ if (old != null && old.length && column.getCanMultiSort() && multi) {
2592
+ if (existingSorting) {
2593
+ sortAction = 'toggle';
2594
+ } else {
2595
+ sortAction = 'add';
2596
+ }
2597
+ } else {
2598
+ // Normal mode
2599
+ if (old != null && old.length && existingIndex !== old.length - 1) {
2600
+ sortAction = 'replace';
2601
+ } else if (existingSorting) {
2602
+ sortAction = 'toggle';
2603
+ } else {
2604
+ sortAction = 'replace';
2605
+ }
2606
+ }
2607
+
2608
+ // Handle toggle states that will remove the sorting
2609
+ if (sortAction === 'toggle') {
2610
+ // If we are "actually" toggling (not a manual set value), should we remove the sorting?
2611
+ if (!hasManualValue) {
2612
+ // Is our intention to remove?
2613
+ if (!nextSortingOrder) {
2614
+ sortAction = 'remove';
2615
+ }
2616
+ }
2617
+ }
2618
+ if (sortAction === 'add') {
2619
+ var _table$options$maxMul;
2620
+ newSorting = [...old, {
2621
+ id: column.id,
2622
+ desc: nextDesc
2623
+ }];
2624
+ // Take latest n columns
2625
+ newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
2626
+ } else if (sortAction === 'toggle') {
2627
+ // This flips (or sets) the
2628
+ newSorting = old.map(d => {
2629
+ if (d.id === column.id) {
2630
+ return {
2631
+ ...d,
2632
+ desc: nextDesc
2633
+ };
2634
+ }
2635
+ return d;
2636
+ });
2637
+ } else if (sortAction === 'remove') {
2638
+ newSorting = old.filter(d => d.id !== column.id);
2639
+ } else {
2640
+ newSorting = [{
2641
+ id: column.id,
2642
+ desc: nextDesc
2643
+ }];
2644
+ }
2645
+ return newSorting;
2646
+ });
2647
+ };
2648
+ column.getFirstSortDir = () => {
2649
+ var _ref, _column$columnDef$sor;
2650
+ const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
2651
+ return sortDescFirst ? 'desc' : 'asc';
2652
+ };
2653
+ column.getNextSortingOrder = multi => {
2654
+ var _table$options$enable, _table$options$enable2;
2655
+ const firstSortDirection = column.getFirstSortDir();
2656
+ const isSorted = column.getIsSorted();
2657
+ if (!isSorted) {
2658
+ return firstSortDirection;
2659
+ }
2660
+ if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && (
2661
+ // If enableSortRemove, enable in general
2662
+ multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
2663
+ ) {
2664
+ return false;
2665
+ }
2666
+ return isSorted === 'desc' ? 'asc' : 'desc';
2667
+ };
2668
+ column.getCanSort = () => {
2669
+ var _column$columnDef$ena, _table$options$enable3;
2670
+ return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
2671
+ };
2672
+ column.getCanMultiSort = () => {
2673
+ var _ref2, _column$columnDef$ena2;
2674
+ return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
2675
+ };
2676
+ column.getIsSorted = () => {
2677
+ var _table$getState$sorti;
2678
+ const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
2679
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2680
+ };
2681
+ column.getSortIndex = () => {
2682
+ var _table$getState$sorti2, _table$getState$sorti3;
2683
+ return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex(d => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
2684
+ };
2685
+ column.clearSorting = () => {
2686
+ //clear sorting for just 1 column
2687
+ table.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
2688
+ };
2689
+ column.getToggleSortingHandler = () => {
2690
+ const canSort = column.getCanSort();
2691
+ return e => {
2692
+ if (!canSort) return;
2693
+ e.persist == null || e.persist();
2694
+ column.toggleSorting == null || column.toggleSorting(undefined, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
2695
+ };
2696
+ };
2697
+ },
2698
+ createTable: table => {
2699
+ table.setSorting = updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
2700
+ table.resetSorting = defaultState => {
2701
+ var _table$initialState$s, _table$initialState;
2702
+ table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
2703
+ };
2704
+ table.getPreSortedRowModel = () => table.getGroupedRowModel();
2705
+ table.getSortedRowModel = () => {
2706
+ if (!table._getSortedRowModel && table.options.getSortedRowModel) {
2707
+ table._getSortedRowModel = table.options.getSortedRowModel(table);
2708
+ }
2709
+ if (table.options.manualSorting || !table._getSortedRowModel) {
2710
+ return table.getPreSortedRowModel();
2711
+ }
2712
+ return table._getSortedRowModel();
2713
+ };
2714
+ }
2715
+ };
2716
+
2717
+ const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
2718
+ //depends on ColumnFaceting
2719
+ GlobalFiltering,
2720
+ //depends on ColumnFiltering
2721
+ RowSorting, ColumnGrouping,
2722
+ //depends on RowSorting
2723
+ RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
2724
+
2725
+ //
2726
+
2727
+ function createTable(options) {
2728
+ var _options$_features, _options$initialState;
2729
+ if (process.env.NODE_ENV !== 'production' && (options.debugAll || options.debugTable)) {
2730
+ console.info('Creating Table Instance...');
2731
+ }
2732
+ const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
2733
+ let table = {
2734
+ _features
2735
+ };
2736
+ const defaultOptions = table._features.reduce((obj, feature) => {
2737
+ return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
2738
+ }, {});
2739
+ const mergeOptions = options => {
2740
+ if (table.options.mergeOptions) {
2741
+ return table.options.mergeOptions(defaultOptions, options);
2742
+ }
2743
+ return {
2744
+ ...defaultOptions,
2745
+ ...options
2746
+ };
2747
+ };
2748
+ const coreInitialState = {};
2749
+ let initialState = {
2750
+ ...coreInitialState,
2751
+ ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
2752
+ };
2753
+ table._features.forEach(feature => {
2754
+ var _feature$getInitialSt;
2755
+ initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
2756
+ });
2757
+ const queued = [];
2758
+ let queuedTimeout = false;
2759
+ const coreInstance = {
2760
+ _features,
2761
+ options: {
2762
+ ...defaultOptions,
2763
+ ...options
2764
+ },
2765
+ initialState,
2766
+ _queue: cb => {
2767
+ queued.push(cb);
2768
+ if (!queuedTimeout) {
2769
+ queuedTimeout = true;
2770
+
2771
+ // Schedule a microtask to run the queued callbacks after
2772
+ // the current call stack (render, etc) has finished.
2773
+ Promise.resolve().then(() => {
2774
+ while (queued.length) {
2775
+ queued.shift()();
2776
+ }
2777
+ queuedTimeout = false;
2778
+ }).catch(error => setTimeout(() => {
2779
+ throw error;
2780
+ }));
2781
+ }
2782
+ },
2783
+ reset: () => {
2784
+ table.setState(table.initialState);
2785
+ },
2786
+ setOptions: updater => {
2787
+ const newOptions = functionalUpdate(updater, table.options);
2788
+ table.options = mergeOptions(newOptions);
2789
+ },
2790
+ getState: () => {
2791
+ return table.options.state;
2792
+ },
2793
+ setState: updater => {
2794
+ table.options.onStateChange == null || table.options.onStateChange(updater);
2795
+ },
2796
+ _getRowId: (row, index, parent) => {
2797
+ var _table$options$getRow;
2798
+ return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : `${parent ? [parent.id, index].join('.') : index}`;
2799
+ },
2800
+ getCoreRowModel: () => {
2801
+ if (!table._getCoreRowModel) {
2802
+ table._getCoreRowModel = table.options.getCoreRowModel(table);
2803
+ }
2804
+ return table._getCoreRowModel();
2805
+ },
2806
+ // The final calls start at the bottom of the model,
2807
+ // expanded rows, which then work their way up
2808
+
2809
+ getRowModel: () => {
2810
+ return table.getPaginationRowModel();
2811
+ },
2812
+ //in next version, we should just pass in the row model as the optional 2nd arg
2813
+ getRow: (id, searchAll) => {
2814
+ let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
2815
+ if (!row) {
2816
+ row = table.getCoreRowModel().rowsById[id];
2817
+ if (!row) {
2818
+ if (process.env.NODE_ENV !== 'production') {
2819
+ throw new Error(`getRow could not find row with ID: ${id}`);
2820
+ }
2821
+ throw new Error();
2822
+ }
2823
+ }
2824
+ return row;
2825
+ },
2826
+ _getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
2827
+ var _defaultColumn;
2828
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2829
+ return {
2830
+ header: props => {
2831
+ const resolvedColumnDef = props.header.column.columnDef;
2832
+ if (resolvedColumnDef.accessorKey) {
2833
+ return resolvedColumnDef.accessorKey;
2834
+ }
2835
+ if (resolvedColumnDef.accessorFn) {
2836
+ return resolvedColumnDef.id;
2837
+ }
2838
+ return null;
2839
+ },
2840
+ // footer: props => props.header.column.id,
2841
+ cell: props => {
2842
+ var _props$renderValue$to, _props$renderValue;
2843
+ return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
2844
+ },
2845
+ ...table._features.reduce((obj, feature) => {
2846
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2847
+ }, {}),
2848
+ ...defaultColumn
2849
+ };
2850
+ }, getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')),
2851
+ _getColumnDefs: () => table.options.columns,
2852
+ getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
2853
+ const recurseColumns = function (columnDefs, parent, depth) {
2854
+ if (depth === void 0) {
2855
+ depth = 0;
2856
+ }
2857
+ return columnDefs.map(columnDef => {
2858
+ const column = createColumn(table, columnDef, depth, parent);
2859
+ const groupingColumnDef = columnDef;
2860
+ column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
2861
+ return column;
2862
+ });
2863
+ };
2864
+ return recurseColumns(columnDefs);
2865
+ }, getMemoOptions(options, 'debugColumns', 'getAllColumns')),
2866
+ getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
2867
+ return allColumns.flatMap(column => {
2868
+ return column.getFlatColumns();
2869
+ });
2870
+ }, getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')),
2871
+ _getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
2872
+ return flatColumns.reduce((acc, column) => {
2873
+ acc[column.id] = column;
2874
+ return acc;
2875
+ }, {});
2876
+ }, getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')),
2877
+ getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
2878
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2879
+ return orderColumns(leafColumns);
2880
+ }, getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')),
2881
+ getColumn: columnId => {
2882
+ const column = table._getAllFlatColumnsById()[columnId];
2883
+ if (process.env.NODE_ENV !== 'production' && !column) {
2884
+ console.error(`[Table] Column with id '${columnId}' does not exist.`);
2885
+ }
2886
+ return column;
2887
+ }
2888
+ };
2889
+ Object.assign(table, coreInstance);
2890
+ for (let index = 0; index < table._features.length; index++) {
2891
+ const feature = table._features[index];
2892
+ feature == null || feature.createTable == null || feature.createTable(table);
2893
+ }
2894
+ return table;
2895
+ }
2896
+
2897
+ function getCoreRowModel() {
2898
+ return table => memo(() => [table.options.data], data => {
2899
+ const rowModel = {
2900
+ rows: [],
2901
+ flatRows: [],
2902
+ rowsById: {}
2903
+ };
2904
+ const accessRows = function (originalRows, depth, parentRow) {
2905
+ if (depth === void 0) {
2906
+ depth = 0;
2907
+ }
2908
+ const rows = [];
2909
+ for (let i = 0; i < originalRows.length; i++) {
2910
+ // This could be an expensive check at scale, so we should move it somewhere else, but where?
2911
+ // if (!id) {
2912
+ // if (process.env.NODE_ENV !== 'production') {
2913
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
2914
+ // }
2915
+ // }
2916
+
2917
+ // Make the row
2918
+ const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
2919
+
2920
+ // Keep track of every row in a flat array
2921
+ rowModel.flatRows.push(row);
2922
+ // Also keep track of every row by its ID
2923
+ rowModel.rowsById[row.id] = row;
2924
+ // Push table row into parent
2925
+ rows.push(row);
2926
+
2927
+ // Get the original subrows
2928
+ if (table.options.getSubRows) {
2929
+ var _row$originalSubRows;
2930
+ row.originalSubRows = table.options.getSubRows(originalRows[i], i);
2931
+
2932
+ // Then recursively access them
2933
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
2934
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
2935
+ }
2936
+ }
2937
+ }
2938
+ return rows;
2939
+ };
2940
+ rowModel.rows = accessRows(data);
2941
+ return rowModel;
2942
+ }, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
2943
+ }
2944
+
2945
+ function getExpandedRowModel() {
2946
+ return table => memo(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
2947
+ if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
2948
+ return rowModel;
2949
+ }
2950
+ if (!paginateExpandedRows) {
2951
+ // Only expand rows at this point if they are being paginated
2952
+ return rowModel;
2953
+ }
2954
+ return expandRows(rowModel);
2955
+ }, getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel'));
2956
+ }
2957
+ function expandRows(rowModel) {
2958
+ const expandedRows = [];
2959
+ const handleRow = row => {
2960
+ var _row$subRows;
2961
+ expandedRows.push(row);
2962
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
2963
+ row.subRows.forEach(handleRow);
2964
+ }
2965
+ };
2966
+ rowModel.rows.forEach(handleRow);
2967
+ return {
2968
+ rows: expandedRows,
2969
+ flatRows: rowModel.flatRows,
2970
+ rowsById: rowModel.rowsById
2971
+ };
2972
+ }
2973
+
2974
+ function getPaginationRowModel(opts) {
2975
+ return table => memo(() => [table.getState().pagination, table.getPrePaginationRowModel(), table.options.paginateExpandedRows ? undefined : table.getState().expanded], (pagination, rowModel) => {
2976
+ if (!rowModel.rows.length) {
2977
+ return rowModel;
2978
+ }
2979
+ const {
2980
+ pageSize,
2981
+ pageIndex
2982
+ } = pagination;
2983
+ let {
2984
+ rows,
2985
+ flatRows,
2986
+ rowsById
2987
+ } = rowModel;
2988
+ const pageStart = pageSize * pageIndex;
2989
+ const pageEnd = pageStart + pageSize;
2990
+ rows = rows.slice(pageStart, pageEnd);
2991
+ let paginatedRowModel;
2992
+ if (!table.options.paginateExpandedRows) {
2993
+ paginatedRowModel = expandRows({
2994
+ rows,
2995
+ flatRows,
2996
+ rowsById
2997
+ });
2998
+ } else {
2999
+ paginatedRowModel = {
3000
+ rows,
3001
+ flatRows,
3002
+ rowsById
3003
+ };
3004
+ }
3005
+ paginatedRowModel.flatRows = [];
3006
+ const handleRow = row => {
3007
+ paginatedRowModel.flatRows.push(row);
3008
+ if (row.subRows.length) {
3009
+ row.subRows.forEach(handleRow);
3010
+ }
3011
+ };
3012
+ paginatedRowModel.rows.forEach(handleRow);
3013
+ return paginatedRowModel;
3014
+ }, getMemoOptions(table.options, 'debugTable', 'getPaginationRowModel'));
3015
+ }
3016
+
3017
+ /**
3018
+ * react-table
3019
+ *
3020
+ * Copyright (c) TanStack
3021
+ *
3022
+ * This source code is licensed under the MIT license found in the
3023
+ * LICENSE.md file in the root directory of this source tree.
3024
+ *
3025
+ * @license MIT
3026
+ */
3027
+
3028
+ //
3029
+
3030
+ /**
3031
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
3032
+ */
3033
+ function flexRender(Comp, props) {
3034
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React.createElement(Comp, props) : Comp;
3035
+ }
3036
+ function isReactComponent(component) {
3037
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
3038
+ }
3039
+ function isClassComponent(component) {
3040
+ return typeof component === 'function' && (() => {
3041
+ const proto = Object.getPrototypeOf(component);
3042
+ return proto.prototype && proto.prototype.isReactComponent;
3043
+ })();
3044
+ }
3045
+ function isExoticComponent(component) {
3046
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
3047
+ }
3048
+ function useReactTable(options) {
3049
+ // Compose in the generic options to the user options
3050
+ const resolvedOptions = {
3051
+ state: {},
3052
+ // Dummy state
3053
+ onStateChange: () => {},
3054
+ // noop
3055
+ renderFallbackValue: null,
3056
+ ...options
3057
+ };
3058
+
3059
+ // Create a new table and store it in state
3060
+ const [tableRef] = React.useState(() => ({
3061
+ current: createTable(resolvedOptions)
3062
+ }));
3063
+
3064
+ // By default, manage table state here using the table's initial state
3065
+ const [state, setState] = React.useState(() => tableRef.current.initialState);
3066
+
3067
+ // Compose the default state above with any user state. This will allow the user
3068
+ // to only control a subset of the state if desired.
3069
+ tableRef.current.setOptions(prev => ({
3070
+ ...prev,
3071
+ ...options,
3072
+ state: {
3073
+ ...state,
3074
+ ...options.state
3075
+ },
3076
+ // Similarly, we'll maintain both our internal state and any user-provided
3077
+ // state.
3078
+ onStateChange: updater => {
3079
+ setState(updater);
3080
+ options.onStateChange == null || options.onStateChange(updater);
3081
+ }
3082
+ }));
3083
+ return tableRef.current;
3084
+ }
3085
+
3086
+ var css_248z$6 = ".tableBodyCell{border-bottom:var(--guit-ref-border-width-thin) solid var(--guit-sem-color-border-neutral-1);height:4.4rem;padding-block:var(--guit-ref-spacing-medium);padding-inline:var(--guit-ref-spacing-large);vertical-align:middle}.tableBodyCell:not(:last-child){-webkit-border-end:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-2);border-inline-end:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-2)}.tableBodyCell__content{align-items:center;display:flex;gap:var(--guit-ref-spacing-3xsmall)}.tableBodyCell__text{-webkit-line-clamp:4;-webkit-box-orient:vertical;color:var(--guit-sem-color-foreground-neutral-2);display:-webkit-box;overflow:hidden}.tableBodyCell:hover .tableRow__actionsWrapper,.tableBodyCell_active .tableRow__actionsWrapper{opacity:1}";
3087
+ styleInject(css_248z$6);
3088
+
3089
+ /**
3090
+ * Renders an individual table body cell (`<td>`).
3091
+ * This component acts as a wrapper that uses TanStack Table's `flexRender`
3092
+ * utility to evaluate and render the appropriate content based on the
3093
+ * specific column definitions.
3094
+ *
3095
+ * @template TData - The shape of the overall row data object.
3096
+ * @template TValue - The type of the specific value held within this cell.
3097
+ * @param props - The properties for the component.
3098
+ * @returns A table cell element with the rendered content.
3099
+ */
3100
+ const TableBodyCell = ({ cell }) => {
3101
+ return (React__default.createElement("td", { className: "tableBodyCell", style: {
3102
+ width: cell.column.getSize(),
3103
+ minWidth: cell.column.getSize()
3104
+ } },
3105
+ React__default.createElement("div", { className: "tableBodyCell__content" }, flexRender(cell.column.columnDef.cell, cell.getContext()))));
3106
+ };
3107
+ const areCellsEqual = (prevProps, nextProps) => {
3108
+ // Expander cell must re-render on every row expand/collapse state change.
3109
+ if (prevProps.cell.column.id === "expander" || nextProps.cell.column.id === "expander")
3110
+ return false;
3111
+ return (prevProps.cell.id === nextProps.cell.id &&
3112
+ prevProps.cell.getValue() === nextProps.cell.getValue() &&
3113
+ prevProps.cell.column.getSize() === nextProps.cell.column.getSize());
3114
+ };
3115
+ const MemoizedTableBodyCell = memo$1(TableBodyCell, areCellsEqual);
3116
+
3117
+ var css_248z$5 = ".tableExpandedRow{background-color:var(--guit-sem-color-background-neutral-2);display:table-row;position:relative;width:100%}.tableExpandedRow .tableExpandedCell{padding:var(--guit-ref-spacing-large)}";
3118
+ styleInject(css_248z$5);
3119
+
3120
+ var css_248z$4 = ".tableRow{display:table-row;position:relative;width:100%}.tableRow:active{background-color:var(--guit-sem-color-background-neutral-3-pressed)}.tableRow:nth-child(2n){background-color:var(--guit-sem-color-background-neutral-3)}.tableRow:nth-child(odd){background-color:var(--guit-sem-color-background-neutral-1)}@media screen and (hover:hover){.tableRow:hover{background-color:var(--guit-sem-color-background-neutral-3-hover)}.tableRow:hover .tableRow__actionsWrapper{opacity:1;pointer-events:auto;visibility:visible}}.tableRow__actionsWrapper{border-bottom:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-1);inset-inline-end:0;opacity:0;pointer-events:none;position:-webkit-sticky;position:sticky;top:0;visibility:hidden;white-space:nowrap;width:1%;z-index:2}.tableRow__actions{align-items:center;background-color:var(--guit-sem-color-background-neutral-3-hover);column-gap:var(--guit-ref-spacing-3xsmall);display:flex;inset-block:0;inset-inline-end:0;padding:var(--guit-ref-spacing-small) var(--guit-ref-spacing-large);position:absolute}.tableRow__actions:after{content:\"\";inset-block:0;pointer-events:none;position:absolute;width:.4rem}[dir=ltr] .tableRow__actions:after{background:linear-gradient(to left,var(--guit-sem-color-raised-top-rgba),#0000);right:100%}[dir=rtl] .tableRow__actions:after{background:linear-gradient(to right,var(--guit-sem-color-raised-top-rgba),#0000);left:100%}";
3121
+ styleInject(css_248z$4);
3122
+
3123
+ var css_248z$3 = ".tableBody{display:table-row-group;width:100%}.tableBody__emptyBody{align-items:center;display:flex;inset:0;justify-content:center;position:fixed}";
3124
+ styleInject(css_248z$3);
3125
+
3126
+ var css_248z$2 = ".tableHeaderCell{border-bottom:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-1);height:4rem;padding-block:var(--guit-ref-spacing-xsmall);padding-inline:var(--guit-ref-spacing-large);vertical-align:middle}.tableHeaderCell:not(:last-child){-webkit-border-end:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-2);border-inline-end:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-neutral-2)}.tableHeaderCell__content{align-items:center;display:flex;gap:var(--guit-ref-spacing-xsmall)}.tableHeaderCell__text{color:var(--guit-sem-color-foreground-neutral-2)}";
3127
+ styleInject(css_248z$2);
3128
+
3129
+ var css_248z$1 = ".tableHeader{width:100%}.tableHeader__sticky{position:-webkit-sticky;position:sticky;top:0;z-index:1}.tableHeader__row{background-color:var(--guit-sem-color-background-neutral-4);position:relative;width:100%}";
3130
+ styleInject(css_248z$1);
3131
+
3132
+ var css_248z = ".dataTable{display:flex;flex-direction:column;height:100%;max-width:100%;overflow-x:auto;will-change:transform}.dataTable__table{border-collapse:initial;display:table;isolation:isolate;table-layout:auto;width:100%}.dataTable__noDataToDisplay{height:100%}";
3133
+ styleInject(css_248z);
3134
+
3135
+ export { MemoizedTableBodyCell as M, getPaginationRowModel as a, getExpandedRowModel as b, flexRender as f, getCoreRowModel as g, useReactTable as u };