@mui/codemod 5.11.12 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,7 +79,7 @@ npx @mui/codemod v5.0.0/rename-css-variables <path>
79
79
 
80
80
  #### `base-hook-imports`
81
81
 
82
- Updates the sources of the imports of the MUI Base hooks to adapt to the new directories of the hooks.
82
+ Updates the sources of the imports of the Base UI hooks to adapt to the new directories of the hooks.
83
83
 
84
84
  ```diff
85
85
  - import { useBadge } from '@mui/base/BadgeUnstyled';
@@ -397,7 +397,7 @@ You can find more details about this breaking change in [the migration guide](ht
397
397
  Renames the `components` and `componentsProps` props to `slots` and `slotProps`, respectively.
398
398
  Also, changes `slots`' fields names to camelCase.
399
399
 
400
- This change only affects MUI Base components.
400
+ This change only affects Base UI components.
401
401
 
402
402
  ```diff
403
403
  <BadgeUnstyled
@@ -7,7 +7,7 @@ exports.default = transformer;
7
7
  const capitalize = str => {
8
8
  return str.charAt(0).toUpperCase() + str.slice(1);
9
9
  };
10
- const JoyComponents = ['Alert', 'AspectRatio', 'Autocomplete', 'AutocompleteListbox', 'AutocompleteOption', 'Avatar', 'AvatarGroup', 'Badge', 'Box', 'Breadcrumbs', 'Button', 'Card', 'CardContent', 'CardCover', 'CardOverflow', 'Checkbox', 'Chip', 'ChipDelete', 'CircularProgress', 'Container', 'CssBaseline', 'Divider', 'FormControl', 'FormHelperText', 'FormLabel', 'Grid', 'IconButton', 'Input', 'LinearProgress', 'Link', 'List', 'ListDivider', 'ListItem', 'ListItemButton', 'ListItemContent', 'ListItemDecorator', 'ListSubheader', 'Menu', 'MenuItem', 'MenuList', 'Modal', 'ModalClose', 'ModalDialog', 'Option', 'Radio', 'RadioGroup', 'ScopedCssBaseline', 'Select', 'Sheet', 'Slider', 'Stack', 'SvgIcon', 'Switch', 'Tab', 'Table', 'TabList', 'TabPanel', 'Tabs', 'Textarea', 'TextField', 'Tooltip', 'Typography'];
10
+ const JoyComponents = ['Alert', 'AspectRatio', 'Autocomplete', 'AutocompleteListbox', 'AutocompleteOption', 'Avatar', 'AvatarGroup', 'Badge', 'Box', 'Breadcrumbs', 'Button', 'Card', 'CardContent', 'CardCover', 'CardOverflow', 'Checkbox', 'Chip', 'ChipDelete', 'CircularProgress', 'Container', 'CssBaseline', 'Divider', 'FormControl', 'FormHelperText', 'FormLabel', 'Grid', 'IconButton', 'Input', 'LinearProgress', 'Link', 'List', 'ListDivider', 'ListItem', 'ListItemButton', 'ListItemContent', 'ListItemDecorator', 'ListSubheader', 'Menu', 'MenuItem', 'MenuList', 'Modal', 'ModalClose', 'ModalDialog', 'Option', 'Radio', 'RadioGroup', 'ScopedCssBaseline', 'Select', 'Sheet', 'Slider', 'Stack', 'SvgIcon', 'Switch', 'Tab', 'Table', 'TableCell', 'TabList', 'TabPanel', 'Tabs', 'Textarea', 'TextField', 'Tooltip', 'Typography'];
11
11
 
