Skip to content

Commit

Permalink
[DataGrid] Store in the state the cell outlined
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw committed Dec 7, 2022
1 parent 1ff32ae commit 4babd8b
Show file tree
Hide file tree
Showing 35 changed files with 285 additions and 111 deletions.
14 changes: 14 additions & 0 deletions docs/data/data-grid/events/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"params": "GridAggregationModel",
"event": "MuiEvent<{}>"
},
{
"projects": ["x-data-grid", "x-data-grid-pro", "x-data-grid-premium"],
"name": "cellBlur",
"description": "Fired when a <code>blur</code> event happens in a cell.",
"params": "GridCellParams",
"event": "MuiEvent<React.FocusEvent<HTMLElement>>"
},
{
"projects": ["x-data-grid", "x-data-grid-pro", "x-data-grid-premium"],
"name": "cellClick",
Expand Down Expand Up @@ -38,6 +45,13 @@
"event": "MuiEvent<MuiBaseEvent>",
"componentProp": "onCellEditStop"
},
{
"projects": ["x-data-grid", "x-data-grid-pro", "x-data-grid-premium"],
"name": "cellFocus",
"description": "Fired when a <code>focus</code> event happens in a cell.",
"params": "GridCellParams",
"event": "MuiEvent<React.FocusEvent<HTMLElement>>"
},
{
"projects": ["x-data-grid", "x-data-grid-pro", "x-data-grid-premium"],
"name": "cellFocusIn",
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"experimentalFeatures": {
"type": {
"name": "shape",
"description": "{ columnGrouping?: bool, lazyLoading?: bool, rowPinning?: bool, warnIfFocusStateIsNotSynced?: bool }"
"description": "{ columnGrouping?: bool, lazyLoading?: bool, rowPinning?: bool }"
}
},
"filterMode": {
Expand Down Expand Up @@ -341,6 +341,7 @@
"cell--textLeft",
"cell--textRight",
"cell--withRenderer",
"cell--outlined",
"cell",
"cellContent",
"cellCheckbox",
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"experimentalFeatures": {
"type": {
"name": "shape",
"description": "{ columnGrouping?: bool, lazyLoading?: bool, rowPinning?: bool, warnIfFocusStateIsNotSynced?: bool }"
"description": "{ columnGrouping?: bool, lazyLoading?: bool, rowPinning?: bool }"
}
},
"filterMode": {
Expand Down Expand Up @@ -319,6 +319,7 @@
"cell--textLeft",
"cell--textRight",
"cell--withRenderer",
"cell--outlined",
"cell",
"cellContent",
"cellCheckbox",
Expand Down
6 changes: 2 additions & 4 deletions docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
"editRowsModel": { "type": { "name": "object" } },
"error": { "type": { "name": "any" } },
"experimentalFeatures": {
"type": {
"name": "shape",
"description": "{ columnGrouping?: bool, warnIfFocusStateIsNotSynced?: bool }"
}
"type": { "name": "shape", "description": "{ columnGrouping?: bool }" }
},
"filterMode": {
"type": { "name": "enum", "description": "'client'<br>&#124;&nbsp;'server'" },
Expand Down Expand Up @@ -263,6 +260,7 @@
"cell--textLeft",
"cell--textRight",
"cell--withRenderer",
"cell--outlined",
"cell",
"cellContent",
"cellCheckbox",
Expand Down
12 changes: 12 additions & 0 deletions docs/pages/x/api/data-grid/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"description": "",
"supportsApiRef": true
},
{
"name": "gridCellOutlineCellSelector",
"returnType": "GridCellIdentifier | null",
"description": "",
"supportsApiRef": true
},
{
"name": "gridColumnGroupsHeaderMaxDepthSelector",
"returnType": "number",
Expand Down Expand Up @@ -134,6 +140,12 @@
"description": "",
"supportsApiRef": false
},
{
"name": "gridOutlineStateSelector",
"returnType": "GridOutlineState",
"description": "",
"supportsApiRef": false
},
{
"name": "gridPageCountSelector",
"returnType": "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-pro-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-pro-zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid-zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
5 changes: 5 additions & 0 deletions docs/translations/api-docs/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
"nodeName": "the cell element",
"conditions": "the cell has a custom renderer"
},
"cell--outlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the cell element",
"conditions": "the cell is outlined"
},
"cell": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the cell element" },
"cellContent": {
"description": "Styles applied to {{nodeName}}.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ DataGridPremiumRaw.propTypes = {
columnGrouping: PropTypes.bool,
lazyLoading: PropTypes.bool,
rowPinning: PropTypes.bool,
warnIfFocusStateIsNotSynced: PropTypes.bool,
}),
/**
* Filtering can be processed on the server or client-side.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ DataGridProRaw.propTypes = {
columnGrouping: PropTypes.bool,
lazyLoading: PropTypes.bool,
rowPinning: PropTypes.bool,
warnIfFocusStateIsNotSynced: PropTypes.bool,
}),
/**
* Filtering can be processed on the server or client-side.
Expand Down
1 change: 0 additions & 1 deletion packages/grid/x-data-grid/src/DataGrid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ DataGridRaw.propTypes = {
*/
experimentalFeatures: PropTypes.shape({
columnGrouping: PropTypes.bool,
warnIfFocusStateIsNotSynced: PropTypes.bool,
}),
/**
* Filtering can be processed on the server or client-side.
Expand Down
5 changes: 3 additions & 2 deletions packages/grid/x-data-grid/src/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
GridEditRowsModel,
GridCellModes,
} from '../models/gridEditRowModel';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass, gridClasses } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { DataGridProcessedProps } from '../models/props/DataGridProps';
Expand All @@ -33,6 +32,7 @@ import { gridRowMaximumTreeDepthSelector } from '../hooks/features/rows/gridRows
import { gridColumnGroupsHeaderMaxDepthSelector } from '../hooks/features/columnGrouping/gridColumnGroupsSelector';
import { randomNumberBetween } from '../utils/utils';
import { GridCellProps } from './cell/GridCell';
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';

export interface GridRowProps {
rowId: GridRowId;
Expand Down Expand Up @@ -122,7 +122,7 @@ const GridRow = React.forwardRef<
onMouseLeave,
...other
} = props;
const apiRef = useGridApiContext();
const apiRef = useGridPrivateApiContext();
const ref = React.useRef<HTMLDivElement>(null);
const rootProps = useGridRootProps();
const currentPage = useGridVisibleRows(apiRef, rootProps);
Expand Down Expand Up @@ -354,6 +354,7 @@ const GridRow = React.forwardRef<
cellMode={cellParams.cellMode}
colIndex={cellProps.indexRelativeToAllColumns}
isEditable={cellParams.isEditable}
isOutlined={apiRef.current.isCellOutlined(rowId, column.field)}
hasFocus={hasFocus}
tabIndex={tabIndex}
className={clsx(classNames)}
Expand Down
Loading

0 comments on commit 4babd8b

Please sign in to comment.