@hillac/mantine-react-table 0.0.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,3876 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import clsx from 'clsx';
3
+ import { useMemo, useCallback, useState, memo, useEffect, useRef, Fragment as Fragment$1, useReducer, createElement, useLayoutEffect } from 'react';
4
+ import { Select, MultiSelect, TextInput, TableTr, TableTd, Collapse, CopyButton, Tooltip, UnstyledButton, Highlight, useDirection, Skeleton, Box, ActionIcon, Text, TableTbody, Flex, Button, useMantineTheme, Menu, Switch, TableTh, TableTfoot, Radio, Checkbox, Badge, Alert, Stack, Autocomplete, RangeSlider, Popover, Transition, Indicator, TableThead, Progress, Group, Pagination, Modal, useMantineColorScheme, Table, lighten, darken, LoadingOverlay, Paper } from '@mantine/core';
5
+ import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
6
+ import { sortFns, constructRow, filterFns, Subscribe, flexRender as flexRender$1, aggregationFns, stockFeatures, createFacetedUniqueValues, createFacetedMinMaxValues, createFacetedRowModel, createGroupedRowModel, createExpandedRowModel, createPaginatedRowModel, createSortedRowModel, createFilteredRowModel, useTable } from '@tanstack/react-table';
7
+ import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
8
+ import { useDebouncedValue, useHover, useMediaQuery } from '@mantine/hooks';
9
+ import { DateInput } from '@mantine/dates';
10
+ import { useCreateAtom, useSelector } from '@tanstack/react-store';
11
+ import { IconX, IconSortDescending, IconSortAscending, IconSearchOff, IconSearch, IconPinnedOff, IconPinned, IconMinimize, IconMaximize, IconGripHorizontal, IconFilterOff, IconFilterCog, IconFilter, IconEyeOff, IconEdit, IconDotsVertical, IconDots, IconDeviceFloppy, IconColumns, IconClearAll, IconCircleX, IconChevronsDown, IconChevronRightPipe, IconChevronRight, IconChevronLeftPipe, IconChevronLeft, IconChevronDown, IconBoxMultiple, IconBaselineDensitySmall, IconBaselineDensityMedium, IconBaselineDensityLarge, IconArrowsSort, IconArrowAutofitContent } from '@tabler/icons-react';
12
+
13
+ const fuzzy$1 = (rowA, rowB, columnId) => {
14
+ let dir = 0;
15
+ if (rowA.columnFiltersMeta[columnId]) {
16
+ dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
17
+ }
18
+ // Provide a fallback for when the item ranks are equal
19
+ return dir === 0
20
+ ? sortFns.alphanumeric(rowA, rowB, columnId)
21
+ : dir;
22
+ };
23
+ const MRT_SortFns = {
24
+ ...sortFns,
25
+ fuzzy: fuzzy$1,
26
+ };
27
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
28
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
29
+
30
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
31
+
32
+ const getMRT_Rows = (table, all) => {
33
+ const { getCenterRows, getPrePaginatedRowModel, getRowModel, state, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
34
+ const { creatingRow, pagination } = state;
35
+ const isRankingRows = getIsRankingRows(table);
36
+ let rows = [];
37
+ if (!isRankingRows) {
38
+ rows =
39
+ !enableRowPinning || rowPinningDisplayMode?.includes('sticky')
40
+ ? all
41
+ ? getPrePaginatedRowModel().rows
42
+ : getRowModel().rows
43
+ : getCenterRows();
44
+ }
45
+ else {
46
+ // fuzzy ranking adjustments
47
+ rows = getPrePaginatedRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
48
+ if (enablePagination && !manualPagination && !all) {
49
+ const start = pagination.pageIndex * pagination.pageSize;
50
+ rows = rows.slice(start, start + pagination.pageSize);
51
+ }
52
+ if (enableRowPinning && !rowPinningDisplayMode?.includes('sticky')) {
53
+ // "re-center-ize" the rows (no top or bottom pinned rows unless sticky)
54
+ rows = rows.filter((row) => !row.getIsPinned());
55
+ }
56
+ }
57
+ // row pinning adjustments
58
+ if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
59
+ const centerPinnedRowIds = rows
60
+ .filter((row) => row.getIsPinned())
61
+ .map((r) => r.id);
62
+ rows = [
63
+ ...getTopRows().filter((row) => !centerPinnedRowIds.includes(row.id)),
64
+ ...rows,
65
+ ];
66
+ }
67
+ // blank inserted creating row adjustments
68
+ if (positionCreatingRow !== undefined &&
69
+ creatingRow &&
70
+ createDisplayMode === 'row') {
71
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
72
+ ? +positionCreatingRow
73
+ : positionCreatingRow === 'top'
74
+ ? 0
75
+ : rows.length;
76
+ rows = [
77
+ ...rows.slice(0, creatingRowIndex),
78
+ creatingRow,
79
+ ...rows.slice(creatingRowIndex),
80
+ ];
81
+ }
82
+ return rows;
83
+ };
84
+ const getCanRankRows = (table) => {
85
+ const { state, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
86
+ const { expanded, globalFilterFn } = state;
87
+ return (!manualExpanding &&
88
+ !manualFiltering &&
89
+ !manualGrouping &&
90
+ !manualSorting &&
91
+ enableGlobalFilterRankedResults &&
92
+ globalFilterFn === 'fuzzy' &&
93
+ expanded !== true &&
94
+ !Object.values(expanded).some(Boolean));
95
+ };
96
+ const getIsRankingRows = (table) => {
97
+ const { globalFilter, sorting } = table.state;
98
+ return (getCanRankRows(table) &&
99
+ globalFilter &&
100
+ !Object.values(sorting).some(Boolean));
101
+ };
102
+ const getIsRowSelected = ({ row, table, }) => {
103
+ const { options: { enableRowSelection }, } = table;
104
+ return (row.getIsSelected() ||
105
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
106
+ row.getCanSelectSubRows() &&
107
+ row.getIsAllSubRowsSelected()));
108
+ };
109
+ const getMRT_RowSelectionHandler = ({ renderedRowIndex = 0, row, table, }) => (event, value) => {
110
+ const { state, options: { enableBatchRowSelection, enableMultiRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
111
+ const { pagination: { pageIndex, pageSize }, } = state;
112
+ const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
113
+ const wasCurrentRowChecked = getIsRowSelected({ row, table });
114
+ // toggle selection of this row
115
+ row.toggleSelected(value ?? !wasCurrentRowChecked);
116
+ const changedRowIds = new Set([row.id]);
117
+ // if shift key is pressed, select all rows between last selected and this one
118
+ if (enableBatchRowSelection &&
119
+ enableMultiRowSelection &&
120
+ event.nativeEvent.shiftKey &&
121
+ lastSelectedRowId.current !== null) {
122
+ const rows = getMRT_Rows(table, true);
123
+ const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
124
+ if (lastIndex !== -1) {
125
+ const isLastIndexChecked = getIsRowSelected({
126
+ row: rows?.[lastIndex],
127
+ table,
128
+ });
129
+ const currentIndex = renderedRowIndex + paginationOffset;
130
+ const [start, end] = lastIndex < currentIndex
131
+ ? [lastIndex, currentIndex]
132
+ : [currentIndex, lastIndex];
133
+ // toggle selection of all rows between last selected and this one
134
+ // but only if the last selected row is not the same as the current one
135
+ if (wasCurrentRowChecked !== isLastIndexChecked) {
136
+ for (let i = start; i <= end; i++) {
137
+ rows[i].toggleSelected(!wasCurrentRowChecked);
138
+ changedRowIds.add(rows[i].id);
139
+ }
140
+ }
141
+ }
142
+ }
143
+ // record the last selected row id
144
+ lastSelectedRowId.current = row.id;
145
+ // if all sub rows were selected, unselect them
146
+ if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
147
+ row.subRows?.forEach((r) => r.toggleSelected(false));
148
+ }
149
+ if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
150
+ changedRowIds.forEach((rowId) => {
151
+ const rowToTogglePin = table.getRow(rowId);
152
+ rowToTogglePin.pin(!wasCurrentRowChecked // was not previously pinned or selected
153
+ ? rowPinningDisplayMode?.includes('bottom')
154
+ ? 'bottom'
155
+ : 'top'
156
+ : false);
157
+ });
158
+ }
159
+ };
160
+ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
161
+ const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId }, } = table;
162
+ if (selectAllMode === 'all' || forceAll) {
163
+ table.toggleAllRowsSelected(value ?? event.target.checked);
164
+ }
165
+ else {
166
+ table.toggleAllPageRowsSelected(value ?? event.target.checked);
167
+ }
168
+ if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
169
+ table.setRowPinning({ bottom: [], top: [] });
170
+ }
171
+ lastSelectedRowId.current = null;
172
+ };
173
+
174
+ const useMRT_Rows = (table) => {
175
+ const { getRowModel, state, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
176
+ const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = state;
177
+ const rows = useMemo(() => getMRT_Rows(table), [
178
+ creatingRow,
179
+ data,
180
+ enableGlobalFilterRankedResults,
181
+ expanded,
182
+ getRowModel().rows,
183
+ globalFilter,
184
+ pagination.pageIndex,
185
+ pagination.pageSize,
186
+ positionCreatingRow,
187
+ rowPinning,
188
+ sorting,
189
+ ]);
190
+ return rows;
191
+ };
192
+
193
+ const extraIndexRangeExtractor = (range, draggingIndex) => {
194
+ const newIndexes = defaultRangeExtractor(range);
195
+ if (draggingIndex === undefined)
196
+ return newIndexes;
197
+ if (draggingIndex >= 0 &&
198
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
199
+ newIndexes.unshift(draggingIndex);
200
+ }
201
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
202
+ newIndexes.push(draggingIndex);
203
+ }
204
+ return newIndexes;
205
+ };
206
+
207
+ const useMRT_RowVirtualizer = (table, rows) => {
208
+ const { getRowModel, state, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
209
+ const { density, draggingRow, expanded } = state;
210
+ if (!enableRowVirtualization)
211
+ return undefined;
212
+ const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
213
+ table,
214
+ });
215
+ const rowCount = rows?.length ?? getRowModel().rows.length;
216
+ const defaultRowHeightByDensity = {
217
+ lg: 62.7,
218
+ md: 54.7,
219
+ sm: 48.7,
220
+ xl: 70.7,
221
+ xs: 42.7,
222
+ };
223
+ const normalRowHeight = defaultRowHeightByDensity[density] ?? defaultRowHeightByDensity['md'];
224
+ const rowVirtualizer = useVirtualizer({
225
+ count: renderDetailPanel ? rowCount * 2 : rowCount,
226
+ estimateSize: (index) => renderDetailPanel && index % 2 === 1
227
+ ? expanded === true
228
+ ? 100
229
+ : 0
230
+ : normalRowHeight,
231
+ getScrollElement: () => tableContainerRef.current,
232
+ measureElement: typeof window !== 'undefined' &&
233
+ navigator.userAgent.indexOf('Firefox') === -1
234
+ ? (element) => element?.getBoundingClientRect().height
235
+ : undefined,
236
+ overscan: 4,
237
+ rangeExtractor: useCallback((range) => {
238
+ const current_index = getRowModel().rows.findIndex((row) => row.id === draggingRow?.id);
239
+ return extraIndexRangeExtractor(range, current_index >= 0 ? current_index : 0);
240
+ }, [draggingRow]),
241
+ ...rowVirtualizerProps,
242
+ });
243
+ rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
244
+ if (rowVirtualizerInstanceRef) {
245
+ // @ts-ignore
246
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
247
+ }
248
+ return rowVirtualizer;
249
+ };
250
+
251
+ const MRT_EditCellTextInput = ({ cell, table, ...rest }) => {
252
+ const { state, options: { createDisplayMode, editDisplayMode, mantineEditSelectProps, mantineEditTextInputProps, }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
253
+ const { column, row } = cell;
254
+ const { columnDef } = column;
255
+ const { creatingRow, editingRow } = state;
256
+ const isCreating = creatingRow?.id === row.id;
257
+ const isEditing = editingRow?.id === row.id;
258
+ const isSelectEdit = columnDef.editVariant === 'select';
259
+ const isMultiSelectEdit = columnDef.editVariant === 'multi-select';
260
+ const [value, setValue] = useState(() => cell.getValue());
261
+ const arg = { cell, column, row, table };
262
+ const textInputProps = {
263
+ ...parseFromValuesOrFunc(mantineEditTextInputProps, arg),
264
+ ...parseFromValuesOrFunc(columnDef.mantineEditTextInputProps, arg),
265
+ ...rest,
266
+ };
267
+ const selectProps = {
268
+ ...parseFromValuesOrFunc(mantineEditSelectProps, arg),
269
+ ...parseFromValuesOrFunc(columnDef.mantineEditSelectProps, arg),
270
+ ...rest,
271
+ };
272
+ const saveInputValueToRowCache = (newValue) => {
273
+ // @ts-ignore
274
+ row._valuesCache[column.id] = newValue;
275
+ if (isCreating) {
276
+ setCreatingRow(row);
277
+ }
278
+ else if (isEditing) {
279
+ setEditingRow(row);
280
+ }
281
+ };
282
+ const handleBlur = (event) => {
283
+ textInputProps.onBlur?.(event);
284
+ saveInputValueToRowCache(value);
285
+ setEditingCell(null);
286
+ };
287
+ const handleEnterKeyDown = (event) => {
288
+ textInputProps.onKeyDown?.(event);
289
+ if (event.key === 'Enter') {
290
+ editInputRefs.current[cell.id]?.blur();
291
+ }
292
+ };
293
+ if (columnDef.Edit) {
294
+ return columnDef.Edit?.({ cell, column, row, table });
295
+ }
296
+ const commonProps = {
297
+ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false,
298
+ label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
299
+ ? column.columnDef.header
300
+ : undefined,
301
+ name: cell.id,
302
+ onClick: (e) => {
303
+ e.stopPropagation();
304
+ textInputProps?.onClick?.(e);
305
+ },
306
+ placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
307
+ ? columnDef.header
308
+ : undefined,
309
+ value,
310
+ variant: editDisplayMode === 'table' ? 'unstyled' : 'default',
311
+ };
312
+ if (isSelectEdit) {
313
+ return (jsx(Select, { ...commonProps, searchable: true, value: value, ...selectProps, onBlur: handleBlur, onChange: (value, option) => {
314
+ selectProps.onChange?.(value, option);
315
+ setValue(value);
316
+ }, onClick: (e) => {
317
+ e.stopPropagation();
318
+ selectProps?.onClick?.(e);
319
+ }, ref: (node) => {
320
+ if (node) {
321
+ editInputRefs.current[cell.id] = node;
322
+ if (selectProps.ref && typeof selectProps.ref === 'object') {
323
+ selectProps.ref.current = node;
324
+ }
325
+ }
326
+ } }));
327
+ }
328
+ if (isMultiSelectEdit) {
329
+ return (jsx(MultiSelect, { ...commonProps, searchable: true, value: value, ...selectProps, onBlur: handleBlur, onChange: (newValue) => {
330
+ selectProps.onChange?.(value);
331
+ setValue(newValue);
332
+ // Save if not in focus, otherwise it will be handled by onBlur
333
+ if (document.activeElement === editInputRefs.current[cell.id])
334
+ return;
335
+ saveInputValueToRowCache(newValue);
336
+ }, onClick: (e) => {
337
+ e.stopPropagation();
338
+ selectProps?.onClick?.(e);
339
+ }, ref: (node) => {
340
+ if (node) {
341
+ editInputRefs.current[cell.id] = node;
342
+ if (selectProps.ref && typeof selectProps.ref === 'object') {
343
+ selectProps.ref.current = node;
344
+ }
345
+ }
346
+ } }));
347
+ }
348
+ return (jsx(TextInput, { ...commonProps, onKeyDown: handleEnterKeyDown, value: value ?? '', ...textInputProps, onBlur: handleBlur, onChange: (event) => {
349
+ textInputProps.onChange?.(event);
350
+ setValue(event.target.value);
351
+ }, onClick: (event) => {
352
+ event.stopPropagation();
353
+ textInputProps?.onClick?.(event);
354
+ }, ref: (node) => {
355
+ if (node) {
356
+ editInputRefs.current[cell.id] = node;
357
+ if (textInputProps.ref) {
358
+ textInputProps.ref.current = node;
359
+ }
360
+ }
361
+ } }));
362
+ };
363
+
364
+ var classes$C = {"root":"MRT_TableDetailPanel-module_root__vQAlM","root-grid":"MRT_TableDetailPanel-module_root-grid__7UMC6","root-virtual-row":"MRT_TableDetailPanel-module_root-virtual-row__r-X4Z","inner":"MRT_TableDetailPanel-module_inner__o-Fk-","inner-grid":"MRT_TableDetailPanel-module_inner-grid__WLZgF","inner-expanded":"MRT_TableDetailPanel-module_inner-expanded__6tg9T","inner-virtual":"MRT_TableDetailPanel-module_inner-virtual__TItRy"};
365
+
366
+ const MRT_TableDetailPanel = ({ parentRowRef, renderedRowIndex = 0, row, rowVirtualizer, striped, table, virtualRow, ...rest }) => {
367
+ const { state, getVisibleLeafColumns, options: { layoutMode, mantineDetailPanelProps, mantineTableBodyRowProps, renderDetailPanel, }, } = table;
368
+ const { isLoading } = state;
369
+ const tableRowProps = parseFromValuesOrFunc(mantineTableBodyRowProps, {
370
+ isDetailPanel: true,
371
+ row,
372
+ table,
373
+ });
374
+ const tableCellProps = {
375
+ ...parseFromValuesOrFunc(mantineDetailPanelProps, {
376
+ row,
377
+ table,
378
+ }),
379
+ ...rest,
380
+ };
381
+ const internalEditComponents = row
382
+ .getAllCells()
383
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
384
+ .map((cell) => (jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
385
+ const DetailPanel = !isLoading &&
386
+ row.getIsExpanded() &&
387
+ renderDetailPanel?.({ internalEditComponents, row, table });
388
+ return (jsx(TableTr, { "data-index": renderDetailPanel ? renderedRowIndex * 2 + 1 : renderedRowIndex, "data-striped": striped, ref: (node) => {
389
+ if (node) {
390
+ rowVirtualizer?.measureElement?.(node);
391
+ }
392
+ }, ...tableRowProps, __vars: {
393
+ '--mrt-parent-row-height': virtualRow
394
+ ? `${parentRowRef.current?.getBoundingClientRect()?.height}px`
395
+ : undefined,
396
+ '--mrt-virtual-row-start': virtualRow
397
+ ? `${virtualRow.start}px`
398
+ : undefined,
399
+ ...tableRowProps?.__vars,
400
+ }, className: clsx('mantine-Table-tr-detail-panel', classes$C.root, layoutMode?.startsWith('grid') && classes$C['root-grid'], virtualRow && classes$C['root-virtual-row'], tableRowProps?.className), children: jsx(TableTd, { colSpan: getVisibleLeafColumns().length, component: "td", ...tableCellProps, __vars: {
401
+ '--mrt-inner-width': `${table.getTotalSize()}px`,
402
+ }, className: clsx('mantine-Table-td-detail-panel', classes$C.inner, layoutMode?.startsWith('grid') && classes$C['inner-grid'], row.getIsExpanded() && classes$C['inner-expanded'], virtualRow && classes$C['inner-virtual']), p: row.getIsExpanded() && DetailPanel ? 'md' : 0, children: rowVirtualizer ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { expanded: row.getIsExpanded(), children: DetailPanel })) }) }));
403
+ };
404
+
405
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
406
+ const getPrimaryShade = (theme) => typeof theme.primaryShade === 'number'
407
+ ? theme.primaryShade
408
+ : (theme.primaryShade?.dark ?? 7);
409
+ const getPrimaryColor = (theme, shade) => theme.colors[theme.primaryColor][shade ?? getPrimaryShade(theme)];
410
+ function dataVariable(name, value) {
411
+ const key = `data-${name}`;
412
+ switch (typeof value) {
413
+ case 'boolean':
414
+ return value ? { [key]: '' } : null;
415
+ case 'number':
416
+ return { [key]: `${value}` };
417
+ case 'string':
418
+ return { [key]: value };
419
+ default:
420
+ return null;
421
+ }
422
+ }
423
+
424
+ var classes$B = {"root":"MRT_CopyButton-module_root__mkXy4"};
425
+
426
+ const MRT_CopyButton = ({ cell, children, table, ...rest }) => {
427
+ const { options: { localization: { clickToCopy, copiedToClipboard }, mantineCopyButtonProps, }, } = table;
428
+ const { column, row } = cell;
429
+ const { columnDef } = column;
430
+ const arg = { cell, column, row, table };
431
+ const buttonProps = {
432
+ ...parseFromValuesOrFunc(mantineCopyButtonProps, arg),
433
+ ...parseFromValuesOrFunc(columnDef.mantineCopyButtonProps, arg),
434
+ ...rest,
435
+ };
436
+ return (jsx(CopyButton, { value: cell.getValue(), children: ({ copied, copy }) => (jsx(Tooltip, { color: copied ? 'green' : undefined, label: buttonProps?.title ?? (copied ? copiedToClipboard : clickToCopy), openDelay: 1000, withinPortal: true, children: jsx(UnstyledButton, { ...buttonProps, className: clsx('mrt-copy-button', classes$B.root, buttonProps?.className), onClick: (e) => {
437
+ e.stopPropagation();
438
+ copy();
439
+ }, role: "presentation", title: undefined, children: children }) })) }));
440
+ };
441
+
442
+ const allowedTypes = ['string', 'number'];
443
+ const allowedFilterVariants = ['text', 'autocomplete'];
444
+ const MRT_TableBodyCellValue = ({ cell, renderedColumnIndex = 0, renderedRowIndex = 0, table, }) => {
445
+ const { state, options: { enableFilterMatchHighlighting, mantineHighlightProps = { size: 'sm' }, }, } = table;
446
+ const { column, row } = cell;
447
+ const { columnDef } = column;
448
+ const { globalFilter, globalFilterFn } = state;
449
+ const filterValue = column.getFilterValue();
450
+ const highlightProps = parseFromValuesOrFunc(mantineHighlightProps, {
451
+ cell,
452
+ column,
453
+ row,
454
+ table,
455
+ });
456
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
457
+ ? columnDef.AggregatedCell({
458
+ cell,
459
+ column,
460
+ row,
461
+ table,
462
+ })
463
+ : row.getIsGrouped() && !cell.getIsGrouped()
464
+ ? null
465
+ : cell.getIsGrouped() && columnDef.GroupedCell
466
+ ? columnDef.GroupedCell({
467
+ cell,
468
+ column,
469
+ row,
470
+ table,
471
+ })
472
+ : undefined;
473
+ const isGroupedValue = renderedCellValue !== undefined;
474
+ if (!isGroupedValue) {
475
+ renderedCellValue = cell.renderValue();
476
+ }
477
+ if (enableFilterMatchHighlighting &&
478
+ columnDef.enableFilterMatchHighlighting !== false &&
479
+ renderedCellValue &&
480
+ allowedTypes.includes(typeof renderedCellValue) &&
481
+ ((filterValue &&
482
+ allowedTypes.includes(typeof filterValue) &&
483
+ allowedFilterVariants.includes(columnDef.filterVariant)) ||
484
+ (globalFilter &&
485
+ allowedTypes.includes(typeof globalFilter) &&
486
+ column.getCanGlobalFilter()))) {
487
+ let highlight = (column.getFilterValue() ??
488
+ globalFilter ??
489
+ '').toString();
490
+ if ((filterValue ? columnDef._filterFn : globalFilterFn) === 'fuzzy') {
491
+ highlight = highlight.split(' ');
492
+ }
493
+ renderedCellValue = (jsx(Highlight, { color: "yellow.3", highlight: highlight, ...highlightProps, children: renderedCellValue?.toString() }));
494
+ }
495
+ if (columnDef.Cell && !isGroupedValue) {
496
+ renderedCellValue = columnDef.Cell({
497
+ cell,
498
+ column,
499
+ renderedCellValue,
500
+ renderedColumnIndex,
501
+ renderedRowIndex,
502
+ row,
503
+ table,
504
+ });
505
+ }
506
+ return renderedCellValue;
507
+ };
508
+
509
+ var classes$A = {"root":"MRT_TableBodyCell-module_root__Wf-zi","root-grid":"MRT_TableBodyCell-module_root-grid__zIuC-","root-virtualized":"MRT_TableBodyCell-module_root-virtualized__jLl8R","root-data-col":"MRT_TableBodyCell-module_root-data-col__HHcxc","root-nowrap":"MRT_TableBodyCell-module_root-nowrap__-k1Jo","root-cursor-pointer":"MRT_TableBodyCell-module_root-cursor-pointer__4kw7J","root-editable-hover":"MRT_TableBodyCell-module_root-editable-hover__2DKSa","root-cell-hover-reveal":"MRT_TableBodyCell-module_root-cell-hover-reveal__T1fAH","cell-hover-reveal":"MRT_TableBodyCell-module_cell-hover-reveal__Q-1Xj","overflowing":"MRT_TableBodyCell-module_overflowing__QcXP4"};
510
+
511
+ const MRT_TableBodyCell = ({ cell, numRows = 1, renderedColumnIndex = 0, renderedRowIndex = 0, rowRef, table, virtualCell, ...rest }) => {
512
+ const direction = useDirection();
513
+ const { state, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, mantineSkeletonProps, mantineTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
514
+ const { columnResizing, creatingRow, density, draggingColumn, editingCell, editingRow, hoveredColumn, isLoading, showSkeletons, } = state;
515
+ const { column, row } = cell;
516
+ const { columnDef } = column;
517
+ const { columnDefType } = columnDef;
518
+ const args = {
519
+ cell,
520
+ column,
521
+ renderedColumnIndex,
522
+ renderedRowIndex,
523
+ row,
524
+ table,
525
+ };
526
+ const tableCellProps = {
527
+ ...parseFromValuesOrFunc(mantineTableBodyCellProps, args),
528
+ ...parseFromValuesOrFunc(columnDef.mantineTableBodyCellProps, args),
529
+ ...rest,
530
+ };
531
+ const skeletonProps = parseFromValuesOrFunc(mantineSkeletonProps, args);
532
+ const [skeletonWidth, setSkeletonWidth] = useState(100);
533
+ useEffect(() => {
534
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
535
+ return;
536
+ const size = column.getSize();
537
+ setSkeletonWidth(columnDefType === 'display'
538
+ ? size / 2
539
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
540
+ }, [isLoading, showSkeletons]);
541
+ const widthStyles = {
542
+ minWidth: `max(calc(var(--col-${parseCSSVarId(column?.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
543
+ width: `calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px)`,
544
+ };
545
+ if (layoutMode === 'grid') {
546
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
547
+ ? 0
548
+ : `var(--col-${parseCSSVarId(column.id)}-size)`} 0 auto`;
549
+ }
550
+ else if (layoutMode === 'grid-no-grow') {
551
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
552
+ }
553
+ const isDraggingColumn = draggingColumn?.id === column.id;
554
+ const isHoveredColumn = hoveredColumn?.id === column.id;
555
+ const isColumnPinned = enableColumnPinning &&
556
+ columnDef.columnDefType !== 'group' &&
557
+ column.getIsPinned();
558
+ const isEditable = !cell.getIsPlaceholder() &&
559
+ parseFromValuesOrFunc(enableEditing, row) &&
560
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
561
+ const isEditing = isEditable &&
562
+ !['custom', 'modal'].includes(editDisplayMode) &&
563
+ (editDisplayMode === 'table' ||
564
+ editingRow?.id === row.id ||
565
+ editingCell?.id === cell.id) &&
566
+ !row.getIsGrouped();
567
+ const isCreating = isEditable && createDisplayMode === 'row' && creatingRow?.id === row.id;
568
+ const showClickToCopyButton = parseFromValuesOrFunc(enableClickToCopy, cell) ||
569
+ (parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) &&
570
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) !== false);
571
+ const handleDoubleClick = (event) => {
572
+ tableCellProps?.onDoubleClick?.(event);
573
+ if (isEditable && editDisplayMode === 'cell') {
574
+ setEditingCell(cell);
575
+ setTimeout(() => {
576
+ const textField = editInputRefs.current[cell.id];
577
+ if (textField) {
578
+ textField.focus();
579
+ textField.select?.();
580
+ }
581
+ }, 100);
582
+ }
583
+ };
584
+ const handleDragEnter = (e) => {
585
+ tableCellProps?.onDragEnter?.(e);
586
+ if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
587
+ setHoveredColumn(null);
588
+ }
589
+ if (enableColumnOrdering && draggingColumn) {
590
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
591
+ }
592
+ };
593
+ const cellValueProps = {
594
+ cell,
595
+ renderedColumnIndex,
596
+ renderedRowIndex,
597
+ table,
598
+ };
599
+ const cellHoverRevealDivRef = useRef(null);
600
+ const [isCellContentOverflowing, setIsCellContentOverflowing] = useState(false);
601
+ const onMouseEnter = () => {
602
+ if (!columnDef.enableCellHoverReveal)
603
+ return;
604
+ const div = cellHoverRevealDivRef.current;
605
+ if (div) {
606
+ const isOverflow = div.scrollWidth > div.clientWidth;
607
+ setIsCellContentOverflowing(isOverflow);
608
+ }
609
+ };
610
+ const onMouseLeave = () => {
611
+ if (!columnDef.enableCellHoverReveal)
612
+ return;
613
+ setIsCellContentOverflowing(false);
614
+ };
615
+ const renderCellContent = () => {
616
+ if (cell.getIsPlaceholder()) {
617
+ return columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null;
618
+ }
619
+ if (showSkeletons !== false && (isLoading || showSkeletons)) {
620
+ return jsx(Skeleton, { height: 20, width: skeletonWidth, ...skeletonProps });
621
+ }
622
+ if (columnDefType === 'display' &&
623
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
624
+ !row.getIsGrouped())) {
625
+ return columnDef.Cell?.({
626
+ column,
627
+ renderedCellValue: cell.renderValue(),
628
+ row,
629
+ rowRef,
630
+ ...cellValueProps,
631
+ });
632
+ }
633
+ if (isCreating || isEditing) {
634
+ return jsx(MRT_EditCellTextInput, { cell: cell, table: table });
635
+ }
636
+ if (showClickToCopyButton && columnDef.enableClickToCopy !== false) {
637
+ return (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, { ...cellValueProps }) }));
638
+ }
639
+ return jsx(MRT_TableBodyCellValue, { ...cellValueProps });
640
+ };
641
+ return (jsx(TableTd, { "data-column-pinned": isColumnPinned || undefined, "data-dragging-column": isDraggingColumn || undefined, "data-first-end-pinned": (isColumnPinned === 'end' && column.getIsFirstColumn(isColumnPinned)) ||
642
+ undefined, "data-hovered-column-target": isHoveredColumn || undefined, "data-index": renderedColumnIndex, "data-last-start-pinned": (isColumnPinned === 'start' &&
643
+ column.getIsLastColumn(isColumnPinned)) ||
644
+ undefined, "data-last-row": renderedRowIndex === numRows - 1 || undefined, "data-resizing": (columnResizeMode === 'onChange' &&
645
+ columnResizing?.isResizingColumn === column.id &&
646
+ columnResizeDirection) ||
647
+ undefined, ...tableCellProps, __vars: {
648
+ '--mrt-cell-align': tableCellProps.align ?? (direction.dir === 'rtl' ? 'right' : 'left'),
649
+ '--mrt-table-cell-start': isColumnPinned === 'start'
650
+ ? `${column.getStart(isColumnPinned)}`
651
+ : undefined,
652
+ '--mrt-table-cell-end': isColumnPinned === 'end'
653
+ ? `${column.getAfter(isColumnPinned)}`
654
+ : undefined,
655
+ ...tableCellProps.__vars,
656
+ }, className: clsx(classes$A.root, layoutMode?.startsWith('grid') && classes$A['root-grid'], virtualCell && classes$A['root-virtualized'], isEditable &&
657
+ editDisplayMode === 'cell' &&
658
+ classes$A['root-cursor-pointer'], isEditable &&
659
+ ['cell', 'table'].includes(editDisplayMode ?? '') &&
660
+ columnDefType !== 'display' &&
661
+ classes$A['root-editable-hover'], columnDefType === 'data' && classes$A['root-data-col'], density === 'xs' && classes$A['root-nowrap'], columnDef.enableCellHoverReveal && classes$A['root-cell-hover-reveal'], tableCellProps?.className), onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: (theme) => ({
662
+ ...widthStyles,
663
+ ...parseFromValuesOrFunc(tableCellProps.style, theme),
664
+ }), children: jsx(Fragment, { children: tableCellProps.children ??
665
+ (columnDef.enableCellHoverReveal ? (jsxs("div", { className: clsx(columnDef.enableCellHoverReveal &&
666
+ !(isCreating || isEditing) &&
667
+ classes$A['cell-hover-reveal'], isCellContentOverflowing && classes$A['overflowing']), ref: cellHoverRevealDivRef, children: [renderCellContent(), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", row.subRows?.length, ")"] }))] })) : (jsxs(Fragment, { children: [renderCellContent(), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", row.subRows?.length, ")"] }))] }))) }) }));
668
+ };
669
+ const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
670
+
671
+ var classes$z = {"root":"MRT_TableBodyRow-module_root__2c3D4","root-grid":"MRT_TableBodyRow-module_root-grid__AwXTe","root-virtualized":"MRT_TableBodyRow-module_root-virtualized__zYgxq"};
672
+
673
+ const MRT_TableBodyRow = ({ children, columnVirtualizer, numRows, pinnedRowIds, renderedRowIndex = 0, row, rowVirtualizer, table, tableProps, virtualRow, ...rest }) => {
674
+ const { state, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, mantineTableBodyRowProps, memoMode, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
675
+ const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = state;
676
+ const visibleCells = row.getVisibleCells();
677
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
678
+ const isRowSelected = getIsRowSelected({ row, table });
679
+ const isRowPinned = enableRowPinning && row.getIsPinned();
680
+ const isRowStickyPinned = isRowPinned && rowPinningDisplayMode?.includes('sticky') && 'sticky';
681
+ const isDraggingRow = draggingRow?.id === row.id;
682
+ const isHoveredRow = hoveredRow?.id === row.id;
683
+ const tableRowProps = {
684
+ ...parseFromValuesOrFunc(mantineTableBodyRowProps, {
685
+ renderedRowIndex,
686
+ row,
687
+ table,
688
+ }),
689
+ ...rest,
690
+ };
691
+ const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
692
+ if (!enableRowPinning ||
693
+ !isRowStickyPinned ||
694
+ !pinnedRowIds ||
695
+ !row.getIsPinned())
696
+ return [];
697
+ return [
698
+ [...pinnedRowIds].reverse().indexOf(row.id),
699
+ pinnedRowIds.indexOf(row.id),
700
+ ];
701
+ }, [pinnedRowIds, rowPinning]);
702
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
703
+ tableHeadRef.current?.clientHeight) ||
704
+ 0;
705
+ const tableFooterHeight = (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0;
706
+ const defaultRowHeightByDensity = {
707
+ lg: 61,
708
+ md: 53,
709
+ sm: 45,
710
+ xl: 69,
711
+ xs: 37,
712
+ };
713
+ const rowHeight =
714
+ // @ts-ignore
715
+ parseInt(tableRowProps?.style?.height, 10) ||
716
+ (defaultRowHeightByDensity[density] ?? defaultRowHeightByDensity['md']);
717
+ const handleDragEnter = (_e) => {
718
+ if (enableRowOrdering && draggingRow) {
719
+ setHoveredRow(row);
720
+ }
721
+ };
722
+ const rowRef = useRef(null);
723
+ let striped = tableProps.striped;
724
+ if (striped) {
725
+ if (striped === true) {
726
+ striped = 'odd';
727
+ }
728
+ if (striped === 'odd' && renderedRowIndex % 2 !== 0) {
729
+ striped = false;
730
+ }
731
+ if (striped === 'even' && renderedRowIndex % 2 === 0) {
732
+ striped = false;
733
+ }
734
+ }
735
+ return (jsxs(Fragment, { children: [jsxs(TableTr, { "data-dragging-row": isDraggingRow || undefined, "data-hovered-row-target": isHoveredRow || undefined, "data-index": renderDetailPanel ? renderedRowIndex * 2 : renderedRowIndex, "data-row-pinned": isRowStickyPinned || isRowPinned || undefined, "data-selected": isRowSelected || undefined, "data-striped": striped, onDragEnter: handleDragEnter, ref: (node) => {
736
+ if (node) {
737
+ rowRef.current = node;
738
+ rowVirtualizer?.measureElement(node);
739
+ }
740
+ }, ...tableRowProps, __vars: {
741
+ ...tableRowProps?.__vars,
742
+ '--mrt-pinned-row-bottom': !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
743
+ ? `${bottomPinnedIndex * rowHeight +
744
+ (enableStickyFooter ? tableFooterHeight - 1 : 0)}`
745
+ : undefined,
746
+ '--mrt-pinned-row-top': virtualRow
747
+ ? undefined
748
+ : topPinnedIndex !== undefined && isRowPinned
749
+ ? `${topPinnedIndex * rowHeight +
750
+ (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}`
751
+ : undefined,
752
+ '--mrt-virtual-row-start': virtualRow
753
+ ? `${virtualRow.start}`
754
+ : undefined,
755
+ }, className: clsx(classes$z.root, layoutMode?.startsWith('grid') && classes$z['root-grid'], virtualRow && classes$z['root-virtualized'], tableRowProps?.className), children: [virtualPaddingLeft ? (jsx(Box, { component: "td", display: "flex", w: virtualPaddingLeft })) : null, children
756
+ ? children
757
+ : (virtualColumns ?? row.getVisibleCells()).map((cellOrVirtualCell, renderedColumnIndex) => {
758
+ let cell = cellOrVirtualCell;
759
+ if (columnVirtualizer) {
760
+ renderedColumnIndex = cellOrVirtualCell
761
+ .index;
762
+ cell = visibleCells[renderedColumnIndex];
763
+ }
764
+ const cellProps = {
765
+ cell,
766
+ numRows,
767
+ renderedColumnIndex,
768
+ renderedRowIndex,
769
+ rowRef,
770
+ table,
771
+ virtualCell: columnVirtualizer
772
+ ? cellOrVirtualCell
773
+ : undefined,
774
+ };
775
+ return memoMode === 'cells' &&
776
+ cell.column.columnDef.columnDefType === 'data' &&
777
+ !draggingColumn &&
778
+ !draggingRow &&
779
+ editingCell?.id !== cell.id &&
780
+ editingRow?.id !== row.id ? (jsx(Memo_MRT_TableBodyCell, { ...cellProps }, cell.id)) : (jsx(MRT_TableBodyCell, { ...cellProps }, cell.id));
781
+ }), virtualPaddingRight ? (jsx(Box, { component: "td", display: "flex", w: virtualPaddingRight })) : null] }), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, renderedRowIndex: renderedRowIndex, row: row, rowVirtualizer: rowVirtualizer, striped: striped, table: table, virtualRow: virtualRow }))] }));
782
+ };
783
+ const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
784
+
785
+ var classes$y = {"root":"MRT_ExpandButton-module_root__IFYio","root-ltr":"MRT_ExpandButton-module_root-ltr__FHNnp","chevron":"MRT_ExpandButton-module_chevron__XzC5P","right":"MRT_ExpandButton-module_right__-pC-A","up":"MRT_ExpandButton-module_up__TZGBo","root-rtl":"MRT_ExpandButton-module_root-rtl__zoudS"};
786
+
787
+ const MRT_ExpandButton = ({ row, table, ...rest }) => {
788
+ const direction = useDirection();
789
+ const { options: { icons: { IconChevronDown }, localization, mantineExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
790
+ const actionIconProps = {
791
+ ...parseFromValuesOrFunc(mantineExpandButtonProps, {
792
+ row,
793
+ table,
794
+ }),
795
+ ...rest,
796
+ };
797
+ const internalEditComponents = row
798
+ .getAllCells()
799
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
800
+ .map((cell) => (jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
801
+ const canExpand = row.getCanExpand();
802
+ const isExpanded = row.getIsExpanded();
803
+ const DetailPanel = !!renderDetailPanel?.({
804
+ internalEditComponents,
805
+ row,
806
+ table,
807
+ });
808
+ const handleToggleExpand = (event) => {
809
+ event.stopPropagation();
810
+ row.toggleExpanded();
811
+ actionIconProps?.onClick?.(event);
812
+ };
813
+ const rtl = direction.dir === 'rtl' || positionExpandColumn === 'last';
814
+ return (jsx(Tooltip, { disabled: !canExpand && !DetailPanel, label: actionIconProps?.title ??
815
+ (isExpanded ? localization.collapse : localization.expand), openDelay: 1000, withinPortal: true, children: jsx(ActionIcon, { "aria-label": localization.expand, color: "gray", disabled: !canExpand && !DetailPanel, variant: "subtle", ...actionIconProps, __vars: {
816
+ '--mrt-row-depth': `${row.depth}`,
817
+ }, className: clsx('mrt-expand-button', classes$y.root, classes$y[`root-${rtl ? 'rtl' : 'ltr'}`], actionIconProps?.className), onClick: handleToggleExpand, title: undefined, children: actionIconProps?.children ?? (jsx(IconChevronDown, { className: clsx('mrt-expand-button-chevron', classes$y.chevron, !canExpand && !renderDetailPanel
818
+ ? classes$y.right
819
+ : isExpanded
820
+ ? classes$y.up
821
+ : undefined) })) }) }));
822
+ };
823
+
824
+ var classes$x = {"root":"MRT_TableBody-module_root__kGhRy","root-grid":"MRT_TableBody-module_root-grid__WdOGg","root-no-rows":"MRT_TableBody-module_root-no-rows__iyi9K","root-virtualized":"MRT_TableBody-module_root-virtualized__TxPAi","empty-row-tr-grid":"MRT_TableBody-module_empty-row-tr-grid__LTgxw","empty-row-td-grid":"MRT_TableBody-module_empty-row-td-grid__pzlgG","empty-row-td-content":"MRT_TableBody-module_empty-row-td-content__Cc2XW","pinned":"MRT_TableBody-module_pinned__XHpcs"};
825
+
826
+ const MRT_TableBodyEmptyRow = ({ table, tableProps, ...commonRowProps }) => {
827
+ const { state, options: { layoutMode, localization, renderDetailPanel, renderEmptyRowsFallback, }, refs: { tablePaperRef }, } = table;
828
+ const { columnFilters, globalFilter } = state;
829
+ const emptyRow = useMemo(() => constructRow(table, 'mrt-row-empty', {}, 0, 0), []);
830
+ const emptyRowProps = {
831
+ ...commonRowProps,
832
+ renderedRowIndex: 0,
833
+ row: emptyRow,
834
+ virtualRow: undefined,
835
+ };
836
+ return (jsxs(MRT_TableBodyRow, { className: clsx('mrt-table-body-row', layoutMode?.startsWith('grid') && classes$x['empty-row-tr-grid']), table: table, tableProps: tableProps, ...emptyRowProps, children: [renderDetailPanel && (jsx(TableTd, { className: clsx('mrt-table-body-cell', layoutMode?.startsWith('grid') && classes$x['empty-row-td-grid']), colSpan: 1, children: jsx(MRT_ExpandButton, { row: emptyRow, table: table }) })), jsx("td", { className: clsx('mrt-table-body-cell', layoutMode?.startsWith('grid') && classes$x['empty-row-td-grid']), colSpan: table.getVisibleLeafColumns().length, children: renderEmptyRowsFallback?.({ table }) ?? (jsx(Text, { __vars: {
837
+ '--mrt-paper-width': `${tablePaperRef.current?.clientWidth}`,
838
+ }, className: clsx(classes$x['empty-row-td-content']), children: globalFilter || columnFilters.length
839
+ ? localization.noResultsFound
840
+ : localization.noRecordsToDisplay })) })] }));
841
+ };
842
+
843
+ const MRT_TableBody = ({ columnVirtualizer, table, tableProps, ...rest }) => {
844
+ const { getBottomRows, getIsSomeRowsPinned, getRowModel, state, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, mantineTableBodyProps, memoMode, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, } = table;
845
+ const { isFullScreen, rowPinning } = state;
846
+ const tableBodyProps = {
847
+ ...parseFromValuesOrFunc(mantineTableBodyProps, { table }),
848
+ ...rest,
849
+ };
850
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
851
+ tableHeadRef.current?.clientHeight) ||
852
+ 0;
853
+ const tableFooterHeight = (enableStickyFooter && tableFooterRef.current?.clientHeight) || 0;
854
+ const pinnedRowIds = useMemo(() => {
855
+ if (!rowPinning.bottom?.length && !rowPinning.top?.length)
856
+ return [];
857
+ return getRowModel()
858
+ .rows.filter((row) => row.getIsPinned())
859
+ .map((r) => r.id);
860
+ }, [rowPinning, getRowModel().rows]);
861
+ const rows = useMRT_Rows(table);
862
+ const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
863
+ const { virtualRows } = rowVirtualizer ?? {};
864
+ const commonRowProps = {
865
+ columnVirtualizer,
866
+ numRows: rows.length,
867
+ table,
868
+ tableProps,
869
+ };
870
+ return (jsxs(Fragment, { children: [!rowPinningDisplayMode?.includes('sticky') &&
871
+ getIsSomeRowsPinned('top') && (jsx(TableTbody, { ...tableBodyProps, __vars: {
872
+ '--mrt-table-head-height': `${tableHeadHeight}`,
873
+ ...tableBodyProps?.__vars,
874
+ }, className: clsx(classes$x.pinned, layoutMode?.startsWith('grid') && classes$x['root-grid'], tableBodyProps?.className), children: getTopRows().map((row, renderedRowIndex) => {
875
+ const rowProps = {
876
+ ...commonRowProps,
877
+ renderedRowIndex,
878
+ row,
879
+ };
880
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, { ...rowProps }, row.id)) : (jsx(MRT_TableBodyRow, { ...rowProps }, row.id));
881
+ }) })), jsx(TableTbody, { ...tableBodyProps, __vars: {
882
+ '--mrt-table-body-height': rowVirtualizer
883
+ ? `${rowVirtualizer.getTotalSize()}px`
884
+ : undefined,
885
+ ...tableBodyProps?.__vars,
886
+ }, className: clsx(classes$x.root, layoutMode?.startsWith('grid') && classes$x['root-grid'], !rows.length && classes$x['root-no-rows'], rowVirtualizer && classes$x['root-virtualized'], tableBodyProps?.className), children: tableBodyProps?.children ??
887
+ (!rows.length ? (jsx(MRT_TableBodyEmptyRow, { ...commonRowProps })) : (jsx(Fragment, { children: (virtualRows ?? rows).map((rowOrVirtualRow, renderedRowIndex) => {
888
+ if (rowVirtualizer) {
889
+ if (renderDetailPanel) {
890
+ if (rowOrVirtualRow.index % 2 === 1) {
891
+ return null;
892
+ }
893
+ else {
894
+ renderedRowIndex = rowOrVirtualRow.index / 2;
895
+ }
896
+ }
897
+ else {
898
+ renderedRowIndex = rowOrVirtualRow.index;
899
+ }
900
+ }
901
+ const row = rowVirtualizer
902
+ ? rows[renderedRowIndex]
903
+ : rowOrVirtualRow;
904
+ const props = {
905
+ ...commonRowProps,
906
+ pinnedRowIds,
907
+ renderedRowIndex,
908
+ row,
909
+ rowVirtualizer,
910
+ virtualRow: rowVirtualizer
911
+ ? rowOrVirtualRow
912
+ : undefined,
913
+ };
914
+ const key = `${row.id}-${row.index}`;
915
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, { ...props }, key)) : (jsx(MRT_TableBodyRow, { ...props }, key));
916
+ }) }))) }), !rowPinningDisplayMode?.includes('sticky') &&
917
+ getIsSomeRowsPinned('bottom') && (jsx(TableTbody, { ...tableBodyProps, __vars: {
918
+ '--mrt-table-footer-height': `${tableFooterHeight}`,
919
+ ...tableBodyProps?.__vars,
920
+ }, className: clsx(classes$x.pinned, layoutMode?.startsWith('grid') && classes$x['root-grid'], tableBodyProps?.className), children: getBottomRows().map((row, renderedRowIndex) => {
921
+ const props = {
922
+ ...commonRowProps,
923
+ renderedRowIndex,
924
+ row,
925
+ };
926
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, { ...props }, row.id)) : (jsx(MRT_TableBodyRow, { ...props }, row.id));
927
+ }) }))] }));
928
+ };
929
+ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
930
+
931
+ var classes$w = {"grab-icon":"MRT_GrabHandleButton-module_grab-icon__mQimy"};
932
+
933
+ const MRT_GrabHandleButton = ({ actionIconProps, onDragEnd, onDragStart, table: { options: { icons: { IconGripHorizontal }, localization: { move }, }, }, }) => {
934
+ return (jsx(Tooltip, { label: actionIconProps?.title ?? move, openDelay: 1000, withinPortal: true, children: jsx(ActionIcon, { "aria-label": actionIconProps?.title ?? move, draggable: true, ...actionIconProps, className: clsx('mrt-grab-handle-button', classes$w['grab-icon'], actionIconProps?.className), color: "gray", onClick: (e) => {
935
+ e.stopPropagation();
936
+ actionIconProps?.onClick?.(e);
937
+ }, onDragEnd: onDragEnd, onDragStart: onDragStart, size: "sm", title: undefined, variant: "transparent", children: jsx(IconGripHorizontal, { size: "100%" }) }) }));
938
+ };
939
+
940
+ const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, ...rest }) => {
941
+ const { options: { mantineRowDragHandleProps }, } = table;
942
+ const actionIconProps = {
943
+ ...parseFromValuesOrFunc(mantineRowDragHandleProps, {
944
+ row,
945
+ table,
946
+ }),
947
+ ...rest,
948
+ };
949
+ const handleDragStart = (event) => {
950
+ actionIconProps?.onDragStart?.(event);
951
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
952
+ table.setDraggingRow(row);
953
+ };
954
+ const handleDragEnd = (event) => {
955
+ actionIconProps?.onDragEnd?.(event);
956
+ table.setDraggingRow(null);
957
+ table.setHoveredRow(null);
958
+ };
959
+ return (jsx(MRT_GrabHandleButton, { actionIconProps: actionIconProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
960
+ };
961
+
962
+ const MRT_RowPinButton = ({ pinningPosition, row, table, ...rest }) => {
963
+ const { options: { icons: { IconPinned, IconX }, localization, rowPinningDisplayMode, }, } = table;
964
+ const isPinned = row.getIsPinned();
965
+ const [tooltipOpened, setTooltipOpened] = useState(false);
966
+ const handleTogglePin = (event) => {
967
+ setTooltipOpened(false);
968
+ event.stopPropagation();
969
+ row.pin(isPinned ? false : pinningPosition);
970
+ };
971
+ return (jsx(Tooltip, { label: isPinned ? localization.unpin : localization.pin, openDelay: 1000, opened: tooltipOpened, children: jsx(ActionIcon, { "aria-label": localization.pin, color: "gray", onClick: handleTogglePin, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "xs", style: {
972
+ height: '24px',
973
+ width: '24px',
974
+ }, variant: "subtle", ...rest, children: isPinned ? (jsx(IconX, {})) : (jsx(IconPinned, { fontSize: "small", style: {
975
+ transform: `rotate(${rowPinningDisplayMode === 'sticky'
976
+ ? 135
977
+ : pinningPosition === 'top'
978
+ ? 180
979
+ : 0}deg)`,
980
+ } })) }) }));
981
+ };
982
+
983
+ const MRT_TableBodyRowPinButton = ({ row, table, ...rest }) => {
984
+ const { state, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
985
+ const { density } = state;
986
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
987
+ if (!canPin)
988
+ return null;
989
+ const rowPinButtonProps = {
990
+ row,
991
+ table,
992
+ ...rest,
993
+ };
994
+ if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
995
+ return (jsxs(Box, { style: {
996
+ display: 'flex',
997
+ flexDirection: density === 'xs' ? 'row' : 'column',
998
+ }, children: [jsx(MRT_RowPinButton, { pinningPosition: "top", ...rowPinButtonProps }), jsx(MRT_RowPinButton, { pinningPosition: "bottom", ...rowPinButtonProps })] }));
999
+ }
1000
+ return (jsx(MRT_RowPinButton, { pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top', ...rowPinButtonProps }));
1001
+ };
1002
+
1003
+ var classes$v = {"root":"MRT_ColumnPinningButtons-module_root__scTtW","left":"MRT_ColumnPinningButtons-module_left__W6Aog","right":"MRT_ColumnPinningButtons-module_right__7AJE3"};
1004
+
1005
+ const MRT_ColumnPinningButtons = ({ column, table, }) => {
1006
+ const { options: { icons: { IconPinned, IconPinnedOff }, localization, }, } = table;
1007
+ return (jsx(Flex, { className: clsx('mrt-column-pinning-buttons', classes$v.root), children: column.getIsPinned() ? (jsx(Tooltip, { label: localization.unpin, withinPortal: true, children: jsx(ActionIcon, { color: "gray", onClick: () => column.pin(false), size: "md", variant: "subtle", children: jsx(IconPinnedOff, {}) }) })) : (jsxs(Fragment, { children: [jsx(Tooltip, { label: localization.pinToLeft, withinPortal: true, children: jsx(ActionIcon, { color: "gray", onClick: () => column.pin('start'), size: "md", variant: "subtle", children: jsx(IconPinned, { className: classes$v.left }) }) }), jsx(Tooltip, { label: localization.pinToRight, withinPortal: true, children: jsx(ActionIcon, { color: "gray", onClick: () => column.pin('end'), size: "md", variant: "subtle", children: jsx(IconPinned, { className: classes$v.right }) }) })] })) }));
1008
+ };
1009
+
1010
+ var classes$u = {"root":"MRT_EditActionButtons-module_root__BfxVZ"};
1011
+
1012
+ const MRT_EditActionButtons = ({ row, table, variant = 'icon', ...rest }) => {
1013
+ const { state, options: { icons: { IconCircleX, IconDeviceFloppy }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
1014
+ const { creatingRow, editingRow, isSaving } = state;
1015
+ const isCreating = creatingRow?.id === row.id;
1016
+ const isEditing = editingRow?.id === row.id;
1017
+ const handleCancel = () => {
1018
+ if (isCreating) {
1019
+ onCreatingRowCancel?.({ row, table });
1020
+ setCreatingRow(null);
1021
+ }
1022
+ else if (isEditing) {
1023
+ onEditingRowCancel?.({ row, table });
1024
+ setEditingRow(null);
1025
+ }
1026
+ row._valuesCache = {}; // reset values cache
1027
+ };
1028
+ const handleSubmitRow = () => {
1029
+ // look for auto-filled input values
1030
+ Object.values(editInputRefs?.current)
1031
+ .filter((inputRef) => row.id === inputRef?.name?.split('_')?.[0])
1032
+ ?.forEach((input) => {
1033
+ if (input.value !== undefined &&
1034
+ Object.hasOwn(row?._valuesCache, input.name)) {
1035
+ // @ts-ignore
1036
+ row._valuesCache[input.name] = input.value;
1037
+ }
1038
+ });
1039
+ if (isCreating)
1040
+ onCreatingRowSave?.({
1041
+ exitCreatingMode: () => setCreatingRow(null),
1042
+ row,
1043
+ table,
1044
+ values: row._valuesCache,
1045
+ });
1046
+ else if (isEditing) {
1047
+ onEditingRowSave?.({
1048
+ exitEditingMode: () => setEditingRow(null),
1049
+ row,
1050
+ table,
1051
+ values: row?._valuesCache,
1052
+ });
1053
+ }
1054
+ };
1055
+ return (jsx(Box, { className: clsx('mrt-edit-action-buttons', classes$u.root), onClick: (e) => e.stopPropagation(), ...rest, children: variant === 'icon' ? (jsxs(Fragment, { children: [jsx(Tooltip, { label: localization.cancel, withinPortal: true, children: jsx(ActionIcon, { "aria-label": localization.cancel, color: "red", onClick: handleCancel, variant: "subtle", children: jsx(IconCircleX, {}) }) }), jsx(Tooltip, { label: localization.save, withinPortal: true, children: jsx(ActionIcon, { "aria-label": localization.save, color: "blue", loading: isSaving, onClick: handleSubmitRow, variant: "subtle", children: jsx(IconDeviceFloppy, {}) }) })] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, variant: "subtle", children: localization.cancel }), jsx(Button, { loading: isSaving, onClick: handleSubmitRow, variant: "filled", children: localization.save })] })) }));
1056
+ };
1057
+
1058
+ var classes$t = {"root":"MRT_ExpandAllButton-module_root__gkBZD","chevron":"MRT_ExpandAllButton-module_chevron__Iep0j","up":"MRT_ExpandAllButton-module_up__Xth3U","right":"MRT_ExpandAllButton-module_right__bS4L-"};
1059
+
1060
+ const MRT_ExpandAllButton = ({ table, ...rest }) => {
1061
+ const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, state, options: { icons: { IconChevronsDown }, localization, mantineExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1062
+ const { density, isLoading } = state;
1063
+ const actionIconProps = {
1064
+ ...parseFromValuesOrFunc(mantineExpandAllButtonProps, {
1065
+ table,
1066
+ }),
1067
+ ...rest,
1068
+ };
1069
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1070
+ return (jsx(Tooltip, { label: (actionIconProps?.title ?? isAllRowsExpanded)
1071
+ ? localization.collapseAll
1072
+ : localization.expandAll, openDelay: 1000, withinPortal: true, children: jsx(ActionIcon, { "aria-label": localization.expandAll, color: "gray", variant: "subtle", ...actionIconProps, className: clsx('mrt-expand-all-button', classes$t.root, actionIconProps?.className, density), disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded), title: undefined, children: actionIconProps?.children ?? (jsx(IconChevronsDown, { className: clsx(classes$t.chevron, isAllRowsExpanded
1073
+ ? classes$t.up
1074
+ : getIsSomeRowsExpanded()
1075
+ ? classes$t.right
1076
+ : undefined) })) }) }));
1077
+ };
1078
+
1079
+ const getColumnId = (columnDef) => columnDef.id ?? columnDef.accessorKey?.toString?.() ?? columnDef.header;
1080
+ const getAllLeafColumnDefs = (columns) => {
1081
+ const allLeafColumnDefs = [];
1082
+ const getLeafColumns = (cols) => {
1083
+ cols.forEach((col) => {
1084
+ if (col.columns) {
1085
+ getLeafColumns(col.columns);
1086
+ }
1087
+ else {
1088
+ allLeafColumnDefs.push(col);
1089
+ }
1090
+ });
1091
+ };
1092
+ getLeafColumns(columns);
1093
+ return allLeafColumnDefs;
1094
+ };
1095
+ const prepareColumns = ({ columnDefs, tableOptions, }) => {
1096
+ const { defaultDisplayColumn, filterFns = {}, sortFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
1097
+ return columnDefs.map((columnDef) => {
1098
+ // assign columnId
1099
+ if (!columnDef.id)
1100
+ columnDef.id = getColumnId(columnDef);
1101
+ // assign columnDefType
1102
+ if (!columnDef.columnDefType)
1103
+ columnDef.columnDefType = 'data';
1104
+ if (columnDef.columns?.length) {
1105
+ columnDef.columnDefType = 'group';
1106
+ // recursively prepare columns if this is a group column
1107
+ columnDef.columns = prepareColumns({
1108
+ columnDefs: columnDef.columns,
1109
+ tableOptions,
1110
+ });
1111
+ }
1112
+ else if (columnDef.columnDefType === 'data') {
1113
+ // assign filterFns
1114
+ if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
1115
+ columnDef.filterFn =
1116
+ filterFns[columnFilterFns[columnDef.id]] ?? filterFns.fuzzy;
1117
+ columnDef._filterFn =
1118
+ columnFilterFns[columnDef.id];
1119
+ }
1120
+ // assign sortFns
1121
+ if (Object.keys(sortFns).includes(columnDef.sortFn)) {
1122
+ columnDef.sortFn = sortFns[columnDef.sortFn];
1123
+ }
1124
+ }
1125
+ else if (columnDef.columnDefType === 'display') {
1126
+ columnDef = {
1127
+ ...defaultDisplayColumn,
1128
+ ...columnDef,
1129
+ };
1130
+ }
1131
+ return columnDef;
1132
+ });
1133
+ };
1134
+ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
1135
+ if (draggedColumn.getCanPin()) {
1136
+ draggedColumn.pin(targetColumn.getIsPinned());
1137
+ }
1138
+ const newColumnOrder = [...columnOrder];
1139
+ newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
1140
+ return newColumnOrder;
1141
+ };
1142
+ const getDefaultColumnFilterFn = (columnDef) => {
1143
+ const { filterVariant } = columnDef;
1144
+ if (filterVariant === 'multi-select')
1145
+ return 'arrIncludesSome';
1146
+ if (filterVariant?.includes('range'))
1147
+ return 'betweenInclusive';
1148
+ if (['checkbox', 'date', 'select'].includes(filterVariant || ''))
1149
+ return 'equals';
1150
+ return 'fuzzy';
1151
+ };
1152
+
1153
+ function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
1154
+ const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
1155
+ return {
1156
+ ...defaultDisplayColumn,
1157
+ header: header ? localization[header] : '',
1158
+ size,
1159
+ ...displayColumnDefOptions?.[id],
1160
+ id,
1161
+ };
1162
+ }
1163
+ const showRowPinningColumn = (tableOptions) => {
1164
+ const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
1165
+ return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
1166
+ };
1167
+ const showRowDragColumn = (tableOptions) => {
1168
+ const { enableRowDragging, enableRowOrdering } = tableOptions;
1169
+ return !!(enableRowDragging || enableRowOrdering);
1170
+ };
1171
+ const showRowExpandColumn = (tableOptions) => {
1172
+ const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
1173
+ return !!(enableExpanding ||
1174
+ (enableGrouping && grouping?.length) ||
1175
+ renderDetailPanel);
1176
+ };
1177
+ const showRowActionsColumn = (tableOptions) => {
1178
+ const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
1179
+ return !!(enableRowActions ||
1180
+ (creatingRow && createDisplayMode === 'row') ||
1181
+ (enableEditing && ['modal', 'row'].includes(editDisplayMode ?? '')));
1182
+ };
1183
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
1184
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
1185
+ const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
1186
+ const getLeadingDisplayColumnIds = (tableOptions) => [
1187
+ showRowPinningColumn(tableOptions) && 'mrt-row-pin',
1188
+ showRowDragColumn(tableOptions) && 'mrt-row-drag',
1189
+ tableOptions.positionActionsColumn === 'first' &&
1190
+ showRowActionsColumn(tableOptions) &&
1191
+ 'mrt-row-actions',
1192
+ tableOptions.positionExpandColumn === 'first' &&
1193
+ showRowExpandColumn(tableOptions) &&
1194
+ 'mrt-row-expand',
1195
+ showRowSelectionColumn(tableOptions) && 'mrt-row-select',
1196
+ showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
1197
+ ].filter(Boolean);
1198
+ const getTrailingDisplayColumnIds = (tableOptions) => [
1199
+ tableOptions.positionActionsColumn === 'last' &&
1200
+ showRowActionsColumn(tableOptions) &&
1201
+ 'mrt-row-actions',
1202
+ tableOptions.positionExpandColumn === 'last' &&
1203
+ showRowExpandColumn(tableOptions) &&
1204
+ 'mrt-row-expand',
1205
+ showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
1206
+ ].filter(Boolean);
1207
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
1208
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
1209
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
1210
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
1211
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
1212
+ let allLeafColumnDefIds = reset
1213
+ ? defaultColumnDefIds
1214
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
1215
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
1216
+ !trailingDisplayColIds.includes(colId));
1217
+ return [
1218
+ ...leadingDisplayColIds,
1219
+ ...allLeafColumnDefIds,
1220
+ ...trailingDisplayColIds,
1221
+ ];
1222
+ };
1223
+
1224
+ var classes$s = {"root":"MRT_ShowHideColumnsMenuItems-module_root__wYgv-","menu":"MRT_ShowHideColumnsMenuItems-module_menu__CeATR","grab":"MRT_ShowHideColumnsMenuItems-module_grab__a-d-y","pin":"MRT_ShowHideColumnsMenuItems-module_pin__P437b","switch":"MRT_ShowHideColumnsMenuItems-module_switch__tMsdt","header":"MRT_ShowHideColumnsMenuItems-module_header__xVkKb"};
1225
+
1226
+ const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, setHoveredColumn, table, }) => {
1227
+ const theme = useMantineTheme();
1228
+ const { state, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, setColumnOrder, } = table;
1229
+ const { columnOrder } = state;
1230
+ const { columnDef } = column;
1231
+ const { columnDefType } = columnDef;
1232
+ const switchChecked = (columnDefType !== 'group' && column.getIsVisible()) ||
1233
+ (columnDefType === 'group' &&
1234
+ column.getLeafColumns().some((col) => col.getIsVisible()));
1235
+ const handleToggleColumnHidden = (column) => {
1236
+ if (columnDefType === 'group') {
1237
+ column?.columns?.forEach?.((childColumn) => {
1238
+ childColumn.toggleVisibility(!switchChecked);
1239
+ });
1240
+ }
1241
+ else {
1242
+ column.toggleVisibility();
1243
+ }
1244
+ };
1245
+ const menuItemRef = useRef(null);
1246
+ const [isDragging, setIsDragging] = useState(false);
1247
+ const handleDragStart = (e) => {
1248
+ setIsDragging(true);
1249
+ e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
1250
+ };
1251
+ const handleDragEnd = (_e) => {
1252
+ setIsDragging(false);
1253
+ setHoveredColumn(null);
1254
+ if (hoveredColumn) {
1255
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
1256
+ }
1257
+ };
1258
+ const handleDragEnter = (_e) => {
1259
+ if (!isDragging && columnDef.enableColumnOrdering !== false) {
1260
+ setHoveredColumn(column);
1261
+ }
1262
+ };
1263
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
1264
+ return null;
1265
+ }
1266
+ return (jsxs(Fragment, { children: [jsx(Menu.Item, { className: classes$s.root, component: "span", onDragEnter: handleDragEnter, ref: menuItemRef, style: {
1267
+ '--_column-depth': `${(column.depth + 0.5) * 2}rem`,
1268
+ '--_hover-color': getPrimaryColor(theme),
1269
+ }, ...dataVariable('dragging', isDragging), ...dataVariable('order-hovered', hoveredColumn?.id === column.id), children: jsxs(Box, { className: classes$s.menu, children: [columnDefType !== 'group' &&
1270
+ enableColumnOrdering &&
1271
+ !allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
1272
+ (columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { className: classes$s.grab }))), enableColumnPinning &&
1273
+ (column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { className: classes$s.pin }))), enableHiding ? (jsx(Tooltip, { label: localization.toggleVisibility, openDelay: 1000, withinPortal: true, children: jsx(Switch, { checked: switchChecked, className: classes$s.switch, disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) }) })) : (jsx(Text, { className: classes$s.header, children: columnDef.header }))] }) }), column.columns?.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
1274
+ };
1275
+
1276
+ var classes$r = {"root":"MRT_ShowHideColumnsMenu-module_root__2UWak","content":"MRT_ShowHideColumnsMenu-module_content__ehkWQ"};
1277
+
1278
+ const MRT_ShowHideColumnsMenu = ({ table, }) => {
1279
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getStartLeafColumns, getEndLeafColumns, state, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, } = table;
1280
+ const { columnOrder, columnPinning } = state;
1281
+ const handleToggleAllColumns = (value) => {
1282
+ getAllLeafColumns()
1283
+ .filter((col) => col.columnDef.enableHiding !== false)
1284
+ .forEach((col) => col.toggleVisibility(value));
1285
+ };
1286
+ const allColumns = useMemo(() => {
1287
+ const columns = getAllColumns();
1288
+ if (columnOrder.length > 0 &&
1289
+ !columns.some((col) => col.columnDef.columnDefType === 'group')) {
1290
+ return [
1291
+ ...getStartLeafColumns(),
1292
+ ...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => col?.id === colId)),
1293
+ ...getEndLeafColumns(),
1294
+ ].filter(Boolean);
1295
+ }
1296
+ return columns;
1297
+ }, [
1298
+ columnOrder,
1299
+ columnPinning,
1300
+ getAllColumns(),
1301
+ getCenterLeafColumns(),
1302
+ getStartLeafColumns(),
1303
+ getEndLeafColumns(),
1304
+ ]);
1305
+ const [hoveredColumn, setHoveredColumn] = useState(null);
1306
+ return (jsxs(Menu.Dropdown, { className: clsx('mrt-show-hide-columns-menu', classes$r.root), children: [jsxs(Flex, { className: classes$r.content, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), variant: "subtle", children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds({
1307
+ ...table.options,
1308
+ state,
1309
+ }, true)), variant: "subtle", children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), variant: "subtle", children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), variant: "subtle", children: localization.showAll }))] }), jsx(Menu.Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] }));
1310
+ };
1311
+
1312
+ const MRT_ShowHideColumnsButton = ({ table, title, ...rest }) => {
1313
+ const { icons: { IconColumns }, localization: { showHideColumns }, } = table.options;
1314
+ return (jsxs(Menu, { closeOnItemClick: false, withinPortal: true, children: [jsx(Tooltip, { label: title ?? showHideColumns, withinPortal: true, children: jsx(Menu.Target, { children: jsx(ActionIcon, { "aria-label": title ?? showHideColumns, color: "gray", size: "lg", variant: "subtle", ...rest, children: jsx(IconColumns, {}) }) }) }), jsx(MRT_ShowHideColumnsMenu, { table: table })] }));
1315
+ };
1316
+
1317
+ const next = {
1318
+ md: 'xs',
1319
+ xl: 'md',
1320
+ xs: 'xl',
1321
+ };
1322
+ const MRT_ToggleDensePaddingButton = ({ table: { state, options: { icons: { IconBaselineDensityLarge, IconBaselineDensityMedium, IconBaselineDensitySmall, }, localization: { toggleDensity }, }, setDensity, }, title, ...rest }) => {
1323
+ const { density } = state;
1324
+ return (jsx(Tooltip, { label: title ?? toggleDensity, withinPortal: true, children: jsx(ActionIcon, { "aria-label": title ?? toggleDensity, color: "gray", onClick: () => setDensity((current) => next[current]), size: "lg", variant: "subtle", ...rest, children: density === 'xs' ? (jsx(IconBaselineDensitySmall, {})) : density === 'md' ? (jsx(IconBaselineDensityMedium, {})) : (jsx(IconBaselineDensityLarge, {})) }) }));
1325
+ };
1326
+
1327
+ const MRT_ToggleFiltersButton = ({ table: { state, options: { icons: { IconFilter, IconFilterOff }, localization: { showHideFilters }, }, setShowColumnFilters, }, title, ...rest }) => {
1328
+ const { showColumnFilters } = state;
1329
+ return (jsx(Tooltip, { label: title ?? showHideFilters, withinPortal: true, children: jsx(ActionIcon, { "aria-label": title ?? showHideFilters, color: "gray", onClick: () => setShowColumnFilters((current) => !current), size: "lg", variant: "subtle", ...rest, children: showColumnFilters ? jsx(IconFilterOff, {}) : jsx(IconFilter, {}) }) }));
1330
+ };
1331
+
1332
+ const MRT_ToggleFullScreenButton = ({ table: { state, options: { icons: { IconMaximize, IconMinimize }, localization: { toggleFullScreen }, }, setIsFullScreen, }, title, ...rest }) => {
1333
+ const { isFullScreen } = state;
1334
+ const [tooltipOpened, setTooltipOpened] = useState(false);
1335
+ const handleToggleFullScreen = () => {
1336
+ setTooltipOpened(false);
1337
+ setIsFullScreen((current) => !current);
1338
+ };
1339
+ return (jsx(Tooltip, { label: title ?? toggleFullScreen, opened: tooltipOpened, withinPortal: true, children: jsx(ActionIcon, { "aria-label": title ?? toggleFullScreen, color: "gray", onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "lg", variant: "subtle", ...rest, children: isFullScreen ? jsx(IconMinimize, {}) : jsx(IconMaximize, {}) }) }));
1340
+ };
1341
+
1342
+ const MRT_ToggleGlobalFilterButton = ({ table: { state, options: { icons: { IconSearch, IconSearchOff }, localization: { showHideSearch }, }, refs: { searchInputRef }, setShowGlobalFilter, }, title, ...rest }) => {
1343
+ const { globalFilter, showGlobalFilter } = state;
1344
+ const handleToggleSearch = () => {
1345
+ setShowGlobalFilter(!showGlobalFilter);
1346
+ setTimeout(() => searchInputRef.current?.focus(), 100);
1347
+ };
1348
+ return (jsx(Tooltip, { label: title ?? showHideSearch, withinPortal: true, children: jsx(ActionIcon, { "aria-label": title ?? showHideSearch, color: "gray", disabled: !!globalFilter, onClick: handleToggleSearch, size: "lg", variant: "subtle", ...rest, children: showGlobalFilter ? jsx(IconSearchOff, {}) : jsx(IconSearch, {}) }) }));
1349
+ };
1350
+
1351
+ const MRT_RowActionMenu = ({ handleEdit, row, table, ...rest }) => {
1352
+ const { options: { editDisplayMode, enableEditing, icons: { IconDots, IconEdit }, localization, positionActionsColumn, renderRowActionMenuItems, }, } = table;
1353
+ return (jsxs(Menu, { closeOnItemClick: true, position: positionActionsColumn === 'first'
1354
+ ? 'bottom-start'
1355
+ : positionActionsColumn === 'last'
1356
+ ? 'bottom-end'
1357
+ : undefined, withinPortal: true, children: [jsx(Tooltip, { label: localization.rowActions, openDelay: 1000, withinPortal: true, children: jsx(Menu.Target, { children: jsx(ActionIcon, { "aria-label": localization.rowActions, color: "gray", onClick: (event) => event.stopPropagation(), size: "sm", variant: "subtle", ...rest, children: jsx(IconDots, {}) }) }) }), jsxs(Menu.Dropdown, { onClick: (event) => event.stopPropagation(), children: [enableEditing && editDisplayMode !== 'table' && (jsx(Menu.Item, { leftSection: jsx(IconEdit, {}), onClick: handleEdit, children: localization.edit })), renderRowActionMenuItems?.({
1358
+ row,
1359
+ table,
1360
+ })] })] }));
1361
+ };
1362
+
1363
+ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
1364
+ const { state, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { IconEdit }, localization: { edit }, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1365
+ const { creatingRow, editingRow } = state;
1366
+ const isCreating = creatingRow?.id === row.id;
1367
+ const isEditing = editingRow?.id === row.id;
1368
+ const handleStartEditMode = (event) => {
1369
+ event.stopPropagation();
1370
+ setEditingRow(row);
1371
+ };
1372
+ const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
1373
+ (isEditing && editDisplayMode === 'row');
1374
+ return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1375
+ parseFromValuesOrFunc(enableEditing, row) ? (jsx(Tooltip, { label: edit, openDelay: 1000, position: "right", withinPortal: true, children: jsx(ActionIcon, { "aria-label": edit, color: "gray", disabled: !!editingRow && editingRow.id !== row.id, onClick: handleStartEditMode, size: "md", variant: "subtle", children: jsx(IconEdit, {}) }) })) : renderRowActionMenuItems ? (jsx(MRT_RowActionMenu, { handleEdit: handleStartEditMode, row: row, table: table })) : null }));
1376
+ };
1377
+
1378
+ var classes$q = {"root":"MRT_TableFooterCell-module_root__d8Scs","grid":"MRT_TableFooterCell-module_grid__H9jLk","group":"MRT_TableFooterCell-module_group__l3-p-"};
1379
+
1380
+ const MRT_TableFooterCell = ({ footer, renderedColumnIndex, table, ...rest }) => {
1381
+ const direction = useDirection();
1382
+ const { options: { enableColumnPinning, layoutMode, mantineTableFooterCellProps }, } = table;
1383
+ const { column } = footer;
1384
+ const { columnDef } = column;
1385
+ const { columnDefType } = columnDef;
1386
+ const isColumnPinned = enableColumnPinning &&
1387
+ columnDef.columnDefType !== 'group' &&
1388
+ column.getIsPinned();
1389
+ const args = { column, table };
1390
+ const tableCellProps = {
1391
+ ...parseFromValuesOrFunc(mantineTableFooterCellProps, args),
1392
+ ...parseFromValuesOrFunc(columnDef.mantineTableFooterCellProps, args),
1393
+ ...rest,
1394
+ };
1395
+ const widthStyles = {
1396
+ minWidth: `max(calc(var(--header-${parseCSSVarId(footer?.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
1397
+ width: `calc(var(--header-${parseCSSVarId(footer.id)}-size) * 1px)`,
1398
+ };
1399
+ if (layoutMode === 'grid') {
1400
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
1401
+ ? 0
1402
+ : `var(--header-${parseCSSVarId(footer.id)}-size)`} 0 auto`;
1403
+ }
1404
+ else if (layoutMode === 'grid-no-grow') {
1405
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
1406
+ }
1407
+ return (jsx(TableTh, { colSpan: footer.colSpan, "data-column-pinned": isColumnPinned || undefined, "data-first-end-pinned": (isColumnPinned === 'end' && column.getIsFirstColumn(isColumnPinned)) ||
1408
+ undefined, "data-index": renderedColumnIndex, "data-last-start-pinned": (isColumnPinned === 'start' &&
1409
+ column.getIsLastColumn(isColumnPinned)) ||
1410
+ undefined, ...tableCellProps, __vars: {
1411
+ '--mrt-cell-align': tableCellProps.align ??
1412
+ (columnDefType === 'group'
1413
+ ? 'center'
1414
+ : direction.dir === 'rtl'
1415
+ ? 'right'
1416
+ : 'left'),
1417
+ '--mrt-table-cell-start': isColumnPinned === 'start'
1418
+ ? `${column.getStart(isColumnPinned)}`
1419
+ : undefined,
1420
+ '--mrt-table-cell-end': isColumnPinned === 'end'
1421
+ ? `${column.getAfter(isColumnPinned)}`
1422
+ : undefined,
1423
+ ...tableCellProps?.__vars,
1424
+ }, className: clsx(classes$q.root, layoutMode?.startsWith('grid') && classes$q.grid, columnDefType === 'group' && classes$q.group, tableCellProps?.className), style: (theme) => ({
1425
+ ...widthStyles,
1426
+ ...parseFromValuesOrFunc(tableCellProps.style, theme),
1427
+ }), children: tableCellProps.children ??
1428
+ (footer.isPlaceholder
1429
+ ? null
1430
+ : (parseFromValuesOrFunc(columnDef.Footer, {
1431
+ column,
1432
+ footer,
1433
+ table,
1434
+ }) ??
1435
+ columnDef.footer ??
1436
+ null)) }));
1437
+ };
1438
+
1439
+ var classes$p = {"root":"MRT_TableFooterRow-module_root__EuoPr","layout-mode-grid":"MRT_TableFooterRow-module_layout-mode-grid__dUEMF"};
1440
+
1441
+ const MRT_TableFooterRow = ({ columnVirtualizer, footerGroup, table, ...rest }) => {
1442
+ const { options: { layoutMode, mantineTableFooterRowProps }, } = table;
1443
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
1444
+ // if no content in row, skip row
1445
+ if (!footerGroup.headers?.some((header) => (typeof header.column.columnDef.footer === 'string' &&
1446
+ !!header.column.columnDef.footer) ||
1447
+ header.column.columnDef.Footer)) {
1448
+ return null;
1449
+ }
1450
+ const tableRowProps = {
1451
+ ...parseFromValuesOrFunc(mantineTableFooterRowProps, {
1452
+ footerGroup,
1453
+ table,
1454
+ }),
1455
+ ...rest,
1456
+ };
1457
+ return (jsxs(TableTr, { className: clsx(classes$p.root, layoutMode?.startsWith('grid') && classes$p['layout-mode-grid']), ...tableRowProps, children: [virtualPaddingLeft ? (jsx(Box, { component: "th", display: "flex", w: virtualPaddingLeft })) : null, (virtualColumns ?? footerGroup.headers).map((footerOrVirtualFooter, renderedColumnIndex) => {
1458
+ let footer = footerOrVirtualFooter;
1459
+ if (columnVirtualizer) {
1460
+ renderedColumnIndex = footerOrVirtualFooter
1461
+ .index;
1462
+ footer = footerGroup.headers[renderedColumnIndex];
1463
+ }
1464
+ return (jsx(MRT_TableFooterCell, { footer: footer, renderedColumnIndex: renderedColumnIndex, table: table }, footer.id));
1465
+ }), virtualPaddingRight ? (jsx(Box, { component: "th", display: "flex", w: virtualPaddingRight })) : null] }));
1466
+ };
1467
+
1468
+ var classes$o = {"root":"MRT_TableFooter-module_root__-JXpw","grid":"MRT_TableFooter-module_grid__J3Ga-","sticky":"MRT_TableFooter-module_sticky__GcoK6"};
1469
+
1470
+ const MRT_TableFooter = ({ columnVirtualizer, table, ...rest }) => {
1471
+ const { getFooterGroups, state, options: { enableStickyFooter, layoutMode, mantineTableFooterProps }, refs: { tableFooterRef }, } = table;
1472
+ const { isFullScreen } = state;
1473
+ const tableFooterProps = {
1474
+ ...parseFromValuesOrFunc(mantineTableFooterProps, {
1475
+ table,
1476
+ }),
1477
+ ...rest,
1478
+ };
1479
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
1480
+ return (jsx(TableTfoot, { ...tableFooterProps, className: clsx(classes$o.root, tableFooterProps?.className, stickFooter && classes$o.sticky, layoutMode?.startsWith('grid') && classes$o.grid), ref: (ref) => {
1481
+ tableFooterRef.current = ref;
1482
+ if (tableFooterProps?.ref) {
1483
+ // @ts-ignore
1484
+ tableFooterProps.ref.current = ref;
1485
+ }
1486
+ }, children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) }));
1487
+ };
1488
+
1489
+ const MRT_SelectCheckbox = ({ renderedRowIndex = 0, row, table, ...rest }) => {
1490
+ const { state, options: { enableMultiRowSelection, localization, mantineSelectAllCheckboxProps, mantineSelectCheckboxProps, selectAllMode, selectDisplayMode, }, } = table;
1491
+ const { density, isLoading } = state;
1492
+ const selectAll = !row;
1493
+ const allRowsSelected = selectAll
1494
+ ? selectAllMode === 'page'
1495
+ ? table.getIsAllPageRowsSelected()
1496
+ : table.getIsAllRowsSelected()
1497
+ : undefined;
1498
+ const isChecked = selectAll
1499
+ ? allRowsSelected
1500
+ : getIsRowSelected({ row, table });
1501
+ const checkboxProps = {
1502
+ ...(selectAll
1503
+ ? parseFromValuesOrFunc(mantineSelectAllCheckboxProps, { table })
1504
+ : parseFromValuesOrFunc(mantineSelectCheckboxProps, {
1505
+ row,
1506
+ table,
1507
+ })),
1508
+ ...rest,
1509
+ };
1510
+ const onSelectionChange = row
1511
+ ? getMRT_RowSelectionHandler({
1512
+ renderedRowIndex,
1513
+ row,
1514
+ table,
1515
+ })
1516
+ : undefined;
1517
+ const onSelectAllChange = getMRT_SelectAllHandler({ table });
1518
+ const commonProps = {
1519
+ 'aria-label': selectAll
1520
+ ? localization.toggleSelectAll
1521
+ : localization.toggleSelectRow,
1522
+ checked: isChecked,
1523
+ disabled: isLoading || (row && !row.getCanSelect()) || row?.id === 'mrt-row-create',
1524
+ onChange: (event) => {
1525
+ event.stopPropagation();
1526
+ if (selectAll) {
1527
+ onSelectAllChange(event);
1528
+ }
1529
+ else {
1530
+ onSelectionChange(event);
1531
+ }
1532
+ },
1533
+ size: density === 'xs' ? 'sm' : 'md',
1534
+ ...checkboxProps,
1535
+ onClick: (e) => {
1536
+ e.stopPropagation();
1537
+ checkboxProps?.onClick?.(e);
1538
+ },
1539
+ title: undefined,
1540
+ };
1541
+ return (jsx(Tooltip, { label: checkboxProps?.title ??
1542
+ (selectAll
1543
+ ? localization.toggleSelectAll
1544
+ : localization.toggleSelectRow), openDelay: 1000, withinPortal: true, children: jsx("span", { children: selectDisplayMode === 'switch' ? (jsx(Switch, { ...commonProps })) : selectDisplayMode === 'radio' ||
1545
+ enableMultiRowSelection === false ? (jsx(Radio, { ...commonProps })) : (jsx(Checkbox, { indeterminate: !isChecked && selectAll
1546
+ ? table.getIsSomeRowsSelected()
1547
+ : row?.getIsSomeSelected() && row.getCanSelectSubRows(), ...commonProps })) }) }));
1548
+ };
1549
+
1550
+ var classes$n = {"alert":"MRT_ToolbarAlertBanner-module_alert__PAhUK","alert-stacked":"MRT_ToolbarAlertBanner-module_alert-stacked__HR7Nq","alert-bottom":"MRT_ToolbarAlertBanner-module_alert-bottom__u9L-S","alert-badge":"MRT_ToolbarAlertBanner-module_alert-badge__GwDmX","toolbar-alert":"MRT_ToolbarAlertBanner-module_toolbar-alert__3sJGU","head-overlay":"MRT_ToolbarAlertBanner-module_head-overlay__Hw7jK"};
1551
+
1552
+ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, ...rest }) => {
1553
+ const { getFilteredSelectedRowModel, getPrePaginatedRowModel, state, options: { enableRowSelection, enableSelectAll, icons: { IconX }, localization, mantineToolbarAlertBannerBadgeProps, mantineToolbarAlertBannerProps, manualPagination, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, } = table;
1554
+ const { density, grouping, rowSelection, showAlertBanner } = state;
1555
+ const alertProps = {
1556
+ ...parseFromValuesOrFunc(mantineToolbarAlertBannerProps, {
1557
+ table,
1558
+ }),
1559
+ ...rest,
1560
+ };
1561
+ const badgeProps = parseFromValuesOrFunc(mantineToolbarAlertBannerBadgeProps, { table });
1562
+ const totalRowCount = rowCount ?? getPrePaginatedRowModel().flatRows.length;
1563
+ const selectedRowCount = useMemo(() => manualPagination
1564
+ ? Object.values(rowSelection).filter(Boolean).length
1565
+ : getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
1566
+ const selectedAlert = selectedRowCount ? (jsxs(Flex, { align: "center", gap: "sm", children: [localization.selectedCountOfRowCountRowsSelected
1567
+ ?.replace('{selectedCount}', selectedRowCount.toString())
1568
+ ?.replace('{rowCount}', totalRowCount.toString()), jsx(Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "compact-xs", variant: "subtle", children: localization.clearSelection })] })) : null;
1569
+ const groupedAlert = grouping.length > 0 ? (jsxs(Flex, { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsxs(Badge, { className: classes$n['alert-badge'], rightSection: jsx(ActionIcon, { color: "white", onClick: () => table.getColumn(columnId).toggleGrouping(), size: "xs", variant: "subtle", children: jsx(IconX, { style: { transform: 'scale(0.8)' } }) }), variant: "filled", ...badgeProps, children: [table.getColumn(columnId).columnDef.header, ' '] })] }, `${index}-${columnId}`)))] })) : null;
1570
+ return (jsx(Collapse, { expanded: showAlertBanner || !!selectedAlert || !!groupedAlert, transitionDuration: stackAlertBanner ? 200 : 0, children: jsx(Alert, { color: "blue", icon: false, ...alertProps, className: clsx(classes$n.alert, stackAlertBanner &&
1571
+ !positionToolbarAlertBanner &&
1572
+ classes$n['alert-stacked'], !stackAlertBanner &&
1573
+ positionToolbarAlertBanner === 'bottom' &&
1574
+ classes$n['alert-bottom'], alertProps?.className), children: renderToolbarAlertBannerContent?.({
1575
+ groupedAlert,
1576
+ selectedAlert,
1577
+ table,
1578
+ }) ?? (jsxs(Flex, { className: clsx(classes$n['toolbar-alert'], positionToolbarAlertBanner === 'head-overlay' &&
1579
+ classes$n['head-overlay'], density), children: [enableRowSelection &&
1580
+ enableSelectAll &&
1581
+ positionToolbarAlertBanner === 'head-overlay' && (jsx(MRT_SelectCheckbox, { table: table })), jsxs(Stack, { children: [alertProps?.children, selectedAlert, groupedAlert] })] })) }) }));
1582
+ };
1583
+
1584
+ var classes$m = {"left":"MRT_ColumnActionMenu-module_left__cfNmY","right":"MRT_ColumnActionMenu-module_right__-nK56"};
1585
+
1586
+ const MRT_ColumnActionMenu = ({ header, table, ...rest }) => {
1587
+ const { state, options: { columnFilterDisplayMode, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { IconArrowAutofitContent, IconBoxMultiple, IconClearAll, IconColumns, IconDotsVertical, IconEyeOff, IconFilter, IconFilterOff, IconPinned, IconPinnedOff, IconSortAscending, IconSortDescending, }, localization, mantineColumnActionsButtonProps, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnResizing, setShowColumnFilters, toggleAllColumnsVisible, } = table;
1588
+ const { column } = header;
1589
+ const { columnDef } = column;
1590
+ const { columnSizing, columnVisibility } = state;
1591
+ const arg = { column, table };
1592
+ const actionIconProps = {
1593
+ ...parseFromValuesOrFunc(mantineColumnActionsButtonProps, arg),
1594
+ ...parseFromValuesOrFunc(columnDef.mantineColumnActionsButtonProps, arg),
1595
+ };
1596
+ const handleClearSort = () => {
1597
+ column.clearSorting();
1598
+ };
1599
+ const handleSortAsc = () => {
1600
+ column.toggleSorting(false);
1601
+ };
1602
+ const handleSortDesc = () => {
1603
+ column.toggleSorting(true);
1604
+ };
1605
+ const handleResetColumnSize = () => {
1606
+ setColumnResizing((old) => ({ ...old, isResizingColumn: false }));
1607
+ column.resetSize();
1608
+ };
1609
+ const handleHideColumn = () => {
1610
+ column.toggleVisibility(false);
1611
+ };
1612
+ const handlePinColumn = (pinDirection) => {
1613
+ column.pin(pinDirection);
1614
+ };
1615
+ const handleGroupByColumn = () => {
1616
+ column.toggleGrouping();
1617
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
1618
+ };
1619
+ const handleClearFilter = () => {
1620
+ column.setFilterValue('');
1621
+ };
1622
+ const handleFilterByColumn = () => {
1623
+ setShowColumnFilters(true);
1624
+ setTimeout(() => filterInputRefs.current[`${column.id}-0`]?.focus(), 100);
1625
+ };
1626
+ const handleShowAllColumns = () => {
1627
+ toggleAllColumnsVisible(true);
1628
+ };
1629
+ const internalColumnMenuItems = (jsxs(Fragment, { children: [enableSorting && column.getCanSort() && (jsxs(Fragment, { children: [enableSortingRemoval !== false && (jsx(Menu.Item, { disabled: !column.getIsSorted(), leftSection: jsx(IconClearAll, {}), onClick: handleClearSort, children: localization.clearSort })), jsx(Menu.Item, { disabled: column.getIsSorted() === 'asc', leftSection: jsx(IconSortAscending, {}), onClick: handleSortAsc, children: localization.sortByColumnAsc?.replace('{column}', String(columnDef.header)) }), jsx(Menu.Item, { disabled: column.getIsSorted() === 'desc', leftSection: jsx(IconSortDescending, {}), onClick: handleSortDesc, children: localization.sortByColumnDesc?.replace('{column}', String(columnDef.header)) }), (enableColumnFilters || enableGrouping || enableHiding) && (jsx(Menu.Divider, {}, 3))] })), enableColumnFilters &&
1630
+ columnFilterDisplayMode !== 'popover' &&
1631
+ column.getCanFilter() && (jsxs(Fragment, { children: [jsx(Menu.Item, { disabled: !column.getFilterValue(), leftSection: jsx(IconFilterOff, {}), onClick: handleClearFilter, children: localization.clearFilter }), jsx(Menu.Item, { leftSection: jsx(IconFilter, {}), onClick: handleFilterByColumn, children: localization.filterByColumn?.replace('{column}', String(columnDef.header)) }), (enableGrouping || enableHiding) && jsx(Menu.Divider, {}, 2)] })), enableGrouping && column.getCanGroup() && (jsxs(Fragment, { children: [jsx(Menu.Item, { leftSection: jsx(IconBoxMultiple, {}), onClick: handleGroupByColumn, children: localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']?.replace('{column}', String(columnDef.header)) }), enableColumnPinning && jsx(Menu.Divider, {})] })), enableColumnPinning && column.getCanPin() && (jsxs(Fragment, { children: [jsx(Menu.Item, { disabled: column.getIsPinned() === 'start' || !column.getCanPin(), leftSection: jsx(IconPinned, { className: classes$m.left }), onClick: () => handlePinColumn('start'), children: localization.pinToLeft }), jsx(Menu.Item, { disabled: column.getIsPinned() === 'end' || !column.getCanPin(), leftSection: jsx(IconPinned, { className: classes$m.right }), onClick: () => handlePinColumn('end'), children: localization.pinToRight }), jsx(Menu.Item, { disabled: !column.getIsPinned(), leftSection: jsx(IconPinnedOff, {}), onClick: () => handlePinColumn(false), children: localization.unpin }), enableHiding && jsx(Menu.Divider, {})] })), enableColumnResizing && column.getCanResize() && (jsx(Menu.Item, { disabled: !columnSizing[column.id], leftSection: jsx(IconArrowAutofitContent, {}), onClick: handleResetColumnSize, children: localization.resetColumnSize }, 0)), enableHiding && (jsxs(Fragment, { children: [jsx(Menu.Item, { disabled: !column.getCanHide(), leftSection: jsx(IconEyeOff, {}), onClick: handleHideColumn, children: localization.hideColumn?.replace('{column}', String(columnDef.header)) }, 0), jsx(Menu.Item, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
1632
+ .length, leftSection: jsx(IconColumns, {}), onClick: handleShowAllColumns, children: localization.showAllColumns?.replace('{column}', String(columnDef.header)) }, 1)] }))] }));
1633
+ return (jsxs(Menu, { closeOnItemClick: true, position: "bottom-start", withinPortal: true, ...rest, children: [jsx(Tooltip, { label: actionIconProps?.title ?? localization.columnActions, openDelay: 1000, withinPortal: true, children: jsx(Menu.Target, { children: jsx(ActionIcon, { "aria-label": localization.columnActions, color: "gray", size: "sm", variant: "subtle", ...actionIconProps, children: jsx(IconDotsVertical, { size: "100%" }) }) }) }), jsx(Menu.Dropdown, { children: columnDef.renderColumnActionsMenuItems?.({
1634
+ column,
1635
+ internalColumnMenuItems,
1636
+ table,
1637
+ }) ??
1638
+ renderColumnActionsMenuItems?.({
1639
+ column,
1640
+ internalColumnMenuItems,
1641
+ table,
1642
+ }) ??
1643
+ internalColumnMenuItems })] }));
1644
+ };
1645
+
1646
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
1647
+ const itemRank = rankItem(row.getValue(columnId), filterValue, {
1648
+ threshold: rankings.MATCHES,
1649
+ });
1650
+ addMeta(itemRank);
1651
+ return itemRank.passed;
1652
+ };
1653
+ fuzzy.autoRemove = (val) => !val;
1654
+ const contains = (row, id, filterValue) => row
1655
+ .getValue(id)
1656
+ ?.toString()
1657
+ .toLowerCase()
1658
+ .trim()
1659
+ .includes(filterValue.toString().toLowerCase().trim());
1660
+ contains.autoRemove = (val) => !val;
1661
+ const startsWith = (row, id, filterValue) => row
1662
+ .getValue(id)
1663
+ ?.toString()
1664
+ .toLowerCase()
1665
+ .trim()
1666
+ .startsWith(filterValue.toString().toLowerCase().trim());
1667
+ startsWith.autoRemove = (val) => !val;
1668
+ const endsWith = (row, id, filterValue) => row
1669
+ .getValue(id)
1670
+ ?.toString()
1671
+ .toLowerCase()
1672
+ .trim()
1673
+ .endsWith(filterValue.toString().toLowerCase().trim());
1674
+ endsWith.autoRemove = (val) => !val;
1675
+ const equals = (row, id, filterValue) => row.getValue(id)?.toString().toLowerCase().trim() ===
1676
+ filterValue?.toString().toLowerCase().trim();
1677
+ equals.autoRemove = (val) => !val;
1678
+ const notEquals = (row, id, filterValue) => row.getValue(id)?.toString().toLowerCase().trim() !==
1679
+ filterValue.toString().toLowerCase().trim();
1680
+ notEquals.autoRemove = (val) => !val;
1681
+ const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
1682
+ ? +row.getValue(id) > +filterValue
1683
+ : row.getValue(id)?.toString().toLowerCase().trim() >
1684
+ filterValue?.toString().toLowerCase().trim();
1685
+ greaterThan.autoRemove = (val) => !val;
1686
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
1687
+ greaterThanOrEqualTo.autoRemove = (val) => !val;
1688
+ const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
1689
+ ? +row.getValue(id) < +filterValue
1690
+ : row.getValue(id)?.toString().toLowerCase().trim() <
1691
+ filterValue?.toString().toLowerCase().trim();
1692
+ lessThan.autoRemove = (val) => !val;
1693
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
1694
+ lessThanOrEqualTo.autoRemove = (val) => !val;
1695
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
1696
+ greaterThan(row, id, filterValues[0])) &&
1697
+ ((!isNaN(+filterValues[0]) &&
1698
+ !isNaN(+filterValues[1]) &&
1699
+ +filterValues[0] > +filterValues[1]) ||
1700
+ ['', undefined].includes(filterValues[1]) ||
1701
+ lessThan(row, id, filterValues[1]));
1702
+ between.autoRemove = (val) => !val;
1703
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
1704
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
1705
+ ((!isNaN(+filterValues[0]) &&
1706
+ !isNaN(+filterValues[1]) &&
1707
+ +filterValues[0] > +filterValues[1]) ||
1708
+ ['', undefined].includes(filterValues[1]) ||
1709
+ lessThanOrEqualTo(row, id, filterValues[1]));
1710
+ betweenInclusive.autoRemove = (val) => !val;
1711
+ const empty = (row, id, _filterValue) => !row.getValue(id)?.toString().trim();
1712
+ empty.autoRemove = (val) => !val;
1713
+ const notEmpty = (row, id, _filterValue) => !!row.getValue(id)?.toString().trim();
1714
+ notEmpty.autoRemove = (val) => !val;
1715
+ const MRT_FilterFns = {
1716
+ ...filterFns,
1717
+ between,
1718
+ betweenInclusive,
1719
+ contains,
1720
+ empty,
1721
+ endsWith,
1722
+ equals,
1723
+ fuzzy,
1724
+ greaterThan,
1725
+ greaterThanOrEqualTo,
1726
+ lessThan,
1727
+ lessThanOrEqualTo,
1728
+ notEmpty,
1729
+ notEquals,
1730
+ startsWith,
1731
+ };
1732
+ function localizedFilterOption(localization, option) {
1733
+ if (!option) {
1734
+ return '';
1735
+ }
1736
+ const key = `filter${option[0].toUpperCase()}${option.slice(1)}`;
1737
+ return localization[key] ?? '';
1738
+ }
1739
+
1740
+ var classes$l = {"root":"MRT_FilterCheckBox-module_root__59h9r"};
1741
+
1742
+ const MRT_FilterCheckbox = ({ column, table, ...rest }) => {
1743
+ const { state, options: { localization, mantineFilterCheckboxProps }, } = table;
1744
+ const { density } = state;
1745
+ const { columnDef } = column;
1746
+ const arg = { column, table };
1747
+ const checkboxProps = {
1748
+ ...parseFromValuesOrFunc(mantineFilterCheckboxProps, arg),
1749
+ ...parseFromValuesOrFunc(columnDef.mantineFilterCheckboxProps, arg),
1750
+ ...rest,
1751
+ };
1752
+ const filterLabel = localization.filterByColumn?.replace('{column}', columnDef.header);
1753
+ const value = column.getFilterValue();
1754
+ return (jsx(Tooltip, { label: checkboxProps?.title ?? filterLabel, openDelay: 1000, withinPortal: true, children: jsx(Checkbox, { checked: value === 'true', className: clsx('mrt-filter-checkbox', classes$l.root), indeterminate: value === undefined, label: checkboxProps.title ?? filterLabel, size: density === 'xs' ? 'sm' : 'md', ...checkboxProps, onChange: (e) => {
1755
+ column.setFilterValue(column.getFilterValue() === undefined
1756
+ ? 'true'
1757
+ : column.getFilterValue() === 'true'
1758
+ ? 'false'
1759
+ : undefined);
1760
+ checkboxProps?.onChange?.(e);
1761
+ }, onClick: (e) => {
1762
+ e.stopPropagation();
1763
+ checkboxProps?.onClick?.(e);
1764
+ }, title: undefined }) }));
1765
+ };
1766
+
1767
+ var classes$k = {"root":"MRT_FilterRangeFields-module_root__KfCcg"};
1768
+
1769
+ var classes$j = {"root":"MRT_FilterTextInput-module_root__Ss8Ql","date-filter":"MRT_FilterTextInput-module_date-filter__jOBLB","range-filter":"MRT_FilterTextInput-module_range-filter__JQHAL","not-filter-chip":"MRT_FilterTextInput-module_not-filter-chip__u8b1y","filter-chip-badge":"MRT_FilterTextInput-module_filter-chip-badge__Sel2k"};
1770
+
1771
+ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
1772
+ const { options: { columnFilterDisplayMode, columnFilterModeOptions, icons: { IconX }, localization, mantineFilterAutocompleteProps, mantineFilterDateInputProps, mantineFilterMultiSelectProps = {
1773
+ clearable: true,
1774
+ }, mantineFilterSelectProps, mantineFilterTextInputProps, manualFiltering, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
1775
+ const { column } = header;
1776
+ const { columnDef } = column;
1777
+ const arg = { column, rangeFilterIndex, table };
1778
+ const textInputProps = {
1779
+ ...parseFromValuesOrFunc(mantineFilterTextInputProps, arg),
1780
+ ...parseFromValuesOrFunc(columnDef.mantineFilterTextInputProps, arg),
1781
+ ...rest,
1782
+ };
1783
+ const selectProps = {
1784
+ ...parseFromValuesOrFunc(mantineFilterSelectProps, arg),
1785
+ ...parseFromValuesOrFunc(columnDef.mantineFilterSelectProps, arg),
1786
+ };
1787
+ const multiSelectProps = {
1788
+ ...parseFromValuesOrFunc(mantineFilterMultiSelectProps, arg),
1789
+ ...parseFromValuesOrFunc(columnDef.mantineFilterMultiSelectProps, arg),
1790
+ };
1791
+ const dateInputProps = {
1792
+ ...parseFromValuesOrFunc(mantineFilterDateInputProps, arg),
1793
+ ...parseFromValuesOrFunc(columnDef.mantineFilterDateInputProps, arg),
1794
+ };
1795
+ const autoCompleteProps = {
1796
+ ...parseFromValuesOrFunc(mantineFilterAutocompleteProps, arg),
1797
+ ...parseFromValuesOrFunc(columnDef.mantineFilterAutocompleteProps, arg),
1798
+ };
1799
+ const isRangeFilter = columnDef.filterVariant === 'range' ||
1800
+ columnDef.filterVariant === 'date-range' ||
1801
+ rangeFilterIndex !== undefined;
1802
+ const isSelectFilter = columnDef.filterVariant === 'select';
1803
+ const isMultiSelectFilter = columnDef.filterVariant === 'multi-select';
1804
+ const isDateFilter = columnDef.filterVariant === 'date' ||
1805
+ columnDef.filterVariant === 'date-range';
1806
+ const isAutoCompleteFilter = columnDef.filterVariant === 'autocomplete';
1807
+ const allowedColumnFilterOptions = columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
1808
+ const currentFilterOption = columnDef._filterFn;
1809
+ const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
1810
+ ? localizedFilterOption(localization, currentFilterOption)
1811
+ : '';
1812
+ const filterPlaceholder = !isRangeFilter
1813
+ ? (textInputProps?.placeholder ??
1814
+ localization.filterByColumn?.replace('{column}', String(columnDef.header)))
1815
+ : rangeFilterIndex === 0
1816
+ ? localization.min
1817
+ : rangeFilterIndex === 1
1818
+ ? localization.max
1819
+ : '';
1820
+ const facetedUniqueValues = column.getFacetedUniqueValues();
1821
+ const filterSelectOptions = useMemo(() => (autoCompleteProps?.data ??
1822
+ selectProps?.data ??
1823
+ multiSelectProps?.data ??
1824
+ ((isAutoCompleteFilter || isSelectFilter || isMultiSelectFilter) &&
1825
+ facetedUniqueValues
1826
+ ? Array.from(facetedUniqueValues.keys())
1827
+ .filter((key) => key !== null)
1828
+ .sort((a, b) => a.localeCompare(b))
1829
+ : []))
1830
+ // @ts-ignore
1831
+ .filter((o) => o !== undefined && o !== null), [
1832
+ autoCompleteProps?.data,
1833
+ facetedUniqueValues,
1834
+ isAutoCompleteFilter,
1835
+ isMultiSelectFilter,
1836
+ isSelectFilter,
1837
+ multiSelectProps?.data,
1838
+ selectProps?.data,
1839
+ ]);
1840
+ const isMounted = useRef(false);
1841
+ const [filterValue, setFilterValue] = useState(() => isMultiSelectFilter
1842
+ ? column.getFilterValue() || []
1843
+ : isRangeFilter
1844
+ ? column.getFilterValue()?.[rangeFilterIndex] || ''
1845
+ : (column.getFilterValue() ?? ''));
1846
+ const [debouncedFilterValue] = useDebouncedValue(filterValue, manualFiltering ? 400 : 200);
1847
+ // send debounced filterValue to table instance
1848
+ useEffect(() => {
1849
+ if (!isMounted.current)
1850
+ return;
1851
+ if (isRangeFilter) {
1852
+ column.setFilterValue((old) => {
1853
+ const newFilterValues = Array.isArray(old) ? old : ['', ''];
1854
+ newFilterValues[rangeFilterIndex] =
1855
+ debouncedFilterValue;
1856
+ return newFilterValues;
1857
+ });
1858
+ }
1859
+ else {
1860
+ column.setFilterValue(debouncedFilterValue ?? undefined);
1861
+ }
1862
+ }, [debouncedFilterValue]);
1863
+ // receive table filter value and set it to local state
1864
+ useEffect(() => {
1865
+ if (!isMounted.current) {
1866
+ isMounted.current = true;
1867
+ return;
1868
+ }
1869
+ const tableFilterValue = column.getFilterValue();
1870
+ if (tableFilterValue === undefined) {
1871
+ handleClear();
1872
+ }
1873
+ else if (isRangeFilter && rangeFilterIndex !== undefined) {
1874
+ setFilterValue((tableFilterValue ?? ['', ''])[rangeFilterIndex]);
1875
+ }
1876
+ else {
1877
+ setFilterValue(tableFilterValue ?? '');
1878
+ }
1879
+ }, [column.getFilterValue()]);
1880
+ const handleClear = () => {
1881
+ if (isMultiSelectFilter) {
1882
+ setFilterValue([]);
1883
+ column.setFilterValue([]);
1884
+ }
1885
+ else if (isRangeFilter) {
1886
+ setFilterValue('');
1887
+ column.setFilterValue((old) => {
1888
+ const newFilterValues = Array.isArray(old) ? old : ['', ''];
1889
+ newFilterValues[rangeFilterIndex] = undefined;
1890
+ return newFilterValues;
1891
+ });
1892
+ // This is from Mantine v6 but it also applies for v7
1893
+ // https://github.com/mantinedev/mantine/issues/4716#issuecomment-1702699688
1894
+ }
1895
+ else if (isSelectFilter) {
1896
+ setFilterValue(null);
1897
+ column.setFilterValue(null);
1898
+ }
1899
+ else {
1900
+ setFilterValue('');
1901
+ column.setFilterValue(undefined);
1902
+ }
1903
+ };
1904
+ const handleClearEmptyFilterChip = () => {
1905
+ if (isMultiSelectFilter) {
1906
+ setFilterValue([]);
1907
+ column.setFilterValue([]);
1908
+ }
1909
+ else {
1910
+ setFilterValue('');
1911
+ column.setFilterValue(undefined);
1912
+ }
1913
+ setColumnFilterFns((prev) => ({
1914
+ ...prev,
1915
+ [header.id]: allowedColumnFilterOptions?.[0] ?? 'fuzzy',
1916
+ }));
1917
+ };
1918
+ const { className, ...commonProps } = {
1919
+ 'aria-label': filterPlaceholder,
1920
+ className: clsx('mrt-filter-text-input', classes$j.root, isDateFilter
1921
+ ? classes$j['date-filter']
1922
+ : isRangeFilter
1923
+ ? classes$j['range-filter']
1924
+ : !filterChipLabel && classes$j['not-filter-chip']),
1925
+ disabled: !!filterChipLabel,
1926
+ onChange: setFilterValue,
1927
+ onClick: (event) => event.stopPropagation(),
1928
+ placeholder: filterPlaceholder,
1929
+ style: {
1930
+ ...(isMultiSelectFilter
1931
+ ? multiSelectProps?.style
1932
+ : isSelectFilter
1933
+ ? selectProps?.style
1934
+ : isDateFilter
1935
+ ? dateInputProps?.style
1936
+ : textInputProps?.style),
1937
+ },
1938
+ title: filterPlaceholder,
1939
+ value: isMultiSelectFilter && !Array.isArray(filterValue) ? [] : filterValue,
1940
+ variant: 'unstyled',
1941
+ };
1942
+ const ClearButton = filterValue ? (jsx(ActionIcon, { "aria-label": localization.clearFilter, color: "var(--mantine-color-gray-7)", onClick: handleClear, size: "sm", title: localization.clearFilter ?? '', variant: "transparent", children: jsx(IconX, {}) })) : null;
1943
+ if (columnDef.Filter) {
1944
+ return (jsx(Fragment, { children: columnDef.Filter?.({ column, header, rangeFilterIndex, table }) }));
1945
+ }
1946
+ if (filterChipLabel) {
1947
+ return (jsx(Box, { style: commonProps.style, children: jsx(Badge, { className: classes$j['filter-chip-badge'], onClick: handleClearEmptyFilterChip, rightSection: ClearButton, size: "lg", children: filterChipLabel }) }));
1948
+ }
1949
+ if (isMultiSelectFilter) {
1950
+ return (jsx(MultiSelect, { ...commonProps, searchable: true, ...multiSelectProps, className: clsx(className, multiSelectProps.className), data: filterSelectOptions, onChange: (value) => setFilterValue(value), ref: (node) => {
1951
+ if (node) {
1952
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
1953
+ node;
1954
+ if (multiSelectProps.ref) {
1955
+ multiSelectProps.ref.current = node;
1956
+ }
1957
+ }
1958
+ }, rightSection: filterValue?.toString()?.length && multiSelectProps?.clearable
1959
+ ? ClearButton
1960
+ : undefined, style: commonProps.style }));
1961
+ }
1962
+ if (isSelectFilter) {
1963
+ return (jsx(Select, { ...commonProps, clearable: true, searchable: true, ...selectProps, className: clsx(className, selectProps.className), clearButtonProps: {
1964
+ size: 'md',
1965
+ }, data: filterSelectOptions, ref: (node) => {
1966
+ if (node) {
1967
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
1968
+ node;
1969
+ if (selectProps.ref) {
1970
+ selectProps.ref.current = node;
1971
+ }
1972
+ }
1973
+ }, style: commonProps.style }));
1974
+ }
1975
+ if (isDateFilter) {
1976
+ return (jsx(DateInput, { ...commonProps, allowDeselect: true, clearable: true, popoverProps: { withinPortal: columnFilterDisplayMode !== 'popover' }, ...dateInputProps, className: clsx(className, dateInputProps.className), onChange: (event) => commonProps.onChange(event === null ? '' : event), ref: (node) => {
1977
+ if (node) {
1978
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
1979
+ node;
1980
+ if (dateInputProps.ref) {
1981
+ dateInputProps.ref.current = node;
1982
+ }
1983
+ }
1984
+ }, style: commonProps.style }));
1985
+ }
1986
+ if (isAutoCompleteFilter) {
1987
+ return (jsx(Autocomplete, { ...commonProps, onChange: (value) => setFilterValue(value), rightSection: filterValue?.toString()?.length ? ClearButton : undefined, ...autoCompleteProps, className: clsx(className, autoCompleteProps.className), data: filterSelectOptions, ref: (node) => {
1988
+ if (node) {
1989
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
1990
+ node;
1991
+ if (autoCompleteProps.ref) {
1992
+ autoCompleteProps.ref.current = node;
1993
+ }
1994
+ }
1995
+ }, style: commonProps.style }));
1996
+ }
1997
+ return (jsx(TextInput, { ...commonProps, onChange: (e) => setFilterValue(e.target.value), rightSection: filterValue?.toString()?.length ? ClearButton : undefined, ...textInputProps, className: clsx(className, textInputProps.className), mt: 0, ref: (node) => {
1998
+ if (node) {
1999
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
2000
+ node;
2001
+ if (textInputProps.ref && typeof textInputProps.ref === 'object') {
2002
+ textInputProps.ref.current = node;
2003
+ }
2004
+ }
2005
+ }, style: commonProps.style }));
2006
+ };
2007
+
2008
+ const MRT_FilterRangeFields = ({ header, table, ...rest }) => {
2009
+ return (jsxs(Box, { ...rest, className: clsx('mrt-filter-range-fields', classes$k.root, rest.className), children: [jsx(MRT_FilterTextInput, { header: header, rangeFilterIndex: 0, table: table }), jsx(MRT_FilterTextInput, { header: header, rangeFilterIndex: 1, table: table })] }));
2010
+ };
2011
+
2012
+ var classes$i = {"root":"MRT_FilterRangeSlider-module_root__uwYEk"};
2013
+
2014
+ const MRT_FilterRangeSlider = ({ header, table, ...rest }) => {
2015
+ const { options: { mantineFilterRangeSliderProps }, refs: { filterInputRefs }, } = table;
2016
+ const { column } = header;
2017
+ const { columnDef } = column;
2018
+ const arg = { column, table };
2019
+ const rangeSliderProps = {
2020
+ ...parseFromValuesOrFunc(mantineFilterRangeSliderProps, arg),
2021
+ ...parseFromValuesOrFunc(columnDef.mantineFilterRangeSliderProps, arg),
2022
+ ...rest,
2023
+ };
2024
+ let [min, max] = rangeSliderProps.min !== undefined && rangeSliderProps.max !== undefined
2025
+ ? [rangeSliderProps.min, rangeSliderProps.max]
2026
+ : (column.getFacetedMinMaxValues() ?? [0, 1]);
2027
+ // fix potential TanStack Table bugs where min or max is an array
2028
+ if (Array.isArray(min))
2029
+ min = min[0];
2030
+ if (Array.isArray(max))
2031
+ max = max[0];
2032
+ if (min === null)
2033
+ min = 0;
2034
+ if (max === null)
2035
+ max = 1;
2036
+ const [filterValues, setFilterValues] = useState([min, max]);
2037
+ const columnFilterValue = column.getFilterValue();
2038
+ const isMounted = useRef(false);
2039
+ useEffect(() => {
2040
+ if (isMounted.current) {
2041
+ if (columnFilterValue === undefined) {
2042
+ setFilterValues([min, max]);
2043
+ }
2044
+ else if (Array.isArray(columnFilterValue)) {
2045
+ setFilterValues(columnFilterValue);
2046
+ }
2047
+ }
2048
+ isMounted.current = true;
2049
+ }, [columnFilterValue, min, max]);
2050
+ return (jsx(RangeSlider, { className: clsx('mrt-filter-range-slider', classes$i.root), max: max, min: min, onChange: (values) => {
2051
+ setFilterValues(values);
2052
+ }, onChangeEnd: (values) => {
2053
+ if (Array.isArray(values)) {
2054
+ if (values[0] <= min && values[1] >= max) {
2055
+ // if the user has selected the entire range, remove the filter
2056
+ column.setFilterValue(undefined);
2057
+ }
2058
+ else {
2059
+ column.setFilterValue(values);
2060
+ }
2061
+ }
2062
+ }, value: filterValues, ...rangeSliderProps, ref: (node) => {
2063
+ if (node) {
2064
+ // @ts-ignore
2065
+ filterInputRefs.current[`${column.id}-0`] = node;
2066
+ // @ts-ignore
2067
+ if (rangeSliderProps?.ref) {
2068
+ // @ts-ignore
2069
+ rangeSliderProps.ref = node;
2070
+ }
2071
+ }
2072
+ } }));
2073
+ };
2074
+
2075
+ var classes$h = {"symbol":"MRT_FilterOptionMenu-module_symbol__a1Bsy"};
2076
+
2077
+ const mrtFilterOptions = (localization) => [
2078
+ {
2079
+ divider: false,
2080
+ label: localization.filterFuzzy,
2081
+ option: 'fuzzy',
2082
+ symbol: '≈',
2083
+ },
2084
+ {
2085
+ divider: false,
2086
+ label: localization.filterContains,
2087
+ option: 'contains',
2088
+ symbol: '*',
2089
+ },
2090
+ {
2091
+ divider: false,
2092
+ label: localization.filterStartsWith,
2093
+ option: 'startsWith',
2094
+ symbol: 'a',
2095
+ },
2096
+ {
2097
+ divider: true,
2098
+ label: localization.filterEndsWith,
2099
+ option: 'endsWith',
2100
+ symbol: 'z',
2101
+ },
2102
+ {
2103
+ divider: false,
2104
+ label: localization.filterEquals,
2105
+ option: 'equals',
2106
+ symbol: '=',
2107
+ },
2108
+ {
2109
+ divider: true,
2110
+ label: localization.filterNotEquals,
2111
+ option: 'notEquals',
2112
+ symbol: '≠',
2113
+ },
2114
+ {
2115
+ divider: false,
2116
+ label: localization.filterBetween,
2117
+ option: 'between',
2118
+ symbol: '⇿',
2119
+ },
2120
+ {
2121
+ divider: true,
2122
+ label: localization.filterBetweenInclusive,
2123
+ option: 'betweenInclusive',
2124
+ symbol: '⬌',
2125
+ },
2126
+ {
2127
+ divider: false,
2128
+ label: localization.filterGreaterThan,
2129
+ option: 'greaterThan',
2130
+ symbol: '>',
2131
+ },
2132
+ {
2133
+ divider: false,
2134
+ label: localization.filterGreaterThanOrEqualTo,
2135
+ option: 'greaterThanOrEqualTo',
2136
+ symbol: '≥',
2137
+ },
2138
+ {
2139
+ divider: false,
2140
+ label: localization.filterLessThan,
2141
+ option: 'lessThan',
2142
+ symbol: '<',
2143
+ },
2144
+ {
2145
+ divider: true,
2146
+ label: localization.filterLessThanOrEqualTo,
2147
+ option: 'lessThanOrEqualTo',
2148
+ symbol: '≤',
2149
+ },
2150
+ {
2151
+ divider: false,
2152
+ label: localization.filterEmpty,
2153
+ option: 'empty',
2154
+ symbol: '∅',
2155
+ },
2156
+ {
2157
+ divider: false,
2158
+ label: localization.filterNotEmpty,
2159
+ option: 'notEmpty',
2160
+ symbol: '!∅',
2161
+ },
2162
+ ];
2163
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2164
+ const emptyModes = ['empty', 'notEmpty'];
2165
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2166
+ const rangeVariants = ['range-slider', 'date-range', 'range'];
2167
+ const MRT_FilterOptionMenu = ({ header, onSelect, table, }) => {
2168
+ const { state, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2169
+ const { globalFilterFn } = state;
2170
+ const { column } = header ?? {};
2171
+ const { columnDef } = column ?? {};
2172
+ const currentFilterValue = column?.getFilterValue();
2173
+ let allowedColumnFilterOptions = columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
2174
+ if (rangeVariants.includes(columnDef?.filterVariant)) {
2175
+ allowedColumnFilterOptions = [
2176
+ ...rangeModes,
2177
+ ...(allowedColumnFilterOptions ?? []),
2178
+ ].filter((option) => rangeModes.includes(option));
2179
+ }
2180
+ const internalFilterOptions = useMemo(() => {
2181
+ const filterOptions = mrtFilterOptions(localization).filter((filterOption) => columnDef
2182
+ ? allowedColumnFilterOptions === undefined ||
2183
+ allowedColumnFilterOptions?.includes(filterOption.option)
2184
+ : (!globalFilterModeOptions ||
2185
+ globalFilterModeOptions.includes(filterOption.option)) &&
2186
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option));
2187
+ if (filterOptions[filterOptions.length - 1].divider) {
2188
+ filterOptions[filterOptions.length - 1].divider = false;
2189
+ }
2190
+ return filterOptions;
2191
+ }, [columnDef, globalFilterModeOptions]);
2192
+ const handleSelectFilterMode = (option) => {
2193
+ const prevFilterMode = columnDef?._filterFn ?? '';
2194
+ if (!header || !column) {
2195
+ // global filter mode
2196
+ setGlobalFilterFn(option);
2197
+ }
2198
+ else if (option !== prevFilterMode) {
2199
+ // column filter mode
2200
+ setColumnFilterFns((prev) => ({
2201
+ ...prev,
2202
+ [header.id]: option,
2203
+ }));
2204
+ // reset filter value and/or perform new filter render
2205
+ if (emptyModes.includes(option)) {
2206
+ // will now be empty/notEmpty filter mode
2207
+ if (currentFilterValue !== ' ' &&
2208
+ !emptyModes.includes(prevFilterMode)) {
2209
+ column.setFilterValue(' ');
2210
+ }
2211
+ else if (currentFilterValue) {
2212
+ column.setFilterValue(currentFilterValue); // perform new filter render
2213
+ }
2214
+ }
2215
+ else if (columnDef?.filterVariant === 'multi-select' ||
2216
+ arrModes.includes(option)) {
2217
+ // will now be array filter mode
2218
+ if (currentFilterValue instanceof String ||
2219
+ currentFilterValue?.length) {
2220
+ column.setFilterValue([]);
2221
+ }
2222
+ else if (currentFilterValue) {
2223
+ column.setFilterValue(currentFilterValue); // perform new filter render
2224
+ }
2225
+ }
2226
+ else if (rangeVariants.includes(columnDef?.filterVariant) ||
2227
+ rangeModes.includes(option)) {
2228
+ // will now be range filter mode
2229
+ if (!Array.isArray(currentFilterValue) ||
2230
+ (!currentFilterValue?.every((v) => v === '') &&
2231
+ !rangeModes.includes(prevFilterMode))) {
2232
+ column.setFilterValue(['', '']);
2233
+ }
2234
+ else {
2235
+ column.setFilterValue(currentFilterValue); // perform new filter render
2236
+ }
2237
+ }
2238
+ else {
2239
+ // will now be single value filter mode
2240
+ if (Array.isArray(currentFilterValue)) {
2241
+ column.setFilterValue('');
2242
+ }
2243
+ else if (currentFilterValue === ' ' &&
2244
+ emptyModes.includes(prevFilterMode)) {
2245
+ column.setFilterValue(undefined);
2246
+ }
2247
+ else {
2248
+ column.setFilterValue(currentFilterValue); // perform new filter render
2249
+ }
2250
+ }
2251
+ }
2252
+ onSelect?.();
2253
+ };
2254
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2255
+ return (jsx(Menu.Dropdown, { children: (header && column && columnDef
2256
+ ? (columnDef.renderColumnFilterModeMenuItems?.({
2257
+ column: column,
2258
+ internalFilterOptions,
2259
+ onSelectFilterMode: handleSelectFilterMode,
2260
+ table,
2261
+ }) ??
2262
+ renderColumnFilterModeMenuItems?.({
2263
+ column: column,
2264
+ internalFilterOptions,
2265
+ onSelectFilterMode: handleSelectFilterMode,
2266
+ table,
2267
+ }))
2268
+ : renderGlobalFilterModeMenuItems?.({
2269
+ internalFilterOptions,
2270
+ onSelectFilterMode: handleSelectFilterMode,
2271
+ table,
2272
+ })) ??
2273
+ internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxs(Fragment$1, { children: [jsx(Menu.Item, { color: option === filterOption ? 'blue' : undefined, leftSection: jsx("span", { className: classes$h.symbol, children: symbol }), onClick: () => handleSelectFilterMode(option), value: option, children: label }), divider && jsx(Menu.Divider, {})] }, index))) }));
2274
+ };
2275
+
2276
+ var classes$g = {"filter-mode-label":"MRT_TableHeadCellFilterContainer-module_filter-mode-label__8reK-"};
2277
+
2278
+ const MRT_TableHeadCellFilterContainer = ({ header, table, ...rest }) => {
2279
+ const { state, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, icons: { IconFilterCog }, localization, }, refs: { filterInputRefs }, } = table;
2280
+ const { showColumnFilters } = state;
2281
+ const { column } = header;
2282
+ const { columnDef } = column;
2283
+ const currentFilterOption = columnDef._filterFn;
2284
+ const allowedColumnFilterOptions = columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
2285
+ const showChangeModeButton = enableColumnFilterModes &&
2286
+ columnDef.enableColumnFilterModes !== false &&
2287
+ (allowedColumnFilterOptions === undefined ||
2288
+ !!allowedColumnFilterOptions?.length);
2289
+ return (jsx(Collapse, { expanded: showColumnFilters || columnFilterDisplayMode === 'popover', children: jsxs(Flex, { direction: "column", ...rest, children: [jsxs(Flex, { align: "flex-end", children: [columnDef.filterVariant === 'checkbox' ? (jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsx(MRT_FilterRangeSlider, { header: header, table: table })) : ['date-range', 'range'].includes(columnDef.filterVariant ?? '') ||
2290
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsx(MRT_FilterTextInput, { header: header, table: table })), showChangeModeButton && (jsxs(Menu, { withinPortal: columnFilterDisplayMode !== 'popover', children: [jsx(Tooltip, { label: localization.changeFilterMode, position: "bottom-start", withinPortal: true, children: jsx(Menu.Target, { children: jsx(ActionIcon, { "aria-label": localization.changeFilterMode, color: "gray", size: "md", variant: "subtle", children: jsx(IconFilterCog, {}) }) }) }), jsx(MRT_FilterOptionMenu, { header: header, onSelect: () => setTimeout(() => filterInputRefs.current[`${column.id}-0`]?.focus(), 100), table: table })] }))] }), showChangeModeButton ? (jsx(Text, { c: "dimmed", className: classes$g['filter-mode-label'], component: "label", children: localization.filterMode.replace('{filterType}', localizedFilterOption(localization, currentFilterOption)) })) : null] }) }));
2291
+ };
2292
+
2293
+ var classes$f = {"root":"MRT_TableHeadCellFilterLabel-module_root__Rur2R"};
2294
+
2295
+ const MRT_TableHeadCellFilterLabel = ({ header, table, ...rest }) => {
2296
+ const { options: { columnFilterDisplayMode, icons: { IconFilter }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
2297
+ const { column } = header;
2298
+ const { columnDef } = column;
2299
+ const filterValue = column.getFilterValue();
2300
+ const [popoverOpened, setPopoverOpened] = useState(false);
2301
+ const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
2302
+ (!!filterValue && !Array.isArray(filterValue));
2303
+ const isRangeFilter = columnDef.filterVariant === 'range' ||
2304
+ columnDef.filterVariant === 'date-range' ||
2305
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
2306
+ const currentFilterOption = columnDef._filterFn;
2307
+ const filterValueFn = columnDef.filterTooltipValueFn || ((value) => value);
2308
+ const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
2309
+ ? localization.filterByColumn?.replace('{column}', String(columnDef.header))
2310
+ : localization.filteringByColumn
2311
+ .replace('{column}', String(columnDef.header))
2312
+ .replace('{filterType}', localizedFilterOption(localization, currentFilterOption))
2313
+ .replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
2314
+ ? column.getFilterValue()
2315
+ .map((v) => filterValueFn(v))
2316
+ .join(`" ${isRangeFilter ? localization.and : localization.or} "`)
2317
+ : filterValueFn(column.getFilterValue())}"`)
2318
+ .replace('" "', '');
2319
+ return (jsx(Fragment, { children: jsxs(Popover, { keepMounted: columnDef.filterVariant === 'range-slider', onChange: setPopoverOpened, onClose: () => setPopoverOpened(false), opened: popoverOpened, position: "top", shadow: "xl", width: 360, withinPortal: true, children: [jsx(Transition, { mounted: columnFilterDisplayMode === 'popover' ||
2320
+ (!!column.getFilterValue() && !isRangeFilter) ||
2321
+ (isRangeFilter &&
2322
+ (!!column.getFilterValue()?.[0] ||
2323
+ !!column.getFilterValue()?.[1])), transition: "scale", children: () => (jsx(Popover.Target, { children: jsx(Tooltip, { disabled: popoverOpened, label: filterTooltip, multiline: true, w: filterTooltip.length > 40 ? 300 : undefined, withinPortal: true, children: jsx(ActionIcon, { "aria-label": filterTooltip, className: clsx('mrt-table-head-cell-filter-label-icon', classes$f.root), size: 18, ...dataVariable('active', isFilterActive), onClick: (event) => {
2324
+ event.stopPropagation();
2325
+ if (columnFilterDisplayMode === 'popover') {
2326
+ setPopoverOpened((opened) => !opened);
2327
+ }
2328
+ else {
2329
+ setShowColumnFilters(true);
2330
+ }
2331
+ setTimeout(() => {
2332
+ const input = filterInputRefs.current[`${column.id}-0`];
2333
+ input?.focus();
2334
+ input?.select();
2335
+ }, 100);
2336
+ }, ...rest, children: jsx(IconFilter, { size: "100%" }) }) }) })) }), columnFilterDisplayMode === 'popover' && (jsx(Popover.Dropdown, { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.key === 'Enter' && setPopoverOpened(false), onMouseDown: (event) => event.stopPropagation(), children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }))] }) }));
2337
+ };
2338
+
2339
+ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, ...rest }) => {
2340
+ const { state, options: { enableColumnOrdering, mantineColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
2341
+ const { columnDef } = column;
2342
+ const { columnOrder, draggingColumn, hoveredColumn } = state;
2343
+ const arg = { column, table };
2344
+ const actionIconProps = {
2345
+ ...parseFromValuesOrFunc(mantineColumnDragHandleProps, arg),
2346
+ ...parseFromValuesOrFunc(columnDef.mantineColumnDragHandleProps, arg),
2347
+ ...rest,
2348
+ };
2349
+ const handleDragStart = (event) => {
2350
+ actionIconProps?.onDragStart?.(event);
2351
+ setDraggingColumn(column);
2352
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
2353
+ };
2354
+ const handleDragEnd = (event) => {
2355
+ actionIconProps?.onDragEnd?.(event);
2356
+ if (hoveredColumn?.id === 'drop-zone') {
2357
+ column.toggleGrouping();
2358
+ }
2359
+ else if (enableColumnOrdering &&
2360
+ hoveredColumn &&
2361
+ hoveredColumn?.id !== draggingColumn?.id) {
2362
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
2363
+ }
2364
+ setDraggingColumn(null);
2365
+ setHoveredColumn(null);
2366
+ };
2367
+ return (jsx(MRT_GrabHandleButton, { actionIconProps: actionIconProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
2368
+ };
2369
+
2370
+ var classes$e = {"root":"MRT_TableHeadCellResizeHandle-module_root__paufe","root-ltr":"MRT_TableHeadCellResizeHandle-module_root-ltr__652AZ","root-rtl":"MRT_TableHeadCellResizeHandle-module_root-rtl__5VlSo","root-hide":"MRT_TableHeadCellResizeHandle-module_root-hide__-ILlD"};
2371
+
2372
+ const MRT_TableHeadCellResizeHandle = ({ header, table, ...rest }) => {
2373
+ const { state, options: { columnResizeDirection, columnResizeMode }, setColumnResizing, } = table;
2374
+ const { density } = state;
2375
+ const { column } = header;
2376
+ const handler = header.getResizeHandler();
2377
+ const offset = column.getIsResizing() && columnResizeMode === 'onEnd'
2378
+ ? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
2379
+ (state.columnResizing.deltaOffset ?? 0)}px)`
2380
+ : undefined;
2381
+ return (jsx(Box, { onDoubleClick: () => {
2382
+ setColumnResizing((old) => ({
2383
+ ...old,
2384
+ isResizingColumn: false,
2385
+ }));
2386
+ column.resetSize();
2387
+ }, onMouseDown: handler, onTouchStart: handler, role: "separator", ...rest, __vars: { '--mrt-transform': offset, ...rest.__vars }, className: clsx('mrt-table-head-cell-resize-handle', classes$e.root, classes$e[`root-${columnResizeDirection}`], !header.subHeaders.length &&
2388
+ columnResizeMode === 'onChange' &&
2389
+ classes$e['root-hide'], density, rest.className) }));
2390
+ };
2391
+
2392
+ var classes$d = {"sort-icon":"MRT_TableHeadCellSortLabel-module_sort-icon__zs1xA","multi-sort-indicator":"MRT_TableHeadCellSortLabel-module_multi-sort-indicator__MGBj2"};
2393
+
2394
+ const MRT_TableHeadCellSortLabel = ({ header, table, ...rest }) => {
2395
+ const { options: { icons: { IconArrowsSort, IconSortAscending, IconSortDescending }, localization, }, } = table;
2396
+ const column = header.column;
2397
+ const { columnDef } = column;
2398
+ return (jsx(Subscribe, { source: table.atoms.sorting, children: (sorting) => {
2399
+ const sorted = column.getIsSorted();
2400
+ const sortIndex = column.getSortIndex();
2401
+ const sortTooltip = sorted
2402
+ ? sorted === 'desc'
2403
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
2404
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
2405
+ : column.getNextSortingOrder() === 'desc'
2406
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
2407
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
2408
+ const SortActionButton = (jsx(ActionIcon, { "aria-label": sortTooltip, ...dataVariable('sorted', sorted), ...rest, className: clsx('mrt-table-head-sort-button', classes$d['sort-icon'], rest.className), children: sorted === 'desc' ? (jsx(IconSortDescending, { size: "100%" })) : sorted === 'asc' ? (jsx(IconSortAscending, { size: "100%" })) : (jsx(IconArrowsSort, { size: "100%" })) }));
2409
+ return (jsx(Tooltip, { label: sortTooltip, openDelay: 1000, withinPortal: true, children: sorting.length < 2 || sortIndex === -1 ? (SortActionButton) : (jsx(Indicator, { classNames: {
2410
+ root: clsx('mrt-table-head-multi-sort-indicator', classes$d['multi-sort-indicator']),
2411
+ }, inline: true, label: sortIndex + 1, offset: 4, children: SortActionButton })) }));
2412
+ } }));
2413
+ };
2414
+
2415
+ var classes$c = {"root":"MRT_TableHeadCell-module_root__6y50a","root-grid":"MRT_TableHeadCell-module_root-grid__bAf1d","root-virtualized":"MRT_TableHeadCell-module_root-virtualized__CWLit","root-no-select":"MRT_TableHeadCell-module_root-no-select__BEOVU","content":"MRT_TableHeadCell-module_content__-pzSK","content-spaced":"MRT_TableHeadCell-module_content-spaced__S85Aa","content-center":"MRT_TableHeadCell-module_content-center__c-17L","content-right":"MRT_TableHeadCell-module_content-right__NSRZU","content-wrapper":"MRT_TableHeadCell-module_content-wrapper__py6aJ","content-wrapper-hidden-overflow":"MRT_TableHeadCell-module_content-wrapper-hidden-overflow__QY40r","content-wrapper-nowrap":"MRT_TableHeadCell-module_content-wrapper-nowrap__-4aIg","labels":"MRT_TableHeadCell-module_labels__oiMSr","labels-right":"MRT_TableHeadCell-module_labels-right__6ZJp-","labels-center":"MRT_TableHeadCell-module_labels-center__MM9q8","labels-sortable":"MRT_TableHeadCell-module_labels-sortable__tyuLr","labels-data":"MRT_TableHeadCell-module_labels-data__PvFGO","content-actions":"MRT_TableHeadCell-module_content-actions__utxbm"};
2416
+
2417
+ const MRT_TableHeadCell = ({ columnVirtualizer, header, renderedHeaderIndex = 0, table, ...rest }) => {
2418
+ const direction = useDirection();
2419
+ const { state, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableHeaderActionsHoverReveal, enableMultiSort, layoutMode, mantineTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
2420
+ const { columnResizing, draggingColumn, grouping, hoveredColumn } = state;
2421
+ const { column } = header;
2422
+ const { columnDef } = column;
2423
+ const { columnDefType } = columnDef;
2424
+ const arg = { column, table };
2425
+ const tableCellProps = {
2426
+ ...parseFromValuesOrFunc(mantineTableHeadCellProps, arg),
2427
+ ...parseFromValuesOrFunc(columnDef.mantineTableHeadCellProps, arg),
2428
+ ...rest,
2429
+ };
2430
+ const widthStyles = {
2431
+ minWidth: `max(calc(var(--header-${parseCSSVarId(header?.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
2432
+ width: `calc(var(--header-${parseCSSVarId(header.id)}-size) * 1px)`,
2433
+ };
2434
+ if (layoutMode === 'grid') {
2435
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
2436
+ ? 0
2437
+ : `var(--header-${parseCSSVarId(header.id)}-size)`} 0 auto`;
2438
+ }
2439
+ else if (layoutMode === 'grid-no-grow') {
2440
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
2441
+ }
2442
+ const isColumnPinned = enableColumnPinning &&
2443
+ columnDef.columnDefType !== 'group' &&
2444
+ column.getIsPinned();
2445
+ const isDraggingColumn = draggingColumn?.id === column.id;
2446
+ const isHoveredColumn = hoveredColumn?.id === column.id;
2447
+ const { hovered: isHoveredHeadCell, ref: isHoveredHeadCellRef } = useHover();
2448
+ const [isOpenedColumnActions, setIsOpenedColumnActions] = useState(false);
2449
+ const columnActionsEnabled = (enableColumnActions || columnDef.enableColumnActions) &&
2450
+ columnDef.enableColumnActions !== false;
2451
+ const showColumnButtons = !enableHeaderActionsHoverReveal ||
2452
+ isOpenedColumnActions ||
2453
+ (isHoveredHeadCell &&
2454
+ !table.getVisibleFlatColumns().find((column) => column.getIsResizing()));
2455
+ const showDragHandle = enableColumnDragging !== false &&
2456
+ columnDef.enableColumnDragging !== false &&
2457
+ (enableColumnDragging ||
2458
+ (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
2459
+ (enableGrouping &&
2460
+ columnDef.enableGrouping !== false &&
2461
+ !grouping.includes(column.id))) &&
2462
+ showColumnButtons;
2463
+ const headerPL = useMemo(() => {
2464
+ let pl = 0;
2465
+ if (column.getCanSort())
2466
+ pl++;
2467
+ // Only add padding for buttons if they will actually be displayed
2468
+ if (showColumnButtons && (columnActionsEnabled || showDragHandle))
2469
+ pl += 1.75;
2470
+ if (showDragHandle)
2471
+ pl += 1.25;
2472
+ return pl;
2473
+ }, [showColumnButtons, showDragHandle, columnActionsEnabled]);
2474
+ const handleDragEnter = (_e) => {
2475
+ if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
2476
+ setHoveredColumn(null);
2477
+ }
2478
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
2479
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2480
+ }
2481
+ };
2482
+ const headerElement = columnDef?.Header instanceof Function
2483
+ ? columnDef?.Header?.({
2484
+ column,
2485
+ header,
2486
+ table,
2487
+ })
2488
+ : (columnDef?.Header ?? columnDef.header);
2489
+ return (jsxs(TableTh, { colSpan: header.colSpan, "data-column-pinned": isColumnPinned || undefined, "data-dragging-column": isDraggingColumn || undefined, "data-first-end-pinned": (isColumnPinned === 'end' && column.getIsFirstColumn(isColumnPinned)) ||
2490
+ undefined, "data-hovered-column-target": isHoveredColumn || undefined, "data-index": renderedHeaderIndex, "data-last-start-pinned": (isColumnPinned === 'start' &&
2491
+ column.getIsLastColumn(isColumnPinned)) ||
2492
+ undefined, "data-resizing": (columnResizeMode === 'onChange' &&
2493
+ columnResizing?.isResizingColumn === column.id &&
2494
+ columnResizeDirection) ||
2495
+ undefined, ...tableCellProps, __vars: {
2496
+ '--mrt-table-cell-start': isColumnPinned === 'start'
2497
+ ? `${column.getStart(isColumnPinned)}`
2498
+ : undefined,
2499
+ '--mrt-table-cell-end': isColumnPinned === 'end'
2500
+ ? `${column.getAfter(isColumnPinned)}`
2501
+ : undefined,
2502
+ }, align: columnDefType === 'group'
2503
+ ? 'center'
2504
+ : direction.dir === 'rtl'
2505
+ ? 'right'
2506
+ : 'left', className: clsx(classes$c.root, layoutMode?.startsWith('grid') && classes$c['root-grid'], enableMultiSort && column.getCanSort() && classes$c['root-no-select'], columnVirtualizer && classes$c['root-virtualized'], tableCellProps?.className), onDragEnter: handleDragEnter, ref: (node) => {
2507
+ if (node) {
2508
+ tableHeadCellRefs.current[column.id] = node;
2509
+ isHoveredHeadCellRef.current = node;
2510
+ if (columnDefType !== 'group') {
2511
+ columnVirtualizer?.measureElement?.(node);
2512
+ }
2513
+ }
2514
+ }, style: (theme) => ({
2515
+ ...widthStyles,
2516
+ ...parseFromValuesOrFunc(tableCellProps?.style, theme),
2517
+ }), children: [header.isPlaceholder
2518
+ ? null
2519
+ : (tableCellProps.children ?? (jsxs(Flex, { className: clsx('mrt-table-head-cell-content', classes$c.content, (columnDefType === 'group' ||
2520
+ tableCellProps?.align === 'center') &&
2521
+ classes$c['content-center'], tableCellProps?.align === 'right' && classes$c['content-right'], column.getCanResize() && classes$c['content-spaced']), children: [jsxs(Flex, { __vars: {
2522
+ '--mrt-table-head-cell-labels-padding-left': `${headerPL}`,
2523
+ }, className: clsx('mrt-table-head-cell-labels', classes$c.labels, column.getCanSort() &&
2524
+ columnDefType !== 'group' &&
2525
+ classes$c['labels-sortable'], tableCellProps?.align === 'right'
2526
+ ? classes$c['labels-right']
2527
+ : tableCellProps?.align === 'center' &&
2528
+ classes$c['labels-center'], columnDefType === 'data' && classes$c['labels-data']), onClick: column.getToggleSortingHandler(), children: [jsx(Flex, { className: clsx('mrt-table-head-cell-content-wrapper', classes$c['content-wrapper'], columnDefType === 'data' &&
2529
+ classes$c['content-wrapper-hidden-overflow'], (columnDef.header?.length ?? 0) < 20 &&
2530
+ classes$c['content-wrapper-nowrap']), children: headerElement }), column.getCanFilter() &&
2531
+ (column.getIsFiltered() || showColumnButtons) && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() &&
2532
+ (column.getIsSorted() || showColumnButtons) && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Flex, { className: clsx('mrt-table-head-cell-content-actions', classes$c['content-actions']), children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
2533
+ current: tableHeadCellRefs.current[column.id],
2534
+ } })), columnActionsEnabled && showColumnButtons && (jsx(MRT_ColumnActionMenu, { header: header, onChange: setIsOpenedColumnActions, opened: isOpenedColumnActions, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] }))), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] }));
2535
+ };
2536
+
2537
+ var classes$b = {"root":"MRT_TableHeadRow-module_root__hUKv4","layout-mode-grid":"MRT_TableHeadRow-module_layout-mode-grid__4ZGri","sticky":"MRT_TableHeadRow-module_sticky__Ej7Ax"};
2538
+
2539
+ const MRT_TableHeadRow = ({ columnVirtualizer, headerGroup, table, ...rest }) => {
2540
+ const { state, options: { enableStickyHeader, layoutMode, mantineTableHeadRowProps }, } = table;
2541
+ const { isFullScreen } = state;
2542
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
2543
+ const tableRowProps = {
2544
+ ...parseFromValuesOrFunc(mantineTableHeadRowProps, {
2545
+ headerGroup,
2546
+ table,
2547
+ }),
2548
+ ...rest,
2549
+ };
2550
+ return (jsxs(TableTr, { ...tableRowProps, className: clsx(classes$b.root, (enableStickyHeader || isFullScreen) && classes$b.sticky, layoutMode?.startsWith('grid') && classes$b['layout-mode-grid'], tableRowProps?.className), children: [virtualPaddingLeft ? (jsx(Box, { component: "th", display: "flex", w: virtualPaddingLeft })) : null, (virtualColumns ?? headerGroup.headers).map((headerOrVirtualHeader, renderedHeaderIndex) => {
2551
+ let header = headerOrVirtualHeader;
2552
+ if (columnVirtualizer) {
2553
+ renderedHeaderIndex = headerOrVirtualHeader
2554
+ .index;
2555
+ header = headerGroup.headers[renderedHeaderIndex];
2556
+ }
2557
+ return (jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, renderedHeaderIndex: renderedHeaderIndex, table: table }, header.id));
2558
+ }), virtualPaddingRight ? (jsx(Box, { component: "th", display: "flex", w: virtualPaddingRight })) : null] }));
2559
+ };
2560
+
2561
+ var classes$a = {"root":"MRT_TableHead-module_root__j9NkO","root-grid":"MRT_TableHead-module_root-grid__c3aGl","root-table-row-group":"MRT_TableHead-module_root-table-row-group__d9FO4","root-sticky":"MRT_TableHead-module_root-sticky__0kuDE","banner-tr":"MRT_TableHead-module_banner-tr__EhT-x","banner-th":"MRT_TableHead-module_banner-th__KwM5a","grid":"MRT_TableHead-module_grid__OJ-td"};
2562
+
2563
+ const MRT_TableHead = ({ columnVirtualizer, table, ...rest }) => {
2564
+ const { getHeaderGroups, getSelectedRowModel, state, options: { enableStickyHeader, layoutMode, mantineTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
2565
+ const { isFullScreen, showAlertBanner } = state;
2566
+ const tableHeadProps = {
2567
+ ...parseFromValuesOrFunc(mantineTableHeadProps, {
2568
+ table,
2569
+ }),
2570
+ ...rest,
2571
+ };
2572
+ const stickyHeader = enableStickyHeader || isFullScreen;
2573
+ return (jsx(TableThead, { ...tableHeadProps, className: clsx(classes$a.root, layoutMode?.startsWith('grid')
2574
+ ? classes$a['root-grid']
2575
+ : classes$a['root-table-row-group'], stickyHeader && classes$a['root-sticky'], tableHeadProps?.className), pos: stickyHeader && layoutMode?.startsWith('grid') ? 'sticky' : 'relative', ref: (ref) => {
2576
+ tableHeadRef.current = ref;
2577
+ if (tableHeadProps?.ref) {
2578
+ // @ts-ignore
2579
+ tableHeadProps.ref.current = ref;
2580
+ }
2581
+ }, children: positionToolbarAlertBanner === 'head-overlay' &&
2582
+ (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (jsx(TableTr, { className: clsx(classes$a['banner-tr'], layoutMode?.startsWith('grid') && classes$a.grid), children: jsx(TableTh, { className: clsx(classes$a['banner-th'], layoutMode?.startsWith('grid') && classes$a.grid), colSpan: table.getVisibleLeafColumns().length, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) }));
2583
+ };
2584
+
2585
+ var classes$9 = {"root":"MRT_GlobalFilterTextInput-module_root__Xmcpv","collapse":"MRT_GlobalFilterTextInput-module_collapse__v311d"};
2586
+
2587
+ const MRT_GlobalFilterTextInput = ({ table, ...rest }) => {
2588
+ const { state, options: { enableGlobalFilterModes, icons: { IconSearch, IconX }, localization, mantineSearchTextInputProps, manualFiltering, positionGlobalFilter, }, refs: { searchInputRef }, setGlobalFilter, } = table;
2589
+ const { globalFilter, showGlobalFilter } = state;
2590
+ const textFieldProps = {
2591
+ ...parseFromValuesOrFunc(mantineSearchTextInputProps, {
2592
+ table,
2593
+ }),
2594
+ ...rest,
2595
+ };
2596
+ const isMounted = useRef(false);
2597
+ const [searchValue, setSearchValue] = useState(globalFilter ?? '');
2598
+ const [debouncedSearchValue] = useDebouncedValue(searchValue, manualFiltering ? 500 : 250);
2599
+ useEffect(() => {
2600
+ setGlobalFilter(debouncedSearchValue || undefined);
2601
+ }, [debouncedSearchValue]);
2602
+ const handleClear = () => {
2603
+ setSearchValue('');
2604
+ setGlobalFilter(undefined);
2605
+ };
2606
+ useEffect(() => {
2607
+ if (isMounted.current) {
2608
+ if (globalFilter === undefined) {
2609
+ handleClear();
2610
+ }
2611
+ else {
2612
+ setSearchValue(globalFilter);
2613
+ }
2614
+ }
2615
+ isMounted.current = true;
2616
+ }, [globalFilter]);
2617
+ return (jsxs(Collapse, { className: classes$9.collapse, expanded: showGlobalFilter, children: [enableGlobalFilterModes && (jsxs(Menu, { withinPortal: true, children: [jsx(Menu.Target, { children: jsx(ActionIcon, { "aria-label": localization.changeSearchMode, color: "gray", size: "sm", variant: "transparent", children: jsx(IconSearch, {}) }) }), jsx(MRT_FilterOptionMenu, { onSelect: handleClear, table: table })] })), jsx(TextInput, { leftSection: !enableGlobalFilterModes && jsx(IconSearch, {}), mt: 0, mx: positionGlobalFilter !== 'left' ? 'mx' : undefined, onChange: (event) => setSearchValue(event.target.value), placeholder: localization.search, rightSection: jsx(ActionIcon, { "aria-label": localization.clearSearch, color: "gray", disabled: !searchValue?.length, hidden: !searchValue, onClick: handleClear, size: "sm", style: {
2618
+ visibility: !searchValue ? 'hidden' : undefined,
2619
+ }, variant: "transparent", children: jsx(Tooltip, { label: localization.clearSearch, withinPortal: true, children: jsx(IconX, {}) }) }), value: searchValue ?? '', variant: "filled", ...textFieldProps, className: clsx('mrt-global-filter-text-input', classes$9.root, textFieldProps?.className), ref: (node) => {
2620
+ if (node) {
2621
+ searchInputRef.current = node;
2622
+ if (textFieldProps?.ref) {
2623
+ // @ts-ignore
2624
+ textFieldProps.ref = node;
2625
+ }
2626
+ }
2627
+ } })] }));
2628
+ };
2629
+
2630
+ const flexRender = flexRender$1;
2631
+ /**
2632
+ * A helper utility for creating MRT column definitions with type inference
2633
+ * for each individual column's `TValue`. Mirrors v9's `createColumnHelper`
2634
+ * surface (`accessor`, `columns`, `display`, `group`) but bound to MRT's
2635
+ * column-def shape (extra MRT-specific props, `StockFeatures` pre-bound).
2636
+ *
2637
+ * From a JavaScript perspective, `display` / `group` / `columns` are identity
2638
+ * functions — they exist purely to anchor TypeScript inference.
2639
+ *
2640
+ * @example
2641
+ * ```tsx
2642
+ * const helper = createMRTColumnHelper<Person>()
2643
+ * const columns = helper.columns([
2644
+ * helper.accessor('firstName', { header: 'First' }),
2645
+ * helper.accessor((row) => row.lastName, { id: 'lastName' }),
2646
+ * helper.display({ id: 'actions', header: 'Actions' }),
2647
+ * ])
2648
+ * ```
2649
+ */
2650
+ function createMRTColumnHelper() {
2651
+ return {
2652
+ accessor: (accessor, column) => {
2653
+ return typeof accessor === 'function'
2654
+ ? {
2655
+ ...column,
2656
+ accessorFn: accessor,
2657
+ }
2658
+ : {
2659
+ ...column,
2660
+ accessorKey: accessor,
2661
+ };
2662
+ },
2663
+ columns: (columns) => columns,
2664
+ display: (column) => column,
2665
+ group: (column) => column,
2666
+ };
2667
+ }
2668
+ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => constructRow(table, 'mrt-row-create', originalRow ??
2669
+ Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
2670
+ [getColumnId(col)]: '',
2671
+ }))), rowIndex, depth, subRows, parentId);
2672
+
2673
+ const getMRT_RowActionsColumnDef = (tableOptions) => {
2674
+ return {
2675
+ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })),
2676
+ ...defaultDisplayColumnProps({
2677
+ header: 'actions',
2678
+ id: 'mrt-row-actions',
2679
+ size: 70,
2680
+ tableOptions,
2681
+ }),
2682
+ };
2683
+ };
2684
+
2685
+ const getMRT_RowDragColumnDef = (tableOptions) => {
2686
+ return {
2687
+ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })),
2688
+ grow: false,
2689
+ ...defaultDisplayColumnProps({
2690
+ header: 'move',
2691
+ id: 'mrt-row-drag',
2692
+ size: 60,
2693
+ tableOptions,
2694
+ }),
2695
+ };
2696
+ };
2697
+
2698
+ const getMRT_RowExpandColumnDef = (tableOptions) => {
2699
+ const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
2700
+ const alignProps = positionExpandColumn === 'last'
2701
+ ? {
2702
+ align: 'right',
2703
+ }
2704
+ : undefined;
2705
+ return {
2706
+ Cell: ({ cell, column, row, table }) => {
2707
+ const expandButtonProps = { row, table };
2708
+ const subRowsLength = row.subRows?.length;
2709
+ if (tableOptions.groupedColumnMode === 'remove' && row.groupingColumnId) {
2710
+ return (jsxs(Flex, { align: "center", gap: "0.25rem", children: [jsx(MRT_ExpandButton, { ...expandButtonProps }), jsx(Tooltip, { label: table.getColumn(row.groupingColumnId).columnDef.header, openDelay: 1000, position: "right", children: jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
2711
+ }
2712
+ else {
2713
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, { ...expandButtonProps }), column.columnDef.GroupedCell?.({ cell, column, row, table })] }));
2714
+ }
2715
+ },
2716
+ Header: enableExpandAll
2717
+ ? ({ table }) => {
2718
+ return (jsxs(Flex, { align: "center", children: [jsx(MRT_ExpandAllButton, { table: table }), groupedColumnMode === 'remove' &&
2719
+ grouping
2720
+ ?.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
2721
+ ?.join(', ')] }));
2722
+ }
2723
+ : undefined,
2724
+ mantineTableBodyCellProps: alignProps,
2725
+ mantineTableHeadCellProps: alignProps,
2726
+ ...defaultDisplayColumnProps({
2727
+ header: 'expand',
2728
+ id: 'mrt-row-expand',
2729
+ size: groupedColumnMode === 'remove'
2730
+ ? (defaultColumn?.size ?? 180)
2731
+ : renderDetailPanel
2732
+ ? enableExpandAll
2733
+ ? 60
2734
+ : 70
2735
+ : 100,
2736
+ tableOptions,
2737
+ }),
2738
+ };
2739
+ };
2740
+
2741
+ const getMRT_RowNumbersColumnDef = (tableOptions) => {
2742
+ const { localization, rowNumberDisplayMode } = tableOptions;
2743
+ return {
2744
+ Cell: ({ renderedRowIndex = 0, row, table }) => {
2745
+ const { pageIndex, pageSize } = table.atoms.pagination.get();
2746
+ return (((rowNumberDisplayMode === 'static'
2747
+ ? renderedRowIndex + pageSize * pageIndex
2748
+ : row.index) ?? 0) + 1);
2749
+ },
2750
+ grow: false,
2751
+ Header: () => localization.rowNumber,
2752
+ ...defaultDisplayColumnProps({
2753
+ header: 'rowNumbers',
2754
+ id: 'mrt-row-numbers',
2755
+ size: 50,
2756
+ tableOptions,
2757
+ }),
2758
+ };
2759
+ };
2760
+
2761
+ const getMRT_RowPinningColumnDef = (tableOptions) => {
2762
+ return {
2763
+ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })),
2764
+ grow: false,
2765
+ ...defaultDisplayColumnProps({
2766
+ header: 'pin',
2767
+ id: 'mrt-row-pin',
2768
+ size: 60,
2769
+ tableOptions,
2770
+ }),
2771
+ };
2772
+ };
2773
+
2774
+ const getMRT_RowSelectColumnDef = (tableOptions) => {
2775
+ const { enableMultiRowSelection, enableSelectAll } = tableOptions;
2776
+ return {
2777
+ Cell: ({ renderedRowIndex, row, table }) => (jsx(MRT_SelectCheckbox, { renderedRowIndex: renderedRowIndex, row: row, table: table })),
2778
+ grow: false,
2779
+ Header: enableSelectAll && enableMultiRowSelection
2780
+ ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
2781
+ : undefined,
2782
+ ...defaultDisplayColumnProps({
2783
+ header: 'select',
2784
+ id: 'mrt-row-select',
2785
+ size: enableSelectAll ? 60 : 70,
2786
+ tableOptions,
2787
+ }),
2788
+ };
2789
+ };
2790
+
2791
+ const MRT_RowAggregationFns = { ...aggregationFns };
2792
+
2793
+ const MRT_Default_Icons = {
2794
+ IconArrowAutofitContent,
2795
+ IconArrowsSort,
2796
+ IconBaselineDensityLarge,
2797
+ IconBaselineDensityMedium,
2798
+ IconBaselineDensitySmall,
2799
+ IconBoxMultiple,
2800
+ IconChevronDown,
2801
+ IconChevronLeft,
2802
+ IconChevronLeftPipe,
2803
+ IconChevronRight,
2804
+ IconChevronRightPipe,
2805
+ IconChevronsDown,
2806
+ IconCircleX,
2807
+ IconClearAll,
2808
+ IconColumns,
2809
+ IconDeviceFloppy,
2810
+ IconDots,
2811
+ IconDotsVertical,
2812
+ IconEdit,
2813
+ IconEyeOff,
2814
+ IconFilter,
2815
+ IconFilterCog,
2816
+ IconFilterOff,
2817
+ IconGripHorizontal,
2818
+ IconMaximize,
2819
+ IconMinimize,
2820
+ IconPinned,
2821
+ IconPinnedOff,
2822
+ IconSearch,
2823
+ IconSearchOff,
2824
+ IconSortAscending,
2825
+ IconSortDescending,
2826
+ IconX,
2827
+ };
2828
+
2829
+ const MRT_Localization_EN = {
2830
+ actions: 'Actions',
2831
+ and: 'and',
2832
+ cancel: 'Cancel',
2833
+ changeFilterMode: 'Change filter mode',
2834
+ changeSearchMode: 'Change search mode',
2835
+ clearFilter: 'Clear filter',
2836
+ clearSearch: 'Clear search',
2837
+ clearSelection: 'Clear selection',
2838
+ clearSort: 'Clear sort',
2839
+ clickToCopy: 'Click to copy',
2840
+ copy: 'Copy',
2841
+ collapse: 'Collapse',
2842
+ collapseAll: 'Collapse all',
2843
+ columnActions: 'Column Actions',
2844
+ copiedToClipboard: 'Copied to clipboard',
2845
+ dropToGroupBy: 'Drop to group by {column}',
2846
+ edit: 'Edit',
2847
+ expand: 'Expand',
2848
+ expandAll: 'Expand all',
2849
+ filterArrIncludes: 'Includes',
2850
+ filterArrIncludesAll: 'Includes all',
2851
+ filterArrIncludesSome: 'Includes',
2852
+ filterBetween: 'Between',
2853
+ filterBetweenInclusive: 'Between Inclusive',
2854
+ filterByColumn: 'Filter by {column}',
2855
+ filterContains: 'Contains',
2856
+ filterEmpty: 'Empty',
2857
+ filterEndsWith: 'Ends With',
2858
+ filterEquals: 'Equals',
2859
+ filterEqualsString: 'Equals',
2860
+ filterFuzzy: 'Fuzzy',
2861
+ filterGreaterThan: 'Greater Than',
2862
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
2863
+ filterInNumberRange: 'Between',
2864
+ filterIncludesString: 'Contains',
2865
+ filterIncludesStringSensitive: 'Contains',
2866
+ filterLessThan: 'Less Than',
2867
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
2868
+ filterMode: 'Filter Mode: {filterType}',
2869
+ filterNotEmpty: 'Not Empty',
2870
+ filterNotEquals: 'Not Equals',
2871
+ filterStartsWith: 'Starts With',
2872
+ filterWeakEquals: 'Equals',
2873
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
2874
+ goToFirstPage: 'Go to first page',
2875
+ goToLastPage: 'Go to last page',
2876
+ goToNextPage: 'Go to next page',
2877
+ goToPreviousPage: 'Go to previous page',
2878
+ grab: 'Grab',
2879
+ groupByColumn: 'Group by {column}',
2880
+ groupedBy: 'Grouped by ',
2881
+ hideAll: 'Hide all',
2882
+ hideColumn: 'Hide {column} column',
2883
+ max: 'Max',
2884
+ min: 'Min',
2885
+ move: 'Move',
2886
+ noRecordsToDisplay: 'No records to display',
2887
+ noResultsFound: 'No results found',
2888
+ of: 'of',
2889
+ or: 'or',
2890
+ pin: 'Pin',
2891
+ pinToLeft: 'Pin to left',
2892
+ pinToRight: 'Pin to right',
2893
+ resetColumnSize: 'Reset column size',
2894
+ resetOrder: 'Reset order',
2895
+ rowActions: 'Row Actions',
2896
+ rowNumber: '#',
2897
+ rowNumbers: 'Row Numbers',
2898
+ rowsPerPage: 'Rows per page',
2899
+ save: 'Save',
2900
+ search: 'Search',
2901
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
2902
+ select: 'Select',
2903
+ showAll: 'Show all',
2904
+ showAllColumns: 'Show all columns',
2905
+ showHideColumns: 'Show/Hide columns',
2906
+ showHideFilters: 'Show/Hide filters',
2907
+ showHideSearch: 'Show/Hide search',
2908
+ sortByColumnAsc: 'Sort by {column} ascending',
2909
+ sortByColumnDesc: 'Sort by {column} descending',
2910
+ sortedByColumnAsc: 'Sorted by {column} ascending',
2911
+ sortedByColumnDesc: 'Sorted by {column} descending',
2912
+ thenBy: ', then by ',
2913
+ toggleDensity: 'Toggle density',
2914
+ toggleFullScreen: 'Toggle full screen',
2915
+ toggleSelectAll: 'Toggle select all',
2916
+ toggleSelectRow: 'Toggle select row',
2917
+ toggleVisibility: 'Toggle visibility',
2918
+ ungroupByColumn: 'Ungroup by {column}',
2919
+ unpin: 'Unpin',
2920
+ unpinAll: 'Unpin all',
2921
+ };
2922
+
2923
+ const MRT_DefaultColumn = {
2924
+ filterVariant: 'text',
2925
+ maxSize: 1000,
2926
+ minSize: 40,
2927
+ size: 180,
2928
+ };
2929
+ const MRT_DefaultDisplayColumn = {
2930
+ columnDefType: 'display',
2931
+ enableClickToCopy: false,
2932
+ enableColumnActions: false,
2933
+ enableColumnDragging: false,
2934
+ enableColumnFilter: false,
2935
+ enableColumnOrdering: false,
2936
+ enableEditing: false,
2937
+ enableGlobalFilter: false,
2938
+ enableGrouping: false,
2939
+ enableHiding: false,
2940
+ enableResizing: false,
2941
+ enableSorting: false,
2942
+ };
2943
+ const useMRT_TableOptions = ({ aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHeaderActionsHoverReveal = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortFns, ...rest }) => {
2944
+ const direction = useDirection();
2945
+ icons = useMemo(() => ({ ...MRT_Default_Icons, ...icons }), [icons]);
2946
+ localization = useMemo(() => ({
2947
+ ...MRT_Localization_EN,
2948
+ ...localization,
2949
+ }), [localization]);
2950
+ aggregationFns = useMemo(() => ({ ...MRT_RowAggregationFns, ...aggregationFns }), []);
2951
+ filterFns = useMemo(() => ({ ...MRT_FilterFns, ...filterFns }), []);
2952
+ sortFns = useMemo(() => ({ ...MRT_SortFns, ...sortFns }), []);
2953
+ defaultColumn = useMemo(() => ({ ...MRT_DefaultColumn, ...defaultColumn }), [defaultColumn]);
2954
+ defaultDisplayColumn = useMemo(() => ({
2955
+ ...MRT_DefaultDisplayColumn,
2956
+ ...defaultDisplayColumn,
2957
+ }), [defaultDisplayColumn]);
2958
+ [enableColumnVirtualization, enableRowVirtualization] = useMemo(() => [enableColumnVirtualization, enableRowVirtualization], []);
2959
+ if (!columnResizeDirection) {
2960
+ columnResizeDirection = direction.dir || 'ltr';
2961
+ }
2962
+ layoutMode =
2963
+ layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
2964
+ if (layoutMode === 'semantic' &&
2965
+ (enableRowVirtualization || enableColumnVirtualization)) {
2966
+ layoutMode = 'grid';
2967
+ }
2968
+ if (enableRowVirtualization) {
2969
+ enableStickyHeader = true;
2970
+ }
2971
+ if (enablePagination === false && manualPagination === undefined) {
2972
+ manualPagination = true;
2973
+ }
2974
+ if (!rest.data?.length) {
2975
+ manualFiltering = true;
2976
+ manualGrouping = true;
2977
+ manualPagination = true;
2978
+ manualSorting = true;
2979
+ }
2980
+ return {
2981
+ aggregationFns,
2982
+ autoResetExpanded,
2983
+ columnFilterDisplayMode,
2984
+ columnResizeDirection,
2985
+ columnResizeMode,
2986
+ createDisplayMode,
2987
+ defaultColumn,
2988
+ defaultDisplayColumn,
2989
+ editDisplayMode,
2990
+ enableBatchRowSelection,
2991
+ enableBottomToolbar,
2992
+ enableColumnActions,
2993
+ enableColumnFilters,
2994
+ enableColumnOrdering,
2995
+ enableColumnPinning,
2996
+ enableColumnResizing,
2997
+ enableColumnVirtualization,
2998
+ enableDensityToggle,
2999
+ enableExpandAll,
3000
+ enableExpanding,
3001
+ enableFacetedValues,
3002
+ enableFilterMatchHighlighting,
3003
+ enableFilters,
3004
+ enableFullScreenToggle,
3005
+ enableGlobalFilter,
3006
+ enableGlobalFilterRankedResults,
3007
+ enableGrouping,
3008
+ enableHeaderActionsHoverReveal,
3009
+ enableHiding,
3010
+ enableMultiRowSelection,
3011
+ enableMultiSort,
3012
+ enablePagination,
3013
+ enableRowPinning,
3014
+ enableRowSelection,
3015
+ enableRowVirtualization,
3016
+ enableSelectAll,
3017
+ enableSorting,
3018
+ enableStickyHeader,
3019
+ enableTableFooter,
3020
+ enableTableHead,
3021
+ enableToolbarInternalActions,
3022
+ enableTopToolbar,
3023
+ filterFns,
3024
+ features: {
3025
+ ...stockFeatures,
3026
+ ...((enableColumnFilters || enableGlobalFilter || enableFilters) &&
3027
+ !manualFiltering
3028
+ ? { filteredRowModel: createFilteredRowModel(), filterFns }
3029
+ : {}),
3030
+ ...(enableSorting && !manualSorting
3031
+ ? { sortedRowModel: createSortedRowModel(), sortFns }
3032
+ : {}),
3033
+ ...(enablePagination && !manualPagination
3034
+ ? { paginatedRowModel: createPaginatedRowModel() }
3035
+ : {}),
3036
+ ...(enableExpanding || enableGrouping
3037
+ ? { expandedRowModel: createExpandedRowModel() }
3038
+ : {}),
3039
+ ...(enableGrouping && !manualGrouping
3040
+ ? {
3041
+ groupedRowModel: createGroupedRowModel(),
3042
+ aggregationFns,
3043
+ }
3044
+ : {}),
3045
+ ...(enableFacetedValues
3046
+ ? {
3047
+ facetedRowModel: createFacetedRowModel(),
3048
+ facetedMinMaxValues: createFacetedMinMaxValues(),
3049
+ facetedUniqueValues: createFacetedUniqueValues(),
3050
+ }
3051
+ : {}),
3052
+ },
3053
+ getSubRows: (row) => row?.subRows,
3054
+ icons,
3055
+ layoutMode,
3056
+ localization,
3057
+ manualFiltering,
3058
+ manualGrouping,
3059
+ manualPagination,
3060
+ manualSorting,
3061
+ paginationDisplayMode,
3062
+ positionActionsColumn,
3063
+ positionCreatingRow,
3064
+ positionExpandColumn,
3065
+ positionGlobalFilter,
3066
+ positionPagination,
3067
+ positionToolbarAlertBanner,
3068
+ positionToolbarDropZone,
3069
+ rowNumberDisplayMode,
3070
+ rowPinningDisplayMode,
3071
+ selectAllMode,
3072
+ sortFns,
3073
+ ...rest,
3074
+ };
3075
+ };
3076
+
3077
+ const blankColProps = {
3078
+ children: null,
3079
+ style: {
3080
+ minWidth: 0,
3081
+ padding: 0,
3082
+ width: 0,
3083
+ },
3084
+ };
3085
+ const getMRT_RowSpacerColumnDef = (tableOptions) => {
3086
+ return {
3087
+ ...defaultDisplayColumnProps({
3088
+ id: 'mrt-row-spacer',
3089
+ size: 0,
3090
+ tableOptions,
3091
+ }),
3092
+ grow: true,
3093
+ ...MRT_DefaultDisplayColumn,
3094
+ mantineTableBodyCellProps: blankColProps,
3095
+ mantineTableFooterCellProps: blankColProps,
3096
+ mantineTableHeadCellProps: blankColProps,
3097
+ };
3098
+ };
3099
+
3100
+ const useMRT_Effects = (table) => {
3101
+ const { getIsSomeRowsPinned, getPrePaginatedRowModel, state, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3102
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = state;
3103
+ const totalColumnCount = table.options.columns.length;
3104
+ const totalRowCount = rowCount ?? getPrePaginatedRowModel().rows.length;
3105
+ const rerender = useReducer(() => ({}), {})[1];
3106
+ const initialBodyHeight = useRef(undefined);
3107
+ const previousTop = useRef(undefined);
3108
+ useEffect(() => {
3109
+ if (typeof window !== 'undefined') {
3110
+ initialBodyHeight.current = document.body.style.height;
3111
+ }
3112
+ }, []);
3113
+ // hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
3114
+ useEffect(() => {
3115
+ if (typeof window !== 'undefined') {
3116
+ if (isFullScreen) {
3117
+ previousTop.current = document.body.getBoundingClientRect().top; // save scroll position
3118
+ document.body.style.height = '100dvh'; // hide page scrollbars when table is in full screen mode
3119
+ }
3120
+ else {
3121
+ document.body.style.height = initialBodyHeight.current;
3122
+ if (!previousTop.current)
3123
+ return;
3124
+ // restore scroll position
3125
+ window.scrollTo({
3126
+ behavior: 'instant',
3127
+ top: -1 * previousTop.current,
3128
+ });
3129
+ }
3130
+ }
3131
+ }, [isFullScreen]);
3132
+ // recalculate column order when columns change or features are toggled on/off
3133
+ useEffect(() => {
3134
+ if (totalColumnCount !== columnOrder.length) {
3135
+ table.setColumnOrder(getDefaultColumnOrderIds({
3136
+ ...table.options,
3137
+ state,
3138
+ }));
3139
+ }
3140
+ }, [totalColumnCount]);
3141
+ // if page index is out of bounds, set it to the last page
3142
+ useEffect(() => {
3143
+ if (!enablePagination || isLoading || showSkeletons)
3144
+ return;
3145
+ const { pageIndex, pageSize } = pagination;
3146
+ const firstVisibleRowIndex = pageIndex * pageSize;
3147
+ if (firstVisibleRowIndex >= totalRowCount && firstVisibleRowIndex > 0) {
3148
+ table.setPageIndex(Math.ceil(totalRowCount / pageSize) - 1);
3149
+ }
3150
+ }, [totalRowCount]);
3151
+ // turn off sort when global filter is looking for ranked results
3152
+ const appliedSort = useRef(sorting);
3153
+ useEffect(() => {
3154
+ if (sorting.length) {
3155
+ appliedSort.current = sorting;
3156
+ }
3157
+ }, [sorting]);
3158
+ useEffect(() => {
3159
+ if (!getCanRankRows(table))
3160
+ return;
3161
+ if (globalFilter) {
3162
+ table.setSorting([]);
3163
+ }
3164
+ else {
3165
+ table.setSorting(() => appliedSort.current || []);
3166
+ }
3167
+ }, [globalFilter]);
3168
+ // fix pinned row top style when density changes
3169
+ useEffect(() => {
3170
+ if (enableRowPinning && getIsSomeRowsPinned()) {
3171
+ setTimeout(() => {
3172
+ rerender();
3173
+ }, 150);
3174
+ }
3175
+ }, [density]);
3176
+ };
3177
+
3178
+ /**
3179
+ * The MRT hook that wraps the TanStack `useTable` hook and adds MRT-specific
3180
+ * state, refs, and helpers. State management is built on top of TanStack
3181
+ * Store atoms (`useCreateAtom` from `@tanstack/react-store`):
3182
+ *
3183
+ * - **TanStack-aware slices** (`columnOrder`, `columnResizing`, `grouping`,
3184
+ * `pagination`) are passed via the `atoms` option on `useTable`. Library
3185
+ * writes (e.g. `table.setSorting(...)`, `table.firstPage()`) flow directly
3186
+ * through these atoms, and they're automatically tracked in
3187
+ * `table.state` by the v9 store.
3188
+ * - **MRT-only slices** (`density`, `isFullScreen`, `creatingRow`,
3189
+ * `editingCell`, `editingRow`, `draggingColumn`, `draggingRow`,
3190
+ * `hoveredColumn`, `hoveredRow`, `globalFilterFn`, `columnFilterFns`,
3191
+ * `showAlertBanner`, `showColumnFilters`, `showGlobalFilter`,
3192
+ * `showToolbarDropZone`) live in atoms outside the v9 store and are
3193
+ * merged into `table.state` after construction so MRT components can read
3194
+ * them via the same `state` surface.
3195
+ *
3196
+ * @param definedTableOptions - table options with proper defaults set
3197
+ * @returns the MRT table instance
3198
+ */
3199
+ const useMRT_TableInstance = (definedTableOptions) => {
3200
+ const lastSelectedRowId = useRef(null);
3201
+ const bottomToolbarRef = useRef(null);
3202
+ const editInputRefs = useRef({});
3203
+ const filterInputRefs = useRef({});
3204
+ const searchInputRef = useRef(null);
3205
+ const tableContainerRef = useRef(null);
3206
+ const tableHeadCellRefs = useRef({});
3207
+ const tablePaperRef = useRef(null);
3208
+ const topToolbarRef = useRef(null);
3209
+ const tableHeadRef = useRef(null);
3210
+ const tableFooterRef = useRef(null);
3211
+ // transform initial state with proper column order
3212
+ const initialState = useMemo(() => {
3213
+ const initState = definedTableOptions.initialState ?? {};
3214
+ initState.columnOrder =
3215
+ initState.columnOrder ??
3216
+ getDefaultColumnOrderIds({
3217
+ ...definedTableOptions,
3218
+ state: {
3219
+ ...definedTableOptions.initialState,
3220
+ ...definedTableOptions.state,
3221
+ },
3222
+ });
3223
+ initState.globalFilterFn = definedTableOptions.globalFilterFn ?? 'fuzzy';
3224
+ return initState;
3225
+ }, []);
3226
+ definedTableOptions.initialState = initialState;
3227
+ // ---------------------------------------------------------------------------
3228
+ // TanStack-aware atoms (passed to `useTable` via `atoms` option). The library
3229
+ // both reads and writes through these.
3230
+ // ---------------------------------------------------------------------------
3231
+ const columnOrderAtom = useCreateAtom(initialState.columnOrder ?? []);
3232
+ const columnResizingAtom = useCreateAtom(initialState.columnResizing ?? {});
3233
+ const groupingAtom = useCreateAtom(initialState.grouping ?? []);
3234
+ const paginationAtom = useCreateAtom(initialState?.pagination ?? { pageIndex: 0, pageSize: 10 });
3235
+ // Subscribe so the consumer re-renders when these slices change. (The library
3236
+ // also reads from these atoms internally; the subscriptions here are for the
3237
+ // MRT component tree.)
3238
+ const columnOrder = useSelector(columnOrderAtom);
3239
+ const columnResizing = useSelector(columnResizingAtom);
3240
+ const grouping = useSelector(groupingAtom);
3241
+ const pagination = useSelector(paginationAtom);
3242
+ // ---------------------------------------------------------------------------
3243
+ // MRT-only atoms — these slices aren't part of v9's `TableState` so they
3244
+ // can't be passed via the `atoms` option. They're maintained as standalone
3245
+ // atoms and merged into `table.state` after construction.
3246
+ // ---------------------------------------------------------------------------
3247
+ // Build the initial columnFilterFns map from each column's `filterFn` (or
3248
+ // the registered default if none set). Constructed as a plain Record so
3249
+ // `useCreateAtom`'s overload resolves to `Atom<T>` (writable) rather than
3250
+ // the function-style `ReadonlyAtom<T>` overload.
3251
+ const initialColumnFilterFns = {};
3252
+ for (const col of getAllLeafColumnDefs(definedTableOptions.columns)) {
3253
+ initialColumnFilterFns[getColumnId(col)] =
3254
+ col.filterFn instanceof Function
3255
+ ? (col.filterFn.name ?? 'custom')
3256
+ : (col.filterFn ??
3257
+ initialState?.columnFilterFns?.[getColumnId(col)] ??
3258
+ getDefaultColumnFilterFn(col));
3259
+ }
3260
+ const columnFilterFnsAtom = useCreateAtom(initialColumnFilterFns);
3261
+ const creatingRowAtom = useCreateAtom(initialState.creatingRow ?? null);
3262
+ const densityAtom = useCreateAtom(initialState?.density ?? 'md');
3263
+ const draggingColumnAtom = useCreateAtom(initialState.draggingColumn ?? null);
3264
+ const draggingRowAtom = useCreateAtom(initialState.draggingRow ?? null);
3265
+ const editingCellAtom = useCreateAtom(initialState.editingCell ?? null);
3266
+ const editingRowAtom = useCreateAtom(initialState.editingRow ?? null);
3267
+ const globalFilterFnAtom = useCreateAtom(initialState.globalFilterFn ?? 'fuzzy');
3268
+ const hoveredColumnAtom = useCreateAtom(initialState.hoveredColumn ?? null);
3269
+ const hoveredRowAtom = useCreateAtom(initialState.hoveredRow ?? null);
3270
+ const isFullScreenAtom = useCreateAtom(initialState?.isFullScreen ?? false);
3271
+ const showAlertBannerAtom = useCreateAtom(initialState?.showAlertBanner ?? false);
3272
+ const showColumnFiltersAtom = useCreateAtom(initialState?.showColumnFilters ?? false);
3273
+ const showGlobalFilterAtom = useCreateAtom(initialState?.showGlobalFilter ?? false);
3274
+ const showToolbarDropZoneAtom = useCreateAtom(initialState?.showToolbarDropZone ?? false);
3275
+ const columnFilterFns = useSelector(columnFilterFnsAtom);
3276
+ const creatingRow = useSelector(creatingRowAtom);
3277
+ const density = useSelector(densityAtom);
3278
+ const draggingColumn = useSelector(draggingColumnAtom);
3279
+ const draggingRow = useSelector(draggingRowAtom);
3280
+ const editingCell = useSelector(editingCellAtom);
3281
+ const editingRow = useSelector(editingRowAtom);
3282
+ const globalFilterFn = useSelector(globalFilterFnAtom);
3283
+ const hoveredColumn = useSelector(hoveredColumnAtom);
3284
+ const hoveredRow = useSelector(hoveredRowAtom);
3285
+ const isFullScreen = useSelector(isFullScreenAtom);
3286
+ const showAlertBanner = useSelector(showAlertBannerAtom);
3287
+ const showColumnFilters = useSelector(showColumnFiltersAtom);
3288
+ const showGlobalFilter = useSelector(showGlobalFilterAtom);
3289
+ const showToolbarDropZone = useSelector(showToolbarDropZoneAtom);
3290
+ // Mirror values into options.state so utilities that read
3291
+ // `tableOptions.state.X` (e.g. column prep, display-column factories) keep
3292
+ // working. The user can still override individual slices by setting
3293
+ // `definedTableOptions.state` from outside.
3294
+ definedTableOptions.state = {
3295
+ columnFilterFns,
3296
+ columnOrder,
3297
+ columnResizing,
3298
+ creatingRow,
3299
+ density,
3300
+ draggingColumn,
3301
+ draggingRow,
3302
+ editingCell,
3303
+ editingRow,
3304
+ globalFilterFn,
3305
+ grouping,
3306
+ hoveredColumn,
3307
+ hoveredRow,
3308
+ isFullScreen,
3309
+ pagination,
3310
+ showAlertBanner,
3311
+ showColumnFilters,
3312
+ showGlobalFilter,
3313
+ showToolbarDropZone,
3314
+ ...definedTableOptions.state,
3315
+ };
3316
+ // The table options now include all state needed to help determine column visibility and order logic
3317
+ const statefulTableOptions = definedTableOptions;
3318
+ // Column preparation mutates/augments definitions and must rerun when an
3319
+ // input that affects those definitions changes. Keep the resulting array
3320
+ // stable across unrelated state updates such as pagination.
3321
+ const columnDefsRef = useRef([]);
3322
+ const columnPreparationDepsRef = useRef(undefined);
3323
+ const sourceColumns = statefulTableOptions.columns;
3324
+ const columnPreparationDeps = [
3325
+ sourceColumns,
3326
+ statefulTableOptions.defaultColumn,
3327
+ statefulTableOptions.defaultDisplayColumn,
3328
+ statefulTableOptions.displayColumnDefOptions,
3329
+ statefulTableOptions.filterFns,
3330
+ statefulTableOptions.sortFns,
3331
+ statefulTableOptions.localization,
3332
+ statefulTableOptions.state.columnFilterFns,
3333
+ statefulTableOptions.state.creatingRow,
3334
+ statefulTableOptions.state.grouping,
3335
+ statefulTableOptions.createDisplayMode,
3336
+ statefulTableOptions.editDisplayMode,
3337
+ statefulTableOptions.enableEditing,
3338
+ statefulTableOptions.enableExpandAll,
3339
+ statefulTableOptions.enableExpanding,
3340
+ statefulTableOptions.enableGrouping,
3341
+ statefulTableOptions.enableMultiRowSelection,
3342
+ statefulTableOptions.enableRowActions,
3343
+ statefulTableOptions.enableRowDragging,
3344
+ statefulTableOptions.enableRowNumbers,
3345
+ statefulTableOptions.enableRowOrdering,
3346
+ statefulTableOptions.enableRowPinning,
3347
+ statefulTableOptions.enableRowSelection,
3348
+ statefulTableOptions.enableSelectAll,
3349
+ statefulTableOptions.groupedColumnMode,
3350
+ statefulTableOptions.layoutMode,
3351
+ statefulTableOptions.positionExpandColumn,
3352
+ statefulTableOptions.renderDetailPanel,
3353
+ statefulTableOptions.rowNumberDisplayMode,
3354
+ statefulTableOptions.rowPinningDisplayMode,
3355
+ ];
3356
+ const previousColumnPreparationDeps = columnPreparationDepsRef.current;
3357
+ const columnPreparationChanged = !previousColumnPreparationDeps ||
3358
+ columnPreparationDeps.length !== previousColumnPreparationDeps.length ||
3359
+ columnPreparationDeps.some((dependency, index) => !Object.is(dependency, previousColumnPreparationDeps[index]));
3360
+ const freezePreparedColumns = !!columnDefsRef.current.length &&
3361
+ (statefulTableOptions.state.columnResizing.isResizingColumn ||
3362
+ !!statefulTableOptions.state.draggingColumn ||
3363
+ !!statefulTableOptions.state.draggingRow);
3364
+ if (columnPreparationChanged && !freezePreparedColumns) {
3365
+ columnDefsRef.current = prepareColumns({
3366
+ columnDefs: [
3367
+ ...[
3368
+ showRowPinningColumn(statefulTableOptions) &&
3369
+ getMRT_RowPinningColumnDef(statefulTableOptions),
3370
+ showRowDragColumn(statefulTableOptions) &&
3371
+ getMRT_RowDragColumnDef(statefulTableOptions),
3372
+ showRowActionsColumn(statefulTableOptions) &&
3373
+ getMRT_RowActionsColumnDef(statefulTableOptions),
3374
+ showRowExpandColumn(statefulTableOptions) &&
3375
+ getMRT_RowExpandColumnDef(statefulTableOptions),
3376
+ showRowSelectionColumn(statefulTableOptions) &&
3377
+ getMRT_RowSelectColumnDef(statefulTableOptions),
3378
+ showRowNumbersColumn(statefulTableOptions) &&
3379
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
3380
+ ].filter(Boolean),
3381
+ ...sourceColumns,
3382
+ ...[
3383
+ showRowSpacerColumn(statefulTableOptions) &&
3384
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
3385
+ ].filter(Boolean),
3386
+ ],
3387
+ tableOptions: statefulTableOptions,
3388
+ });
3389
+ columnPreparationDepsRef.current = columnPreparationDeps;
3390
+ }
3391
+ statefulTableOptions.columns = columnDefsRef.current;
3392
+ // if loading, generate blank rows to show skeleton loaders
3393
+ statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
3394
+ statefulTableOptions.state.showSkeletons) &&
3395
+ !statefulTableOptions.data.length
3396
+ ? [
3397
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
3398
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
3399
+ [getColumnId(col)]: null,
3400
+ }))))
3401
+ : statefulTableOptions.data, [
3402
+ statefulTableOptions.data,
3403
+ statefulTableOptions.state.isLoading,
3404
+ statefulTableOptions.state.showSkeletons,
3405
+ ]);
3406
+ const table = useTable({
3407
+ ...statefulTableOptions,
3408
+ globalFilterFn: (globalFilterFn ?? 'fuzzy'),
3409
+ // Hand TanStack-aware slices over to our external atoms — library writes
3410
+ // (e.g. `table.setPageIndex(...)`, drag-resize) flow straight into them.
3411
+ atoms: {
3412
+ columnOrder: columnOrderAtom,
3413
+ columnResizing: columnResizingAtom,
3414
+ grouping: groupingAtom,
3415
+ pagination: paginationAtom,
3416
+ },
3417
+ }, (state) => state);
3418
+ // v9 spells the resize setter `setcolumnResizing` (lowercase 'c') because
3419
+ // it's auto-generated from the state-key name. Expose a camelCase alias so
3420
+ // MRT consumers don't need to know about that quirk; route writes through
3421
+ // our owned atom directly.
3422
+ table.setColumnResizing = columnResizingAtom.set;
3423
+ // The v9 store doesn't track MRT-only slices, so `table.state` is missing
3424
+ // them after `useTable` returns. Patch them in here so all MRT components
3425
+ // can read `table.state.density`, `table.state.isFullScreen`, etc.
3426
+ table.state = {
3427
+ ...table.state,
3428
+ columnFilterFns,
3429
+ creatingRow,
3430
+ density,
3431
+ draggingColumn,
3432
+ draggingRow,
3433
+ editingCell,
3434
+ editingRow,
3435
+ globalFilterFn,
3436
+ hoveredColumn,
3437
+ hoveredRow,
3438
+ isFullScreen,
3439
+ showAlertBanner,
3440
+ showColumnFilters,
3441
+ showGlobalFilter,
3442
+ showToolbarDropZone,
3443
+ };
3444
+ // v8-style `getState()` alias for any consumer that still calls it.
3445
+ table.getState = () => table.state;
3446
+ table.refs = {
3447
+ bottomToolbarRef,
3448
+ editInputRefs,
3449
+ filterInputRefs,
3450
+ lastSelectedRowId,
3451
+ searchInputRef,
3452
+ tableContainerRef,
3453
+ tableFooterRef,
3454
+ tableHeadCellRefs,
3455
+ tableHeadRef,
3456
+ tablePaperRef,
3457
+ topToolbarRef,
3458
+ };
3459
+ // Setters write through atom.set (or call the user-supplied on*Change
3460
+ // handler if one was provided so external state ownership still works).
3461
+ // The `as any` casts bridge atom.set's overloaded signature with React's
3462
+ // `Dispatch<SetStateAction<T>>` shape — the runtime contract is identical
3463
+ // (both accept a value or an updater function).
3464
+ table.setCreatingRow = (row) => {
3465
+ let _row = row;
3466
+ if (row === true) {
3467
+ _row = createRow(table);
3468
+ }
3469
+ if (statefulTableOptions?.onCreatingRowChange) {
3470
+ statefulTableOptions.onCreatingRowChange(_row);
3471
+ }
3472
+ else {
3473
+ creatingRowAtom.set(_row);
3474
+ }
3475
+ };
3476
+ table.setColumnFilterFns = (statefulTableOptions.onColumnFilterFnsChange ??
3477
+ columnFilterFnsAtom.set);
3478
+ table.setDensity = (statefulTableOptions.onDensityChange ??
3479
+ densityAtom.set);
3480
+ table.setDraggingColumn = (statefulTableOptions.onDraggingColumnChange ??
3481
+ draggingColumnAtom.set);
3482
+ table.setDraggingRow = (statefulTableOptions.onDraggingRowChange ??
3483
+ draggingRowAtom.set);
3484
+ table.setEditingCell = (statefulTableOptions.onEditingCellChange ??
3485
+ editingCellAtom.set);
3486
+ table.setEditingRow = (statefulTableOptions.onEditingRowChange ??
3487
+ editingRowAtom.set);
3488
+ table.setGlobalFilterFn = (statefulTableOptions.onGlobalFilterFnChange ??
3489
+ globalFilterFnAtom.set);
3490
+ table.setHoveredColumn = (statefulTableOptions.onHoveredColumnChange ??
3491
+ hoveredColumnAtom.set);
3492
+ table.setHoveredRow = (statefulTableOptions.onHoveredRowChange ??
3493
+ hoveredRowAtom.set);
3494
+ table.setIsFullScreen = (statefulTableOptions.onIsFullScreenChange ??
3495
+ isFullScreenAtom.set);
3496
+ table.setShowAlertBanner = (statefulTableOptions.onShowAlertBannerChange ??
3497
+ showAlertBannerAtom.set);
3498
+ table.setShowColumnFilters =
3499
+ (statefulTableOptions.onShowColumnFiltersChange ??
3500
+ showColumnFiltersAtom.set);
3501
+ table.setShowGlobalFilter = (statefulTableOptions.onShowGlobalFilterChange ??
3502
+ showGlobalFilterAtom.set);
3503
+ table.setShowToolbarDropZone =
3504
+ (statefulTableOptions.onShowToolbarDropZoneChange ??
3505
+ showToolbarDropZoneAtom.set);
3506
+ useMRT_Effects(table);
3507
+ return table;
3508
+ };
3509
+
3510
+ const useMantineReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
3511
+
3512
+ var commonClasses = {"common-toolbar-styles":"common-styles-module_common-toolbar-styles__DnjR8"};
3513
+
3514
+ var classes$8 = {"root":"MRT_BottomToolbar-module_root__VDeWo","root-fullscreen":"MRT_BottomToolbar-module_root-fullscreen__esE15","custom-toolbar-container":"MRT_BottomToolbar-module_custom-toolbar-container__XcDRF","paginator-container":"MRT_BottomToolbar-module_paginator-container__A3eWY","paginator-container-alert-banner":"MRT_BottomToolbar-module_paginator-container-alert-banner__gyqtO"};
3515
+
3516
+ var classes$7 = {"collapse":"MRT_ProgressBar-module_collapse__rOLJH","collapse-top":"MRT_ProgressBar-module_collapse-top__oCi0h"};
3517
+
3518
+ const MRT_ProgressBar = ({ isTopToolbar, table, ...rest }) => {
3519
+ const { state, options: { mantineProgressProps }, } = table;
3520
+ const { isSaving, showProgressBars } = state;
3521
+ const linearProgressProps = {
3522
+ ...parseFromValuesOrFunc(mantineProgressProps, {
3523
+ isTopToolbar,
3524
+ table,
3525
+ }),
3526
+ ...rest,
3527
+ };
3528
+ return (jsx(Collapse, { className: clsx(classes$7.collapse, isTopToolbar && classes$7['collapse-top']), expanded: isSaving || showProgressBars, children: jsx(Progress, { animated: true, "aria-busy": "true", "aria-label": "Loading", radius: 0, value: 100, ...linearProgressProps }) }));
3529
+ };
3530
+
3531
+ var classes$6 = {"root":"MRT_TablePagination-module_root__yZ8pm","pagesize":"MRT_TablePagination-module_pagesize__-vmTn","with-top-margin":"MRT_TablePagination-module_with-top-margin__aM5-m"};
3532
+
3533
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100].map((x) => x.toString());
3534
+ const MRT_TablePagination = ({ position = 'bottom', table, ...props }) => {
3535
+ const { getPrePaginatedRowModel, state, options: { enableToolbarInternalActions, icons: { IconChevronLeft, IconChevronLeftPipe, IconChevronRight, IconChevronRightPipe, }, localization, mantinePaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
3536
+ const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = state;
3537
+ const paginationProps = {
3538
+ ...parseFromValuesOrFunc(mantinePaginationProps, {
3539
+ table,
3540
+ }),
3541
+ ...props,
3542
+ };
3543
+ const totalRowCount = rowCount ?? getPrePaginatedRowModel().rows.length;
3544
+ const numberOfPages = Math.ceil(totalRowCount / pageSize);
3545
+ const showFirstLastPageButtons = numberOfPages > 2;
3546
+ const firstRowIndex = pageIndex * pageSize;
3547
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3548
+ const { rowsPerPageOptions = defaultRowsPerPage, showRowsPerPage = true, withEdges = showFirstLastPageButtons, ...rest } = paginationProps ?? {};
3549
+ const needsTopMargin = position === 'top' && enableToolbarInternalActions && !showGlobalFilter;
3550
+ return (jsxs(Box, { className: clsx('mrt-table-pagination', classes$6.root, needsTopMargin && classes$6['with-top-margin']), children: [paginationProps?.showRowsPerPage !== false && (jsxs(Group, { gap: "xs", children: [jsx(Text, { id: "rpp-label", children: localization.rowsPerPage }), jsx(Select, { allowDeselect: false, "aria-labelledby": "rpp-label", className: classes$6.pagesize, data: paginationProps?.rowsPerPageOptions ?? defaultRowsPerPage, onChange: (value) => setPageSize(+value), value: pageSize.toString() })] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, { firstIcon: IconChevronLeftPipe, lastIcon: IconChevronRightPipe, nextIcon: IconChevronRight, onChange: (newPageIndex) => setPageIndex(newPageIndex - 1), previousIcon: IconChevronLeft, total: numberOfPages, value: pageIndex + 1, withEdges: withEdges, ...rest })) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Text, { children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Group, { gap: 6, children: [withEdges && (jsx(ActionIcon, { "aria-label": localization.goToFirstPage, color: "gray", disabled: pageIndex <= 0, onClick: () => setPageIndex(0), variant: "subtle", children: jsx(IconChevronLeftPipe, {}) })), jsx(ActionIcon, { "aria-label": localization.goToPreviousPage, color: "gray", disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), variant: "subtle", children: jsx(IconChevronLeft, {}) }), jsx(ActionIcon, { "aria-label": localization.goToNextPage, color: "gray", disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), variant: "subtle", children: jsx(IconChevronRight, {}) }), withEdges && (jsx(ActionIcon, { "aria-label": localization.goToLastPage, color: "gray", disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), variant: "subtle", children: jsx(IconChevronRightPipe, {}) }))] })] })) : null] }));
3551
+ };
3552
+
3553
+ var classes$5 = {"root":"MRT_ToolbarDropZone-module_root__eGTXb","hovered":"MRT_ToolbarDropZone-module_hovered__g7PeJ"};
3554
+
3555
+ const MRT_ToolbarDropZone = ({ table, ...rest }) => {
3556
+ const { state, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
3557
+ const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = state;
3558
+ const handleDragEnter = (_event) => {
3559
+ setHoveredColumn({ id: 'drop-zone' });
3560
+ };
3561
+ useEffect(() => {
3562
+ if (table.options.state?.showToolbarDropZone !== undefined) {
3563
+ setShowToolbarDropZone(!!enableGrouping &&
3564
+ !!draggingColumn &&
3565
+ draggingColumn.columnDef.enableGrouping !== false &&
3566
+ !grouping.includes(draggingColumn.id));
3567
+ }
3568
+ }, [enableGrouping, draggingColumn, grouping]);
3569
+ return (jsx(Transition, { mounted: showToolbarDropZone, transition: "fade", children: () => (jsx(Flex, { className: clsx('mrt-toolbar-dropzone', classes$5.root, hoveredColumn?.id === 'drop-zone' && classes$5.hovered), onDragEnter: handleDragEnter, ...rest, children: jsx(Text, { children: localization.dropToGroupBy.replace('{column}', draggingColumn?.columnDef?.header ?? '') }) })) }));
3570
+ };
3571
+
3572
+ const MRT_BottomToolbar = ({ table, ...rest }) => {
3573
+ const { state, options: { enablePagination, mantineBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
3574
+ const { isFullScreen } = state;
3575
+ const isMobile = useMediaQuery('(max-width: 720px)');
3576
+ const toolbarProps = {
3577
+ ...parseFromValuesOrFunc(mantineBottomToolbarProps, {
3578
+ table,
3579
+ }),
3580
+ ...rest,
3581
+ };
3582
+ const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
3583
+ return (jsxs(Box, { ...toolbarProps, className: clsx('mrt-bottom-toolbar', classes$8.root, commonClasses['common-toolbar-styles'], isFullScreen && classes$8['root-fullscreen'], toolbarProps?.className), ref: (node) => {
3584
+ if (node) {
3585
+ bottomToolbarRef.current = node;
3586
+ if (toolbarProps?.ref) {
3587
+ toolbarProps.ref.current = node;
3588
+ }
3589
+ }
3590
+ }, children: [jsx(MRT_ProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone ?? '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { className: classes$8['custom-toolbar-container'], children: [renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (jsx("span", {})), jsx(Box, { className: clsx(classes$8['paginator-container'], stackAlertBanner && classes$8['paginator-container-alert-banner']), children: enablePagination &&
3591
+ ['both', 'bottom'].includes(positionPagination ?? '') && (jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] }));
3592
+ };
3593
+
3594
+ var classes$4 = {"root":"MRT_TopToolbar-module_root__r4-V9","root-fullscreen":"MRT_TopToolbar-module_root-fullscreen__3itT8","actions-container":"MRT_TopToolbar-module_actions-container__-uL0u","actions-container-stack-alert":"MRT_TopToolbar-module_actions-container-stack-alert__OYDL6"};
3595
+
3596
+ var classes$3 = {"root":"MRT_ToolbarInternalButtons-module_root__NKoUG"};
3597
+
3598
+ const MRT_ToolbarInternalButtons = ({ table, ...rest }) => {
3599
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
3600
+ return (jsx(Flex, { ...rest, className: clsx('mrt-toolbar-internal-buttons', classes$3.root, rest?.className), children: renderToolbarInternalActions?.({ table }) ?? (jsxs(Fragment, { children: [enableFilters &&
3601
+ enableGlobalFilter &&
3602
+ !initialState?.showGlobalFilter && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
3603
+ enableColumnFilters &&
3604
+ columnFilterDisplayMode !== 'popover' && (jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsx(MRT_ToggleFullScreenButton, { table: table }))] })) }));
3605
+ };
3606
+
3607
+ const MRT_TopToolbar = ({ table, ...rest }) => {
3608
+ const { state, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, mantineTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
3609
+ const { isFullScreen, showGlobalFilter } = state;
3610
+ const isMobile = useMediaQuery('(max-width:720px)');
3611
+ const isTablet = useMediaQuery('(max-width:1024px)');
3612
+ const toolbarProps = {
3613
+ ...parseFromValuesOrFunc(mantineTopToolbarProps, { table }),
3614
+ ...rest,
3615
+ };
3616
+ const stackAlertBanner = isMobile ||
3617
+ !!renderTopToolbarCustomActions ||
3618
+ (showGlobalFilter && isTablet);
3619
+ const globalFilterProps = {
3620
+ style: !isTablet
3621
+ ? {
3622
+ zIndex: 3,
3623
+ }
3624
+ : undefined,
3625
+ table,
3626
+ };
3627
+ return (jsxs(Box, { ...toolbarProps, className: clsx(commonClasses['common-toolbar-styles'], classes$4['root'], isFullScreen && classes$4['root-fullscreen'], toolbarProps?.className), ref: (node) => {
3628
+ if (node) {
3629
+ topToolbarRef.current = node;
3630
+ if (toolbarProps?.ref) {
3631
+ toolbarProps.ref.current = node;
3632
+ }
3633
+ }
3634
+ }, children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone ?? '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Flex, { className: clsx(classes$4['actions-container'], stackAlertBanner && classes$4['actions-container-stack-alert']), children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextInput, { ...globalFilterProps })), renderTopToolbarCustomActions?.({ table }) ?? jsx("span", {}), enableToolbarInternalActions ? (jsxs(Flex, { justify: 'end', wrap: 'wrap-reverse', children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextInput, { ...globalFilterProps })), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3635
+ positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextInput, { ...globalFilterProps })))] }), enablePagination &&
3636
+ ['both', 'top'].includes(positionPagination ?? '') && (jsx(Flex, { justify: "end", children: jsx(MRT_TablePagination, { position: "top", table: table }) })), jsx(MRT_ProgressBar, { isTopToolbar: true, table: table })] }));
3637
+ };
3638
+
3639
+ const MRT_EditRowModal = ({ open, table, ...rest }) => {
3640
+ const { state, options: { mantineCreateRowModalProps, mantineEditRowModalProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowModalContent, renderEditRowModalContent, }, setCreatingRow, setEditingRow, } = table;
3641
+ const { creatingRow, editingRow } = state;
3642
+ const row = (creatingRow ?? editingRow);
3643
+ const arg = { row, table };
3644
+ const modalProps = {
3645
+ ...parseFromValuesOrFunc(mantineEditRowModalProps, arg),
3646
+ ...(creatingRow && parseFromValuesOrFunc(mantineCreateRowModalProps, arg)),
3647
+ ...rest,
3648
+ };
3649
+ const internalEditComponents = row
3650
+ .getAllCells()
3651
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3652
+ .map((cell) => (jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
3653
+ const handleCancel = () => {
3654
+ if (creatingRow) {
3655
+ onCreatingRowCancel?.({ row, table });
3656
+ setCreatingRow(null);
3657
+ }
3658
+ else {
3659
+ onEditingRowCancel?.({ row, table });
3660
+ setEditingRow(null);
3661
+ }
3662
+ row._valuesCache = {}; // reset values cache
3663
+ modalProps.onClose?.();
3664
+ };
3665
+ return (createElement(Modal, { opened: open, withCloseButton: false, ...modalProps, key: row.id, onClose: handleCancel }, ((creatingRow &&
3666
+ renderCreateRowModalContent?.({
3667
+ internalEditComponents,
3668
+ row,
3669
+ table,
3670
+ })) ||
3671
+ renderEditRowModalContent?.({
3672
+ internalEditComponents,
3673
+ row,
3674
+ table,
3675
+ })) ?? (jsxs(Fragment, { children: [jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsx(Stack, { gap: "lg", pb: 24, pt: 16, children: internalEditComponents }) }), jsx(Flex, { justify: "flex-end", children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] }))));
3676
+ };
3677
+
3678
+ const useMRT_ColumnVirtualizer = (table) => {
3679
+ const { getStartLeafColumns, getEndLeafColumns, state, getVisibleLeafColumns, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
3680
+ const { columnPinning, draggingColumn } = state;
3681
+ if (!enableColumnVirtualization)
3682
+ return undefined;
3683
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
3684
+ table,
3685
+ });
3686
+ const visibleColumns = getVisibleLeafColumns();
3687
+ const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnPinning
3688
+ ? [
3689
+ getStartLeafColumns().map((c) => c.getPinnedIndex()),
3690
+ getEndLeafColumns()
3691
+ .map((column) => visibleColumns.length - column.getPinnedIndex() - 1)
3692
+ .sort((a, b) => a - b),
3693
+ ]
3694
+ : [[], []], [visibleColumns.length, columnPinning, enableColumnPinning]);
3695
+ const numPinnedLeft = leftPinnedIndexes.length;
3696
+ const numPinnedRight = rightPinnedIndexes.length;
3697
+ const draggingColumnIndex = useMemo(() => draggingColumn?.id
3698
+ ? visibleColumns.findIndex((c) => c.id === draggingColumn?.id)
3699
+ : undefined, [draggingColumn?.id]);
3700
+ const columnVirtualizer = useVirtualizer({
3701
+ count: visibleColumns.length,
3702
+ estimateSize: (index) => visibleColumns[index].getSize(),
3703
+ getScrollElement: () => tableContainerRef.current,
3704
+ horizontal: true,
3705
+ overscan: 3,
3706
+ rangeExtractor: useCallback((range) => {
3707
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
3708
+ if (!numPinnedLeft && !numPinnedRight) {
3709
+ return newIndexes;
3710
+ }
3711
+ return [
3712
+ ...new Set([
3713
+ ...leftPinnedIndexes,
3714
+ ...newIndexes,
3715
+ ...rightPinnedIndexes,
3716
+ ]),
3717
+ ];
3718
+ }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]),
3719
+ ...columnVirtualizerProps,
3720
+ });
3721
+ const virtualColumns = columnVirtualizer.getVirtualItems();
3722
+ columnVirtualizer.virtualColumns = virtualColumns;
3723
+ const numColumns = virtualColumns.length;
3724
+ if (numColumns) {
3725
+ const totalSize = columnVirtualizer.getTotalSize();
3726
+ const leftNonPinnedStart = virtualColumns[numPinnedLeft]?.start || 0;
3727
+ const leftNonPinnedEnd = virtualColumns[leftPinnedIndexes.length - 1]?.end || 0;
3728
+ const rightNonPinnedStart = virtualColumns[numColumns - numPinnedRight]?.start || 0;
3729
+ const rightNonPinnedEnd = virtualColumns[numColumns - numPinnedRight - 1]?.end || 0;
3730
+ columnVirtualizer.virtualPaddingLeft = leftNonPinnedStart - leftNonPinnedEnd;
3731
+ columnVirtualizer.virtualPaddingRight =
3732
+ totalSize -
3733
+ rightNonPinnedEnd -
3734
+ (numPinnedRight ? totalSize - rightNonPinnedStart : 0);
3735
+ }
3736
+ if (columnVirtualizerInstanceRef) {
3737
+ // @ts-ignore - TODO: fix this
3738
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
3739
+ }
3740
+ return columnVirtualizer;
3741
+ };
3742
+
3743
+ var classes$2 = {"root":"MRT_Table-module_root__ms2uS","root-grid":"MRT_Table-module_root-grid__2Pynz"};
3744
+
3745
+ const MRT_Table = ({ table, ...rest }) => {
3746
+ const { getFlatHeaders, state, options: { columns, enableTableFooter, enableTableHead, layoutMode, mantineTableProps, memoMode, }, } = table;
3747
+ const { columnSizing, columnResizing, columnVisibility, density } = state;
3748
+ const tableProps = {
3749
+ highlightOnHover: true,
3750
+ horizontalSpacing: density,
3751
+ verticalSpacing: density,
3752
+ ...parseFromValuesOrFunc(mantineTableProps, { table }),
3753
+ ...rest,
3754
+ };
3755
+ const columnSizeVars = useMemo(() => {
3756
+ const headers = getFlatHeaders();
3757
+ const colSizes = {};
3758
+ for (let i = 0; i < headers.length; i++) {
3759
+ const header = headers[i];
3760
+ const colSize = header.getSize();
3761
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
3762
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
3763
+ }
3764
+ return colSizes;
3765
+ }, [columns, columnSizing, columnResizing, columnVisibility]);
3766
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3767
+ const commonTableGroupProps = {
3768
+ columnVirtualizer,
3769
+ table,
3770
+ };
3771
+ const { colorScheme } = useMantineColorScheme();
3772
+ const { stripedColor } = tableProps;
3773
+ return (jsxs(Table, { className: clsx('mrt-table', classes$2.root, layoutMode?.startsWith('grid') && classes$2['root-grid'], tableProps.className), ...tableProps, __vars: {
3774
+ ...columnSizeVars,
3775
+ '--mrt-striped-row-background-color': stripedColor,
3776
+ '--mrt-striped-row-hover-background-color': stripedColor
3777
+ ? colorScheme === 'dark'
3778
+ ? lighten(stripedColor, 0.08)
3779
+ : darken(stripedColor, 0.12)
3780
+ : undefined,
3781
+ ...tableProps.__vars,
3782
+ }, children: [enableTableHead && jsx(MRT_TableHead, { ...commonTableGroupProps }), memoMode === 'table-body' || columnResizing.isResizingColumn ? (jsx(Memo_MRT_TableBody, { ...commonTableGroupProps, tableProps: tableProps })) : (jsx(MRT_TableBody, { ...commonTableGroupProps, tableProps: tableProps })), enableTableFooter && jsx(MRT_TableFooter, { ...commonTableGroupProps })] }));
3783
+ };
3784
+
3785
+ var classes$1 = {"root":"MRT_TableContainer-module_root__JIsGB","root-sticky":"MRT_TableContainer-module_root-sticky__uC4qx","root-fullscreen":"MRT_TableContainer-module_root-fullscreen__aM8Jg"};
3786
+
3787
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3788
+ const MRT_TableContainer = ({ table, ...rest }) => {
3789
+ const { state, options: { createDisplayMode, editDisplayMode, enableStickyHeader, mantineLoadingOverlayProps, mantineTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3790
+ const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = state;
3791
+ const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3792
+ const tableContainerProps = {
3793
+ ...parseFromValuesOrFunc(mantineTableContainerProps, { table }),
3794
+ ...rest,
3795
+ };
3796
+ const loadingOverlayProps = parseFromValuesOrFunc(mantineLoadingOverlayProps, { table });
3797
+ useIsomorphicLayoutEffect(() => {
3798
+ const topToolbarHeight = typeof document !== 'undefined'
3799
+ ? (topToolbarRef.current?.offsetHeight ?? 0)
3800
+ : 0;
3801
+ const bottomToolbarHeight = typeof document !== 'undefined'
3802
+ ? (bottomToolbarRef?.current?.offsetHeight ?? 0)
3803
+ : 0;
3804
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
3805
+ });
3806
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3807
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
3808
+ return (jsxs(Box, { ...tableContainerProps, __vars: {
3809
+ '--mrt-top-toolbar-height': `${totalToolbarHeight}`,
3810
+ ...tableContainerProps?.__vars,
3811
+ }, className: clsx('mrt-table-container', classes$1.root, enableStickyHeader && classes$1['root-sticky'], isFullScreen && classes$1['root-fullscreen'], tableContainerProps?.className), ref: (node) => {
3812
+ if (node) {
3813
+ tableContainerRef.current = node;
3814
+ if (tableContainerProps?.ref) {
3815
+ // @ts-ignore
3816
+ tableContainerProps.ref.current = node;
3817
+ }
3818
+ }
3819
+ }, children: [jsx(LoadingOverlay, { visible: isLoading || showLoadingOverlay, zIndex: 2, ...loadingOverlayProps }), jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table }))] }));
3820
+ };
3821
+
3822
+ var classes = {"root":"MRT_TablePaper-module_root__q0v5L"};
3823
+
3824
+ const MRT_TablePaper = ({ table, ...rest }) => {
3825
+ const { state, options: { enableBottomToolbar, enableTopToolbar, mantinePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
3826
+ const { isFullScreen } = state;
3827
+ const tablePaperProps = {
3828
+ ...parseFromValuesOrFunc(mantinePaperProps, { table }),
3829
+ ...rest,
3830
+ };
3831
+ return (jsxs(Paper, { shadow: "xs", withBorder: true, ...tablePaperProps, className: clsx('mrt-table-paper', classes.root, isFullScreen && 'mrt-table-paper-fullscreen', tablePaperProps?.className), ref: (ref) => {
3832
+ tablePaperRef.current = ref;
3833
+ if (tablePaperProps?.ref) {
3834
+ tablePaperProps.ref.current = ref;
3835
+ }
3836
+ },
3837
+ // rare case where we should use inline styles to guarantee highest specificity
3838
+ style: (theme) => ({
3839
+ zIndex: isFullScreen ? 200 : undefined,
3840
+ ...parseFromValuesOrFunc(tablePaperProps?.style, theme),
3841
+ ...(isFullScreen
3842
+ ? {
3843
+ border: 0,
3844
+ borderRadius: 0,
3845
+ bottom: 0,
3846
+ height: '100vh',
3847
+ left: 0,
3848
+ margin: 0,
3849
+ maxHeight: '100vh',
3850
+ maxWidth: '100vw',
3851
+ padding: 0,
3852
+ position: 'fixed',
3853
+ right: 0,
3854
+ top: 0,
3855
+ width: '100vw',
3856
+ }
3857
+ : null),
3858
+ }), children: [enableTopToolbar &&
3859
+ (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
3860
+ (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? (jsx(MRT_BottomToolbar, { table: table })))] }));
3861
+ };
3862
+
3863
+ const isTableInstanceProp = (props) => props.table !== undefined;
3864
+ const MantineReactTable = (props) => {
3865
+ let table;
3866
+ if (isTableInstanceProp(props)) {
3867
+ table = props.table;
3868
+ }
3869
+ else {
3870
+ table = useMantineReactTable(props);
3871
+ }
3872
+ return jsx(MRT_TablePaper, { table: table });
3873
+ };
3874
+
3875
+ export { MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextInput, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextInput, MRT_GlobalFilterTextInput, MRT_GrabHandleButton, MRT_ProgressBar, MRT_RowActionMenu, MRT_RowAggregationFns, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyEmptyRow, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MantineReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, dataVariable, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getPrimaryColor, getPrimaryShade, getTrailingDisplayColumnIds, localizedFilterOption, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMantineReactTable };
3876
+ //# sourceMappingURL=index.js.map