@mui/x-codemod 7.0.0-beta.7 → 7.6.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/README.md +49 -18
- package/codemod.js +1 -1
- package/package.json +18 -14
- package/v6.0.0/data-grid/rename-linkOperators-logicOperators/index.js +1 -1
- package/v7.0.0/data-grid/preset-safe/index.js +2 -0
- package/v7.0.0/data-grid/remove-stabilized-experimentalFeatures/index.js +29 -0
- package/v7.0.0/data-grid/rename-cell-selection-props/index.js +3 -1
- package/v7.0.0/tree-view/preset-safe/index.js +2 -0
- package/v7.0.0/tree-view/rename-nodeid/index.js +21 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ This repository contains a collection of codemod scripts based for use with
|
|
|
13
13
|
<!-- #default-branch-switch -->
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npx @mui/x-codemod@
|
|
16
|
+
npx @mui/x-codemod@latest <codemod> <paths...>
|
|
17
17
|
|
|
18
18
|
Applies a `@mui/x-codemod` to the specified paths
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ Options:
|
|
|
29
29
|
--jscodeshift Pass options directly to jscodeshift [array]
|
|
30
30
|
|
|
31
31
|
Examples:
|
|
32
|
-
npx @mui/x-codemod@latest
|
|
32
|
+
npx @mui/x-codemod@latest v7.0.0/preset-safe src
|
|
33
33
|
npx @mui/x-codemod@latest v6.0.0/component-rename-prop src --
|
|
34
34
|
--component=DataGrid --from=prop --to=newProp
|
|
35
35
|
```
|
|
@@ -40,9 +40,9 @@ To pass more options directly to jscodeshift, use `--jscodeshift=...`. For examp
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
// single option
|
|
43
|
-
npx @mui/x-codemod@
|
|
43
|
+
npx @mui/x-codemod@latest --jscodeshift=--run-in-band
|
|
44
44
|
// multiple options
|
|
45
|
-
npx @mui/x-codemod@
|
|
45
|
+
npx @mui/x-codemod@latest --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
See all available options [here](https://github.com/facebook/jscodeshift#usage-cli).
|
|
@@ -53,7 +53,7 @@ Options to [recast](https://github.com/benjamn/recast)'s printer can be provided
|
|
|
53
53
|
through jscodeshift's `printOptions` command line argument
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
npx @mui/x-codemod@
|
|
56
|
+
npx @mui/x-codemod@latest <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## v7.0.0
|
|
@@ -66,7 +66,7 @@ It runs codemods for both Data Grid and Date and Time Pickers packages.
|
|
|
66
66
|
To run codemods for a specific package, refer to the respective section.
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
npx @mui/x-codemod@
|
|
69
|
+
npx @mui/x-codemod@latest v7.0.0/preset-safe <path|folder>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
The corresponding sub-sections are listed below
|
|
@@ -82,7 +82,7 @@ The corresponding sub-sections are listed below
|
|
|
82
82
|
The `preset-safe` codemods for pickers.
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
npx @mui/x-codemod@
|
|
85
|
+
npx @mui/x-codemod@latest v7.0.0/pickers/preset-safe <path|folder>
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
The list includes these transformers
|
|
@@ -108,7 +108,7 @@ This change only affects Date and Time Picker components.
|
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
```bash
|
|
111
|
-
npx @mui/x-codemod@
|
|
111
|
+
npx @mui/x-codemod@latest v7.0.0/pickers/rename-components-to-slots <path>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
#### `rename-default-calendar-month-to-reference-date`
|
|
@@ -121,7 +121,7 @@ Replace the `defaultCalendarMonth` prop with the `referenceDate` prop.
|
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
|
-
npx @mui/x-codemod@
|
|
124
|
+
npx @mui/x-codemod@latest v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
#### `rename-day-picker-classes`
|
|
@@ -134,7 +134,7 @@ Rename the `dayPickerClasses` variable to `dayCalendarClasses`.
|
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
|
-
npx @mui/x-codemod@
|
|
137
|
+
npx @mui/x-codemod@latest v7.0.0/pickers/rename-day-picker-classes <path>
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
#### `rename-slots-types`
|
|
@@ -149,7 +149,7 @@ Replace types suffix `SlotsComponent` by `Slots` and `SlotsComponentsProps` by `
|
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
```bash
|
|
152
|
-
npx @mui/x-codemod@
|
|
152
|
+
npx @mui/x-codemod@latest v7.0.0/pickers/rename-slots-types <path>
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
### Data Grid codemods
|
|
@@ -159,13 +159,14 @@ npx @mui/x-codemod@next v7.0.0/pickers/rename-slots-types <path>
|
|
|
159
159
|
The `preset-safe` codemods for data grid.
|
|
160
160
|
|
|
161
161
|
```bash
|
|
162
|
-
npx @mui/x-codemod@
|
|
162
|
+
npx @mui/x-codemod@latest v7.0.0/data-grid/preset-safe <path|folder>
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
The list includes these transformers
|
|
166
166
|
|
|
167
167
|
- [`rename-components-to-slots-data-grid`](#rename-components-to-slots-data-grid)
|
|
168
168
|
- [`rename-cell-selection-props`](#rename-cell-selection-props)
|
|
169
|
+
- [`remove-stabilized-v7-experimentalFeatures`](#remove-stabilized-v7-experimentalFeatures)
|
|
169
170
|
|
|
170
171
|
#### `rename-components-to-slots-data-grid`
|
|
171
172
|
|
|
@@ -183,7 +184,7 @@ This change only affects Data Grid components.
|
|
|
183
184
|
```
|
|
184
185
|
|
|
185
186
|
```bash
|
|
186
|
-
npx @mui/x-codemod@
|
|
187
|
+
npx @mui/x-codemod@latest v7.0.0/data-grid/rename-components-to-slots <path>
|
|
187
188
|
```
|
|
188
189
|
|
|
189
190
|
#### `rename-cell-selection-props`
|
|
@@ -202,7 +203,26 @@ Rename props related to `cellSelection` feature.
|
|
|
202
203
|
```
|
|
203
204
|
|
|
204
205
|
```bash
|
|
205
|
-
npx @mui/x-codemod@
|
|
206
|
+
npx @mui/x-codemod@latest v7.0.0/data-grid/rename-cell-selection-props <path>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### `remove-stabilized-v7-experimentalFeatures`
|
|
210
|
+
|
|
211
|
+
Remove feature flags for stabilized `experimentalFeatures`.
|
|
212
|
+
|
|
213
|
+
```diff
|
|
214
|
+
<DataGrid
|
|
215
|
+
- experimentalFeatures={{
|
|
216
|
+
- lazyLoading: true,
|
|
217
|
+
- ariaV7: true,
|
|
218
|
+
- clipboardPaste: true,
|
|
219
|
+
- columnGrouping: true,
|
|
220
|
+
- }}
|
|
221
|
+
/>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
npx @mui/x-codemod@latest v7.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
|
|
206
226
|
```
|
|
207
227
|
|
|
208
228
|
### Tree View codemods
|
|
@@ -212,7 +232,7 @@ npx @mui/x-codemod@next v7.0.0/data-grid/rename-cell-selection-props <path>
|
|
|
212
232
|
The `preset-safe` codemods for tree view.
|
|
213
233
|
|
|
214
234
|
```bash
|
|
215
|
-
npx @mui/x-codemod@
|
|
235
|
+
npx @mui/x-codemod@latest v7.0.0/tree-view/preset-safe <path|folder>
|
|
216
236
|
```
|
|
217
237
|
|
|
218
238
|
The list includes these transformers
|
|
@@ -223,6 +243,7 @@ The list includes these transformers
|
|
|
223
243
|
- [`rename-selection-props`](#rename-selection-props)
|
|
224
244
|
- [`replace-transition-props-by-slot`](#replace-transition-props-by-slot)
|
|
225
245
|
- [`rename-focus-callback`](#rename-focus-callback)
|
|
246
|
+
- [`rename-nodeid`](#rename-nodeid)
|
|
226
247
|
|
|
227
248
|
#### `rename-tree-view-simple-tree-view`
|
|
228
249
|
|
|
@@ -238,7 +259,7 @@ Renames the `TreeView` component to `SimpleTreeView`
|
|
|
238
259
|
return (
|
|
239
260
|
- <TreeView>
|
|
240
261
|
+ <SimpleTreeView>
|
|
241
|
-
<TreeItem
|
|
262
|
+
<TreeItem itemId="1" label="First item" />
|
|
242
263
|
- </TreeView>
|
|
243
264
|
+ </SimpleTreeView>
|
|
244
265
|
);
|
|
@@ -253,8 +274,8 @@ Renames the `useTreeItem` hook to `useTreeItemState`
|
|
|
253
274
|
+import { TreeItem, useTreeItemState } from '@mui/x-tree-view/TreeItem';
|
|
254
275
|
|
|
255
276
|
const CustomContent = React.forwardRef((props, ref) => {
|
|
256
|
-
- const { disabled } = useTreeItem(props.
|
|
257
|
-
+ const { disabled } = useTreeItemState(props.
|
|
277
|
+
- const { disabled } = useTreeItem(props.itemId);
|
|
278
|
+
+ const { disabled } = useTreeItemState(props.itemId);
|
|
258
279
|
|
|
259
280
|
// Render some UI
|
|
260
281
|
});
|
|
@@ -327,6 +348,16 @@ Replace the `onNodeFocus` callback with `onItemFocus`:
|
|
|
327
348
|
/>
|
|
328
349
|
```
|
|
329
350
|
|
|
351
|
+
#### `rename-nodeid`
|
|
352
|
+
|
|
353
|
+
Rename nodeId to itemId
|
|
354
|
+
|
|
355
|
+
```diff
|
|
356
|
+
<TreeItem
|
|
357
|
+
- nodeId='unique-id'
|
|
358
|
+
+ itemId='unique-id'
|
|
359
|
+
```
|
|
360
|
+
|
|
330
361
|
## v6.0.0
|
|
331
362
|
|
|
332
363
|
### 🚀 `preset-safe` for v6.0.0
|
package/codemod.js
CHANGED
|
@@ -65,7 +65,7 @@ function run(argv) {
|
|
|
65
65
|
parser
|
|
66
66
|
}, other || []);
|
|
67
67
|
}
|
|
68
|
-
_yargs.default.command({
|
|
68
|
+
(0, _yargs.default)(process.argv.slice(2)).command({
|
|
69
69
|
command: '$0 <codemod> <paths...>',
|
|
70
70
|
describe: 'Applies a `@mui/x-codemod` to the specified paths',
|
|
71
71
|
builder: command => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-codemod",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -13,13 +13,6 @@
|
|
|
13
13
|
"codemod",
|
|
14
14
|
"jscodeshift"
|
|
15
15
|
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/x-codemod/**/*.test.ts'",
|
|
18
|
-
"typescript": "tsc -p tsconfig.json",
|
|
19
|
-
"prebuild": "rimraf build",
|
|
20
|
-
"copy-files": "cpy README.md build && cpy package.json build",
|
|
21
|
-
"build": "node ../../scripts/build.mjs node --ignore 'src/types.ts' && yarn copy-files"
|
|
22
|
-
},
|
|
23
16
|
"repository": {
|
|
24
17
|
"type": "git",
|
|
25
18
|
"url": "https://github.com/mui/mui-x.git",
|
|
@@ -32,21 +25,32 @@
|
|
|
32
25
|
"url": "https://opencollective.com/mui-org"
|
|
33
26
|
},
|
|
34
27
|
"dependencies": {
|
|
35
|
-
"@babel/core": "^7.24.
|
|
36
|
-
"@babel/runtime": "^7.24.
|
|
37
|
-
"@babel/traverse": "^7.24.
|
|
28
|
+
"@babel/core": "^7.24.6",
|
|
29
|
+
"@babel/runtime": "^7.24.6",
|
|
30
|
+
"@babel/traverse": "^7.24.6",
|
|
38
31
|
"jscodeshift": "0.13.1",
|
|
39
32
|
"jscodeshift-add-imports": "^1.0.10",
|
|
40
33
|
"yargs": "^17.7.2"
|
|
41
34
|
},
|
|
42
35
|
"devDependencies": {
|
|
43
|
-
"@types/jscodeshift": "^0.11.5"
|
|
36
|
+
"@types/jscodeshift": "^0.11.5",
|
|
37
|
+
"dayjs": "^1.11.11",
|
|
38
|
+
"moment-timezone": "^0.5.45",
|
|
39
|
+
"rimraf": "^5.0.7"
|
|
44
40
|
},
|
|
45
41
|
"sideEffects": false,
|
|
46
42
|
"publishConfig": {
|
|
47
|
-
"access": "public"
|
|
43
|
+
"access": "public",
|
|
44
|
+
"directory": "build"
|
|
48
45
|
},
|
|
49
46
|
"engines": {
|
|
50
47
|
"node": ">=14.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/x-codemod/**/*.test.ts'",
|
|
51
|
+
"typescript": "tsc -p tsconfig.json",
|
|
52
|
+
"prebuild": "rimraf build",
|
|
53
|
+
"copy-files": "cpy README.md build && cpy package.json build",
|
|
54
|
+
"build": "node ../../scripts/build.mjs node --ignore 'src/types.ts' && pnpm copy-files"
|
|
51
55
|
}
|
|
52
|
-
}
|
|
56
|
+
}
|
|
@@ -8,7 +8,7 @@ exports.default = transform;
|
|
|
8
8
|
var _renameCSSClasses = _interopRequireDefault(require("../../../util/renameCSSClasses"));
|
|
9
9
|
var _renameIdentifiers = _interopRequireWildcard(require("../../../util/renameIdentifiers"));
|
|
10
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
12
|
const renamedIdentifiers = {
|
|
13
13
|
GridLinkOperator: 'GridLogicOperator',
|
|
14
14
|
linkOperatorInputProps: 'logicOperatorInputProps',
|
|
@@ -7,8 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = transformer;
|
|
8
8
|
var _renameComponentsToSlots = _interopRequireDefault(require("../rename-components-to-slots"));
|
|
9
9
|
var _renameCellSelectionProps = _interopRequireDefault(require("../rename-cell-selection-props"));
|
|
10
|
+
var _removeStabilizedExperimentalFeatures = _interopRequireDefault(require("../remove-stabilized-experimentalFeatures"));
|
|
10
11
|
function transformer(file, api, options) {
|
|
11
12
|
file.source = (0, _renameComponentsToSlots.default)(file, api, options);
|
|
12
13
|
file.source = (0, _renameCellSelectionProps.default)(file, api, options);
|
|
14
|
+
file.source = (0, _removeStabilizedExperimentalFeatures.default)(file, api, options);
|
|
13
15
|
return file.source;
|
|
14
16
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = transformer;
|
|
8
|
+
var _removeObjectProperty = _interopRequireDefault(require("../../../util/removeObjectProperty"));
|
|
9
|
+
const componentsNames = ['DataGrid', 'DataGridPro', 'DataGridPremium'];
|
|
10
|
+
const propName = 'experimentalFeatures';
|
|
11
|
+
const propKeys = ['columnGrouping', 'clipboardPaste', 'lazyLoading', 'ariaV7'];
|
|
12
|
+
function transformer(file, api, options) {
|
|
13
|
+
const j = api.jscodeshift;
|
|
14
|
+
const root = j(file.source);
|
|
15
|
+
const printOptions = options.printOptions || {
|
|
16
|
+
quote: 'single',
|
|
17
|
+
trailingComma: true
|
|
18
|
+
};
|
|
19
|
+
propKeys.forEach(propKey => {
|
|
20
|
+
(0, _removeObjectProperty.default)({
|
|
21
|
+
root,
|
|
22
|
+
j,
|
|
23
|
+
propName,
|
|
24
|
+
componentsNames,
|
|
25
|
+
propKey
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return root.toSource(printOptions);
|
|
29
|
+
}
|
|
@@ -10,7 +10,9 @@ const componentNames = ['DataGridPremium'];
|
|
|
10
10
|
const props = {
|
|
11
11
|
unstable_cellSelection: 'cellSelection',
|
|
12
12
|
unstable_cellSelectionModel: 'cellSelectionModel',
|
|
13
|
-
unstable_onCellSelectionModelChange: 'onCellSelectionModelChange'
|
|
13
|
+
unstable_onCellSelectionModelChange: 'onCellSelectionModelChange',
|
|
14
|
+
unstable_ignoreValueFormatterDuringExport: 'ignoreValueFormatterDuringExport',
|
|
15
|
+
unstable_splitClipboardPastedText: 'splitClipboardPastedText'
|
|
14
16
|
};
|
|
15
17
|
function transformer(file, api, options) {
|
|
16
18
|
const j = api.jscodeshift;
|
|
@@ -8,6 +8,7 @@ exports.default = transformer;
|
|
|
8
8
|
var _renameExpansionProps = _interopRequireDefault(require("../rename-expansion-props"));
|
|
9
9
|
var _renameSelectionProps = _interopRequireDefault(require("../rename-selection-props"));
|
|
10
10
|
var _renameFocusCallback = _interopRequireDefault(require("../rename-focus-callback"));
|
|
11
|
+
var _renameNodeid = _interopRequireDefault(require("../rename-nodeid"));
|
|
11
12
|
var _replaceTransitionPropsBySlot = _interopRequireDefault(require("../replace-transition-props-by-slot"));
|
|
12
13
|
var _renameUseTreeItem = _interopRequireDefault(require("../rename-use-tree-item"));
|
|
13
14
|
var _renameTreeViewSimpleTreeView = _interopRequireDefault(require("../rename-tree-view-simple-tree-view"));
|
|
@@ -15,6 +16,7 @@ function transformer(file, api, options) {
|
|
|
15
16
|
file.source = (0, _renameExpansionProps.default)(file, api, options);
|
|
16
17
|
file.source = (0, _renameSelectionProps.default)(file, api, options);
|
|
17
18
|
file.source = (0, _renameFocusCallback.default)(file, api, options);
|
|
19
|
+
file.source = (0, _renameNodeid.default)(file, api, options);
|
|
18
20
|
file.source = (0, _replaceTransitionPropsBySlot.default)(file, api, options);
|
|
19
21
|
file.source = (0, _renameUseTreeItem.default)(file, api, options);
|
|
20
22
|
file.source = (0, _renameTreeViewSimpleTreeView.default)(file, api, options);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = transformer;
|
|
8
|
+
var _renameProps = _interopRequireDefault(require("../../../util/renameProps"));
|
|
9
|
+
function transformer(file, api, options) {
|
|
10
|
+
const j = api.jscodeshift;
|
|
11
|
+
const root = j(file.source);
|
|
12
|
+
const printOptions = options.printOptions;
|
|
13
|
+
return (0, _renameProps.default)({
|
|
14
|
+
root,
|
|
15
|
+
componentNames: ['TreeView', 'SimpleTreeView'],
|
|
16
|
+
props: {
|
|
17
|
+
nodeId: 'itemId'
|
|
18
|
+
},
|
|
19
|
+
j
|
|
20
|
+
}).toSource(printOptions);
|
|
21
|
+
}
|