@mui/codemod 6.0.0-alpha.10 → 6.0.0-alpha.11

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/codemod.js CHANGED
@@ -23,7 +23,6 @@ async function runJscodeshiftTransform(transform, files, flags, codemodFlags) {
23
23
 
24
24
  let transformerPath;
25
25
  let error;
26
- // eslint-disable-next-line no-restricted-syntax
27
26
  for (const item of paths) {
28
27
  try {
29
28
  // eslint-disable-next-line no-await-in-loop
@@ -113,7 +112,6 @@ async function runPostcssTransform(transform, files) {
113
112
 
114
113
  let configPath;
115
114
  let error;
116
- // eslint-disable-next-line no-restricted-syntax
117
115
  for (const item of paths) {
118
116
  try {
119
117
  // eslint-disable-next-line no-await-in-loop
@@ -163,6 +163,11 @@ function migrateToVariants(j, styles) {
163
163
  const buildArrowFunctionAST = getBuildArrowFunctionAST(j);
164
164
  const objectToArrowFunction = getObjectToArrowFunction(j);
165
165
 
166
+ /**
167
+ * A map of used variable with its original name
168
+ */
169
+ const parameterMap = {};
170
+
166
171
  /**
167
172
  *
168
173
  * @param {import('jscodeshift').Identifier | import('jscodeshift').BinaryExpression | import('jscodeshift').UnaryExpression | import('jscodeshift').MemberExpression} node
@@ -199,6 +204,21 @@ function migrateToVariants(j, styles) {
199
204
  });
200
205
  return result;
201
206
  }
207
+ function resolveParamName(name) {
208
+ if (typeof name !== 'string') {
209
+ if (name.type === 'Identifier' && parameterMap[name.name]) {
210
+ if (parameterMap[name.name].includes('-')) {
211
+ return j.stringLiteral(parameterMap[name.name]);
212
+ }
213
+ return {
214
+ ...name,
215
+ name: parameterMap[name.name]
216
+ };
217
+ }
218
+ return name;
219
+ }
220
+ return parameterMap[name] || name;
221
+ }
202
222
 
203
223
  /**
204
224
  *
@@ -213,25 +233,25 @@ function migrateToVariants(j, styles) {
213
233
  };
214
234
  function assignProperties(_node) {
215
235
  if (_node.type === 'BinaryExpression') {
216
- variables.add(getObjectKey(_node.left).name);
236
+ variables.add(resolveParamName(getObjectKey(_node.left).name));
217
237
  if (_node.operator === '===') {
218
- properties.push(j.objectProperty(getIdentifierKey(_node.left), _node.right));
238
+ properties.push(j.objectProperty(resolveParamName(getIdentifierKey(_node.left)), _node.right));
219
239
  } else {
220
240
  isAllEqual = false;
221
241
  }
222
242
  }
223
243
  if (_node.type === 'MemberExpression' || _node.type === 'Identifier') {
224
244
  isAllEqual = false;
225
- variables.add(getObjectKey(_node).name);
245
+ variables.add(resolveParamName(getObjectKey(_node).name));
226
246
  }
227
247
  if (_node.type === 'UnaryExpression') {
228
248
  isAllEqual = false;
229
249
  if (_node.argument.type === 'UnaryExpression') {
230
250
  // handle `!!variable`
231
- variables.add(getObjectKey(_node.argument.argument).name);
251
+ variables.add(resolveParamName(getObjectKey(_node.argument.argument).name));
232
252
  } else {
233
253
  // handle `!variable`
234
- variables.add(getObjectKey(_node.argument).name);
254
+ variables.add(resolveParamName(getObjectKey(_node.argument).name));
235
255
  }
236
256
  }
237
257
  }
@@ -267,7 +287,7 @@ function migrateToVariants(j, styles) {
267
287
  const currentArrow = currentProps.type === 'ObjectExpression' ? objectToArrowFunction(currentProps) : currentProps;
268
288
  const variables = new Set();
269
289
  [...parentArrow.params[0].properties, ...currentArrow.params[0].properties].forEach(param => {
270
- variables.add(param.key.name);
290
+ variables.add(resolveParamName(param.key.name));
271
291
  });
272
292
  return buildArrowFunctionAST(variables, j.logicalExpression('&&', parentArrow.body, currentArrow.body));
273
293
  }
@@ -278,7 +298,24 @@ function migrateToVariants(j, styles) {
278
298
  style.params.forEach(param => {
279
299
  if (param.type === 'ObjectPattern') {
280
300
  param.properties.forEach(prop => {
281
- parameters.add(prop.key.name);
301
+ if (prop.type === 'ObjectProperty') {
302
+ let paramName;
303
+ if (prop.value.type === 'Identifier') {
304
+ paramName = prop.value.name;
305
+ }
306
+ if (prop.value.type === 'AssignmentPattern') {
307
+ paramName = prop.value.left.name;
308
+ }
309
+ if (paramName) {
310
+ parameters.add(paramName);
311
+ if (prop.key.type === 'Identifier') {
312
+ parameterMap[paramName] = prop.key.name;
313
+ }
314
+ if (prop.key.type === 'StringLiteral') {
315
+ parameterMap[paramName] = prop.key.value;
316
+ }
317
+ }
318
+ }
282
319
  });
283
320
  }
284
321
  if (param.type === 'Identifier') {
@@ -25,4 +25,34 @@ const ToolbarRoot = styled('div', {
25
25
  disabled
26
26
  }) => ownerState.variant !== 'regular' && !disabled && theme.mixins.toolbar4, ({
27
27
  theme
28
- }) => theme.vars && theme.mixins.toolbar5);
28
+ }) => theme.vars && theme.mixins.toolbar5);
29
+ const ToggleButton = styled('button')(({
30
+ theme,
31
+ 'aria-pressed': pressed = 'false'
32
+ }) => ({
33
+ padding: '0.5rem 1rem',
34
+ borderRadius: theme.vars.radius.sm,
35
+ display: 'inline-flex',
36
+ justifyContent: 'center',
37
+ gap: '8px',
38
+ minHeight: 40,
39
+ fontFamily: theme.vars.fontFamily.body,
40
+ fontSize: theme.vars.fontSize.md,
41
+ fontWeight: theme.vars.fontWeight.md,
42
+ alignItems: 'center',
43
+ border: '1px solid',
44
+ borderColor: theme.vars.palette.neutral.outlinedBorder,
45
+ backgroundColor: theme.vars.palette.background.body,
46
+ boxShadow: theme.vars.shadow.md,
47
+ [theme.focus.selector]: theme.focus.default,
48
+ ...theme.variants.plain.neutral,
49
+ ...(pressed === 'false' && {
50
+ '&:hover': theme.variants.plainHover.neutral,
51
+ '&:active': theme.variants.plainActive.neutral
52
+ }),
53
+ ...(pressed === 'true' && {
54
+ color: theme.vars.palette.danger.plainColor,
55
+ backgroundColor: theme.vars.palette.background.body,
56
+ boxShadow: theme.shadow.sm.replace(/,/g, ', inset')
57
+ })
58
+ }));
@@ -49,4 +49,42 @@ const ToolbarRoot = styled('div', {
49
49
  }]
50
50
  }), ({
51
51
  theme
52
- }) => theme.vars && theme.mixins.toolbar5);
52
+ }) => theme.vars && theme.mixins.toolbar5);
53
+ const ToggleButton = styled('button')(({
54
+ theme
55
+ }) => ({
56
+ padding: '0.5rem 1rem',
57
+ borderRadius: theme.vars.radius.sm,
58
+ display: 'inline-flex',
59
+ justifyContent: 'center',
60
+ gap: '8px',
61
+ minHeight: 40,
62
+ fontFamily: theme.vars.fontFamily.body,
63
+ fontSize: theme.vars.fontSize.md,
64
+ fontWeight: theme.vars.fontWeight.md,
65
+ alignItems: 'center',
66
+ border: '1px solid',
67
+ borderColor: theme.vars.palette.neutral.outlinedBorder,
68
+ backgroundColor: theme.vars.palette.background.body,
69
+ boxShadow: theme.vars.shadow.md,
70
+ [theme.focus.selector]: theme.focus.default,
71
+ ...theme.variants.plain.neutral,
72
+ variants: [{
73
+ props: {
74
+ "aria-pressed": 'false'
75
+ },
76
+ style: {
77
+ '&:hover': theme.variants.plainHover.neutral,
78
+ '&:active': theme.variants.plainActive.neutral
79
+ }
80
+ }, {
81
+ props: {
82
+ "aria-pressed": 'true'
83
+ },
84
+ style: {
85
+ color: theme.vars.palette.danger.plainColor,
86
+ backgroundColor: theme.vars.palette.background.body,
87
+ boxShadow: theme.shadow.sm.replace(/,/g, ', inset')
88
+ }
89
+ }]
90
+ }));
@@ -12,14 +12,18 @@ var _migrateToVariants = require("../../util/migrateToVariants");
12
12
  * @param {import('jscodeshift').MemberExpression | import('jscodeshift').Identifier} node
13
13
  */
14
14
  function getCssVarName(node) {
15
- if (node.type === 'MemberExpression') {
16
- var _getObjectKey;
17
- return `--${(_getObjectKey = (0, _migrateToVariants.getObjectKey)(node)) == null ? void 0 : _getObjectKey.name}-${node.property.name}`;
18
- }
19
- if (node.type === 'Identifier') {
20
- return `--${node.name}`;
15
+ let varName = '-';
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'}`;
19
+ if (node.object.type === 'MemberExpression') {
20
+ node = node.object;
21
+ } else {
22
+ node = node.property;
23
+ }
21
24
  }
22
- return '';
25
+ varName += `-${node.name || 'unknown'}`;
26
+ return varName;
23
27
  }
24
28
 
25
29
  /**
@@ -112,6 +116,18 @@ function sxV6(file, api, options) {
112
116
  conditionalExpressions.push([currentIndex, newElement]);
113
117
  }
114
118
  }
119
+ function rootThemeCallback(data) {
120
+ 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));
123
+ } else if (data.root.type === 'ArrayExpression') {
124
+ data.root.elements.forEach((item, index) => {
125
+ if (item === data.node) {
126
+ data.root.elements[index] = buildArrowFunctionAST([j.identifier('theme')], data.root);
127
+ }
128
+ });
129
+ }
130
+ }
115
131
 
116
132
  /**
117
133
  *
@@ -121,10 +137,47 @@ function sxV6(file, api, options) {
121
137
  if (data.node.type === 'ArrowFunctionExpression') {
122
138
  const returnExpression = (0, _getReturnExpression.default)(data.node);
123
139
  if (returnExpression) {
124
- recurseObjectExpression({
125
- ...data,
126
- node: returnExpression
127
- });
140
+ var _returnExpression$pro, _getObjectKey, _getObjectKey2, _getObjectKey3, _getObjectKey4;
141
+ if (returnExpression.type === 'MemberExpression' && ((_returnExpression$pro = returnExpression.property) == null ? void 0 : _returnExpression$pro.type) === 'ConditionalExpression') {
142
+ recurseObjectExpression({
143
+ ...data,
144
+ node: j.conditionalExpression(returnExpression.property.test, {
145
+ ...returnExpression,
146
+ property: returnExpression.property.consequent
147
+ }, {
148
+ ...returnExpression,
149
+ property: returnExpression.property.alternate
150
+ })
151
+ });
152
+ } else if (returnExpression.type === 'TemplateLiteral') {
153
+ const firstExpression = returnExpression.expressions[0];
154
+ if ((firstExpression == null ? void 0 : firstExpression.type) === 'ConditionalExpression') {
155
+ recurseObjectExpression({
156
+ ...data,
157
+ node: j.conditionalExpression(firstExpression.test, {
158
+ ...returnExpression,
159
+ expressions: [firstExpression.consequent, ...(returnExpression.expressions || []).slice(1)]
160
+ }, {
161
+ ...returnExpression,
162
+ expressions: [firstExpression.alternate, ...(returnExpression.expressions || []).slice(1)]
163
+ })
164
+ });
165
+ } else {
166
+ recurseObjectExpression({
167
+ ...data,
168
+ node: returnExpression
169
+ });
170
+ }
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);
174
+ rootThemeCallback(data);
175
+ } else {
176
+ recurseObjectExpression({
177
+ ...data,
178
+ node: returnExpression
179
+ });
180
+ }
128
181
  }
129
182
  }
130
183
  if (data.node.type === 'ObjectExpression') {
@@ -162,8 +215,8 @@ function sxV6(file, api, options) {
162
215
  }
163
216
  if (data.node.type === 'SpreadElement') {
164
217
  if (data.node.argument.type === 'LogicalExpression') {
165
- var _getObjectKey2, _getObjectKey3;
166
- const paramName = data.node.argument.left.type === 'BinaryExpression' ? (_getObjectKey2 = (0, _migrateToVariants.getObjectKey)(data.node.argument.left.left)) == null ? void 0 : _getObjectKey2.name : (_getObjectKey3 = (0, _migrateToVariants.getObjectKey)(data.node.argument.left)) == null ? void 0 : _getObjectKey3.name;
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;
167
220
  if (paramName === 'theme' && data.node.argument.left.right.type === 'StringLiteral') {
168
221
  if (data.node.argument.right.type === 'ObjectExpression') {
169
222
  const mode = data.node.argument.left.right.value;
@@ -209,7 +262,7 @@ function sxV6(file, api, options) {
209
262
  }
210
263
  });
211
264
  }
212
- wrapSxInArray(j.logicalExpression(data.node.argument.operator, data.node.argument.left, data.node.argument.right));
265
+ wrapSxInArray(j.logicalExpression(data.node.argument.operator, data.node.argument.left, data.buildStyle(data.node.argument.right)));
213
266
  if (data.deleteSelf) {
214
267
  data.deleteSelf();
215
268
  } else {
@@ -235,7 +288,7 @@ function sxV6(file, api, options) {
235
288
  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')) {
236
289
  if (data.node.consequent.type !== 'ObjectExpression' && data.node.alternate.type !== 'ObjectExpression') {
237
290
  if ((0, _migrateToVariants.isThemePaletteMode)(data.node.test.left)) {
238
- var _data$replaceValue;
291
+ var _data$replaceValue2;
239
292
  const consequentKey = (0, _migrateToVariants.getObjectKey)(data.node.consequent);
240
293
  if (consequentKey.type === 'Identifier' && consequentKey.name !== 'theme') {
241
294
  const varName = getCssVarName(data.node.consequent);
@@ -254,17 +307,8 @@ function sxV6(file, api, options) {
254
307
  }
255
308
  data.modeStyles[data.node.test.right.value].push(j.objectProperty(data.key, replaceUndefined(data.node.consequent)));
256
309
  }
257
- (_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, replaceUndefined(data.node.alternate));
258
- if (data.root.type === 'ObjectExpression') {
259
- var _data$replaceRoot;
260
- (_data$replaceRoot = data.replaceRoot) == null || _data$replaceRoot.call(data, buildArrowFunctionAST([j.identifier('theme')], data.root));
261
- } else if (data.root.type === 'ArrayExpression') {
262
- data.root.elements.forEach((item, index) => {
263
- if (item === data.node) {
264
- data.root.elements[index] = buildArrowFunctionAST([j.identifier('theme')], data.root);
265
- }
266
- });
267
- }
310
+ (_data$replaceValue2 = data.replaceValue) == null || _data$replaceValue2.call(data, replaceUndefined(data.node.alternate));
311
+ rootThemeCallback(data);
268
312
  } else {
269
313
  var _data$buildStyle, _data$buildStyle2;
270
314
  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))));
@@ -279,7 +323,7 @@ function sxV6(file, api, options) {
279
323
  }
280
324
  }
281
325
  if (data.node.type === 'TemplateLiteral') {
282
- var _data$parentNode2;
326
+ var _data$parentNode2, _data$node$expression;
283
327
  if (((_data$parentNode2 = data.parentNode) == null ? void 0 : _data$parentNode2.type) === 'ObjectExpression') {
284
328
  const modeStyles = {};
285
329
  data.node.expressions.forEach((expression, index) => {
@@ -318,11 +362,17 @@ function sxV6(file, api, options) {
318
362
  data.modeStyles[mode].push(j.objectProperty(data.key, clonedNode));
319
363
  });
320
364
  if (data.key) {
321
- var _data$replaceValue2;
322
- (_data$replaceValue2 = data.replaceValue) == null || _data$replaceValue2.call(data, data.node);
365
+ var _data$replaceValue3;
366
+ (_data$replaceValue3 = data.replaceValue) == null || _data$replaceValue3.call(data, data.node);
323
367
  }
324
368
  }
325
369
  }
370
+ if ((_data$node$expression = data.node.expressions) != null && _data$node$expression.some(expression => {
371
+ var _getObjectKey7, _getObjectKey8;
372
+ return ((_getObjectKey7 = (0, _migrateToVariants.getObjectKey)(expression)) == null ? void 0 : _getObjectKey7.name) === 'theme' || expression.type === 'CallExpression' && ((_getObjectKey8 = (0, _migrateToVariants.getObjectKey)(expression.callee)) == null ? void 0 : _getObjectKey8.name) === 'theme';
373
+ })) {
374
+ rootThemeCallback(data);
375
+ }
326
376
  }
327
377
  }
328
378
  });
@@ -344,7 +394,7 @@ function sxV6(file, api, options) {
344
394
  }
345
395
  lines.push(line);
346
396
  }
347
- if (line.includes('sx=')) {
397
+ if (line.includes('sx=') && !line.match(/sx=\{\{[^}]+\}\}/)) {
348
398
  isInStyled = true;
349
399
  spaceMatch = line.match(/^\s+/);
350
400
  }
@@ -38,4 +38,18 @@ var _jsxRuntime = require("react/jsx-runtime");
38
38
  backgroundPosition: 'center',
39
39
  backgroundImage: `url(${post.image})`
40
40
  }
41
+ });
42
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Chip, {
43
+ size: "sm",
44
+ variant: "outlined",
45
+ color: colors[data.role],
46
+ sx: {
47
+ ml: 'auto',
48
+ borderRadius: '2px',
49
+ minHeight: '20px',
50
+ paddingInline: '4px',
51
+ fontSize: 'xs',
52
+ bgcolor: `${colors[data.role]}.softBg`
53
+ },
54
+ children: data.role
41
55
  });
@@ -3,54 +3,54 @@
3
3
  var _jsxRuntime = require("react/jsx-runtime");
4
4
  /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
5
5
  sx: theme => ({
6
- backgroundImage: "var(--items-imageDark)",
6
+ backgroundImage: "var(--imageDark-items-selectedItemIndex)",
7
7
  ...theme.applyStyles("light", {
8
- backgroundImage: "var(--items-imageLight)"
8
+ backgroundImage: "var(--imageLight-items-selectedItemIndex)"
9
9
  })
10
10
  }),
11
11
  style: {
12
- "--items-imageLight": items[selectedItemIndex].imageLight,
13
- "--items-imageDark": items[selectedItemIndex].imageDark
12
+ "--imageLight-items-selectedItemIndex": items[selectedItemIndex].imageLight,
13
+ "--imageDark-items-selectedItemIndex": items[selectedItemIndex].imageDark
14
14
  }
15
15
  });
16
16
  /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
17
17
  style: {
18
- "--items-imageLight": items[selectedItemIndex].imageLight,
19
- "--items-imageDark": items[selectedItemIndex].imageDark,
18
+ "--imageLight-items-selectedItemIndex": items[selectedItemIndex].imageLight,
19
+ "--imageDark-items-selectedItemIndex": items[selectedItemIndex].imageDark,
20
20
  ...props.style
21
21
  },
22
22
  sx: theme => ({
23
- backgroundImage: "var(--items-imageDark)",
23
+ backgroundImage: "var(--imageDark-items-selectedItemIndex)",
24
24
  ...theme.applyStyles("light", {
25
- backgroundImage: "var(--items-imageLight)"
25
+ backgroundImage: "var(--imageLight-items-selectedItemIndex)"
26
26
  })
27
27
  })
28
28
  });
29
29
  /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
30
30
  style: {
31
- "--items-imageLight": items[selectedItemIndex].imageLight,
32
- "--items-imageDark": items[selectedItemIndex].imageDark,
31
+ "--imageLight-items-selectedItemIndex": items[selectedItemIndex].imageLight,
32
+ "--imageDark-items-selectedItemIndex": items[selectedItemIndex].imageDark,
33
33
  color: 'red',
34
34
  ...props.style
35
35
  },
36
36
  sx: theme => ({
37
- backgroundImage: "var(--items-imageDark)",
37
+ backgroundImage: "var(--imageDark-items-selectedItemIndex)",
38
38
  ...theme.applyStyles("light", {
39
- backgroundImage: "var(--items-imageLight)"
39
+ backgroundImage: "var(--imageLight-items-selectedItemIndex)"
40
40
  })
41
41
  })
42
42
  });
43
43
  /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
44
44
  ...props,
45
45
  sx: theme => ({
46
- backgroundImage: "var(--items-imageDark)",
46
+ backgroundImage: "var(--imageDark-items-selectedItemIndex)",
47
47
  ...theme.applyStyles("light", {
48
- backgroundImage: "var(--items-imageLight)"
48
+ backgroundImage: "var(--imageLight-items-selectedItemIndex)"
49
49
  })
50
50
  }),
51
51
  style: {
52
- "--items-imageLight": items[selectedItemIndex].imageLight,
53
- "--items-imageDark": items[selectedItemIndex].imageDark,
52
+ "--imageLight-items-selectedItemIndex": items[selectedItemIndex].imageLight,
53
+ "--imageDark-items-selectedItemIndex": items[selectedItemIndex].imageDark,
54
54
  ...props.style
55
55
  }
56
56
  });
@@ -68,4 +68,21 @@ var _jsxRuntime = require("react/jsx-runtime");
68
68
  style: {
69
69
  "--post-image": post.image
70
70
  }
71
+ });
72
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Chip, {
73
+ size: "sm",
74
+ variant: "outlined",
75
+ color: colors[data.role],
76
+ sx: {
77
+ ml: 'auto',
78
+ borderRadius: '2px',
79
+ minHeight: '20px',
80
+ paddingInline: '4px',
81
+ fontSize: 'xs',
82
+ bgcolor: `${"var(--colors-data-role)"}.softBg`
83
+ },
84
+ style: {
85
+ "--colors-data-role": colors[data.role]
86
+ },
87
+ children: data.role
71
88
  });
@@ -84,4 +84,24 @@ var _jsxRuntime = require("react/jsx-runtime");
84
84
  display: 'none'
85
85
  })
86
86
  }]
87
- });
87
+ });
88
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Step, {
89
+ indicator: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepIndicator, {
90
+ variant: activeStep <= index ? 'soft' : 'solid',
91
+ color: activeStep < index ? 'neutral' : 'primary',
92
+ children: activeStep <= index ? index + 1 : /*#__PURE__*/(0, _jsxRuntime.jsx)(Check, {})
93
+ }),
94
+ sx: {
95
+ '&:not([data-active])': {
96
+ '&::after': {
97
+ ...(activeStep > index && index !== 2 && {
98
+ bgcolor: 'primary.solidBg'
99
+ })
100
+ }
101
+ }
102
+ },
103
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepButton, {
104
+ onClick: () => setActiveStep(index),
105
+ children: step
106
+ })
107
+ }, step);
@@ -99,4 +99,22 @@ var _jsxRuntime = require("react/jsx-runtime");
99
99
  }, open && {
100
100
  display: 'none'
101
101
  }]
