@mui/x-data-grid 8.0.0-alpha.8 → 8.0.0-alpha.9

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 (147) hide show
  1. package/CHANGELOG.md +436 -3
  2. package/DataGrid/useDataGridComponent.d.ts +2 -1
  3. package/components/GridApiContext.js +2 -0
  4. package/components/GridConfigurationContext.js +2 -0
  5. package/components/GridRow.js +2 -0
  6. package/components/GridScrollArea.js +2 -0
  7. package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
  8. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
  9. package/components/panel/GridPanel.js +2 -1
  10. package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
  11. package/components/toolbar/GridToolbarColumnsButton.js +6 -1
  12. package/components/toolbar/GridToolbarFilterButton.js +6 -1
  13. package/context/GridContextProvider.d.ts +2 -1
  14. package/context/GridRootPropsContext.js +2 -0
  15. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
  16. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
  17. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
  18. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
  19. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
  20. package/hooks/core/useGridApiInitialization.d.ts +2 -2
  21. package/hooks/core/useGridInitialization.d.ts +2 -2
  22. package/hooks/core/useGridIsRtl.d.ts +2 -2
  23. package/hooks/core/useGridLocaleText.d.ts +2 -2
  24. package/hooks/core/useGridLoggerFactory.d.ts +2 -2
  25. package/hooks/core/useGridRefs.d.ts +2 -2
  26. package/hooks/core/useGridStateInitialization.d.ts +2 -2
  27. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
  28. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
  29. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
  30. package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  31. package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
  32. package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
  33. package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
  34. package/hooks/features/columns/useGridColumns.d.ts +2 -2
  35. package/hooks/features/density/useGridDensity.d.ts +2 -2
  36. package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
  37. package/hooks/features/dimensions/useGridDimensions.js +1 -3
  38. package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
  39. package/hooks/features/editing/useGridEditing.d.ts +2 -2
  40. package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
  41. package/hooks/features/events/useGridEvents.d.ts +2 -2
  42. package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
  43. package/hooks/features/export/useGridCsvExport.d.ts +2 -2
  44. package/hooks/features/export/useGridPrintExport.d.ts +2 -2
  45. package/hooks/features/export/utils.d.ts +2 -2
  46. package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
  47. package/hooks/features/filter/gridFilterUtils.js +3 -3
  48. package/hooks/features/filter/useGridFilter.d.ts +2 -2
  49. package/hooks/features/focus/useGridFocus.d.ts +2 -2
  50. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  51. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  52. package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  53. package/hooks/features/listView/useGridListView.d.ts +2 -2
  54. package/hooks/features/pagination/useGridPagination.d.ts +2 -2
  55. package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
  56. package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
  57. package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
  58. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
  59. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  60. package/hooks/features/preferencesPanel/index.d.ts +1 -1
  61. package/hooks/features/preferencesPanel/index.js +1 -1
  62. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
  63. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  64. package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
  65. package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
  66. package/hooks/features/rowSelection/utils.d.ts +3 -2
  67. package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
  68. package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
  69. package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
  70. package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
  71. package/hooks/features/rows/useGridRows.d.ts +2 -2
  72. package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
  73. package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
  74. package/hooks/features/scroll/useGridScroll.d.ts +2 -2
  75. package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
  76. package/hooks/features/sorting/gridSortingUtils.js +2 -2
  77. package/hooks/features/sorting/useGridSorting.d.ts +2 -2
  78. package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
  79. package/hooks/features/virtualization/useGridVirtualScroller.js +1 -8
  80. package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  81. package/hooks/utils/useGridApiContext.d.ts +2 -2
  82. package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
  83. package/hooks/utils/useGridApiMethod.d.ts +2 -2
  84. package/hooks/utils/useGridApiRef.d.ts +2 -2
  85. package/hooks/utils/useGridApiRef.js +3 -1
  86. package/hooks/utils/useGridInitializeState.d.ts +3 -3
  87. package/hooks/utils/useGridLogger.d.ts +2 -2
  88. package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
  89. package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
  90. package/hooks/utils/useGridSelector.d.ts +2 -2
  91. package/hooks/utils/useGridVisibleRows.d.ts +3 -3
  92. package/index.js +1 -1
  93. package/locales/faIR.js +5 -6
  94. package/locales/urPK.js +9 -10
  95. package/models/colDef/gridColDef.d.ts +9 -8
  96. package/models/gridExport.d.ts +2 -2
  97. package/models/gridFilterOperator.d.ts +2 -1
  98. package/models/props/DataGridProps.d.ts +2 -1
  99. package/modern/components/GridApiContext.js +2 -0
  100. package/modern/components/GridConfigurationContext.js +2 -0
  101. package/modern/components/GridRow.js +2 -0
  102. package/modern/components/GridScrollArea.js +2 -0
  103. package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
  104. package/modern/components/panel/GridPanel.js +2 -1
  105. package/modern/components/toolbar/GridToolbarColumnsButton.js +6 -1
  106. package/modern/components/toolbar/GridToolbarFilterButton.js +6 -1
  107. package/modern/context/GridRootPropsContext.js +2 -0
  108. package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  109. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
  110. package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
  111. package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  112. package/modern/hooks/features/preferencesPanel/index.js +1 -1
  113. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  114. package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
  115. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -8
  116. package/modern/hooks/utils/useGridApiRef.js +3 -1
  117. package/modern/index.js +1 -1
  118. package/modern/locales/faIR.js +5 -6
  119. package/modern/locales/urPK.js +9 -10
  120. package/modern/utils/isJSDOM.js +1 -0
  121. package/node/components/GridApiContext.js +1 -0
  122. package/node/components/GridConfigurationContext.js +1 -0
  123. package/node/components/GridRow.js +1 -0
  124. package/node/components/GridScrollArea.js +1 -0
  125. package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +19 -5
  126. package/node/components/panel/GridPanel.js +2 -1
  127. package/node/components/toolbar/GridToolbarColumnsButton.js +6 -1
  128. package/node/components/toolbar/GridToolbarFilterButton.js +6 -1
  129. package/node/context/GridRootPropsContext.js +1 -0
  130. package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  131. package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
  132. package/node/hooks/features/filter/gridFilterUtils.js +3 -3
  133. package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
  134. package/node/hooks/features/preferencesPanel/index.js +11 -10
  135. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  136. package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
  137. package/node/hooks/features/virtualization/useGridVirtualScroller.js +3 -10
  138. package/node/hooks/utils/useGridApiRef.js +3 -1
  139. package/node/index.js +1 -1
  140. package/node/locales/faIR.js +5 -6
  141. package/node/locales/urPK.js +9 -10
  142. package/node/utils/isJSDOM.js +7 -0
  143. package/package.json +2 -2
  144. package/utils/createSelector.d.ts +2 -2
  145. package/utils/getPublicApiRef.d.ts +2 -1
  146. package/utils/isJSDOM.d.ts +1 -0
  147. package/utils/isJSDOM.js +1 -0
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { RefObject } from '@mui/x-internals/types';
2
3
  import { GridCellClassNamePropType } from '../gridCellClass';
