@openrewrite/recipes-react 0.21.0 → 0.22.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/mui/adapt-v4-theme.d.ts +8 -0
- package/dist/mui/adapt-v4-theme.d.ts.map +1 -0
- package/dist/mui/adapt-v4-theme.js +65 -0
- package/dist/mui/adapt-v4-theme.js.map +1 -0
- package/dist/mui/add-component-prop.d.ts +18 -0
- package/dist/mui/add-component-prop.d.ts.map +1 -0
- package/dist/mui/add-component-prop.js +53 -0
- package/dist/mui/add-component-prop.js.map +1 -0
- package/dist/mui/add-emotion-prepend.d.ts +8 -0
- package/dist/mui/add-emotion-prepend.d.ts.map +1 -0
- package/dist/mui/add-emotion-prepend.js +71 -0
- package/dist/mui/add-emotion-prepend.js.map +1 -0
- package/dist/mui/change-module-specifier.d.ts +14 -0
- package/dist/mui/change-module-specifier.d.ts.map +1 -0
- package/dist/mui/change-module-specifier.js +95 -0
- package/dist/mui/change-module-specifier.js.map +1 -0
- package/dist/mui/convert-mui-imports.d.ts +14 -0
- package/dist/mui/convert-mui-imports.d.ts.map +1 -0
- package/dist/mui/convert-mui-imports.js +195 -0
- package/dist/mui/convert-mui-imports.js.map +1 -0
- package/dist/mui/convert-prop-to-sx.d.ts +22 -0
- package/dist/mui/convert-prop-to-sx.d.ts.map +1 -0
- package/dist/mui/convert-prop-to-sx.js +99 -0
- package/dist/mui/convert-prop-to-sx.js.map +1 -0
- package/dist/mui/index.d.ts +32 -0
- package/dist/mui/index.d.ts.map +1 -0
- package/dist/mui/index.js +67 -0
- package/dist/mui/index.js.map +1 -0
- package/dist/mui/jsx-attributes.d.ts +27 -0
- package/dist/mui/jsx-attributes.d.ts.map +1 -0
- package/dist/mui/jsx-attributes.js +140 -0
- package/dist/mui/jsx-attributes.js.map +1 -0
- package/dist/mui/mark-manual-migration.d.ts +16 -0
- package/dist/mui/mark-manual-migration.d.ts.map +1 -0
- package/dist/mui/mark-manual-migration.js +73 -0
- package/dist/mui/mark-manual-migration.js.map +1 -0
- package/dist/mui/mark-palette-mode-usage.d.ts +12 -0
- package/dist/mui/mark-palette-mode-usage.d.ts.map +1 -0
- package/dist/mui/mark-palette-mode-usage.js +50 -0
- package/dist/mui/mark-palette-mode-usage.js.map +1 -0
- package/dist/mui/move-component-prop-to-slot.d.ts +22 -0
- package/dist/mui/move-component-prop-to-slot.d.ts.map +1 -0
- package/dist/mui/move-component-prop-to-slot.js +87 -0
- package/dist/mui/move-component-prop-to-slot.js.map +1 -0
- package/dist/mui/move-primary-text-to-children.d.ts +12 -0
- package/dist/mui/move-primary-text-to-children.d.ts.map +1 -0
- package/dist/mui/move-primary-text-to-children.js +52 -0
- package/dist/mui/move-primary-text-to-children.js.map +1 -0
- package/dist/mui/move-system-props-to-sx.d.ts +16 -0
- package/dist/mui/move-system-props-to-sx.d.ts.map +1 -0
- package/dist/mui/move-system-props-to-sx.js +122 -0
- package/dist/mui/move-system-props-to-sx.js.map +1 -0
- package/dist/mui/mui-components.d.ts +8 -0
- package/dist/mui/mui-components.d.ts.map +1 -0
- package/dist/mui/mui-components.js +41 -0
- package/dist/mui/mui-components.js.map +1 -0
- package/dist/mui/mui-tag-visitor.d.ts +5 -0
- package/dist/mui/mui-tag-visitor.d.ts.map +1 -0
- package/dist/mui/mui-tag-visitor.js +54 -0
- package/dist/mui/mui-tag-visitor.js.map +1 -0
- package/dist/mui/pre-v5-recipe.d.ts +14 -0
- package/dist/mui/pre-v5-recipe.d.ts.map +1 -0
- package/dist/mui/pre-v5-recipe.js +88 -0
- package/dist/mui/pre-v5-recipe.js.map +1 -0
- package/dist/mui/remove-component-prop.d.ts +18 -0
- package/dist/mui/remove-component-prop.d.ts.map +1 -0
- package/dist/mui/remove-component-prop.js +55 -0
- package/dist/mui/remove-component-prop.js.map +1 -0
- package/dist/mui/remove-root-ref.d.ts +8 -0
- package/dist/mui/remove-root-ref.d.ts.map +1 -0
- package/dist/mui/remove-root-ref.js +61 -0
- package/dist/mui/remove-root-ref.js.map +1 -0
- package/dist/mui/remove-spacing-px-suffix.d.ts +8 -0
- package/dist/mui/remove-spacing-px-suffix.d.ts.map +1 -0
- package/dist/mui/remove-spacing-px-suffix.js +62 -0
- package/dist/mui/remove-spacing-px-suffix.js.map +1 -0
- package/dist/mui/rename-component-prop.d.ts +20 -0
- package/dist/mui/rename-component-prop.d.ts.map +1 -0
- package/dist/mui/rename-component-prop.js +66 -0
- package/dist/mui/rename-component-prop.js.map +1 -0
- package/dist/mui/rename-joy-css-variables.d.ts +8 -0
- package/dist/mui/rename-joy-css-variables.d.ts.map +1 -0
- package/dist/mui/rename-joy-css-variables.js +51 -0
- package/dist/mui/rename-joy-css-variables.js.map +1 -0
- package/dist/mui/rename-theme-palette-type.d.ts +8 -0
- package/dist/mui/rename-theme-palette-type.d.ts.map +1 -0
- package/dist/mui/rename-theme-palette-type.js +61 -0
- package/dist/mui/rename-theme-palette-type.js.map +1 -0
- package/dist/mui/replace-box-border-radius.d.ts +10 -0
- package/dist/mui/replace-box-border-radius.d.ts.map +1 -0
- package/dist/mui/replace-box-border-radius.js +50 -0
- package/dist/mui/replace-box-border-radius.js.map +1 -0
- package/dist/mui/replace-breakpoints-width.d.ts +8 -0
- package/dist/mui/replace-breakpoints-width.d.ts.map +1 -0
- package/dist/mui/replace-breakpoints-width.js +46 -0
- package/dist/mui/replace-breakpoints-width.js.map +1 -0
- package/dist/mui/replace-component-class.d.ts +18 -0
- package/dist/mui/replace-component-class.d.ts.map +1 -0
- package/dist/mui/replace-component-class.js +126 -0
- package/dist/mui/replace-component-class.js.map +1 -0
- package/dist/mui/replace-components-with-slots.d.ts +14 -0
- package/dist/mui/replace-components-with-slots.d.ts.map +1 -0
- package/dist/mui/replace-components-with-slots.js +69 -0
- package/dist/mui/replace-components-with-slots.js.map +1 -0
- package/dist/mui/replace-import-paths.d.ts +14 -0
- package/dist/mui/replace-import-paths.d.ts.map +1 -0
- package/dist/mui/replace-import-paths.js +101 -0
- package/dist/mui/replace-import-paths.js.map +1 -0
- package/dist/mui/replace-in-string-literals.d.ts +15 -0
- package/dist/mui/replace-in-string-literals.d.ts.map +1 -0
- package/dist/mui/replace-in-string-literals.js +62 -0
- package/dist/mui/replace-in-string-literals.js.map +1 -0
- package/dist/mui/replace-list-item-button-prop.d.ts +12 -0
- package/dist/mui/replace-list-item-button-prop.d.ts.map +1 -0
- package/dist/mui/replace-list-item-button-prop.js +80 -0
- package/dist/mui/replace-list-item-button-prop.js.map +1 -0
- package/dist/mui/replace-tabs-scroll-buttons.d.ts +8 -0
- package/dist/mui/replace-tabs-scroll-buttons.d.ts.map +1 -0
- package/dist/mui/replace-tabs-scroll-buttons.js +41 -0
- package/dist/mui/replace-tabs-scroll-buttons.js.map +1 -0
- package/dist/mui/replace-theme-color-functions.d.ts +8 -0
- package/dist/mui/replace-theme-color-functions.d.ts.map +1 -0
- package/dist/mui/replace-theme-color-functions.js +72 -0
- package/dist/mui/replace-theme-color-functions.js.map +1 -0
- package/dist/mui/replace-theme-spacing-unit.d.ts +8 -0
- package/dist/mui/replace-theme-spacing-unit.d.ts.map +1 -0
- package/dist/mui/replace-theme-spacing-unit.js +77 -0
- package/dist/mui/replace-theme-spacing-unit.js.map +1 -0
- package/dist/mui/replace-typography-round.d.ts +8 -0
- package/dist/mui/replace-typography-round.d.ts.map +1 -0
- package/dist/mui/replace-typography-round.js +44 -0
- package/dist/mui/replace-typography-round.js.map +1 -0
- package/dist/mui/shift-hidden-down-props.d.ts +10 -0
- package/dist/mui/shift-hidden-down-props.d.ts.map +1 -0
- package/dist/mui/shift-hidden-down-props.js +49 -0
- package/dist/mui/shift-hidden-down-props.js.map +1 -0
- package/dist/mui/theme-access.d.ts +5 -0
- package/dist/mui/theme-access.d.ts.map +1 -0
- package/dist/mui/theme-access.js +21 -0
- package/dist/mui/theme-access.js.map +1 -0
- package/dist/mui/update-theme-breakpoints.d.ts +10 -0
- package/dist/mui/update-theme-breakpoints.d.ts.map +1 -0
- package/dist/mui/update-theme-breakpoints.js +58 -0
- package/dist/mui/update-theme-breakpoints.js.map +1 -0
- package/dist/mui/upgrade-grid-props.d.ts +16 -0
- package/dist/mui/upgrade-grid-props.d.ts.map +1 -0
- package/dist/mui/upgrade-grid-props.js +90 -0
- package/dist/mui/upgrade-grid-props.js.map +1 -0
- package/dist/search/find-enzyme-usage.d.ts +4 -0
- package/dist/search/find-enzyme-usage.d.ts.map +1 -1
- package/dist/search/find-enzyme-usage.js +91 -7
- package/dist/search/find-enzyme-usage.js.map +1 -1
- package/dist/testing/enzyme-host-components.d.ts +12 -0
- package/dist/testing/enzyme-host-components.d.ts.map +1 -1
- package/dist/testing/enzyme-host-components.js +100 -0
- package/dist/testing/enzyme-host-components.js.map +1 -1
- package/dist/testing/enzyme-render-blockers.d.ts +13 -4
- package/dist/testing/enzyme-render-blockers.d.ts.map +1 -1
- package/dist/testing/enzyme-render-blockers.js +162 -6
- package/dist/testing/enzyme-render-blockers.js.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.d.ts +9 -2
- package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.js +163 -16
- package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
- package/dist/testing/enzyme-usage.d.ts +7 -0
- package/dist/testing/enzyme-usage.d.ts.map +1 -1
- package/dist/testing/enzyme-usage.js +8 -1
- package/dist/testing/enzyme-usage.js.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.d.ts +8 -5
- package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.js +16 -4
- package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
- package/dist/zustand/redux-stores.d.ts +2 -0
- package/dist/zustand/redux-stores.d.ts.map +1 -1
- package/dist/zustand/redux-stores.js +120 -6
- package/dist/zustand/redux-stores.js.map +1 -1
- package/dist/zustand/redux-to-zustand.d.ts.map +1 -1
- package/dist/zustand/redux-to-zustand.js +10 -4
- package/dist/zustand/redux-to-zustand.js.map +1 -1
- package/dist/zustand/zustand-plan.d.ts +7 -0
- package/dist/zustand/zustand-plan.d.ts.map +1 -1
- package/dist/zustand/zustand-plan.js +141 -21
- package/dist/zustand/zustand-plan.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/mui/adapt-v4-theme.ts +43 -0
- package/src/mui/add-component-prop.ts +43 -0
- package/src/mui/add-emotion-prepend.ts +48 -0
- package/src/mui/change-module-specifier.ts +71 -0
- package/src/mui/convert-mui-imports.ts +184 -0
- package/src/mui/convert-prop-to-sx.ts +89 -0
- package/src/mui/index.ts +31 -0
- package/src/mui/jsx-attributes.ts +133 -0
- package/src/mui/mark-manual-migration.ts +53 -0
- package/src/mui/mark-palette-mode-usage.ts +36 -0
- package/src/mui/move-component-prop-to-slot.ts +84 -0
- package/src/mui/move-primary-text-to-children.ts +41 -0
- package/src/mui/move-system-props-to-sx.ts +118 -0
- package/src/mui/mui-components.ts +40 -0
- package/src/mui/mui-tag-visitor.ts +36 -0
- package/src/mui/pre-v5-recipe.ts +82 -0
- package/src/mui/remove-component-prop.ts +43 -0
- package/src/mui/remove-root-ref.ts +41 -0
- package/src/mui/remove-spacing-px-suffix.ts +43 -0
- package/src/mui/rename-component-prop.ts +55 -0
- package/src/mui/rename-joy-css-variables.ts +41 -0
- package/src/mui/rename-theme-palette-type.ts +42 -0
- package/src/mui/replace-box-border-radius.ts +42 -0
- package/src/mui/replace-breakpoints-width.ts +28 -0
- package/src/mui/replace-component-class.ts +97 -0
- package/src/mui/replace-components-with-slots.ts +61 -0
- package/src/mui/replace-import-paths.ts +100 -0
- package/src/mui/replace-in-string-literals.ts +44 -0
- package/src/mui/replace-list-item-button-prop.ts +59 -0
- package/src/mui/replace-tabs-scroll-buttons.ts +31 -0
- package/src/mui/replace-theme-color-functions.ts +55 -0
- package/src/mui/replace-theme-spacing-unit.ts +59 -0
- package/src/mui/replace-typography-round.ts +29 -0
- package/src/mui/shift-hidden-down-props.ts +44 -0
- package/src/mui/theme-access.ts +18 -0
- package/src/mui/update-theme-breakpoints.ts +47 -0
- package/src/mui/upgrade-grid-props.ts +82 -0
- package/src/search/find-enzyme-usage.ts +80 -7
- package/src/testing/enzyme-host-components.ts +110 -0
- package/src/testing/enzyme-render-blockers.ts +174 -9
- package/src/testing/enzyme-to-react-testing-library.ts +159 -25
- package/src/testing/enzyme-usage.ts +13 -0
- package/src/testing/enzyme-wrapper-scope.ts +27 -6
- package/src/zustand/redux-stores.ts +119 -5
- package/src/zustand/redux-to-zustand.ts +12 -5
- package/src/zustand/zustand-plan.ts +159 -18
|
@@ -0,0 +1,62 @@
|
|
|
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.RemoveSpacingPxSuffix = 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 theme_access_1 = require("./theme-access");
|
|
17
|
+
const isSpacingCall = (e) => (e === null || e === void 0 ? void 0 : e.kind) === java_1.J.Kind.MethodInvocation && e.name.simpleName === "spacing";
|
|
18
|
+
class RemoveSpacingPxSuffix extends rewrite_1.Recipe {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.name = "org.openrewrite.react.mui.remove-spacing-px-suffix";
|
|
22
|
+
this.displayName = "Remove the `px` suffix after `theme.spacing()`";
|
|
23
|
+
this.description = "Removes a `px` that follows a `theme.spacing()` call in a template literal, or is added to it as a string, since the call returns the unit.";
|
|
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
|
+
visitTemplateExpression(template, ctx) {
|
|
29
|
+
const _super = Object.create(null, {
|
|
30
|
+
visitTemplateExpression: { get: () => super.visitTemplateExpression }
|
|
31
|
+
});
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const visited = yield _super.visitTemplateExpression.call(this, template, ctx);
|
|
34
|
+
let changed = false;
|
|
35
|
+
const spans = visited.spans.map(span => {
|
|
36
|
+
var _a;
|
|
37
|
+
const tail = span.element.tail;
|
|
38
|
+
if (!isSpacingCall(span.element.expression) || typeof tail.value !== "string" || !tail.value.startsWith("px") || !((_a = tail.valueSource) === null || _a === void 0 ? void 0 : _a.startsWith("}px")))
|
|
39
|
+
return span;
|
|
40
|
+
changed = true;
|
|
41
|
+
return Object.assign(Object.assign({}, span), { element: Object.assign(Object.assign({}, span.element), { tail: Object.assign(Object.assign({}, tail), { value: tail.value.slice(2), valueSource: `}${tail.valueSource.slice(3)}` }) }) });
|
|
42
|
+
});
|
|
43
|
+
return changed ? Object.assign(Object.assign({}, visited), { spans }) : visited;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
visitBinary(binary, ctx) {
|
|
47
|
+
const _super = Object.create(null, {
|
|
48
|
+
visitBinary: { get: () => super.visitBinary }
|
|
49
|
+
});
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const visited = yield _super.visitBinary.call(this, binary, ctx);
|
|
52
|
+
if (visited.operator.element !== "Addition" || !isSpacingCall(visited.left) || (0, theme_access_1.stringValue)(visited.right) !== "px")
|
|
53
|
+
return visited;
|
|
54
|
+
return Object.assign(Object.assign({}, visited.left), { prefix: visited.prefix });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}());
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.RemoveSpacingPxSuffix = RemoveSpacingPxSuffix;
|
|
62
|
+
//# sourceMappingURL=remove-spacing-px-suffix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-spacing-px-suffix.js","sourceRoot":"","sources":["../../src/mui/remove-spacing-px-suffix.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAA2F;AAC3F,oDAA4C;AAC5C,iDAA2C;AAE3C,MAAM,aAAa,GAAG,CAAC,CAAgB,EAAW,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,QAAC,CAAC,IAAI,CAAC,gBAAgB,IAAK,CAAwB,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC;AAUpJ,MAAa,qBAAsB,SAAQ,gBAAM;IAAjD;;QACa,SAAI,GAAG,oDAAoD,CAAC;QAC5D,gBAAW,GAAW,gDAAgD,CAAC;QACvE,gBAAW,GAAW,6IAA6I,CAAC;IAwBjL,CAAC;IAtBS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC3E,uBAAuB,CAAC,QAA+B,EAAE,GAAqB;;;;;wBACzF,MAAM,OAAO,GAAG,MAAM,OAAM,uBAAuB,YAAC,QAAQ,EAAE,GAAG,CAA0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,KAAE,MAAM,EAAE,OAAO,CAAC,MAAM,GAAM,CAAC;oBAC1D,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AA3BD,sDA2BC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class RenameComponentProp extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.rename-component-prop";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
componentName: string;
|
|
7
|
+
oldPropName: string;
|
|
8
|
+
newPropName: string;
|
|
9
|
+
newPropValue?: string;
|
|
10
|
+
packageName?: string;
|
|
11
|
+
constructor(options?: {
|
|
12
|
+
componentName?: string;
|
|
13
|
+
oldPropName?: string;
|
|
14
|
+
newPropName?: string;
|
|
15
|
+
newPropValue?: string;
|
|
16
|
+
packageName?: string;
|
|
17
|
+
});
|
|
18
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=rename-component-prop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-component-prop.d.ts","sourceRoot":"","sources":["../../src/mui/rename-component-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAgBnF,qBAAa,mBAAoB,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,qDAAqD;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyC;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0I;IAGtK,aAAa,EAAG,MAAM,CAAC;IAGvB,WAAW,EAAG,MAAM,CAAC;IAGrB,WAAW,EAAG,MAAM,CAAC;IAGrB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAInI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAc9D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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.RenameComponentProp = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
21
|
+
const jsx_attributes_1 = require("./jsx-attributes");
|
|
22
|
+
const jsx_attributes_2 = require("./jsx-attributes");
|
|
23
|
+
const mui_tag_visitor_1 = require("./mui-tag-visitor");
|
|
24
|
+
class RenameComponentProp extends rewrite_1.Recipe {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.name = "org.openrewrite.react.mui.rename-component-prop";
|
|
28
|
+
this.displayName = "Rename a Material UI component prop";
|
|
29
|
+
this.description = "Renames a prop of a Material UI component, found through the imports of the file. Tags that already set the new prop are left alone.";
|
|
30
|
+
}
|
|
31
|
+
editor() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { oldPropName, newPropName, newPropValue } = this;
|
|
34
|
+
return (0, mui_tag_visitor_1.muiTagEditor)(this.componentName, this.packageName, (tag, cursor) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const attribute = (0, jsx_attributes_1.findAttribute)(tag, oldPropName);
|
|
36
|
+
if (!attribute || (0, jsx_attributes_1.findAttribute)(tag, newPropName))
|
|
37
|
+
return tag;
|
|
38
|
+
if (newPropValue !== undefined) {
|
|
39
|
+
const value = (0, jsx_attributes_2.attributeExpression)(attribute);
|
|
40
|
+
if (attribute.value && !(value.kind === java_1.J.Kind.Literal && value.value === true))
|
|
41
|
+
return tag;
|
|
42
|
+
return (0, jsx_attributes_2.replaceAttribute)(tag, attribute, yield (0, jsx_attributes_2.newAttribute)(cursor, tag, newPropName, JSON.stringify(newPropValue)));
|
|
43
|
+
}
|
|
44
|
+
const renamed = Object.assign(Object.assign({}, attribute), { key: Object.assign(Object.assign({}, attribute.key), { simpleName: newPropName }) });
|
|
45
|
+
return Object.assign(Object.assign({}, tag), { attributes: tag.attributes.map(a => a.element === attribute ? Object.assign(Object.assign({}, a), { element: renamed }) : a) });
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.RenameComponentProp = RenameComponentProp;
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, rewrite_1.Option)({ displayName: "Component name", description: "The Material UI component, such as `Autocomplete`.", example: "Autocomplete" })
|
|
53
|
+
], RenameComponentProp.prototype, "componentName", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, rewrite_1.Option)({ displayName: "Old prop name", description: "The prop to rename.", example: "closeIcon" })
|
|
56
|
+
], RenameComponentProp.prototype, "oldPropName", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, rewrite_1.Option)({ displayName: "New prop name", description: "The name the prop gets.", example: "clearIcon" })
|
|
59
|
+
], RenameComponentProp.prototype, "newPropName", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, rewrite_1.Option)({ displayName: "New prop value", description: "Set the renamed prop to this string. Only a prop that is set without a value, or to `true`, is renamed then.", example: "horizontal", required: false })
|
|
62
|
+
], RenameComponentProp.prototype, "newPropValue", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(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 })
|
|
65
|
+
], RenameComponentProp.prototype, "packageName", void 0);
|
|
66
|
+
//# sourceMappingURL=rename-component-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-component-prop.js","sourceRoot":"","sources":["../../src/mui/rename-component-prop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAmF;AACnF,oDAA4C;AAC5C,qDAA+C;AAC/C,qDAAqF;AACrF,uDAA+C;AAY/C,MAAa,mBAAoB,SAAQ,gBAAM;IAoB3C,YAAY,OAA6H;QACrI,KAAK,CAAC,OAAO,CAAC,CAAC;QApBV,SAAI,GAAG,iDAAiD,CAAC;QACzD,gBAAW,GAAW,qCAAqC,CAAC;QAC5D,gBAAW,GAAW,sIAAsI,CAAC;IAmBtK,CA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J;AAtCD,kDAsCC;AAhCG;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,oDAAoD,EAAE,OAAO,EAAE,cAAc,EAAC,CAAC;0DAC7G;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,qBAAqB,EAAE,OAAO,EAAE,WAAW,EAAC,CAAC;wDAC5E;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,yBAAyB,EAAE,OAAO,EAAE,WAAW,EAAC,CAAC;wDAChF;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,8GAA8G,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;yDACvL;AAGtB;IADC,IAAA,gBAAM,EAAC,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 RenameJoyCssVariables extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.rename-joy-css-variables";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=rename-joy-css-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-joy-css-variables.d.ts","sourceRoot":"","sources":["../../src/mui/rename-joy-css-variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAqB3E,qBAAa,qBAAsB,SAAQ,MAAM;IAC7C,QAAQ,CAAC,IAAI,wDAAwD;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAiC;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAwJ;IAE9K,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAc9D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.RenameJoyCssVariables = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const replace_in_string_literals_1 = require("./replace-in-string-literals");
|
|
15
|
+
const JOY_COMPONENTS = new Set(["Alert", "AspectRatio", "Autocomplete", "AutocompleteListbox", "AutocompleteOption", "Avatar", "AvatarGroup", "Badge",
|
|
16
|
+
"Box", "Breadcrumbs", "Button", "Card", "CardContent", "CardCover", "CardOverflow", "Checkbox", "Chip", "ChipDelete", "CircularProgress",
|
|
17
|
+
"Container", "CssBaseline", "Divider", "FormControl", "FormHelperText", "FormLabel", "Grid", "IconButton", "Input", "LinearProgress", "Link",
|
|
18
|
+
"List", "ListDivider", "ListItem", "ListItemButton", "ListItemContent", "ListItemDecorator", "ListSubheader", "Menu", "MenuItem", "MenuList",
|
|
19
|
+
"Modal", "ModalClose", "ModalDialog", "ModalOverflow", "Option", "Radio", "RadioGroup", "Select", "Sheet", "Skeleton", "Slider", "Stack",
|
|
20
|
+
"SvgIcon", "Switch", "Tab", "Table", "TableCell", "TabList", "TabPanel", "Tabs", "Textarea", "TextField", "Tooltip", "Typography"]);
|
|
21
|
+
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
22
|
+
class RenameJoyCssVariables extends rewrite_1.Recipe {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.name = "org.openrewrite.react.mui.rename-joy-css-variables";
|
|
26
|
+
this.displayName = "Rename Joy UI CSS variables";
|
|
27
|
+
this.description = "Renames the CSS variables of Joy UI components in string literals to the new naming standard, and `--internal-` and `--private_` to `--unstable_`.";
|
|
28
|
+
}
|
|
29
|
+
editor() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return (0, replace_in_string_literals_1.literalEditor)(text => text
|
|
32
|
+
.replace(/--([a-zA-Z]+)([-_])([a-zA-Z]+)-([a-zA-Z]+)/gm, (matched, c1, c2, c3, c4) => {
|
|
33
|
+
if (!JOY_COMPONENTS.has(c1) && !["internal", "unstable", "private"].includes(c1))
|
|
34
|
+
return matched;
|
|
35
|
+
if (c1 === "List" && ["divider", "item"].includes(c3))
|
|
36
|
+
return `--${c1}${capitalize(c3)}-${c4}`;
|
|
37
|
+
if (c1 === "List" && c3 === "decorator")
|
|
38
|
+
return `--${c1}Item${capitalize(c3)}-${c4}`;
|
|
39
|
+
if (!JOY_COMPONENTS.has(c3))
|
|
40
|
+
return `--${c1}${c2}${c3}${capitalize(c4)}`;
|
|
41
|
+
return matched;
|
|
42
|
+
})
|
|
43
|
+
.replace(/--List-decoratorSize/gm, "--ListItemDecorator-size")
|
|
44
|
+
.replace(/--List-decoratorColor/gm, "--ListItemDecorator-color")
|
|
45
|
+
.replace(/--internal-/gm, "--unstable_")
|
|
46
|
+
.replace(/--private_/gm, "--unstable_"));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.RenameJoyCssVariables = RenameJoyCssVariables;
|
|
51
|
+
//# sourceMappingURL=rename-joy-css-variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-joy-css-variables.js","sourceRoot":"","sources":["../../src/mui/rename-joy-css-variables.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,6EAA2D;AAE3D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO;IACjJ,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB;IACxI,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM;IAC5I,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAC5I,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO;IACxI,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AAExI,MAAM,UAAU,GAAG,CAAC,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;iBAC/D,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC;iBACvC,OAAO,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;QACjD,CAAC;KAAA;CACJ;AAnBD,sDAmBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class RenameThemePaletteType extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.rename-theme-palette-type";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=rename-theme-palette-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-theme-palette-type.d.ts","sourceRoot":"","sources":["../../src/mui/rename-theme-palette-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAcvF,qBAAa,sBAAuB,SAAQ,MAAM;IAC9C,QAAQ,CAAC,IAAI,yDAAyD;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA+C;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA8F;IAEpH,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsB9D"}
|
|
@@ -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.RenameThemePaletteType = 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 jsx_attributes_1 = require("./jsx-attributes");
|
|
17
|
+
const theme_access_1 = require("./theme-access");
|
|
18
|
+
class RenameThemePaletteType extends rewrite_1.Recipe {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.name = "org.openrewrite.react.mui.rename-theme-palette-type";
|
|
22
|
+
this.displayName = "Rename the theme palette `type` to `mode`";
|
|
23
|
+
this.description = "Renames `type` to `mode` in the `palette` object of a theme and in `palette.type` reads.";
|
|
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
|
+
visitFieldAccess(fieldAccess, ctx) {
|
|
29
|
+
const _super = Object.create(null, {
|
|
30
|
+
visitFieldAccess: { get: () => super.visitFieldAccess }
|
|
31
|
+
});
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const visited = yield _super.visitFieldAccess.call(this, fieldAccess, ctx);
|
|
34
|
+
return visited.name.element.simpleName === "type" && (0, theme_access_1.endsWithName)(visited.target, "palette")
|
|
35
|
+
? Object.assign(Object.assign({}, visited), { name: Object.assign(Object.assign({}, visited.name), { element: Object.assign(Object.assign({}, visited.name.element), { simpleName: "mode" }) }) }) : visited;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
visitPropertyAssignment(property, ctx) {
|
|
39
|
+
const _super = Object.create(null, {
|
|
40
|
+
visitPropertyAssignment: { get: () => super.visitPropertyAssignment }
|
|
41
|
+
});
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const visited = yield _super.visitPropertyAssignment.call(this, property, ctx);
|
|
44
|
+
const object = visited.initializer;
|
|
45
|
+
if ((0, jsx_attributes_1.propertyKey)(visited) !== "palette" || !(0, jsx_attributes_1.isObjectLiteral)(object))
|
|
46
|
+
return visited;
|
|
47
|
+
const statements = (0, jsx_attributes_1.objectProperties)(object).map(s => {
|
|
48
|
+
const name = s.element.kind === javascript_1.JS.Kind.PropertyAssignment && s.element.name.element;
|
|
49
|
+
return name && (0, java_1.isIdentifier)(name) && name.simpleName === "type"
|
|
50
|
+
? Object.assign(Object.assign({}, s), { element: Object.assign(Object.assign({}, s.element), { name: Object.assign(Object.assign({}, s.element.name), { element: Object.assign(Object.assign({}, name), { simpleName: "mode" }) }) }) }) : s;
|
|
51
|
+
});
|
|
52
|
+
return statements.every((s, i) => s === (0, jsx_attributes_1.objectProperties)(object)[i]) ? visited
|
|
53
|
+
: Object.assign(Object.assign({}, visited), { initializer: Object.assign(Object.assign({}, object), { body: Object.assign(Object.assign({}, object.body), { statements }) }) });
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}());
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.RenameThemePaletteType = RenameThemePaletteType;
|
|
61
|
+
//# sourceMappingURL=rename-theme-palette-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-theme-palette-type.js","sourceRoot":"","sources":["../../src/mui/rename-theme-palette-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAA2F;AAC3F,oDAA0D;AAC1D,qDAAgF;AAChF,iDAA4C;AAU5C,MAAa,sBAAuB,SAAQ,gBAAM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IAAI,CAAC,OAAO,CAAC;4BACrF,OAAO,IAAI,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM;gCAC3D,CAAC,iCAAK,CAAC,KAAE,OAAO,kCAAM,CAAC,CAAC,OAAO,KAAE,IAAI,kCAAM,CAAC,CAAC,OAAO,CAAC,IAAI,KAAE,OAAO,kCAAM,IAAI,KAAE,UAAU,EAAE,MAAM,aAAK,CAAC,CAAC,CAAC,CAAC;wBACjH,CAAC,CAAC,CAAC;wBACH,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAA,iCAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;4BAC1E,CAAC,CAAC,gCAAI,OAAO,KAAE,WAAW,kCAAM,MAAM,KAAE,IAAI,kCAAM,MAAM,CAAC,IAAK,KAAE,UAAU,SAA4B,CAAC;oBAC/G,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AA3BD,wDA2BC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExecutionContext, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
import { PreV5Recipe } from "./pre-v5-recipe";
|
|
3
|
+
export declare class ReplaceBoxBorderRadius extends PreV5Recipe {
|
|
4
|
+
readonly name = "org.openrewrite.react.mui.replace-box-border-radius";
|
|
5
|
+
readonly displayName: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
private readonly written;
|
|
8
|
+
protected v4Editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=replace-box-border-radius.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-box-border-radius.d.ts","sourceRoot":"","sources":["../../src/mui/replace-box-border-radius.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAc5C,qBAAa,sBAAuB,SAAQ,WAAW;IACnD,QAAQ,CAAC,IAAI,yDAAyD;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0C;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0I;IAGtK,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;cAE7B,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAiB1E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.ReplaceBoxBorderRadius = void 0;
|
|
13
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
14
|
+
const pre_v5_recipe_1 = require("./pre-v5-recipe");
|
|
15
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
16
|
+
const jsx_attributes_1 = require("./jsx-attributes");
|
|
17
|
+
const mui_components_1 = require("./mui-components");
|
|
18
|
+
const mui_tag_visitor_1 = require("./mui-tag-visitor");
|
|
19
|
+
class ReplaceBoxBorderRadius extends pre_v5_recipe_1.PreV5Recipe {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.name = "org.openrewrite.react.mui.replace-box-border-radius";
|
|
23
|
+
this.displayName = "Update the Box `borderRadius` values";
|
|
24
|
+
this.description = "Replaces `borderRadius=\"borderRadius\"` with `borderRadius={1}`, and a number `borderRadius={16}` with the pixel string `\"16px\"`.";
|
|
25
|
+
this.written = new Set();
|
|
26
|
+
}
|
|
27
|
+
v4Editor() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const written = this.written;
|
|
30
|
+
return (0, mui_tag_visitor_1.muiTagEditor)("Box", undefined, (tag, cursor) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const attribute = (0, jsx_attributes_1.findAttribute)(tag, "borderRadius");
|
|
32
|
+
if (!(attribute === null || attribute === void 0 ? void 0 : attribute.value) || written.has(attribute.id))
|
|
33
|
+
return tag;
|
|
34
|
+
if ((0, mui_components_1.attributeString)(attribute) === "borderRadius" && attribute.value.element.kind === java_1.J.Kind.Literal) {
|
|
35
|
+
const created = yield (0, jsx_attributes_1.newAttribute)(cursor, tag, "borderRadius", "{1}");
|
|
36
|
+
written.add(created.id);
|
|
37
|
+
return (0, jsx_attributes_1.replaceAttribute)(tag, attribute, created);
|
|
38
|
+
}
|
|
39
|
+
const value = attribute.value.element.kind === javascript_1.JS.Kind.JsxEmbeddedExpression ? (0, jsx_attributes_1.attributeExpression)(attribute) : undefined;
|
|
40
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) !== java_1.J.Kind.Literal || typeof value.value !== "number")
|
|
41
|
+
return tag;
|
|
42
|
+
const created = yield (0, jsx_attributes_1.newAttribute)(cursor, tag, "borderRadius", `"${value.value}px"`);
|
|
43
|
+
written.add(created.id);
|
|
44
|
+
return (0, jsx_attributes_1.replaceAttribute)(tag, attribute, created);
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ReplaceBoxBorderRadius = ReplaceBoxBorderRadius;
|
|
50
|
+
//# sourceMappingURL=replace-box-border-radius.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-box-border-radius.js","sourceRoot":"","sources":["../../src/mui/replace-box-border-radius.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gEAAwD;AACxD,mDAA4C;AAC5C,oDAA4C;AAC5C,qDAAoG;AACpG,qDAAiD;AACjD,uDAA+C;AAU/C,MAAa,sBAAuB,SAAQ,2BAAW;IAAvD;;QACa,SAAI,GAAG,qDAAqD,CAAC;QAC7D,gBAAW,GAAW,sCAAsC,CAAC;QAC7D,gBAAW,GAAW,sIAAsI,CAAC;QAGrJ,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAmBjD,CAAC;IAjBmB,QAAQ;;YACpB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,OAAO,IAAA,8BAAY,EAAC,KAAK,EAAE,SAAS,EAAE,CAAO,GAAG,EAAE,MAAM,EAAE,EAAE;gBACxD,MAAM,SAAS,GAAG,IAAA,8BAAa,EAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBACrD,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,CAAA,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAAE,OAAO,GAAG,CAAC;gBAC/D,IAAI,IAAA,gCAAe,EAAC,SAAS,CAAC,KAAK,cAAc,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACnG,MAAM,OAAO,GAAG,MAAM,IAAA,6BAAY,EAAC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;oBACvE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBACxB,OAAO,IAAA,iCAAgB,EAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;gBACrD,CAAC;gBACD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,eAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAA,oCAAmB,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC1H,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,QAAC,CAAC,IAAI,CAAC,OAAO,IAAI,OAAQ,KAAmB,CAAC,KAAK,KAAK,QAAQ;oBAAE,OAAO,GAAG,CAAC;gBACjG,MAAM,OAAO,GAAG,MAAM,IAAA,6BAAY,EAAC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,IAAK,KAAmB,CAAC,KAAK,KAAK,CAAC,CAAC;gBACrG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACxB,OAAO,IAAA,iCAAgB,EAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAzBD,wDAyBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceBreakpointsWidth extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.replace-breakpoints-width";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=replace-breakpoints-width.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-breakpoints-width.d.ts","sourceRoot":"","sources":["../../src/mui/replace-breakpoints-width.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAUvF,qBAAa,uBAAwB,SAAQ,MAAM;IAC/C,QAAQ,CAAC,IAAI,yDAAyD;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyE;IACrG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAgI;IAEtJ,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAY9D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.ReplaceBreakpointsWidth = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
const theme_access_1 = require("./theme-access");
|
|
16
|
+
class ReplaceBreakpointsWidth extends rewrite_1.Recipe {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.name = "org.openrewrite.react.mui.replace-breakpoints-width";
|
|
20
|
+
this.displayName = "Replace `theme.breakpoints.width()` with `theme.breakpoints.values`";
|
|
21
|
+
this.description = "Replaces `theme.breakpoints.width('md')` with `theme.breakpoints.values.md`, for a breakpoint written as a string literal.";
|
|
22
|
+
}
|
|
23
|
+
editor() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
26
|
+
visitMethodInvocation(invocation, ctx) {
|
|
27
|
+
const _super = Object.create(null, {
|
|
28
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
29
|
+
});
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
var _a;
|
|
32
|
+
const visited = yield _super.visitMethodInvocation.call(this, invocation, ctx);
|
|
33
|
+
const select = (_a = visited.select) === null || _a === void 0 ? void 0 : _a.element;
|
|
34
|
+
const key = visited.arguments.elements.length === 1 ? (0, theme_access_1.stringValue)(visited.arguments.elements[0].element) : undefined;
|
|
35
|
+
if (visited.name.simpleName !== "width" || !key || !/^[A-Za-z_$][\w$]*$/.test(key) || !(0, theme_access_1.endsWithName)(select, "breakpoints"))
|
|
36
|
+
return visited;
|
|
37
|
+
const replaced = yield (0, javascript_1.template) `${select}.values.${(0, javascript_1.raw)(key)}`.apply(visited, this.cursor);
|
|
38
|
+
return replaced ? Object.assign(Object.assign({}, replaced), { prefix: visited.prefix }) : visited;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ReplaceBreakpointsWidth = ReplaceBreakpointsWidth;
|
|
46
|
+
//# sourceMappingURL=replace-breakpoints-width.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-breakpoints-width.js","sourceRoot":"","sources":["../../src/mui/replace-breakpoints-width.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAAsG;AAEtG,iDAAyD;AAOzD,MAAa,uBAAwB,SAAQ,gBAAM;IAAnD;;QACa,SAAI,GAAG,qDAAqD,CAAC;Q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
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class ReplaceComponentClass extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.replace-component-class";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
componentName: string;
|
|
7
|
+
oldClass: string;
|
|
8
|
+
newClasses: string;
|
|
9
|
+
packageName?: string;
|
|
10
|
+
constructor(options?: {
|
|
11
|
+
componentName?: string;
|
|
12
|
+
oldClass?: string;
|
|
13
|
+
newClasses?: string;
|
|
14
|
+
packageName?: string;
|
|
15
|
+
});
|
|
16
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=replace-component-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-component-class.d.ts","sourceRoot":"","sources":["../../src/mui/replace-component-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAsB/F,qBAAa,qBAAsB,SAAQ,MAAM;IAC7C,QAAQ,CAAC,IAAI,uDAAuD;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA2C;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA6L;IAGzN,aAAa,EAAG,MAAM,CAAC;IAGvB,QAAQ,EAAG,MAAM,CAAC;IAGlB,UAAU,EAAG,MAAM,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAqD9D"}
|
|
@@ -0,0 +1,126 @@
|
|
|
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.ReplaceComponentClass = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
21
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
22
|
+
const jsx_attributes_1 = require("./jsx-attributes");
|
|
23
|
+
const mui_components_1 = require("./mui-components");
|
|
24
|
+
const mui_tag_visitor_1 = require("./mui-tag-visitor");
|
|
25
|
+
const lowerFirst = (s) => s.charAt(0).toLowerCase() + s.slice(1);
|
|
26
|
+
class ReplaceComponentClass extends rewrite_1.Recipe {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super(options);
|
|
29
|
+
this.name = "org.openrewrite.react.mui.replace-component-class";
|
|
30
|
+
this.displayName = "Replace a Material UI component class";
|
|
31
|
+
this.description = "Replaces a class of a Material UI component in its `classes` prop, in `xClasses` members and in `.MuiComponent-class` selectors. With several new classes only selectors are rewritten.";
|
|
32
|
+
}
|
|
33
|
+
editor() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const { componentName, oldClass } = this;
|
|
36
|
+
const news = this.newClasses.split(",").map(s => s.trim());
|
|
37
|
+
const single = news.length === 1 ? news[0] : undefined;
|
|
38
|
+
const pattern = (0, mui_tag_visitor_1.packagePattern)(this.packageName);
|
|
39
|
+
const selector = new RegExp(`\\.Mui${componentName}-${(0, mui_components_1.escapeRegExp)(oldClass)}(?![A-Za-z0-9_-])`, "g");
|
|
40
|
+
const replacement = news.map(n => `.Mui${componentName}-${n}`).join("");
|
|
41
|
+
const classesName = `${lowerFirst(componentName)}Classes`;
|
|
42
|
+
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
45
|
+
this.components = new Map();
|
|
46
|
+
this.classesImported = false;
|
|
47
|
+
}
|
|
48
|
+
visitJsCompilationUnit(cu, ctx) {
|
|
49
|
+
const _super = Object.create(null, {
|
|
50
|
+
visitJsCompilationUnit: { get: () => super.visitJsCompilationUnit }
|
|
51
|
+
});
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
this.components = (0, mui_components_1.muiComponents)(cu, pattern);
|
|
54
|
+
this.classesImported = [...this.components.entries()].some(([local, name]) => local === classesName && name === classesName);
|
|
55
|
+
return _super.visitJsCompilationUnit.call(this, cu, ctx);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
visitJsxTag(tag, ctx) {
|
|
59
|
+
const _super = Object.create(null, {
|
|
60
|
+
visitJsxTag: { get: () => super.visitJsxTag }
|
|
61
|
+
});
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const visited = yield _super.visitJsxTag.call(this, tag, ctx);
|
|
64
|
+
const name = visited.openName.element;
|
|
65
|
+
if (!single || !(0, java_1.isIdentifier)(name) || this.components.get(name.simpleName) !== componentName)
|
|
66
|
+
return visited;
|
|
67
|
+
const classes = (0, jsx_attributes_1.findAttribute)(visited, "classes");
|
|
68
|
+
const object = classes && (0, jsx_attributes_1.attributeObject)(classes);
|
|
69
|
+
if (!classes || !object)
|
|
70
|
+
return visited;
|
|
71
|
+
const statements = (0, jsx_attributes_1.objectProperties)(object).map(s => {
|
|
72
|
+
const key = s.element.kind === javascript_1.JS.Kind.PropertyAssignment && s.element.name.element;
|
|
73
|
+
return key && (0, java_1.isIdentifier)(key) && (0, jsx_attributes_1.propertyKey)(s.element) === oldClass
|
|
74
|
+
? Object.assign(Object.assign({}, s), { element: Object.assign(Object.assign({}, s.element), { name: Object.assign(Object.assign({}, s.element.name), { element: Object.assign(Object.assign({}, key), { simpleName: single }) }) }) }) : s;
|
|
75
|
+
});
|
|
76
|
+
if (statements.every((s, i) => s === (0, jsx_attributes_1.objectProperties)(object)[i]))
|
|
77
|
+
return visited;
|
|
78
|
+
const embedded = classes.value.element;
|
|
79
|
+
const updated = Object.assign(Object.assign({}, classes), { value: Object.assign(Object.assign({}, classes.value), { element: Object.assign(Object.assign({}, embedded), { expression: Object.assign(Object.assign({}, embedded.expression), { element: Object.assign(Object.assign({}, object), { body: Object.assign(Object.assign({}, object.body), { statements }) }) }) }) }) });
|
|
80
|
+
return Object.assign(Object.assign({}, visited), { attributes: visited.attributes.map(a => a.element === classes ? Object.assign(Object.assign({}, a), { element: updated }) : a) });
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
visitFieldAccess(fieldAccess, ctx) {
|
|
84
|
+
const _super = Object.create(null, {
|
|
85
|
+
visitFieldAccess: { get: () => super.visitFieldAccess }
|
|
86
|
+
});
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const visited = yield _super.visitFieldAccess.call(this, fieldAccess, ctx);
|
|
89
|
+
const target = visited.target;
|
|
90
|
+
if (!single || !this.classesImported || !(0, java_1.isIdentifier)(target) || target.simpleName !== classesName || visited.name.element.simpleName !== oldClass)
|
|
91
|
+
return visited;
|
|
92
|
+
return Object.assign(Object.assign({}, visited), { name: Object.assign(Object.assign({}, visited.name), { element: Object.assign(Object.assign({}, visited.name.element), { simpleName: single }) }) });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
visitLiteral(literal, ctx) {
|
|
96
|
+
const _super = Object.create(null, {
|
|
97
|
+
visitLiteral: { get: () => super.visitLiteral }
|
|
98
|
+
});
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const visited = yield _super.visitLiteral.call(this, literal, ctx);
|
|
101
|
+
if (typeof visited.value !== "string" || !visited.valueSource)
|
|
102
|
+
return visited;
|
|
103
|
+
selector.lastIndex = 0;
|
|
104
|
+
if (!selector.test(visited.value))
|
|
105
|
+
return visited;
|
|
106
|
+
return Object.assign(Object.assign({}, visited), { value: visited.value.replace(selector, replacement), valueSource: visited.valueSource.replace(selector, replacement) });
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}());
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.ReplaceComponentClass = ReplaceComponentClass;
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, rewrite_1.Option)({ displayName: "Component name", description: "The Material UI component.", example: "Avatar" })
|
|
116
|
+
], ReplaceComponentClass.prototype, "componentName", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, rewrite_1.Option)({ displayName: "Old class", description: "The class key that is replaced.", example: "circle" })
|
|
119
|
+
], ReplaceComponentClass.prototype, "oldClass", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, rewrite_1.Option)({ displayName: "New classes", description: "The class key that replaces it, or several separated by commas that a selector gets one after the other.", example: "circular" })
|
|
122
|
+
], ReplaceComponentClass.prototype, "newClasses", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, rewrite_1.Option)({ displayName: "Package name", description: "A package that re-exports Material UI.", example: "@org/ui", required: false })
|
|
125
|
+
], ReplaceComponentClass.prototype, "packageName", void 0);
|
|
126
|
+
//# sourceMappingURL=replace-component-class.js.map
|