@mui/x-data-grid 9.14.0 → 9.15.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.
Files changed (283) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/DataGrid/DataGrid.js +8 -0
  3. package/DataGrid/DataGrid.mjs +9 -1
  4. package/DataGrid/useDataGridComponent.js +2 -2
  5. package/DataGrid/useDataGridComponent.mjs +2 -2
  6. package/DataGrid/useDataGridProps.mjs +1 -1
  7. package/colDef/gridActionsColDef.mjs +1 -1
  8. package/colDef/gridBooleanColDef.mjs +1 -1
  9. package/colDef/gridCheckboxSelectionColDef.mjs +1 -1
  10. package/colDef/gridDateColDef.mjs +1 -1
  11. package/colDef/gridDefaultColumnTypes.mjs +1 -1
  12. package/colDef/gridLongTextColDef.mjs +1 -1
  13. package/colDef/gridNumericColDef.mjs +1 -1
  14. package/colDef/gridSingleSelectColDef.mjs +1 -1
  15. package/components/GridColumnHeaders.mjs +2 -2
  16. package/components/GridColumnSortButton.mjs +2 -2
  17. package/components/GridColumnUnsortedIcon.mjs +2 -2
  18. package/components/GridFooter.mjs +1 -1
  19. package/components/GridHeader.mjs +1 -1
  20. package/components/GridHeaders.mjs +1 -1
  21. package/components/GridLoadingOverlay.mjs +2 -2
  22. package/components/GridNoColumnsOverlay.mjs +1 -1
  23. package/components/GridNoResultsOverlay.mjs +1 -1
  24. package/components/GridNoRowsOverlay.mjs +1 -1
  25. package/components/GridPagination.js +9 -1
  26. package/components/GridPagination.mjs +10 -2
  27. package/components/GridRow.mjs +2 -2
  28. package/components/GridRowCount.mjs +2 -2
  29. package/components/GridRowDragAndDropOverlay.mjs +1 -1
  30. package/components/GridScrollArea.mjs +1 -1
  31. package/components/GridSelectedRowCount.mjs +2 -2
  32. package/components/GridShadowScrollArea.mjs +2 -2
  33. package/components/GridSkeletonLoadingOverlay.mjs +2 -2
  34. package/components/base/GridFooterPlaceholder.mjs +1 -1
  35. package/components/base/GridOverlays.mjs +1 -1
  36. package/components/cell/GridActionsCell.js +2 -2
  37. package/components/cell/GridActionsCell.mjs +5 -5
  38. package/components/cell/GridActionsCellItem.d.mts +20 -6
  39. package/components/cell/GridActionsCellItem.d.ts +20 -6
  40. package/components/cell/GridActionsCellItem.js +30 -7
  41. package/components/cell/GridActionsCellItem.mjs +32 -9
  42. package/components/cell/GridBooleanCell.mjs +2 -2
  43. package/components/cell/GridCell.js +1 -1
  44. package/components/cell/GridCell.mjs +3 -3
  45. package/components/cell/GridEditBooleanCell.mjs +2 -2
  46. package/components/cell/GridEditDateCell.mjs +2 -2
  47. package/components/cell/GridEditInputCell.mjs +2 -2
  48. package/components/cell/GridEditLongTextCell.mjs +1 -1
  49. package/components/cell/GridEditSingleSelectCell.mjs +2 -2
  50. package/components/cell/GridFooterCell.mjs +2 -2
  51. package/components/cell/GridLongTextCell.mjs +1 -1
  52. package/components/cell/GridSkeletonCell.mjs +2 -2
  53. package/components/columnHeaders/ColumnHeaderMenuIcon.mjs +1 -1
  54. package/components/columnHeaders/GridBaseColumnHeaders.mjs +2 -2
  55. package/components/columnHeaders/GridColumnGroupHeader.mjs +1 -1
  56. package/components/columnHeaders/GridColumnHeaderFilterIconButton.mjs +1 -1
  57. package/components/columnHeaders/GridColumnHeaderItem.mjs +1 -1
  58. package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -1
  59. package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -1
  60. package/components/columnHeaders/GridColumnHeaderSeparator.mjs +2 -2
  61. package/components/columnHeaders/GridColumnHeaderSortIcon.js +17 -0
  62. package/components/columnHeaders/GridColumnHeaderSortIcon.mjs +18 -1
  63. package/components/columnHeaders/GridColumnHeaderTitle.mjs +2 -2
  64. package/components/columnHeaders/GridGenericColumnHeaderItem.mjs +2 -2
  65. package/components/columnHeaders/GridIconButtonContainer.mjs +2 -2
  66. package/components/columnSelection/GridCellCheckboxRenderer.mjs +2 -2
  67. package/components/columnSelection/GridHeaderCheckbox.mjs +2 -2
  68. package/components/columnSelection/GridRowCheckbox.js +1 -3
  69. package/components/columnSelection/GridRowCheckbox.mjs +3 -5
  70. package/components/columnsManagement/GridColumnsManagement.mjs +1 -1
  71. package/components/columnsPanel/ColumnsPanelTrigger.mjs +2 -2
  72. package/components/containers/GridFooterContainer.mjs +2 -2
  73. package/components/containers/GridOverlay.mjs +2 -2
  74. package/components/containers/GridRoot.mjs +2 -2
  75. package/components/containers/GridRootStyles.js +22 -10
  76. package/components/containers/GridRootStyles.mjs +22 -10
  77. package/components/containers/GridToolbarContainer.mjs +2 -2
  78. package/components/export/ExportCsv.mjs +2 -2
  79. package/components/export/ExportPrint.js +4 -1
  80. package/components/export/ExportPrint.mjs +6 -3
  81. package/components/filterPanel/FilterPanelTrigger.mjs +2 -2
  82. package/components/menu/GridMenu.mjs +2 -2
  83. package/components/menu/columnMenu/GridColumnHeaderMenu.mjs +1 -1
  84. package/components/menu/columnMenu/GridColumnMenu.mjs +2 -2
  85. package/components/menu/columnMenu/GridColumnMenuContainer.mjs +2 -2
  86. package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.mjs +1 -1
  87. package/components/panel/GridColumnsPanel.mjs +1 -1
  88. package/components/panel/GridPanel.mjs +2 -2
  89. package/components/panel/GridPanelContent.mjs +2 -2
  90. package/components/panel/GridPanelContext.mjs +1 -1
  91. package/components/panel/GridPanelFooter.mjs +2 -2
  92. package/components/panel/GridPanelHeader.mjs +2 -2
  93. package/components/panel/GridPanelWrapper.mjs +2 -2
  94. package/components/panel/GridPreferencesPanel.mjs +1 -1
  95. package/components/panel/filterPanel/GridFilterForm.mjs +1 -1
  96. package/components/panel/filterPanel/GridFilterFormBase.mjs +2 -2
  97. package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -12
  98. package/components/panel/filterPanel/GridFilterInputBoolean.mjs +3 -14
  99. package/components/panel/filterPanel/GridFilterInputDate.mjs +2 -2
  100. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.mjs +2 -2
  101. package/components/panel/filterPanel/GridFilterInputMultipleValue.mjs +2 -2
  102. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -12
  103. package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +3 -14
  104. package/components/panel/filterPanel/GridFilterInputValue.mjs +2 -2
  105. package/components/panel/filterPanel/GridFilterPanel.mjs +1 -1
  106. package/components/panel/filterPanel/GridFilterPanelBase.mjs +2 -2
  107. package/components/panel/filterPanel/filterPanelUtils.mjs +1 -1
  108. package/components/quickFilter/QuickFilter.mjs +2 -2
  109. package/components/quickFilter/QuickFilterClear.js +17 -0
  110. package/components/quickFilter/QuickFilterClear.mjs +19 -2
  111. package/components/quickFilter/QuickFilterControl.mjs +2 -2
  112. package/components/quickFilter/QuickFilterTrigger.mjs +2 -2
  113. package/components/toolbar/GridToolbar.mjs +2 -2
  114. package/components/toolbar/GridToolbarColumnsButton.mjs +1 -1
  115. package/components/toolbar/GridToolbarDensitySelector.mjs +1 -1
  116. package/components/toolbar/GridToolbarExport.js +4 -1
  117. package/components/toolbar/GridToolbarExport.mjs +6 -3
  118. package/components/toolbar/GridToolbarExportContainer.mjs +1 -1
  119. package/components/toolbar/GridToolbarFilterButton.mjs +1 -1
  120. package/components/toolbar/GridToolbarQuickFilter.mjs +2 -2
  121. package/components/toolbarV8/GridToolbar.mjs +2 -2
  122. package/components/toolbarV8/Toolbar.mjs +2 -2
  123. package/components/toolbarV8/ToolbarButton.js +17 -0
  124. package/components/toolbarV8/ToolbarButton.mjs +19 -2
  125. package/components/virtualization/GridBottomContainer.mjs +1 -1
  126. package/components/virtualization/GridMainContainer.mjs +1 -1
  127. package/components/virtualization/GridTopContainer.mjs +1 -1
  128. package/components/virtualization/GridVirtualScrollbar.js +2 -2
  129. package/components/virtualization/GridVirtualScrollbar.mjs +2 -2
  130. package/components/virtualization/GridVirtualScroller.js +2 -2
  131. package/components/virtualization/GridVirtualScroller.mjs +3 -3
  132. package/components/virtualization/GridVirtualScrollerContent.mjs +1 -1
  133. package/components/virtualization/GridVirtualScrollerRenderZone.mjs +1 -1
  134. package/constants/cssVariables.mjs +1 -1
  135. package/constants/defaultGridSlotsComponents.mjs +1 -1
  136. package/constants/signature.d.mts +1 -1
  137. package/constants/signature.d.ts +1 -1
  138. package/hooks/core/pipeProcessing/useGridPipeProcessing.mjs +2 -2
  139. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +2 -2
  140. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.mjs +2 -2
  141. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +2 -2
  142. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.mjs +2 -2
  143. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.mts +1 -1
  144. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
  145. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.js +2 -2
  146. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.mjs +2 -2
  147. package/hooks/core/strategyProcessing/useGridStrategyProcessing.mjs +2 -2
  148. package/hooks/core/useGridApiInitialization.js +1 -1
  149. package/hooks/core/useGridApiInitialization.mjs +1 -1
  150. package/hooks/core/useGridIsRtl.mjs +1 -1
  151. package/hooks/core/useGridProps.mjs +1 -1
  152. package/hooks/core/useGridStateInitialization.mjs +1 -1
  153. package/hooks/core/useGridVirtualizer.d.mts +2 -2
  154. package/hooks/core/useGridVirtualizer.d.ts +2 -2
  155. package/hooks/core/useGridVirtualizer.js +6 -6
  156. package/hooks/core/useGridVirtualizer.mjs +4 -4
  157. package/hooks/features/columnGrouping/gridColumnGroupsUtils.mjs +2 -2
  158. package/hooks/features/columnGrouping/useGridColumnGrouping.mjs +1 -1
  159. package/hooks/features/columnHeaders/useGridColumnHeaders.mjs +1 -1
  160. package/hooks/features/columnMenu/getColumnMenuItemKeys.mjs +1 -1
  161. package/hooks/features/columnMenu/useGridColumnMenu.mjs +1 -1
  162. package/hooks/features/columnMenu/useGridColumnMenuSlots.mjs +2 -2
  163. package/hooks/features/columnResize/useGridColumnResize.mjs +1 -1
  164. package/hooks/features/columns/gridColumnsInterfaces.d.mts +1 -1
  165. package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -1
  166. package/hooks/features/columns/gridColumnsUtils.d.mts +1 -1
  167. package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
  168. package/hooks/features/columns/gridColumnsUtils.mjs +1 -1
  169. package/hooks/features/columns/useGridColumns.js +1 -1
  170. package/hooks/features/columns/useGridColumns.mjs +2 -2
  171. package/hooks/features/dataSource/cache.js +1 -1
  172. package/hooks/features/dataSource/cache.mjs +1 -1
  173. package/hooks/features/dataSource/useGridDataSourceBase.js +13 -28
  174. package/hooks/features/dataSource/useGridDataSourceBase.mjs +16 -31
  175. package/hooks/features/dataSource/useGridDataSourcePolling.d.mts +29 -0
  176. package/hooks/features/dataSource/useGridDataSourcePolling.d.ts +29 -0
  177. package/hooks/features/dataSource/useGridDataSourcePolling.js +62 -0
  178. package/hooks/features/dataSource/useGridDataSourcePolling.mjs +54 -0
  179. package/hooks/features/dataSource/utils.d.mts +1 -1
  180. package/hooks/features/dataSource/utils.d.ts +1 -1
  181. package/hooks/features/dataSource/utils.mjs +1 -1
  182. package/hooks/features/density/useGridDensity.mjs +1 -1
  183. package/hooks/features/dimensions/useGridDimensions.d.mts +1 -1
  184. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  185. package/hooks/features/dimensions/useGridDimensions.js +3 -3
  186. package/hooks/features/dimensions/useGridDimensions.mjs +3 -3
  187. package/hooks/features/editing/useGridCellEditing.js +1 -1
  188. package/hooks/features/editing/useGridCellEditing.mjs +5 -5
  189. package/hooks/features/editing/useGridEditing.mjs +1 -1
  190. package/hooks/features/editing/useGridRowEditing.js +1 -1
  191. package/hooks/features/editing/useGridRowEditing.mjs +5 -5
  192. package/hooks/features/export/serializers/csvSerializer.js +5 -5
  193. package/hooks/features/export/serializers/csvSerializer.mjs +5 -5
  194. package/hooks/features/export/useGridPrintExport.js +44 -20
  195. package/hooks/features/export/useGridPrintExport.mjs +45 -21
  196. package/hooks/features/filter/gridFilterUtils.js +3 -3
  197. package/hooks/features/filter/gridFilterUtils.mjs +5 -5
  198. package/hooks/features/filter/useGridFilter.js +2 -2
  199. package/hooks/features/filter/useGridFilter.mjs +3 -3
  200. package/hooks/features/focus/useGridFocus.mjs +1 -1
  201. package/hooks/features/headerFiltering/useGridHeaderFiltering.mjs +1 -1
  202. package/hooks/features/listView/useGridListView.d.mts +2 -2
  203. package/hooks/features/listView/useGridListView.d.ts +2 -2
  204. package/hooks/features/listView/useGridListView.js +1 -1
  205. package/hooks/features/listView/useGridListView.mjs +2 -2
  206. package/hooks/features/pagination/useGridPagination.mjs +1 -1
  207. package/hooks/features/pagination/useGridPaginationMeta.mjs +1 -1
  208. package/hooks/features/pagination/useGridPaginationModel.mjs +1 -1
  209. package/hooks/features/pagination/useGridRowCount.js +2 -2
  210. package/hooks/features/pagination/useGridRowCount.mjs +2 -2
  211. package/hooks/features/preferencesPanel/gridPreferencePanelsValue.d.mts +1 -1
  212. package/hooks/features/preferencesPanel/gridPreferencePanelsValue.d.ts +1 -1
  213. package/hooks/features/preferencesPanel/useGridPreferencesPanel.mjs +1 -1
  214. package/hooks/features/rowSelection/useGridRowSelection.mjs +1 -1
  215. package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.mjs +1 -1
  216. package/hooks/features/rows/gridRowsUtils.js +2 -2
  217. package/hooks/features/rows/gridRowsUtils.mjs +3 -3
  218. package/hooks/features/rows/useGridRowSpanning.mjs +1 -1
  219. package/hooks/features/rows/useGridRows.mjs +1 -1
  220. package/hooks/features/rows/useGridRowsMeta.mjs +1 -1
  221. package/hooks/features/rows/useGridRowsOverridableMethods.mjs +1 -1
  222. package/hooks/features/rows/useGridRowsPreProcessors.mjs +1 -1
  223. package/hooks/features/sorting/gridSortingUtils.js +1 -1
  224. package/hooks/features/sorting/gridSortingUtils.mjs +3 -3
  225. package/hooks/features/sorting/useGridSorting.js +2 -2
  226. package/hooks/features/sorting/useGridSorting.mjs +3 -3
  227. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.mjs +1 -1
  228. package/hooks/features/virtualization/useGridVirtualization.mjs +1 -1
  229. package/hooks/utils/index.d.mts +1 -1
  230. package/hooks/utils/index.d.ts +1 -1
  231. package/hooks/utils/index.js +8 -12
  232. package/hooks/utils/index.mjs +2 -1
  233. package/hooks/utils/useGridSelector.js +2 -2
  234. package/hooks/utils/useGridSelector.mjs +2 -2
  235. package/index.js +1 -1
  236. package/index.mjs +1 -1
  237. package/internals/constants.d.mts +1 -1
  238. package/internals/constants.d.ts +1 -1
  239. package/internals/index.d.mts +1 -0
  240. package/internals/index.d.ts +1 -0
  241. package/internals/index.js +8 -0
  242. package/internals/index.mjs +1 -0
  243. package/internals/utils/cache.d.mts +0 -1
  244. package/internals/utils/cache.d.ts +0 -1
  245. package/internals/utils/cache.js +1 -3
  246. package/internals/utils/cache.mjs +1 -3
  247. package/internals/utils/computeSlots.mjs +1 -1
  248. package/internals/utils/propValidation.js +2 -2
  249. package/internals/utils/propValidation.mjs +3 -3
  250. package/material/index.mjs +2 -2
  251. package/models/api/gridCoreApi.d.mts +1 -1
  252. package/models/api/gridCoreApi.d.ts +1 -1
  253. package/models/api/gridEditingApi.d.mts +6 -6
  254. package/models/api/gridEditingApi.d.ts +6 -6
  255. package/models/api/gridPrintExportApi.d.mts +2 -1
  256. package/models/api/gridPrintExportApi.d.ts +2 -1
  257. package/models/events/gridEventLookup.d.mts +5 -5
  258. package/models/events/gridEventLookup.d.ts +5 -5
  259. package/models/gridBaseSlots.d.mts +18 -1
  260. package/models/gridBaseSlots.d.ts +18 -1
  261. package/models/gridEditRowModel.d.mts +3 -3
  262. package/models/gridEditRowModel.d.ts +3 -3
  263. package/models/gridExport.d.mts +13 -0
  264. package/models/gridExport.d.ts +13 -0
  265. package/models/gridFilterItem.d.mts +2 -2
  266. package/models/gridFilterItem.d.ts +2 -2
  267. package/models/index.d.mts +2 -1
  268. package/models/index.d.ts +2 -1
  269. package/models/params/gridEditCellParams.d.mts +2 -2
  270. package/models/params/gridEditCellParams.d.ts +2 -2
  271. package/models/params/gridRowParams.d.mts +2 -2
  272. package/models/params/gridRowParams.d.ts +2 -2
  273. package/models/props/DataGridProps.d.mts +8 -0
  274. package/models/props/DataGridProps.d.ts +8 -0
  275. package/package.json +5 -5
  276. package/utils/createSelector.d.mts +1 -1
  277. package/utils/createSelector.d.ts +1 -1
  278. package/utils/createSelector.js +1 -1
  279. package/utils/createSelector.mjs +1 -1
  280. package/hooks/utils/useFirstRender.d.mts +0 -1
  281. package/hooks/utils/useFirstRender.d.ts +0 -1
  282. package/hooks/utils/useFirstRender.js +0 -16
  283. package/hooks/utils/useFirstRender.mjs +0 -1
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
4
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
5
+ import _toPropertyKey from "@babel/runtime/helpers/toPropertyKey";
6
6
  import * as React from 'react';
