@react-spectrum/codemods 0.5.2 → 0.6.1

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 (51) hide show
  1. package/dist/index.js +0 -0
  2. package/dist/s1-to-s2/src/codemods/codemod.js +33 -25
  3. package/dist/s1-to-s2/src/codemods/components/ActionGroup/transform.js +164 -0
  4. package/dist/s1-to-s2/src/codemods/components/ActionMenu/transform.js +15 -0
  5. package/dist/s1-to-s2/src/codemods/components/Avatar/transform.js +77 -0
  6. package/dist/s1-to-s2/src/codemods/components/Badge/transform.js +17 -0
  7. package/dist/s1-to-s2/src/codemods/components/Breadcrumbs/transform.js +26 -0
  8. package/dist/s1-to-s2/src/codemods/components/Button/transform.js +45 -0
  9. package/dist/s1-to-s2/src/codemods/components/CheckboxGroup/transform.js +12 -0
  10. package/dist/s1-to-s2/src/codemods/components/ColorField/transform.js +26 -0
  11. package/dist/s1-to-s2/src/codemods/components/ColorSlider/transform.js +12 -0
  12. package/dist/s1-to-s2/src/codemods/components/Column/transform.js +12 -0
  13. package/dist/s1-to-s2/src/codemods/components/ComboBox/transform.js +29 -0
  14. package/dist/s1-to-s2/src/codemods/components/ContextualHelp/transform.js +15 -0
  15. package/dist/s1-to-s2/src/codemods/components/DialogContainer/transform.js +16 -0
  16. package/dist/s1-to-s2/src/codemods/components/DialogTrigger/transform.js +111 -0
  17. package/dist/s1-to-s2/src/codemods/components/Divider/transform.js +12 -0
  18. package/dist/s1-to-s2/src/codemods/components/Form/transform.js +21 -0
  19. package/dist/s1-to-s2/src/codemods/components/InlineAlert/transform.js +17 -0
  20. package/dist/s1-to-s2/src/codemods/components/Item/transform.js +25 -0
  21. package/dist/s1-to-s2/src/codemods/components/Link/transform.js +76 -0
  22. package/dist/s1-to-s2/src/codemods/components/NumberField/transform.js +23 -0
  23. package/dist/s1-to-s2/src/codemods/components/Picker/transform.js +33 -0
  24. package/dist/s1-to-s2/src/codemods/components/ProgressBar/transform.js +23 -0
  25. package/dist/s1-to-s2/src/codemods/components/ProgressCircle/transform.js +17 -0
  26. package/dist/s1-to-s2/src/codemods/components/RadioGroup/transform.js +23 -0
  27. package/dist/s1-to-s2/src/codemods/components/RangeSlider/transform.js +18 -0
  28. package/dist/s1-to-s2/src/codemods/components/Row/transform.js +111 -0
  29. package/dist/s1-to-s2/src/codemods/components/SearchField/transform.js +29 -0
  30. package/dist/s1-to-s2/src/codemods/components/Section/transform.js +37 -0
  31. package/dist/s1-to-s2/src/codemods/components/Slider/transform.js +24 -0
  32. package/dist/s1-to-s2/src/codemods/components/StatusLight/transform.js +20 -0
  33. package/dist/s1-to-s2/src/codemods/components/TableView/transform.js +189 -0
  34. package/dist/s1-to-s2/src/codemods/components/Tabs/transform.js +116 -0
  35. package/dist/s1-to-s2/src/codemods/components/TagGroup/transform.js +27 -0
  36. package/dist/s1-to-s2/src/codemods/components/TextArea/transform.js +29 -0
  37. package/dist/s1-to-s2/src/codemods/components/TextField/transform.js +29 -0
  38. package/dist/s1-to-s2/src/codemods/components/Tooltip/transform.js +29 -0
  39. package/dist/s1-to-s2/src/codemods/components/TooltipTrigger/transform.js +15 -0
  40. package/dist/s1-to-s2/src/codemods/{styleProps.js → shared/styleProps.js} +22 -9
  41. package/dist/s1-to-s2/src/codemods/shared/transforms.js +608 -0
  42. package/dist/s1-to-s2/src/codemods/{unsafeStyle.js → shared/unsafeStyle.js} +1 -1
  43. package/dist/s1-to-s2/src/codemods/{utils.js → shared/utils.js} +26 -16
  44. package/package.json +6 -6
  45. package/dist/s1-to-s2/src/codemods/button.js +0 -52
  46. package/dist/s1-to-s2/src/codemods/changes.js +0 -1260
  47. package/dist/s1-to-s2/src/codemods/dialog.js +0 -63
  48. package/dist/s1-to-s2/src/codemods/transforms.js +0 -1043
  49. /package/dist/s1-to-s2/src/{iconMap.js → codemods/icons/iconMap.js} +0 -0
  50. /package/dist/s1-to-s2/src/codemods/{colors.js → shared/colors.js} +0 -0
  51. /package/dist/s1-to-s2/src/codemods/{dimensions.js → shared/dimensions.js} +0 -0
