Skip to content

Commit

Permalink
[docs] Fix DataTable.tsx demo in v4 (#27196)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siv-tspab authored Jul 24, 2021
1 parent 4fe0df5 commit 3320af6
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defaults: &defaults
REACT_DIST_TAG: << parameters.react-dist-tag >>
working_directory: /tmp/material-ui
docker:
- image: circleci/node:10
- image: circleci/node:12
# CircleCI has disabled the cache across forks for security reasons.
# Following their official statement, it was a quick solution, they
# are working on providing this feature back with appropriate security measures.
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
test_regressions:
<<: *defaults
docker:
- image: circleci/node:10
- image: circleci/node:12
- image: selenium/standalone-chrome:3.11.0
steps:
- checkout
Expand Down
1 change: 1 addition & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"buildCommand": "build:codesandbox",
"installCommand": "install:codesandbox",
"packages": [
"packages/material-ui",
"packages/material-ui-icons",
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ variables:
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
versionSpec: '12.x'
displayName: 'Install Node.js'

- script: |
Expand Down
1 change: 1 addition & 0 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = {
alias: {
'@material-ui/core': '../packages/material-ui/src',
'@material-ui/utils': '../packages/material-ui-utils/src',
'@material-ui/styles': '../packages/material-ui-styles/src',
},
transformFunctions: ['require'],
},
Expand Down
31 changes: 25 additions & 6 deletions docs/src/pages/components/tables/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ import * as React from 'react';
import { DataGrid } from '@material-ui/data-grid';

const columns = [
{ field: 'id', headerName: 'ID', width: 70 },
{ field: 'firstName', headerName: 'First name', width: 130 },
{ field: 'lastName', headerName: 'Last name', width: 130 },
{ field: 'id', headerName: 'ID', width: 90 },
{
field: 'firstName',
headerName: 'First name',
width: 150,
editable: true,
},
{
field: 'lastName',
headerName: 'Last name',
width: 150,
editable: true,
},
{
field: 'age',
headerName: 'Age',
type: 'number',
width: 90,
width: 110,
editable: true,
},
{
field: 'fullName',
Expand All @@ -18,7 +29,9 @@ const columns = [
sortable: false,
width: 160,
valueGetter: (params) =>
`${params.getValue('firstName') || ''} ${params.getValue('lastName') || ''}`,
`${params.getValue(params.id, 'firstName') || ''} ${
params.getValue(params.id, 'lastName') || ''
}`,
},
];

Expand All @@ -37,7 +50,13 @@ const rows = [
export default function DataTable() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />
<DataGrid
rows={rows}
columns={columns}
pageSize={5}
checkboxSelection
disableSelectionOnClick
/>
</div>
);
}
37 changes: 28 additions & 9 deletions docs/src/pages/components/tables/DataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import * as React from 'react';
import { DataGrid, ColDef, ValueGetterParams } from '@material-ui/data-grid';
import { DataGrid, GridColDef, GridValueGetterParams } from '@material-ui/data-grid';

const columns: ColDef[] = [
{ field: 'id', headerName: 'ID', width: 70 },
{ field: 'firstName', headerName: 'First name', width: 130 },
{ field: 'lastName', headerName: 'Last name', width: 130 },
const columns: GridColDef[] = [
{ field: 'id', headerName: 'ID', width: 90 },
{
field: 'firstName',
headerName: 'First name',
width: 150,
editable: true,
},
{
field: 'lastName',
headerName: 'Last name',
width: 150,
editable: true,
},
{
field: 'age',
headerName: 'Age',
type: 'number',
width: 90,
width: 110,
editable: true,
},
{
field: 'fullName',
headerName: 'Full name',
description: 'This column has a value getter and is not sortable.',
sortable: false,
width: 160,
valueGetter: (params: ValueGetterParams) =>
`${params.getValue('firstName') || ''} ${params.getValue('lastName') || ''}`,
valueGetter: (params: GridValueGetterParams) =>
`${params.getValue(params.id, 'firstName') || ''} ${
params.getValue(params.id, 'lastName') || ''
}`,
},
];

Expand All @@ -37,7 +50,13 @@ const rows = [
export default function DataTable() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />
<DataGrid
rows={rows}
columns={columns}
pageSize={5}
checkboxSelection
disableSelectionOnClick
/>
</div>
);
}
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

[build.environment]
YARN_VERSION = "1.21.1"
NODE_VERSION = "10"
NODE_VERSION = "12"
NODE_OPTIONS = "--max_old_space_size=4096"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"proptypes": "ts-node --skip-project ./scripts/generateProptypes.ts",
"deduplicate": "node scripts/deduplicate.js",
"argos": "argos upload test/regressions/screenshots/chrome --token $ARGOS_TOKEN",
"install:codesandbox": "yarn install --ignore-engines",
"build:codesandbox": "lerna run --parallel --scope \"@material-ui/*\" build",
"docs:api": "rimraf ./docs/pages/api-docs && cross-env BABEL_ENV=test __NEXT_EXPORT_TRAILING_SLASH=true babel-node ./docs/scripts/buildApi.js ./packages/material-ui/src ./docs/pages/api-docs && cross-env BABEL_ENV=test __NEXT_EXPORT_TRAILING_SLASH=true babel-node ./docs/scripts/buildApi.js ./packages/material-ui-lab/src ./docs/pages/api-docs",
"docs:build": "yarn workspace docs build",
Expand Down
43 changes: 29 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2075,12 +2075,14 @@
write-file-atomic "^2.3.0"

"@material-ui/data-grid@^4.0.0-alpha.6":
version "4.0.0-alpha.6"
resolved "https://registry.yarnpkg.com/@material-ui/data-grid/-/data-grid-4.0.0-alpha.6.tgz#78e14791777e1aa12b9b4b84d82d8e5ff437beb3"
integrity sha512-XFUdIK+It5PY3ivO4u0hDUxQNC4ASTuQHZlVe9K3RFEjZRNt70W29WoL36IvJ1o/bN208uUuQvzY9tn3J0P8lQ==
version "4.0.0-alpha.34"
resolved "https://registry.yarnpkg.com/@material-ui/data-grid/-/data-grid-4.0.0-alpha.34.tgz#b757b240bfb12c4a375af74c9f09c43762430106"
integrity sha512-hXHjyLRKbOk+rObEnQbTzZ8Xgtfn/Li40NVmzkall+eIPktqqJ3GJDzOv0EVD+GGjXDixf+XT9BppjXk87EwiQ==
dependencies:
"@material-ui/utils" "^5.0.0-alpha.14"
clsx "^1.0.4"
prop-types "^15.7.2"
tslib "^2.0.0"
reselect "^4.0.0"

"@material-ui/pickers@^3.2.5":
version "3.2.10"
Expand All @@ -2101,6 +2103,17 @@
dependencies:
"@types/react" "*"

"@material-ui/utils@^5.0.0-alpha.14":
version "5.0.0-beta.0"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-5.0.0-beta.0.tgz#2b2083b356a98618de73c9bd29f271f9143a07a2"
integrity sha512-eBBqd+53NBUCgTU6TFGlhN0GsAPmnrHwdVBW6y4t/jP6sEXgDjVaJm5FKSYKkkCl+iRfZEAfdYyCeAn04eummw==
dependencies:
"@babel/runtime" "^7.4.4"
"@types/prop-types" "^15.7.3"
"@types/react-is" "^16.7.1 || ^17.0.0"
prop-types "^15.7.2"
react-is "^17.0.0"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
Expand Down Expand Up @@ -2643,10 +2656,10 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.1.tgz#b6e98083f13faa1e5231bfa3bdb1b0feff536b6d"
integrity sha512-boy4xPNEtiw6N3abRhBi/e7hNvy3Tt8E9ZRAQrwAGzoCGZS/1wjo9KY7JHhnfnEsG5wSjDbymCozUM9a3ea7OQ==

"@types/prop-types@*":
version "15.7.1"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
integrity sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==
"@types/prop-types@*", "@types/prop-types@^15.7.3":
version "15.7.4"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
integrity sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==

"@types/q@^1.5.1":
version "1.5.2"
Expand All @@ -2660,6 +2673,13 @@
dependencies:
"@types/react" "*"

"@types/react-is@^16.7.1 || ^17.0.0":
version "17.0.1"
resolved "https://registry.yarnpkg.com/@types/react-is/-/react-is-17.0.1.tgz#8298442d3860a716e3e8435c1e6e36c189639bdb"
integrity sha512-X6jVqDIibL2sY0Qtth5EzNeUgPyoCWeBZdmE5xKr7hI4zaQDwN0VaQd7pJnlOB0mDGnOVH0cZZVXg9cnWhztQg==
dependencies:
"@types/react" "*"

"@types/react-native@*":
version "0.57.51"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.57.51.tgz#adcb02141734b72822848351be734971e508f5f1"
Expand Down Expand Up @@ -13800,7 +13820,7 @@ react-final-form@^6.3.0:
"@scarf/scarf" "^1.0.5"
ts-essentials "^6.0.5"

[email protected], react-is@^16.12.0, react-is@^16.13.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, "react-is@^16.8.0 || ^17.0.0", react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0:
[email protected], react-is@^16.12.0, react-is@^16.13.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, "react-is@^16.8.0 || ^17.0.0", react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0, react-is@^17.0.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
Expand Down Expand Up @@ -16397,11 +16417,6 @@ tslib@^1.13.0, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==

tslib@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==

[email protected]:
version "5.14.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.14.0.tgz#be62637135ac244fc9b37ed6ea5252c9eba1616e"
Expand Down

0 comments on commit 3320af6

Please sign in to comment.