@mui/codemod 6.0.0-dev.240424162023-9968b4889d → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +1037 -294
  2. package/codemod.js +0 -2
  3. package/node/deprecations/accordion-props/test-cases/actual.js +6 -3
  4. package/node/deprecations/accordion-props/test-cases/expected.js +14 -10
  5. package/node/deprecations/accordion-props/test-cases/theme.expected.js +8 -7
  6. package/node/deprecations/alert-props/test-cases/expected.js +12 -4
  7. package/node/deprecations/alert-props/test-cases/theme.expected.js +12 -5
  8. package/node/deprecations/all/deprecations-all.js +38 -14
  9. package/node/deprecations/all/postcss.config.js +10 -1
  10. package/node/deprecations/autocomplete-props/autocomplete-props.js +22 -0
  11. package/node/deprecations/autocomplete-props/index.js +13 -0
  12. package/node/deprecations/autocomplete-props/test-cases/actual.js +75 -0
  13. package/node/deprecations/autocomplete-props/test-cases/expected.js +75 -0
  14. package/node/deprecations/autocomplete-props/test-cases/theme.actual.js +47 -0
  15. package/node/deprecations/autocomplete-props/test-cases/theme.expected.js +47 -0
  16. package/node/deprecations/avatar-group-props/avatar-group-props.js +81 -0
  17. package/node/deprecations/avatar-group-props/index.js +13 -0
  18. package/node/deprecations/avatar-group-props/test-cases/actual.js +56 -0
  19. package/node/deprecations/avatar-group-props/test-cases/expected.js +58 -0
  20. package/node/deprecations/avatar-group-props/test-cases/theme.actual.js +48 -0
  21. package/node/deprecations/avatar-group-props/test-cases/theme.expected.js +50 -0
  22. package/node/deprecations/avatar-props/test-cases/expected.js +8 -6
  23. package/node/deprecations/avatar-props/test-cases/theme.expected.js +8 -7
  24. package/node/deprecations/backdrop-props/backdrop-props.js +3 -5
  25. package/node/deprecations/backdrop-props/test-cases/actual.js +30 -13
  26. package/node/deprecations/backdrop-props/test-cases/expected.js +23 -13
  27. package/node/deprecations/backdrop-props/test-cases/theme.actual.js +32 -6
  28. package/node/deprecations/backdrop-props/test-cases/theme.expected.js +27 -5
  29. package/node/deprecations/badge-props/test-cases/expected.js +12 -5
  30. package/node/deprecations/badge-props/test-cases/theme.expected.js +12 -5
  31. package/node/deprecations/circular-progress-classes/circular-progress-classes.js +77 -0
  32. package/node/deprecations/circular-progress-classes/index.js +13 -0
  33. package/node/deprecations/circular-progress-classes/postcss-plugin.js +33 -0
  34. package/node/deprecations/circular-progress-classes/postcss.config.js +8 -0
  35. package/node/deprecations/circular-progress-classes/test-cases/actual.js +7 -0
  36. package/node/deprecations/circular-progress-classes/test-cases/expected.js +7 -0
  37. package/node/deprecations/divider-props/divider-props.js +28 -15
  38. package/node/deprecations/divider-props/test-cases/actual.js +3 -0
  39. package/node/deprecations/divider-props/test-cases/expected.js +5 -8
  40. package/node/deprecations/divider-props/test-cases/theme.actual.js +28 -0
  41. package/node/deprecations/divider-props/test-cases/theme.expected.js +25 -0
  42. package/node/deprecations/filled-input-props/filled-input-props.js +22 -0
  43. package/node/deprecations/filled-input-props/index.js +13 -0
  44. package/node/deprecations/filled-input-props/test-cases/actual.js +60 -0
  45. package/node/deprecations/filled-input-props/test-cases/expected.js +52 -0
  46. package/node/deprecations/filled-input-props/test-cases/theme.actual.js +73 -0
  47. package/node/deprecations/filled-input-props/test-cases/theme.expected.js +65 -0
  48. package/node/deprecations/form-control-label-props/form-control-label-props.js +22 -0
  49. package/node/deprecations/form-control-label-props/index.js +13 -0
  50. package/node/deprecations/form-control-label-props/test-cases/actual.js +21 -0
  51. package/node/deprecations/form-control-label-props/test-cases/expected.js +21 -0
  52. package/node/deprecations/form-control-label-props/test-cases/theme.actual.js +23 -0
  53. package/node/deprecations/form-control-label-props/test-cases/theme.expected.js +23 -0
  54. package/node/deprecations/grid-props/grid-props.js +51 -0
  55. package/node/deprecations/grid-props/index.js +13 -0
  56. package/node/deprecations/grid-props/test-cases/actual.js +25 -0
  57. package/node/deprecations/grid-props/test-cases/expected.js +23 -0
  58. package/node/deprecations/grid-props/test-cases/theme.actual.js +24 -0
  59. package/node/deprecations/grid-props/test-cases/theme.expected.js +23 -0
  60. package/node/deprecations/image-list-item-bar-classes/image-list-item-bar-classes.js +77 -0
  61. package/node/deprecations/image-list-item-bar-classes/index.js +13 -0
  62. package/node/deprecations/image-list-item-bar-classes/postcss-plugin.js +39 -0
  63. package/node/deprecations/image-list-item-bar-classes/postcss.config.js +8 -0
  64. package/node/deprecations/image-list-item-bar-classes/test-cases/actual.js +11 -0
  65. package/node/deprecations/image-list-item-bar-classes/test-cases/expected.js +11 -0
  66. package/node/deprecations/input-base-props/index.js +13 -0
  67. package/node/deprecations/input-base-props/input-base-props.js +22 -0
  68. package/node/deprecations/input-base-props/test-cases/actual.js +60 -0
  69. package/node/deprecations/input-base-props/test-cases/expected.js +52 -0
  70. package/node/deprecations/input-base-props/test-cases/theme.actual.js +73 -0
  71. package/node/deprecations/input-base-props/test-cases/theme.expected.js +65 -0
  72. package/node/deprecations/input-props/index.js +13 -0
  73. package/node/deprecations/input-props/input-props.js +22 -0
  74. package/node/deprecations/input-props/test-cases/actual.js +60 -0
  75. package/node/deprecations/input-props/test-cases/expected.js +52 -0
  76. package/node/deprecations/input-props/test-cases/theme.actual.js +73 -0
  77. package/node/deprecations/input-props/test-cases/theme.expected.js +65 -0
  78. package/node/deprecations/list-item-props/index.js +13 -0
  79. package/node/deprecations/list-item-props/list-item-props.js +22 -0
  80. package/node/deprecations/list-item-props/test-cases/actual.js +43 -0
  81. package/node/deprecations/list-item-props/test-cases/expected.js +40 -0
  82. package/node/deprecations/list-item-props/test-cases/theme.actual.js +56 -0
  83. package/node/deprecations/list-item-props/test-cases/theme.expected.js +53 -0
  84. package/node/deprecations/modal-props/index.js +13 -0
  85. package/node/deprecations/modal-props/modal-props.js +22 -0
  86. package/node/deprecations/modal-props/test-cases/actual.js +43 -0
  87. package/node/deprecations/modal-props/test-cases/expected.js +40 -0
  88. package/node/deprecations/modal-props/test-cases/theme.actual.js +56 -0
  89. package/node/deprecations/modal-props/test-cases/theme.expected.js +53 -0
  90. package/node/deprecations/outlined-input-props/index.js +13 -0
  91. package/node/deprecations/outlined-input-props/outlined-input-props.js +22 -0
  92. package/node/deprecations/outlined-input-props/test-cases/actual.js +60 -0
  93. package/node/deprecations/outlined-input-props/test-cases/expected.js +52 -0
  94. package/node/deprecations/outlined-input-props/test-cases/theme.actual.js +73 -0
  95. package/node/deprecations/outlined-input-props/test-cases/theme.expected.js +65 -0
  96. package/node/deprecations/pagination-item-props/index.js +13 -0
  97. package/node/deprecations/pagination-item-props/pagination-item-props.js +22 -0
  98. package/node/deprecations/pagination-item-props/test-cases/actual.js +27 -0
  99. package/node/deprecations/pagination-item-props/test-cases/expected.js +21 -0
  100. package/node/deprecations/pagination-item-props/test-cases/theme.actual.js +28 -0
  101. package/node/deprecations/pagination-item-props/test-cases/theme.expected.js +26 -0
  102. package/node/deprecations/popper-props/index.js +13 -0
  103. package/node/deprecations/popper-props/popper-props.js +22 -0
  104. package/node/deprecations/popper-props/test-cases/actual.js +27 -0
  105. package/node/deprecations/popper-props/test-cases/expected.js +24 -0
  106. package/node/deprecations/popper-props/test-cases/theme.actual.js +32 -0
  107. package/node/deprecations/popper-props/test-cases/theme.expected.js +29 -0
  108. package/node/deprecations/slider-props/test-cases/expected.js +12 -4
  109. package/node/deprecations/slider-props/test-cases/theme.expected.js +12 -5
  110. package/node/deprecations/speed-dial-props/index.js +13 -0
  111. package/node/deprecations/speed-dial-props/speed-dial-props.js +31 -0
  112. package/node/deprecations/speed-dial-props/test-cases/actual.js +41 -0
  113. package/node/deprecations/speed-dial-props/test-cases/expected.js +54 -0
  114. package/node/deprecations/speed-dial-props/test-cases/theme.actual.js +33 -0
  115. package/node/deprecations/speed-dial-props/test-cases/theme.expected.js +40 -0
  116. package/node/deprecations/step-label-props/step-label-props.js +0 -14
  117. package/node/deprecations/step-label-props/test-cases/actual.js +0 -23
  118. package/node/deprecations/step-label-props/test-cases/expected.js +4 -26
  119. package/node/deprecations/step-label-props/test-cases/theme.actual.js +0 -22
  120. package/node/deprecations/step-label-props/test-cases/theme.expected.js +4 -28
  121. package/node/deprecations/tab-classes/index.js +13 -0
  122. package/node/deprecations/tab-classes/postcss-plugin.js +30 -0
  123. package/node/deprecations/tab-classes/postcss.config.js +8 -0
  124. package/node/deprecations/tab-classes/tab-classes.js +53 -0
  125. package/node/deprecations/tab-classes/test-cases/actual.js +5 -0
  126. package/node/deprecations/tab-classes/test-cases/expected.js +5 -0
  127. package/node/deprecations/table-sort-label-classes/index.js +13 -0
  128. package/node/deprecations/table-sort-label-classes/postcss-plugin.js +33 -0
  129. package/node/deprecations/table-sort-label-classes/postcss.config.js +8 -0
  130. package/node/deprecations/table-sort-label-classes/table-sort-label-classes.js +77 -0
  131. package/node/deprecations/table-sort-label-classes/test-cases/actual.js +7 -0
  132. package/node/deprecations/table-sort-label-classes/test-cases/expected.js +7 -0
  133. package/node/deprecations/text-field-props/index.js +13 -0
  134. package/node/deprecations/text-field-props/test-cases/actual.js +27 -0
  135. package/node/deprecations/text-field-props/test-cases/expected.js +31 -0
  136. package/node/deprecations/text-field-props/test-cases/theme.actual.js +13 -0
  137. package/node/deprecations/text-field-props/test-cases/theme.expected.js +15 -0
  138. package/node/deprecations/text-field-props/text-field-props.js +48 -0
  139. package/node/deprecations/tooltip-props/index.js +13 -0
  140. package/node/deprecations/tooltip-props/test-cases/actual.js +92 -0
  141. package/node/deprecations/tooltip-props/test-cases/expected.js +84 -0
  142. package/node/deprecations/tooltip-props/test-cases/theme.actual.js +73 -0
  143. package/node/deprecations/tooltip-props/test-cases/theme.expected.js +65 -0
  144. package/node/deprecations/tooltip-props/tooltip-props.js +22 -0
  145. package/node/deprecations/typography-props/index.js +13 -0
  146. package/node/deprecations/typography-props/test-cases/actual.js +80 -0
  147. package/node/deprecations/typography-props/test-cases/expected.js +86 -0
  148. package/node/deprecations/typography-props/test-cases/theme.actual.js +85 -0
  149. package/node/deprecations/typography-props/test-cases/theme.expected.js +86 -0
  150. package/node/deprecations/typography-props/typography-props.js +81 -0
  151. package/node/deprecations/utils/movePropIntoSlotProps.js +4 -12
  152. package/node/deprecations/utils/movePropIntoSlots.js +4 -12
  153. package/node/deprecations/utils/replaceComponentsWithSlots.js +32 -25
  154. package/node/util/getReturnExpression.js +19 -0
  155. package/node/util/migrateToVariants.js +586 -0
  156. package/node/util/propsToObject.js +2 -6
  157. package/node/util/renameClassKey.js +1 -2
  158. package/node/v0.15.0/import-path.js +2 -2
  159. package/node/v5.0.0/avatar-circle-circular.js +2 -4
  160. package/node/v5.0.0/badge-overlap-value.js +4 -7
  161. package/node/v5.0.0/badge-overlap-value.test/actual.js +3 -4
  162. package/node/v5.0.0/badge-overlap-value.test/expected.js +3 -4
  163. package/node/v5.0.0/base-hook-imports.js +1 -2
  164. package/node/v5.0.0/base-remove-component-prop.test/actual.js +4 -4
  165. package/node/v5.0.0/base-remove-component-prop.test/expected.js +4 -4
  166. package/node/v5.0.0/base-remove-unstyled-suffix.js +1 -2
  167. package/node/v5.0.0/base-remove-unstyled-suffix.test/actual.js +5 -5
  168. package/node/v5.0.0/base-remove-unstyled-suffix.test/expected.js +4 -4
  169. package/node/v5.0.0/base-rename-components-to-slots.js +1 -1
  170. package/node/v5.0.0/base-use-named-exports.js +5 -8
  171. package/node/v5.0.0/box-sx-prop.js +1 -2
  172. package/node/v5.0.0/box-sx-prop.test/actual.js +4 -4
  173. package/node/v5.0.0/box-sx-prop.test/expected.js +3 -3
  174. package/node/v5.0.0/button-color-prop.js +1 -2
  175. package/node/v5.0.0/chip-variant-prop.js +1 -2
  176. package/node/v5.0.0/circularprogress-variant.js +2 -4
  177. package/node/v5.0.0/create-theme.test/custom-fn.actual.js +3 -4
  178. package/node/v5.0.0/create-theme.test/custom-fn.expected.js +3 -4
  179. package/node/v5.0.0/fab-variant.js +2 -4
  180. package/node/v5.0.0/grid-list-component.test/actual.js +1 -1
  181. package/node/v5.0.0/grid-list-component.test/expected.js +1 -1
  182. package/node/v5.0.0/joy-avatar-remove-imgProps.js +3 -7
  183. package/node/v5.0.0/joy-rename-components-to-slots.js +1 -1
  184. package/node/v5.0.0/joy-rename-row-prop.js +1 -2
  185. package/node/v5.0.0/joy-text-field-to-input.js +4 -7
  186. package/node/v5.0.0/jss-to-styled.test/first.actual.js +11 -14
  187. package/node/v5.0.0/jss-to-styled.test/first.expected.js +11 -14
  188. package/node/v5.0.0/jss-to-styled.test/seventh.actual.js +4 -4
  189. package/node/v5.0.0/jss-to-styled.test/seventh.expected.js +4 -4
  190. package/node/v5.0.0/jss-to-styled.test/sixth.actual.js +3 -3
  191. package/node/v5.0.0/jss-to-styled.test/sixth.expected.js +3 -3
  192. package/node/v5.0.0/jss-to-styled.test/withCreateStyles.actual.js +3 -3
  193. package/node/v5.0.0/jss-to-styled.test/withCreateStyles.expected.js +3 -4
  194. package/node/v5.0.0/jss-to-styled.test/withCreateStyles1.actual.js +3 -3
  195. package/node/v5.0.0/jss-to-styled.test/withCreateStyles1.expected.js +3 -4
  196. package/node/v5.0.0/jss-to-styled.test/withCreateStyles2.actual.js +3 -3
  197. package/node/v5.0.0/jss-to-styled.test/withCreateStyles2.expected.js +3 -4
  198. package/node/v5.0.0/jss-to-styled.test/withCreateStyles3.actual.js +3 -3
  199. package/node/v5.0.0/jss-to-styled.test/withCreateStyles3.expected.js +3 -4
  200. package/node/v5.0.0/jss-to-tss-react.js +4 -6
  201. package/node/v5.0.0/jss-to-tss-react.test/actual-mixins-pattern.js +6 -5
  202. package/node/v5.0.0/jss-to-tss-react.test/actual-withStyles.js +4 -4
  203. package/node/v5.0.0/jss-to-tss-react.test/expected-mixins-pattern.js +6 -5
  204. package/node/v5.0.0/jss-to-tss-react.test/expected-withStyles.js +4 -4
  205. package/node/v5.0.0/link-underline-hover.js +1 -4
  206. package/node/v5.0.0/pagination-round-circular.js +3 -8
  207. package/node/v5.0.0/preset-safe.test/actual.js +6 -4
  208. package/node/v5.0.0/preset-safe.test/expected.js +9 -6
  209. package/node/v5.0.0/root-ref.test/expected.js +4 -4
  210. package/node/v5.0.0/skeleton-variant.js +3 -5
  211. package/node/v5.0.0/table-props.js +4 -9
  212. package/node/v5.0.0/table-props.test/actual.js +4 -5
  213. package/node/v5.0.0/table-props.test/expected.js +4 -5
  214. package/node/v5.0.0/tabs-scroll-buttons.js +4 -5
  215. package/node/v5.0.0/theme-spacing.test/large-actual.js +11 -11
  216. package/node/v5.0.0/theme-spacing.test/large-expected.js +11 -11
  217. package/node/v5.0.0/variant-prop.test/actual.js +12 -6
  218. package/node/v5.0.0/variant-prop.test/expected.js +15 -12
  219. package/node/v5.0.0/with-mobile-dialog.test/expected.js +6 -5
  220. package/node/v5.0.0/with-width.test/expected.js +6 -5
  221. package/node/v6.0.0/all/v6-all.js +4 -5
  222. package/node/v6.0.0/grid-v2-props/grid-v2-props.js +142 -0
  223. package/node/v6.0.0/grid-v2-props/index.js +13 -0
  224. package/node/v6.0.0/grid-v2-props/test-cases/actual.js +89 -0
  225. package/node/v6.0.0/grid-v2-props/test-cases/custom-breakpoints.actual.js +18 -0
  226. package/node/v6.0.0/grid-v2-props/test-cases/custom-breakpoints.expected.js +22 -0
  227. package/node/v6.0.0/grid-v2-props/test-cases/expected.js +101 -0
  228. package/node/v6.0.0/list-item-button-prop/index.js +13 -0
  229. package/node/v6.0.0/list-item-button-prop/list-item-button-prop.js +93 -0
  230. package/node/v6.0.0/list-item-button-prop/test-cases/actual.js +31 -0
  231. package/node/v6.0.0/list-item-button-prop/test-cases/expected.js +20 -0
  232. package/node/v6.0.0/list-item-button-prop/test-cases/theme.actual.js +20 -0
  233. package/node/v6.0.0/list-item-button-prop/test-cases/theme.expected.js +24 -0
  234. package/node/v6.0.0/styled/styled-v6.js +2 -415
  235. package/node/v6.0.0/styled/test-cases/BasicStyled.actual.js +55 -44
  236. package/node/v6.0.0/styled/test-cases/BasicStyled.expected.js +5 -6
  237. package/node/v6.0.0/styled/test-cases/ConditionalStyled.actual.js +98 -61
  238. package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +54 -29
  239. package/node/v6.0.0/styled/test-cases/DynamicPropsStyled.actual.js +39 -0
  240. package/node/v6.0.0/styled/test-cases/DynamicPropsStyled.expected.js +65 -0
  241. package/node/v6.0.0/styled/test-cases/LogicalStyled.actual.js +31 -1
  242. package/node/v6.0.0/styled/test-cases/LogicalStyled.expected.js +39 -1
  243. package/node/v6.0.0/styled/test-cases/NestedSpread.actual.js +33 -28
  244. package/node/v6.0.0/styled/test-cases/NestedSpread.expected.js +20 -22
  245. package/node/v6.0.0/styled/test-cases/ThemePaletteMode.expected.js +28 -26
  246. package/node/v6.0.0/styled/test-cases/VariantAndModeStyled.actual.js +6 -5
  247. package/node/v6.0.0/styled/test-cases/VariantAndModeStyled.expected.js +8 -8
  248. package/node/v6.0.0/sx-prop/index.js +13 -0
  249. package/node/v6.0.0/sx-prop/sx-v6.js +411 -0
  250. package/node/v6.0.0/sx-prop/test-cases/basic-sx.actual.js +36 -0
  251. package/node/v6.0.0/sx-prop/test-cases/basic-sx.expected.js +46 -0
  252. package/node/v6.0.0/sx-prop/test-cases/sx-applyStyles.actual.js +89 -0
  253. package/node/v6.0.0/sx-prop/test-cases/sx-applyStyles.expected.js +82 -0
  254. package/node/v6.0.0/sx-prop/test-cases/sx-condition.actual.js +92 -0
  255. package/node/v6.0.0/sx-prop/test-cases/sx-condition.expected.js +89 -0
  256. package/node/v6.0.0/sx-prop/test-cases/sx-css-vars.actual.js +55 -0
  257. package/node/v6.0.0/sx-prop/test-cases/sx-css-vars.expected.js +88 -0
  258. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic.actual.js +107 -0
  259. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic.expected.js +120 -0
  260. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic2.actual.js +49 -0
  261. package/node/v6.0.0/sx-prop/test-cases/sx-dynamic2.expected.js +64 -0
  262. package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.actual.js +17 -0
  263. package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.expected.js +17 -0
  264. package/node/v6.0.0/sx-prop/test-cases/sx-line-break.actual.js +69 -0
  265. package/node/v6.0.0/sx-prop/test-cases/sx-line-break.expected.js +69 -0
  266. package/node/v6.0.0/sx-prop/test-cases/sx-value-callback.actual.js +102 -0
  267. package/node/v6.0.0/sx-prop/test-cases/sx-value-callback.expected.js +111 -0
  268. package/node/v6.0.0/system-props/index.js +13 -0
  269. package/node/v6.0.0/system-props/removeSystemProps.js +233 -0
  270. package/node/v6.0.0/system-props/test-cases/system-props.actual.js +83 -0
  271. package/node/v6.0.0/system-props/test-cases/system-props.expected.js +98 -0
  272. package/node/v6.0.0/theme-v6/index.js +13 -0
  273. package/node/v6.0.0/theme-v6/test-cases/basicTheme.actual.js +559 -0
  274. package/node/v6.0.0/theme-v6/test-cases/basicTheme.expected.js +644 -0
  275. package/node/v6.0.0/theme-v6/test-cases/themeVariants.actual.js +65 -0
  276. package/node/v6.0.0/theme-v6/test-cases/themeVariants.expected.js +74 -0
  277. package/node/v6.0.0/theme-v6/theme-v6.js +86 -0
  278. package/package.json +11 -11
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = styledV6;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- const MAX_DEPTH = 20;
10
-
8
+ var _migrateToVariants = _interopRequireDefault(require("../../util/migrateToVariants"));
11
9
  /**
12
10
  * @param {import('jscodeshift').FileInfo} file
13
11
  * @param {import('jscodeshift').API} api
@@ -16,204 +14,6 @@ function styledV6(file, api, options) {
16
14
  const j = api.jscodeshift;
17
15
  const root = j(file.source);
18
16
  const printOptions = options.printOptions;
19
- function createBuildStyle(key, upperBuildStyle) {
20
- return function buildStyle(styleExpression) {
21
- if (key) {
22
- if (key.type === 'Identifier' || key.type === 'StringLiteral') {
23
- return upperBuildStyle(j.objectExpression([j.objectProperty(key, styleExpression)]));
24
- }
25
- if (key.type === 'TemplateLiteral') {
26
- return upperBuildStyle(j.objectExpression([(0, _extends2.default)({}, j.objectProperty(key, styleExpression), {
27
- computed: true
28
- })]));
29
- }
30
- }
31
- return upperBuildStyle ? upperBuildStyle(styleExpression) : styleExpression;
32
- };
33
- }
34
-
35
- /**
36
- *
37
- * @param {import('ast-types').namedTypes.MemberExpression | import('ast-types').namedTypes.Identifier} node
38
- */
39
- function getIdentifierKey(node) {
40
- if (node.type === 'MemberExpression') {
41
- return node.property;
42
- }
43
- return node;
44
- }
45
-
46
- /**
47
- *
48
- * @param {import('ast-types').namedTypes.UnaryExpression | import('ast-types').namedTypes.MemberExpression | import('ast-types').namedTypes.Identifier} node
49
- */
50
- function getObjectKey(node) {
51
- let tempNode = (0, _extends2.default)({}, node);
52
- while (tempNode.type === 'UnaryExpression') {
53
- tempNode = tempNode.argument;
54
- }
55
- while (tempNode.type === 'MemberExpression') {
56
- tempNode = tempNode.object;
57
- }
58
- return tempNode;
59
- }
60
-
61
- /**
62
- *
63
- * @param {import('ast-types').namedTypes.ObjectExpression} objectExpression
64
- * @param {import('ast-types').namedTypes.BinaryExpression} addtional
65
- */
66
- function objectToArrowFunction(objectExpression, addtional) {
67
- const paramKeys = new Set();
68
- let left;
69
- objectExpression.properties.forEach((prop, index) => {
70
- paramKeys.add(prop.key.name);
71
- const result = j.binaryExpression('===', prop.key, prop.value);
72
- if (index === 0) {
73
- left = result;
74
- } else {
75
- left = j.logicalExpression('&&', left, result);
76
- }
77
- });
78
- if (addtional) {
79
- paramKeys.add(getObjectKey(addtional.left).name);
80
- }
81
- return buildArrowFunctionAST(paramKeys, addtional ? j.logicalExpression('&&', left, addtional) : left);
82
- }
83
-
84
- /**
85
- *
86
- * @param {import('ast-types').namedTypes.Identifier | import('ast-types').namedTypes.BinaryExpression | import('ast-types').namedTypes.UnaryExpression} node
87
- */
88
- function inverseBinaryExpression(node) {
89
- if (node.type === 'Identifier') {
90
- return j.unaryExpression('!', node);
91
- }
92
- if (node.operator === '===') {
93
- return (0, _extends2.default)({}, node, {
94
- operator: '!=='
95
- });
96
- }
97
- if (node.operator === '!==') {
98
- return (0, _extends2.default)({}, node, {
99
- operator: '==='
100
- });
101
- }
102
- if (node.operator === '!') {
103
- var _node$argument;
104
- if (((_node$argument = node.argument) == null ? void 0 : _node$argument.operator) === '!') {
105
- return node.argument;
106
- }
107
- return j.unaryExpression('!', node);
108
- }
109
- return node;
110
- }
111
-
112
- /**
113
- *
114
- * @param {import('ast-types').namedTypes.ObjectExpression} node
115
- */
116
- function removeProperty(parentNode, child) {
117
- if (parentNode) {
118
- if (parentNode.type === 'ObjectExpression') {
119
- parentNode.properties = parentNode.properties.filter(prop => prop !== child && prop.value !== child);
120
- }
121
- }
122
- }
123
- function buildObjectAST(jsObject) {
124
- const result = j.objectExpression([]);
125
- Object.entries(jsObject).forEach(([key, value]) => {
126
- result.properties.push(j.objectProperty(j.identifier(key), value));
127
- });
128
- return result;
129
- }
130
- function buildArrowFunctionAST(params, body) {
131
- return j.arrowFunctionExpression([j.objectPattern([...params].map(k => (0, _extends2.default)({}, j.objectProperty(j.identifier(k), j.identifier(k)), {
132
- shorthand: true
133
- })))], body);
134
- }
135
-
136
- /**
137
- *
138
- * @param {{ properties: any[] }} node
139
- * @param {Record<string, any[]>} modeStyles
140
- */
141
- function appendPaletteModeStyles(node, modeStyles) {
142
- Object.entries(modeStyles).forEach(([mode, objectStyles]) => {
143
- node.properties.push(j.spreadElement(j.callExpression(j.memberExpression(j.identifier('theme'), j.identifier('applyStyles')), [j.stringLiteral(mode), j.objectExpression(objectStyles)])));
144
- });
145
- }
146
-
147
- /**
148
- *
149
- * @param {import('ast-types').namedTypes.LogicalExpression | import('ast-types').namedTypes.BinaryExpression | import('ast-types').namedTypes.UnaryExpression | import('ast-types').namedTypes.MemberExpression} node
150
- */
151
- function buildProps(node) {
152
- const properties = [];
153
- const variables = new Set();
154
- let isAllEqual = true;
155
- let tempNode = (0, _extends2.default)({}, node);
156
- function assignProperties(_node) {
157
- if (_node.type === 'BinaryExpression') {
158
- variables.add(getObjectKey(_node.left).name);
159
- if (_node.operator === '===') {
160
- properties.push(j.objectProperty(getIdentifierKey(_node.left), _node.right));
161
- } else {
162
- isAllEqual = false;
163
- }
164
- }
165
- if (_node.type === 'MemberExpression' || _node.type === 'Identifier') {
166
- isAllEqual = false;
167
- variables.add(getObjectKey(_node).name);
168
- }
169
- if (_node.type === 'UnaryExpression') {
170
- isAllEqual = false;
171
- if (_node.argument.type === 'UnaryExpression') {
172
- // handle `!!variable`
173
- variables.add(getObjectKey(_node.argument.argument).name);
174
- } else {
175
- // handle `!variable`
176
- variables.add(getObjectKey(_node.argument).name);
177
- }
178
- }
179
- }
180
- let counter = 0;
181
- if (tempNode.type !== 'LogicalExpression') {
182
- assignProperties(tempNode);
183
- } else {
184
- while (tempNode.type === 'LogicalExpression' && counter < MAX_DEPTH) {
185
- counter += 1;
186
- if (tempNode.operator !== '&&') {
187
- isAllEqual = false;
188
- }
189
- assignProperties(tempNode.right);
190
- if (tempNode.left.type !== 'LogicalExpression') {
191
- assignProperties(tempNode.left);
192
- break;
193
- }
194
- tempNode = (0, _extends2.default)({}, tempNode.left);
195
- }
196
- }
197
- if (!isAllEqual) {
198
- return buildArrowFunctionAST(variables, node);
199
- }
200
- return j.objectExpression(properties);
201
- }
202
- function mergeProps(parentProps, currentProps) {
203
- if (parentProps.type === 'ObjectExpression' && currentProps.type === 'ObjectExpression') {
204
- return j.objectExpression([...parentProps.properties, ...currentProps.properties]);
205
- }
206
- const parentArrow = parentProps.type === 'ObjectExpression' ? objectToArrowFunction(parentProps) : parentProps;
207
- const currentArrow = currentProps.type === 'ObjectExpression' ? objectToArrowFunction(currentProps) : currentProps;
208
- const variables = new Set();
209
- [...parentArrow.params[0].properties, ...currentArrow.params[0].properties].forEach(param => {
210
- variables.add(param.key.name);
211
- });
212
- return buildArrowFunctionAST(variables, j.logicalExpression('&&', parentArrow.body, currentArrow.body));
213
- }
214
- function isThemePaletteMode(node) {
215
- return node.type === 'MemberExpression' && node.object.type === 'MemberExpression' && node.object.object.name === 'theme' && node.object.property.name === 'palette' && node.property.name === 'mode';
216
- }
217
17
  let shouldTransform = false;
