@mui/x-codemod 7.0.0-beta.6 → 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 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@next <codemod> <paths...>
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@latest v6.0.0/preset-safe src
33
- npx @mui/x-codemod@latest v6.0.0/component-rename-prop src --
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@next --jscodeshift=--run-in-band
43
+ npx @mui/x-codemod --jscodeshift=--run-in-band
44
44
  // multiple options
45
- npx @mui/x-codemod@next --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
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@next <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
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@next v7.0.0/preset-safe <path|folder>
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@next v7.0.0/pickers/preset-safe <path|folder>
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@next v7.0.0/pickers/rename-components-to-slots <path>
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@next v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
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@next v7.0.0/pickers/rename-day-picker-classes <path>
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@next v7.0.0/pickers/rename-slots-types <path>
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@next v7.0.0/data-grid/preset-safe <path|folder>
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@next v7.0.0/data-grid/rename-components-to-slots <path>
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@next v7.0.0/data-grid/rename-cell-selection-props <path>
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@next v7.0.0/tree-view/preset-safe <path|folder>
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
@@ -222,6 +242,8 @@ The list includes these transformers
222
242
  - [`rename-expansion-props`](#rename-expansion-props)
223
243
  - [`rename-selection-props`](#rename-selection-props)
224
244
  - [`replace-transition-props-by-slot`](#replace-transition-props-by-slot)
245
+ - [`rename-focus-callback`](#rename-focus-callback)
246
+ - [`rename-nodeid`](#rename-nodeid)
225
247
 
226
248
  #### `rename-tree-view-simple-tree-view`
227
249
 
@@ -237,7 +259,7 @@ Renames the `TreeView` component to `SimpleTreeView`
237
259
  return (
238
260
  - <TreeView>
239
261
  + <SimpleTreeView>
240
- <TreeItem nodeId="1" label="First item" />
262
+ <TreeItem itemId="1" label="First item" />
241
263
  - </TreeView>
242
264
  + </SimpleTreeView>
243
265
  );
@@ -252,8 +274,8 @@ Renames the `useTreeItem` hook to `useTreeItemState`
252
274
  +import { TreeItem, useTreeItemState } from '@mui/x-tree-view/TreeItem';
253
275
 
254
276
  const CustomContent = React.forwardRef((props, ref) => {
255
- - const { disabled } = useTreeItem(props.nodeId);
256
- + const { disabled } = useTreeItemState(props.nodeId);
277
+ - const { disabled } = useTreeItem(props.itemId);
278
+ + const { disabled } = useTreeItemState(props.itemId);
257
279
 
258
280
  // Render some UI
259
281
  });
@@ -274,13 +296,13 @@ Rename the expansion props
274
296
  ```diff
275
297
  <TreeView
276
298
  - onNodeToggle={handleExpansionChange}
277
- + onExpandedNodesChange={handleExpansionChange}
299
+ + onExpandedItemsChange={handleExpansionChange}
278
300
 
279
- - expanded={expandedNodes}
280
- + expandedNodes={expandedNodes}
301
+ - expanded={expandedItems}
302
+ + expandedItems={expandedItems}
281
303
 
282
- - defaultExpanded={defaultExpandedNodes}
283
- + defaultExpandedNodes={defaultExpandedNodes}
304
+ - defaultExpanded={defaultExpandedItems}
305
+ + defaultExpandedItems={defaultExpandedItems}
284
306
  />
285
307
  ```
286
308
 
@@ -291,13 +313,13 @@ Rename the selection props
291
313
  ```diff
292
314
  <TreeView
293
315
  - onNodeSelect={handleSelectionChange}
294
- + onSelectedNodesChange={handleSelectionChange}
316
+ + onSelectedItemsChange={handleSelectionChange}
295
317
 
296
- - selected={selectedNodes}
297
- + selectedNodes={selectedNodes}
318
+ - selected={selectedItems}
319
+ + selectedItems={selectedItems}
298
320
 
299
- - defaultSelected={defaultSelectedNodes}
300
- + defaultSelectedNodes={defaultSelectedNodes}
321
+ - defaultSelected={defaultSelectedItems}
322
+ + defaultSelectedItems={defaultSelectedItems}
301
323
  />
302
324
  ```
303
325
 
@@ -315,6 +337,27 @@ Replace the `TransitionComponent` and `TransitionProps` components with the `gro
315
337
  />
316
338
  ```
317
339
 
340
+ #### `rename-focus-callback`
341
+
342
+ Replace the `onNodeFocus` callback with `onItemFocus`:
343
+
344
+ ```diff
345
+ <TreeView
346
+ - onNodeFocus={onNodeFocus}
347
+ + onItemFocus={onItemFocus}
348
+ />
349
+ ```
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
+
318
361
  ## v6.0.0
319
362
 
320
363
  ### 🚀 `preset-safe` for v6.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-codemod",
3
- "version": "7.0.0-beta.6",
3
+ "version": "7.0.0",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -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;
@@ -7,12 +7,16 @@ 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 _renameFocusCallback = _interopRequireDefault(require("../rename-focus-callback"));
11
+ var _renameNodeid = _interopRequireDefault(require("../rename-nodeid"));
10
12
  var _replaceTransitionPropsBySlot = _interopRequireDefault(require("../replace-transition-props-by-slot"));
11
13
  var _renameUseTreeItem = _interopRequireDefault(require("../rename-use-tree-item"));
12
14
  var _renameTreeViewSimpleTreeView = _interopRequireDefault(require("../rename-tree-view-simple-tree-view"));
13
15
  function transformer(file, api, options) {
14
16
  file.source = (0, _renameExpansionProps.default)(file, api, options);
15
17
  file.source = (0, _renameSelectionProps.default)(file, api, options);
18
+ file.source = (0, _renameFocusCallback.default)(file, api, options);
19
+ file.source = (0, _renameNodeid.default)(file, api, options);
16
20
  file.source = (0, _replaceTransitionPropsBySlot.default)(file, api, options);
17
21
  file.source = (0, _renameUseTreeItem.default)(file, api, options);
18
22
  file.source = (0, _renameTreeViewSimpleTreeView.default)(file, api, options);
@@ -14,9 +14,9 @@ function transformer(file, api, options) {
14
14
  root,
15
15
  componentNames: ['TreeView', 'SimpleTreeView'],
16
16
  props: {
17
- expanded: 'expandedNodes',
18
- defaultExpanded: 'defaultExpandedNodes',
19
- onNodeToggle: 'onExpandedNodesChange'
17
+ expanded: 'expandedItems',
18
+ defaultExpanded: 'defaultExpandedItems',
19
+ onNodeToggle: 'onExpandedItemsChange'
20
20
  },
21
21
  j
22
22
  }).toSource(printOptions);
@@ -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
+ onNodeFocus: 'onItemFocus'
18
+ },
19
+ j
20
+ }).toSource(printOptions);
21
+ }
@@ -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
+ }
@@ -14,9 +14,9 @@ function transformer(file, api, options) {
14
14
  root,
15
15
  componentNames: ['TreeView', 'SimpleTreeView'],
16
16
  props: {
17
- selected: 'selectedNodes',
18
- defaultSelected: 'defaultSelectedNodes',
19
- onNodeSelect: 'onSelectedNodesChange'
17
+ selected: 'selectedItems',
18
+ defaultSelected: 'defaultSelectedItems',
19
+ onNodeSelect: 'onSelectedItemsChange'
20
20
  },
21
21
  j
22
22
  }).toSource(printOptions);