tmo-ui-components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3675 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+
6
+ function _interopNamespaceDefault(e) {
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
24
+
25
+ const variantStyles$1 = {
26
+ primary: {
27
+ backgroundColor: '#e20074',
28
+ color: '#ffffff',
29
+ border: 'none',
30
+ },
31
+ secondary: {
32
+ backgroundColor: '#6c757d',
33
+ color: '#ffffff',
34
+ border: 'none',
35
+ },
36
+ outline: {
37
+ backgroundColor: 'transparent',
38
+ color: '#e20074',
39
+ border: '2px solid #e20074',
40
+ },
41
+ ghost: {
42
+ backgroundColor: 'transparent',
43
+ color: '#e20074',
44
+ border: 'none',
45
+ },
46
+ };
47
+ const sizeStyles$1 = {
48
+ sm: {
49
+ padding: '8px 16px',
50
+ fontSize: '14px',
51
+ },
52
+ md: {
53
+ padding: '12px 24px',
54
+ fontSize: '16px',
55
+ },
56
+ lg: {
57
+ padding: '16px 32px',
58
+ fontSize: '18px',
59
+ },
60
+ };
61
+ const Button = ({ children, variant = 'primary', size = 'md', isLoading = false, fullWidth = false, disabled, style, ...props }) => {
62
+ const baseStyles = {
63
+ borderRadius: '8px',
64
+ fontWeight: 600,
65
+ cursor: disabled || isLoading ? 'not-allowed' : 'pointer',
66
+ opacity: disabled || isLoading ? 0.6 : 1,
67
+ transition: 'all 0.2s ease-in-out',
68
+ display: 'inline-flex',
69
+ alignItems: 'center',
70
+ justifyContent: 'center',
71
+ gap: '8px',
72
+ width: fullWidth ? '100%' : 'auto',
73
+ ...variantStyles$1[variant],
74
+ ...sizeStyles$1[size],
75
+ ...style,
76
+ };
77
+ return (jsxRuntime.jsxs("button", { style: baseStyles, disabled: disabled || isLoading, ...props, children: [isLoading && (jsxRuntime.jsx("span", { style: {
78
+ width: '16px',
79
+ height: '16px',
80
+ border: '2px solid currentColor',
81
+ borderTopColor: 'transparent',
82
+ borderRadius: '50%',
83
+ animation: 'spin 1s linear infinite',
84
+ } })), children] }));
85
+ };
86
+
87
+ const variantStyles = {
88
+ elevated: {
89
+ backgroundColor: '#ffffff',
90
+ boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
91
+ border: 'none',
92
+ },
93
+ outlined: {
94
+ backgroundColor: '#ffffff',
95
+ boxShadow: 'none',
96
+ border: '1px solid #e5e7eb',
97
+ },
98
+ filled: {
99
+ backgroundColor: '#f9fafb',
100
+ boxShadow: 'none',
101
+ border: 'none',
102
+ },
103
+ };
104
+ const paddingStyles = {
105
+ none: '0',
106
+ sm: '12px',
107
+ md: '16px',
108
+ lg: '24px',
109
+ };
110
+ const Card = ({ children, variant = 'elevated', padding = 'md', hoverable = false, style, ...props }) => {
111
+ const baseStyles = {
112
+ borderRadius: '12px',
113
+ overflow: 'hidden',
114
+ transition: 'all 0.2s ease-in-out',
115
+ padding: paddingStyles[padding],
116
+ ...variantStyles[variant],
117
+ ...style,
118
+ };
119
+ const hoverStyles = hoverable ? {
120
+ cursor: 'pointer',
121
+ } : {};
122
+ return (jsxRuntime.jsx("div", { style: { ...baseStyles, ...hoverStyles }, ...props, children: children }));
123
+ };
124
+ const CardHeader = ({ children, style, ...props }) => {
125
+ const headerStyles = {
126
+ paddingBottom: '12px',
127
+ borderBottom: '1px solid #e5e7eb',
128
+ marginBottom: '12px',
129
+ fontWeight: 600,
130
+ fontSize: '18px',
131
+ color: '#111827',
132
+ ...style,
133
+ };
134
+ return (jsxRuntime.jsx("div", { style: headerStyles, ...props, children: children }));
135
+ };
136
+ const CardBody = ({ children, style, ...props }) => {
137
+ const bodyStyles = {
138
+ color: '#4b5563',
139
+ fontSize: '14px',
140
+ lineHeight: '1.6',
141
+ ...style,
142
+ };
143
+ return (jsxRuntime.jsx("div", { style: bodyStyles, ...props, children: children }));
144
+ };
145
+ const CardFooter = ({ children, style, ...props }) => {
146
+ const footerStyles = {
147
+ paddingTop: '12px',
148
+ borderTop: '1px solid #e5e7eb',
149
+ marginTop: '12px',
150
+ display: 'flex',
151
+ justifyContent: 'flex-end',
152
+ gap: '8px',
153
+ ...style,
154
+ };
155
+ return (jsxRuntime.jsx("div", { style: footerStyles, ...props, children: children }));
156
+ };
157
+
158
+ const sizeStyles = {
159
+ sm: {
160
+ padding: '8px 12px',
161
+ fontSize: '14px',
162
+ },
163
+ md: {
164
+ padding: '12px 16px',
165
+ fontSize: '16px',
166
+ },
167
+ lg: {
168
+ padding: '16px 20px',
169
+ fontSize: '18px',
170
+ },
171
+ };
172
+ const Input = ({ label, error, helperText, size = 'md', fullWidth = false, disabled, style, id, ...props }) => {
173
+ const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
174
+ const containerStyles = {
175
+ display: 'flex',
176
+ flexDirection: 'column',
177
+ gap: '4px',
178
+ width: fullWidth ? '100%' : 'auto',
179
+ };
180
+ const labelStyles = {
181
+ fontSize: '14px',
182
+ fontWeight: 500,
183
+ color: '#374151',
184
+ marginBottom: '4px',
185
+ };
186
+ const inputStyles = {
187
+ borderRadius: '8px',
188
+ border: `2px solid ${error ? '#ef4444' : '#d1d5db'}`,
189
+ outline: 'none',
190
+ transition: 'all 0.2s ease-in-out',
191
+ backgroundColor: disabled ? '#f3f4f6' : '#ffffff',
192
+ color: '#111827',
193
+ width: fullWidth ? '100%' : 'auto',
194
+ boxSizing: 'border-box',
195
+ ...sizeStyles[size],
196
+ ...style,
197
+ };
198
+ const helperStyles = {
199
+ fontSize: '12px',
200
+ color: error ? '#ef4444' : '#6b7280',
201
+ marginTop: '4px',
202
+ };
203
+ return (jsxRuntime.jsxs("div", { style: containerStyles, children: [label && (jsxRuntime.jsx("label", { htmlFor: inputId, style: labelStyles, children: label })), jsxRuntime.jsx("input", { id: inputId, style: inputStyles, disabled: disabled, ...props }), (error || helperText) && (jsxRuntime.jsx("span", { style: helperStyles, children: error || helperText }))] }));
204
+ };
205
+
206
+ /**
207
+ * table-core
208
+ *
209
+ * Copyright (c) TanStack
210
+ *
211
+ * This source code is licensed under the MIT license found in the
212
+ * LICENSE.md file in the root directory of this source tree.
213
+ *
214
+ * @license MIT
215
+ */
216
+ // type Person = {
217
+ // firstName: string
218
+ // lastName: string
219
+ // age: number
220
+ // visits: number
221
+ // status: string
222
+ // progress: number
223
+ // createdAt: Date
224
+ // nested: {
225
+ // foo: [
226
+ // {
227
+ // bar: 'bar'
228
+ // }
229
+ // ]
230
+ // bar: { subBar: boolean }[]
231
+ // baz: {
232
+ // foo: 'foo'
233
+ // bar: {
234
+ // baz: 'baz'
235
+ // }
236
+ // }
237
+ // }
238
+ // }
239
+
240
+
241
+ // Is this type a tuple?
242
+
243
+ // If this type is a tuple, what indices are allowed?
244
+
245
+ ///
246
+
247
+ function functionalUpdate(updater, input) {
248
+ return typeof updater === 'function' ? updater(input) : updater;
249
+ }
250
+ function makeStateUpdater(key, instance) {
251
+ return updater => {
252
+ instance.setState(old => {
253
+ return {
254
+ ...old,
255
+ [key]: functionalUpdate(updater, old[key])
256
+ };
257
+ });
258
+ };
259
+ }
260
+ function isFunction(d) {
261
+ return d instanceof Function;
262
+ }
263
+ function isNumberArray(d) {
264
+ return Array.isArray(d) && d.every(val => typeof val === 'number');
265
+ }
266
+ function flattenBy(arr, getChildren) {
267
+ const flat = [];
268
+ const recurse = subArr => {
269
+ subArr.forEach(item => {
270
+ flat.push(item);
271
+ const children = getChildren(item);
272
+ if (children != null && children.length) {
273
+ recurse(children);
274
+ }
275
+ });
276
+ };
277
+ recurse(arr);
278
+ return flat;
279
+ }
280
+ function memo(getDeps, fn, opts) {
281
+ let deps = [];
282
+ let result;
283
+ return depArgs => {
284
+ let depTime;
285
+ if (opts.key && opts.debug) depTime = Date.now();
286
+ const newDeps = getDeps(depArgs);
287
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
288
+ if (!depsChanged) {
289
+ return result;
290
+ }
291
+ deps = newDeps;
292
+ let resultTime;
293
+ if (opts.key && opts.debug) resultTime = Date.now();
294
+ result = fn(...newDeps);
295
+ opts == null || opts.onChange == null || opts.onChange(result);
296
+ if (opts.key && opts.debug) {
297
+ if (opts != null && opts.debug()) {
298
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
299
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
300
+ const resultFpsPercentage = resultEndTime / 16;
301
+ const pad = (str, num) => {
302
+ str = String(str);
303
+ while (str.length < num) {
304
+ str = ' ' + str;
305
+ }
306
+ return str;
307
+ };
308
+ console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
309
+ font-size: .6rem;
310
+ font-weight: bold;
311
+ color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
312
+ }
313
+ }
314
+ return result;
315
+ };
316
+ }
317
+ function getMemoOptions(tableOptions, debugLevel, key, onChange) {
318
+ return {
319
+ debug: () => {
320
+ var _tableOptions$debugAl;
321
+ return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
322
+ },
323
+ key: process.env.NODE_ENV === 'development' && key,
324
+ onChange
325
+ };
326
+ }
327
+
328
+ function createCell(table, row, column, columnId) {
329
+ const getRenderValue = () => {
330
+ var _cell$getValue;
331
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
332
+ };
333
+ const cell = {
334
+ id: `${row.id}_${column.id}`,
335
+ row,
336
+ column,
337
+ getValue: () => row.getValue(columnId),
338
+ renderValue: getRenderValue,
339
+ getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
340
+ table,
341
+ column,
342
+ row,
343
+ cell: cell,
344
+ getValue: cell.getValue,
345
+ renderValue: cell.renderValue
346
+ }), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
347
+ };
348
+ table._features.forEach(feature => {
349
+ feature.createCell == null || feature.createCell(cell, column, row, table);
350
+ }, {});
351
+ return cell;
352
+ }
353
+
354
+ function createColumn(table, columnDef, depth, parent) {
355
+ var _ref, _resolvedColumnDef$id;
356
+ const defaultColumn = table._getDefaultColumnDef();
357
+ const resolvedColumnDef = {
358
+ ...defaultColumn,
359
+ ...columnDef
360
+ };
361
+ const accessorKey = resolvedColumnDef.accessorKey;
362
+ 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;
363
+ let accessorFn;
364
+ if (resolvedColumnDef.accessorFn) {
365
+ accessorFn = resolvedColumnDef.accessorFn;
366
+ } else if (accessorKey) {
367
+ // Support deep accessor keys
368
+ if (accessorKey.includes('.')) {
369
+ accessorFn = originalRow => {
370
+ let result = originalRow;
371
+ for (const key of accessorKey.split('.')) {
372
+ var _result;
373
+ result = (_result = result) == null ? void 0 : _result[key];
374
+ if (process.env.NODE_ENV !== 'production' && result === undefined) {
375
+ console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
376
+ }
377
+ }
378
+ return result;
379
+ };
380
+ } else {
381
+ accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
382
+ }
383
+ }
384
+ if (!id) {
385
+ if (process.env.NODE_ENV !== 'production') {
386
+ throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
387
+ }
388
+ throw new Error();
389
+ }
390
+ let column = {
391
+ id: `${String(id)}`,
392
+ accessorFn,
393
+ parent: parent,
394
+ depth,
395
+ columnDef: resolvedColumnDef,
396
+ columns: [],
397
+ getFlatColumns: memo(() => [true], () => {
398
+ var _column$columns;
399
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
400
+ }, getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')),
401
+ getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
402
+ var _column$columns2;
403
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
404
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
405
+ return orderColumns(leafColumns);
406
+ }
407
+ return [column];
408
+ }, getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns'))
409
+ };
410
+ for (const feature of table._features) {
411
+ feature.createColumn == null || feature.createColumn(column, table);
412
+ }
413
+
414
+ // Yes, we have to convert table to unknown, because we know more than the compiler here.
415
+ return column;
416
+ }
417
+
418
+ const debug = 'debugHeaders';
419
+ //
420
+
421
+ function createHeader(table, column, options) {
422
+ var _options$id;
423
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
424
+ let header = {
425
+ id,
426
+ column,
427
+ index: options.index,
428
+ isPlaceholder: !!options.isPlaceholder,
429
+ placeholderId: options.placeholderId,
430
+ depth: options.depth,
431
+ subHeaders: [],
432
+ colSpan: 0,
433
+ rowSpan: 0,
434
+ headerGroup: null,
435
+ getLeafHeaders: () => {
436
+ const leafHeaders = [];
437
+ const recurseHeader = h => {
438
+ if (h.subHeaders && h.subHeaders.length) {
439
+ h.subHeaders.map(recurseHeader);
440
+ }
441
+ leafHeaders.push(h);
442
+ };
443
+ recurseHeader(header);
444
+ return leafHeaders;
445
+ },
446
+ getContext: () => ({
447
+ table,
448
+ header: header,
449
+ column
450
+ })
451
+ };
452
+ table._features.forEach(feature => {
453
+ feature.createHeader == null || feature.createHeader(header, table);
454
+ });
455
+ return header;
456
+ }
457
+ const Headers = {
458
+ createTable: table => {
459
+ // Header Groups
460
+
461
+ table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
462
+ var _left$map$filter, _right$map$filter;
463
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
464
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
465
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
466
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
467
+ return headerGroups;
468
+ }, getMemoOptions(table.options, debug, 'getHeaderGroups'));
469
+ table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
470
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
471
+ return buildHeaderGroups(allColumns, leafColumns, table, 'center');
472
+ }, getMemoOptions(table.options, debug, 'getCenterHeaderGroups'));
473
+ table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
474
+ var _left$map$filter2;
475
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
476
+ return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
477
+ }, getMemoOptions(table.options, debug, 'getLeftHeaderGroups'));
478
+ table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
479
+ var _right$map$filter2;
480
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
481
+ return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
482
+ }, getMemoOptions(table.options, debug, 'getRightHeaderGroups'));
483
+
484
+ // Footer Groups
485
+
486
+ table.getFooterGroups = memo(() => [table.getHeaderGroups()], headerGroups => {
487
+ return [...headerGroups].reverse();
488
+ }, getMemoOptions(table.options, debug, 'getFooterGroups'));
489
+ table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], headerGroups => {
490
+ return [...headerGroups].reverse();
491
+ }, getMemoOptions(table.options, debug, 'getLeftFooterGroups'));
492
+ table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], headerGroups => {
493
+ return [...headerGroups].reverse();
494
+ }, getMemoOptions(table.options, debug, 'getCenterFooterGroups'));
495
+ table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], headerGroups => {
496
+ return [...headerGroups].reverse();
497
+ }, getMemoOptions(table.options, debug, 'getRightFooterGroups'));
498
+
499
+ // Flat Headers
500
+
501
+ table.getFlatHeaders = memo(() => [table.getHeaderGroups()], headerGroups => {
502
+ return headerGroups.map(headerGroup => {
503
+ return headerGroup.headers;
504
+ }).flat();
505
+ }, getMemoOptions(table.options, debug, 'getFlatHeaders'));
506
+ table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], left => {
507
+ return left.map(headerGroup => {
508
+ return headerGroup.headers;
509
+ }).flat();
510
+ }, getMemoOptions(table.options, debug, 'getLeftFlatHeaders'));
511
+ table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], left => {
512
+ return left.map(headerGroup => {
513
+ return headerGroup.headers;
514
+ }).flat();
515
+ }, getMemoOptions(table.options, debug, 'getCenterFlatHeaders'));
516
+ table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], left => {
517
+ return left.map(headerGroup => {
518
+ return headerGroup.headers;
519
+ }).flat();
520
+ }, getMemoOptions(table.options, debug, 'getRightFlatHeaders'));
521
+
522
+ // Leaf Headers
523
+
524
+ table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
525
+ return flatHeaders.filter(header => {
526
+ var _header$subHeaders;
527
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
528
+ });
529
+ }, getMemoOptions(table.options, debug, 'getCenterLeafHeaders'));
530
+ table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
531
+ return flatHeaders.filter(header => {
532
+ var _header$subHeaders2;
533
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
534
+ });
535
+ }, getMemoOptions(table.options, debug, 'getLeftLeafHeaders'));
536
+ table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], flatHeaders => {
537
+ return flatHeaders.filter(header => {
538
+ var _header$subHeaders3;
539
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
540
+ });
541
+ }, getMemoOptions(table.options, debug, 'getRightLeafHeaders'));
542
+ table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
543
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
544
+ 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 => {
545
+ return header.getLeafHeaders();
546
+ }).flat();
547
+ }, getMemoOptions(table.options, debug, 'getLeafHeaders'));
548
+ }
549
+ };
550
+ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
551
+ var _headerGroups$0$heade, _headerGroups$;
552
+ // Find the max depth of the columns:
553
+ // build the leaf column row
554
+ // build each buffer row going up
555
+ // placeholder for non-existent level
556
+ // real column for existing level
557
+
558
+ let maxDepth = 0;
559
+ const findMaxDepth = function (columns, depth) {
560
+ if (depth === void 0) {
561
+ depth = 1;
562
+ }
563
+ maxDepth = Math.max(maxDepth, depth);
564
+ columns.filter(column => column.getIsVisible()).forEach(column => {
565
+ var _column$columns;
566
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
567
+ findMaxDepth(column.columns, depth + 1);
568
+ }
569
+ }, 0);
570
+ };
571
+ findMaxDepth(allColumns);
572
+ let headerGroups = [];
573
+ const createHeaderGroup = (headersToGroup, depth) => {
574
+ // The header group we are creating
575
+ const headerGroup = {
576
+ depth,
577
+ id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
578
+ headers: []
579
+ };
580
+
581
+ // The parent columns we're going to scan next
582
+ const pendingParentHeaders = [];
583
+
584
+ // Scan each column for parents
585
+ headersToGroup.forEach(headerToGroup => {
586
+ // What is the latest (last) parent column?
587
+
588
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
589
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
590
+ let column;
591
+ let isPlaceholder = false;
592
+ if (isLeafHeader && headerToGroup.column.parent) {
593
+ // The parent header is new
594
+ column = headerToGroup.column.parent;
595
+ } else {
596
+ // The parent header is repeated
597
+ column = headerToGroup.column;
598
+ isPlaceholder = true;
599
+ }
600
+ if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
601
+ // This column is repeated. Add it as a sub header to the next batch
602
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
603
+ } else {
604
+ // This is a new header. Let's create it
605
+ const header = createHeader(table, column, {
606
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
607
+ isPlaceholder,
608
+ placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
609
+ depth,
610
+ index: pendingParentHeaders.length
611
+ });
612
+
613
+ // Add the headerToGroup as a subHeader of the new header
614
+ header.subHeaders.push(headerToGroup);
615
+ // Add the new header to the pendingParentHeaders to get grouped
616
+ // in the next batch
617
+ pendingParentHeaders.push(header);
618
+ }
619
+ headerGroup.headers.push(headerToGroup);
620
+ headerToGroup.headerGroup = headerGroup;
621
+ });
622
+ headerGroups.push(headerGroup);
623
+ if (depth > 0) {
624
+ createHeaderGroup(pendingParentHeaders, depth - 1);
625
+ }
626
+ };
627
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
628
+ depth: maxDepth,
629
+ index
630
+ }));
631
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
632
+ headerGroups.reverse();
633
+
634
+ // headerGroups = headerGroups.filter(headerGroup => {
635
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
636
+ // })
637
+
638
+ const recurseHeadersForSpans = headers => {
639
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
640
+ return filteredHeaders.map(header => {
641
+ let colSpan = 0;
642
+ let rowSpan = 0;
643
+ let childRowSpans = [0];
644
+ if (header.subHeaders && header.subHeaders.length) {
645
+ childRowSpans = [];
646
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
647
+ let {
648
+ colSpan: childColSpan,
649
+ rowSpan: childRowSpan
650
+ } = _ref;
651
+ colSpan += childColSpan;
652
+ childRowSpans.push(childRowSpan);
653
+ });
654
+ } else {
655
+ colSpan = 1;
656
+ }
657
+ const minChildRowSpan = Math.min(...childRowSpans);
658
+ rowSpan = rowSpan + minChildRowSpan;
659
+ header.colSpan = colSpan;
660
+ header.rowSpan = rowSpan;
661
+ return {
662
+ colSpan,
663
+ rowSpan
664
+ };
665
+ });
666
+ };
667
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
668
+ return headerGroups;
669
+ }
670
+
671
+ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
672
+ let row = {
673
+ id,
674
+ index: rowIndex,
675
+ original,
676
+ depth,
677
+ parentId,
678
+ _valuesCache: {},
679
+ _uniqueValuesCache: {},
680
+ getValue: columnId => {
681
+ if (row._valuesCache.hasOwnProperty(columnId)) {
682
+ return row._valuesCache[columnId];
683
+ }
684
+ const column = table.getColumn(columnId);
685
+ if (!(column != null && column.accessorFn)) {
686
+ return undefined;
687
+ }
688
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
689
+ return row._valuesCache[columnId];
690
+ },
691
+ getUniqueValues: columnId => {
692
+ if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
693
+ return row._uniqueValuesCache[columnId];
694
+ }
695
+ const column = table.getColumn(columnId);
696
+ if (!(column != null && column.accessorFn)) {
697
+ return undefined;
698
+ }
699
+ if (!column.columnDef.getUniqueValues) {
700
+ row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
701
+ return row._uniqueValuesCache[columnId];
702
+ }
703
+ row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
704
+ return row._uniqueValuesCache[columnId];
705
+ },
706
+ renderValue: columnId => {
707
+ var _row$getValue;
708
+ return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
709
+ },
710
+ subRows: [],
711
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
712
+ getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
713
+ getParentRows: () => {
714
+ let parentRows = [];
715
+ let currentRow = row;
716
+ while (true) {
717
+ const parentRow = currentRow.getParentRow();
718
+ if (!parentRow) break;
719
+ parentRows.push(parentRow);
720
+ currentRow = parentRow;
721
+ }
722
+ return parentRows.reverse();
723
+ },
724
+ getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
725
+ return leafColumns.map(column => {
726
+ return createCell(table, row, column, column.id);
727
+ });
728
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
729
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
730
+ return allCells.reduce((acc, cell) => {
731
+ acc[cell.column.id] = cell;
732
+ return acc;
733
+ }, {});
734
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
735
+ };
736
+ for (let i = 0; i < table._features.length; i++) {
737
+ const feature = table._features[i];
738
+ feature == null || feature.createRow == null || feature.createRow(row, table);
739
+ }
740
+ return row;
741
+ };
742
+
743
+ //
744
+
745
+ const ColumnFaceting = {
746
+ createColumn: (column, table) => {
747
+ column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
748
+ column.getFacetedRowModel = () => {
749
+ if (!column._getFacetedRowModel) {
750
+ return table.getPreFilteredRowModel();
751
+ }
752
+ return column._getFacetedRowModel();
753
+ };
754
+ column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
755
+ column.getFacetedUniqueValues = () => {
756
+ if (!column._getFacetedUniqueValues) {
757
+ return new Map();
758
+ }
759
+ return column._getFacetedUniqueValues();
760
+ };
761
+ column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
762
+ column.getFacetedMinMaxValues = () => {
763
+ if (!column._getFacetedMinMaxValues) {
764
+ return undefined;
765
+ }
766
+ return column._getFacetedMinMaxValues();
767
+ };
768
+ }
769
+ };
770
+
771
+ const includesString = (row, columnId, filterValue) => {
772
+ var _filterValue$toString, _row$getValue;
773
+ const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
774
+ 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));
775
+ };
776
+ includesString.autoRemove = val => testFalsey(val);
777
+ const includesStringSensitive = (row, columnId, filterValue) => {
778
+ var _row$getValue2;
779
+ return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
780
+ };
781
+ includesStringSensitive.autoRemove = val => testFalsey(val);
782
+ const equalsString = (row, columnId, filterValue) => {
783
+ var _row$getValue3;
784
+ return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
785
+ };
786
+ equalsString.autoRemove = val => testFalsey(val);
787
+ const arrIncludes = (row, columnId, filterValue) => {
788
+ var _row$getValue4;
789
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
790
+ };
791
+ arrIncludes.autoRemove = val => testFalsey(val);
792
+ const arrIncludesAll = (row, columnId, filterValue) => {
793
+ return !filterValue.some(val => {
794
+ var _row$getValue5;
795
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
796
+ });
797
+ };
798
+ arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
799
+ const arrIncludesSome = (row, columnId, filterValue) => {
800
+ return filterValue.some(val => {
801
+ var _row$getValue6;
802
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
803
+ });
804
+ };
805
+ arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
806
+ const equals = (row, columnId, filterValue) => {
807
+ return row.getValue(columnId) === filterValue;
808
+ };
809
+ equals.autoRemove = val => testFalsey(val);
810
+ const weakEquals = (row, columnId, filterValue) => {
811
+ return row.getValue(columnId) == filterValue;
812
+ };
813
+ weakEquals.autoRemove = val => testFalsey(val);
814
+ const inNumberRange = (row, columnId, filterValue) => {
815
+ let [min, max] = filterValue;
816
+ const rowValue = row.getValue(columnId);
817
+ return rowValue >= min && rowValue <= max;
818
+ };
819
+ inNumberRange.resolveFilterValue = val => {
820
+ let [unsafeMin, unsafeMax] = val;
821
+ let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
822
+ let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
823
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
824
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
825
+ if (min > max) {
826
+ const temp = min;
827
+ min = max;
828
+ max = temp;
829
+ }
830
+ return [min, max];
831
+ };
832
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
833
+
834
+ // Export
835
+
836
+ const filterFns = {
837
+ includesString,
838
+ includesStringSensitive,
839
+ equalsString,
840
+ arrIncludes,
841
+ arrIncludesAll,
842
+ arrIncludesSome,
843
+ equals,
844
+ weakEquals,
845
+ inNumberRange
846
+ };
847
+ // Utils
848
+
849
+ function testFalsey(val) {
850
+ return val === undefined || val === null || val === '';
851
+ }
852
+
853
+ //
854
+
855
+ const ColumnFiltering = {
856
+ getDefaultColumnDef: () => {
857
+ return {
858
+ filterFn: 'auto'
859
+ };
860
+ },
861
+ getInitialState: state => {
862
+ return {
863
+ columnFilters: [],
864
+ ...state
865
+ };
866
+ },
867
+ getDefaultOptions: table => {
868
+ return {
869
+ onColumnFiltersChange: makeStateUpdater('columnFilters', table),
870
+ filterFromLeafRows: false,
871
+ maxLeafRowFilterDepth: 100
872
+ };
873
+ },
874
+ createColumn: (column, table) => {
875
+ column.getAutoFilterFn = () => {
876
+ const firstRow = table.getCoreRowModel().flatRows[0];
877
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
878
+ if (typeof value === 'string') {
879
+ return filterFns.includesString;
880
+ }
881
+ if (typeof value === 'number') {
882
+ return filterFns.inNumberRange;
883
+ }
884
+ if (typeof value === 'boolean') {
885
+ return filterFns.equals;
886
+ }
887
+ if (value !== null && typeof value === 'object') {
888
+ return filterFns.equals;
889
+ }
890
+ if (Array.isArray(value)) {
891
+ return filterFns.arrIncludes;
892
+ }
893
+ return filterFns.weakEquals;
894
+ };
895
+ column.getFilterFn = () => {
896
+ var _table$options$filter, _table$options$filter2;
897
+ return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
898
+ (_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];
899
+ };
900
+ column.getCanFilter = () => {
901
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
902
+ 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;
903
+ };
904
+ column.getIsFiltered = () => column.getFilterIndex() > -1;
905
+ column.getFilterValue = () => {
906
+ var _table$getState$colum;
907
+ 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;
908
+ };
909
+ column.getFilterIndex = () => {
910
+ var _table$getState$colum2, _table$getState$colum3;
911
+ 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;
912
+ };
913
+ column.setFilterValue = value => {
914
+ table.setColumnFilters(old => {
915
+ const filterFn = column.getFilterFn();
916
+ const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
917
+ const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
918
+
919
+ //
920
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
921
+ var _old$filter;
922
+ return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
923
+ }
924
+ const newFilterObj = {
925
+ id: column.id,
926
+ value: newFilter
927
+ };
928
+ if (previousFilter) {
929
+ var _old$map;
930
+ return (_old$map = old == null ? void 0 : old.map(d => {
931
+ if (d.id === column.id) {
932
+ return newFilterObj;
933
+ }
934
+ return d;
935
+ })) != null ? _old$map : [];
936
+ }
937
+ if (old != null && old.length) {
938
+ return [...old, newFilterObj];
939
+ }
940
+ return [newFilterObj];
941
+ });
942
+ };
943
+ },
944
+ createRow: (row, _table) => {
945
+ row.columnFilters = {};
946
+ row.columnFiltersMeta = {};
947
+ },
948
+ createTable: table => {
949
+ table.setColumnFilters = updater => {
950
+ const leafColumns = table.getAllLeafColumns();
951
+ const updateFn = old => {
952
+ var _functionalUpdate;
953
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
954
+ const column = leafColumns.find(d => d.id === filter.id);
955
+ if (column) {
956
+ const filterFn = column.getFilterFn();
957
+ if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
958
+ return false;
959
+ }
960
+ }
961
+ return true;
962
+ });
963
+ };
964
+ table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
965
+ };
966
+ table.resetColumnFilters = defaultState => {
967
+ var _table$initialState$c, _table$initialState;
968
+ table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
969
+ };
970
+ table.getPreFilteredRowModel = () => table.getCoreRowModel();
971
+ table.getFilteredRowModel = () => {
972
+ if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
973
+ table._getFilteredRowModel = table.options.getFilteredRowModel(table);
974
+ }
975
+ if (table.options.manualFiltering || !table._getFilteredRowModel) {
976
+ return table.getPreFilteredRowModel();
977
+ }
978
+ return table._getFilteredRowModel();
979
+ };
980
+ }
981
+ };
982
+ function shouldAutoRemoveFilter(filterFn, value, column) {
983
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
984
+ }
985
+
986
+ const sum = (columnId, _leafRows, childRows) => {
987
+ // It's faster to just add the aggregations together instead of
988
+ // process leaf nodes individually
989
+ return childRows.reduce((sum, next) => {
990
+ const nextValue = next.getValue(columnId);
991
+ return sum + (typeof nextValue === 'number' ? nextValue : 0);
992
+ }, 0);
993
+ };
994
+ const min = (columnId, _leafRows, childRows) => {
995
+ let min;
996
+ childRows.forEach(row => {
997
+ const value = row.getValue(columnId);
998
+ if (value != null && (min > value || min === undefined && value >= value)) {
999
+ min = value;
1000
+ }
1001
+ });
1002
+ return min;
1003
+ };
1004
+ const max = (columnId, _leafRows, childRows) => {
1005
+ let max;
1006
+ childRows.forEach(row => {
1007
+ const value = row.getValue(columnId);
1008
+ if (value != null && (max < value || max === undefined && value >= value)) {
1009
+ max = value;
1010
+ }
1011
+ });
1012
+ return max;
1013
+ };
1014
+ const extent = (columnId, _leafRows, childRows) => {
1015
+ let min;
1016
+ let max;
1017
+ childRows.forEach(row => {
1018
+ const value = row.getValue(columnId);
1019
+ if (value != null) {
1020
+ if (min === undefined) {
1021
+ if (value >= value) min = max = value;
1022
+ } else {
1023
+ if (min > value) min = value;
1024
+ if (max < value) max = value;
1025
+ }
1026
+ }
1027
+ });
1028
+ return [min, max];
1029
+ };
1030
+ const mean = (columnId, leafRows) => {
1031
+ let count = 0;
1032
+ let sum = 0;
1033
+ leafRows.forEach(row => {
1034
+ let value = row.getValue(columnId);
1035
+ if (value != null && (value = +value) >= value) {
1036
+ ++count, sum += value;
1037
+ }
1038
+ });
1039
+ if (count) return sum / count;
1040
+ return;
1041
+ };
1042
+ const median = (columnId, leafRows) => {
1043
+ if (!leafRows.length) {
1044
+ return;
1045
+ }
1046
+ const values = leafRows.map(row => row.getValue(columnId));
1047
+ if (!isNumberArray(values)) {
1048
+ return;
1049
+ }
1050
+ if (values.length === 1) {
1051
+ return values[0];
1052
+ }
1053
+ const mid = Math.floor(values.length / 2);
1054
+ const nums = values.sort((a, b) => a - b);
1055
+ return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
1056
+ };
1057
+ const unique = (columnId, leafRows) => {
1058
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1059
+ };
1060
+ const uniqueCount = (columnId, leafRows) => {
1061
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1062
+ };
1063
+ const count = (_columnId, leafRows) => {
1064
+ return leafRows.length;
1065
+ };
1066
+ const aggregationFns = {
1067
+ sum,
1068
+ min,
1069
+ max,
1070
+ extent,
1071
+ mean,
1072
+ median,
1073
+ unique,
1074
+ uniqueCount,
1075
+ count
1076
+ };
1077
+
1078
+ //
1079
+
1080
+ const ColumnGrouping = {
1081
+ getDefaultColumnDef: () => {
1082
+ return {
1083
+ aggregatedCell: props => {
1084
+ var _toString, _props$getValue;
1085
+ return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
1086
+ },
1087
+ aggregationFn: 'auto'
1088
+ };
1089
+ },
1090
+ getInitialState: state => {
1091
+ return {
1092
+ grouping: [],
1093
+ ...state
1094
+ };
1095
+ },
1096
+ getDefaultOptions: table => {
1097
+ return {
1098
+ onGroupingChange: makeStateUpdater('grouping', table),
1099
+ groupedColumnMode: 'reorder'
1100
+ };
1101
+ },
1102
+ createColumn: (column, table) => {
1103
+ column.toggleGrouping = () => {
1104
+ table.setGrouping(old => {
1105
+ // Find any existing grouping for this column
1106
+ if (old != null && old.includes(column.id)) {
1107
+ return old.filter(d => d !== column.id);
1108
+ }
1109
+ return [...(old != null ? old : []), column.id];
1110
+ });
1111
+ };
1112
+ column.getCanGroup = () => {
1113
+ var _column$columnDef$ena, _table$options$enable;
1114
+ 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);
1115
+ };
1116
+ column.getIsGrouped = () => {
1117
+ var _table$getState$group;
1118
+ return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
1119
+ };
1120
+ column.getGroupedIndex = () => {
1121
+ var _table$getState$group2;
1122
+ return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
1123
+ };
1124
+ column.getToggleGroupingHandler = () => {
1125
+ const canGroup = column.getCanGroup();
1126
+ return () => {
1127
+ if (!canGroup) return;
1128
+ column.toggleGrouping();
1129
+ };
1130
+ };
1131
+ column.getAutoAggregationFn = () => {
1132
+ const firstRow = table.getCoreRowModel().flatRows[0];
1133
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1134
+ if (typeof value === 'number') {
1135
+ return aggregationFns.sum;
1136
+ }
1137
+ if (Object.prototype.toString.call(value) === '[object Date]') {
1138
+ return aggregationFns.extent;
1139
+ }
1140
+ };
1141
+ column.getAggregationFn = () => {
1142
+ var _table$options$aggreg, _table$options$aggreg2;
1143
+ if (!column) {
1144
+ throw new Error();
1145
+ }
1146
+ 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];
1147
+ };
1148
+ },
1149
+ createTable: table => {
1150
+ table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
1151
+ table.resetGrouping = defaultState => {
1152
+ var _table$initialState$g, _table$initialState;
1153
+ table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
1154
+ };
1155
+ table.getPreGroupedRowModel = () => table.getFilteredRowModel();
1156
+ table.getGroupedRowModel = () => {
1157
+ if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
1158
+ table._getGroupedRowModel = table.options.getGroupedRowModel(table);
1159
+ }
1160
+ if (table.options.manualGrouping || !table._getGroupedRowModel) {
1161
+ return table.getPreGroupedRowModel();
1162
+ }
1163
+ return table._getGroupedRowModel();
1164
+ };
1165
+ },
1166
+ createRow: (row, table) => {
1167
+ row.getIsGrouped = () => !!row.groupingColumnId;
1168
+ row.getGroupingValue = columnId => {
1169
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
1170
+ return row._groupingValuesCache[columnId];
1171
+ }
1172
+ const column = table.getColumn(columnId);
1173
+ if (!(column != null && column.columnDef.getGroupingValue)) {
1174
+ return row.getValue(columnId);
1175
+ }
1176
+ row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
1177
+ return row._groupingValuesCache[columnId];
1178
+ };
1179
+ row._groupingValuesCache = {};
1180
+ },
1181
+ createCell: (cell, column, row, table) => {
1182
+ cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
1183
+ cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
1184
+ cell.getIsAggregated = () => {
1185
+ var _row$subRows;
1186
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1187
+ };
1188
+ }
1189
+ };
1190
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
1191
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) {
1192
+ return leafColumns;
1193
+ }
1194
+ const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
1195
+ if (groupedColumnMode === 'remove') {
1196
+ return nonGroupingColumns;
1197
+ }
1198
+ const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
1199
+ return [...groupingColumns, ...nonGroupingColumns];
1200
+ }
1201
+
1202
+ //
1203
+
1204
+ const ColumnOrdering = {
1205
+ getInitialState: state => {
1206
+ return {
1207
+ columnOrder: [],
1208
+ ...state
1209
+ };
1210
+ },
1211
+ getDefaultOptions: table => {
1212
+ return {
1213
+ onColumnOrderChange: makeStateUpdater('columnOrder', table)
1214
+ };
1215
+ },
1216
+ createColumn: (column, table) => {
1217
+ column.getIndex = memo(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
1218
+ column.getIsFirstColumn = position => {
1219
+ var _columns$;
1220
+ const columns = _getVisibleLeafColumns(table, position);
1221
+ return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
1222
+ };
1223
+ column.getIsLastColumn = position => {
1224
+ var _columns;
1225
+ const columns = _getVisibleLeafColumns(table, position);
1226
+ return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
1227
+ };
1228
+ },
1229
+ createTable: table => {
1230
+ table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
1231
+ table.resetColumnOrder = defaultState => {
1232
+ var _table$initialState$c;
1233
+ table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
1234
+ };
1235
+ table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
1236
+ // Sort grouped columns to the start of the column list
1237
+ // before the headers are built
1238
+ let orderedColumns = [];
1239
+
1240
+ // If there is no order, return the normal columns
1241
+ if (!(columnOrder != null && columnOrder.length)) {
1242
+ orderedColumns = columns;
1243
+ } else {
1244
+ const columnOrderCopy = [...columnOrder];
1245
+
1246
+ // If there is an order, make a copy of the columns
1247
+ const columnsCopy = [...columns];
1248
+
1249
+ // And make a new ordered array of the columns
1250
+
1251
+ // Loop over the columns and place them in order into the new array
1252
+ while (columnsCopy.length && columnOrderCopy.length) {
1253
+ const targetColumnId = columnOrderCopy.shift();
1254
+ const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
1255
+ if (foundIndex > -1) {
1256
+ orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
1257
+ }
1258
+ }
1259
+
1260
+ // If there are any columns left, add them to the end
1261
+ orderedColumns = [...orderedColumns, ...columnsCopy];
1262
+ }
1263
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
1264
+ }, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
1265
+ }
1266
+ };
1267
+
1268
+ //
1269
+
1270
+ const getDefaultColumnPinningState = () => ({
1271
+ left: [],
1272
+ right: []
1273
+ });
1274
+ const ColumnPinning = {
1275
+ getInitialState: state => {
1276
+ return {
1277
+ columnPinning: getDefaultColumnPinningState(),
1278
+ ...state
1279
+ };
1280
+ },
1281
+ getDefaultOptions: table => {
1282
+ return {
1283
+ onColumnPinningChange: makeStateUpdater('columnPinning', table)
1284
+ };
1285
+ },
1286
+ createColumn: (column, table) => {
1287
+ column.pin = position => {
1288
+ const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
1289
+ table.setColumnPinning(old => {
1290
+ var _old$left3, _old$right3;
1291
+ if (position === 'right') {
1292
+ var _old$left, _old$right;
1293
+ return {
1294
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1295
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
1296
+ };
1297
+ }
1298
+ if (position === 'left') {
1299
+ var _old$left2, _old$right2;
1300
+ return {
1301
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
1302
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1303
+ };
1304
+ }
1305
+ return {
1306
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1307
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1308
+ };
1309
+ });
1310
+ };
1311
+ column.getCanPin = () => {
1312
+ const leafColumns = column.getLeafColumns();
1313
+ return leafColumns.some(d => {
1314
+ var _d$columnDef$enablePi, _ref, _table$options$enable;
1315
+ 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);
1316
+ });
1317
+ };
1318
+ column.getIsPinned = () => {
1319
+ const leafColumnIds = column.getLeafColumns().map(d => d.id);
1320
+ const {
1321
+ left,
1322
+ right
1323
+ } = table.getState().columnPinning;
1324
+ const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
1325
+ const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
1326
+ return isLeft ? 'left' : isRight ? 'right' : false;
1327
+ };
1328
+ column.getPinnedIndex = () => {
1329
+ var _table$getState$colum, _table$getState$colum2;
1330
+ const position = column.getIsPinned();
1331
+ 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;
1332
+ };
1333
+ },
1334
+ createRow: (row, table) => {
1335
+ row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
1336
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1337
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1338
+ }, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
1339
+ row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
1340
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1341
+ ...d,
1342
+ position: 'left'
1343
+ }));
1344
+ return cells;
1345
+ }, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
1346
+ row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
1347
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1348
+ ...d,
1349
+ position: 'right'
1350
+ }));
1351
+ return cells;
1352
+ }, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
1353
+ },
1354
+ createTable: table => {
1355
+ table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
1356
+ table.resetColumnPinning = defaultState => {
1357
+ var _table$initialState$c, _table$initialState;
1358
+ return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
1359
+ };
1360
+ table.getIsSomeColumnsPinned = position => {
1361
+ var _pinningState$positio;
1362
+ const pinningState = table.getState().columnPinning;
1363
+ if (!position) {
1364
+ var _pinningState$left, _pinningState$right;
1365
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1366
+ }
1367
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1368
+ };
1369
+ table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
1370
+ return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1371
+ }, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
1372
+ table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
1373
+ return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1374
+ }, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
1375
+ table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
1376
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1377
+ return allColumns.filter(d => !leftAndRight.includes(d.id));
1378
+ }, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
1379
+ }
1380
+ };
1381
+
1382
+ function safelyAccessDocument(_document) {
1383
+ return _document || (typeof document !== 'undefined' ? document : null);
1384
+ }
1385
+
1386
+ //
1387
+
1388
+ //
1389
+
1390
+ const defaultColumnSizing = {
1391
+ size: 150,
1392
+ minSize: 20,
1393
+ maxSize: Number.MAX_SAFE_INTEGER
1394
+ };
1395
+ const getDefaultColumnSizingInfoState = () => ({
1396
+ startOffset: null,
1397
+ startSize: null,
1398
+ deltaOffset: null,
1399
+ deltaPercentage: null,
1400
+ isResizingColumn: false,
1401
+ columnSizingStart: []
1402
+ });
1403
+ const ColumnSizing = {
1404
+ getDefaultColumnDef: () => {
1405
+ return defaultColumnSizing;
1406
+ },
1407
+ getInitialState: state => {
1408
+ return {
1409
+ columnSizing: {},
1410
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
1411
+ ...state
1412
+ };
1413
+ },
1414
+ getDefaultOptions: table => {
1415
+ return {
1416
+ columnResizeMode: 'onEnd',
1417
+ columnResizeDirection: 'ltr',
1418
+ onColumnSizingChange: makeStateUpdater('columnSizing', table),
1419
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
1420
+ };
1421
+ },
1422
+ createColumn: (column, table) => {
1423
+ column.getSize = () => {
1424
+ var _column$columnDef$min, _ref, _column$columnDef$max;
1425
+ const columnSize = table.getState().columnSizing[column.id];
1426
+ 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);
1427
+ };
1428
+ 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'));
1429
+ 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'));
1430
+ column.resetSize = () => {
1431
+ table.setColumnSizing(_ref2 => {
1432
+ let {
1433
+ [column.id]: _,
1434
+ ...rest
1435
+ } = _ref2;
1436
+ return rest;
1437
+ });
1438
+ };
1439
+ column.getCanResize = () => {
1440
+ var _column$columnDef$ena, _table$options$enable;
1441
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
1442
+ };
1443
+ column.getIsResizing = () => {
1444
+ return table.getState().columnSizingInfo.isResizingColumn === column.id;
1445
+ };
1446
+ },
1447
+ createHeader: (header, table) => {
1448
+ header.getSize = () => {
1449
+ let sum = 0;
1450
+ const recurse = header => {
1451
+ if (header.subHeaders.length) {
1452
+ header.subHeaders.forEach(recurse);
1453
+ } else {
1454
+ var _header$column$getSiz;
1455
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
1456
+ }
1457
+ };
1458
+ recurse(header);
1459
+ return sum;
1460
+ };
1461
+ header.getStart = () => {
1462
+ if (header.index > 0) {
1463
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
1464
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
1465
+ }
1466
+ return 0;
1467
+ };
1468
+ header.getResizeHandler = _contextDocument => {
1469
+ const column = table.getColumn(header.column.id);
1470
+ const canResize = column == null ? void 0 : column.getCanResize();
1471
+ return e => {
1472
+ if (!column || !canResize) {
1473
+ return;
1474
+ }
1475
+ e.persist == null || e.persist();
1476
+ if (isTouchStartEvent(e)) {
1477
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
1478
+ if (e.touches && e.touches.length > 1) {
1479
+ return;
1480
+ }
1481
+ }
1482
+ const startSize = header.getSize();
1483
+ const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
1484
+ const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1485
+ const newColumnSizing = {};
1486
+ const updateOffset = (eventType, clientXPos) => {
1487
+ if (typeof clientXPos !== 'number') {
1488
+ return;
1489
+ }
1490
+ table.setColumnSizingInfo(old => {
1491
+ var _old$startOffset, _old$startSize;
1492
+ const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
1493
+ const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
1494
+ const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
1495
+ old.columnSizingStart.forEach(_ref3 => {
1496
+ let [columnId, headerSize] = _ref3;
1497
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
1498
+ });
1499
+ return {
1500
+ ...old,
1501
+ deltaOffset,
1502
+ deltaPercentage
1503
+ };
1504
+ });
1505
+ if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
1506
+ table.setColumnSizing(old => ({
1507
+ ...old,
1508
+ ...newColumnSizing
1509
+ }));
1510
+ }
1511
+ };
1512
+ const onMove = clientXPos => updateOffset('move', clientXPos);
1513
+ const onEnd = clientXPos => {
1514
+ updateOffset('end', clientXPos);
1515
+ table.setColumnSizingInfo(old => ({
1516
+ ...old,
1517
+ isResizingColumn: false,
1518
+ startOffset: null,
1519
+ startSize: null,
1520
+ deltaOffset: null,
1521
+ deltaPercentage: null,
1522
+ columnSizingStart: []
1523
+ }));
1524
+ };
1525
+ const contextDocument = safelyAccessDocument(_contextDocument);
1526
+ const mouseEvents = {
1527
+ moveHandler: e => onMove(e.clientX),
1528
+ upHandler: e => {
1529
+ contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
1530
+ contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
1531
+ onEnd(e.clientX);
1532
+ }
1533
+ };
1534
+ const touchEvents = {
1535
+ moveHandler: e => {
1536
+ if (e.cancelable) {
1537
+ e.preventDefault();
1538
+ e.stopPropagation();
1539
+ }
1540
+ onMove(e.touches[0].clientX);
1541
+ return false;
1542
+ },
1543
+ upHandler: e => {
1544
+ var _e$touches$;
1545
+ contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
1546
+ contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
1547
+ if (e.cancelable) {
1548
+ e.preventDefault();
1549
+ e.stopPropagation();
1550
+ }
1551
+ onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
1552
+ }
1553
+ };
1554
+ const passiveIfSupported = passiveEventSupported() ? {
1555
+ passive: false
1556
+ } : false;
1557
+ if (isTouchStartEvent(e)) {
1558
+ contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
1559
+ contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
1560
+ } else {
1561
+ contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
1562
+ contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
1563
+ }
1564
+ table.setColumnSizingInfo(old => ({
1565
+ ...old,
1566
+ startOffset: clientX,
1567
+ startSize,
1568
+ deltaOffset: 0,
1569
+ deltaPercentage: 0,
1570
+ columnSizingStart,
1571
+ isResizingColumn: column.id
1572
+ }));
1573
+ };
1574
+ };
1575
+ },
1576
+ createTable: table => {
1577
+ table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
1578
+ table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
1579
+ table.resetColumnSizing = defaultState => {
1580
+ var _table$initialState$c;
1581
+ table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
1582
+ };
1583
+ table.resetHeaderSizeInfo = defaultState => {
1584
+ var _table$initialState$c2;
1585
+ table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
1586
+ };
1587
+ table.getTotalSize = () => {
1588
+ var _table$getHeaderGroup, _table$getHeaderGroup2;
1589
+ return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
1590
+ return sum + header.getSize();
1591
+ }, 0)) != null ? _table$getHeaderGroup : 0;
1592
+ };
1593
+ table.getLeftTotalSize = () => {
1594
+ var _table$getLeftHeaderG, _table$getLeftHeaderG2;
1595
+ return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
1596
+ return sum + header.getSize();
1597
+ }, 0)) != null ? _table$getLeftHeaderG : 0;
1598
+ };
1599
+ table.getCenterTotalSize = () => {
1600
+ var _table$getCenterHeade, _table$getCenterHeade2;
1601
+ return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
1602
+ return sum + header.getSize();
1603
+ }, 0)) != null ? _table$getCenterHeade : 0;
1604
+ };
1605
+ table.getRightTotalSize = () => {
1606
+ var _table$getRightHeader, _table$getRightHeader2;
1607
+ return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
1608
+ return sum + header.getSize();
1609
+ }, 0)) != null ? _table$getRightHeader : 0;
1610
+ };
1611
+ }
1612
+ };
1613
+ let passiveSupported = null;
1614
+ function passiveEventSupported() {
1615
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
1616
+ let supported = false;
1617
+ try {
1618
+ const options = {
1619
+ get passive() {
1620
+ supported = true;
1621
+ return false;
1622
+ }
1623
+ };
1624
+ const noop = () => {};
1625
+ window.addEventListener('test', noop, options);
1626
+ window.removeEventListener('test', noop);
1627
+ } catch (err) {
1628
+ supported = false;
1629
+ }
1630
+ passiveSupported = supported;
1631
+ return passiveSupported;
1632
+ }
1633
+ function isTouchStartEvent(e) {
1634
+ return e.type === 'touchstart';
1635
+ }
1636
+
1637
+ //
1638
+
1639
+ const ColumnVisibility = {
1640
+ getInitialState: state => {
1641
+ return {
1642
+ columnVisibility: {},
1643
+ ...state
1644
+ };
1645
+ },
1646
+ getDefaultOptions: table => {
1647
+ return {
1648
+ onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
1649
+ };
1650
+ },
1651
+ createColumn: (column, table) => {
1652
+ column.toggleVisibility = value => {
1653
+ if (column.getCanHide()) {
1654
+ table.setColumnVisibility(old => ({
1655
+ ...old,
1656
+ [column.id]: value != null ? value : !column.getIsVisible()
1657
+ }));
1658
+ }
1659
+ };
1660
+ column.getIsVisible = () => {
1661
+ var _ref, _table$getState$colum;
1662
+ const childColumns = column.columns;
1663
+ 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;
1664
+ };
1665
+ column.getCanHide = () => {
1666
+ var _column$columnDef$ena, _table$options$enable;
1667
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
1668
+ };
1669
+ column.getToggleVisibilityHandler = () => {
1670
+ return e => {
1671
+ column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
1672
+ };
1673
+ };
1674
+ },
1675
+ createRow: (row, table) => {
1676
+ row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
1677
+ return cells.filter(cell => cell.column.getIsVisible());
1678
+ }, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
1679
+ row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
1680
+ },
1681
+ createTable: table => {
1682
+ const makeVisibleColumnsMethod = (key, getColumns) => {
1683
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
1684
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
1685
+ }, getMemoOptions(table.options, 'debugColumns', key));
1686
+ };
1687
+ table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
1688
+ table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
1689
+ table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
1690
+ table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
1691
+ table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
1692
+ table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
1693
+ table.resetColumnVisibility = defaultState => {
1694
+ var _table$initialState$c;
1695
+ table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
1696
+ };
1697
+ table.toggleAllColumnsVisible = value => {
1698
+ var _value;
1699
+ value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
1700
+ table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
1701
+ ...obj,
1702
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
1703
+ }), {}));
1704
+ };
1705
+ table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
1706
+ table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
1707
+ table.getToggleAllColumnsVisibilityHandler = () => {
1708
+ return e => {
1709
+ var _target;
1710
+ table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
1711
+ };
1712
+ };
1713
+ }
1714
+ };
1715
+ function _getVisibleLeafColumns(table, position) {
1716
+ return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
1717
+ }
1718
+
1719
+ //
1720
+
1721
+ const GlobalFaceting = {
1722
+ createTable: table => {
1723
+ table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
1724
+ table.getGlobalFacetedRowModel = () => {
1725
+ if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
1726
+ return table.getPreFilteredRowModel();
1727
+ }
1728
+ return table._getGlobalFacetedRowModel();
1729
+ };
1730
+ table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
1731
+ table.getGlobalFacetedUniqueValues = () => {
1732
+ if (!table._getGlobalFacetedUniqueValues) {
1733
+ return new Map();
1734
+ }
1735
+ return table._getGlobalFacetedUniqueValues();
1736
+ };
1737
+ table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
1738
+ table.getGlobalFacetedMinMaxValues = () => {
1739
+ if (!table._getGlobalFacetedMinMaxValues) {
1740
+ return;
1741
+ }
1742
+ return table._getGlobalFacetedMinMaxValues();
1743
+ };
1744
+ }
1745
+ };
1746
+
1747
+ //
1748
+
1749
+ const GlobalFiltering = {
1750
+ getInitialState: state => {
1751
+ return {
1752
+ globalFilter: undefined,
1753
+ ...state
1754
+ };
1755
+ },
1756
+ getDefaultOptions: table => {
1757
+ return {
1758
+ onGlobalFilterChange: makeStateUpdater('globalFilter', table),
1759
+ globalFilterFn: 'auto',
1760
+ getColumnCanGlobalFilter: column => {
1761
+ var _table$getCoreRowMode;
1762
+ const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
1763
+ return typeof value === 'string' || typeof value === 'number';
1764
+ }
1765
+ };
1766
+ },
1767
+ createColumn: (column, table) => {
1768
+ column.getCanGlobalFilter = () => {
1769
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
1770
+ 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;
1771
+ };
1772
+ },
1773
+ createTable: table => {
1774
+ table.getGlobalAutoFilterFn = () => {
1775
+ return filterFns.includesString;
1776
+ };
1777
+ table.getGlobalFilterFn = () => {
1778
+ var _table$options$filter, _table$options$filter2;
1779
+ const {
1780
+ globalFilterFn: globalFilterFn
1781
+ } = table.options;
1782
+ 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];
1783
+ };
1784
+ table.setGlobalFilter = updater => {
1785
+ table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
1786
+ };
1787
+ table.resetGlobalFilter = defaultState => {
1788
+ table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
1789
+ };
1790
+ }
1791
+ };
1792
+
1793
+ //
1794
+
1795
+ const RowExpanding = {
1796
+ getInitialState: state => {
1797
+ return {
1798
+ expanded: {},
1799
+ ...state
1800
+ };
1801
+ },
1802
+ getDefaultOptions: table => {
1803
+ return {
1804
+ onExpandedChange: makeStateUpdater('expanded', table),
1805
+ paginateExpandedRows: true
1806
+ };
1807
+ },
1808
+ createTable: table => {
1809
+ let registered = false;
1810
+ let queued = false;
1811
+ table._autoResetExpanded = () => {
1812
+ var _ref, _table$options$autoRe;
1813
+ if (!registered) {
1814
+ table._queue(() => {
1815
+ registered = true;
1816
+ });
1817
+ return;
1818
+ }
1819
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
1820
+ if (queued) return;
1821
+ queued = true;
1822
+ table._queue(() => {
1823
+ table.resetExpanded();
1824
+ queued = false;
1825
+ });
1826
+ }
1827
+ };
1828
+ table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
1829
+ table.toggleAllRowsExpanded = expanded => {
1830
+ if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
1831
+ table.setExpanded(true);
1832
+ } else {
1833
+ table.setExpanded({});
1834
+ }
1835
+ };
1836
+ table.resetExpanded = defaultState => {
1837
+ var _table$initialState$e, _table$initialState;
1838
+ table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
1839
+ };
1840
+ table.getCanSomeRowsExpand = () => {
1841
+ return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
1842
+ };
1843
+ table.getToggleAllRowsExpandedHandler = () => {
1844
+ return e => {
1845
+ e.persist == null || e.persist();
1846
+ table.toggleAllRowsExpanded();
1847
+ };
1848
+ };
1849
+ table.getIsSomeRowsExpanded = () => {
1850
+ const expanded = table.getState().expanded;
1851
+ return expanded === true || Object.values(expanded).some(Boolean);
1852
+ };
1853
+ table.getIsAllRowsExpanded = () => {
1854
+ const expanded = table.getState().expanded;
1855
+
1856
+ // If expanded is true, save some cycles and return true
1857
+ if (typeof expanded === 'boolean') {
1858
+ return expanded === true;
1859
+ }
1860
+ if (!Object.keys(expanded).length) {
1861
+ return false;
1862
+ }
1863
+
1864
+ // If any row is not expanded, return false
1865
+ if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
1866
+ return false;
1867
+ }
1868
+
1869
+ // They must all be expanded :shrug:
1870
+ return true;
1871
+ };
1872
+ table.getExpandedDepth = () => {
1873
+ let maxDepth = 0;
1874
+ const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
1875
+ rowIds.forEach(id => {
1876
+ const splitId = id.split('.');
1877
+ maxDepth = Math.max(maxDepth, splitId.length);
1878
+ });
1879
+ return maxDepth;
1880
+ };
1881
+ table.getPreExpandedRowModel = () => table.getSortedRowModel();
1882
+ table.getExpandedRowModel = () => {
1883
+ if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
1884
+ table._getExpandedRowModel = table.options.getExpandedRowModel(table);
1885
+ }
1886
+ if (table.options.manualExpanding || !table._getExpandedRowModel) {
1887
+ return table.getPreExpandedRowModel();
1888
+ }
1889
+ return table._getExpandedRowModel();
1890
+ };
1891
+ },
1892
+ createRow: (row, table) => {
1893
+ row.toggleExpanded = expanded => {
1894
+ table.setExpanded(old => {
1895
+ var _expanded;
1896
+ const exists = old === true ? true : !!(old != null && old[row.id]);
1897
+ let oldExpanded = {};
1898
+ if (old === true) {
1899
+ Object.keys(table.getRowModel().rowsById).forEach(rowId => {
1900
+ oldExpanded[rowId] = true;
1901
+ });
1902
+ } else {
1903
+ oldExpanded = old;
1904
+ }
1905
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
1906
+ if (!exists && expanded) {
1907
+ return {
1908
+ ...oldExpanded,
1909
+ [row.id]: true
1910
+ };
1911
+ }
1912
+ if (exists && !expanded) {
1913
+ const {
1914
+ [row.id]: _,
1915
+ ...rest
1916
+ } = oldExpanded;
1917
+ return rest;
1918
+ }
1919
+ return old;
1920
+ });
1921
+ };
1922
+ row.getIsExpanded = () => {
1923
+ var _table$options$getIsR;
1924
+ const expanded = table.getState().expanded;
1925
+ 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]));
1926
+ };
1927
+ row.getCanExpand = () => {
1928
+ var _table$options$getRow, _table$options$enable, _row$subRows;
1929
+ 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);
1930
+ };
1931
+ row.getIsAllParentsExpanded = () => {
1932
+ let isFullyExpanded = true;
1933
+ let currentRow = row;
1934
+ while (isFullyExpanded && currentRow.parentId) {
1935
+ currentRow = table.getRow(currentRow.parentId, true);
1936
+ isFullyExpanded = currentRow.getIsExpanded();
1937
+ }
1938
+ return isFullyExpanded;
1939
+ };
1940
+ row.getToggleExpandedHandler = () => {
1941
+ const canExpand = row.getCanExpand();
1942
+ return () => {
1943
+ if (!canExpand) return;
1944
+ row.toggleExpanded();
1945
+ };
1946
+ };
1947
+ }
1948
+ };
1949
+
1950
+ //
1951
+
1952
+ const defaultPageIndex = 0;
1953
+ const defaultPageSize = 10;
1954
+ const getDefaultPaginationState = () => ({
1955
+ pageIndex: defaultPageIndex,
1956
+ pageSize: defaultPageSize
1957
+ });
1958
+ const RowPagination = {
1959
+ getInitialState: state => {
1960
+ return {
1961
+ ...state,
1962
+ pagination: {
1963
+ ...getDefaultPaginationState(),
1964
+ ...(state == null ? void 0 : state.pagination)
1965
+ }
1966
+ };
1967
+ },
1968
+ getDefaultOptions: table => {
1969
+ return {
1970
+ onPaginationChange: makeStateUpdater('pagination', table)
1971
+ };
1972
+ },
1973
+ createTable: table => {
1974
+ let registered = false;
1975
+ let queued = false;
1976
+ table._autoResetPageIndex = () => {
1977
+ var _ref, _table$options$autoRe;
1978
+ if (!registered) {
1979
+ table._queue(() => {
1980
+ registered = true;
1981
+ });
1982
+ return;
1983
+ }
1984
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
1985
+ if (queued) return;
1986
+ queued = true;
1987
+ table._queue(() => {
1988
+ table.resetPageIndex();
1989
+ queued = false;
1990
+ });
1991
+ }
1992
+ };
1993
+ table.setPagination = updater => {
1994
+ const safeUpdater = old => {
1995
+ let newState = functionalUpdate(updater, old);
1996
+ return newState;
1997
+ };
1998
+ return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
1999
+ };
2000
+ table.resetPagination = defaultState => {
2001
+ var _table$initialState$p;
2002
+ table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
2003
+ };
2004
+ table.setPageIndex = updater => {
2005
+ table.setPagination(old => {
2006
+ let pageIndex = functionalUpdate(updater, old.pageIndex);
2007
+ const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
2008
+ pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
2009
+ return {
2010
+ ...old,
2011
+ pageIndex
2012
+ };
2013
+ });
2014
+ };
2015
+ table.resetPageIndex = defaultState => {
2016
+ var _table$initialState$p2, _table$initialState;
2017
+ 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);
2018
+ };
2019
+ table.resetPageSize = defaultState => {
2020
+ var _table$initialState$p3, _table$initialState2;
2021
+ 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);
2022
+ };
2023
+ table.setPageSize = updater => {
2024
+ table.setPagination(old => {
2025
+ const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
2026
+ const topRowIndex = old.pageSize * old.pageIndex;
2027
+ const pageIndex = Math.floor(topRowIndex / pageSize);
2028
+ return {
2029
+ ...old,
2030
+ pageIndex,
2031
+ pageSize
2032
+ };
2033
+ });
2034
+ };
2035
+ //deprecated
2036
+ table.setPageCount = updater => table.setPagination(old => {
2037
+ var _table$options$pageCo;
2038
+ let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
2039
+ if (typeof newPageCount === 'number') {
2040
+ newPageCount = Math.max(-1, newPageCount);
2041
+ }
2042
+ return {
2043
+ ...old,
2044
+ pageCount: newPageCount
2045
+ };
2046
+ });
2047
+ table.getPageOptions = memo(() => [table.getPageCount()], pageCount => {
2048
+ let pageOptions = [];
2049
+ if (pageCount && pageCount > 0) {
2050
+ pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
2051
+ }
2052
+ return pageOptions;
2053
+ }, getMemoOptions(table.options, 'debugTable', 'getPageOptions'));
2054
+ table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
2055
+ table.getCanNextPage = () => {
2056
+ const {
2057
+ pageIndex
2058
+ } = table.getState().pagination;
2059
+ const pageCount = table.getPageCount();
2060
+ if (pageCount === -1) {
2061
+ return true;
2062
+ }
2063
+ if (pageCount === 0) {
2064
+ return false;
2065
+ }
2066
+ return pageIndex < pageCount - 1;
2067
+ };
2068
+ table.previousPage = () => {
2069
+ return table.setPageIndex(old => old - 1);
2070
+ };
2071
+ table.nextPage = () => {
2072
+ return table.setPageIndex(old => {
2073
+ return old + 1;
2074
+ });
2075
+ };
2076
+ table.firstPage = () => {
2077
+ return table.setPageIndex(0);
2078
+ };
2079
+ table.lastPage = () => {
2080
+ return table.setPageIndex(table.getPageCount() - 1);
2081
+ };
2082
+ table.getPrePaginationRowModel = () => table.getExpandedRowModel();
2083
+ table.getPaginationRowModel = () => {
2084
+ if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
2085
+ table._getPaginationRowModel = table.options.getPaginationRowModel(table);
2086
+ }
2087
+ if (table.options.manualPagination || !table._getPaginationRowModel) {
2088
+ return table.getPrePaginationRowModel();
2089
+ }
2090
+ return table._getPaginationRowModel();
2091
+ };
2092
+ table.getPageCount = () => {
2093
+ var _table$options$pageCo2;
2094
+ return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
2095
+ };
2096
+ table.getRowCount = () => {
2097
+ var _table$options$rowCou;
2098
+ return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
2099
+ };
2100
+ }
2101
+ };
2102
+
2103
+ //
2104
+
2105
+ const getDefaultRowPinningState = () => ({
2106
+ top: [],
2107
+ bottom: []
2108
+ });
2109
+ const RowPinning = {
2110
+ getInitialState: state => {
2111
+ return {
2112
+ rowPinning: getDefaultRowPinningState(),
2113
+ ...state
2114
+ };
2115
+ },
2116
+ getDefaultOptions: table => {
2117
+ return {
2118
+ onRowPinningChange: makeStateUpdater('rowPinning', table)
2119
+ };
2120
+ },
2121
+ createRow: (row, table) => {
2122
+ row.pin = (position, includeLeafRows, includeParentRows) => {
2123
+ const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
2124
+ let {
2125
+ id
2126
+ } = _ref;
2127
+ return id;
2128
+ }) : [];
2129
+ const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
2130
+ let {
2131
+ id
2132
+ } = _ref2;
2133
+ return id;
2134
+ }) : [];
2135
+ const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
2136
+ table.setRowPinning(old => {
2137
+ var _old$top3, _old$bottom3;
2138
+ if (position === 'bottom') {
2139
+ var _old$top, _old$bottom;
2140
+ return {
2141
+ top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter(d => !(rowIds != null && rowIds.has(d))),
2142
+ bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
2143
+ };
2144
+ }
2145
+ if (position === 'top') {
2146
+ var _old$top2, _old$bottom2;
2147
+ return {
2148
+ top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
2149
+ bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter(d => !(rowIds != null && rowIds.has(d)))
2150
+ };
2151
+ }
2152
+ return {
2153
+ top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter(d => !(rowIds != null && rowIds.has(d))),
2154
+ bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter(d => !(rowIds != null && rowIds.has(d)))
2155
+ };
2156
+ });
2157
+ };
2158
+ row.getCanPin = () => {
2159
+ var _ref3;
2160
+ const {
2161
+ enableRowPinning,
2162
+ enablePinning
2163
+ } = table.options;
2164
+ if (typeof enableRowPinning === 'function') {
2165
+ return enableRowPinning(row);
2166
+ }
2167
+ return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
2168
+ };
2169
+ row.getIsPinned = () => {
2170
+ const rowIds = [row.id];
2171
+ const {
2172
+ top,
2173
+ bottom
2174
+ } = table.getState().rowPinning;
2175
+ const isTop = rowIds.some(d => top == null ? void 0 : top.includes(d));
2176
+ const isBottom = rowIds.some(d => bottom == null ? void 0 : bottom.includes(d));
2177
+ return isTop ? 'top' : isBottom ? 'bottom' : false;
2178
+ };
2179
+ row.getPinnedIndex = () => {
2180
+ var _ref4, _visiblePinnedRowIds$;
2181
+ const position = row.getIsPinned();
2182
+ if (!position) return -1;
2183
+ const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
2184
+ let {
2185
+ id
2186
+ } = _ref5;
2187
+ return id;
2188
+ });
2189
+ return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
2190
+ };
2191
+ },
2192
+ createTable: table => {
2193
+ table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
2194
+ table.resetRowPinning = defaultState => {
2195
+ var _table$initialState$r, _table$initialState;
2196
+ return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
2197
+ };
2198
+ table.getIsSomeRowsPinned = position => {
2199
+ var _pinningState$positio;
2200
+ const pinningState = table.getState().rowPinning;
2201
+ if (!position) {
2202
+ var _pinningState$top, _pinningState$bottom;
2203
+ return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
2204
+ }
2205
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
2206
+ };
2207
+ table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
2208
+ var _table$options$keepPi;
2209
+ const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
2210
+ //get all rows that are pinned even if they would not be otherwise visible
2211
+ //account for expanded parent rows, but not pagination or filtering
2212
+ (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => {
2213
+ const row = table.getRow(rowId, true);
2214
+ return row.getIsAllParentsExpanded() ? row : null;
2215
+ }) :
2216
+ //else get only visible rows that are pinned
2217
+ (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => visibleRows.find(row => row.id === rowId));
2218
+ return rows.filter(Boolean).map(d => ({
2219
+ ...d,
2220
+ position
2221
+ }));
2222
+ };
2223
+ table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
2224
+ table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
2225
+ table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
2226
+ const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
2227
+ return allRows.filter(d => !topAndBottom.has(d.id));
2228
+ }, getMemoOptions(table.options, 'debugRows', 'getCenterRows'));
2229
+ }
2230
+ };
2231
+
2232
+ //
2233
+
2234
+ const RowSelection = {
2235
+ getInitialState: state => {
2236
+ return {
2237
+ rowSelection: {},
2238
+ ...state
2239
+ };
2240
+ },
2241
+ getDefaultOptions: table => {
2242
+ return {
2243
+ onRowSelectionChange: makeStateUpdater('rowSelection', table),
2244
+ enableRowSelection: true,
2245
+ enableMultiRowSelection: true,
2246
+ enableSubRowSelection: true
2247
+ // enableGroupingRowSelection: false,
2248
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
2249
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
2250
+ };
2251
+ },
2252
+ createTable: table => {
2253
+ table.setRowSelection = updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
2254
+ table.resetRowSelection = defaultState => {
2255
+ var _table$initialState$r;
2256
+ return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
2257
+ };
2258
+ table.toggleAllRowsSelected = value => {
2259
+ table.setRowSelection(old => {
2260
+ value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
2261
+ const rowSelection = {
2262
+ ...old
2263
+ };
2264
+ const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
2265
+
2266
+ // We don't use `mutateRowIsSelected` here for performance reasons.
2267
+ // All of the rows are flat already, so it wouldn't be worth it
2268
+ if (value) {
2269
+ preGroupedFlatRows.forEach(row => {
2270
+ if (!row.getCanSelect()) {
2271
+ return;
2272
+ }
2273
+ rowSelection[row.id] = true;
2274
+ });
2275
+ } else {
2276
+ preGroupedFlatRows.forEach(row => {
2277
+ delete rowSelection[row.id];
2278
+ });
2279
+ }
2280
+ return rowSelection;
2281
+ });
2282
+ };
2283
+ table.toggleAllPageRowsSelected = value => table.setRowSelection(old => {
2284
+ const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
2285
+ const rowSelection = {
2286
+ ...old
2287
+ };
2288
+ table.getRowModel().rows.forEach(row => {
2289
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
2290
+ });
2291
+ return rowSelection;
2292
+ });
2293
+
2294
+ // addRowSelectionRange: rowId => {
2295
+ // const {
2296
+ // rows,
2297
+ // rowsById,
2298
+ // options: { selectGroupingRows, selectSubRows },
2299
+ // } = table
2300
+
2301
+ // const findSelectedRow = (rows: Row[]) => {
2302
+ // let found
2303
+ // rows.find(d => {
2304
+ // if (d.getIsSelected()) {
2305
+ // found = d
2306
+ // return true
2307
+ // }
2308
+ // const subFound = findSelectedRow(d.subRows || [])
2309
+ // if (subFound) {
2310
+ // found = subFound
2311
+ // return true
2312
+ // }
2313
+ // return false
2314
+ // })
2315
+ // return found
2316
+ // }
2317
+
2318
+ // const firstRow = findSelectedRow(rows) || rows[0]
2319
+ // const lastRow = rowsById[rowId]
2320
+
2321
+ // let include = false
2322
+ // const selectedRowIds = {}
2323
+
2324
+ // const addRow = (row: Row) => {
2325
+ // mutateRowIsSelected(selectedRowIds, row.id, true, {
2326
+ // rowsById,
2327
+ // selectGroupingRows: selectGroupingRows!,
2328
+ // selectSubRows: selectSubRows!,
2329
+ // })
2330
+ // }
2331
+
2332
+ // table.rows.forEach(row => {
2333
+ // const isFirstRow = row.id === firstRow.id
2334
+ // const isLastRow = row.id === lastRow.id
2335
+
2336
+ // if (isFirstRow || isLastRow) {
2337
+ // if (!include) {
2338
+ // include = true
2339
+ // } else if (include) {
2340
+ // addRow(row)
2341
+ // include = false
2342
+ // }
2343
+ // }
2344
+
2345
+ // if (include) {
2346
+ // addRow(row)
2347
+ // }
2348
+ // })
2349
+
2350
+ // table.setRowSelection(selectedRowIds)
2351
+ // },
2352
+ table.getPreSelectedRowModel = () => table.getCoreRowModel();
2353
+ table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
2354
+ if (!Object.keys(rowSelection).length) {
2355
+ return {
2356
+ rows: [],
2357
+ flatRows: [],
2358
+ rowsById: {}
2359
+ };
2360
+ }
2361
+ return selectRowsFn(table, rowModel);
2362
+ }, getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel'));
2363
+ table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
2364
+ if (!Object.keys(rowSelection).length) {
2365
+ return {
2366
+ rows: [],
2367
+ flatRows: [],
2368
+ rowsById: {}
2369
+ };
2370
+ }
2371
+ return selectRowsFn(table, rowModel);
2372
+ }, getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel'));
2373
+ table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
2374
+ if (!Object.keys(rowSelection).length) {
2375
+ return {
2376
+ rows: [],
2377
+ flatRows: [],
2378
+ rowsById: {}
2379
+ };
2380
+ }
2381
+ return selectRowsFn(table, rowModel);
2382
+ }, getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel'));
2383
+
2384
+ ///
2385
+
2386
+ // getGroupingRowCanSelect: rowId => {
2387
+ // const row = table.getRow(rowId)
2388
+
2389
+ // if (!row) {
2390
+ // throw new Error()
2391
+ // }
2392
+
2393
+ // if (typeof table.options.enableGroupingRowSelection === 'function') {
2394
+ // return table.options.enableGroupingRowSelection(row)
2395
+ // }
2396
+
2397
+ // return table.options.enableGroupingRowSelection ?? false
2398
+ // },
2399
+
2400
+ table.getIsAllRowsSelected = () => {
2401
+ const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
2402
+ const {
2403
+ rowSelection
2404
+ } = table.getState();
2405
+ let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
2406
+ if (isAllRowsSelected) {
2407
+ if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
2408
+ isAllRowsSelected = false;
2409
+ }
2410
+ }
2411
+ return isAllRowsSelected;
2412
+ };
2413
+ table.getIsAllPageRowsSelected = () => {
2414
+ const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
2415
+ const {
2416
+ rowSelection
2417
+ } = table.getState();
2418
+ let isAllPageRowsSelected = !!paginationFlatRows.length;
2419
+ if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
2420
+ isAllPageRowsSelected = false;
2421
+ }
2422
+ return isAllPageRowsSelected;
2423
+ };
2424
+ table.getIsSomeRowsSelected = () => {
2425
+ var _table$getState$rowSe;
2426
+ const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2427
+ return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
2428
+ };
2429
+ table.getIsSomePageRowsSelected = () => {
2430
+ const paginationFlatRows = table.getPaginationRowModel().flatRows;
2431
+ return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
2432
+ };
2433
+ table.getToggleAllRowsSelectedHandler = () => {
2434
+ return e => {
2435
+ table.toggleAllRowsSelected(e.target.checked);
2436
+ };
2437
+ };
2438
+ table.getToggleAllPageRowsSelectedHandler = () => {
2439
+ return e => {
2440
+ table.toggleAllPageRowsSelected(e.target.checked);
2441
+ };
2442
+ };
2443
+ },
2444
+ createRow: (row, table) => {
2445
+ row.toggleSelected = (value, opts) => {
2446
+ const isSelected = row.getIsSelected();
2447
+ table.setRowSelection(old => {
2448
+ var _opts$selectChildren;
2449
+ value = typeof value !== 'undefined' ? value : !isSelected;
2450
+ if (row.getCanSelect() && isSelected === value) {
2451
+ return old;
2452
+ }
2453
+ const selectedRowIds = {
2454
+ ...old
2455
+ };
2456
+ mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
2457
+ return selectedRowIds;
2458
+ });
2459
+ };
2460
+ row.getIsSelected = () => {
2461
+ const {
2462
+ rowSelection
2463
+ } = table.getState();
2464
+ return isRowSelected(row, rowSelection);
2465
+ };
2466
+ row.getIsSomeSelected = () => {
2467
+ const {
2468
+ rowSelection
2469
+ } = table.getState();
2470
+ return isSubRowSelected(row, rowSelection) === 'some';
2471
+ };
2472
+ row.getIsAllSubRowsSelected = () => {
2473
+ const {
2474
+ rowSelection
2475
+ } = table.getState();
2476
+ return isSubRowSelected(row, rowSelection) === 'all';
2477
+ };
2478
+ row.getCanSelect = () => {
2479
+ var _table$options$enable;
2480
+ if (typeof table.options.enableRowSelection === 'function') {
2481
+ return table.options.enableRowSelection(row);
2482
+ }
2483
+ return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
2484
+ };
2485
+ row.getCanSelectSubRows = () => {
2486
+ var _table$options$enable2;
2487
+ if (typeof table.options.enableSubRowSelection === 'function') {
2488
+ return table.options.enableSubRowSelection(row);
2489
+ }
2490
+ return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
2491
+ };
2492
+ row.getCanMultiSelect = () => {
2493
+ var _table$options$enable3;
2494
+ if (typeof table.options.enableMultiRowSelection === 'function') {
2495
+ return table.options.enableMultiRowSelection(row);
2496
+ }
2497
+ return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
2498
+ };
2499
+ row.getToggleSelectedHandler = () => {
2500
+ const canSelect = row.getCanSelect();
2501
+ return e => {
2502
+ var _target;
2503
+ if (!canSelect) return;
2504
+ row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2505
+ };
2506
+ };
2507
+ }
2508
+ };
2509
+ const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
2510
+ var _row$subRows;
2511
+ const row = table.getRow(id, true);
2512
+
2513
+ // const isGrouped = row.getIsGrouped()
2514
+
2515
+ // if ( // TODO: enforce grouping row selection rules
2516
+ // !isGrouped ||
2517
+ // (isGrouped && table.options.enableGroupingRowSelection)
2518
+ // ) {
2519
+ if (value) {
2520
+ if (!row.getCanMultiSelect()) {
2521
+ Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
2522
+ }
2523
+ if (row.getCanSelect()) {
2524
+ selectedRowIds[id] = true;
2525
+ }
2526
+ } else {
2527
+ delete selectedRowIds[id];
2528
+ }
2529
+ // }
2530
+
2531
+ if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2532
+ row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
2533
+ }
2534
+ };
2535
+ function selectRowsFn(table, rowModel) {
2536
+ const rowSelection = table.getState().rowSelection;
2537
+ const newSelectedFlatRows = [];
2538
+ const newSelectedRowsById = {};
2539
+
2540
+ // Filters top level and nested rows
2541
+ const recurseRows = function (rows, depth) {
2542
+ return rows.map(row => {
2543
+ var _row$subRows2;
2544
+ const isSelected = isRowSelected(row, rowSelection);
2545
+ if (isSelected) {
2546
+ newSelectedFlatRows.push(row);
2547
+ newSelectedRowsById[row.id] = row;
2548
+ }
2549
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2550
+ row = {
2551
+ ...row,
2552
+ subRows: recurseRows(row.subRows)
2553
+ };
2554
+ }
2555
+ if (isSelected) {
2556
+ return row;
2557
+ }
2558
+ }).filter(Boolean);
2559
+ };
2560
+ return {
2561
+ rows: recurseRows(rowModel.rows),
2562
+ flatRows: newSelectedFlatRows,
2563
+ rowsById: newSelectedRowsById
2564
+ };
2565
+ }
2566
+ function isRowSelected(row, selection) {
2567
+ var _selection$row$id;
2568
+ return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
2569
+ }
2570
+ function isSubRowSelected(row, selection, table) {
2571
+ var _row$subRows3;
2572
+ if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
2573
+ let allChildrenSelected = true;
2574
+ let someSelected = false;
2575
+ row.subRows.forEach(subRow => {
2576
+ // Bail out early if we know both of these
2577
+ if (someSelected && !allChildrenSelected) {
2578
+ return;
2579
+ }
2580
+ if (subRow.getCanSelect()) {
2581
+ if (isRowSelected(subRow, selection)) {
2582
+ someSelected = true;
2583
+ } else {
2584
+ allChildrenSelected = false;
2585
+ }
2586
+ }
2587
+
2588
+ // Check row selection of nested subrows
2589
+ if (subRow.subRows && subRow.subRows.length) {
2590
+ const subRowChildrenSelected = isSubRowSelected(subRow, selection);
2591
+ if (subRowChildrenSelected === 'all') {
2592
+ someSelected = true;
2593
+ } else if (subRowChildrenSelected === 'some') {
2594
+ someSelected = true;
2595
+ allChildrenSelected = false;
2596
+ } else {
2597
+ allChildrenSelected = false;
2598
+ }
2599
+ }
2600
+ });
2601
+ return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
2602
+ }
2603
+
2604
+ const reSplitAlphaNumeric = /([0-9]+)/gm;
2605
+ const alphanumeric = (rowA, rowB, columnId) => {
2606
+ return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2607
+ };
2608
+ const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
2609
+ return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2610
+ };
2611
+
2612
+ // The text filter is more basic (less numeric support)
2613
+ // but is much faster
2614
+ const text = (rowA, rowB, columnId) => {
2615
+ return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2616
+ };
2617
+
2618
+ // The text filter is more basic (less numeric support)
2619
+ // but is much faster
2620
+ const textCaseSensitive = (rowA, rowB, columnId) => {
2621
+ return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2622
+ };
2623
+ const datetime = (rowA, rowB, columnId) => {
2624
+ const a = rowA.getValue(columnId);
2625
+ const b = rowB.getValue(columnId);
2626
+
2627
+ // Can handle nullish values
2628
+ // Use > and < because == (and ===) doesn't work with
2629
+ // Date objects (would require calling getTime()).
2630
+ return a > b ? 1 : a < b ? -1 : 0;
2631
+ };
2632
+ const basic = (rowA, rowB, columnId) => {
2633
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2634
+ };
2635
+
2636
+ // Utils
2637
+
2638
+ function compareBasic(a, b) {
2639
+ return a === b ? 0 : a > b ? 1 : -1;
2640
+ }
2641
+ function toString(a) {
2642
+ if (typeof a === 'number') {
2643
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
2644
+ return '';
2645
+ }
2646
+ return String(a);
2647
+ }
2648
+ if (typeof a === 'string') {
2649
+ return a;
2650
+ }
2651
+ return '';
2652
+ }
2653
+
2654
+ // Mixed sorting is slow, but very inclusive of many edge cases.
2655
+ // It handles numbers, mixed alphanumeric combinations, and even
2656
+ // null, undefined, and Infinity
2657
+ function compareAlphanumeric(aStr, bStr) {
2658
+ // Split on number groups, but keep the delimiter
2659
+ // Then remove falsey split values
2660
+ const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2661
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
2662
+
2663
+ // While
2664
+ while (a.length && b.length) {
2665
+ const aa = a.shift();
2666
+ const bb = b.shift();
2667
+ const an = parseInt(aa, 10);
2668
+ const bn = parseInt(bb, 10);
2669
+ const combo = [an, bn].sort();
2670
+
2671
+ // Both are string
2672
+ if (isNaN(combo[0])) {
2673
+ if (aa > bb) {
2674
+ return 1;
2675
+ }
2676
+ if (bb > aa) {
2677
+ return -1;
2678
+ }
2679
+ continue;
2680
+ }
2681
+
2682
+ // One is a string, one is a number
2683
+ if (isNaN(combo[1])) {
2684
+ return isNaN(an) ? -1 : 1;
2685
+ }
2686
+
2687
+ // Both are numbers
2688
+ if (an > bn) {
2689
+ return 1;
2690
+ }
2691
+ if (bn > an) {
2692
+ return -1;
2693
+ }
2694
+ }
2695
+ return a.length - b.length;
2696
+ }
2697
+
2698
+ // Exports
2699
+
2700
+ const sortingFns = {
2701
+ alphanumeric,
2702
+ alphanumericCaseSensitive,
2703
+ text,
2704
+ textCaseSensitive,
2705
+ datetime,
2706
+ basic
2707
+ };
2708
+
2709
+ //
2710
+
2711
+ const RowSorting = {
2712
+ getInitialState: state => {
2713
+ return {
2714
+ sorting: [],
2715
+ ...state
2716
+ };
2717
+ },
2718
+ getDefaultColumnDef: () => {
2719
+ return {
2720
+ sortingFn: 'auto',
2721
+ sortUndefined: 1
2722
+ };
2723
+ },
2724
+ getDefaultOptions: table => {
2725
+ return {
2726
+ onSortingChange: makeStateUpdater('sorting', table),
2727
+ isMultiSortEvent: e => {
2728
+ return e.shiftKey;
2729
+ }
2730
+ };
2731
+ },
2732
+ createColumn: (column, table) => {
2733
+ column.getAutoSortingFn = () => {
2734
+ const firstRows = table.getFilteredRowModel().flatRows.slice(10);
2735
+ let isString = false;
2736
+ for (const row of firstRows) {
2737
+ const value = row == null ? void 0 : row.getValue(column.id);
2738
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2739
+ return sortingFns.datetime;
2740
+ }
2741
+ if (typeof value === 'string') {
2742
+ isString = true;
2743
+ if (value.split(reSplitAlphaNumeric).length > 1) {
2744
+ return sortingFns.alphanumeric;
2745
+ }
2746
+ }
2747
+ }
2748
+ if (isString) {
2749
+ return sortingFns.text;
2750
+ }
2751
+ return sortingFns.basic;
2752
+ };
2753
+ column.getAutoSortDir = () => {
2754
+ const firstRow = table.getFilteredRowModel().flatRows[0];
2755
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2756
+ if (typeof value === 'string') {
2757
+ return 'asc';
2758
+ }
2759
+ return 'desc';
2760
+ };
2761
+ column.getSortingFn = () => {
2762
+ var _table$options$sortin, _table$options$sortin2;
2763
+ if (!column) {
2764
+ throw new Error();
2765
+ }
2766
+ 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];
2767
+ };
2768
+ column.toggleSorting = (desc, multi) => {
2769
+ // if (column.columns.length) {
2770
+ // column.columns.forEach((c, i) => {
2771
+ // if (c.id) {
2772
+ // table.toggleColumnSorting(c.id, undefined, multi || !!i)
2773
+ // }
2774
+ // })
2775
+ // return
2776
+ // }
2777
+
2778
+ // this needs to be outside of table.setSorting to be in sync with rerender
2779
+ const nextSortingOrder = column.getNextSortingOrder();
2780
+ const hasManualValue = typeof desc !== 'undefined' && desc !== null;
2781
+ table.setSorting(old => {
2782
+ // Find any existing sorting for this column
2783
+ const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2784
+ const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2785
+ let newSorting = [];
2786
+
2787
+ // What should we do with this sort action?
2788
+ let sortAction;
2789
+ let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
2790
+
2791
+ // Multi-mode
2792
+ if (old != null && old.length && column.getCanMultiSort() && multi) {
2793
+ if (existingSorting) {
2794
+ sortAction = 'toggle';
2795
+ } else {
2796
+ sortAction = 'add';
2797
+ }
2798
+ } else {
2799
+ // Normal mode
2800
+ if (old != null && old.length && existingIndex !== old.length - 1) {
2801
+ sortAction = 'replace';
2802
+ } else if (existingSorting) {
2803
+ sortAction = 'toggle';
2804
+ } else {
2805
+ sortAction = 'replace';
2806
+ }
2807
+ }
2808
+
2809
+ // Handle toggle states that will remove the sorting
2810
+ if (sortAction === 'toggle') {
2811
+ // If we are "actually" toggling (not a manual set value), should we remove the sorting?
2812
+ if (!hasManualValue) {
2813
+ // Is our intention to remove?
2814
+ if (!nextSortingOrder) {
2815
+ sortAction = 'remove';
2816
+ }
2817
+ }
2818
+ }
2819
+ if (sortAction === 'add') {
2820
+ var _table$options$maxMul;
2821
+ newSorting = [...old, {
2822
+ id: column.id,
2823
+ desc: nextDesc
2824
+ }];
2825
+ // Take latest n columns
2826
+ newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
2827
+ } else if (sortAction === 'toggle') {
2828
+ // This flips (or sets) the
2829
+ newSorting = old.map(d => {
2830
+ if (d.id === column.id) {
2831
+ return {
2832
+ ...d,
2833
+ desc: nextDesc
2834
+ };
2835
+ }
2836
+ return d;
2837
+ });
2838
+ } else if (sortAction === 'remove') {
2839
+ newSorting = old.filter(d => d.id !== column.id);
2840
+ } else {
2841
+ newSorting = [{
2842
+ id: column.id,
2843
+ desc: nextDesc
2844
+ }];
2845
+ }
2846
+ return newSorting;
2847
+ });
2848
+ };
2849
+ column.getFirstSortDir = () => {
2850
+ var _ref, _column$columnDef$sor;
2851
+ const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
2852
+ return sortDescFirst ? 'desc' : 'asc';
2853
+ };
2854
+ column.getNextSortingOrder = multi => {
2855
+ var _table$options$enable, _table$options$enable2;
2856
+ const firstSortDirection = column.getFirstSortDir();
2857
+ const isSorted = column.getIsSorted();
2858
+ if (!isSorted) {
2859
+ return firstSortDirection;
2860
+ }
2861
+ if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && (
2862
+ // If enableSortRemove, enable in general
2863
+ multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
2864
+ ) {
2865
+ return false;
2866
+ }
2867
+ return isSorted === 'desc' ? 'asc' : 'desc';
2868
+ };
2869
+ column.getCanSort = () => {
2870
+ var _column$columnDef$ena, _table$options$enable3;
2871
+ 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;
2872
+ };
2873
+ column.getCanMultiSort = () => {
2874
+ var _ref2, _column$columnDef$ena2;
2875
+ return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
2876
+ };
2877
+ column.getIsSorted = () => {
2878
+ var _table$getState$sorti;
2879
+ const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
2880
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2881
+ };
2882
+ column.getSortIndex = () => {
2883
+ var _table$getState$sorti2, _table$getState$sorti3;
2884
+ 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;
2885
+ };
2886
+ column.clearSorting = () => {
2887
+ //clear sorting for just 1 column
2888
+ table.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
2889
+ };
2890
+ column.getToggleSortingHandler = () => {
2891
+ const canSort = column.getCanSort();
2892
+ return e => {
2893
+ if (!canSort) return;
2894
+ e.persist == null || e.persist();
2895
+ column.toggleSorting == null || column.toggleSorting(undefined, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
2896
+ };
2897
+ };
2898
+ },
2899
+ createTable: table => {
2900
+ table.setSorting = updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
2901
+ table.resetSorting = defaultState => {
2902
+ var _table$initialState$s, _table$initialState;
2903
+ table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
2904
+ };
2905
+ table.getPreSortedRowModel = () => table.getGroupedRowModel();
2906
+ table.getSortedRowModel = () => {
2907
+ if (!table._getSortedRowModel && table.options.getSortedRowModel) {
2908
+ table._getSortedRowModel = table.options.getSortedRowModel(table);
2909
+ }
2910
+ if (table.options.manualSorting || !table._getSortedRowModel) {
2911
+ return table.getPreSortedRowModel();
2912
+ }
2913
+ return table._getSortedRowModel();
2914
+ };
2915
+ }
2916
+ };
2917
+
2918
+ const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
2919
+ //depends on ColumnFaceting
2920
+ GlobalFiltering,
2921
+ //depends on ColumnFiltering
2922
+ RowSorting, ColumnGrouping,
2923
+ //depends on RowSorting
2924
+ RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
2925
+
2926
+ //
2927
+
2928
+ function createTable(options) {
2929
+ var _options$_features, _options$initialState;
2930
+ if (process.env.NODE_ENV !== 'production' && (options.debugAll || options.debugTable)) {
2931
+ console.info('Creating Table Instance...');
2932
+ }
2933
+ const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
2934
+ let table = {
2935
+ _features
2936
+ };
2937
+ const defaultOptions = table._features.reduce((obj, feature) => {
2938
+ return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
2939
+ }, {});
2940
+ const mergeOptions = options => {
2941
+ if (table.options.mergeOptions) {
2942
+ return table.options.mergeOptions(defaultOptions, options);
2943
+ }
2944
+ return {
2945
+ ...defaultOptions,
2946
+ ...options
2947
+ };
2948
+ };
2949
+ const coreInitialState = {};
2950
+ let initialState = {
2951
+ ...coreInitialState,
2952
+ ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
2953
+ };
2954
+ table._features.forEach(feature => {
2955
+ var _feature$getInitialSt;
2956
+ initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
2957
+ });
2958
+ const queued = [];
2959
+ let queuedTimeout = false;
2960
+ const coreInstance = {
2961
+ _features,
2962
+ options: {
2963
+ ...defaultOptions,
2964
+ ...options
2965
+ },
2966
+ initialState,
2967
+ _queue: cb => {
2968
+ queued.push(cb);
2969
+ if (!queuedTimeout) {
2970
+ queuedTimeout = true;
2971
+
2972
+ // Schedule a microtask to run the queued callbacks after
2973
+ // the current call stack (render, etc) has finished.
2974
+ Promise.resolve().then(() => {
2975
+ while (queued.length) {
2976
+ queued.shift()();
2977
+ }
2978
+ queuedTimeout = false;
2979
+ }).catch(error => setTimeout(() => {
2980
+ throw error;
2981
+ }));
2982
+ }
2983
+ },
2984
+ reset: () => {
2985
+ table.setState(table.initialState);
2986
+ },
2987
+ setOptions: updater => {
2988
+ const newOptions = functionalUpdate(updater, table.options);
2989
+ table.options = mergeOptions(newOptions);
2990
+ },
2991
+ getState: () => {
2992
+ return table.options.state;
2993
+ },
2994
+ setState: updater => {
2995
+ table.options.onStateChange == null || table.options.onStateChange(updater);
2996
+ },
2997
+ _getRowId: (row, index, parent) => {
2998
+ var _table$options$getRow;
2999
+ 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}`;
3000
+ },
3001
+ getCoreRowModel: () => {
3002
+ if (!table._getCoreRowModel) {
3003
+ table._getCoreRowModel = table.options.getCoreRowModel(table);
3004
+ }
3005
+ return table._getCoreRowModel();
3006
+ },
3007
+ // The final calls start at the bottom of the model,
3008
+ // expanded rows, which then work their way up
3009
+
3010
+ getRowModel: () => {
3011
+ return table.getPaginationRowModel();
3012
+ },
3013
+ //in next version, we should just pass in the row model as the optional 2nd arg
3014
+ getRow: (id, searchAll) => {
3015
+ let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
3016
+ if (!row) {
3017
+ row = table.getCoreRowModel().rowsById[id];
3018
+ if (!row) {
3019
+ if (process.env.NODE_ENV !== 'production') {
3020
+ throw new Error(`getRow could not find row with ID: ${id}`);
3021
+ }
3022
+ throw new Error();
3023
+ }
3024
+ }
3025
+ return row;
3026
+ },
3027
+ _getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
3028
+ var _defaultColumn;
3029
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
3030
+ return {
3031
+ header: props => {
3032
+ const resolvedColumnDef = props.header.column.columnDef;
3033
+ if (resolvedColumnDef.accessorKey) {
3034
+ return resolvedColumnDef.accessorKey;
3035
+ }
3036
+ if (resolvedColumnDef.accessorFn) {
3037
+ return resolvedColumnDef.id;
3038
+ }
3039
+ return null;
3040
+ },
3041
+ // footer: props => props.header.column.id,
3042
+ cell: props => {
3043
+ var _props$renderValue$to, _props$renderValue;
3044
+ return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
3045
+ },
3046
+ ...table._features.reduce((obj, feature) => {
3047
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
3048
+ }, {}),
3049
+ ...defaultColumn
3050
+ };
3051
+ }, getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')),
3052
+ _getColumnDefs: () => table.options.columns,
3053
+ getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
3054
+ const recurseColumns = function (columnDefs, parent, depth) {
3055
+ if (depth === void 0) {
3056
+ depth = 0;
3057
+ }
3058
+ return columnDefs.map(columnDef => {
3059
+ const column = createColumn(table, columnDef, depth, parent);
3060
+ const groupingColumnDef = columnDef;
3061
+ column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
3062
+ return column;
3063
+ });
3064
+ };
3065
+ return recurseColumns(columnDefs);
3066
+ }, getMemoOptions(options, 'debugColumns', 'getAllColumns')),
3067
+ getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
3068
+ return allColumns.flatMap(column => {
3069
+ return column.getFlatColumns();
3070
+ });
3071
+ }, getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')),
3072
+ _getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
3073
+ return flatColumns.reduce((acc, column) => {
3074
+ acc[column.id] = column;
3075
+ return acc;
3076
+ }, {});
3077
+ }, getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')),
3078
+ getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
3079
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
3080
+ return orderColumns(leafColumns);
3081
+ }, getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')),
3082
+ getColumn: columnId => {
3083
+ const column = table._getAllFlatColumnsById()[columnId];
3084
+ if (process.env.NODE_ENV !== 'production' && !column) {
3085
+ console.error(`[Table] Column with id '${columnId}' does not exist.`);
3086
+ }
3087
+ return column;
3088
+ }
3089
+ };
3090
+ Object.assign(table, coreInstance);
3091
+ for (let index = 0; index < table._features.length; index++) {
3092
+ const feature = table._features[index];
3093
+ feature == null || feature.createTable == null || feature.createTable(table);
3094
+ }
3095
+ return table;
3096
+ }
3097
+
3098
+ function getCoreRowModel() {
3099
+ return table => memo(() => [table.options.data], data => {
3100
+ const rowModel = {
3101
+ rows: [],
3102
+ flatRows: [],
3103
+ rowsById: {}
3104
+ };
3105
+ const accessRows = function (originalRows, depth, parentRow) {
3106
+ if (depth === void 0) {
3107
+ depth = 0;
3108
+ }
3109
+ const rows = [];
3110
+ for (let i = 0; i < originalRows.length; i++) {
3111
+ // This could be an expensive check at scale, so we should move it somewhere else, but where?
3112
+ // if (!id) {
3113
+ // if (process.env.NODE_ENV !== 'production') {
3114
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3115
+ // }
3116
+ // }
3117
+
3118
+ // Make the row
3119
+ const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
3120
+
3121
+ // Keep track of every row in a flat array
3122
+ rowModel.flatRows.push(row);
3123
+ // Also keep track of every row by its ID
3124
+ rowModel.rowsById[row.id] = row;
3125
+ // Push table row into parent
3126
+ rows.push(row);
3127
+
3128
+ // Get the original subrows
3129
+ if (table.options.getSubRows) {
3130
+ var _row$originalSubRows;
3131
+ row.originalSubRows = table.options.getSubRows(originalRows[i], i);
3132
+
3133
+ // Then recursively access them
3134
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3135
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3136
+ }
3137
+ }
3138
+ }
3139
+ return rows;
3140
+ };
3141
+ rowModel.rows = accessRows(data);
3142
+ return rowModel;
3143
+ }, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
3144
+ }
3145
+
3146
+ /**
3147
+ * react-table
3148
+ *
3149
+ * Copyright (c) TanStack
3150
+ *
3151
+ * This source code is licensed under the MIT license found in the
3152
+ * LICENSE.md file in the root directory of this source tree.
3153
+ *
3154
+ * @license MIT
3155
+ */
3156
+
3157
+ //
3158
+
3159
+ /**
3160
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
3161
+ */
3162
+ function flexRender(Comp, props) {
3163
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
3164
+ }
3165
+ function isReactComponent(component) {
3166
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
3167
+ }
3168
+ function isClassComponent(component) {
3169
+ return typeof component === 'function' && (() => {
3170
+ const proto = Object.getPrototypeOf(component);
3171
+ return proto.prototype && proto.prototype.isReactComponent;
3172
+ })();
3173
+ }
3174
+ function isExoticComponent(component) {
3175
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
3176
+ }
3177
+ function useReactTable(options) {
3178
+ // Compose in the generic options to the user options
3179
+ const resolvedOptions = {
3180
+ state: {},
3181
+ // Dummy state
3182
+ onStateChange: () => {},
3183
+ // noop
3184
+ renderFallbackValue: null,
3185
+ ...options
3186
+ };
3187
+
3188
+ // Create a new table and store it in state
3189
+ const [tableRef] = React__namespace.useState(() => ({
3190
+ current: createTable(resolvedOptions)
3191
+ }));
3192
+
3193
+ // By default, manage table state here using the table's initial state
3194
+ const [state, setState] = React__namespace.useState(() => tableRef.current.initialState);
3195
+
3196
+ // Compose the default state above with any user state. This will allow the user
3197
+ // to only control a subset of the state if desired.
3198
+ tableRef.current.setOptions(prev => ({
3199
+ ...prev,
3200
+ ...options,
3201
+ state: {
3202
+ ...state,
3203
+ ...options.state
3204
+ },
3205
+ // Similarly, we'll maintain both our internal state and any user-provided
3206
+ // state.
3207
+ onStateChange: updater => {
3208
+ setState(updater);
3209
+ options.onStateChange == null || options.onStateChange(updater);
3210
+ }
3211
+ }));
3212
+ return tableRef.current;
3213
+ }
3214
+
3215
+ // Theme colors
3216
+ const brand = { primary: '#e20074' };
3217
+ const gray = {
3218
+ 500: '#6b7280',
3219
+ 600: '#4b5563',
3220
+ 800: '#1f2937',
3221
+ };
3222
+ // Icons
3223
+ const DownArrowIcon = ({ size = 7, fill = gray[600] }) => (jsxRuntime.jsx("svg", { width: size, height: size / 1.75, viewBox: "0 0 7 4", fill: fill, xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M0.571637 0C0.458634 2.40803e-05 0.348175 0.0335519 0.254223 0.0963447C0.160272 0.159138 0.0870471 0.248377 0.0438056 0.35278C0.000564098 0.457183 -0.0107522 0.572062 0.0112872 0.682896C0.0333261 0.79373 0.0877309 0.89554 0.167624 0.975458L3.02486 3.83269C3.13202 3.93982 3.27734 4 3.42887 4C3.58039 4 3.72572 3.93982 3.83288 3.83269L6.69011 0.975458C6.77 0.89554 6.82441 0.79373 6.84645 0.682896C6.86849 0.572062 6.85717 0.457183 6.81393 0.35278C6.77069 0.248377 6.69746 0.159138 6.60351 0.0963447C6.50956 0.0335519 6.3991 2.40803e-05 6.2861 0H0.571637Z", fill: fill ?? gray[600] }) }));
3224
+ const DragHandleIcon = ({ size = 16, color = gray[500] }) => (jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { flexShrink: 0 }, children: jsxRuntime.jsx("path", { d: "M12.8125 5.625C12.6271 5.625 12.4458 5.57002 12.2917 5.467C12.1375 5.36399 12.0173 5.21757 11.9464 5.04627C11.8754 4.87496 11.8568 4.68646 11.893 4.5046C11.9292 4.32275 12.0185 4.1557 12.1496 4.02459C12.2807 3.89348 12.4477 3.80419 12.6296 3.76801C12.8115 3.73184 13 3.75041 13.1713 3.82136C13.3426 3.89232 13.489 4.01248 13.592 4.16665C13.695 4.32082 13.75 4.50208 13.75 4.6875C13.75 4.93614 13.6512 5.1746 13.4754 5.35041C13.2996 5.52623 13.0611 5.625 12.8125 5.625ZM13.75 10C13.75 9.81458 13.695 9.63333 13.592 9.47915C13.489 9.32498 13.3426 9.20482 13.1713 9.13386C13 9.06291 12.8115 9.04434 12.6296 9.08051C12.4477 9.11669 12.2807 9.20598 12.1496 9.33709C12.0185 9.4682 11.9292 9.63525 11.893 9.8171C11.8568 9.99896 11.8754 10.1875 11.9464 10.3588C12.0173 10.5301 12.1375 10.6765 12.2917 10.7795C12.4458 10.8825 12.6271 10.9375 12.8125 10.9375C13.0611 10.9375 13.2996 10.8387 13.4754 10.6629C13.6512 10.4871 13.75 10.2486 13.75 10ZM11.875 15.3125C11.875 15.4979 11.93 15.6792 12.033 15.8333C12.136 15.9875 12.2824 16.1077 12.4537 16.1786C12.625 16.2496 12.8135 16.2682 12.9954 16.232C13.1773 16.1958 13.3443 16.1065 13.4754 15.9754C13.6065 15.8443 13.6958 15.6773 13.732 15.4954C13.7682 15.3135 13.7496 15.125 13.6786 14.9537C13.6077 14.7824 13.4875 14.636 13.3333 14.533C13.1792 14.43 12.9979 14.375 12.8125 14.375C12.5639 14.375 12.3254 14.4738 12.1496 14.6496C11.9738 14.8254 11.875 15.0639 11.875 15.3125ZM8.125 4.6875C8.125 4.50208 8.07002 4.32082 7.967 4.16665C7.86399 4.01248 7.71757 3.89232 7.54626 3.82136C7.37496 3.75041 7.18646 3.73184 7.0046 3.76801C6.82275 3.80419 6.6557 3.89348 6.52459 4.02459C6.39348 4.1557 6.30419 4.32275 6.26801 4.5046C6.23184 4.68646 6.25041 4.87496 6.32136 5.04627C6.39232 5.21757 6.51248 5.36399 6.66665 5.467C6.82082 5.57002 7.00208 5.625 7.1875 5.625C7.43614 5.625 7.6746 5.52623 7.85041 5.35041C8.02623 5.1746 8.125 4.93614 8.125 4.6875ZM8.125 10C8.125 9.81458 8.07002 9.63333 7.967 9.47915C7.86399 9.32498 7.71757 9.20482 7.54626 9.13386C7.37496 9.06291 7.18646 9.04434 7.0046 9.08051C6.82275 9.11669 6.6557 9.20598 6.52459 9.33709C6.39348 9.4682 6.30419 9.63525 6.26801 9.8171C6.23184 9.99896 6.25041 10.1875 6.32136 10.3588C6.39232 10.5301 6.51248 10.6765 6.66665 10.7795C6.82082 10.8825 7.00208 10.9375 7.1875 10.9375C7.43614 10.9375 7.6746 10.8387 7.85041 10.6629C8.02623 10.4871 8.125 10.2486 8.125 10ZM8.125 15.3125C8.125 15.1271 8.07002 14.9458 7.967 14.7917C7.86399 14.6375 7.71757 14.5173 7.54626 14.4464C7.37496 14.3754 7.18646 14.3568 7.0046 14.393C6.82275 14.4292 6.6557 14.5185 6.52459 14.6496C6.39348 14.7807 6.30419 14.9477 6.26801 15.1296C6.23184 15.3115 6.25041 15.5 6.32136 15.6713C6.39232 15.8426 6.51248 15.989 6.66665 16.092C6.82082 16.195 7.00208 16.25 7.1875 16.25C7.43614 16.25 7.6746 16.1512 7.85041 15.9754C8.02623 15.7996 8.125 15.5611 8.125 15.3125Z", fill: color }) }));
3225
+ const AscSortIcon = ({ size = 16, isActive = false }) => (jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M0.5 3.1665L3.16667 0.499838M3.16667 0.499838L5.83333 3.1665M3.16667 0.499838V11.1665M5.83333 11.1665H12.5M5.83333 8.49984H10.5M5.83333 5.83317H8.5", stroke: isActive ? brand.primary : gray[800], strokeLinecap: "round", strokeLinejoin: "round" }) }));
3226
+ const DescSortIcon = ({ size = 16, isActive = false }) => (jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M0.5 8.5L3.16667 11.1667M3.16667 11.1667L5.83333 8.5M3.16667 11.1667V0.5M5.83333 0.5H12.5M5.83333 3.16667H10.5M5.83333 5.83333H8.5", stroke: isActive ? brand.primary : gray[800], strokeLinecap: "round", strokeLinejoin: "round" }) }));
3227
+ const SearchIcon = ({ size = 16 }) => (jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "5.5", stroke: gray[800], strokeWidth: "1.5" }), jsxRuntime.jsx("path", { d: "M11 11L14 14", stroke: gray[800], strokeWidth: "1.5", strokeLinecap: "round" })] }));
3228
+ const BackArrow = ({ size = 6, fill = '#666' }) => (jsxRuntime.jsx("svg", { width: size, height: size * 1.5, viewBox: "0 0 6 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M5 1L1 5L5 9", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
3229
+ const RightArrow = ({ size = 6, fill = '#666' }) => (jsxRuntime.jsx("svg", { width: size, height: size * 1.5, viewBox: "0 0 6 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M1 1L5 5L1 9", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
3230
+ const FirstPageIcon = ({ size = 10, fill = '#666' }) => (jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M10 1L5 6L10 11", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M2 1V11", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round" })] }));
3231
+ const LastPageIcon = ({ size = 10, fill = '#666' }) => (jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M2 1L7 6L2 11", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M10 1V11", stroke: fill, strokeWidth: "1.5", strokeLinecap: "round" })] }));
3232
+ // Inline Styles
3233
+ const styles = {
3234
+ container: {
3235
+ width: '100%',
3236
+ display: 'flex',
3237
+ flexDirection: 'column',
3238
+ flex: 1,
3239
+ minHeight: 0,
3240
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
3241
+ },
3242
+ table: {
3243
+ width: '100%',
3244
+ minWidth: 'max-content',
3245
+ borderCollapse: 'collapse',
3246
+ borderSpacing: 0,
3247
+ fontSize: 14,
3248
+ background: 'transparent',
3249
+ tableLayout: 'fixed',
3250
+ },
3251
+ tableHead: {
3252
+ background: '#f5f5f5',
3253
+ position: 'sticky',
3254
+ top: 0,
3255
+ zIndex: 10,
3256
+ },
3257
+ tableRow: (borderBottom, focused) => ({
3258
+ borderBottom: borderBottom ? '1px solid #ebebeb' : 'none',
3259
+ cursor: 'pointer',
3260
+ background: focused ? '#f8f9fa' : 'transparent',
3261
+ }),
3262
+ tableHeaderCell: {
3263
+ color: '#707070',
3264
+ height: 40,
3265
+ textAlign: 'start',
3266
+ overflow: 'visible',
3267
+ whiteSpace: 'nowrap',
3268
+ padding: '0 25px',
3269
+ fontSize: 14,
3270
+ fontWeight: 400,
3271
+ position: 'relative',
3272
+ },
3273
+ tableCell: {
3274
+ color: '#333333',
3275
+ height: 40,
3276
+ textAlign: 'start',
3277
+ overflow: 'hidden',
3278
+ textOverflow: 'ellipsis',
3279
+ whiteSpace: 'nowrap',
3280
+ padding: '0 25px',
3281
+ fontSize: 13,
3282
+ },
3283
+ dropdownPanel: {
3284
+ position: 'fixed',
3285
+ width: 260,
3286
+ maxHeight: 390,
3287
+ background: '#ffffff',
3288
+ borderRadius: 16,
3289
+ boxShadow: '0 4px 20px rgba(0, 0, 0, 0.15)',
3290
+ padding: '12px 8px',
3291
+ zIndex: 9999,
3292
+ display: 'flex',
3293
+ flexDirection: 'column',
3294
+ overflow: 'hidden',
3295
+ },
3296
+ filterOption: (isHeader) => ({
3297
+ display: 'flex',
3298
+ alignItems: 'center',
3299
+ width: 244,
3300
+ height: isHeader ? 52 : 48,
3301
+ padding: isHeader ? '16px 16px 12px 16px' : '12px 16px',
3302
+ gap: 12,
3303
+ cursor: 'pointer',
3304
+ transition: 'background 0.15s ease',
3305
+ }),
3306
+ button: (variant) => ({
3307
+ background: variant === 'primary' ? '#e20074' : '#ffffff',
3308
+ border: `1px solid ${variant === 'primary' ? '#e20074' : '#8f8f8f'}`,
3309
+ borderRadius: 12,
3310
+ padding: '8px 16px',
3311
+ fontSize: 14,
3312
+ fontWeight: 600,
3313
+ color: variant === 'primary' ? '#ffffff' : '#333333',
3314
+ cursor: 'pointer',
3315
+ minWidth: 78,
3316
+ display: 'inline-flex',
3317
+ alignItems: 'center',
3318
+ justifyContent: 'center',
3319
+ }),
3320
+ paginationWrapper: {
3321
+ display: 'flex',
3322
+ gap: 12,
3323
+ alignItems: 'center',
3324
+ justifyContent: 'flex-end',
3325
+ marginTop: 10,
3326
+ },
3327
+ pageControls: {
3328
+ display: 'flex',
3329
+ alignItems: 'center',
3330
+ gap: 4,
3331
+ height: 35,
3332
+ padding: '4.5px 8px',
3333
+ borderRadius: 12,
3334
+ border: '1px solid #E0E0E0',
3335
+ background: '#fff',
3336
+ fontSize: 12,
3337
+ color: '#333',
3338
+ minWidth: 190,
3339
+ justifyContent: 'space-between',
3340
+ },
3341
+ iconBtn: (disabled) => ({
3342
+ display: 'flex',
3343
+ alignItems: 'center',
3344
+ justifyContent: 'center',
3345
+ background: 'transparent',
3346
+ border: 'none',
3347
+ cursor: disabled ? 'not-allowed' : 'pointer',
3348
+ padding: 4,
3349
+ color: disabled ? '#ccc' : '#666',
3350
+ }),
3351
+ };
3352
+ const CustomCheckbox = ({ checked, indeterminate, onClick }) => (jsxRuntime.jsxs("div", { onClick: onClick, style: {
3353
+ width: 16,
3354
+ height: 16,
3355
+ cursor: 'pointer',
3356
+ borderRadius: 4,
3357
+ flexShrink: 0,
3358
+ border: '1px solid #D6D6D6',
3359
+ backgroundColor: checked || indeterminate ? '#e20074' : 'white',
3360
+ display: 'flex',
3361
+ alignItems: 'center',
3362
+ justifyContent: 'center',
3363
+ }, children: [checked && (jsxRuntime.jsx("svg", { width: "10", height: "8", viewBox: "0 0 10 8", fill: "none", children: jsxRuntime.jsx("path", { d: "M1 4L3.5 6.5L9 1", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })), indeterminate && !checked && (jsxRuntime.jsx("svg", { width: "8", height: "2", viewBox: "0 0 8 2", fill: "none", children: jsxRuntime.jsx("path", { d: "M1 1H7", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }) }))] }));
3364
+ const FilterDropdown = ({ columnKey, columnHeader, data, filterOptions, currentFilter, onApply, filterLabel, isOpen, onToggle, onClose, enableSorting = false, enableFilter = true, currentSortOrder, onSort, }) => {
3365
+ const containerRef = React.useRef(null);
3366
+ const dropdownRef = React.useRef(null);
3367
+ const [tempSelection, setTempSelection] = React.useState(new Set(currentFilter?.selectedValues || []));
3368
+ const [searchQuery, setSearchQuery] = React.useState('');
3369
+ const [dropdownPosition, setDropdownPosition] = React.useState(null);
3370
+ const uniqueValues = React.useMemo(() => {
3371
+ if (filterOptions && filterOptions.length > 0) {
3372
+ return Array.from(new Set(filterOptions)).sort();
3373
+ }
3374
+ const values = new Set();
3375
+ data.forEach((row) => {
3376
+ const value = row[columnKey];
3377
+ if (value !== undefined && value !== null && value !== '') {
3378
+ values.add(String(value));
3379
+ }
3380
+ });
3381
+ return Array.from(values).sort();
3382
+ }, [data, columnKey, filterOptions]);
3383
+ React.useLayoutEffect(() => {
3384
+ if (!isOpen || !containerRef.current)
3385
+ return;
3386
+ const rect = containerRef.current.getBoundingClientRect();
3387
+ setDropdownPosition({
3388
+ top: rect.bottom + 4,
3389
+ left: Math.max(8, rect.right - 260),
3390
+ });
3391
+ }, [isOpen]);
3392
+ React.useEffect(() => {
3393
+ if (isOpen) {
3394
+ setTempSelection(new Set(currentFilter?.selectedValues || []));
3395
+ setSearchQuery('');
3396
+ }
3397
+ }, [isOpen, currentFilter]);
3398
+ React.useEffect(() => {
3399
+ const handleClickOutside = (event) => {
3400
+ if (containerRef.current && !containerRef.current.contains(event.target) &&
3401
+ dropdownRef.current && !dropdownRef.current.contains(event.target)) {
3402
+ onClose();
3403
+ }
3404
+ };
3405
+ const handleKeyDown = (event) => {
3406
+ if (event.key === 'Escape')
3407
+ onClose();
3408
+ };
3409
+ if (isOpen) {
3410
+ document.addEventListener('mousedown', handleClickOutside);
3411
+ document.addEventListener('keydown', handleKeyDown);
3412
+ }
3413
+ return () => {
3414
+ document.removeEventListener('mousedown', handleClickOutside);
3415
+ document.removeEventListener('keydown', handleKeyDown);
3416
+ };
3417
+ }, [isOpen, onClose]);
3418
+ const filteredValues = React.useMemo(() => {
3419
+ if (!searchQuery.trim())
3420
+ return uniqueValues;
3421
+ const query = searchQuery.toLowerCase();
3422
+ return uniqueValues.filter((value) => String(value).toLowerCase().includes(query));
3423
+ }, [uniqueValues, searchQuery]);
3424
+ const allFilteredSelected = filteredValues.length > 0 && filteredValues.every((value) => tempSelection.has(value));
3425
+ const someFilteredSelected = filteredValues.some((value) => tempSelection.has(value)) && !allFilteredSelected;
3426
+ const handleToggleAll = () => {
3427
+ if (allFilteredSelected) {
3428
+ setTempSelection((prev) => {
3429
+ const newSet = new Set(prev);
3430
+ filteredValues.forEach((value) => newSet.delete(value));
3431
+ return newSet;
3432
+ });
3433
+ }
3434
+ else {
3435
+ setTempSelection((prev) => {
3436
+ const newSet = new Set(prev);
3437
+ filteredValues.forEach((value) => newSet.add(value));
3438
+ return newSet;
3439
+ });
3440
+ }
3441
+ };
3442
+ const handleToggleValue = (value) => {
3443
+ setTempSelection((prev) => {
3444
+ const newSet = new Set(prev);
3445
+ if (newSet.has(value))
3446
+ newSet.delete(value);
3447
+ else
3448
+ newSet.add(value);
3449
+ return newSet;
3450
+ });
3451
+ };
3452
+ const handleClearAll = () => {
3453
+ onApply(columnKey, new Set());
3454
+ onClose();
3455
+ };
3456
+ const handleApply = () => {
3457
+ onApply(columnKey, tempSelection);
3458
+ onClose();
3459
+ };
3460
+ const hasActiveFilter = currentFilter && currentFilter.selectedValues.size > 0;
3461
+ const isActive = isOpen || hasActiveFilter || !!currentSortOrder;
3462
+ return (jsxRuntime.jsxs("div", { ref: containerRef, style: { position: 'relative', display: 'inline-flex', alignItems: 'center' }, children: [jsxRuntime.jsx("button", { onClick: (e) => { e.stopPropagation(); onToggle(); }, type: "button", style: { display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'transparent', border: 'none', padding: 2, cursor: 'pointer', borderRadius: 4 }, children: jsxRuntime.jsx("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', transition: 'transform 0.2s ease', transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)' }, children: jsxRuntime.jsx(DownArrowIcon, { size: 8, fill: isActive ? brand.primary : gray[600] }) }) }), isOpen && dropdownPosition && (jsxRuntime.jsxs("div", { ref: dropdownRef, onClick: (e) => e.stopPropagation(), style: { ...styles.dropdownPanel, top: dropdownPosition.top, left: dropdownPosition.left }, children: [enableSorting && onSort && (jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: 6 }, children: [jsxRuntime.jsx("span", { style: { fontSize: 16, fontWeight: 500, color: '#333333' }, children: "Sort" }), jsxRuntime.jsxs("div", { style: { display: 'flex', gap: 8 }, children: [jsxRuntime.jsxs("button", { type: "button", onClick: (e) => { e.stopPropagation(); onSort('ASC'); }, style: { display: 'flex', alignItems: 'center', justifyContent: 'center', width: 69, gap: 4, padding: 6, borderRadius: 8, border: 'none', background: currentSortOrder === 'ASC' ? 'rgba(226, 0, 116, 0.05)' : 'transparent', cursor: 'pointer', fontSize: 13, color: currentSortOrder === 'ASC' ? '#e20074' : '#707070' }, children: [jsxRuntime.jsx(AscSortIcon, { size: 12, isActive: currentSortOrder === 'ASC' }), jsxRuntime.jsx("span", { children: "A to Z" })] }), jsxRuntime.jsxs("button", { type: "button", onClick: (e) => { e.stopPropagation(); onSort('DESC'); }, style: { display: 'flex', alignItems: 'center', justifyContent: 'center', width: 69, gap: 4, padding: 6, borderRadius: 8, border: 'none', background: currentSortOrder === 'DESC' ? 'rgba(226, 0, 116, 0.05)' : 'transparent', cursor: 'pointer', fontSize: 13, color: currentSortOrder === 'DESC' ? '#e20074' : '#707070' }, children: [jsxRuntime.jsx(DescSortIcon, { size: 12, isActive: currentSortOrder === 'DESC' }), jsxRuntime.jsx("span", { children: "Z to A" })] })] })] })), enableFilter && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { style: { padding: '8px 4px' }, children: jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', width: 236, height: 34, gap: 10, padding: '12px 10px', borderRadius: 12, border: '1px solid #e8e8e8', background: '#ffffff' }, children: [jsxRuntime.jsx(SearchIcon, { size: 16 }), jsxRuntime.jsx("input", { type: "text", placeholder: "Search", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), onClick: (e) => e.stopPropagation(), style: { flex: 1, border: 'none', outline: 'none', background: 'transparent', fontSize: 13, color: '#333333' } })] }) }), filteredValues.length > 0 && (jsxRuntime.jsxs("div", { style: styles.filterOption(true), onClick: (e) => { e.stopPropagation(); handleToggleAll(); }, children: [jsxRuntime.jsx(CustomCheckbox, { checked: allFilteredSelected, indeterminate: someFilteredSelected, onClick: (e) => { e.stopPropagation(); handleToggleAll(); } }), jsxRuntime.jsxs("span", { style: { fontSize: 13, color: '#333333', flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: ["All ", columnHeader || columnKey] })] })), jsxRuntime.jsxs("div", { style: { flex: 1, overflowY: 'auto', maxHeight: 250 }, children: [filteredValues.filter((value) => value !== '' && value !== null && value !== undefined).map((value) => (jsxRuntime.jsxs("div", { style: styles.filterOption(false), onClick: (e) => { e.stopPropagation(); handleToggleValue(value); }, children: [jsxRuntime.jsx(CustomCheckbox, { checked: tempSelection.has(value), onClick: (e) => { e.stopPropagation(); handleToggleValue(value); } }), jsxRuntime.jsx("span", { title: filterLabel ? filterLabel(value) : value, style: { fontSize: 13, color: '#333333', flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: filterLabel ? filterLabel(value) : value })] }, value))), filteredValues.length === 0 && jsxRuntime.jsx("div", { style: { padding: 16, color: '#8f8f8f', fontSize: 13, textAlign: 'center' }, children: "No values found" })] }), jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end', alignItems: 'center', gap: 10, padding: '10px 12px', paddingBottom: 0 }, children: [jsxRuntime.jsx("button", { style: styles.button('secondary'), onClick: (e) => { e.stopPropagation(); handleClearAll(); }, disabled: tempSelection.size === 0 && (!currentFilter || currentFilter.selectedValues.size === 0), children: "Reset" }), jsxRuntime.jsx("button", { style: styles.button('primary'), onClick: (e) => { e.stopPropagation(); handleApply(); }, children: "Apply" })] })] }))] }))] }));
3463
+ };
3464
+ // Pagination Component
3465
+ const PAGE_SIZE_OPTIONS = [10, 20, 30, 40, 50];
3466
+ const Pagination = ({ page, pageSize, total, onPageChange, onPageSizeChange }) => {
3467
+ const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
3468
+ const dropdownRef = React.useRef(null);
3469
+ const start = total === 0 ? 0 : (page - 1) * pageSize + 1;
3470
+ const end = Math.min(page * pageSize, total);
3471
+ const totalPages = Math.max(1, Math.ceil(total / pageSize));
3472
+ React.useEffect(() => {
3473
+ const handleClickOutside = (event) => {
3474
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
3475
+ setIsDropdownOpen(false);
3476
+ }
3477
+ };
3478
+ document.addEventListener('mousedown', handleClickOutside);
3479
+ return () => document.removeEventListener('mousedown', handleClickOutside);
3480
+ }, []);
3481
+ return (jsxRuntime.jsxs("div", { style: styles.paginationWrapper, children: [jsxRuntime.jsxs("div", { ref: dropdownRef, style: { position: 'relative', display: 'flex', alignItems: 'center' }, children: [jsxRuntime.jsxs("div", { onClick: () => setIsDropdownOpen(!isDropdownOpen), style: { display: 'flex', alignItems: 'center', gap: 10, height: 35, padding: '10px 12px', borderRadius: 12, border: `1px solid ${isDropdownOpen ? '#e20074' : '#E0E0E0'}`, fontSize: 12, color: '#333', background: '#fff', cursor: 'pointer', userSelect: 'none' }, children: [jsxRuntime.jsxs("span", { style: { whiteSpace: 'nowrap' }, children: [pageSize, " Rows/Pg"] }), jsxRuntime.jsx("span", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', transition: 'transform 0.2s ease', transform: isDropdownOpen ? 'rotate(180deg)' : 'rotate(0deg)' }, children: jsxRuntime.jsx(DownArrowIcon, { size: 8 }) })] }), isDropdownOpen && (jsxRuntime.jsx("div", { style: { position: 'absolute', top: 'calc(100% + 4px)', left: 0, minWidth: '100%', background: '#fff', border: '1px solid #E0E0E0', borderRadius: 12, boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)', zIndex: 1000, overflow: 'hidden' }, children: PAGE_SIZE_OPTIONS.map((size) => (jsxRuntime.jsxs("div", { onClick: () => { onPageSizeChange(size); setIsDropdownOpen(false); }, style: { padding: '10px 16px', fontSize: 12, color: size === pageSize ? '#e20074' : '#333', background: size === pageSize ? 'rgba(226, 0, 116, 0.05)' : 'transparent', cursor: 'pointer', whiteSpace: 'nowrap' }, children: [size, " Rows/Pg"] }, size))) }))] }), jsxRuntime.jsxs("div", { style: styles.pageControls, children: [jsxRuntime.jsx("button", { style: styles.iconBtn(page === 1), disabled: page === 1, onClick: () => onPageChange(1), title: "First page", children: jsxRuntime.jsx(FirstPageIcon, { size: 10, fill: page === 1 ? '#ccc' : '#666' }) }), jsxRuntime.jsx("button", { style: styles.iconBtn(page === 1), disabled: page === 1, onClick: () => onPageChange(page - 1), title: "Previous page", children: jsxRuntime.jsx(BackArrow, { size: 7, fill: page === 1 ? '#ccc' : '#666' }) }), jsxRuntime.jsxs("span", { style: { padding: '0 8px', fontSize: 12, color: '#333', whiteSpace: 'nowrap', flex: 1, textAlign: 'center' }, children: [start, "-", end, " of ", total.toLocaleString()] }), jsxRuntime.jsx("button", { style: styles.iconBtn(page >= totalPages), disabled: page >= totalPages, onClick: () => onPageChange(page + 1), title: "Next page", children: jsxRuntime.jsx(RightArrow, { size: 7, fill: page >= totalPages ? '#ccc' : '#666' }) }), jsxRuntime.jsx("button", { style: styles.iconBtn(page >= totalPages), disabled: page >= totalPages, onClick: () => onPageChange(totalPages), title: "Last page", children: jsxRuntime.jsx(LastPageIcon, { size: 10, fill: page >= totalPages ? '#ccc' : '#666' }) })] })] }));
3482
+ };
3483
+ // Main DataTable Component
3484
+ const DataTable = ({ data, columns, loading = false, onSort, config = {}, onRowClick, pagination, onPageChange, onPageSizeChange, headerStyle, checkboxSelection, filterState, onFilterChange, enableColumnReorder, columnOrder, onColumnOrderChange, sortingState: controlledSortingState, customHeaderComponent, }) => {
3485
+ const { height = 0, rowHeight = 40 } = config;
3486
+ const [internalSortingState, setInternalSortingState] = React.useState({});
3487
+ const sortingState = controlledSortingState ?? internalSortingState;
3488
+ const [openFilterColumn, setOpenFilterColumn] = React.useState(null);
3489
+ const tableWrapperRef = React.useRef(null);
3490
+ // Drag and drop state
3491
+ const [draggedColumn, setDraggedColumn] = React.useState(null);
3492
+ const [hoveredColumn, setHoveredColumn] = React.useState(null);
3493
+ const [dropIndicator, setDropIndicator] = React.useState(null);
3494
+ const columnHeaderRefs = React.useRef(new Map());
3495
+ const dropIndicatorRef = React.useRef(null);
3496
+ const draggedColumnRef = React.useRef(null);
3497
+ // Apply client-side filtering
3498
+ const filteredData = React.useMemo(() => {
3499
+ if (!data || !filterState)
3500
+ return data;
3501
+ const activeFilters = Object.entries(filterState).filter(([, filter]) => filter.selectedValues.size > 0);
3502
+ if (activeFilters.length === 0)
3503
+ return data;
3504
+ return data.filter((row) => {
3505
+ return activeFilters.every(([columnKey, filter]) => {
3506
+ const column = columns.find((col) => col.accessorKey === columnKey);
3507
+ const rowValue = row[columnKey];
3508
+ if (column?.filterFn)
3509
+ return column.filterFn(rowValue, filter.selectedValues);
3510
+ if (rowValue === undefined || rowValue === null)
3511
+ return false;
3512
+ return filter.selectedValues.has(String(rowValue));
3513
+ });
3514
+ });
3515
+ }, [data, filterState, columns]);
3516
+ const handleFilterApply = React.useCallback((columnKey, selectedValues) => {
3517
+ onFilterChange?.(columnKey, selectedValues);
3518
+ }, [onFilterChange]);
3519
+ // Reorder columns based on columnOrder prop
3520
+ const orderedColumns = React.useMemo(() => {
3521
+ if (!columnOrder || columnOrder.length === 0)
3522
+ return columns;
3523
+ const columnMap = new Map(columns.map((col) => [col.accessorKey, col]));
3524
+ const ordered = [];
3525
+ for (const key of columnOrder) {
3526
+ const col = columnMap.get(key);
3527
+ if (col) {
3528
+ ordered.push(col);
3529
+ columnMap.delete(key);
3530
+ }
3531
+ }
3532
+ for (const col of columnMap.values()) {
3533
+ ordered.push(col);
3534
+ }
3535
+ return ordered;
3536
+ }, [columns, columnOrder]);
3537
+ // Drag and drop handlers
3538
+ const handleDragStart = React.useCallback((e, columnKey, isDraggable) => {
3539
+ if (!enableColumnReorder || !isDraggable) {
3540
+ e.preventDefault();
3541
+ return;
3542
+ }
3543
+ setDraggedColumn(columnKey);
3544
+ draggedColumnRef.current = columnKey;
3545
+ e.dataTransfer.effectAllowed = 'move';
3546
+ e.dataTransfer.setData('text/plain', columnKey);
3547
+ }, [enableColumnReorder]);
3548
+ const handleDragOver = React.useCallback((e, columnKey, isDraggable) => {
3549
+ if (!enableColumnReorder || !draggedColumn || !onColumnOrderChange)
3550
+ return;
3551
+ e.preventDefault();
3552
+ e.dataTransfer.dropEffect = 'move';
3553
+ if (columnKey && columnKey !== draggedColumn) {
3554
+ const headerElement = columnHeaderRefs.current.get(columnKey);
3555
+ let dropPosition = 'before';
3556
+ if (headerElement) {
3557
+ const rect = headerElement.getBoundingClientRect();
3558
+ const mouseX = e.clientX;
3559
+ const elementCenter = rect.left + rect.width / 2;
3560
+ dropPosition = mouseX < elementCenter ? 'before' : 'after';
3561
+ }
3562
+ if (isDraggable) {
3563
+ const indicator = { columnKey, position: dropPosition };
3564
+ setDropIndicator(indicator);
3565
+ dropIndicatorRef.current = indicator;
3566
+ }
3567
+ else {
3568
+ dropIndicatorRef.current = { columnKey, position: dropPosition };
3569
+ }
3570
+ }
3571
+ else if (columnKey === draggedColumn) {
3572
+ setDropIndicator(null);
3573
+ dropIndicatorRef.current = null;
3574
+ }
3575
+ }, [enableColumnReorder, draggedColumn, onColumnOrderChange]);
3576
+ const handleDrop = React.useCallback((e, targetColumnKey) => {
3577
+ e.preventDefault();
3578
+ const currentDropIndicator = dropIndicatorRef.current;
3579
+ const currentDraggedColumn = draggedColumnRef.current;
3580
+ if (currentDraggedColumn && targetColumnKey && targetColumnKey !== currentDraggedColumn && onColumnOrderChange && currentDropIndicator) {
3581
+ const visibleColumnKeys = orderedColumns.map((col) => col.accessorKey ?? '').filter(Boolean);
3582
+ let currentOrder = columnOrder && columnOrder.length > 0 ? columnOrder.filter((key) => visibleColumnKeys.includes(key)) : visibleColumnKeys;
3583
+ visibleColumnKeys.forEach((key) => { if (!currentOrder.includes(key))
3584
+ currentOrder.push(key); });
3585
+ const draggedIndex = currentOrder.indexOf(currentDraggedColumn);
3586
+ const targetIndex = currentOrder.indexOf(targetColumnKey);
3587
+ if (draggedIndex !== -1 && targetIndex !== -1 && draggedIndex !== targetIndex) {
3588
+ const newOrder = [...currentOrder];
3589
+ newOrder.splice(draggedIndex, 1);
3590
+ let insertIndex;
3591
+ if (draggedIndex < targetIndex) {
3592
+ const adjustedTargetIndex = targetIndex - 1;
3593
+ insertIndex = currentDropIndicator.position === 'after' ? adjustedTargetIndex + 1 : adjustedTargetIndex;
3594
+ }
3595
+ else {
3596
+ insertIndex = currentDropIndicator.position === 'after' ? targetIndex + 1 : targetIndex;
3597
+ }
3598
+ newOrder.splice(insertIndex, 0, currentDraggedColumn);
3599
+ onColumnOrderChange(newOrder.filter(Boolean));
3600
+ }
3601
+ }
3602
+ setDraggedColumn(null);
3603
+ setDropIndicator(null);
3604
+ dropIndicatorRef.current = null;
3605
+ draggedColumnRef.current = null;
3606
+ }, [onColumnOrderChange, columnOrder, orderedColumns]);
3607
+ const handleDragEnd = React.useCallback(() => {
3608
+ setDraggedColumn(null);
3609
+ setDropIndicator(null);
3610
+ dropIndicatorRef.current = null;
3611
+ draggedColumnRef.current = null;
3612
+ }, []);
3613
+ const tableData = filteredData ?? [];
3614
+ const table = useReactTable({
3615
+ data: tableData,
3616
+ columns: orderedColumns,
3617
+ getCoreRowModel: getCoreRowModel(),
3618
+ });
3619
+ const { getHeaderGroups, getRowModel } = table;
3620
+ const rows = getRowModel().rows;
3621
+ const headerGroup = getHeaderGroups();
3622
+ return (jsxRuntime.jsxs("div", { style: { ...styles.container, position: 'relative', height: height > 0 ? height : '100%' }, children: [customHeaderComponent, jsxRuntime.jsx("div", { style: { position: 'relative', flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }, children: jsxRuntime.jsx("div", { ref: tableWrapperRef, style: { overflowX: 'auto', overflowY: 'auto', flex: 1, minHeight: 0, maxHeight: height > 0 ? height - 50 : undefined, ...(draggedColumn && { cursor: 'grabbing' }) }, children: jsxRuntime.jsxs("table", { style: styles.table, children: [jsxRuntime.jsx("thead", { style: styles.tableHead, children: headerGroup.map((hg) => (jsxRuntime.jsx("tr", { children: hg.headers.map((header, idx) => {
3623
+ const columnDef = header.column.columnDef;
3624
+ const columnKey = columnDef.accessorKey ?? '';
3625
+ const isDraggable = !!(enableColumnReorder && !columnDef.disableDrag && !columnDef.isPrimary && columnKey);
3626
+ const isDragging = draggedColumn === columnKey;
3627
+ const isHovered = hoveredColumn === columnKey;
3628
+ typeof columnDef.header === 'string' ? columnDef.header : columnKey;
3629
+ const showDropIndicatorBefore = dropIndicator?.columnKey === columnKey && dropIndicator?.position === 'before';
3630
+ const showDropIndicatorAfter = dropIndicator?.columnKey === columnKey && dropIndicator?.position === 'after';
3631
+ return (jsxRuntime.jsxs("th", { ref: (el) => { if (el && columnKey)
3632
+ columnHeaderRefs.current.set(columnKey, el); }, onDragOver: (e) => handleDragOver(e, columnKey, isDraggable), onDrop: (e) => handleDrop(e, columnKey), onMouseEnter: () => isDraggable && setHoveredColumn(columnKey), onMouseLeave: () => setHoveredColumn(null), style: {
3633
+ ...styles.tableHeaderCell,
3634
+ ...headerStyle,
3635
+ ...(idx === 0 && { paddingLeft: 12.5, borderTopLeftRadius: 12, borderBottomLeftRadius: 12 }),
3636
+ ...(idx === hg.headers.length - 1 && { borderTopRightRadius: 12, borderBottomRightRadius: 12 }),
3637
+ ...(isDragging && { opacity: 0.5 }),
3638
+ }, children: [showDropIndicatorBefore && jsxRuntime.jsx("div", { style: { position: 'absolute', left: 0, top: 0, bottom: 0, width: 3, background: '#FFADD5', zIndex: 10 } }), showDropIndicatorAfter && jsxRuntime.jsx("div", { style: { position: 'absolute', right: 0, top: 0, bottom: 0, width: 3, background: '#FFADD5', zIndex: 10 } }), (() => {
3639
+ const isColumnSortable = columnDef.enableSorting === true;
3640
+ const showSorting = isColumnSortable;
3641
+ const showCheckbox = columnDef.enableCheckbox && checkboxSelection;
3642
+ const showFilter = columnDef.enableFilter && columnDef.accessorKey && onFilterChange;
3643
+ const showDropdown = (showSorting || showFilter) && columnDef.accessorKey;
3644
+ const currentSortOrder = columnDef.accessorKey ? sortingState[columnDef.accessorKey] : undefined;
3645
+ const columnFilter = columnDef.accessorKey ? filterState?.[columnDef.accessorKey] : undefined;
3646
+ const hasActiveFilter = !!(columnFilter && columnFilter.selectedValues && columnFilter.selectedValues.size > 0);
3647
+ const isColumnActive = !!currentSortOrder || hasActiveFilter;
3648
+ return (jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: showCheckbox ? 8 : showDropdown ? 4 : 2, cursor: showDropdown ? 'pointer' : 'default', justifyContent: 'flex-start' }, onClick: () => { if (showDropdown && columnDef.accessorKey)
3649
+ setOpenFilterColumn(openFilterColumn === columnDef.accessorKey ? null : columnDef.accessorKey); }, children: [showCheckbox && (jsxRuntime.jsx(CustomCheckbox, { checked: checkboxSelection.isAllSelected, indeterminate: checkboxSelection.isPartiallySelected, onClick: (e) => { e.stopPropagation(); checkboxSelection.onSelectAll(); } })), jsxRuntime.jsx("span", { style: { color: isColumnActive ? brand.primary : 'inherit' }, children: flexRender(header.column.columnDef.header, header.getContext()) }), showDropdown && columnDef.accessorKey && (jsxRuntime.jsx(FilterDropdown, { columnKey: columnDef.accessorKey, columnHeader: typeof columnDef.header === 'string' ? columnDef.header : undefined, data: data ?? [], filterOptions: columnDef.filterOptions, currentFilter: filterState?.[columnDef.accessorKey], onApply: handleFilterApply, filterLabel: columnDef.filterLabel, isOpen: openFilterColumn === columnDef.accessorKey, onToggle: () => setOpenFilterColumn(openFilterColumn === columnDef.accessorKey ? null : columnDef.accessorKey ?? null), onClose: () => setOpenFilterColumn(null), enableSorting: showSorting, enableFilter: !!showFilter, currentSortOrder: currentSortOrder ?? null, onSort: (order) => {
3650
+ if (columnDef.accessorKey) {
3651
+ if (!controlledSortingState)
3652
+ setInternalSortingState({ [columnDef.accessorKey]: order });
3653
+ onSort?.(columnDef.accessorKey, order);
3654
+ }
3655
+ } })), isDraggable && (jsxRuntime.jsx("div", { draggable: true, onDragStart: (e) => { e.stopPropagation(); handleDragStart(e, columnKey, isDraggable); }, onDragEnd: handleDragEnd, style: { display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'grab', padding: 2, marginLeft: 'auto', opacity: isHovered || isDragging ? 1 : 0, transition: 'opacity 0.15s ease' }, onClick: (e) => e.stopPropagation(), children: jsxRuntime.jsx(DragHandleIcon, { size: 16, color: isDragging ? brand.primary : gray[500] }) }))] }));
3656
+ })()] }, header.id));
3657
+ }) }, hg.id))) }), loading ? (jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { colSpan: orderedColumns.length, style: { textAlign: 'center', verticalAlign: 'middle', padding: '70px 20px', height: 400 }, children: jsxRuntime.jsx("div", { style: { fontSize: 18, color: 'rgb(108, 114, 128)', display: 'flex', justifyContent: 'center' }, children: "Loading..." }) }) }) })) : rows.length ? (jsxRuntime.jsx("tbody", { children: rows.map((row, idx) => (jsxRuntime.jsx("tr", { style: styles.tableRow(idx !== rows.length - 1, false), ...(onRowClick ? { onClick: () => onRowClick(row.original) } : {}), onMouseEnter: (e) => (e.currentTarget.style.background = '#f8f9fa'), onMouseLeave: (e) => (e.currentTarget.style.background = 'transparent'), children: row.getVisibleCells().map((cell, cellIdx) => {
3658
+ const columnDef = cell.column.columnDef;
3659
+ const showCheckbox = columnDef.enableCheckbox && checkboxSelection;
3660
+ const rowId = showCheckbox ? checkboxSelection.getRowId(row.original) : '';
3661
+ const isRowSelected = showCheckbox ? checkboxSelection.selectedRows.has(rowId) : false;
3662
+ const isDragging = draggedColumn === columnDef.accessorKey;
3663
+ return (jsxRuntime.jsx("td", { style: { ...styles.tableCell, height: rowHeight, ...(cellIdx === 0 && { paddingLeft: 12.5 }), ...(isDragging && { opacity: 1, background: '#fafafa' }) }, children: jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: showCheckbox ? 16 : 0, overflow: 'hidden', minWidth: 0 }, children: [showCheckbox && jsxRuntime.jsx(CustomCheckbox, { checked: isRowSelected, onClick: (e) => checkboxSelection.onRowSelect(rowId, e) }), columnDef.truncate ? (jsxRuntime.jsx("span", { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', minWidth: 0, flex: 1, display: 'block' }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) })) : (flexRender(cell.column.columnDef.cell, cell.getContext()))] }) }, cell.id));
3664
+ }) }, row.id))) })) : (jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { colSpan: orderedColumns.length, style: { textAlign: 'center', verticalAlign: 'middle', padding: '70px 20px' }, children: jsxRuntime.jsx("div", { style: { fontSize: 18, color: 'rgb(108, 114, 128)', display: 'flex', justifyContent: 'center' }, children: "No data" }) }) }) }))] }) }) }), pagination && onPageChange && onPageSizeChange && (jsxRuntime.jsx(Pagination, { page: pagination.page, pageSize: pagination.pageSize, total: pagination.totalRecords, onPageChange: onPageChange, onPageSizeChange: onPageSizeChange }))] }));
3665
+ };
3666
+
3667
+ exports.Button = Button;
3668
+ exports.Card = Card;
3669
+ exports.CardBody = CardBody;
3670
+ exports.CardFooter = CardFooter;
3671
+ exports.CardHeader = CardHeader;
3672
+ exports.CustomCheckbox = CustomCheckbox;
3673
+ exports.DataTable = DataTable;
3674
+ exports.Input = Input;
3675
+ //# sourceMappingURL=index.js.map