@react-spectrum/codemods 0.5.1 → 0.6.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 (50) hide show
  1. package/dist/s1-to-s2/src/codemods/codemod.js +33 -25
  2. package/dist/s1-to-s2/src/codemods/components/ActionGroup/transform.js +164 -0
  3. package/dist/s1-to-s2/src/codemods/components/ActionMenu/transform.js +15 -0
  4. package/dist/s1-to-s2/src/codemods/components/Avatar/transform.js +77 -0
  5. package/dist/s1-to-s2/src/codemods/components/Badge/transform.js +17 -0
  6. package/dist/s1-to-s2/src/codemods/components/Breadcrumbs/transform.js +26 -0
  7. package/dist/s1-to-s2/src/codemods/components/Button/transform.js +45 -0
  8. package/dist/s1-to-s2/src/codemods/components/CheckboxGroup/transform.js +12 -0
  9. package/dist/s1-to-s2/src/codemods/components/ColorField/transform.js +26 -0
  10. package/dist/s1-to-s2/src/codemods/components/ColorSlider/transform.js +12 -0
  11. package/dist/s1-to-s2/src/codemods/components/Column/transform.js +12 -0
  12. package/dist/s1-to-s2/src/codemods/components/ComboBox/transform.js +29 -0
  13. package/dist/s1-to-s2/src/codemods/components/ContextualHelp/transform.js +15 -0
  14. package/dist/s1-to-s2/src/codemods/components/DialogContainer/transform.js +16 -0
  15. package/dist/s1-to-s2/src/codemods/components/DialogTrigger/transform.js +111 -0
  16. package/dist/s1-to-s2/src/codemods/components/Divider/transform.js +12 -0
  17. package/dist/s1-to-s2/src/codemods/components/Form/transform.js +21 -0
  18. package/dist/s1-to-s2/src/codemods/components/InlineAlert/transform.js +17 -0
  19. package/dist/s1-to-s2/src/codemods/components/Item/transform.js +25 -0
  20. package/dist/s1-to-s2/src/codemods/components/Link/transform.js +76 -0
  21. package/dist/s1-to-s2/src/codemods/components/NumberField/transform.js +23 -0
  22. package/dist/s1-to-s2/src/codemods/components/Picker/transform.js +33 -0
  23. package/dist/s1-to-s2/src/codemods/components/ProgressBar/transform.js +23 -0
  24. package/dist/s1-to-s2/src/codemods/components/ProgressCircle/transform.js +17 -0
  25. package/dist/s1-to-s2/src/codemods/components/RadioGroup/transform.js +23 -0
  26. package/dist/s1-to-s2/src/codemods/components/RangeSlider/transform.js +18 -0
  27. package/dist/s1-to-s2/src/codemods/components/Row/transform.js +111 -0
  28. package/dist/s1-to-s2/src/codemods/components/SearchField/transform.js +29 -0
  29. package/dist/s1-to-s2/src/codemods/components/Section/transform.js +37 -0
  30. package/dist/s1-to-s2/src/codemods/components/Slider/transform.js +24 -0
  31. package/dist/s1-to-s2/src/codemods/components/StatusLight/transform.js +20 -0
  32. package/dist/s1-to-s2/src/codemods/components/TableView/transform.js +189 -0
  33. package/dist/s1-to-s2/src/codemods/components/Tabs/transform.js +116 -0
  34. package/dist/s1-to-s2/src/codemods/components/TagGroup/transform.js +27 -0
  35. package/dist/s1-to-s2/src/codemods/components/TextArea/transform.js +29 -0
  36. package/dist/s1-to-s2/src/codemods/components/TextField/transform.js +29 -0
  37. package/dist/s1-to-s2/src/codemods/components/Tooltip/transform.js +29 -0
  38. package/dist/s1-to-s2/src/codemods/components/TooltipTrigger/transform.js +15 -0
  39. package/dist/s1-to-s2/src/codemods/{styleProps.js → shared/styleProps.js} +22 -9
  40. package/dist/s1-to-s2/src/codemods/shared/transforms.js +608 -0
  41. package/dist/s1-to-s2/src/codemods/{unsafeStyle.js → shared/unsafeStyle.js} +1 -1
  42. package/dist/s1-to-s2/src/codemods/{utils.js → shared/utils.js} +26 -16
  43. package/package.json +6 -6
  44. package/dist/s1-to-s2/src/codemods/button.js +0 -52
  45. package/dist/s1-to-s2/src/codemods/changes.js +0 -1260
  46. package/dist/s1-to-s2/src/codemods/dialog.js +0 -63
  47. package/dist/s1-to-s2/src/codemods/transforms.js +0 -1043
  48. /package/dist/s1-to-s2/src/{iconMap.js → codemods/icons/iconMap.js} +0 -0
  49. /package/dist/s1-to-s2/src/codemods/{colors.js → shared/colors.js} +0 -0
  50. /package/dist/s1-to-s2/src/codemods/{dimensions.js → shared/dimensions.js} +0 -0
