Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Introduce new component #18872

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const productionPlugins = [
];

module.exports = {
presets: defaultPresets.concat(['@babel/preset-react']),
presets: defaultPresets.concat(['@babel/preset-react', '@babel/preset-typescript']),
plugins: [
'babel-plugin-optimize-clsx',
['@babel/plugin-proposal-class-properties', { loose: true }],
Expand Down
14 changes: 6 additions & 8 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ module.exports = withTypescript({

config.externals = [
(context, request, callback) => {
const hasDependencyOnRepoPackages = [
'notistack',
'material-table',
'@material-ui/pickers',
].includes(request);
const hasDependencyOnRepoPackages = ['notistack', '@material-ui/pickers'].includes(
request,
);

if (hasDependencyOnRepoPackages) {
return callback(null);
Expand Down Expand Up @@ -92,8 +90,8 @@ module.exports = withTypescript({
},
// transpile 3rd party packages with dependencies in this repository
{
test: /\.(js|mjs|jsx)$/,
include: /node_modules(\/|\\)(material-table|notistack|@material-ui(\/|\\)pickers)/,
test: /\.(js|mjs|jsx|tsx)$/,
include: /node_modules(\/|\\)(notistack|@material-ui(\/|\\)pickers)/,
use: {
loader: 'babel-loader',
options: {
Expand All @@ -116,7 +114,7 @@ module.exports = withTypescript({
},
// required to transpile ../packages/
{
test: /\.(js|mjs|jsx)$/,
test: /\.(js|mjs|jsx|tsx)$/,
include: [workspaceRoot],
exclude: /node_modules/,
use: options.defaultLoaders.babel,
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"babel-plugin-transform-dev-warning": "^0.1.1",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"chance": "^1.1.4",
"clean-css": "^4.1.11",
"clipboard-copy": "^3.0.0",
"clsx": "^1.0.2",
Expand All @@ -79,7 +80,6 @@
"lz-string": "^1.4.4",
"markdown-to-jsx": "^6.10.2",
"marked": "^0.8.0",
"material-table": "^1.50.0",
"material-ui-popup-state": "^1.4.1",
"next": "8.1.0",
"notistack": "^0.9.3",
Expand Down Expand Up @@ -116,6 +116,7 @@
},
"devDependencies": {
"@babel/preset-typescript": "^7.7.4",
"@types/chance": "^1.0.8",
"babel-plugin-unwrap-createstyles": "^4.1.0",
"cpy-cli": "^3.0.0",
"gm": "^1.23.0"
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/api/backdrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">backgroundColor</span> | <span class="prop-type">'black'<br>&#124;&nbsp;'white'</span> | <span class="prop-default">'black'</span> | The background color. |
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | The content of the component. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">invisible</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the backdrop is invisible. It can be used when rendering a popover or a custom select component. |
Expand All @@ -43,6 +44,8 @@ Any other props supplied will be provided to the root element (native element).
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiBackdrop-root</span> | Styles applied to the root element.
| <span class="prop-name">invisible</span> | <span class="prop-name">.MuiBackdrop-invisible</span> | Styles applied to the root element if `invisible={true}`.
| <span class="prop-name">black</span> | <span class="prop-name">.MuiBackdrop-black</span> | Styles applied to the root element if `backgroundColor="black`.
| <span class="prop-name">white</span> | <span class="prop-name">.MuiBackdrop-white</span> | Styles applied to the root element if `backgroundColor="white`.

You can override the style of the component thanks to one of these customization points:

Expand Down
7 changes: 7 additions & 0 deletions docs/pages/api/data-grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import markdown from './data-grid.md';

export default function Page() {
return <MarkdownDocs markdown={markdown} />;
}
82 changes: 82 additions & 0 deletions docs/pages/api/data-grid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
filename: /packages/material-ui-lab/src/DataGrid/DataGrid.js
---

<!--- This documentation is automatically generated, do not try to edit it. -->

# DataGrid API

<p class="description">The API documentation of the DataGrid React component. Learn more about the props and the CSS customization points.</p>

## Import

```js
import DataGrid from '@material-ui/lab/DataGrid';
// or
import { DataGrid } from '@material-ui/lab';
```

You can learn more about the difference by [reading this guide](/guides/minimizing-bundle-size/).



## Props

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | The content of the component. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">columns</span> | <span class="prop-type">Array&lt;{ children?: Array&lt;object&gt;, field: string, label?: string, resizable?: bool, sortable?: bool, sortingComparator?: func, sortingOrder?: Array&lt;'asc'<br>&#124;&nbsp;'desc'<br>&#124;&nbsp;null&gt; }&gt;</span> | <span class="prop-default">[]</span> | The columns configuration. |
| <span class="prop-name">dataProvider</span> | <span class="prop-type">{ getList: func }</span> | | Manage the communication with the data store. |
| <span class="prop-name">defaultColumnOptions</span> | <span class="prop-type">{ resizable?: bool, sortable?: bool, sortingComparator?: func, sortingOrder?: Array&lt;'asc'<br>&#124;&nbsp;'desc'<br>&#124;&nbsp;null&gt; }</span> | <span class="prop-default">{ resizable: false, sortable: false, sortingOrder: ['asc', 'desc', null],}</span> | The default options that get applied to each column. |
| <span class="prop-name">defaultPage</span> | <span class="prop-type">number</span> | <span class="prop-default">0</span> | The initial page to be displayed. |
| <span class="prop-name">defaultRowsPerPage</span> | <span class="prop-type">number</span> | <span class="prop-default">50</span> | The initial rows per page size. Must be one of the paginationPageSize options. |
| <span class="prop-name">defaultSorting</span> | <span class="prop-type">Array&lt;{ field: string, sort: 'asc'<br>&#124;&nbsp;'desc' }&gt;</span> | <span class="prop-default">[]</span> | The default sorting state. (Uncontrolled) |
| <span class="prop-name">loading</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the loading state is displayed. If `false` the component shows the loading state, while it waits for new data being loaded. |
| <span class="prop-name">onSortingChange</span> | <span class="prop-type">func</span> | | Callback fired when the user change the column sort.<br><br>**Signature:**<br>`function(event: object, value: SortingType) => void`<br>*event:* The event source of the callback.<br>*value:* The new sorting value. |
| <span class="prop-name">pagination</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the pagination is enabled. |
| <span class="prop-name">paginationRowsPerPageOptions</span> | <span class="prop-type">Array&lt;number<br>&#124;&nbsp;{ label: string, value: number }&gt;</span> | <span class="prop-default">[10, 25, 50, 100, 250, 500]</span> | The possible pagination size options to be selected by the user. |
| <span class="prop-name">rowsData</span> | <span class="prop-type">array</span> | <span class="prop-default">[]</span> | The data record array to be rendered. |
| <span class="prop-name">sorting</span> | <span class="prop-type">Array&lt;{ field: string, sort: 'asc'<br>&#124;&nbsp;'desc' }&gt;</span> | | Sorting state. (Controlled) |
| <span class="prop-name">text</span> | <span class="prop-type">any</span> | <span class="prop-default">{ loading: 'Loading', reload: 'Reload',}</span> | The localization strings. |

The `ref` is forwarded to the root element.

Any other props supplied will be provided to the root element (native element).

## CSS

- Style sheet name: `MuiDataGrid`.
- Style sheet details:

| Rule name | Global class | Description |
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiDataGrid-root</span> | Styles applied to the root element.
| <span class="prop-name">bodyContainer</span> | <span class="prop-name">.MuiDataGrid-bodyContainer</span> |
| <span class="prop-name">headerLabel</span> | <span class="prop-name">.MuiDataGrid-headerLabel</span> |
| <span class="prop-name">resize</span> | <span class="prop-name">.MuiDataGrid-resize</span> |

You can override the style of the component thanks to one of these customization points:

- With a rule name of the [`classes` object prop](/customization/components/#overriding-styles-with-classes).
- With a [global class name](/customization/components/#overriding-styles-with-global-class-names).
- With a theme and an [`overrides` property](/customization/globals/#css).

If that's not sufficient, you can check the [implementation of the component](https://github.com/mui-org/material-ui/blob/master/packages/material-ui-lab/src/DataGrid/DataGrid.js) for more detail.

## Demos

- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)
- [Data Grid](/components/data-grid/)

14 changes: 14 additions & 0 deletions docs/pages/components/data-grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../src/pages/components/data-grid',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/accessibility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/accessibility',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/accessibility',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/accessibility';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/columns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/columns', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/columns',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/columns';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/customization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/customization',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/customization',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/customization';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/data', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/data',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/data';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/editing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/editing', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/editing',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/editing';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/export', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/export',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/export';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/filtering.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/filtering',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/filtering',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/filtering';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/group-pivot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/group-pivot',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/group-pivot',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/group-pivot';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/localization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/localization',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/localization',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/localization';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/paging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/paging', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/paging',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/paging';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/data-grid/rows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/data-grid/rows', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/rows',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/rows';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
18 changes: 18 additions & 0 deletions docs/pages/components/data-grid/selection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context(
'docs/src/pages/components/data-grid/selection',
false,
/\.(md|js|tsx)$/,
);
const reqSource = require.context(
'!raw-loader!../../../src/pages/components/data-grid/selection',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/data-grid/selection';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
Loading