@workday/canvas-kit-codemod 7.0.0-alpha.85-next.12 → 7.0.0-alpha.86-next.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recategorizeIconButtons.d.ts","sourceRoot":"","sources":["../../../lib/v7/recategorizeIconButtons.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAMR,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"recategorizeIconButtons.d.ts","sourceRoot":"","sources":["../../../lib/v7/recategorizeIconButtons.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EAMR,MAAM,aAAa,CAAC;AAcrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA0J7E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getImportRenameMap } from './utils/getImportRenameMap';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
var updateJSXTag = function (nodePath, newTag) {
|
|
3
4
|
var componentName = nodePath.value.openingElement.name.name;
|
|
4
5
|
if (componentName === 'IconButton') {
|
|
@@ -43,15 +44,30 @@ export default function transformer(file, api, options) {
|
|
|
43
44
|
value.openingElement.name.name === styledMap.IconButton);
|
|
44
45
|
})
|
|
45
46
|
.forEach(function (nodePath) {
|
|
46
|
-
var _a
|
|
47
|
+
var _a;
|
|
47
48
|
var attrs = nodePath.value.openingElement.attributes;
|
|
48
49
|
var variantProp = attrs === null || attrs === void 0 ? void 0 : attrs.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'variant'; });
|
|
49
50
|
// Default IconButton variant is `circle`
|
|
50
51
|
if (variantProp) {
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
var valueBody = variantProp.value;
|
|
53
|
+
if ((valueBody === null || valueBody === void 0 ? void 0 : valueBody.type) === 'JSXExpressionContainer' &&
|
|
54
|
+
valueBody.expression.type === 'StringLiteral') {
|
|
55
|
+
variantProp.value = valueBody.expression;
|
|
56
|
+
}
|
|
57
|
+
var variantPropValue = variantProp.value.value;
|
|
58
|
+
if (variantPropValue) {
|
|
59
|
+
variantProp.value.value = variantPropValue.replace('Filled', '');
|
|
60
|
+
buttonType = /filled/gi.test(variantPropValue) ? 'SecondaryButton' : 'TertiaryButton';
|
|
61
|
+
if (!variantPropValue.includes('inverse')) {
|
|
62
|
+
(_a = nodePath.value.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.splice(attrs === null || attrs === void 0 ? void 0 : attrs.indexOf(variantProp), 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.warn(chalk.bold.red('** CANNOT UPDATE EXPRESSION FOR ICON BUTTON VARIANT. **') +
|
|
67
|
+
'\nYou will need to manually update this file to fix this warning.' +
|
|
68
|
+
'\nFile Name: ' +
|
|
69
|
+
chalk.blue(file.path) +
|
|
70
|
+
'\nConsult Upgrade Guide Section for v7: "Removal of Icon Button"');
|
|
55
71
|
}
|
|
56
72
|
}
|
|
57
73
|
updateJSXTag(nodePath, buttonType);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workday/canvas-kit-codemod",
|
|
3
3
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "7.0.0-alpha.
|
|
5
|
+
"version": "7.0.0-alpha.86-next.13+5701970e",
|
|
6
6
|
"description": "A collection of codemods for use on Workday Canvas Kit packages.",
|
|
7
7
|
"main": "dist/es6/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"test": "TZ=UTC jest -c ../../jest.config.js",
|
|
43
43
|
"typecheck:src": "tsc -p . --noEmit --incremental false"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "5701970e49ba5d7f1a3047e12a9632c7a1118388"
|
|
46
46
|
}
|