@mui/x-data-grid 6.6.0 → 6.8.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 +147 -13
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +23 -69
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/index.d.ts +2 -1
- package/components/cell/index.js +1 -1
- package/components/containers/GridRootStyles.js +38 -17
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/panel/GridColumnsPanel.d.ts +14 -0
- package/components/panel/GridColumnsPanel.js +14 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -0
- package/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/virtualization/GridVirtualScroller.js +4 -9
- package/components/virtualization/GridVirtualScrollerContent.js +11 -20
- package/constants/defaultGridSlotsComponents.js +6 -2
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +4 -4
- package/hooks/core/useGridApiInitialization.js +4 -1
- package/hooks/core/useGridStateInitialization.js +2 -9
- package/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
- package/hooks/features/filter/gridFilterUtils.js +19 -13
- package/hooks/features/filter/useGridFilter.js +4 -2
- package/hooks/features/focus/useGridFocus.js +10 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/hooks/features/sorting/useGridSorting.js +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
- package/hooks/features/virtualization/useGridVirtualScroller.js +42 -40
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridSelector.d.ts +3 -1
- package/hooks/utils/useGridSelector.js +37 -6
- package/hooks/utils/useLazyRef.d.ts +2 -0
- package/hooks/utils/useLazyRef.js +9 -0
- package/hooks/utils/useOnMount.d.ts +2 -0
- package/hooks/utils/useOnMount.js +7 -0
- package/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +25 -69
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/index.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +25 -18
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/legacy/components/panel/GridColumnsPanel.js +14 -0
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +7 -7
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +1 -5
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -6
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/legacy/components/toolbar/GridToolbar.js +2 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
- package/legacy/constants/defaultGridSlotsComponents.js +6 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +4 -4
- package/legacy/hooks/core/useGridApiInitialization.js +4 -1
- package/legacy/hooks/core/useGridStateInitialization.js +2 -7
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +4 -2
- package/legacy/hooks/features/focus/useGridFocus.js +10 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/legacy/hooks/features/sorting/useGridSorting.js +2 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
- package/legacy/hooks/utils/index.js +1 -1
- package/legacy/hooks/utils/useGridSelector.js +43 -5
- package/legacy/hooks/utils/useLazyRef.js +9 -0
- package/legacy/hooks/utils/useOnMount.js +7 -0
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +4 -4
- package/legacy/locales/beBY.js +4 -4
- package/legacy/locales/bgBG.js +4 -4
- package/legacy/locales/csCZ.js +25 -27
- package/legacy/locales/daDK.js +4 -4
- package/legacy/locales/deDE.js +25 -27
- package/legacy/locales/elGR.js +70 -79
- package/legacy/locales/esES.js +4 -4
- package/legacy/locales/faIR.js +4 -4
- package/legacy/locales/fiFI.js +4 -4
- package/legacy/locales/heIL.js +4 -4
- package/legacy/locales/huHU.js +4 -4
- package/legacy/locales/itIT.js +4 -4
- package/legacy/locales/jaJP.js +4 -4
- package/legacy/locales/koKR.js +4 -4
- package/legacy/locales/nbNO.js +4 -4
- package/legacy/locales/plPL.js +4 -4
- package/legacy/locales/ptBR.js +4 -4
- package/legacy/locales/roRO.js +4 -4
- package/legacy/locales/ruRU.js +4 -4
- package/legacy/locales/skSK.js +4 -4
- package/legacy/locales/svSE.js +4 -4
- package/legacy/locales/trTR.js +16 -17
- package/legacy/locales/ukUA.js +4 -4
- package/legacy/locales/urPK.js +4 -4
- package/legacy/locales/viVN.js +4 -4
- package/legacy/locales/zhCN.js +4 -4
- package/legacy/locales/zhTW.js +4 -4
- package/legacy/utils/EventManager.js +2 -2
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/doesSupportPreventScroll.js +13 -0
- package/legacy/utils/fastMemo.js +5 -0
- package/legacy/utils/fastObjectShallowCompare.js +32 -0
- package/legacy/utils/keyboardUtils.js +4 -2
- package/locales/arSD.js +4 -4
- package/locales/beBY.js +4 -4
- package/locales/bgBG.js +4 -4
- package/locales/csCZ.js +25 -27
- package/locales/daDK.js +4 -4
- package/locales/deDE.js +25 -27
- package/locales/elGR.js +66 -79
- package/locales/esES.js +4 -4
- package/locales/faIR.js +4 -4
- package/locales/fiFI.js +4 -4
- package/locales/heIL.js +4 -4
- package/locales/huHU.js +4 -4
- package/locales/itIT.js +4 -4
- package/locales/jaJP.js +4 -4
- package/locales/koKR.js +4 -4
- package/locales/nbNO.js +4 -4
- package/locales/plPL.js +4 -4
- package/locales/ptBR.js +4 -4
- package/locales/roRO.js +4 -4
- package/locales/ruRU.js +4 -4
- package/locales/skSK.js +4 -4
- package/locales/svSE.js +4 -4
- package/locales/trTR.js +16 -17
- package/locales/ukUA.js +4 -4
- package/locales/urPK.js +4 -4
- package/locales/viVN.js +4 -4
- package/locales/zhCN.js +4 -4
- package/locales/zhTW.js +4 -4
- package/models/api/gridCoreApi.d.ts +6 -0
- package/models/colDef/gridColDef.d.ts +4 -3
- package/models/colDef/gridColType.d.ts +3 -1
- package/models/events/gridEventLookup.d.ts +11 -3
- package/modern/components/GridColumnHeaders.js +3 -1
- package/modern/components/GridRow.js +22 -69
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/index.js +1 -1
- package/modern/components/containers/GridRootStyles.js +38 -17
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/panel/GridColumnsPanel.js +14 -0
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/virtualization/GridVirtualScroller.js +4 -9
- package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/modern/constants/defaultGridSlotsComponents.js +6 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +4 -4
- package/modern/hooks/core/useGridApiInitialization.js +4 -1
- package/modern/hooks/core/useGridStateInitialization.js +2 -9
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
- package/modern/hooks/features/filter/useGridFilter.js +4 -2
- package/modern/hooks/features/focus/useGridFocus.js +9 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/modern/hooks/features/sorting/useGridSorting.js +2 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +42 -40
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridSelector.js +37 -6
- package/modern/hooks/utils/useLazyRef.js +9 -0
- package/modern/hooks/utils/useOnMount.js +7 -0
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +4 -4
- package/modern/locales/beBY.js +4 -4
- package/modern/locales/bgBG.js +4 -4
- package/modern/locales/csCZ.js +25 -27
- package/modern/locales/daDK.js +4 -4
- package/modern/locales/deDE.js +25 -27
- package/modern/locales/elGR.js +66 -79
- package/modern/locales/esES.js +4 -4
- package/modern/locales/faIR.js +4 -4
- package/modern/locales/fiFI.js +4 -4
- package/modern/locales/heIL.js +4 -4
- package/modern/locales/huHU.js +4 -4
- package/modern/locales/itIT.js +4 -4
- package/modern/locales/jaJP.js +4 -4
- package/modern/locales/koKR.js +4 -4
- package/modern/locales/nbNO.js +4 -4
- package/modern/locales/plPL.js +4 -4
- package/modern/locales/ptBR.js +4 -4
- package/modern/locales/roRO.js +4 -4
- package/modern/locales/ruRU.js +4 -4
- package/modern/locales/skSK.js +4 -4
- package/modern/locales/svSE.js +4 -4
- package/modern/locales/trTR.js +16 -17
- package/modern/locales/ukUA.js +4 -4
- package/modern/locales/urPK.js +4 -4
- package/modern/locales/viVN.js +4 -4
- package/modern/locales/zhCN.js +4 -4
- package/modern/locales/zhTW.js +4 -4
- package/modern/utils/EventManager.js +2 -2
- package/modern/utils/Store.js +24 -0
- package/modern/utils/doesSupportPreventScroll.js +13 -0
- package/modern/utils/fastMemo.js +5 -0
- package/modern/utils/fastObjectShallowCompare.js +32 -0
- package/modern/utils/keyboardUtils.js +4 -2
- package/node/components/GridColumnHeaders.js +4 -2
- package/node/components/GridRow.js +22 -69
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/index.js +17 -10
- package/node/components/containers/GridRootStyles.js +38 -17
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/panel/GridColumnsPanel.js +14 -0
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/node/components/toolbar/GridToolbar.js +2 -2
- package/node/components/virtualization/GridVirtualScroller.js +4 -9
- package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/node/constants/defaultGridSlotsComponents.js +4 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +4 -4
- package/node/hooks/core/useGridApiInitialization.js +4 -1
- package/node/hooks/core/useGridStateInitialization.js +2 -9
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterUtils.js +17 -12
- package/node/hooks/features/filter/useGridFilter.js +7 -5
- package/node/hooks/features/focus/useGridFocus.js +9 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/node/hooks/features/sorting/useGridSorting.js +2 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +42 -38
- package/node/hooks/utils/index.js +14 -10
- package/node/hooks/utils/useGridSelector.js +41 -7
- package/node/hooks/utils/useLazyRef.js +17 -0
- package/node/hooks/utils/useOnMount.js +15 -0
- package/node/index.js +1 -1
- package/node/locales/arSD.js +4 -4
- package/node/locales/beBY.js +4 -4
- package/node/locales/bgBG.js +4 -4
- package/node/locales/csCZ.js +25 -27
- package/node/locales/daDK.js +4 -4
- package/node/locales/deDE.js +25 -27
- package/node/locales/elGR.js +66 -79
- package/node/locales/esES.js +4 -4
- package/node/locales/faIR.js +4 -4
- package/node/locales/fiFI.js +4 -4
- package/node/locales/heIL.js +4 -4
- package/node/locales/huHU.js +4 -4
- package/node/locales/itIT.js +4 -4
- package/node/locales/jaJP.js +4 -4
- package/node/locales/koKR.js +4 -4
- package/node/locales/nbNO.js +4 -4
- package/node/locales/plPL.js +4 -4
- package/node/locales/ptBR.js +4 -4
- package/node/locales/roRO.js +4 -4
- package/node/locales/ruRU.js +4 -4
- package/node/locales/skSK.js +4 -4
- package/node/locales/svSE.js +4 -4
- package/node/locales/trTR.js +16 -17
- package/node/locales/ukUA.js +4 -4
- package/node/locales/urPK.js +4 -4
- package/node/locales/viVN.js +4 -4
- package/node/locales/zhCN.js +4 -4
- package/node/locales/zhTW.js +4 -4
- package/node/utils/EventManager.js +2 -2
- package/node/utils/Store.js +31 -0
- package/node/utils/doesSupportPreventScroll.js +19 -0
- package/node/utils/fastMemo.js +13 -0
- package/node/utils/fastObjectShallowCompare.js +38 -0
- package/node/utils/keyboardUtils.js +4 -2
- package/package.json +1 -1
- package/themeAugmentation/overrides.d.ts +1 -1
- package/utils/EventManager.js +2 -2
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/doesSupportPreventScroll.d.ts +1 -0
- package/utils/doesSupportPreventScroll.js +13 -0
- package/utils/fastMemo.d.ts +1 -0
- package/utils/fastMemo.js +5 -0
- package/utils/fastObjectShallowCompare.d.ts +1 -0
- package/utils/fastObjectShallowCompare.js +32 -0
- package/utils/keyboardUtils.js +4 -2
|
@@ -20,11 +20,12 @@ var _warning = require("../../../utils/warning");
|
|
|
20
20
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
21
21
|
var _utils2 = require("../../../utils/utils");
|
|
22
22
|
var _gridRowParams = require("../../../models/params/gridRowParams");
|
|
23
|
+
var _colDef = require("../../../colDef");
|
|
23
24
|
const _excluded = ["id"],
|
|
24
25
|
_excluded2 = ["id"];
|
|
25
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
const missingOnProcessRowUpdateErrorWarning = (0, _warning.buildWarning)(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
28
|
+
const missingOnProcessRowUpdateErrorWarning = (0, _warning.buildWarning)(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#server-side-persistence.'], 'error');
|
|
28
29
|
const useGridRowEditing = (apiRef, props) => {
|
|
29
30
|
const [rowModesModel, setRowModesModel] = React.useState({});
|
|
30
31
|
const rowModesModelRef = React.useRef(rowModesModel);
|
|
@@ -122,7 +123,13 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
122
123
|
} else if (event.key === 'Enter') {
|
|
123
124
|
reason = _gridRowParams.GridRowEditStopReasons.enterKeyDown;
|
|
124
125
|
} else if (event.key === 'Tab') {
|
|
125
|
-
const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef).filter(field =>
|
|
126
|
+
const columnFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef).filter(field => {
|
|
127
|
+
const column = apiRef.current.getColumn(field);
|
|
128
|
+
if (column.type === _colDef.GRID_ACTIONS_COLUMN_TYPE) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return apiRef.current.isCellEditable(apiRef.current.getCellParams(params.id, field));
|
|
132
|
+
});
|
|
126
133
|
if (event.shiftKey) {
|
|
127
134
|
if (params.field === columnFields[0]) {
|
|
128
135
|
// Exit if user pressed Shift+Tab on the first field
|
|
@@ -143,8 +150,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
if (reason) {
|
|
146
|
-
const
|
|
147
|
-
const newParams = (0, _extends2.default)({}, rowParams, {
|
|
153
|
+
const newParams = (0, _extends2.default)({}, apiRef.current.getRowParams(params.id), {
|
|
148
154
|
reason,
|
|
149
155
|
field: params.field
|
|
150
156
|
});
|
|
@@ -186,7 +192,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
186
192
|
id,
|
|
187
193
|
field,
|
|
188
194
|
reason,
|
|
189
|
-
key
|
|
195
|
+
key,
|
|
196
|
+
columns
|
|
190
197
|
} = params;
|
|
191
198
|
const startRowEditModeParams = {
|
|
192
199
|
id,
|
|
@@ -198,7 +205,8 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
198
205
|
// The sequence of events makes the key pressed by the end-users update the textbox directly.
|
|
199
206
|
startRowEditModeParams.deleteValue = !!field;
|
|
200
207
|
} else {
|
|
201
|
-
|
|
208
|
+
const colDef = columns.find(col => col.field === field);
|
|
209
|
+
startRowEditModeParams.initialValue = colDef.valueParser ? colDef.valueParser(key) : key;
|
|
202
210
|
}
|
|
203
211
|
} else if (reason === _gridRowParams.GridRowEditStartReasons.deleteKeyDown) {
|
|
204
212
|
startRowEditModeParams.deleteValue = !!field;
|
|
@@ -194,21 +194,25 @@ const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
196
|
exports.buildAggregatedFilterApplier = buildAggregatedFilterApplier;
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
197
|
+
const isNotNull = result => result != null;
|
|
198
|
+
const filterModelItems = (cache, apiRef, items) => {
|
|
199
|
+
if (!cache.cleanedFilterItems) {
|
|
200
|
+
cache.cleanedFilterItems = items.filter(item => getFilterCallbackFromItem(item, apiRef) !== null);
|
|
201
|
+
}
|
|
202
|
+
return cache.cleanedFilterItems;
|
|
203
|
+
};
|
|
204
|
+
const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel, apiRef, cache) => {
|
|
205
|
+
const cleanedFilterItems = filterModelItems(cache, apiRef, filterModel.items);
|
|
206
|
+
const cleanedFilterItemResults = allFilterItemResults.filter(isNotNull);
|
|
207
|
+
const cleanedQuickFilterResults = allQuickFilterResults.filter(isNotNull);
|
|
205
208
|
|
|
206
209
|
// get result for filter items model
|
|
207
|
-
if (
|
|
210
|
+
if (cleanedFilterItemResults.length > 0) {
|
|
208
211
|
// Return true if the item pass with one of the rows
|
|
209
212
|
const filterItemPredicate = item => {
|
|
210
|
-
return
|
|
213
|
+
return cleanedFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
|
|
211
214
|
};
|
|
215
|
+
const logicOperator = filterModel.logicOperator ?? (0, _gridFilterState.getDefaultGridFilterModel)().logicOperator;
|
|
212
216
|
if (logicOperator === _models.GridLogicOperator.And) {
|
|
213
217
|
const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
214
218
|
if (!passesAllFilters) {
|
|
@@ -223,11 +227,12 @@ const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterMode
|
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
// get result for quick filter model
|
|
226
|
-
if (
|
|
230
|
+
if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
|
|
227
231
|
// Return true if the item pass with one of the rows
|
|
228
232
|
const quickFilterValuePredicate = value => {
|
|
229
|
-
return
|
|
233
|
+
return cleanedQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
|
|
230
234
|
};
|
|
235
|
+
const quickFilterLogicOperator = filterModel.quickFilterLogicOperator ?? (0, _gridFilterState.getDefaultGridFilterModel)().quickFilterLogicOperator;
|
|
231
236
|
if (quickFilterLogicOperator === _models.GridLogicOperator.And) {
|
|
232
237
|
const passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
|
|
233
238
|
if (!passesAllQuickFilterValues) {
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useGridFilter = exports.filterStateInitializer = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _utils = require("@mui/utils");
|
|
10
11
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
11
12
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
12
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
@@ -19,7 +20,7 @@ var _rows = require("../rows");
|
|
|
19
20
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
20
21
|
var _strategyProcessing = require("../../core/strategyProcessing");
|
|
21
22
|
var _gridFilterUtils = require("./gridFilterUtils");
|
|
22
|
-
var
|
|
23
|
+
var _utils2 = require("../../../utils/utils");
|
|
23
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -191,7 +192,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
191
192
|
}, [apiRef]);
|
|
192
193
|
const setQuickFilterValues = React.useCallback(values => {
|
|
193
194
|
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
|
|
194
|
-
if ((0,
|
|
195
|
+
if ((0, _utils2.isDeepEqual)(filterModel.quickFilterValues, values)) {
|
|
195
196
|
return;
|
|
196
197
|
}
|
|
197
198
|
apiRef.current.setFilterModel((0, _extends2.default)({}, filterModel, {
|
|
@@ -232,7 +233,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
232
233
|
// Always export if the model has been initialized
|
|
233
234
|
props.initialState?.filter?.filterModel != null ||
|
|
234
235
|
// Export if the model is not equal to the default value
|
|
235
|
-
!(0,
|
|
236
|
+
!(0, _utils2.isDeepEqual)(filterModelToExport, (0, _gridFilterState.getDefaultGridFilterModel)());
|
|
236
237
|
if (!shouldExportFilterModel) {
|
|
237
238
|
return prevState;
|
|
238
239
|
}
|
|
@@ -264,6 +265,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
264
265
|
const tree = (0, _rows.gridRowTreeSelector)(apiRef);
|
|
265
266
|
const rowIds = tree[_rows.GRID_ROOT_GROUP_ID].children;
|
|
266
267
|
const filteredRowsLookup = {};
|
|
268
|
+
const filterCache = {};
|
|
267
269
|
for (let i = 0; i < rowIds.length; i += 1) {
|
|
268
270
|
const rowId = rowIds[i];
|
|
269
271
|
let isRowPassing;
|
|
@@ -274,7 +276,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
274
276
|
passingFilterItems,
|
|
275
277
|
passingQuickFilterValues
|
|
276
278
|
} = params.isRowMatchingFilters(rowId);
|
|
277
|
-
isRowPassing = (0, _gridFilterUtils.passFilterLogic)([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
|
|
279
|
+
isRowPassing = (0, _gridFilterUtils.passFilterLogic)([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef, filterCache);
|
|
278
280
|
}
|
|
279
281
|
filteredRowsLookup[rowId] = isRowPassing;
|
|
280
282
|
}
|
|
@@ -340,7 +342,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
340
342
|
/**
|
|
341
343
|
* EFFECTS
|
|
342
344
|
*/
|
|
343
|
-
|
|
345
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
344
346
|
if (props.filterModel !== undefined) {
|
|
345
347
|
apiRef.current.setFilterModel(props.filterModel);
|
|
346
348
|
}
|
|
@@ -8,6 +8,7 @@ exports.useGridFocus = exports.focusStateInitializer = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _utils = require("@mui/utils");
|
|
11
|
+
var _gridClasses = require("../../../constants/gridClasses");
|
|
11
12
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
12
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
13
14
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
@@ -246,7 +247,6 @@ const useGridFocus = (apiRef, props) => {
|
|
|
246
247
|
}
|
|
247
248
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
248
249
|
}, [apiRef]);
|
|
249
|
-
const focussedColumnGroup = (0, _gridFocusStateSelector.unstable_gridFocusColumnGroupHeaderSelector)(apiRef);
|
|
250
250
|
const handleColumnGroupHeaderFocus = React.useCallback(({
|
|
251
251
|
fields,
|
|
252
252
|
depth
|
|
@@ -254,13 +254,17 @@ const useGridFocus = (apiRef, props) => {
|
|
|
254
254
|
if (event.target !== event.currentTarget) {
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
const focusedColumnGroup = (0, _gridFocusStateSelector.unstable_gridFocusColumnGroupHeaderSelector)(apiRef);
|
|
258
|
+
if (focusedColumnGroup !== null && focusedColumnGroup.depth === depth && fields.includes(focusedColumnGroup.field)) {
|
|
258
259
|
// This group cell has already been focused
|
|
259
260
|
return;
|
|
260
261
|
}
|
|
261
262
|
apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
262
|
-
}, [apiRef
|
|
263
|
-
const handleBlur = React.useCallback(() => {
|
|
263
|
+
}, [apiRef]);
|
|
264
|
+
const handleBlur = React.useCallback((_, event) => {
|
|
265
|
+
if (event.relatedTarget?.className.includes(_gridClasses.gridClasses.columnHeader)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
264
268
|
logger.debug(`Clearing focus`);
|
|
265
269
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
266
270
|
focus: {
|
|
@@ -360,6 +364,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
360
364
|
};
|
|
361
365
|
}, [apiRef, handleDocumentClick]);
|
|
362
366
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderBlur', handleBlur);
|
|
367
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'headerFilterBlur', handleBlur);
|
|
363
368
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
364
369
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
365
370
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
@@ -19,7 +19,6 @@ var _gridDetailPanelToggleField = require("../../../constants/gridDetailPanelTog
|
|
|
19
19
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
20
20
|
var _focus = require("../focus");
|
|
21
21
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
22
|
-
var _useGridSelector = require("../../utils/useGridSelector");
|
|
23
22
|
var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilteringSelectors");
|
|
24
23
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
25
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -330,12 +329,12 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
330
329
|
event.preventDefault();
|
|
331
330
|
}
|
|
332
331
|
}, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
|
|
333
|
-
const focusedColumnGroup = (0, _useGridSelector.useGridSelector)(apiRef, _focus.unstable_gridFocusColumnGroupHeaderSelector);
|
|
334
332
|
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
335
333
|
const dimensions = apiRef.current.getRootDimensions();
|
|
336
334
|
if (!dimensions) {
|
|
337
335
|
return;
|
|
338
336
|
}
|
|
337
|
+
const focusedColumnGroup = (0, _focus.unstable_gridFocusColumnGroupHeaderSelector)(apiRef);
|
|
339
338
|
if (focusedColumnGroup === null) {
|
|
340
339
|
return;
|
|
341
340
|
}
|
|
@@ -419,7 +418,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
419
418
|
if (shouldPreventDefault) {
|
|
420
419
|
event.preventDefault();
|
|
421
420
|
}
|
|
422
|
-
}, [apiRef,
|
|
421
|
+
}, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
423
422
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
424
423
|
// Ignore portal
|
|
425
424
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.MissingRowIdError = void 0;
|
|
6
7
|
exports.useGridParamsApi = useGridParamsApi;
|
|
7
8
|
var React = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _domUtils = require("../../../utils/domUtils");
|
|
@@ -10,11 +11,7 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
|
10
11
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
|
|
14
|
-
function warnMissingColumn(field) {
|
|
15
|
-
console.warn([`MUI: You are calling getValue('${field}') but the column \`${field}\` is not defined.`, `Instead, you can access the data from \`params.row.${field}\`.`].join('\n'));
|
|
16
|
-
warnedOnceMissingColumn = true;
|
|
17
|
-
}
|
|
14
|
+
class MissingRowIdError extends Error {}
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* @requires useGridColumns (method)
|
|
@@ -24,6 +21,7 @@ function warnMissingColumn(field) {
|
|
|
24
21
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
25
22
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
26
23
|
*/
|
|
24
|
+
exports.MissingRowIdError = MissingRowIdError;
|
|
27
25
|
function useGridParamsApi(apiRef) {
|
|
28
26
|
const getColumnHeaderParams = React.useCallback(field => ({
|
|
29
27
|
field,
|
|
@@ -32,7 +30,7 @@ function useGridParamsApi(apiRef) {
|
|
|
32
30
|
const getRowParams = React.useCallback(id => {
|
|
33
31
|
const row = apiRef.current.getRow(id);
|
|
34
32
|
if (!row) {
|
|
35
|
-
throw new
|
|
33
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
36
34
|
}
|
|
37
35
|
const params = {
|
|
38
36
|
id,
|
|
@@ -45,7 +43,7 @@ function useGridParamsApi(apiRef) {
|
|
|
45
43
|
const row = apiRef.current.getRow(id);
|
|
46
44
|
const rowNode = apiRef.current.getRowNode(id);
|
|
47
45
|
if (!row || !rowNode) {
|
|
48
|
-
throw new
|
|
46
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
49
47
|
}
|
|
50
48
|
const cellFocus = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
51
49
|
const cellTabIndex = (0, _gridFocusStateSelector.gridTabIndexCellSelector)(apiRef);
|
|
@@ -69,7 +67,7 @@ function useGridParamsApi(apiRef) {
|
|
|
69
67
|
const row = apiRef.current.getRow(id);
|
|
70
68
|
const rowNode = apiRef.current.getRowNode(id);
|
|
71
69
|
if (!row || !rowNode) {
|
|
72
|
-
throw new
|
|
70
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
73
71
|
}
|
|
74
72
|
const cellFocus = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
75
73
|
const cellTabIndex = (0, _gridFocusStateSelector.gridTabIndexCellSelector)(apiRef);
|
|
@@ -83,7 +81,8 @@ function useGridParamsApi(apiRef) {
|
|
|
83
81
|
hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
|
|
84
82
|
tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
|
|
85
83
|
value,
|
|
86
|
-
formattedValue: value
|
|
84
|
+
formattedValue: value,
|
|
85
|
+
isEditable: false
|
|
87
86
|
};
|
|
88
87
|
if (colDef && colDef.valueFormatter) {
|
|
89
88
|
params.formattedValue = colDef.valueFormatter({
|
|
@@ -98,15 +97,10 @@ function useGridParamsApi(apiRef) {
|
|
|
98
97
|
}, [apiRef]);
|
|
99
98
|
const getCellValue = React.useCallback((id, field) => {
|
|
100
99
|
const colDef = apiRef.current.getColumn(field);
|
|
101
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
102
|
-
if (!colDef && !warnedOnceMissingColumn) {
|
|
103
|
-
warnMissingColumn(field);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
100
|
if (!colDef || !colDef.valueGetter) {
|
|
107
101
|
const rowModel = apiRef.current.getRow(id);
|
|
108
102
|
if (!rowModel) {
|
|
109
|
-
throw new
|
|
103
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
110
104
|
}
|
|
111
105
|
return rowModel[field];
|
|
112
106
|
}
|
|
@@ -51,7 +51,7 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
51
51
|
getRowSpacing,
|
|
52
52
|
getEstimatedRowHeight
|
|
53
53
|
} = props;
|
|
54
|
-
const rowsHeightLookup = React.useRef(
|
|
54
|
+
const rowsHeightLookup = React.useRef(Object.create(null));
|
|
55
55
|
|
|
56
56
|
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
57
57
|
const lastMeasuredRowIndex = React.useRef(-1);
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useGridSorting = exports.sortingStateInitializer = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _utils = require("@mui/utils");
|
|
10
11
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
11
12
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
12
13
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -248,7 +249,7 @@ const useGridSorting = (apiRef, props) => {
|
|
|
248
249
|
/**
|
|
249
250
|
* EFFECTS
|
|
250
251
|
*/
|
|
251
|
-
|
|
252
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
252
253
|
if (props.sortModel !== undefined) {
|
|
253
254
|
apiRef.current.setSortModel(props.sortModel);
|
|
254
255
|
}
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.areRenderContextsEqual = void 0;
|
|
7
8
|
exports.binarySearch = binarySearch;
|
|
8
9
|
exports.useGridVirtualScroller = exports.getRenderableIndexes = void 0;
|
|
9
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
@@ -27,8 +28,7 @@ var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
|
27
28
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
28
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
30
|
const _excluded = ["style"],
|
|
30
|
-
_excluded2 = ["style"]
|
|
31
|
-
_excluded3 = ["style"];
|
|
31
|
+
_excluded2 = ["style"];
|
|
32
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
34
|
// Uses binary search to avoid looping through all possible positions
|
|
@@ -67,6 +67,12 @@ const areRenderContextsEqual = (context1, context2) => {
|
|
|
67
67
|
}
|
|
68
68
|
return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
|
|
69
69
|
};
|
|
70
|
+
exports.areRenderContextsEqual = areRenderContextsEqual;
|
|
71
|
+
// The `maxSize` is 3 so that reselect caches the `renderedColumns` values for the pinned left,
|
|
72
|
+
// unpinned, and pinned right sections.
|
|
73
|
+
const MEMOIZE_OPTIONS = {
|
|
74
|
+
maxSize: 3
|
|
75
|
+
};
|
|
70
76
|
const useGridVirtualScroller = props => {
|
|
71
77
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
72
78
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
@@ -101,12 +107,12 @@ const useGridVirtualScroller = props => {
|
|
|
101
107
|
height: null
|
|
102
108
|
});
|
|
103
109
|
const prevTotalWidth = React.useRef(columnsTotalWidth);
|
|
104
|
-
const rowStyleCache = React.useRef(
|
|
110
|
+
const rowStyleCache = React.useRef(Object.create(null));
|
|
105
111
|
const prevGetRowProps = React.useRef();
|
|
106
112
|
const prevRootRowStyle = React.useRef();
|
|
107
113
|
const getRenderedColumnsRef = React.useRef((0, _reselect.defaultMemoize)((columns, firstColumnToRender, lastColumnToRender) => {
|
|
108
114
|
return columns.slice(firstColumnToRender, lastColumnToRender);
|
|
109
|
-
}));
|
|
115
|
+
}, MEMOIZE_OPTIONS));
|
|
110
116
|
const getNearestIndexToRender = React.useCallback(offset => {
|
|
111
117
|
const lastMeasuredIndexRelativeToAllRows = apiRef.current.getLastMeasuredRowIndex();
|
|
112
118
|
let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
|
|
@@ -264,7 +270,7 @@ const useGridVirtualScroller = props => {
|
|
|
264
270
|
};
|
|
265
271
|
apiRef.current.publishEvent('scrollPositionChange', params);
|
|
266
272
|
}, [apiRef, computeRenderContext, containerDimensions.width, updateRenderContext]);
|
|
267
|
-
const handleScroll = event => {
|
|
273
|
+
const handleScroll = (0, _utils.unstable_useEventCallback)(event => {
|
|
268
274
|
const {
|
|
269
275
|
scrollTop,
|
|
270
276
|
scrollLeft
|
|
@@ -306,13 +312,13 @@ const useGridVirtualScroller = props => {
|
|
|
306
312
|
});
|
|
307
313
|
prevTotalWidth.current = columnsTotalWidth;
|
|
308
314
|
}
|
|
309
|
-
};
|
|
310
|
-
const handleWheel = event => {
|
|
315
|
+
});
|
|
316
|
+
const handleWheel = (0, _utils.unstable_useEventCallback)(event => {
|
|
311
317
|
apiRef.current.publishEvent('virtualScrollerWheel', {}, event);
|
|
312
|
-
};
|
|
313
|
-
const handleTouchMove = event => {
|
|
318
|
+
});
|
|
319
|
+
const handleTouchMove = (0, _utils.unstable_useEventCallback)(event => {
|
|
314
320
|
apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
|
|
315
|
-
};
|
|
321
|
+
});
|
|
316
322
|
const getRows = (params = {
|
|
317
323
|
renderContext
|
|
318
324
|
}) => {
|
|
@@ -385,7 +391,7 @@ const useGridVirtualScroller = props => {
|
|
|
385
391
|
rootRowProps = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
386
392
|
const invalidatesCachedRowStyle = prevGetRowProps.current !== getRowProps || prevRootRowStyle.current !== rootRowStyle;
|
|
387
393
|
if (invalidatesCachedRowStyle) {
|
|
388
|
-
rowStyleCache.current =
|
|
394
|
+
rowStyleCache.current = Object.create(null);
|
|
389
395
|
}
|
|
390
396
|
const rows = [];
|
|
391
397
|
for (let i = 0; i < renderedRows.length; i += 1) {
|
|
@@ -457,22 +463,25 @@ const useGridVirtualScroller = props => {
|
|
|
457
463
|
height,
|
|
458
464
|
minHeight: shouldExtendContent ? '100%' : 'auto'
|
|
459
465
|
};
|
|
466
|
+
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
467
|
+
size.height = (0, _gridRowsUtils.getMinimalContentHeight)(apiRef, rootProps.rowHeight); // Give room to show the overlay when there no rows.
|
|
468
|
+
}
|
|
469
|
+
|
|
460
470
|
return size;
|
|
461
|
-
}, [rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, needsHorizontalScrollbar]);
|
|
471
|
+
}, [apiRef, rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, needsHorizontalScrollbar, rootProps.autoHeight, rootProps.rowHeight, currentPage.rows.length]);
|
|
462
472
|
React.useEffect(() => {
|
|
463
473
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
464
474
|
}, [apiRef, contentSize]);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
475
|
+
const rootStyle = React.useMemo(() => {
|
|
476
|
+
const style = {};
|
|
477
|
+
if (!needsHorizontalScrollbar) {
|
|
478
|
+
style.overflowX = 'hidden';
|
|
479
|
+
}
|
|
480
|
+
if (rootProps.autoHeight) {
|
|
481
|
+
style.overflowY = 'hidden';
|
|
482
|
+
}
|
|
483
|
+
return style;
|
|
484
|
+
}, [needsHorizontalScrollbar, rootProps.autoHeight]);
|
|
476
485
|
const getRenderContext = React.useCallback(() => {
|
|
477
486
|
return prevRenderContext.current;
|
|
478
487
|
}, []);
|
|
@@ -483,23 +492,18 @@ const useGridVirtualScroller = props => {
|
|
|
483
492
|
renderContext,
|
|
484
493
|
updateRenderZonePosition,
|
|
485
494
|
getRows,
|
|
486
|
-
getRootProps: (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
onWheel: handleWheel,
|
|
495
|
-
onTouchMove: handleTouchMove,
|
|
496
|
-
style: (0, _extends2.default)({}, style, rootStyle)
|
|
497
|
-
}, other);
|
|
498
|
-
},
|
|
495
|
+
getRootProps: (inputProps = {}) => (0, _extends2.default)({
|
|
496
|
+
ref: handleRef,
|
|
497
|
+
onScroll: handleScroll,
|
|
498
|
+
onWheel: handleWheel,
|
|
499
|
+
onTouchMove: handleTouchMove
|
|
500
|
+
}, inputProps, {
|
|
501
|
+
style: inputProps.style ? (0, _extends2.default)({}, inputProps.style, rootStyle) : rootStyle
|
|
502
|
+
}),
|
|
499
503
|
getContentProps: ({
|
|
500
|
-
style
|
|
504
|
+
style
|
|
501
505
|
} = {}) => ({
|
|
502
|
-
style: (0, _extends2.default)({}, style, contentSize)
|
|
506
|
+
style: style ? (0, _extends2.default)({}, style, contentSize) : contentSize
|
|
503
507
|
}),
|
|
504
508
|
getRenderZoneProps: () => ({
|
|
505
509
|
ref: renderZoneRef
|
|
@@ -3,9 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useGridSelector: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "useGridSelector", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _useGridSelector.useGridSelector;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
6
15
|
var _useGridApiEventHandler = require("./useGridApiEventHandler");
|
|
7
16
|
Object.keys(_useGridApiEventHandler).forEach(function (key) {
|
|
8
17
|
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
9
19
|
if (key in exports && exports[key] === _useGridApiEventHandler[key]) return;
|
|
10
20
|
Object.defineProperty(exports, key, {
|
|
11
21
|
enumerable: true,
|
|
@@ -17,6 +27,7 @@ Object.keys(_useGridApiEventHandler).forEach(function (key) {
|
|
|
17
27
|
var _useGridApiMethod = require("./useGridApiMethod");
|
|
18
28
|
Object.keys(_useGridApiMethod).forEach(function (key) {
|
|
19
29
|
if (key === "default" || key === "__esModule") return;
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
31
|
if (key in exports && exports[key] === _useGridApiMethod[key]) return;
|
|
21
32
|
Object.defineProperty(exports, key, {
|
|
22
33
|
enumerable: true,
|
|
@@ -28,6 +39,7 @@ Object.keys(_useGridApiMethod).forEach(function (key) {
|
|
|
28
39
|
var _useGridLogger = require("./useGridLogger");
|
|
29
40
|
Object.keys(_useGridLogger).forEach(function (key) {
|
|
30
41
|
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
43
|
if (key in exports && exports[key] === _useGridLogger[key]) return;
|
|
32
44
|
Object.defineProperty(exports, key, {
|
|
33
45
|
enumerable: true,
|
|
@@ -37,19 +49,10 @@ Object.keys(_useGridLogger).forEach(function (key) {
|
|
|
37
49
|
});
|
|
38
50
|
});
|
|
39
51
|
var _useGridSelector = require("./useGridSelector");
|
|
40
|
-
Object.keys(_useGridSelector).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _useGridSelector[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _useGridSelector[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
52
|
var _useGridNativeEventListener = require("./useGridNativeEventListener");
|
|
51
53
|
Object.keys(_useGridNativeEventListener).forEach(function (key) {
|
|
52
54
|
if (key === "default" || key === "__esModule") return;
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
53
56
|
if (key in exports && exports[key] === _useGridNativeEventListener[key]) return;
|
|
54
57
|
Object.defineProperty(exports, key, {
|
|
55
58
|
enumerable: true,
|
|
@@ -61,6 +64,7 @@ Object.keys(_useGridNativeEventListener).forEach(function (key) {
|
|
|
61
64
|
var _useFirstRender = require("./useFirstRender");
|
|
62
65
|
Object.keys(_useFirstRender).forEach(function (key) {
|
|
63
66
|
if (key === "default" || key === "__esModule") return;
|
|
67
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
64
68
|
if (key in exports && exports[key] === _useFirstRender[key]) return;
|
|
65
69
|
Object.defineProperty(exports, key, {
|
|
66
70
|
enumerable: true,
|
|
@@ -3,21 +3,55 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useGridSelector = void 0;
|
|
6
|
+
exports.useGridSelector = exports.objectShallowCompare = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _useLazyRef = require("./useLazyRef");
|
|
9
|
+
var _useOnMount = require("./useOnMount");
|
|
7
10
|
var _warning = require("../../utils/warning");
|
|
11
|
+
var _fastObjectShallowCompare = require("../../utils/fastObjectShallowCompare");
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
const stateNotInitializedWarning = (0, _warning.buildWarning)(['MUI: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
|
|
8
15
|
function isOutputSelector(selector) {
|
|
9
16
|
return selector.acceptsApiRef;
|
|
10
17
|
}
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
function applySelector(apiRef, selector) {
|
|
19
|
+
if (isOutputSelector(selector)) {
|
|
20
|
+
return selector(apiRef);
|
|
21
|
+
}
|
|
22
|
+
return selector(apiRef.current.state);
|
|
23
|
+
}
|
|
24
|
+
const defaultCompare = Object.is;
|
|
25
|
+
const objectShallowCompare = _fastObjectShallowCompare.fastObjectShallowCompare;
|
|
26
|
+
exports.objectShallowCompare = objectShallowCompare;
|
|
27
|
+
const createRefs = () => ({
|
|
28
|
+
state: null,
|
|
29
|
+
equals: null,
|
|
30
|
+
selector: null
|
|
31
|
+
});
|
|
32
|
+
const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
13
33
|
if (process.env.NODE_ENV !== 'production') {
|
|
14
34
|
if (!apiRef.current.state) {
|
|
15
35
|
stateNotInitializedWarning();
|
|
16
36
|
}
|
|
17
37
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
38
|
+
const refs = (0, _useLazyRef.useLazyRef)(createRefs);
|
|
39
|
+
const didInit = refs.current.selector !== null;
|
|
40
|
+
const [state, setState] = React.useState(
|
|
41
|
+
// We don't use an initialization function to avoid allocations
|
|
42
|
+
didInit ? null : applySelector(apiRef, selector));
|
|
43
|
+
refs.current.state = state;
|
|
44
|
+
refs.current.equals = equals;
|
|
45
|
+
refs.current.selector = selector;
|
|
46
|
+
(0, _useOnMount.useOnMount)(() => {
|
|
47
|
+
return apiRef.current.store.subscribe(() => {
|
|
48
|
+
const newState = applySelector(apiRef, refs.current.selector);
|
|
49
|
+
if (!refs.current.equals(refs.current.state, newState)) {
|
|
50
|
+
refs.current.state = newState;
|
|
51
|
+
setState(newState);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return state;
|
|
22
56
|
};
|
|
23
57
|
exports.useGridSelector = useGridSelector;
|