material-react-table 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +2 -2
- package/dist/cjs/index.js +2400 -2365
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/cjs/types/column.utils.d.ts +6 -6
- package/dist/cjs/types/filterFns.d.ts +14 -14
- package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/cjs/types/icons.d.ts +1 -1
- package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/cjs/types/types.d.ts +198 -198
- package/dist/esm/material-react-table.esm.js +2027 -1993
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/esm/types/column.utils.d.ts +6 -6
- package/dist/esm/types/filterFns.d.ts +14 -14
- package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/esm/types/icons.d.ts +1 -1
- package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/esm/types/types.d.ts +198 -198
- package/dist/index.d.ts +239 -239
- package/locales/fr.esm.js +1 -1
- package/locales/fr.esm.js.map +1 -1
- package/locales/fr.js +1 -1
- package/locales/fr.js.map +1 -1
- package/locales/tr.d.ts +2 -0
- package/locales/tr.esm.d.ts +2 -0
- package/locales/tr.esm.js +93 -0
- package/locales/tr.esm.js.map +1 -0
- package/locales/tr.js +97 -0
- package/locales/tr.js.map +1 -0
- package/locales/uk.d.ts +2 -0
- package/locales/uk.esm.d.ts +2 -0
- package/locales/uk.esm.js +93 -0
- package/locales/uk.esm.js.map +1 -0
- package/locales/uk.js +97 -0
- package/locales/uk.js.map +1 -0
- package/locales/vi.d.ts +2 -0
- package/locales/vi.esm.d.ts +2 -0
- package/locales/vi.esm.js +93 -0
- package/locales/vi.esm.js.map +1 -0
- package/locales/vi.js +97 -0
- package/locales/vi.js.map +1 -0
- package/locales/zh-Hans.d.ts +2 -0
- package/locales/zh-Hans.esm.d.ts +2 -0
- package/locales/zh-Hans.esm.js +93 -0
- package/locales/zh-Hans.esm.js.map +1 -0
- package/locales/zh-Hans.js +97 -0
- package/locales/zh-Hans.js.map +1 -0
- package/locales/zh-Hant.d.ts +2 -0
- package/locales/zh-Hant.esm.d.ts +2 -0
- package/locales/zh-Hant.esm.js +93 -0
- package/locales/zh-Hant.esm.js.map +1 -0
- package/locales/zh-Hant.js +97 -0
- package/locales/zh-Hant.js.map +1 -0
- package/package.json +2 -1
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBody.tsx +9 -9
- package/src/body/MRT_TableBodyCell.tsx +22 -22
- package/src/body/MRT_TableBodyCellValue.tsx +5 -5
- package/src/body/MRT_TableBodyRow.tsx +32 -32
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +2 -2
- package/src/body/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_CopyButton.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +4 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -3
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +10 -10
- package/src/buttons/MRT_RowPinButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -8
- package/src/column.utils.ts +23 -17
- package/src/filterFns.ts +29 -29
- package/src/footer/MRT_TableFooter.tsx +9 -9
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +2 -2
- package/src/head/MRT_TableHead.tsx +9 -9
- package/src/head/MRT_TableHeadCell.tsx +10 -6
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -6
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +11 -4
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +106 -61
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +2 -2
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +11 -11
- package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -8
- package/src/head/MRT_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_DisplayColumns.tsx +5 -5
- package/src/hooks/useMRT_Effects.ts +3 -3
- package/src/hooks/useMRT_TableInstance.ts +15 -14
- package/src/hooks/useMRT_TableOptions.ts +3 -3
- package/src/icons.ts +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +9 -9
- package/src/inputs/MRT_FilterCheckbox.tsx +7 -7
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -1
- package/src/inputs/MRT_FilterRangeSlider.tsx +6 -6
- package/src/inputs/MRT_FilterTextField.tsx +75 -75
- package/src/inputs/MRT_GlobalFilterTextField.tsx +26 -26
- package/src/inputs/MRT_SelectCheckbox.tsx +7 -7
- package/src/locales/fr.ts +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +14 -14
- package/src/menus/MRT_FilterOptionMenu.tsx +35 -35
- package/src/menus/MRT_RowActionMenu.tsx +7 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +6 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -5
- package/src/modals/MRT_EditRowModal.tsx +8 -8
- package/src/sortingFns.ts +1 -1
- package/src/table/MRT_Table.tsx +7 -7
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TablePaper.tsx +9 -9
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -5
- package/src/toolbar/MRT_LinearProgressBar.tsx +4 -4
- package/src/toolbar/MRT_TablePagination.tsx +19 -19
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +4 -4
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -6
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -5
- package/src/toolbar/MRT_TopToolbar.tsx +7 -7
- package/src/types.ts +263 -263
- package/src/useMaterialReactTable.ts +1 -1
@@ -1,9 +1,9 @@
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
2
|
+
import FormHelperText from '@mui/material/FormHelperText';
|
1
3
|
import Slider from '@mui/material/Slider';
|
2
4
|
import Stack from '@mui/material/Stack';
|
3
|
-
import FormHelperText from '@mui/material/FormHelperText';
|
4
|
-
import { type MRT_TableInstance, type MRT_Header } from '../types';
|
5
|
-
import { useEffect, useRef, useState } from 'react';
|
6
5
|
import { parseFromValuesOrFunc } from '../column.utils';
|
6
|
+
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
9
9
|
header: MRT_Header<TData>;
|
@@ -15,7 +15,7 @@ export const MRT_FilterRangeSlider = <TData extends Record<string, any>>({
|
|
15
15
|
table,
|
16
16
|
}: Props<TData>) => {
|
17
17
|
const {
|
18
|
-
options: { localization, muiFilterSliderProps
|
18
|
+
options: { enableColumnFilterModes, localization, muiFilterSliderProps },
|
19
19
|
refs: { filterInputRefs },
|
20
20
|
} = table;
|
21
21
|
const { column } = header;
|
@@ -62,8 +62,8 @@ export const MRT_FilterRangeSlider = <TData extends Record<string, any>>({
|
|
62
62
|
<Stack>
|
63
63
|
<Slider
|
64
64
|
disableSwap
|
65
|
-
min={min}
|
66
65
|
max={max}
|
66
|
+
min={min}
|
67
67
|
onChange={(_event, values) => {
|
68
68
|
setFilterValues(values as [number, number]);
|
69
69
|
}}
|
@@ -105,9 +105,9 @@ export const MRT_FilterRangeSlider = <TData extends Record<string, any>>({
|
|
105
105
|
{showChangeModeButton ? (
|
106
106
|
<FormHelperText
|
107
107
|
sx={{
|
108
|
-
m: '-3px -6px',
|
109
108
|
fontSize: '0.75rem',
|
110
109
|
lineHeight: '0.8rem',
|
110
|
+
m: '-3px -6px',
|
111
111
|
whiteSpace: 'nowrap',
|
112
112
|
}}
|
113
113
|
>
|
@@ -3,9 +3,9 @@ import {
|
|
3
3
|
type MouseEvent,
|
4
4
|
useCallback,
|
5
5
|
useEffect,
|
6
|
+
useMemo,
|
6
7
|
useRef,
|
7
8
|
useState,
|
8
|
-
useMemo,
|
9
9
|
} from 'react';
|
10
10
|
import Box from '@mui/material/Box';
|
11
11
|
import Checkbox from '@mui/material/Checkbox';
|
@@ -14,12 +14,12 @@ import IconButton from '@mui/material/IconButton';
|
|
14
14
|
import InputAdornment from '@mui/material/InputAdornment';
|
15
15
|
import MenuItem from '@mui/material/MenuItem';
|
16
16
|
import TextField from '@mui/material/TextField';
|
17
|
+
import { type TextFieldProps } from '@mui/material/TextField';
|
17
18
|
import Tooltip from '@mui/material/Tooltip';
|
18
19
|
import { debounce } from '@mui/material/utils';
|
20
|
+
import { parseFromValuesOrFunc } from '../column.utils';
|
19
21
|
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
20
|
-
import { type TextFieldProps } from '@mui/material/TextField';
|
21
22
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
22
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
23
23
|
|
24
24
|
interface Props<TData extends Record<string, any>> {
|
25
25
|
header: MRT_Header<TData>;
|
@@ -34,9 +34,9 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
34
34
|
}: Props<TData>) => {
|
35
35
|
const {
|
36
36
|
options: {
|
37
|
-
enableColumnFilterModes,
|
38
37
|
columnFilterModeOptions,
|
39
|
-
|
38
|
+
enableColumnFilterModes,
|
39
|
+
icons: { CloseIcon, FilterListIcon },
|
40
40
|
localization,
|
41
41
|
manualFiltering,
|
42
42
|
muiFilterTextFieldProps,
|
@@ -107,7 +107,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
107
107
|
],
|
108
108
|
);
|
109
109
|
|
110
|
-
const [anchorEl, setAnchorEl] = useState<
|
110
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
111
111
|
const [filterValue, setFilterValue] = useState<string | string[]>(() =>
|
112
112
|
isMultiSelectFilter
|
113
113
|
? (column.getFilterValue() as string[]) || []
|
@@ -128,7 +128,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
128
128
|
? event.target.valueAsNumber
|
129
129
|
: event.target.value;
|
130
130
|
if (isRangeFilter) {
|
131
|
-
column.setFilterValue((old: Array<
|
131
|
+
column.setFilterValue((old: Array<Date | null | number | string>) => {
|
132
132
|
const newFilterValues = old ?? ['', ''];
|
133
133
|
newFilterValues[rangeFilterIndex as number] = value;
|
134
134
|
return newFilterValues;
|
@@ -202,31 +202,6 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
202
202
|
return (
|
203
203
|
<>
|
204
204
|
<TextField
|
205
|
-
fullWidth
|
206
|
-
inputProps={{
|
207
|
-
disabled: !!filterChipLabel,
|
208
|
-
sx: {
|
209
|
-
textOverflow: 'ellipsis',
|
210
|
-
width: filterChipLabel ? 0 : undefined,
|
211
|
-
},
|
212
|
-
title: filterPlaceholder,
|
213
|
-
}}
|
214
|
-
helperText={
|
215
|
-
showChangeModeButton ? (
|
216
|
-
<label>
|
217
|
-
{localization.filterMode.replace(
|
218
|
-
'{filterType}',
|
219
|
-
// @ts-ignore
|
220
|
-
localization[
|
221
|
-
`filter${
|
222
|
-
currentFilterOption?.charAt(0)?.toUpperCase() +
|
223
|
-
currentFilterOption?.slice(1)
|
224
|
-
}`
|
225
|
-
],
|
226
|
-
)}
|
227
|
-
</label>
|
228
|
-
) : null
|
229
|
-
}
|
230
205
|
FormHelperTextProps={{
|
231
206
|
sx: {
|
232
207
|
fontSize: '0.75rem',
|
@@ -234,40 +209,7 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
234
209
|
whiteSpace: 'nowrap',
|
235
210
|
},
|
236
211
|
}}
|
237
|
-
margin="none"
|
238
|
-
placeholder={
|
239
|
-
filterChipLabel || isSelectFilter || isMultiSelectFilter
|
240
|
-
? undefined
|
241
|
-
: filterPlaceholder
|
242
|
-
}
|
243
|
-
onChange={handleChange}
|
244
|
-
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
245
|
-
select={isSelectFilter || isMultiSelectFilter}
|
246
|
-
value={filterValue ?? ''}
|
247
|
-
variant="standard"
|
248
212
|
InputProps={{
|
249
|
-
startAdornment: showChangeModeButton ? (
|
250
|
-
<InputAdornment position="start">
|
251
|
-
<Tooltip arrow title={localization.changeFilterMode}>
|
252
|
-
<span>
|
253
|
-
<IconButton
|
254
|
-
aria-label={localization.changeFilterMode}
|
255
|
-
onClick={handleFilterMenuOpen}
|
256
|
-
size="small"
|
257
|
-
sx={{ height: '1.75rem', width: '1.75rem' }}
|
258
|
-
>
|
259
|
-
<FilterListIcon />
|
260
|
-
</IconButton>
|
261
|
-
</span>
|
262
|
-
</Tooltip>
|
263
|
-
{filterChipLabel && (
|
264
|
-
<Chip
|
265
|
-
onDelete={handleClearEmptyFilterChip}
|
266
|
-
label={filterChipLabel}
|
267
|
-
/>
|
268
|
-
)}
|
269
|
-
</InputAdornment>
|
270
|
-
) : null,
|
271
213
|
endAdornment: !filterChipLabel && (
|
272
214
|
<InputAdornment position="end">
|
273
215
|
<Tooltip
|
@@ -292,6 +234,28 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
292
234
|
</Tooltip>
|
293
235
|
</InputAdornment>
|
294
236
|
),
|
237
|
+
startAdornment: showChangeModeButton ? (
|
238
|
+
<InputAdornment position="start">
|
239
|
+
<Tooltip arrow title={localization.changeFilterMode}>
|
240
|
+
<span>
|
241
|
+
<IconButton
|
242
|
+
aria-label={localization.changeFilterMode}
|
243
|
+
onClick={handleFilterMenuOpen}
|
244
|
+
size="small"
|
245
|
+
sx={{ height: '1.75rem', width: '1.75rem' }}
|
246
|
+
>
|
247
|
+
<FilterListIcon />
|
248
|
+
</IconButton>
|
249
|
+
</span>
|
250
|
+
</Tooltip>
|
251
|
+
{filterChipLabel && (
|
252
|
+
<Chip
|
253
|
+
label={filterChipLabel}
|
254
|
+
onDelete={handleClearEmptyFilterChip}
|
255
|
+
/>
|
256
|
+
)}
|
257
|
+
</InputAdornment>
|
258
|
+
) : null,
|
295
259
|
}}
|
296
260
|
SelectProps={{
|
297
261
|
displayEmpty: true,
|
@@ -324,6 +288,42 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
324
288
|
)
|
325
289
|
: undefined,
|
326
290
|
}}
|
291
|
+
fullWidth
|
292
|
+
helperText={
|
293
|
+
showChangeModeButton ? (
|
294
|
+
<label>
|
295
|
+
{localization.filterMode.replace(
|
296
|
+
'{filterType}',
|
297
|
+
// @ts-ignore
|
298
|
+
localization[
|
299
|
+
`filter${
|
300
|
+
currentFilterOption?.charAt(0)?.toUpperCase() +
|
301
|
+
currentFilterOption?.slice(1)
|
302
|
+
}`
|
303
|
+
],
|
304
|
+
)}
|
305
|
+
</label>
|
306
|
+
) : null
|
307
|
+
}
|
308
|
+
inputProps={{
|
309
|
+
disabled: !!filterChipLabel,
|
310
|
+
sx: {
|
311
|
+
textOverflow: 'ellipsis',
|
312
|
+
width: filterChipLabel ? 0 : undefined,
|
313
|
+
},
|
314
|
+
title: filterPlaceholder,
|
315
|
+
}}
|
316
|
+
margin="none"
|
317
|
+
onChange={handleChange}
|
318
|
+
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
319
|
+
placeholder={
|
320
|
+
filterChipLabel || isSelectFilter || isMultiSelectFilter
|
321
|
+
? undefined
|
322
|
+
: filterPlaceholder
|
323
|
+
}
|
324
|
+
select={isSelectFilter || isMultiSelectFilter}
|
325
|
+
value={filterValue ?? ''}
|
326
|
+
variant="standard"
|
327
327
|
{...textFieldProps}
|
328
328
|
inputRef={(inputRef) => {
|
329
329
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
|
@@ -333,28 +333,28 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
333
333
|
}
|
334
334
|
}}
|
335
335
|
sx={(theme) => ({
|
336
|
-
|
336
|
+
'& .MuiSelect-icon': {
|
337
|
+
mr: '1.5rem',
|
338
|
+
},
|
337
339
|
minWidth: isRangeFilter
|
338
340
|
? '100px'
|
339
341
|
: !filterChipLabel
|
340
342
|
? '120px'
|
341
343
|
: 'auto',
|
342
|
-
width: 'calc(100% + 4px)',
|
343
344
|
mx: '-2px',
|
344
|
-
|
345
|
-
|
346
|
-
},
|
345
|
+
p: 0,
|
346
|
+
width: 'calc(100% + 4px)',
|
347
347
|
...(parseFromValuesOrFunc(textFieldProps?.sx, theme) as any),
|
348
348
|
})}
|
349
349
|
>
|
350
350
|
{(isSelectFilter || isMultiSelectFilter) && (
|
351
|
-
<MenuItem divider
|
351
|
+
<MenuItem disabled divider hidden value="">
|
352
352
|
<Box sx={{ opacity: 0.5 }}>{filterPlaceholder}</Box>
|
353
353
|
</MenuItem>
|
354
354
|
)}
|
355
355
|
{textFieldProps.children ??
|
356
356
|
filterSelectOptions?.map(
|
357
|
-
(option:
|
357
|
+
(option: { text: string; value: string } | string) => {
|
358
358
|
if (!option) return '';
|
359
359
|
let value: string;
|
360
360
|
let text: string;
|
@@ -369,10 +369,10 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
369
369
|
<MenuItem
|
370
370
|
key={value}
|
371
371
|
sx={{
|
372
|
-
display: 'flex',
|
373
|
-
m: 0,
|
374
372
|
alignItems: 'center',
|
373
|
+
display: 'flex',
|
375
374
|
gap: '0.5rem',
|
375
|
+
m: 0,
|
376
376
|
}}
|
377
377
|
value={value}
|
378
378
|
>
|
@@ -396,8 +396,8 @@ export const MRT_FilterTextField = <TData extends Record<string, any>>({
|
|
396
396
|
anchorEl={anchorEl}
|
397
397
|
header={header}
|
398
398
|
setAnchorEl={setAnchorEl}
|
399
|
-
table={table}
|
400
399
|
setFilterValue={setFilterValue}
|
400
|
+
table={table}
|
401
401
|
/>
|
402
402
|
</>
|
403
403
|
);
|
@@ -12,9 +12,9 @@ import InputAdornment from '@mui/material/InputAdornment';
|
|
12
12
|
import TextField from '@mui/material/TextField';
|
13
13
|
import Tooltip from '@mui/material/Tooltip';
|
14
14
|
import { debounce } from '@mui/material/utils';
|
15
|
+
import { parseFromValuesOrFunc } from '../column.utils';
|
15
16
|
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
16
17
|
import { type MRT_TableInstance } from '../types';
|
17
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
18
18
|
|
19
19
|
interface Props<TData extends Record<string, any>> {
|
20
20
|
table: MRT_TableInstance<TData>;
|
@@ -25,15 +25,15 @@ export const MRT_GlobalFilterTextField = <TData extends Record<string, any>>({
|
|
25
25
|
}: Props<TData>) => {
|
26
26
|
const {
|
27
27
|
getState,
|
28
|
-
setGlobalFilter,
|
29
28
|
options: {
|
30
29
|
enableGlobalFilterModes,
|
31
|
-
icons: {
|
30
|
+
icons: { CloseIcon, SearchIcon },
|
32
31
|
localization,
|
33
32
|
manualFiltering,
|
34
33
|
muiSearchTextFieldProps,
|
35
34
|
},
|
36
35
|
refs: { searchInputRef },
|
36
|
+
setGlobalFilter,
|
37
37
|
} = table;
|
38
38
|
const { globalFilter, showGlobalFilter } = getState();
|
39
39
|
|
@@ -42,7 +42,7 @@ export const MRT_GlobalFilterTextField = <TData extends Record<string, any>>({
|
|
42
42
|
});
|
43
43
|
|
44
44
|
const isMounted = useRef(false);
|
45
|
-
const [anchorEl, setAnchorEl] = useState<
|
45
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
46
46
|
const [searchValue, setSearchValue] = useState(globalFilter ?? '');
|
47
47
|
|
48
48
|
const handleChangeDebounced = useCallback(
|
@@ -83,32 +83,12 @@ export const MRT_GlobalFilterTextField = <TData extends Record<string, any>>({
|
|
83
83
|
return (
|
84
84
|
<Collapse
|
85
85
|
in={showGlobalFilter}
|
86
|
+
mountOnEnter
|
86
87
|
orientation="horizontal"
|
87
88
|
unmountOnExit
|
88
|
-
mountOnEnter
|
89
89
|
>
|
90
90
|
<TextField
|
91
|
-
placeholder={localization.search}
|
92
|
-
onChange={handleChange}
|
93
|
-
value={searchValue ?? ''}
|
94
|
-
variant="standard"
|
95
91
|
InputProps={{
|
96
|
-
startAdornment: enableGlobalFilterModes ? (
|
97
|
-
<InputAdornment position="start">
|
98
|
-
<Tooltip arrow title={localization.changeSearchMode}>
|
99
|
-
<IconButton
|
100
|
-
aria-label={localization.changeSearchMode}
|
101
|
-
onClick={handleGlobalFilterMenuOpen}
|
102
|
-
size="small"
|
103
|
-
sx={{ height: '1.75rem', width: '1.75rem' }}
|
104
|
-
>
|
105
|
-
<SearchIcon />
|
106
|
-
</IconButton>
|
107
|
-
</Tooltip>
|
108
|
-
</InputAdornment>
|
109
|
-
) : (
|
110
|
-
<SearchIcon style={{ marginRight: '4px' }} />
|
111
|
-
),
|
112
92
|
endAdornment: (
|
113
93
|
<InputAdornment position="end">
|
114
94
|
<Tooltip arrow title={localization.clearSearch ?? ''}>
|
@@ -125,7 +105,27 @@ export const MRT_GlobalFilterTextField = <TData extends Record<string, any>>({
|
|
125
105
|
</Tooltip>
|
126
106
|
</InputAdornment>
|
127
107
|
),
|
108
|
+
startAdornment: enableGlobalFilterModes ? (
|
109
|
+
<InputAdornment position="start">
|
110
|
+
<Tooltip arrow title={localization.changeSearchMode}>
|
111
|
+
<IconButton
|
112
|
+
aria-label={localization.changeSearchMode}
|
113
|
+
onClick={handleGlobalFilterMenuOpen}
|
114
|
+
size="small"
|
115
|
+
sx={{ height: '1.75rem', width: '1.75rem' }}
|
116
|
+
>
|
117
|
+
<SearchIcon />
|
118
|
+
</IconButton>
|
119
|
+
</Tooltip>
|
120
|
+
</InputAdornment>
|
121
|
+
) : (
|
122
|
+
<SearchIcon style={{ marginRight: '4px' }} />
|
123
|
+
),
|
128
124
|
}}
|
125
|
+
onChange={handleChange}
|
126
|
+
placeholder={localization.search}
|
127
|
+
value={searchValue ?? ''}
|
128
|
+
variant="standard"
|
129
129
|
{...textFieldProps}
|
130
130
|
inputRef={(inputRef) => {
|
131
131
|
searchInputRef.current = inputRef;
|
@@ -136,9 +136,9 @@ export const MRT_GlobalFilterTextField = <TData extends Record<string, any>>({
|
|
136
136
|
/>
|
137
137
|
<MRT_FilterOptionMenu
|
138
138
|
anchorEl={anchorEl}
|
139
|
+
onSelect={handleClear}
|
139
140
|
setAnchorEl={setAnchorEl}
|
140
141
|
table={table}
|
141
|
-
onSelect={handleClear}
|
142
142
|
/>
|
143
143
|
</Collapse>
|
144
144
|
);
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { type MouseEvent } from 'react';
|
2
2
|
import Checkbox, { type CheckboxProps } from '@mui/material/Checkbox';
|
3
|
-
import Tooltip from '@mui/material/Tooltip';
|
4
3
|
import Radio, { type RadioProps } from '@mui/material/Radio';
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
5
5
|
import { type Theme } from '@mui/material/styles';
|
6
|
-
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
7
6
|
import { parseFromValuesOrFunc } from '../column.utils';
|
7
|
+
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
8
8
|
|
9
9
|
interface Props<TData extends Record<string, any>> {
|
10
10
|
row?: MRT_Row<TData>;
|
@@ -20,12 +20,12 @@ export const MRT_SelectCheckbox = <TData extends Record<string, any>>({
|
|
20
20
|
const {
|
21
21
|
getState,
|
22
22
|
options: {
|
23
|
-
localization,
|
24
23
|
enableMultiRowSelection,
|
25
|
-
rowPinningDisplayMode,
|
26
24
|
enableRowPinning,
|
27
|
-
|
25
|
+
localization,
|
28
26
|
muiSelectAllCheckboxProps,
|
27
|
+
muiSelectCheckboxProps,
|
28
|
+
rowPinningDisplayMode,
|
29
29
|
selectAllMode,
|
30
30
|
},
|
31
31
|
} = table;
|
@@ -70,7 +70,7 @@ export const MRT_SelectCheckbox = <TData extends Record<string, any>>({
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
},
|
73
|
-
size: (density === 'compact' ? 'small' : 'medium') as '
|
73
|
+
size: (density === 'compact' ? 'small' : 'medium') as 'medium' | 'small',
|
74
74
|
...checkboxProps,
|
75
75
|
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
76
76
|
e.stopPropagation();
|
@@ -78,8 +78,8 @@ export const MRT_SelectCheckbox = <TData extends Record<string, any>>({
|
|
78
78
|
},
|
79
79
|
sx: (theme: Theme) => ({
|
80
80
|
height: density === 'compact' ? '1.75rem' : '2.5rem',
|
81
|
-
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
82
81
|
m: density !== 'compact' ? '-0.4rem' : undefined,
|
82
|
+
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
83
83
|
zIndex: 0,
|
84
84
|
...parseFromValuesOrFunc(checkboxProps?.sx, theme),
|
85
85
|
}),
|
package/src/locales/fr.ts
CHANGED
@@ -70,7 +70,7 @@ export const MRT_Localization_FR: MRT_Localization = {
|
|
70
70
|
save: 'Sauvegarder',
|
71
71
|
search: 'Rechercher',
|
72
72
|
selectedCountOfRowCountRowsSelected:
|
73
|
-
'{selectedCount}
|
73
|
+
'{selectedCount} sur {rowCount} ligne(s)',
|
74
74
|
select: 'Sélectionner',
|
75
75
|
showAll: 'Afficher tous',
|
76
76
|
showAllColumns: 'Afficher toutes les colonnes',
|
@@ -9,15 +9,15 @@ import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
|
|
9
9
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
10
10
|
|
11
11
|
export const commonMenuItemStyles = {
|
12
|
-
py: '6px',
|
13
|
-
my: 0,
|
14
|
-
justifyContent: 'space-between',
|
15
12
|
alignItems: 'center',
|
13
|
+
justifyContent: 'space-between',
|
14
|
+
my: 0,
|
15
|
+
py: '6px',
|
16
16
|
};
|
17
17
|
|
18
18
|
export const commonListItemStyles = {
|
19
|
-
display: 'flex',
|
20
19
|
alignItems: 'center',
|
20
|
+
display: 'flex',
|
21
21
|
};
|
22
22
|
|
23
23
|
interface Props<TData extends Record<string, any>> {
|
@@ -35,36 +35,36 @@ export const MRT_ColumnActionMenu = <TData extends Record<string, any>>({
|
|
35
35
|
}: Props<TData>) => {
|
36
36
|
const {
|
37
37
|
getState,
|
38
|
-
toggleAllColumnsVisible,
|
39
|
-
setColumnOrder,
|
40
38
|
options: {
|
41
39
|
columnFilterModeOptions,
|
42
40
|
enableColumnFilterModes,
|
43
41
|
enableColumnFilters,
|
42
|
+
enableColumnPinning,
|
44
43
|
enableColumnResizing,
|
45
44
|
enableGrouping,
|
46
45
|
enableHiding,
|
47
|
-
enableColumnPinning,
|
48
46
|
enableSorting,
|
49
47
|
enableSortingRemoval,
|
50
48
|
icons: {
|
51
49
|
ArrowRightIcon,
|
52
50
|
ClearAllIcon,
|
53
|
-
ViewColumnIcon,
|
54
51
|
DynamicFeedIcon,
|
55
52
|
FilterListIcon,
|
56
53
|
FilterListOffIcon,
|
57
54
|
PushPinIcon,
|
58
|
-
SortIcon,
|
59
55
|
RestartAltIcon,
|
56
|
+
SortIcon,
|
57
|
+
ViewColumnIcon,
|
60
58
|
VisibilityOffIcon,
|
61
59
|
},
|
62
60
|
localization,
|
63
61
|
renderColumnActionsMenuItems,
|
64
62
|
},
|
65
63
|
refs: { filterInputRefs },
|
64
|
+
setColumnOrder,
|
66
65
|
setColumnSizingInfo,
|
67
66
|
setShowColumnFilters,
|
67
|
+
toggleAllColumnsVisible,
|
68
68
|
} = table;
|
69
69
|
const { column } = header;
|
70
70
|
const { columnDef } = column;
|
@@ -73,7 +73,7 @@ export const MRT_ColumnActionMenu = <TData extends Record<string, any>>({
|
|
73
73
|
const columnFilterValue = column.getFilterValue();
|
74
74
|
|
75
75
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] =
|
76
|
-
useState<
|
76
|
+
useState<HTMLElement | null>(null);
|
77
77
|
|
78
78
|
const handleClearSort = () => {
|
79
79
|
column.clearSorting();
|
@@ -180,9 +180,9 @@ export const MRT_ColumnActionMenu = <TData extends Record<string, any>>({
|
|
180
180
|
</Box>
|
181
181
|
</MenuItem>,
|
182
182
|
<MenuItem
|
183
|
+
disabled={column.getIsSorted() === 'desc'}
|
183
184
|
divider={enableColumnFilters || enableGrouping || enableHiding}
|
184
185
|
key={2}
|
185
|
-
disabled={column.getIsSorted() === 'desc'}
|
186
186
|
onClick={handleSortDesc}
|
187
187
|
sx={commonMenuItemStyles}
|
188
188
|
>
|
@@ -383,12 +383,12 @@ export const MRT_ColumnActionMenu = <TData extends Record<string, any>>({
|
|
383
383
|
|
384
384
|
return (
|
385
385
|
<Menu
|
386
|
-
anchorEl={anchorEl}
|
387
|
-
open={!!anchorEl}
|
388
|
-
onClose={() => setAnchorEl(null)}
|
389
386
|
MenuListProps={{
|
390
387
|
dense: density === 'compact',
|
391
388
|
}}
|
389
|
+
anchorEl={anchorEl}
|
390
|
+
onClose={() => setAnchorEl(null)}
|
391
|
+
open={!!anchorEl}
|
392
392
|
>
|
393
393
|
{columnDef.renderColumnActionsMenuItems?.({
|
394
394
|
closeMenu: () => setAnchorEl(null),
|