Skip to content

Commit

Permalink
[DataGrid] Replace require with import (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Oct 27, 2020
1 parent 236d458 commit e39acaf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/grid/data-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"build": "cd ../ && rollup --config rollup.data-grid.config.js"
},
"dependencies": {
"@material-ui/utils": "^5.0.0-alpha.14",
"prop-types": "^15.7.2",
"tslib": "^2.0.0"
},
Expand Down
31 changes: 15 additions & 16 deletions packages/grid/data-grid/src/DataGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import PropTypes from 'prop-types';
import { chainPropTypes } from '@material-ui/utils';
import { GridComponent, GridComponentProps, classnames } from '../../_modules_/grid';

// TODO: Refactor to import when moving to material-ui v5
const chainPropTypes = require('@material-ui/utils').chainPropTypes;

const FORCED_PROPS: Partial<GridComponentProps> = {
disableColumnResize: true,
disableColumnReorder: true,
Expand Down Expand Up @@ -55,8 +53,8 @@ const DataGrid2 = React.forwardRef<HTMLDivElement, DataGridProps>(function DataG
);
});

DataGrid2.propTypes = {
apiRef: chainPropTypes(PropTypes.any, (props) => {
(DataGrid2 as any).propTypes = {
apiRef: chainPropTypes(PropTypes.any, (props: any) => {
if (props.apiRef != null) {
throw new Error(
[
Expand All @@ -67,8 +65,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}
return null;
}),
columns: chainPropTypes(PropTypes.any, (props) => {
columns: chainPropTypes(PropTypes.any, (props: any) => {
if (props.columns && props.columns.some((column) => column.resizable)) {
throw new Error(
[
Expand All @@ -79,8 +78,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}
return null;
}),
disableColumnReorder: chainPropTypes(PropTypes.bool, (props) => {
disableColumnReorder: chainPropTypes(PropTypes.bool, (props: any) => {
if (props.disableColumnReorder === false) {
throw new Error(
[
Expand All @@ -91,8 +91,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}
return null;
}),
disableColumnResize: chainPropTypes(PropTypes.bool, (props) => {
disableColumnResize: chainPropTypes(PropTypes.bool, (props: any) => {
if (props.disableColumnResize === false) {
throw new Error(
[
Expand All @@ -103,8 +104,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}
return null;
}),
disableMultipleColumnsSorting: chainPropTypes(PropTypes.bool, (props) => {
disableMultipleColumnsSorting: chainPropTypes(PropTypes.bool, (props: any) => {
if (props.disableMultipleColumnsSorting === false) {
throw new Error(
[
Expand All @@ -115,10 +117,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}

return null;
}),
disableMultipleSelection: chainPropTypes(PropTypes.bool, (props) => {
disableMultipleSelection: chainPropTypes(PropTypes.bool, (props: any) => {
if (props.disableMultipleSelection === false) {
throw new Error(
[
Expand All @@ -129,10 +130,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}

return null;
}),
pageSize: chainPropTypes(PropTypes.number, (props) => {
pageSize: chainPropTypes(PropTypes.number, (props: any) => {
if (props.pageSize && props.pageSize > MAX_PAGE_SIZE) {
throw new Error(
[
Expand All @@ -143,10 +143,9 @@ DataGrid2.propTypes = {
].join('\n'),
);
}

return null;
}),
pagination: (props) => {
pagination: (props: any) => {
if (props.pagination === false) {
return new Error(
[
Expand Down
1 change: 1 addition & 0 deletions packages/grid/x-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"build": "cd ../ && rollup --config rollup.x-grid.config.js"
},
"dependencies": {
"@material-ui/utils": "^5.0.0-alpha.14",
"@material-ui/x-license": "^4.0.0-alpha.8",
"prop-types": "^15.7.2",
"tslib": "^2.0.0"
Expand Down
4 changes: 1 addition & 3 deletions packages/grid/x-grid/src/XGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as React from 'react';
import { LicenseInfo, useLicenseVerifier } from '@material-ui/x-license';
import { ponyfillGlobal } from '@material-ui/utils';
import { GridComponent, GridComponentProps, classnames } from '../../_modules_/grid';

// This is the package release date. Each package version should update this const
// automatically when a new version is published on npm.
let RELEASE_INFO = '__RELEASE_INFO__';

// TODO: Refactor to import when moving to material-ui v5
const ponyfillGlobal = require('@material-ui/utils').ponyfillGlobal;

// eslint-disable-next-line no-useless-concat
if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
// eslint-disable-next-line no-underscore-dangle
Expand Down
20 changes: 19 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2840,6 +2840,17 @@
prop-types "^15.7.2"
react-is "^16.8.0"

"@material-ui/utils@^5.0.0-alpha.14":
version "5.0.0-alpha.14"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-5.0.0-alpha.14.tgz#1f4458b511d64c3bf1260b25cca6dde565986bde"
integrity sha512-NIZNxDFUiTmr9cTA/iKYhqLBonlc3vgKfs+753NPjRoDhOj4aGr04yLvWegi4LbaIdu1veJTwGxXehypu1ud6Q==
dependencies:
"@babel/runtime" "^7.4.4"
"@types/prop-types" "^15.7.3"
"@types/react-is" "^16.7.1"
prop-types "^15.7.2"
react-is "^16.8.0"

"@mdx-js/loader@^1.5.1":
version "1.6.6"
resolved "https://registry.yarnpkg.com/@mdx-js/loader/-/loader-1.6.6.tgz#de7438f3b18b097d66380f8698123a91c587a2f9"
Expand Down Expand Up @@ -5181,7 +5192,7 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.1.tgz#b6e98083f13faa1e5231bfa3bdb1b0feff536b6d"
integrity sha512-boy4xPNEtiw6N3abRhBi/e7hNvy3Tt8E9ZRAQrwAGzoCGZS/1wjo9KY7JHhnfnEsG5wSjDbymCozUM9a3ea7OQ==

"@types/prop-types@*":
"@types/prop-types@*", "@types/prop-types@^15.7.3":
version "15.7.3"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
Expand Down Expand Up @@ -5226,6 +5237,13 @@
dependencies:
"@types/react" "*"

"@types/react-is@^16.7.1":
version "16.7.1"
resolved "https://registry.yarnpkg.com/@types/react-is/-/react-is-16.7.1.tgz#d3f1c68c358c00ce116b55ef5410cf486dd08539"
integrity sha512-dMLFD2cCsxtDgMkTydQCM0PxDq8vwc6uN5M/jRktDfYvH3nQj6pjC9OrCXS2lKlYoYTNJorI/dI8x9dpLshexQ==
dependencies:
"@types/react" "*"

"@types/react-native@*":
version "0.62.17"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.17.tgz#78e630692557ae82a106dab7682560a8b541c49a"
Expand Down

0 comments on commit e39acaf

Please sign in to comment.