@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
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformUseAccentWeightAttribute;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
7
  function isJSXAttribute(attribute) {
8
- return (attribute === null || attribute === void 0 ? void 0 : attribute.type) === 'JSXAttribute';
8
+ return attribute?.type === 'JSXAttribute';
9
9
  }
10
10
  function removeAttribute(attributes, attribute) {
11
- attributes === null || attributes === void 0 ? void 0 : attributes.splice(attributes === null || attributes === void 0 ? void 0 : attributes.indexOf(attribute), 1);
11
+ attributes?.splice(attributes?.indexOf(attribute), 1);
12
12
  }
13
- var componentsToTransform = [
13
+ const componentsToTransform = [
14
14
  'Typography',
15
15
  'Caption',
16
16
  'DisplayTitle',
@@ -22,32 +22,31 @@ var componentsToTransform = [
22
22
  'Title',
23
23
  ];
24
24
  function transformUseAccentWeightAttribute(file, api, options) {
25
- var alias = options.alias;
26
- var j = api.jscodeshift;
27
- var source = j(file.source);
28
- componentsToTransform.forEach(function (componentName) {
29
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
25
+ const { alias } = options;
26
+ const j = api.jscodeshift;
27
+ const source = j(file.source);
28
+ componentsToTransform.forEach((componentName) => {
29
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias);
30
30
  if (!localName) {
31
31
  return;
32
32
  }
33
33
  source
34
34
  .find(j.JSXOpeningElement)
35
- .filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
35
+ .filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
36
36
  // useAccentWeight по умолчанию теперь false, поэтому, чтобы
37
37
  // пользователи продолжили использовать accent шрифты мы включим accent режим,
38
38
  // добавив useAccentWeight, если его нету.
39
39
  .forEach(function handleUseAccentWeightAttribute(path) {
40
- var _a, _b;
41
- var attributes = path.node.attributes;
40
+ const attributes = path.node.attributes;
42
41
  if (!attributes) {
43
42
  return;
44
43
  }
45
- var accentAttribute = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return isJSXAttribute(attr) && attr.name.name === 'useAccentWeight'; });
46
- var weightAttribute = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return isJSXAttribute(attr) && attr.name.name === 'weight'; });
44
+ const accentAttribute = attributes?.find((attr) => isJSXAttribute(attr) && attr.name.name === 'useAccentWeight');
45
+ const weightAttribute = attributes?.find((attr) => isJSXAttribute(attr) && attr.name.name === 'weight');
47
46
  // weight задан и не равен `undefined`
48
- var hasDefinedWeightAttribute = Boolean(weightAttribute &&
47
+ const hasDefinedWeightAttribute = Boolean(weightAttribute &&
49
48
  weightAttribute.type === 'JSXAttribute' &&
50
- !(((_a = weightAttribute.value) === null || _a === void 0 ? void 0 : _a.type) === 'JSXExpressionContainer' &&
49
+ !(weightAttribute.value?.type === 'JSXExpressionContainer' &&
51
50
  weightAttribute.value.expression.type === 'Identifier' &&
52
51
  weightAttribute.value.expression.name === 'undefined'));
53
52
  // есть weight и нету useAccentWeight: нужно добавить
@@ -62,7 +61,7 @@ function transformUseAccentWeightAttribute(file, api, options) {
62
61
  removeAttribute(attributes, accentAttribute);
63
62
  return;
64
63
  }
65
- if (((_b = accentAttribute.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer' &&
64
+ if (accentAttribute.value?.type === 'JSXExpressionContainer' &&
66
65
  accentAttribute.value.expression.type === 'BooleanLiteral') {
67
66
  // useAccentWeight={true} => useAccentWeight
68
67
  if (accentAttribute.value.expression.value === true) {
@@ -2,20 +2,20 @@
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, 'UsersStack', 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, 'UsersStack', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
- var attributeToReplace = 'direction';
17
- var newAttributeName = 'avatarsPosition';
18
- var directionToAvatarsPosition = {
16
+ const attributeToReplace = 'direction';
17
+ const newAttributeName = 'avatarsPosition';
18
+ const directionToAvatarsPosition = {
19
19
  'row': 'inline-start',
20
20
  'row-reverse': 'inline-end',
21
21
  'column': 'block-start',
@@ -23,12 +23,12 @@ function transformer(file, api, options) {
23
23
  source
24
24
  .find(j.JSXElement, { openingElement: { name: { name: localName } } })
25
25
  .find(j.JSXAttribute, { name: { name: attributeToReplace } })
26
- .forEach(function (path) {
27
- var avatar = path.node;
26
+ .forEach((path) => {
27
+ const avatar = path.node;
28
28
  avatar.name.name = newAttributeName;
29
- var value = (0, codemod_helpers_1.getStringValueFromAttribute)(avatar);
29
+ const value = (0, codemod_helpers_1.getStringValueFromAttribute)(avatar);
30
30
  if (!value || !directionToAvatarsPosition[value]) {
31
- (0, report_1.report)(api, ": ".concat(localName, " has been changed. Manual changes required: need to change direction prop to avatarsPosition."));
31
+ (0, report_1.report)(api, `: ${localName} has been changed. Manual changes required: need to change direction prop to avatarsPosition.`);
32
32
  return;
33
33
  }
34
34
  avatar.value = j.stringLiteral(directionToAvatarsPosition[value]);
@@ -2,16 +2,16 @@
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
- var RENAME_MAP = {
7
+ const RENAME_MAP = {
8
8
  onClose: 'onClosed',
9
9
  };
10
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;
11
+ const { alias } = options;
12
+ const j = api.jscodeshift;
13
+ const source = j(file.source);
14
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ActionSheet', alias);
15
15
  if (localName) {
16
16
  (0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
17
17
  }
@@ -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, 'Alert', 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, 'Alert', alias);
12
12
  if (!localName) {
13
13
  return source.toSource();
14
14
  }
@@ -2,37 +2,37 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Checkbox', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Checkbox', alias);
14
14
  if (localName) {
15
- [localName, "".concat(localName, ".Input")].forEach(function (componentName) {
15
+ [localName, `${localName}.Input`].forEach((componentName) => {
16
16
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
17
17
  root: source,
18
- componentName: componentName,
18
+ componentName,
19
19
  propName: 'getRef',
20
20
  slotName: 'input',
21
21
  slotPropName: 'getRootRef',
22
22
  });
23
23
  (0, movePropIntoSlotProps_1.moveDataAttrsIntoSlotProps)(j, {
24
24
  root: source,
25
- componentName: componentName,
25
+ componentName,
26
26
  slotName: 'input',
27
27
  });
28
28
  (0, movePropIntoSlotProps_1.moveAriaAttrsIntoSlotProps)(j, {
29
29
  root: source,
30
- componentName: componentName,
30
+ componentName,
31
31
  slotName: 'input',
32
32
  });
33
33
  (0, moveInputPropsIntoSlotProps_1.moveInputPropsIntoSlotProps)(j, {
34
34
  root: source,
35
- componentName: componentName,
35
+ componentName,
36
36
  excludedProps: ['checked', 'disabled', 'readOnly', 'required', 'name', 'value', 'form'],
37
37
  });
38
38
  });
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsInput', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsInput', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,
@@ -1,23 +1,13 @@
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.moveAllPropsIntoSlotProp = moveAllPropsIntoSlotProp;
13
- var movePropIntoSlotProps_1 = require("./movePropIntoSlotProps");
14
- function moveAllPropsIntoSlotProp(j, _a) {
15
- var root = _a.root, componentName = _a.componentName, slotName = _a.slotName, excludedProps = _a.excludedProps;
4
+ const movePropIntoSlotProps_1 = require("./movePropIntoSlotProps");
5
+ function moveAllPropsIntoSlotProp(j, { root, componentName, slotName, excludedProps }) {
16
6
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
17
- root: root,
18
- componentName: componentName,
19
- slotName: slotName,
7
+ root,
8
+ componentName,
9
+ slotName,
20
10
  propName: /.+/,
21
- excludedProps: __spreadArray(__spreadArray([], (excludedProps || []), true), ['slotProps'], false),
11
+ excludedProps: [...(excludedProps || []), 'slotProps'],
22
12
  });
23
13
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moveInputPropsIntoSlotProps = moveInputPropsIntoSlotProps;
4
- var movePropIntoSlotProps_1 = require("./movePropIntoSlotProps");
5
- var INPUT_SPECIFIC_PROPS = [
4
+ const movePropIntoSlotProps_1 = require("./movePropIntoSlotProps");
5
+ const INPUT_SPECIFIC_PROPS = [
6
6
  'accept',
7
7
  'alt',
8
8
  'autoComplete',
@@ -24,6 +24,7 @@ var INPUT_SPECIFIC_PROPS = [
24
24
  'multiple',
25
25
  'name',
26
26
  'pattern',
27
+ 'enterKeyHint',
27
28
  'placeholder',
28
29
  'readOnly',
29
30
  'required',
@@ -44,13 +45,12 @@ var INPUT_SPECIFIC_PROPS = [
44
45
  'onKeyUp',
45
46
  'onKeyUpCapture',
46
47
  ];
47
- function moveInputPropsIntoSlotProps(j, _a) {
48
- var root = _a.root, componentName = _a.componentName, excludedProps = _a.excludedProps, _b = _a.slotName, slotName = _b === void 0 ? 'input' : _b;
48
+ function moveInputPropsIntoSlotProps(j, { root, componentName, excludedProps, slotName = 'input' }) {
49
49
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
50
- root: root,
51
- componentName: componentName,
50
+ root,
51
+ componentName,
52
52
  propName: INPUT_SPECIFIC_PROPS,
53
- excludedProps: excludedProps,
54
- slotName: slotName,
53
+ excludedProps,
54
+ slotName,
55
55
  });
56
56
  }
@@ -1,21 +1,12 @@
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.movePropIntoSlotProps = movePropIntoSlotProps;
13
4
  exports.moveDataAttrsIntoSlotProps = moveDataAttrsIntoSlotProps;
14
5
  exports.moveAriaAttrsIntoSlotProps = moveAriaAttrsIntoSlotProps;
15
6
  function assignObject(j, options) {
16
- var target = options.target, expression = options.expression, key = options.key;
7
+ const { target, expression, key } = options;
17
8
  if (target && target.type === 'JSXAttribute') {
18
- var expContainer = target.value;
9
+ const expContainer = target.value;
19
10
  if (expContainer.expression.type === 'ObjectExpression') {
20
11
  // case `<prop>={{ ... }}`
21
12
  expContainer.expression.properties.push(j.objectProperty(j.identifier(key), expression));
@@ -30,12 +21,11 @@ function assignObject(j, options) {
30
21
  }
31
22
  }
32
23
  function appendAttribute(j, options) {
33
- var _a;
34
- var target = options.target, attributeName = options.attributeName, expression = options.expression;
35
- (_a = target.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.push(j.jsxAttribute(j.jsxIdentifier(attributeName), j.jsxExpressionContainer(expression)));
24
+ const { target, attributeName, expression } = options;
25
+ target.openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier(attributeName), j.jsxExpressionContainer(expression)));
36
26
  }
37
27
  function findComponentJSX(j, root, componentName, callback) {
38
- var _a = componentName.split('.'), component = _a[0], subcomponent = _a[1];
28
+ const [component, subcomponent] = componentName.split('.');
39
29
  if (subcomponent) {
40
30
  root
41
31
  .find(j.JSXElement, {
@@ -54,17 +44,17 @@ function findComponentJSX(j, root, componentName, callback) {
54
44
  }
55
45
  }
56
46
  function moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName) {
57
- var attributes = element.openingElement.attributes;
58
- var propIndex = attributes === null || attributes === void 0 ? void 0 : attributes.findIndex(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === propName; });
47
+ const attributes = element.openingElement.attributes;
48
+ const propIndex = attributes?.findIndex((attr) => attr.type === 'JSXAttribute' && attr.name.name === propName);
59
49
  if (!attributes || propIndex === -1 || propIndex === undefined) {
60
50
  return;
61
51
  }
62
- var removedAttr = attributes === null || attributes === void 0 ? void 0 : attributes.splice(propIndex, 1)[0];
63
- if ((removedAttr === null || removedAttr === void 0 ? void 0 : removedAttr.type) !== 'JSXAttribute') {
52
+ const removedAttr = attributes?.splice(propIndex, 1)[0];
53
+ if (removedAttr?.type !== 'JSXAttribute') {
64
54
  return;
65
55
  }
66
- var removedValue = (function () {
67
- if (!(removedAttr === null || removedAttr === void 0 ? void 0 : removedAttr.value)) {
56
+ const removedValue = (() => {
57
+ if (!removedAttr?.value) {
68
58
  return j.literal(true);
69
59
  }
70
60
  switch (removedAttr.value.type) {
@@ -79,27 +69,21 @@ function moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName)
79
69
  if (removedValue === undefined) {
80
70
  return;
81
71
  }
82
- var getSlotPropNameLiteral = function (name) {
83
- return name.includes('-') ? j.stringLiteral(name) : j.identifier(name);
84
- };
85
- var hasSlotProps = false;
86
- attributes.forEach(function (attr) {
87
- var _a, _b, _c, _d;
72
+ const getSlotPropNameLiteral = (name) => name.includes('-') ? j.stringLiteral(name) : j.identifier(name);
73
+ let hasSlotProps = false;
74
+ attributes.forEach((attr) => {
88
75
  if (attr.type === 'JSXAttribute' &&
89
- ((_a = attr.name) === null || _a === void 0 ? void 0 : _a.name) === 'slotProps' &&
90
- ((_b = attr.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer' &&
91
- ((_c = attr.value) === null || _c === void 0 ? void 0 : _c.expression.type) === 'ObjectExpression') {
76
+ attr.name?.name === 'slotProps' &&
77
+ attr.value?.type === 'JSXExpressionContainer' &&
78
+ attr.value?.expression.type === 'ObjectExpression') {
92
79
  hasSlotProps = true;
93
- var slots = (_d = attr.value) === null || _d === void 0 ? void 0 : _d.expression;
94
- var slotIndex = slots.properties.findIndex(function (prop) {
95
- var _a, _b;
96
- return prop.type === 'ObjectProperty' &&
97
- ((_a = prop === null || prop === void 0 ? void 0 : prop.key) === null || _a === void 0 ? void 0 : _a.type) === 'Identifier' &&
98
- ((_b = prop === null || prop === void 0 ? void 0 : prop.key) === null || _b === void 0 ? void 0 : _b.name) === slotName;
99
- });
80
+ const slots = attr.value?.expression;
81
+ const slotIndex = slots.properties.findIndex((prop) => prop.type === 'ObjectProperty' &&
82
+ prop?.key?.type === 'Identifier' &&
83
+ prop?.key?.name === slotName);
100
84
  if (slotIndex === -1) {
101
85
  // Создаем новый слот
102
- var slotValue = slotPropName
86
+ const slotValue = slotPropName
103
87
  ? j.objectExpression([
104
88
  j.objectProperty(getSlotPropNameLiteral(slotPropName), removedValue),
105
89
  ])
@@ -111,9 +95,9 @@ function moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName)
111
95
  });
112
96
  }
113
97
  else if (slots.properties[slotIndex].type === 'ObjectProperty') {
114
- var property = slots.properties[slotIndex];
98
+ const property = slots.properties[slotIndex];
115
99
  // Добавляем свойство в существующий слот
116
- var existingSlot = property.value;
100
+ const existingSlot = property.value;
117
101
  if (slotPropName) {
118
102
  if (existingSlot.type === 'ObjectExpression') {
119
103
  existingSlot.properties.push(j.objectProperty(getSlotPropNameLiteral(slotPropName), removedValue));
@@ -135,7 +119,7 @@ function moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName)
135
119
  });
136
120
  if (!hasSlotProps) {
137
121
  // Создаем slotsProps
138
- var slotValue = slotPropName
122
+ const slotValue = slotPropName
139
123
  ? j.objectExpression([j.objectProperty(getSlotPropNameLiteral(slotPropName), removedValue)])
140
124
  : removedValue;
141
125
  appendAttribute(j, {
@@ -146,29 +130,28 @@ function moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName)
146
130
  }
147
131
  }
148
132
  function moveMultipleJsxPropsIntoSlotProps(j, element, propName, slotName, excludedProps) {
149
- var attributes = element.openingElement.attributes;
133
+ const attributes = element.openingElement.attributes;
150
134
  if (!attributes) {
151
135
  return;
152
136
  }
153
- var checkMatch = function (attrName) {
137
+ const checkMatch = (attrName) => {
154
138
  return (((propName instanceof RegExp && propName.test(attrName)) ||
155
139
  (propName instanceof Array && propName.includes(attrName))) &&
156
- !(excludedProps === null || excludedProps === void 0 ? void 0 : excludedProps.includes(attrName)));
140
+ !excludedProps?.includes(attrName));
157
141
  };
158
- __spreadArray([], attributes, true).reverse()
159
- .forEach(function (attr) {
160
- return attr.type === 'JSXAttribute' &&
161
- typeof attr.name.name === 'string' &&
162
- checkMatch(attr.name.name) &&
163
- moveJsxPropIntoSlotProps(j, element, attr.name.name, slotName, attr.name.name);
164
- });
142
+ [...attributes]
143
+ .reverse()
144
+ .forEach((attr) => attr.type === 'JSXAttribute' &&
145
+ typeof attr.name.name === 'string' &&
146
+ checkMatch(attr.name.name) &&
147
+ moveJsxPropIntoSlotProps(j, element, attr.name.name, slotName, attr.name.name));
165
148
  }
166
149
  function moveJsxPropIntoSlotPropsByName(j, element, propName, slotName, slotPropName) {
167
150
  moveJsxPropIntoSlotProps(j, element, propName, slotName, slotPropName);
168
151
  }
169
152
  function movePropIntoSlotProps(j, options) {
170
- var propName = options.propName, slotName = options.slotName, slotPropName = options.slotPropName, root = options.root, componentName = options.componentName, excludedProps = options.excludedProps;
171
- findComponentJSX(j, root, componentName, function (elementPath) {
153
+ const { propName, slotName, slotPropName, root, componentName, excludedProps } = options;
154
+ findComponentJSX(j, root, componentName, (elementPath) => {
172
155
  if (typeof propName === 'string') {
173
156
  moveJsxPropIntoSlotPropsByName(j, elementPath.node, propName, slotName, slotPropName);
174
157
  }
@@ -177,21 +160,19 @@ function movePropIntoSlotProps(j, options) {
177
160
  }
178
161
  });
179
162
  }
180
- function moveDataAttrsIntoSlotProps(j, _a) {
181
- var root = _a.root, componentName = _a.componentName, slotName = _a.slotName;
163
+ function moveDataAttrsIntoSlotProps(j, { root, componentName, slotName }) {
182
164
  movePropIntoSlotProps(j, {
183
- root: root,
184
- componentName: componentName,
165
+ root,
166
+ componentName,
185
167
  propName: /data-.+/,
186
- slotName: slotName,
168
+ slotName,
187
169
  });
188
170
  }
189
- function moveAriaAttrsIntoSlotProps(j, _a) {
190
- var root = _a.root, componentName = _a.componentName, slotName = _a.slotName;
171
+ function moveAriaAttrsIntoSlotProps(j, { root, componentName, slotName }) {
191
172
  movePropIntoSlotProps(j, {
192
- root: root,
193
- componentName: componentName,
173
+ root,
174
+ componentName,
194
175
  propName: /aria-.+/,
195
- slotName: slotName,
176
+ slotName,
196
177
  });
197
178
  }
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomSelect', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomSelect', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'File', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'File', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Input', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Input', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,
@@ -43,6 +43,7 @@ function transformer(file, api, options) {
43
43
  'multiple',
44
44
  'name',
45
45
  'pattern',
46
+ 'enterKeyHint',
46
47
  'placeholder',
47
48
  'readOnly',
48
49
  'required',
@@ -2,15 +2,15 @@
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 moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
- var movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const moveInputPropsIntoSlotProps_1 = require("./common/moveInputPropsIntoSlotProps");
7
+ const movePropIntoSlotProps_1 = require("./common/movePropIntoSlotProps");
8
8
  exports.parser = 'tsx';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'NativeSelect', alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'NativeSelect', alias);
14
14
  if (localName) {
15
15
  (0, movePropIntoSlotProps_1.movePropIntoSlotProps)(j, {
16
16
  root: source,