7
7
  import { GridStrategyGroup } from "./gridStrategyProcessingApi.mjs";
8
8
  import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
@@ -9,7 +9,7 @@ exports.unwrapPrivateAPI = unwrapPrivateAPI;
9
9
  exports.useGridApiInitialization = useGridApiInitialization;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _EventManager = require("@mui/x-internals/EventManager");
12
- var _store = require("@mui/x-internals/store");
12
+ var _store = require("@base-ui/utils/store");
13
13
  var _useGridApiMethod = require("../utils/useGridApiMethod");
14
14
  var _signature = require("../../constants/signature");
15
15
  var _getPublicApiRef = require("../../utils/getPublicApiRef");
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { EventManager } from '@mui/x-internals/EventManager';
5
- import { Store } from '@mui/x-internals/store';
5
+ import { Store } from '@base-ui/utils/store';
6
6
  import { useGridApiMethod } from "../utils/useGridApiMethod.mjs";
7
7
  import { GridSignature } from "../../constants/signature.mjs";
8
8
  import { getPublicApiRef } from "../../utils/getPublicApiRef.mjs";
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { useRtl } from '@mui/system/RtlProvider';
6
6
  export const useGridIsRtl = apiRef => {
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  export const propsStateInitializer = (state, props) => {
6
6
  return _extends({}, state, {
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
5
5
  import * as React from 'react';
6
6
  import { useGridApiMethod } from "../utils/index.mjs";
@@ -4,10 +4,10 @@ import { Dimensions, LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
4
4
  * Virtualizer setup
5
5
  */
6
6
  export declare function useGridVirtualizer(): {
7
- store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
7
+ store: import("@base-ui/utils/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
8
8
  api: {
9
9
  updateDimensions: (firstUpdate?: boolean) => void;
10
- debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
10
+ debouncedUpdateDimensions: ((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable | undefined;
11
11
  rowsMeta: {
12
12
  getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
13
13
  setLastMeasuredRowIndex: (index: number) => void;
@@ -4,10 +4,10 @@ import { Dimensions, LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
4
4
  * Virtualizer setup
5
5
  */
6
6
  export declare function useGridVirtualizer(): {
7
- store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
7
+ store: import("@base-ui/utils/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
8
8
  api: {
9
9
  updateDimensions: (firstUpdate?: boolean) => void;
10
- debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
10
+ debouncedUpdateDimensions: ((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable | undefined;
11
11
  rowsMeta: {
12
12
  getRowHeight: (rowId: import("@mui/x-virtualizer").RowId) => any;
13
13
  setLastMeasuredRowIndex: (index: number) => void;
@@ -13,9 +13,9 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
13
13
  var _RtlProvider = require("@mui/system/RtlProvider");
14
14
  var _math = require("@mui/x-internals/math");
15
15
  var _lruMemoize = require("@mui/x-internals/lruMemoize");
16
- var _store = require("@mui/x-internals/store");
16
+ var _useStoreEffect = require("@mui/x-internals/useStoreEffect");
17
17
  var _xVirtualizer = require("@mui/x-virtualizer");
18
- var _useFirstRender = require("../utils/useFirstRender");
18
+ var _useOnFirstRender = require("@base-ui/utils/useOnFirstRender");
19
19
  var _createSelector = require("../../utils/createSelector");
20
20
  var _useGridSelector = require("../utils/useGridSelector");
21
21
  var _gridDimensionsSelectors = require("../features/dimensions/gridDimensionsSelectors");
@@ -252,12 +252,12 @@ function useGridVirtualizer() {
252
252
  // initialization code runs between those two moments.
253
253
  //
254
254
  // TODO(v9): Remove this
255
- (0, _useFirstRender.useFirstRender)(() => {
255
+ (0, _useOnFirstRender.useOnFirstRender)(() => {
256
256
  apiRef.current.store.state.dimensions = addGridDimensions(virtualizer.store.state.dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight);
257
257
  apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
258
258
  apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
259
259
  });
260
- (0, _store.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.dimensions, (_, dimensions) => {
260
+ (0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.dimensions, (_, dimensions) => {
261
261
  if (!dimensions.isReady) {
262
262
  return;
263
263
  }
@@ -265,14 +265,14 @@ function useGridVirtualizer() {
265
265
  dimensions: addGridDimensions(dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight)
266
266
  }));
267
267
  });
268
- (0, _store.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.rowsMeta, (_, rowsMeta) => {
268
+ (0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.rowsMeta, (_, rowsMeta) => {
269
269
  if (rowsMeta !== apiRef.current.state.rowsMeta) {
270
270
  apiRef.current.setState(gridState => (0, _extends2.default)({}, gridState, {
271
271
  rowsMeta
272
272
  }));
273
273
  }
274
274
  });
275
- (0, _store.useStoreEffect)(virtualizer.store, _xVirtualizer.Virtualization.selectors.store, (_, virtualization) => {
275
+ (0, _useStoreEffect.useStoreEffect)(virtualizer.store, _xVirtualizer.Virtualization.selectors.store, (_, virtualization) => {
276
276
  if (virtualization.renderContext === _xVirtualizer.EMPTY_RENDER_CONTEXT) {
277
277
  return;
278
278
  }
@@ -1,13 +1,13 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  import * as React from 'react';
3
3
  import useLazyRef from '@mui/utils/useLazyRef';
4
4
  import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import { useRtl } from '@mui/system/RtlProvider';
6
6
  import { roundToDecimalPlaces } from '@mui/x-internals/math';
7
7
  import { lruMemoize } from '@mui/x-internals/lruMemoize';
8
- import { useStoreEffect } from '@mui/x-internals/store';
8
+ import { useStoreEffect } from '@mui/x-internals/useStoreEffect';
9
9
  import { useVirtualizer, Dimensions, LayoutDataGrid, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
10
- import { useFirstRender } from "../utils/useFirstRender.mjs";
10
+ import { useOnFirstRender } from '@base-ui/utils/useOnFirstRender';
11
11
  import { createSelector } from "../../utils/createSelector.mjs";
12
12
  import { useGridSelector } from "../utils/useGridSelector.mjs";
13
13
  import { gridHasFillerSelector, gridVerticalScrollbarWidthSelector } from "../features/dimensions/gridDimensionsSelectors.mjs";
@@ -244,7 +244,7 @@ export function useGridVirtualizer() {
244
244
  // initialization code runs between those two moments.
245
245
  //
246
246
  // TODO(v9): Remove this
247
- useFirstRender(() => {
247
+ useOnFirstRender(() => {
248
248
  apiRef.current.store.state.dimensions = addGridDimensions(virtualizer.store.state.dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight);
249
249
  apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
250
250
  apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
@@ -1,6 +1,6 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
3
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
4
4
  const _excluded = ["groupId", "children"];
5
5
  import { isLeaf } from "../../../models/gridColumnGrouping.mjs";
6
6
  export const createGroupLookup = columnGroupingModel => {
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { gridColumnGroupsLookupSelector, gridColumnGroupsUnwrappedModelSelector } from "./gridColumnGroupsSelector.mjs";
6
6
  import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled } from '@mui/material/styles';
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  /**
3
3
  * Returns the list of column menu item keys (sorted by `displayOrder`) that should be rendered for a given column.
4
4
  * This is shared between the column header (to know if menu is empty) and the menu itself (to render items).
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { useGridLogger, useGridApiMethod, useGridEvent } from "../../utils/index.mjs";
6
6
  import { gridColumnMenuSelector } from "./columnMenuSelector.mjs";
@@ -1,5 +1,5 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
3
  const _excluded = ["displayOrder"];
4
4
  import * as React from 'react';
5
5
  import { useGridRootProps } from "../../utils/useGridRootProps.mjs";
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import useEventCallback from '@mui/utils/useEventCallback';
6
6
  import ownerDocument from '@mui/utils/ownerDocument';
@@ -2,7 +2,7 @@ import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridCol
2
2
  import type { GridColumnDimensionProperties } from "./gridColumnsUtils.mjs";
3
3
  export declare enum GridPinnedColumnPosition {
4
4
  LEFT = "left",
5
- RIGHT = "right",
5
+ RIGHT = "right"
6
6
  }
7
7
  export type GridColumnLookup = {
8
8
  [field: string]: GridStateColDef;
@@ -2,7 +2,7 @@ import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridCol
2
2
  import type { GridColumnDimensionProperties } from "./gridColumnsUtils.js";
3
3
  export declare enum GridPinnedColumnPosition {
4
4
  LEFT = "left",
5
- RIGHT = "right",
5
+ RIGHT = "right"
6
6
  }
7
7
  export type GridColumnLookup = {
8
8
  [field: string]: GridStateColDef;
@@ -7,7 +7,7 @@ import type { GridApiCommon } from "../../../models/api/gridApiCommon.mjs";
7
7
  import type { GridRowEntry } from "../../../models/gridRows.mjs";
8
8
  import type { GridDimensions } from "../dimensions/gridDimensionsApi.mjs";
9
9
  export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ['maxWidth', 'minWidth', 'width', 'flex'];
10
- export type GridColumnDimensionProperties = (typeof COLUMNS_DIMENSION_PROPERTIES)[number];
10
+ export type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
11
11
  /**
12
12
  * Computes width for flex columns.
13
13
  * Based on CSS Flexbox specification:
@@ -7,7 +7,7 @@ import type { GridApiCommon } from "../../../models/api/gridApiCommon.js";
7
7
  import type { GridRowEntry } from "../../../models/gridRows.js";
8
8
  import type { GridDimensions } from "../dimensions/gridDimensionsApi.js";
9
9
  export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ['maxWidth', 'minWidth', 'width', 'flex'];
10
- export type GridColumnDimensionProperties = (typeof COLUMNS_DIMENSION_PROPERTIES)[number];
10
+ export type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
11
11
  /**
12
12
  * Computes width for flex columns.
13
13
  * Based on CSS Flexbox specification:
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from "@babel/runtime/helpers/extends";
2
2
  import resolveProps from '@mui/utils/resolveProps';
3
3
  import { GRID_STRING_COL_DEF } from "../../../colDef/index.mjs";
4
4
  import { getRegisteredColumnTypeDef, isCommunityColumnType } from "../../../colDef/gridColumnTypesRegistry.mjs";
@@ -360,7 +360,7 @@ function useGridColumns(apiRef, props) {
360
360
  }
361
361
  const lookup = (0, _gridColumnsSelector.gridColumnLookupSelector)(apiRef);
362
362
  if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
363
- (0, _warning.warnOnce)(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions']);
363
+ (0, _warning.warnOnce)(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions'].join('\n'));
364
364
  }
365
365
  }, [apiRef, props.signature]);
366
366
  (0, _useGridEvent.useGridEvent)(apiRef, 'columnsChange', checkMultiSelectColumns);
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
4
  import * as React from 'react';
5
5
  import { warnOnce } from '@mui/x-internals/warning';
6
6
  import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
@@ -351,7 +351,7 @@ export function useGridColumns(apiRef, props) {
351
351
  }
352
352
  const lookup = gridColumnLookupSelector(apiRef);
353
353
  if (orderedFields.some(field => lookup[field]?.type === 'multiSelect')) {
354
- warnOnce(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions']);
354
+ warnOnce(['MUI X: The `multiSelect` column type is available in Pro and Premium versions', 'Use `<DataGridPro />` or `<DataGridPremium />` to render it correctly.', 'For more details, see https://mui.com/x/react-data-grid/column-definition/#multi-select-keyboard-interactions'].join('\n'));
355
355
  }
356
356
  }, [apiRef, props.signature]);
357
357
  useGridEvent(apiRef, 'columnsChange', checkMultiSelectColumns);
@@ -9,11 +9,11 @@ function getKeyDefault(params) {
9
9
  return JSON.stringify([params.filterModel, params.sortModel, params.start, params.end]);
10
10
  }
11
11
  class GridDataSourceCacheDefault {
12
+ cache = {};
12
13
  constructor({
13
14
  ttl = 300_000,
14
15
  getKey = getKeyDefault
15
16
  }) {
16
- this.cache = {};
17
17
  this.ttl = ttl;
18
18
  this.getKey = getKey;
19
19
  }
@@ -2,11 +2,11 @@ export function getKeyDefault(params) {
2
2
  return JSON.stringify([params.filterModel, params.sortModel, params.start, params.end]);
3
3
  }
4
4
  export class GridDataSourceCacheDefault {
5
+ cache = {};
5
6
  constructor({
6
7
  ttl = 300_000,
7
8
  getKey = getKeyDefault
8
9
  }) {
9
- this.cache = {};
10
10
  this.ttl = ttl;
11
11
  this.getKey = getKey;
12
12
  }
@@ -25,6 +25,7 @@ var _columns = require("../columns");
25
25
  var _gridFilterUtils = require("../filter/gridFilterUtils");
26
26
  var _gridDataSourceSelector = require("./gridDataSourceSelector");
27
27
  var _useGridDataSourceFilterModelChange = require("./useGridDataSourceFilterModelChange");
28
+ var _useGridDataSourcePolling = require("./useGridDataSourcePolling");
28
29
  var _utils2 = require("./utils");
29
30
  var _cache = require("./cache");
30
31
  var _gridDataSourceError = require("./gridDataSourceError");
@@ -55,9 +56,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
55
56
  const rowsAreUpToDate = React.useRef(false);
56
57
  // Requests that are still running and will apply their response when they settle.
57
58
  const pendingRequestCount = React.useRef(0);
58
- const pollingIntervalRef = React.useRef(null);
59
59
  const onDataSourceErrorProp = props.onDataSourceError;
60
- const revalidateMs = props.dataSourceRevalidateMs;
61
60
  const cacheChunkManager = (0, _useLazyRef.default)(() => {
62
61
  if (!props.pagination) {
63
62
  return new _utils2.CacheChunkManager(paginationModel.pageSize);
@@ -149,7 +148,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
149
148
  cause: originalError
150
149
  }));
151
150
  } else if (process.env.NODE_ENV !== 'production') {
152
- (0, _warning.warnOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
151
+ (0, _warning.errorOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
153
152
  }
154
153
  }
155
154
  } finally {
@@ -210,19 +209,16 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
210
209
  // Ignore background revalidation errors.
211
210
  }
212
211
  });
213
- const stopPolling = React.useCallback(() => {
214
- if (pollingIntervalRef.current !== null) {
215
- clearInterval(pollingIntervalRef.current);
216
- pollingIntervalRef.current = null;
217
- }
218
- }, []);
219
- const startPolling = (0, _useEventCallback.default)(() => {
220
- stopPolling();
221
- if (revalidateMs <= 0 || !standardRowsUpdateStrategyActive) {
222
- return;
223
- }
224
- pollingIntervalRef.current = setInterval(revalidate, revalidateMs);
212
+ const {
213
+ startPolling: startPollingWith,
214
+ stopPolling
215
+ } = (0, _useGridDataSourcePolling.useGridDataSourcePolling)({
216
+ revalidateMs: props.dataSourceRevalidateMs,
217
+ isActive: standardRowsUpdateStrategyActive,
218
+ // Rows that are still loading start the polling when they arrive.
219
+ shouldResume: () => rowsAreUpToDate.current
225
220
  });
221
+ const startPolling = React.useCallback(() => startPollingWith(revalidate), [startPollingWith, revalidate]);
226
222
  const handleDataUpdate = React.useCallback(params => {
227
223
  if ('error' in params) {
228
224
  // Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
@@ -276,7 +272,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
276
272
  cause: errorThrown
277
273
  }));
278
274
  } else if (process.env.NODE_ENV !== 'production') {
279
- (0, _warning.warnOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
275
+ (0, _warning.errorOnce)(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
280
276
  }
281
277
  throw errorThrown; // Let the caller handle the error further
282
278
  }
@@ -329,17 +325,6 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
329
325
  const newCache = getCache(props.dataSourceCache, options.cacheOptions);
330
326
  setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
331
327
  }, [props.dataSourceCache, options.cacheOptions]);
332
- React.useEffect(() => {
333
- if (!standardRowsUpdateStrategyActive) {
334
- stopPolling();
335
- }
336
- }, [standardRowsUpdateStrategyActive, stopPolling]);
337
- React.useEffect(() => {
338
- if (revalidateMs <= 0) {
339
- stopPolling();
340
- }
341
- }, [revalidateMs, stopPolling]);
342
- React.useEffect(() => stopPolling, [stopPolling]);
343
328
  const lastApiRef = React.useRef(apiRef);
344
329
  const lastStrategy = React.useRef(currentStrategy);
345
330
  const lastDataSource = React.useRef(props.dataSource);
@@ -388,7 +373,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
388
373
  // strategies always reset the rows on refetch to keep their order consistent with the
389
374
  // response. Warn so the limitation is discoverable at runtime, not only in the docs.
390
375
  if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === _utils2.DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === _utils2.DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
391
- (0, _warning.warnOnce)(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
376
+ (0, _warning.warnOnce)(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.'].join('\n'));
392
377
  }
393
378
  }, [props.dataSourceKeepPreviousData, currentStrategy]);
394
379
  return {
@@ -1,13 +1,13 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["skipCache", "keepChildrenExpanded", "showChildrenLoading"];
6
6
  import * as React from 'react';
7
7
  import useLazyRef from '@mui/utils/useLazyRef';
8
8
  import useEventCallback from '@mui/utils/useEventCallback';
9
9
  import debounce from '@mui/utils/debounce';
10
- import { warnOnce } from '@mui/x-internals/warning';
10
+ import { errorOnce, warnOnce } from '@mui/x-internals/warning';
11
11
  import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
12
12
  import { GRID_ROOT_GROUP_ID, getReplaceRow, isReplaceUpdate } from "../rows/gridRowsUtils.mjs";
13
13
  import { runIf } from "../../../utils/utils.mjs";
@@ -19,6 +19,7 @@ import { gridColumnLookupSelector } from "../columns/index.mjs";
19
19
  import { removeIncompleteFilterItems } from "../filter/gridFilterUtils.mjs";
20
20
  import { gridGetRowsParamsSelector } from "./gridDataSourceSelector.mjs";
21
21
  import { useGridDataSourceFilterModelChange } from "./useGridDataSourceFilterModelChange.mjs";
22
+ import { useGridDataSourcePolling } from "./useGridDataSourcePolling.mjs";
22
23
  import { CacheChunkManager, DataSourceRowsUpdateStrategy } from "./utils.mjs";
23
24
  import { GridDataSourceCacheDefault } from "./cache.mjs";
24
25
  import { GridGetRowsError, GridUpdateRowError } from "./gridDataSourceError.mjs";
@@ -48,9 +49,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
48
49
  const rowsAreUpToDate = React.useRef(false);
49
50
  // Requests that are still running and will apply their response when they settle.
50
51
  const pendingRequestCount = React.useRef(0);
51
- const pollingIntervalRef = React.useRef(null);
52
52
  const onDataSourceErrorProp = props.onDataSourceError;
53
- const revalidateMs = props.dataSourceRevalidateMs;
54
53
  const cacheChunkManager = useLazyRef(() => {
55
54
  if (!props.pagination) {
56
55
  return new CacheChunkManager(paginationModel.pageSize);
@@ -142,7 +141,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
142
141
  cause: originalError
143
142
  }));
144
143
  } else if (process.env.NODE_ENV !== 'production') {
145
- warnOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
144
+ errorOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
146
145
  }
147
146
  }
148
147
  } finally {
@@ -203,19 +202,16 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
203
202
  // Ignore background revalidation errors.
204
203
  }
205
204
  });
206
- const stopPolling = React.useCallback(() => {
207
- if (pollingIntervalRef.current !== null) {
208
- clearInterval(pollingIntervalRef.current);
209
- pollingIntervalRef.current = null;
210
- }
211
- }, []);
212
- const startPolling = useEventCallback(() => {
213
- stopPolling();
214
- if (revalidateMs <= 0 || !standardRowsUpdateStrategyActive) {
215
- return;
216
- }
217
- pollingIntervalRef.current = setInterval(revalidate, revalidateMs);
205
+ const {
206
+ startPolling: startPollingWith,
207
+ stopPolling
208
+ } = useGridDataSourcePolling({
209
+ revalidateMs: props.dataSourceRevalidateMs,
210
+ isActive: standardRowsUpdateStrategyActive,
211
+ // Rows that are still loading start the polling when they arrive.
212
+ shouldResume: () => rowsAreUpToDate.current
218
213
  });
214
+ const startPolling = React.useCallback(() => startPollingWith(revalidate), [startPollingWith, revalidate]);
219
215
  const handleDataUpdate = React.useCallback(params => {
220
216
  if ('error' in params) {
221
217
  // Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
@@ -269,7 +265,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
269
265
  cause: errorThrown
270
266
  }));
271
267
  } else if (process.env.NODE_ENV !== 'production') {
272
- warnOnce(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
268
+ errorOnce(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'].join('\n'));
273
269
  }
274
270
  throw errorThrown; // Let the caller handle the error further
275
271
  }
@@ -322,17 +318,6 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
322
318
  const newCache = getCache(props.dataSourceCache, options.cacheOptions);
323
319
  setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
324
320
  }, [props.dataSourceCache, options.cacheOptions]);
325
- React.useEffect(() => {
326
- if (!standardRowsUpdateStrategyActive) {
327
- stopPolling();
328
- }
329
- }, [standardRowsUpdateStrategyActive, stopPolling]);
330
- React.useEffect(() => {
331
- if (revalidateMs <= 0) {
332
- stopPolling();
333
- }
334
- }, [revalidateMs, stopPolling]);
335
- React.useEffect(() => stopPolling, [stopPolling]);
336
321
  const lastApiRef = React.useRef(apiRef);
337
322
  const lastStrategy = React.useRef(currentStrategy);
338
323
  const lastDataSource = React.useRef(props.dataSource);
@@ -381,7 +366,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
381
366
  // strategies always reset the rows on refetch to keep their order consistent with the
382
367
  // response. Warn so the limitation is discoverable at runtime, not only in the docs.
383
368
  if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
384
- warnOnce(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
369
+ warnOnce(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.'].join('\n'));
385
370
  }
386
371
  }, [props.dataSourceKeepPreviousData, currentStrategy]);
387
372
  return {
@@ -0,0 +1,29 @@
1
+ interface UseGridDataSourcePollingOptions {
2
+ /**
3
+ * The polling interval in milliseconds. The polling is off when it is `0` or less.
4
+ */
5
+ revalidateMs: number;
6
+ /**
7
+ * The polling is off when it is `false`.
8
+ */
9
+ isActive: boolean;
10
+ /**
11
+ * Runs when `<Activity>` shows the grid again, if the polling started before.
12
+ * @returns {boolean} `true` to resume the polling.
13
+ * @default () => true
14
+ */
15
+ shouldResume?: () => boolean;
16
+ }
17
+ /**
18
+ * Calls a revalidation callback at the `revalidateMs` interval.
19
+ * The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
20
+ */
21
+ export declare const useGridDataSourcePolling: ({
22
+ revalidateMs,
23
+ isActive,
24
+ shouldResume
25
+ }: UseGridDataSourcePollingOptions) => {
26
+ startPolling: (callback: () => void) => void;
27
+ stopPolling: () => void;
28
+ };
29
+ export {};
@@ -0,0 +1,29 @@
1
+ interface UseGridDataSourcePollingOptions {
2
+ /**
3
+ * The polling interval in milliseconds. The polling is off when it is `0` or less.
4
+ */
5
+ revalidateMs: number;
6
+ /**
7
+ * The polling is off when it is `false`.
8
+ */
9
+ isActive: boolean;
10
+ /**
11
+ * Runs when `<Activity>` shows the grid again, if the polling started before.
12
+ * @returns {boolean} `true` to resume the polling.
13
+ * @default () => true
14
+ */
15
+ shouldResume?: () => boolean;
16
+ }
17
+ /**
18
+ * Calls a revalidation callback at the `revalidateMs` interval.
19
+ * The polling pauses while `<Activity>` hides the grid and stops after the grid unmounts.
20
+ */
21
+ export declare const useGridDataSourcePolling: ({
22
+ revalidateMs,
23
+ isActive,
24
+ shouldResume
25
+ }: UseGridDataSourcePollingOptions) => {
26
+ startPolling: (callback: () => void) => void;
27
+ stopPolling: () => void;
28
+ };
29
+ export {};