102
- });
102
+ });
103
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Step, {
104
+ indicator: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepIndicator, {
105
+ variant: activeStep <= index ? 'soft' : 'solid',
106
+ color: activeStep < index ? 'neutral' : 'primary',
107
+ children: activeStep <= index ? index + 1 : /*#__PURE__*/(0, _jsxRuntime.jsx)(Check, {})
108
+ }),
109
+ sx: [activeStep > index && index !== 2 && {
110
+ '&:not([data-active])': {
111
+ '&::after': {
112
+ bgcolor: 'primary.solidBg'
113
+ }
114
+ }
115
+ }],
116
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepButton, {
117
+ onClick: () => setActiveStep(index),
118
+ children: step
119
+ })
120
+ }, step);
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = EnableColorOnDarkAppBar;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _AppBar = _interopRequireDefault(require("@mui/material/AppBar"));
10
+ var _Stack = _interopRequireDefault(require("@mui/material/Stack"));
11
+ var _Toolbar = _interopRequireDefault(require("@mui/material/Toolbar"));
12
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
14
+ var _Menu = _interopRequireDefault(require("@mui/icons-material/Menu"));
15
+ var _styles = require("@mui/material/styles");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ var _MenuIcon;
18
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
+ function appBarLabel(label) {
21
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Toolbar.default, {
22
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
23
+ edge: "start",
24
+ color: "inherit",
25
+ "aria-label": "menu",
26
+ sx: {
27
+ mr: 2
28
+ },
29
+ children: _MenuIcon || (_MenuIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {}))
30
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
31
+ variant: "h6",
32
+ noWrap: true,
33
+ component: "div",
34
+ sx: {
35
+ flexGrow: 1
36
+ },
37
+ children: label
38
+ })]
39
+ });
40
+ }
41
+ const darkTheme = (0, _styles.createTheme)({
42
+ palette: {
43
+ mode: 'dark',
44
+ primary: {
45
+ main: '#1976d2'
46
+ }
47
+ }
48
+ });
49
+ function EnableColorOnDarkAppBar() {
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Stack.default, {
51
+ spacing: 2,
52
+ sx: {
53
+ flexGrow: 1
54
+ },
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.ThemeProvider, {
56
+ theme: darkTheme,
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AppBar.default, {
58
+ position: "static",
59
+ color: "primary",
60
+ enableColorOnDark: true,
61
+ children: appBarLabel('enableColorOnDark')
62
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppBar.default, {
63
+ position: "static",
64
+ color: "primary",
65
+ children: appBarLabel('default')
66
+ })]
67
+ })
68
+ });
69
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = EnableColorOnDarkAppBar;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _AppBar = _interopRequireDefault(require("@mui/material/AppBar"));
10
+ var _Stack = _interopRequireDefault(require("@mui/material/Stack"));
11
+ var _Toolbar = _interopRequireDefault(require("@mui/material/Toolbar"));
12
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
14
+ var _Menu = _interopRequireDefault(require("@mui/icons-material/Menu"));
15
+ var _styles = require("@mui/material/styles");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ var _MenuIcon;
18
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
+ function appBarLabel(label) {
21
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Toolbar.default, {
22
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
23
+ edge: "start",
24
+ color: "inherit",
25
+ "aria-label": "menu",
26
+ sx: {
27
+ mr: 2
28
+ },
29
+ children: _MenuIcon || (_MenuIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {}))
30
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
31
+ variant: "h6",
32
+ noWrap: true,
33
+ component: "div",
34
+ sx: {
35
+ flexGrow: 1
36
+ },
37
+ children: label
38
+ })]
39
+ });
40
+ }
41
+ const darkTheme = (0, _styles.createTheme)({
42
+ palette: {
43
+ mode: 'dark',
44
+ primary: {
45
+ main: '#1976d2'
46
+ }
47
+ }
48
+ });
49
+ function EnableColorOnDarkAppBar() {
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Stack.default, {
51
+ spacing: 2,
52
+ sx: {
53
+ flexGrow: 1
54
+ },
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.ThemeProvider, {
56
+ theme: darkTheme,
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AppBar.default, {
58
+ position: "static",
59
+ color: "primary",
60
+ enableColorOnDark: true,
61
+ children: appBarLabel('enableColorOnDark')
62
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AppBar.default, {
63
+ position: "static",
64
+ color: "primary",
65
+ children: appBarLabel('default')
66
+ })]
67
+ })
68
+ });
69
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ var _jsxRuntime = require("react/jsx-runtime");
4
+ function FacebookCircularProgress(props) {
5
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Box, {
6
+ sx: {
7
+ position: 'relative'
8
+ },
9
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
10
+ variant: "determinate",
11
+ sx: {
12
+ color: theme => theme.palette.grey[theme.palette.mode === 'light' ? 200 : 800]
13
+ },
14
+ size: 40,
15
+ thickness: 4,
16
+ ...props,
17
+ value: 100
18
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
19
+ variant: "indeterminate",
20
+ disableShrink: true,
21
+ sx: {
22
+ color: theme => theme.palette.mode === 'light' ? '#1a90ff' : '#308fe8',
23
+ animationDuration: '550ms',
24
+ position: 'absolute',
25
+ left: 0,
26
+ [`& .${circularProgressClasses.circle}`]: {
27
+ strokeLinecap: 'round'
28
+ }
29
+ },
30
+ size: 40,
31
+ thickness: 4,
32
+ ...props
33
+ })]
34
+ });
35
+ }
36
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Paper, {
37
+ elevation: 0,
38
+ sx: {
39
+ display: 'flex',
40
+ border: theme => `1px solid ${theme.palette.divider}`,
41
+ flexWrap: 'wrap'
42
+ }
43
+ });
44
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Divider, {
45
+ sx: {
46
+ border: theme => `1px solid ${theme.palette.mode === 'dark' ? '#fff' : '#000'}`
47
+ }
48
+ });
49
+ /*#__PURE__*/(0, _jsxRuntime.jsxs)(Typography, {
50
+ component: "span",
51
+ variant: "subtitle1",
52
+ color: "inherit",
53
+ sx: {
54
+ position: 'relative',
55
+ p: 4,
56
+ pt: 2,
57
+ pb: theme => `calc(${theme.spacing(1)} + 6px)`
58
+ },
59
+ children: [image.title, /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageMarked, {
60
+ className: "MuiImageMarked-root"
61
+ })]
62
+ });
63
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Autocomplete, {
64
+ sx: {
65
+ display: 'inline-block',
66
+ '& input': {
67
+ width: 200,
68
+ bgcolor: 'background.paper',
69
+ color: theme => theme.palette.getContrastText(theme.palette.background.paper)
70
+ }
71
+ },
72
+ id: "custom-input-demo",
73
+ options: options,
74
+ renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
75
+ ref: params.InputProps.ref,
76
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
77
+ type: "text",
78
+ ...params.inputProps
79
+ })
80
+ })
81
+ });
82
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
83
+ sx: {
84
+ position: 'relative',
85
+ width: 400,
86
+ bgcolor: 'background.paper',
87
+ border: '2px solid #000',
88
+ boxShadow: theme => theme.shadows[5],
89
+ p: 4
90
+ }
91
+ });
92
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Backdrop, {
93
+ sx: {
94
+ color: '#fff',
95
+ zIndex: theme => theme.zIndex.drawer + 1
96
+ },
97
+ open: open,
98
+ onClick: handleClose,
99
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
100
+ color: "inherit"
101
+ })
102
+ });
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ var _jsxRuntime = require("react/jsx-runtime");
4
+ function FacebookCircularProgress(props) {
5
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Box, {
6
+ sx: {
7
+ position: 'relative'
8
+ },
9
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
10
+ variant: "determinate",
11
+ sx: theme => ({
12
+ color: theme.palette.grey[800],
13
+ ...theme.applyStyles("light", {
14
+ color: theme.palette.grey[200]
15
+ })
16
+ }),
17
+ size: 40,
18
+ thickness: 4,
19
+ ...props,
20
+ value: 100
21
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
22
+ variant: "indeterminate",
23
+ disableShrink: true,
24
+ sx: theme => ({
25
+ color: '#308fe8',
26
+ animationDuration: '550ms',
27
+ position: 'absolute',
28
+ left: 0,
29
+ [`& .${circularProgressClasses.circle}`]: {
30
+ strokeLinecap: 'round'
31
+ },
32
+ ...theme.applyStyles("light", {
33
+ color: '#1a90ff'
34
+ })
35
+ }),
36
+ size: 40,
37
+ thickness: 4,
38
+ ...props
39
+ })]
40
+ });
41
+ }
42
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Paper, {
43
+ elevation: 0,
44
+ sx: theme => ({
45
+ display: 'flex',
46
+ border: `1px solid ${theme.palette.divider}`,
47
+ flexWrap: 'wrap'
48
+ })
49
+ });
50
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Divider, {
51
+ sx: theme => ({
52
+ border: `1px solid ${'#000'}`,
53
+ ...theme.applyStyles("dark", {
54
+ border: `1px solid ${'#fff'}`
55
+ })
56
+ })
57
+ });
58
+ /*#__PURE__*/(0, _jsxRuntime.jsxs)(Typography, {
59
+ component: "span",
60
+ variant: "subtitle1",
61
+ color: "inherit",
62
+ sx: theme => ({
63
+ position: 'relative',
64
+ p: 4,
65
+ pt: 2,
66
+ pb: `calc(${theme.spacing(1)} + 6px)`
67
+ }),
68
+ children: [image.title, /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageMarked, {
69
+ className: "MuiImageMarked-root"
70
+ })]
71
+ });
72
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Autocomplete, {
73
+ sx: theme => ({
74
+ display: 'inline-block',
75
+ '& input': {
76
+ width: 200,
77
+ bgcolor: 'background.paper',
78
+ color: theme.palette.getContrastText(theme.palette.background.paper)
79
+ }
80
+ }),
81
+ id: "custom-input-demo",
82
+ options: options,
83
+ renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
84
+ ref: params.InputProps.ref,
85
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
86
+ type: "text",
87
+ ...params.inputProps
88
+ })
89
+ })
90
+ });
91
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
92
+ sx: theme => ({
93
+ position: 'relative',
94
+ width: 400,
95
+ bgcolor: 'background.paper',
96
+ border: '2px solid #000',
97
+ boxShadow: theme.shadows[5],
98
+ p: 4
99
+ })
100
+ });
101
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(Backdrop, {
102
+ sx: theme => ({
103
+ color: '#fff',
104
+ zIndex: theme.zIndex.drawer + 1
105
+ }),
106
+ open: open,
107
+ onClick: handleClose,
108
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CircularProgress, {
109
+ color: "inherit"
110
+ })
111
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "6.0.0-alpha.10",
3
+ "version": "6.0.0-alpha.11",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -24,9 +24,9 @@
24
24
  "url": "https://opencollective.com/mui-org"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/core": "^7.24.6",
28
- "@babel/runtime": "^7.24.6",
29
- "@babel/traverse": "^7.24.6",
27
+ "@babel/core": "^7.24.7",
28
+ "@babel/runtime": "^7.24.7",
29
+ "@babel/traverse": "^7.24.7",
30
30
  "jscodeshift": "^0.15.2",
31
31
  "jscodeshift-add-imports": "^1.0.10",
32
32
  "postcss": "^8.4.38",