@mui/x-codemod 8.0.0-alpha.0 → 8.0.0-alpha.10
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 +215 -44
- package/package.json +6 -6
- package/v8.0.0/charts/preset-safe/index.js +10 -0
- package/v8.0.0/charts/remove-experimental-mark-rendering/index.js +24 -0
- package/v8.0.0/charts/rename-label-and-tick-font-size/index.js +56 -0
- package/v8.0.0/charts/rename-legend-position-type/index.js +29 -0
- package/v8.0.0/charts/replace-legend-direction-values/index.js +57 -0
- package/v8.0.0/charts/replace-legend-position-values/index.js +60 -0
- package/v8.0.0/data-grid/preset-safe/index.js +12 -0
- package/v8.0.0/data-grid/remove-stabilized-experimentalFeatures/index.js +29 -0
- package/v8.0.0/pickers/preset-safe/index.js +14 -0
- package/v8.0.0/pickers/rename-adapter-date-fns-imports/index.js +46 -0
- package/v8.0.0/pickers/rename-and-move-field-value-type/index.js +27 -0
- package/v8.0.0/preset-safe/index.js +5 -1
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
|
-
|
|
42
|
+
# single option
|
|
43
43
|
npx @mui/x-codemod@next --jscodeshift=--run-in-band
|
|
44
|
-
|
|
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@
|
|
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
|
|
84
|
+
#### `preset-safe` for Tree View v8.0.0
|
|
80
85
|
|
|
81
|
-
The `preset-safe` codemods for
|
|
86
|
+
The `preset-safe` codemods for Tree View.
|
|
87
|
+
|
|
88
|
+
<!-- #default-branch-switch -->
|
|
82
89
|
|
|
83
90
|
```bash
|
|
84
|
-
npx @mui/x-codemod@
|
|
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
|
-
|
|
104
|
-
-
|
|
105
|
-
+
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
+
|
|
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
|
|
133
|
+
#### `preset-safe` for Charts v8.0.0
|
|
134
|
+
|
|
135
|
+
The `preset-safe` codemods for Charts.
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
<!-- #default-branch-switch -->
|
|
129
138
|
|
|
130
139
|
```bash
|
|
131
|
-
npx @mui/x-codemod@
|
|
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
|
-
|
|
145
|
-
-
|
|
146
|
-
+
|
|
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,154 @@ 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
|
-
-
|
|
156
|
-
+
|
|
199
|
+
-import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
|
|
200
|
+
+import { ChartContainer } from '@mui/x-charts/ChartContainer';
|
|
157
201
|
|
|
158
|
-
|
|
159
|
-
|
|
202
|
+
-<ResponsiveChartContainer>
|
|
203
|
+
+<ChartContainer>
|
|
160
204
|
<BarPlot />
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
-</ResponsiveChartContainer>
|
|
206
|
+
+</ChartContainer>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### `rename-legend-position-type`
|
|
210
|
+
|
|
211
|
+
Renames `LegendPosition` to `Position`.
|
|
212
|
+
|
|
213
|
+
```diff
|
|
214
|
+
-import { LegendPosition } from '@mui/x-charts/ChartsLegend';
|
|
215
|
+
+import { Position } from '@mui/x-charts/models';
|
|
163
216
|
```
|
|
164
217
|
|
|
165
|
-
|
|
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.
|
|
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.
|
|
168
231
|
|
|
169
232
|
```diff
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
+
|
|
233
|
+
<ChartsXAxis
|
|
234
|
+
- labelFontSize={18}
|
|
235
|
+
+ labelStyle={{
|
|
236
|
+
+ fontSize: 18
|
|
237
|
+
+ }}
|
|
238
|
+
- tickFontSize={20}
|
|
239
|
+
+ tickStyle={{
|
|
240
|
+
+ fontSize: 20
|
|
241
|
+
+ }}
|
|
242
|
+
/>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Data Grid codemods
|
|
246
|
+
|
|
247
|
+
#### `preset-safe` for Data Grid v8.0.0
|
|
248
|
+
|
|
249
|
+
The `preset-safe` codemods for Data Grid.
|
|
250
|
+
|
|
251
|
+
<!-- #default-branch-switch -->
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/preset-safe <path|folder>
|
|
173
255
|
```
|
|
174
256
|
|
|
175
|
-
|
|
257
|
+
The list includes these transformers
|
|
258
|
+
|
|
259
|
+
- [`remove-stabilized-v8-experimentalFeatures`](#remove-stabilized-v8-experimentalFeatures)
|
|
260
|
+
|
|
261
|
+
#### `remove-stabilized-v8-experimentalFeatures`
|
|
262
|
+
|
|
263
|
+
Remove feature flags for stabilized `experimentalFeatures`.
|
|
264
|
+
|
|
265
|
+
```diff
|
|
266
|
+
<DataGridPremium
|
|
267
|
+
- experimentalFeatures={{
|
|
268
|
+
- ariaV8: true,
|
|
269
|
+
- }}
|
|
270
|
+
/>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
<!-- #default-branch-switch -->
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Pickers codemods
|
|
280
|
+
|
|
281
|
+
#### `preset-safe` for Pickers v8.0.0
|
|
282
|
+
|
|
283
|
+
The `preset-safe` codemods for Pickers.
|
|
284
|
+
|
|
285
|
+
<!-- #default-branch-switch -->
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
npx @mui/x-codemod@next v8.0.0/pickers/preset-safe <path|folder>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The list includes these transformers
|
|
292
|
+
|
|
293
|
+
- [`rename-adapter-date-fns-imports`](#rename-adapter-date-fns-imports)
|
|
294
|
+
- [`rename-and-move-field-value-type`](#rename-and-move-field-value-type)
|
|
295
|
+
|
|
296
|
+
#### `rename-adapter-date-fns-imports`
|
|
297
|
+
|
|
298
|
+
> [!WARNING]
|
|
299
|
+
> This codemod is not idempotent. Running it multiple times will rename the imports back and forth.
|
|
300
|
+
> Usage of `AdapterDateFnsV3` would be replaced by `AdapterDateFns` and a subsequent run would rename it to `AdapterDateFnsV2`.
|
|
301
|
+
|
|
302
|
+
- Renames `AdapterDateFns` and `AdapterDateFnsJalali` imports to `AdapterDateFnsV2` and `AdapterDateFnsJalaliV2` respectfully.
|
|
303
|
+
|
|
304
|
+
```diff
|
|
305
|
+
-import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
306
|
+
-import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali';
|
|
307
|
+
+import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV2';
|
|
308
|
+
+import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV2';
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
- Renames `AdapterDateFnsV3` and `AdapterDateFnsJalaliV3` imports to `AdapterDateFns` and `AdapterDateFnsJalali` respectfully.
|
|
312
|
+
|
|
313
|
+
```diff
|
|
314
|
+
-import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
|
|
315
|
+
-import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalaliV3';
|
|
316
|
+
+import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
317
|
+
+import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali';
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
<!-- #default-branch-switch -->
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
npx @mui/x-codemod@next v8.0.0/pickers/rename-adapter-date-fns-imports <path>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### `rename-and-move-field-value-type`
|
|
327
|
+
|
|
328
|
+
Renames `FieldValueType` to `PickerValueType`.
|
|
329
|
+
|
|
330
|
+
```diff
|
|
331
|
+
-import { FieldValueType } from '@mui/x-date-pickers';
|
|
332
|
+
+import { PickerValueType } from '@mui/x-date-pickers';
|
|
333
|
+
|
|
334
|
+
interface MyComponentProps {
|
|
335
|
+
- valueType: FieldValueType;
|
|
336
|
+
+ valueType: PickerValueType;
|
|
337
|
+
foo: string;
|
|
338
|
+
bar: number;
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
<!-- #default-branch-switch -->
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
npx @mui/x-codemod@next v8.0.0/pickers/rename-and-move-field-value-type <path>
|
|
346
|
+
```
|
|
176
347
|
|
|
177
348
|
## v7.0.0
|
|
178
349
|
|
|
@@ -195,9 +366,9 @@ The corresponding sub-sections are listed below
|
|
|
195
366
|
|
|
196
367
|
### Pickers codemods
|
|
197
368
|
|
|
198
|
-
#### `preset-safe` for
|
|
369
|
+
#### `preset-safe` for Pickers v7.0.0
|
|
199
370
|
|
|
200
|
-
The `preset-safe` codemods for
|
|
371
|
+
The `preset-safe` codemods for Pickers.
|
|
201
372
|
|
|
202
373
|
```bash
|
|
203
374
|
npx @mui/x-codemod@latest v7.0.0/pickers/preset-safe <path|folder>
|
|
@@ -374,13 +545,13 @@ Renames the Tree View component to Simple Tree View
|
|
|
374
545
|
-import { TreeView } from '@mui/x-tree-view/TreeView';
|
|
375
546
|
+import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
|
|
376
547
|
|
|
377
|
-
|
|
378
|
-
-
|
|
379
|
-
+
|
|
380
|
-
|
|
381
|
-
-
|
|
382
|
-
+
|
|
383
|
-
|
|
548
|
+
return (
|
|
549
|
+
- <TreeView>
|
|
550
|
+
+ <SimpleTreeView>
|
|
551
|
+
<TreeItem itemId="1" label="First item" />
|
|
552
|
+
- </TreeView>
|
|
553
|
+
+ </SimpleTreeView>
|
|
554
|
+
);
|
|
384
555
|
```
|
|
385
556
|
|
|
386
557
|
#### `rename-use-tree-item`
|
|
@@ -496,9 +667,9 @@ The corresponding sub-sections are listed below
|
|
|
496
667
|
|
|
497
668
|
### Pickers codemods
|
|
498
669
|
|
|
499
|
-
#### `preset-safe` for
|
|
670
|
+
#### `preset-safe` for Pickers v6.0.0
|
|
500
671
|
|
|
501
|
-
The `preset-safe` codemods for
|
|
672
|
+
The `preset-safe` codemods for Pickers.
|
|
502
673
|
|
|
503
674
|
```bash
|
|
504
675
|
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.
|
|
3
|
+
"version": "8.0.0-alpha.10",
|
|
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.
|
|
29
|
-
"@babel/runtime": "^7.26.
|
|
30
|
-
"@babel/traverse": "^7.
|
|
31
|
-
"jscodeshift": "17.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.
|
|
33
|
+
"@mui/x-internals": "8.0.0-alpha.10"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jscodeshift": "^0.12.0",
|
|
@@ -7,8 +7,18 @@ 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"));
|
|
10
15
|
function transformer(file, api, options) {
|
|
11
16
|
file.source = (0, _renameLegendToSlotsLegend.default)(file, api, options);
|
|
12
17
|
file.source = (0, _renameResponsiveChartContainer.default)(file, api, options);
|
|
18
|
+
file.source = (0, _renameLabelAndTickFontSize.default)(file, api, options);
|
|
19
|
+
file.source = (0, _replaceLegendDirectionValues.default)(file, api, options);
|
|
20
|
+
file.source = (0, _replaceLegendPositionValues.default)(file, api, options);
|
|
21
|
+
file.source = (0, _removeExperimentalMarkRendering.default)(file, api, options);
|
|
22
|
+
file.source = (0, _renameLegendPositionType.default)(file, api, options);
|
|
13
23
|
return file.source;
|
|
14
24
|
}
|
|
@@ -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,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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 _renameAdapterDateFnsImports = _interopRequireDefault(require("../rename-adapter-date-fns-imports"));
|
|
9
|
+
var _renameAndMoveFieldValueType = _interopRequireDefault(require("../rename-and-move-field-value-type"));
|
|
10
|
+
function transformer(file, api, options) {
|
|
11
|
+
file.source = (0, _renameAdapterDateFnsImports.default)(file, api, options);
|
|
12
|
+
file.source = (0, _renameAndMoveFieldValueType.default)(file, api, options);
|
|
13
|
+
return file.source;
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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: 'models',
|
|
21
|
+
importsMapping: {
|
|
22
|
+
FieldValueType: 'PickerValueType'
|
|
23
|
+
}
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
return root.toSource(printOptions);
|
|
27
|
+
}
|
|
@@ -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("../
|
|
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
|
}
|