@workday/canvas-kit-codemod 7.1.4 → 7.2.0-427-next.2

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 (84) hide show
  1. package/README.md +41 -5
  2. package/dist/es6/v5/compoundCard.js +19 -22
  3. package/dist/es6/v5/getImportRenameMap.js +11 -12
  4. package/dist/es6/v5/index.js +2 -13
  5. package/dist/es6/v5/mapTypeTokensToNewHierarchy.js +62 -62
  6. package/dist/es6/v5/maps.js +2 -2
  7. package/dist/es6/v5/moveInputProvider.js +6 -6
  8. package/dist/es6/v5/recategorizeButtons.js +34 -35
  9. package/dist/es6/v5/removeButtonEnums.js +26 -28
  10. package/dist/es6/v5/removeDefaultImports.js +7 -7
  11. package/dist/es6/v5/renameButtonRefs.js +8 -8
  12. package/dist/es6/v5/renameCoreImports.js +10 -10
  13. package/dist/es6/v5/renameInputRefs.js +17 -21
  14. package/dist/es6/v5/renamePreviewTokenImports.js +10 -10
  15. package/dist/es6/v5/renameSpacing.js +18 -18
  16. package/dist/es6/v5/slashImports.js +31 -33
  17. package/dist/es6/v6/deprecateCookieBanner.js +3 -3
  18. package/dist/es6/v6/deprecateHeader.js +4 -4
  19. package/dist/es6/v6/deprecatePageHeader.js +3 -3
  20. package/dist/es6/v6/index.js +3 -14
  21. package/dist/es6/v6/moveAndRenameSearchBar.js +23 -29
  22. package/dist/es6/v6/renameCanvasDepthValue.js +3 -3
  23. package/dist/es6/v6/utils/index.js +28 -31
  24. package/dist/es6/v7/compoundActionBar.js +27 -39
  25. package/dist/es6/v7/compoundBanner.js +40 -43
  26. package/dist/es6/v7/index.js +3 -14
  27. package/dist/es6/v7/recategorizeIconButtons.js +27 -31
  28. package/dist/es6/v7/removePropFromPopper.js +14 -18
  29. package/dist/es6/v7/renameIconPosition.js +13 -17
  30. package/dist/es6/v7/renameIconRef.js +17 -21
  31. package/dist/es6/v7/renameLayoutImports.js +14 -14
  32. package/dist/es6/v7/updateDisclosureShowHide.js +22 -22
  33. package/dist/es6/v7/updateModelSignatures.js +21 -21
  34. package/dist/es6/v7/updateSegmentedControl.js +8 -11
  35. package/dist/es6/v7/updateTabs.js +8 -8
  36. package/dist/es6/v7/utils/getImportRenameMap.js +11 -12
  37. package/dist/es6/v7/utils/hasImportSpecifiers.js +9 -11
  38. package/dist/es6/v8/index.d.ts +4 -0
  39. package/dist/es6/v8/index.d.ts.map +1 -0
  40. package/dist/es6/v8/index.js +25 -0
  41. package/dist/es6/v8/promoteBreadcrumbs.d.ts +4 -0
  42. package/dist/es6/v8/promoteBreadcrumbs.d.ts.map +1 -0
  43. package/dist/es6/v8/promoteBreadcrumbs.js +56 -0
  44. package/dist/es6/v8/promoteComponentsToTesting.d.ts +4 -0
  45. package/dist/es6/v8/promoteComponentsToTesting.d.ts.map +1 -0
  46. package/dist/es6/v8/promoteComponentsToTesting.js +76 -0
  47. package/dist/es6/v8/refactorActionBarOverflowButton.d.ts +3 -0
  48. package/dist/es6/v8/refactorActionBarOverflowButton.d.ts.map +1 -0
  49. package/dist/es6/v8/refactorActionBarOverflowButton.js +46 -0
  50. package/dist/es6/v8/removeDefaultImports.d.ts +3 -0
  51. package/dist/es6/v8/removeDefaultImports.d.ts.map +1 -0
  52. package/dist/es6/v8/removeDefaultImports.js +52 -0
  53. package/dist/es6/v8/renameLoadingAnimation.d.ts +3 -0
  54. package/dist/es6/v8/renameLoadingAnimation.d.ts.map +1 -0
  55. package/dist/es6/v8/renameLoadingAnimation.js +62 -0
  56. package/dist/es6/v8/restructureBreadcrumbs.d.ts +3 -0
  57. package/dist/es6/v8/restructureBreadcrumbs.d.ts.map +1 -0
  58. package/dist/es6/v8/restructureBreadcrumbs.js +55 -0
  59. package/dist/es6/v8/softDeprecateDrawer.d.ts +3 -0
  60. package/dist/es6/v8/softDeprecateDrawer.d.ts.map +1 -0
  61. package/dist/es6/v8/softDeprecateDrawer.js +103 -0
  62. package/dist/es6/v8/softDeprecateLayout.d.ts +3 -0
  63. package/dist/es6/v8/softDeprecateLayout.d.ts.map +1 -0
  64. package/dist/es6/v8/softDeprecateLayout.js +76 -0
  65. package/dist/es6/v8/softDeprecatePreviewMenu.d.ts +3 -0
  66. package/dist/es6/v8/softDeprecatePreviewMenu.d.ts.map +1 -0
  67. package/dist/es6/v8/softDeprecatePreviewMenu.js +79 -0
  68. package/dist/es6/v9/compoundToast.d.ts +3 -0
  69. package/dist/es6/v9/compoundToast.d.ts.map +1 -0
  70. package/dist/es6/v9/compoundToast.js +121 -0
  71. package/dist/es6/v9/deprecateStack.d.ts +3 -0
  72. package/dist/es6/v9/deprecateStack.d.ts.map +1 -0
  73. package/dist/es6/v9/deprecateStack.js +275 -0
  74. package/dist/es6/v9/index.d.ts +4 -0
  75. package/dist/es6/v9/index.d.ts.map +1 -0
  76. package/dist/es6/v9/index.js +16 -0
  77. package/dist/es6/v9/promoteToast.d.ts +4 -0
  78. package/dist/es6/v9/promoteToast.d.ts.map +1 -0
  79. package/dist/es6/v9/promoteToast.js +56 -0
  80. package/dist/es6/v9/promoteUseThemedRing.d.ts +4 -0
  81. package/dist/es6/v9/promoteUseThemedRing.d.ts.map +1 -0
  82. package/dist/es6/v9/promoteUseThemedRing.js +56 -0
  83. package/index.js +40 -5
  84. package/package.json +2 -2
