@openrewrite/recipes-react 0.21.0 → 0.23.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 (243) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +27 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/migration/change-component-prop-value.d.ts.map +1 -1
  6. package/dist/migration/change-component-prop-value.js +14 -4
  7. package/dist/migration/change-component-prop-value.js.map +1 -1
  8. package/dist/mui/adapt-v4-theme.d.ts +8 -0
  9. package/dist/mui/adapt-v4-theme.d.ts.map +1 -0
  10. package/dist/mui/adapt-v4-theme.js +65 -0
  11. package/dist/mui/adapt-v4-theme.js.map +1 -0
  12. package/dist/mui/add-component-prop.d.ts +18 -0
  13. package/dist/mui/add-component-prop.d.ts.map +1 -0
  14. package/dist/mui/add-component-prop.js +53 -0
  15. package/dist/mui/add-component-prop.js.map +1 -0
  16. package/dist/mui/add-emotion-prepend.d.ts +8 -0
  17. package/dist/mui/add-emotion-prepend.d.ts.map +1 -0
  18. package/dist/mui/add-emotion-prepend.js +71 -0
  19. package/dist/mui/add-emotion-prepend.js.map +1 -0
  20. package/dist/mui/change-module-specifier.d.ts +14 -0
  21. package/dist/mui/change-module-specifier.d.ts.map +1 -0
  22. package/dist/mui/change-module-specifier.js +95 -0
  23. package/dist/mui/change-module-specifier.js.map +1 -0
  24. package/dist/mui/convert-mui-imports.d.ts +14 -0
  25. package/dist/mui/convert-mui-imports.d.ts.map +1 -0
  26. package/dist/mui/convert-mui-imports.js +195 -0
  27. package/dist/mui/convert-mui-imports.js.map +1 -0
  28. package/dist/mui/convert-prop-to-sx.d.ts +22 -0
  29. package/dist/mui/convert-prop-to-sx.d.ts.map +1 -0
  30. package/dist/mui/convert-prop-to-sx.js +99 -0
  31. package/dist/mui/convert-prop-to-sx.js.map +1 -0
  32. package/dist/mui/index.d.ts +32 -0
  33. package/dist/mui/index.d.ts.map +1 -0
  34. package/dist/mui/index.js +67 -0
  35. package/dist/mui/index.js.map +1 -0
  36. package/dist/mui/jsx-attributes.d.ts +27 -0
  37. package/dist/mui/jsx-attributes.d.ts.map +1 -0
  38. package/dist/mui/jsx-attributes.js +140 -0
  39. package/dist/mui/jsx-attributes.js.map +1 -0
  40. package/dist/mui/mark-manual-migration.d.ts +16 -0
  41. package/dist/mui/mark-manual-migration.d.ts.map +1 -0
  42. package/dist/mui/mark-manual-migration.js +73 -0
  43. package/dist/mui/mark-manual-migration.js.map +1 -0
  44. package/dist/mui/mark-palette-mode-usage.d.ts +12 -0
  45. package/dist/mui/mark-palette-mode-usage.d.ts.map +1 -0
  46. package/dist/mui/mark-palette-mode-usage.js +50 -0
  47. package/dist/mui/mark-palette-mode-usage.js.map +1 -0
  48. package/dist/mui/move-component-prop-to-slot.d.ts +22 -0
  49. package/dist/mui/move-component-prop-to-slot.d.ts.map +1 -0
  50. package/dist/mui/move-component-prop-to-slot.js +87 -0
  51. package/dist/mui/move-component-prop-to-slot.js.map +1 -0
  52. package/dist/mui/move-primary-text-to-children.d.ts +12 -0
  53. package/dist/mui/move-primary-text-to-children.d.ts.map +1 -0
  54. package/dist/mui/move-primary-text-to-children.js +52 -0
  55. package/dist/mui/move-primary-text-to-children.js.map +1 -0
  56. package/dist/mui/move-system-props-to-sx.d.ts +16 -0
  57. package/dist/mui/move-system-props-to-sx.d.ts.map +1 -0
  58. package/dist/mui/move-system-props-to-sx.js +122 -0
  59. package/dist/mui/move-system-props-to-sx.js.map +1 -0
  60. package/dist/mui/mui-components.d.ts +8 -0
  61. package/dist/mui/mui-components.d.ts.map +1 -0
  62. package/dist/mui/mui-components.js +41 -0
  63. package/dist/mui/mui-components.js.map +1 -0
  64. package/dist/mui/mui-tag-visitor.d.ts +5 -0
  65. package/dist/mui/mui-tag-visitor.d.ts.map +1 -0
  66. package/dist/mui/mui-tag-visitor.js +54 -0
  67. package/dist/mui/mui-tag-visitor.js.map +1 -0
  68. package/dist/mui/pre-v5-recipe.d.ts +14 -0
  69. package/dist/mui/pre-v5-recipe.d.ts.map +1 -0
  70. package/dist/mui/pre-v5-recipe.js +88 -0
  71. package/dist/mui/pre-v5-recipe.js.map +1 -0
  72. package/dist/mui/remove-component-prop.d.ts +18 -0
  73. package/dist/mui/remove-component-prop.d.ts.map +1 -0
  74. package/dist/mui/remove-component-prop.js +55 -0
  75. package/dist/mui/remove-component-prop.js.map +1 -0
  76. package/dist/mui/remove-root-ref.d.ts +8 -0
  77. package/dist/mui/remove-root-ref.d.ts.map +1 -0
  78. package/dist/mui/remove-root-ref.js +61 -0
  79. package/dist/mui/remove-root-ref.js.map +1 -0
  80. package/dist/mui/remove-spacing-px-suffix.d.ts +8 -0
  81. package/dist/mui/remove-spacing-px-suffix.d.ts.map +1 -0
  82. package/dist/mui/remove-spacing-px-suffix.js +62 -0
  83. package/dist/mui/remove-spacing-px-suffix.js.map +1 -0
  84. package/dist/mui/rename-component-prop.d.ts +20 -0
  85. package/dist/mui/rename-component-prop.d.ts.map +1 -0
  86. package/dist/mui/rename-component-prop.js +66 -0
  87. package/dist/mui/rename-component-prop.js.map +1 -0
  88. package/dist/mui/rename-joy-css-variables.d.ts +8 -0
  89. package/dist/mui/rename-joy-css-variables.d.ts.map +1 -0
  90. package/dist/mui/rename-joy-css-variables.js +51 -0
  91. package/dist/mui/rename-joy-css-variables.js.map +1 -0
  92. package/dist/mui/rename-theme-palette-type.d.ts +8 -0
  93. package/dist/mui/rename-theme-palette-type.d.ts.map +1 -0
  94. package/dist/mui/rename-theme-palette-type.js +61 -0
  95. package/dist/mui/rename-theme-palette-type.js.map +1 -0
  96. package/dist/mui/replace-box-border-radius.d.ts +10 -0
  97. package/dist/mui/replace-box-border-radius.d.ts.map +1 -0
  98. package/dist/mui/replace-box-border-radius.js +50 -0
  99. package/dist/mui/replace-box-border-radius.js.map +1 -0
  100. package/dist/mui/replace-breakpoints-width.d.ts +8 -0
  101. package/dist/mui/replace-breakpoints-width.d.ts.map +1 -0
  102. package/dist/mui/replace-breakpoints-width.js +46 -0
  103. package/dist/mui/replace-breakpoints-width.js.map +1 -0
  104. package/dist/mui/replace-component-class.d.ts +18 -0
  105. package/dist/mui/replace-component-class.d.ts.map +1 -0
  106. package/dist/mui/replace-component-class.js +126 -0
  107. package/dist/mui/replace-component-class.js.map +1 -0
  108. package/dist/mui/replace-components-with-slots.d.ts +14 -0
  109. package/dist/mui/replace-components-with-slots.d.ts.map +1 -0
  110. package/dist/mui/replace-components-with-slots.js +69 -0
  111. package/dist/mui/replace-components-with-slots.js.map +1 -0
  112. package/dist/mui/replace-import-paths.d.ts +14 -0
  113. package/dist/mui/replace-import-paths.d.ts.map +1 -0
  114. package/dist/mui/replace-import-paths.js +101 -0
  115. package/dist/mui/replace-import-paths.js.map +1 -0
  116. package/dist/mui/replace-in-string-literals.d.ts +15 -0
  117. package/dist/mui/replace-in-string-literals.d.ts.map +1 -0
  118. package/dist/mui/replace-in-string-literals.js +62 -0
  119. package/dist/mui/replace-in-string-literals.js.map +1 -0
  120. package/dist/mui/replace-list-item-button-prop.d.ts +12 -0
  121. package/dist/mui/replace-list-item-button-prop.d.ts.map +1 -0
  122. package/dist/mui/replace-list-item-button-prop.js +80 -0
  123. package/dist/mui/replace-list-item-button-prop.js.map +1 -0
  124. package/dist/mui/replace-tabs-scroll-buttons.d.ts +8 -0
  125. package/dist/mui/replace-tabs-scroll-buttons.d.ts.map +1 -0
  126. package/dist/mui/replace-tabs-scroll-buttons.js +41 -0
  127. package/dist/mui/replace-tabs-scroll-buttons.js.map +1 -0
  128. package/dist/mui/replace-theme-color-functions.d.ts +8 -0
  129. package/dist/mui/replace-theme-color-functions.d.ts.map +1 -0
  130. package/dist/mui/replace-theme-color-functions.js +72 -0
  131. package/dist/mui/replace-theme-color-functions.js.map +1 -0
  132. package/dist/mui/replace-theme-spacing-unit.d.ts +8 -0
  133. package/dist/mui/replace-theme-spacing-unit.d.ts.map +1 -0
  134. package/dist/mui/replace-theme-spacing-unit.js +77 -0
  135. package/dist/mui/replace-theme-spacing-unit.js.map +1 -0
  136. package/dist/mui/replace-typography-round.d.ts +8 -0
  137. package/dist/mui/replace-typography-round.d.ts.map +1 -0
  138. package/dist/mui/replace-typography-round.js +44 -0
  139. package/dist/mui/replace-typography-round.js.map +1 -0
  140. package/dist/mui/shift-hidden-down-props.d.ts +10 -0
  141. package/dist/mui/shift-hidden-down-props.d.ts.map +1 -0
  142. package/dist/mui/shift-hidden-down-props.js +49 -0
  143. package/dist/mui/shift-hidden-down-props.js.map +1 -0
  144. package/dist/mui/theme-access.d.ts +5 -0
  145. package/dist/mui/theme-access.d.ts.map +1 -0
  146. package/dist/mui/theme-access.js +21 -0
  147. package/dist/mui/theme-access.js.map +1 -0
  148. package/dist/mui/update-theme-breakpoints.d.ts +10 -0
  149. package/dist/mui/update-theme-breakpoints.d.ts.map +1 -0
  150. package/dist/mui/update-theme-breakpoints.js +58 -0
  151. package/dist/mui/update-theme-breakpoints.js.map +1 -0
  152. package/dist/mui/upgrade-grid-props.d.ts +16 -0
  153. package/dist/mui/upgrade-grid-props.d.ts.map +1 -0
  154. package/dist/mui/upgrade-grid-props.js +90 -0
  155. package/dist/mui/upgrade-grid-props.js.map +1 -0
  156. package/dist/react19/use-context-hook.d.ts.map +1 -1
  157. package/dist/react19/use-context-hook.js +2 -0
  158. package/dist/react19/use-context-hook.js.map +1 -1
  159. package/dist/search/find-enzyme-usage.d.ts +4 -0
  160. package/dist/search/find-enzyme-usage.d.ts.map +1 -1
  161. package/dist/search/find-enzyme-usage.js +91 -7
  162. package/dist/search/find-enzyme-usage.js.map +1 -1
  163. package/dist/testing/enzyme-host-components.d.ts +12 -0
  164. package/dist/testing/enzyme-host-components.d.ts.map +1 -1
  165. package/dist/testing/enzyme-host-components.js +100 -0
  166. package/dist/testing/enzyme-host-components.js.map +1 -1
  167. package/dist/testing/enzyme-render-blockers.d.ts +13 -4
  168. package/dist/testing/enzyme-render-blockers.d.ts.map +1 -1
  169. package/dist/testing/enzyme-render-blockers.js +162 -6
  170. package/dist/testing/enzyme-render-blockers.js.map +1 -1
  171. package/dist/testing/enzyme-to-react-testing-library.d.ts +9 -2
  172. package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
  173. package/dist/testing/enzyme-to-react-testing-library.js +163 -16
  174. package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
  175. package/dist/testing/enzyme-usage.d.ts +7 -0
  176. package/dist/testing/enzyme-usage.d.ts.map +1 -1
  177. package/dist/testing/enzyme-usage.js +8 -1
  178. package/dist/testing/enzyme-usage.js.map +1 -1
  179. package/dist/testing/enzyme-wrapper-scope.d.ts +8 -5
  180. package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
  181. package/dist/testing/enzyme-wrapper-scope.js +16 -4
  182. package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
  183. package/dist/zustand/redux-stores.d.ts +2 -0
  184. package/dist/zustand/redux-stores.d.ts.map +1 -1
  185. package/dist/zustand/redux-stores.js +120 -6
  186. package/dist/zustand/redux-stores.js.map +1 -1
  187. package/dist/zustand/redux-to-zustand.d.ts.map +1 -1
  188. package/dist/zustand/redux-to-zustand.js +10 -4
  189. package/dist/zustand/redux-to-zustand.js.map +1 -1
  190. package/dist/zustand/zustand-plan.d.ts +7 -0
  191. package/dist/zustand/zustand-plan.d.ts.map +1 -1
  192. package/dist/zustand/zustand-plan.js +141 -21
  193. package/dist/zustand/zustand-plan.js.map +1 -1
  194. package/package.json +2 -2
  195. package/src/index.ts +10 -0
  196. package/src/migration/change-component-prop-value.ts +19 -8
  197. package/src/mui/adapt-v4-theme.ts +43 -0
  198. package/src/mui/add-component-prop.ts +43 -0
  199. package/src/mui/add-emotion-prepend.ts +48 -0
  200. package/src/mui/change-module-specifier.ts +71 -0
  201. package/src/mui/convert-mui-imports.ts +184 -0
  202. package/src/mui/convert-prop-to-sx.ts +89 -0
  203. package/src/mui/index.ts +31 -0
  204. package/src/mui/jsx-attributes.ts +133 -0
  205. package/src/mui/mark-manual-migration.ts +53 -0
  206. package/src/mui/mark-palette-mode-usage.ts +36 -0
  207. package/src/mui/move-component-prop-to-slot.ts +84 -0
  208. package/src/mui/move-primary-text-to-children.ts +41 -0
  209. package/src/mui/move-system-props-to-sx.ts +118 -0
  210. package/src/mui/mui-components.ts +40 -0
  211. package/src/mui/mui-tag-visitor.ts +36 -0
  212. package/src/mui/pre-v5-recipe.ts +82 -0
  213. package/src/mui/remove-component-prop.ts +43 -0
  214. package/src/mui/remove-root-ref.ts +41 -0
  215. package/src/mui/remove-spacing-px-suffix.ts +43 -0
  216. package/src/mui/rename-component-prop.ts +55 -0
  217. package/src/mui/rename-joy-css-variables.ts +41 -0
  218. package/src/mui/rename-theme-palette-type.ts +42 -0
  219. package/src/mui/replace-box-border-radius.ts +42 -0
  220. package/src/mui/replace-breakpoints-width.ts +28 -0
  221. package/src/mui/replace-component-class.ts +97 -0
  222. package/src/mui/replace-components-with-slots.ts +61 -0
  223. package/src/mui/replace-import-paths.ts +100 -0
  224. package/src/mui/replace-in-string-literals.ts +44 -0
  225. package/src/mui/replace-list-item-button-prop.ts +59 -0
  226. package/src/mui/replace-tabs-scroll-buttons.ts +31 -0
  227. package/src/mui/replace-theme-color-functions.ts +55 -0
  228. package/src/mui/replace-theme-spacing-unit.ts +59 -0
  229. package/src/mui/replace-typography-round.ts +29 -0
  230. package/src/mui/shift-hidden-down-props.ts +44 -0
  231. package/src/mui/theme-access.ts +18 -0
  232. package/src/mui/update-theme-breakpoints.ts +47 -0
  233. package/src/mui/upgrade-grid-props.ts +82 -0
  234. package/src/react19/use-context-hook.ts +2 -0
  235. package/src/search/find-enzyme-usage.ts +80 -7
  236. package/src/testing/enzyme-host-components.ts +110 -0
  237. package/src/testing/enzyme-render-blockers.ts +174 -9
  238. package/src/testing/enzyme-to-react-testing-library.ts +159 -25
  239. package/src/testing/enzyme-usage.ts +13 -0
  240. package/src/testing/enzyme-wrapper-scope.ts +27 -6
  241. package/src/zustand/redux-stores.ts +119 -5
  242. package/src/zustand/redux-to-zustand.ts +12 -5
  243. package/src/zustand/zustand-plan.ts +159 -18
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MoveSystemPropsToSx = void 0;
19
+ const rewrite_1 = require("@openrewrite/rewrite");
20
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
21
+ const jsx_attributes_1 = require("./jsx-attributes");
22
+ const mui_components_1 = require("./mui-components");
23
+ const theme_access_1 = require("./theme-access");
24
+ const mui_tag_visitor_1 = require("./mui-tag-visitor");
25
+ const SYSTEM_PROPS = new Set(["border", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "borderTopColor", "borderRightColor",
26
+ "borderBottomColor", "borderLeftColor", "outline", "outlineColor", "borderRadius", "color", "bgcolor", "backgroundColor", "p", "pt", "pr", "pb",
27
+ "pl", "px", "py", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "paddingX", "paddingY", "paddingInline",
28
+ "paddingInlineStart", "paddingInlineEnd", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "m", "mt", "mr", "mb", "ml", "mx", "my",
29
+ "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "marginX", "marginY", "marginInline", "marginInlineStart", "marginInlineEnd",
30
+ "marginBlock", "marginBlockStart", "marginBlockEnd", "displayPrint", "display", "overflow", "textOverflow", "visibility", "whiteSpace", "flexBasis",
31
+ "flexDirection", "flexWrap", "justifyContent", "alignItems", "alignContent", "order", "flex", "flexGrow", "flexShrink", "alignSelf",
32
+ "justifyItems", "justifySelf", "gap", "rowGap", "columnGap", "gridColumn", "gridRow", "gridAutoFlow", "gridAutoColumns", "gridAutoRows",
33
+ "gridTemplateColumns", "gridTemplateRows", "gridTemplateAreas", "gridArea", "position", "zIndex", "top", "right", "bottom", "left", "boxShadow",
34
+ "width", "maxWidth", "minWidth", "height", "maxHeight", "minHeight", "boxSizing", "font", "fontFamily", "fontSize", "fontStyle", "fontWeight",
35
+ "letterSpacing", "textTransform", "lineHeight", "textAlign", "typography"]);
36
+ const isSxColor = (value, keepInherit) => {
37
+ const text = (0, theme_access_1.stringValue)(value);
38
+ if (text === undefined)
39
+ return true;
40
+ return (!keepInherit && text === "inherit") || text.includes(".") || text === "divider" || text.startsWith("#") || /\(.*\)/.test(text);
41
+ };
42
+ class MoveSystemPropsToSx extends rewrite_1.Recipe {
43
+ constructor(options) {
44
+ super(options);
45
+ this.name = "org.openrewrite.react.mui.move-system-props-to-sx";
46
+ this.displayName = "Move system props into the `sx` prop";
47
+ this.description = "Moves the system props of Box, Stack, Typography, Link, Grid and the like into their `sx` prop. Tags with a spread attribute, or an `sx` that is not an object literal, are left alone.";
48
+ }
49
+ editor() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const names = new Set(this.componentNames.split(",").map(s => s.trim()));
52
+ const v9 = this.version === "v9";
53
+ const v6 = this.version === "v6";
54
+ const typographyLike = new Set(["Typography", ...(v9 ? ["DialogContentText", "TimelineContent", "TimelineOppositeContent"] : [])]);
55
+ const moves = (component, key, value) => {
56
+ if (!SYSTEM_PROPS.has(key))
57
+ return false;
58
+ if (typographyLike.has(component) && (v6 || v9))
59
+ return key !== "color" || isSxColor(value, !v9);
60
+ if (component === "Link" && v6)
61
+ return key !== "color";
62
+ if (component === "Link" && v9)
63
+ return key !== "color" || isSxColor(value, true);
64
+ return true;
65
+ };
66
+ return (0, mui_tag_visitor_1.muiTagEditor)(c => names.has(c), this.packageName, (visited, cursor, component) => __awaiter(this, void 0, void 0, function* () {
67
+ if ((0, jsx_attributes_1.hasSpread)(visited))
68
+ return visited;
69
+ const moved = visited.attributes.map(a => a.element).filter((a) => {
70
+ const key = (0, mui_components_1.attributeName)(a);
71
+ return a.kind === javascript_1.JS.Kind.JsxAttribute && !!key && !!a.value && moves(component, key, (0, jsx_attributes_1.attributeExpression)(a));
72
+ });
73
+ if (!moved.length)
74
+ return visited;
75
+ const sx = (0, jsx_attributes_1.findAttribute)(visited, "sx");
76
+ if (sx && !(0, jsx_attributes_1.attributeObject)(sx))
77
+ return visited;
78
+ return move(visited, moved, sx, cursor);
79
+ }));
80
+ });
81
+ }
82
+ }
83
+ exports.MoveSystemPropsToSx = MoveSystemPropsToSx;
84
+ __decorate([
85
+ (0, rewrite_1.Option)({ displayName: "Component names", description: "The components to migrate, separated by commas.", example: "Box,Stack,Typography,Link,Grid" })
86
+ ], MoveSystemPropsToSx.prototype, "componentNames", void 0);
87
+ __decorate([
88
+ (0, rewrite_1.Option)({ displayName: "Version", description: "`v6` or `v9`, which differ in what is kept as a prop of `Typography` and `Link`; anything else moves every system prop.", example: "v6", required: false })
89
+ ], MoveSystemPropsToSx.prototype, "version", void 0);
90
+ __decorate([
91
+ (0, rewrite_1.Option)({ displayName: "Package name", description: "A package that re-exports Material UI.", example: "@org/ui", required: false })
92
+ ], MoveSystemPropsToSx.prototype, "packageName", void 0);
93
+ function move(tag, moved, sx, cursor) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ const keyOf = (a) => (0, mui_components_1.attributeName)(a);
96
+ const valueOf = (a) => (0, jsx_attributes_1.bare)((0, jsx_attributes_1.attributeExpression)(a));
97
+ const existing = sx && (0, jsx_attributes_1.attributeObject)(sx);
98
+ const keys = existing ? new Set((0, jsx_attributes_1.objectProperties)(existing).map(p => { var _a, _b; return (_b = (_a = p.element.name) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.simpleName; })) : new Set();
99
+ const fresh = moved.filter(a => !keys.has(keyOf(a)));
100
+ let object = existing;
101
+ for (const attribute of fresh) {
102
+ object = object
103
+ ? (0, jsx_attributes_1.appendProperty)(object, yield (0, jsx_attributes_1.newProperty)(cursor, tag, keyOf(attribute), valueOf(attribute)))
104
+ : yield (0, jsx_attributes_1.newObject)(cursor, tag, keyOf(attribute), valueOf(attribute));
105
+ }
106
+ const movedSet = new Set(moved);
107
+ const first = moved[0];
108
+ let attributes = tag.attributes;
109
+ if (sx) {
110
+ const embedded = sx.value.element;
111
+ const updated = Object.assign(Object.assign({}, sx), { value: Object.assign(Object.assign({}, sx.value), { element: Object.assign(Object.assign({}, embedded), { expression: Object.assign(Object.assign({}, embedded.expression), { element: object }) }) }) });
112
+ attributes = attributes.filter(a => !movedSet.has(a.element)).map(a => a.element === sx ? Object.assign(Object.assign({}, a), { element: updated }) : a);
113
+ }
114
+ else {
115
+ const created = yield (0, jsx_attributes_1.newAttribute)(cursor, tag, "sx", object);
116
+ attributes = attributes.flatMap(a => a.element === first ? [Object.assign(Object.assign({}, a), { element: Object.assign(Object.assign({}, created), { prefix: first.prefix }) })]
117
+ : movedSet.has(a.element) ? [] : [a]);
118
+ }
119
+ return (0, jsx_attributes_1.withAttributes)(tag, attributes);
120
+ });
121
+ }
122
+ //# sourceMappingURL=move-system-props-to-sx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-system-props-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
+ export declare const escapeRegExp: (s: string) => string;
3
+ export declare const MUI_PACKAGES: RegExp;
4
+ export declare function muiComponents(cu: JS.CompilationUnit, packages?: RegExp): Map<string, string>;
5
+ export declare function tagComponent(tag: JSX.Tag, components: Map<string, string>): string | undefined;
6
+ export declare function attributeName(attribute: JSX.Attribute | JSX.SpreadAttribute): string | undefined;
7
+ export declare function attributeString(attribute: JSX.Attribute): string | undefined;
8
+ //# sourceMappingURL=mui-components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mui-components.d.ts","sourceRoot":"","sources":["../../src/mui/mui-components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAE,GAAG,EAAC,MAAM,iCAAiC,CAAC;AAIxD,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MAAkD,CAAC;AAG5F,eAAO,MAAM,YAAY,QAAiM,CAAC;AAG3N,wBAAgB,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,eAAe,EAAE,QAAQ,GAAE,MAAqB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU1G;AAGD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAG9F;AAGD,wBAAgB,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,eAAe,GAAG,MAAM,GAAG,SAAS,CAGhG;AAGD,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,MAAM,GAAG,SAAS,CAI5E"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MUI_PACKAGES = exports.escapeRegExp = void 0;
4
+ exports.muiComponents = muiComponents;
5
+ exports.tagComponent = tagComponent;
6
+ exports.attributeName = attributeName;
7
+ exports.attributeString = attributeString;
8
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
9
+ const java_1 = require("@openrewrite/rewrite/java");
10
+ const module_imports_1 = require("../util/module-imports");
11
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
12
+ exports.escapeRegExp = escapeRegExp;
13
+ exports.MUI_PACKAGES = /^(@mui\/(material|lab|system|base|joy|styles|icons-material|utils|x-date-pickers|x-date-pickers-pro|x-tree-view)|@material-ui\/(core|lab|styles|system|icons|utils|types)|material-ui)(\/|$)/;
14
+ function muiComponents(cu, packages = exports.MUI_PACKAGES) {
15
+ const components = new Map();
16
+ for (const { local, name, module } of (0, module_imports_1.importBindings)(cu)) {
17
+ if (!packages.test(module))
18
+ continue;
19
+ const component = name === "default" ? module.split("/").pop() : name;
20
+ if (name === "default" && !module.includes("/"))
21
+ continue;
22
+ components.set(local, component);
23
+ }
24
+ return components;
25
+ }
26
+ function tagComponent(tag, components) {
27
+ const name = tag.openName.element;
28
+ return (0, java_1.isIdentifier)(name) ? components.get(name.simpleName) : undefined;
29
+ }
30
+ function attributeName(attribute) {
31
+ return attribute.kind === javascript_1.JS.Kind.JsxAttribute && (0, java_1.isIdentifier)(attribute.key)
32
+ ? attribute.key.simpleName : undefined;
33
+ }
34
+ function attributeString(attribute) {
35
+ var _a;
36
+ let value = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.element;
37
+ if ((value === null || value === void 0 ? void 0 : value.kind) === javascript_1.JS.Kind.JsxEmbeddedExpression)
38
+ value = value.expression.element;
39
+ return (value === null || value === void 0 ? void 0 : value.kind) === java_1.J.Kind.Literal && typeof value.value === "string" ? value.value : undefined;
40
+ }
41
+ //# sourceMappingURL=mui-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mui-components.js","sourceRoot":"","sources":["../../src/mui/mui-components.ts"],"names":[],"mappings":";;;AAUA,sCAUC;AAGD,oCAGC;AAGD,sCAGC;AAGD,0CAIC;AAvCD,gEAAwD;AACxD,oDAA0D;AAC1D,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C,CAAG,SAA2B,CAAC,GAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACpF,CAAC;AAGD,SAAgB,eAAe,CAAC,SAAwB;;IACpD,IAAI,KAAK,GAAkB,MAAA,SAAS,CAAC,KAAK,0CAAE,OAAO,CAAC;IACpD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,eAAE,CAAC,IAAI,CAAC,qBAAqB;QAAE,KAAK,GAAI,KAAgC,CAAC,UAAU,CAAC,OAAO,CAAC;IAChH,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,QAAC,CAAC,IAAI,CAAC,OAAO,IAAI,OAAQ,KAAmB,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAmB,CAAC,KAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/I,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Cursor, ExecutionContext, TreeVisitor } from "@openrewrite/rewrite";
2
+ import { JSX } from "@openrewrite/rewrite/javascript";
3
+ export declare function packagePattern(packageName?: string): RegExp;
4
+ export declare function muiTagEditor(component: string | ((name: string) => boolean), packageName: string | undefined, handle: (tag: JSX.Tag, cursor: Cursor, component: string) => Promise<JSX.Tag>): Promise<TreeVisitor<any, ExecutionContext>>;
5
+ //# sourceMappingURL=mui-tag-visitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mui-tag-visitor.d.ts","sourceRoot":"","sources":["../../src/mui/mui-tag-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAwB,GAAG,EAAsB,MAAM,iCAAiC,CAAC;AAKhG,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAG3D;AAOD,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAChF,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAkBvJ"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.packagePattern = packagePattern;
13
+ exports.muiTagEditor = muiTagEditor;
14
+ const rewrite_1 = require("@openrewrite/rewrite");
15
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
16
+ const mui_components_1 = require("./mui-components");
17
+ function packagePattern(packageName) {
18
+ if (!packageName)
19
+ return mui_components_1.MUI_PACKAGES;
20
+ return new RegExp(`^${(0, mui_components_1.escapeRegExp)(packageName)}(/|$)`);
21
+ }
22
+ function muiTagEditor(component, packageName, handle) {
23
+ const pattern = packagePattern(packageName);
24
+ const matches = typeof component === "string" ? (name) => name === component : component;
25
+ return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.components = new Map();
29
+ }
30
+ visitJsCompilationUnit(cu, ctx) {
31
+ const _super = Object.create(null, {
32
+ visitJsCompilationUnit: { get: () => super.visitJsCompilationUnit }
33
+ });
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ this.components = (0, mui_components_1.muiComponents)(cu, pattern);
36
+ for (const name of this.components.values())
37
+ if (matches(name))
38
+ return _super.visitJsCompilationUnit.call(this, cu, ctx);
39
+ return cu;
40
+ });
41
+ }
42
+ visitJsxTag(tag, ctx) {
43
+ const _super = Object.create(null, {
44
+ visitJsxTag: { get: () => super.visitJsxTag }
45
+ });
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const visited = yield _super.visitJsxTag.call(this, tag, ctx);
48
+ const name = (0, mui_components_1.tagComponent)(visited, this.components);
49
+ return name && matches(name) ? handle(visited, this.cursor, name) : visited;
50
+ });
51
+ }
52
+ }());
53
+ }
54
+ //# sourceMappingURL=mui-tag-visitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mui-tag-visitor.js","sourceRoot":"","sources":["../../src/mui/mui-tag-visitor.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,wCAGC;AAOD,oCAmBC;AAnCD,kDAAuF;AACvF,gEAAgG;AAEhG,qDAAyF;AAGzF,SAAgB,cAAc,CAAC,WAAoB;IAC/C,IAAI,CAAC,WAAW;QAAE,OAAO,6BAAY,CAAC;IACtC,OAAO,IAAI,MAAM,CAAC,IAAI,IAAA,6BAAY,EAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC;AAOD,SAAgB,YAAY,CAAC,SAA+C,EAAE,WAA+B,EAChF,MAA6E;IACtG,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;QAAjD;;YACjC,eAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAanD,CAAC;QAXkB,sBAAsB,CAAC,EAAsB,EAAE,GAAqB;;;;;gBAC/E,IAAI,CAAC,UAAU,GAAG,IAAA,8BAAa,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC7C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;oBAAE,IAAI,OAAO,CAAC,IAAI,CAAC;wBAAE,OAAO,OAAM,sBAAsB,YAAC,EAAE,EAAE,GAAG,EAAE;gBAC7G,OAAO,EAAE,CAAC;YACd,CAAC;SAAA;QAEc,WAAW,CAAC,GAAY,EAAE,GAAqB;;;;;gBAC1D,MAAM,OAAO,GAAG,MAAM,OAAM,WAAW,YAAC,GAAG,EAAE,GAAG,CAAY,CAAC;gBAC7D,MAAM,IAAI,GAAG,IAAA,6BAAY,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;gBACpD,OAAO,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAChF,CAAC;SAAA;KACJ,EAAE,CAAC,CAAC;AACT,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ExecutionContext, ScanningRecipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export interface V4Projects {
3
+ roots: Set<string>;
4
+ declaring: Set<string>;
5
+ importing: Set<string>;
6
+ }
7
+ export declare abstract class PreV5Recipe extends ScanningRecipe<V4Projects> {
8
+ protected abstract v4Editor(): Promise<TreeVisitor<any, ExecutionContext>>;
9
+ initialValue(): V4Projects;
10
+ scanner(projects: V4Projects): Promise<TreeVisitor<any, ExecutionContext>>;
11
+ editorWithData(projects: V4Projects): Promise<TreeVisitor<any, ExecutionContext>>;
12
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
13
+ }
14
+ //# sourceMappingURL=pre-v5-recipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-v5-recipe.d.ts","sourceRoot":"","sources":["../../src/mui/pre-v5-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAA0B,cAAc,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAalH,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC1B;AAiBD,8BAAsB,WAAY,SAAQ,cAAc,CAAC,UAAU,CAAC;IAEhE,SAAS,CAAC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAE1E,YAAY,IAAI,UAAU;IAIpB,OAAO,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAsB1E,cAAc,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAcxE,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAGvE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PreV5Recipe = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
15
+ const json_1 = require("@openrewrite/rewrite/json");
16
+ const module_imports_1 = require("../util/module-imports");
17
+ const json_and_javascript_1 = require("../util/json-and-javascript");
18
+ const java_recipe_proxy_1 = require("../util/java-recipe-proxy");
19
+ const V4_PACKAGE = /^(@material-ui\/|material-ui(\/|$))/;
20
+ const V4_DEPENDENCY = /^@material-ui\/core$/;
21
+ const rootOf = (path, roots) => {
22
+ let best = "";
23
+ for (const root of roots)
24
+ if (path.startsWith(root) && root.length > best.length)
25
+ best = root;
26
+ return best;
27
+ };
28
+ class PreV5Recipe extends rewrite_1.ScanningRecipe {
29
+ initialValue() {
30
+ return { roots: new Set(), declaring: new Set(), importing: new Set() };
31
+ }
32
+ scanner(projects) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const json = new class extends json_1.JsonVisitor {
35
+ visitDocument(doc) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ var _a, _b, _c, _d;
38
+ if (!/(^|\/)package\.json$/.test(doc.sourcePath))
39
+ return doc;
40
+ const root = doc.sourcePath.slice(0, -"package.json".length);
41
+ projects.roots.add(root);
42
+ const resolution = (0, javascript_1.findNodeResolutionResult)(doc);
43
+ const declared = [...(_a = resolution === null || resolution === void 0 ? void 0 : resolution.dependencies) !== null && _a !== void 0 ? _a : [], ...(_b = resolution === null || resolution === void 0 ? void 0 : resolution.devDependencies) !== null && _b !== void 0 ? _b : [],
44
+ ...(_c = resolution === null || resolution === void 0 ? void 0 : resolution.peerDependencies) !== null && _c !== void 0 ? _c : [], ...(_d = resolution === null || resolution === void 0 ? void 0 : resolution.optionalDependencies) !== null && _d !== void 0 ? _d : []];
45
+ if (declared.some(dep => V4_DEPENDENCY.test(dep.name)))
46
+ projects.declaring.add(root);
47
+ return doc;
48
+ });
49
+ }
50
+ }();
51
+ const javascript = yield (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
52
+ visitJsCompilationUnit(cu) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ if ((0, module_imports_1.importBindings)(cu).some(({ module }) => V4_PACKAGE.test(module)))
55
+ projects.importing.add(cu.sourcePath);
56
+ return cu;
57
+ });
58
+ }
59
+ }());
60
+ return (0, json_and_javascript_1.jsonAndJavaScript)(json, javascript, true);
61
+ });
62
+ }
63
+ editorWithData(projects) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const v4 = new Set(projects.declaring);
66
+ for (const path of projects.importing)
67
+ v4.add(rootOf(path, projects.roots));
68
+ const onV4 = new class extends javascript_1.JavaScriptVisitor {
69
+ visitJsCompilationUnit(cu) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ return v4.has(rootOf(cu.sourcePath, projects.roots)) ? (0, rewrite_1.foundSearchResult)(cu) : cu;
72
+ });
73
+ }
74
+ }();
75
+ return (0, rewrite_1.check)(onV4, yield this.v4Editor());
76
+ });
77
+ }
78
+ editor() {
79
+ const _super = Object.create(null, {
80
+ editor: { get: () => super.editor }
81
+ });
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ return (0, rewrite_1.check)((0, java_recipe_proxy_1.treesOfType)("org.openrewrite.javascript.tree.JS"), _super.editor.call(this));
84
+ });
85
+ }
86
+ }
87
+ exports.PreV5Recipe = PreV5Recipe;
88
+ //# sourceMappingURL=pre-v5-recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-v5-recipe.js","sourceRoot":"","sources":["../../src/mui/pre-v5-recipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAkH;AAClH,gEAAqH;AAErH,oDAA4D;AAC5D,2DAAsD;AACtD,qEAA8D;AAC9D,iE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,EAAsB;;wBACxD,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAiB,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACtF,CAAC;iBAAA;aACJ,EAAE,CAAC;YACJ,OAAO,IAAA,eAAK,EAAC,IAAI,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9C,CAAC;KAAA;IAIc,MAAM;;;;;YACjB,OAAO,IAAA,eAAK,EAAC,IAAA,+BAAW,EAAC,oCAAoC,CAAC,EAAE,OAAM,MAAM,YAAG,CAAC;QACpF,CAAC;KAAA;CACJ;AA/CD,kCA+CC"}
@@ -0,0 +1,18 @@
1
+ import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export declare class RemoveComponentProp extends Recipe {
3
+ readonly name = "org.openrewrite.react.mui.remove-component-prop";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ componentName: string;
7
+ propName: string;
8
+ value?: string;
9
+ packageName?: string;
10
+ constructor(options?: {
11
+ componentName?: string;
12
+ propName?: string;
13
+ value?: string;
14
+ packageName?: string;
15
+ });
16
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
17
+ }
18
+ //# sourceMappingURL=remove-component-prop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-component-prop.d.ts","sourceRoot":"","sources":["../../src/mui/remove-component-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAanF,qBAAa,mBAAoB,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,qDAAqD;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyC;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA4J;IAGxL,aAAa,EAAG,MAAM,CAAC;IAGvB,QAAQ,EAAG,MAAM,CAAC;IAGlB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAInG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAQ9D"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.RemoveComponentProp = void 0;
19
+ const rewrite_1 = require("@openrewrite/rewrite");
20
+ const jsx_attributes_1 = require("./jsx-attributes");
21
+ const mui_components_1 = require("./mui-components");
22
+ const mui_tag_visitor_1 = require("./mui-tag-visitor");
23
+ class RemoveComponentProp extends rewrite_1.Recipe {
24
+ constructor(options) {
25
+ super(options);
26
+ this.name = "org.openrewrite.react.mui.remove-component-prop";
27
+ this.displayName = "Remove a Material UI component prop";
28
+ this.description = "Removes a prop of a Material UI component, found through the imports of the file. With `value` set, only a prop set to that string literal is removed.";
29
+ }
30
+ editor() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { propName, value } = this;
33
+ return (0, mui_tag_visitor_1.muiTagEditor)(this.componentName, this.packageName, (tag) => __awaiter(this, void 0, void 0, function* () {
34
+ const attribute = (0, jsx_attributes_1.findAttribute)(tag, propName);
35
+ if (!attribute || (value !== undefined && (0, mui_components_1.attributeString)(attribute) !== value))
36
+ return tag;
37
+ return (0, jsx_attributes_1.replaceAttribute)(tag, attribute, undefined);
38
+ }));
39
+ });
40
+ }
41
+ }
42
+ exports.RemoveComponentProp = RemoveComponentProp;
43
+ __decorate([
44
+ (0, rewrite_1.Option)({ displayName: "Component name", description: "The Material UI component, such as `Dialog`.", example: "Dialog" })
45
+ ], RemoveComponentProp.prototype, "componentName", void 0);
46
+ __decorate([
47
+ (0, rewrite_1.Option)({ displayName: "Prop name", description: "The prop to remove.", example: "disableBackdropClick" })
48
+ ], RemoveComponentProp.prototype, "propName", void 0);
49
+ __decorate([
50
+ (0, rewrite_1.Option)({ displayName: "Value", description: "Only remove the prop when it is set to this string literal.", example: "default", required: false })
51
+ ], RemoveComponentProp.prototype, "value", void 0);
52
+ __decorate([
53
+ (0, rewrite_1.Option)({ displayName: "Package name", description: "A package that re-exports Material UI, when the components are not imported from Material UI itself.", example: "@org/ui", required: false })
54
+ ], RemoveComponentProp.prototype, "packageName", void 0);
55
+ //# sourceMappingURL=remove-component-prop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-component-prop.js","sourceRoot":"","sources":["../../src/mui/remove-component-prop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kD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C,EAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,sGAAsG,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;wDAC3K"}
@@ -0,0 +1,8 @@
1
+ import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export declare class RemoveRootRef extends Recipe {
3
+ readonly name = "org.openrewrite.react.mui.remove-root-ref";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
7
+ }
8
+ //# sourceMappingURL=remove-root-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-root-ref.d.ts","sourceRoot":"","sources":["../../src/mui/remove-root-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAevF,qBAAa,aAAc,SAAQ,MAAM;IACrC,QAAQ,CAAC,IAAI,+CAA+C;IAC5D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAsB;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAsL;IAE5M,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAoB9D"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RemoveRootRef = void 0;
13
+ const rewrite_1 = require("@openrewrite/rewrite");
14
+ const javascript_1 = require("@openrewrite/rewrite/javascript");
15
+ const java_1 = require("@openrewrite/rewrite/java");
16
+ const java_2 = require("@openrewrite/rewrite/java");
17
+ const mui_components_1 = require("./mui-components");
18
+ class RemoveRootRef extends rewrite_1.Recipe {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.name = "org.openrewrite.react.mui.remove-root-ref";
22
+ this.displayName = "Remove `RootRef`";
23
+ this.description = "Replaces `<RootRef rootRef={ref}>...</RootRef>` by a fragment and removes the import, since `RootRef` is gone in v5. The `rootRef` has to become the `ref` of the child by hand.";
24
+ }
25
+ editor() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.components = new Map();
31
+ }
32
+ visitJsCompilationUnit(cu, ctx) {
33
+ const _super = Object.create(null, {
34
+ visitJsCompilationUnit: { get: () => super.visitJsCompilationUnit }
35
+ });
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ this.components = (0, mui_components_1.muiComponents)(cu, mui_components_1.MUI_PACKAGES);
38
+ return _super.visitJsCompilationUnit.call(this, cu, ctx);
39
+ });
40
+ }
41
+ visitJsxTag(tag, ctx) {
42
+ const _super = Object.create(null, {
43
+ visitJsxTag: { get: () => super.visitJsxTag }
44
+ });
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const visited = yield _super.visitJsxTag.call(this, tag, ctx);
47
+ if ((0, mui_components_1.tagComponent)(visited, this.components) !== "RootRef" || !visited.children)
48
+ return visited;
49
+ const local = visited.openName.element.simpleName;
50
+ for (const module of ["@material-ui/core", "@material-ui/core/RootRef", "@mui/material"])
51
+ (0, javascript_1.maybeRemoveImport)(this, module, module.endsWith("RootRef") ? "default" : "RootRef");
52
+ const empty = { kind: java_1.J.Kind.Empty, id: visited.id, prefix: java_2.emptySpace, markers: visited.markers };
53
+ return Object.assign(Object.assign({}, visited), { openName: Object.assign(Object.assign({}, visited.openName), { element: empty }), afterName: java_2.emptySpace, attributes: [], closingName: Object.assign(Object.assign({}, visited.closingName), { element: empty }) });
54
+ });
55
+ }
56
+ }());
57
+ });
58
+ }
59
+ }
60
+ exports.RemoveRootRef = RemoveRootRef;
61
+ //# sourceMappingURL=remove-root-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-root-ref.js","sourceRoot":"","sources":["../../src/mui/remove-root-ref.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAAmH;AACnH,oDAA0D;AAC1D,oDAAqD;AACrD,qDAA2E;AAW3E,MAAa,aAAc,SAAQ,gBAAM;IAAzC;;QACa,SAAI,GAAG,2CAA2C,CAAC;QACnD,gBAAW,GAAW,kBAAkB,CAAC;QACzC,gBAAW,GAAW,kLAAkL,CAAC;IAsBtN,CAAC;IApBS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAAjD;;oBACjC,eAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;gBAgBnD,CAAC;gBAdkB,sBAAsB,CAAC,EAAsB,EAAE,GAAqB;;;;;wBAC/E,IAAI,CAAC,UAAU,GAAG,IAAA,8BAAa,EAAC,EAAE,EAAE,6BAAY,CAAC,CAAC;wBAClD,OAAO,OAAM,sBAAsB,YAAC,EAAE,EAAE,GAAG,EAAE;oBACjD,CAAC;iBAAA;gBAEc,WAAW,CAAC,GAAY,EAAE,GAAqB;;;;;wBAC1D,MAAM,OAAO,GAAG,MAAM,OAAM,WAAW,YAAC,GAAG,EAAE,GAAG,CAAY,CAAC;wBAC7D,IAAI,IAAA,6BAAY,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ;4BAAE,OAAO,OAAO,CAAC;wBAC9F,MAAM,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,OAAwB,CAAC,UAAU,CAAC;wBACpE,KAAK,MAAM,MAAM,IAAI,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,eAAe,CAAC;4BAAE,IAAA,8BAAiB,EAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;wBAC9K,MAAM,KAAK,GAAG,EAAC,IAAI,EAAE,QAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,iBAAU,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAY,CAAC;wBAC5G,OAAO,gCAAI,OAAO,KAAE,QAAQ,kCAAM,OAAO,CAAC,QAAQ,KAAE,OAAO,EAAE,KAAK,KAAG,SAAS,EAAE,iBAAU,EAAE,UAAU,EAAE,EAAE,EACtG,WAAW,kCAAM,OAAO,CAAC,WAAW,KAAE,OAAO,EAAE,KAAK,MAAa,CAAC;oBAC1E,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AAzBD,sCAyBC"}
@@ -0,0 +1,8 @@
1
+ import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
2
+ export declare class RemoveSpacingPxSuffix extends Recipe {
3
+ readonly name = "org.openrewrite.react.mui.remove-spacing-px-suffix";
4
+ readonly displayName: string;
5
+ readonly description: string;
6
+ editor(): Promise<TreeVisitor<any, ExecutionContext>>;
7
+ }
8
+ //# sourceMappingURL=remove-spacing-px-suffix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-spacing-px-suffix.d.ts","sourceRoot":"","sources":["../../src/mui/remove-spacing-px-suffix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAevF,qBAAa,qBAAsB,SAAQ,MAAM;IAC7C,QAAQ,CAAC,IAAI,wDAAwD;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAoD;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAiJ;IAEvK,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsB9D"}