@@ -0,0 +1,189 @@
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 = transformTable;
37
+ const utils_1 = require("../../shared/utils");
38
+ const transforms_1 = require("../../shared/transforms");
39
+ const t = __importStar(require("@babel/types"));
40
+ /**
41
+ * Copies the columns prop from the TableHeader to the Row component.
42
+ */
43
+ function addColumnsPropToRow(path) {
44
+ const tableHeaderPath = path.get('children').find((child) => t.isJSXElement(child.node) &&
45
+ t.isJSXIdentifier(child.node.openingElement.name) &&
46
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'TableHeader');
47
+ if (!tableHeaderPath) {
48
+ (0, utils_1.addComment)(path.node, ' TODO(S2-upgrade): Could not find TableHeader within Table to retrieve columns prop.');
49
+ return;
50
+ }
51
+ const columnsProp = tableHeaderPath
52
+ .get('openingElement')
53
+ .get('attributes')
54
+ .find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'columns');
55
+ if (columnsProp) {
56
+ path.traverse({
57
+ JSXElement(innerPath) {
58
+ if (t.isJSXElement(innerPath.node) &&
59
+ t.isJSXIdentifier(innerPath.node.openingElement.name) &&
60
+ (0, utils_1.getName)(innerPath, innerPath.node.openingElement.name) === 'Row') {
61
+ let rowPath = innerPath;
62
+ rowPath.node.openingElement.attributes.push(columnsProp.node);
63
+ // If Row doesn't contain id prop, leave a comment for the user to check manually
64
+ let idProp = rowPath.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'id');
65
+ if (!idProp) {
66
+ (0, utils_1.addComment)(rowPath.node, ' TODO(S2-upgrade): If the items do not have id properties, you\'ll need to add an id prop to the Row.');
67
+ }
68
+ }
69
+ }
70
+ });
71
+ }
72
+ }
73
+ function commentIfNestedColumns(path) {
74
+ const headerPath = path.get('children').find((child) => t.isJSXElement(child.node) &&
75
+ t.isJSXIdentifier(child.node.openingElement.name) &&
76
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'TableHeader');
77
+ const columns = headerPath?.get('children') || [];
78
+ let hasNestedColumns = false;
79
+ columns.forEach(column => {
80
+ let columnChildren = column.get('children');
81
+ if (columnChildren.find(child => t.isJSXElement(child.node) &&
82
+ t.isJSXIdentifier(child.node.openingElement.name) &&
83
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'Column')) {
84
+ hasNestedColumns = true;
85
+ }
86
+ });
87
+ if (hasNestedColumns) {
88
+ (0, utils_1.addComment)(path.node, ' TODO(S2-upgrade): Nested Column components are not supported yet.');
89
+ }
90
+ }
91
+ /**
92
+ * Adds isRowHeader to the first Column in a table if there isn't already a row header.
93
+ * @param path
94
+ */
95
+ function addRowHeader(path) {
96
+ let tableHeaderPath = path.get('children').find((child) => t.isJSXElement(child.node) &&
97
+ t.isJSXIdentifier(child.node.openingElement.name) &&
98
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'TableHeader');
99
+ // Check if isRowHeader is already set on a Column
100
+ let hasRowHeader = false;
101
+ tableHeaderPath?.get('children').forEach((child) => {
102
+ if (t.isJSXElement(child.node) &&
103
+ t.isJSXIdentifier(child.node.openingElement.name) &&
104
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'Column') {
105
+ let isRowHeaderProp = child.get('openingElement').get('attributes').find((attr) => t.isJSXAttribute(attr.node) && attr.node.name.name === 'isRowHeader');
106
+ if (isRowHeaderProp) {
107
+ hasRowHeader = true;
108
+ }
109
+ }
110
+ });
111
+ // If there isn't already a row header, add one to the first Column if possible
112
+ if (!hasRowHeader) {
113
+ tableHeaderPath?.get('children').forEach((child) => {
114
+ // Add to first Column if static
115
+ if (!hasRowHeader &&
116
+ t.isJSXElement(child.node) &&
117
+ t.isJSXIdentifier(child.node.openingElement.name) &&
118
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'Column') {
119
+ child.node.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('isRowHeader'), t.jsxExpressionContainer(t.booleanLiteral(true))));
120
+ hasRowHeader = true;
121
+ }
122
+ // If render function is used, leave a comment to update manually
123
+ if (t.isJSXExpressionContainer(child.node) &&
124
+ t.isArrowFunctionExpression(child.node.expression)) {
125
+ (0, utils_1.addComment)(child.node, ' TODO(S2-upgrade): You\'ll need to add isRowHeader to one of the columns manually.');
126
+ }
127
+ // If array.map is used, leave a comment to update manually
128
+ if (t.isJSXExpressionContainer(child.node) &&
129
+ t.isCallExpression(child.node.expression) &&
130
+ t.isMemberExpression(child.node.expression.callee) &&
131
+ t.isIdentifier(child.node.expression.callee.property) &&
132
+ child.node.expression.callee.property.name === 'map') {
133
+ (0, utils_1.addComment)(child.node, ' TODO(S2-upgrade): You\'ll need to add isRowHeader to one of the columns manually.');
134
+ }
135
+ });
136
+ }
137
+ }
138
+ /**
139
+ * Moves loadingState and onLoadMore from TableBody to TableView.
140
+ * @param path
141
+ */
142
+ function movePropsFromTableBodyToTableView(path) {
143
+ const tableBodyPath = path.get('children').find((child) => t.isJSXElement(child.node) &&
144
+ t.isJSXIdentifier(child.node.openingElement.name) &&
145
+ (0, utils_1.getName)(child, child.node.openingElement.name) === 'TableBody');
146
+ if (!tableBodyPath) {
147
+ return;
148
+ }
149
+ const propsToMove = ['loadingState', 'onLoadMore'];
150
+ const newAttributes = [];
151
+ tableBodyPath.node.openingElement.attributes = tableBodyPath.node.openingElement.attributes.filter(attribute => {
152
+ if (t.isJSXAttribute(attribute) && propsToMove.includes(attribute.name.name)) {
153
+ newAttributes.push(attribute);
154
+ return false; // Remove from TableBody
155
+ }
156
+ return true; // Keep in TableBody
157
+ });
158
+ if (newAttributes.length > 0) {
159
+ path.node.openingElement.attributes.push(...newAttributes);
160
+ }
161
+ }
162
+ /**
163
+ * Transforms TableView:
164
+ * - For Column and Row: Update key to be id (and keep key if rendered inside array.map).
165
+ * - For dynamic tables, pass a columns prop into Row.
166
+ * - For Row: Update dynamic render function to pass in column instead of columnKey.
167
+ * - Comment out UNSTABLE_allowsExpandableRows (it has not been implemented yet).
168
+ * - Comment out UNSTABLE_onExpandedChange (it has not been implemented yet).
169
+ * - Comment out UNSTABLE_expandedKeys (it has not been implemented yet).
170
+ * - Comment out UNSTABLE_defaultExpandedKeys (it has not been implemented yet).
171
+ */
172
+ function transformTable(path) {
173
+ // Add columns prop to Row for dynamic tables
174
+ addColumnsPropToRow(path);
175
+ // Comment out nested columns
176
+ commentIfNestedColumns(path);
177
+ // Comment out dragAndDropHooks
178
+ (0, transforms_1.commentOutProp)(path, { propName: 'dragAndDropHooks' });
179
+ // Comment out selectionStyle="highlight"
180
+ (0, transforms_1.commentOutProp)(path, { propName: 'selectionStyle' });
181
+ // Comment out unstable expandable rows props
182
+ (0, transforms_1.commentOutProp)(path, { propName: 'UNSTABLE_allowsExpandableRows' });
183
+ (0, transforms_1.commentOutProp)(path, { propName: 'UNSTABLE_onExpandedChange' });
184
+ (0, transforms_1.commentOutProp)(path, { propName: 'UNSTABLE_expandedKeys' });
185
+ (0, transforms_1.commentOutProp)(path, { propName: 'UNSTABLE_defaultExpandedKeys' });
186
+ addRowHeader(path);
187
+ // Move loadingState and onLoadMore from TableBody to TableView
188
+ movePropsFromTableBodyToTableView(path);
189
+ }
@@ -0,0 +1,116 @@
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 = transformTabs;
37
+ const utils_1 = require("../../shared/utils");
38
+ const transforms_1 = require("../../shared/transforms");
39
+ const t = __importStar(require("@babel/types"));
40
+ function transformTabList(tabListPath) {
41
+ tabListPath.get('children').forEach(itemPath => {
42
+ if (t.isJSXElement(itemPath.node) &&
43
+ t.isJSXIdentifier(itemPath.node.openingElement.name) &&
44
+ (0, utils_1.getName)(itemPath, itemPath.node.openingElement.name) === 'Item') {
45
+ (0, transforms_1.updateComponentWithinCollection)(itemPath, { parentComponentName: 'TabList', newComponentName: 'Tab' });
46
+ }
47
+ });
48
+ return tabListPath.node;
49
+ }
50
+ function transformTabPanels(tabPanelsPath, itemsProp) {
51
+ // Dynamic case
52
+ let dynamicRender = tabPanelsPath.get('children').find(path => t.isJSXExpressionContainer(path.node));
53
+ if (dynamicRender) {
54
+ (0, transforms_1.updateToNewComponentName)(tabPanelsPath, { newComponentName: 'Collection' });
55
+ let itemPath = dynamicRender.get('expression').get('body');
56
+ (0, transforms_1.updateComponentWithinCollection)(itemPath, { parentComponentName: 'Collection', newComponentName: 'TabPanel' });
57
+ if (itemsProp) {
58
+ tabPanelsPath.node.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('items'), itemsProp.value));
59
+ }
60
+ return [tabPanelsPath.node];
61
+ }
62
+ // Static case
63
+ return tabPanelsPath.get('children').map(itemPath => {
64
+ if (t.isJSXElement(itemPath.node) &&
65
+ t.isJSXIdentifier(itemPath.node.openingElement.name) &&
66
+ (0, utils_1.getName)(itemPath, itemPath.node.openingElement.name) === 'Item') {
67
+ (0, transforms_1.updateComponentWithinCollection)(itemPath, { parentComponentName: 'TabPanels', newComponentName: 'TabPanel' });
68
+ return itemPath.node;
69
+ }
70
+ return null;
71
+ }).filter(Boolean);
72
+ }
73
+ /**
74
+ * Transforms Tabs props and structure:
75
+ * - Inside TabList: Update Item to be Tab.
76
+ * - Update items on Tabs to be on TabList.
77
+ * - Inside TabPanels: Update Item to be a TabPanel and remove the surrounding TabPanels.
78
+ * - Remove isEmphasized (it is no longer supported in Spectrum 2).
79
+ * - Remove isQuiet (it is no longer supported in Spectrum 2).
80
+ */
81
+ function transformTabs(path) {
82
+ let program = path.findParent((p) => t.isProgram(p.node));
83
+ (0, utils_1.removeComponentImport)(program, 'TabPanels');
84
+ let tabListNode = null;
85
+ let tabPanelsNodes = [];
86
+ let itemsProp = null;
87
+ path.node.openingElement.attributes = path.node.openingElement.attributes.filter(attr => {
88
+ if (t.isJSXAttribute(attr) && attr.name.name === 'items') {
89
+ itemsProp = attr;
90
+ return false;
91
+ }
92
+ return true;
93
+ });
94
+ path.get('children').forEach(childPath => {
95
+ if (t.isJSXElement(childPath.node)) {
96
+ if (t.isJSXIdentifier(childPath.node.openingElement.name) &&
97
+ (0, utils_1.getName)(childPath, childPath.node.openingElement.name) === 'TabList') {
98
+ tabListNode = transformTabList(childPath);
99
+ if (itemsProp) {
100
+ tabListNode.openingElement.attributes.push(itemsProp);
101
+ }
102
+ }
103
+ else if (t.isJSXIdentifier(childPath.node.openingElement.name) &&
104
+ (0, utils_1.getName)(childPath, childPath.node.openingElement.name) === 'TabPanels') {
105
+ tabPanelsNodes = transformTabPanels(childPath, itemsProp);
106
+ }
107
+ }
108
+ });
109
+ if (tabListNode) {
110
+ path.node.children = [tabListNode, ...tabPanelsNodes];
111
+ }
112
+ // Remove isEmphasized
113
+ (0, transforms_1.removeProp)(path, { propName: 'isEmphasized' });
114
+ // Remove isQuiet
115
+ (0, transforms_1.removeProp)(path, { propName: 'isQuiet' });
116
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformTagGroup;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms TagGroup:
7
+ * - Rename actionLabel to groupActionLabel.
8
+ * - Rename onAction to onGroupAction.
9
+ * - Change validationState="invalid" to isInvalid.
10
+ * - Update Item to be Tag.
11
+ * - Remove validationState="valid" (it is no longer supported in Spectrum 2).
12
+ */
13
+ function transformTagGroup(path) {
14
+ // Rename actionLabel to groupActionLabel
15
+ (0, transforms_1.updatePropName)(path, { oldPropName: 'actionLabel', newPropName: 'groupActionLabel' });
16
+ // Rename onAction to onGroupAction
17
+ (0, transforms_1.updatePropName)(path, { oldPropName: 'onAction', newPropName: 'onGroupAction' });
18
+ // Change validationState="invalid" to isInvalid
19
+ (0, transforms_1.updatePropNameAndValue)(path, {
20
+ oldPropName: 'validationState',
21
+ oldPropValue: 'invalid',
22
+ newPropName: 'isInvalid',
23
+ newPropValue: true
24
+ });
25
+ // Remove validationState="valid"
26
+ (0, transforms_1.removeProp)(path, { propName: 'validationState', propValue: 'valid' });
27
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformTextArea;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms TextArea:
7
+ * - Comment out icon (it has not been implemented yet).
8
+ * - Remove isQuiet (it is no longer supported in Spectrum 2).
9
+ * - Remove placeholder (it has been removed due to accessibility issues).
10
+ * - Change validationState="invalid" to isInvalid.
11
+ * - Remove validationState="valid" (it is no longer supported in Spectrum 2).
12
+ */
13
+ function transformTextArea(path) {
14
+ // Comment out icon
15
+ (0, transforms_1.commentOutProp)(path, { propName: 'icon' });
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,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformTextField;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms TextField:
7
+ * - Comment out icon (it has not been implemented yet).
8
+ * - Remove isQuiet (it is no longer supported in Spectrum 2).
9
+ * - Remove placeholder (it has been removed due to accessibility issues).
10
+ * - Change validationState="invalid" to isInvalid.
11
+ * - Remove validationState="valid" (it is no longer supported in Spectrum 2).
12
+ */
13
+ function transformTextField(path) {
14
+ // Comment out icon
15
+ (0, transforms_1.commentOutProp)(path, { propName: 'icon' });
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,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformTooltip;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms Tooltip:
7
+ * - Remove variant (it is no longer supported in Spectrum 2).
8
+ * - Move placement prop to the parent TooltipTrigger.
9
+ * - Remove showIcon (it is no longer supported in Spectrum 2).
10
+ * - Move isOpen prop to the parent TooltipTrigger.
11
+ */
12
+ function transformTooltip(path) {
13
+ // Remove variant
14
+ (0, transforms_1.removeProp)(path, { propName: 'variant' });
15
+ // Move placement prop to the parent TooltipTrigger
16
+ (0, transforms_1.movePropToParentComponent)(path, {
17
+ parentComponentName: 'TooltipTrigger',
18
+ childComponentName: 'Tooltip',
19
+ propName: 'placement'
20
+ });
21
+ // Remove showIcon
22
+ (0, transforms_1.removeProp)(path, { propName: 'showIcon' });
23
+ // Move isOpen prop to the parent TooltipTrigger
24
+ (0, transforms_1.movePropToParentComponent)(path, {
25
+ parentComponentName: 'TooltipTrigger',
26
+ childComponentName: 'Tooltip',
27
+ propName: 'isOpen'
28
+ });
29
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformTooltipTrigger;
4
+ const transforms_1 = require("../../shared/transforms");
5
+ /**
6
+ * Transforms TooltipTrigger:
7
+ * - Updates placement prop to single value.
8
+ */
9
+ function transformTooltipTrigger(path) {
10
+ // Update placement prop to single value
11
+ (0, transforms_1.updatePlacementToSingleValue)(path, {
12
+ propToUpdateName: 'placement',
13
+ childComponentName: 'Tooltip'
14
+ });
15
+ }
@@ -15,21 +15,34 @@ 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;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
37
  };
25
38
  Object.defineProperty(exports, "__esModule", { value: true });
26
39
  exports.borderRadius = exports.borderWidths = void 0;
27
- exports.transformStyleProps = transformStyleProps;
40
+ exports.default = transformStyleProps;
28
41
  const utils_1 = require("./utils");
29
42
  const colors_1 = require("./colors");
30
43
  const dimensions_1 = require("./dimensions");
31
44
  const t = __importStar(require("@babel/types"));
32
- const unsafeStyle_1 = require("./unsafeStyle");
45
+ const unsafeStyle_1 = __importDefault(require("./unsafeStyle"));
33
46
  exports.borderWidths = {
34
47
  none: 0,
35
48
  thin: 1,
@@ -509,7 +522,7 @@ function handleProp(path, element, colorVersion) {
509
522
  switch (prop) {
510
523
  case 'UNSAFE_style':
511
524
  if (propValue.type === 'ObjectExpression') {
512
- let value = (0, unsafeStyle_1.transformUnsafeStyle)(propValue, element);
525
+ let value = (0, unsafeStyle_1.default)(propValue, element);
513
526
  if (value) {
514
527
  path.remove();
515
528
  return value;