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