package/dist/index.js CHANGED
File without changes
@@ -15,27 +15,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.default = transformer;
30
40
  /* eslint-disable max-depth */
31
- const utils_1 = require("./utils");
32
- const changes_1 = require("./changes");
33
- const transforms_1 = require("./transforms");
41
+ const utils_1 = require("./shared/utils");
34
42
  const getComponents_1 = require("../getComponents");
35
- const iconMap_1 = require("../iconMap");
43
+ const iconMap_1 = require("./icons/iconMap");
36
44
  const recast_1 = require("recast");
37
45
  const t = __importStar(require("@babel/types"));
38
- const styleProps_1 = require("./styleProps");
46
+ const styleProps_1 = __importDefault(require("./shared/styleProps"));
39
47
  const traverse_1 = __importDefault(require("@babel/traverse"));
40
48
  // Determine list of available components in S2 from index.ts
41
49
  let availableComponents = (0, getComponents_1.getComponents)();
@@ -194,7 +202,7 @@ function transformer(file, api, options) {
194
202
  return;
195
203
  }
196
204
  try {
197
- let res = (0, styleProps_1.transformStyleProps)(path, elementName);
205
+ let res = (0, styleProps_1.default)(path, elementName);
198
206
  if (res) {
199
207
  hasMacros || (hasMacros = res.hasMacros);
200
208
  usedLightDark || (usedLightDark = res.usedLightDark);
@@ -203,19 +211,19 @@ function transformer(file, api, options) {
203
211
  catch (error) {
204
212
  (0, utils_1.addComment)(path.node, ' TODO(S2-upgrade): Could not transform style prop automatically: ' + error);
205
213
  }
206
- const componentInfo = changes_1.changes[elementName];
207
- if (!componentInfo) {
208
- return;
209
- }
210
- const { changes } = componentInfo;
211
- changes.forEach((change) => {
212
- const { function: functionInfo } = change;
213
- let { name: functionName, args: functionArgs } = functionInfo;
214
- // Call the respective transformation function
215
- if (transforms_1.functionMap[functionName]) {
216
- transforms_1.functionMap[functionName](path, functionArgs);
214
+ // Try to find a specific transform
215
+ try {
216
+ // Dynamically import the transform based on elementName
217
+ const transformPath = `./components/${elementName}/transform`;
218
+ // Use require for dynamic import in CommonJS context
219
+ const componentTransform = require(transformPath);
220
+ if (componentTransform && typeof componentTransform.default === 'function') {
221
+ componentTransform.default(path);
217
222
  }
218
- });
223
+ }
224
+ catch {
225
+ // Do nothing if the transform doesn't exist
226
+ }
219
227
  });
220
228
  if (hasMacros) {
221
229
  let specifiers = [t.importSpecifier(t.identifier('style'), t.identifier('style'))];
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = transformActionGroup;
37
+ const utils_1 = require("../../shared/utils");
38
+ const transforms_1 = require("../../shared/transforms");
39
+ const getComponents_1 = require("../../../getComponents");
40
+ const t = __importStar(require("@babel/types"));
41
+ let availableComponents = (0, getComponents_1.getComponents)();
42
+ /**
43
+ * Transforms ActionGroup:
44
+ * - Comment out overflowMode (it has not been implemented yet).
45
+ * - Comment out buttonLabelBehavior (it has not been implemented yet).
46
+ * - Comment out summaryIcon (it has not been implemented yet).
47
+ * - Use ActionButtonGroup if no selection.
48
+ * - Use ToggleButtonGroup if selection is used.
49
+ * - Update root level onAction to onPress on each ActionButton.
50
+ * - Apply isDisabled directly on each ActionButton/ToggleButton instead of disabledKeys.
51
+ * - Convert dynamic collections render function to items.map.
52
+ */
53
+ function transformActionGroup(path) {
54
+ // Comment out overflowMode
55
+ (0, transforms_1.commentOutProp)(path, { propName: 'overflowMode' });
56
+ // Comment out buttonLabelBehavior
57
+ (0, transforms_1.commentOutProp)(path, { propName: 'buttonLabelBehavior' });
58
+ // Comment out summaryIcon
59
+ (0, transforms_1.commentOutProp)(path, { propName: 'summaryIcon' });
60
+ let selectionModePath = path.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'selectionMode');
61
+ let selectionMode = t.isStringLiteral(selectionModePath?.node.value) ? selectionModePath.node.value.value : 'none';
62
+ let newComponentName, childComponentName;
63
+ if (selectionMode === 'none') {
64
+ // Use ActionButtonGroup if no selection
65
+ newComponentName = 'ActionButtonGroup';
66
+ childComponentName = 'ActionButton';
67
+ selectionModePath?.remove();
68
+ }
69
+ else {
70
+ // Use ToggleButtonGroup if selection is used
71
+ newComponentName = 'ToggleButtonGroup';
72
+ childComponentName = 'ToggleButton';
73
+ }
74
+ let localName = newComponentName;
75
+ if (availableComponents.has(newComponentName)) {
76
+ let program = path.findParent((p) => t.isProgram(p.node));
77
+ localName = (0, utils_1.addComponentImport)(program, newComponentName);
78
+ }
79
+ let localChildName = childComponentName;
80
+ if (availableComponents.has(childComponentName)) {
81
+ let program = path.findParent((p) => t.isProgram(p.node));
82
+ localChildName = (0, utils_1.addComponentImport)(program, childComponentName);
83
+ }
84
+ // Convert dynamic collection to an array.map.
85
+ let items = path.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'items');
86
+ let itemArg;
87
+ if (items && t.isJSXExpressionContainer(items.node.value) && t.isExpression(items.node.value.expression)) {
88
+ let child = path.get('children').find(c => c.isJSXExpressionContainer());
89
+ if (child && child.isJSXExpressionContainer() && t.isFunction(child.node.expression)) {
90
+ let arg = child.node.expression.params[0];
91
+ if (t.isIdentifier(arg)) {
92
+ itemArg = arg;
93
+ }
94
+ child.replaceWith(t.jsxExpressionContainer(t.callExpression(t.memberExpression(items.node.value.expression, t.identifier('map')), [child.node.expression])));
95
+ }
96
+ }
97
+ items?.remove();
98
+ let onAction = path.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'onAction');
99
+ // Pull disabledKeys prop out into a variable, converted to a Set.
100
+ // Then we can check it in the isDisabled prop of each item.
101
+ let disabledKeysPath = path.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'disabledKeys');
102
+ let disabledKeys;
103
+ if (disabledKeysPath && t.isJSXExpressionContainer(disabledKeysPath.node.value) && t.isExpression(disabledKeysPath.node.value.expression)) {
104
+ disabledKeys = path.scope.generateUidIdentifier('disabledKeys');
105
+ path.scope.push({
106
+ id: disabledKeys,
107
+ init: t.newExpression(t.identifier('Set'), [disabledKeysPath.node.value.expression]),
108
+ kind: 'let'
109
+ });
110
+ disabledKeysPath.remove();
111
+ }
112
+ path.traverse({
113
+ JSXElement(child) {
114
+ if (t.isJSXIdentifier(child.node.openingElement.name) && child.node.openingElement.name.name === 'Item') {
115
+ // Replace Item with ActionButton or ToggleButton.
116
+ let childNode = t.cloneNode(child.node);
117
+ childNode.openingElement.name = t.jsxIdentifier(localChildName);
118
+ if (childNode.closingElement) {
119
+ childNode.closingElement.name = t.jsxIdentifier(localChildName);
120
+ }
121
+ // If there is no key prop and we are using dynamic collections, add a default computed from item.key ?? item.id.
122
+ let key = childNode.openingElement.attributes.find(attr => t.isJSXAttribute(attr) && attr.name.name === 'key');
123
+ if (!key && itemArg) {
124
+ let id = t.jsxExpressionContainer(t.logicalExpression('??', t.memberExpression(itemArg, t.identifier('key')), t.memberExpression(itemArg, t.identifier('id'))));
125
+ key = t.jsxAttribute(t.jsxIdentifier('key'), id);
126
+ childNode.openingElement.attributes.push(key);
127
+ }
128
+ // If this is a ToggleButtonGroup, add an id prop in addition to key when needed.
129
+ if (key && newComponentName === 'ToggleButtonGroup') {
130
+ // If we are in an array.map we need both key and id. Otherwise, we only need id.
131
+ if (itemArg) {
132
+ childNode.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('id'), key.value));
133
+ }
134
+ else {
135
+ key.name.name = 'id';
136
+ }
137
+ }
138
+ let keyValue = undefined;
139
+ if (key && t.isJSXExpressionContainer(key.value) && t.isExpression(key.value.expression)) {
140
+ keyValue = key.value.expression;
141
+ }
142
+ else if (key && t.isStringLiteral(key.value)) {
143
+ keyValue = key.value;
144
+ }
145
+ // Add an onPress to each item that calls the previous onAction, passing in the key.
146
+ if (onAction && t.isJSXExpressionContainer(onAction.node.value) && t.isExpression(onAction.node.value.expression)) {
147
+ childNode.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('onPress'), t.jsxExpressionContainer(keyValue
148
+ ? t.arrowFunctionExpression([], t.callExpression(onAction.node.value.expression, [keyValue]))
149
+ : onAction.node.value.expression)));
150
+ }
151
+ // Add an isDisabled prop to each item, testing whether it is in disabledKeys.
152
+ if (disabledKeys && keyValue) {
153
+ childNode.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('isDisabled'), t.jsxExpressionContainer(t.callExpression(t.memberExpression(disabledKeys, t.identifier('has')), [keyValue]))));
154
+ }
155
+ child.replaceWith(childNode);
156
+ }
157
+ }
158
+ });
159
+ onAction?.remove();
160
+ path.node.openingElement.name = t.jsxIdentifier(localName);
161
+ if (path.node.closingElement) {
162
+ path.node.closingElement.name = t.jsxIdentifier(localName);
163
+ }
164
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformActionMenu;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms ActionMenu:
7
+ * - Comment out closeOnSelect (it has not been implemented yet).
8
+ * - Comment out trigger (it has not been implemented yet).
9
+ */
10
+ function transformActionMenu(path) {
11
+ // Comment out closeOnSelect
12
+ (0, transforms_1.commentOutProp)(path, { propName: 'closeOnSelect' });
13
+ // Comment out trigger
14
+ (0, transforms_1.commentOutProp)(path, { propName: 'trigger' });
15
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = transformAvatar;
37
+ const transforms_1 = require("../../shared/transforms");
38
+ const utils_1 = require("../../shared/utils");
39
+ const t = __importStar(require("@babel/types"));
40
+ function updateAvatarSize(path) {
41
+ if (t.isJSXElement(path.node) &&
42
+ t.isJSXIdentifier(path.node.openingElement.name) &&
43
+ (0, utils_1.getName)(path, path.node.openingElement.name) === 'Avatar') {
44
+ let sizeAttrPath = path.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'size');
45
+ if (sizeAttrPath) {
46
+ let value = sizeAttrPath.node.value;
47
+ if (value?.type === 'StringLiteral') {
48
+ const avatarDimensions = {
49
+ 'avatar-size-50': 16,
50
+ 'avatar-size-75': 18,
51
+ 'avatar-size-100': 20,
52
+ 'avatar-size-200': 22,
53
+ 'avatar-size-300': 26,
54
+ 'avatar-size-400': 28,
55
+ 'avatar-size-500': 32,
56
+ 'avatar-size-600': 36,
57
+ 'avatar-size-700': 40
58
+ };
59
+ let val = avatarDimensions[value.value];
60
+ if (val != null) {
61
+ sizeAttrPath.node.value = t.jsxExpressionContainer(t.numericLiteral(val));
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * Transforms Avatar:
69
+ * - Comment out isDisabled (it has not been implemented yet).
70
+ * - Update size to be a pixel value if it currently matches 'avatar-size-*'.
71
+ */
72
+ function transformAvatar(path) {
73
+ // Comment out isDisabled
74
+ (0, transforms_1.commentOutProp)(path, { propName: 'isDisabled' });
75
+ // Update size to be a pixel value if it currently matches 'avatar-size-*'
76
+ updateAvatarSize(path);
77
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformBadge;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms Badge:
7
+ * - Change variant="info" to variant="informative".
8
+ */
9
+ function transformBadge(path) {
10
+ // Change variant="info" to variant="informative"
11
+ (0, transforms_1.updatePropNameAndValue)(path, {
12
+ oldPropName: 'variant',
13
+ oldPropValue: 'info',
14
+ newPropName: 'variant',
15
+ newPropValue: 'informative'
16
+ });
17
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformBreadcrumbs;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms Breadcrumbs:
7
+ * - Comment out showRoot (it has not been implemented yet).
8
+ * - Comment out isMultiline (it has not been implemented yet).
9
+ * - Comment out autoFocusCurrent (it has not been implemented yet).
10
+ * - Remove size="S" (Small is no longer a supported size in Spectrum 2).
11
+ * - Add comment to wrap in nav element if needed.
12
+ */
13
+ function transformBreadcrumbs(path) {
14
+ // Comment out showRoot
15
+ (0, transforms_1.commentOutProp)(path, { propName: 'showRoot' });
16
+ // Comment out isMultiline
17
+ (0, transforms_1.commentOutProp)(path, { propName: 'isMultiline' });
18
+ // Comment out autoFocusCurrent
19
+ (0, transforms_1.commentOutProp)(path, { propName: 'autoFocusCurrent' });
20
+ // Remove size="S"
21
+ (0, transforms_1.removeProp)(path, { propName: 'size', propValue: 'S' });
22
+ // Add comment to wrap in nav element if needed
23
+ (0, transforms_1.addCommentToElement)(path, {
24
+ comment: 'S2 Breadcrumbs no longer includes a nav element by default. You can wrap the Breadcrumbs component in a nav element if needed.'
25
+ });
26
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformButton;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms Button:
7
+ * - Change variant="cta" to variant="accent"
8
+ * - Change variant="overBackground" to variant="primary" staticColor="white"
9
+ * - Change style to fillStyle
10
+ * - Remove isQuiet (it is no longer supported in Spectrum 2)
11
+ * - If href is present, the Button should be converted to a LinkButton
12
+ * - Remove elementType (it is no longer supported in Spectrum 2).
13
+ */
14
+ function transformButton(path) {
15
+ // Change variant="cta" to variant="accent"
16
+ (0, transforms_1.updatePropNameAndValue)(path, {
17
+ oldPropName: 'variant',
18
+ oldPropValue: 'cta',
19
+ newPropName: 'variant',
20
+ newPropValue: 'accent'
21
+ });
22
+ // Change variant="overBackground" to variant="primary" staticColor="white"
23
+ (0, transforms_1.updatePropValueAndAddNewPropName)(path, {
24
+ oldPropName: 'variant',
25
+ oldPropValue: 'overBackground',
26
+ newPropName: 'variant',
27
+ newPropValue: 'primary',
28
+ additionalPropName: 'staticColor',
29
+ additionalPropValue: 'white'
30
+ });
31
+ // Change style to fillStyle
32
+ (0, transforms_1.updatePropName)(path, {
33
+ oldPropName: 'style',
34
+ newPropName: 'fillStyle'
35
+ });
36
+ // Remove isQuiet
37
+ (0, transforms_1.removeProp)(path, { propName: 'isQuiet' });
38
+ // If href is present, the Button should be converted to a LinkButton
39
+ (0, transforms_1.updateComponentIfPropPresent)(path, {
40
+ propName: 'href',
41
+ newComponentName: 'LinkButton'
42
+ });
43
+ // Remove elementType
44
+ (0, transforms_1.removeProp)(path, { propName: 'elementType' });
45
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformCheckboxGroup;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms CheckboxGroup:
7
+ * - Remove showErrorIcon (it has been removed due to accessibility issues).
8
+ */
9
+ function transformCheckboxGroup(path) {
10
+ // Remove showErrorIcon
11
+ (0, transforms_1.removeProp)(path, { propName: 'showErrorIcon' });
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformColorField;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms ColorField:
7
+ * - Remove isQuiet (it is no longer supported in Spectrum 2).
8
+ * - Remove placeholder (it has been removed due to accessibility issues).
9
+ * - Change validationState="invalid" to isInvalid.
10
+ * - Remove validationState="valid" (it is no longer supported in Spectrum 2).
11
+ */
12
+ function transformColorField(path) {
13
+ // Remove isQuiet
14
+ (0, transforms_1.removeProp)(path, { propName: 'isQuiet' });
15
+ // Remove placeholder
16
+ (0, transforms_1.removeProp)(path, { propName: 'placeholder' });
17
+ // Change validationState="invalid" to isInvalid
18
+ (0, transforms_1.updatePropNameAndValue)(path, {
19
+ oldPropName: 'validationState',
20
+ oldPropValue: 'invalid',
21
+ newPropName: 'isInvalid',
22
+ newPropValue: true
23
+ });
24
+ // Remove validationState="valid"
25
+ (0, transforms_1.removeProp)(path, { propName: 'validationState', propValue: 'valid' });
26
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformColorSlider;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms ColorSlider:
7
+ * - Remove showValueLabel (it has been removed due to accessibility issues).
8
+ */
9
+ function transformColorSlider(path) {
10
+ // Remove showValueLabel
11
+ (0, transforms_1.removeProp)(path, { propName: 'showValueLabel' });
12
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformColumn;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms Column:
7
+ * - Update key to id.
8
+ */
9
+ function transformColumn(path) {
10
+ // Update key to id
11
+ (0, transforms_1.updateKeyToId)(path);
12
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformComboBox;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms ComboBox:
7
+ * - Change menuWidth value from a DimensionValue to a pixel value.
8
+ * - Remove isQuiet (it is no longer supported in Spectrum 2).
9
+ * - Remove placeholder (it is no longer supported in Spectrum 2).
10
+ * - Change validationState="invalid" to isInvalid.
11
+ * - Remove validationState="valid" (it is no longer supported in Spectrum 2).
12
+ */
13
+ function transformComboBox(path) {
14
+ // Change menuWidth value from a DimensionValue to a pixel value
15
+ (0, transforms_1.convertDimensionValueToPx)(path, { propName: 'menuWidth' });
16
+ // Remove isQuiet
17
+ (0, transforms_1.removeProp)(path, { propName: 'isQuiet' });
18
+ // Remove placeholder
19
+ (0, transforms_1.removeProp)(path, { propName: 'placeholder' });
20
+ // Change validationState="invalid" to isInvalid
21
+ (0, transforms_1.updatePropNameAndValue)(path, {
22
+ oldPropName: 'validationState',
23
+ oldPropValue: 'invalid',
24
+ newPropName: 'isInvalid',
25
+ newPropValue: true
26
+ });
27
+ // Remove validationState="valid"
28
+ (0, transforms_1.removeProp)(path, { propName: 'validationState', propValue: 'valid' });
29
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformContextualHelp;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms ContextualHelp:
7
+ * - Comment out variant="info" (informative variant is the only one supported).
8
+ * - Update placement prop to have only one value (e.g., "bottom left" becomes "bottom").
9
+ */
10
+ function transformContextualHelp(path) {
11
+ // Comment out variant="info"
12
+ (0, transforms_1.commentOutProp)(path, { propName: 'variant', propValue: 'info' });
13
+ // Update placement prop to have only one value
14
+ (0, transforms_1.updatePlacementToSingleValue)(path, { propToUpdateName: 'placement' });
15
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformDialogContainer;
4
+ const transform_1 = require("../DialogTrigger/transform");
5
+ const transforms_1 = require("../../shared/transforms");
6
+ /**
7
+ * Transforms DialogContainer:
8
+ * - Remove type (dependent on the dialog level child used, e.g., Dialog, FullscreenDialog, Popover).
9
+ * - Move isDismissable (as isDismissible) to the dialog level component.
10
+ * - Move isKeyboardDismissDisabled to the dialog level component.
11
+ */
12
+ function transformDialogContainer(path) {
13
+ // Move isDismissable (as isDismissible) to the dialog level component
14
+ (0, transforms_1.updatePropName)(path, { oldPropName: 'isDismissable', newPropName: 'isDismissible' });
15
+ (0, transform_1.updateDialogChild)(path);
16
+ }