@mui/codemod 6.0.0-beta.5 → 6.0.0-beta.6

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.
Files changed (46) hide show
  1. package/README.md +0 -1
  2. package/node/deprecations/avatar-group-props/avatar-group-props.js +2 -8
  3. package/node/deprecations/divider-props/divider-props.js +2 -4
  4. package/node/deprecations/typography-props/typography-props.js +3 -8
  5. package/node/deprecations/utils/movePropIntoSlotProps.js +4 -12
  6. package/node/deprecations/utils/movePropIntoSlots.js +4 -12
  7. package/node/deprecations/utils/replaceComponentsWithSlots.js +3 -8
  8. package/node/util/getReturnExpression.js +1 -2
  9. package/node/util/migrateToVariants.js +13 -24
  10. package/node/util/propsToObject.js +2 -6
  11. package/node/util/renameClassKey.js +1 -2
  12. package/node/v5.0.0/avatar-circle-circular.js +2 -4
  13. package/node/v5.0.0/badge-overlap-value.js +4 -7
  14. package/node/v5.0.0/base-hook-imports.js +1 -2
  15. package/node/v5.0.0/base-remove-unstyled-suffix.js +1 -2
  16. package/node/v5.0.0/base-rename-components-to-slots.js +1 -1
  17. package/node/v5.0.0/base-use-named-exports.js +5 -8
  18. package/node/v5.0.0/box-sx-prop.js +1 -2
  19. package/node/v5.0.0/button-color-prop.js +1 -2
  20. package/node/v5.0.0/chip-variant-prop.js +1 -2
  21. package/node/v5.0.0/circularprogress-variant.js +2 -4
  22. package/node/v5.0.0/fab-variant.js +2 -4
  23. package/node/v5.0.0/grid-list-component.test/actual.js +1 -1
  24. package/node/v5.0.0/grid-list-component.test/expected.js +1 -1
  25. package/node/v5.0.0/joy-avatar-remove-imgProps.js +3 -7
  26. package/node/v5.0.0/joy-rename-components-to-slots.js +1 -1
  27. package/node/v5.0.0/joy-rename-row-prop.js +1 -2
  28. package/node/v5.0.0/joy-text-field-to-input.js +4 -7
  29. package/node/v5.0.0/jss-to-tss-react.js +4 -6
  30. package/node/v5.0.0/link-underline-hover.js +1 -4
  31. package/node/v5.0.0/pagination-round-circular.js +3 -8
  32. package/node/v5.0.0/skeleton-variant.js +3 -5
  33. package/node/v5.0.0/table-props.js +4 -9
  34. package/node/v5.0.0/tabs-scroll-buttons.js +4 -5
  35. package/node/v6.0.0/grid-v2-props/grid-v2-props.js +4 -11
  36. package/node/v6.0.0/list-item-button-prop/list-item-button-prop.js +1 -2
  37. package/node/v6.0.0/styled/test-cases/NestedSpread.actual.js +2 -3
  38. package/node/v6.0.0/styled/test-cases/NestedSpread.expected.js +2 -3
  39. package/node/v6.0.0/sx-prop/sx-v6.js +18 -34
  40. package/node/v6.0.0/sx-prop/test-cases/sx-condition.actual.js +3 -4
  41. package/node/v6.0.0/sx-prop/test-cases/sx-condition.expected.js +3 -4
  42. package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.actual.js +17 -0
  43. package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.expected.js +17 -0
  44. package/node/v6.0.0/system-props/removeSystemProps.js +10 -19
  45. package/node/v6.0.0/theme-v6/theme-v6.js +2 -3
  46. package/package.json +2 -2
@@ -25,10 +25,8 @@ function transformer(file, api, options) {
25
25
  ].includes(sourceVal);
