@mui/x-codemod 7.0.0-beta.7 → 7.0.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 +50 -19
- package/package.json +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 <codemod> <paths...>
|
|
17
17
|
|
|
18
18
|
Applies a `@mui/x-codemod` to the specified paths
|
|
19
19
|
|
|
@@ -29,8 +29,8 @@ Options:
|
|
|
29
29
|
--jscodeshift Pass options directly to jscodeshift [array]
|
|
30
30
|
|
|
31
31
|
Examples:
|
|
32
|
-
npx @mui/x-codemod
|
|
33
|
-
npx @mui/x-codemod
|
|
32
|
+
npx @mui/x-codemod v6.0.0/preset-safe src
|
|
33
|
+
npx @mui/x-codemod v6.0.0/component-rename-prop src --
|
|
34
34
|
--component=DataGrid --from=prop --to=newProp
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -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 --jscodeshift=--run-in-band
|
|
44
44
|
// multiple options
|
|
45
|
-
npx @mui/x-codemod
|
|
45
|
+
npx @mui/x-codemod --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 <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 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 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 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 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 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 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 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 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 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@next 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 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/package.json
CHANGED
|
@@ -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
|
+
}
|