@mui/x-data-grid-pro 6.3.1 → 6.5.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/CHANGELOG.md +113 -0
- package/DataGridPro/DataGridPro.js +25 -1
- package/DataGridPro/useDataGridProComponent.js +5 -3
- package/DataGridPro/useDataGridProProps.js +7 -13
- package/components/GridColumnHeaders.js +15 -1
- package/components/GridDetailPanel.js +1 -1
- package/components/headerFiltering/GridHeaderFilterAdornment.d.ts +14 -0
- package/components/headerFiltering/GridHeaderFilterAdornment.js +99 -0
- package/components/headerFiltering/GridHeaderFilterCell.d.ts +20 -0
- package/components/headerFiltering/GridHeaderFilterCell.js +224 -0
- package/components/headerFiltering/GridHeaderFilterClearButton.d.ts +6 -0
- package/components/headerFiltering/GridHeaderFilterClearButton.js +25 -0
- package/components/headerFiltering/GridHeaderFilterMenu.d.ts +14 -0
- package/components/headerFiltering/GridHeaderFilterMenu.js +69 -0
- package/components/headerFiltering/constants.d.ts +3 -0
- package/components/headerFiltering/constants.js +30 -0
- package/components/headerFiltering/index.d.ts +2 -0
- package/components/headerFiltering/index.js +2 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -1
- package/constants/dataGridProDefaultSlotsComponents.js +5 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +21 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +111 -0
- package/hooks/features/columnResize/useGridColumnResize.js +12 -1
- package/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -0
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +4 -0
- package/legacy/DataGridPro/DataGridPro.js +25 -1
- package/legacy/DataGridPro/useDataGridProComponent.js +5 -3
- package/legacy/DataGridPro/useDataGridProProps.js +10 -9
- package/legacy/components/GridColumnHeaders.js +15 -1
- package/legacy/components/GridDetailPanel.js +1 -1
- package/legacy/components/headerFiltering/GridHeaderFilterAdornment.js +97 -0
- package/legacy/components/headerFiltering/GridHeaderFilterCell.js +230 -0
- package/legacy/components/headerFiltering/GridHeaderFilterClearButton.js +24 -0
- package/legacy/components/headerFiltering/GridHeaderFilterMenu.js +68 -0
- package/legacy/components/headerFiltering/constants.js +30 -0
- package/legacy/components/headerFiltering/index.js +2 -0
- package/legacy/components/index.js +2 -1
- package/legacy/constants/dataGridProDefaultSlotsComponents.js +5 -1
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +120 -0
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +12 -1
- package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -0
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +4 -0
- package/legacy/material/icons.js +4 -1
- package/legacy/material/index.js +3 -2
- package/legacy/models/gridProSlotProps.js +1 -0
- package/legacy/utils/releaseInfo.js +1 -1
- package/legacy/utils/tree/createRowTree.js +1 -0
- package/legacy/utils/tree/insertDataRowInTree.js +4 -0
- package/legacy/utils/tree/removeDataRowFromTree.js +1 -0
- package/legacy/utils/tree/updateRowTree.js +2 -0
- package/legacy/utils/tree/utils.js +20 -12
- package/material/icons.d.ts +3 -0
- package/material/icons.js +4 -1
- package/material/index.d.ts +1 -0
- package/material/index.js +3 -2
- package/models/dataGridProProps.d.ts +16 -1
- package/models/gridProIconSlotsComponent.d.ts +5 -0
- package/models/gridProSlotProps.d.ts +9 -0
- package/models/gridProSlotProps.js +1 -0
- package/models/gridProSlotsComponent.d.ts +13 -2
- package/modern/DataGridPro/DataGridPro.js +25 -1
- package/modern/DataGridPro/useDataGridProComponent.js +5 -3
- package/modern/DataGridPro/useDataGridProProps.js +7 -13
- package/modern/components/GridColumnHeaders.js +15 -1
- package/modern/components/GridDetailPanel.js +1 -1
- package/modern/components/headerFiltering/GridHeaderFilterAdornment.js +98 -0
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +222 -0
- package/modern/components/headerFiltering/GridHeaderFilterClearButton.js +24 -0
- package/modern/components/headerFiltering/GridHeaderFilterMenu.js +68 -0
- package/modern/components/headerFiltering/constants.js +30 -0
- package/modern/components/headerFiltering/index.js +2 -0
- package/modern/components/index.js +2 -1
- package/modern/constants/dataGridProDefaultSlotsComponents.js +5 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +110 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +11 -0
- package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -0
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +4 -0
- package/modern/material/icons.js +4 -1
- package/modern/material/index.js +3 -2
- package/modern/models/gridProSlotProps.js +1 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/createRowTree.js +1 -0
- package/modern/utils/tree/insertDataRowInTree.js +4 -0
- package/modern/utils/tree/removeDataRowFromTree.js +1 -0
- package/modern/utils/tree/updateRowTree.js +2 -0
- package/modern/utils/tree/utils.js +19 -13
- package/node/DataGridPro/DataGridPro.js +25 -1
- package/node/DataGridPro/useDataGridProComponent.js +4 -2
- package/node/DataGridPro/useDataGridProProps.js +6 -12
- package/node/components/GridColumnHeaders.js +15 -1
- package/node/components/GridDetailPanel.js +2 -2
- package/node/components/headerFiltering/GridHeaderFilterAdornment.js +105 -0
- package/node/components/headerFiltering/GridHeaderFilterCell.js +230 -0
- package/node/components/headerFiltering/GridHeaderFilterClearButton.js +32 -0
- package/node/components/headerFiltering/GridHeaderFilterMenu.js +75 -0
- package/node/components/headerFiltering/constants.js +37 -0
- package/node/components/headerFiltering/index.js +27 -0
- package/node/components/index.js +11 -0
- package/node/constants/dataGridProDefaultSlotsComponents.js +5 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +120 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +11 -0
- package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -0
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -0
- package/node/material/icons.js +6 -2
- package/node/material/index.js +2 -1
- package/node/models/gridProSlotProps.js +5 -0
- package/node/utils/releaseInfo.js +1 -1
- package/node/utils/tree/createRowTree.js +1 -0
- package/node/utils/tree/insertDataRowInTree.js +4 -0
- package/node/utils/tree/removeDataRowFromTree.js +1 -0
- package/node/utils/tree/updateRowTree.js +2 -0
- package/node/utils/tree/utils.js +19 -13
- package/package.json +2 -2
- package/typeOverloads/modules.d.ts +13 -1
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/createRowTree.d.ts +2 -0
- package/utils/tree/createRowTree.js +1 -0
- package/utils/tree/insertDataRowInTree.d.ts +5 -1
- package/utils/tree/insertDataRowInTree.js +4 -0
- package/utils/tree/removeDataRowFromTree.js +1 -0
- package/utils/tree/updateRowTree.js +2 -0
- package/utils/tree/utils.d.ts +4 -2
- package/utils/tree/utils.js +19 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,119 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## v6.5.0
|
|
7
|
+
|
|
8
|
+
_May 19, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 💫 Introduce filtering on column headers for `DataGridPro` and `DataGridPremium`:
|
|
13
|
+
|
|
14
|
+
https://github.com/mui/mui-x/assets/12609561/c4c2bfec-59cf-4cab-932d-dc1983081de9
|
|
15
|
+
|
|
16
|
+
See [the documentation](https://mui.com/x/react-data-grid/filtering/#header-filters) for more information
|
|
17
|
+
|
|
18
|
+
- 🌍 Improve Hebrew (he-IL) and Czech (cs-CZ) locales
|
|
19
|
+
- 📝 Support for editing on pinned rows
|
|
20
|
+
- 🚀 Performance improvements
|
|
21
|
+
- 🐞 Bugfixes
|
|
22
|
+
- 📚 Documentation improvements
|
|
23
|
+
|
|
24
|
+
### `@mui/x-data-grid@6.5.0` / `@mui/x-data-grid-pro@6.5.0` / `@mui/x-data-grid-premium@6.5.0`
|
|
25
|
+
|
|
26
|
+
#### Changes
|
|
27
|
+
|
|
28
|
+
- [DataGrid] Fix grid size calculation when `.MuiDataGrid-main` has border (#8882) @cherniavskii
|
|
29
|
+
- [DataGridPro] Filtering on Column Header (#7760) @MBilalShafi
|
|
30
|
+
- [DataGridPro] Improve `treeData` and `rowGrouping` performance (#8990) @MBilalShafi
|
|
31
|
+
- [DataGridPro] Support pinned rows editing (#8921) @cherniavskii
|
|
32
|
+
- [l10n] Improve Hebrew (he-IL) locale (#8943) @Itzik-Tech
|
|
33
|
+
- [l10n] Improve Czech (cs-CZ) locale (#8829) @harastaivan
|
|
34
|
+
- [l10n] Improve Czech (cs-CZ) locale (#8956) @davidzemancz
|
|
35
|
+
|
|
36
|
+
### `@mui/x-date-pickers@6.5.0` / `@mui/x-date-pickers-pro@6.5.0`
|
|
37
|
+
|
|
38
|
+
#### Changes
|
|
39
|
+
|
|
40
|
+
- [fields] Select the first section instead of last when clicking right of content (#9005) @noraleonte
|
|
41
|
+
- [fields] Refactor prop drilling in fields (#8660) @flaviendelangle
|
|
42
|
+
- [pickers] Allow to render the months before `currentMonth` instead of the one after (#8592) @flaviendelangle
|
|
43
|
+
- [pickers] Fix view management when `openTo` or `views` is modified (#8997) @alexfauquette
|
|
44
|
+
- [l10n] Improve Czech (cs-CZ) locale (#8829) @harastaivan
|
|
45
|
+
|
|
46
|
+
### Docs
|
|
47
|
+
|
|
48
|
+
- [docs] Clarify what Controlled / Uncontrolled means (#8926) @flaviendelangle
|
|
49
|
+
- [docs] Fix docs using wrong service worker (#9030) @cherniavskii
|
|
50
|
+
- [docs] Remove prop-types from JS demos (#9008) @flaviendelangle
|
|
51
|
+
|
|
52
|
+
### Core
|
|
53
|
+
|
|
54
|
+
- [core] Add assertion about checkbox rerenders (#8974) @oliviertassinari
|
|
55
|
+
- [core] Allow selecting a section by type in field tests (#9009) @flaviendelangle
|
|
56
|
+
- [core] Fix `yarn.lock` (#8988) @flaviendelangle
|
|
57
|
+
- [core] Fix flacky adapter test (#8995) @flaviendelangle
|
|
58
|
+
- [charts] Clean the axis rendering (#8948) @alexfauquette
|
|
59
|
+
- [DataGrid] Memoize root props for better performance (#8942) @romgrk
|
|
60
|
+
- [test] Skip flaky unit tests in JSDOM (#8994) @cherniavskii
|
|
61
|
+
|
|
62
|
+
## v6.4.0
|
|
63
|
+
|
|
64
|
+
_May 12, 2023_
|
|
65
|
+
|
|
66
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
67
|
+
|
|
68
|
+
- 🎁 Introduce clipboard paste support for `DataGridPremium`:
|
|
69
|
+
|
|
70
|
+
https://github.com/mui/mui-x/assets/13808724/abfcb5c6-9db6-4677-9ba7-ae97de441080
|
|
71
|
+
|
|
72
|
+
See [the documentation](https://mui.com/x/react-data-grid/clipboard/#clipboard-paste) for more information
|
|
73
|
+
|
|
74
|
+
- 🌍 Improve French (fr-FR), German (de-DE), Portuguese (pt-BR) and Ukrainian (uk-UA) locales on the data grid
|
|
75
|
+
- 🌍 Add Slovak (sk-SK) locale on the pickers
|
|
76
|
+
- 🐞 Bugfixes
|
|
77
|
+
- 📚 Documentation improvements
|
|
78
|
+
|
|
79
|
+
### `@mui/x-data-grid@v6.4.0` / `@mui/x-data-grid-pro@v6.4.0` / `@mui/x-data-grid-premium@v6.4.0`
|
|
80
|
+
|
|
81
|
+
#### Changes
|
|
82
|
+
|
|
83
|
+
- [DataGrid] Fix DataGrid rendering in JSDOM (#8968) @cherniavskii
|
|
84
|
+
- [DataGrid] Fix layout when rendered inside a parent with `display: grid` (#8577) @cherniavskii
|
|
85
|
+
- [DataGrid] Add Joy UI icon slots (#8940) @siriwatknp
|
|
86
|
+
- [DataGrid] Add Joy UI pagination slot (#8871) @cherniavskii
|
|
87
|
+
- [DataGrid] Extract `baseChip` slot (#8748) @cherniavskii
|
|
88
|
+
- [DataGridPremium] Implement Clipboard import (#7389) @cherniavskii
|
|
89
|
+
- [l10n] Improve French (fr-FR) locale (#8825) @vallereaugabriel
|
|
90
|
+
- [l10n] Improve German (de-DE) locale (#8898) @marcauberer
|
|
91
|
+
- [l10n] Improve Portuguese (pt-BR) locale (#8960) @Sorriso337
|
|
92
|
+
- [l10n] Improve Ukrainian (uk-UA) locale (#8863) @Neonin
|
|
93
|
+
|
|
94
|
+
### `@mui/x-date-pickers@v6.4.0` / `@mui/x-date-pickers-pro@v6.4.0`
|
|
95
|
+
|
|
96
|
+
#### Changes
|
|
97
|
+
|
|
98
|
+
- [pickers] Fix trailing zeros inconsistency in `LuxonAdapter` (#8955) @alexfauquette
|
|
99
|
+
- [pickers] Stop using deprecated adapter methods (#8735) @flaviendelangle
|
|
100
|
+
- [pickers] Strictly type the `adapterLocale` prop of `LocalizationProvider` (#8780) @flaviendelangle
|
|
101
|
+
- [l10n] Add Slovak (sk-SK) locale (#8875) @MatejFacko
|
|
102
|
+
|
|
103
|
+
### Docs
|
|
104
|
+
|
|
105
|
+
- [docs] Fix date pickers typo in the docs (#8939) @richbustos
|
|
106
|
+
- [docs] Fix master detail demo (#8894) @m4theushw
|
|
107
|
+
- [docs] Fix typo in clipboard docs (#8971) @MBilalShafi
|
|
108
|
+
- [docs] Reduce list of dependencies in Codesandbox/Stackblitz demos (#8535) @cherniavskii
|
|
109
|
+
|
|
110
|
+
### Core
|
|
111
|
+
|
|
112
|
+
- [core] Improve testing of the adapters (#8789) @flaviendelangle
|
|
113
|
+
- [core] Update license key for tests (#8917) @LukasTy
|
|
114
|
+
- [charts] Make introduction docs pages for each chart (#8869) @alexfauquette
|
|
115
|
+
- [charts] Document Tooltip and Highlighs (#8867) @alexfauquette
|
|
116
|
+
- [test] Cover row grouping regression with a unit test (#8870) @cherniavskii
|
|
117
|
+
- [test] Fix flaky regression tests (#8954) @cherniavskii
|
|
118
|
+
|
|
6
119
|
## 6.3.1
|
|
7
120
|
|
|
8
121
|
_May 5, 2023_
|
|
@@ -91,6 +91,11 @@ DataGridProRaw.propTypes = {
|
|
|
91
91
|
* Override or extend the styles applied to the component.
|
|
92
92
|
*/
|
|
93
93
|
classes: PropTypes.object,
|
|
94
|
+
/**
|
|
95
|
+
* The character used to separate cell values when copying to the clipboard.
|
|
96
|
+
* @default '\t'
|
|
97
|
+
*/
|
|
98
|
+
clipboardCopyCellDelimiter: PropTypes.string,
|
|
94
99
|
/**
|
|
95
100
|
* Number of extra columns to be rendered before/after the visible slice.
|
|
96
101
|
* @default 3
|
|
@@ -443,6 +448,11 @@ DataGridProRaw.propTypes = {
|
|
|
443
448
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
444
449
|
*/
|
|
445
450
|
onCellModesModelChange: PropTypes.func,
|
|
451
|
+
/**
|
|
452
|
+
* Callback called when the data is copied to the clipboard.
|
|
453
|
+
* @param {string} data The data copied to the clipboard.
|
|
454
|
+
*/
|
|
455
|
+
onClipboardCopy: PropTypes.func,
|
|
446
456
|
/**
|
|
447
457
|
* Callback fired when a click event comes from a column header element.
|
|
448
458
|
* @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
|
|
@@ -816,5 +826,19 @@ DataGridProRaw.propTypes = {
|
|
|
816
826
|
* If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop.
|
|
817
827
|
* @default false
|
|
818
828
|
*/
|
|
819
|
-
treeData: PropTypes.bool
|
|
829
|
+
treeData: PropTypes.bool,
|
|
830
|
+
/**
|
|
831
|
+
* If `true`, enables the data grid filtering on header feature.
|
|
832
|
+
* @default false
|
|
833
|
+
*/
|
|
834
|
+
unstable_headerFilters: PropTypes.bool,
|
|
835
|
+
/**
|
|
836
|
+
* If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
837
|
+
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
838
|
+
* @default: false
|
|
839
|
+
*/
|
|
840
|
+
unstable_ignoreValueFormatterDuringExport: PropTypes.oneOfType([PropTypes.shape({
|
|
841
|
+
clipboardExport: PropTypes.bool,
|
|
842
|
+
csvExport: PropTypes.bool
|
|
843
|
+
}), PropTypes.bool])
|
|
820
844
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer } from '@mui/x-data-grid/internals';
|
|
1
|
+
import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer, headerFilteringStateInitializer, useGridHeaderFiltering } from '@mui/x-data-grid/internals';
|
|
2
2
|
// Pro-only features
|
|
3
3
|
import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
4
4
|
import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
@@ -35,6 +35,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
35
35
|
/**
|
|
36
36
|
* Register all state initializers here.
|
|
37
37
|
*/
|
|
38
|
+
useGridInitializeState(headerFilteringStateInitializer, apiRef, props);
|
|
38
39
|
useGridInitializeState(rowSelectionStateInitializer, apiRef, props);
|
|
39
40
|
useGridInitializeState(detailPanelStateInitializer, apiRef, props);
|
|
40
41
|
useGridInitializeState(columnPinningStateInitializer, apiRef, props);
|
|
@@ -53,6 +54,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
53
54
|
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
54
55
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
55
56
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
57
|
+
useGridHeaderFiltering(apiRef, props);
|
|
56
58
|
useGridTreeData(apiRef);
|
|
57
59
|
useGridKeyboardNavigation(apiRef, props);
|
|
58
60
|
useGridRowSelection(apiRef, props);
|
|
@@ -79,9 +81,9 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
79
81
|
useGridInfiniteLoader(apiRef, props);
|
|
80
82
|
useGridLazyLoader(apiRef, props);
|
|
81
83
|
useGridColumnMenu(apiRef);
|
|
82
|
-
useGridCsvExport(apiRef);
|
|
84
|
+
useGridCsvExport(apiRef, props);
|
|
83
85
|
useGridPrintExport(apiRef, props);
|
|
84
|
-
useGridClipboard(apiRef);
|
|
86
|
+
useGridClipboard(apiRef, props);
|
|
85
87
|
useGridDimensions(apiRef, props);
|
|
86
88
|
useGridEvents(apiRef, props);
|
|
87
89
|
useGridStatePersistence(apiRef);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["components", "componentsProps"];
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import { useThemeProps } from '@mui/material/styles';
|
|
6
4
|
import { GRID_DEFAULT_LOCALE_TEXT, DATA_GRID_PROPS_DEFAULT_VALUES } from '@mui/x-data-grid';
|
|
7
|
-
import { computeSlots, uncapitalizeObjectKeys } from '@mui/x-data-grid/internals';
|
|
5
|
+
import { computeSlots, uncapitalizeObjectKeys, useProps } from '@mui/x-data-grid/internals';
|
|
8
6
|
import { DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS } from '../constants/dataGridProDefaultSlotsComponents';
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -20,19 +18,15 @@ export const DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_D
|
|
|
20
18
|
disableChildrenSorting: false,
|
|
21
19
|
rowReordering: false,
|
|
22
20
|
rowsLoadingMode: 'client',
|
|
23
|
-
getDetailPanelHeight: () => 500
|
|
21
|
+
getDetailPanelHeight: () => 500,
|
|
22
|
+
unstable_headerFilters: false
|
|
24
23
|
});
|
|
25
24
|
const defaultSlots = uncapitalizeObjectKeys(DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS);
|
|
26
25
|
export const useDataGridProProps = inProps => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
components,
|
|
33
|
-
componentsProps
|
|
34
|
-
} = _useThemeProps,
|
|
35
|
-
themedProps = _objectWithoutPropertiesLoose(_useThemeProps, _excluded);
|
|
26
|
+
const [components, componentsProps, themedProps] = useProps(useThemeProps({
|
|
27
|
+
props: inProps,
|
|
28
|
+
name: 'MuiDataGrid'
|
|
29
|
+
}));
|
|
36
30
|
const localeText = React.useMemo(() => _extends({}, GRID_DEFAULT_LOCALE_TEXT, themedProps.localeText), [themedProps.localeText]);
|
|
37
31
|
const slots = React.useMemo(() => computeSlots({
|
|
38
32
|
defaultSlots,
|
|
@@ -6,11 +6,12 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
7
7
|
import { styled, alpha, useTheme } from '@mui/material/styles';
|
|
8
8
|
import { getDataGridUtilityClass, gridClasses, useGridApiEventHandler, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
|
|
9
|
-
import { GridBaseColumnHeaders, GridColumnHeadersInner
|
|
9
|
+
import { GridBaseColumnHeaders, GridColumnHeadersInner } from '@mui/x-data-grid/internals';
|
|
10
10
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
11
11
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
12
12
|
import { GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
13
13
|
import { filterColumns } from './DataGridProVirtualScroller';
|
|
14
|
+
import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const useUtilityClasses = ownerState => {
|
|
16
17
|
const {
|
|
@@ -122,6 +123,7 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
122
123
|
getRootProps,
|
|
123
124
|
getInnerProps,
|
|
124
125
|
getColumnHeaders,
|
|
126
|
+
getColumnFilters,
|
|
125
127
|
getColumnGroupHeaders
|
|
126
128
|
} = useGridColumnHeaders({
|
|
127
129
|
innerRef,
|
|
@@ -180,6 +182,10 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
180
182
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
181
183
|
}, {
|
|
182
184
|
disableReorder: true
|
|
185
|
+
}), getColumnFilters({
|
|
186
|
+
renderContext: leftRenderContext,
|
|
187
|
+
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
188
|
+
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
183
189
|
})]
|
|
184
190
|
})), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
|
|
185
191
|
isDragging: isDragging
|
|
@@ -192,6 +198,10 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
192
198
|
renderContext,
|
|
193
199
|
minFirstColumn: leftPinnedColumns.length,
|
|
194
200
|
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
201
|
+
}), getColumnFilters({
|
|
202
|
+
renderContext,
|
|
203
|
+
minFirstColumn: leftPinnedColumns.length,
|
|
204
|
+
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
195
205
|
})]
|
|
196
206
|
})), rightRenderContext && /*#__PURE__*/_jsxs(GridColumnHeadersPinnedColumnHeaders, _extends({
|
|
197
207
|
ownerState: _extends({}, ownerState, {
|
|
@@ -214,6 +224,10 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
214
224
|
}, {
|
|
215
225
|
disableReorder: true,
|
|
216
226
|
separatorSide: GridColumnHeaderSeparatorSides.Left
|
|
227
|
+
}), getColumnFilters({
|
|
228
|
+
renderContext: rightRenderContext,
|
|
229
|
+
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
230
|
+
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
217
231
|
})]
|
|
218
232
|
}))]
|
|
219
233
|
}));
|
|
@@ -4,7 +4,7 @@ const _excluded = ["rowId", "height", "style"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import Box from '@mui/material/Box';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
|
-
import { useGridRootProps } from '
|
|
7
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
8
|
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
const DetailPanel = styled(Box, {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridFilterItem, GridFilterOperator, GridColDef } from '@mui/x-data-grid';
|
|
3
|
+
declare function GridHeaderFilterAdornment(props: {
|
|
4
|
+
operators: GridFilterOperator<any, any, any>[];
|
|
5
|
+
field: GridColDef['field'];
|
|
6
|
+
item: GridFilterItem;
|
|
7
|
+
applyFilterChanges: (item: GridFilterItem) => void;
|
|
8
|
+
headerFilterMenuRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
9
|
+
buttonRef: React.Ref<HTMLButtonElement>;
|
|
10
|
+
}): JSX.Element | null;
|
|
11
|
+
declare namespace GridHeaderFilterAdornment {
|
|
12
|
+
var propTypes: any;
|
|
13
|
+
}
|
|
14
|
+
export { GridHeaderFilterAdornment };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["operators", "item", "field", "buttonRef", "headerFilterMenuRef"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useGridApiContext } from '@mui/x-data-grid';
|
|
7
|
+
import { unstable_useId as useId } from '@mui/utils';
|
|
8
|
+
import { unstable_gridHeaderFilteringMenuSelector } from '@mui/x-data-grid/internals';
|
|
9
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
10
|
+
import { OPERATOR_SYMBOL_MAPPING } from './constants';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const sx = {
|
|
14
|
+
width: 22,
|
|
15
|
+
height: 22,
|
|
16
|
+
padding: '0px 0px 2px 2px'
|
|
17
|
+
};
|
|
18
|
+
function GridHeaderFilterAdornment(props) {
|
|
19
|
+
var _rootProps$slotProps, _OPERATOR_SYMBOL_MAPP;
|
|
20
|
+
const {
|
|
21
|
+
operators,
|
|
22
|
+
item,
|
|
23
|
+
field,
|
|
24
|
+
buttonRef,
|
|
25
|
+
headerFilterMenuRef
|
|
26
|
+
} = props,
|
|
27
|
+
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
28
|
+
const buttonId = useId();
|
|
29
|
+
const menuId = useId();
|
|
30
|
+
const rootProps = useGridRootProps();
|
|
31
|
+
const apiRef = useGridApiContext();
|
|
32
|
+
const open = Boolean(unstable_gridHeaderFilteringMenuSelector(apiRef) === field && headerFilterMenuRef.current);
|
|
33
|
+
const handleClick = event => {
|
|
34
|
+
headerFilterMenuRef.current = event.currentTarget;
|
|
35
|
+
apiRef.current.showHeaderFilterMenu(field);
|
|
36
|
+
};
|
|
37
|
+
if (!rootProps.slots.headerFilterMenu) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
41
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputAdornment, {
|
|
42
|
+
position: "start",
|
|
43
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
44
|
+
id: buttonId,
|
|
45
|
+
ref: buttonRef,
|
|
46
|
+
"aria-label": apiRef.current.getLocaleText('filterPanelOperator'),
|
|
47
|
+
title: apiRef.current.getLocaleText('filterPanelOperator'),
|
|
48
|
+
"aria-controls": menuId,
|
|
49
|
+
"aria-expanded": open ? 'true' : undefined,
|
|
50
|
+
"aria-haspopup": "true",
|
|
51
|
+
tabIndex: -1,
|
|
52
|
+
size: "small",
|
|
53
|
+
onClick: handleClick,
|
|
54
|
+
sx: sx
|
|
55
|
+
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseIconButton, {
|
|
56
|
+
children: (_OPERATOR_SYMBOL_MAPP = OPERATOR_SYMBOL_MAPPING[item == null ? void 0 : item.operator]) != null ? _OPERATOR_SYMBOL_MAPP : '='
|
|
57
|
+
}))
|
|
58
|
+
}), /*#__PURE__*/_jsx(rootProps.slots.headerFilterMenu, _extends({
|
|
59
|
+
field: field,
|
|
60
|
+
open: open,
|
|
61
|
+
item: item,
|
|
62
|
+
targetRef: headerFilterMenuRef,
|
|
63
|
+
operators: operators,
|
|
64
|
+
labelledBy: buttonId,
|
|
65
|
+
id: menuId
|
|
66
|
+
}, others))]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
process.env.NODE_ENV !== "production" ? GridHeaderFilterAdornment.propTypes = {
|
|
70
|
+
// ----------------------------- Warning --------------------------------
|
|
71
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
72
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
73
|
+
// ----------------------------------------------------------------------
|
|
74
|
+
applyFilterChanges: PropTypes.func.isRequired,
|
|
75
|
+
buttonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
76
|
+
current: PropTypes.object
|
|
77
|
+
})]),
|
|
78
|
+
field: PropTypes.string.isRequired,
|
|
79
|
+
headerFilterMenuRef: PropTypes.shape({
|
|
80
|
+
current: PropTypes.object
|
|
81
|
+
}).isRequired,
|
|
82
|
+
item: PropTypes.shape({
|
|
83
|
+
field: PropTypes.string.isRequired,
|
|
84
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
85
|
+
operator: PropTypes.string.isRequired,
|
|
86
|
+
value: PropTypes.any
|
|
87
|
+
}).isRequired,
|
|
88
|
+
operators: PropTypes.arrayOf(PropTypes.shape({
|
|
89
|
+
getApplyFilterFn: PropTypes.func.isRequired,
|
|
90
|
+
getValueAsString: PropTypes.func,
|
|
91
|
+
headerLabel: PropTypes.string,
|
|
92
|
+
InputComponent: PropTypes.elementType,
|
|
93
|
+
InputComponentProps: PropTypes.object,
|
|
94
|
+
label: PropTypes.string,
|
|
95
|
+
requiresFilterValue: PropTypes.bool,
|
|
96
|
+
value: PropTypes.string.isRequired
|
|
97
|
+
})).isRequired
|
|
98
|
+
} : void 0;
|
|
99
|
+
export { GridHeaderFilterAdornment };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridFilterItem, GridFilterOperator, GridColDef } from '@mui/x-data-grid';
|
|
3
|
+
import { GridStateColDef } from '@mui/x-data-grid/internals';
|
|
4
|
+
export interface GridHeaderFilterCellProps extends Pick<GridStateColDef, 'headerClassName'> {
|
|
5
|
+
colIndex: number;
|
|
6
|
+
height: number;
|
|
7
|
+
sortIndex?: number;
|
|
8
|
+
hasFocus?: boolean;
|
|
9
|
+
tabIndex: 0 | -1;
|
|
10
|
+
headerFilterComponent?: React.ReactNode;
|
|
11
|
+
filterOperators?: GridFilterOperator[];
|
|
12
|
+
width: number;
|
|
13
|
+
colDef: GridColDef;
|
|
14
|
+
headerFilterMenuRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
15
|
+
item: GridFilterItem;
|
|
16
|
+
showClearIcon?: boolean;
|
|
17
|
+
InputComponentProps: GridFilterOperator['InputComponentProps'];
|
|
18
|
+
}
|
|
19
|
+
declare const GridHeaderFilterCell: React.ForwardRefExoticComponent<GridHeaderFilterCellProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export { GridHeaderFilterCell };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["colIndex", "height", "hasFocus", "headerFilterComponent", "filterOperators", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_capitalize as capitalize } from '@mui/utils';
|
|
8
|
+
import { gridVisibleColumnFieldsSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
9
|
+
import { useGridPrivateApiContext, unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector, isNavigationKey } from '@mui/x-data-grid/internals';
|
|
10
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
|
+
import { GridHeaderFilterAdornment } from './GridHeaderFilterAdornment';
|
|
12
|
+
import { GridHeaderFilterClearButton } from './GridHeaderFilterClearButton';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const useUtilityClasses = ownerState => {
|
|
16
|
+
const {
|
|
17
|
+
colDef,
|
|
18
|
+
classes,
|
|
19
|
+
showColumnVerticalBorder
|
|
20
|
+
} = ownerState;
|
|
21
|
+
const slots = {
|
|
22
|
+
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', 'withBorderColor', showColumnVerticalBorder && 'columnHeader--withRightBorder']
|
|
23
|
+
};
|
|
24
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
25
|
+
};
|
|
26
|
+
const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
27
|
+
var _filterOperators$find, _currentOperator$head, _colDef$headerName;
|
|
28
|
+
const {
|
|
29
|
+
colIndex,
|
|
30
|
+
height,
|
|
31
|
+
hasFocus,
|
|
32
|
+
headerFilterComponent,
|
|
33
|
+
filterOperators,
|
|
34
|
+
width,
|
|
35
|
+
headerClassName,
|
|
36
|
+
colDef,
|
|
37
|
+
item,
|
|
38
|
+
headerFilterMenuRef,
|
|
39
|
+
InputComponentProps,
|
|
40
|
+
showClearIcon = true
|
|
41
|
+
} = props,
|
|
42
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
43
|
+
const apiRef = useGridPrivateApiContext();
|
|
44
|
+
const columnFields = gridVisibleColumnFieldsSelector(apiRef);
|
|
45
|
+
const rootProps = useGridRootProps();
|
|
46
|
+
const cellRef = React.useRef(null);
|
|
47
|
+
const handleRef = useForkRef(ref, cellRef);
|
|
48
|
+
const inputRef = React.useRef(null);
|
|
49
|
+
const buttonRef = React.useRef(null);
|
|
50
|
+
const isEditing = unstable_gridHeaderFilteringEditFieldSelector(apiRef) === colDef.field;
|
|
51
|
+
const isMenuOpen = unstable_gridHeaderFilteringMenuSelector(apiRef) === colDef.field;
|
|
52
|
+
const currentOperator = filterOperators[0];
|
|
53
|
+
const InputComponent = colDef.filterable ? currentOperator.InputComponent : null;
|
|
54
|
+
const applyFilterChanges = React.useCallback(updatedItem => {
|
|
55
|
+
if (item.value && !updatedItem.value) {
|
|
56
|
+
apiRef.current.deleteFilterItem(updatedItem);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
apiRef.current.upsertFilterItem(updatedItem);
|
|
60
|
+
}, [apiRef, item]);
|
|
61
|
+
const clearFilterItem = React.useCallback(() => {
|
|
62
|
+
apiRef.current.deleteFilterItem(item);
|
|
63
|
+
}, [apiRef, item]);
|
|
64
|
+
React.useLayoutEffect(() => {
|
|
65
|
+
if (hasFocus && !isMenuOpen) {
|
|
66
|
+
let focusableElement = cellRef.current.querySelector('[tabindex="0"]');
|
|
67
|
+
if (isEditing && InputComponent) {
|
|
68
|
+
focusableElement = inputRef.current;
|
|
69
|
+
}
|
|
70
|
+
const elementToFocus = focusableElement || cellRef.current;
|
|
71
|
+
elementToFocus == null ? void 0 : elementToFocus.focus();
|
|
72
|
+
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
73
|
+
}
|
|
74
|
+
}, [InputComponent, apiRef, hasFocus, isEditing, isMenuOpen]);
|
|
75
|
+
const onKeyDown = React.useCallback(event => {
|
|
76
|
+
if (isMenuOpen || isNavigationKey(event.key)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
switch (event.key) {
|
|
80
|
+
case 'Escape':
|
|
81
|
+
if (isEditing) {
|
|
82
|
+
apiRef.current.stopHeaderFilterEditMode();
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'Enter':
|
|
86
|
+
if (isEditing) {
|
|
87
|
+
apiRef.current.stopHeaderFilterEditMode();
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (event.metaKey || event.ctrlKey) {
|
|
91
|
+
headerFilterMenuRef.current = buttonRef.current;
|
|
92
|
+
apiRef.current.showHeaderFilterMenu(colDef.field);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
apiRef.current.startHeaderFilterEditMode(colDef.field);
|
|
96
|
+
break;
|
|
97
|
+
case 'Tab':
|
|
98
|
+
{
|
|
99
|
+
if (isEditing) {
|
|
100
|
+
var _columnFields;
|
|
101
|
+
const fieldToFocus = (_columnFields = columnFields[colIndex + (event.shiftKey ? -1 : 1)]) != null ? _columnFields : null;
|
|
102
|
+
if (fieldToFocus) {
|
|
103
|
+
apiRef.current.startHeaderFilterEditMode(fieldToFocus);
|
|
104
|
+
apiRef.current.setColumnHeaderFilterFocus(fieldToFocus, event);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
if (isEditing || event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
apiRef.current.startHeaderFilterEditMode(colDef.field);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}, [apiRef, colDef.field, colIndex, columnFields, headerFilterMenuRef, isEditing, isMenuOpen]);
|
|
117
|
+
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
118
|
+
apiRef.current.publishEvent(eventName, apiRef.current.getColumnHeaderParams(colDef.field), event);
|
|
119
|
+
if (propHandler) {
|
|
120
|
+
propHandler(event);
|
|
121
|
+
}
|
|
122
|
+
}, [apiRef, colDef.field]);
|
|
123
|
+
const onMouseDown = React.useCallback(event => {
|
|
124
|
+
if (!hasFocus) {
|
|
125
|
+
if (inputRef.current) {
|
|
126
|
+
inputRef.current.focus();
|
|
127
|
+
}
|
|
128
|
+
apiRef.current.setColumnHeaderFilterFocus(colDef.field, event);
|
|
129
|
+
}
|
|
130
|
+
}, [apiRef, colDef.field, hasFocus]);
|
|
131
|
+
const mouseEventsHandlers = React.useMemo(() => ({
|
|
132
|
+
onKeyDown: publish('headerFilterKeyDown', onKeyDown),
|
|
133
|
+
onClick: publish('headerFilterClick'),
|
|
134
|
+
onMouseDown: publish('headerFilterMouseDown', onMouseDown)
|
|
135
|
+
}), [onMouseDown, onKeyDown, publish]);
|
|
136
|
+
const ownerState = _extends({}, rootProps, {
|
|
137
|
+
colDef
|
|
138
|
+
});
|
|
139
|
+
const classes = useUtilityClasses(ownerState);
|
|
140
|
+
const isNoInputOperator = (filterOperators == null ? void 0 : (_filterOperators$find = filterOperators.find(({
|
|
141
|
+
value
|
|
142
|
+
}) => item.operator === value)) == null ? void 0 : _filterOperators$find.requiresFilterValue) === false;
|
|
143
|
+
const isApplied = Boolean(item == null ? void 0 : item.value) || isNoInputOperator;
|
|
144
|
+
const label = (_currentOperator$head = currentOperator.headerLabel) != null ? _currentOperator$head : apiRef.current.getLocaleText(`headerFilterOperator${capitalize(item.operator)}`);
|
|
145
|
+
const isFilterActive = isApplied || hasFocus;
|
|
146
|
+
return /*#__PURE__*/_jsxs("div", _extends({
|
|
147
|
+
className: clsx(classes.root, headerClassName),
|
|
148
|
+
ref: handleRef,
|
|
149
|
+
style: {
|
|
150
|
+
height,
|
|
151
|
+
width,
|
|
152
|
+
minWidth: width,
|
|
153
|
+
maxWidth: width
|
|
154
|
+
},
|
|
155
|
+
role: "columnheader",
|
|
156
|
+
"aria-colindex": colIndex + 1,
|
|
157
|
+
"aria-label": headerFilterComponent == null ? (_colDef$headerName = colDef.headerName) != null ? _colDef$headerName : colDef.field : undefined
|
|
158
|
+
}, other, mouseEventsHandlers, {
|
|
159
|
+
children: [headerFilterComponent, InputComponent && headerFilterComponent === undefined ? /*#__PURE__*/_jsx(InputComponent, _extends({
|
|
160
|
+
apiRef: apiRef,
|
|
161
|
+
item: item,
|
|
162
|
+
inputRef: inputRef,
|
|
163
|
+
applyValue: applyFilterChanges,
|
|
164
|
+
onFocus: () => apiRef.current.startHeaderFilterEditMode(colDef.field),
|
|
165
|
+
onBlur: () => apiRef.current.stopHeaderFilterEditMode(),
|
|
166
|
+
placeholder: apiRef.current.getLocaleText('columnMenuFilter'),
|
|
167
|
+
label: isFilterActive ? capitalize(label) : ' ',
|
|
168
|
+
isFilterActive: isFilterActive,
|
|
169
|
+
headerFilterMenu: /*#__PURE__*/_jsx(GridHeaderFilterAdornment, {
|
|
170
|
+
operators: filterOperators,
|
|
171
|
+
item: item,
|
|
172
|
+
field: colDef.field,
|
|
173
|
+
applyFilterChanges: applyFilterChanges,
|
|
174
|
+
headerFilterMenuRef: headerFilterMenuRef,
|
|
175
|
+
buttonRef: buttonRef
|
|
176
|
+
}),
|
|
177
|
+
clearButton: showClearIcon && isApplied ? /*#__PURE__*/_jsx(GridHeaderFilterClearButton, {
|
|
178
|
+
onClick: clearFilterItem
|
|
179
|
+
}) : null,
|
|
180
|
+
disabled: isNoInputOperator,
|
|
181
|
+
tabIndex: -1
|
|
182
|
+
}, currentOperator == null ? void 0 : currentOperator.InputComponentProps, InputComponentProps)) : null]
|
|
183
|
+
}));
|
|
184
|
+
});
|
|
185
|
+
process.env.NODE_ENV !== "production" ? GridHeaderFilterCell.propTypes = {
|
|
186
|
+
// ----------------------------- Warning --------------------------------
|
|
187
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
188
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
189
|
+
// ----------------------------------------------------------------------
|
|
190
|
+
colDef: PropTypes.object.isRequired,
|
|
191
|
+
colIndex: PropTypes.number.isRequired,
|
|
192
|
+
filterOperators: PropTypes.arrayOf(PropTypes.shape({
|
|
193
|
+
getApplyFilterFn: PropTypes.func.isRequired,
|
|
194
|
+
getValueAsString: PropTypes.func,
|
|
195
|
+
headerLabel: PropTypes.string,
|
|
196
|
+
InputComponent: PropTypes.elementType,
|
|
197
|
+
InputComponentProps: PropTypes.object,
|
|
198
|
+
label: PropTypes.string,
|
|
199
|
+
requiresFilterValue: PropTypes.bool,
|
|
200
|
+
value: PropTypes.string.isRequired
|
|
201
|
+
})),
|
|
202
|
+
hasFocus: PropTypes.bool,
|
|
203
|
+
/**
|
|
204
|
+
* Class name that will be added in the column header cell.
|
|
205
|
+
*/
|
|
206
|
+
headerClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
207
|
+
headerFilterComponent: PropTypes.node,
|
|
208
|
+
headerFilterMenuRef: PropTypes.shape({
|
|
209
|
+
current: PropTypes.object
|
|
210
|
+
}).isRequired,
|
|
211
|
+
height: PropTypes.number.isRequired,
|
|
212
|
+
InputComponentProps: PropTypes.object,
|
|
213
|
+
item: PropTypes.shape({
|
|
214
|
+
field: PropTypes.string.isRequired,
|
|
215
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
216
|
+
operator: PropTypes.string.isRequired,
|
|
217
|
+
value: PropTypes.any
|
|
218
|
+
}).isRequired,
|
|
219
|
+
showClearIcon: PropTypes.bool,
|
|
220
|
+
sortIndex: PropTypes.number,
|
|
221
|
+
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
222
|
+
width: PropTypes.number.isRequired
|
|
223
|
+
} : void 0;
|
|
224
|
+
export { GridHeaderFilterCell };
|