@workday/canvas-kit-codemod 7.0.0-alpha.0-next.7 → 7.0.0-alpha.102-next.27

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 (34) hide show
  1. package/dist/es6/v7/compoundActionBar.d.ts.map +1 -1
  2. package/dist/es6/v7/compoundActionBar.js +58 -9
  3. package/dist/es6/v7/index.d.ts +3 -2
  4. package/dist/es6/v7/index.d.ts.map +1 -1
  5. package/dist/es6/v7/index.js +39 -4
  6. package/dist/es6/v7/recategorizeIconButtons.d.ts +3 -0
  7. package/dist/es6/v7/recategorizeIconButtons.d.ts.map +1 -0
  8. package/dist/es6/v7/recategorizeIconButtons.js +140 -0
  9. package/dist/es6/v7/removePropFromPopper.d.ts +3 -0
  10. package/dist/es6/v7/removePropFromPopper.d.ts.map +1 -0
  11. package/dist/es6/v7/removePropFromPopper.js +31 -0
  12. package/dist/es6/v7/renameIconPosition.d.ts +3 -0
  13. package/dist/es6/v7/renameIconPosition.d.ts.map +1 -0
  14. package/dist/es6/v7/renameIconPosition.js +37 -0
  15. package/dist/es6/v7/renameIconRef.d.ts +3 -0
  16. package/dist/es6/v7/renameIconRef.d.ts.map +1 -0
  17. package/dist/es6/v7/renameIconRef.js +70 -0
  18. package/dist/es6/v7/renameLayoutImports.d.ts.map +1 -1
  19. package/dist/es6/v7/renameLayoutImports.js +51 -29
  20. package/dist/es6/v7/updateDisclosureShowHide.d.ts +3 -0
  21. package/dist/es6/v7/updateDisclosureShowHide.d.ts.map +1 -0
  22. package/dist/es6/v7/updateDisclosureShowHide.js +96 -0
  23. package/dist/es6/v7/updateModelSignatures.d.ts +3 -0
  24. package/dist/es6/v7/updateModelSignatures.d.ts.map +1 -0
  25. package/dist/es6/v7/updateModelSignatures.js +90 -0
  26. package/dist/es6/v7/updateSegmentedControl.d.ts +3 -0
  27. package/dist/es6/v7/updateSegmentedControl.d.ts.map +1 -0
  28. package/dist/es6/v7/updateSegmentedControl.js +24 -0
  29. package/dist/es6/v7/updateTabs.d.ts +3 -0
  30. package/dist/es6/v7/updateTabs.d.ts.map +1 -0
  31. package/dist/es6/v7/updateTabs.js +48 -0
  32. package/dist/es6/v7/utils/getImportRenameMap.d.ts.map +1 -1
  33. package/dist/es6/v7/utils/getImportRenameMap.js +3 -1
  34. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"compoundActionBar.d.ts","sourceRoot":"","sources":["../../../lib/v7/compoundActionBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAyC,MAAM,aAAa,CAAC;AAM3F,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAmD7E"}
1
+ {"version":3,"file":"compoundActionBar.d.ts","sourceRoot":"","sources":["../../../lib/v7/compoundActionBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAyC,MAAM,aAAa,CAAC;AAM3F,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA0H7E"}
@@ -1,3 +1,10 @@
1
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
2
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
4
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
5
+ r[k] = a[j];
6
+ return r;
7
+ };
1
8
  import { getImportRenameMap } from './utils/getImportRenameMap';
2
9
  import { hasImportSpecifiers } from '../v6/utils';
3
10
  var actionBarPackage = '@workday/canvas-kit-react/action-bar';
@@ -18,7 +25,6 @@ export default function transformer(file, api, options) {
18
25
  }
19
26
  });
20
27
  var _a = getImportRenameMap(j, root, '@workday/canvas-kit-react/action-bar'), importMap = _a.importMap, styledMap = _a.styledMap;
21
- // Remove fixed prop from ActionBar component
22
28
  root
23
29
  .find(j.JSXElement, function (value) {
24
30
  return value.openingElement.name.type === 'JSXIdentifier' &&
@@ -26,17 +32,60 @@ export default function transformer(file, api, options) {
26
32
  value.openingElement.name.name === styledMap.ActionBar);
27
33
  })
