@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.
- 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/migration/change-component-prop-value.d.ts.map +1 -1
- package/dist/migration/change-component-prop-value.js +14 -4
- package/dist/migration/change-component-prop-value.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/react19/use-context-hook.d.ts.map +1 -1
- package/dist/react19/use-context-hook.js +2 -0
- package/dist/react19/use-context-hook.js.map +1 -1
- 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 +2 -2
- package/src/index.ts +10 -0
- package/src/migration/change-component-prop-value.ts +19 -8
- 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/react19/use-context-hook.ts +2 -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,140 @@
|
|
|
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.withAttributes = exports.bare = exports.objectProperties = exports.isObjectLiteral = exports.hasSpread = void 0;
|
|
13
|
+
exports.findAttribute = findAttribute;
|
|
14
|
+
exports.attributeExpression = attributeExpression;
|
|
15
|
+
exports.attributeObject = attributeObject;
|
|
16
|
+
exports.propertyKey = propertyKey;
|
|
17
|
+
exports.findProperty = findProperty;
|
|
18
|
+
exports.newAttribute = newAttribute;
|
|
19
|
+
exports.newObjectAttribute = newObjectAttribute;
|
|
20
|
+
exports.spaced = spaced;
|
|
21
|
+
exports.newObject = newObject;
|
|
22
|
+
exports.newProperty = newProperty;
|
|
23
|
+
exports.appendProperty = appendProperty;
|
|
24
|
+
exports.replaceAttribute = replaceAttribute;
|
|
25
|
+
exports.appendAttribute = appendAttribute;
|
|
26
|
+
exports.newPropertyFromSource = newPropertyFromSource;
|
|
27
|
+
exports.sourceExpression = sourceExpression;
|
|
28
|
+
exports.renameTag = renameTag;
|
|
29
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
30
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
31
|
+
const mui_components_1 = require("./mui-components");
|
|
32
|
+
function findAttribute(tag, name) {
|
|
33
|
+
return tag.attributes.map(a => a.element).find((a) => (0, mui_components_1.attributeName)(a) === name);
|
|
34
|
+
}
|
|
35
|
+
const hasSpread = (tag) => tag.attributes.some(a => a.element.kind === javascript_1.JS.Kind.JsxSpreadAttribute);
|
|
36
|
+
exports.hasSpread = hasSpread;
|
|
37
|
+
function attributeExpression(attribute) {
|
|
38
|
+
var _a;
|
|
39
|
+
const value = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.element;
|
|
40
|
+
if (!value)
|
|
41
|
+
return { kind: java_1.J.Kind.Literal, id: attribute.id, prefix: java_1.emptySpace, markers: { kind: "org.openrewrite.marker.Markers", id: attribute.id, markers: [] }, value: true, valueSource: "true" };
|
|
42
|
+
return value.kind === javascript_1.JS.Kind.JsxEmbeddedExpression ? value.expression.element : value;
|
|
43
|
+
}
|
|
44
|
+
const isObjectLiteral = (e) => (e === null || e === void 0 ? void 0 : e.kind) === java_1.J.Kind.NewClass && !e.class && !!e.body;
|
|
45
|
+
exports.isObjectLiteral = isObjectLiteral;
|
|
46
|
+
function attributeObject(attribute) {
|
|
47
|
+
var _a;
|
|
48
|
+
const value = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.element;
|
|
49
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) !== javascript_1.JS.Kind.JsxEmbeddedExpression)
|
|
50
|
+
return undefined;
|
|
51
|
+
const inner = value.expression.element;
|
|
52
|
+
return (0, exports.isObjectLiteral)(inner) ? inner : undefined;
|
|
53
|
+
}
|
|
54
|
+
const objectProperties = (object) => object.body.statements;
|
|
55
|
+
exports.objectProperties = objectProperties;
|
|
56
|
+
function propertyKey(property) {
|
|
57
|
+
if ((property === null || property === void 0 ? void 0 : property.kind) !== javascript_1.JS.Kind.PropertyAssignment)
|
|
58
|
+
return undefined;
|
|
59
|
+
const name = property.name.element;
|
|
60
|
+
if ((0, java_1.isIdentifier)(name))
|
|
61
|
+
return name.simpleName;
|
|
62
|
+
return name.kind === java_1.J.Kind.Literal && typeof name.value === "string" ? name.value : undefined;
|
|
63
|
+
}
|
|
64
|
+
function findProperty(object, key) {
|
|
65
|
+
return (0, exports.objectProperties)(object).map(p => p.element).find(p => propertyKey(p) === key);
|
|
66
|
+
}
|
|
67
|
+
const trimmed = (node) => (Object.assign(Object.assign({}, node), { prefix: java_1.emptySpace }));
|
|
68
|
+
exports.bare = trimmed;
|
|
69
|
+
const withAttributes = (tag, attributes) => (Object.assign(Object.assign({}, tag), { attributes }));
|
|
70
|
+
exports.withAttributes = withAttributes;
|
|
71
|
+
const attributeRightPadded = (attribute, like) => (Object.assign(Object.assign({}, like), { element: attribute }));
|
|
72
|
+
function newAttribute(cursor, tag, name, value) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const probe = typeof value === "string"
|
|
75
|
+
? yield (0, javascript_1.template) `<X ${(0, javascript_1.raw)(name)}=${(0, javascript_1.raw)(value)} />`.apply(tag, cursor)
|
|
76
|
+
: yield (0, javascript_1.template) `<X ${(0, javascript_1.raw)(name)}={${trimmed(value)}} />`.apply(tag, cursor);
|
|
77
|
+
return probe.attributes[0].element;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function newObjectAttribute(cursor, tag, name, key, value) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const probe = yield (0, javascript_1.template) `<X ${(0, javascript_1.raw)(name)}={{ ${(0, javascript_1.raw)(key)}: ${trimmed(value)} }} />`.apply(tag, cursor);
|
|
83
|
+
const attribute = probe.attributes[0].element;
|
|
84
|
+
const embedded = attribute.value.element;
|
|
85
|
+
return Object.assign(Object.assign({}, attribute), { value: Object.assign(Object.assign({}, attribute.value), { element: Object.assign(Object.assign({}, embedded), { expression: Object.assign(Object.assign({}, embedded.expression), { element: spaced(attributeObject(attribute)) }) }) }) });
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const space = (whitespace) => (Object.assign(Object.assign({}, java_1.emptySpace), { whitespace }));
|
|
89
|
+
function spaced(object) {
|
|
90
|
+
const [first, ...rest] = (0, exports.objectProperties)(object);
|
|
91
|
+
return Object.assign(Object.assign({}, object), { body: Object.assign(Object.assign({}, object.body), { statements: [Object.assign(Object.assign({}, first), { element: Object.assign(Object.assign({}, first.element), { prefix: space(" ") }) }), ...rest], end: space(" ") }) });
|
|
92
|
+
}
|
|
93
|
+
function newObject(cursor, tag, key, value) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const attribute = yield newObjectAttribute(cursor, tag, "x", key, value);
|
|
96
|
+
return attributeObject(attribute);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function newProperty(cursor, tag, key, value) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const object = yield newObject(cursor, tag, key, value);
|
|
102
|
+
return (0, exports.objectProperties)(object)[0];
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function appendProperty(object, property) {
|
|
106
|
+
const statements = (0, exports.objectProperties)(object);
|
|
107
|
+
const last = statements[statements.length - 1];
|
|
108
|
+
const prefix = last ? last.element.prefix : Object.assign({}, property.element.prefix);
|
|
109
|
+
const added = Object.assign(Object.assign({}, property), { element: Object.assign(Object.assign({}, property.element), { prefix: statements.length ? prefix : property.element.prefix }) });
|
|
110
|
+
return Object.assign(Object.assign({}, object), { body: Object.assign(Object.assign({}, object.body), { statements: [...statements, added] }) });
|
|
111
|
+
}
|
|
112
|
+
function replaceAttribute(tag, old, replacement) {
|
|
113
|
+
const attributes = tag.attributes.flatMap(a => a.element !== old ? [a] :
|
|
114
|
+
replacement ? [attributeRightPadded(Object.assign(Object.assign({}, replacement), { prefix: old.prefix }), a)] : []);
|
|
115
|
+
return (0, exports.withAttributes)(tag, attributes);
|
|
116
|
+
}
|
|
117
|
+
function appendAttribute(tag, attribute) {
|
|
118
|
+
var _a;
|
|
119
|
+
const last = tag.attributes[tag.attributes.length - 1];
|
|
120
|
+
const prefix = last ? last.element.prefix : Object.assign(Object.assign({}, java_1.emptySpace), { whitespace: " " });
|
|
121
|
+
const added = { kind: java_1.J.Kind.RightPadded, element: Object.assign(Object.assign({}, attribute), { prefix }), after: java_1.emptySpace, markers: (_a = last === null || last === void 0 ? void 0 : last.markers) !== null && _a !== void 0 ? _a : attribute.markers };
|
|
122
|
+
return (0, exports.withAttributes)(tag, [...tag.attributes, added]);
|
|
123
|
+
}
|
|
124
|
+
function newPropertyFromSource(cursor, anchor, key, source) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const probe = yield (0, javascript_1.template) `<X a={{ ${(0, javascript_1.raw)(key)}: ${(0, javascript_1.raw)(source)} }} />`.apply(anchor, cursor);
|
|
127
|
+
return (0, exports.objectProperties)(attributeObject(probe.attributes[0].element))[0];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function sourceExpression(cursor, anchor, source) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const probe = yield (0, javascript_1.template) `<X a={${(0, javascript_1.raw)(source)}} />`.apply(anchor, cursor);
|
|
133
|
+
return attributeExpression(probe.attributes[0].element);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function renameTag(tag, name) {
|
|
137
|
+
const rename = (n) => (0, java_1.isIdentifier)(n) ? Object.assign(Object.assign({}, n), { simpleName: name }) : n;
|
|
138
|
+
return Object.assign(Object.assign(Object.assign({}, tag), { openName: Object.assign(Object.assign({}, tag.openName), { element: rename(tag.openName.element) }) }), (tag.closingName ? { closingName: Object.assign(Object.assign({}, tag.closingName), { element: rename(tag.closingName.element) }) } : {}));
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=jsx-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-attributes.js","sourceRoot":"","sources":["../../src/mui/jsx-attributes.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,sCAEC;AAKD,kDAIC;AAMD,0CAKC;AAID,kCAKC;AAED,oCAEC;AAcD,oCAKC;AAGD,gDAKC;AAKD,wBAGC;AAGD,8BAGC;AAGD,kCAGC;AAGD,wCAMC;AAGD,4CAIC;AAGD,0CAKC;AAGD,sDAGC;AAGD,4CAGC;AAGD,8BAIC;AAnID,gEAAuE;AACvE,oDAAsE;AACtE,qDAA+C;AAI/C,SAAgB,aAAa,CAAC,GAAY,EAAE,IAAY;IACpD,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAsB,EAAE,CAAC,IAAA,8BAAa,EAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACzG,CAAC;AAEM,MAAM,SAAS,GAAG,CAAC,GAAY,EAAW,EAAE,CAAC,GAAG,CAAC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CAAM,EAAE,EAAE,CAAC,IAAA,mBAAY,EAAC,CAAC,CAAC,CAAC,CAAC,iCAAK,CAAC,KAAE,UAAU,EAAE,IAAI,IAAE,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,8CAAI,GAAG,KAAE,QAAQ,kCAAM,GAAG,CAAC,QAAQ,KAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,QAC1E,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,WAAW,kCAAM,GAAG,CAAC,WAAW,KAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,GAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAY,CAAC;AAC9H,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MarkManualMigration extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.mark-manual-migration";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
importedName: string;
|
|
7
|
+
message: string;
|
|
8
|
+
packageName?: string;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
importedName?: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
packageName?: string;
|
|
13
|
+
});
|
|
14
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mark-manual-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark-manual-migration.d.ts","sourceRoot":"","sources":["../../src/mui/mark-manual-migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAgC,MAAM,sBAAsB,CAAC;AAelH,qBAAa,mBAAoB,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,qDAAqD;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0D;IACtF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAmJ;IAG/K,YAAY,EAAG,MAAM,CAAC;IAGtB,OAAO,EAAG,MAAM,CAAC;IAGjB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAIjF,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAmB9D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.MarkManualMigration = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
21
|
+
const module_imports_1 = require("../util/module-imports");
|
|
22
|
+
const mui_tag_visitor_1 = require("./mui-tag-visitor");
|
|
23
|
+
class MarkManualMigration extends rewrite_1.Recipe {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super(options);
|
|
26
|
+
this.name = "org.openrewrite.react.mui.mark-manual-migration";
|
|
27
|
+
this.displayName = "Mark a Material UI API that needs a manual migration";
|
|
28
|
+
this.description = "Marks every import of the named export of a Material UI package with a message saying how to migrate it, where no mechanical rewrite is safe.";
|
|
29
|
+
}
|
|
30
|
+
editor() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { importedName, message } = this;
|
|
33
|
+
const pattern = (0, mui_tag_visitor_1.packagePattern)(this.packageName);
|
|
34
|
+
const matches = (b) => (importedName === "*" || b.name === importedName) && pattern.test(b.module);
|
|
35
|
+
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
this.matches = false;
|
|
39
|
+
}
|
|
40
|
+
visitJsCompilationUnit(cu, ctx) {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
visitJsCompilationUnit: { get: () => super.visitJsCompilationUnit }
|
|
43
|
+
});
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
this.matches = (0, module_imports_1.importBindings)(cu).some(matches);
|
|
46
|
+
return this.matches ? _super.visitJsCompilationUnit.call(this, cu, ctx) : cu;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
visitImportDeclaration(declaration, ctx) {
|
|
50
|
+
const _super = Object.create(null, {
|
|
51
|
+
visitImportDeclaration: { get: () => super.visitImportDeclaration }
|
|
52
|
+
});
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const visited = yield _super.visitImportDeclaration.call(this, declaration, ctx);
|
|
55
|
+
const bindings = (0, module_imports_1.importBindings)({ statements: [{ element: visited }] });
|
|
56
|
+
return bindings.some(matches) ? (0, rewrite_1.foundSearchResult)(visited, message) : visited;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}());
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.MarkManualMigration = MarkManualMigration;
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, rewrite_1.Option)({ displayName: "Imported name", description: "The export that is imported, such as `makeStyles`, or `*` for any import of the package.", example: "makeStyles" })
|
|
66
|
+
], MarkManualMigration.prototype, "importedName", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, rewrite_1.Option)({ displayName: "Message", description: "What to do, shown in the marker.", example: "Migrate to the `styled` API" })
|
|
69
|
+
], MarkManualMigration.prototype, "message", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, rewrite_1.Option)({ displayName: "Package name", description: "A package that re-exports Material UI.", example: "@org/ui", required: false })
|
|
72
|
+
], MarkManualMigration.prototype, "packageName", void 0);
|
|
73
|
+
//# sourceMappingURL=mark-manual-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark-manual-migration.js","sourceRoot":"","sources":["../../src/mui/mark-manual-migration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAkH;AAClH,gEAA2F;AAE3F,2DAAsD;AACtD,uDAAiD;AAWjD,MAAa,mBAAoB,SAAQ,gBAAM;IAc3C,YAAY,OAA2E;QACnF,KAAK,CAAC,OAAO,CAAC,CAAC;QAdV,SAAI,GAAG,iDAAiD,CAAC;QACzD,gBAAW,GAAW,sDAAsD,CAAC;QAC7E,gBAAW,G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,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AArCD,kDAqCC;AA/BG;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,0FAA0F,EAAE,OAAO,EAAE,YAAY,EAAC,CAAC;yDACjJ;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,kCAAkC,EAAE,OAAO,EAAE,6BAA6B,EAAC,CAAC;oDACzG;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;wDAC7G"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MarkPaletteModeUsage extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.mark-palette-mode-usage";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
message: string;
|
|
7
|
+
constructor(options?: {
|
|
8
|
+
message?: string;
|
|
9
|
+
});
|
|
10
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=mark-palette-mode-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark-palette-mode-usage.d.ts","sourceRoot":"","sources":["../../src/mui/mark-palette-mode-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAgC,MAAM,sBAAsB,CAAC;AAclH,qBAAa,oBAAqB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,uDAAuD;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAwC;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA8H;IAG1J,OAAO,EAAG,MAAM,CAAC;gBAEL,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAS9D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.MarkPaletteModeUsage = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
21
|
+
const theme_access_1 = require("./theme-access");
|
|
22
|
+
class MarkPaletteModeUsage extends rewrite_1.Recipe {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
super(options);
|
|
25
|
+
this.name = "org.openrewrite.react.mui.mark-palette-mode-usage";
|
|
26
|
+
this.displayName = "Mark reads of `theme.palette.mode`";
|
|
27
|
+
this.description = "Marks every read of `<something>.palette.mode` with a message saying to use `theme.applyStyles()` for dark mode instead.";
|
|
28
|
+
}
|
|
29
|
+
editor() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { message } = this;
|
|
32
|
+
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
33
|
+
visitFieldAccess(fieldAccess, ctx) {
|
|
34
|
+
const _super = Object.create(null, {
|
|
35
|
+
visitFieldAccess: { get: () => super.visitFieldAccess }
|
|
36
|
+
});
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const visited = yield _super.visitFieldAccess.call(this, fieldAccess, ctx);
|
|
39
|
+
return visited.name.element.simpleName === "mode" && (0, theme_access_1.endsWithName)(visited.target, "palette") ? (0, rewrite_1.foundSearchResult)(visited, message) : visited;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}());
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MarkPaletteModeUsage = MarkPaletteModeUsage;
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, rewrite_1.Option)({ displayName: "Message", description: "What to do, shown in the marker.", example: "Use theme.applyStyles('dark', {...}) in place of theme.palette.mode checks" })
|
|
49
|
+
], MarkPaletteModeUsage.prototype, "message", void 0);
|
|
50
|
+
//# sourceMappingURL=mark-palette-mode-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark-palette-mode-usage.js","sourceRoot":"","sources":["../../src/mui/mark-palette-mode-usage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAkH;AAClH,gEAAuF;AAEvF,iDAA4C;AAW5C,MAAa,oBAAqB,SAAQ,gBAAM;IAQ5C,YAAY,OAA8B;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QARV,SAAI,GAAG,mDAAmD,CAAC;QAC3D,gBAAW,GAAW,oCAAoC,CAAC;QAC3D,gBAAW,GAAW,0HAA0H,CAAC;IAO1J,CAAC;IAEK,MAAM;;YACR,MAAM,EAAC,OAAO,EAAC,GAAG,IAAI,CAAC;YACvB,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC3E,gBAAgB,CAAC,WAA0B,EAAE,GAAqB;;;;;wBAC7E,MAAM,OAAO,GAAG,MAAM,OAAM,gBAAgB,YAAC,WAAW,EAAE,GAAG,CAAkB,CAAC;wBAChF,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,MAAM,IAAI,IAAA,2BAAY,EAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBACjJ,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AArBD,oDAqBC;AAfG;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,kCAAkC,EAAE,OAAO,EAAE,4EAA4E,EAAC,CAAC;qDACxJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MoveComponentPropToSlot extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.move-component-prop-to-slot";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
componentName: string;
|
|
7
|
+
propName: string;
|
|
8
|
+
targetProp: string;
|
|
9
|
+
slotName: string;
|
|
10
|
+
slotPropName?: string;
|
|
11
|
+
packageName?: string;
|
|
12
|
+
constructor(options?: {
|
|
13
|
+
componentName?: string;
|
|
14
|
+
propName?: string;
|
|
15
|
+
targetProp?: string;
|
|
16
|
+
slotName?: string;
|
|
17
|
+
slotPropName?: string;
|
|
18
|
+
packageName?: string;
|
|
19
|
+
});
|
|
20
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=move-component-prop-to-slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-component-prop-to-slot.d.ts","sourceRoot":"","sources":["../../src/mui/move-component-prop-to-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAsBnF,qBAAa,uBAAwB,SAAQ,MAAM;IAC/C,QAAQ,CAAC,IAAI,2DAA2D;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAmD;IAC/E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAqL;IAGjN,aAAa,EAAG,MAAM,CAAC;IAGvB,QAAQ,EAAG,MAAM,CAAC;IAGlB,UAAU,EAAG,MAAM,CAAC;IAGpB,QAAQ,EAAG,MAAM,CAAC;IAGlB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,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,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAIlJ,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAkC9D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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.MoveComponentPropToSlot = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const jsx_attributes_1 = require("./jsx-attributes");
|
|
21
|
+
const mui_tag_visitor_1 = require("./mui-tag-visitor");
|
|
22
|
+
const jsx_attributes_2 = require("./jsx-attributes");
|
|
23
|
+
class MoveComponentPropToSlot extends rewrite_1.Recipe {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super(options);
|
|
26
|
+
this.name = "org.openrewrite.react.mui.move-component-prop-to-slot";
|
|
27
|
+
this.displayName = "Move a Material UI component prop into a slot";
|
|
28
|
+
this.description = "Moves a deprecated prop of a Material UI component into its `slots` or `slotProps` prop. Tags whose target is not an object literal, or already sets that slot, are left alone.";
|
|
29
|
+
}
|
|
30
|
+
editor() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { propName, targetProp, slotName, slotPropName } = this;
|
|
33
|
+
return (0, mui_tag_visitor_1.muiTagEditor)(this.componentName, this.packageName, (tag, cursor) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const attribute = (0, jsx_attributes_1.findAttribute)(tag, propName);
|
|
35
|
+
if (!attribute)
|
|
36
|
+
return tag;
|
|
37
|
+
const value = (0, jsx_attributes_1.bare)((0, jsx_attributes_1.attributeExpression)(attribute));
|
|
38
|
+
const target = (0, jsx_attributes_1.findAttribute)(tag, targetProp);
|
|
39
|
+
if (!target) {
|
|
40
|
+
const moved = slotPropName
|
|
41
|
+
? yield (0, jsx_attributes_1.newObjectAttribute)(cursor, tag, targetProp, slotName, yield (0, jsx_attributes_1.newObject)(cursor, tag, slotPropName, value))
|
|
42
|
+
: yield (0, jsx_attributes_1.newObjectAttribute)(cursor, tag, targetProp, slotName, value);
|
|
43
|
+
return (0, jsx_attributes_1.replaceAttribute)(tag, attribute, moved);
|
|
44
|
+
}
|
|
45
|
+
const object = (0, jsx_attributes_1.attributeObject)(target);
|
|
46
|
+
if (!object)
|
|
47
|
+
return tag;
|
|
48
|
+
const slot = (0, jsx_attributes_1.findProperty)(object, slotName);
|
|
49
|
+
let updated;
|
|
50
|
+
if (!slot) {
|
|
51
|
+
const inner = slotPropName ? yield (0, jsx_attributes_1.newObject)(cursor, tag, slotPropName, value) : value;
|
|
52
|
+
updated = (0, jsx_attributes_1.appendProperty)(object, yield (0, jsx_attributes_1.newProperty)(cursor, tag, slotName, inner));
|
|
53
|
+
}
|
|
54
|
+
else if (slotPropName && slot.initializer && (0, jsx_attributes_2.isObjectLiteral)(slot.initializer) && !(0, jsx_attributes_1.findProperty)(slot.initializer, slotPropName)) {
|
|
55
|
+
const added = (0, jsx_attributes_1.appendProperty)(slot.initializer, yield (0, jsx_attributes_1.newProperty)(cursor, tag, slotPropName, value));
|
|
56
|
+
updated = Object.assign(Object.assign({}, object), { body: Object.assign(Object.assign({}, object.body), { statements: object.body.statements.map(s => s.element === slot ? Object.assign(Object.assign({}, s), { element: Object.assign(Object.assign({}, slot), { initializer: added }) }) : s) }) });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return tag;
|
|
60
|
+
}
|
|
61
|
+
const embedded = target.value.element;
|
|
62
|
+
const retargeted = Object.assign(Object.assign({}, target), { value: Object.assign(Object.assign({}, target.value), { element: Object.assign(Object.assign({}, embedded), { expression: Object.assign(Object.assign({}, embedded.expression), { element: updated }) }) }) });
|
|
63
|
+
return (0, jsx_attributes_1.replaceAttribute)((0, jsx_attributes_1.replaceAttribute)(tag, target, retargeted), attribute, undefined);
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.MoveComponentPropToSlot = MoveComponentPropToSlot;
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, rewrite_1.Option)({ displayName: "Component name", description: "The Material UI component, such as `Dialog`.", example: "Dialog" })
|
|
71
|
+
], MoveComponentPropToSlot.prototype, "componentName", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, rewrite_1.Option)({ displayName: "Prop name", description: "The deprecated prop to move.", example: "TransitionComponent" })
|
|
74
|
+
], MoveComponentPropToSlot.prototype, "propName", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, rewrite_1.Option)({ displayName: "Target prop", description: "The prop the value moves into, `slots` or `slotProps`.", example: "slots", valid: ["slots", "slotProps"] })
|
|
77
|
+
], MoveComponentPropToSlot.prototype, "targetProp", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, rewrite_1.Option)({ displayName: "Slot name", description: "The key under the target prop.", example: "transition" })
|
|
80
|
+
], MoveComponentPropToSlot.prototype, "slotName", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, rewrite_1.Option)({ displayName: "Slot prop name", description: "A key under the slot, when the prop becomes one prop of the slot.", example: "ref", required: false })
|
|
83
|
+
], MoveComponentPropToSlot.prototype, "slotPropName", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(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 })
|
|
86
|
+
], MoveComponentPropToSlot.prototype, "packageName", void 0);
|
|
87
|
+
//# sourceMappingURL=move-component-prop-to-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-component-prop-to-slot.js","sourceRoot":"","sources":["../../src/mui/move-component-prop-to-slot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAmF;AACnF,qDAG0B;AAC1B,uDAA+C;AAC/C,qDAAiD;AAgBjD,MAAa,uBAAwB,SAAQ,gBAAM;IAuB/C,YAAY,OAA4I;QACpJ,KAAK,CAAC,OAAO,CAAC,CAAC;QAvBV,SAAI,GAAG,uDAAuD,CAAC;QAC/D,gBAAW,GAAW,+CAA+C,CAAC;QACtE,gBAAW,GAAW,iLAAiL,CAAC;IAsBjN,CAAC;IAEK,MAAM;;YACR,MAAM,EAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC;YAC5D,OAAO,IAAA,8BAAY,EAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,CAAO,GAAG,EAAE,MAAM,EAAE,EAAE;gBAC5E,MAAM,SAAS,GAAG,IAAA,8BAAa,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC/C,IAAI,CAAC,SAAS;oBAAE,OAAO,GAAG,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAA,qBAAI,EAAC,IA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AAE,OAAO,EAAE,qBAAqB,EAAC,CAAC;yDAC9F;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,wDAAwD,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,EAAC,CAAC;2DACzI;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,gCAAgC,EAAE,OAAO,EAAE,YAAY,EAAC,CAAC;yDACvF;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,mEAAmE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;6DACrI;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,sGAAsG,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;4DAC3K"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MovePrimaryTextToChildren extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.move-primary-text-to-children";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
packageName?: string;
|
|
7
|
+
constructor(options?: {
|
|
8
|
+
packageName?: string;
|
|
9
|
+
});
|
|
10
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=move-primary-text-to-children.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-primary-text-to-children.d.ts","sourceRoot":"","sources":["../../src/mui/move-primary-text-to-children.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAcnF,qBAAa,yBAA0B,SAAQ,MAAM;IACjD,QAAQ,CAAC,IAAI,6DAA6D;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAuD;IACnF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAsH;IAGlJ,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAC;IAItC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAc9D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.MovePrimaryTextToChildren = 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_tag_visitor_1 = require("./mui-tag-visitor");
|
|
24
|
+
class MovePrimaryTextToChildren extends rewrite_1.Recipe {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.name = "org.openrewrite.react.mui.move-primary-text-to-children";
|
|
28
|
+
this.displayName = "Move `MenuItem`'s `primaryText` into its children";
|
|
29
|
+
this.description = "Turns `<MenuItem primaryText=\"x\" />` into `<MenuItem>x</MenuItem>`. Only a self-closing `MenuItem` is changed.";
|
|
30
|
+
}
|
|
31
|
+
editor() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return (0, mui_tag_visitor_1.muiTagEditor)("MenuItem", this.packageName, (tag, cursor) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const attribute = (0, jsx_attributes_1.findAttribute)(tag, "primaryText");
|
|
35
|
+
if (!attribute || tag.children)
|
|
36
|
+
return tag;
|
|
37
|
+
const value = (0, jsx_attributes_1.attributeExpression)(attribute);
|
|
38
|
+
const isText = value.kind === java_1.J.Kind.Literal && typeof value.value === "string" && !/[{}<>]/.test(value.value);
|
|
39
|
+
const probe = (isText
|
|
40
|
+
? yield (0, javascript_1.template) `<X>${(0, javascript_1.raw)(value.value)}</X>`.apply(tag, cursor)
|
|
41
|
+
: yield (0, javascript_1.template) `<X>{${(0, jsx_attributes_1.bare)(value)}}</X>`.apply(tag, cursor));
|
|
42
|
+
const without = (0, jsx_attributes_1.replaceAttribute)(tag, attribute, undefined);
|
|
43
|
+
return Object.assign(Object.assign({}, without), { selfClosing: undefined, children: probe.children, closingName: Object.assign(Object.assign({}, probe.closingName), { element: without.openName.element }), afterClosingName: probe.afterClosingName });
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MovePrimaryTextToChildren = MovePrimaryTextToChildren;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, rewrite_1.Option)({ displayName: "Package name", description: "The package the component is imported from, when it is not one of Material UI's.", required: false, example: "@acme/ui" })
|
|
51
|
+
], MovePrimaryTextToChildren.prototype, "packageName", void 0);
|
|
52
|
+
//# sourceMappingURL=move-primary-text-to-children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-primary-text-to-children.js","sourceRoot":"","sources":["../../src/mui/move-primary-text-to-children.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAmF;AACnF,gEAAmE;AACnE,oDAA4C;AAC5C,qDAA4F;AAC5F,uDAA+C;AAU/C,MAAa,yBAA0B,SAAQ,gBAAM;IAQjD,YAAY,OAAgC;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QARV,SAAI,GAAG,yDAAyD,CAAC;QACjE,gBAAW,GAAW,mDAAmD,CAAC;QAC1E,gBAAW,GAAW,kHAAkH,CAAC;IAOlJ,CAAC;IAEK,MAAM;;YACR,OAAO,IAAA,8BAAY,EAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,CAAO,GAAG,EAAE,MAAM,EAAE,EAAE;gBACpE,MAAM,SAAS,GAAG,IAAA,8BAAa,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;gBACpD,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ;oBAAE,OAAO,GAAG,CAAC;gBAC3C,MAAM,KAAK,GAAG,IAAA,oCAAmB,EAAC,SAAS,CAAC,CAAC;gBAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,OAAO,IAAI,OAAQ,KAAmB,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAE,KAAmB,CAAC,KAAe,CAAC,CAAC;gBACvJ,MAAM,KAAK,GAAG,CAAC,MAAM;oBACjB,CAAC,CAAC,MAAM,IAAA,qBAAQ,EAAA,MAAM,IAAA,gBAAG,EAAE,KAAmB,CAAC,KAAe,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC;oBACxF,CAAC,CAAC,MAAM,IAAA,qBAAQ,EAAA,OAAO,IAAA,qBAAI,EAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAY,CAAC;gBAC7E,MAAM,OAAO,GAAG,IAAA,iCAAgB,EAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC5D,OAAO,gCAAI,OAAO,KAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,kCAAM,KAAK,CAAC,WAAY,KAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,KACxI,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GAAY,CAAC;YAC7D,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AA1BD,8DA0BC;AApBG;IADC,IAAA,gBAAM,EAAC,EAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,kFAAkF,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAC,CAAC;8DACxJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MoveSystemPropsToSx extends Recipe {
|
|
3
|
+
readonly name = "org.openrewrite.react.mui.move-system-props-to-sx";
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
componentNames: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
packageName?: string;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
componentNames?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
packageName?: string;
|
|
13
|
+
});
|
|
14
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=move-system-props-to-sx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-system-props-to-sx.d.ts","sourceRoot":"","sources":["../../src/mui/move-system-props-to-sx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,gBAAgB,EAAU,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AA4C3F,qBAAa,mBAAoB,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,uDAAuD;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA0C;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA6L;IAGzN,cAAc,EAAG,MAAM,CAAC;IAGxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAInF,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA2B9D"}
|