26
26
  }).forEach(path => {
27
27
  path.node.specifiers.forEach(elementNode => {
28
- var _elementNode$imported;
29
- if (elementNode.type === 'ImportSpecifier' && ((_elementNode$imported = elementNode.imported) == null ? void 0 : _elementNode$imported.name) === 'TextField' || elementNode.type === 'ImportDefaultSpecifier') {
30
- var _elementNode$imported2;
31
- if (((_elementNode$imported2 = elementNode.imported) == null ? void 0 : _elementNode$imported2.name) === 'TextField') {
28
+ if (elementNode.type === 'ImportSpecifier' && elementNode.imported?.name === 'TextField' || elementNode.type === 'ImportDefaultSpecifier') {
29
+ if (elementNode.imported?.name === 'TextField') {
32
30
  elementNode.imported.name = 'Input';
33
31
  }
34
32
  let newElementName;
@@ -45,7 +43,6 @@ function transformer(file, api, options) {
45
43
  let formLabelValue;
46
44
  let formHelperTextValue;
47
45
  elementPath.node.openingElement.attributes.forEach(attributeNode => {
48
- var _attributeNode$value$, _attributeNode$value$2;
49
46
  if (attributeNode.type !== 'JSXAttribute') {
50
47
  return;
51
48
  }
@@ -57,7 +54,7 @@ function transformer(file, api, options) {
57
54
  formControlAttributeNodes.push(attributeNode);
58
55
  break;
59
56
  case 'slotProps':
60
- if (((_attributeNode$value$ = attributeNode.value.expression) == null ? void 0 : _attributeNode$value$.type) === 'ObjectExpression') {
57
+ if (attributeNode.value.expression?.type === 'ObjectExpression') {
61
58
  attributeNode.value.expression.properties.forEach(propNode => {
62
59
  if (propNode.value.type !== 'ObjectExpression') {
63
60
  return;
@@ -85,7 +82,7 @@ function transformer(file, api, options) {
85
82
  }
86
83
  break;
87
84
  case 'slots':
88
- if (((_attributeNode$value$2 = attributeNode.value.expression) == null ? void 0 : _attributeNode$value$2.type) === 'ObjectExpression') {
85
+ if (attributeNode.value.expression?.type === 'ObjectExpression') {
89
86
  attributeNode.value.expression.properties.forEach(propNode => {
90
87
  const newAttributeNode = j.jsxAttribute(j.jsxIdentifier('component'), j.jsxExpressionContainer(propNode.value));
91
88
  switch (propNode.key.name) {
@@ -7,8 +7,7 @@ exports.default = transformer;
7
7
  const ruleEndRegEx = /[^a-zA-Z0-9_]+/;
8
8
  function transformNestedKeys(j, comments, propValueNode, ruleRegEx, nestedKeys) {
9
9
  propValueNode.properties.forEach(prop => {
10
- var _prop$value, _prop$value2;
11
- if (((_prop$value = prop.value) == null ? void 0 : _prop$value.type) === 'ObjectExpression') {
10
+ if (prop.value?.type === 'ObjectExpression') {
12
11
  if (typeof prop.key.value === 'string' && ruleRegEx !== null) {
13
12
  let ruleIndex = prop.key.value.search(ruleRegEx);
14
13
  let searchStartIndex = 0;
@@ -45,7 +44,7 @@ function transformNestedKeys(j, comments, propValueNode, ruleRegEx, nestedKeys)
45
44
  }
46
45
  }
47
46
  transformNestedKeys(j, comments, prop.value, ruleRegEx, nestedKeys);
48
- } else if (((_prop$value2 = prop.value) == null ? void 0 : _prop$value2.type) === 'ArrowFunctionExpression') {
47
+ } else if (prop.value?.type === 'ArrowFunctionExpression') {
49
48
  comments.push(j.commentLine(' TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.', true));
50
49
  }
51
50
  });
@@ -68,10 +67,9 @@ function transformStylesExpression(j, comments, stylesExpression, nestedKeys, se
68
67
  }
69
68
  if (objectExpression !== undefined) {
70
69
  objectExpression.properties.forEach(prop => {
71
- var _prop$key, _prop$key2;
72
- if ((_prop$key = prop.key) != null && _prop$key.name) {
70
+ if (prop.key?.name) {
73
71
  ruleNames.push(prop.key.name);
74
- } else if (((_prop$key2 = prop.key) == null ? void 0 : _prop$key2.value) === '@global') {
72
+ } else if (prop.key?.value === '@global') {
75
73
  comments.push(j.commentLine(` TODO jss-to-tss-react codemod: '@global' is not supported by tss-react.`, true));
76
74
  comments.push(j.commentLine(` See https://mui.com/material-ui/customization/how-to-customize/#4-global-css-override for alternatives.`, true));
77
75
  }
@@ -41,10 +41,7 @@ function transformer(file, api, options) {
41
41
  root.findJSXElements(name).forEach(({
42
42
  node
43
43
  }) => {
44
- const hasUnderlineProp = node.openingElement.attributes.find(attr => {
45
- var _attr$name;
46
- return (attr == null || (_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'underline';
47
- });
44
+ const hasUnderlineProp = node.openingElement.attributes.find(attr => attr?.name?.name === 'underline');
48
45
  if (!hasUnderlineProp) {
49
46
  node.openingElement.attributes.push(j.jsxAttribute(j.jsxIdentifier('underline'), j.literal('hover')));
50
47
  }
@@ -13,18 +13,13 @@ function transformer(file, api, options) {
13
13
  const printOptions = options.printOptions;
14
14
  const source = j(file.source).find(j.JSXElement).filter(({
15
15
  node
16
- }) => {
17
- var _node$openingElement$;
18
- return (_node$openingElement$ = node.openingElement.name.name) == null ? void 0 : _node$openingElement$.match(/^(Pagination|PaginationItem)$/);
19
- }).forEach(path => {
16
+ }) => node.openingElement.name.name?.match(/^(Pagination|PaginationItem)$/)).forEach(path => {
20
17
  path.node.openingElement.attributes.forEach(node => {
21
- var _node$value$expressio;
22
- if (node.type === 'JSXAttribute' && node.name.name === 'shape' && (node.value.value === 'round' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'round')) {
18
+ if (node.type === 'JSXAttribute' && node.name.name === 'shape' && (node.value.value === 'round' || node.value.expression?.value === 'round')) {
23
19
  node.value = j.literal('circular');
24
20
  }
25
21
  if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
26
- var _node$value;
27
- (((_node$value = node.value) == null || (_node$value = _node$value.expression) == null ? void 0 : _node$value.properties) || []).forEach(subNode => {
22
+ (node.value?.expression?.properties || []).forEach(subNode => {
28
23
  if (subNode.key.name === 'round') {
29
24
  subNode.key.name = 'circular';
30
25
  }
@@ -14,17 +14,15 @@ function transformer(file, api, options) {
14
14
  const source = j(file.source).findJSXElements('Skeleton').forEach(path => {
15
15
  path.node.openingElement.attributes.forEach(node => {
16
16
  if (node.type === 'JSXAttribute' && node.name.name === 'variant') {
17
- var _node$value$expressio, _node$value$expressio2;
18
- if (node.value.value === 'circle' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'circle') {
17
+ if (node.value.value === 'circle' || node.value.expression?.value === 'circle') {
19
18
  node.value = j.literal('circular');
20
19
  }
21
- if (node.value.value === 'rect' || ((_node$value$expressio2 = node.value.expression) == null ? void 0 : _node$value$expressio2.value) === 'rect') {
20
+ if (node.value.value === 'rect' || node.value.expression?.value === 'rect') {
22
21
  node.value = j.literal('rectangular');
23
22
  }
24
23
  }
25
24
  if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
26
- var _node$value;
27
- (_node$value = node.value) == null || (_node$value = _node$value.expression) == null || (_node$value = _node$value.properties) == null || _node$value.forEach(subNode => {
25
+ node.value?.expression?.properties?.forEach(subNode => {
28
26
  if (subNode.key.name === 'circle') {
29
27
  subNode.key.name = 'circular';
30
28
  }
@@ -14,15 +14,11 @@ function transformer(file, api, options) {
14
14
  const printOptions = options.printOptions;
15
15
  root.find(j.JSXElement).filter(({
16
16
  node
17
- }) => {
18
- var _node$openingElement$;
19
- return (_node$openingElement$ = node.openingElement.name.name) == null ? void 0 : _node$openingElement$.match(/^(Table|TableCell)$/);
20
- }).forEach(({
17
+ }) => node.openingElement.name.name?.match(/^(Table|TableCell)$/)).forEach(({
21
18
  node
22
19
  }) => {
23
20
  node.openingElement.attributes.forEach(attr => {
24
- var _attr$name, _attr$value, _attr$value2;
25
- if (((_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'padding' && (((_attr$value = attr.value) == null ? void 0 : _attr$value.value) === 'default' || ((_attr$value2 = attr.value) == null || (_attr$value2 = _attr$value2.expression) == null ? void 0 : _attr$value2.value) === 'default')) {
21
+ if (attr.name?.name === 'padding' && (attr.value?.value === 'default' || attr.value?.expression?.value === 'default')) {
26
22
  attr.value = j.literal('normal');
27
23
  }
28
24
  });
@@ -31,14 +27,13 @@ function transformer(file, api, options) {
31
27
  node
32
28
  }) => {
33
29
  node.openingElement.attributes.forEach(attr => {
34
- var _attr$name2, _attr$name3;
35
30
  if (attr.type === 'JSXAttribute' && attr.name.name === 'onChangeRowsPerPage') {
36
31
  attr.name.name = 'onRowsPerPageChange';
37
32
  }
38
- if (attr.type === 'JSXAttribute' && ((_attr$name2 = attr.name) == null ? void 0 : _attr$name2.name) === 'onChangePage') {
33
+ if (attr.type === 'JSXAttribute' && attr.name?.name === 'onChangePage') {
39
34
  attr.name.name = 'onPageChange';
40
35
  }
41
- if (attr.type === 'JSXAttribute' && ((_attr$name3 = attr.name) == null ? void 0 : _attr$name3.name) === 'classes') {
36
+ if (attr.type === 'JSXAttribute' && attr.name?.name === 'classes') {
42
37
  (attr.value.expression.properties || []).forEach(subNode => {
43
38
  if (subNode.key.name === 'input') {
44
39
  subNode.key.name = 'select';
@@ -19,13 +19,12 @@ function transformer(file, api, options) {
19
19
  node.openingElement.attributes.forEach(attr => {
20
20
  if (attr.name && attr.name.name === 'scrollButtons') {
21
21
  if (attr.value) {
22
- var _attr$value$expressio, _attr$value$expressio2, _attr$value$expressio3, _attr$value$expressio4;
23
- prevScrollButtonValue = attr.value.value || ((_attr$value$expressio = attr.value.expression) == null ? void 0 : _attr$value$expressio.value);
24
- if (attr.value.value === 'on' || ((_attr$value$expressio2 = attr.value.expression) == null ? void 0 : _attr$value$expressio2.value) === 'on') {
22
+ prevScrollButtonValue = attr.value.value || attr.value.expression?.value;
23
+ if (attr.value.value === 'on' || attr.value.expression?.value === 'on') {
25
24
  delete attr.value;
26
- } else if (attr.value.value === 'desktop' || ((_attr$value$expressio3 = attr.value.expression) == null ? void 0 : _attr$value$expressio3.value) === 'desktop') {
25
+ } else if (attr.value.value === 'desktop' || attr.value.expression?.value === 'desktop') {
27
26
  delete attr.value;
28
- } else if (attr.value.value === 'off' || ((_attr$value$expressio4 = attr.value.expression) == null ? void 0 : _attr$value$expressio4.value) === 'off') {
27
+ } else if (attr.value.value === 'off' || attr.value.expression?.value === 'off') {
29
28
  attr.value = j.jsxExpressionContainer(j.literal(false));
30
29
  }
31
30
  }
@@ -17,13 +17,12 @@ const defaultBreakpoints = ['xs', 'sm', 'md', 'lg', 'xl'];
17
17
  * @param {import('jscodeshift').API} api
18
18
  */
19
19
  function gridV2Props(file, api, options) {
20
- var _file$path, _file$path2, _options$muiBreakpoin;
21
- if ((_file$path = file.path) != null && _file$path.endsWith('.json') || (_file$path2 = file.path) != null && _file$path2.endsWith('.d.ts')) {
20
+ if (file.path?.endsWith('.json') || file.path?.endsWith('.d.ts')) {
22
21
  return file.source;
23
22
  }
24
23
  const j = api.jscodeshift;
25
24
  const root = j(file.source);
26
- const breakpoints = ((_options$muiBreakpoin = options.muiBreakpoints) == null ? void 0 : _options$muiBreakpoin.split(',')) || defaultBreakpoints;
25
+ const breakpoints = options.muiBreakpoints?.split(',') || defaultBreakpoints;
27
26
  const printOptions = options.printOptions;
28
27
  const gridLocalNames = [];
29
28
  root.find(j.ImportDeclaration, decl => possibleDefaultImports.includes(decl.source.value)).forEach(decl => {
@@ -101,10 +100,7 @@ function gridV2Props(file, api, options) {
101
100
  }
102
101
  el.node.openingElement.attributes.push(j.jsxAttribute(j.jsxIdentifier('size'), sizePropValue));
103
102
  }
104
- el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => {
105
- var _attr$name;
106
- return !breakpoints.includes(attr == null || (_attr$name = attr.name) == null ? void 0 : _attr$name.name);
107
- });
103
+ el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => !breakpoints.includes(attr?.name?.name));
108
104
  const offset = j.objectExpression([]);
109
105
  const offsetNodes = j(el).find(j.JSXAttribute).filter(path => path.parent.parent.node === el.node && path.node.name.name.endsWith('Offset') && breakpoints.includes(path.node.name.name.replace('Offset', '')));
110
106
  offsetNodes.nodes().forEach(node => {
@@ -139,10 +135,7 @@ function gridV2Props(file, api, options) {
139
135
  }
140
136
  el.node.openingElement.attributes.push(j.jsxAttribute(j.jsxIdentifier('offset'), offsetPropValue));
141
137
  }
142
- el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => {
143
- var _attr$name2;
144
- return !breakpoints.includes(attr == null || (_attr$name2 = attr.name) == null ? void 0 : _attr$name2.name.replace('Offset', ''));
145
- });
138
+ el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => !breakpoints.includes(attr?.name?.name.replace('Offset', '')));
146
139
  el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => !attributesToPrune.includes(attr));
147
140
  });
148
141
  return root.toSource(printOptions);
@@ -26,8 +26,7 @@ function transformer(file, api, options) {
26
26
  }).forEach(path => {
27
27
  const defaultProps = path.parent.value;
28
28
  defaultProps.properties.forEach(property => {
29
- var _property$key;
30
- if (((_property$key = property.key) == null ? void 0 : _property$key.name) === 'button') {
29
+ if (property.key?.name === 'button') {
31
30
  // Remove the button property from the defaultProps object
32
31
  const newListButtonProps = defaultProps.properties.filter(prop => prop.key.name !== 'button');
33
32
  const muiListItemButtonNode = j.objectProperty(j.identifier('MuiListItemButton'), j.objectExpression([j.property('init', j.identifier('defaultProps'), j.objectExpression(newListButtonProps))]));
@@ -4,8 +4,7 @@ const Component = styled('div')(({
4
4
  theme,
5
5
  ownerState
6
6
  }) => {
7
- var _palette;
8
- const palette = (_palette = (theme.vars || theme).palette) == null ? void 0 : _palette[ownerState.color];
7
+ const palette = (theme.vars || theme).palette?.[ownerState.color];
9
8
  return {
10
9
  overflow: 'visible',
11
10
  // Explicitly set the default value to solve a bug on IE11.
@@ -29,7 +28,7 @@ const Component = styled('div')(({
29
28
  marginRight: ownerState.size === 'small' ? -3 : -12
30
29
  }),
31
30
  ...(ownerState.color !== 'inherit' && ownerState.color !== 'default' && {
32
- color: palette == null ? void 0 : palette.main,
31
+ color: palette?.main,
33
32
  ...(!ownerState.disableRipple && {
34
33
  '&:hover': {
35
34
  // The codemod won't handle this case when the variable is not declared in the style argument.
@@ -3,8 +3,7 @@
3
3
  const Component = styled('div')(({
4
4
  theme
5
5
  }) => {
6
- var _palette;
7
- const palette = (_palette = (theme.vars || theme).palette) == null ? void 0 : _palette[ownerState.color];
6
+ const palette = (theme.vars || theme).palette?.[ownerState.color];
8
7
  return {
9
8
  // Explicitly set the default value to solve a bug on IE11.
10
9
  overflow: 'visible',
@@ -60,7 +59,7 @@ const Component = styled('div')(({
60
59
  ownerState
61
60
  }) => ownerState.color !== 'inherit' && ownerState.color !== 'default',
62
61
  style: {
63
- color: palette == null ? void 0 : palette.main
62
+ color: palette?.main
64
63
  }
65
64
  }, {
66
65
  props: ({
@@ -14,8 +14,7 @@ var _migrateToVariants = require("../../util/migrateToVariants");
14
14
  function getCssVarName(node) {
15
15
  let varName = '-';
16
16
  while (node.type === 'MemberExpression') {
17
- var _node$object, _node$property;
18
- varName += `-${((_node$object = node.object) == null ? void 0 : _node$object.name) || ((_node$property = node.property) == null ? void 0 : _node$property.name) || 'unknown'}`;
17
+ varName += `-${node.object?.name || node.property?.name || 'unknown'}`;
19
18
  if (node.object.type === 'MemberExpression') {
20
19
  node = node.object;
21
20
  } else {
@@ -43,7 +42,7 @@ function sxV6(file, api, options) {
43
42
  * @param {import('jscodeshift').Identifier} node
44
43
  */
45
44
  function replaceUndefined(node, replacement = j.nullLiteral()) {
46
- if ((node == null ? void 0 : node.type) === 'Identifier' && node.name === 'undefined') {
45
+ if (node?.type === 'Identifier' && node.name === 'undefined') {
47
46
  return replacement;
48
47
  }
49
48
  return node;
@@ -118,8 +117,7 @@ function sxV6(file, api, options) {
118
117
  }
119
118
  function rootThemeCallback(data) {
120
119
  if (data.root.type === 'ObjectExpression') {
121
- var _data$replaceRoot;
122
- (_data$replaceRoot = data.replaceRoot) == null || _data$replaceRoot.call(data, buildArrowFunctionAST([j.identifier('theme')], data.root));
120
+ data.replaceRoot?.(buildArrowFunctionAST([j.identifier('theme')], data.root));
123
121
  } else if (data.root.type === 'ArrayExpression') {
124
122
  data.root.elements.forEach((item, index) => {
125
123
  if (item === data.node) {
@@ -137,8 +135,7 @@ function sxV6(file, api, options) {
137
135
  if (data.node.type === 'ArrowFunctionExpression') {
138
136
  const returnExpression = (0, _getReturnExpression.default)(data.node);
139
137
  if (returnExpression) {
140
- var _returnExpression$pro, _getObjectKey, _getObjectKey2, _getObjectKey3, _getObjectKey4;
141
- if (returnExpression.type === 'MemberExpression' && ((_returnExpression$pro = returnExpression.property) == null ? void 0 : _returnExpression$pro.type) === 'ConditionalExpression') {
138
+ if (returnExpression.type === 'MemberExpression' && returnExpression.property?.type === 'ConditionalExpression') {
142
139
  recurseObjectExpression({
143
140
  ...data,
144
141
  node: j.conditionalExpression(returnExpression.property.test, {
@@ -151,7 +148,7 @@ function sxV6(file, api, options) {
151
148
  });
152
149
  } else if (returnExpression.type === 'TemplateLiteral') {
153
150
  const firstExpression = returnExpression.expressions[0];
154
- if ((firstExpression == null ? void 0 : firstExpression.type) === 'ConditionalExpression') {
151
+ if (firstExpression?.type === 'ConditionalExpression') {
155
152
  recurseObjectExpression({
156
153
  ...data,
157
154
  node: j.conditionalExpression(firstExpression.test, {
@@ -168,9 +165,8 @@ function sxV6(file, api, options) {
168
165
  node: returnExpression
169
166
  });
170
167
  }
171
- } else if (returnExpression.type === 'CallExpression' && ((_getObjectKey = (0, _migrateToVariants.getObjectKey)(returnExpression.callee)) == null ? void 0 : _getObjectKey.name) === 'theme' || returnExpression.type === 'MemberExpression' && ((_getObjectKey2 = (0, _migrateToVariants.getObjectKey)(returnExpression)) == null ? void 0 : _getObjectKey2.name) === 'theme' || returnExpression.type === 'BinaryExpression' && (((_getObjectKey3 = (0, _migrateToVariants.getObjectKey)(returnExpression.left)) == null ? void 0 : _getObjectKey3.name) === 'theme' || ((_getObjectKey4 = (0, _migrateToVariants.getObjectKey)(returnExpression.right)) == null ? void 0 : _getObjectKey4.name) === 'theme')) {
172
- var _data$replaceValue;
173
- (_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, returnExpression);
168
+ } else if (returnExpression.type === 'CallExpression' && (0, _migrateToVariants.getObjectKey)(returnExpression.callee)?.name === 'theme' || returnExpression.type === 'MemberExpression' && (0, _migrateToVariants.getObjectKey)(returnExpression)?.name === 'theme' || returnExpression.type === 'BinaryExpression' && ((0, _migrateToVariants.getObjectKey)(returnExpression.left)?.name === 'theme' || (0, _migrateToVariants.getObjectKey)(returnExpression.right)?.name === 'theme')) {
169
+ data.replaceValue?.(returnExpression);
174
170
  rootThemeCallback(data);
175
171
  } else {
176
172
  recurseObjectExpression({
@@ -196,8 +192,7 @@ function sxV6(file, api, options) {
196
192
  deleteSelf: () => {
197
193
  (0, _migrateToVariants.removeProperty)(data.node, prop);
198
194
  if (data.node.properties.length === 0) {
199
- var _data$deleteSelf;
200
- (_data$deleteSelf = data.deleteSelf) == null || _data$deleteSelf.call(data);
195
+ data.deleteSelf?.();
201
196
  }
202
197
  },
203
198
  modeStyles
@@ -215,8 +210,7 @@ function sxV6(file, api, options) {
215
210
  }
216
211
  if (data.node.type === 'SpreadElement') {
217
212
  if (data.node.argument.type === 'LogicalExpression') {
218
- var _getObjectKey5, _getObjectKey6;
219
- const paramName = data.node.argument.left.type === 'BinaryExpression' ? (_getObjectKey5 = (0, _migrateToVariants.getObjectKey)(data.node.argument.left.left)) == null ? void 0 : _getObjectKey5.name : (_getObjectKey6 = (0, _migrateToVariants.getObjectKey)(data.node.argument.left)) == null ? void 0 : _getObjectKey6.name;
213
+ const paramName = data.node.argument.left.type === 'BinaryExpression' ? (0, _migrateToVariants.getObjectKey)(data.node.argument.left.left)?.name : (0, _migrateToVariants.getObjectKey)(data.node.argument.left)?.name;
220
214
  if (paramName === 'theme' && data.node.argument.left.right.type === 'StringLiteral') {
221
215
  if (data.node.argument.right.type === 'ObjectExpression') {
222
216
  const mode = data.node.argument.left.right.value;
@@ -270,7 +264,7 @@ function sxV6(file, api, options) {
270
264
  }
271
265
  }
272
266
  if (data.node.argument.type === 'ConditionalExpression') {
273
- const isSxSpread = data.node.argument.consequent.type === 'Identifier' && data.node.argument.consequent.name === 'sx' || data.node.argument.alternate.type === 'Identifier' && data.node.argument.alternate.name === 'sx';
267
+ const isSxSpread = data.node.argument.test.type === 'CallExpression' && data.node.argument.test.callee.type === 'MemberExpression' && data.node.argument.test.callee.object.name === 'Array' && data.node.argument.test.callee.property.name === 'isArray' || data.node.argument.consequent.type === 'Identifier' && data.node.argument.consequent.name === 'sx' || data.node.argument.alternate.type === 'Identifier' && data.node.argument.alternate.name === 'sx';
274
268
  if (!isSxSpread) {
275
269
  recurseObjectExpression({
276
270
  ...data,
@@ -286,8 +280,7 @@ function sxV6(file, api, options) {
286
280
  }
287
281
  }
288
282
  if (data.node.argument.type === 'CallExpression') {
289
- var _getObjectKey7, _data$node$argument$c;
290
- if (((_getObjectKey7 = (0, _migrateToVariants.getObjectKey)(data.node.argument.callee)) == null ? void 0 : _getObjectKey7.name) === 'theme' && (_data$node$argument$c = data.node.argument.callee.property) != null && (_data$node$argument$c = _data$node$argument$c.name) != null && _data$node$argument$c.startsWith('apply')) {
283
+ if ((0, _migrateToVariants.getObjectKey)(data.node.argument.callee)?.name === 'theme' && data.node.argument.callee.property?.name?.startsWith('apply')) {
291
284
  const objIndex = data.node.argument.arguments.findIndex(arg => arg.type === 'ObjectExpression');
292
285
  recurseObjectExpression({
293
286
  ...data,
@@ -306,11 +299,9 @@ function sxV6(file, api, options) {
306
299
  }
307
300
  if (data.node.type === 'ConditionalExpression') {
308
301
  if (data.node.test.type === 'BinaryExpression' || data.node.test.type === 'UnaryExpression' || data.node.test.type === 'Identifier' || data.node.test.type === 'MemberExpression') {
309
- var _data$parentNode, _data$node$test, _data$node$test2;
310
- if (((_data$parentNode = data.parentNode) == null ? void 0 : _data$parentNode.type) === 'ObjectExpression' && (((_data$node$test = data.node.test) == null ? void 0 : _data$node$test.type) === 'BinaryExpression' || ((_data$node$test2 = data.node.test) == null ? void 0 : _data$node$test2.type) === 'Identifier')) {
302
+ if (data.parentNode?.type === 'ObjectExpression' && (data.node.test?.type === 'BinaryExpression' || data.node.test?.type === 'Identifier')) {
311
303
  if (data.node.consequent.type !== 'ObjectExpression' && data.node.alternate.type !== 'ObjectExpression') {
312
304
  if ((0, _migrateToVariants.isThemePaletteMode)(data.node.test.left)) {
313
- var _data$replaceValue2;
314
305
  const consequentKey = (0, _migrateToVariants.getObjectKey)(data.node.consequent);
315
306
  if (consequentKey.type === 'Identifier' && consequentKey.name !== 'theme') {
316
307
  const varName = getCssVarName(data.node.consequent);
@@ -329,11 +320,10 @@ function sxV6(file, api, options) {
329
320
  }
330
321
  data.modeStyles[data.node.test.right.value].push(j.objectProperty(data.key, replaceUndefined(data.node.consequent)));
331
322
  }
332
- (_data$replaceValue2 = data.replaceValue) == null || _data$replaceValue2.call(data, replaceUndefined(data.node.alternate));
323
+ data.replaceValue?.(replaceUndefined(data.node.alternate));
333
324
  rootThemeCallback(data);
334
325
  } else {
335
- var _data$buildStyle, _data$buildStyle2;
336
- wrapSxInArray(j.conditionalExpression(data.node.test, (_data$buildStyle = data.buildStyle) == null ? void 0 : _data$buildStyle.call(data, replaceUndefined(data.node.consequent)), (_data$buildStyle2 = data.buildStyle) == null ? void 0 : _data$buildStyle2.call(data, replaceUndefined(data.node.alternate))));
326
+ wrapSxInArray(j.conditionalExpression(data.node.test, data.buildStyle?.(replaceUndefined(data.node.consequent)), data.buildStyle?.(replaceUndefined(data.node.alternate))));
337
327
  if (data.deleteSelf) {
338
328
  data.deleteSelf();
339
329
  } else {
@@ -345,8 +335,7 @@ function sxV6(file, api, options) {
345
335
  }
346
336
  }
347
337
  if (data.node.type === 'TemplateLiteral') {
348
- var _data$parentNode2, _data$node$expression;
349
- if (((_data$parentNode2 = data.parentNode) == null ? void 0 : _data$parentNode2.type) === 'ObjectExpression') {
338
+ if (data.parentNode?.type === 'ObjectExpression') {
350
339
  const modeStyles = {};
351
340
  data.node.expressions.forEach((expression, index) => {
352
341
  if (expression.type === 'MemberExpression') {
@@ -384,15 +373,11 @@ function sxV6(file, api, options) {
384
373
  data.modeStyles[mode].push(j.objectProperty(data.key, clonedNode));
385
374
  });
386
375
  if (data.key) {
387
- var _data$replaceValue3;
388
- (_data$replaceValue3 = data.replaceValue) == null || _data$replaceValue3.call(data, data.node);
376
+ data.replaceValue?.(data.node);
389
377
  }
390
378
  }
391
379
  }
392
- if ((_data$node$expression = data.node.expressions) != null && _data$node$expression.some(expression => {
393
- var _getObjectKey8, _getObjectKey9;
394
- return ((_getObjectKey8 = (0, _migrateToVariants.getObjectKey)(expression)) == null ? void 0 : _getObjectKey8.name) === 'theme' || expression.type === 'CallExpression' && ((_getObjectKey9 = (0, _migrateToVariants.getObjectKey)(expression.callee)) == null ? void 0 : _getObjectKey9.name) === 'theme';
395
- })) {
380
+ if (data.node.expressions?.some(expression => (0, _migrateToVariants.getObjectKey)(expression)?.name === 'theme' || expression.type === 'CallExpression' && (0, _migrateToVariants.getObjectKey)(expression.callee)?.name === 'theme')) {
396
381
  rootThemeCallback(data);
397
382
  }
398
383
  }
@@ -409,8 +394,7 @@ function sxV6(file, api, options) {
409
394
  if (!isInStyled) {
410
395
  lines.push(line);
411
396
  } else if (line !== '') {
412
- var _line$match, _spaceMatch;
413
- if (spaceMatch && ((_line$match = line.match(/^\s+/)) == null ? void 0 : _line$match[0]) === ((_spaceMatch = spaceMatch) == null ? void 0 : _spaceMatch[0]) && line.endsWith('}')) {
397
+ if (spaceMatch && line.match(/^\s+/)?.[0] === spaceMatch?.[0] && line.endsWith('}')) {
414
398
  isInStyled = false;
415
399
  spaceMatch = null;
416
400
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  var _jsxRuntime = require("react/jsx-runtime");
4
4
  var _react = require("react");
5
- var _it$images$, _productOffer$ui, _productOffer$ui2;
6
5
  /*#__PURE__*/(0, _react.createElement)(Card, {
7
6
  ...otherProps,
8
7
  ref: ref,
@@ -56,7 +55,7 @@ var _it$images$, _productOffer$ui, _productOffer$ui2;
56
55
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ResponsiveImage, {
57
56
  sizes: imageSizes,
58
57
  loading: imageLoading,
59
- src: (_it$images$ = it.images[0]) == null ? void 0 : _it$images$.src,
58
+ src: it.images[0]?.src,
60
59
  alt: it.name,
61
60
  style: {
62
61
  aspectRatio: '100/55',
@@ -69,11 +68,11 @@ var _it$images$, _productOffer$ui, _productOffer$ui2;
69
68
  })
70
69
  }
71
70
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(NoSsr, {
72
- children: productOffer && ((_productOffer$ui = productOffer.ui) == null ? void 0 : _productOffer$ui.itemCard) && /*#__PURE__*/(0, _jsxRuntime.jsx)(PromoBanner, {
71
+ children: productOffer && productOffer.ui?.itemCard && /*#__PURE__*/(0, _jsxRuntime.jsx)(PromoBanner, {
73
72
  style: {
74
73
  ...defaultPromoCodeStyles,
75
74
  ...productOffer.style,
76
- ...((_productOffer$ui2 = productOffer.ui) == null || (_productOffer$ui2 = _productOffer$ui2.itemCard) == null ? void 0 : _productOffer$ui2.style)
75
+ ...productOffer.ui?.itemCard?.style
77
76
  },
78
77
  children: productOffer.offerText
79
78
  })
@@ -2,7 +2,6 @@
2
2
 
3
3
  var _jsxRuntime = require("react/jsx-runtime");
4
4
  var _react = require("react");
5
- var _it$images$, _productOffer$ui, _productOffer$ui2;
6
5
  /*#__PURE__*/(0, _react.createElement)(Card, {
7
6
  ...otherProps,
8
7
  ref: ref,
@@ -54,7 +53,7 @@ var _it$images$, _productOffer$ui, _productOffer$ui2;
54
53
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ResponsiveImage, {
55
54
  sizes: imageSizes,
56
55
  loading: imageLoading,
57
- src: (_it$images$ = it.images[0]) == null ? void 0 : _it$images$.src,
56
+ src: it.images[0]?.src,
58
57
  alt: it.name,
59
58
  style: {
60
59
  aspectRatio: '100/55',
@@ -67,11 +66,11 @@ var _it$images$, _productOffer$ui, _productOffer$ui2;
67
66
  })
68
67
  }
69
68
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(NoSsr, {
70
- children: productOffer && ((_productOffer$ui = productOffer.ui) == null ? void 0 : _productOffer$ui.itemCard) && /*#__PURE__*/(0, _jsxRuntime.jsx)(PromoBanner, {
69
+ children: productOffer && productOffer.ui?.itemCard && /*#__PURE__*/(0, _jsxRuntime.jsx)(PromoBanner, {
71
70
  style: {
72
71
  ...defaultPromoCodeStyles,
73
72
  ...productOffer.style,
74
- ...((_productOffer$ui2 = productOffer.ui) == null || (_productOffer$ui2 = _productOffer$ui2.itemCard) == null ? void 0 : _productOffer$ui2.style)
73
+ ...productOffer.ui?.itemCard?.style
75
74
  },
76
75
  children: productOffer.offerText
77
76
  })
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _jsxRuntime = require("react/jsx-runtime");
4
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, {
5
+ ...layoutProps,
6
+ ...slotProps.layout,
7
+ slots: slots,
8
+ slotProps: slotProps,
9
+ sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps.layout.sx])],
10
+ className: clsx(className, slotProps.layout.className),
11
+ ref: ref
12
+ });
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(FormControl, {
14
+ disabled: disabled,
15
+ id: id,
16
+ sx: [...(Array.isArray(formControlSx) ? formControlSx : [formControlSx])]
17
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _jsxRuntime = require("react/jsx-runtime");
4
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, {
5
+ ...layoutProps,
6
+ ...slotProps.layout,
7
+ slots: slots,
8
+ slotProps: slotProps,
9
+ sx: [...(Array.isArray(sx) ? sx : [sx]), ...(Array.isArray(slotProps?.layout?.sx) ? slotProps.layout.sx : [slotProps.layout.sx])],
10
+ className: clsx(className, slotProps.layout.className),
11
+ ref: ref
12
+ });
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(FormControl, {
14
+ disabled: disabled,
15
+ id: id,
16
+ sx: [...(Array.isArray(formControlSx) ? formControlSx : [formControlSx])]
17
+ });
@@ -134,8 +134,7 @@ const components = ['Box', 'Stack', 'Typography', 'Link', 'Grid'];
134
134
  * @param {import('jscodeshift').API} api
135
135
  */
136
136
  function removeSystemProps(file, api, options) {
137
- var _file$path, _file$path2;
138
- if ((_file$path = file.path) != null && _file$path.endsWith('.json') || (_file$path2 = file.path) != null && _file$path2.endsWith('.d.ts')) {
137
+ if (file.path?.endsWith('.json') || file.path?.endsWith('.d.ts')) {
139
138
  return file.source;
140
139
  }
141
140
  const j = api.jscodeshift;
@@ -144,10 +143,7 @@ function removeSystemProps(file, api, options) {
144
143
  const deprecatedElements = [];
145
144
  const customReplacement = {
146
145
  Typography: {
147
- matcher: (key, val) => {
148
- var _val$value;
149
- return key !== 'color' || ((_val$value = val.value) == null ? void 0 : _val$value.includes('.')) && val.value !== 'inherit' || val.value === 'divider';
150
- }
146
+ matcher: (key, val) => key !== 'color' || val.value?.includes('.') && val.value !== 'inherit' || val.value === 'divider'
151
147
  },
152
148
  Link: {
153
149
  matcher: key => key !== 'color'
@@ -181,12 +177,11 @@ function removeSystemProps(file, api, options) {
181
177
  }
182
178
  }
183
179
  }).forEach(el => {
184
- var _el$value, _sxNodesArray$;
185
180
  const sx = j.objectExpression([]);
186
- const elementName = (_el$value = el.value) == null || (_el$value = _el$value.openingElement) == null || (_el$value = _el$value.name) == null ? void 0 : _el$value.name;
181
+ const elementName = el.value?.openingElement?.name?.name;
187
182
  const sxNodes = j(el).find(j.JSXAttribute).filter(path => path.parent.parent.node === el.node && path.node.name.name === 'sx');
188
183
  const sxNodesArray = sxNodes.nodes() || [];
189
- const existingSxValue = (_sxNodesArray$ = sxNodesArray[0]) == null || (_sxNodesArray$ = _sxNodesArray$.value) == null ? void 0 : _sxNodesArray$.expression;
184
+ const existingSxValue = sxNodesArray[0]?.value?.expression;
190
185
  let spreadElement = null;
191
186
  el.node.openingElement.attributes.forEach(attr => {
192
187
  if (attr.type === 'JSXSpreadAttribute') {
@@ -195,12 +190,11 @@ function removeSystemProps(file, api, options) {
195
190
  });
196
191
  const attrToPrune = ['sx'];
197
192
  el.node.openingElement.attributes.forEach(attr => {
198
- var _attr$name, _attr$name2;
199
- if (attr.type === 'JSXSpreadAttribute' || !attr.value || !systemProps.includes(attr == null || (_attr$name = attr.name) == null ? void 0 : _attr$name.name)) {
193
+ if (attr.type === 'JSXSpreadAttribute' || !attr.value || !systemProps.includes(attr?.name?.name)) {
200
194
  return;
201
195
  }
202
- const key = attr == null || (_attr$name2 = attr.name) == null ? void 0 : _attr$name2.name;
203
- const literal = attr == null ? void 0 : attr.value;
196
+ const key = attr?.name?.name;
197
+ const literal = attr?.value;
204
198
  const val = literal.type === 'JSXExpressionContainer' ? literal.expression : literal;
205
199
  const shouldPrune = !elementReplacement[elementName] || elementReplacement[elementName].matcher(key, val);
206
200
  if (key && val) {
@@ -211,17 +205,14 @@ function removeSystemProps(file, api, options) {
211
205
  }
212
206
  });
213
207
  if (sx.properties.length) {
214
- el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => {
215
- var _attr$name3;
216
- return attr.type !== 'JSXAttribute' || !attrToPrune.includes(attr == null || (_attr$name3 = attr.name) == null ? void 0 : _attr$name3.name);
217
- });
208
+ el.node.openingElement.attributes = el.node.openingElement.attributes.filter(attr => attr.type !== 'JSXAttribute' || !attrToPrune.includes(attr?.name?.name));
218
209
  let finalSx;
219
210
  if (!existingSxValue) {
220
211
  finalSx = sx;
221
- } else if ((existingSxValue == null ? void 0 : existingSxValue.type) === 'ObjectExpression') {
212
+ } else if (existingSxValue?.type === 'ObjectExpression') {
222
213
  sx.properties.push(...existingSxValue.properties);
223
214
  finalSx = sx;
224
- } else if ((existingSxValue == null ? void 0 : existingSxValue.type) === 'ArrayExpression') {
215
+ } else if (existingSxValue?.type === 'ArrayExpression') {
225
216
  existingSxValue.elements = [sx, ...existingSxValue.elements];
226
217
  finalSx = existingSxValue;
227
218
  } else {