28
34
  .forEach(function (nodePath) {
35
+ (nodePath.value.children || []).forEach(function (child, index) {
36
+ if (child.type === 'JSXElement') {
37
+ // bail early if we find a `ActionBar.List` as a child
38
+ if (child.openingElement.name.type === 'JSXMemberExpression' &&
39
+ child.openingElement.name.object.type === 'JSXIdentifier' &&
40
+ child.openingElement.name.object.name === 'ActionBar' &&
41
+ child.openingElement.name.property.type === 'JSXIdentifier' &&
42
+ child.openingElement.name.property.name === 'List') {
43
+ return;
44
+ }
45
+ // Transform Primary and Secondary button to ActionBar.Item
46
+ if (child.openingElement.name.type === 'JSXIdentifier') {
47
+ var buttonAttrs = child.openingElement.attributes || [];
48
+ var ActionItemJSX = j.jsxMemberExpression(j.jsxIdentifier(importMap.ActionBar), j.jsxIdentifier('Item'));
49
+ if (nodePath.value.children &&
50
+ ['PrimaryButton', 'SecondaryButton'].includes(child.openingElement.name.name)) {
51
+ // Add isPrimary attribute to primary Action Item
52
+ var elementAttrs = child.openingElement.name.name === 'PrimaryButton'
53
+ ? __spreadArrays(buttonAttrs, [j.jsxAttribute(j.jsxIdentifier('isPrimary'))]) : buttonAttrs;
54
+ nodePath.value.children[index] = j.jsxElement(j.jsxOpeningElement(ActionItemJSX, elementAttrs), j.jsxClosingElement(ActionItemJSX), child.children);
55
+ }
56
+ }
57
+ }
58
+ });
59
+ var children = nodePath.value.children || [];
60
+ // Remove all attributes from ActionBar to replace them to ActionBar.List
29
61
  var attributes = nodePath.value.openingElement.attributes;
30
62
  if (attributes) {
31
- // remove these attributes from ActionBar
32
- nodePath.value.openingElement.attributes = attributes.filter(function (item) {
33
- return item.type === 'JSXAttribute' &&
34
- item.name.type === 'JSXIdentifier' &&
35
- ['fixed'].includes(item.name.name)
36
- ? false
37
- : true;
38
- });
63
+ nodePath.value.openingElement.attributes = attributes.filter(function (item) { return !(item.type === 'JSXAttribute' && item.name.type === 'JSXIdentifier'); });
39
64
  }
65
+ // Create closing element for ActionBar without closing tag
66
+ if (nodePath.value.openingElement.selfClosing) {
67
+ nodePath.value.openingElement.selfClosing = false;
68
+ nodePath.value.closingElement = j.jsxClosingElement(nodePath.value.openingElement.name);
69
+ }
70
+ // Create ActionBar.List component
71
+ var ActionBarListJSX = j.jsxMemberExpression(j.jsxIdentifier(importMap.ActionBar), j.jsxIdentifier('List'));
72
+ var subComponentJSX = j.jsxElement(j.jsxOpeningElement(ActionBarListJSX,
73
+ // All attributes except fixed should be passed
74
+ attributes === null ||
75
+ // All attributes except fixed should be passed
76
+ attributes === void 0 ? void 0 :
77
+ // All attributes except fixed should be passed
78
+ attributes.filter(function (attr) { return !(attr.type === 'JSXAttribute' && attr.name.name === 'fixed'); })), j.jsxClosingElement(ActionBarListJSX), children);
79
+ // Keep space for code structure
80
+ var textLiteralStart = children.find(function (child) { return child.type === 'JSXText'; });
81
+ var textLiteralEnd = children
82
+ .slice()
83
+ .reverse()
84
+ .find(function (child) { return child.type === 'JSXText'; });
85
+ nodePath.value.children =
86
+ textLiteralStart && textLiteralEnd
87
+ ? [textLiteralStart, subComponentJSX, textLiteralEnd]
88
+ : [subComponentJSX];
40
89
  });
41
90
  return root.toSource();
42
91
  }
