@workday/canvas-kit-codemod 8.0.0-alpha.241-next.12 → 8.0.0-alpha.245-next.15

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":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAUtC,QAAA,MAAM,SAAS,EAAE,SAahB,CAAC;AACF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v8/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAWtC,QAAA,MAAM,SAAS,EAAE,SAchB,CAAC;AACF,eAAe,SAAS,CAAC"}
@@ -16,6 +16,7 @@ import revomeDefaultImports from './removeDefaultImports';
16
16
  import promoteComponentsToTesting from './promoteComponentsToTesting';
17
17
  import promoteBreadcrumbs from './promoteBreadcrumbs';
18
18
  import restructureBreadcrumbs from './restructureBreadcrumbs';
19
+ import refactorActionBarOverflowButton from './refactorActionBarOverflowButton';
19
20
  var transform = function (file, api, options) {
20
21
  // These will run in order. If your transform depends on others, place yours after dependent transforms
21
22
  var fixes = [
@@ -26,6 +27,7 @@ var transform = function (file, api, options) {
26
27
  softDeprecateLayout,
27
28
  softDeprecatePreviewMenu,
28
29
  promoteComponentsToTesting,
30
+ refactorActionBarOverflowButton,
29
31
  ];
30
32
  return fixes.reduce(function (source, fix) { return fix(__assign(__assign({}, file), { source: source }), api, options); }, file.source);
31
33
  };
@@ -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=refactorActionBarOverflowButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refactorActionBarOverflowButton.d.ts","sourceRoot":"","sources":["../../../lib/v8/refactorActionBarOverflowButton.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,UA6E7E"}
@@ -0,0 +1,50 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ var actionBarPackage = '@workday/canvas-kit-react/action-bar';
4
+ export default function transformer(file, api, options) {
5
+ var j = api.jscodeshift;
6
+ var root = j(file.source);
7
+ if (!hasImportSpecifiers(api, root, actionBarPackage, ['ActionBar'])) {
8
+ return file.source;
9
+ }
10
+ // Replace default import with named or renamed import
11
+ root.find(j.ImportDefaultSpecifier).forEach(function (nodePath) {
12
+ var _a;
13
+ var parent = nodePath.parent;
14
+ var importSource = String(parent.node.source.value);
15
+ var localName = (_a = nodePath.value.local) === null || _a === void 0 ? void 0 : _a.name;
16
+ if (actionBarPackage === importSource && localName) {
17
+ nodePath.replace(j.importSpecifier(j.identifier('ActionBar'), j.identifier(localName)));
18
+ }
19
+ });
20
+ var _a = getImportRenameMap(j, root, '@workday/canvas-kit-react/action-bar'), importMap = _a.importMap, styledMap = _a.styledMap;
21
+ root
22
+ .find(j.JSXElement, function (value) {
23
+ return value.openingElement.name.type === 'JSXIdentifier' &&
24
+ (value.openingElement.name.name === importMap.ActionBar ||
25
+ value.openingElement.name.name === styledMap.ActionBar);
26
+ })
27
+ .forEach(function (nodePath) {
28
+ (nodePath.value.children || []).forEach(function (child, index) {
29
+ var _a;
30
+ // Remove all attributes from ActionBar to replace them to ActionBar.List
31
+ var attributes = nodePath.value.openingElement.attributes || [];
32
+ var isModelProp = !!attributes.find(function (attr) {
33
+ return attr.type === 'JSXAttribute' &&
34
+ (attr.name.name === 'model' || attr.name.name === 'items');
35
+ });
36
+ if (child.type === 'JSXElement' &&
37
+ child.openingElement.name.type === 'JSXMemberExpression' &&
38
+ child.openingElement.name.object.type === 'JSXIdentifier' &&
39
+ child.openingElement.name.object.name === importMap.ActionBar &&
40
+ child.openingElement.name.property.type === 'JSXIdentifier' &&
41
+ child.openingElement.name.property.name === 'List' &&
42
+ isModelProp) {
43
+ var ActionBarOverflowButtonJSX = j.jsxMemberExpression(j.jsxIdentifier(importMap.ActionBar), j.jsxIdentifier('OverflowButton'));
44
+ var overflowButton = j.jsxElement(j.jsxOpeningElement(ActionBarOverflowButtonJSX, [j.jsxAttribute(j.jsxIdentifier('aria-label'), j.stringLiteral('More actions'))], true));
45
+ (_a = child.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.push(j.jsxAttribute(j.jsxIdentifier('overflowButton'), j.jsxExpressionContainer(overflowButton)));
46
+ }
47
+ });
48
+ });
49
+ return root.toSource();
50
+ }
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": "8.0.0-alpha.241-next.12+c1b970cd",
5
+ "version": "8.0.0-alpha.245-next.15+3cf0e815",
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,
@@ -43,5 +43,5 @@
43
43
  "test": "TZ=UTC jest -c ../../jest.config.js",
44
44
  "typecheck:src": "tsc -p . --noEmit --incremental false"
45
45
  },
46
- "gitHead": "c1b970cd840e4394197f7af5ec82c22d4d8bb0f6"
46
+ "gitHead": "3cf0e815d0b1e5092d277a5951576dd5c2b5deba"
47
47
  }