@@ -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,46 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ const actionBarPackage = '@workday/canvas-kit-react/action-bar';
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const 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(nodePath => {
12
+ var _a;
13
+ const parent = nodePath.parent;
14
+ const importSource = String(parent.node.source.value);
15
+ const 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
+ const { importMap, styledMap } = getImportRenameMap(j, root, '@workday/canvas-kit-react/action-bar');
21
+ root
22
+ .find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXIdentifier' &&
23
+ (value.openingElement.name.name === importMap.ActionBar ||
24
+ value.openingElement.name.name === styledMap.ActionBar))
25
+ .forEach(nodePath => {
26
+ (nodePath.value.children || []).forEach((child, index) => {
27
+ var _a;
28
+ // Remove all attributes from ActionBar to replace them to ActionBar.List
29
+ const attributes = nodePath.value.openingElement.attributes || [];
30
+ const isModelProp = !!attributes.find(attr => attr.type === 'JSXAttribute' &&
31
+ (attr.name.name === 'model' || attr.name.name === 'items'));
32
+ if (child.type === 'JSXElement' &&
33
+ child.openingElement.name.type === 'JSXMemberExpression' &&
34
+ child.openingElement.name.object.type === 'JSXIdentifier' &&
35
+ child.openingElement.name.object.name === importMap.ActionBar &&
36
+ child.openingElement.name.property.type === 'JSXIdentifier' &&
37
+ child.openingElement.name.property.name === 'List' &&
38
+ isModelProp) {
39
+ const ActionBarOverflowButtonJSX = j.jsxMemberExpression(j.jsxIdentifier(importMap.ActionBar), j.jsxIdentifier('OverflowButton'));
40
+ const overflowButton = j.jsxElement(j.jsxOpeningElement(ActionBarOverflowButtonJSX, [j.jsxAttribute(j.jsxIdentifier('aria-label'), j.stringLiteral('More actions'))], true));
41
+ (_a = child.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.push(j.jsxAttribute(j.jsxIdentifier('overflowButton'), j.jsxExpressionContainer(overflowButton)));
42
+ }
43
+ });
44
+ });
45
+ return root.toSource();
46
+ }
@@ -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=removeDefaultImports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeDefaultImports.d.ts","sourceRoot":"","sources":["../../../lib/v8/removeDefaultImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAA6B,MAAM,aAAa,CAAC;AAiC/E,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAuB7E"}
@@ -0,0 +1,52 @@
1
+ // List of import paths and the named export
2
+ // before: import Button from '@workday/canvas-kit-react/button
3
+ // after: import { Button } from '@workday/canvas-kit-react/button
4
+ const renameDefaultMap = {
5
+ '@workday/canvas-kit-labs-react/combobox': 'Combobox',
6
+ '@workday/canvas-kit-labs-react/drawer': 'Drawer',
7
+ '@workday/canvas-kit-preview-react/breadcrumbs': 'Breadcrumbs',
8
+ '@workday/canvas-kit-preview-react/color-picker': 'ColorPicker',
9
+ '@workday/canvas-kit-preview-react/menu': 'Menu',
10
+ '@workday/canvas-kit-preview-react/select': 'Select',
11
+ '@workday/canvas-kit-preview-react/side-panel': 'SidePanel',
12
+ '@workday/canvas-kit-react-fonts': 'fonts',
13
+ '@workday/canvas-kit-react/toast': 'Toast',
14
+ '@workday/canvas-kit-react/tokens': 'Canvas',
15
+ '@workday/canvas-kit-react/tooltip': 'Tooltip',
16
+ '@workday/canvas-kit-react/text-area': 'TextArea',
17
+ '@workday/canvas-kit-react/avatar': 'Avatar',
18
+ '@workday/canvas-kit-react/badge': 'CountBadge',
19
+ '@workday/canvas-kit-react/checkbox': 'Checkbox',
20
+ '@workday/canvas-kit-react/form-field': 'FormField',
21
+ '@workday/canvas-kit-react/loading-animation': 'LoadingDots',
22
+ '@workday/canvas-kit-react/radio': 'Radio',
23
+ '@workday/canvas-kit-react/segmented-control': 'SegmentedControl',
24
+ '@workday/canvas-kit-react/select': 'Select',
25
+ '@workday/canvas-kit-react/side-panel': 'SidePanel',
26
+ '@workday/canvas-kit-react/status-indicator': 'StatusIndicator',
27
+ '@workday/canvas-kit-react/switch': 'Switch',
28
+ '@workday/canvas-kit-react/table': 'Table',
29
+ '@workday/canvas-kit-react/text-input': 'TextInput',
30
+ };
31
+ export default function transformer(file, api, options) {
32
+ const j = api.jscodeshift;
33
+ const root = j(file.source);
34
+ // Renames default imports from `renameDefaultMap` and changes them to named exports
35
+ // Example:
36
+ // before:
37
+ // import Button from '@workday/canvas-kit-react/button';
38
+ // import StyledButton from '@workday/canvas-kit-react/button';
39
+ // after:
40
+ // import { Button } from '@workday/canvas-kit-react/button';
41
+ // import { Button as StyledButton } from '@workday/canvas-kit-react/button';
42
+ root.find(j.ImportDefaultSpecifier).forEach(nodePath => {
43
+ var _a;
44
+ const parent = nodePath.parent;
45
+ const importSource = String(parent.node.source.value);
46
+ const localName = (_a = nodePath.value.local) === null || _a === void 0 ? void 0 : _a.name;
47
+ if (Object.keys(renameDefaultMap).includes(importSource) && localName) {
48
+ nodePath.replace(j.importSpecifier(j.identifier(localName)));
49
+ }
50
+ });
51
+ return root.toSource();
52
+ }
@@ -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=renameLoadingAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renameLoadingAnimation.d.ts","sourceRoot":"","sources":["../../../lib/v8/renameLoadingAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AASnD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA+D7E"}
@@ -0,0 +1,62 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ const mainPackage = '@workday/canvas-kit-react';
4
+ const loadingAnimationPackage = '@workday/canvas-kit-react/loading-animation';
5
+ const loadingDotsPackage = '@workday/canvas-kit-react/loading-dots';
6
+ const loadingAnimationImports = ['LoadingDots', 'LoadingAnimation'];
7
+ export default function transformer(file, api, options) {
8
+ const j = api.jscodeshift;
9
+ const root = j(file.source);
10
+ // exit if the named imports aren't found
11
+ if (!hasImportSpecifiers(api, root, loadingAnimationPackage, loadingAnimationImports)) {
12
+ return file.source;
13
+ }
14
+ // getImportRenameMap utility will tell us if the file containsCanvasImports
15
+ // and give us an importMap to track what identifiers we need to update
16
+ const { importMap } = getImportRenameMap(j, root, '@workday/canvas-kit-react/loading-animation');
17
+ root
18
+ .find(j.ImportDeclaration, {
19
+ // filter on imports from "@workday/canvas-kit/react" including slash imports
20
+ source: { value: (value) => value.includes(mainPackage) },
21
+ })
22
+ .forEach(nodePath => {
23
+ var _a;
24
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
25
+ if (specifier.type === 'ImportSpecifier') {
26
+ // Transform named import
27
+ // e.g. `import {LoadingAnimation}` becomes `import {LoadingDots}`
28
+ if (specifier.imported.name === 'LoadingAnimation') {
29
+ specifier.imported.name = 'LoadingDots';
30
+ }
31
+ // Transform slash imports
32
+ // e.g. `import {LoadingAnimation} from from "@workday/canvas-kit-react/loading-animation"`
33
+ // and `import {LoadingDots} from from "@workday/canvas-kit-react/loading-animation"`
34
+ // becomes `import {LoadingDots} from from "@workday/canvas-kit-react/loading-dots"`
35
+ if (nodePath.value.source.value === loadingAnimationPackage) {
36
+ nodePath.value.source.value = loadingDotsPackage;
37
+ }
38
+ }
39
+ return specifier;
40
+ });
41
+ });
42
+ // Transform LoadingAnimation JSXElements
43
+ // e.g. `<LoadingAnimation />` becomes `<LoadingDots />`
44
+ root.find(j.JSXIdentifier, { name: 'LoadingAnimation' }).forEach(nodePath => {
45
+ nodePath.node.name = 'LoadingDots';
46
+ });
47
+ // Transform styled compoents
48
+ // e.g. `const StyledLoadingAnimation = styled(LoadingAnimation)({});`
49
+ // becomes `const StyledLoadingAnimation = styled(LoadingDots)({});`
50
+ root.find(j.VariableDeclarator).forEach(nodePath => {
51
+ var _a;
52
+ if (((_a = nodePath.value.init) === null || _a === void 0 ? void 0 : _a.type) === 'CallExpression' &&
53
+ nodePath.value.init.callee.type === 'CallExpression' &&
54
+ nodePath.value.init.callee.callee.type === 'Identifier' &&
55
+ nodePath.value.init.callee.callee.name === 'styled' &&
56
+ nodePath.value.init.callee.arguments[0].type === 'Identifier' &&
57
+ nodePath.value.init.callee.arguments[0].name === importMap.LoadingAnimation) {
58
+ nodePath.value.init.callee.arguments[0].name = 'LoadingDots';
59
+ }
60
+ });
61
+ return root.toSource();
62
+ }
@@ -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=restructureBreadcrumbs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restructureBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../lib/v8/restructureBreadcrumbs.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,UAwE7E"}
@@ -0,0 +1,55 @@
1
+ import { getImportRenameMap } from '../v7/utils/getImportRenameMap';
2
+ import { hasImportSpecifiers } from '../v6/utils';
3
+ const breadcrumbsPackage = '@workday/canvas-kit-react/breadcrumbs';
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const root = j(file.source);
7
+ if (!hasImportSpecifiers(api, root, breadcrumbsPackage, ['Breadcrumbs'])) {
8
+ return file.source;
9
+ }
10
+ const { importMap, styledMap } = getImportRenameMap(j, root, breadcrumbsPackage);
11
+ root
12
+ .find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXMemberExpression' &&
13
+ value.openingElement.name.object.type === 'JSXIdentifier' &&
14
+ (value.openingElement.name.object.name === importMap.Breadcrumbs ||
15
+ value.openingElement.name.object.name === styledMap.Breadcrumbs) &&
16
+ value.openingElement.name.property.name === 'Nav')
17
+ .forEach(nodePath => {
18
+ // Select all props from opening tag
19
+ const attributes = nodePath.value.openingElement.attributes || [];
20
+ if (attributes) {
21
+ nodePath.value.openingElement.attributes = attributes.filter(item => !(item.type === 'JSXAttribute' && item.name.type === 'JSXIdentifier'));
22
+ }
23
+ nodePath.value.openingElement = j.jsxOpeningElement(j.jsxIdentifier(importMap.Breadcrumbs));
24
+ nodePath.value.openingElement.attributes = attributes;
25
+ nodePath.value.closingElement = j.jsxClosingElement(j.jsxIdentifier(importMap.Breadcrumbs));
26
+ (nodePath.value.children || []).forEach(child => {
27
+ if (child.type === 'JSXElement' &&
28
+ child.openingElement.name.type === 'JSXMemberExpression' &&
29
+ child.openingElement.name.property.name === 'CollapsibleList') {
30
+ if (child.openingElement.name.type === 'JSXMemberExpression') {
31
+ child.openingElement.name.property.name = 'List';
32
+ }
33
+ if (child.closingElement && child.closingElement.name.type === 'JSXMemberExpression') {
34
+ child.closingElement.name.property.name = 'List';
35
+ }
36
+ }
37
+ });
38
+ });
39
+ root
40
+ .find(j.JSXElement, (value) => value.openingElement.name.type === 'JSXMemberExpression' &&
41
+ value.openingElement.name.object.type === 'JSXIdentifier' &&
42
+ (value.openingElement.name.object.name === importMap.Breadcrumbs ||
43
+ value.openingElement.name.object.name === styledMap.Breadcrumbs) &&
44
+ value.openingElement.name.property.name === 'ListItem')
45
+ .forEach(nodePath => {
46
+ if (nodePath.value.openingElement.name.type === 'JSXMemberExpression') {
47
+ nodePath.value.openingElement.name.property.name = 'Item';
48
+ }
49
+ if (nodePath.value.closingElement &&
50
+ nodePath.value.closingElement.name.type === 'JSXMemberExpression') {
51
+ nodePath.value.closingElement.name.property.name = 'Item';
52
+ }
53
+ });
54
+ return root.toSource();
55
+ }
@@ -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=softDeprecateDrawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecateDrawer.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecateDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAYlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA0G7E"}
@@ -0,0 +1,103 @@
1
+ const mainPackage = '@workday/canvas-kit-labs-react';
2
+ const drawerPackage = '@workday/canvas-kit-labs-react/drawer';
3
+ const drawerImportNames = [
4
+ 'Drawer',
5
+ 'DrawerProps',
6
+ 'DrawerHeaderProps',
7
+ 'DrawerHeader',
8
+ 'DrawerDirection',
9
+ ];
10
+ export default function transformer(file, api, options) {
11
+ const j = api.jscodeshift;
12
+ const root = j(file.source);
13
+ let hasDrawerImports = false;
14
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
15
+ root.find(j.ImportDeclaration, (nodePath) => {
16
+ const value = nodePath.source.value;
17
+ // If there's an import from the drawer package, set the import boolean check to true
18
+ if (value === drawerPackage) {
19
+ hasDrawerImports = true;
20
+ return false;
21
+ }
22
+ // If there's an import from the main package, check to see if Drawer or DrawerProps are among the named imports
23
+ // e.g. import {Drawer} from '@workday/canvas-kit-labs-react';
24
+ if (value === mainPackage) {
25
+ (nodePath.specifiers || []).forEach(specifier => {
26
+ if (specifier.type === 'ImportSpecifier' &&
27
+ drawerImportNames.includes(specifier.imported.name)) {
28
+ hasDrawerImports = true;
29
+ }
30
+ });
31
+ }
32
+ return false;
33
+ });
34
+ // Failsafe to skip transforms unless a Drawer import is detected
35
+ if (!hasDrawerImports) {
36
+ return root.toSource();
37
+ }
38
+ root
39
+ .find(j.ImportDeclaration, {
40
+ source: { value: (value) => value.includes(mainPackage) },
41
+ })
42
+ .forEach(nodePath => {
43
+ var _a;
44
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
45
+ if (specifier.type === 'ImportSpecifier') {
46
+ // `import {Drawer}` becomes `import {DeprecatedDrawer}`
47
+ // `import {DrawerProps}` becomes `import {DeprecatedDrawerProps}`
48
+ // `import {DrawerHeader}` becomes `import {DeprecatedDrawerHeader}`
49
+ // `import {DrawerHeaderProps}` becomes `import {DeprecatedDrawerHeaderProps}`
50
+ if (drawerImportNames.includes(specifier.imported.name)) {
51
+ specifier.imported.name = `Deprecated${specifier.imported.name}`;
52
+ }
53
+ }
54
+ return specifier;
55
+ });
56
+ });
57
+ // Transform DrawerProps type references
58
+ // e.g. `type CustomProps = DrawerProps;` becomes `type CustomProps = DeprecatedDrawerProps;`
59
+ // Transform DrawerHeaderProps type references
60
+ // e.g. `type CustomProps = DrawerHeaderProps;` becomes `type CustomProps = DeprecatedDrawerHeaderProps;`
61
+ const typeNames = ['DrawerProps', 'DrawerHeaderProps'];
62
+ root
63
+ .find(j.TSTypeReference, {
64
+ typeName: {
65
+ type: 'Identifier',
66
+ name: (value) => typeNames.includes(value),
67
+ },
68
+ })
69
+ .forEach(nodePath => {
70
+ const identifier = nodePath.value.typeName;
71
+ identifier.name = `Deprecated${identifier.name}`;
72
+ });
73
+ // Transform DrawerProps type interface declaration references
74
+ // e.g. `interface CustomProps extends DrawerProps` becomes `interface CustomProps extends DeprecatedDrawerProps`
75
+ root.find(j.TSInterfaceDeclaration).forEach(nodePath => {
76
+ var _a;
77
+ // If the interface is extending DrawerProps, transform the extension name to DeprecatedDrawerProps
78
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(typeExtension => {
79
+ if (typeExtension.expression.type === 'Identifier') {
80
+ const typeExtensionName = typeExtension.expression.name;
81
+ if (typeExtension.expression.type === 'Identifier' &&
82
+ typeNames.includes(typeExtensionName)) {
83
+ typeExtension.expression.name = `Deprecated${typeExtensionName}`;
84
+ }
85
+ }
86
+ });
87
+ });
88
+ // Transform `<DrawerDirection>` to `<DeprecatedDrawerDirection>`
89
+ root.find(j.Identifier, { name: 'DrawerDirection' }).forEach(nodePath => {
90
+ nodePath.value.name = 'DeprecatedDrawerDirection';
91
+ });
92
+ // Transform Drawer JSXElements
93
+ // e.g. `<Drawer>` becomes `<DeprecatedDrawer>`
94
+ root.find(j.JSXIdentifier, { name: 'Drawer' }).forEach(nodePath => {
95
+ nodePath.node.name = 'DeprecatedDrawer';
96
+ });
97
+ // Transform Drawer JSXElements
98
+ // e.g. `<DrawerHeader>` becomes `<DeprecatedDrawerHeader>`
99
+ root.find(j.JSXIdentifier, { name: 'DrawerHeader' }).forEach(nodePath => {
100
+ nodePath.node.name = 'DeprecatedDrawerHeader';
101
+ });
102
+ return root.toSource();
103
+ }
@@ -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=softDeprecateLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecateLayout.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecateLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAMlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAkF7E"}
@@ -0,0 +1,76 @@
1
+ const mainPackage = '@workday/canvas-kit-react';
2
+ const allImportNames = ['Layout', 'LayoutProps', 'Column', 'ColumnProps'];
3
+ const importPackages = [mainPackage, `${mainPackage}/layout`];
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const root = j(file.source);
7
+ let hasLayoutImports = false;
8
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
9
+ root.find(j.ImportDeclaration, (nodePath) => {
10
+ var _a;
11
+ // If there's an import from the layout package or an import from the main package,
12
+ // check to see if Layout or LayoutProps are among the named imports
13
+ // e.g. import {Layout} from '@workday/canvas-kit-react';
14
+ if (importPackages.includes(nodePath.source.value)) {
15
+ (_a = nodePath.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
16
+ hasLayoutImports =
17
+ specifier.type === 'ImportSpecifier' && allImportNames.includes(specifier.imported.name);
18
+ });
19
+ }
20
+ return false;
21
+ });
22
+ // Failsafe to skip transforms unless a Layout import is detected
23
+ if (!hasLayoutImports) {
24
+ return root.toSource();
25
+ }
26
+ root
27
+ .find(j.ImportDeclaration, {
28
+ source: { value: (value) => value.includes(mainPackage) },
29
+ })
30
+ .forEach(nodePath => {
31
+ var _a;
32
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
33
+ // Adds Deprecated part to a import name for Layout, LayoutProps, Column, ColumnProps
34
+ if (specifier.type === 'ImportSpecifier' &&
35
+ allImportNames.includes(specifier.imported.name)) {
36
+ specifier.imported.name = `Deprecated${specifier.imported.name}`;
37
+ }
38
+ return specifier;
39
+ });
40
+ });
41
+ // Add Deprecated in menu types and type interfaces
42
+ const typeNames = ['LayoutProps', 'ColumnProps'];
43
+ root
44
+ .find(j.TSTypeReference, {
45
+ typeName: {
46
+ type: 'Identifier',
47
+ name: (name) => typeNames.includes(name),
48
+ },
49
+ })
50
+ .forEach(nodePath => {
51
+ const identifier = nodePath.value.typeName;
52
+ identifier.name = `Deprecated${identifier.name}`;
53
+ });
54
+ // Add Deprecated to all interface names
55
+ root.find(j.TSInterfaceDeclaration).forEach(nodePath => {
56
+ var _a;
57
+ // If the interface is extending menu interfaces it should add Deprecated to them
58
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(typeExtension => {
59
+ if (typeExtension.expression.type === 'Identifier' &&
60
+ typeNames.includes(typeExtension.expression.name)) {
61
+ typeExtension.expression.name = `Deprecated${typeExtension.expression.name}`;
62
+ }
63
+ });
64
+ });
65
+ // Transform Layout and LayoutItem JSXElements
66
+ // e.g. `<Layout>` becomes `<DeprecatedLayout>`
67
+ // e.g. `<Column>` becomes `<DeprecatedColumn>`
68
+ root
69
+ .find(j.JSXIdentifier, { name: (name) => name === 'Layout' || name === 'Column' })
70
+ .forEach(nodePath => {
71
+ if (nodePath.name !== 'property') {
72
+ nodePath.node.name = `Deprecated${nodePath.node.name}`;
73
+ }
74
+ });
75
+ return root.toSource();
76
+ }
@@ -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=softDeprecatePreviewMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softDeprecatePreviewMenu.d.ts","sourceRoot":"","sources":["../../../lib/v8/softDeprecatePreviewMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAiC,OAAO,EAAC,MAAM,aAAa,CAAC;AAMlF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UAmF7E"}
@@ -0,0 +1,79 @@
1
+ const mainPackage = '@workday/canvas-kit-preview-react';
2
+ const menuPackage = '@workday/canvas-kit-preview-react/menu';
3
+ const allImportNames = ['Menu', 'MenuProps', 'MenuState', 'MenuItem', 'MenuItemProps'];
4
+ export default function transformer(file, api, options) {
5
+ const j = api.jscodeshift;
6
+ const root = j(file.source);
7
+ let hasMenuImports = false;
8
+ // This toggles the failsafe that prevents us from accidentally transforming something unintentionally.
9
+ root.find(j.ImportDeclaration, (nodePath) => {
10
+ const value = nodePath.source.value;
11
+ // If there's an import from the menu preview package, set the import boolean check to true
12
+ if (value === menuPackage) {
13
+ hasMenuImports = true;
14
+ return false;
15
+ }
16
+ // If there's an import from the main package, check to see if Menu or MenuProps are among the named imports
17
+ // e.g. import {Menu} from '@workday/canvas-kit-preview-react';
18
+ if (value === mainPackage) {
19
+ (nodePath.specifiers || []).forEach(specifier => {
20
+ if (specifier.type === 'ImportSpecifier') {
21
+ if (allImportNames.includes(specifier.imported.name)) {
22
+ hasMenuImports = true;
23
+ }
24
+ }
25
+ });
26
+ }
27
+ return false;
28
+ });
29
+ // Failsafe to skip transforms unless a Menu import is detected
30
+ if (!hasMenuImports) {
31
+ return root.toSource();
32
+ }
33
+ root
34
+ .find(j.ImportDeclaration, {
35
+ source: { value: (value) => value.includes(mainPackage) },
36
+ })
37
+ .forEach(nodePath => {
38
+ var _a;
39
+ (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach(specifier => {
40
+ if (specifier.type === 'ImportSpecifier') {
41
+ // Adds Deprecated part to a import name for Menu, MenuProps, MenuState, MenuItem, MenuItemProps
42
+ if (allImportNames.includes(specifier.imported.name)) {
43
+ specifier.imported.name = `Deprecated${specifier.imported.name}`;
44
+ }
45
+ }
46
+ return specifier;
47
+ });
48
+ });
49
+ // Add Deprecated in types using menu interfaces
50
+ const typeNames = ['MenuProps', 'MenuState', 'MenuItemProps'];
51
+ root
52
+ .find(j.TSTypeReference, {
53
+ typeName: { type: 'Identifier', name: (name) => typeNames.includes(name) },
54
+ })
55
+ .forEach(nodePath => {
56
+ const identifier = nodePath.value.typeName;
57
+ identifier.name = `Deprecated${identifier.name}`;
58
+ });
59
+ // Add Deprecated to all interface names
60
+ root.find(j.TSInterfaceDeclaration).forEach(nodePath => {
61
+ var _a;
62
+ // If the interface is extending menu interfaces it should add Deprecated to them
63
+ (_a = nodePath.node.extends) === null || _a === void 0 ? void 0 : _a.forEach(typeExtension => {
64
+ if (typeExtension.expression.type === 'Identifier' &&
65
+ typeNames.includes(typeExtension.expression.name)) {
66
+ typeExtension.expression.name = `Deprecated${typeExtension.expression.name}`;
67
+ }
68
+ });
69
+ });
70
+ // Transform Menu and MenuItem JSXElements
71
+ // e.g. `<Menu>` becomes `<DeprecatedMenu>`
72
+ // e.g. `<MenuItem>` becomes `<DeprecatedMenuItem>`
73
+ root
74
+ .find(j.JSXIdentifier, { name: (name) => name === 'Menu' || name === 'MenuItem' })
75
+ .forEach(nodePath => {
76
+ nodePath.node.name = `Deprecated${nodePath.node.name}`;
77
+ });
78
+ return root.toSource();
79
+ }
@@ -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=compoundToast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compoundToast.d.ts","sourceRoot":"","sources":["../../../lib/v9/compoundToast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAc,OAAO,EAAC,MAAM,aAAa,CAAC;AAM/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,UA8M7E"}