-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
135 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 32 additions & 23 deletions
55
packages/grid/_modules_/grid/components/column-header-separator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
import * as React from 'react'; | ||
import { ColDef } from '../models'; | ||
import { useIcons } from '../hooks/utils/useIcons'; | ||
import { classnames } from '../utils'; | ||
import { OptionsContext } from './options-context'; | ||
|
||
export interface ColumnHeaderSeparatorProps { | ||
resizable: boolean | undefined; | ||
onResize?: () => void; | ||
column: ColDef; | ||
onResizeColumn?: any; | ||
resizable: boolean; | ||
} | ||
|
||
export const ColumnHeaderSeparator: React.FC<ColumnHeaderSeparatorProps> = React.memo( | ||
({ onResize, resizable }) => { | ||
const icons = useIcons(); | ||
const { showColumnRightBorder, headerHeight } = React.useContext(OptionsContext); | ||
export const ColumnHeaderSeparator = React.memo(function ColumnHeaderSeparator( | ||
props: ColumnHeaderSeparatorProps, | ||
) { | ||
const { column, onResizeColumn, resizable } = props; | ||
const icons = useIcons(); | ||
const { showColumnRightBorder, headerHeight } = React.useContext(OptionsContext); | ||
const Icon = icons!.columnResize!; | ||
|
||
const resizeIconProps = { | ||
className: `MuiDataGrid-iconSeparator ${resizable ? 'MuiDataGrid-resizable' : ''}`, | ||
...(resizable && onResize ? { onMouseDown: onResize } : {}), | ||
}; | ||
const handleMouseDown = resizable | ||
? (event) => { | ||
onResizeColumn(event, column); | ||
} | ||
: undefined; | ||
|
||
const icon = React.createElement(icons!.columnResize!, resizeIconProps); | ||
|
||
return ( | ||
<div | ||
className="MuiDataGrid-columnSeparator" | ||
style={{ minHeight: headerHeight, opacity: showColumnRightBorder ? 0 : 1 }} | ||
> | ||
{icon} | ||
</div> | ||
); | ||
}, | ||
); | ||
ColumnHeaderSeparator.displayName = 'ColumnHeaderSeparator'; | ||
return ( | ||
// eslint-disable-next-line jsx-a11y/no-static-element-interactions | ||
<div | ||
className="MuiDataGrid-columnSeparator" | ||
style={{ minHeight: headerHeight, opacity: showColumnRightBorder ? 0 : 1 }} | ||
onMouseDown={handleMouseDown} | ||
> | ||
<Icon | ||
className={classnames('MuiDataGrid-iconSeparator', { | ||
'MuiDataGrid-resizable': resizable, | ||
})} | ||
/> | ||
</div> | ||
); | ||
}); |
30 changes: 13 additions & 17 deletions
30
packages/grid/_modules_/grid/components/column-headers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.