@mui/x-data-grid 6.4.0 → 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 +56 -0
- package/DataGrid/useDataGridProps.js +5 -12
- package/colDef/gridNumericOperators.js +0 -6
- package/components/cell/GridEditInputCell.js +4 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
- package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +2 -1
- package/constants/localeTextConstants.js +26 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +9 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editing/useGridEditing.js +0 -3
- package/hooks/features/focus/gridFocusState.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/hooks/features/focus/useGridFocus.js +55 -9
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/hooks/features/headerFiltering/index.d.ts +1 -0
- package/hooks/features/headerFiltering/index.js +1 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +2 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/hooks/features/rows/useGridRows.js +16 -1
- package/index.js +1 -1
- package/internals/index.d.ts +6 -1
- package/internals/index.js +4 -0
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/internals/utils/useProps.d.ts +8 -0
- package/internals/utils/useProps.js +13 -0
- package/legacy/DataGrid/useDataGridProps.js +8 -8
- package/legacy/colDef/gridNumericOperators.js +0 -6
- package/legacy/components/cell/GridEditInputCell.js +4 -1
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/panel/filterPanel/index.js +2 -1
- package/legacy/constants/localeTextConstants.js +26 -0
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/legacy/hooks/features/editing/useGridEditing.js +0 -3
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +10 -0
- package/legacy/hooks/features/focus/useGridFocus.js +58 -9
- package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
- package/legacy/hooks/features/headerFiltering/index.js +1 -0
- package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
- package/legacy/hooks/features/index.js +2 -1
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/legacy/hooks/features/rows/useGridRows.js +16 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +4 -0
- package/legacy/internals/utils/index.js +2 -1
- package/legacy/internals/utils/useProps.js +11 -0
- package/legacy/locales/arSD.js +28 -0
- package/legacy/locales/beBY.js +28 -0
- package/legacy/locales/bgBG.js +28 -0
- package/legacy/locales/csCZ.js +36 -8
- package/legacy/locales/daDK.js +28 -0
- package/legacy/locales/deDE.js +28 -0
- package/legacy/locales/elGR.js +27 -0
- package/legacy/locales/esES.js +28 -0
- package/legacy/locales/faIR.js +28 -0
- package/legacy/locales/fiFI.js +28 -0
- package/legacy/locales/frFR.js +28 -0
- package/legacy/locales/heIL.js +30 -2
- package/legacy/locales/huHU.js +28 -0
- package/legacy/locales/itIT.js +28 -0
- package/legacy/locales/jaJP.js +28 -0
- package/legacy/locales/koKR.js +28 -0
- package/legacy/locales/nbNO.js +28 -0
- package/legacy/locales/nlNL.js +28 -0
- package/legacy/locales/plPL.js +28 -0
- package/legacy/locales/ptBR.js +28 -0
- package/legacy/locales/roRO.js +28 -0
- package/legacy/locales/ruRU.js +28 -0
- package/legacy/locales/skSK.js +28 -0
- package/legacy/locales/svSE.js +28 -0
- package/legacy/locales/trTR.js +28 -0
- package/legacy/locales/ukUA.js +28 -0
- package/legacy/locales/urPK.js +28 -0
- package/legacy/locales/viVN.js +27 -0
- package/legacy/locales/zhCN.js +28 -0
- package/legacy/locales/zhTW.js +28 -0
- package/legacy/material/index.js +2 -0
- package/legacy/models/api/gridHeaderFilteringApi.js +1 -0
- package/legacy/models/gridHeaderFilteringModel.js +1 -0
- package/legacy/models/index.js +0 -1
- package/locales/arSD.js +28 -0
- package/locales/beBY.js +28 -0
- package/locales/bgBG.js +28 -0
- package/locales/csCZ.js +36 -8
- package/locales/daDK.js +28 -0
- package/locales/deDE.js +28 -0
- package/locales/elGR.js +27 -0
- package/locales/esES.js +28 -0
- package/locales/faIR.js +28 -0
- package/locales/fiFI.js +28 -0
- package/locales/frFR.js +28 -0
- package/locales/heIL.js +30 -2
- package/locales/huHU.js +28 -0
- package/locales/itIT.js +28 -0
- package/locales/jaJP.js +28 -0
- package/locales/koKR.js +28 -0
- package/locales/nbNO.js +28 -0
- package/locales/nlNL.js +28 -0
- package/locales/plPL.js +28 -0
- package/locales/ptBR.js +28 -0
- package/locales/roRO.js +28 -0
- package/locales/ruRU.js +28 -0
- package/locales/skSK.js +28 -0
- package/locales/svSE.js +28 -0
- package/locales/trTR.js +28 -0
- package/locales/ukUA.js +28 -0
- package/locales/urPK.js +28 -0
- package/locales/viVN.js +27 -0
- package/locales/zhCN.js +28 -0
- package/locales/zhTW.js +28 -0
- package/material/index.d.ts +3 -66
- package/material/index.js +2 -0
- package/models/api/gridApiCommon.d.ts +3 -2
- package/models/api/gridCoreApi.d.ts +4 -0
- package/models/api/gridFocusApi.d.ts +6 -0
- package/models/api/gridHeaderFilteringApi.d.ts +30 -0
- package/models/api/gridHeaderFilteringApi.js +1 -0
- package/models/api/gridLocaleTextApi.d.ts +25 -0
- package/models/events/gridEventLookup.d.ts +27 -1
- package/models/gridFilterOperator.d.ts +4 -0
- package/models/gridHeaderFilteringModel.d.ts +5 -0
- package/models/gridHeaderFilteringModel.js +1 -0
- package/models/gridSlotsComponent.d.ts +16 -4
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/index.d.ts +1 -1
- package/models/index.js +0 -1
- package/modern/DataGrid/useDataGridProps.js +5 -12
- package/modern/colDef/gridNumericOperators.js +0 -6
- package/modern/components/cell/GridEditInputCell.js +4 -1
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/panel/filterPanel/index.js +2 -1
- package/modern/constants/localeTextConstants.js +26 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editing/useGridEditing.js +0 -3
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/modern/hooks/features/focus/useGridFocus.js +55 -9
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/modern/hooks/features/headerFiltering/index.js +1 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/modern/hooks/features/rows/useGridRows.js +16 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +4 -0
- package/modern/internals/utils/index.js +2 -1
- package/modern/internals/utils/useProps.js +13 -0
- package/modern/locales/arSD.js +28 -0
- package/modern/locales/beBY.js +28 -0
- package/modern/locales/bgBG.js +28 -0
- package/modern/locales/csCZ.js +36 -8
- package/modern/locales/daDK.js +28 -0
- package/modern/locales/deDE.js +28 -0
- package/modern/locales/elGR.js +27 -0
- package/modern/locales/esES.js +28 -0
- package/modern/locales/faIR.js +28 -0
- package/modern/locales/fiFI.js +28 -0
- package/modern/locales/frFR.js +28 -0
- package/modern/locales/heIL.js +30 -2
- package/modern/locales/huHU.js +28 -0
- package/modern/locales/itIT.js +28 -0
- package/modern/locales/jaJP.js +28 -0
- package/modern/locales/koKR.js +28 -0
- package/modern/locales/nbNO.js +28 -0
- package/modern/locales/nlNL.js +28 -0
- package/modern/locales/plPL.js +28 -0
- package/modern/locales/ptBR.js +28 -0
- package/modern/locales/roRO.js +28 -0
- package/modern/locales/ruRU.js +28 -0
- package/modern/locales/skSK.js +28 -0
- package/modern/locales/svSE.js +28 -0
- package/modern/locales/trTR.js +28 -0
- package/modern/locales/ukUA.js +28 -0
- package/modern/locales/urPK.js +28 -0
- package/modern/locales/viVN.js +27 -0
- package/modern/locales/zhCN.js +28 -0
- package/modern/locales/zhTW.js +28 -0
- package/modern/material/index.js +2 -0
- package/modern/models/api/gridHeaderFilteringApi.js +1 -0
- package/modern/models/gridHeaderFilteringModel.js +1 -0
- package/modern/models/index.js +0 -1
- package/node/DataGrid/useDataGridProps.js +4 -11
- package/node/colDef/gridNumericOperators.js +0 -6
- package/node/components/cell/GridEditInputCell.js +4 -1
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
- package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
- package/node/components/panel/filterPanel/index.js +26 -8
- package/node/constants/localeTextConstants.js +26 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editing/useGridEditing.js +0 -3
- package/node/hooks/features/focus/gridFocusStateSelector.js +9 -1
- package/node/hooks/features/focus/useGridFocus.js +55 -9
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
- package/node/hooks/features/headerFiltering/index.js +16 -0
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +113 -4
- package/node/hooks/features/rows/useGridRows.js +16 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +46 -0
- package/node/internals/utils/index.js +11 -0
- package/node/internals/utils/useProps.js +22 -0
- package/node/locales/arSD.js +28 -0
- package/node/locales/beBY.js +28 -0
- package/node/locales/bgBG.js +28 -0
- package/node/locales/csCZ.js +36 -8
- package/node/locales/daDK.js +28 -0
- package/node/locales/deDE.js +28 -0
- package/node/locales/elGR.js +27 -0
- package/node/locales/esES.js +28 -0
- package/node/locales/faIR.js +28 -0
- package/node/locales/fiFI.js +28 -0
- package/node/locales/frFR.js +28 -0
- package/node/locales/heIL.js +30 -2
- package/node/locales/huHU.js +28 -0
- package/node/locales/itIT.js +28 -0
- package/node/locales/jaJP.js +28 -0
- package/node/locales/koKR.js +28 -0
- package/node/locales/nbNO.js +28 -0
- package/node/locales/nlNL.js +28 -0
- package/node/locales/plPL.js +28 -0
- package/node/locales/ptBR.js +28 -0
- package/node/locales/roRO.js +28 -0
- package/node/locales/ruRU.js +28 -0
- package/node/locales/skSK.js +28 -0
- package/node/locales/svSE.js +28 -0
- package/node/locales/trTR.js +28 -0
- package/node/locales/ukUA.js +28 -0
- package/node/locales/urPK.js +28 -0
- package/node/locales/viVN.js +27 -0
- package/node/locales/zhCN.js +28 -0
- package/node/locales/zhTW.js +28 -0
- package/node/material/index.js +2 -0
- package/node/models/api/gridHeaderFilteringApi.js +5 -0
- package/node/models/gridHeaderFilteringModel.js +5 -0
- package/node/models/index.js +0 -11
- package/package.json +1 -1
|
@@ -2,10 +2,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "getOptionLabel", "getOptionValue"];
|
|
5
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "getOptionLabel", "getOptionValue", "placeholder", "tabIndex", "label", "headerFilterMenu", "isFilterActive", "clearButton"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { unstable_useId as useId } from '@mui/utils';
|
|
9
|
+
import { styled } from '@mui/material/styles';
|
|
9
10
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
10
11
|
import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
11
12
|
import { createElement as _createElement } from "react";
|
|
@@ -33,6 +34,11 @@ var renderSingleSelectOptions = function renderSingleSelectOptions(_ref) {
|
|
|
33
34
|
}), label);
|
|
34
35
|
});
|
|
35
36
|
};
|
|
37
|
+
var SingleSelectOperatorContainer = styled('div')({
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'flex-end',
|
|
40
|
+
width: '100%'
|
|
41
|
+
});
|
|
36
42
|
function GridFilterInputSingleSelect(props) {
|
|
37
43
|
var _item$value, _rootProps$slotProps$, _rootProps$slotProps, _rootProps$slotProps$2, _resolvedColumn, _resolvedColumn2, _rootProps$slotProps2, _rootProps$slotProps3, _rootProps$slotProps4;
|
|
38
44
|
var item = props.item,
|
|
@@ -42,6 +48,12 @@ function GridFilterInputSingleSelect(props) {
|
|
|
42
48
|
focusElementRef = props.focusElementRef,
|
|
43
49
|
getOptionLabelProp = props.getOptionLabel,
|
|
44
50
|
getOptionValueProp = props.getOptionValue,
|
|
51
|
+
placeholder = props.placeholder,
|
|
52
|
+
tabIndex = props.tabIndex,
|
|
53
|
+
labelProp = props.label,
|
|
54
|
+
headerFilterMenu = props.headerFilterMenu,
|
|
55
|
+
isFilterActive = props.isFilterActive,
|
|
56
|
+
clearButton = props.clearButton,
|
|
45
57
|
others = _objectWithoutProperties(props, _excluded);
|
|
46
58
|
var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
|
|
47
59
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -102,36 +114,40 @@ function GridFilterInputSingleSelect(props) {
|
|
|
102
114
|
if (!isSingleSelectColDef(resolvedColumn)) {
|
|
103
115
|
return null;
|
|
104
116
|
}
|
|
105
|
-
var label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
106
|
-
return /*#__PURE__*/_jsxs(
|
|
107
|
-
children: [/*#__PURE__*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
var label = labelProp != null ? labelProp : apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
118
|
+
return /*#__PURE__*/_jsxs(SingleSelectOperatorContainer, {
|
|
119
|
+
children: [/*#__PURE__*/_jsxs(rootProps.slots.baseFormControl, {
|
|
120
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseInputLabel, {
|
|
121
|
+
id: labelId,
|
|
122
|
+
shrink: true,
|
|
123
|
+
variant: "standard",
|
|
124
|
+
children: label
|
|
125
|
+
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
|
|
126
|
+
id: id,
|
|
127
|
+
label: label,
|
|
128
|
+
labelId: labelId,
|
|
129
|
+
value: filterValueState,
|
|
130
|
+
onChange: onFilterChange,
|
|
131
|
+
startAdornment: isFilterActive ? headerFilterMenu : null,
|
|
132
|
+
variant: "standard",
|
|
133
|
+
type: type || 'text',
|
|
134
|
+
inputProps: {
|
|
135
|
+
tabIndex: tabIndex,
|
|
136
|
+
ref: focusElementRef,
|
|
137
|
+
placeholder: placeholder != null ? placeholder : apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
138
|
+
},
|
|
139
|
+
native: isSelectNative
|
|
140
|
+
}, others, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
|
|
141
|
+
children: renderSingleSelectOptions({
|
|
142
|
+
column: resolvedColumn,
|
|
143
|
+
OptionComponent: rootProps.slots.baseSelectOption,
|
|
144
|
+
getOptionLabel: getOptionLabel,
|
|
145
|
+
getOptionValue: getOptionValue,
|
|
146
|
+
isSelectNative: isSelectNative,
|
|
147
|
+
baseSelectOptionProps: (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseSelectOption
|
|
148
|
+
})
|
|
149
|
+
}))]
|
|
150
|
+
}), clearButton]
|
|
135
151
|
});
|
|
136
152
|
}
|
|
137
153
|
process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
|
|
@@ -143,6 +159,7 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
|
|
|
143
159
|
current: PropTypes.object.isRequired
|
|
144
160
|
}).isRequired,
|
|
145
161
|
applyValue: PropTypes.func.isRequired,
|
|
162
|
+
clearButton: PropTypes.node,
|
|
146
163
|
focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
|
|
147
164
|
/**
|
|
148
165
|
* Used to determine the label displayed for a given value option.
|
|
@@ -156,6 +173,12 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
|
|
|
156
173
|
* @returns {string} The value to be used.
|
|
157
174
|
*/
|
|
158
175
|
getOptionValue: PropTypes.func,
|
|
176
|
+
headerFilterMenu: PropTypes.node,
|
|
177
|
+
/**
|
|
178
|
+
* It is `true` if the filter either has a value or an operator with no value
|
|
179
|
+
* required is selected (e.g. `isEmpty`)
|
|
180
|
+
*/
|
|
181
|
+
isFilterActive: PropTypes.bool,
|
|
159
182
|
item: PropTypes.shape({
|
|
160
183
|
field: PropTypes.string.isRequired,
|
|
161
184
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
|
|
4
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "headerFilterMenu", "isFilterActive", "clearButton", "InputProps"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { unstable_useId as useId } from '@mui/utils';
|
|
@@ -15,6 +15,12 @@ function GridFilterInputValue(props) {
|
|
|
15
15
|
type = props.type,
|
|
16
16
|
apiRef = props.apiRef,
|
|
17
17
|
focusElementRef = props.focusElementRef,
|
|
18
|
+
tabIndex = props.tabIndex,
|
|
19
|
+
disabled = props.disabled,
|
|
20
|
+
headerFilterMenu = props.headerFilterMenu,
|
|
21
|
+
isFilterActive = props.isFilterActive,
|
|
22
|
+
clearButton = props.clearButton,
|
|
23
|
+
InputProps = props.InputProps,
|
|
18
24
|
others = _objectWithoutProperties(props, _excluded);
|
|
19
25
|
var filterTimeout = React.useRef();
|
|
20
26
|
var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
|
|
@@ -49,9 +55,6 @@ function GridFilterInputValue(props) {
|
|
|
49
55
|
var itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
|
|
50
56
|
setFilterValueState(String(itemValue));
|
|
51
57
|
}, [item.value]);
|
|
52
|
-
var InputProps = applying ? {
|
|
53
|
-
endAdornment: /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {})
|
|
54
|
-
} : others.InputProps;
|
|
55
58
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
|
|
56
59
|
id: id,
|
|
57
60
|
label: apiRef.current.getLocaleText('filterPanelInputLabel'),
|
|
@@ -60,7 +63,20 @@ function GridFilterInputValue(props) {
|
|
|
60
63
|
onChange: onFilterChange,
|
|
61
64
|
variant: "standard",
|
|
62
65
|
type: type || 'text',
|
|
63
|
-
InputProps:
|
|
66
|
+
InputProps: _extends({}, applying || clearButton ? {
|
|
67
|
+
endAdornment: applying ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {
|
|
68
|
+
fontSize: "small",
|
|
69
|
+
color: "action"
|
|
70
|
+
}) : clearButton
|
|
71
|
+
} : {}, headerFilterMenu && isFilterActive ? {
|
|
72
|
+
startAdornment: headerFilterMenu
|
|
73
|
+
} : {}, {
|
|
74
|
+
disabled: disabled
|
|
75
|
+
}, InputProps, {
|
|
76
|
+
inputProps: _extends({
|
|
77
|
+
tabIndex: tabIndex
|
|
78
|
+
}, InputProps == null ? void 0 : InputProps.inputProps)
|
|
79
|
+
}),
|
|
64
80
|
InputLabelProps: {
|
|
65
81
|
shrink: true
|
|
66
82
|
},
|
|
@@ -76,7 +92,14 @@ process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
|
|
|
76
92
|
current: PropTypes.object.isRequired
|
|
77
93
|
}).isRequired,
|
|
78
94
|
applyValue: PropTypes.func.isRequired,
|
|
95
|
+
clearButton: PropTypes.node,
|
|
79
96
|
focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
|
|
97
|
+
headerFilterMenu: PropTypes.node,
|
|
98
|
+
/**
|
|
99
|
+
* It is `true` if the filter either has a value or an operator with no value
|
|
100
|
+
* required is selected (e.g. `isEmpty`)
|
|
101
|
+
*/
|
|
102
|
+
isFilterActive: PropTypes.bool,
|
|
80
103
|
item: PropTypes.shape({
|
|
81
104
|
field: PropTypes.string.isRequired,
|
|
82
105
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -218,4 +218,4 @@ process.env.NODE_ENV !== "production" ? GridFilterPanel.propTypes = {
|
|
|
218
218
|
*/
|
|
219
219
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
220
220
|
} : void 0;
|
|
221
|
-
export { GridFilterPanel };
|
|
221
|
+
export { GridFilterPanel, getGridFilter };
|
|
@@ -2,7 +2,8 @@ export * from './GridFilterForm';
|
|
|
2
2
|
export * from './GridFilterInputValue';
|
|
3
3
|
export * from './GridFilterInputDate';
|
|
4
4
|
export * from './GridFilterInputSingleSelect';
|
|
5
|
+
export * from './GridFilterInputBoolean';
|
|
5
6
|
export * from './GridFilterInputValueProps';
|
|
6
|
-
export
|
|
7
|
+
export { GridFilterPanel } from './GridFilterPanel';
|
|
7
8
|
export * from './GridFilterInputMultipleValue';
|
|
8
9
|
export * from './GridFilterInputMultipleSingleSelect';
|
|
@@ -60,6 +60,32 @@ export var GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
60
60
|
filterOperatorIsEmpty: 'is empty',
|
|
61
61
|
filterOperatorIsNotEmpty: 'is not empty',
|
|
62
62
|
filterOperatorIsAnyOf: 'is any of',
|
|
63
|
+
'filterOperator=': '=',
|
|
64
|
+
'filterOperator!=': '!=',
|
|
65
|
+
'filterOperator>': '>',
|
|
66
|
+
'filterOperator>=': '>=',
|
|
67
|
+
'filterOperator<': '<',
|
|
68
|
+
'filterOperator<=': '<=',
|
|
69
|
+
// Header filter operators text
|
|
70
|
+
headerFilterOperatorContains: 'Contains',
|
|
71
|
+
headerFilterOperatorEquals: 'Equals',
|
|
72
|
+
headerFilterOperatorStartsWith: 'Starts with',
|
|
73
|
+
headerFilterOperatorEndsWith: 'Ends with',
|
|
74
|
+
headerFilterOperatorIs: 'Is',
|
|
75
|
+
headerFilterOperatorNot: 'Is not',
|
|
76
|
+
headerFilterOperatorAfter: 'Is after',
|
|
77
|
+
headerFilterOperatorOnOrAfter: 'Is on or after',
|
|
78
|
+
headerFilterOperatorBefore: 'Is before',
|
|
79
|
+
headerFilterOperatorOnOrBefore: 'Is on or before',
|
|
80
|
+
headerFilterOperatorIsEmpty: 'Is empty',
|
|
81
|
+
headerFilterOperatorIsNotEmpty: 'Is not empty',
|
|
82
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
83
|
+
'headerFilterOperator=': 'Equals',
|
|
84
|
+
'headerFilterOperator!=': 'Not equals',
|
|
85
|
+
'headerFilterOperator>': 'Is greater than',
|
|
86
|
+
'headerFilterOperator>=': 'Is greater than or equal to',
|
|
87
|
+
'headerFilterOperator<': 'Is less than',
|
|
88
|
+
'headerFilterOperator<=': 'Is less than or equal to',
|
|
63
89
|
// Filter values text
|
|
64
90
|
filterValueAny: 'any',
|
|
65
91
|
filterValueTrue: 'true',
|
|
@@ -298,10 +298,8 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
298
298
|
var tabIndex = columnGroupHeaderTabIndexState !== null && columnGroupHeaderTabIndexState.depth === depth && columnFields.includes(columnGroupHeaderTabIndexState.field) ? 0 : -1;
|
|
299
299
|
var headerInfo = {
|
|
300
300
|
groupId: groupId,
|
|
301
|
-
width: columnFields.
|
|
302
|
-
return apiRef.current.getColumn(field).computedWidth;
|
|
303
|
-
}).reduce(function (acc, val) {
|
|
304
|
-
return acc + val;
|
|
301
|
+
width: columnFields.reduce(function (acc, field) {
|
|
302
|
+
return acc + apiRef.current.getColumn(field).computedWidth;
|
|
305
303
|
}, 0),
|
|
306
304
|
fields: columnFields,
|
|
307
305
|
colIndex: columnIndex,
|
|
@@ -360,6 +358,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
360
358
|
return {
|
|
361
359
|
renderContext: renderContext,
|
|
362
360
|
getColumnHeaders: getColumnHeaders,
|
|
361
|
+
getColumnsToRender: getColumnsToRender,
|
|
363
362
|
getColumnGroupHeaders: getColumnGroupHeaders,
|
|
364
363
|
isDragging: !!dragCol,
|
|
365
364
|
getRootProps: function getRootProps() {
|
|
@@ -373,6 +372,7 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
373
372
|
ref: handleInnerRef,
|
|
374
373
|
role: 'rowgroup'
|
|
375
374
|
};
|
|
376
|
-
}
|
|
375
|
+
},
|
|
376
|
+
headerHeight: headerHeight
|
|
377
377
|
};
|
|
378
378
|
};
|
|
@@ -162,8 +162,8 @@ export function useGridDimensions(apiRef, props) {
|
|
|
162
162
|
if (!mainEl) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
var height = mainEl.
|
|
166
|
-
var width = mainEl.
|
|
165
|
+
var height = mainEl.clientHeight || 0;
|
|
166
|
+
var width = mainEl.clientWidth || 0;
|
|
167
167
|
var win = ownerWindow(mainEl);
|
|
168
168
|
var computedStyle = win.getComputedStyle(mainEl);
|
|
169
169
|
var paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
@@ -32,9 +32,6 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
|
|
|
32
32
|
if (isCellEditableProp) {
|
|
33
33
|
return isCellEditableProp(params);
|
|
34
34
|
}
|
|
35
|
-
if (params.rowNode.type === 'pinnedRow') {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
35
|
return true;
|
|
39
36
|
}, [isCellEditableProp]);
|
|
40
37
|
var maybeDebounce = function maybeDebounce(id, field, debounceMs, callback) {
|
|
@@ -9,6 +9,11 @@ export var gridFocusColumnHeaderSelector = createSelector(gridFocusStateSelector
|
|
|
9
9
|
return focusState.columnHeader;
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
export var unstable_gridFocusColumnHeaderFilterSelector = createSelector(gridFocusStateSelector, function (focusState) {
|
|
14
|
+
return focusState.columnHeaderFilter;
|
|
15
|
+
});
|
|
16
|
+
|
|
12
17
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
18
|
export var unstable_gridFocusColumnGroupHeaderSelector = createSelector(gridFocusStateSelector, function (focusState) {
|
|
14
19
|
return focusState.columnGroupHeader;
|
|
@@ -23,6 +28,11 @@ export var gridTabIndexColumnHeaderSelector = createSelector(gridTabIndexStateSe
|
|
|
23
28
|
return state.columnHeader;
|
|
24
29
|
});
|
|
25
30
|
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
32
|
+
export var unstable_gridTabIndexColumnHeaderFilterSelector = createSelector(gridTabIndexStateSelector, function (state) {
|
|
33
|
+
return state.columnHeaderFilter;
|
|
34
|
+
});
|
|
35
|
+
|
|
26
36
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
37
|
export var unstable_gridTabIndexColumnGroupHeaderSelector = createSelector(gridTabIndexStateSelector, function (state) {
|
|
28
38
|
return state.columnGroupHeader;
|
|
@@ -9,16 +9,19 @@ import { gridFocusCellSelector, unstable_gridFocusColumnGroupHeaderSelector } fr
|
|
|
9
9
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
10
10
|
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
11
|
import { clamp } from '../../../utils/utils';
|
|
12
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
12
13
|
export var focusStateInitializer = function focusStateInitializer(state) {
|
|
13
14
|
return _extends({}, state, {
|
|
14
15
|
focus: {
|
|
15
16
|
cell: null,
|
|
16
17
|
columnHeader: null,
|
|
18
|
+
columnHeaderFilter: null,
|
|
17
19
|
columnGroupHeader: null
|
|
18
20
|
},
|
|
19
21
|
tabIndex: {
|
|
20
22
|
cell: null,
|
|
21
23
|
columnHeader: null,
|
|
24
|
+
columnHeaderFilter: null,
|
|
22
25
|
columnGroupHeader: null
|
|
23
26
|
}
|
|
24
27
|
});
|
|
@@ -54,6 +57,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
54
57
|
field: field
|
|
55
58
|
},
|
|
56
59
|
columnHeader: null,
|
|
60
|
+
columnHeaderFilter: null,
|
|
57
61
|
columnGroupHeader: null
|
|
58
62
|
},
|
|
59
63
|
focus: {
|
|
@@ -62,6 +66,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
62
66
|
field: field
|
|
63
67
|
},
|
|
64
68
|
columnHeader: null,
|
|
69
|
+
columnHeaderFilter: null,
|
|
65
70
|
columnGroupHeader: null
|
|
66
71
|
}
|
|
67
72
|
});
|
|
@@ -90,6 +95,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
90
95
|
columnHeader: {
|
|
91
96
|
field: field
|
|
92
97
|
},
|
|
98
|
+
columnHeaderFilter: null,
|
|
93
99
|
cell: null,
|
|
94
100
|
columnGroupHeader: null
|
|
95
101
|
},
|
|
@@ -97,6 +103,34 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
97
103
|
columnHeader: {
|
|
98
104
|
field: field
|
|
99
105
|
},
|
|
106
|
+
columnHeaderFilter: null,
|
|
107
|
+
cell: null,
|
|
108
|
+
columnGroupHeader: null
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
apiRef.current.forceUpdate();
|
|
113
|
+
}, [apiRef, logger, publishCellFocusOut]);
|
|
114
|
+
var setColumnHeaderFilterFocus = React.useCallback(function (field) {
|
|
115
|
+
var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
116
|
+
var cell = gridFocusCellSelector(apiRef);
|
|
117
|
+
publishCellFocusOut(cell, event);
|
|
118
|
+
apiRef.current.setState(function (state) {
|
|
119
|
+
logger.debug("Focusing on column header filter with colIndex=".concat(field));
|
|
120
|
+
return _extends({}, state, {
|
|
121
|
+
tabIndex: {
|
|
122
|
+
columnHeader: null,
|
|
123
|
+
columnHeaderFilter: {
|
|
124
|
+
field: field
|
|
125
|
+
},
|
|
126
|
+
cell: null,
|
|
127
|
+
columnGroupHeader: null
|
|
128
|
+
},
|
|
129
|
+
focus: {
|
|
130
|
+
columnHeader: null,
|
|
131
|
+
columnHeaderFilter: {
|
|
132
|
+
field: field
|
|
133
|
+
},
|
|
100
134
|
cell: null,
|
|
101
135
|
columnGroupHeader: null
|
|
102
136
|
}
|
|
@@ -118,6 +152,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
118
152
|
depth: depth
|
|
119
153
|
},
|
|
120
154
|
columnHeader: null,
|
|
155
|
+
columnHeaderFilter: null,
|
|
121
156
|
cell: null
|
|
122
157
|
},
|
|
123
158
|
focus: {
|
|
@@ -126,6 +161,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
126
161
|
depth: depth
|
|
127
162
|
},
|
|
128
163
|
columnHeader: null,
|
|
164
|
+
columnHeaderFilter: null,
|
|
129
165
|
cell: null
|
|
130
166
|
}
|
|
131
167
|
});
|
|
@@ -137,8 +173,18 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
137
173
|
}, [apiRef]);
|
|
138
174
|
var moveFocusToRelativeCell = React.useCallback(function (id, field, direction) {
|
|
139
175
|
var columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
140
|
-
var rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
141
176
|
var visibleColumns = gridVisibleColumnDefinitionsSelector(apiRef);
|
|
177
|
+
var currentPage = getVisibleRows(apiRef, {
|
|
178
|
+
pagination: props.pagination,
|
|
179
|
+
paginationMode: props.paginationMode
|
|
180
|
+
});
|
|
181
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
182
|
+
|
|
183
|
+
// Include pinned rows as well
|
|
184
|
+
var currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
|
|
185
|
+
var rowIndexToFocus = currentPageRows.findIndex(function (row) {
|
|
186
|
+
return row.id === id;
|
|
187
|
+
});
|
|
142
188
|
if (direction === 'right') {
|
|
143
189
|
columnIndexToFocus += 1;
|
|
144
190
|
} else if (direction === 'left') {
|
|
@@ -146,14 +192,10 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
146
192
|
} else {
|
|
147
193
|
rowIndexToFocus += 1;
|
|
148
194
|
}
|
|
149
|
-
var currentPage = getVisibleRows(apiRef, {
|
|
150
|
-
pagination: props.pagination,
|
|
151
|
-
paginationMode: props.paginationMode
|
|
152
|
-
});
|
|
153
195
|
if (columnIndexToFocus >= visibleColumns.length) {
|
|
154
196
|
// Go to next row if we are after the last column
|
|
155
197
|
rowIndexToFocus += 1;
|
|
156
|
-
if (rowIndexToFocus <
|
|
198
|
+
if (rowIndexToFocus < currentPageRows.length) {
|
|
157
199
|
// Go to first column of the next row if there's one more row
|
|
158
200
|
columnIndexToFocus = 0;
|
|
159
201
|
}
|
|
@@ -165,8 +207,11 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
165
207
|
columnIndexToFocus = visibleColumns.length - 1;
|
|
166
208
|
}
|
|
167
209
|
}
|
|
168
|
-
rowIndexToFocus = clamp(rowIndexToFocus, 0,
|
|
169
|
-
var rowToFocus =
|
|
210
|
+
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPageRows.length - 1);
|
|
211
|
+
var rowToFocus = currentPageRows[rowIndexToFocus];
|
|
212
|
+
if (!rowToFocus) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
170
215
|
var colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
171
216
|
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
172
217
|
if (direction === 'left' || direction === 'below') {
|
|
@@ -218,6 +263,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
218
263
|
focus: {
|
|
219
264
|
cell: null,
|
|
220
265
|
columnHeader: null,
|
|
266
|
+
columnHeaderFilter: null,
|
|
221
267
|
columnGroupHeader: null
|
|
222
268
|
}
|
|
223
269
|
});
|
|
@@ -258,6 +304,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
258
304
|
focus: {
|
|
259
305
|
cell: null,
|
|
260
306
|
columnHeader: null,
|
|
307
|
+
columnHeaderFilter: null,
|
|
261
308
|
columnGroupHeader: null
|
|
262
309
|
}
|
|
263
310
|
});
|
|
@@ -288,6 +335,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
288
335
|
focus: {
|
|
289
336
|
cell: null,
|
|
290
337
|
columnHeader: null,
|
|
338
|
+
columnHeaderFilter: null,
|
|
291
339
|
columnGroupHeader: null
|
|
292
340
|
}
|
|
293
341
|
});
|
|
@@ -296,7 +344,8 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
296
344
|
}, [apiRef]);
|
|
297
345
|
var focusApi = {
|
|
298
346
|
setCellFocus: setCellFocus,
|
|
299
|
-
setColumnHeaderFocus: setColumnHeaderFocus
|
|
347
|
+
setColumnHeaderFocus: setColumnHeaderFocus,
|
|
348
|
+
setColumnHeaderFilterFocus: setColumnHeaderFilterFocus
|
|
300
349
|
};
|
|
301
350
|
var focusPrivateApi = {
|
|
302
351
|
moveFocusToRelativeCell: moveFocusToRelativeCell,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { createSelector } from '../../../utils/createSelector';
|
|
3
|
+
export var unstable_gridHeaderFilteringStateSelector = function unstable_gridHeaderFilteringStateSelector(state) {
|
|
4
|
+
return state.headerFiltering;
|
|
5
|
+
};
|
|
6
|
+
export var unstable_gridHeaderFilteringEditFieldSelector = createSelector(unstable_gridHeaderFilteringStateSelector, function (headerFilteringState) {
|
|
7
|
+
return headerFilteringState.editing;
|
|
8
|
+
});
|
|
9
|
+
export var unstable_gridHeaderFilteringMenuSelector = createSelector(unstable_gridHeaderFilteringStateSelector, function (headerFilteringState) {
|
|
10
|
+
return headerFilteringState.menuOpen;
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridHeaderFilteringSelectors';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
|
+
import { useGridLogger } from '../../utils';
|
|
5
|
+
import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
6
|
+
export var headerFilteringStateInitializer = function headerFilteringStateInitializer(state) {
|
|
7
|
+
return _extends({}, state, {
|
|
8
|
+
headerFiltering: {
|
|
9
|
+
editing: null,
|
|
10
|
+
menuOpen: null
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export var useGridHeaderFiltering = function useGridHeaderFiltering(apiRef, props) {
|
|
15
|
+
var logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
|
|
16
|
+
var setHeaderFilterState = React.useCallback(function (headerFilterState) {
|
|
17
|
+
apiRef.current.setState(function (state) {
|
|
18
|
+
var _headerFilterState$ed, _headerFilterState$me;
|
|
19
|
+
// Safety check to avoid MIT users from using it
|
|
20
|
+
// This hook should ultimately be moved to the Pro package
|
|
21
|
+
if (props.signature === 'DataGrid') {
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
24
|
+
return _extends({}, state, {
|
|
25
|
+
headerFiltering: {
|
|
26
|
+
editing: (_headerFilterState$ed = headerFilterState.editing) != null ? _headerFilterState$ed : null,
|
|
27
|
+
menuOpen: (_headerFilterState$me = headerFilterState.menuOpen) != null ? _headerFilterState$me : null
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
apiRef.current.forceUpdate();
|
|
32
|
+
}, [apiRef, props.signature]);
|
|
33
|
+
var startHeaderFilterEditMode = React.useCallback(function (field) {
|
|
34
|
+
logger.debug("Starting edit mode on header filter for field: ".concat(field));
|
|
35
|
+
apiRef.current.setHeaderFilterState({
|
|
36
|
+
editing: field
|
|
37
|
+
});
|
|
38
|
+
}, [apiRef, logger]);
|
|
39
|
+
var stopHeaderFilterEditMode = React.useCallback(function () {
|
|
40
|
+
logger.debug("Stopping edit mode on header filter");
|
|
41
|
+
apiRef.current.setHeaderFilterState({
|
|
42
|
+
editing: null
|
|
43
|
+
});
|
|
44
|
+
}, [apiRef, logger]);
|
|
45
|
+
var showHeaderFilterMenu = React.useCallback(function (field) {
|
|
46
|
+
logger.debug("Opening header filter menu for field: ".concat(field));
|
|
47
|
+
apiRef.current.setHeaderFilterState({
|
|
48
|
+
menuOpen: field
|
|
49
|
+
});
|
|
50
|
+
}, [apiRef, logger]);
|
|
51
|
+
var hideHeaderFilterMenu = React.useCallback(function () {
|
|
52
|
+
logger.debug("Hiding header filter menu for active field");
|
|
53
|
+
var fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
|
|
54
|
+
if (fieldToFocus) {
|
|
55
|
+
var columnLookup = gridColumnLookupSelector(apiRef);
|
|
56
|
+
var columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
|
|
57
|
+
var orderedFields = gridColumnFieldsSelector(apiRef);
|
|
58
|
+
|
|
59
|
+
// If the column was removed from the grid, we need to find the closest visible field
|
|
60
|
+
if (!columnLookup[fieldToFocus]) {
|
|
61
|
+
fieldToFocus = orderedFields[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// If the field to focus is hidden, we need to find the closest visible field
|
|
65
|
+
if (columnVisibilityModel[fieldToFocus] === false) {
|
|
66
|
+
// contains visible column fields + the field that was just hidden
|
|
67
|
+
var visibleOrderedFields = orderedFields.filter(function (field) {
|
|
68
|
+
if (field === fieldToFocus) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return columnVisibilityModel[field] !== false;
|
|
72
|
+
});
|
|
73
|
+
var fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
|
|
74
|
+
fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
|
|
75
|
+
}
|
|
76
|
+
apiRef.current.setHeaderFilterState({
|
|
77
|
+
menuOpen: null
|
|
78
|
+
});
|
|
79
|
+
apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
|
|
80
|
+
}
|
|
81
|
+
}, [apiRef, logger]);
|
|
82
|
+
var headerFilterPrivateApi = {
|
|
83
|
+
setHeaderFilterState: setHeaderFilterState
|
|
84
|
+
};
|
|
85
|
+
var headerFilterApi = {
|
|
86
|
+
startHeaderFilterEditMode: startHeaderFilterEditMode,
|
|
87
|
+
stopHeaderFilterEditMode: stopHeaderFilterEditMode,
|
|
88
|
+
showHeaderFilterMenu: showHeaderFilterMenu,
|
|
89
|
+
hideHeaderFilterMenu: hideHeaderFilterMenu
|
|
90
|
+
};
|
|
91
|
+
useGridApiMethod(apiRef, headerFilterApi, 'public');
|
|
92
|
+
useGridApiMethod(apiRef, headerFilterPrivateApi, 'private');
|
|
93
|
+
};
|