12
12
  /**
13
13
  * @param {import('jscodeshift').FileInfo} file
@@ -16,15 +16,24 @@ function transformer(file) {
16
16
  return file.source
17
17
  // from `--<Component>-<slot>-<property>` to `--<Component>-<slot><Property>`
18
18
  .replace(/--([a-zA-Z]+)([-_])([a-zA-Z]+)-([a-zA-Z]+)/gm, (matched, capture1, capture2, capture3, capture4) => {
19
- if (!JoyComponents.includes(capture1) && !['internal', 'unstable'].includes(capture1)) {
19
+ if (!JoyComponents.includes(capture1) && !['internal', 'unstable', 'private'].includes(capture1)) {
20
20
  return matched;
21
21
  }
22
22
  // turn `--List-item-...` and `--List-divider-...` to `--ListItem-...` and `--ListDivider-...`
23
23
  if (capture1 === 'List' && ['divider', 'item'].includes(capture3)) {
24
24
  return `--${capture1}${capitalize(capture3)}-${capture4}`;
25
25
  }
26
- return `--${capture1}${capture2}${capture3}${capitalize(capture4)}`;
27
- })
26
+ // turn `--List-decorator-...` to `--ListItemDecorator-...`
27
+ if (capture1 === 'List' && ['decorator'].includes(capture3)) {
28
+ return `--${capture1}Item${capitalize(capture3)}-${capture4}`;
29
+ }
30
+ if (!JoyComponents.includes(capture3)) {
31
+ return `--${capture1}${capture2}${capture3}${capitalize(capture4)}`;
32
+ }
33
+ return matched;
34
+ }).replace(/--List-decoratorSize/gm, '--ListItemDecorator-size').replace(/--List-decoratorColor/gm, '--ListItemDecorator-color')
28
35
  // from `--internal-...` to `--unstable_...`
29
- .replace(/--internal-/gm, '--unstable_');
36
+ .replace(/--internal-/gm, '--unstable_')
37
+ // from `--private_...` to `--unstable_...`
38
+ .replace(/--private_/gm, '--unstable_');
30
39
  }
@@ -4,7 +4,12 @@ var _jsxRuntime = require("react/jsx-runtime");
4
4
  /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
5
5
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(List, {
6
6
  sx: {
7
- py: 'var(--ListDivider-gap)'
7
+ py: 'var(--ListDivider-gap)',
8
+ '--List-decorator-size': '24px'
9
+ }
10
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(List, {
11
+ sx: {
12
+ '--List-decoratorSize': '24px'
8
13
  }
9
14
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ListItem, {
10
15
  sx: {
@@ -14,6 +19,10 @@ var _jsxRuntime = require("react/jsx-runtime");
14
19
  sx: {
15
20
  '--Input-decoratorChildHeight': '10px'
16
21
  }
22
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ModalDialog, {
23
+ sx: {
24
+ '--unstable_ModalDialog-descriptionOffset': '12px'
25
+ }
17
26
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Autocomplete, {
18
27
  sx: {
19
28
  '--Autocomplete-wrapperGap': '10px'
@@ -26,6 +35,10 @@ var _jsxRuntime = require("react/jsx-runtime");
26
35
  sx: {
27
36
  py: 'var(--internal-action-radius)'
28
37
  }
38
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Item, {
39
+ sx: {
40
+ py: 'var(--private_action-radius)'
41
+ }
29
42
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Item, {
30
43
  sx: {
31
44
  py: 'var(--unstable_action-radius)'
@@ -4,7 +4,12 @@ var _jsxRuntime = require("react/jsx-runtime");
4
4
  /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
5
5
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(List, {
6
6
  sx: {
7
- py: 'var(--ListDivider-gap)'
7
+ py: 'var(--ListDivider-gap)',
8
+ '--ListItemDecorator-size': '24px'
9
+ }
10
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(List, {
11
+ sx: {
12
+ '--ListItemDecorator-size': '24px'
8
13
  }
9
14
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ListItem, {
10
15
  sx: {
@@ -14,6 +19,10 @@ var _jsxRuntime = require("react/jsx-runtime");
14
19
  sx: {
15
20
  '--Input-decoratorChildHeight': '10px'
16
21
  }
22
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ModalDialog, {
23
+ sx: {
24
+ '--unstable_ModalDialog-descriptionOffset': '12px'
25
+ }
17
26
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Autocomplete, {
18
27
  sx: {
19
28
  '--Autocomplete-wrapperGap': '10px'
@@ -30,5 +39,9 @@ var _jsxRuntime = require("react/jsx-runtime");
30
39
  sx: {
31
40
  py: 'var(--unstable_actionRadius)'
32
41
  }
42
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Item, {
43
+ sx: {
44
+ py: 'var(--unstable_actionRadius)'
45
+ }
33
46
  })]
34
47
  });
@@ -30,7 +30,7 @@ function transformer(file, api, options) {
30
30
  if (node.imported.name === 'Theme') {
31
31
  hasTheme = true;
32
32
  }
33
- if (node.imported.name === 'ThemeProvider' || node.imported.nmae === 'MuiThemeProvider') {
33
+ if (node.imported.name === 'ThemeProvider' || node.imported.name === 'MuiThemeProvider') {
34
34
  isRootFile = true;
35
35
  }
36
36
  });
@@ -186,7 +186,7 @@ const NewStartScreen = () => {
186
186
  }, category.name))
187
187
  });
188
188
  };
189
- function DocSearcHit(props) {
189
+ function DocSearchHit(props) {
190
190
  const {
191
191
  children,
192
192
  hit
@@ -205,7 +205,7 @@ function DocSearcHit(props) {
205
205
  text = 'Joy UI';
206
206
  }
207
207
  if (pathname.startsWith('/base/')) {
208
- text = 'MUI Base';
208
+ text = 'Base UI';
209
209
  }
210
210
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
211
211
  label: text,
@@ -238,7 +238,7 @@ function DocSearcHit(props) {
238
238
  children: children
239
239
  });
240
240
  }
241
- process.env.NODE_ENV !== "production" ? DocSearcHit.propTypes = {
241
+ process.env.NODE_ENV !== "production" ? DocSearchHit.propTypes = {
242
242
  children: _propTypes.default.node,
243
243
  hit: _propTypes.default.object.isRequired
244
244
  } : void 0;
@@ -358,7 +358,7 @@ function AppSearch() {
358
358
  });
359
359
  });
360
360
  },
361
- hitComponent: DocSearcHit,
361
+ hitComponent: DocSearchHit,
362
362
  initialScrollY: typeof window !== 'undefined' ? window.scrollY : undefined,
363
363
  onClose: onClose,
364
364
  navigator: keyboardNavigator
@@ -186,7 +186,7 @@ const NewStartScreen = () => {
186
186
  }, category.name))
187
187
  });
188
188
  };
189
- function DocSearcHit(props) {
189
+ function DocSearchHit(props) {
190
190
  const {
191
191
  children,
192
192
  hit
@@ -205,7 +205,7 @@ function DocSearcHit(props) {
205
205
  text = 'Joy UI';
206
206
  }
207
207
  if (pathname.startsWith('/base/')) {
208
- text = 'MUI Base';
208
+ text = 'Base UI';
209
209
  }
210
210
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
211
211
  label: text,
@@ -238,7 +238,7 @@ function DocSearcHit(props) {
238
238
  children: children
239
239
  });
240
240
  }
241
- process.env.NODE_ENV !== "production" ? DocSearcHit.propTypes = {
241
+ process.env.NODE_ENV !== "production" ? DocSearchHit.propTypes = {
242
242
  children: _propTypes.default.node,
243
243
  hit: _propTypes.default.object.isRequired
244
244
  } : void 0;
@@ -358,7 +358,7 @@ function AppSearch() {
358
358
  });
359
359
  });
360
360
  },
361
- hitComponent: DocSearcHit,
361
+ hitComponent: DocSearchHit,
362
362
  initialScrollY: typeof window !== 'undefined' ? window.scrollY : undefined,
363
363
  onClose: onClose,
364
364
  navigator: keyboardNavigator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "5.11.12",
3
+ "version": "5.12.0",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -30,9 +30,9 @@
30
30
  "url": "https://opencollective.com/mui"
31
31
  },
32
32
  "dependencies": {
33
- "@babel/core": "^7.21.0",
33
+ "@babel/core": "^7.21.3",
34
34
  "@babel/runtime": "^7.21.0",
35
- "@babel/traverse": "^7.21.2",
35
+ "@babel/traverse": "^7.21.3",
36
36
  "jscodeshift": "^0.13.1",
37
37
  "jscodeshift-add-imports": "^1.0.10",
38
38
  "yargs": "^17.7.1"