@vkontakte/vkui-codemods 1.1.0-beta.2 → 1.1.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/dist/autoDetectVKUIVersion.js +16 -24
- package/dist/cli.js +97 -160
- package/dist/codemod-helpers.js +41 -43
- package/dist/getAvailableCodemods.js +13 -14
- package/dist/helpers/logger.js +17 -17
- package/dist/index.js +76 -147
- package/dist/report.js +4 -4
- package/dist/testHelpers/testHelper.js +17 -88
- package/dist/transforms/v6/accordion.js +10 -10
- package/dist/transforms/v6/action-sheet-item.js +5 -5
- package/dist/transforms/v6/action-sheet.js +15 -15
- package/dist/transforms/v6/alert.js +14 -14
- package/dist/transforms/v6/appearance-provider.js +8 -10
- package/dist/transforms/v6/banner.js +10 -10
- package/dist/transforms/v6/calendar-range.js +6 -6
- package/dist/transforms/v6/calendar.js +6 -6
- package/dist/transforms/v6/card-scroll.js +5 -5
- package/dist/transforms/v6/chip.js +6 -6
- package/dist/transforms/v6/chips-input.js +6 -6
- package/dist/transforms/v6/config-provider.js +20 -20
- package/dist/transforms/v6/content-card.js +7 -7
- package/dist/transforms/v6/custom-scroll-view.js +11 -13
- package/dist/transforms/v6/date-input.js +6 -6
- package/dist/transforms/v6/date-range-input.js +6 -6
- package/dist/transforms/v6/fixed-layout.js +11 -11
- package/dist/transforms/v6/forbid-imports.js +8 -8
- package/dist/transforms/v6/form-item.js +9 -9
- package/dist/transforms/v6/form-layout.js +10 -10
- package/dist/transforms/v6/gallery.js +5 -5
- package/dist/transforms/v6/gradient-prop-change.js +12 -12
- package/dist/transforms/v6/horizontal-cell-show-more.js +7 -11
- package/dist/transforms/v6/image-base.js +7 -7
- package/dist/transforms/v6/modal-card.js +16 -18
- package/dist/transforms/v6/modal-page-header.js +11 -11
- package/dist/transforms/v6/pagination.js +12 -12
- package/dist/transforms/v6/panel-header-content.js +10 -10
- package/dist/transforms/v6/panel-header.js +11 -11
- package/dist/transforms/v6/placeholder.js +5 -5
- package/dist/transforms/v6/popout-wrapper.js +9 -9
- package/dist/transforms/v6/popover.js +45 -54
- package/dist/transforms/v6/popper.js +35 -44
- package/dist/transforms/v6/range-slider.js +14 -25
- package/dist/transforms/v6/rich-tooltip.js +10 -10
- package/dist/transforms/v6/search.js +6 -6
- package/dist/transforms/v6/select.js +7 -7
- package/dist/transforms/v6/simple-cell.js +13 -15
- package/dist/transforms/v6/split-col.js +9 -9
- package/dist/transforms/v6/tabbar.js +5 -5
- package/dist/transforms/v6/tappable.js +13 -15
- package/dist/transforms/v6/text-tooltip.js +47 -58
- package/dist/transforms/v6/tooltip-container.js +14 -14
- package/dist/transforms/v6/tooltip.js +63 -72
- package/dist/transforms/v6/typography.js +19 -21
- package/dist/transforms/v6/users-stack.js +13 -13
- package/dist/transforms/v6/visually-hidden-input.js +13 -24
- package/dist/transforms/v7/action-sheet.js +5 -5
- package/dist/transforms/v7/alert.js +5 -5
- package/dist/transforms/v7/appearance-provider.js +12 -12
- package/dist/transforms/v7/appearance.js +16 -16
- package/dist/transforms/v7/banner.js +13 -14
- package/dist/transforms/v7/calendar.js +5 -5
- package/dist/transforms/v7/card-grid.js +5 -5
- package/dist/transforms/v7/card-scroll.js +17 -18
- package/dist/transforms/v7/cell-button.js +13 -13
- package/dist/transforms/v7/cell.js +5 -5
- package/dist/transforms/v7/chips-select.js +8 -8
- package/dist/transforms/v7/common/moveFromChildrenToLabel.js +19 -21
- package/dist/transforms/v7/common/remapSizePropValue.js +14 -16
- package/dist/transforms/v7/common/removeChildrenFromComponent.js +6 -6
- package/dist/transforms/v7/common/swapGapPropElements.js +7 -7
- package/dist/transforms/v7/config-provider.js +32 -36
- package/dist/transforms/v7/content-card.js +5 -5
- package/dist/transforms/v7/counter.js +12 -12
- package/dist/transforms/v7/custom-scroll-view.js +8 -8
- package/dist/transforms/v7/custom-select.js +8 -8
- package/dist/transforms/v7/date-picker.js +8 -8
- package/dist/transforms/v7/flex.js +6 -6
- package/dist/transforms/v7/form-item.js +29 -35
- package/dist/transforms/v7/form-status.js +5 -5
- package/dist/transforms/v7/header.js +21 -21
- package/dist/transforms/v7/horizontal-cell-show-more.js +16 -19
- package/dist/transforms/v7/horizontal-cell.js +5 -5
- package/dist/transforms/v7/horizontal-scroll.js +12 -12
- package/dist/transforms/v7/image-overlay.js +30 -32
- package/dist/transforms/v7/mini-info-cell.js +5 -5
- package/dist/transforms/v7/modal-card.js +7 -7
- package/dist/transforms/v7/onboarding-tooltip.js +5 -5
- package/dist/transforms/v7/panel-header-back.js +6 -6
- package/dist/transforms/v7/panel-header-close.js +6 -6
- package/dist/transforms/v7/panel-header-content.js +5 -5
- package/dist/transforms/v7/panel-header-edit.js +6 -6
- package/dist/transforms/v7/panel-header-submit.js +6 -6
- package/dist/transforms/v7/panel-spinner.js +10 -10
- package/dist/transforms/v7/placeholder.js +5 -5
- package/dist/transforms/v7/rich-cell.js +5 -5
- package/dist/transforms/v7/screen-spinner.js +7 -7
- package/dist/transforms/v7/scroll-arrow.js +20 -23
- package/dist/transforms/v7/select.js +8 -8
- package/dist/transforms/v7/separator.js +6 -6
- package/dist/transforms/v7/simple-cell.js +5 -5
- package/dist/transforms/v7/simple-grid.js +6 -6
- package/dist/transforms/v7/spacing.js +9 -9
- package/dist/transforms/v7/spinner.js +9 -9
- package/dist/transforms/v7/subnavigation-bar.js +10 -10
- package/dist/transforms/v7/subnavigation-button.js +5 -5
- package/dist/transforms/v7/tabbar-item.js +5 -5
- package/dist/transforms/v7/tooltip.js +5 -5
- package/dist/transforms/v7/typography.js +16 -17
- package/dist/transforms/v7/users-stack.js +13 -13
- package/dist/transforms/v8/action-sheet.js +6 -6
- package/dist/transforms/v8/alert.js +5 -5
- package/dist/transforms/v8/checkbox.js +12 -12
- package/dist/transforms/v8/chips-input.js +7 -7
- package/dist/transforms/v8/chips-select.js +7 -7
- package/dist/transforms/v8/common/moveAllPropsIntoSlotProp.js +6 -16
- package/dist/transforms/v8/common/moveInputPropsIntoSlotProps.js +8 -8
- package/dist/transforms/v8/common/movePropIntoSlotProps.js +44 -63
- package/dist/transforms/v8/custom-select.js +7 -7
- package/dist/transforms/v8/file.js +7 -7
- package/dist/transforms/v8/input.js +8 -7
- package/dist/transforms/v8/native-select.js +7 -7
- package/dist/transforms/v8/popout-wrapper.js +12 -12
- package/dist/transforms/v8/radio.js +12 -12
- package/dist/transforms/v8/rich-cell.js +11 -11
- package/dist/transforms/v8/search.js +8 -7
- package/dist/transforms/v8/select.js +7 -7
- package/dist/transforms/v8/snackbar.js +6 -6
- package/dist/transforms/v8/split-layout.js +7 -7
- package/dist/transforms/v8/switch.js +7 -7
- package/dist/transforms/v8/text-area.js +7 -7
- package/dist/transforms/v8/write-bar.js +7 -7
- package/package.json +6 -5
|
@@ -5,32 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parser = void 0;
|
|
7
7
|
exports.default = transformer;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
10
|
+
const report_1 = require("../../report");
|
|
11
11
|
exports.parser = 'tsx';
|
|
12
12
|
function transformer(file, api, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const { alias } = options;
|
|
14
|
+
const j = api.jscodeshift;
|
|
15
|
+
const source = j(file.source);
|
|
16
|
+
const { localName: localNameModalCard } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCard', alias);
|
|
17
|
+
const { localName: localNameModalCardBase } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCardBase', alias);
|
|
18
|
+
const localNamesForChange = [];
|
|
19
19
|
if (localNameModalCard) {
|
|
20
20
|
localNamesForChange.push(localNameModalCard);
|
|
21
21
|
}
|
|
22
22
|
if (localNameModalCardBase) {
|
|
23
23
|
localNamesForChange.push(localNameModalCardBase);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const modalCards = source
|
|
26
26
|
.find(j.JSXOpeningElement)
|
|
27
|
-
.filter(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var headerAttribute = j(path).find(j.JSXAttribute, { name: { name: 'header' } });
|
|
33
|
-
var subheaderAttribute = j(path).find(j.JSXAttribute, { name: { name: 'subheader' } });
|
|
27
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' &&
|
|
28
|
+
localNamesForChange.includes(path.value.name.name));
|
|
29
|
+
modalCards.forEach((path) => {
|
|
30
|
+
const headerAttribute = j(path).find(j.JSXAttribute, { name: { name: 'header' } });
|
|
31
|
+
const subheaderAttribute = j(path).find(j.JSXAttribute, { name: { name: 'subheader' } });
|
|
34
32
|
if (subheaderAttribute.length > 0) {
|
|
35
33
|
if (path.node.attributes) {
|
|
36
34
|
path.node.attributes.push(j.jsxAttribute(j.jsxIdentifier('subheaderComponent'), j.stringLiteral('h5')));
|
|
@@ -43,7 +41,7 @@ function transformer(file, api, options) {
|
|
|
43
41
|
}
|
|
44
42
|
});
|
|
45
43
|
if (modalCards.size() > 0) {
|
|
46
|
-
(0, report_1.report)(api,
|
|
44
|
+
(0, report_1.report)(api, `: ${chalk_1.default.white.bgBlue('ModalCard')} and ${chalk_1.default.white.bgBlue('ModalCardBase')} might need 'Spacing' now. Manual changes required.`);
|
|
47
45
|
}
|
|
48
46
|
return source.toSource();
|
|
49
47
|
}
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const { alias } = options;
|
|
9
|
+
const j = api.jscodeshift;
|
|
10
|
+
const source = j(file.source);
|
|
11
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalPageHeader', alias);
|
|
12
12
|
if (!localName) {
|
|
13
13
|
return source.toSource();
|
|
14
14
|
}
|
|
15
15
|
source
|
|
16
|
-
.find(j.JSXOpeningElement,
|
|
17
|
-
.forEach(
|
|
18
|
-
|
|
16
|
+
.find(j.JSXOpeningElement, (element) => element.name.type === 'JSXIdentifier' && element.name.name === localName)
|
|
17
|
+
.forEach((element) => {
|
|
18
|
+
const attributes = element.value.attributes;
|
|
19
19
|
if (attributes) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const getRefIndex = attributes.findIndex((attribute) => attribute.type === 'JSXAttribute' && attribute.name.name === 'getRef');
|
|
21
|
+
const getRootRefIndex = attributes.findIndex((attribute) => attribute.type === 'JSXAttribute' && attribute.name.name === 'getRootRef');
|
|
22
22
|
if (getRefIndex !== -1 && getRootRefIndex === -1) {
|
|
23
|
-
|
|
23
|
+
const attribute = attributes[getRefIndex];
|
|
24
24
|
if (attribute.type === 'JSXAttribute') {
|
|
25
25
|
attribute.name.name = 'getRootRef';
|
|
26
26
|
}
|
|
@@ -5,30 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parser = void 0;
|
|
7
7
|
exports.default = transformer;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
10
|
+
const report_1 = require("../../report");
|
|
11
11
|
exports.parser = 'tsx';
|
|
12
|
-
|
|
12
|
+
const RENAME_MAP = {
|
|
13
13
|
prevButtonAriaLabel: 'prevButtonLabel',
|
|
14
14
|
nextButtonAriaLabel: 'nextButtonLabel',
|
|
15
15
|
};
|
|
16
16
|
function transformer(file, api, options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const { alias } = options;
|
|
18
|
+
const j = api.jscodeshift;
|
|
19
|
+
const source = j(file.source);
|
|
20
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Pagination', alias);
|
|
21
21
|
if (!localName) {
|
|
22
22
|
return source.toSource();
|
|
23
23
|
}
|
|
24
24
|
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
25
25
|
source
|
|
26
26
|
.find(j.JSXOpeningElement)
|
|
27
|
-
.filter(
|
|
27
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
|
|
28
28
|
.find(j.JSXAttribute)
|
|
29
|
-
.filter(
|
|
30
|
-
.forEach(
|
|
31
|
-
(0, report_1.report)(api,
|
|
29
|
+
.filter((attribute) => attribute.node.name.name === 'getPageAriaLabel')
|
|
30
|
+
.forEach(() => {
|
|
31
|
+
(0, report_1.report)(api, `: ${chalk_1.default.white.bgBlue('getPageAriaLabel')} prop in ${chalk_1.default.white.bgBlue('Pagination')} component is no longer available. Manual changes required.`);
|
|
32
32
|
});
|
|
33
33
|
return source.toSource();
|
|
34
34
|
}
|
|
@@ -5,21 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parser = void 0;
|
|
7
7
|
exports.default = transformer;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
10
|
+
const report_1 = require("../../report");
|
|
11
11
|
exports.parser = 'tsx';
|
|
12
12
|
function transformer(file, api, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const { alias } = options;
|
|
14
|
+
const j = api.jscodeshift;
|
|
15
|
+
const source = j(file.source);
|
|
16
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'PanelHeader', alias);
|
|
17
17
|
if (!localName) {
|
|
18
18
|
return source.toSource();
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const elements = source.find(j.JSXOpeningElement).filter((path) => {
|
|
21
21
|
if (path.value.name.type === 'JSXMemberExpression') {
|
|
22
|
-
|
|
22
|
+
const property = path.value.name;
|
|
23
23
|
if (property.object.type === 'JSXIdentifier' &&
|
|
24
24
|
property.object.name === localName &&
|
|
25
25
|
property.property.name === 'Content') {
|
|
@@ -29,7 +29,7 @@ function transformer(file, api, options) {
|
|
|
29
29
|
return false;
|
|
30
30
|
});
|
|
31
31
|
if (elements.size() > 0) {
|
|
32
|
-
(0, report_1.report)(api,
|
|
32
|
+
(0, report_1.report)(api, `: ${chalk_1.default.white.bgBlue('<PanelHeader.Content>')} is no longer available. Manual changes required.`);
|
|
33
33
|
}
|
|
34
34
|
return source.toSource();
|
|
35
35
|
}
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
const report_1 = require("../../report");
|
|
7
7
|
exports.parser = 'tsx';
|
|
8
8
|
function transformer(file, api, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const { alias } = options;
|
|
10
|
+
const j = api.jscodeshift;
|
|
11
|
+
const source = j(file.source);
|
|
12
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'PanelHeader', alias);
|
|
13
13
|
if (!localName) {
|
|
14
14
|
return source.toSource();
|
|
15
15
|
}
|
|
16
16
|
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'visor', 'float');
|
|
17
17
|
source
|
|
18
|
-
.find(j.JSXOpeningElement,
|
|
19
|
-
.find(j.JSXAttribute,
|
|
20
|
-
.forEach(
|
|
21
|
-
|
|
18
|
+
.find(j.JSXOpeningElement, (element) => element.name.type === 'JSXIdentifier' && element.name.name === localName)
|
|
19
|
+
.find(j.JSXAttribute, (attribute) => attribute.name.name === 'separator')
|
|
20
|
+
.forEach((attribute) => {
|
|
21
|
+
const node = attribute.node;
|
|
22
22
|
if (!node.value) {
|
|
23
23
|
j(attribute).remove();
|
|
24
24
|
}
|
|
@@ -32,7 +32,7 @@ function transformer(file, api, options) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
(0, report_1.report)(api,
|
|
35
|
+
(0, report_1.report)(api, `Manual changes required for PanelHeader's separator prop.`);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
return source.toSource();
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
exports.default = transformer;
|
|
5
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const { alias } = options;
|
|
9
|
+
const j = api.jscodeshift;
|
|
10
|
+
const source = j(file.source);
|
|
11
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Placeholder', alias);
|
|
12
12
|
if (localName) {
|
|
13
13
|
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'withPadding', 'noPadding');
|
|
14
14
|
}
|
|
@@ -5,21 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parser = void 0;
|
|
7
7
|
exports.default = transformer;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
10
|
+
const report_1 = require("../../report");
|
|
11
11
|
exports.parser = 'tsx';
|
|
12
12
|
function transformer(file, api, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const { alias } = options;
|
|
14
|
+
const j = api.jscodeshift;
|
|
15
|
+
const source = j(file.source);
|
|
16
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'PopoutWrapper', alias);
|
|
17
17
|
if (!localName) {
|
|
18
18
|
return source.toSource();
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const components = source.find(j.JSXOpeningElement, (element) => element.name.type === 'JSXIdentifier' && element.name.name === localName);
|
|
21
21
|
if (components.size() > 0) {
|
|
22
|
-
(0, report_1.report)(api,
|
|
22
|
+
(0, report_1.report)(api, `: When using ${chalk_1.default.white.bgBlue('PopoutWrapper')} you might need to apply useScrollLock() hook manually.`);
|
|
23
23
|
}
|
|
24
24
|
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'hasMask', 'noBackground');
|
|
25
25
|
return source.toSource();
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.parser = void 0;
|
|
5
4
|
exports.default = transformer;
|
|
6
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
7
6
|
exports.parser = 'tsx';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const componentName = 'unstable_Popover';
|
|
8
|
+
const componentNameTo = 'Popover';
|
|
9
|
+
const ATTRIBUTE_MANIPULATOR = {
|
|
11
10
|
action: {
|
|
12
11
|
keyTo: 'trigger',
|
|
13
12
|
},
|
|
@@ -18,101 +17,93 @@ var ATTRIBUTE_MANIPULATOR = {
|
|
|
18
17
|
keyTo: 'offsetByCrossAxis',
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const FORCE_PORTAL = 'forcePortal';
|
|
21
|
+
const COMPLEX_ATTRIBUTE_MANIPULATOR = {
|
|
22
|
+
[FORCE_PORTAL]: {
|
|
24
23
|
keyTo: 'usePortal',
|
|
25
24
|
},
|
|
26
|
-
|
|
25
|
+
portalRoot: {
|
|
27
26
|
keyTo: 'usePortal',
|
|
28
27
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
};
|
|
29
|
+
const LEGACY_SHOWN_DELAY_PROP = 'shownDelay';
|
|
30
|
+
const LEGACY_HIDE_DELAY_PROP = 'hideDelay';
|
|
31
|
+
const NEW_HOVER_DELAY_PROP = 'hoverDelay';
|
|
33
32
|
function transformer(file, api, options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const { alias } = options;
|
|
34
|
+
const j = api.jscodeshift;
|
|
35
|
+
const source = j(file.source);
|
|
36
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias);
|
|
37
|
+
const attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_MANIPULATOR, api);
|
|
39
38
|
if (!localName) {
|
|
40
39
|
return source.toSource();
|
|
41
40
|
}
|
|
42
41
|
source
|
|
43
42
|
.find(j.ImportDeclaration)
|
|
44
|
-
.filter(
|
|
43
|
+
.filter((path) => path.node.source.value === alias)
|
|
45
44
|
.find(j.ImportSpecifier, { imported: { name: componentName } })
|
|
46
|
-
.forEach(
|
|
47
|
-
return j(path).replaceWith(function (path) {
|
|
48
|
-
return j.importSpecifier(j.identifier(componentNameTo), path.node.local);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
45
|
+
.forEach((path) => j(path).replaceWith((path) => j.importSpecifier(j.identifier(componentNameTo), path.node.local)));
|
|
51
46
|
source
|
|
52
47
|
.find(j.JSXOpeningElement)
|
|
53
|
-
.filter(
|
|
54
|
-
.find(j.JSXAttribute,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
var attributeName = attribute.node.name.name;
|
|
59
|
-
var foundFix = attributeReplacer.getReplacers(attributeName);
|
|
48
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
|
|
49
|
+
.find(j.JSXAttribute, (attribute) => typeof attribute.name.name === 'string' ? attributeReplacer.has(attribute.name.name) : false)
|
|
50
|
+
.forEach((attribute) => {
|
|
51
|
+
const attributeName = attribute.node.name.name;
|
|
52
|
+
const foundFix = attributeReplacer.getReplacers(attributeName);
|
|
60
53
|
if (foundFix && foundFix.action !== 'remove') {
|
|
61
|
-
|
|
54
|
+
const value = attribute.node.value;
|
|
62
55
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(foundFix.keyTo()), foundFix.valueTo(value)));
|
|
63
56
|
}
|
|
64
57
|
});
|
|
65
|
-
|
|
66
|
-
source.findJSXElements(localName).forEach(
|
|
58
|
+
const complexAttributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(COMPLEX_ATTRIBUTE_MANIPULATOR, api);
|
|
59
|
+
source.findJSXElements(localName).forEach((element) => {
|
|
67
60
|
j(element)
|
|
68
|
-
.find(j.JSXAttribute,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.forEach(function (attribute, _, attributes) {
|
|
74
|
-
var attributeName = attribute.node.name.name;
|
|
61
|
+
.find(j.JSXAttribute, (attribute) => typeof attribute.name.name === 'string'
|
|
62
|
+
? complexAttributeReplacer.has(attribute.name.name)
|
|
63
|
+
: false)
|
|
64
|
+
.forEach((attribute, _, attributes) => {
|
|
65
|
+
const attributeName = attribute.node.name.name;
|
|
75
66
|
if (attributes.length === 2 && attributeName === FORCE_PORTAL) {
|
|
76
67
|
j(attribute).remove();
|
|
77
68
|
}
|
|
78
69
|
else {
|
|
79
|
-
|
|
70
|
+
const foundFix = complexAttributeReplacer.getReplacers(attributeName);
|
|
80
71
|
if (foundFix && foundFix.action !== 'remove') {
|
|
81
|
-
|
|
72
|
+
const value = attribute.node.value;
|
|
82
73
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(foundFix.keyTo()), foundFix.valueTo(value)));
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
76
|
});
|
|
86
77
|
// разрешаем hoverDelay
|
|
87
|
-
|
|
88
|
-
j(element).find(j.JSXAttribute,
|
|
89
|
-
j(element).find(j.JSXAttribute,
|
|
90
|
-
]
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
attributeCollection.find(j.NumericLiteral).forEach(
|
|
78
|
+
const [shownDelayAttr, hideDelayAttr] = [
|
|
79
|
+
j(element).find(j.JSXAttribute, (attribute) => attribute.name.name === LEGACY_SHOWN_DELAY_PROP),
|
|
80
|
+
j(element).find(j.JSXAttribute, (attribute) => attribute.name.name === LEGACY_HIDE_DELAY_PROP),
|
|
81
|
+
];
|
|
82
|
+
const getNumericLiteral = (attributeCollection) => {
|
|
83
|
+
let val;
|
|
84
|
+
attributeCollection.find(j.NumericLiteral).forEach((attribute) => {
|
|
94
85
|
val = attribute.node;
|
|
95
86
|
});
|
|
96
87
|
return val ? val : j.numericLiteral(0);
|
|
97
88
|
};
|
|
98
89
|
if (shownDelayAttr.length === 1 && hideDelayAttr.length === 0) {
|
|
99
|
-
shownDelayAttr.forEach(
|
|
90
|
+
shownDelayAttr.forEach((attribute) => {
|
|
100
91
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(NEW_HOVER_DELAY_PROP), j.jsxExpressionContainer(getNumericLiteral(shownDelayAttr))));
|
|
101
92
|
});
|
|
102
93
|
}
|
|
103
94
|
else if (shownDelayAttr.length === 0 && hideDelayAttr.length === 1) {
|
|
104
|
-
hideDelayAttr.forEach(
|
|
95
|
+
hideDelayAttr.forEach((attribute) => {
|
|
105
96
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(NEW_HOVER_DELAY_PROP), j.jsxExpressionContainer(j.arrayExpression([j.numericLiteral(0), getNumericLiteral(hideDelayAttr)]))));
|
|
106
97
|
});
|
|
107
98
|
}
|
|
108
99
|
else if (shownDelayAttr.length === 1 && hideDelayAttr.length === 1) {
|
|
109
|
-
shownDelayAttr.forEach(
|
|
100
|
+
shownDelayAttr.forEach((attribute) => {
|
|
110
101
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(NEW_HOVER_DELAY_PROP), j.jsxExpressionContainer(j.arrayExpression([
|
|
111
102
|
getNumericLiteral(shownDelayAttr),
|
|
112
103
|
getNumericLiteral(hideDelayAttr),
|
|
113
104
|
]))));
|
|
114
105
|
});
|
|
115
|
-
hideDelayAttr.forEach(
|
|
106
|
+
hideDelayAttr.forEach((attribute) => {
|
|
116
107
|
j(attribute).remove();
|
|
117
108
|
});
|
|
118
109
|
}
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.parser = void 0;
|
|
8
7
|
exports.default = transformer;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
11
10
|
exports.parser = 'tsx';
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const componentName = 'unstable_Popper';
|
|
12
|
+
const ATTRIBUTE_MANIPULATOR = {
|
|
14
13
|
offsetDistance: {
|
|
15
14
|
keyTo: 'offsetByMainAxis',
|
|
16
15
|
},
|
|
@@ -19,76 +18,68 @@ var ATTRIBUTE_MANIPULATOR = {
|
|
|
19
18
|
},
|
|
20
19
|
renderContent: {
|
|
21
20
|
keyTo: 'children',
|
|
22
|
-
reportText:
|
|
23
|
-
return ": ".concat(chalk_1.default.white.bgBlue('children'), " prop in ").concat(chalk_1.default.white.bgBlue('Popper'), ". You should unwraps function manually");
|
|
24
|
-
},
|
|
21
|
+
reportText: () => `: ${chalk_1.default.white.bgBlue('children')} prop in ${chalk_1.default.white.bgBlue('Popper')}. You should unwraps function manually`,
|
|
25
22
|
},
|
|
26
23
|
arrowClassName: {
|
|
27
24
|
keyTo: 'arrowProps',
|
|
28
|
-
valueTo:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
: v;
|
|
34
|
-
},
|
|
25
|
+
valueTo: (v, api) => v
|
|
26
|
+
? api.jscodeshift.jsxExpressionContainer(api.jscodeshift.objectExpression([
|
|
27
|
+
api.jscodeshift.property('init', api.jscodeshift.identifier('iconClassName'), v),
|
|
28
|
+
]))
|
|
29
|
+
: v,
|
|
35
30
|
},
|
|
36
31
|
onPlacementChange: {
|
|
37
32
|
keyTo: 'onPlacementChange',
|
|
38
|
-
reportText:
|
|
39
|
-
return ": ".concat(chalk_1.default.white.bgBlue('onPlacementChange'), " prop in ").concat(chalk_1.default.white.bgBlue('Popper'), ". You should move function params from object to array arguments manually.");
|
|
40
|
-
},
|
|
33
|
+
reportText: () => `: ${chalk_1.default.white.bgBlue('onPlacementChange')} prop in ${chalk_1.default.white.bgBlue('Popper')}. You should move function params from object to array arguments manually.`,
|
|
41
34
|
},
|
|
42
35
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
const FORCE_PORTAL = 'forcePortal';
|
|
37
|
+
const COMPLEX_ATTRIBUTE_MANIPULATOR = {
|
|
38
|
+
[FORCE_PORTAL]: {
|
|
46
39
|
keyTo: 'usePortal',
|
|
47
40
|
},
|
|
48
|
-
|
|
41
|
+
portalRoot: {
|
|
49
42
|
keyTo: 'usePortal',
|
|
50
43
|
},
|
|
51
|
-
|
|
44
|
+
};
|
|
52
45
|
function transformer(file, api, options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
const { alias } = options;
|
|
47
|
+
const j = api.jscodeshift;
|
|
48
|
+
const source = j(file.source);
|
|
49
|
+
const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias);
|
|
50
|
+
const attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_MANIPULATOR, api);
|
|
58
51
|
if (!localName) {
|
|
59
52
|
return source.toSource();
|
|
60
53
|
}
|
|
61
54
|
source
|
|
62
55
|
.find(j.ImportDeclaration)
|
|
63
|
-
.filter(
|
|
56
|
+
.filter((path) => path.node.source.value === alias)
|
|
64
57
|
.find(j.ImportSpecifier, { imported: { name: componentName } })
|
|
65
|
-
.forEach(
|
|
66
|
-
return j(path).replaceWith(function (path) { return j.importSpecifier(j.identifier('Popper'), path.node.local); });
|
|
67
|
-
});
|
|
58
|
+
.forEach((path) => j(path).replaceWith((path) => j.importSpecifier(j.identifier('Popper'), path.node.local)));
|
|
68
59
|
source
|
|
69
60
|
.find(j.JSXOpeningElement)
|
|
70
|
-
.filter(
|
|
71
|
-
.find(j.JSXAttribute,
|
|
72
|
-
.forEach(
|
|
73
|
-
|
|
61
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
|
|
62
|
+
.find(j.JSXAttribute, (attribute) => attributeReplacer.has(attribute.name.name))
|
|
63
|
+
.forEach((attribute) => {
|
|
64
|
+
const foundFix = attributeReplacer.getReplacers(attribute.node.name.name);
|
|
74
65
|
if (foundFix && foundFix.action !== 'remove') {
|
|
75
|
-
|
|
66
|
+
const value = attribute.node.value;
|
|
76
67
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(foundFix.keyTo()), foundFix.valueTo(value)));
|
|
77
68
|
}
|
|
78
69
|
});
|
|
79
|
-
|
|
80
|
-
source.findJSXElements(localName).forEach(
|
|
70
|
+
const complexAttributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(COMPLEX_ATTRIBUTE_MANIPULATOR, api);
|
|
71
|
+
source.findJSXElements(localName).forEach((element) => {
|
|
81
72
|
j(element)
|
|
82
|
-
.find(j.JSXAttribute,
|
|
83
|
-
.forEach(
|
|
84
|
-
|
|
73
|
+
.find(j.JSXAttribute, (attribute) => complexAttributeReplacer.has(attribute.name.name))
|
|
74
|
+
.forEach((attribute, _, attributes) => {
|
|
75
|
+
const attributeName = attribute.node.name.name;
|
|
85
76
|
if (attributes.length === 2 && attributeName === FORCE_PORTAL) {
|
|
86
77
|
j(attribute).remove();
|
|
87
78
|
}
|
|
88
79
|
else {
|
|
89
|
-
|
|
80
|
+
const foundFix = complexAttributeReplacer.getReplacers(attributeName);
|
|
90
81
|
if (foundFix && foundFix.action !== 'remove') {
|
|
91
|
-
|
|
82
|
+
const value = attribute.node.value;
|
|
92
83
|
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(foundFix.keyTo()), foundFix.valueTo(value)));
|
|
93
84
|
}
|
|
94
85
|
}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.parser = void 0;
|
|
13
4
|
exports.default = transformer;
|
|
14
5
|
exports.parser = 'tsx';
|
|
15
6
|
function transformer(file, api, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const { alias } = options;
|
|
8
|
+
const j = api.jscodeshift;
|
|
9
|
+
const source = j(file.source);
|
|
10
|
+
let localImportName = 'RangeSlider';
|
|
11
|
+
let needRename = true;
|
|
12
|
+
const componentImport = source
|
|
22
13
|
.find(j.ImportDeclaration)
|
|
23
|
-
.filter(
|
|
14
|
+
.filter((path) => path.node.source.value === alias)
|
|
24
15
|
.find(j.ImportSpecifier, { imported: { name: 'RangeSlider' } });
|
|
25
16
|
if (componentImport.length === 0) {
|
|
26
17
|
return source.toSource();
|
|
27
18
|
}
|
|
28
|
-
|
|
19
|
+
const sliderImport = source
|
|
29
20
|
.find(j.ImportDeclaration)
|
|
30
|
-
.filter(
|
|
21
|
+
.filter((path) => path.node.source.value === alias)
|
|
31
22
|
.find(j.ImportSpecifier, { imported: { name: 'Slider' } });
|
|
32
|
-
componentImport.forEach(
|
|
23
|
+
componentImport.forEach((path) => {
|
|
33
24
|
if (path.node.local &&
|
|
34
25
|
path.node.local.name !== path.node.imported.name &&
|
|
35
26
|
typeof path.node.local.name === 'string') {
|
|
@@ -40,15 +31,13 @@ function transformer(file, api, options) {
|
|
|
40
31
|
j(path).remove();
|
|
41
32
|
}
|
|
42
33
|
else {
|
|
43
|
-
j(path).replaceWith(
|
|
44
|
-
return j.importSpecifier(j.identifier('Slider'), needRename ? null : path.node.local);
|
|
45
|
-
});
|
|
34
|
+
j(path).replaceWith((path) => j.importSpecifier(j.identifier('Slider'), needRename ? null : path.node.local));
|
|
46
35
|
}
|
|
47
36
|
});
|
|
48
|
-
source.findJSXElements(localImportName).replaceWith(
|
|
37
|
+
source.findJSXElements(localImportName).replaceWith((path) => {
|
|
49
38
|
localImportName = needRename ? 'Slider' : localImportName;
|
|
50
|
-
|
|
51
|
-
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localImportName),
|
|
39
|
+
const props = path.node.openingElement.attributes;
|
|
40
|
+
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localImportName), [j.jsxAttribute(j.jsxIdentifier('multiple')), ...(props || [])], path.node.closingElement ? false : true), path.node.closingElement ? j.jsxClosingElement(j.jsxIdentifier(localImportName)) : null, path.node.children);
|
|
52
41
|
});
|
|
53
42
|
return source.toSource();
|
|
54
43
|
}
|