3
4
  import { GridColumnHeaderClassNamePropType } from '../gridColumnHeaderClass';
4
5
  import type { GridFilterOperator } from '../gridFilterOperator';
@@ -24,13 +25,13 @@ export type ValueOptions = string | number | {
24
25
  * Value that can be used as a key for grouping rows
25
26
  */
26
27
  export type GridKeyValue = string | number | boolean;
27
- export type GridApplyQuickFilter<R extends GridValidRowModel = GridValidRowModel, V = any> = (value: V, row: R, column: GridColDef, apiRef: React.RefObject<GridApiCommunity>) => boolean;
28
- export type GetApplyQuickFilterFn<R extends GridValidRowModel = GridValidRowModel, V = any> = (value: any, colDef: GridStateColDef<R, V>, apiRef: React.RefObject<GridApiCommunity>) => null | GridApplyQuickFilter<R, V>;
29
- export type GridValueGetter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V, TValue = never> = (value: TValue, row: R, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => V;
30
- export type GridValueFormatter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V, TValue = never> = (value: TValue, row: R, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => F;
31
- export type GridValueSetter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => R;
32
- export type GridValueParser<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: F | undefined, row: R | undefined, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => V;
33
- export type GridColSpanFn<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => number | undefined;
28
+ export type GridApplyQuickFilter<R extends GridValidRowModel = GridValidRowModel, V = any> = (value: V, row: R, column: GridColDef, apiRef: RefObject<GridApiCommunity>) => boolean;
29
+ export type GetApplyQuickFilterFn<R extends GridValidRowModel = GridValidRowModel, V = any> = (value: any, colDef: GridStateColDef<R, V>, apiRef: RefObject<GridApiCommunity>) => null | GridApplyQuickFilter<R, V>;
30
+ export type GridValueGetter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V, TValue = never> = (value: TValue, row: R, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => V;
31
+ export type GridValueFormatter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V, TValue = never> = (value: TValue, row: R, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => F;
32
+ export type GridValueSetter<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => R;
33
+ export type GridValueParser<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: F | undefined, row: R | undefined, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => V;
34
+ export type GridColSpanFn<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => number | undefined;
34
35
  /**
35
36
  * Column Definition base interface.
36
37
  */
@@ -217,7 +218,7 @@ export interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel,
217
218
  * This function can return `null` to skip filtering for this value and column.
218
219
  * @param {any} value The value with which we want to filter the column.
219
220
  * @param {GridStateColDef} colDef The column from which we want to filter the rows.
220
- * @param {React.RefObject<GridApiCommunity>} apiRef Deprecated: The API of the grid.
221
+ * @param {RefObject<GridApiCommunity>} apiRef Deprecated: The API of the grid.
221
222
  * @returns {null | GridApplyQuickFilter} The function to call to check if a row pass this filter value or not.
222
223
  */
223
224
  getApplyQuickFilterFn?: GetApplyQuickFilterFn<R, V>;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridRowId } from './gridRows';
3
3
  import type { GridApiCommon } from './api';
4
4
  import type { GridApiCommunity } from './api/gridApiCommunity';
@@ -49,7 +49,7 @@ export interface GridGetRowsToExportParams<Api extends GridApiCommon = GridApiCo
49
49
  /**
50
50
  * The API of the grid.
51
51
  */
52
- apiRef: React.RefObject<Api>;
52
+ apiRef: RefObject<Api>;
53
53
  }
54
54
  export interface GridCsvGetRowsToExportParams<Api extends GridApiCommon = GridApiCommunity> extends GridGetRowsToExportParams<Api> {
55
55
  }
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react';
2
+ import { RefObject } from '@mui/x-internals/types';
2
3
  import { GridFilterItem } from './gridFilterItem';
3
4
  import type { GridColDef } from './colDef/gridColDef';
4
5
  import type { GridValidRowModel } from './gridRows';
5
6
  import type { GridApiCommunity } from './api/gridApiCommunity';
6
- type ApplyFilterFn<R extends GridValidRowModel = any, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: React.RefObject<GridApiCommunity>) => boolean;
7
+ type ApplyFilterFn<R extends GridValidRowModel = any, V = any, F = V> = (value: V, row: R, column: GridColDef<R, V, F>, apiRef: RefObject<GridApiCommunity>) => boolean;
7
8
  export type GetApplyFilterFn<R extends GridValidRowModel = any, V = any, F = V> = (filterItem: GridFilterItem, column: GridColDef<R, V, F>) => null | ApplyFilterFn<R, V, F>;
8
9
  /**
9
10
  * Filter operator definition interface.
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { RefObject } from '@mui/x-internals/types';
2
3
  import { SxProps } from '@mui/system';
3
4
  import { Theme } from '@mui/material/styles';
4
5
  import { CommonProps } from '@mui/material/OverridableComponent';
@@ -369,7 +370,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
369
370
  /**
370
371
  * The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
371
372
  */
372
- apiRef?: React.RefObject<GridApiCommunity>;
373
+ apiRef?: RefObject<GridApiCommunity>;
373
374
  /**
374
375
  * Signal to the underlying logic what version of the public component API
375
376
  * of the Data Grid is exposed [[GridSignature]].
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  export const GridApiContext = /*#__PURE__*/React.createContext(undefined);
3
5
  if (process.env.NODE_ENV !== 'production') {
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  export const GridConfigurationContext = /*#__PURE__*/React.createContext(undefined);
3
5
  if (process.env.NODE_ENV !== 'production') {
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
5
  const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "offsetTop", "offsetLeft", "columnsTotalWidth", "firstColumnIndex", "lastColumnIndex", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "isNotVisible", "showBottomBorder", "scrollbarWidth", "gridHasFiller", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import clsx from 'clsx';
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
5
5
  import { useGridSelector } from "../../hooks/index.js";
6
- import { gridPreferencePanelStateSelector } from "../../hooks/features/preferencesPanel/gridPreferencePanelSelector.js";
6
+ import { gridPreferencePanelSelectorWithLabel, gridPreferencePanelStateSelector } from "../../hooks/features/preferencesPanel/gridPreferencePanelSelector.js";
7
7
  import { GridPreferencePanelsValue } from "../../hooks/features/preferencesPanel/gridPreferencePanelsValue.js";
8
8
  import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
9
9
  import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
@@ -19,6 +19,21 @@ const useUtilityClasses = ownerState => {
19
19
  };
20
20
  return composeClasses(slots, getDataGridUtilityClass, classes);
21
21
  };
22
+ function GridColumnHeaderFilterIconButtonWrapped(props) {
23
+ if (!props.counter) {
24
+ return null;
25
+ }
26
+ return /*#__PURE__*/_jsx(GridColumnHeaderFilterIconButton, _extends({}, props));
27
+ }
28
+ process.env.NODE_ENV !== "production" ? GridColumnHeaderFilterIconButtonWrapped.propTypes = {
29
+ // ----------------------------- Warning --------------------------------
30
+ // | These PropTypes are generated from the TypeScript type definitions |
31
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
32
+ // ----------------------------------------------------------------------
33
+ counter: PropTypes.number,
34
+ field: PropTypes.string.isRequired,
35
+ onClick: PropTypes.func
36
+ } : void 0;
22
37
  function GridColumnHeaderFilterIconButton(props) {
23
38
  const {
24
39
  counter,
@@ -31,8 +46,8 @@ function GridColumnHeaderFilterIconButton(props) {
31
46
  classes: rootProps.classes
32
47
  });
33
48
  const classes = useUtilityClasses(ownerState);
34
- const preferencePanel = useGridSelector(apiRef, gridPreferencePanelStateSelector);
35
49
  const labelId = useId();
50
+ const isOpen = useGridSelector(apiRef, gridPreferencePanelSelectorWithLabel, labelId);
36
51
  const panelId = useId();
37
52
  const toggleFilter = React.useCallback(event => {
38
53
  event.preventDefault();
@@ -53,7 +68,6 @@ function GridColumnHeaderFilterIconButton(props) {
53
68
  if (!counter) {
54
69
  return null;
55
70
  }
56
- const open = preferencePanel.open && preferencePanel.labelId === labelId;
57
71
  const iconButton = /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
58
72
  id: labelId,
59
73
  onClick: toggleFilter,
@@ -61,8 +75,8 @@ function GridColumnHeaderFilterIconButton(props) {
61
75
  size: "small",
62
76
  tabIndex: -1,
63
77
  "aria-haspopup": "menu",
64
- "aria-expanded": open,
65
- "aria-controls": open ? panelId : undefined
78
+ "aria-expanded": isOpen,
79
+ "aria-controls": isOpen ? panelId : undefined
66
80
  }, rootProps.slotProps?.baseIconButton, {
67
81
  children: /*#__PURE__*/_jsx(rootProps.slots.columnFilteredIcon, {
68
82
  className: classes.icon,
@@ -91,4 +105,4 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderFilterIconButton.propTyp
91
105
  field: PropTypes.string.isRequired,
92
106
  onClick: PropTypes.func
93
107
  } : void 0;
94
- export { GridColumnHeaderFilterIconButton };
108
+ export { GridColumnHeaderFilterIconButtonWrapped as GridColumnHeaderFilterIconButton };
@@ -91,7 +91,8 @@ const GridPanel = forwardRef((props, ref) => {
91
91
  }, other, {
92
92
  ref: ref,
93
93
  children: /*#__PURE__*/_jsx(ClickAwayListener, {
94
- mouseEvent: "onMouseUp",
94
+ mouseEvent: "onPointerUp",
95
+ touchEvent: false,
95
96
  onClickAway: handleClickAway,
96
97
  children: /*#__PURE__*/_jsx(GridPaperRoot, {
97
98
  className: classes.paper,
@@ -46,7 +46,12 @@ const GridToolbarColumnsButton = forwardRef(function GridToolbarColumnsButton(pr
46
46
  "aria-expanded": isOpen,
47
47
  "aria-controls": isOpen ? columnPanelId : undefined,
48
48
  startIcon: /*#__PURE__*/_jsx(rootProps.slots.columnSelectorIcon, {}),
49
- onClick: showColumns
49
+ onClick: showColumns,
50
+ onPointerUp: event => {
51
+ if (preferencePanel.open) {
52
+ event.stopPropagation();
53
+ }
54
+ }
50
55
  }, rootProps.slotProps?.baseButton, buttonProps, {
51
56
  ref: ref,
52
57
  children: apiRef.current.getLocaleText('toolbarColumns')
@@ -113,7 +113,12 @@ const GridToolbarFilterButton = forwardRef(function GridToolbarFilterButton(prop
113
113
  }, rootProps.slotProps?.baseBadge, badgeProps, {
114
114
  children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {})
115
115
  })),
116
- onClick: toggleFilter
116
+ onClick: toggleFilter,
117
+ onPointerUp: event => {
118
+ if (preferencePanel.open) {
119
+ event.stopPropagation();
120
+ }
121
+ }
117
122
  }, rootProps.slotProps?.baseButton, buttonProps, {
118
123
  ref: ref,
119
124
  children: apiRef.current.getLocaleText('toolbarFilters')
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  const GridRootPropsContext = /*#__PURE__*/React.createContext(undefined);
3
5
  if (process.env.NODE_ENV !== 'production') {
@@ -40,7 +40,6 @@ export const useGridColumnMenu = apiRef => {
40
40
  });
41
41
  });
42
42
  apiRef.current.hidePreferences();
43
- apiRef.current.forceUpdate();
44
43
  }
45
44
  }, [apiRef, logger]);
46
45
  const hideColumnMenu = React.useCallback(() => {
@@ -82,7 +81,6 @@ export const useGridColumnMenu = apiRef => {
82
81
  columnMenu: newState
83
82
  });
84
83
  });
85
- apiRef.current.forceUpdate();
86
84
  }
87
85
  }, [apiRef, logger]);
88
86
  const toggleColumnMenu = React.useCallback(field => {
@@ -15,6 +15,7 @@ import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
15
15
  import { calculatePinnedRowsHeight, getValidRowHeight, rowHeightWarning } from "../rows/gridRowsUtils.js";
16
16
  import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
17
17
  import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../../constants/dataGridPropsDefaultValues.js";
18
+ import { isJSDOM } from "../../../utils/isJSDOM.js";
18
19
  const EMPTY_SIZE = {
19
20
  width: 0,
20
21
  height: 0
@@ -220,9 +221,6 @@ export function useGridDimensions(apiRef, props) {
220
221
  const isFirstSizing = React.useRef(true);
221
222
  const handleResize = React.useCallback(size => {
222
223
  rootDimensionsRef.current = size;
223
-
224
- // jsdom has no layout capabilities
225
- const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
226
224
  if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
227
225
  logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
228
226
  errorShown.current = true;
@@ -19,7 +19,7 @@ function getHasEval() {
19
19
  /**
20
20
  * Adds default values to the optional fields of a filter items.
21
21
  * @param {GridFilterItem} item The raw filter item.
22
- * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
22
+ * @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
23
23
  * @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
24
24
  * TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
25
25
  */
@@ -133,7 +133,7 @@ let filterItemsApplierId = 1;
133
133
  /**
134
134
  * Generates a method to easily check if a row is matching the current filter model.
135
135
  * @param {GridFilterModel} filterModel The model with which we want to filter the rows.
136
- * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
136
+ * @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
137
137
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
138
138
  */
139
139
  const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) => {
@@ -181,7 +181,7 @@ export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
181
181
  /**
182
182
  * Generates a method to easily check if a row is matching the current quick filter.
183
183
  * @param {any[]} filterModel The model with which we want to filter the rows.
184
- * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
184
+ * @param {RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
185
185
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
186
186
  */
187
187
  const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
@@ -1 +1,8 @@
1
- export const gridPreferencePanelStateSelector = state => state.preferencePanel;
1
+ import { createSelector } from "../../../utils/createSelector.js";
2
+ export const gridPreferencePanelStateSelector = state => state.preferencePanel;
3
+ export const gridPreferencePanelSelectorWithLabel = createSelector(gridPreferencePanelStateSelector, (panel, labelId) => {
4
+ if (panel.open && panel.labelId === labelId) {
5
+ return true;
6
+ }
7
+ return false;
8
+ });
@@ -1,3 +1,3 @@
1
- export * from "./gridPreferencePanelSelector.js";
1
+ export { gridPreferencePanelStateSelector } from "./gridPreferencePanelSelector.js";
2
2
  export * from "./gridPreferencePanelState.js";
3
3
  export * from "./gridPreferencePanelsValue.js";
@@ -15,42 +15,29 @@ export const preferencePanelStateInitializer = (state, props) => _extends({}, st
15
15
  */
16
16
  export const useGridPreferencesPanel = (apiRef, props) => {
17
17
  const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
18
- const hideTimeout = React.useRef(undefined);
19
- const immediateTimeout = React.useRef(undefined);
20
18
 
21
19
  /**
22
20
  * API METHODS
23
21
  */
24
22
  const hidePreferences = React.useCallback(() => {
25
- logger.debug('Hiding Preferences Panel');
26
- const preferencePanelState = gridPreferencePanelStateSelector(apiRef.current.state);
27
- if (preferencePanelState.openedPanelValue) {
23
+ apiRef.current.setState(state => {
24
+ if (!state.preferencePanel.open) {
25
+ return state;
26
+ }
27
+ logger.debug('Hiding Preferences Panel');
28
+ const preferencePanelState = gridPreferencePanelStateSelector(state);
28
29
  apiRef.current.publishEvent('preferencePanelClose', {
29
30
  openedPanelValue: preferencePanelState.openedPanelValue
30
31
  });
31
- }
32
- apiRef.current.setState(state => _extends({}, state, {
33
- preferencePanel: {
34
- open: false
35
- }
36
- }));
37
- apiRef.current.forceUpdate();
32
+ return _extends({}, state, {
33
+ preferencePanel: {
34
+ open: false
35
+ }
36
+ });
37
+ });
38
38
  }, [apiRef, logger]);
39
-
40
- // This is to prevent the preferences from closing when you open a select box or another panel,
41
- // The issue is in MUI core V4 => Fixed in V5
42
- const doNotHidePanel = React.useCallback(() => {
43
- immediateTimeout.current = setTimeout(() => clearTimeout(hideTimeout.current), 0);
44
- }, []);
45
-
46
- // This is a hack for the issue with Core V4, by delaying hiding the panel on the clickAwayListener,
47
- // we can cancel the action if the trigger element still need the panel...
48
- const hidePreferencesDelayed = React.useCallback(() => {
49
- hideTimeout.current = setTimeout(hidePreferences, 100);
50
- }, [hidePreferences]);
51
39
  const showPreferences = React.useCallback((newValue, panelId, labelId) => {
52
40
  logger.debug('Opening Preferences Panel');
53
- doNotHidePanel();
54
41
  apiRef.current.setState(state => _extends({}, state, {
55
42
  preferencePanel: _extends({}, state.preferencePanel, {
56
43
  open: true,
@@ -62,11 +49,10 @@ export const useGridPreferencesPanel = (apiRef, props) => {
62
49
  apiRef.current.publishEvent('preferencePanelOpen', {
63
50
  openedPanelValue: newValue
64
51
  });
65
- apiRef.current.forceUpdate();
66
- }, [logger, doNotHidePanel, apiRef]);
52
+ }, [logger, apiRef]);
67
53
  useGridApiMethod(apiRef, {
68
54
  showPreferences,
69
- hidePreferences: hidePreferencesDelayed
55
+ hidePreferences
70
56
  }, 'public');
71
57
 
72
58
  /**
@@ -99,14 +85,4 @@ export const useGridPreferencesPanel = (apiRef, props) => {
99
85
  }, [apiRef]);
100
86
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
101
87
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
102
-
103
- /**
104
- * EFFECTS
105
- */
106
- React.useEffect(() => {
107
- return () => {
108
- clearTimeout(hideTimeout.current);
109
- clearTimeout(immediateTimeout.current);
110
- };
111
- }, []);
112
88
  };
@@ -19,7 +19,7 @@ const isDesc = direction => direction === 'desc';
19
19
  /**
20
20
  * Transform an item of the sorting model into a method comparing two rows.
21
21
  * @param {GridSortItem} sortItem The sort item we want to apply.
22
- * @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
22
+ * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
23
23
  * @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
24
24
  */
25
25
  const parseSortItem = (sortItem, apiRef) => {
@@ -72,7 +72,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
72
72
  /**
73
73
  * Generates a method to easily sort a list of rows according to the current sort model.
74
74
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
75
- * @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
75
+ * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
76
76
  * @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
77
77
  */
78
78
  export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
@@ -26,6 +26,7 @@ import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpan
26
26
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
27
27
  import { minimalContentHeight } from "../rows/gridRowsUtils.js";
28
28
  import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
29
+ import { isJSDOM } from "../../../utils/isJSDOM.js";
29
30
  import { jsx as _jsx } from "react/jsx-runtime";
30
31
  const MINIMUM_COLUMN_WIDTH = 50;
31
32
  var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
@@ -45,14 +46,6 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
45
46
  direction: ScrollDirection.NONE,
46
47
  buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
47
48
  });
48
- let isJSDOM = false;
49
- try {
50
- if (typeof window !== 'undefined') {
51
- isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
52
- }
53
- } catch (_) {
54
- /* ignore */
55
- }
56
49
  export const useGridVirtualScroller = () => {
57
50
  const apiRef = useGridPrivateApiContext();
58
51
  const rootProps = useGridRootProps();
@@ -2,4 +2,6 @@ import * as React from 'react';
2
2
  /**
3
3
  * Hook that instantiate a [[GridApiRef]].
4
4
  */
5
- export const useGridApiRef = () => React.useRef({});
5
+ export const useGridApiRef = () =>
6
+ // TODO v8: initialize with null (see https://github.com/mui/mui-x/issues/16135#issuecomment-2589395230 and https://github.com/mui/mui-x/issues/16000#issuecomment-2567820735)
7
+ React.useRef({});
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.0.0-alpha.8
2
+ * @mui/x-data-grid v8.0.0-alpha.9
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -45,8 +45,7 @@ const faIRGrid = {
45
45
  columnsManagementNoColumns: 'بدون سطر',
46
46
  columnsManagementShowHideAllText: 'نمایش/مخفی کردن همه',
47
47
  columnsManagementReset: 'بازنشانی',
48
- // columnsManagementDeleteIconLabel: 'Clear',
49
-
48
+ columnsManagementDeleteIconLabel: 'پاک کردن',
50
49
  // Filter panel text
51
50
  filterPanelAddFilter: 'افزودن فیلتر',
52
51
  filterPanelRemoveAll: 'حذف همه',
@@ -60,9 +59,9 @@ const faIRGrid = {
60
59
  filterPanelInputPlaceholder: 'فیلتر مقدار',
61
60
  // Filter operators text
62
61
  filterOperatorContains: 'شامل',
63
- // filterOperatorDoesNotContain: 'does not contain',
62
+ filterOperatorDoesNotContain: 'شامل نمیشود',
64
63
  filterOperatorEquals: 'مساوی',
65
- // filterOperatorDoesNotEqual: 'does not equal',
64
+ filterOperatorDoesNotEqual: 'برابر نیست',
66
65
  filterOperatorStartsWith: 'شروع با',
67
66
  filterOperatorEndsWith: 'پایان با',
68
67
  filterOperatorIs: 'هست',
@@ -82,9 +81,9 @@ const faIRGrid = {
82
81
  'filterOperator<=': '<=',
83
82
  // Header filter operators text
84
83
  headerFilterOperatorContains: 'شامل',
85
- // headerFilterOperatorDoesNotContain: 'Does not contain',
84
+ headerFilterOperatorDoesNotContain: 'شامل نمیشود',
86
85
  headerFilterOperatorEquals: 'مساوی',
87
- // headerFilterOperatorDoesNotEqual: 'Does not equal',
86
+ headerFilterOperatorDoesNotEqual: 'برابر نیست',
88
87
  headerFilterOperatorStartsWith: 'شروع با',
89
88
  headerFilterOperatorEndsWith: 'پایان با',
90
89
  headerFilterOperatorIs: 'هست',
@@ -41,12 +41,11 @@ const urPKGrid = {
41
41
  toolbarExportPrint: 'پرنٹ کریں',
42
42
  toolbarExportExcel: 'ایکسل کے طور پر ڈاوٴنلوڈ کریں',
43
43
  // Columns management text
44
- // columnsManagementSearchTitle: 'Search',
45
- // columnsManagementNoColumns: 'No columns',
46
- // columnsManagementShowHideAllText: 'Show/Hide All',
47
- // columnsManagementReset: 'Reset',
48
- // columnsManagementDeleteIconLabel: 'Clear',
49
-
44
+ columnsManagementSearchTitle: 'تلاش',
45
+ columnsManagementNoColumns: 'کوئی کالم نہیں',
46
+ columnsManagementShowHideAllText: 'تمام دکھائیں/چھپائیں',
47
+ columnsManagementReset: 'ریسیٹ',
48
+ columnsManagementDeleteIconLabel: 'کلئیر',
50
49
  // Filter panel text
51
50
  filterPanelAddFilter: 'نیا فلٹر',
52
51
  filterPanelRemoveAll: 'سارے ختم کریں',
@@ -60,9 +59,9 @@ const urPKGrid = {
60
59
  filterPanelInputPlaceholder: 'ویلیو کو فلٹر کریں',
61
60
  // Filter operators text
62
61
  filterOperatorContains: 'شامل ہے',
63
- // filterOperatorDoesNotContain: 'does not contain',
62
+ filterOperatorDoesNotContain: 'موجود نہیں ہے',
64
63
  filterOperatorEquals: 'برابر ہے',
65
- // filterOperatorDoesNotEqual: 'does not equal',
64
+ filterOperatorDoesNotEqual: 'برابر نہیں ہے',
66
65
  filterOperatorStartsWith: 'شروع ہوتا ہے',
67
66
  filterOperatorEndsWith: 'ختم ہوتا ہے',
68
67
  filterOperatorIs: 'ہے',
@@ -82,9 +81,9 @@ const urPKGrid = {
82
81
  'filterOperator<=': '<=',
83
82
  // Header filter operators text
84
83
  headerFilterOperatorContains: 'شامل ہے',
85
- // headerFilterOperatorDoesNotContain: 'Does not contain',
84
+ headerFilterOperatorDoesNotContain: 'موجود نہیں ہے',
86
85
  headerFilterOperatorEquals: 'برابر ہے',
87
- // headerFilterOperatorDoesNotEqual: 'Does not equal',
86
+ headerFilterOperatorDoesNotEqual: 'برابر نہیں ہے',
88
87
  headerFilterOperatorStartsWith: 'شروع ہوتا ہے',
89
88
  headerFilterOperatorEndsWith: 'ختم ہوتا ہے',
90
89
  headerFilterOperatorIs: 'ہے',
@@ -0,0 +1 @@
1
+ export const isJSDOM = typeof window !== 'undefined' && /jsdom|HappyDOM/.test(window.navigator.userAgent);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.GridColumnHeaderFilterIconButton = GridColumnHeaderFilterIconButton;
8
+ exports.GridColumnHeaderFilterIconButton = GridColumnHeaderFilterIconButtonWrapped;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -27,6 +27,21 @@ const useUtilityClasses = ownerState => {
27
27
  };
28
28
  return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
29
29
  };
30
+ function GridColumnHeaderFilterIconButtonWrapped(props) {
31
+ if (!props.counter) {
32
+ return null;
33
+ }
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnHeaderFilterIconButton, (0, _extends2.default)({}, props));
35
+ }
36
+ process.env.NODE_ENV !== "production" ? GridColumnHeaderFilterIconButtonWrapped.propTypes = {
37
+ // ----------------------------- Warning --------------------------------
38
+ // | These PropTypes are generated from the TypeScript type definitions |
39
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
40
+ // ----------------------------------------------------------------------
41
+ counter: _propTypes.default.number,
42
+ field: _propTypes.default.string.isRequired,
43
+ onClick: _propTypes.default.func
44
+ } : void 0;
30
45
  function GridColumnHeaderFilterIconButton(props) {
31
46
  const {
32
47
  counter,
@@ -39,8 +54,8 @@ function GridColumnHeaderFilterIconButton(props) {
39
54
  classes: rootProps.classes
40
55
  });
41
56
  const classes = useUtilityClasses(ownerState);
42
- const preferencePanel = (0, _hooks.useGridSelector)(apiRef, _gridPreferencePanelSelector.gridPreferencePanelStateSelector);
43
57
  const labelId = (0, _utils.unstable_useId)();
58
+ const isOpen = (0, _hooks.useGridSelector)(apiRef, _gridPreferencePanelSelector.gridPreferencePanelSelectorWithLabel, labelId);
44
59
  const panelId = (0, _utils.unstable_useId)();
45
60
  const toggleFilter = React.useCallback(event => {
46
61
  event.preventDefault();
@@ -61,7 +76,6 @@ function GridColumnHeaderFilterIconButton(props) {
61
76
  if (!counter) {
62
77
  return null;
63
78
  }
64
- const open = preferencePanel.open && preferencePanel.labelId === labelId;
65
79
  const iconButton = /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
66
80
  id: labelId,
67
81
  onClick: toggleFilter,
@@ -69,8 +83,8 @@ function GridColumnHeaderFilterIconButton(props) {
69
83
  size: "small",
70
84
  tabIndex: -1,
71
85
  "aria-haspopup": "menu",
72
- "aria-expanded": open,
73
- "aria-controls": open ? panelId : undefined
86
+ "aria-expanded": isOpen,
87
+ "aria-controls": isOpen ? panelId : undefined
74
88
  }, rootProps.slotProps?.baseIconButton, {
75
89
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnFilteredIcon, {
76
90
  className: classes.icon,
@@ -99,7 +99,8 @@ const GridPanel = exports.GridPanel = (0, _forwardRef.forwardRef)((props, ref) =
99
99
  }, other, {
100
100
  ref: ref,
101
101
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayListener.default, {
102
- mouseEvent: "onMouseUp",
102
+ mouseEvent: "onPointerUp",
103
+ touchEvent: false,
103
104
  onClickAway: handleClickAway,
104
105
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridPaperRoot, {
105
106
  className: classes.paper,