@mui/codemod
Version:
Codemod scripts for Material UI.
53 lines (52 loc) • 1.51 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transformer;
var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
/**
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
function transformer(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const printOptions = options.printOptions;
(0, _movePropIntoSlotProps.default)(j, {
root,
packageName: options.packageName,
componentName: 'TextField',
propName: 'InputProps',
slotName: 'input'
});
(0, _movePropIntoSlotProps.default)(j, {
root,
packageName: options.packageName,
componentName: 'TextField',
propName: 'inputProps',
slotName: 'htmlInput'
});
(0, _movePropIntoSlotProps.default)(j, {
root,
packageName: options.packageName,
componentName: 'TextField',
propName: 'SelectProps',
slotName: 'select'
});
(0, _movePropIntoSlotProps.default)(j, {
root,
packageName: options.packageName,
componentName: 'TextField',
propName: 'InputLabelProps',
slotName: 'inputLabel'
});
(0, _movePropIntoSlotProps.default)(j, {
root,
packageName: options.packageName,
componentName: 'TextField',
propName: 'FormHelperTextProps',
slotName: 'formHelperText'
});
return root.toSource(printOptions);
}
;