@vkontakte/vkui-codemods 1.1.0-beta.0 → 1.1.0-beta.2
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/dist/transforms/v8/action-sheet.js +19 -0
- package/dist/transforms/v8/alert.js +19 -0
- package/dist/transforms/v8/checkbox.js +1 -1
- package/dist/transforms/v8/common/moveInputPropsIntoSlotProps.js +10 -0
- package/dist/transforms/v8/custom-select.js +13 -1
- package/dist/transforms/v8/file.js +1 -0
- package/dist/transforms/v8/input.js +24 -0
- package/dist/transforms/v8/popout-wrapper.js +67 -0
- package/dist/transforms/v8/radio.js +1 -1
- package/dist/transforms/v8/rich-cell.js +50 -0
- package/dist/transforms/v8/search.js +1 -4
- package/dist/transforms/v8/snackbar.js +19 -0
- package/dist/transforms/v8/switch.js +1 -1
- package/dist/transforms/v8/text-area.js +18 -0
- package/dist/transforms/v8/write-bar.js +18 -0
- package/package.json +4 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
var RENAME_MAP = {
|
|
8
|
+
onClose: 'onClosed',
|
|
9
|
+
};
|
|
10
|
+
function transformer(file, api, options) {
|
|
11
|
+
var alias = options.alias;
|
|
12
|
+
var j = api.jscodeshift;
|
|
13
|
+
var source = j(file.source);
|
|
14
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ActionSheet', alias).localName;
|
|
15
|
+
if (localName) {
|
|
16
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
17
|
+
}
|
|
18
|
+
return source.toSource();
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
function transformer(file, api, options) {
|
|
8
|
+
var alias = options.alias;
|
|
9
|
+
var j = api.jscodeshift;
|
|
10
|
+
var source = j(file.source);
|
|
11
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Alert', alias).localName;
|
|
12
|
+
if (!localName) {
|
|
13
|
+
return source.toSource();
|
|
14
|
+
}
|
|
15
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, {
|
|
16
|
+
onClose: 'onClosed',
|
|
17
|
+
});
|
|
18
|
+
return source.toSource();
|
|
19
|
+
}
|
|
@@ -33,7 +33,7 @@ function transformer(file, api, options) {
|
|
|
33
33
|
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
34
34
|
root: source,
|
|
35
35
|
componentName: componentName,
|
|
36
|
-
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value'],
|
|
36
|
+
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value', 'form'],
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -33,6 +33,16 @@ var INPUT_SPECIFIC_PROPS = [
|
|
|
33
33
|
'type',
|
|
34
34
|
'value',
|
|
35
35
|
'width',
|
|
36
|
+
'onInput',
|
|
37
|
+
'onInputCapture',
|
|
38
|
+
'onClick',
|
|
39
|
+
'onClickCapture',
|
|
40
|
+
'onPaste',
|
|
41
|
+
'onPasteCapture',
|
|
42
|
+
'onKeyDown',
|
|
43
|
+
'onKeyDownCapture',
|
|
44
|
+
'onKeyUp',
|
|
45
|
+
'onKeyUpCapture',
|
|
36
46
|
];
|
|
37
47
|
function moveInputPropsIntoSlotProps(j, _a) {
|
|
38
48
|
var root = _a.root, componentName = _a.componentName, excludedProps = _a.excludedProps, _b = _a.slotName, slotName = _b === void 0 ? 'input' : _b;
|
|
@@ -46,7 +46,19 @@ function transformer(file, api, options) {
|
|
|
46
46
|
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
47
47
|
root: source,
|
|
48
48
|
componentName: localName,
|
|
49
|
-
excludedProps: [
|
|
49
|
+
excludedProps: [
|
|
50
|
+
'disabled',
|
|
51
|
+
'readOnly',
|
|
52
|
+
'required',
|
|
53
|
+
'name',
|
|
54
|
+
'value',
|
|
55
|
+
'placeholder',
|
|
56
|
+
'minLength',
|
|
57
|
+
'maxLength',
|
|
58
|
+
'pattern',
|
|
59
|
+
'form',
|
|
60
|
+
'onClick',
|
|
61
|
+
],
|
|
50
62
|
});
|
|
51
63
|
}
|
|
52
64
|
return source.toSource();
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
5
|
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
var moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
|
|
6
7
|
var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
|
|
7
8
|
exports.parser = 'tsx';
|
|
8
9
|
function transformer(file, api, options) {
|
|
@@ -28,6 +29,29 @@ function transformer(file, api, options) {
|
|
|
28
29
|
componentName: localName,
|
|
29
30
|
slotName: 'input',
|
|
30
31
|
});
|
|
32
|
+
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
33
|
+
root: source,
|
|
34
|
+
componentName: localName,
|
|
35
|
+
excludedProps: [
|
|
36
|
+
'autoComplete',
|
|
37
|
+
'disabled',
|
|
38
|
+
'list',
|
|
39
|
+
'max',
|
|
40
|
+
'maxLength',
|
|
41
|
+
'min',
|
|
42
|
+
'minLength',
|
|
43
|
+
'multiple',
|
|
44
|
+
'name',
|
|
45
|
+
'pattern',
|
|
46
|
+
'placeholder',
|
|
47
|
+
'readOnly',
|
|
48
|
+
'required',
|
|
49
|
+
'step',
|
|
50
|
+
'type',
|
|
51
|
+
'value',
|
|
52
|
+
'form',
|
|
53
|
+
],
|
|
54
|
+
});
|
|
31
55
|
}
|
|
32
56
|
return source.toSource();
|
|
33
57
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
function transformer(file, api, options) {
|
|
8
|
+
var alias = options.alias;
|
|
9
|
+
var j = api.jscodeshift;
|
|
10
|
+
var source = j(file.source);
|
|
11
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PopoutWrapper', alias).localName;
|
|
12
|
+
if (!localName) {
|
|
13
|
+
return source.toSource();
|
|
14
|
+
}
|
|
15
|
+
source
|
|
16
|
+
.find(j.JSXElement, {
|
|
17
|
+
openingElement: {
|
|
18
|
+
name: {
|
|
19
|
+
name: localName,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
.forEach(function (path) {
|
|
24
|
+
var element = path.node;
|
|
25
|
+
var attributes = element.openingElement.attributes;
|
|
26
|
+
if (!attributes) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var fixedAttribute = null;
|
|
30
|
+
var fixedValueIsFalse = false;
|
|
31
|
+
// Находим атрибут fixed
|
|
32
|
+
attributes.forEach(function (attr) {
|
|
33
|
+
if (attr.type === 'JSXAttribute' && attr.name.name === 'fixed') {
|
|
34
|
+
fixedAttribute = attr;
|
|
35
|
+
// Проверяем значение атрибута
|
|
36
|
+
if (!attr.value) {
|
|
37
|
+
// fixed без значения считается true
|
|
38
|
+
fixedValueIsFalse = false;
|
|
39
|
+
}
|
|
40
|
+
else if (attr.value.type === 'JSXExpressionContainer' &&
|
|
41
|
+
attr.value.expression.type === 'BooleanLiteral') {
|
|
42
|
+
// fixed={true} или fixed={false}
|
|
43
|
+
fixedValueIsFalse = !attr.value.expression.value;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Сложное выражение - оставляем как есть, но удалим fixed
|
|
47
|
+
fixedValueIsFalse = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// Если нашли атрибут fixed
|
|
52
|
+
if (fixedAttribute) {
|
|
53
|
+
// Удаляем атрибут fixed
|
|
54
|
+
attributes.splice(attributes.indexOf(fixedAttribute), 1);
|
|
55
|
+
// Если fixed={false}, добавляем strategy="none"
|
|
56
|
+
if (fixedValueIsFalse) {
|
|
57
|
+
// Проверяем, нет ли уже атрибута strategy
|
|
58
|
+
var hasStrategy = attributes.some(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'strategy'; });
|
|
59
|
+
if (!hasStrategy) {
|
|
60
|
+
// Добавляем strategy="none"
|
|
61
|
+
attributes.push(j.jsxAttribute(j.jsxIdentifier('strategy'), j.stringLiteral('none')));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return source.toSource();
|
|
67
|
+
}
|
|
@@ -39,7 +39,7 @@ function transformer(file, api, options) {
|
|
|
39
39
|
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
40
40
|
root: source,
|
|
41
41
|
componentName: componentName,
|
|
42
|
-
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value'],
|
|
42
|
+
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value', 'form'],
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
function transformer(file, api, options) {
|
|
8
|
+
var alias = options.alias;
|
|
9
|
+
var j = api.jscodeshift;
|
|
10
|
+
var source = j(file.source);
|
|
11
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'RichCell', alias).localName;
|
|
12
|
+
if (!localName) {
|
|
13
|
+
return source.toSource();
|
|
14
|
+
}
|
|
15
|
+
source
|
|
16
|
+
.find(j.JSXElement, {
|
|
17
|
+
openingElement: {
|
|
18
|
+
name: {
|
|
19
|
+
name: localName,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
.forEach(function (path) {
|
|
24
|
+
var element = path.node;
|
|
25
|
+
var attributes = element.openingElement.attributes;
|
|
26
|
+
if (!attributes) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var afterAlignValue = null;
|
|
30
|
+
attributes.forEach(function (attr) {
|
|
31
|
+
if (attr.type === 'JSXAttribute' && attr.name.name === 'afterAlign') {
|
|
32
|
+
afterAlignValue = (0, codemod_helpers_1.getStringValueFromAttribute)(attr);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (afterAlignValue !== null && afterAlignValue !== 'start') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
attributes.forEach(function (attr) {
|
|
39
|
+
if (attr.type === 'JSXAttribute') {
|
|
40
|
+
if (attr.name.name === 'after') {
|
|
41
|
+
attr.name.name = 'meta';
|
|
42
|
+
}
|
|
43
|
+
else if (attr.name.name === 'afterCaption') {
|
|
44
|
+
attr.name.name = 'submeta';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return source.toSource();
|
|
50
|
+
}
|
|
@@ -34,14 +34,10 @@ function transformer(file, api, options) {
|
|
|
34
34
|
componentName: localName,
|
|
35
35
|
slotName: 'input',
|
|
36
36
|
excludedProps: [
|
|
37
|
-
'alt',
|
|
38
37
|
'autoComplete',
|
|
39
|
-
'capture',
|
|
40
38
|
'disabled',
|
|
41
39
|
'list',
|
|
42
|
-
'max',
|
|
43
40
|
'maxLength',
|
|
44
|
-
'min',
|
|
45
41
|
'minLength',
|
|
46
42
|
'name',
|
|
47
43
|
'pattern',
|
|
@@ -49,6 +45,7 @@ function transformer(file, api, options) {
|
|
|
49
45
|
'readOnly',
|
|
50
46
|
'required',
|
|
51
47
|
'value',
|
|
48
|
+
'form',
|
|
52
49
|
],
|
|
53
50
|
});
|
|
54
51
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
var RENAME_MAP = {
|
|
8
|
+
onClose: 'onClosed',
|
|
9
|
+
};
|
|
10
|
+
function transformer(file, api, options) {
|
|
11
|
+
var alias = options.alias;
|
|
12
|
+
var j = api.jscodeshift;
|
|
13
|
+
var source = j(file.source);
|
|
14
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Snackbar', alias).localName;
|
|
15
|
+
if (localName) {
|
|
16
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
17
|
+
}
|
|
18
|
+
return source.toSource();
|
|
19
|
+
}
|
|
@@ -32,7 +32,7 @@ function transformer(file, api, options) {
|
|
|
32
32
|
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
33
33
|
root: source,
|
|
34
34
|
componentName: localName,
|
|
35
|
-
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value'],
|
|
35
|
+
excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value', 'form'],
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
return source.toSource();
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
5
|
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
var moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
|
|
6
7
|
var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
|
|
7
8
|
exports.parser = 'tsx';
|
|
8
9
|
function transformer(file, api, options) {
|
|
@@ -28,6 +29,23 @@ function transformer(file, api, options) {
|
|
|
28
29
|
componentName: localName,
|
|
29
30
|
slotName: 'textArea',
|
|
30
31
|
});
|
|
32
|
+
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
33
|
+
root: source,
|
|
34
|
+
componentName: localName,
|
|
35
|
+
slotName: 'textArea',
|
|
36
|
+
excludedProps: [
|
|
37
|
+
'autoComplete',
|
|
38
|
+
'disabled',
|
|
39
|
+
'maxLength',
|
|
40
|
+
'minLength',
|
|
41
|
+
'name',
|
|
42
|
+
'placeholder',
|
|
43
|
+
'readOnly',
|
|
44
|
+
'required',
|
|
45
|
+
'value',
|
|
46
|
+
'form',
|
|
47
|
+
],
|
|
48
|
+
});
|
|
31
49
|
}
|
|
32
50
|
return source.toSource();
|
|
33
51
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
5
|
var codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
var moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
|
|
6
7
|
var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
|
|
7
8
|
exports.parser = 'tsx';
|
|
8
9
|
function transformer(file, api, options) {
|
|
@@ -28,6 +29,23 @@ function transformer(file, api, options) {
|
|
|
28
29
|
componentName: localName,
|
|
29
30
|
slotName: 'textArea',
|
|
30
31
|
});
|
|
32
|
+
(0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
|
|
33
|
+
root: source,
|
|
34
|
+
componentName: localName,
|
|
35
|
+
slotName: 'textArea',
|
|
36
|
+
excludedProps: [
|
|
37
|
+
'autoComplete',
|
|
38
|
+
'disabled',
|
|
39
|
+
'maxLength',
|
|
40
|
+
'minLength',
|
|
41
|
+
'name',
|
|
42
|
+
'placeholder',
|
|
43
|
+
'readOnly',
|
|
44
|
+
'required',
|
|
45
|
+
'value',
|
|
46
|
+
'form',
|
|
47
|
+
],
|
|
48
|
+
});
|
|
31
49
|
}
|
|
32
50
|
return source.toSource();
|
|
33
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/vkui-codemods",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.2",
|
|
4
4
|
"description": "Codemods for automatic VKUI major version upgrade",
|
|
5
5
|
"repository": "https://github.com/VKCOM/VKUI",
|
|
6
6
|
"homepage": "https://vkui.io/",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"chalk": "^4.1.2",
|
|
18
|
-
"commander": "^14.0.
|
|
18
|
+
"commander": "^14.0.3",
|
|
19
19
|
"cross-spawn": "^7.0.5",
|
|
20
20
|
"jscodeshift": "^17.3.0",
|
|
21
21
|
"prompts": "^2.4.2",
|
|
22
22
|
"typescript": "^5.9.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@swc/core": "^1.
|
|
25
|
+
"@swc/core": "^1.15.11",
|
|
26
26
|
"@types/cross-spawn": "^6.0.6",
|
|
27
27
|
"@types/jscodeshift": "^17.3.0",
|
|
28
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^25.2.2",
|
|
29
29
|
"@types/prompts": "^2.4.9"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|