218
18
  root.find(j.CallExpression).forEach(path => {
219
19
  const styles = [];
@@ -238,220 +38,7 @@ function styledV6(file, api, options) {
238
38
  if (!shouldTransform && styles.length > 0) {
239
39
  shouldTransform = true;
240
40
  }
241
-
242
- // 2. Find logical spread expressions to convert to variants
243
- styles.forEach(style => {
244
- const parameters = new Set();
245
- style.params.forEach(param => {
246
- if (param.type === 'ObjectPattern') {
247
- param.properties.forEach(prop => {
248
- parameters.add(prop.key.name);
249
- });
250
- }
251
- });
252
- const variants = [];
253
- if (style.body.type === 'LogicalExpression') {
254
- if (style.params[0] && style.params[0].type === 'ObjectPattern' && style.params[0].properties.some(prop => prop.key.name !== 'theme')) {
255
- // case: ({ theme, ownerState }) => ownerState.variant === 'regular' && theme.mixins.toolbar
256
- style.body = j.objectExpression([j.objectProperty(j.identifier('variants'), j.arrayExpression([j.objectExpression([j.objectProperty(j.identifier('props'), buildProps(style.body.left)), j.objectProperty(j.identifier('style'), style.body.right)])]))]);
257
- }
258
- } else if (style.body.type === 'ConditionalExpression') {
259
- // skip ConditionalExpression
260
- } else {
261
- let objectExpression = style.body;
262
- let counter = 0;
263
- while (objectExpression.type !== 'ObjectExpression' && counter < MAX_DEPTH) {
264
- counter += 1;
265
- if (objectExpression.type === 'BlockStatement') {
266
- objectExpression = objectExpression.body.find(item => item.type === 'ReturnStatement').argument;
267
- }
268
- }
269
- recurseObjectExpression({
270
- node: objectExpression,
271
- buildStyle: createBuildStyle()
272
- });
273
- if (variants.length) {
274
- objectExpression.properties.push(j.objectProperty(j.identifier('variants'), j.arrayExpression(variants.filter(variant => {
275
- const props = variant.properties.find(prop => prop.key.name === 'props');
276
- const styleVal = variant.properties.find(prop => prop.key.name === 'style');
277
- return props && styleVal && styleVal.value.properties.length > 0 && (props.value.type === 'ArrowFunctionExpression' || props.value.properties.length > 0);
278
- }))));
279
- }
280
- }
281
- function recurseObjectExpression(data) {
282
- if (data.node.type === 'ObjectExpression') {
283
- const modeStyles = {}; // to collect styles from `theme.palette.mode === '...'`
284
- data.node.properties.forEach(prop => {
285
- if (prop.type === 'ObjectProperty') {
286
- recurseObjectExpression((0, _extends2.default)({}, data, {
287
- node: prop.value,
288
- parentNode: data.node,
289
- key: prop.key,
290
- buildStyle: createBuildStyle(prop.key, data.buildStyle),
291
- replaceValue: newValue => {
292
- prop.value = newValue;
293
- },
294
- modeStyles
295
- }));
296
- } else {
297
- recurseObjectExpression((0, _extends2.default)({}, data, {
298
- node: prop,
299
- parentNode: data.node,
300
- buildStyle: createBuildStyle(prop.key, data.buildStyle)
301
- }));
302
- }
303
- });
304
- appendPaletteModeStyles(data.node, modeStyles);
305
- }
306
- if (data.node.type === 'SpreadElement') {
307
- if (data.node.argument.type === 'LogicalExpression') {
308
- var _getObjectKey;
309
- const paramName = (_getObjectKey = getObjectKey(data.node.argument.left)) == null ? void 0 : _getObjectKey.name;
310
- if (paramName && !parameters.has(paramName)) {
311
- return;
312
- }
313
- const scopeProps = buildProps(data.node.argument.left);
314
- const variant = {
315
- props: data.props ? mergeProps(data.props, scopeProps) : scopeProps,
316
- style: data.node.argument.right
317
- };
318
- const lastLength = variants.push({}); // preserve the order of the recursive calls
319
-
320
- const modeStyles = {}; // to collect styles from `theme.palette.mode === '...'`
321
- variant.style.properties.forEach(prop => {
322
- if (prop.type === 'ObjectProperty') {
323
- recurseObjectExpression((0, _extends2.default)({}, data, {
324
- node: prop.value,
325
- parentNode: variant.style,
326
- props: variant.props,
327
- key: prop.key,
328
- buildStyle: createBuildStyle(prop.key, data.buildStyle),
329
- replaceValue: newValue => {
330
- prop.value = newValue;
331
- },
332
- modeStyles
333
- }));
334
- } else {
335
- recurseObjectExpression((0, _extends2.default)({}, data, {
336
- node: prop,
337
- parentNode: variant.style,
338
- props: variant.props,
339
- buildStyle: createBuildStyle(prop.key, data.buildStyle)
340
- }));
341
- }
342
- });
343
- appendPaletteModeStyles(variant.style, modeStyles);
344
- variant.style = data.buildStyle(variant.style);
345
- variants[lastLength - 1] = buildObjectAST(variant);
346
- removeProperty(data.parentNode, data.node);
347
- }
348
- if (data.node.argument.type === 'ConditionalExpression') {
349
- recurseObjectExpression((0, _extends2.default)({}, data, {
350
- node: data.node.argument,
351
- parentNode: data.node
352
- }));
353
- removeProperty(data.parentNode, data.node);
354
- }
355
- }
356
- if (data.node.type === 'ConditionalExpression') {
357
- if (data.node.test.type === 'BinaryExpression' || data.node.test.type === 'UnaryExpression' || data.node.test.type === 'Identifier') {
358
- var _getObjectKey2, _data$parentNode2, _data$node$test;
359
- let leftName = (_getObjectKey2 = getObjectKey(data.node.test)) == null ? void 0 : _getObjectKey2.name;
360
- if (data.node.test.left) {
361
- var _getObjectKey3;
362
- leftName = (_getObjectKey3 = getObjectKey(data.node.test.left)) == null ? void 0 : _getObjectKey3.name;
363
- }
364
- if (data.node.test.argument) {
365
- var _getObjectKey4;
366
- leftName = (_getObjectKey4 = getObjectKey(data.node.test.argument)) == null ? void 0 : _getObjectKey4.name;
367
- }
368
- if (parameters.has(leftName) && leftName !== 'theme') {
369
- var _data$parentNode;
370
- let props = buildProps(data.node.test);
371
- if (data.props) {
372
- props = mergeProps(data.props, props);
373
- }
374
- const styleVal = data.buildStyle(data.node.consequent);
375
- const variant = {
376
- props,
377
- style: styleVal
378
- };
379
- variants.push(buildObjectAST(variant));
380
-
381
- // create another variant with inverted condition
382
- let props2 = buildProps(inverseBinaryExpression(data.node.test));
383
- if (data.props) {
384
- props2 = mergeProps(data.props, props2);
385
- }
386
- const styleVal2 = data.buildStyle(data.node.alternate);
387
- const variant2 = {
388
- props: props2,
389
- style: styleVal2
390
- };
391
- variants.push(buildObjectAST(variant2));
392
- if (((_data$parentNode = data.parentNode) == null ? void 0 : _data$parentNode.type) === 'ObjectExpression') {
393
- removeProperty(data.parentNode, data.node);
394
- }
395
- }
396
- 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)) {
397
- if (data.node.consequent.type !== 'ObjectExpression' && data.node.alternate.type !== 'ObjectExpression') {
398
- var _data$replaceValue;
399
- if (data.modeStyles) {
400
- if (!data.modeStyles[data.node.test.right.value]) {
401
- data.modeStyles[data.node.test.right.value] = [];
402
- }
403
- data.modeStyles[data.node.test.right.value].push(j.objectProperty(data.key, data.node.consequent));
404
- }
405
- (_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, data.node.alternate);
406
- }
407
- }
408
- }
409
- }
410
- if (data.node.type === 'TemplateLiteral') {
411
- var _data$parentNode3;
412
- if (((_data$parentNode3 = data.parentNode) == null ? void 0 : _data$parentNode3.type) === 'ObjectExpression') {
413
- const modeStyles = {};
414
- data.node.expressions.forEach((expression, index) => {
415
- recurseObjectExpression((0, _extends2.default)({}, data, {
416
- node: expression,
417
- parentNode: data.parentNode,
418
- buildStyle: createBuildStyle(data.key, data.buildStyle),
419
- replaceValue: newValue => {
420
- data.node.expressions[index] = newValue;
421
- },
422
- modeStyles
423
- }));
424
- });
425
- if (data.modeStyles) {
426
- Object.entries(modeStyles).forEach(([mode, objectStyles]) => {
427
- const clonedNode = (0, _extends2.default)({}, data.node, {
428
- expressions: data.node.expressions.map(expression => (0, _extends2.default)({}, expression))
429
- });
430
- clonedNode.expressions = objectStyles.map(item => item.value);
431
- if (!data.modeStyles[mode]) {
432
- data.modeStyles[mode] = [];
433
- }
434
- data.modeStyles[mode].push(j.objectProperty(data.key, clonedNode));
435
- });
436
- }
437
- }
438
- }
439
- if (data.key && data.key.type === 'Identifier' && data.node.type === 'MemberExpression' && data.node.object.type === 'ObjectExpression' && parameters.has(getObjectKey(data.node.property).name)) {
440
- data.node.object.properties.forEach(prop => {
441
- variants.push(buildObjectAST({
442
- props: j.objectExpression([j.objectProperty(getIdentifierKey(data.node.property), j.stringLiteral(prop.key.name))]),
443
- style: data.buildStyle(prop.value)
444
- }));
445
- });
446
- removeProperty(data.parentNode, data.node);
447
- }
448
- }
449
- style.params.forEach(param => {
450
- if (param.type === 'ObjectPattern') {
451
- param.properties = param.properties.filter(prop => prop.key.name === 'theme');
452
- }
453
- });
454
- });
41
+ (0, _migrateToVariants.default)(j, styles);
455
42
 
456
43
  // Replace arrow function with object expression if the arg properties is empty
457
44
  args.forEach((arg, index) => {
@@ -1,78 +1,89 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
5
3
  const FormHelperTextRoot = styled('p')(({
6
4
  theme,
7
5
  ownerState,
8
6
  disabled
9
- }) => (0, _extends2.default)({
10
- color: (theme.vars || theme).palette.text.secondary
11
- }, theme.typography.caption, {
7
+ }) => ({
8
+ color: (theme.vars || theme).palette.text.secondary,
9
+ ...theme.typography.caption,
12
10
  textAlign: 'left',
13
11
  [`&.${formHelperTextClasses.disabled}`]: {
14
12
  color: (theme.vars || theme).palette.text.disabled
15
- }
16
- }, ownerState.size === 'small' && {
17
- marginTop: 4
18
- }, ownerState.size === 'small' && ownerState.variant === 'contained' && {
19
- marginTop: 6
20
- }, ownerState.size === 'small' && ownerState.variant === 'contained' && disabled && {
21
- marginTop: 6
22
- }, ownerState.size !== 'small' && {
23
- marginBottom: 4
24
- }, ownerState.size !== 'small' && ownerState.variant !== 'contained' && !disabled && {
25
- marginBottom: 6
26
- }, ownerState.contained && {
27
- marginLeft: 14,
28
- marginRight: 14
29
- }, !ownerState.contained && {
30
- marginTop: 14,
31
- marginBottom: 14
32
- }, !!ownerState.disabled && {
33
- opacity: 0.5
13
+ },
14
+ ...(ownerState.size === 'small' && {
15
+ marginTop: 4
16
+ }),
17
+ ...(ownerState.size === 'small' && ownerState.variant === 'contained' && {
18
+ marginTop: 6
19
+ }),
20
+ ...(ownerState.size === 'small' && ownerState.variant === 'contained' && disabled && {
21
+ marginTop: 6
22
+ }),
23
+ ...(ownerState.size !== 'small' && {
24
+ marginBottom: 4
25
+ }),
26
+ ...(ownerState.size !== 'small' && ownerState.variant !== 'contained' && !disabled && {
27
+ marginBottom: 6
28
+ }),
29
+ ...(ownerState.contained && {
30
+ marginLeft: 14,
31
+ marginRight: 14
32
+ }),
33
+ ...(!ownerState.contained && {
34
+ marginTop: 14,
35
+ marginBottom: 14
36
+ }),
37
+ ...(!!ownerState.disabled && {
38
+ opacity: 0.5
39
+ })
34
40
  }));
35
41
  const Component = styled.div(({
36
42
  theme,
37
43
  ownerState
38
- }) => (0, _extends2.default)({}, theme.typography.caption, ownerState.size === 'small' && {
39
- marginTop: (theme.vars || theme).spacing(1)
44
+ }) => ({
45
+ ...theme.typography.caption,
46
+ ...(ownerState.size === 'small' && {
47
+ marginTop: (theme.vars || theme).spacing(1)
48
+ })
40
49
  }));
41
50
  const ImageListRoot = styled('ul')(({
42
51
  ownerState
43
52
  }) => {
44
- return (0, _extends2.default)({
53
+ return {
45
54
  display: 'grid',
46
55
  overflowY: 'auto',
47
56
  listStyle: 'none',
48
57
  padding: 0,
49
58
  // Add iOS momentum scrolling for iOS < 13.0
50
- WebkitOverflowScrolling: 'touch'
51
- }, ownerState.variant === 'masonry' && {
52
- display: 'block'
53
- });
59
+ WebkitOverflowScrolling: 'touch',
60
+ ...(ownerState.variant === 'masonry' && {
61
+ display: 'block'
62
+ })
63
+ };
54
64
  });
55
65
  const ImageListItemRoot = styled('li')(({
56
66
  ownerState
57
67
  }) => ({
58
68
  display: 'block',
59
69
  position: 'relative',
60
- [`& .${imageListItemClasses.img}`]: (0, _extends2.default)({
70
+ [`& .${imageListItemClasses.img}`]: {
61
71
  objectFit: 'cover',
62
72
  width: '100%',
63
73
  height: '100%',
64
- display: 'block'
65
- }, ownerState.variant === 'standard' && {
66
- height: 'auto',
67
- flexGrow: 1
68
- }, {
74
+ display: 'block',
75
+ ...(ownerState.variant === 'standard' && {
76
+ height: 'auto',
77
+ flexGrow: 1
78
+ }),
69
79
  '&:hover': {
70
- '&[data-shape="circular"]': (0, _extends2.default)({
71
- borderRadius: '50%'
72
- }, ownerState.variant === 'unique' && {
73
- height: 'auto',
74
- flexGrow: 1
75
- })
80
+ '&[data-shape="circular"]': {
81
+ borderRadius: '50%',
82
+ ...(ownerState.variant === 'unique' && {
83
+ height: 'auto',
84
+ flexGrow: 1
85
+ })
86
+ }
76
87
  }
77
- })
88
+ }
78
89
  }));
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
5
3
  const FormHelperTextRoot = styled('p')(({
6
4
  theme
7
- }) => (0, _extends2.default)({
8
- color: (theme.vars || theme).palette.text.secondary
9
- }, theme.typography.caption, {
5
+ }) => ({
6
+ color: (theme.vars || theme).palette.text.secondary,
7
+ ...theme.typography.caption,
10
8
  textAlign: 'left',
11
9
  [`&.${formHelperTextClasses.disabled}`]: {
12
10
  color: (theme.vars || theme).palette.text.disabled
@@ -76,7 +74,8 @@ const FormHelperTextRoot = styled('p')(({
76
74
  }));
77
75
  const Component = styled.div(({
78
76
  theme
79
- }) => (0, _extends2.default)({}, theme.typography.caption, {
77
+ }) => ({
78
+ ...theme.typography.caption,
80
79
  variants: [{
81
80
  props: {
82
81
  size: 'small'