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

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 (33) hide show
  1. package/README.md +255 -180
  2. package/codemod.js +0 -2
  3. package/node/deprecations/all/deprecations-all.js +4 -0
  4. package/node/deprecations/all/postcss.config.js +7 -1
  5. package/node/deprecations/tab-classes/index.js +13 -0
  6. package/node/deprecations/tab-classes/postcss-plugin.js +30 -0
  7. package/node/deprecations/tab-classes/postcss.config.js +8 -0
  8. package/node/deprecations/tab-classes/tab-classes.js +53 -0
  9. package/node/deprecations/tab-classes/test-cases/actual.js +5 -0
  10. package/node/deprecations/tab-classes/test-cases/expected.js +5 -0
  11. package/node/deprecations/table-sort-label-classes/index.js +13 -0
  12. package/node/deprecations/table-sort-label-classes/postcss-plugin.js +33 -0
  13. package/node/deprecations/table-sort-label-classes/postcss.config.js +8 -0
  14. package/node/deprecations/table-sort-label-classes/table-sort-label-classes.js +77 -0
  15. package/node/deprecations/table-sort-label-classes/test-cases/actual.js +7 -0
  16. package/node/deprecations/table-sort-label-classes/test-cases/expected.js +7 -0
  17. package/node/util/migrateToVariants.js +91 -43
  18. package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +9 -22
  19. package/node/v6.0.0/styled/test-cases/DynamicPropsStyled.actual.js +39 -0
  20. package/node/v6.0.0/styled/test-cases/DynamicPropsStyled.expected.js +65 -0
  21. package/node/v6.0.0/styled/test-cases/LogicalStyled.actual.js +31 -1
  22. package/node/v6.0.0/styled/test-cases/LogicalStyled.expected.js +39 -1
  23. package/node/v6.0.0/styled/test-cases/NestedSpread.expected.js +11 -13
  24. package/node/v6.0.0/sx-prop/sx-v6.js +80 -30
  25. package/node/v6.0.0/sx-prop/test-cases/sx-css-vars.actual.js +14 -0
  26. package/node/v6.0.0/sx-prop/test-cases/sx-css-vars.expected.js +33 -16
  27. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic.actual.js +21 -1
  28. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic.expected.js +19 -1
  29. package/node/v6.0.0/sx-prop/test-cases/sx-line-break.actual.js +69 -0
  30. package/node/v6.0.0/sx-prop/test-cases/sx-line-break.expected.js +69 -0
  31. package/node/v6.0.0/sx-prop/test-cases/sx-value-callback.actual.js +102 -0
  32. package/node/v6.0.0/sx-prop/test-cases/sx-value-callback.expected.js +111 -0
  33. package/package.json +5 -5
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
@@ -26,9 +26,11 @@ var _modalProps = _interopRequireDefault(require("../modal-props"));
26
26
  var _outlinedInputProps = _interopRequireDefault(require("../outlined-input-props"));
27
27
  var _paginationItemClasses = _interopRequireDefault(require("../pagination-item-classes"));
28
28
  var _speedDialProps = _interopRequireDefault(require("../speed-dial-props"));
29
+ var _tableSortLabelClasses = _interopRequireDefault(require("../table-sort-label-classes"));
29
30
  var _stepConnectorClasses = _interopRequireDefault(require("../step-connector-classes"));
30
31
  var _stepLabelProps = _interopRequireDefault(require("../step-label-props"));
31
32
  var _textFieldProps = _interopRequireDefault(require("../text-field-props"));
33
+ var _tabClasses = _interopRequireDefault(require("../tab-classes"));
32
34
  var _toggleButtonGroupClasses = _interopRequireDefault(require("../toggle-button-group-classes"));
