Skip to content

Commit

Permalink
[core] Create a new package to share utils across X packages (#13528)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle authored Jul 1, 2024
1 parent 5ba5e26 commit b7897ea
Show file tree
Hide file tree
Showing 29 changed files with 158 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"packages/x-date-pickers",
"packages/x-date-pickers-pro",
"packages/x-charts",
"packages/x-tree-view"
"packages/x-tree-view",
"packages/x-internals"
],
"publishDirectory": {
"@mui/x-license": "packages/x-license/build",
Expand All @@ -24,7 +25,8 @@
"@mui/x-charts": "packages/x-charts/build",
"@mui/x-charts-pro": "packages/x-charts-pro/build",
"@mui/x-tree-view": "packages/x-tree-view/build",
"@mui/x-tree-view-pro": "packages/x-tree-view-pro/build"
"@mui/x-tree-view-pro": "packages/x-tree-view-pro/build",
"@mui/x-internals": "packages/x-internals/build"
},
"sandboxes": ["/bug-reproductions/x-data-grid"],
"silent": true
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const defaultAlias = {
'@mui/x-charts-pro': resolveAliasPath('./packages/x-charts-pro/src'),
'@mui/x-tree-view': resolveAliasPath('./packages/x-tree-view/src'),
'@mui/x-tree-view-pro': resolveAliasPath('./packages/x-tree-view-pro/src'),
'@mui/x-internals': resolveAliasPath('./packages/x-internals/src'),
'@mui/material-nextjs': '@mui/monorepo/packages/mui-material-nextjs/src',
'@mui-internal/api-docs-builder': resolveAliasPath(
'./node_modules/@mui/monorepo/packages/api-docs-builder',
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "6.7.0",
"version": "7.7.1",
"private": true,
"author": "MUI Team",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ponyfillGlobal.muiDocConfig = {
'@mui/x-charts-pro': getMuiPackageVersion('x-charts-pro', muiCommitRef),
'@mui/x-tree-view': getMuiPackageVersion('x-tree-view', muiCommitRef),
'@mui/x-tree-view-pro': getMuiPackageVersion('x-tree-view-pro', muiCommitRef),
'@mui/x-internals': getMuiPackageVersion('x-internals', muiCommitRef),
exceljs: 'latest',
};
return output;
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-material-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-material-ui",
"version": "6.3.0",
"version": "7.7.1",
"private": true,
"description": "Custom eslint rules for MUI X.",
"main": "src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@mui/x-charts-pro",
"version": "7.7.0",
"private": true,
"description": "The community edition of the Charts components (MUI X).",
"description": "The Pro plan edition of the Charts components (MUI X).",
"author": "MUI Team",
"main": "./src/index.ts",
"license": "SEE LICENSE IN LICENSE",
Expand Down
1 change: 1 addition & 0 deletions packages/x-data-grid-premium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@mui/utils": "^5.15.20",
"@mui/x-data-grid": "workspace:*",
"@mui/x-data-grid-pro": "workspace:*",
"@mui/x-internals": "workspace:*",
"@mui/x-license": "workspace:*",
"@types/format-util": "^1.0.4",
"clsx": "^2.1.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/x-data-grid-premium/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"references": [
{ "path": "../x-data-grid/tsconfig.build.json" },
{ "path": "../x-data-grid-pro/tsconfig.build.json" },
{ "path": "../x-license/tsconfig.build.json" }
{ "path": "../x-license/tsconfig.build.json" },
{ "path": "../x-internals/tsconfig.build.json" }
],
"include": ["src/**/*.ts*"],
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
Expand Down
1 change: 1 addition & 0 deletions packages/x-data-grid-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@mui/utils": "^5.15.20",
"@mui/x-data-grid": "workspace:*",
"@mui/x-license": "workspace:*",
"@mui/x-internals": "workspace:*",
"@types/format-util": "^1.0.4",
"clsx": "^2.1.1",
"prop-types": "^15.8.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { GridRowId } from '@mui/x-data-grid';
import { useResizeObserver } from '@mui/x-data-grid/internals';
import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
import { DataGridProProcessedProps } from '../models/dataGridProProps';
Expand Down
3 changes: 2 additions & 1 deletion packages/x-data-grid-pro/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"references": [
{ "path": "../x-data-grid/tsconfig.build.json" },
{ "path": "../x-license/tsconfig.build.json" }
{ "path": "../x-license/tsconfig.build.json" },
{ "path": "../x-internals/tsconfig.build.json" }
],
"include": ["src/**/*.ts*"],
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
Expand Down
1 change: 1 addition & 0 deletions packages/x-data-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@babel/runtime": "^7.24.7",
"@mui/system": "^5.15.20",
"@mui/utils": "^5.15.20",
"@mui/x-internals": "workspace:*",
"clsx": "^2.1.1",
"prop-types": "^15.8.1",
"reselect": "^4.1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
} from '@mui/utils';
import useLazyRef from '@mui/utils/useLazyRef';
import useTimeout from '@mui/utils/useTimeout';
import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
import { useTheme, Theme } from '@mui/material/styles';
import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
import { useGridRootProps } from '../../utils/useGridRootProps';
import { useGridSelector } from '../../utils/useGridSelector';
import { useResizeObserver } from '../../utils/useResizeObserver';
import { useRunOnce } from '../../utils/useRunOnce';
import {
gridVisibleColumnDefinitionsSelector,
Expand Down
1 change: 0 additions & 1 deletion packages/x-data-grid/src/hooks/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export { useGridSelector } from './useGridSelector';
export * from './useGridNativeEventListener';
export * from './useFirstRender';
export * from './useOnMount';
export * from './useResizeObserver';
export * from './useRunOnce';
1 change: 1 addition & 0 deletions packages/x-data-grid/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"rootDir": "./src",
"types": ["node", "@mui/material/themeCssVarsAugmentation", "@emotion/styled", "@mui/types"]
},
"references": [{ "path": "../x-internals/tsconfig.build.json" }],
"include": ["src/**/*.ts*"],
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
}
21 changes: 21 additions & 0 deletions packages/x-internals/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Material-UI SAS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions packages/x-internals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @mui/x-internals

