Skip to content

Commit

Permalink
[core] Fix generate Proptypes script skipping unstable items (#38198)
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert authored Jul 28, 2023
1 parent b6e9a6b commit 55fb595
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
23 changes: 23 additions & 0 deletions packages/mui-system/src/Unstable_Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,29 @@ Grid.propTypes /* remove-proptypes */ = {
PropTypes.func,
PropTypes.object,
]),
/**
* @internal
* The level of the grid starts from `0`
* and increases when the grid nests inside another grid regardless of container or item.
*
* ```js
* <Grid> // level 0
* <Grid> // level 1
* <Grid> // level 2
* <Grid> // level 1
* ```
*
* Only consecutive grid is considered nesting.
* A grid container will start at `0` if there are non-Grid element above it.
*
* ```js
* <Grid> // level 0
* <div>
* <Grid> // level 0
* <Grid> // level 1
* ```
*/
unstable_level: PropTypes.number,
/**
* Defines the `flex-wrap` style property.
* It's applied for all screen sizes.
Expand Down
16 changes: 10 additions & 6 deletions scripts/generateProptypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,18 @@ async function run(argv: HandlerArgv) {

const files = _.flatten(allFiles)
.filter((filePath) => {
const folderName = path.basename(path.dirname(filePath));
// Filter out files where the directory name and filename doesn't match
// Example: Modal/ModalManager.d.ts
let folderName = path.basename(path.dirname(filePath));
const fileName = path.basename(filePath).replace(/(\.d\.ts|\.tsx|\.ts)/g, '');

return (
// Filter out files where the directory name and filename doesn't match
// Example: Modal/ModalManager.d.ts
fileName === folderName
);
// An exception is if the folder name starts with Unstable_/unstable_
// Example: Unstable_Grid2/Grid2.tsx
if (/(u|U)nstable_/g.test(folderName)) {
folderName = folderName.slice(9);
}

return fileName === folderName;
})
.filter((filePath) => {
return filePattern.test(filePath);
Expand Down

0 comments on commit 55fb595

Please sign in to comment.