33
35
  /**
34
36
  * @param {import('jscodeshift').FileInfo} file
@@ -58,7 +60,9 @@ function deprecationsAll(file, api, options) {
58
60
  file.source = (0, _speedDialProps.default)(file, api, options);
59
61
  file.source = (0, _stepConnectorClasses.default)(file, api, options);
60
62
  file.source = (0, _stepLabelProps.default)(file, api, options);
63
+ file.source = (0, _tableSortLabelClasses.default)(file, api, options);
61
64
  file.source = (0, _textFieldProps.default)(file, api, options);
65
+ file.source = (0, _tabClasses.default)(file, api, options);
62
66
  file.source = (0, _toggleButtonGroupClasses.default)(file, api, options);
63
67
  return file.source;
64
68
  }
@@ -27,6 +27,12 @@ const {
27
27
  const {
28
28
  plugin: circularProgressClassesPlugin
29
29
  } = require('../circular-progress-classes/postcss-plugin');
30
+ const {
31
+ plugin: tabClassesPlugin
32
+ } = require('../tab-classes/postcss-plugin');
33
+ const {
34
+ plugin: tableSortLabelClassesPlugin
35
+ } = require('../table-sort-label-classes/postcss-plugin');
30
36
  module.exports = {
31
- plugins: [accordionSummaryClassesPlugin, alertClassesPlugin, buttonClassesPlugin, buttonGroupClassesPlugin, chipClassesPlugin, circularProgressClassesPlugin, paginationItemClassesPlugin, stepConnectorClassesPlugin, toggleButtonGroupClassesPlugin]
37
+ plugins: [accordionSummaryClassesPlugin, alertClassesPlugin, buttonClassesPlugin, buttonGroupClassesPlugin, chipClassesPlugin, circularProgressClassesPlugin, paginationItemClassesPlugin, stepConnectorClassesPlugin, toggleButtonGroupClassesPlugin, tabClassesPlugin, tableSortLabelClassesPlugin]
32
38
  };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _tabClasses.default;
11
+ }
12
+ });
13
+ var _tabClasses = _interopRequireDefault(require("./tab-classes"));
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ const classes = [{
4
+ deprecatedClass: ' .MuiTab-iconWrapper',
5
+ replacementSelector: ' .MuiTab-icon'
6
+ }];
7
+ const plugin = () => {
8
+ return {
9
+ postcssPlugin: `Replace deprecated Tab classes with new classes`,
10
+ Rule(rule) {
11
+ const {
12
+ selector
13
+ } = rule;
14
+ classes.forEach(({
15
+ deprecatedClass,
16
+ replacementSelector
17
+ }) => {
18
+ const selectorRegex = new RegExp(`${deprecatedClass}$`);
19
+ if (selector.match(selectorRegex)) {
20
+ rule.selector = selector.replace(selectorRegex, replacementSelector);
21
+ }
22
+ });
23
+ }
24
+ };
25
+ };
26
+ plugin.postcss = true;
27
+ module.exports = {
28
+ plugin,
29
+ classes
30
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ const {
4
+ plugin
5
+ } = require('./postcss-plugin');
6
+ module.exports = {
7
+ plugins: [plugin]
8
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _postcssPlugin = require("./postcss-plugin");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const root = j(file.source);
15
+ const printOptions = options.printOptions;
16
+ _postcssPlugin.classes.forEach(({
17
+ deprecatedClass,
18
+ replacementSelector
19
+ }) => {
20
+ const replacementSelectorPrefix = '&';
21
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(/^@mui\/material\/Tab$/)).forEach(path => {
22
+ path.node.specifiers.forEach(specifier => {
23
+ if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'tabClasses') {
24
+ const deprecatedAtomicClass = deprecatedClass.replace(`${deprecatedClass.split('-')[0]}-`, '');
25
+ root.find(j.MemberExpression, {
26
+ object: {
27
+ name: specifier.local.name
28
+ },
29
+ property: {
30
+ name: deprecatedAtomicClass
31
+ }
32
+ }).forEach(memberExpression => {
33
+ const parent = memberExpression.parentPath.parentPath.value;
34
+ if (parent.type === j.TemplateLiteral.name) {
35
+ const memberExpressionIndex = parent.expressions.findIndex(expression => expression === memberExpression.value);
36
+ const precedingTemplateElement = parent.quasis[memberExpressionIndex];
37
+ const atomicClasses = ['icon'];
38
+ if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
39
+ const atomicClassesArgs = [memberExpressionIndex, 1, ...atomicClasses.map(atomicClass => j.memberExpression(memberExpression.value.object, j.identifier(atomicClass)))];
40
+ parent.expressions.splice(...atomicClassesArgs);
41
+ }
42
+ }
43
+ });
44
+ }
45
+ });
46
+ });
47
+ const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}$`);
48
+ root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
49
+ path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`)));
50
+ });
51
+ });
52
+ return root.toSource(printOptions);
53
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ var _Tab = require("@mui/material/Tab");
4
+ '& .MuiTab-iconWrapper';
5
+ `& .${_Tab.tabClasses.iconWrapper}`;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ var _Tab = require("@mui/material/Tab");
4
+ "& .MuiTab-icon";
5
+ `& .${_Tab.tabClasses.icon}`;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _tableSortLabelClasses.default;
11
+ }
12
+ });
13
+ var _tableSortLabelClasses = _interopRequireDefault(require("./table-sort-label-classes"));
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ const classes = [{
4
+ deprecatedClass: ' .MuiTableSortLabel-iconDirectionDesc',
5
+ replacementSelector: '.MuiTableSortLabel-directionDesc > .MuiTableSortLabel-icon'
6
+ }, {
7
+ deprecatedClass: ' .MuiTableSortLabel-iconDirectionAsc',
8
+ replacementSelector: '.MuiTableSortLabel-directionAsc > .MuiTableSortLabel-icon'
9
+ }];
10
+ const plugin = () => {
11
+ return {
12
+ postcssPlugin: `Replace deprecated TableSortLabel classes with new classes`,
13
+ Rule(rule) {
14
+ const {
15
+ selector
16
+ } = rule;
17
+ classes.forEach(({
18
+ deprecatedClass,
19
+ replacementSelector
20
+ }) => {
21
+ const selectorRegex = new RegExp(`${deprecatedClass}$`);
22
+ if (selector.match(selectorRegex)) {
23
+ rule.selector = selector.replace(selectorRegex, replacementSelector);
24
+ }
25
+ });
26
+ }
27
+ };
28
+ };
29
+ plugin.postcss = true;
30
+ module.exports = {
31
+ plugin,
32
+ classes
33
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ const {
4
+ plugin
5
+ } = require('./postcss-plugin');
6
+ module.exports = {
7
+ plugins: [plugin]
8
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _postcssPlugin = require("./postcss-plugin");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const root = j(file.source);
15
+ const printOptions = options.printOptions;
16
+ _postcssPlugin.classes.forEach(({
17
+ deprecatedClass,
18
+ replacementSelector
19
+ }) => {
20
+ const replacementSelectorPrefix = '&';
21
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(/^@mui\/material\/TableSortLabel$/)).forEach(path => {
22
+ path.node.specifiers.forEach(specifier => {
23
+ if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'tableSortLabelClasses') {
24
+ const deprecatedAtomicClass = deprecatedClass.replace(`${deprecatedClass.split('-')[0]}-`, '');
25
+ root.find(j.MemberExpression, {
26
+ object: {
27
+ name: specifier.local.name
28
+ },
29
+ property: {
30
+ name: deprecatedAtomicClass
31
+ }
32
+ }).forEach(memberExpression => {
33
+ const parent = memberExpression.parentPath.parentPath.value;
34
+ if (parent.type === j.TemplateLiteral.name) {
35
+ const memberExpressionIndex = parent.expressions.findIndex(expression => expression === memberExpression.value);
36
+ const precedingTemplateElement = parent.quasis[memberExpressionIndex];
37
+ const atomicClasses = replacementSelector.replaceAll('MuiTableSortLabel-', '').replaceAll(replacementSelectorPrefix, '').replaceAll(' > ', '').split('.').filter(Boolean);
38
+ if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
39
+ const atomicClassesArgs = [memberExpressionIndex, 1, ...atomicClasses.map(atomicClass => j.memberExpression(memberExpression.value.object, j.identifier(atomicClass)))];
40
+ parent.expressions.splice(...atomicClassesArgs);
41
+ if (replacementSelector.includes(' > ')) {
42
+ const quasisArgs = [memberExpressionIndex, 1, j.templateElement({
43
+ raw: precedingTemplateElement.value.raw.replace(' ', ''),
44
+ cooked: precedingTemplateElement.value.cooked.replace(' ', '')
45
+ }, false), j.templateElement({
46
+ raw: ' > .',
47
+ cooked: ' > .'
48
+ }, false)];
49
+ if (atomicClasses.length === 3) {
50
+ quasisArgs.splice(3, 0, j.templateElement({
51
+ raw: '.',
52
+ cooked: '.'
53
+ }, false));
54
+ }
55
+ parent.quasis.splice(...quasisArgs);
56
+ } else {
57
+ parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
58
+ raw: precedingTemplateElement.value.raw,
59
+ cooked: precedingTemplateElement.value.cooked
60
+ }, false), j.templateElement({
61
+ raw: '.',
62
+ cooked: '.'
63
+ }, false));
64
+ }
65
+ }
66
+ }
67
+ });
68
+ }
69
+ });
70
+ });
71
+ const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}$`);
72
+ root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
73
+ path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`)));
74
+ });
75
+ });
76
+ return root.toSource(printOptions);
77
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _TableSortLabel = require("@mui/material/TableSortLabel");
4
+ '& .MuiTableSortLabel-iconDirectionDesc';
5
+ '& .MuiTableSortLabel-iconDirectionAsc';
6
+ `& .${_TableSortLabel.tableSortLabelClasses.iconDirectionDesc}`;
7
+ `& .${_TableSortLabel.tableSortLabelClasses.iconDirectionAsc}`;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _TableSortLabel = require("@mui/material/TableSortLabel");
4
+ "&.MuiTableSortLabel-directionDesc > .MuiTableSortLabel-icon";
5
+ "&.MuiTableSortLabel-directionAsc > .MuiTableSortLabel-icon";
6
+ `&.${_TableSortLabel.tableSortLabelClasses.directionDesc} > .${_TableSortLabel.tableSortLabelClasses.icon}`;
7
+ `&.${_TableSortLabel.tableSortLabelClasses.directionAsc} > .${_TableSortLabel.tableSortLabelClasses.icon}`;
@@ -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') {
@@ -294,25 +331,32 @@ function migrateToVariants(j, styles) {
294
331
  } else if (style.body.type === 'ConditionalExpression') {
295
332
  // skip ConditionalExpression
296
333
  } else {
297
- let objectExpression = style.body;
298
- let counter = 0;
299
- while (objectExpression.type !== 'ObjectExpression' && counter < MAX_DEPTH) {
300
- counter += 1;
301
- if (objectExpression.type === 'BlockStatement') {
302
- objectExpression = objectExpression.body.find(item => item.type === 'ReturnStatement').argument;
303
- }
334
+ const expressions = [];
335
+ if (style.body.type === 'ArrayExpression') {
336
+ expressions.push(...style.body.elements);
337
+ } else {
338
+ expressions.push(style.body);
304
339
  }
305
- recurseObjectExpression({
306
- node: objectExpression,
307
- buildStyle: createBuildStyle()
340
+ expressions.forEach(objectExpression => {
341
+ let counter = 0;
342
+ while (objectExpression.type !== 'ObjectExpression' && counter < MAX_DEPTH) {
343
+ counter += 1;
344
+ if (objectExpression.type === 'BlockStatement') {
345
+ objectExpression = objectExpression.body.find(item => item.type === 'ReturnStatement').argument;
346
+ }
347
+ }
348
+ recurseObjectExpression({
349
+ node: objectExpression,
350
+ buildStyle: createBuildStyle()
351
+ });
352
+ if (variants.length && objectExpression.type === 'ObjectExpression') {
353
+ objectExpression.properties.push(j.objectProperty(j.identifier('variants'), j.arrayExpression(variants.filter(variant => {
354
+ const props = variant.properties.find(prop => prop.key.name === 'props');
355
+ const styleVal = variant.properties.find(prop => prop.key.name === 'style');
356
+ return props && styleVal && (!styleVal.value.properties || styleVal.value.properties.length > 0) && (props.value.type === 'ArrowFunctionExpression' || props.value.properties.length > 0);
357
+ }))));
358
+ }
308
359
  });
309
- if (variants.length) {
310
- objectExpression.properties.push(j.objectProperty(j.identifier('variants'), j.arrayExpression(variants.filter(variant => {
311
- const props = variant.properties.find(prop => prop.key.name === 'props');
312
- const styleVal = variant.properties.find(prop => prop.key.name === 'style');
313
- return props && styleVal && (!styleVal.value.properties || styleVal.value.properties.length > 0) && (props.value.type === 'ArrowFunctionExpression' || props.value.properties.length > 0);
314
- }))));
315
- }
316
360
  }
317
361
  function recurseObjectExpression(data) {
318
362
  if (data.node.type === 'ObjectExpression') {
@@ -440,7 +484,6 @@ function migrateToVariants(j, styles) {
440
484
  leftName = (_getObjectKey5 = getObjectKey(data.node.test.argument)) == null ? void 0 : _getObjectKey5.name;
441
485
  }
442
486
  if (parameters.has(leftName) && leftName !== 'theme') {
443
- var _data$parentNode;
444
487
  let props = buildProps(data.node.test);
445
488
  if (data.props) {
446
489
  props = mergeProps(data.props, props);
@@ -451,32 +494,37 @@ function migrateToVariants(j, styles) {
451
494
  style: styleVal
452
495
  };
453
496
  variants.push(buildObjectAST(variant));
454
-
455
- // create another variant with inverted condition
456
- let props2 = buildProps(inverseBinaryExpression(data.node.test));
457
- if (data.props) {
458
- props2 = mergeProps(data.props, props2);
459
- }
460
- const styleVal2 = data.buildStyle(data.node.alternate);
461
- const variant2 = {
462
- props: props2,
463
- style: styleVal2
464
- };
465
- variants.push(buildObjectAST(variant2));
466
- if (((_data$parentNode = data.parentNode) == null ? void 0 : _data$parentNode.type) === 'ObjectExpression') {
467
- removeProperty(data.parentNode, data.node);
497
+ if (data.node.consequent.type === 'ObjectExpression' && data.node.alternate.type === 'ObjectExpression') {
498
+ var _data$parentNode;
499
+ // create another variant with inverted condition
500
+ let props2 = buildProps(inverseBinaryExpression(data.node.test));
501
+ if (data.props) {
502
+ props2 = mergeProps(data.props, props2);
503
+ }
504
+ const styleVal2 = data.buildStyle(data.node.alternate);
505
+ const variant2 = {
506
+ props: props2,
507
+ style: styleVal2
508
+ };
509
+ variants.push(buildObjectAST(variant2));
510
+ if (((_data$parentNode = data.parentNode) == null ? void 0 : _data$parentNode.type) === 'ObjectExpression') {
511
+ removeProperty(data.parentNode, data.node);
512
+ }
513
+ } else {
514
+ var _data$replaceValue;
515
+ (_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, data.node.alternate);
468
516
  }
469
517
  }
470
518
  if (leftName === 'theme' && ((_data$parentNode2 = data.parentNode) == null ? void 0 : _data$parentNode2.type) === 'ObjectExpression' && ((_data$node$test = data.node.test) == null ? void 0 : _data$node$test.type) === 'BinaryExpression' && isThemePaletteMode(data.node.test.left)) {
471
519
  if (data.node.consequent.type !== 'ObjectExpression' && data.node.alternate.type !== 'ObjectExpression') {
472
- var _data$replaceValue;
520
+ var _data$replaceValue2;
473
521
  if (data.modeStyles) {
474
522
  if (!data.modeStyles[data.node.test.right.value]) {
475
523
  data.modeStyles[data.node.test.right.value] = [];
476
524
  }
477
525
  data.modeStyles[data.node.test.right.value].push(j.objectProperty(data.key, data.node.consequent));
478
526
  }
479
- (_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, data.node.alternate);
527
+ (_data$replaceValue2 = data.replaceValue) == null || _data$replaceValue2.call(data, data.node.alternate);
480
528
  }
481
529
  }
482
530
  }
@@ -512,10 +560,10 @@ function migrateToVariants(j, styles) {
512
560
  data.modeStyles[mode].push(j.objectProperty(data.key, clonedNode));
513
561
  });
514
562
  if (data.key) {
515
- var _data$replaceValue2;
563
+ var _data$replaceValue3;
516
564
  // to remove the arrow function
517
565
  // { ...: theme => `1px solid...` } to { ...: `1px solid...` }
518
- (_data$replaceValue2 = data.replaceValue) == null || _data$replaceValue2.call(data, data.node);
566
+ (_data$replaceValue3 = data.replaceValue) == null || _data$replaceValue3.call(data, data.node);
519
567
  }
520
568
  }
521
569
  }
@@ -18,6 +18,7 @@ const LinearProgressBar1 = styled('span', {
18
18
  variant: 'buffer'
19
19
  },
20
20
  style: {
21
+ backgroundColor: (theme.vars || theme).palette[ownerState.color].light,
21
22
  '&:hover': {}
22
23
  }
23
24
  }, {
@@ -28,14 +29,6 @@ const LinearProgressBar1 = styled('span', {
28
29
  style: {
29
30
  backgroundColor: 'currentColor'
30
31
  }
31
- }, {
32
- props: {
33
- variant: 'buffer',
34
- color: 'normal'
35
- },
36
- style: {
37
- backgroundColor: (theme.vars || theme).palette[ownerState.color].light
38
- }
39
32
  }, {
40
33
  props: ({
41
34
  variant,
@@ -58,18 +51,18 @@ const LinearProgressBar1 = styled('span', {
58
51
  }
59
52
  }, {
60
53
  props: ({
61
- ownerState,
62
- color
63
- }) => ownerState.variant !== 'buffer' && color === 'inherit',
54
+ ownerState
55
+ }) => ownerState.variant !== 'buffer',
64
56
  style: {
65
- backgroundColor: 'currentColor'
57
+ backgroundColor: (theme.vars || theme).palette[ownerState.color].main
66
58
  }
67
59
  }, {
68
60
  props: ({
69
- ownerState
70
- }) => ownerState.variant !== 'buffer' && ownerState.color !== 'inherit',
61
+ ownerState,
62
+ color
63
+ }) => ownerState.variant !== 'buffer' && color === 'inherit',
71
64
  style: {
72
- backgroundColor: (theme.vars || theme).palette[ownerState.color].main
65
+ backgroundColor: 'currentColor'
73
66
  }
74
67
  }]
75
68
  }));
@@ -84,6 +77,7 @@ const ExpandMore = styled(props => {
84
77
  })(({
85
78
  theme
86
79
  }) => ({
80
+ transform: 'rotate(180deg)',
87
81
  marginLeft: 'auto',
88
82
  transition: theme.transitions.create('transform', {
89
83
  duration: theme.transitions.duration.shortest
@@ -95,13 +89,6 @@ const ExpandMore = styled(props => {
95
89
  style: {
96
90
  transform: 'rotate(0deg)'
97
91
  }
98
- }, {
99
- props: ({
100
- expand
101
- }) => !!expand,
102
- style: {
103
- transform: 'rotate(180deg)'
104
- }
105
92
  }]
106
93
  }));
107
94
  const Main = styled('main', {
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styles = require("@mui/material/styles");
8
+ const DemoToolbarRoot = (0, _styles.styled)('div', {
9
+ shouldForwardProp: prop => prop !== 'demoOptions' && prop !== 'openDemoSource'
10
+ })(({
11
+ theme,
12
+ demoOptions,
13
+ openDemoSource
14
+ }) => [{
15
+ display: 'none',
16
+ [theme.breakpoints.up('sm')]: {
17
+ top: 0,
18
+ maxHeight: 50,
19
+ display: 'block',
20
+ marginTop: demoOptions.bg === 'inline' ? theme.spacing(1) : -1,
21
+ padding: theme.spacing(0.5, 1),
22
+ border: `1px solid ${(theme.vars || theme).palette.divider}`,
23
+ borderTopWidth: demoOptions.bg === 'inline' ? 1 : 0,
24
+ backgroundColor: (0, _styles.alpha)(theme.palette.grey[50], 0.2),
25
+ borderRadius: openDemoSource ? 0 : '0 0 12px 12px',
26
+ transition: theme.transitions.create('border-radius'),
27
+ ...(theme.direction === 'rtl' && {
28
+ left: theme.spacing(1)
29
+ }),
30
+ ...(theme.direction !== 'rtl' && {
31
+ right: theme.spacing(1)
32
+ })
33
+ }
34
+ }, theme.applyDarkStyles({
35
+ [theme.breakpoints.up('sm')]: {
36
+ backgroundColor: (0, _styles.alpha)(theme.palette.primaryDark[800], 0.2)
37
+ }
38
+ })]);
39
+ var _default = exports.default = DemoToolbarRoot;