Shared utilities used by MUI X packages.
This package should never be installed or used directly.
57 changes: 57 additions & 0 deletions packages/x-internals/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@mui/x-internals",
"version": "7.7.1",
"description": "Utility functions for the MUI X packages (internal use only).",
"author": "MUI Team",
"license": "MIT",
"bugs": {
"url": "https://github.com/mui/mui-x/issues"
},
"homepage": "https://mui.com/x/",
"sideEffects": false,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mui-org"
},
"publishConfig": {
"access": "public",
"directory": "build"
},
"keywords": [
"react",
"react-component",
"material-ui",
"mui",
"mui-x",
"utils"
],
"scripts": {
"typescript": "tsc -p tsconfig.json",
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files ",
"build:modern": "node ../../scripts/build.mjs modern",
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
"build:copy-files": "node ../../scripts/copyFiles.mjs",
"build:types": "node ../../scripts/buildTypes.mjs",
"prebuild": "rimraf build tsconfig.build.tsbuildinfo"
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"directory": "packages/x-internals"
},
"dependencies": {
"@babel/runtime": "^7.24.7",
"@mui/utils": "^5.15.20"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@mui/internal-test-utils": "^1.0.2",
"rimraf": "^5.0.7"
},
"engines": {
"node": ">=14.0.0"
}
}
1 change: 1 addition & 0 deletions packages/x-internals/src/useResizeObserver/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useResizeObserver } from './useResizeObserver';
16 changes: 16 additions & 0 deletions packages/x-internals/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// This config is for emitting declarations (.d.ts) only
// Actual .ts source files are transpiled via babel
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"noEmit": false,
"emitDeclarationOnly": true,
"outDir": "build",
"rootDir": "./src",
"types": ["node"]
},
"include": ["src/**/*.ts*"],
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
}
7 changes: 7 additions & 0 deletions packages/x-internals/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node", "@mui/internal-test-utils/initMatchers", "chai-dom", "mocha"]
},
"include": ["src/**/*"]
}
29 changes: 29 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/x-data-grid-premium.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,6 @@
{ "name": "useGridVirtualization", "kind": "Function" },
{ "name": "useKeepGroupedColumnsHidden", "kind": "Variable" },
{ "name": "useOnMount", "kind": "Function" },
{ "name": "useResizeObserver", "kind": "Function" },
{ "name": "useRunOnce", "kind": "Variable" },
{ "name": "ValueOptions", "kind": "TypeAlias" },
{ "name": "virtualizationStateInitializer", "kind": "Variable" }
Expand Down
1 change: 0 additions & 1 deletion scripts/x-data-grid-pro.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@
{ "name": "useGridSelector", "kind": "Variable" },
{ "name": "useGridVirtualization", "kind": "Function" },
{ "name": "useOnMount", "kind": "Function" },
{ "name": "useResizeObserver", "kind": "Function" },
{ "name": "useRunOnce", "kind": "Variable" },
{ "name": "ValueOptions", "kind": "TypeAlias" },
{ "name": "virtualizationStateInitializer", "kind": "Variable" }
Expand Down
1 change: 0 additions & 1 deletion scripts/x-data-grid.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@
{ "name": "useGridSelector", "kind": "Variable" },
{ "name": "useGridVirtualization", "kind": "Function" },
{ "name": "useOnMount", "kind": "Function" },
{ "name": "useResizeObserver", "kind": "Function" },
{ "name": "useRunOnce", "kind": "Variable" },
{ "name": "ValueOptions", "kind": "TypeAlias" },
{ "name": "virtualizationStateInitializer", "kind": "Variable" }
Expand Down
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mui-x-internal/test",
"version": "7.2.0",
"version": "7.7.1",
"private": true,
"scripts": {
"typescript": "tsc -p tsconfig.json"
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"@mui/x-tree-view-pro/*": ["./packages/x-tree-view-pro/src/*"],
"@mui/x-license": ["./packages/x-license/src"],
"@mui/x-license/*": ["./packages/x-license/src/*"],
"@mui/x-internals": ["./packages/x-internals/src"],
"@mui/x-internals/*": ["./packages/x-internals/src/*"],
"@mui/docs": ["./node_modules/@mui/monorepo/packages/mui-docs/src"],
"@mui/docs/*": ["./node_modules/@mui/monorepo/packages/mui-docs/src/*"],
"@mui-internal/api-docs-builder": ["./node_modules/@mui/monorepo/packages/api-docs-builder"],
Expand Down
1 change: 1 addition & 0 deletions webpackBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'@mui/x-tree-view': path.resolve(__dirname, './packages/x-tree-view/src'),
'@mui/x-tree-view-pro': path.resolve(__dirname, './packages/x-tree-view-pro/src'),
'@mui/x-license': path.resolve(__dirname, './packages/x-license/src'),
'@mui/x-internals': path.resolve(__dirname, './packages/x-internals/src'),
'@mui/material-nextjs': path.resolve(
__dirname,
'./node_modules/@mui/monorepo/packages/mui-material-nextjs/src',
Expand Down

0 comments on commit b7897ea

Please sign in to comment.