@@ -1,3 +1,4 @@
1
- import { API, FileInfo, Options } from 'jscodeshift';
2
- export default function transformer(file: FileInfo, api: API, options: Options): void;
1
+ import { Transform } from 'jscodeshift';
2
+ declare const transform: Transform;
3
+ export default transform;
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v7/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,QAI7E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v7/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AActC,QAAA,MAAM,SAAS,EAAE,SAiBhB,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -1,5 +1,40 @@
1
- export default function transformer(file, api, options) {
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import compoundActionBar from './compoundActionBar';
13
+ import compoundBanner from './compoundBanner';
14
+ import removePropFromPopper from './removePropFromPopper';
15
+ import renameIconRef from './renameIconRef';
16
+ import renameLayoutImports from './renameLayoutImports';
17
+ import updateSegmentedControl from './updateSegmentedControl';
18
+ import renameIconPosition from './renameIconPosition';
19
+ import recategorizeIconButtons from './recategorizeIconButtons';
20
+ import updateModelSignatures from './updateModelSignatures';
21
+ import updateTabs from './updateTabs';
22
+ import updateDisclosureShowHide from './updateDisclosureShowHide';
23
+ var transform = function (file, api, options) {
2
24
  // These will run in order. If your transform depends on others, place yours after dependent transforms
3
- // const fixes = [];
4
- // return fixes.reduce((source, fix) => fix({...file, source}, api, options), file.source);
5
- }
25
+ var fixes = [
26
+ compoundActionBar,
27
+ compoundBanner,
28
+ recategorizeIconButtons,
29
+ renameIconRef,
30
+ removePropFromPopper,
31
+ renameIconPosition,
32
+ renameLayoutImports,
33
+ updateSegmentedControl,
34
+ updateModelSignatures,
35
+ updateTabs,
36
+ updateDisclosureShowHide,
37
+ ];
38
+ return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
39
+ };
40
+ export default transform;
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=recategorizeIconButtons.d.ts.map
@@ -0,0 +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;AAcrB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAoK7E"}
@@ -0,0 +1,140 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ import chalk from 'chalk';
3
+ var updateJSXTag = function (nodePath, newTag) {
4
+ var componentName = nodePath.value.openingElement.name.name;
5
+ if (componentName === 'IconButton') {
6
+ nodePath.value.openingElement.name.name = newTag;
7
+ if (nodePath.value.closingElement) {
8
+ nodePath.value.closingElement.name.name = newTag;
9
+ }
10
+ }
11
+ };
12
+ export default function transformer(file, api, options) {
13
+ var j = api.jscodeshift;
14
+ var root = j(file.source);
15
+ var requiredImportSpecifiers = [];
16
+ /**
17
+ * 1. Find button imports
18
+ */
19
+ var _a = getImportRenameMap(j, root, '@workday/canvas-kit-react/button'), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap, styledMap = _a.styledMap;
20
+ if (!containsCanvasImports) {
21
+ return file.source;
22
+ }
23
+ var buttonType = 'TertiaryButton'; //default button if no variant is specified
24
+ // Button Mapping
25
+ // circle -> tertiary
26
+ // circle-filled -> secondary
27
+ // inverse -> tertiary inverse
28
+ // inverse-filled -> secondary inverse
29
+ // plain/square -> not supported
30
+ // square-filled -> not supported
31
+ /**
32
+ * 2. Find `IconButton`
33
+ * - If it has no variant, it means it's "circle" which is the default
34
+ * - Swap to `TertiaryButton`
35
+ * - Add `TertiaryButton` import if it doesn't exist.
36
+ * - If not
37
+ * - check the variant of the IconButton
38
+ * - Swap it out for the appropriate mapping
39
+ */
40
+ root
41
+ .find(j.JSXElement, function (value) {
42
+ return value.openingElement.name.type === 'JSXIdentifier' &&
43
+ (value.openingElement.name.name === importMap.IconButton ||
44
+ value.openingElement.name.name === styledMap.IconButton);
45
+ })
46
+ .forEach(function (nodePath) {
47
+ var _a;
48
+ var attrs = nodePath.value.openingElement.attributes;
49
+ var variantProp = attrs === null || attrs === void 0 ? void 0 : attrs.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'variant'; });
50
+ // Default IconButton variant is `circle`
51
+ if (variantProp) {
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"');
71
+ }
72
+ }
73
+ updateJSXTag(nodePath, buttonType);
74
+ requiredImportSpecifiers.push(buttonType);
75
+ });
76
+ if (requiredImportSpecifiers.length === 0) {
77
+ return file.source;
78
+ }
79
+ // Find all instances of IconButton within a style function
80
+ // const StyledIconButton = styled(IconButton) gets renamed to
81
+ // const StyledIconButton = styled(CorrectButtonMapping)
82
+ root.find(j.VariableDeclarator).forEach(function (nodePath) {
83
+ var _a;
84
+ if (((_a = nodePath.value.init) === null || _a === void 0 ? void 0 : _a.type) === 'CallExpression' &&
85
+ nodePath.value.init.callee.type === 'CallExpression' &&
86
+ nodePath.value.init.callee.callee.type === 'Identifier' &&
87
+ nodePath.value.init.callee.callee.name === 'styled' &&
88
+ nodePath.value.init.callee.arguments[0].type === 'Identifier' &&
89
+ nodePath.value.init.callee.arguments[0].name === importMap.IconButton) {
90
+ nodePath.value.init.callee.arguments[0].name = buttonType;
91
+ requiredImportSpecifiers.push(buttonType);
92
+ }
93
+ });
94
+ /**
95
+ * Remove old imports: `IconButton`
96
+ * Add new required imports
97
+ */
98
+ var buttonImports = root.find(j.ImportDeclaration, {
99
+ source: {
100
+ value: function (value) {
101
+ return value === '@workday/canvas-kit-react' || value === '@workday/canvas-kit-react/button';
102
+ },
103
+ },
104
+ });
105
+ if (!buttonImports.length) {
106
+ // Add new specifiers to a new import
107
+ var allImports = root.find(j.ImportDeclaration);
108
+ var lastImport = allImports.at(allImports.length);
109
+ if (lastImport) {
110
+ lastImport.insertAfter(j.importDeclaration(requiredImportSpecifiers.map(function (specifier) { return j.importSpecifier(j.identifier(specifier)); }), j.stringLiteral('@workday/canvas-kit-react/button')));
111
+ }
112
+ }
113
+ else {
114
+ buttonImports.forEach(function (_a) {
115
+ var _b;
116
+ var node = _a.node;
117
+ var specifiersToRemove = ['IconButton'];
118
+ // Remove old specifiers
119
+ if (typeof node.source.value === 'string' &&
120
+ node.source.value.includes('@workday/canvas-kit-react')) {
121
+ (_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.forEach(function (specifier) {
122
+ var _a, _b;
123
+ if (specifier.type === 'ImportSpecifier' &&
124
+ specifiersToRemove.includes(specifier.imported.name)) {
125
+ // delete specifier
126
+ (_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.splice((_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.indexOf(specifier), 1);
127
+ }
128
+ });
129
+ }
130
+ // Add new specifiers to existing import
131
+ requiredImportSpecifiers.forEach(function (specifier) {
132
+ var _a, _b;
133
+ if (!((_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.find(function (existing) { return existing.type === 'ImportSpecifier' && existing.imported.name === specifier; }))) {
134
+ (_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.push(j.importSpecifier(j.identifier(specifier)));
135
+ }
136
+ });
137
+ });
138
+ }
139
+ return root.toSource();
140
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=removePropFromPopper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removePropFromPopper.d.ts","sourceRoot":"","sources":["../../../lib/v7/removePropFromPopper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAM/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAkC7E"}
@@ -0,0 +1,31 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ var popupBarPackage = '@workday/canvas-kit-react/popup';
4
+ export default function transformer(file, api, options) {
5
+ var j = api.jscodeshift;
6
+ var root = j(file.source);
7
+ if (!hasImportSpecifiers(api, root, popupBarPackage, ['Popper'])) {
8
+ return file.source;
9
+ }
10
+ var _a = getImportRenameMap(j, root, popupBarPackage), importMap = _a.importMap, styledMap = _a.styledMap;
11
+ root
12
+ .find(j.JSXElement, function (value) {
13
+ return value.openingElement.name.type === 'JSXIdentifier' &&
14
+ (value.openingElement.name.name === importMap.Popper ||
15
+ value.openingElement.name.name === styledMap.Popper);
16
+ })
17
+ .forEach(function (nodePath) {
18
+ var attributes = nodePath.value.openingElement.attributes;
19
+ // Remove containerElement prop from Popper component
20
+ if (attributes) {
21
+ nodePath.value.openingElement.attributes = attributes.filter(function (item) {
22
+ return item.type === 'JSXAttribute' &&
23
+ item.name.type === 'JSXIdentifier' &&
24
+ ['containerElement'].includes(item.name.name)
25
+ ? false
26
+ : true;
27
+ });
28
+ }
29
+ });
30
+ return root.toSource();
31
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=renameIconPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renameIconPosition.d.ts","sourceRoot":"","sources":["../../../lib/v7/renameIconPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAA+C,MAAM,aAAa,CAAC;AAIjG,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA+C7E"}
@@ -0,0 +1,37 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ export default function transformer(file, api, options) {
3
+ var j = api.jscodeshift;
4
+ var root = j(file.source);
5
+ var _a = getImportRenameMap(j, root, '@workday/canvas-kit-react/button'), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap, styledMap = _a.styledMap;
6
+ if (!containsCanvasImports) {
7
+ return file.source;
8
+ }
9
+ root
10
+ .find(j.JSXElement, function (value) {
11
+ return value.openingElement.name.type === 'JSXIdentifier' &&
12
+ (value.openingElement.name.name ===
13
+ (importMap.PrimaryButton || importMap.SecondaryButton) ||
14
+ value.openingElement.name.name === (styledMap.PrimaryButton || styledMap.SecondaryButton));
15
+ })
16
+ .forEach(function (nodePath) {
17
+ var _a;
18
+ var findAttribute = function (name) { return function (item) {
19
+ return item.type === 'JSXAttribute' &&
20
+ item.name.type === 'JSXIdentifier' &&
21
+ item.name.name === name;
22
+ }; };
23
+ var attributes = nodePath.value.openingElement.attributes;
24
+ if (attributes) {
25
+ var iconPosition = attributes.find(findAttribute('iconPosition'));
26
+ if (((_a = iconPosition === null || iconPosition === void 0 ? void 0 : iconPosition.value) === null || _a === void 0 ? void 0 : _a.type) === 'StringLiteral') {
27
+ if (iconPosition.value.value === 'left') {
28
+ iconPosition.value.value = 'start';
29
+ }
30
+ else {
31
+ iconPosition.value.value = 'end';
32
+ }
33
+ }
34
+ }
35
+ });
36
+ return root.toSource();
37
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=renameIconRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renameIconRef.d.ts","sourceRoot":"","sources":["../../../lib/v7/renameIconRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAC;AAgBlE,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAiE7E"}
@@ -0,0 +1,70 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ var inputsMap = {
3
+ '@workday/canvas-kit-react/icon': [
4
+ 'AccentIcon',
5
+ 'AppletIcon',
6
+ 'SystemIcon',
7
+ 'SystemIconCircle',
8
+ 'Graphic',
9
+ 'Svg',
10
+ ],
11
+ };
12
+ export default function transformer(file, api, options) {
13
+ var j = api.jscodeshift;
14
+ var root = j(file.source);
15
+ // defaultImports should be an array of local names that were imported using
16
+ // a default import from any of the modules listed in inputsMap. For example,
17
+ // given...
18
+ //
19
+ // ```
20
+ // import Checkbox from '@workday/canvas-kit-react/checkbox';
21
+ // import CanvasTextArea from '@workday/canvas-kit-react/text-area';
22
+ // import {TextInput} from '@workday/canvas-kit-react/text-input';
23
+ // import StatusIndicator from '@workday/canvas-kit-react/status-indicator';
24
+ // ```
25
+ //
26
+ // ... defaultImports should be set to `['Checkbox', 'CanvasTextArea']`
27
+ var defaultImports = [];
28
+ root.find(j.ImportDefaultSpecifier).forEach(function (nodePath) {
29
+ var _a;
30
+ var packageName = nodePath.parent.node.source.value;
31
+ var localName = (_a = nodePath.value.local) === null || _a === void 0 ? void 0 : _a.name;
32
+ if (packageName in inputsMap && localName) {
33
+ defaultImports.push(localName);
34
+ }
35
+ });
36
+ var runningSource = file.source;
37
+ var _loop_1 = function (inputPackageName) {
38
+ var currentRoot = j(runningSource);
39
+ var _a = getImportRenameMap(j, currentRoot, inputPackageName), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap, styledMap = _a.styledMap;
40
+ if (containsCanvasImports) {
41
+ var inputNames_1 = inputsMap[inputPackageName];
42
+ currentRoot
43
+ .find(j.JSXIdentifier, function (value) { return value.name === 'iconRef'; })
44
+ .replaceWith(function (nodePath) {
45
+ var _a, _b, _c, _d;
46
+ var elementName = (_d = (_c = (_b = (_a = nodePath.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.name;
47
+ // Rewrite inputRef to ref if any of the following are true:
48
+ // (a) elementName was the name used in a default import of the current
49
+ // input being processed (e.g., `import TextInput ...`)
50
+ // (b) elementName was the name used in a named import of the current
51
+ // input being processed (e.g., `import {TextInput} ...` or
52
+ // `import {TextInput as CanvasTextInput} ...`)
53
+ // (c) elementName was created by calling `styled` on the current input
54
+ // being processed (e.g., `const StyledTextInput = styled(TextInput)`)
55
+ if (defaultImports.includes(elementName) ||
56
+ inputNames_1.map(function (n) { return importMap[n]; }).includes(elementName) ||
57
+ inputNames_1.map(function (n) { return styledMap[n]; }).includes(elementName)) {
58
+ return j.jsxIdentifier('ref');
59
+ }
60
+ return nodePath.value;
61
+ });
62
+ runningSource = currentRoot.toSource();
63
+ }
64
+ };
65
+ for (var _i = 0, _a = Object.keys(inputsMap); _i < _a.length; _i++) {
66
+ var inputPackageName = _a[_i];
67
+ _loop_1(inputPackageName);
68
+ }
69
+ return runningSource;
70
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"renameLayoutImports.d.ts","sourceRoot":"","sources":["../../../lib/v7/renameLayoutImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAelE,QAAA,MAAM,SAAS,EAAE,SAqFhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"renameLayoutImports.d.ts","sourceRoot":"","sources":["../../../lib/v7/renameLayoutImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA6B,MAAM,aAAa,CAAC;AAoDlE,QAAA,MAAM,SAAS,EAAE,SAyEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -6,6 +6,42 @@ var commonSpecifiers = [
6
6
  'useThemeRTL',
7
7
  'useThemedRing',
8
8
  ];
9
+ var layoutSpecifiers = [
10
+ 'Flex',
11
+ 'Stack',
12
+ 'StackProps',
13
+ 'HStackProps',
14
+ 'VStack',
15
+ 'VStackProps',
16
+ 'HStack',
17
+ 'Box',
18
+ 'BoxProps',
19
+ 'FlexProps',
20
+ 'ColorStyleProps',
21
+ 'StackSpacing',
22
+ 'StackDirection',
23
+ 'StackStyleProps',
24
+ 'FlexStyleProps',
25
+ 'SpaceStyleProps',
26
+ 'DepthStyleProps',
27
+ 'BorderShorthandStyleProps',
28
+ 'BorderColorStyleProps',
29
+ 'BorderRadiusStyleProps',
30
+ 'BorderLineStyleProps',
31
+ 'BorderWidthStyleProps',
32
+ 'BorderLogicalStyleProps',
33
+ 'BorderStyleProps',
34
+ 'border',
35
+ 'ColorTokens',
36
+ 'ColorStyleProps',
37
+ 'color',
38
+ 'FlexItemStyleProps',
39
+ 'flexItem',
40
+ 'PositionStandardProps',
41
+ 'PositionLogicalProps',
42
+ 'PositionStyleProps',
43
+ 'position',
44
+ ];
9
45
  // 1. Gather all import specifiers from @workday/canvas-kit-labs-react/layout
10
46
  // 2. Filter through all imports from @workday/canvas-kit-labs-react/common and gather specifiers we care about
11
47
  // 3. If there's an existing @workday/canvas-kit-react/layout add gathered specifiers to that import
@@ -15,39 +51,24 @@ var transform = function (file, api) {
15
51
  var root = j(file.source);
16
52
  var reactLayoutSpecifiers = [];
17
53
  var foundImport = [];
18
- // for each specifier in @workday/canvas-kit-labs-react/layout it pushes
19
- // the specifier to reactLayoutSpecifiers
20
- // We also push the found import to foundImport
21
54
  root
22
- .find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-labs-react/layout' } })
23
- .forEach(function (nodePath) {
24
- var _a;
25
- (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(function (specifier) {
26
- var _a, _b;
27
- if (specifier.type === 'ImportSpecifier') {
28
- reactLayoutSpecifiers.push({
29
- importedName: (_a = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _a === void 0 ? void 0 : _a.name,
30
- name: (_b = specifier === null || specifier === void 0 ? void 0 : specifier.imported) === null || _b === void 0 ? void 0 : _b.name,
31
- });
32
- }
33
- });
34
- foundImport.push(nodePath);
35
- });
36
- // We filter through @workday/canvas-kit-labs-react/common specifiers and
37
- // if it includes specifiers that we want, we push those to reactLayoutSpecifiers
38
- root
39
- .find(j.ImportDeclaration, { source: { value: '@workday/canvas-kit-labs-react/common' } })
55
+ .find(j.ImportDeclaration, {
56
+ source: { value: function (value) { return value.includes('@workday/canvas-kit-labs-react'); } },
57
+ })
40
58
  .forEach(function (nodePath) {
41
59
  var _a;
42
60
  nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(function (specifier) {
43
- var _a, _b;
61
+ var _a, _b, _c, _d;
44
62
  if (specifier.type === 'ImportSpecifier' &&
45
63
  !commonSpecifiers.includes(specifier.imported.name)) {
46
- reactLayoutSpecifiers.push({
47
- importedName: (_a = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _a === void 0 ? void 0 : _a.name,
48
- name: (_b = specifier === null || specifier === void 0 ? void 0 : specifier.imported) === null || _b === void 0 ? void 0 : _b.name,
49
- });
50
- return false;
64
+ if (((_a = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _a === void 0 ? void 0 : _a.name) !== undefined &&
65
+ layoutSpecifiers.includes((_b = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _b === void 0 ? void 0 : _b.name)) {
66
+ reactLayoutSpecifiers.push({
67
+ importedName: (_c = specifier === null || specifier === void 0 ? void 0 : specifier.local) === null || _c === void 0 ? void 0 : _c.name,
68
+ name: (_d = specifier === null || specifier === void 0 ? void 0 : specifier.imported) === null || _d === void 0 ? void 0 : _d.name,
69
+ });
70
+ return false;
71
+ }
51
72
  }
52
73
  return true;
53
74
  });
@@ -68,11 +89,12 @@ var transform = function (file, api) {
68
89
  }
69
90
  else {
70
91
  // create new import
71
- foundImport[0].insertBefore(j.importDeclaration(reactLayoutSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/layout')));
92
+ if (foundImport.length) {
93
+ foundImport[0].insertBefore(j.importDeclaration(reactLayoutSpecifiers.map(mapToSpecifiers), j.stringLiteral('@workday/canvas-kit-react/layout')));
94
+ }
72
95
  }
73
96
  foundImport.forEach(function (importPath) {
74
97
  var _a;
75
- // remove imports we no longer need
76
98
  if (((_a = importPath.value.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
77
99
  importPath.value.source.value === '@workday/canvas-kit-labs-react/layout') {
78
100
  importPath.prune();
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=updateDisclosureShowHide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateDisclosureShowHide.d.ts","sourceRoot":"","sources":["../../../lib/v7/updateDisclosureShowHide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA6B,OAAO,EAAC,MAAM,aAAa,CAAC;AAK9E,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAiH7E"}
@@ -0,0 +1,96 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ var keys = function (input) { return Object.keys(input); };
3
+ export default function transformer(file, api, options) {
4
+ var j = api.jscodeshift;
5
+ var root = j(file.source);
6
+ var _a = getImportRenameMap(j, root), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap;
7
+ if (!containsCanvasImports) {
8
+ return file.source;
9
+ }
10
+ var disclosureModels = [
11
+ 'useDisclosureModel',
12
+ 'usePopupModel',
13
+ 'useModalModel',
14
+ 'useDialogModel',
15
+ ];
16
+ // inverse the import map. It is more useful this way for this function
17
+ var imports = Object.keys(importMap).reduce(function (result, key) {
18
+ result[importMap[key]] = key;
19
+ return result;
20
+ }, {});
21
+ root.find(j.CallExpression).forEach(function (nodePath) {
22
+ var value = nodePath.value;
23
+ // check if the identifier was imported from CK AND follows the `use{*}Model` naming convention
24
+ if (value.callee.type === 'Identifier' &&
25
+ disclosureModels.includes(imports[value.callee.name])) {
26
+ // loop over all the arguments of the `use{*}Model` hook
27
+ value.arguments.forEach(function (argument) {
28
+ // look for object expressions: `use{*}Model({ /* here */ })`
29
+ if (argument.type === 'ObjectExpression') {
30
+ // loop over all the properties looking for `ObjectMethod` and `ObjectProperties` where
31
+ // the value is a function matching `on{*}` or `should{*}` naming convention
32
+ argument.properties.forEach(function (property) {
33
+ // If it is an `ObjectMethod` or an `ObjectProperty` with an arrow function expression:
34
+ // {
35
+ // onShow() {}, // ObjectMethod
36
+ // onHide: () => {}, ObjectProperty with arrow function expression
37
+ // }
38
+ if ((property.type === 'ObjectMethod' ||
39
+ (property.type === 'ObjectProperty' &&
40
+ property.value.type === 'ArrowFunctionExpression')) &&
41
+ property.key.type === 'Identifier') {
42
+ var propertyName_1 = property.key.name;
43
+ // Both types have a `params`, but are at different places in the AST
44
+ var params_1 = property.type === 'ObjectMethod'
45
+ ? property.params
46
+ : property.value.type === 'ArrowFunctionExpression'
47
+ ? property.value.params
48
+ : [];
49
+ // create a mapping for param names of callbacks and guards. This makes the logic more
50
+ // difficult to follow, but decreases duplication
51
+ var paramMapping_1 = {
52
+ on: ['event'],
53
+ should: ['event'],
54
+ };
55
+ // We will be overriding the params with this variable later
56
+ var finalParams_1 = [];
57
+ // loop over each `paramMapping` type. `on*` and `should*` functions have different signatures
58
+ keys(paramMapping_1).forEach(function (key) {
59
+ // matches `onShow` and `shouldShow`
60
+ if (new RegExp(key + "[A-Za-z]+").test(propertyName_1)) {
61
+ params_1.forEach(function (param) {
62
+ if (param.type === 'ObjectPattern') {
63
+ param.properties.forEach(function (property) {
64
+ if (property.type === 'ObjectProperty' &&
65
+ property.key.type === 'Identifier') {
66
+ if (property.value.type === 'Identifier' ||
67
+ property.value.type === 'ObjectPattern') {
68
+ var index = paramMapping_1[key].indexOf(property.key.name);
69
+ // use `property.value` instead of `property.key.name` in case they
70
+ // renamed it example `shouldShow({ data: myData })`. The key name is
71
+ // `data` while the value is `myData`
72
+ finalParams_1[index] = property.value;
73
+ }
74
+ }
75
+ });
76
+ }
77
+ });
78
+ // `ObjectMethod` and `ObjectProperty` have params in a different place in the
79
+ // AST, so apply `finalParams` where appropriate
80
+ if (property.type === 'ObjectMethod') {
81
+ property.params = finalParams_1;
82
+ }
83
+ else if (property.type === 'ObjectProperty' &&
84
+ property.value.type === 'ArrowFunctionExpression') {
85
+ property.value.params = finalParams_1;
86
+ }
87
+ }
88
+ });
89
+ }
90
+ });
91
+ }
92
+ });
93
+ }
94
+ });
95
+ return root.toSource();
96
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=updateModelSignatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateModelSignatures.d.ts","sourceRoot":"","sources":["../../../lib/v7/updateModelSignatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAA6B,OAAO,EAAC,MAAM,aAAa,CAAC;AAK9E,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA0G7E"}
@@ -0,0 +1,90 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ var keys = function (input) { return Object.keys(input); };
3
+ export default function transformer(file, api, options) {
4
+ var j = api.jscodeshift;
5
+ var root = j(file.source);
6
+ var _a = getImportRenameMap(j, root), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap;
7
+ if (!containsCanvasImports) {
8
+ return file.source;
9
+ }
10
+ // inverse the import map. It is more useful this way for this function
11
+ var imports = Object.keys(importMap).reduce(function (result, key) {
12
+ result[importMap[key]] = key;
13
+ return result;
14
+ }, {});
15
+ root.find(j.CallExpression).forEach(function (nodePath) {
16
+ var value = nodePath.value;
17
+ // check if the identifier was imported from CK AND follows the `use{*}Model` naming convention
18
+ if (value.callee.type === 'Identifier' &&
19
+ /use[a-zA-Z]+Model/.test(imports[value.callee.name])) {
20
+ // loop over all the arguments of the `use{*}Model` hook
21
+ value.arguments.forEach(function (argument) {
22
+ // look for object expressions: `use{*}Model({ /* here */ })`
23
+ if (argument.type === 'ObjectExpression') {
24
+ // loop over all the properties looking for `ObjectMethod` and `ObjectProperties` where
25
+ // the value is a function matching `on{*}` or `should{*}` naming convention
26
+ argument.properties.forEach(function (property) {
27
+ // If it is an `ObjectMethod` or an `ObjectProperty` with an arrow function expression:
28
+ // {
29
+ // onShow() {}, // ObjectMethod
30
+ // onHide: () => {}, ObjectProperty with arrow function expression
31
+ // }
32
+ if ((property.type === 'ObjectMethod' ||
33
+ (property.type === 'ObjectProperty' &&
34
+ property.value.type === 'ArrowFunctionExpression')) &&
35
+ property.key.type === 'Identifier') {
36
+ var propertyName_1 = property.key.name;
37
+ // Both types have a `params`, but are at different places in the AST
38
+ var params_1 = property.type === 'ObjectMethod'
39
+ ? property.params
40
+ : property.value.type === 'ArrowFunctionExpression'
41
+ ? property.value.params
42
+ : [];
43
+ // create a mapping for param names of callbacks and guards. This makes the logic more
44
+ // difficult to follow, but decreases duplication
45
+ var paramMapping_1 = {
46
+ on: ['data', 'state'],
47
+ should: ['data', 'prevState'],
48
+ };
49
+ // We will be overriding the params with this variable later
50
+ var finalParams_1 = [];
51
+ // loop over each `paramMapping` type. `on*` and `should*` functions have different signatures
52
+ keys(paramMapping_1).forEach(function (key) {
53
+ // matches `onShow` and `shouldShow`
54
+ if (new RegExp(key + "[A-Za-z]+").test(propertyName_1)) {
55
+ params_1.forEach(function (param) {
56
+ if (param.type === 'ObjectPattern') {
57
+ param.properties.forEach(function (property) {
58
+ if (property.type === 'ObjectProperty' &&
59
+ property.key.type === 'Identifier') {
60
+ if (property.value.type === 'Identifier' ||
61
+ property.value.type === 'ObjectPattern') {
62
+ var index = paramMapping_1[key].indexOf(property.key.name);
63
+ // use `property.value` instead of `property.key.name` in case they
64
+ // renamed it example `shouldShow({ data: myData })`. The key name is
65
+ // `data` while the value is `myData`
66
+ finalParams_1[index] = property.value;
67
+ }
68
+ }
69
+ });
70
+ }
71
+ });
72
+ // `ObjectMethod` and `ObjectProperty` have params in a different place in the
73
+ // AST, so apply `finalParams` where appropriate
74
+ if (property.type === 'ObjectMethod') {
75
+ property.params = finalParams_1;
76
+ }
77
+ else if (property.type === 'ObjectProperty' &&
78
+ property.value.type === 'ArrowFunctionExpression') {
79
+ property.value.params = finalParams_1;
80
+ }
81
+ }
82
+ });
83
+ }
84
+ });
85
+ }
86
+ });
87
+ }
88
+ });
89
+ return root.toSource();
90
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=updateSegmentedControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateSegmentedControl.d.ts","sourceRoot":"","sources":["../../../lib/v7/updateSegmentedControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAI/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAgC7E"}
@@ -0,0 +1,24 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ export default function transformer(file, api, options) {
3
+ var j = api.jscodeshift;
4
+ var root = j(file.source);
5
+ var _a = getImportRenameMap(j, root, '@workday/canvas-kit-react/segmented-control'), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap, styledMap = _a.styledMap;
6
+ if (!containsCanvasImports) {
7
+ return file.source;
8
+ }
9
+ root
10
+ .find(j.JSXElement, function (value) {
11
+ return value.openingElement.name.type === 'JSXIdentifier' &&
12
+ (value.openingElement.name.name === importMap.SegmentedControl ||
13
+ value.openingElement.name.name === styledMap.SegmentedControl);
14
+ })
15
+ .forEach(function (nodePath) {
16
+ for (var _i = 0, _a = nodePath.value.children || []; _i < _a.length; _i++) {
17
+ var child = _a[_i];
18
+ if (child.type === 'JSXElement' && child.openingElement.name.type === 'JSXIdentifier') {
19
+ child.openingElement.name.name = 'SegmentedControl.Button';
20
+ }
21
+ }
22
+ });
23
+ return root.toSource();
24
+ }
@@ -0,0 +1,3 @@
1
+ import { API, FileInfo, Options } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API, options: Options): string;
3
+ //# sourceMappingURL=updateTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateTabs.d.ts","sourceRoot":"","sources":["../../../lib/v7/updateTabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AAGnD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAuD7E"}
@@ -0,0 +1,48 @@
1
+ import { getImportRenameMap } from './utils/getImportRenameMap';
2
+ export default function transformer(file, api, options) {
3
+ var j = api.jscodeshift;
4
+ var root = j(file.source);
5
+ var _a = getImportRenameMap(j, root), containsCanvasImports = _a.containsCanvasImports, importMap = _a.importMap;
6
+ if (!containsCanvasImports) {
7
+ return file.source;
8
+ }
9
+ root
10
+ // Find <Tabs
11
+ .find(j.JSXOpeningElement, { name: { object: { name: importMap.Tabs } } })
12
+ // Filter for <Tabs.Item and <Tabs.Panel
13
+ .filter(function (path) {
14
+ return (path.value.name.type === 'JSXMemberExpression' &&
15
+ (path.value.name.property.name === 'Item' || path.value.name.property.name === 'Panel'));
16
+ })
17
+ .forEach(function (nodePath) {
18
+ var _a;
19
+ nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(function (attribute) {
20
+ if (attribute.type === 'JSXAttribute' &&
21
+ attribute.name.type === 'JSXIdentifier' &&
22
+ attribute.name.name === 'name') {
23
+ attribute.name.name = 'data-id';
24
+ }
25
+ return attribute;
26
+ });
27
+ });
28
+ root
29
+ // find <Tabs.Menu.Item
30
+ .find(j.JSXOpeningElement, {
31
+ name: {
32
+ object: { object: { name: importMap.Tabs }, property: { name: 'Menu' } },
33
+ property: { name: 'Item' },
34
+ },
35
+ })
36
+ .forEach(function (nodePath) {
37
+ var _a;
38
+ nodePath.value.attributes = (_a = nodePath.value.attributes) === null || _a === void 0 ? void 0 : _a.map(function (attribute) {
39
+ if (attribute.type === 'JSXAttribute' &&
40
+ attribute.name.type === 'JSXIdentifier' &&
41
+ attribute.name.name === 'name') {
42
+ attribute.name.name = 'data-id';
43
+ }
44
+ return attribute;
45
+ });
46
+ });
47
+ return root.toSource();
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"getImportRenameMap.d.ts","sourceRoot":"","sources":["../../../../lib/v7/utils/getImportRenameMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,SAAK;;;;EAyDzF"}
1
+ {"version":3,"file":"getImportRenameMap.d.ts","sourceRoot":"","sources":["../../../../lib/v7/utils/getImportRenameMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,SAAK;;;;EA2DzF"}
@@ -9,7 +9,9 @@ export function getImportRenameMap(j, root, packageName) {
9
9
  // imports our module
10
10
  var value = node.source.value;
11
11
  if (typeof value === 'string' &&
12
- (value === '@workday/canvas-kit-react' || value === packageName)) {
12
+ (value === '@workday/canvas-kit-react' ||
13
+ value.startsWith('@workday/canvas-kit-react/') ||
14
+ value === packageName)) {
13
15
  containsCanvasImports = true;
14
16
  (node.specifiers || []).forEach(function (specifier) {
15
17
  if (specifier.type === 'ImportSpecifier') {
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.0-next.7+23568685",
5
+ "version": "7.0.0-alpha.102-next.27+a618e6a9",
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": "23568685fec785046d37cb320289d8ab9e74e283"
45
+ "gitHead": "a618e6a972dc1d5d577833b94d71e4e3be761f11"
46
46
  }