-
{name}
-
+
+ {name}
);
}
diff --git a/packages/react-data-grid-addons/style/rdg-contextmenu.less b/packages/react-data-grid-addons/style/rdg-contextmenu.less
new file mode 100644
index 0000000000..2a55f1cb72
--- /dev/null
+++ b/packages/react-data-grid-addons/style/rdg-contextmenu.less
@@ -0,0 +1,39 @@
+.react-contextmenu {
+ cursor: pointer;
+ background-color: #fff;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ box-shadow: 0 6px 10px rgba(0, 0, 0, 0.24);
+
+ font-size: 14px;
+ line-height: 2;
+ white-space: nowrap;
+
+ > .react-contextmenu-item:not(:last-child) {
+ border-bottom: 1px solid #ddd;
+ }
+
+ .react-contextmenu-submenu > & {
+ margin-top: -1px;
+ }
+}
+
+.react-contextmenu-item:not(.react-contextmenu-submenu) {
+ padding: 0 12px;
+}
+
+.react-contextmenu-item--selected {
+ background-color: darken(#fff, 4%);
+}
+
+.react-contextmenu-submenu > .react-contextmenu-item {
+ &::after {
+ content: "▶";
+ margin-left: 12px;
+ margin-right: -6px;
+ }
+
+ &:not(.react-contextmenu-item--active) + .react-contextmenu {
+ display: none;
+ }
+}
diff --git a/packages/react-data-grid-addons/style/rdg-image.less b/packages/react-data-grid-addons/style/rdg-image.less
index 2449ae3f16..df9ae6f1a1 100644
--- a/packages/react-data-grid-addons/style/rdg-image.less
+++ b/packages/react-data-grid-addons/style/rdg-image.less
@@ -4,4 +4,5 @@
display: inline-block;
height: 40px;
width: 40px;
-}
\ No newline at end of file
+ vertical-align: middle;
+}
diff --git a/packages/react-data-grid-addons/style/rdg-toolbar.less b/packages/react-data-grid-addons/style/rdg-toolbar.less
index e5adc1e2d3..1de5d8fc88 100644
--- a/packages/react-data-grid-addons/style/rdg-toolbar.less
+++ b/packages/react-data-grid-addons/style/rdg-toolbar.less
@@ -15,7 +15,7 @@
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
- line-height: 1.42857143;
+ line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: middle;
@@ -43,9 +43,12 @@
.react-grid-Toolbar .grouped-col-btn + .grouped-col-btn {
margin-left: 5px;
}
-.react-grid-Toolbar .grouped-col-btn__remove {
- margin-left: 5px;
+
+.grouped-col-btn > .MuiSvgIcon-root {
+ font-size: 18px;
+ vertical-align: middle;
}
+
.react-grid-Toolbar .tools {
float: right;
position: relative;
diff --git a/packages/react-data-grid-addons/style/react-data-grid-addons.less b/packages/react-data-grid-addons/style/react-data-grid-addons.less
index ae82e5a876..8ff5c3176c 100644
--- a/packages/react-data-grid-addons/style/react-data-grid-addons.less
+++ b/packages/react-data-grid-addons/style/react-data-grid-addons.less
@@ -1,3 +1,19 @@
+@import 'rdg-contextmenu.less';
@import 'rdg-drop-target.less';
@import 'rdg-image.less';
@import 'rdg-toolbar.less';
+
+.rdg-dragging {
+ cursor: grabbing;
+}
+
+.rdg-draggable-header-cell {
+ cursor: move;
+ display: inline-block;
+ height: inherit;
+ background-color: inherit;
+}
+
+.rdg-can-drop {
+ background-color: #ececec;
+}
diff --git a/packages/react-data-grid/package.json b/packages/react-data-grid/package.json
index 8786e72b74..7bcaddbfc7 100644
--- a/packages/react-data-grid/package.json
+++ b/packages/react-data-grid/package.json
@@ -27,8 +27,10 @@
"build": "tsc"
},
"dependencies": {
+ "@material-ui/core": "^4.5.1",
+ "@material-ui/icons": "^4.5.1",
"classnames": "^2.2.6",
- "react-is": "^16.8.4",
+ "react-is": "^16.10.2",
"shallowequal": "^1.1.0",
"tslib": "^1.10.0"
},
diff --git a/packages/react-data-grid/src/Canvas.tsx b/packages/react-data-grid/src/Canvas.tsx
index 3e2f46fa0c..c412df58ad 100644
--- a/packages/react-data-grid/src/Canvas.tsx
+++ b/packages/react-data-grid/src/Canvas.tsx
@@ -1,4 +1,4 @@
-import React, { Fragment, useState, useRef, useEffect, useMemo } from 'react';
+import React, { useState, useRef, useEffect, useMemo } from 'react';
import { isElement } from 'react-is';
import Row from './Row';
@@ -80,7 +80,7 @@ export default function Canvas
({
rowHeight,
rowKey,
rowRenderer,
- RowsContainer = Fragment,
+ RowsContainer,
rowsCount,
scrollToRowIndex,
selectedRows
@@ -275,12 +275,26 @@ export default function Canvas({
);
}
- const paddingTop = rowOverscanStartIdx * rowHeight;
- const paddingBottom = (rowsCount - 1 - rowOverscanEndIdx) * rowHeight;
+ let grid = (
+
+ {getRows()}
+
+ );
+
+ if (RowsContainer !== undefined) {
+ grid = ;
+ }
return (
({
editorPortalTarget={editorPortalTarget}
{...interactionMasksMetaData}
/>
-
+ {grid}
);
}
diff --git a/packages/react-data-grid/src/Cell.tsx b/packages/react-data-grid/src/Cell.tsx
index c8856a5a86..49035127a8 100644
--- a/packages/react-data-grid/src/Cell.tsx
+++ b/packages/react-data-grid/src/Cell.tsx
@@ -79,24 +79,27 @@ export default class Cell extends React.Component> implements Ce
};
getStyle(): React.CSSProperties {
- const { column, height, scrollLeft } = this.props;
+ const { column } = this.props;
- return {
- height,
+ const style: React.CSSProperties = {
width: column.width,
- left: column.left,
- transform: !isPositionStickySupported() && isFrozen(column) ? `translateX(${scrollLeft}px)` : 'none'
+ left: column.left
};
+
+ if (!isPositionStickySupported() && isFrozen(column)) {
+ style.transform = `translateX(${this.props.scrollLeft}px)`;
+ }
+
+ return style;
}
getCellClass() {
- const { idx, column, lastFrozenColumnIndex, tooltip, expandableOptions } = this.props;
+ const { column, tooltip, expandableOptions } = this.props;
return classNames(
column.cellClass,
- 'react-grid-Cell',
+ 'rdg-cell',
this.props.className, {
- 'react-grid-Cell--frozen': isFrozen(column),
- 'rdg-last--frozen': lastFrozenColumnIndex === idx,
+ 'rdg-cell-frozen': isFrozen(column),
'has-tooltip': !!tooltip,
'rdg-child-cell': expandableOptions && expandableOptions.subRowDetails && expandableOptions.treeDepth > 0
}
diff --git a/packages/react-data-grid/src/Cell/CellContent.tsx b/packages/react-data-grid/src/Cell/CellContent.tsx
index dc9813fa06..ac8a74b705 100644
--- a/packages/react-data-grid/src/Cell/CellContent.tsx
+++ b/packages/react-data-grid/src/Cell/CellContent.tsx
@@ -38,7 +38,7 @@ export default function CellContent({
}: CellContentProps) {
const isExpandCell = expandableOptions ? expandableOptions.field === column.key : false;
const treeDepth = expandableOptions ? expandableOptions.treeDepth : 0;
- const marginLeft = expandableOptions && isExpandCell ? expandableOptions.treeDepth * 30 : 0;
+ const style = expandableOptions && isExpandCell ? { marginLeft: expandableOptions.treeDepth * 30 } : undefined;
function handleDeleteSubRow() {
if (onDeleteSubRow) {
@@ -60,27 +60,25 @@ export default function CellContent({
/>
);
- const classes = classNames('react-grid-Cell__value',
- { 'cell-tooltip': !!tooltip }
+ const classes = classNames('rdg-cell-value',
+ { 'rdg-cell-tooltip': !!tooltip }
);
return (
{cellDeleter}
-
-
-
- rowIdx={rowIdx}
- rowData={rowData}
- column={column}
- value={value}
- isRowSelected={isRowSelected}
- onRowSelectionChange={onRowSelectionChange}
- />
-
+
+
+ rowIdx={rowIdx}
+ rowData={rowData}
+ column={column}
+ value={value}
+ isRowSelected={isRowSelected}
+ onRowSelectionChange={onRowSelectionChange}
+ />
{cellControls}
- {tooltip &&
{tooltip}}
+ {tooltip &&
{tooltip}}
);
}
diff --git a/packages/react-data-grid/src/ChildRowDeleteButton.tsx b/packages/react-data-grid/src/ChildRowDeleteButton.tsx
index 00e99baf57..b364dafbb0 100644
--- a/packages/react-data-grid/src/ChildRowDeleteButton.tsx
+++ b/packages/react-data-grid/src/ChildRowDeleteButton.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import { RemoveCircle } from '@material-ui/icons';
export interface ChildRowDeleteButtonProps {
treeDepth: number;
@@ -15,7 +16,7 @@ export default function ChildRowDeleteButton({ treeDepth, cellHeight, onDeleteSu
{isDeleteSubRowEnabled && (
)}
>
diff --git a/packages/react-data-grid/src/Header.tsx b/packages/react-data-grid/src/Header.tsx
index 3a3c020316..4fff9a474d 100644
--- a/packages/react-data-grid/src/Header.tsx
+++ b/packages/react-data-grid/src/Header.tsx
@@ -1,9 +1,8 @@
import React, { forwardRef, useRef, useState, useMemo, useImperativeHandle } from 'react';
-import classNames from 'classnames';
import HeaderRow from './HeaderRow';
import { getColumnMetrics } from './utils/columnUtils';
-import { getScrollbarSize } from './utils';
+import { getScrollbarSize, isPositionStickySupported } from './utils';
import { CalculatedColumn, HeaderRowData, ColumnMetrics, CellMetaData } from './common/types';
import { DEFINE_SORT } from './common/enums';
import { ReactDataGridProps } from './ReactDataGrid';
@@ -26,7 +25,6 @@ export interface HeaderProps
extends SharedDataGridProps {
columnMetrics: ColumnMetrics;
headerRows: [HeaderRowData, HeaderRowData | undefined];
cellMetaData: CellMetaData;
- rowOffsetHeight: number;
onSort?(columnKey: keyof R, direction: DEFINE_SORT): void;
onColumnResize(idx: number, width: number): void;
}
@@ -36,6 +34,7 @@ export interface HeaderHandle {
}
export default forwardRef(function Header(props: HeaderProps, ref: React.Ref) {
+ const headerRef = useRef(null);
const rowRef = useRef>(null);
const filterRowRef = useRef>(null);
@@ -55,6 +54,8 @@ export default forwardRef(function Header(props: HeaderProps, ref: React.R
useImperativeHandle(ref, () => ({
setScrollLeft(scrollLeft: number): void {
+ headerRef.current!.scrollLeft = scrollLeft;
+ if (isPositionStickySupported()) return;
rowRef.current!.setScrollLeft(scrollLeft);
if (filterRowRef.current) {
filterRowRef.current.setScrollLeft(scrollLeft);
@@ -85,7 +86,7 @@ export default forwardRef(function Header(props: HeaderProps, ref: React.R
props.onSelectedRowsChange(newSelectedRows);
}
- function getHeaderRow(row: HeaderRowData, ref: React.RefObject>) {
+ function getHeaderRow(row: HeaderRowData, ref?: React.RefObject>) {
return (
key={row.rowType}
@@ -93,6 +94,7 @@ export default forwardRef(function Header(props: HeaderProps, ref: React.R
rowType={row.rowType}
onColumnResize={onColumnResize}
onColumnResizeEnd={onColumnResizeEnd}
+ width={columnMetrics.totalColumnWidth + getScrollbarSize()}
height={row.height}
columns={columnMetrics.columns}
draggableHeaderCell={props.draggableHeaderCell}
@@ -110,10 +112,11 @@ export default forwardRef(function Header(props: HeaderProps, ref: React.R
}
function getHeaderRows() {
+ const setRef = !isPositionStickySupported();
const { headerRows } = props;
- const rows = [getHeaderRow(headerRows[0], rowRef)];
+ const rows = [getHeaderRow(headerRows[0], setRef ? rowRef : undefined)];
if (headerRows[1]) {
- rows.push(getHeaderRow(headerRows[1], filterRowRef));
+ rows.push(getHeaderRow(headerRows[1], setRef ? filterRowRef : undefined));
}
return rows;
@@ -124,17 +127,10 @@ export default forwardRef(function Header(props: HeaderProps, ref: React.R
props.cellMetaData.onCellClick({ rowIdx: -1, idx: -1 });
}
- const className = classNames('react-grid-Header', {
- 'react-grid-Header--resizing': resizing !== null
- });
-
return (
{getHeaderRows()}
diff --git a/packages/react-data-grid/src/HeaderCell.tsx b/packages/react-data-grid/src/HeaderCell.tsx
index 8553c4474e..7650e6ac9c 100644
--- a/packages/react-data-grid/src/HeaderCell.tsx
+++ b/packages/react-data-grid/src/HeaderCell.tsx
@@ -7,7 +7,7 @@ import { CalculatedColumn, HeaderRowProps } from './common/types';
function SimpleCellRenderer
({ column, rowType }: HeaderRowProps) {
const headerText = rowType === HeaderRowType.HEADER ? column.name : '';
- return {headerText}
;
+ return <>{headerText}>;
}
interface Props {
@@ -132,24 +132,21 @@ export default class HeaderCell extends React.Component> {
}
render() {
- const { column, rowType, height } = this.props;
+ const { column, rowType } = this.props;
- const className = classNames('react-grid-HeaderCell', {
+ const className = classNames('rdg-cell', {
'rdg-header-cell-resizable': column.resizable,
- 'react-grid-HeaderCell--frozen': isFrozen(column)
+ 'rdg-cell-frozen': isFrozen(column)
}, this.props.className, column.cellClass);
- const style: React.CSSProperties = {
- width: column.width,
- left: column.left,
- height
- };
-
const cell = (
diff --git a/packages/react-data-grid/src/HeaderRow.tsx b/packages/react-data-grid/src/HeaderRow.tsx
index d04e028548..0dfad7a8ff 100644
--- a/packages/react-data-grid/src/HeaderRow.tsx
+++ b/packages/react-data-grid/src/HeaderRow.tsx
@@ -4,6 +4,7 @@ import HeaderCell from './HeaderCell';
import SortableHeaderCell from './common/cells/headerCells/SortableHeaderCell';
import FilterableHeaderCell from './common/cells/headerCells/FilterableHeaderCell';
import { isFrozen } from './utils/columnUtils';
+import { isPositionStickySupported } from './utils';
import { HeaderRowType, HeaderCellType, DEFINE_SORT } from './common/enums';
import { CalculatedColumn, AddFilterEvent } from './common/types';
import { HeaderProps } from './Header';
@@ -19,6 +20,7 @@ type SharedHeaderProps
= Pick,
>;
export interface HeaderRowProps extends SharedHeaderProps {
+ width: number;
height: number;
columns: CalculatedColumn[];
onColumnResize(column: CalculatedColumn, width: number): void;
@@ -32,7 +34,6 @@ export interface HeaderRowProps extends SharedHeaderProps {
export default class HeaderRow extends React.Component> {
static displayName = 'HeaderRow';
- private readonly headerRow = React.createRef();
private readonly cells = new Map>();
getHeaderCellType(column: CalculatedColumn): HeaderCellType {
@@ -93,6 +94,7 @@ export default class HeaderRow extends React.Component> {
const cells = [];
const frozenCells = [];
const { columns, rowType } = this.props;
+ const setRef = !isPositionStickySupported();
for (const column of columns) {
const { key } = column;
@@ -101,7 +103,9 @@ export default class HeaderRow extends React.Component> {
const cell = (
key={key as string}
- ref={node => node ? this.cells.set(key, node) : this.cells.delete(key)}
+ ref={setRef
+ ? node => node ? this.cells.set(key, node) : this.cells.delete(key)
+ : undefined}
column={column}
rowType={rowType}
height={this.props.height}
@@ -126,7 +130,6 @@ export default class HeaderRow extends React.Component> {
}
setScrollLeft(scrollLeft: number): void {
- this.headerRow.current!.scrollLeft = scrollLeft;
this.props.columns.forEach(column => {
const { key } = column;
if (!this.cells.has(key)) return;
@@ -140,15 +143,10 @@ export default class HeaderRow extends React.Component> {
}
render() {
- const { height, rowType } = this.props;
-
return (
{this.getCells()}
diff --git a/packages/react-data-grid/src/ReactDataGrid.tsx b/packages/react-data-grid/src/ReactDataGrid.tsx
index a180ba508d..3fa291303e 100644
--- a/packages/react-data-grid/src/ReactDataGrid.tsx
+++ b/packages/react-data-grid/src/ReactDataGrid.tsx
@@ -398,12 +398,11 @@ const ReactDataGridBase = forwardRef(function ReactDataGrid({
const headerRows = getHeaderRows();
const rowOffsetHeight = headerRows[0].height + (headerRows[1] ? headerRows[1].height : 0);
- const style = width ? { width } : undefined;
return (
{columnMetrics && (
@@ -416,7 +415,6 @@ const ReactDataGridBase = forwardRef(function ReactDataGrid
({
columnMetrics={columnMetrics}
onColumnResize={handleColumnResize}
headerRows={headerRows}
- rowOffsetHeight={rowOffsetHeight}
sortColumn={props.sortColumn}
sortDirection={props.sortDirection}
draggableHeaderCell={props.draggableHeaderCell}
@@ -427,11 +425,7 @@ const ReactDataGridBase = forwardRef(function ReactDataGrid({
getValidFilterValues={props.getValidFilterValues}
cellMetaData={cellMetaData}
/>
- {rowsCount === 0 && isValidElementType(props.emptyRowsView) ? (
-
- {createElement(props.emptyRowsView)}
-
- ) : (
+ {rowsCount === 0 && isValidElementType(props.emptyRowsView) ? createElement(props.emptyRowsView) : (