@mui/x-codemod 7.0.0-alpha.8 → 7.0.0-alpha.9
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
CHANGED
|
@@ -29,8 +29,8 @@ Options:
|
|
|
29
29
|
--jscodeshift Pass options directly to jscodeshift [array]
|
|
30
30
|
|
|
31
31
|
Examples:
|
|
32
|
-
npx @mui/x-codemod v6.0.0/preset-safe src
|
|
33
|
-
npx @mui/x-codemod v6.0.0/component-rename-prop src --
|
|
32
|
+
npx @mui/x-codemod@latest v6.0.0/preset-safe src
|
|
33
|
+
npx @mui/x-codemod@latest 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 --jscodeshift=--run-in-band
|
|
43
|
+
npx @mui/x-codemod@next --jscodeshift=--run-in-band
|
|
44
44
|
// multiple options
|
|
45
|
-
npx @mui/x-codemod --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
|
|
45
|
+
npx @mui/x-codemod@next --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 <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
|
|
56
|
+
npx @mui/x-codemod@next <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 v7.0.0/preset-safe <path|folder>
|
|
69
|
+
npx @mui/x-codemod@next 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 v7.0.0/pickers/preset-safe <path|folder>
|
|
85
|
+
npx @mui/x-codemod@next 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 v7.0.0/pickers/rename-components-to-slots <path>
|
|
111
|
+
npx @mui/x-codemod@next v7.0.0/pickers/rename-components-to-slots <path>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
#### `rename-default-calendar-month-to-reference-date`
|
|
@@ -116,12 +116,12 @@ npx @mui/x-codemod v7.0.0/pickers/rename-components-to-slots <path>
|
|
|
116
116
|
Replace the `defaultCalendarMonth` prop with the `referenceDate` prop.
|
|
117
117
|
|
|
118
118
|
```diff
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
-<DateCalendar defaultCalendarMonth={dayjs('2022-04-01')};
|
|
120
|
+
+<DateCalendar referenceDate{dayjs('2022-04-01')} />
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
|
-
npx @mui/x-codemod v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
|
|
124
|
+
npx @mui/x-codemod@next v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
#### `rename-day-picker-classes`
|
|
@@ -129,12 +129,12 @@ npx @mui/x-codemod v7.0.0/pickers/rename-default-calendar-month-to-reference-dat
|
|
|
129
129
|
Rename the `dayPickerClasses` variable to `dayCalendarClasses`.
|
|
130
130
|
|
|
131
131
|
```diff
|
|
132
|
-
-
|
|
133
|
-
+
|
|
132
|
+
-import { dayPickerClasses } from '@mui/x-date-pickers/DateCalendar';
|
|
133
|
+
+import { dayCalendarClasses } from '@mui/x-date-pickers/DateCalendar';
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
|
-
npx @mui/x-codemod v7.0.0/pickers/rename-day-picker-classes <path>
|
|
137
|
+
npx @mui/x-codemod@next 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 v7.0.0/pickers/rename-slots-types <path>
|
|
152
|
+
npx @mui/x-codemod@next v7.0.0/pickers/rename-slots-types <path>
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
### Data Grid codemods
|
|
@@ -159,7 +159,7 @@ npx @mui/x-codemod 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 v7.0.0/data-grid/preset-safe <path|folder>
|
|
162
|
+
npx @mui/x-codemod@next v7.0.0/data-grid/preset-safe <path|folder>
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
The list includes these transformers
|
|
@@ -176,14 +176,14 @@ This change only affects Data Grid components.
|
|
|
176
176
|
```diff
|
|
177
177
|
<DataGrid
|
|
178
178
|
- components={{ Toolbar: CustomToolbar }}
|
|
179
|
-
+ slots={{ toolbar: CustomToolbar }}
|
|
180
179
|
- componentsProps={{ toolbar: { showQuickFilter: true }}}
|
|
180
|
+
+ slots={{ toolbar: CustomToolbar }}
|
|
181
181
|
+ slotProps={{ toolbar: { showQuickFilter: true }}}
|
|
182
182
|
/>;
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
```bash
|
|
186
|
-
npx @mui/x-codemod v7.0.0/data-grid/rename-components-to-slots <path>
|
|
186
|
+
npx @mui/x-codemod@next v7.0.0/data-grid/rename-components-to-slots <path>
|
|
187
187
|
```
|
|
188
188
|
|
|
189
189
|
#### `rename-cell-selection-props`
|
|
@@ -193,16 +193,16 @@ Rename props related to `cellSelection` feature.
|
|
|
193
193
|
```diff
|
|
194
194
|
<DataGridPremium
|
|
195
195
|
- unstable_cellSelection
|
|
196
|
+
- unstable_cellSelectionModel={{ 0: { id: true, currencyPair: true, price1M: false } }}
|
|
197
|
+
- unstable_onCellSelectionModelChange={() => {}}
|
|
196
198
|
+ cellSelection
|
|
197
|
-
- cellSelectionModel={{ 0: { id: true, currencyPair: true, price1M: false } }}
|
|
198
199
|
+ cellSelectionModel={{ 0: { id: true, currencyPair: true, price1M: false } }}
|
|
199
|
-
- unstable_onCellSelectionModelChange={() => {}}
|
|
200
200
|
+ onCellSelectionModelChange={() => {}}
|
|
201
201
|
/>;
|
|
202
202
|
```
|
|
203
203
|
|
|
204
204
|
```bash
|
|
205
|
-
npx @mui/x-codemod v7.0.0/data-grid/rename-cell-selection-props <path>
|
|
205
|
+
npx @mui/x-codemod@next v7.0.0/data-grid/rename-cell-selection-props <path>
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
### Tree View codemods
|
|
@@ -212,12 +212,13 @@ npx @mui/x-codemod v7.0.0/data-grid/rename-cell-selection-props <path>
|
|
|
212
212
|
The `preset-safe` codemods for tree view.
|
|
213
213
|
|
|
214
214
|
```bash
|
|
215
|
-
npx @mui/x-codemod v7.0.0/tree-view/preset-safe <path|folder>
|
|
215
|
+
npx @mui/x-codemod@next v7.0.0/tree-view/preset-safe <path|folder>
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
The list includes these transformers
|
|
219
219
|
|
|
220
220
|
- [`rename-tree-view-simple-tree-view`](#rename-tree-view-simple-tree-view)
|
|
221
|
+
- [`rename-use-tree-item`](#rename-use-tree-item)
|
|
221
222
|
- [`rename-expansion-props`](#rename-expansion-props)
|
|
222
223
|
- [`rename-selection-props`](#rename-selection-props)
|
|
223
224
|
|
|
@@ -241,21 +242,45 @@ Renames the `TreeView` component to `SimpleTreeView`
|
|
|
241
242
|
);
|
|
242
243
|
```
|
|
243
244
|
|
|
245
|
+
#### `rename-use-tree-item`
|
|
246
|
+
|
|
247
|
+
Renames the `useTreeItem` hook to `useTreeItemState`
|
|
248
|
+
|
|
249
|
+
```diff
|
|
250
|
+
-import { TreeItem, useTreeItem } from '@mui/x-tree-view/TreeItem';
|
|
251
|
+
+import { TreeItem, useTreeItemState } from '@mui/x-tree-view/TreeItem';
|
|
252
|
+
|
|
253
|
+
const CustomContent = React.forwardRef((props, ref) => {
|
|
254
|
+
- const { disabled } = useTreeItem(props.nodeId);
|
|
255
|
+
+ const { disabled } = useTreeItemState(props.nodeId);
|
|
256
|
+
|
|
257
|
+
// Render some UI
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
function App() {
|
|
261
|
+
return (
|
|
262
|
+
<SimpleTreeView>
|
|
263
|
+
<TreeItem ContentComponent={CustomContent} />
|
|
264
|
+
</SimpleTreeView>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
244
269
|
#### `rename-expansion-props`
|
|
245
270
|
|
|
246
271
|
Rename the expansion props
|
|
247
272
|
|
|
248
273
|
```diff
|
|
249
|
-
|
|
250
|
-
-
|
|
251
|
-
+
|
|
274
|
+
<TreeView
|
|
275
|
+
- onNodeToggle={handleExpansionChange}
|
|
276
|
+
+ onExpandedNodesChange={handleExpansionChange}
|
|
252
277
|
|
|
253
|
-
-
|
|
254
|
-
+
|
|
278
|
+
- expanded={expandedNodes}
|
|
279
|
+
+ expandedNodes={expandedNodes}
|
|
255
280
|
|
|
256
|
-
-
|
|
257
|
-
+
|
|
258
|
-
|
|
281
|
+
- defaultExpanded={defaultExpandedNodes}
|
|
282
|
+
+ defaultExpandedNodes={defaultExpandedNodes}
|
|
283
|
+
/>
|
|
259
284
|
```
|
|
260
285
|
|
|
261
286
|
#### `rename-selection-props`
|
|
@@ -263,16 +288,16 @@ Rename the expansion props
|
|
|
263
288
|
Rename the selection props
|
|
264
289
|
|
|
265
290
|
```diff
|
|
266
|
-
|
|
267
|
-
-
|
|
268
|
-
+
|
|
291
|
+
<TreeView
|
|
292
|
+
- onNodeSelect={handleSelectionChange}
|
|
293
|
+
+ onSelectedNodesChange={handleSelectionChange}
|
|
269
294
|
|
|
270
|
-
-
|
|
271
|
-
+
|
|
295
|
+
- selected={selectedNodes}
|
|
296
|
+
+ selectedNodes={selectedNodes}
|
|
272
297
|
|
|
273
|
-
-
|
|
274
|
-
+
|
|
275
|
-
|
|
298
|
+
- defaultSelected={defaultSelectedNodes}
|
|
299
|
+
+ defaultSelectedNodes={defaultSelectedNodes}
|
|
300
|
+
/>
|
|
276
301
|
```
|
|
277
302
|
|
|
278
303
|
## v6.0.0
|
|
@@ -285,7 +310,7 @@ It runs codemods for both Data Grid and Date and Time Pickers packages.
|
|
|
285
310
|
To run codemods for a specific package, refer to the respective section.
|
|
286
311
|
|
|
287
312
|
```bash
|
|
288
|
-
npx @mui/x-codemod v6.0.0/preset-safe <path|folder>
|
|
313
|
+
npx @mui/x-codemod@latest v6.0.0/preset-safe <path|folder>
|
|
289
314
|
```
|
|
290
315
|
|
|
291
316
|
The corresponding sub-sections are listed below
|
|
@@ -300,7 +325,7 @@ The corresponding sub-sections are listed below
|
|
|
300
325
|
The `preset-safe` codemods for pickers.
|
|
301
326
|
|
|
302
327
|
```bash
|
|
303
|
-
npx @mui/x-codemod v6.0.0/pickers/preset-safe <path|folder>
|
|
328
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/preset-safe <path|folder>
|
|
304
329
|
```
|
|
305
330
|
|
|
306
331
|
The list includes these transformers
|
|
@@ -385,7 +410,7 @@ Renames the `locale` prop of the `LocalizationProvider` component into `adapterL
|
|
|
385
410
|
```
|
|
386
411
|
|
|
387
412
|
```bash
|
|
388
|
-
npx @mui/x-codemod v6.0.0/pickers/localization-provider-rename-locale <path>
|
|
413
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/localization-provider-rename-locale <path>
|
|
389
414
|
```
|
|
390
415
|
|
|
391
416
|
#### `text-props-to-localeText`
|
|
@@ -402,7 +427,7 @@ Replace props used for localization such as `cancelText` to their corresponding
|
|
|
402
427
|
```
|
|
403
428
|
|
|
404
429
|
```bash
|
|
405
|
-
npx @mui/x-codemod v6.0.0/pickers/text-props-to-localeText <path>
|
|
430
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/text-props-to-localeText <path>
|
|
406
431
|
```
|
|
407
432
|
|
|
408
433
|
If you were always using the same text value in all your components, consider moving those translation from the component to the `LocalizationProvider` by hand.
|
|
@@ -443,7 +468,7 @@ Replace props used for `Tabs` in DateTime pickers by `componentsProps.tabs` prop
|
|
|
443
468
|
```
|
|
444
469
|
|
|
445
470
|
```bash
|
|
446
|
-
npx @mui/x-codemod v6.0.0/pickers/replace-tabs-props <path>
|
|
471
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/replace-tabs-props <path>
|
|
447
472
|
```
|
|
448
473
|
|
|
449
474
|
#### `replace-toolbar-props-by-slot`
|
|
@@ -469,7 +494,7 @@ Replace props used to customize the `Toolbar` in pickers by slots properties and
|
|
|
469
494
|
```
|
|
470
495
|
|
|
471
496
|
```bash
|
|
472
|
-
npx @mui/x-codemod v6.0.0/pickers/replace-toolbar-props-by-slot <path>
|
|
497
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/replace-toolbar-props-by-slot <path>
|
|
473
498
|
```
|
|
474
499
|
|
|
475
500
|
#### `migrate-to-components-componentsProps`
|
|
@@ -519,7 +544,7 @@ Replace customization props by their equivalent `components` and `componentsProp
|
|
|
519
544
|
```
|
|
520
545
|
|
|
521
546
|
```bash
|
|
522
|
-
npx @mui/x-codemod v6.0.0/pickers/migrate-to-components-componentsProps <path>
|
|
547
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/migrate-to-components-componentsProps <path>
|
|
523
548
|
```
|
|
524
549
|
|
|
525
550
|
#### `replace-arrows-button-slot`
|
|
@@ -545,7 +570,7 @@ Replace `LeftArrowButton` and `RightArrowButton` slots for navigation buttons by
|
|
|
545
570
|
```
|
|
546
571
|
|
|
547
572
|
```bash
|
|
548
|
-
npx @mui/x-codemod v6.0.0/pickers/replace-arrows-button-slot <path>
|
|
573
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/replace-arrows-button-slot <path>
|
|
549
574
|
```
|
|
550
575
|
|
|
551
576
|
#### `rename-should-disable-time`
|
|
@@ -560,7 +585,7 @@ Replace `shouldDisableTime` by `shouldDisableClock`.
|
|
|
560
585
|
```
|
|
561
586
|
|
|
562
587
|
```bash
|
|
563
|
-
npx @mui/x-codemod v6.0.0/pickers/rename-should-disable-time <path>
|
|
588
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/rename-should-disable-time <path>
|
|
564
589
|
```
|
|
565
590
|
|
|
566
591
|
#### `rename-inputFormat-prop`
|
|
@@ -575,7 +600,7 @@ Replace `inputFormat` prop with `format`.
|
|
|
575
600
|
```
|
|
576
601
|
|
|
577
602
|
```bash
|
|
578
|
-
npx @mui/x-codemod v6.0.0/pickers/rename-inputFormat-prop <path>
|
|
603
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/rename-inputFormat-prop <path>
|
|
579
604
|
```
|
|
580
605
|
|
|
581
606
|
#### `rename-default-toolbar-title-localeText`
|
|
@@ -598,7 +623,7 @@ Rename toolbar related translation keys, removing `Default` part from them to be
|
|
|
598
623
|
```
|
|
599
624
|
|
|
600
625
|
```bash
|
|
601
|
-
npx @mui/x-codemod v6.0.0/pickers/rename-default-toolbar-title-localeText <path>
|
|
626
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/rename-default-toolbar-title-localeText <path>
|
|
602
627
|
```
|
|
603
628
|
|
|
604
629
|
#### `rename-components-to-slots-pickers`
|
|
@@ -617,7 +642,7 @@ This change only affects Date and Time Pickers components.
|
|
|
617
642
|
```
|
|
618
643
|
|
|
619
644
|
```bash
|
|
620
|
-
npx @mui/x-codemod v6.0.0/pickers/rename-components-to-slots <path>
|
|
645
|
+
npx @mui/x-codemod@latest v6.0.0/pickers/rename-components-to-slots <path>
|
|
621
646
|
```
|
|
622
647
|
|
|
623
648
|
### Data Grid codemods
|
|
@@ -627,7 +652,7 @@ npx @mui/x-codemod v6.0.0/pickers/rename-components-to-slots <path>
|
|
|
627
652
|
The `preset-safe` codemods for data grid.
|
|
628
653
|
|
|
629
654
|
```bash
|
|
630
|
-
npx @mui/x-codemod v6.0.0/data-grid/preset-safe <path|folder>
|
|
655
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/preset-safe <path|folder>
|
|
631
656
|
```
|
|
632
657
|
|
|
633
658
|
The list includes these transformers
|
|
@@ -662,7 +687,7 @@ Replace column menu items that have been renamed.
|
|
|
662
687
|
```
|
|
663
688
|
|
|
664
689
|
```bash
|
|
665
|
-
npx @mui/x-codemod v6.0.0/data-grid/column-menu-components-rename <path>
|
|
690
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/column-menu-components-rename <path>
|
|
666
691
|
```
|
|
667
692
|
|
|
668
693
|
If you are using `GridRowGroupingColumnMenuItems` and `GridRowGroupableColumnMenuItems` for grouping, consider fixing them manually as these imports are replaced by `GridColumnMenuGroupingItem` and may require some extra work to port.
|
|
@@ -689,7 +714,7 @@ Data Grid props that have been renamed.
|
|
|
689
714
|
```
|
|
690
715
|
|
|
691
716
|
```bash
|
|
692
|
-
npx @mui/x-codemod v6.0.0/data-grid/row-selection-props-rename <path>
|
|
717
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/row-selection-props-rename <path>
|
|
693
718
|
```
|
|
694
719
|
|
|
695
720
|
#### `rename-rowsPerPageOptions-prop`
|
|
@@ -704,7 +729,7 @@ Rename `rowsPerPageOptions` prop to `pageSizeOptions`.
|
|
|
704
729
|
```
|
|
705
730
|
|
|
706
731
|
```bash
|
|
707
|
-
npx @mui/x-codemod v6.0.0/data-grid/rename-rowsPerPageOptions-prop <path>
|
|
732
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/rename-rowsPerPageOptions-prop <path>
|
|
708
733
|
```
|
|
709
734
|
|
|
710
735
|
#### `remove-disableExtendRowFullWidth-prop`
|
|
@@ -718,7 +743,7 @@ Remove `disableExtendRowFullWidth` prop which is no longer supported.
|
|
|
718
743
|
```
|
|
719
744
|
|
|
720
745
|
```bash
|
|
721
|
-
npx @mui/x-codemod v6.0.0/data-grid/remove-disableExtendRowFullWidth-prop <path>
|
|
746
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/remove-disableExtendRowFullWidth-prop <path>
|
|
722
747
|
```
|
|
723
748
|
|
|
724
749
|
#### `rename-linkOperators-logicOperators`
|
|
@@ -773,7 +798,7 @@ Rename `linkOperators` related props to `logicOperators` and rename classes.
|
|
|
773
798
|
```
|
|
774
799
|
|
|
775
800
|
```bash
|
|
776
|
-
npx @mui/x-codemod v6.0.0/data-grid/rename-linkOperators-logicOperators <path>
|
|
801
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/rename-linkOperators-logicOperators <path>
|
|
777
802
|
```
|
|
778
803
|
|
|
779
804
|
#### `rename-filter-item-props`
|
|
@@ -814,7 +839,7 @@ Rename filter item props to the new values.
|
|
|
814
839
|
```
|
|
815
840
|
|
|
816
841
|
```bash
|
|
817
|
-
npx @mui/x-codemod v6.0.0/data-grid/rename-filter-item-props <path>
|
|
842
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/rename-filter-item-props <path>
|
|
818
843
|
```
|
|
819
844
|
|
|
820
845
|
#### `rename-selectors-and-events`
|
|
@@ -853,7 +878,7 @@ Rename selectors and events.
|
|
|
853
878
|
```
|
|
854
879
|
|
|
855
880
|
```bash
|
|
856
|
-
npx @mui/x-codemod v6.0.0/data-grid/rename-selectors-and-events <path>
|
|
881
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/rename-selectors-and-events <path>
|
|
857
882
|
```
|
|
858
883
|
|
|
859
884
|
#### `remove-stabilized-experimentalFeatures`
|
|
@@ -878,7 +903,7 @@ Remove feature flags for stabilized `experimentalFeatures`.
|
|
|
878
903
|
```
|
|
879
904
|
|
|
880
905
|
```bash
|
|
881
|
-
npx @mui/x-codemod v6.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
|
|
906
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
|
|
882
907
|
```
|
|
883
908
|
|
|
884
909
|
#### `replace-onCellFocusOut-prop`
|
|
@@ -897,7 +922,7 @@ Replace `onCellFocusOut` prop with `componentsProps.cell.onBlur`.
|
|
|
897
922
|
```
|
|
898
923
|
|
|
899
924
|
```bash
|
|
900
|
-
npx @mui/x-codemod v6.0.0/data-grid/replace-onCellFocusOut-prop <path>
|
|
925
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/replace-onCellFocusOut-prop <path>
|
|
901
926
|
```
|
|
902
927
|
|
|
903
928
|
#### `rename-components-to-slots-data-grid`
|
|
@@ -916,7 +941,7 @@ This change only affects Data Grid components.
|
|
|
916
941
|
```
|
|
917
942
|
|
|
918
943
|
```bash
|
|
919
|
-
npx @mui/x-codemod v6.0.0/data-grid/rename-components-to-slots <path>
|
|
944
|
+
npx @mui/x-codemod@latest v6.0.0/data-grid/rename-components-to-slots <path>
|
|
920
945
|
```
|
|
921
946
|
|
|
922
947
|
You can find more details about Data Grid breaking change in [the migration guide](https://mui.com/x/migration/migration-data-grid-v5/).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-codemod",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.9",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/core": "^7.23.7",
|
|
36
|
-
"@babel/runtime": "^7.23.
|
|
36
|
+
"@babel/runtime": "^7.23.8",
|
|
37
37
|
"@babel/traverse": "^7.23.7",
|
|
38
38
|
"jscodeshift": "0.13.1",
|
|
39
39
|
"jscodeshift-add-imports": "^1.0.10",
|
|
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = transformer;
|
|
8
8
|
var _renameExpansionProps = _interopRequireDefault(require("../rename-expansion-props"));
|
|
9
9
|
var _renameSelectionProps = _interopRequireDefault(require("../rename-selection-props"));
|
|
10
|
+
var _renameUseTreeItem = _interopRequireDefault(require("../rename-use-tree-item"));
|
|
10
11
|
var _renameTreeViewSimpleTreeView = _interopRequireDefault(require("../rename-tree-view-simple-tree-view"));
|
|
11
12
|
function transformer(file, api, options) {
|
|
12
13
|
file.source = (0, _renameExpansionProps.default)(file, api, options);
|
|
13
14
|
file.source = (0, _renameSelectionProps.default)(file, api, options);
|
|
15
|
+
file.source = (0, _renameUseTreeItem.default)(file, api, options);
|
|
14
16
|
file.source = (0, _renameTreeViewSimpleTreeView.default)(file, api, options);
|
|
15
17
|
return file.source;
|
|
16
18
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
const PACKAGE_REGEXP = /@mui\/x-tree-view(\/TreeItem|)/;
|
|
8
|
+
const matchImport = path => (path.node.source.value?.toString() ?? '').match(PACKAGE_REGEXP);
|
|
9
|
+
function transformer(file, api, options) {
|
|
10
|
+
const j = api.jscodeshift;
|
|
11
|
+
const root = j(file.source);
|
|
12
|
+
const printOptions = options.printOptions || {
|
|
13
|
+
quote: 'single',
|
|
14
|
+
trailingComma: true
|
|
15
|
+
};
|
|
16
|
+
const matchingImports = root.find(j.ImportDeclaration).filter(path => !!matchImport(path));
|
|
17
|
+
|
|
18
|
+
// Rename the import specifiers
|
|
19
|
+
// - import { useTreeItem } from '@mui/x-tree-view/TreeItem'
|
|
20
|
+
// + import { useTreeItemState } from '@mui/x-tree-view/TreeItem'
|
|
21
|
+
matchingImports.find(j.ImportSpecifier).filter(path => path.node.imported.name === 'useTreeItem').replaceWith(j.importSpecifier(j.identifier('useTreeItemState')));
|
|
22
|
+
|
|
23
|
+
// Rename the import usage
|
|
24
|
+
// - useTreeItem(nodeId);
|
|
25
|
+
// + useTreeItemState(nodeId)
|
|
26
|
+
root.find(j.Identifier).filter(path => path.node.name === 'useTreeItem').replaceWith(j.identifier('useTreeItemState'));
|
|
27
|
+
return root.toSource(printOptions);
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _path = _interopRequireDefault(require("path"));
|
|
5
|
+
var _chai = require("chai");
|
|
6
|
+
var _jscodeshift = _interopRequireDefault(require("jscodeshift"));
|
|
7
|
+
var _ = _interopRequireDefault(require("."));
|
|
8
|
+
var _readFile = _interopRequireDefault(require("../../../util/readFile"));
|
|
9
|
+
function read(fileName) {
|
|
10
|
+
return (0, _readFile.default)(_path.default.join(__dirname, fileName));
|
|
11
|
+
}
|
|
12
|
+
const TEST_FILES = ['nested-imports', 'root-imports'];
|
|
13
|
+
describe('v7.0.0/tree-view', () => {
|
|
14
|
+
describe('rename-use-tree-item', () => {
|
|
15
|
+
TEST_FILES.forEach(testFile => {
|
|
16
|
+
const actualPath = `./actual-${testFile}.spec.tsx`;
|
|
17
|
+
const expectedPath = `./expected-${testFile}.spec.tsx`;
|
|
18
|
+
describe(`${testFile.replace(/-/g, ' ')}`, () => {
|
|
19
|
+
it('transforms imports as needed', () => {
|
|
20
|
+
const actual = (0, _.default)({
|
|
21
|
+
source: read(actualPath)
|
|
22
|
+
}, {
|
|
23
|
+
jscodeshift: _jscodeshift.default.withParser('tsx')
|
|
24
|
+
}, {});
|
|
25
|
+
const expected = read(expectedPath);
|
|
26
|
+
(0, _chai.expect)(actual).to.equal(expected, 'The transformed version should be correct');
|
|
27
|
+
});
|
|
28
|
+
it('should be idempotent', () => {
|
|
29
|
+
const actual = (0, _.default)({
|
|
30
|
+
source: read(expectedPath)
|
|
31
|
+
}, {
|
|
32
|
+
jscodeshift: _jscodeshift.default.withParser('tsx')
|
|
33
|
+
}, {});
|
|
34
|
+
const expected = read(expectedPath);
|
|
35
|
+
(0, _chai.expect)(actual).to.equal(expected, 'The transformed version should be correct');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|