Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/data/data-grid/components/CustomSortIcons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import SortIcon from '@mui/icons-material/Sort';
import { DataGrid } from '@mui/x-data-grid';

export function SortedDescendingIcon() {
Expand All @@ -11,6 +12,10 @@ export function SortedAscendingIcon() {
return <ExpandLessIcon className="icon" />;
}

export function UnsortedIcon() {
return <SortIcon className="icon" />;
}

const rows = [
{
id: 1,
Expand Down Expand Up @@ -41,6 +46,7 @@ export default function CustomSortIcons() {
slots={{
columnSortedDescendingIcon: SortedDescendingIcon,
columnSortedAscendingIcon: SortedAscendingIcon,
columnUnsortedIcon: UnsortedIcon,
}}
/>
</div>
Expand Down
6 changes: 6 additions & 0 deletions docs/data/data-grid/components/CustomSortIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import SortIcon from '@mui/icons-material/Sort';
import { DataGrid } from '@mui/x-data-grid';

export function SortedDescendingIcon() {
Expand All @@ -11,6 +12,10 @@ export function SortedAscendingIcon() {
return <ExpandLessIcon className="icon" />;
}

export function UnsortedIcon() {
return <SortIcon className="icon" />;
}

const rows = [
{
id: 1,
Expand Down Expand Up @@ -41,6 +46,7 @@ export default function CustomSortIcons() {
slots={{
columnSortedDescendingIcon: SortedDescendingIcon,
columnSortedAscendingIcon: SortedAscendingIcon,
columnUnsortedIcon: UnsortedIcon,
}}
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/data/data-grid/components/CustomSortIcons.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
slots={{
columnSortedDescendingIcon: SortedDescendingIcon,
columnSortedAscendingIcon: SortedAscendingIcon,
columnUnsortedIcon: UnsortedIcon,
}}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ You have to import it from `@mui/x-license` instead:
- The `baseInputAdornment` slot was removed.
- The `pagination` slot has been mostly refactored to `basePagination`.
- The `paper` slot has been renamed to `panelContent`.
- The `columnUnsortedIcon` slot was removed.
- The icon slots now require material icons to be passed like `Icon as any`.
Note: This is due to typing issues that might be resolved later.

Expand Down
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,12 @@
"default": "GridColumnIcon",
"class": null
},
{
"name": "columnUnsortedIcon",
"description": "Icon displayed on the side of the column header title when unsorted.",
"default": "GridColumnUnsortedIcon",
"class": null
},
{
"name": "columnSortedAscendingIcon",
"description": "Icon displayed on the side of the column header title when sorted in ascending order.",
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,12 @@
"default": "GridColumnIcon",
"class": null
},
{
"name": "columnUnsortedIcon",
"description": "Icon displayed on the side of the column header title when unsorted.",
"default": "GridColumnUnsortedIcon",
"class": null
},
{
"name": "columnSortedAscendingIcon",
"description": "Icon displayed on the side of the column header title when sorted in ascending order.",
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,12 @@
"default": "GridColumnIcon",
"class": null
},
{
"name": "columnUnsortedIcon",
"description": "Icon displayed on the side of the column header title when unsorted.",
"default": "GridColumnUnsortedIcon",
"class": null
},
{
"name": "columnSortedAscendingIcon",
"description": "Icon displayed on the side of the column header title when sorted in ascending order.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"columnSortedAscendingIcon": "Icon displayed on the side of the column header title when sorted in ascending order.",
"columnSortedDescendingIcon": "Icon displayed on the side of the column header title when sorted in descending order.",
"columnsPanel": "GridColumns panel component rendered when clicking the columns button.",
"columnUnsortedIcon": "Icon displayed on the side of the column header title when unsorted.",
"densityComfortableIcon": "Icon displayed on the &quot;comfortable&quot; density option in the toolbar.",
"densityCompactIcon": "Icon displayed on the compact density option in the toolbar.",
"densityStandardIcon": "Icon displayed on the standard density option in the toolbar.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,7 @@
"columnSortedAscendingIcon": "Icon displayed on the side of the column header title when sorted in ascending order.",
"columnSortedDescendingIcon": "Icon displayed on the side of the column header title when sorted in descending order.",
"columnsPanel": "GridColumns panel component rendered when clicking the columns button.",
"columnUnsortedIcon": "Icon displayed on the side of the column header title when unsorted.",
"densityComfortableIcon": "Icon displayed on the &quot;comfortable&quot; density option in the toolbar.",
"densityCompactIcon": "Icon displayed on the compact density option in the toolbar.",
"densityStandardIcon": "Icon displayed on the standard density option in the toolbar.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@
"columnSortedAscendingIcon": "Icon displayed on the side of the column header title when sorted in ascending order.",
"columnSortedDescendingIcon": "Icon displayed on the side of the column header title when sorted in descending order.",
"columnsPanel": "GridColumns panel component rendered when clicking the columns button.",
"columnUnsortedIcon": "Icon displayed on the side of the column header title when unsorted.",
"densityComfortableIcon": "Icon displayed on the &quot;comfortable&quot; density option in the toolbar.",
"densityCompactIcon": "Icon displayed on the compact density option in the toolbar.",
"densityStandardIcon": "Icon displayed on the standard density option in the toolbar.",
Expand Down
3 changes: 1 addition & 2 deletions packages/x-data-grid/src/components/GridColumnSortButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { DataGridProcessedProps } from '../models/props/DataGridProps';
import { vars } from '../constants/cssVariables';
import { GridColumnUnsortedIcon } from './GridColumnUnsortedIcon';
import { NotRendered } from '../utils/assert';

export type GridColumnSortButtonProps = GridSlotProps['baseIconButton'] & {
Expand Down Expand Up @@ -61,7 +60,7 @@ function getIcon(
} else if (direction === 'desc') {
Icon = icons.columnSortedDescendingIcon;
} else {
Icon = GridColumnUnsortedIcon;
Icon = icons.columnUnsortedIcon;
iconProps.sortingOrder = sortingOrder;
}
return Icon ? <Icon fontSize="small" className={className} {...iconProps} /> : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { GridBaseIconProps } from '../models/gridSlotsComponentsProps';
import { GridSortDirection } from '../models/gridSortModel';

interface GridColumnUnsortedIconProps extends GridBaseIconProps {
export interface GridColumnUnsortedIconProps extends GridBaseIconProps {
sortingOrder: GridSortDirection[];
}

Expand Down
2 changes: 2 additions & 0 deletions packages/x-data-grid/src/material/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import type { GridIconSlotsComponent } from '../models';
import type { GridBaseSlots } from '../models/gridSlotsComponent';
import type { GridSlotProps as P } from '../models/gridSlotsComponentsProps';
import type { PopperProps } from '../models/gridBaseSlots';
import { GridColumnUnsortedIcon } from '../components/GridColumnUnsortedIcon';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';

Expand Down Expand Up @@ -633,6 +634,7 @@ const iconSlots: GridIconSlotsComponent = {
filterPanelDeleteIcon: GridCloseIcon,
columnFilteredIcon: GridFilterAltIcon,
columnSelectorIcon: GridColumnIcon,
columnUnsortedIcon: GridColumnUnsortedIcon,
columnSortedAscendingIcon: GridArrowUpwardIcon,
columnSortedDescendingIcon: GridArrowDownwardIcon,
columnResizeIcon: GridSeparatorIcon,
Expand Down
6 changes: 6 additions & 0 deletions packages/x-data-grid/src/models/gridIconSlotsComponent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { IconProps } from './gridBaseSlots';
import type { GridColumnUnsortedIconProps } from '../components/GridColumnUnsortedIcon';

/**
* Set of icons used in the grid component UI.
Expand Down Expand Up @@ -35,6 +36,11 @@ export interface GridIconSlotsComponent {
* @default GridColumnIcon
*/
columnSelectorIcon: React.JSXElementConstructor<IconProps>;
/**
* Icon displayed on the side of the column header title when unsorted.
* @default GridColumnUnsortedIcon
*/
columnUnsortedIcon: React.JSXElementConstructor<GridColumnUnsortedIconProps> | null;
/**
* Icon displayed on the side of the column header title when sorted in ascending order.
* @default GridArrowUpwardIcon
Expand Down