@hillac/mantine-react-table 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -21
- package/UPSTREAM.md +7 -5
- package/dist/index.d.ts +32 -30
- package/dist/index.js +112 -28
- package/dist/index.js.map +1 -1
- package/package.json +45 -32
- package/styles.css +346 -365
package/README.md
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mantine React Table
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
TanStack Table
|
|
3
|
+
This repository owns and publishes `@hillac/mantine-react-table`, a Mantine 9
|
|
4
|
+
and TanStack Table 9 port of the Mantine React Table example maintained in
|
|
5
|
+
`TanStack/table`.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
See the [migration guide](https://github.com/TanStack/table/blob/290284f29867021c77afbdd02c05f16f862cb509/examples/react/mantine-react-table/README.md)
|
|
8
|
+
when upgrading from the original `mantine-react-table` v2 package.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
The package source is checked into `src/` and is edited directly. See
|
|
11
|
+
[`UPSTREAM.md`](./UPSTREAM.md) for the pinned upstream revision.
|
|
12
|
+
|
|
13
|
+
## Development
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
|
-
|
|
16
|
+
pnpm install
|
|
17
|
+
pnpm demo
|
|
18
|
+
pnpm typecheck
|
|
19
|
+
pnpm build
|
|
20
|
+
pnpm test:e2e
|
|
21
|
+
pnpm validate
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
The playground includes asynchronous mock data, client and mock-server
|
|
25
|
+
filtering/sorting, numeric and date ranges, pagination, infinite scrolling, URL
|
|
26
|
+
state, configurable latency, loading skeletons, and error banners.
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
MantineReactTable,
|
|
20
|
-
createMRTColumnHelper,
|
|
21
|
-
useMantineReactTable,
|
|
22
|
-
} from '@hillac/mantine-react-table'
|
|
28
|
+
## Consuming the package
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add @hillac/mantine-react-table
|
|
25
32
|
```
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import '@mantine/core/styles.css'
|
|
31
|
-
import '@mantine/dates/styles.css'
|
|
32
|
-
```
|
|
34
|
+
The package can also be aliased as `mantine-react-table` in a consumer's
|
|
35
|
+
`package.json`.
|
package/UPSTREAM.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Upstream source
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- Commit: `36733a38b6a77878eea616b25012c47a0f93d4da`
|
|
3
|
+
The implementation in `src/` was copied from the Mantine React Table example in
|
|
4
|
+
[`TanStack/table`](https://github.com/TanStack/table/tree/c14e0221b1e656c7bb35e7b3d4cdf188719a3599/examples/react/mantine-react-table/src/mantine-react-table)
|
|
5
|
+
at revision `c14e0221b1e656c7bb35e7b3d4cdf188719a3599`.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
The former publisher patches were applied before the source was checked in. This
|
|
8
|
+
repository now owns its source directly. Run `scripts/create-upstream-patch.sh`
|
|
9
|
+
to produce one reviewable patch containing the difference from this pinned
|
|
10
|
+
upstream revision.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { MutableRefObject, HTMLProps, ReactNode, Dispatch, SetStateAction, RefObject, DragEventHandler, MouseEvent, ChangeEvent, JSX } from 'react';
|
|
3
|
+
import * as _tanstack_react_table from '@tanstack/react-table';
|
|
3
4
|
import { Row, StockFeatures, DeepKeys, FilterFn, Column, Cell, Header, HeaderGroup, TableState, AggregationFnDef, SortFn, OnChangeFn, TableOptions, Updater, Table, ColumnDef, ColumnFiltersState, AccessorFn, DeepValue, ColumnOrderState, ColumnPinningState, columnResizingState, ColumnSizingState, ColumnVisibilityState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, RowPinningPosition, Renderable } from '@tanstack/react-table';
|
|
4
5
|
import { Virtualizer, VirtualizerOptions, VirtualItem } from '@tanstack/react-virtual';
|
|
5
6
|
import { BoxProps, ActionIconProps, UnstyledButtonProps, ModalProps, SelectProps, TextInputProps, AutocompleteProps, CheckboxProps, MultiSelectProps, RangeSliderProps, HighlightProps, LoadingOverlayProps, PaginationProps, PaperProps, ProgressProps, RadioProps, SwitchProps, SkeletonProps, TableTdProps, TableTbodyProps, TableTrProps, TableThProps, TableTfootProps, TableTheadProps, TableProps, BadgeProps, AlertProps, FlexProps, MenuProps, MantineTheme } from '@mantine/core';
|
|
6
7
|
import { DateInputProps } from '@mantine/dates';
|
|
7
|
-
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
8
8
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
9
9
|
import * as _tabler_icons_react from '@tabler/icons-react';
|
|
10
10
|
|
|
11
11
|
declare const MRT_RowAggregationFns: {
|
|
12
|
-
sum:
|
|
13
|
-
min:
|
|
14
|
-
max:
|
|
15
|
-
extent:
|
|
16
|
-
mean:
|
|
17
|
-
median:
|
|
18
|
-
unique:
|
|
19
|
-
uniqueCount:
|
|
20
|
-
count:
|
|
21
|
-
first:
|
|
22
|
-
last:
|
|
12
|
+
sum: _tanstack_react_table.AggregationFnDef<any, any, unknown, number>;
|
|
13
|
+
min: _tanstack_react_table.AggregationFnDef<any, any, unknown, (number | Date) | undefined>;
|
|
14
|
+
max: _tanstack_react_table.AggregationFnDef<any, any, unknown, (number | Date) | undefined>;
|
|
15
|
+
extent: _tanstack_react_table.AggregationFnDef<any, any, unknown, [(number | Date) | undefined, (number | Date) | undefined]>;
|
|
16
|
+
mean: _tanstack_react_table.AggregationFnDef<any, any, unknown, number | undefined>;
|
|
17
|
+
median: _tanstack_react_table.AggregationFnDef<any, any, unknown, number | undefined>;
|
|
18
|
+
unique: _tanstack_react_table.AggregationFnDef<any, any, unknown, unknown[]>;
|
|
19
|
+
uniqueCount: _tanstack_react_table.AggregationFnDef<any, any, unknown, number>;
|
|
20
|
+
count: _tanstack_react_table.AggregationFnDef<any, any, unknown, number>;
|
|
21
|
+
first: _tanstack_react_table.AggregationFnDef<any, any, unknown, unknown>;
|
|
22
|
+
last: _tanstack_react_table.AggregationFnDef<any, any, unknown, unknown>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
declare const MRT_FilterFns: {
|
|
@@ -79,28 +79,28 @@ declare const MRT_FilterFns: {
|
|
|
79
79
|
<TData extends MRT_RowData>(row: Row<StockFeatures, TData>, id: string, filterValue: number | string): boolean;
|
|
80
80
|
autoRemove(val: any): boolean;
|
|
81
81
|
};
|
|
82
|
-
arrIncludes:
|
|
83
|
-
arrIncludesAll:
|
|
84
|
-
arrHas:
|
|
85
|
-
arrIncludesSome:
|
|
86
|
-
equalsString:
|
|
87
|
-
equalsStringSensitive:
|
|
88
|
-
inDateRange:
|
|
89
|
-
inNumberRange:
|
|
90
|
-
includesString:
|
|
91
|
-
includesStringSensitive:
|
|
92
|
-
weakEquals:
|
|
82
|
+
arrIncludes: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
83
|
+
arrIncludesAll: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
84
|
+
arrHas: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
85
|
+
arrIncludesSome: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
86
|
+
equalsString: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
87
|
+
equalsStringSensitive: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
88
|
+
inDateRange: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
89
|
+
inNumberRange: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
90
|
+
includesString: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
91
|
+
includesStringSensitive: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
92
|
+
weakEquals: _tanstack_react_table.CreatedFilterFn<any, any>;
|
|
93
93
|
};
|
|
94
94
|
declare function localizedFilterOption(localization: MRT_Localization, option: MRT_FilterOption): string;
|
|
95
95
|
|
|
96
96
|
declare const MRT_SortFns: {
|
|
97
97
|
fuzzy: <TData extends MRT_RowData>(rowA: Row<StockFeatures, TData>, rowB: Row<StockFeatures, TData>, columnId: string) => number;
|
|
98
|
-
alphanumeric:
|
|
99
|
-
alphanumericCaseSensitive:
|
|
100
|
-
basic:
|
|
101
|
-
datetime:
|
|
102
|
-
text:
|
|
103
|
-
textCaseSensitive:
|
|
98
|
+
alphanumeric: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
99
|
+
alphanumericCaseSensitive: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
100
|
+
basic: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
101
|
+
datetime: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
102
|
+
text: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
103
|
+
textCaseSensitive: _tanstack_react_table.CreatedSortFn<any, any>;
|
|
104
104
|
};
|
|
105
105
|
declare const rankGlobalFuzzy: <TData extends MRT_RowData>(rowA: MRT_Row<TData>, rowB: MRT_Row<TData>) => number;
|
|
106
106
|
|
|
@@ -1365,10 +1365,12 @@ declare const MRT_FilterRangeSlider: <TData extends MRT_RowData>({ header, table
|
|
|
1365
1365
|
|
|
1366
1366
|
interface Props$j<TData extends MRT_RowData> extends TextInputProps {
|
|
1367
1367
|
header: MRT_Header<TData>;
|
|
1368
|
+
onRangeFilterValueChange?: (value: any) => void;
|
|
1368
1369
|
rangeFilterIndex?: number;
|
|
1370
|
+
rangeFilterValue?: any;
|
|
1369
1371
|
table: MRT_TableInstance<TData>;
|
|
1370
1372
|
}
|
|
1371
|
-
declare const MRT_FilterTextInput: <TData extends MRT_RowData>({ header, rangeFilterIndex, table, ...rest }: Props$j<TData>) => react.JSX.Element;
|
|
1373
|
+
declare const MRT_FilterTextInput: <TData extends MRT_RowData>({ header, onRangeFilterValueChange, rangeFilterIndex, rangeFilterValue, table, ...rest }: Props$j<TData>) => react.JSX.Element;
|
|
1372
1374
|
|
|
1373
1375
|
interface Props$i<TData extends MRT_RowData> extends TextInputProps {
|
|
1374
1376
|
table: MRT_TableInstance<TData>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { useMemo, useCallback, useState, memo, useEffect, useRef, Fragment as Fragment$1, useReducer, createElement
|
|
3
|
+
import { useMemo, useCallback, useState, memo, useEffect, useRef, Fragment as Fragment$1, useLayoutEffect, useReducer, createElement } from 'react';
|
|
4
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
5
|
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
|
6
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';
|
|
@@ -1658,6 +1658,16 @@ const contains = (row, id, filterValue) => row
|
|
|
1658
1658
|
.trim()
|
|
1659
1659
|
.includes(filterValue.toString().toLowerCase().trim());
|
|
1660
1660
|
contains.autoRemove = (val) => !val;
|
|
1661
|
+
const getDateFilterTimestamp = (value) => {
|
|
1662
|
+
if (typeof value === 'string') {
|
|
1663
|
+
const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1664
|
+
if (dateOnly) {
|
|
1665
|
+
return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])).getTime();
|
|
1666
|
+
}
|
|
1667
|
+
return new Date(value).getTime();
|
|
1668
|
+
}
|
|
1669
|
+
return new Date(value).getTime();
|
|
1670
|
+
};
|
|
1661
1671
|
const startsWith = (row, id, filterValue) => row
|
|
1662
1672
|
.getValue(id)
|
|
1663
1673
|
?.toString()
|
|
@@ -1672,23 +1682,41 @@ const endsWith = (row, id, filterValue) => row
|
|
|
1672
1682
|
.trim()
|
|
1673
1683
|
.endsWith(filterValue.toString().toLowerCase().trim());
|
|
1674
1684
|
endsWith.autoRemove = (val) => !val;
|
|
1675
|
-
const equals = (row, id, filterValue) =>
|
|
1676
|
-
|
|
1685
|
+
const equals = (row, id, filterValue) => {
|
|
1686
|
+
const rowValue = row.getValue(id);
|
|
1687
|
+
if (rowValue instanceof Date) {
|
|
1688
|
+
return rowValue.getTime() === getDateFilterTimestamp(filterValue);
|
|
1689
|
+
}
|
|
1690
|
+
return (rowValue?.toString().toLowerCase().trim() ===
|
|
1691
|
+
filterValue?.toString().toLowerCase().trim());
|
|
1692
|
+
};
|
|
1677
1693
|
equals.autoRemove = (val) => !val;
|
|
1678
1694
|
const notEquals = (row, id, filterValue) => row.getValue(id)?.toString().toLowerCase().trim() !==
|
|
1679
1695
|
filterValue.toString().toLowerCase().trim();
|
|
1680
1696
|
notEquals.autoRemove = (val) => !val;
|
|
1681
|
-
const greaterThan = (row, id, filterValue) =>
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1697
|
+
const greaterThan = (row, id, filterValue) => {
|
|
1698
|
+
const rowValue = row.getValue(id);
|
|
1699
|
+
if (rowValue instanceof Date) {
|
|
1700
|
+
return rowValue.getTime() > getDateFilterTimestamp(filterValue);
|
|
1701
|
+
}
|
|
1702
|
+
return !isNaN(+filterValue) && !isNaN(+rowValue)
|
|
1703
|
+
? +rowValue > +filterValue
|
|
1704
|
+
: rowValue?.toString().toLowerCase().trim() >
|
|
1705
|
+
filterValue?.toString().toLowerCase().trim();
|
|
1706
|
+
};
|
|
1685
1707
|
greaterThan.autoRemove = (val) => !val;
|
|
1686
1708
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
1687
1709
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
1688
|
-
const lessThan = (row, id, filterValue) =>
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1710
|
+
const lessThan = (row, id, filterValue) => {
|
|
1711
|
+
const rowValue = row.getValue(id);
|
|
1712
|
+
if (rowValue instanceof Date) {
|
|
1713
|
+
return rowValue.getTime() < getDateFilterTimestamp(filterValue);
|
|
1714
|
+
}
|
|
1715
|
+
return !isNaN(+filterValue) && !isNaN(+rowValue)
|
|
1716
|
+
? +rowValue < +filterValue
|
|
1717
|
+
: rowValue?.toString().toLowerCase().trim() <
|
|
1718
|
+
filterValue?.toString().toLowerCase().trim();
|
|
1719
|
+
};
|
|
1692
1720
|
lessThan.autoRemove = (val) => !val;
|
|
1693
1721
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
1694
1722
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
@@ -1700,13 +1728,23 @@ const between = (row, id, filterValues) => (['', undefined].includes(filterValue
|
|
|
1700
1728
|
['', undefined].includes(filterValues[1]) ||
|
|
1701
1729
|
lessThan(row, id, filterValues[1]));
|
|
1702
1730
|
between.autoRemove = (val) => !val;
|
|
1703
|
-
const betweenInclusive = (row, id, filterValues) =>
|
|
1704
|
-
|
|
1705
|
-
(
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1731
|
+
const betweenInclusive = (row, id, filterValues) => {
|
|
1732
|
+
const rowValue = row.getValue(id);
|
|
1733
|
+
if (rowValue instanceof Date) {
|
|
1734
|
+
const minimum = filterValues[0] === '' ? undefined : getDateFilterTimestamp(filterValues[0]);
|
|
1735
|
+
const maximum = filterValues[1] === '' ? undefined : getDateFilterTimestamp(filterValues[1]);
|
|
1736
|
+
const endOfMaximumDay = maximum === undefined ? undefined : maximum + 86_400_000 - 1;
|
|
1737
|
+
return ((minimum === undefined || rowValue.getTime() >= minimum) &&
|
|
1738
|
+
(endOfMaximumDay === undefined || rowValue.getTime() <= endOfMaximumDay));
|
|
1739
|
+
}
|
|
1740
|
+
return ((['', undefined].includes(filterValues[0]) ||
|
|
1741
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
1742
|
+
((!isNaN(+filterValues[0]) &&
|
|
1743
|
+
!isNaN(+filterValues[1]) &&
|
|
1744
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
1745
|
+
['', undefined].includes(filterValues[1]) ||
|
|
1746
|
+
lessThanOrEqualTo(row, id, filterValues[1])));
|
|
1747
|
+
};
|
|
1710
1748
|
betweenInclusive.autoRemove = (val) => !val;
|
|
1711
1749
|
const empty = (row, id, _filterValue) => !row.getValue(id)?.toString().trim();
|
|
1712
1750
|
empty.autoRemove = (val) => !val;
|
|
@@ -1768,7 +1806,7 @@ var classes$k = {"root":"MRT_FilterRangeFields-module_root__KfCcg"};
|
|
|
1768
1806
|
|
|
1769
1807
|
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
1808
|
|
|
1771
|
-
const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
1809
|
+
const MRT_FilterTextInput = ({ header, onRangeFilterValueChange, rangeFilterIndex, rangeFilterValue, table, ...rest }) => {
|
|
1772
1810
|
const { options: { columnFilterDisplayMode, columnFilterModeOptions, icons: { IconX }, localization, mantineFilterAutocompleteProps, mantineFilterDateInputProps, mantineFilterMultiSelectProps = {
|
|
1773
1811
|
clearable: true,
|
|
1774
1812
|
}, mantineFilterSelectProps, mantineFilterTextInputProps, manualFiltering, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
@@ -1848,6 +1886,8 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1848
1886
|
useEffect(() => {
|
|
1849
1887
|
if (!isMounted.current)
|
|
1850
1888
|
return;
|
|
1889
|
+
if (onRangeFilterValueChange)
|
|
1890
|
+
return;
|
|
1851
1891
|
if (isRangeFilter) {
|
|
1852
1892
|
column.setFilterValue((old) => {
|
|
1853
1893
|
const newFilterValues = Array.isArray(old) ? old : ['', ''];
|
|
@@ -1862,6 +1902,8 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1862
1902
|
}, [debouncedFilterValue]);
|
|
1863
1903
|
// receive table filter value and set it to local state
|
|
1864
1904
|
useEffect(() => {
|
|
1905
|
+
if (onRangeFilterValueChange)
|
|
1906
|
+
return;
|
|
1865
1907
|
if (!isMounted.current) {
|
|
1866
1908
|
isMounted.current = true;
|
|
1867
1909
|
return;
|
|
@@ -1883,6 +1925,10 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1883
1925
|
column.setFilterValue([]);
|
|
1884
1926
|
}
|
|
1885
1927
|
else if (isRangeFilter) {
|
|
1928
|
+
if (onRangeFilterValueChange) {
|
|
1929
|
+
onRangeFilterValueChange(undefined);
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1886
1932
|
setFilterValue('');
|
|
1887
1933
|
column.setFilterValue((old) => {
|
|
1888
1934
|
const newFilterValues = Array.isArray(old) ? old : ['', ''];
|
|
@@ -1915,6 +1961,12 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1915
1961
|
[header.id]: allowedColumnFilterOptions?.[0] ?? 'fuzzy',
|
|
1916
1962
|
}));
|
|
1917
1963
|
};
|
|
1964
|
+
const displayedFilterValue = onRangeFilterValueChange
|
|
1965
|
+
? (rangeFilterValue ?? '')
|
|
1966
|
+
: filterValue;
|
|
1967
|
+
const handleFilterValueChange = (value) => onRangeFilterValueChange
|
|
1968
|
+
? onRangeFilterValueChange(value)
|
|
1969
|
+
: setFilterValue(value);
|
|
1918
1970
|
const { className, ...commonProps } = {
|
|
1919
1971
|
'aria-label': filterPlaceholder,
|
|
1920
1972
|
className: clsx('mrt-filter-text-input', classes$j.root, isDateFilter
|
|
@@ -1923,7 +1975,7 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1923
1975
|
? classes$j['range-filter']
|
|
1924
1976
|
: !filterChipLabel && classes$j['not-filter-chip']),
|
|
1925
1977
|
disabled: !!filterChipLabel,
|
|
1926
|
-
onChange:
|
|
1978
|
+
onChange: handleFilterValueChange,
|
|
1927
1979
|
onClick: (event) => event.stopPropagation(),
|
|
1928
1980
|
placeholder: filterPlaceholder,
|
|
1929
1981
|
style: {
|
|
@@ -1936,10 +1988,12 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1936
1988
|
: textInputProps?.style),
|
|
1937
1989
|
},
|
|
1938
1990
|
title: filterPlaceholder,
|
|
1939
|
-
value: isMultiSelectFilter && !Array.isArray(
|
|
1991
|
+
value: isMultiSelectFilter && !Array.isArray(displayedFilterValue)
|
|
1992
|
+
? []
|
|
1993
|
+
: displayedFilterValue,
|
|
1940
1994
|
variant: 'unstyled',
|
|
1941
1995
|
};
|
|
1942
|
-
const ClearButton =
|
|
1996
|
+
const ClearButton = displayedFilterValue ? (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
1997
|
if (columnDef.Filter) {
|
|
1944
1998
|
return (jsx(Fragment, { children: columnDef.Filter?.({ column, header, rangeFilterIndex, table }) }));
|
|
1945
1999
|
}
|
|
@@ -1955,9 +2009,7 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1955
2009
|
multiSelectProps.ref.current = node;
|
|
1956
2010
|
}
|
|
1957
2011
|
}
|
|
1958
|
-
},
|
|
1959
|
-
? ClearButton
|
|
1960
|
-
: undefined, style: commonProps.style }));
|
|
2012
|
+
}, style: commonProps.style }));
|
|
1961
2013
|
}
|
|
1962
2014
|
if (isSelectFilter) {
|
|
1963
2015
|
return (jsx(Select, { ...commonProps, clearable: true, searchable: true, ...selectProps, className: clsx(className, selectProps.className), clearButtonProps: {
|
|
@@ -1994,7 +2046,7 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
1994
2046
|
}
|
|
1995
2047
|
}, style: commonProps.style }));
|
|
1996
2048
|
}
|
|
1997
|
-
return (jsx(TextInput, { ...commonProps, onChange: (e) =>
|
|
2049
|
+
return (jsx(TextInput, { ...commonProps, onChange: (e) => handleFilterValueChange(e.target.value), rightSection: displayedFilterValue?.toString()?.length ? ClearButton : undefined, ...textInputProps, className: clsx(className, textInputProps.className), mt: 0, ref: (node) => {
|
|
1998
2050
|
if (node) {
|
|
1999
2051
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
|
|
2000
2052
|
node;
|
|
@@ -2006,7 +2058,39 @@ const MRT_FilterTextInput = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
2006
2058
|
};
|
|
2007
2059
|
|
|
2008
2060
|
const MRT_FilterRangeFields = ({ header, table, ...rest }) => {
|
|
2009
|
-
|
|
2061
|
+
const { options: { manualFiltering }, } = table;
|
|
2062
|
+
const { column } = header;
|
|
2063
|
+
const columnFilterValue = column.getFilterValue();
|
|
2064
|
+
const minimum = Array.isArray(columnFilterValue) ? columnFilterValue[0] ?? '' : '';
|
|
2065
|
+
const maximum = Array.isArray(columnFilterValue) ? columnFilterValue[1] ?? '' : '';
|
|
2066
|
+
const [filterValues, setFilterValues] = useState([
|
|
2067
|
+
minimum,
|
|
2068
|
+
maximum,
|
|
2069
|
+
]);
|
|
2070
|
+
const filterValuesRef = useRef(filterValues);
|
|
2071
|
+
const timeoutRef = useRef(undefined);
|
|
2072
|
+
// A new array with identical bounds is not an external change. Real changes
|
|
2073
|
+
// replace the draft and cancel pending edits before they can overwrite a reset.
|
|
2074
|
+
useLayoutEffect(() => {
|
|
2075
|
+
const next = [minimum, maximum];
|
|
2076
|
+
filterValuesRef.current = next;
|
|
2077
|
+
setFilterValues(next);
|
|
2078
|
+
return () => clearTimeout(timeoutRef.current);
|
|
2079
|
+
}, [minimum, maximum]);
|
|
2080
|
+
const setRangeFilterValue = (index, value) => {
|
|
2081
|
+
const next = [...filterValuesRef.current];
|
|
2082
|
+
next[index] = value ?? '';
|
|
2083
|
+
filterValuesRef.current = next;
|
|
2084
|
+
setFilterValues(next);
|
|
2085
|
+
clearTimeout(timeoutRef.current);
|
|
2086
|
+
// Only user edits schedule writes: mounting and receiving external state
|
|
2087
|
+
// must not echo values back, including during Strict Mode effect replay.
|
|
2088
|
+
timeoutRef.current = setTimeout(() => {
|
|
2089
|
+
const hasFilterValue = next.some((bound) => bound !== '');
|
|
2090
|
+
column.setFilterValue(hasFilterValue ? [...next] : undefined);
|
|
2091
|
+
}, manualFiltering ? 400 : 200);
|
|
2092
|
+
};
|
|
2093
|
+
return (jsxs(Box, { ...rest, className: clsx('mrt-filter-range-fields', classes$k.root, rest.className), children: [jsx(MRT_FilterTextInput, { header: header, onRangeFilterValueChange: (value) => setRangeFilterValue(0, value), rangeFilterIndex: 0, rangeFilterValue: filterValues[0], table: table }), jsx(MRT_FilterTextInput, { header: header, onRangeFilterValueChange: (value) => setRangeFilterValue(1, value), rangeFilterIndex: 1, rangeFilterValue: filterValues[1], table: table })] }));
|
|
2010
2094
|
};
|
|
2011
2095
|
|
|
2012
2096
|
var classes$i = {"root":"MRT_FilterRangeSlider-module_root__uwYEk"};
|
|
@@ -3435,7 +3519,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
3435
3519
|
showLoadingOverlay: statefulTableOptions.state.showLoadingOverlay ?? false,
|
|
3436
3520
|
showProgressBars: statefulTableOptions.state.showProgressBars ?? false,
|
|
3437
3521
|
showSkeletons: statefulTableOptions.state.showSkeletons,
|
|
3438
|
-
showAlertBanner,
|
|
3522
|
+
showAlertBanner: statefulTableOptions.state.showAlertBanner ?? showAlertBanner,
|
|
3439
3523
|
showColumnFilters,
|
|
3440
3524
|
showGlobalFilter,
|
|
3441
3525
|
showToolbarDropZone,
|