@mui/x-codemod 8.0.0-alpha.1 → 8.0.0-alpha.11

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
@@ -39,9 +39,10 @@ Examples:
39
39
  To pass more options directly to jscodeshift, use `--jscodeshift=...`. For example:
40
40
 
41
41
  ```bash
42
- // single option
42
+ # single option
43
43
  npx @mui/x-codemod@next --jscodeshift=--run-in-band
44
- // multiple options
44
+
45
+ # multiple options
45
46
  npx @mui/x-codemod@next --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
46
47
  ```
47
48
 
@@ -65,23 +66,29 @@ A combination of all important transformers for migrating v7 to v8.
65
66
  It runs codemods for all MUI X packages (Data Grid, Date and Time Pickers, Tree View, and Charts).
66
67
  To run codemods for a specific package, refer to the respective section.
67
68
 
69
+ <!-- #default-branch-switch -->
70
+
68
71
  ```bash
69
- npx @mui/x-codemod@latest v8.0.0/preset-safe <path|folder>
72
+ npx @mui/x-codemod@next v8.0.0/preset-safe <path|folder>
70
73
  ```
71
74
 
72
75
  The corresponding sub-sections are listed below
73
76
 
74
77
  - [`preset-safe-for-tree-view`](#preset-safe-for-tree-view-v800)
75
78
  - [`preset-safe-for-charts`](#preset-safe-for-charts-v800)
79
+ - [`preset-safe-for-data-grid`](#preset-safe-for-data-grid-v800)
80
+ - [`preset-safe-for-pickers`](#preset-safe-for-pickers-v800)
76
81
 
77
82
  ### Tree View codemods
78
83
 
79
- #### `preset-safe` for tree view v8.0.0
84
+ #### `preset-safe` for Tree View v8.0.0
80
85
 
81
- The `preset-safe` codemods for tree view.
86
+ The `preset-safe` codemods for Tree View.
87
+
88
+ <!-- #default-branch-switch -->
82
89
 
83
90
  ```bash
84
- npx @mui/x-codemod@latest v8.0.0/tree-view/preset-safe <path|folder>
91
+ npx @mui/x-codemod@next v8.0.0/tree-view/preset-safe <path|folder>
85
92
  ```
86
93
 
87
94
  The list includes these transformers
@@ -100,13 +107,13 @@ Renames the Tree View component to Simple Tree View
100
107
  -import { TreeView } from '@mui/x-tree-view/TreeView';
101
108
  +import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
102
109
 
103
- return (
104
- - <TreeView>
105
- + <SimpleTreeView>
106
- <TreeItem itemId="1" label="First item" />
107
- - </TreeView>
108
- + </SimpleTreeView>
109
- );
110
+ return (
111
+ - <TreeView>
112
+ + <SimpleTreeView>
113
+ <TreeItem itemId="1" label="First item" />
114
+ - </TreeView>
115
+ + </SimpleTreeView>
116
+ );
110
117
  ```
111
118
 
112
119
  #### `rename-tree-item-2`
@@ -123,28 +130,65 @@ Renames the `TreeItem2` component to `TreeItem` (same for any subcomponents or u
123
130
 
124
131
  ### Charts codemods
125
132
 
126
- #### `preset-safe` for charts v8.0.0
133
+ #### `preset-safe` for Charts v8.0.0
127
134
 
128
- The `preset-safe` codemods for charts.
135
+ The `preset-safe` codemods for Charts.
136
+
137
+ <!-- #default-branch-switch -->
129
138
 
130
139
  ```bash
131
- npx @mui/x-codemod@latest v8.0.0/charts/preset-safe <path|folder>
140
+ npx @mui/x-codemod@next v8.0.0/charts/preset-safe <path|folder>
132
141
  ```
133
142
 
134
143
  The list includes these transformers
135
144
 
136
145
  - [`rename-legend-to-slots-legend`](#rename-legend-to-slots-legend)
146
+ - [`replace-legend-direction-values`](#replace-legend-direction-values)
137
147
  - [`rename-responsive-chart-container`](#rename-responsive-chart-container)
148
+ - [`rename-label-and-tick-font-size`](#rename-label-and-tick-font-size)
138
149
 
139
150
  #### `rename-legend-to-slots-legend`
140
151
 
141
152
  Renames legend props to the corresponding slotProps.
142
153
 
143
154
  ```diff
144
- <LineChart
145
- - legend={{ hiden: true}}
146
- + slotProps={{ legend: { hiden: true} }}
147
- />
155
+ <LineChart
156
+ - legend={{ hiden: true}}
157
+ + slotProps={{ legend: { hiden: true} }}
158
+ />
159
+ ```
160
+
161
+ #### `replace-legend-direction-values`
162
+
163
+ Replace `row` and `column` values by `horizontal` and `vertical` respectively.
164
+
165
+ ```diff
166
+ <BarChart
167
+ slotProps={{
168
+ legend: {
169
+ - direction: "row"
170
+ + direction: "horizontal"
171
+ }
172
+ }}
173
+ />
174
+ ```
175
+
176
+ #### `replace-legend-position-values`
177
+
178
+ Replace `"left" | "middle" | "right"` values `"start" | "center" | "end"` respectively.
179
+ This is to align with the CSS values and reflect the RTL ability of the legend component.
180
+
181
+ ```diff
182
+ <BarChart
183
+ slotProps={{
184
+ legend: {
185
+ position: {
186
+ - horizontal: "left",
187
+ + horizontal: "start",
188
+ }
189
+ }
190
+ }}
191
+ />
148
192
  ```
149
193
 
150
194
  #### `rename-responsive-chart-container`
@@ -152,27 +196,168 @@ Renames legend props to the corresponding slotProps.
152
196
  Renames `ResponsiveChartContainer` and `ResponsiveChartContainerPro` by `ChartContainer` and `ChartContainerPro` which have the same behavior in v8.
153
197
 
154
198
  ```diff
155
- - import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
156
- + import { ChartContainer } from '@mui/x-charts/ChartContainer';
199
+ -import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
200
+ +import { ChartContainer } from '@mui/x-charts/ChartContainer';
157
201
 
158
- - <ResponsiveChartContainer>
159
- + <ChartContainer>
202
+ -<ResponsiveChartContainer>
203
+ +<ChartContainer>
160
204
  <BarPlot />
161
- - </ResponsiveChartContainer>
162
- + </ChartContainer>
205
+ -</ResponsiveChartContainer>
206
+ +</ChartContainer>
163
207
  ```
164
208
 
165
- :::warning
166
- If you imported both `ResponsiveChartContainer` and `ChartContainer` in the same file, you might end up with duplicated import.
167
- Verify the git diff to remove the duplicate.
209
+ #### `rename-legend-position-type`
210
+
211
+ Renames `LegendPosition` to `Position`.
168
212
 
169
213
  ```diff
170
- import { ChartContainer } from '@mui/x-charts/ChartContainer';
171
- - import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
172
- + import { ChartContainer } from '@mui/x-charts/ChartContainer';
214
+ -import { LegendPosition } from '@mui/x-charts/ChartsLegend';
215
+ +import { Position } from '@mui/x-charts/models';
173
216
  ```
174
217
 
175
- :::
218
+ > [!WARNING]
219
+ > If you imported both `ResponsiveChartContainer` and `ChartContainer` in the same file, you might end up with duplicated import.
220
+ > Verify the git diff to remove the duplicate.
221
+ >
222
+ > ```diff
223
+ > import { ChartContainer } from '@mui/x-charts/ChartContainer';
224
+ > -import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
225
+ > +import { ChartContainer } from '@mui/x-charts/ChartContainer';
226
+ > ```
227
+
228
+ #### `rename-label-and-tick-font-size`
229
+
230
+ Renames `labelFontSize` and `tickFontSize` props to the corresponding `xxxStyle` prop.
231
+
232
+ ```diff
233
+ <ChartsXAxis
234
+ - labelFontSize={18}
235
+ + labelStyle={{
236
+ + fontSize: 18
237
+ + }}
238
+ - tickFontSize={20}
239
+ + tickStyle={{
240
+ + fontSize: 20
241
+ + }}
242
+ />
243
+ ```
244
+
245
+ #### `remove-on-axis-click-handler`
246
+
247
+ Remove the `<ChartsOnAxisClickHandler />` and move the associated `onAxisClick` prop to its parent.
248
+
249
+ > [!WARNING]
250
+ > This codemode does not work if component got renamed or if the handler is not a direct child of the container.
251
+
252
+ ```diff
253
+ + <ChartContainer onAxisClick={() => {}}>
254
+ - <ChartContainer>
255
+ - <ChartsOnAxisClickHandler onAxisClick={() => {}} />
256
+ </ChartContainer>
257
+ ```
258
+
259
+ ### Data Grid codemods
260
+
261
+ #### `preset-safe` for Data Grid v8.0.0
262
+
263
+ The `preset-safe` codemods for Data Grid.
264
+
265
+ <!-- #default-branch-switch -->
266
+
267
+ ```bash
268
+ npx @mui/x-codemod@next v8.0.0/data-grid/preset-safe <path|folder>
269
+ ```
270
+
271
+ The list includes these transformers
272
+
273
+ - [`remove-stabilized-v8-experimentalFeatures`](#remove-stabilized-v8-experimentalFeatures)
274
+
275
+ #### `remove-stabilized-v8-experimentalFeatures`
276
+
277
+ Remove feature flags for stabilized `experimentalFeatures`.
278
+
279
+ ```diff
280
+ <DataGridPremium
281
+ - experimentalFeatures={{
282
+ - ariaV8: true,
283
+ - }}
284
+ />
285
+ ```
286
+
287
+ <!-- #default-branch-switch -->
288
+
289
+ ```bash
290
+ npx @mui/x-codemod@next v8.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
291
+ ```
292
+
293
+ ### Pickers codemods
294
+
295
+ #### `preset-safe` for Pickers v8.0.0
296
+
297
+ The `preset-safe` codemods for Pickers.
298
+
299
+ <!-- #default-branch-switch -->
300
+
301
+ ```bash
302
+ npx @mui/x-codemod@next v8.0.0/pickers/preset-safe <path|folder>
303
+ ```
304
+
305
+ The list includes these transformers
306
+
307
+ - [`rename-adapter-date-fns-imports`](#rename-adapter-date-fns-imports)
308
+ - [`rename-and-move-field-value-type`](#rename-and-move-field-value-type)
309
+
310
+ #### `rename-adapter-date-fns-imports`
311
+
312
+ > [!WARNING]
313
+ > This codemod is not idempotent. Running it multiple times will rename the imports back and forth.
314
+ > Usage of `AdapterDateFnsV3` would be replaced by `AdapterDateFns` and a subsequent run would rename it to `AdapterDateFnsV2`.
315
+
316
+ - Renames `AdapterDateFns` and `AdapterDateFnsJalali` imports to `AdapterDateFnsV2` and `AdapterDateFnsJalaliV2` respectfully.
317
+
318
+ ```diff
319
+ -import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
320
+ -import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali';
321
+ +import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV2';
322
+ +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV2';
323
+ ```
324
+
325
+ - Renames `AdapterDateFnsV3` and `AdapterDateFnsJalaliV3` imports to `AdapterDateFns` and `AdapterDateFnsJalali` respectfully.
326
+
327
+ ```diff
328
+ -import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
329
+ -import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3';
330
+ +import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
331
+ +import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali';
332
+ ```
333
+
334
+ <!-- #default-branch-switch -->
335
+
336
+ ```bash
337
+ npx @mui/x-codemod@next v8.0.0/pickers/rename-adapter-date-fns-imports <path>
338
+ ```
339
+
340
+ #### `rename-and-move-field-value-type`
341
+
342
+ Renames `FieldValueType` to `PickerValueType`.
343
+
344
+ ```diff
345
+ -import { FieldValueType } from '@mui/x-date-pickers';
346
+ +import { PickerValueType } from '@mui/x-date-pickers';
347
+
348
+ interface MyComponentProps {
349
+ - valueType: FieldValueType;
350
+ + valueType: PickerValueType;
351
+ foo: string;
352
+ bar: number;
353
+ }
354
+ ```
355
+
356
+ <!-- #default-branch-switch -->
357
+
358
+ ```bash
359
+ npx @mui/x-codemod@next v8.0.0/pickers/rename-and-move-field-value-type <path>
360
+ ```
176
361
 
177
362
  ## v7.0.0
178
363
 
@@ -195,9 +380,9 @@ The corresponding sub-sections are listed below
195
380
 
196
381
  ### Pickers codemods
197
382
 
198
- #### `preset-safe` for pickers v7.0.0
383
+ #### `preset-safe` for Pickers v7.0.0
199
384
 
200
- The `preset-safe` codemods for pickers.
385
+ The `preset-safe` codemods for Pickers.
201
386
 
202
387
  ```bash
203
388
  npx @mui/x-codemod@latest v7.0.0/pickers/preset-safe <path|folder>
@@ -374,13 +559,13 @@ Renames the Tree View component to Simple Tree View
374
559
  -import { TreeView } from '@mui/x-tree-view/TreeView';
375
560
  +import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
376
561
 
377
- return (
378
- - <TreeView>
379
- + <SimpleTreeView>
380
- <TreeItem itemId="1" label="First item" />
381
- - </TreeView>
382
- + </SimpleTreeView>
383
- );
562
+ return (
563
+ - <TreeView>
564
+ + <SimpleTreeView>
565
+ <TreeItem itemId="1" label="First item" />
566
+ - </TreeView>
567
+ + </SimpleTreeView>
568
+ );
384
569
  ```
385
570
 
386
571
  #### `rename-use-tree-item`
@@ -496,9 +681,9 @@ The corresponding sub-sections are listed below
496
681
 
497
682
  ### Pickers codemods
498
683
 
499
- #### `preset-safe` for pickers v6.0.0
684
+ #### `preset-safe` for Pickers v6.0.0
500
685
 
501
- The `preset-safe` codemods for pickers.
686
+ The `preset-safe` codemods for Pickers.
502
687
 
503
688
  ```bash
504
689
  npx @mui/x-codemod@latest v6.0.0/pickers/preset-safe <path|folder>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-codemod",
3
- "version": "8.0.0-alpha.1",
3
+ "version": "8.0.0-alpha.11",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -25,12 +25,12 @@
25
25
  "url": "https://opencollective.com/mui-org"
26
26
  },
27
27
  "dependencies": {
28
- "@babel/core": "^7.26.0",
29
- "@babel/runtime": "^7.26.0",
30
- "@babel/traverse": "^7.25.9",
31
- "jscodeshift": "17.1.1",
28
+ "@babel/core": "^7.26.7",
29
+ "@babel/runtime": "^7.26.7",
30
+ "@babel/traverse": "^7.26.7",
31
+ "jscodeshift": "17.1.2",
32
32
  "yargs": "^17.7.2",
33
- "@mui/x-internals": "8.0.0-alpha.1"
33
+ "@mui/x-internals": "8.0.0-alpha.11"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/jscodeshift": "^0.12.0",
@@ -7,8 +7,20 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = transformer;
8
8
  var _renameLegendToSlotsLegend = _interopRequireDefault(require("../rename-legend-to-slots-legend"));
9
9
  var _renameResponsiveChartContainer = _interopRequireDefault(require("../rename-responsive-chart-container"));
10
+ var _renameLabelAndTickFontSize = _interopRequireDefault(require("../rename-label-and-tick-font-size"));
11
+ var _replaceLegendDirectionValues = _interopRequireDefault(require("../replace-legend-direction-values"));
12
+ var _replaceLegendPositionValues = _interopRequireDefault(require("../replace-legend-position-values"));
13
+ var _removeExperimentalMarkRendering = _interopRequireDefault(require("../remove-experimental-mark-rendering"));
14
+ var _renameLegendPositionType = _interopRequireDefault(require("../rename-legend-position-type"));
15
+ var _removeOnAxisClickHandler = _interopRequireDefault(require("../remove-on-axis-click-handler"));
10
16
  function transformer(file, api, options) {
11
17
  file.source = (0, _renameLegendToSlotsLegend.default)(file, api, options);
12
18
  file.source = (0, _renameResponsiveChartContainer.default)(file, api, options);
19
+ file.source = (0, _renameLabelAndTickFontSize.default)(file, api, options);
20
+ file.source = (0, _replaceLegendDirectionValues.default)(file, api, options);
21
+ file.source = (0, _replaceLegendPositionValues.default)(file, api, options);
22
+ file.source = (0, _removeExperimentalMarkRendering.default)(file, api, options);
23
+ file.source = (0, _renameLegendPositionType.default)(file, api, options);
24
+ file.source = (0, _removeOnAxisClickHandler.default)(file, api, options);
13
25
  return file.source;
14
26
  }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _removeProps = _interopRequireDefault(require("../../../util/removeProps"));
9
+ const componentNames = ['LineChart', 'LineChartPro', 'MarkPlot'];
10
+ const props = ['experimentalMarkRendering'];
11
+ function transformer(file, api, options) {
12
+ const j = api.jscodeshift;
13
+ const root = j(file.source);
14
+ const printOptions = options.printOptions || {
15
+ quote: 'single',
16
+ trailingComma: true
17
+ };
18
+ return (0, _removeProps.default)({
19
+ root,
20
+ j,
21
+ props,
22
+ componentNames
23
+ }).toSource(printOptions);
24
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ /**
8
+ * @param {import('jscodeshift').FileInfo} file
9
+ * @param {import('jscodeshift').API} api
10
+ */
11
+ function transformer(file, api, options) {
12
+ const j = api.jscodeshift;
13
+ const printOptions = options.printOptions;
14
+ const root = j(file.source);
15
+
16
+ // Move the handler to the container
17
+ root.findJSXElements().filter(path => Boolean(path.node.openingElement) && path.node.openingElement.name.type === 'JSXIdentifier' && path.node.openingElement.name.name.includes('ChartContainer')).forEach(path => {
18
+ // We find the <ChartsOnAxisClickHandler /> node
19
+ const clickHandler = path.node.children?.find(child => {
20
+ if (child.type !== 'JSXElement') {
21
+ return false;
22
+ }
23
+ if (child.openingElement.name.type !== 'JSXIdentifier') {
24
+ return false;
25
+ }
26
+ return child.openingElement.name.name === 'ChartsOnAxisClickHandler';
27
+ });
28
+ if (!clickHandler) {
29
+ return;
30
+ }
31
+ const clickCallback = clickHandler.openingElement.attributes?.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'onAxisClick');
32
+ if (!clickCallback) {
33
+ return;
34
+ }
35
+
36
+ // Move the callback to the container
37
+ path.node.openingElement.attributes?.push(clickCallback);
38
+
39
+ // Remove the children
40
+ path.node.children = path.node.children?.filter(child => {
41
+ if (child.type !== 'JSXElement') {
42
+ return true;
43
+ }
44
+ if (child.openingElement.name.type !== 'JSXIdentifier') {
45
+ return true;
46
+ }
47
+ return child.openingElement.name.name !== 'ChartsOnAxisClickHandler';
48
+ });
49
+ });
50
+
51
+ // Remove nested import
52
+ root.find(j.ImportDeclaration, {
53
+ source: {
54
+ value: '@mui/x-charts/ChartsOnAxisClickHandler'
55
+ }
56
+ }).remove();
57
+
58
+ // Remove global import
59
+ root.find(j.ImportDeclaration).forEach(path => {
60
+ if (typeof path.node.source.value !== 'string') {
61
+ return;
62
+ }
63
+ if (!path.node.source.value.includes('@mui/x-charts')) {
64
+ return;
65
+ }
66
+ path.node.specifiers = path.node.specifiers?.filter(specifier => {
67
+ if (specifier.type !== 'ImportSpecifier') {
68
+ return true;
69
+ }
70
+ return specifier.imported.name !== 'ChartsOnAxisClickHandler';
71
+ });
72
+ });
73
+ return root.toSource(printOptions);
74
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _addComponentsSlots = require("../../../util/addComponentsSlots");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const printOptions = options.printOptions;
15
+ const root = j(file.source);
16
+ root.find(j.ImportDeclaration).filter(({
17
+ node
18
+ }) => {
19
+ return typeof node.source.value === 'string' && node.source.value.startsWith('@mui/x-charts');
20
+ }).forEach(path => {
21
+ path.node.specifiers?.forEach(node => {
22
+ root.findJSXElements(node.local?.name).forEach(elementPath => {
23
+ if (elementPath.node.type !== 'JSXElement') {
24
+ return;
25
+ }
26
+ ['label', 'tick'].forEach(attributeName => {
27
+ const attributeValue = elementPath.node.openingElement.attributes?.find(elementNode => elementNode.type === 'JSXAttribute' && elementNode.name.name === `${attributeName}FontSize`);
28
+ if (!attributeValue) {
29
+ return;
30
+ }
31
+ const attributeStyle = elementPath.node.openingElement.attributes?.find(elementNode => elementNode.type === 'JSXAttribute' && elementNode.name.name === `${attributeName}Style`);
32
+
33
+ // @ts-ignore receives an object.
34
+ const styleValue = attributeStyle?.value.expression.properties.find(prop => prop.key.name === 'fontSize');
35
+ if (attributeStyle === null) {
36
+ // We create a new "style" object
37
+ elementPath.node.openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier(`${attributeName}Style`), j.jsxExpressionContainer(j.objectExpression([j.objectProperty(j.identifier('fontSize'),
38
+ // @ts-ignore receives an object.
39
+ attributeValue.value.expression)]))));
40
+ } else {
41
+ (0, _addComponentsSlots.transformNestedProp)(elementPath, `${attributeName}Style`, 'fontSize',
42
+ // @ts-ignore receives an object.
43
+ styleValue?.value ?? attributeValue.value.expression, j);
44
+ }
45
+ });
46
+
47
+ // Remove the legend prop
48
+ j(elementPath).find(j.JSXAttribute).filter(a => a.value.name.name === 'labelFontSize' || a.value.name.name === 'tickFontSize').forEach(pathToRemove => {
49
+ j(pathToRemove).remove();
50
+ });
51
+ });
52
+ });
53
+ });
54
+ const transformed = root.findJSXElements();
55
+ return transformed.toSource(printOptions);
56
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _renameImports = require("../../../util/renameImports");
8
+ function transformer(file, api, options) {
9
+ const j = api.jscodeshift;
10
+ const root = j(file.source);
11
+ const printOptions = options.printOptions || {
12
+ quote: 'single',
13
+ trailingComma: true,
14
+ wrapColumn: 40
15
+ };
16
+ (0, _renameImports.renameImports)({
17
+ j,
18
+ root,
19
+ packageNames: ['@mui/x-charts', '@mui/x-charts-pro'],
20
+ imports: [{
21
+ oldEndpoint: 'ChartsLegend',
22
+ newEndpoint: 'models',
23
+ importsMapping: {
24
+ LegendPosition: 'Position'
25
+ }
26
+ }]
27
+ });
28
+ return root.toSource(printOptions);
29
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _addComponentsSlots = require("../../../util/addComponentsSlots");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const printOptions = options.printOptions;
15
+ const root = j(file.source);
16
+ root.find(j.ImportDeclaration).filter(({
17
+ node
18
+ }) => {
19
+ return typeof node.source.value === 'string' && node.source.value.startsWith('@mui/x-charts');
20
+ }).forEach(path => {
21
+ path.node.specifiers?.forEach(node => {
22
+ root.findJSXElements(node.local?.name).forEach(elementPath => {
23
+ if (elementPath.node.type !== 'JSXElement') {
24
+ return;
25
+ }
26
+ const slotProps = elementPath.node.openingElement.attributes?.find(elementNode => elementNode.type === 'JSXAttribute' && elementNode.name.name === 'slotProps');
27
+ if (slotProps === null) {
28
+ // No slotProps to manage
29
+ return;
30
+ }
31
+ const direction = slotProps?.value?.expression?.properties
32
+ // @ts-expect-error
33
+ ?.find(v => v?.key?.name === 'legend')
34
+ // @ts-expect-error
35
+ ?.value?.properties?.find(v => v?.key?.name === 'direction');
36
+ if (direction === undefined || direction?.value === undefined || direction?.value?.value === undefined) {
37
+ return;
38
+ }
39
+ const directionValue = direction.value;
40
+ directionValue.value = mapFix(directionValue.value);
41
+ (0, _addComponentsSlots.transformNestedProp)(elementPath, 'slotProps', 'legend.direction', directionValue, j);
42
+ });
43
+ });
44
+ });
45
+ const transformed = root.findJSXElements();
46
+ return transformed.toSource(printOptions);
47
+ }
48
+ function mapFix(v) {
49
+ switch (v) {
50
+ case 'row':
51
+ return 'horizontal';
52
+ case 'column':
53
+ return 'vertical';
54
+ default:
55
+ return v;
56
+ }
57
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _addComponentsSlots = require("../../../util/addComponentsSlots");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const printOptions = options.printOptions;
15
+ const root = j(file.source);
16
+ root.find(j.ImportDeclaration).filter(({
17
+ node
18
+ }) => {
19
+ return typeof node.source.value === 'string' && node.source.value.startsWith('@mui/x-charts');
20
+ }).forEach(path => {
21
+ path.node.specifiers?.forEach(node => {
22
+ root.findJSXElements(node.local?.name).forEach(elementPath => {
23
+ if (elementPath.node.type !== 'JSXElement') {
24
+ return;
25
+ }
26
+ const slotProps = elementPath.node.openingElement.attributes?.find(elementNode => elementNode.type === 'JSXAttribute' && elementNode.name.name === 'slotProps');
27
+ if (slotProps === null) {
28
+ // No slotProps to manage
29
+ return;
30
+ }
31
+ const position = slotProps?.value?.expression?.properties
32
+ // @ts-expect-error
33
+ ?.find(v => v?.key?.name === 'legend')
34
+ // @ts-expect-error
35
+ ?.value?.properties?.find(v => v?.key?.name === 'position');
36
+ const horizontal = position?.value?.properties?.find(v => v?.key?.name === 'horizontal');
37
+ if (horizontal === undefined || horizontal?.value === undefined || horizontal?.value?.value === undefined) {
38
+ return;
39
+ }
40
+ const horizontalValue = horizontal.value;
41
+ horizontalValue.value = mapFix(horizontalValue.value);
42
+ (0, _addComponentsSlots.transformNestedProp)(elementPath, 'slotProps', 'legend.position.horizontal', horizontalValue, j);
43
+ });
44
+ });
45
+ });
46
+ const transformed = root.findJSXElements();
47
+ return transformed.toSource(printOptions);
48
+ }
49
+ function mapFix(v) {
50
+ switch (v) {
51
+ case 'left':
52
+ return 'start';
53
+ case 'right':
54
+ return 'end';
55
+ case 'middle':
56
+ return 'center';
57
+ default:
58
+ return v;
59
+ }
60
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _removeStabilizedExperimentalFeatures = _interopRequireDefault(require("../remove-stabilized-experimentalFeatures"));
9
+ function transformer(file, api, options) {
10
+ file.source = (0, _removeStabilizedExperimentalFeatures.default)(file, api, options);
11
+ return file.source;
12
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _removeObjectProperty = _interopRequireDefault(require("../../../util/removeObjectProperty"));
9
+ const componentsNames = ['DataGridPremium'];
10
+ const propName = 'experimentalFeatures';
11
+ const propKeys = ['ariaV8'];
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
+ }
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = transformer;
8
+ var _renameAdapterDateFnsImports = _interopRequireDefault(require("../rename-adapter-date-fns-imports"));
8
9
  var _renameAndMoveFieldValueType = _interopRequireDefault(require("../rename-and-move-field-value-type"));
9
10
  function transformer(file, api, options) {
11
+ file.source = (0, _renameAdapterDateFnsImports.default)(file, api, options);
10
12
  file.source = (0, _renameAndMoveFieldValueType.default)(file, api, options);
11
13
  return file.source;
12
14
  }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _renameImports = require("../../../util/renameImports");
8
+ function transformer(file, api, options) {
9
+ const j = api.jscodeshift;
10
+ const root = j(file.source);
11
+ const printOptions = options.printOptions || {
12
+ quote: 'single',
13
+ trailingComma: true
14
+ };
15
+ (0, _renameImports.renameImports)({
16
+ j,
17
+ root,
18
+ packageNames: ['@mui/x-date-pickers', '@mui/x-date-pickers-pro'],
19
+ imports: [{
20
+ oldEndpoint: 'AdapterDateFns',
21
+ newEndpoint: 'AdapterDateFnsV2',
22
+ importsMapping: {
23
+ AdapterDateFns: 'AdapterDateFns'
24
+ }
25
+ }, {
26
+ oldEndpoint: 'AdapterDateFnsV3',
27
+ newEndpoint: 'AdapterDateFns',
28
+ importsMapping: {
29
+ AdapterDateFns: 'AdapterDateFns'
30
+ }
31
+ }, {
32
+ oldEndpoint: 'AdapterDateFnsJalali',
33
+ newEndpoint: 'AdapterDateFnsJalaliV2',
34
+ importsMapping: {
35
+ AdapterDateFnsJalali: 'AdapterDateFnsJalali'
36
+ }
37
+ }, {
38
+ oldEndpoint: 'AdapterDateFnsJalaliV3',
39
+ newEndpoint: 'AdapterDateFnsJalali',
40
+ importsMapping: {
41
+ AdapterDateFnsJalali: 'AdapterDateFnsJalali'
42
+ }
43
+ }]
44
+ });
45
+ return root.toSource(printOptions);
46
+ }
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = transformer;
8
8
  var _presetSafe = _interopRequireDefault(require("../tree-view/preset-safe"));
9
- var _presetSafe2 = _interopRequireDefault(require("../charts/preset-safe"));
9
+ var _presetSafe2 = _interopRequireDefault(require("../pickers/preset-safe"));
10
+ var _presetSafe3 = _interopRequireDefault(require("../charts/preset-safe"));
11
+ var _presetSafe4 = _interopRequireDefault(require("../data-grid/preset-safe"));
10
12
  function transformer(file, api, options) {
11
13
  file.source = (0, _presetSafe.default)(file, api, options);
12
14
  file.source = (0, _presetSafe2.default)(file, api, options);
15
+ file.source = (0, _presetSafe3.default)(file, api, options);
16
+ file.source = (0, _presetSafe4.default)(file, api, options);
13
17
  return file.source;
14
18
  }